You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The grammar currently seems limited in how it deals with assignment expressions and in particular what can appear on the LHS of an assignment expression. Arbitrary expressions on the LHS of assignments are a common technique in building DSLs like e.g. Boost.SML.
To take a simple example, a UDL on the LHS:
voidf() { "hello"_s = 42; }
(The UDL is effectively a function call which might return e.g. a reference to a variable.) tree-sitter parse says:
But the tree is incorrect with operator= binding more tightly than the operator+: it's as if the code read x + (y = 5). Ironically that expression produces an error:
I'm not sure what should be done about this in general: perhaps some surgery on the LHS of assignment? I see that parenthesized expressions are allowed there by the current grammar, so this parses:
the first case should be fixed, I'll agree. About binary expressions - that's just asking for a mess of conflicts. So, would just fixing the first case be good enough?
The grammar currently seems limited in how it deals with assignment expressions and in particular what can appear on the LHS of an assignment expression. Arbitrary expressions on the LHS of assignments are a common technique in building DSLs like e.g. Boost.SML.
To take a simple example, a UDL on the LHS:
(The UDL is effectively a function call which might return e.g. a reference to a variable.)
tree-sitter parse
says:Another example:
(If this looks odd, consider a DSL with overloaded operators.) This produces a parse tree without error:
But the tree is incorrect with
operator=
binding more tightly than theoperator+
: it's as if the code readx + (y = 5)
. Ironically that expression produces an error:I'm not sure what should be done about this in general: perhaps some surgery on the LHS of assignment? I see that parenthesized expressions are allowed there by the current grammar, so this parses:
The text was updated successfully, but these errors were encountered: