-
Notifications
You must be signed in to change notification settings - Fork 1
Description
While constructing grammar at https://github.com/mbebenita/was, I found few sticky moments. Probably it's nothing but let me notice it here. (Current grammar can be found at https://github.com/mbebenita/was/blob/3c437599cc0f39a2053acb24672403b64a38d96d/was_parser.yy#L175) The issue can be closed if nothing we can add to the proposal on the subject.
Block operators and precedence
It's hard to produce non-ambiguous grammar for block operators included in the expression, e.g. $a = if (1) { 1; } else { 2; }. We are trying to introduce a precedence for binary operators and this harder to express in grammar rules: block items appear at high and low precedence see "group_expression" and "expression"
Select operator
This operator is unique and probably deserve different treatment, e.g. no precedence. The grammar is successful only when 'select' has no precedence and currently placed at the same level as block operators. It's probably okay since it has distinct grammar to be properly parsed and recognized by human.
Optional trailing label for a block
It's trivial to see how ambiguous it can be misread as start of multi-block expressions, and grammar for it is certainly ambiguous as well. Though a parser can recognize this case as treat at as enclosing block label.