From: Richard W.M. Jones Date: Fri, 3 Jan 2020 14:48:54 +0000 (+0000) Subject: parser: Optional semicolon between statements. X-Git-Tag: v'0.2'~100 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=cd5cb328d707b89caad44b038422d6456c1aee03;p=goals.git parser: Optional semicolon between statements. --- diff --git a/src/lexer.mll b/src/lexer.mll index 4a316a0..f2d0830 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -43,6 +43,7 @@ rule read = | newline { new_line lexbuf; read lexbuf } | "," { COMMA } | ":" { COLON } + | ";" { SEMICOLON } | "=" { EQUALS } | "(" { LEFT_PAREN } | ")" { RIGHT_PAREN } diff --git a/src/parser.mly b/src/parser.mly index db70924..b84ac15 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -70,6 +70,7 @@ let do_include env loc filename optflag file = %token OPTINCLUDE %token RIGHT_ARRAY %token RIGHT_PAREN +%token SEMICOLON %token STRING %token TACTIC %token TACTIC_KEYWORD @@ -85,11 +86,12 @@ file: stmts: | (* none *) { Ast.Env.empty } - | stmts INCLUDE STRING + | stmts INCLUDE STRING option(SEMICOLON) { do_include $1 $loc $3 false file } - | stmts OPTINCLUDE STRING + | stmts OPTINCLUDE STRING option(SEMICOLON) { do_include $1 $loc $3 true file } - | stmts stmt { let name, expr = $2 in Ast.Env.add name expr $1 } + | stmts stmt option(SEMICOLON) + { let name, expr = $2 in Ast.Env.add name expr $1 } ; stmt: