diff --git a/compilers/opsc/src/Ops/Compiler/Grammar.pm b/compilers/opsc/src/Ops/Compiler/Grammar.pm index 26aa6f07e0..b109708140 100644 --- a/compilers/opsc/src/Ops/Compiler/Grammar.pm +++ b/compilers/opsc/src/Ops/Compiler/Grammar.pm @@ -149,13 +149,36 @@ rule statement_list { } token statement { - <.ws> + | + | + | <.ws> } + +proto rule statement_control { <...> } + +rule statement_control:sym { + '(' ')' + + [ 'else' ]? +} + + token term:sym { } +token term:sym { } +token term:sym { } +token term:sym { # longer to work-around lack of LTM + [ + | \d+ '.' \d* + | \d* '.' \d+ + ] +} + +# Assignment +token infix:sym<=> { } token postcircumfix:sym<( )> { - '(' <.ws> ? ')' + '(' <.ws> ')' } token postcircumfix:sym<[ ]> { @@ -163,6 +186,14 @@ token postcircumfix:sym<[ ]> { } +token arglist { + <.ws> + [ + | + | + ] +} + rule blockoid { '{' @@ -205,8 +236,20 @@ token ws { INIT { Ops::Compiler::Grammar.O(':prec, :assoc', '%methodop'); - Ops::Compiler::Grammar.O(':prec, :assoc', '%multiplicative'); - Ops::Compiler::Grammar.O(':prec, :assoc', '%additive'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%autoincrement'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%exponentiation'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%symbolic_unary'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%multiplicative'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%additive'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%concatenation'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%relational'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%tight_and'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%tight_or'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%conditional'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%assignment'); + Ops::Compiler::Grammar.O(':prec, :assoc, :nextterm', '%comma'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%list_infix'); + Ops::Compiler::Grammar.O(':prec, :assoc', '%list_prefix'); } diff --git a/t/compilers/opsc/01-parse-body.t b/t/compilers/opsc/01-parse-body.t index fc87e7c09e..a54e8cf0dd 100644 --- a/t/compilers/opsc/01-parse-body.t +++ b/t/compilers/opsc/01-parse-body.t @@ -26,6 +26,27 @@ inline op noop() { |); ok(1, "Single call op parsed"); + _parse($c, q| +inline op noop() { + char bar; +} +|); + ok(1, "Simple declaration parsed"); + + _parse($c, q| +inline op noop() { + Interp * const new_interp; +} +|); + ok(1, "Complex declaration parsed"); + + _parse($c, q| +inline op noop() { + Interp * const new_interp = foo(); +} +|); + ok(1, "More complex declaration parsed"); + };