aMOPel / tree-sitter-nim

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

[New Feature] conceptDecl #3

Closed aMOPel closed 2 years ago

aMOPel commented 2 years ago

official grammar:

conceptParam = ('var' | 'out')? symbol
conceptDecl = 'concept' conceptParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
              &IND{>} stmt
primary = operatorB primary primarySuffix* |
          tupleDecl | routineExpr | enumDecl
          objectDecl | conceptDecl | ('bind' primary)
          ('var' | 'out' | 'ref' | 'ptr' | 'distinct') primary
        /  prefixOperator* identOrLiteral primarySuffix*

example:

see existing tests below https://nim-lang.org/docs/manual_experimental.html#concepts

some work has already been done:

https://github.com/aMOPel/tree-sitter-nim/blob/main/grammar.js#L287

existing tests:

(needs to be moved to test/corpus/declarations.txt) https://github.com/aMOPel/tree-sitter-nim/blob/main/test/declaration.txt#L325

encountered problem

severely impacted parser generation and compile time