Author: bernhard
Date: Thu Feb 8 13:48:20 2007
New Revision: 16927
Modified:
trunk/languages/plumhead/src/partridge/Plumhead.pg
trunk/languages/plumhead/src/partridge/PlumheadPAST.tg
Log:
[Plumhead partridge]
Pass some more tests in t/arithmetics.t
Modified: trunk/languages/plumhead/src/partridge/Plumhead.pg
==============================================================================
--- trunk/languages/plumhead/src/partridge/Plumhead.pg (original)
+++ trunk/languages/plumhead/src/partridge/Plumhead.pg Thu Feb 8 13:48:20 2007
@@ -13,6 +13,8 @@
token DOUBLEQUOTE_STRING { " <-["]>* " }
token SINGLEQUOTE_STRING { ' <-[']>* ' }
token ECHO { e c h o }
+token PAREN_OPEN { \( }
+token PAREN_CLOSE { \) }
token NUMBER { \d+ }
@@ -41,5 +43,5 @@
rule unary_expression { <UNARY_MINUS>? <postfix_expression> }
-rule postfix_expression { <NUMBER> }
+rule postfix_expression { <NUMBER> | <?PAREN_OPEN> <expression> <?PAREN_CLOSE>
}
Modified: trunk/languages/plumhead/src/partridge/PlumheadPAST.tg
==============================================================================
--- trunk/languages/plumhead/src/partridge/PlumheadPAST.tg (original)
+++ trunk/languages/plumhead/src/partridge/PlumheadPAST.tg Thu Feb 8
13:48:20 2007
@@ -96,6 +96,12 @@
.local pmc past
+ $P0 = node['expression']
+ if null $P0 goto no_expression_1
+ past = tree.'get'('past', $P0, 'Plumhead::Grammar::expression')
+ goto handled_expression
+ no_expression_1:
+
$P0 = node['DOUBLEQUOTE_STRING']
if null $P0 goto no_DOUBLEQUOTE_STRING
past = tree.'get'('past', $P0, 'Plumhead::Grammar::DOUBLEQUOTE_STRING')
@@ -116,11 +122,10 @@
$P0 = node['adding_expression']
if null $P0 goto no_adding_expression
- .local pmc mult, past_mult, summand, summand_0, past_summand_0
+ .local pmc past_mult, summand, summand_0, past_summand_0
summand = $P0['summand']
if null summand goto no_summand
- mult = $P0['multiplying_expression']
- past_mult = tree.'get'('past', mult,
'Plumhead::Grammar::expression')
+ past_mult = tree.'get'('past', $P0,
'Plumhead::Grammar::expression')
summand_0 = summand[0]
.local string add_op, pirop
pirop = 'n_add'
@@ -140,11 +145,10 @@
$P0 = node['multiplying_expression']
if null $P0 goto no_multiplying_expression
- .local pmc unary, past_unary, multiplicand, multiplicand_0,
past_multiplicand_0
+ .local pmc past_unary, multiplicand, multiplicand_0,
past_multiplicand_0
multiplicand = $P0['multiplicand']
if null multiplicand goto no_multiplicand
- unary = $P0['unary_expression']
- past_unary = tree.'get'('past', unary,
'Plumhead::Grammar::expression')
+ past_unary = tree.'get'('past', $P0,
'Plumhead::Grammar::expression')
multiplicand_0 = multiplicand[0]
.local string mul_op, pirop
pirop = 'n_mul'
@@ -169,13 +173,17 @@
$P2 = $P0['UNARY_MINUS']
if null $P2 goto no_minus
past = new 'PAST::Op'
- past.init( 'node' => $P1, 'name' => 'prefix:-' )
.local pmc cpast
cpast = tree.'get'('past', $P1,
'Plumhead::Grammar::expression')
- past.push( cpast )
+ past.init( cpast, 'node' => $P0, 'name' => 'prefix:-' )
goto handled_expression
no_minus:
- past = tree.'get'('past', $P1, 'Plumhead::Grammar::expression')
+ $P2 = $P1['expression']
+ if null $P2 goto no_expression
+ past = tree.'get'('past', $P2, 'Plumhead::Grammar::expression')
+ goto handled_expression
+ no_expression:
+ past = tree.'get'('past', $P0, 'Plumhead::Grammar::expression')
goto handled_expression
no_unary_expression: