Author: bernhard
Date: Fri Feb  2 13:31:46 2007
New Revision: 16870

Modified:
   trunk/languages/plumhead/src/partridge/Plumhead.pg
   trunk/languages/plumhead/src/partridge/PlumheadPAST.tg

Log:
[Plumhead partridge]
Make some tests in hello.t succeed again.


Modified: trunk/languages/plumhead/src/partridge/Plumhead.pg
==============================================================================
--- trunk/languages/plumhead/src/partridge/Plumhead.pg  (original)
+++ trunk/languages/plumhead/src/partridge/Plumhead.pg  Fri Feb  2 13:31:46 2007
@@ -7,7 +7,7 @@
 
 token TOP         { <program> }
 
-regex SEA                     { .* <before: \<> }
+regex SEA                     { .* <?before: \<> }
 token CODE_START              { \< \? p h p }
 token CODE_END                { \? \> }
 token DOUBLEQUOTE_STRING      { " <-["]>* " }
@@ -22,11 +22,11 @@
 
 token program     { ^ <SEA> <code> }
 
-rule  code        { <CODE_START> <statement>* <CODE_END> }
+rule  code        { <?CODE_START> <statement>* <?CODE_END> }
 
 rule statement    { <ECHO> <expression> ; }
 
-token expression  { <DOUBLEQUOTE_STRING> | <adding_expression> }
+token expression  { <DOUBLEQUOTE_STRING> | <SINGLEQUOTE_STRING> | 
<adding_expression> }
 
 rule adding_expression { <multiplying_expression> ( <PLUS> 
<multiplying_expression> )* }
 

Modified: trunk/languages/plumhead/src/partridge/PlumheadPAST.tg
==============================================================================
--- trunk/languages/plumhead/src/partridge/PlumheadPAST.tg      (original)
+++ trunk/languages/plumhead/src/partridge/PlumheadPAST.tg      Fri Feb  2 
13:31:46 2007
@@ -22,41 +22,35 @@
 
     .local pmc past
     past = new 'PAST::Stmts'
-    past.'init'('node'=>node)
+    past.'init'( 'node' => node )
 
-    $P0 = node['sea']
+    $P0 = node['SEA']
+    if null $P0 goto handled_sea
     .local pmc past_sea
-    past_sea = tree.'get'('past', $P0, 'Plumhead::Grammar::sea')
+    past_sea = tree.'get'('past', $P0, 'Plumhead::Grammar::SEA')
     past.'push'(past_sea)
 handled_sea:
 
     $P0 = node['code']
     if null $P0 goto handled_code
-    .local pmc iter
-    iter = new .Iterator, $P0
-  iter_loop:
-    unless iter goto iter_end
-    .local pmc cnode, cnode2, cpast
-    cnode = shift iter
-    cpast = tree.'get'('past', cnode, 'Plumhead::Grammar::code')
-    if null cpast goto iter_loop
-    past.'push'(cpast)
-    goto iter_loop
-  iter_end:
+    .local pmc past_code
+    past_code = tree.'get'('past', $P0, 'Plumhead::Grammar::code')
+    past.'push'(past_code)
 handled_code:
 
     .return (past)
 }
 
-transform past (Plumhead::Grammar::sea) :language('PIR') {
+transform past (Plumhead::Grammar::SEA) :language('PIR') {
 
-    .local pmc past_val
-    past_val = new 'PAST::Val'                             
     .local string val
     val = node
     .local pmc code_string
     code_string = new 'PGE::CodeString'
     ( val ) = code_string.'escape'( val )
+
+    .local pmc past_val
+    past_val = new 'PAST::Val'                             
     past_val.'init'( 'name' => val, 'vtype' => '.Undef' )                      
        
 
     .local pmc past                                                  
@@ -70,7 +64,7 @@
 
     .local pmc past
     past = new 'PAST::Stmts'
-    past.'init'('node'=>node)
+    past.'init'( 'node' => node )
 
     $P0 = node['statement']
     if null $P0 goto handled_statement
@@ -78,14 +72,14 @@
     iter = new .Iterator, $P0
   iter_loop:
     unless iter goto iter_end
-    .local pmc cnode, cnode2, cpast
+    .local pmc cnode, cpast
     cnode = shift iter
     if null cnode goto iter_loop
-    $P1 = cnode['expression']
+    $P1 = cnode['ECHO']
     if null $P1 goto iter_loop
-    $P2 = $P1['DOUBLEQUOTE_STRING']
+    $P2 = cnode['expression']
     if null $P2 goto iter_loop
-    cpast = tree.'get'('past', $P2, 'Plumhead::Grammar::DOUBLEQUOTE_STRING')
+    cpast = tree.'get'('past', $P2, 'Plumhead::Grammar::expression')
     if null cpast goto iter_loop
     past.'push'(cpast)
     goto iter_loop
@@ -96,6 +90,23 @@
     .return (past)
 }
 
+transform past (Plumhead::Grammar::expression) :language('PIR') {
+
+    .local pmc past
+
+    $P0 = node['DOUBLEQUOTE_STRING']
+    if null $P0 goto handled_doublequote
+    past = tree.'get'('past', $P0, 'Plumhead::Grammar::DOUBLEQUOTE_STRING')
+    handled_doublequote:
+
+    $P0 = node['SINGLEQUOTE_STRING']
+    if null $P0 goto handled_singlequote
+    past = tree.'get'('past', $P0, 'Plumhead::Grammar::SINGLEQUOTE_STRING')
+    handled_singlequote:
+
+    .return (past)
+}
+
 
 transform past (Plumhead::Grammar::DOUBLEQUOTE_STRING) :language('PIR') {
 
@@ -113,3 +124,20 @@
     .return (past)
 }
 
+
+transform past (Plumhead::Grammar::SINGLEQUOTE_STRING) :language('PIR') {
+
+    .local pmc past_val
+    past_val = new 'PAST::Val'                             
+    .local string val
+    val = node
+    .local pmc code_string
+    past_val.'init'( 'name' => val, 'vtype' => '.Undef' )                      
        
+
+    .local pmc past                                                  
+    past = new 'PAST::Op'
+    past.'init'( past_val, 'node'=> node, 'pirop' => 'print' )  
+
+    .return (past)
+}
+

Reply via email to