Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of git@github.com:rakudo/rakudo
  • Loading branch information
Martin Berends committed Aug 9, 2009
2 parents bf5ed94 + f489207 commit e690c9f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 34 deletions.
68 changes: 44 additions & 24 deletions build/gen_whatever_pir.pl
Expand Up @@ -9,40 +9,57 @@
infix:** infix:* infix:/ infix:% infix:div infix:mod infix:+ infix:-
infix:== infix:!= infix:< infix:> infix:<= infix:>= infix:<=>
infix:.. infix:^.. infix:..^ infix:^..^
prefix:+ prefix:- prefix:~ prefix:? prefix:! prefix:^
);

for (@ops) {
print qq{
.namespace []
.sub '$_' :multi('Whatever', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'Whatever')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi('WhateverCode', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'WhateverCode')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
};
if (/^infix:/) {
print qq{
.namespace []
.sub '$_' :multi('Whatever', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'Whatever')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi('WhateverCode', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'WhateverCode')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
};
}
else {
print qq{
.namespace []
.sub '$_' :multi('Whatever')
.param pmc x
.tailcall '!whatever_helper'('$_', x)
.end
.sub '$_' :multi('WhateverCode', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
};
}
}

print q{
.namespace []
.sub '!whatever_helper' :anon
.param string opname
.param pmc left
.param pmc right
.param pmc right :optional
.local pmc opfunc
opfunc = find_name opname
.lex '$opfunc', opfunc
Expand All @@ -60,8 +77,11 @@
left = find_lex '$left'
right = find_lex '$right'
left = '!whatever_eval'(left, arg)
if null right goto unary
right = '!whatever_eval'(right, arg)
.tailcall opfunc(left, right)
unary:
.tailcall opfunc(left)
.end
.sub '!whatever_eval' :multi(_)
.param pmc whatever
Expand Down
3 changes: 3 additions & 0 deletions src/parser/actions.pm
Expand Up @@ -2228,6 +2228,9 @@ method circumfix($/, $key) {
$call_on
);
}
elsif $key eq 'quote' {
$past := $<quote_expression>.ast;
}
make $past;
}

Expand Down
17 changes: 7 additions & 10 deletions src/parser/grammar.pg
Expand Up @@ -723,10 +723,7 @@ rule enum_declarator {
}}
]?

[
| <?before '(' > <circumfix> {*} #= circumfix
| <?before '<' | '«' > <quote> {*} #= quote
]
<?before '(' | '<' | '<<' | '«' > <circumfix> {*} #= circumfix
}

rule scope_declarator {
Expand Down Expand Up @@ -826,10 +823,12 @@ token special_variable {
}

token circumfix {
| '(' <statementlist> ')' {*} #= ( )
| '[' <statementlist> ']' {*} #= [ ]
| <?before '{' | <lambda> > <pblock> {*} #= { }
| <sigil> '(' <semilist> ')' {*} #= $( )
| '(' <statementlist> ')' {*} #= ( )
| '[' <statementlist> ']' {*} #= [ ]
| <?before '{' | <lambda> > <pblock> {*} #= { }
| <sigil> '(' <semilist> ')' {*} #= $( )
| <?before '<<' | '«'> <quote_expression: :ww :qq> {*} #= quote
| <?before '<' > <quote_expression: :w :q> {*} #= quote
}

token def_module_name {
Expand Down Expand Up @@ -919,8 +918,6 @@ token quote {
[
| <.before \'> <quote_expression: :q>
| <.before '"' > <quote_expression: :qq>
| <.before '<<' | '«'> <quote_expression: :ww :qq>
| <.before '<' > <quote_expression: :w :q>
| <.before '/'> <quote_expression: :regex>
| [m|rx] <.nofun> <.ws>
[ [':P5'|':Perl5'] <.nofun> <.ws> <quote_expression: :regex :P5>
Expand Down

0 comments on commit e690c9f

Please sign in to comment.