Permalink
Browse files

squaak: improve sub call in expressions

This limits sub calls to variables, not arbitrary expressions.
  • Loading branch information...
Benabik committed Dec 5, 2011
1 parent 0ea3629 commit 9fa9cbeea0bb3297d055b681a9ea2a07c5d06af1
@@ -160,10 +160,7 @@ method statement:sym<if>($/) {
}
method statement:sym<sub_call>($/) {
- my $invocant := $<primary>.ast;
- my $past := $<arguments>.ast;
- $past.unshift($invocant);
- make $past;
+ make $<primary>.ast;
}
method arguments($/) {
@@ -330,6 +327,8 @@ method postfix_expression:sym<member>($/) {
:node($/) );
}
+method postfix_expression:sym<call>($/) { make $<arguments>.ast }
+
method identifier($/) {
our @?BLOCK;
my $name := ~$<ident>;
@@ -369,7 +368,6 @@ method quote:sym<'>($/) { make $<quote_EXPR>.ast; }
method quote:sym<">($/) { make $<quote_EXPR>.ast; }
method circumfix:sym<( )>($/) { make $<EXPR>.ast; }
-method postcircumfix:sym<( )>($/) { make $<arguments>.ast }
method named_field($/) {
my $past := $<EXPR>.ast;
@@ -77,7 +77,7 @@ rule statement:sym<if> {
}
rule statement:sym<sub_call> {
- <primary> <arguments>
+ <primary>
}
rule arguments {
@@ -134,13 +134,15 @@ rule postfix_expression:sym<key> { '{' <EXPR> '}' }
rule postfix_expression:sym<member> { '.' <identifier> }
+rule postfix_expression:sym<call> { <arguments> }
+
token identifier {
<!keyword> <ident>
}
token keyword {
- ['and'|'catch'|'do' |'else' |'end' |'for' |'if'
- |'not'|'or' |'sub' |'throw'|'try' |'var'|'while']>>
+ ['and'|'catch' |'do' |'else' |'end'|'for'|'if' |'not'
+ |'or' |'return'|'sub'|'throw'|'try'|'var'|'while']>>
}
token term:sym<integer_constant> { <integer> }
@@ -163,7 +165,6 @@ token quote:sym<"> { <?["]> <quote_EXPR: ':qq'> }
## Operators
INIT {
- Squaak::Grammar.O(':prec<x>, :assoc<unary>', '%methodop');
Squaak::Grammar.O(':prec<w>, :assoc<unary>', '%unary-negate');
Squaak::Grammar.O(':prec<v>, :assoc<unary>', '%unary-not');
Squaak::Grammar.O(':prec<u>, :assoc<left>', '%multiplicative');
@@ -174,9 +175,6 @@ INIT {
}
token circumfix:sym<( )> { '(' <.ws> <EXPR> ')' }
-token postcircumfix:sym<( )> {
- <arguments> <O( '%methodop, :pasttype<call>' )>
-}
rule circumfix:sym<[ ]> {
'[' [<EXPR> ** ',']? ']'

0 comments on commit 9fa9cbe

Please sign in to comment.