hasura / kriti-lang

A minimal JSON templating language
Apache License 2.0
56 stars 9 forks source link

Fixes shift/reduce conflict in path lookups by index #56

Closed solomon-b closed 2 years ago

solomon-b commented 2 years ago

We had a shift/reduce conflict on the ] token:

State 107

    path_element -> '[' int . ']'                       (rule 25)
    num_lit -> int .                                    (rule 61)

    ','            reduce using rule 61
    ']'            shift, and enter state 130
            (reduce using rule 61)

State 130

    path_element -> '[' int ']' .                       (rule 25)

    'in'           reduce using rule 25
    '.'            reduce using rule 25
    '?'            reduce using rule 25
    '??'           reduce using rule 25
    '=='           reduce using rule 25
    '!='           reduce using rule 25
    '>'            reduce using rule 25
    '<'            reduce using rule 25
    '<='           reduce using rule 25
    '>='           reduce using rule 25
    '&&'           reduce using rule 25
    '||'           reduce using rule 25
    '}}'           reduce using rule 25
    '['            reduce using rule 25
    ')'            reduce using rule 25

Rule 61
    num_lit -> int                                     (61)

We needed to set the int case of the num_lit production rule to be lower precedence then ] for path lookups. I believe that the parser defaulting to the correct behavior but now it will explicitly perform correctly.

I also went ahead and regenerated the BNF grammar for documentation purposes.