tree-sitter-nim
tree-sitter-nim copied to clipboard
[New Feature] complex expressions
official grammar:
expr = (blockExpr
| ifExpr
| whenExpr
| caseStmt
| forExpr
| tryExpr)
/ simpleExpr
blockExpr = 'block' symbol? colcom stmt
condExpr = expr colcom expr optInd
('elif' expr colcom expr optInd)*
'else' colcom expr
ifExpr = 'if' condExpr
whenExpr = 'when' condExpr
caseStmt = 'case' expr ':'? COMMENT?
(IND{>} ofBranches DED
| IND{=} ofBranches)
forExpr = forStmt
tryExpr = 'try' colcom stmt &(optInd 'except'|'finally')
(optInd 'except' exprList colcom stmt)*
(optInd 'finally' colcom stmt)?
examples:
see existing tests below
Some work has already been done:
https://github.com/aMOPel/tree-sitter-nim/blob/main/grammar.js#L707
existing tests:
(needs to be moved to test/corpus/expr.txt
)
https://github.com/aMOPel/tree-sitter-nim/blob/main/test/expr.txt