Skip to content

Grammar building issues #9

Open

Description

@yurydelendik

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.

Activity

  1. qwertie commented on May 27, 2016

    @qwertie

    Would you mind editing this to show example expressions in which the problems you describe occur?

  2. yurydelendik commented on May 27, 2016

    @yurydelendik
    Author

    Would you mind editing this to show example expressions

    We addressed first two in the latest proposal: block operators have the same precedence as literals and '()'-group, and the select operator got parens and has the same precedence as the latter.

    Examples for the optional trailing label is:

    1. optional: (block (nop)) => { nop }
    2. specified: (block $a (nop)) => { nop $a: }
    3. mutil-block with optional: (block (block $b (nop)) nop) => { nop $b: nop }
    4. ambiguous: (block $a (block $b (nop)) nop) and (block (block $a (block $b (nop)) nop)) => ? { nop $b: nop $a:}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions