Ejemplo n.º 1
0
 public List<Tree> TreeDtrs(List<Tree> dtrs)
 {
     /*@bgen(jjtree) TreeDtrs */
     var jjtn000 = new SimpleNode(JjtTreeDtrs);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     try
     {
         switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
         {
             case Identifier:
             case TreeNodeTerminalLabel:
             case TreeNodeNonterminalLabel:
             {
                 Tree tree = TreeNode();
                 TreeDtrs(dtrs);
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 dtrs.Insert(0, tree);
                 return dtrs;
             }
             case CloseParen:
             {
                 Jj_consume_token(CloseParen);
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return dtrs;
             }
             default:
                 jj_la1[9] = jj_gen;
                 Jj_consume_token(-1);
                 throw new ParseException();
         }
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 2
0
 // the argument says whether there must be a foot node on the aux tree.
 public AuxiliaryTree TreeRoot(bool requiresFoot)
 {
     /*@bgen(jjtree) TreeRoot */
     var jjtn000 = new SimpleNode(JjtTreeRoot);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     Tree t;
     try
     {
         t = TreeNode();
         JjTree.CloseNodeScope(jjtn000, true);
         jjtc000 = false;
         return new AuxiliaryTree(t, requiresFoot);
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 3
0
 public Tree TreeNode()
 {
     /*@bgen(jjtree) TreeNode */
     var jjtn000 = new SimpleNode(JjtTreeNode);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     try
     {
         Token label;
         switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
         {
             case TreeNodeNonterminalLabel:
             {
                 label = Jj_consume_token(TreeNodeNonterminalLabel);
                 List<Tree> dtrs = TreeDtrs(new List<Tree>());
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return treeFactory.NewTreeNode(label.Image.Substring(1), dtrs);
             }
             case TreeNodeTerminalLabel:
             {
                 label = Jj_consume_token(TreeNodeTerminalLabel);
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return treeFactory.NewTreeNode(label.Image, new List<Tree>());
             }
             case Identifier:
             {
                 label = Jj_consume_token(Identifier);
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return treeFactory.NewTreeNode(label.Image, new List<Tree>());
             }
             default:
                 jj_la1[8] = jj_gen;
                 Jj_consume_token(-1);
                 throw new ParseException();
         }
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 4
0
 public TsurgeonPattern NodeName()
 {
     /*@bgen(jjtree) NodeName */
     var jjtn000 = new SimpleNode(JjtNodeName);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     Token t;
     try
     {
         t = Jj_consume_token(Identifier);
         JjTree.CloseNodeScope(jjtn000, true);
         jjtc000 = false;
         return new FetchNode(t.Image);
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 5
0
 public List<AuxiliaryTree> TreeList(bool requiresFoot)
 {
     /*@bgen(jjtree) TreeList */
     var jjtn000 = new SimpleNode(JjtTreeList);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     var trees = new List<AuxiliaryTree>();
     try
     {
         AuxiliaryTree tree = TreeRoot(requiresFoot);
         trees.Add(tree);
         //label_3:
         while (true)
         {
             switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
             {
                 case Identifier:
                 case TreeNodeTerminalLabel:
                 case TreeNodeNonterminalLabel:
                 {
                     ;
                     break;
                 }
                 default:
                     jj_la1[7] = jj_gen;
                     //break label_3;
                     goto post_label_3;
             }
             tree = TreeRoot(requiresFoot);
             trees.Add(tree);
         }
         post_label_3:
         {
             JjTree.CloseNodeScope(jjtn000, true);
             jjtc000 = false;
             return trees;
         }
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 6
0
 // TODO: what does this next comment mean?
 // we'll also put in a way to use a SELECTION with a list of nodes.
 public TsurgeonPattern NodeSelection()
 {
     /*@bgen(jjtree) NodeSelection */
     var jjtn000 = new SimpleNode(JjtNodeSelection);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     try
     {
         TsurgeonPattern result = NodeName();
         JjTree.CloseNodeScope(jjtn000, true);
         jjtc000 = false;
         return result;
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 7
0
 public List<TsurgeonPattern> NodeSelectionList(List<TsurgeonPattern> l)
 {
     /*@bgen(jjtree) NodeSelectionList */
     var jjtn000 = new SimpleNode(JjtNodeSelectionList);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     try
     {
         TsurgeonPattern result = NodeSelection();
         l.Add(result);
         //label_2:
         while (true)
         {
             switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
             {
                 case Identifier:
                 {
                     ;
                     break;
                 }
                 default:
                     jj_la1[6] = jj_gen;
                     //break label_2;
                     goto post_label_2;
             }
             result = NodeSelection();
             l.Add(result);
         }
         post_label_2:
         {
             JjTree.CloseNodeScope(jjtn000, true);
             jjtc000 = false;
             return l;
         }
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 8
0
 public TreeLocation Location()
 {
     /*@bgen(jjtree) Location */
     var jjtn000 = new SimpleNode(JjtLocation);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     try
     {
         Token rel = Jj_consume_token(LocationRelation);
         TsurgeonPattern child = NodeSelection();
         JjTree.CloseNodeScope(jjtn000, true);
         jjtc000 = false;
         return new TreeLocation(rel.Image, child);
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 9
0
 // TODO: this is wasteful in terms of creating TsurgeonPatternRoot.
 // Should separate that out into another production
 public TsurgeonPatternRoot Root()
 {
     /*@bgen(jjtree) Root */
     var jjtn000 = new SimpleNode(JjtRoot);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     List<TsurgeonPattern> results = null;
     try
     {
         TsurgeonPattern result;
         switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
         {
             case Delete:
             case Prune:
             case Relabel:
             case Excise:
             case Insert:
             case Move:
             case Replace:
             case CreateSubtree:
             case Adjoin:
             case AdjoinToHead:
             case AdjoinToFoot:
             case Coindex:
             {
                 result = Operation();
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return new TsurgeonPatternRoot(result);
             }
             default:
                 jj_la1[1] = jj_gen;
                 Token name;
                 if (Jj_2_1(2))
                 {
                     Jj_consume_token(If);
                     Jj_consume_token(Exists);
                     name = Jj_consume_token(Name);
                     result = Root();
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new TsurgeonPatternRoot(new IfExistsNode(name.Image, false, result.children));
                 }
                 else if (Jj_2_2(2))
                 {
                     Jj_consume_token(If);
                     Jj_consume_token(Not);
                     Jj_consume_token(Exists);
                     name = Jj_consume_token(Name);
                     result = Root();
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new TsurgeonPatternRoot(new IfExistsNode(name.Image, true, result.children));
                 }
                 else
                 {
                     switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
                     {
                         case OpenBracket:
                         {
                             //label_1:
                             while (true)
                             {
                                 Jj_consume_token(OpenBracket);
                                 result = Root();
                                 Jj_consume_token(CloseBracket);
                                 if (results == null)
                                 {
                                     results = new List<TsurgeonPattern>();
                                 }
                                 foreach (TsurgeonPattern child in result.children)
                                 {
                                     results.Add(child);
                                 }
                                 switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
                                 {
                                     case OpenBracket:
                                     {
                                         ;
                                         break;
                                     }
                                     default:
                                         jj_la1[0] = jj_gen;
                                         goto post_label_1;
                                 }
                             }
                             post_label_1:
                             {
                                 JjTree.CloseNodeScope(jjtn000, true);
                                 jjtc000 = false;
                                 var array = new TsurgeonPattern[results.Count];
                                 return new TsurgeonPatternRoot(results.ToArray());
                             }
                         }
                         default:
                             jj_la1[2] = jj_gen;
                             Jj_consume_token(-1);
                             throw new ParseException();
                     }
                 }
         }
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }
Ejemplo n.º 10
0
 public TsurgeonPattern Operation()
 {
     /*@bgen(jjtree) Operation */
     var jjtn000 = new SimpleNode(JjtOperation);
     bool jjtc000 = true;
     JjTree.OpenNodeScope(jjtn000);
     Token operatorToken;
     Token hashInt;
     try
     {
         TsurgeonPattern child1;
         TsurgeonPattern child2 = null;
         List<TsurgeonPattern> nodeSelections = null;
         switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
         {
             case Delete:
             {
                 operatorToken = Jj_consume_token(Delete);
                 nodeSelections = NodeSelectionList(new List<TsurgeonPattern>());
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return new DeleteNode(nodeSelections);
             }
             case Prune:
             {
                 operatorToken = Jj_consume_token(Prune);
                 nodeSelections = NodeSelectionList(new List<TsurgeonPattern>());
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return new PruneNode(nodeSelections);
             }
             case Excise:
             {
                 operatorToken = Jj_consume_token(Excise);
                 child1 = NodeSelection();
                 child2 = NodeSelection();
                 JjTree.CloseNodeScope(jjtn000, true);
                 jjtc000 = false;
                 return new ExciseNode(child1, child2);
             }
             default:
                 jj_la1[3] = jj_gen;
                 Token newLabel = null;
                 if (Jj_2_3(3))
                 {
                     operatorToken = Jj_consume_token(Relabel);
                     child1 = NodeSelection();
                     newLabel = Jj_consume_token(Identifier);
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new RelabelNode(child1, newLabel.Image);
                 }
                 else if (Jj_2_4(3))
                 {
                     operatorToken = Jj_consume_token(Relabel);
                     child1 = NodeSelection();
                     newLabel = Jj_consume_token(Quotex);
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new RelabelNode(child1, newLabel.Image);
                 }
                 else if (Jj_2_5(3))
                 {
                     operatorToken = Jj_consume_token(Relabel);
                     child1 = NodeSelection();
                     Token regex = Jj_consume_token(Regex);
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new RelabelNode(child1, regex.Image);
                 }
                 else if (Jj_2_6(3))
                 {
                     operatorToken = Jj_consume_token(Relabel);
                     child1 = NodeSelection();
                     newLabel = Jj_consume_token(GeneralRelabel);
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new RelabelNode(child1, newLabel.Image);
                 }
                 else if (Jj_2_7(3))
                 {
                     operatorToken = Jj_consume_token(Replace);
                     child1 = NodeSelection();
                     child2 = NodeSelection();
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new ReplaceNode(child1, new[] {child2});
                 }
                 else if (Jj_2_8(3))
                 {
                     operatorToken = Jj_consume_token(Replace);
                     child1 = NodeSelection();
                     List<AuxiliaryTree> treeList = TreeList(false);
                     JjTree.CloseNodeScope(jjtn000, true);
                     jjtc000 = false;
                     return new ReplaceNode(child1, treeList);
                 }
                 else
                 {
                     TreeLocation loc = null;
                     switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
                     {
                         case Move:
                         {
                             operatorToken = Jj_consume_token(Move);
                             child1 = NodeSelection();
                             loc = Location();
                             JjTree.CloseNodeScope(jjtn000, true);
                             jjtc000 = false;
                             return new MoveNode(child1, loc);
                         }
                         default:
                             jj_la1[4] = jj_gen;
                             if (Jj_2_9(3))
                             {
                                 operatorToken = Jj_consume_token(Insert);
                                 child1 = NodeSelection();
                                 loc = Location();
                                 JjTree.CloseNodeScope(jjtn000, true);
                                 jjtc000 = false;
                                 return new InsertNode(child1, loc);
                             }
                             else
                             {
                                 AuxiliaryTree tree = null;
                                 if (Jj_2_10(3))
                                 {
                                     operatorToken = Jj_consume_token(Insert);
                                     tree = TreeRoot(false);
                                     loc = Location();
                                     JjTree.CloseNodeScope(jjtn000, true);
                                     jjtc000 = false;
                                     return new InsertNode(tree, loc);
                                 }
                                 else
                                 {
                                     switch ((jj_ntk == -1) ? Jj_ntk_f() : jj_ntk)
                                     {
                                         case CreateSubtree:
                                         {
                                             operatorToken = Jj_consume_token(CreateSubtree);
                                             tree = TreeRoot(false);
                                             nodeSelections = NodeSelectionList(new List<TsurgeonPattern>());
                                             JjTree.CloseNodeScope(jjtn000, true);
                                             jjtc000 = false;
                                             if (nodeSelections.Count == 1)
                                             {
                                                 return new CreateSubtreeNode(nodeSelections[0], tree);
                                             }
                                             else if (nodeSelections.Count == 2)
                                             {
                                                 return new CreateSubtreeNode(nodeSelections[0],
                                                     nodeSelections[1], tree);
                                             }
                                             else
                                             {
                                                 throw new ParseException(
                                                     "Illegal number of nodes given to createSubtree (" +
                                                     nodeSelections.Count + ")");
                                             }
                                         }
                                         case Adjoin:
                                         {
                                             operatorToken = Jj_consume_token(Adjoin);
                                             tree = TreeRoot(true);
                                             child1 = NodeSelection();
                                             JjTree.CloseNodeScope(jjtn000, true);
                                             jjtc000 = false;
                                             return new AdjoinNode(tree, child1);
                                         }
                                         case AdjoinToHead:
                                         {
                                             operatorToken = Jj_consume_token(AdjoinToHead);
                                             tree = TreeRoot(true);
                                             child1 = NodeSelection();
                                             JjTree.CloseNodeScope(jjtn000, true);
                                             jjtc000 = false;
                                             return new AdjoinToHeadNode(tree, child1);
                                         }
                                         case AdjoinToFoot:
                                         {
                                             operatorToken = Jj_consume_token(AdjoinToFoot);
                                             tree = TreeRoot(true);
                                             child1 = NodeSelection();
                                             JjTree.CloseNodeScope(jjtn000, true);
                                             jjtc000 = false;
                                             return new AdjoinToFootNode(tree, child1);
                                         }
                                         case Coindex:
                                         {
                                             operatorToken = Jj_consume_token(Coindex);
                                             nodeSelections = NodeSelectionList(new List<TsurgeonPattern>());
                                             JjTree.CloseNodeScope(jjtn000, true);
                                             jjtc000 = false;
                                             return new CoindexNodes(nodeSelections.ToArray());
                                         }
                                         default:
                                             jj_la1[5] = jj_gen;
                                             Jj_consume_token(-1);
                                             throw new ParseException();
                                     }
                                 }
                             }
                     }
                 }
         }
     }
     catch (Exception jjte000)
     {
         if (jjtc000)
         {
             JjTree.ClearNodeScope(jjtn000);
             jjtc000 = false;
         }
         else
         {
             JjTree.PopNode();
         }
         if (jjte000 is SystemException)
         {
             throw jjte000;
         }
         if (jjte000 is ParseException)
         {
             throw jjte000;
         }
         throw jjte000;
     }
     finally
     {
         if (jjtc000)
         {
             JjTree.CloseNodeScope(jjtn000, true);
         }
     }
 }