-
-
Save FROGGS/f2d7c5f145af54eecf3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm | |
index 933f764..436f106 100644 | |
--- a/src/Perl6/Actions.pm | |
+++ b/src/Perl6/Actions.pm | |
@@ -5737,6 +5737,22 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
} | |
} | |
+class Perl6::P5Actions is HLL::Actions does STDActions { | |
+ | |
+ method dec_number($/) { | |
+# say("dec_number: $/"); | |
+ my $int := $<int> ?? filter_number(~$<int>) !! "0"; | |
+ my $frac := $<frac> ?? filter_number(~$<frac>) !! "0"; | |
+ if $<escale> { | |
+ my $e := nqp::islist($<escale>) ?? $<escale>[0] !! $<escale>; | |
+# say('dec_number exponent: ' ~ ~$e.ast); | |
+ make radcalc($/, 10, $<coeff>, 10, nqp::unbox_i($e.ast), :num); | |
+ } else { | |
+ make radcalc($/, 10, $<coeff>); | |
+ } | |
+ } | |
+} | |
+ | |
class Perl6::QActions is HLL::Actions does STDActions { | |
method nibbler($/) { | |
my @asts; | |
diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm | |
index d39047f..01a19b3 100644 | |
--- a/src/Perl6/Grammar.pm | |
+++ b/src/Perl6/Grammar.pm | |
@@ -313,6 +313,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD { | |
%*LANG<Q-actions> := Perl6::QActions; | |
%*LANG<MAIN> := Perl6::Grammar; | |
%*LANG<MAIN-actions> := Perl6::Actions; | |
+ %*LANG<Perl5> := Perl6::P5Grammar; | |
+ %*LANG<Perl5-actions> := Perl6::P5Actions; | |
# Package declarator to meta-package mapping. Starts pretty much empty; | |
# we get the mappings either imported or supplied by the setting. One | |
@@ -1007,6 +1009,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { | |
<.finishpad> | |
[ | |
| '{YOU_ARE_HERE}' <you_are_here> | |
+ | :dba('Perl 5 block') '{:p5' <nibble(self.quote_lang(%*LANG<Perl5>, '{:p5', '}'))> [ '}' || <.panic: "Unable to parse Perl 5 block; couldn't find final '}'"> ] | |
| :dba('block') '{' ~ '}' <statementlist> <?ENDSTMT> | |
| <?terminator> { $*W.throw($/, 'X::Syntax::Missing', what =>'block') } | |
| <?> { $*W.throw($/, 'X::Syntax::Missing', what => 'block') } | |
@@ -3614,6 +3617,22 @@ grammar Perl6::Grammar is HLL::Grammar does STD { | |
} | |
} | |
+grammar Perl6::P5Grammar is HLL::Grammar does STD { | |
+ | |
+ method TOP() { | |
+ <dec_number> | |
+ } | |
+ | |
+ token dec_number { | |
+ :dba('decimal number') | |
+ [ | |
+ | $<coeff> = [ '.' <frac=.decint> ] <escale>? | |
+ | $<coeff> = [ <int=.decint> '.' <frac=.decint> ] <escale>? | |
+ | $<coeff> = [ <int=.decint> ] <escale> | |
+ ] | |
+ } | |
+} | |
+ | |
grammar Perl6::QGrammar is HLL::Grammar does STD { | |
method throw_unrecog_backslash_seq ($sequence) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment