diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-01-14 13:51:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-14 13:51:28 +0100 |
commit | fadbd8f70ded950bbe2eefcf0272b93e31a79966 (patch) | |
tree | cef5a6f81b83e6b1fcc43ead631d441fbaa0b659 /doc/grammar.txt | |
parent | 9fc04a555ca0fc9eaff6d4eb9ba47a0a64feb9c2 (diff) | |
download | Nim-fadbd8f70ded950bbe2eefcf0272b93e31a79966.tar.gz |
fixes #10665 (#13141) [backport]
Diffstat (limited to 'doc/grammar.txt')
-rw-r--r-- | doc/grammar.txt | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt index b5aa6fd5a..725384c3d 100644 --- a/doc/grammar.txt +++ b/doc/grammar.txt @@ -54,53 +54,52 @@ identOrLiteral = generalizedLit | symbol | literal | castExpr tupleConstr = '(' optInd (exprColonEqExpr comma?)* optPar ')' arrayConstr = '[' optInd (exprColonEqExpr comma?)* optPar ']' -primarySuffix = '(' (exprColonEqExpr comma?)* ')' doBlocks? - | doBlocks +primarySuffix = '(' (exprColonEqExpr comma?)* ')' | '.' optInd symbol generalizedLit? - | '[' optInd indexExprList optPar ']' - | '{' optInd indexExprList optPar '}' + | '[' optInd exprColonEqExprList optPar ']' + | '{' optInd exprColonEqExprList optPar '}' | &( '`'|IDENT|literal|'cast'|'addr'|'type') expr # command syntax condExpr = expr colcom expr optInd ('elif' expr colcom expr optInd)* 'else' colcom expr ifExpr = 'if' condExpr whenExpr = 'when' condExpr -pragma = '{.' optInd (exprColonExpr comma?)* optPar ('.}' | '}') -identVis = symbol opr? # postfix position -identVisDot = symbol '.' optInd symbol opr? +pragma = '{.' optInd (exprColonEqExpr comma?)* optPar ('.}' | '}') +identVis = symbol OPR? # postfix position +identVisDot = symbol '.' optInd symbol OPR? identWithPragma = identVis pragma? identWithPragmaDot = identVisDot pragma? declColonEquals = identWithPragma (comma identWithPragma)* comma? (':' optInd typeDesc)? ('=' optInd expr)? -identColonEquals = ident (comma ident)* comma? +identColonEquals = IDENT (comma IDENT)* comma? (':' optInd typeDesc)? ('=' optInd expr)?) inlTupleDecl = 'tuple' - [' optInd (identColonEquals (comma/semicolon)?)* optPar ']' + '[' optInd (identColonEquals (comma/semicolon)?)* optPar ']' extTupleDecl = 'tuple' COMMENT? (IND{>} identColonEquals (IND{=} identColonEquals)*)? tupleClass = 'tuple' paramList = '(' declColonEquals ^* (comma/semicolon) ')' paramListArrow = paramList? ('->' optInd typeDesc)? paramListColon = paramList? (':' optInd typeDesc)? -doBlock = 'do' paramListArrow pragmas? colcom stmt -procExpr = 'proc' paramListColon pragmas? ('=' COMMENT? stmt)? +doBlock = 'do' paramListArrow pragma? colcom stmt +procExpr = 'proc' paramListColon pragma? ('=' COMMENT? stmt)? distinct = 'distinct' optInd typeDesc forStmt = 'for' (identWithPragma ^+ comma) 'in' expr colcom stmt forExpr = forStmt expr = (blockExpr | ifExpr | whenExpr - | caseExpr - | forExpr + | caseStmt + | forExpr | tryExpr) / simpleExpr typeKeyw = 'var' | 'out' | 'ref' | 'ptr' | 'shared' | 'tuple' | 'proc' | 'iterator' | 'distinct' | 'object' | 'enum' -primary = typeKeyw typeDescK +primary = typeKeyw optInd typeDesc / prefixOperator* identOrLiteral primarySuffix* / 'bind' primary -typeDesc = simpleExpr -typeDefAux = simpleExpr +typeDesc = simpleExpr ('not' expr)? +typeDefAux = simpleExpr ('not' expr)? | 'concept' typeClass postExprBlocks = ':' stmt? ( IND{=} doBlock | IND{=} 'of' exprList ':' stmt @@ -110,14 +109,16 @@ postExprBlocks = ':' stmt? ( IND{=} doBlock exprStmt = simpleExpr (( '=' optInd expr colonBody? ) / ( expr ^+ comma - doBlocks - / macroColon + postExprBlocks ))? importStmt = 'import' optInd expr ((comma expr)* / 'except' optInd (expr ^+ comma)) +exportStmt = 'export' optInd expr + ((comma expr)* + / 'except' optInd (expr ^+ comma)) includeStmt = 'include' optInd expr ^+ comma -fromStmt = 'from' moduleName 'import' optInd expr (comma expr)* +fromStmt = 'from' expr 'import' optInd expr (comma expr)* returnStmt = 'return' optInd expr? raiseStmt = 'raise' optInd expr? yieldStmt = 'yield' optInd expr? @@ -157,9 +158,8 @@ indAndComment = (IND{>} COMMENT)? | COMMENT? routine = optInd identVis pattern? genericParamList? paramListColon pragma? ('=' COMMENT? stmt)? indAndComment commentStmt = COMMENT -section(p) = COMMENT? p / (IND{>} (p / COMMENT)^+IND{=} DED) -constant = identWithPragma (colon typeDesc)? '=' optInd expr indAndComment -enum = 'enum' optInd (symbol optInd ('=' optInd expr COMMENT?)? comma?)+ +section(RULE) = COMMENT? RULE / (IND{>} (RULE / COMMENT)^+IND{=} DED) +enum = 'enum' optInd (symbol pragma? optInd ('=' optInd expr COMMENT?)? comma?)+ objectWhen = 'when' expr colcom objectPart COMMENT? ('elif' expr colcom objectPart COMMENT?)* ('else' colcom objectPart COMMENT?)? @@ -177,10 +177,12 @@ typeClassParam = ('var' | 'out')? symbol typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')? &IND{>} stmt typeDef = identWithPragmaDot genericParamList? '=' optInd typeDefAux + indAndComment? / identVisDot genericParamList? pragma '=' optInd typeDefAux indAndComment? varTuple = '(' optInd identWithPragma ^+ comma optPar ')' '=' optInd expr -colonBody = colcom stmt doBlocks? +colonBody = colcom stmt postExprBlocks? variable = (varTuple / identColonEquals) colonBody? indAndComment +constant = (varTuple / identWithPragma) (colon typeDesc)? '=' optInd expr indAndComment bindStmt = 'bind' optInd qualifiedIdent ^+ comma mixinStmt = 'mixin' optInd qualifiedIdent ^+ comma pragmaStmt = pragma (':' COMMENT? stmt)? |