llvm-project/mlir/lib/Parser
Alex Zinenko 40d5d09f9d Print parens around the return type of a function if it is also a function type
Existing type syntax contains the following productions:

    function-type ::= type-list-parens `->` type-list
    type-list ::= type | type-list-parens
    type ::= <..> | function-type

Due to these rules, when the parser sees `->` followed by `(`, it cannot
disambiguate if `(` starts a parenthesized list of function result types, or a
parenthesized list of operands of another function type, returned from the
current function.  We would need an unknown amount of lookahead to try to find
the `->` at the right level of function nesting to differentiate between type
lists and singular function types.

Instead, require the result type of the function that is a function type itself
to be always parenthesized, at the syntax level.  Update the spec and the
parser to correspond to the production rule names used in the spec (although it
would have worked without modifications).  Fix the function type parsing bug in
the process, as it used to accept the non-parenthesized list of types for
arguments, disallowed by the spec.

PiperOrigin-RevId: 232528361
2019-03-29 16:14:50 -07:00
..
Lexer.cpp Minor fix to the lexer whitespace loop. 2019-03-29 16:07:07 -07:00
Lexer.h Implement value type abstraction for locations. 2019-03-29 13:52:31 -07:00
Parser.cpp Print parens around the return type of a function if it is also a function type 2019-03-29 16:14:50 -07:00
Token.cpp Avoid hardcoded 4096 constant 2019-03-29 13:06:36 -07:00
Token.h Add parsing for floating point attributes. 2019-03-29 12:51:12 -07:00
TokenKinds.def Recommit: Define a AffineOps dialect as well as an AffineIfOp operation. Replace all instances of IfInst with AffineIfOp and delete IfInst. 2019-03-29 15:59:30 -07:00