Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Add basic statements and terminators.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 21, 2009
1 parent 9924922 commit b079e0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/NQP/Actions.pm
@@ -1,7 +1,16 @@
class NQP::Actions is HLL::Actions;

method TOP($/) { make $<statementlist>.ast; }

method TOP($/) { make $<EXPR>.ast; }
method statementlist($/) {
my $past := PAST::Stmts.new( :node($/) );
if $<statement> {
for $<statement> { $past.push( $_.ast ); }
}
make $past;
}

method statement($/) { make $<EXPR>.ast; }

## Terms

Expand Down
16 changes: 15 additions & 1 deletion src/NQP/Grammar.pm
@@ -1,6 +1,20 @@
grammar NQP::Grammar is HLL::Grammar;

token TOP { <EXPR> [ $ || <.panic: 'Confused'> ] }
token TOP { <statementlist> [ $ || <.panic: 'Confused'> ] }

rule statementlist {
| $
| [<statement><.eat_terminator> ]*
}

token statement {
| <EXPR>
}

token eat_terminator {
| ';'
| $
}

## Terms

Expand Down

0 comments on commit b079e0d

Please sign in to comment.