summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorVindaar <basti90@gmail.com>2022-12-08 10:59:13 +0100
committerGitHub <noreply@github.com>2022-12-08 10:59:13 +0100
commit0a1d4ba8427854306b89f4e91ed7902fb23adafb (patch)
treefe295a3e818c7dda3b60cf5d0f08a1cdd8a24fc5 /doc
parente669835665bd3b9ab600d1ce3502f4b643606175 (diff)
downloadNim-0a1d4ba8427854306b89f4e91ed7902fb23adafb.tar.gz
fix issue #20922 by handling missing expr in `exprList` for `tkOf` (#20930)
* fix issue #20922 by handling missing expr in `exprList` for `tkOf`

* fix line numbers in test case

* rewrite exprList requiring expr, add optionalExprList for except

As suggested by @metagn.

* update test case to reflect new code

* update grammar.txt

* update line numbers in test case taking into account nimout

Given the number of errors that are produced it seems easier to do it
this way instead of using `tt.Error`.
Diffstat (limited to 'doc')
-rw-r--r--doc/grammar.txt7
1 files changed, 4 insertions, 3 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt
index a0ff7d9f0..88094981c 100644
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -30,6 +30,7 @@ symbol = '`' (KEYW|IDENT|literal|(operator|'('|')'|'['|']'|'{'|'}'|'=')+)+ '`'
 exprColonEqExpr = expr (':'|'=' expr)?
 exprEqExpr = expr ('=' expr)?
 exprList = expr ^+ comma
+optionalExprList = expr ^* comma
 exprColonEqExprList = exprColonEqExpr (comma exprColonEqExpr)* (comma)?
 qualifiedIdent = symbol ('.' optInd symbol)?
 setOrTableConstr = '{' ((exprColonEqExpr comma)* | ':' ) '}'
@@ -109,7 +110,7 @@ typeDefValue = ((tupleDecl | enumDecl | objectDecl | conceptDecl |
 postExprBlocks = ':' stmt? ( IND{=} doBlock
                            | IND{=} 'of' exprList ':' stmt
                            | IND{=} 'elif' expr ':' stmt
-                           | IND{=} 'except' exprList ':' stmt
+                           | IND{=} 'except' optionalExprList ':' stmt
                            | IND{=} 'finally' ':' stmt
                            | IND{=} 'else' ':' stmt )*
 exprStmt = simpleExpr postExprBlocks?
@@ -148,10 +149,10 @@ caseStmt = 'case' expr ':'? COMMENT?
             (IND{>} ofBranches DED
             | IND{=} ofBranches)
 tryStmt = 'try' colcom stmt &(IND{=}? 'except'|'finally')
-           (IND{=}? 'except' exprList colcom stmt)*
+           (IND{=}? 'except' optionalExprList colcom stmt)*
            (IND{=}? 'finally' colcom stmt)?
 tryExpr = 'try' colcom stmt &(optInd 'except'|'finally')
-           (optInd 'except' exprList colcom stmt)*
+           (optInd 'except' optionalExprList colcom stmt)*
            (optInd 'finally' colcom stmt)?
 blockStmt = 'block' symbol? colcom stmt
 blockExpr = 'block' symbol? colcom stmt