[svn:parrot] r35735 - trunk/examples/tge/branch

[email protected]
Newsgroups perl.cvs.parrot
Message-ID <[email protected]>
Author: allison
Date: Sun Jan 18 21:54:46 2009
New Revision: 35735

Modified:
   trunk/examples/tge/branch/branch.g
   trunk/examples/tge/branch/transform.pir

Log:
[cage] Update TGE examples so they'll actually compile and run. Found while attempting to test Reini Urban's path change for TT #123.

Modified: trunk/examples/tge/branch/branch.g
==============================================================================
--- trunk/examples/tge/branch/branch.g	(original)
+++ trunk/examples/tge/branch/branch.g	Sun Jan 18 21:54:46 2009
@@ -1,9 +1,11 @@
-    Leaf:   min(.) = { 
+    grammar TreeMin is TGE;Grammar;
+
+    transform min (Leaf) :language('PIR') {
         $P1 = getattribute node, "value"
-        .return ($P1)
+       .return ($P1)
     }
 
-    Branch: min(.) = {
+    transform min (Branch) :language('PIR') {
         .local pmc left
         .local pmc right
         .local pmc min
@@ -11,9 +13,9 @@
         .local pmc right_val
 
         left = getattribute node, "left"
-        left_val = tree.get('min', left)
+        left_val = tree.'get'('min', left)
         right = getattribute node, "right"
-        right_val = tree.get('min', right)
+        right_val = tree.'get'('min', right)
 
         min = left_val
         if min <= right_val goto got_min
@@ -23,47 +25,47 @@
     }
 
     # find the global minimum and propagate it back down the tree
-    ROOT:   gmin(.) = { 
+    transform gmin (ROOT) :language('PIR') {
         .local pmc gmin
         gmin = new 'Integer'
-        gmin = tree.get('min', node)
+        gmin = tree.'get'('min', node)
         .return (gmin)
     }
 
-    Branch: gmin(.left)  = { 
+    transform gmin (Branch) :applyto('left') :language('PIR') {
         .local pmc gmin
-        gmin = tree.get('gmin', node)
+        gmin = tree.'get'('gmin', node)
         .return (gmin)
     }
 
-    Branch: gmin(.right) = {
+    transform gmin (Branch) :applyto('right') :language('PIR') {
         .local pmc gmin
-        gmin = tree.get('gmin', node)
+        gmin = tree.'get'('gmin', node)
         .return (gmin)
     }
 
     # reconstruct the tree with every leaf replaced with the minimum
     # value
-    Leaf:   result(.) = {
+    transform result (Leaf) :language('PIR') {
         .local pmc newnode
 
         newnode = new 'Leaf'
-        $P1 = tree.get('gmin', node)
+        $P1 = tree.'get'('gmin', node)
         setattribute newnode, 'value', $P1
         .return(newnode)
     }
 
-    Branch: result(.) = {
+    transform result (Branch) :language('PIR') {
         .local pmc newnode
         .local pmc left_child
         .local pmc right_child
         newnode = new 'Branch'
         left_child = getattribute node, 'left'
         right_child = getattribute node, 'right'
-        $P1 = tree.get('result', left_child)
-        $P2 = tree.get('result', right_child)
+        $P1 = tree.'get'('result', left_child)
+        $P2 = tree.'get'('result', right_child)
 
         setattribute newnode, 'left', $P1
         setattribute newnode, 'right', $P2
         .return(newnode)
-    }
+    }
\ No newline at end of file

Modified: trunk/examples/tge/branch/transform.pir
==============================================================================
--- trunk/examples/tge/branch/transform.pir	(original)
+++ trunk/examples/tge/branch/transform.pir	Sun Jan 18 21:54:46 2009
@@ -18,7 +18,7 @@
 .sub _main :main
     .param pmc argv
 
-    load_bytecode '../../../runtime/parrot/library/TGE.pbc'
+    load_bytecode 'TGE.pbc'
     load_bytecode 'lib/Leaf.pir'
     load_bytecode 'lib/Branch.pir'
 
@@ -28,8 +28,8 @@
 
     # Compile a grammar from the source grammar file
     .local pmc grammar
-    grammar = new 'TGE'
-    grammar.'agcompile'(source)
+    $P1 = new ['TGE';'Compiler']
+    grammar = $P1.'compile'(source)
 
     # Build up the tree for testing
     .local pmc tree
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.