Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add comments and command separators.

  • Loading branch information...
commit 3d62c115889748dfc78b109cd99b8b28dba9da30 1 parent e634d9f
@pmichaud authored
Showing with 17 additions and 5 deletions.
  1. +8 −2 src/PmTcl/Actions.pm
  2. +9 −3 src/PmTcl/Grammar.pm
View
10 src/PmTcl/Actions.pm
@@ -12,7 +12,7 @@ method TOP($/) {
' get_hll_global lexpad, "%VARS"',
' .lex "%VARS", lexpad') )
),
- $<command>.ast
+ $<script>.ast
);
make $block;
}
@@ -25,11 +25,17 @@ method body($/) {
' new lexpad, ["Hash"]',
' .lex "%VARS", lexpad') )
),
- $<command>.ast
+ $<script>.ast
);
make $block;
}
+method script($/) {
+ my $past := PAST::Stmts.new( :node($/) );
+ for $<command> { $past.push($_.ast); }
+ make $past;
+}
+
method command($/) {
my $past := PAST::Op.new( :name(~$<word>[0].ast), :node($/) );
my $i := 1;
View
12 src/PmTcl/Grammar.pm
@@ -2,11 +2,17 @@ INIT { pir::load_bytecode('HLL.pbc'); }
grammar PmTcl::Grammar is HLL::Grammar;
-token TOP { <command> }
+token TOP { <script> }
-token body { <command> }
+token body { <script> }
-token command { [ <.ws> <word> ]+ }
+token script {
+ [ \h* [ '#' \N* | <command> ] \h* [ ';' | \n ] ]*
+}
+
+token command { [ \h* <word> ]+ }
+
+token command_sep { ';' | \n }
token word {
[
Please sign in to comment.
Something went wrong with that request. Please try again.