Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle circumfix parens.
  • Loading branch information
arnsholt committed Nov 29, 2014
1 parent 9680eaf commit 11580c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Snake/Actions.nqp
Expand Up @@ -74,6 +74,15 @@ method term:sym<string>($/) { make $<string>.ast; }
method term:sym<integer>($/) { make QAST::IVal.new(:value($<integer>.ast)) }
method term:sym<float>($/) { make QAST::NVal.new(:value($<dec_number>.ast)) }

method circumfix:sym<( )>($/) {
if +$<expression_list>.ast > 1 || $<expression_list><trailing> {
nqp::die("Tuples NYI");
}
else {
make $<expression_list>.ast[0]
}
}

method circumfix:sym<[ ]>($/) {
my $ast := QAST::Op.new(:op<list>);
for $<expression_list>.ast -> $e {
Expand Down
2 changes: 1 addition & 1 deletion src/Snake/Grammar.nqp
Expand Up @@ -246,7 +246,7 @@ token postfix:sym<attribute> { '.' <identifier> <O('%dotty')> }
token postcircumfix:sym<( )> { '(' ~ ')' [:my $*WS_NL := 1; <.ws> <expression_list>?] <O('%call')> }

## 6.13: Expression lists
rule expression_list { <EXPR>+ % [ ',' ]$<trailing>=[ ',' ]? }
rule expression_list { <EXPR>+ % [ ',' ][$<trailing>=[ ',' ]]? }

# 7: Simple statements
#proto token simple-statement {*}
Expand Down

0 comments on commit 11580c8

Please sign in to comment.