// *** end of global SYN and SEM declarations from ATG *** private static void NT_BinaryTree() { for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: // SEM tree = new BTree(); break; case 2: NT_SubTree(ref tree); break; case 3: // SEM Console.WriteLine("Tree:"); Console.Write("("); if (tree.HasBeenAssigned()) { Console.Write(tree); } Console.WriteLine(")"); break; } // switch } // for } // NT_BinaryTree
} // NT_BinaryTree private static void NT_SubTree(ref BTree t) { BTree left = new BTree(); BTree right = new BTree(); for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: NT_SubTree(ref left); break; case 2: Lex.GETnumberAttr(out num); break; case 3: // SEM t.Value = num; t.Left = left; t.Right = right; break; case 4: NT_SubTree(ref right); break; } // switch } // for } // NT_SubTree
public static void StartSem() { //-----------------------------------|---------------------------------------- for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: NT_BinaryTree(); break; } // switch } // for } // StartSem