Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature] complex expressions #5

Open
aMOPel opened this issue Aug 19, 2022 · 0 comments
Open

[New Feature] complex expressions #5

aMOPel opened this issue Aug 19, 2022 · 0 comments

Comments

@aMOPel
Copy link
Owner

aMOPel commented Aug 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant