Description
The parser eagerly turns *
into postfix operators, which is not always correct. Consider the example below:
foo : (a:int) -> auto = { return a*2; }
It fails to compile in cppfront with an error message (missing ';'
). The error goes away when adding a space in front of the *
because the parser then does not recognize it as postfix operator. But insisting on a whitespace in front on a binary operator seems questionable, it is a significant deviation from regular C++.
In general the postfix *
and &
operators are problematic, as they create an ambiguity with binary *
and &
. Resolving that requires either an LR(2) parser or a lot of lexer magic to recognize these as postfix operators. Having them as prefix operators would be easier.
There are also other ambiguities in the grammar, some of them probably fixable (e.g., template-argument -> expression | id-expression
, but if the expression is an identifier the parser cannot distinguish these cases), some of them probably unfixable without major changes to the language (e.g., template syntax, there the parser cannot parse a<b,c>d
correctly without knowing if a
is a template or not). I am not sure if it makes sense to open bugs for all of them. If you want I can report them, of course, but I do not want to spam the issue tracker with problems if you only consider the syntax experimental anyway. (On the other hand it is probably useful to know if the suggested syntax works or not).