develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35174 - branches/rvar2/languages/perl6/src/parser

From:
pmichaud
Date:
January 7, 2009 13:40
Subject:
[svn:parrot] r35174 - branches/rvar2/languages/perl6/src/parser
Message ID:
20090107213952.58805CB9F9@x12.develooper.com
Author: pmichaud
Date: Wed Jan  7 13:39:49 2009
New Revision: 35174

Modified:
   branches/rvar2/languages/perl6/src/parser/actions.pm
   branches/rvar2/languages/perl6/src/parser/grammar.pg

Log:
[rakudo]:  Update regex/token/rule implementation a bit, restore $<> $n



Modified: branches/rvar2/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar2/languages/perl6/src/parser/actions.pm	(original)
+++ branches/rvar2/languages/perl6/src/parser/actions.pm	Wed Jan  7 13:39:49 2009
@@ -1671,6 +1671,20 @@
     elsif $key eq 'special_variable' {
         $var := $( $<special_variable> );
     }
+    elsif $key eq '$0' {
+        $var := PAST::Var.new( 
+                    :scope('keyed_int'), 
+                    :node($/),
+                    :viviself('Failure'),
+                    PAST::Var.new( :scope('lexical'), :name('$/') ),
+                    +$<matchidx> );
+    }
+    elsif $key eq '$<>' {
+        $var := $( $<postcircumfix> );
+        $var.unshift( PAST::Var.new( :scope('lexical'), :name('$/'), 
+                                     :viviself('Failure'), :node($/) )
+        );
+    }
     make $var;
 }
 
@@ -2115,32 +2129,23 @@
 }
 
 
-method regex_declarator($/, $key) {
-    make $( $/{$key} );
-}
-
-
-method regex_declarator_regex($/) {
-    my $past := $( $<quote_expression> );
-    $past.name( ~$<identifier>[0] );
+method regex_declarator($/) {
+    my $sym  := ~$<sym>;
+    my $past := $( $<regex_def> );
+    if $sym eq 'token'   { $past.compiler_args( :ratchet(1) ); }
+    elsif $sym eq 'rule' { $past.compiler_args( :s(1), :ratchet(1) ); }
     make $past;
 }
 
-
-method regex_declarator_token($/) {
-    my $past := $( $<quote_expression> );
-    $past.compiler_args( :ratchet(1) );
-    $past.name( ~$<identifier>[0] );
-    make $past;
-}
-
-
-method regex_declarator_rule($/) {
-    my $past := $( $<quote_expression> );
-    $past.compiler_args( :s(1), :ratchet(1) );
-    $past.name( ~$<identifier>[0] );
+method regex_def($/) {
+    my $past := $( $<regex_block> );
+    $past.name( ~$<deflongname>[0] );
     make $past;
 }
+   
+method regex_block($/) {
+    make $( $<quote_expression> );
+} 
 
 
 method type_declarator($/) {

Modified: branches/rvar2/languages/perl6/src/parser/grammar.pg
==============================================================================
--- branches/rvar2/languages/perl6/src/parser/grammar.pg	(original)
+++ branches/rvar2/languages/perl6/src/parser/grammar.pg	Wed Jan  7 13:39:49 2009
@@ -812,35 +812,23 @@
     {*}
 }
 
-# These regex rules are some way off STD.pm at the moment, but we'll work them
-# closer to it over time.
-rule regex_declarator {
-    | <regex_declarator_regex> {*}          #= regex_declarator_regex
-    | <regex_declarator_token> {*}          #= regex_declarator_token
-    | <regex_declarator_rule> {*}           #= regex_declarator_rule
-}
 
-rule regex_declarator_regex {
-    $<sym>='regex'
-    <identifier>?
-    <before '{'> <quote_expression: :regex><.BLOCK_STATEMENT_END>?
+rule regex_declarator {
+    $<sym>=[regex|token|rule] <regex_def>
     {*}
 }
 
-rule regex_declarator_token {
-    $<sym>='token'
-    <identifier>?
-    <before '{'> <quote_expression: :regex :ratchet><.BLOCK_STATEMENT_END>?
-    {*}
+rule regex_def {
+    <deflongname=name>?  <regex_block> {*}
 }
 
-rule regex_declarator_rule {
-    $<sym>='rule'
-    <identifier>?
-    <before '{'> <quote_expression: :regex :ratchet :sigspace><.BLOCK_STATEMENT_END>?
+token regex_block {
+    <?before '{'> <quote_expression: :regex>
+    <.BLOCK_STATEMENT_END>?
     {*}
 }
 
+
 ##  S05 shows semilist as being a list of statements, in order
 ##  to support multidimensional argument lists.  For now we
 ##  just handle a single-dimensional argument list.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About