Author: pmichaud
Date: Fri May 9 12:35:48 2008
New Revision: 27396
Modified:
trunk/languages/perl6/config/makefiles/root.in
trunk/languages/perl6/perl6.pir
trunk/languages/perl6/src/parser/expression.pir
trunk/languages/perl6/src/parser/grammar.pg
Log:
[rakudo]:
* Refactor EXPR handling slightly so that we can start
to do some listop processing.
Modified: trunk/languages/perl6/config/makefiles/root.in
==============================================================================
--- trunk/languages/perl6/config/makefiles/root.in (original)
+++ trunk/languages/perl6/config/makefiles/root.in Fri May 9 12:35:48 2008
@@ -34,6 +34,7 @@
src/gen_grammar.pir \
src/gen_actions.pir \
src/gen_builtins.pir \
+ src/parser/expression.pir \
src/parser/quote_expression.pir \
$(PERL6_GROUP)
Modified: trunk/languages/perl6/perl6.pir
==============================================================================
--- trunk/languages/perl6/perl6.pir (original)
+++ trunk/languages/perl6/perl6.pir Fri May 9 12:35:48 2008
@@ -201,6 +201,7 @@
.include 'src/gen_grammar.pir'
+.include 'src/parser/expression.pir'
.include 'src/parser/quote_expression.pir'
.include 'src/gen_actions.pir'
Modified: trunk/languages/perl6/src/parser/expression.pir
==============================================================================
--- trunk/languages/perl6/src/parser/expression.pir (original)
+++ trunk/languages/perl6/src/parser/expression.pir Fri May 9 12:35:48 2008
@@ -13,13 +13,18 @@
=over 4
-=item C<expression(PMC mob)>
+=item C<EXPR([tighter])>
-The C<expression> subroutine implements the Perl6::Grammar
-<expression> subrule. It accepts a match object representing
-the current state of the parse, passes the match object
-to the operator precedence parser to obtain an expression,
-and returns the result to the caller.
+The C<EXPR> method implements the Perl6::Grammar <EXPR> subrule.
+It forwards the match object (invocant) to the operator
+precedence parser to obtain an expression, and returns the
+result to the caller. Any C<tighter> option is passed as a
+corresponding option to the operator precedence parser, which
+parses expressions of tighter precedence.
+
+(FIXME Parrot bug RT#53296 prevents us from using :optional
+on the C<tighter> argument along with :slurpy :named parameters,
+so we use :multi as a temporary workaround.)
=cut
@@ -27,40 +32,21 @@
.include "cclass.pasm"
-.sub "expression"
- .param pmc mob
- .param string stoptoken :optional
- .param int has_stoptoken :opt_flag
+.sub "EXPR" :method :multi(_)
.param pmc adverbs :slurpy :named
.local pmc optable
- .local pmc ws
- optable = find_global 'Perl6::Grammar', "$optable"
- ws = find_global 'Perl6::Grammar', 'ws'
- setattribute optable, "&!ws", ws
- if has_stoptoken > 0 goto expression_1
- stoptoken = ''
- expression_1:
- .return optable."parse"(mob, 'stop'=> stoptoken)
+ optable = get_hll_global ['Perl6::Grammar'], "$optable"
+ .return optable."parse"(self, 'rulename'=>'EXPR', adverbs :named :flat)
.end
-
-=item C<listop_expression>
-
-Parse a listop expression -- i.e., the tokens that follow
-a listop. This limits the parse to tokens that are tighter
-than the listop precedence level, nominally indicated by C<< infix:<== >>.
-
-=cut
-
-.sub 'listop_expression'
- .param pmc mob
+.sub "EXPR" :method :multi(_,_)
+ .param pmc tighter
.param pmc adverbs :slurpy :named
- .local pmc optable, ws
- optable = find_global 'Perl6::Grammar', "$optable"
- ws = find_global 'Perl6::Grammar', 'ws'
- setattribute optable, "&!ws", ws
- .return optable.'parse'(mob, 'tighter'=>'infix:<==')
+ .local pmc optable
+
+ optable = get_hll_global ['Perl6::Grammar'], "$optable"
+ .return optable."parse"(self, 'rulename'=>'EXPR', 'tighter'=>tighter,
adverbs :named :flat)
.end
=back
Modified: trunk/languages/perl6/src/parser/grammar.pg
==============================================================================
--- trunk/languages/perl6/src/parser/grammar.pg (original)
+++ trunk/languages/perl6/src/parser/grammar.pg Fri May 9 12:35:48 2008
@@ -749,7 +749,7 @@
## parser needs a term, it gets it by calling the 'term'
## token above.
-rule EXPR is optable { ... }
+## rule EXPR is optable { ... }
proto 'term:' is precedence('z=')
is parsed(&term)