From 5b915a88e8da6aac59e03dbed487d17dab2e035f Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 10 Dec 2022 16:06:13 +0100 Subject: [PATCH] fix do --- parser.mly | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/parser.mly b/parser.mly index 41bb77a..210ac29 100644 --- a/parser.mly +++ b/parser.mly @@ -51,12 +51,12 @@ args_ident: /* ( */ | Lpardeb ; s = args_ident { s } - /* a, ... */ + /* type a, ... */ | t = Ltype ; a = arg_ident ; Lcomma ; s = args_ident { Arg { type_t = t ; name = a } :: s } - /* c) */ + /* type c) */ | t = Ltype ; a = arg_ident ; Lparfin { [ Arg { type_t = t ; name = a } ] } @@ -98,24 +98,11 @@ instr: [ Assign { var = v ; expr = e ; pos = $startpos($2) } ] } - /* function(); */ - | f = Lvar ; a = args_expr ; Lsc { - [ Do { expr = Call { func = f ; args = a ; pos = $startpos(a) } ; pos = $startpos} ] + /* e; */ + | e = expr ; Lsc { + [ Do { expr = e ; pos = $startpos} ] } -args_expr: - /* ( */ - | Lpardeb ; s = args_expr { s } - - /* a, ... */ - | a = expr ; Lcomma ; s = args_expr { a :: s } - - /* c) */ - | a = expr ; Lparfin { [ a ] } - - /* ) */ - | Lparfin { [] } - expr: /* int */ | n = Lint { @@ -151,4 +138,19 @@ expr: | a = expr ; Ldiv ; b = expr { Call { func = "%div" ; args = [ a ; b ] ; pos = $startpos($2) } } + + /* function() */ + | f = Lvar ; Lpardeb ; a = args_expr { + Call { func = f ; args = a ; pos = $startpos(a) } + } ; + +args_expr: + /* a, ... */ + | a = expr ; Lcomma ; s = args_expr { a :: s } + + /* c) */ + | a = expr ; Lparfin { [ a ] } + + /* ) */ + | Lparfin { [] }