siraben / tree-sitter-promela

Promela grammar for tree-sitter
MIT License
7 stars 0 forks source link

Incorrect parsing of declaration of variable of custom in body #1

Closed siraben closed 2 years ago

siraben commented 2 years ago

The following program

Crypt x;
init {
  Crypt x;
}

produces the parse tree

(program
  (one_decl
    (var_list
      (ivar
        (vardcl
          (uname)))))
  (init
    (body
      (step
        (stmnt
          (Stmnt
            (full_expr
              (expr
                (varref
                  (cmpnd
                    (pfld))))))))
      (step
        (stmnt
          (Stmnt
            (full_expr
              (expr
                (varref
                  (cmpnd
                    (pfld)))))))))))

Whereas we expect something like

(program
  (one_decl
    (var_list
      (ivar
        (vardcl
          (uname)))))
  (init
    (body
      (step
        (one_decl
          (var_list
            (ivar
              (vardcl
               (uname)))))))))
siraben commented 2 years ago

Removing $.full_expr from the Stmnt rule results in the correct parse, but Promela allows arbitrary expressions in lieu of statements, so the vardcl rule should fire first.