aMOPel / tree-sitter-nim

tree-sitter parser for the nim programming language
MIT License
36 stars 10 forks source link

[New Feature] routineExpr #8

Closed aMOPel closed 2 years ago

aMOPel commented 2 years ago

official grammar:

routineExpr = ('proc' | 'func' | 'iterator') paramListColon pragma? ('=' COMMENT? stmt)?
primary = operatorB primary primarySuffix* |
          tupleDecl | routineExpr | enumDecl
          objectDecl | conceptDecl | ('bind' primary)
          ('var' | 'out' | 'ref' | 'ptr' | 'distinct') primary
        /  prefixOperator* identOrLiteral primarySuffix*`'|IDENT|literal|'cast'|'addr'|'type') expr # <==== HERE command syntax

example:

let p = proc (a: int): int = a * 2

https://nim-lang.org/docs/manual.html#procedures-anonymous-procs also test for the sugar: https://nim-lang.org/docs/sugar.html#%3D%3E.m%2Cuntyped%2Cuntyped