Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created December 3, 2016 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/b8463544f39af5fd4a684d969f4be04a to your computer and use it in GitHub Desktop.
Save zoffixznet/b8463544f39af5fd4a684d969f4be04a to your computer and use it in GitHub Desktop.
diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp
index d7595d8..6f1336c 100644
--- a/src/Perl6/Actions.nqp
+++ b/src/Perl6/Actions.nqp
@@ -4974,6 +4974,14 @@ class Perl6::Actions is HLL::Actions does STDActions {
my $val;
if nqp::can($ast,'has_compile_time_value') && $ast.has_compile_time_value {
$val := $ast.compile_time_value;
+ if $*NEGATE_VALUE {
+ my $neg-op := $*W.find_symbol(['&prefix:<->']);
+ nqp::say("Calling neg op " ~ $val.HOW.name($val) ~ " " ~ $val);
+ $val := $neg-op($val);
+ $val := $*W.add_numeric_constant(
+ $/, $val.HOW.name($val), $val,
+ );
+ }
}
else { # for negatives
$val := (
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 3645905..29c7ebb 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -2946,8 +2946,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*IN_DECL := '';
[
| <value>
- | <[-−]> $<value>=\d+
| <sign> $<value>=['Inf'|'∞'] :my $*INF_VALUE := 1;
+ | [ <[-−]> :my $*NEGATE_VALUE := 1; ]? $<value>=<numish>
| <typename>
| where <.ws> <EXPR('i=')>
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment