summaryrefslogtreecommitdiffhomepage
path: root/parser.y
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-06 22:05:38 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-06 22:05:38 +0200
commit42a52e16ffaa4d49fa26f1184a0660324705bc7c (patch)
treebf4935f062b8b5dc1fb10ae75ed286fab2d8ae0f /parser.y
parent88099fdaf55a24854508b7a75d690fa76be6f44a (diff)
parser: make final semicolon optional
Modify the grammar to allow omitting the last semicolon after the last statement of a compound statement. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y2
1 files changed, 2 insertions, 0 deletions
diff --git a/parser.y b/parser.y
index 90cc84c..f9c14a5 100644
--- a/parser.y
+++ b/parser.y
@@ -120,7 +120,9 @@ stmt(A) ::= break_stmt(B). { A = B; }
stmt(A) ::= decl_stmt(B). { A = B; }
//cpd_stmt(A) ::= T_LBRACE T_RBRACE. { A = NULL; }
+cpd_stmt(A) ::= T_LBRACE stmts(B) exp(C) T_RBRACE. { A = B ? append_op(B, C) : C; }
cpd_stmt(A) ::= T_LBRACE stmts(B) T_RBRACE. { A = B; }
+cpd_stmt(A) ::= T_LBRACE exp(B) T_RBRACE. { A = B; }
exp_stmt(A) ::= exp(B) T_SCOL. { A = B; }
exp_stmt(A) ::= T_SCOL. { A = 0; }