diff options
author | metagn <metagngn@gmail.com> | 2023-04-14 13:34:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 12:34:49 +0200 |
commit | 2a0d8a9a06d7231bc00956de08b802995619b478 (patch) | |
tree | 14b43f4dc08907e4fca7ee65f78cc0f6582955f6 /doc | |
parent | c694d8e4fd6a14ab6a79fe6359033a4be6133b8c (diff) | |
download | Nim-2a0d8a9a06d7231bc00956de08b802995619b478.tar.gz |
make grammar a bit more honest (#21655)
* test if expr parsing expr refs #19802 * in any case * just be honest * fix symbol/keyword issue too
Diffstat (limited to 'doc')
-rw-r--r-- | doc/grammar.txt | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt index 14d0ce60e..89095d65c 100644 --- a/doc/grammar.txt +++ b/doc/grammar.txt @@ -7,7 +7,7 @@ colcom = ':' COMMENT? operator = OP0 | OP1 | OP2 | OP3 | OP4 | OP5 | OP6 | OP7 | OP8 | OP9 | 'or' | 'xor' | 'and' | 'is' | 'isnot' | 'in' | 'notin' | 'of' | 'as' | 'from' - | 'div' | 'mod' | 'shl' | 'shr' | 'not' | 'static' | '..' + | 'div' | 'mod' | 'shl' | 'shr' | 'not' | '..' prefixOperator = operator optInd = COMMENT? IND? optPar = (IND{>} | IND{=})? @@ -26,13 +26,14 @@ operatorB = OP0 | OP1 | OP2 | OP3 | OP4 | OP5 | OP6 | OP7 | OP8 | OP9 | 'div' | 'mod' | 'shl' | 'shr' | 'in' | 'notin' | 'is' | 'isnot' | 'not' | 'of' | 'as' | 'from' | '..' | 'and' | 'or' | 'xor' symbol = '`' (KEYW|IDENT|literal|(operator|'('|')'|'['|']'|'{'|'}'|'=')+)+ '`' - | IDENT | KEYW + | IDENT | 'addr' | 'type' | 'static' +symbolOrKeyword = symbol | KEYW exprColonEqExpr = expr (':'|'=' expr)? exprEqExpr = expr ('=' expr)? exprList = expr ^+ comma optionalExprList = expr ^* comma exprColonEqExprList = exprColonEqExpr (comma exprColonEqExpr)* (comma)? -qualifiedIdent = symbol ('.' optInd symbol)? +qualifiedIdent = symbol ('.' optInd symbolOrKeyword)? setOrTableConstr = '{' ((exprColonEqExpr comma)* | ':' ) '}' castExpr = 'cast' ('[' optInd typeDesc optPar ']' '(' optInd expr optPar ')') / parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try' @@ -58,13 +59,13 @@ identOrLiteral = generalizedLit | symbol | literal tupleConstr = '(' optInd (exprColonEqExpr comma?)* optPar ')' arrayConstr = '[' optInd (exprColonEqExpr comma?)* optPar ']' primarySuffix = '(' (exprColonEqExpr comma?)* ')' - | '.' optInd symbol ('[:' exprList ']' ( '(' exprColonEqExpr ')' )?)? generalizedLit? - | DOTLIKEOP optInd symbol generalizedLit? + | '.' optInd symbolOrKeyword ('[:' exprList ']' ( '(' exprColonEqExpr ')' )?)? generalizedLit? + | DOTLIKEOP optInd symbolOrKeyword generalizedLit? | '[' optInd exprColonEqExprList optPar ']' | '{' optInd exprColonEqExprList optPar '}' pragma = '{.' optInd (exprColonEqExpr comma?)* optPar ('.}' | '}') identVis = symbol OPR? # postfix position -identVisDot = symbol '.' optInd symbol OPR? +identVisDot = symbol '.' optInd symbolOrKeyword OPR? identWithPragma = identVis pragma? identWithPragmaDot = identVisDot pragma? declColonEquals = identWithPragma (comma identWithPragma)* comma? @@ -135,9 +136,9 @@ condStmt = expr colcom stmt COMMENT? (IND{=} 'else' colcom stmt)? ifStmt = 'if' condStmt whenStmt = 'when' condStmt -condExpr = expr colcom expr optInd - ('elif' expr colcom expr optInd)* - 'else' colcom expr +condExpr = expr colcom stmt optInd + ('elif' expr colcom stmt optInd)* + 'else' colcom stmt ifExpr = 'if' condExpr whenExpr = 'when' condExpr whileStmt = 'while' expr colcom stmt |