New test.
[mono.git] / mono / monoburg / sample.brg
index be8688141222bb32ef3ab03f6aef29b0891dd0f8..619b6fc821dd756886f403bee3faaba5da611871 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <glib.h>
 #include <stdio.h>
+#include <string.h>
 
 #define MBTREE_TYPE  MBTree
 
@@ -25,7 +26,7 @@ struct _MBTree {
 # we must fisrt define the terminals
 # with or without numbers
 # 
-%term Assign Constant Fetch=3 Four=8 Mul=5 Plus=6
+%term Assign Constant Fetch=3 Four=8 Mul=5 Plus=6 AltFetch=7
 
 #
 # optional start nonterminal
@@ -38,11 +39,14 @@ con:  Four                    0
 
 addr: con                     0 
 
-addr: Plus(con,reg)           
+addr: Plus(con,reg)           
 {
        int ern = mono_burg_rule (tree->state, MB_NTERM_addr);
        printf ("%s\n", mono_burg_rule_string [ern]);
-} 
+} cost 
+{  
+  return 1;
+}
 
 addr: Plus(con,Mul(Four,reg)) 2 
 {
@@ -50,6 +54,7 @@ addr: Plus(con,Mul(Four,reg)) 2
        printf ("%s\n", mono_burg_rule_string [ern]);
 } 
 
+reg:  AltFetch(addr),
 reg:  Fetch(addr)             1 
 {
        int ern = mono_burg_rule (tree->state, MB_NTERM_reg);
@@ -99,7 +104,7 @@ reduce (MBTree *tree, int goal)
        if (n) { /* not a terminal */
          // printf ("XXTE %s %d\n", mono_burg_rule_string [ern], n);
                if (mono_burg_func [ern])
-                       mono_burg_func [ern] (tree);
+                       mono_burg_func [ern] (tree, NULL);
                else
                        g_warning ("no code for rule %s\n", 
                                   mono_burg_rule_string [ern]);
@@ -131,7 +136,7 @@ main ()
 
        t = create_tree (MB_TERM_Fetch, l, NULL);
 
-       s = mono_burg_label (t);
+       s = mono_burg_label (t, NULL);
 
        g_assert (s);