Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Restructure infixish to be more in line with STD.
This just aids parsing; the now-enabled extra cases will need some AST
generation improvements too.
  • Loading branch information
jnthn committed Jul 9, 2014
1 parent 9044339 commit b764567
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/Perl6/Grammar.nqp
Expand Up @@ -3307,19 +3307,30 @@ grammar Perl6::Grammar is HLL::Grammar does STD {

token infixish($in_meta = nqp::getlexdyn('$*IN_META')) {
:my $*IN_META := $in_meta;
:my $oper;
<!stdstopper>
<!infixstopper>
:dba('infix or meta-infix')
[
| <colonpair> <OPER=fake_infix>
| :dba('bracketed infix') '[' ~ ']' <infixish('[]')> {} <OPER=.copyOPER($<infixish>)>
# XXX Gets false positives.
#[ <!before '='> { self.worry("Useless use of [] around infix op") unless $*IN_META; } ]?
| <OPER=infix_circumfix_meta_operator>
| <OPER=infix> <![=]>
| <OPER=infix_prefix_meta_operator>
| <infix> <OPER=infix_postfix_meta_operator>
| <colonpair> <fake_infix> { $oper := $<fake_infix> }
| [
| :dba('bracketed infix') '[' ~ ']' <infixish('[]')> { $oper := $<infixish><OPER> }
# XXX Gets false positives.
#[ <!before '='> { self.worry("Useless use of [] around infix op") unless $*IN_META; } ]?
| <infix_circumfix_meta_operator> { $oper := $<infix_circumfix_meta_operator> }
| <infix_prefix_meta_operator> { $oper := $<infix_prefix_meta_operator> }
| <infix> { $oper := $<infix> }
]
[ <?before '='> <infix_postfix_meta_operator> { $oper := $<infix_postfix_meta_operator> } ]?
]
<OPER=.asOPER($oper)>
}

method asOPER($OPER) {
my $cur := self.'!cursor_start_cur'();
$cur.'!cursor_pass'(self.pos());
nqp::bindattr($cur, NQPCursor, '$!match', $OPER);
$cur
}

token fake_infix {
Expand Down Expand Up @@ -3427,14 +3438,6 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$cur
}

method copyOPER($from) {
my $OPER := $from<OPER>;
my $cur := self.'!cursor_start_cur'();
$cur.'!cursor_pass'(self.pos());
nqp::bindattr($cur, NQPCursor, '$!match', $OPER);
$cur
}

proto token dotty { <...> }
token dotty:sym<.> {
<sym> <dottyop>
Expand Down

0 comments on commit b764567

Please sign in to comment.