siraben / tree-sitter-promela

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

Incorrect parsing of channel declarations #4

Closed siraben closed 2 years ago

siraben commented 2 years ago

This should have a parse

chan f = [N] of { mtype, int }

but the parser returns

(program [1, 0] - [2, 0]
  (one_decl [1, 0] - [1, 28]
    (type [1, 0] - [1, 4])
    (var_list [1, 5] - [1, 28]
      (ivar [1, 5] - [1, 6]
        (vardcl [1, 5] - [1, 6]
          (uname [1, 5] - [1, 6])))
      (ERROR [1, 7] - [1, 23]
        (ERROR [1, 9] - [1, 15]
          (ERROR [1, 10] - [1, 11])))
      (ivar [1, 25] - [1, 28]
        (vardcl [1, 25] - [1, 28]
          (uname [1, 25] - [1, 28])))))
  (ERROR [1, 29] - [1, 30]))
siraben commented 2 years ago

Looks like the source code was originally

#define N 12

mtype = { operator, value }

chan f = [N] of { mtype, int }

So N was replaced by 12 which is a const_expr. Tools would need to perform C macro expansion