From 0a1d4ba8427854306b89f4e91ed7902fb23adafb Mon Sep 17 00:00:00 2001 From: Vindaar Date: Thu, 8 Dec 2022 10:59:13 +0100 Subject: 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`. --- doc/grammar.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'doc') 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 -- cgit 1.4.1-2-gfad0