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

Commit

Permalink
Add some precedence to the operator tokens, fix operator spec parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 19, 2009
1 parent 0bd524c commit 74835b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/HLL/Actions.pm
@@ -1,7 +1,6 @@
class HLL::Actions;

method EXPR($/, $key?) {
Q:PIR { say 'EXPR' };
unless $key { return 0; }
my $past;
if $key eq 'INFIX' {
Expand Down
3 changes: 3 additions & 0 deletions src/NQP/Actions.pm
@@ -1,5 +1,8 @@
class NQP::Actions is HLL::Actions;

# These will eventually go in NQP::Grammar.
NQP::Grammar.O(':prec<t=>, :assoc<left>', '%additive');

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

method term:sym<value>($/) { make $<value>.ast; }
Expand Down
4 changes: 2 additions & 2 deletions src/NQP/Grammar.pm
Expand Up @@ -6,8 +6,8 @@ proto token term { <...> }
token term:sym<value> { <value> }

proto token infix { <...> }
token infix:sym<+> { $<sym>=['+'] }
token infix:sym<-> { $<sym>=['-'] }
token infix:sym<+> { $<sym>=['+'] <O('%additive, :pirop<add>')> }
token infix:sym<-> { $<sym>=['-'] <O('%additive, :pirop<sub>')> }

token value {
| <integer>
Expand Down
6 changes: 6 additions & 0 deletions src/cheats/hll-grammar.pir
Expand Up @@ -104,7 +104,13 @@ C< :!pair >, and C<< :pair<strval> >>.
# as a lookup of a previously saved hash to be merged in.
.local string lookup
.local int lpos
# Find the first whitespace or comma
lpos = find_cclass .CCLASS_WHITESPACE, spec, pos, eos
$I0 = index spec, ',', pos
if $I0 < 0 goto have_lookup_lpos
if $I0 >= lpos goto have_lookup_lpos
lpos = $I0
have_lookup_lpos:
$I0 = lpos - pos
lookup = substr spec, pos, $I0
.local pmc lhash, lhash_it
Expand Down

0 comments on commit 74835b5

Please sign in to comment.