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

Commit

Permalink
Treat leading '-' as part of numeric literals.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Nov 24, 2009
1 parent 0ce5b09 commit fb49c3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 7 additions & 8 deletions src/NQP/Actions.pm
Expand Up @@ -584,14 +584,13 @@ method postcircumfix:sym<( )>($/) {
}

method value($/) {
my $past := $<quote>
?? $<quote>.ast
!! PAST::Val.new(
:value($<dec_number>
?? $<dec_number>.ast
!! $<integer>.ast)
);
make $past;
make $<quote> ?? $<quote>.ast !! $<number>.ast;
}

method number($/) {
my $value := $<dec_number> ?? $<dec_number>.ast !! $<integer>.ast;
if ~$<sign> eq '-' { $value := -$value; }
make PAST::Val.new( :value($value) );
}

method quote:sym<apos>($/) { make $<quote_EXPR>.ast; }
Expand Down
10 changes: 7 additions & 3 deletions src/NQP/Grammar.pm
Expand Up @@ -352,9 +352,13 @@ token arglist {
token term:sym<value> { <value> }

token value {
| <dec_number>
| <quote>
| <integer>
| <number>
}

token number {
$<sign>=[<[+\-]>?]
[ <dec_number> | <integer> ]
}

proto token quote { <...> }
Expand Down Expand Up @@ -433,7 +437,7 @@ token infix:sym<**> { <sym> <O('%exponentiation, :pirop<pow>')> }

token prefix:sym<+> { <sym> <O('%symbolic_unary, :pirop<set N*>')> }
token prefix:sym<~> { <sym> <O('%symbolic_unary, :pirop<set S*>')> }
token prefix:sym<-> { <sym> <![>]> <O('%symbolic_unary, :pirop<neg>')> }
token prefix:sym<-> { <sym> <![>]> <!number> <O('%symbolic_unary, :pirop<neg>')> }
token prefix:sym<?> { <sym> <O('%symbolic_unary, :pirop<istrue>')> }
token prefix:sym<!> { <sym> <O('%symbolic_unary, :pirop<isfalse>')> }
token prefix:sym<|> { <sym> <O('%symbolic_unary')> }
Expand Down

0 comments on commit fb49c3e

Please sign in to comment.