public override Node VisitTypeExpr(ML4DParser.TypeExprContext context) { ExpressionNode node; switch (context.value.Type) { case ML4DLexer.INUM: node = new IntNode(int.Parse(context.value.Text)); break; case ML4DLexer.FNUM: node = new DoubleNode(double.Parse(context.value.Text, CultureInfo.InvariantCulture)); break; case ML4DLexer.BOOLVAL: node = new BoolNode(bool.Parse(context.value.Text)); break; case ML4DLexer.ID: node = new IDNode(context.value.Text); break; default: throw new NotSupportedException($"The value {context.value.Text}, is not allowed."); } return(node); }
public void TestAverageValue() { var root = new IntNode(42); var neighbor = new IntNode(21); // Single root.AddDirectedEdge(neighbor, 10); Assert.AreEqual(10, root.Cost(neighbor)); // Flood for (int i = 0; i < root.QueueSize; i++) { root.UpdateDirectedEdge(neighbor, 20); } Assert.AreEqual(20, root.Cost(neighbor)); // Suite for (int i = 1; i <= root.QueueSize; i++) { root.UpdateDirectedEdge(neighbor, i); } var Σ = (1 + root.QueueSize) / 2; Assert.AreEqual(Σ, root.Cost(neighbor)); }
public Node SimpleType() { switch (CurrentToken) { case TokenCategory.INT: var intType = new IntNode() { AnchorToken = Expect(TokenCategory.INT) }; return(intType); case TokenCategory.STR: var strType = new StrNode() { AnchorToken = Expect(TokenCategory.STR) }; return(strType); case TokenCategory.BOOL: var boolType = new BoolNode() { AnchorToken = Expect(TokenCategory.BOOL) }; return(boolType); default: throw new SyntaxError(firstOfDeclaration, tokenStream.Current); } }
public static IntNode AddNode(IntNode pos, int a)//function for add a organ in to the list { IntNode c = new IntNode(a, pos.GetNext()); pos.SetNext(c); return(pos); }
public void Run() { if (_sortInsert == null) { throw new NullReferenceException("Sort Insert cannot be null"); } Console.WriteLine("Running Sort Insert passing the following Values in the order presented"); Console.WriteLine("5 10 7 3 1 9"); Console.WriteLine(); var newNode = new IntNode(5); _sortInsert.SortedInsert(newNode); newNode = new IntNode(10); _sortInsert.SortedInsert(newNode); newNode = new IntNode(7); _sortInsert.SortedInsert(newNode); newNode = new IntNode(3); _sortInsert.SortedInsert(newNode); newNode = new IntNode(1); _sortInsert.SortedInsert(newNode); newNode = new IntNode(9); _sortInsert.SortedInsert(newNode); var temp = _sortInsert.Head; while (temp != null) { Console.Write(temp.Data + " "); temp = temp.Next; } }
public override IEnumerable <AssociativeNode> BuildOutputAst(List <AssociativeNode> inputAstNodes) { // Set default values. if (!HasConnectedInput(0)) { inputAstNodes[0] = new IntNode(0); } if (!HasConnectedInput(1)) { inputAstNodes[1] = new IntNode(10); } if (!HasConnectedInput(2)) { inputAstNodes[2] = new IntNode(1); } return(new[] { AstFactory.BuildAssignment( GetAstIdentifierForOutputIndex(0), new RangeExprNode { From = inputAstNodes[0], To = inputAstNodes[1], Step = inputAstNodes[2], HasRangeAmountOperator = true, StepOperator = ProtoCore.DSASM.RangeStepOperator.StepSize }) }); }
private object DecodeScalar(byte[] content) { DictNode rootNode = (DictNode)BEncode.Decode(content); IntNode codeNode = (IntNode)rootNode["code"]; switch (codeNode.Value) { case 1: case 2: throw new DbProxyException("数据集收到的数据包出错!"); case 3: DictNode itemNode = (DictNode)rootNode["item"]; string typeName = ((BytesNode)itemNode["type"]).StringText; string value = ((BytesNode)itemNode["value"]).StringText; if (rootNode.ContainsKey("parmlist")) { HandleParmsNode((rootNode)["parmlist"]); } return(NodeEncoder.GetObject(typeName, value)); case 4: BytesNode messageNode = (BytesNode)rootNode["message"]; throw new DbProxyException(messageNode.StringText); case 5: throw new DbProxyException("校验出错!"); default: throw new DbProxyException(string.Format("无效消息代码:{0}!", codeNode.Value)); } }
private static void InsertNode(IntNode root, int value) { if (root.Data >= value) { if (root.LeftChild == null) { var newNode = new IntNode(value); root.LeftChild = newNode; } else { InsertNode(root.LeftChild, value); } } else { if (root.RightChild == null) { var newNode = new IntNode(value); root.RightChild = newNode; } else { InsertNode(root.RightChild, value); } } }
/// <summary> /// Places the new node inside the head in ascending order /// </summary> /// <param name="newNode"></param> public void SortedInsert(IntNode newNode) { //If there is no data or the data in the newNode is less than the current heads Data if (Head == null || Head.Data >= newNode.Data) { //Make the current newNode next node the head since the value is less newNode.Next = Head; //The newNode is now the Head of the List Head = newNode; //return void to break execution return; } //Assign currentNode Head's reference (since it's on the heap) var currentNode = Head; //While the current node has a node next to it //And if that next nodes data is less than this new node while (currentNode.Next != null && currentNode.Next.Data < newNode.Data) { //Shift the current node down until the newNode is less than the next node or it's at the end //Assign Current node the next objects reference currentNode = currentNode.Next; } //After the while loop the next node should either be null or bigger then the new nodes data newNode.Next = currentNode.Next; //Assign the current node's next to the new node, which will affect the object contained in the head since //It has a reference to the same object currentNode.Next = newNode; }
void num(out Node node) { node = null; String localvalue = String.Empty; if (la.kind == 38) { Get(); localvalue = "-"; } if (la.kind == 2) { Get(); node = new IntNode() { value = localvalue + t.val }; } else if (la.kind == 3) { Get(); node = new DoubleNode() { value = localvalue + t.val }; } else { SynErr(67); } }
public void DisconnectedComponents() { var graph = new IntGraph(); var nodes = new IntNode[5]; for (int i = 0; i < nodes.Length; i++) { nodes[i] = graph.AddNode(i); } nodes[0].ConnectWith(nodes[2]); nodes[2].ConnectWith(nodes[1]); nodes[1].ConnectWith(nodes[0]); nodes[3].ConnectWith(nodes[4]); nodes[4].ConnectWith(nodes[3]); var components = graph.FindStronglyConnectedComponents(); Assert.Equal(2, components.Count); Assert.Contains(new HashSet <INode> { nodes[0], nodes[1], nodes[2] }, components); Assert.Contains(new HashSet <INode> { nodes[3], nodes[4] }, components); }
//// CHRIS' SUGGESTION: //// DO THIS INLINE //private static IntNode GetRightHalfHead(IntNode nodeAfterReversedPart, int nodeListLength) //{ // if (nodeListLength % 2 == 0) // // When n is even, start comparing at the two middlemost nodes // return nodeAfterReversedPart; // // When n is odd, start comparing at the nodes to the left and right of // // the middlemost node // return nodeAfterReversedPart.Next; //} private static bool IntNodeListsDataAreEqual(IntNode leftHead, IntNode rightHead) { var leftComp = leftHead; var rightComp = rightHead; // When changed design to Chris' suggestion of reversing the first half of the list in place // this means that there is no null "at the end of" the elements that we are comparing at the end // of the list. Makes it not a great way to decide when to stop // Could look for the null at the end of the collection, or do 1/2 n comparisons // This helper doesn't know about 1/2 n, so let's stop when we reach the null at the end of the // list while (rightComp != null) { //Console.WriteLine($"leftComp.Data == {leftComp.Data}"); //Console.WriteLine($"rightComp.Data == {rightComp.Data}"); //Console.WriteLine("\n"); if (leftComp.Data != rightComp.Data) { return(false); } leftComp = leftComp.Next; rightComp = rightComp.Next; } return(true); }
public void TestEncodeInteger1() { //Test1测试用例为4 IntNode ih1 = new IntNode(4); string source1 = BEncode.StringEncode(ih1); Assert.AreEqual(source1, "i4e"); //Test2测试用例为1234567890 IntNode ih2 = new IntNode(1234567890); string source2 = BEncode.StringEncode(ih2); Assert.AreEqual(source2, "i1234567890e"); //Test3测试用例为0 IntNode ih3 = new IntNode(0); string source3 = BEncode.StringEncode(ih3); Assert.AreEqual(source3, "i0e"); //Test4测试用例为-10 IntNode ih4 = new IntNode(-10); string source4 = BEncode.StringEncode(ih4); Assert.AreEqual(source4, "i-10e"); }
public void TestAPI() { var root = new IntNode(42); Assert.AreEqual(42, root.Content); Assert.AreEqual(0, root.NeighborsCount); Assert.IsNull(root.Find(42)); Assert.IsFalse(root.HasNeighbor(root)); var neighbor = new IntNode(21); root.AddDirectedEdge(neighbor); Assert.AreEqual(1, root.NeighborsCount); Assert.IsTrue(root.HasNeighbor(neighbor)); var found = root.Find(21); Assert.AreSame(found, neighbor); var neighbors = ">"; root.ForEachNeighbor(node => { neighbors += $" {node.Content.ToString()}"; }); Assert.AreEqual("> 21", neighbors); root.RemoveDirectedEdge(neighbor); Assert.AreEqual(0, root.NeighborsCount); Assert.IsFalse(root.HasNeighbor(neighbor)); Assert.IsNull(root.Find(21)); }
public void TestIntCodec() { TestIntNode(0); TestIntNode(1); TestIntNode(0x100); TestIntNode(181); TestIntNode(0x10000); TestIntNode(1573280); TestIntNode(0x1000000); TestIntNode(int.MaxValue); TestIntNode(-1, EsfType.INT32_BYTE); TestIntNode(-0xff); TestIntNode(-0xffff); TestIntNode(-0xffffff); TestIntNode(-11831522); TestIntNode(int.MinValue); IntNode testNode = new IntNode { Value = 17 }; VerifyEncodeDecode(testNode); IntNode node = new IntNode(); node.FromString("17"); assertEqual(node, testNode); }
public override IEnumerable <AssociativeNode> BuildOutputAst(List <AssociativeNode> inputAstNodes) { AssociativeNode rhs = null; if (IsPartiallyApplied) { var connectedInputs = new List <AssociativeNode>(); var functionNode = new IdentifierNode(functionName); var paramNumNode = new IntNode(1); var positionNode = AstFactory.BuildExprList(connectedInputs); var arguments = AstFactory.BuildExprList(inputAstNodes); var inputParams = new List <AssociativeNode> { functionNode, paramNumNode, positionNode, arguments, AstFactory.BuildBooleanNode(true) }; rhs = AstFactory.BuildFunctionCall("__CreateFunctionObject", inputParams); } else { rhs = AstFactory.BuildFunctionCall(functionName, inputAstNodes); } return(new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs) }); }
public void Visit(IntNode node) { if (!scope.IsDefinedType("Int", out node.StaticType)) { errors.Add(SemanticError.NotDeclaredType(new TypeNode(node.Line, node.Column, "Int"))); } }
public static void AddNodeA(IntNode a, int x) { bool flag = true; while (a.GetNext() != null) { if (x > a.GetInfo() && x <= a.GetNext().GetInfo()) { IntNode c = new IntNode(x, a.GetNext()); a.SetNext(c); a = c; flag = false; } else if (x <= a.GetInfo() && flag) { IntNode c = new IntNode(a.GetInfo(), a.GetNext()); a.SetInfo(x); a.SetNext(c); flag = false; } a = a.GetNext(); } if (x > a.GetInfo() && flag) { IntNode p = new IntNode(x); a.SetNext(p); } }
private int DecodeNonQuery(byte[] content) { DictNode rootNode = (DictNode)BEncode.Decode(content); IntNode codeNode = (IntNode)rootNode["code"]; switch (codeNode.Value) { case 1: IntNode lineNode = (IntNode)rootNode["linenum"]; if (rootNode.ContainsKey("parmlist")) { HandleParmsNode((rootNode)["parmlist"]); } return(lineNode.Value); case 2: case 3: throw new DbProxyException("数据集收到的数据包出错!"); case 4: BytesNode messageNode = (BytesNode)rootNode["message"]; throw new DbProxyException(messageNode.StringText); case 5: throw new DbProxyException("校验出错!"); default: throw new DbProxyException(string.Format("无效消息代码:{0}!", codeNode.Value)); } }
public void Pop() { if (!IsEmpty()) { head = head.Last; brel--; } }
public void Visit(IntNode node) { Code.Add(new AssignConstToVarCodeLine(VariableManager.PeekVariableCounter(), node.Value)); if (object_return_type) { Code.Add(new AssignStrToVarCodeLine(return_type, "Int")); } }
public static IntNode DelNode(IntNode pos)// function for delete a organ in the list { IntNode a = pos.GetNext(); pos.SetNext(pos.GetNext().GetNext()); a.SetNext(null); return(a); }
public void Visit(IntNode node) { IC.Add(new AssignmentConstantToVariable(VariableManager.PeekVariableCounter(), node.Value)); if (special_object_return_type) { SetReturnType("Int"); } }
private static void Median(string[] a, int[] x) { var currentSize = 0; var NumList = new List <int>(); IntNode root = null; Tuple <IntNode, bool> nodeResult = new Tuple <IntNode, bool>(root, true); for (int i = 0; i < a.Count(); i++) { switch (a[i]) { case "a": if (root == null) { root = new IntNode(x[i]); } else { InsertNode(root, x[i]); } nodeResult = new Tuple <IntNode, bool>(root, true); currentSize++; break; case "r": if (i == 0 || root == null) { Console.WriteLine("Wrong!"); continue; } nodeResult = RemoveNode(root, x[i]); root = nodeResult.Item1; if (nodeResult.Item2) { currentSize--; } break; } if (currentSize == 0 || !nodeResult.Item2) { Console.WriteLine("Wrong!"); continue; } var result1 = Traverse(root); var result = CustomTraverse(root, currentSize / 2 + 1); if (currentSize % 2 == 0) { //Console.WriteLine(decimal.Divide((long)result[currentSize / 2 - 1] + (long)result[currentSize / 2], 2)); Console.WriteLine(decimal.Divide((long)result[result.Count - 1] + (long)result[result.Count - 2], 2)); } else { //Console.WriteLine(result[currentSize / 2]); Console.WriteLine(result[result.Count - 1]); } } }
public void TestSingleValue() { var root = new IntNode(42); var neighbor = new IntNode(21); root.AddDirectedEdge(neighbor, 10); Assert.AreEqual(10, root.Cost(neighbor)); }
public void Push(int value) { if (!IsFull()) { IntNode newintnode = new IntNode(value); newintnode.Last = head; head = newintnode; brel++; } }
public void TestCountDifferentNeighbor() { var root = new IntNode(0); for (int i = 1; i <= 10; i++) { var neighbor = new IntNode(i); root.AddDirectedEdge(neighbor); } Assert.AreEqual(10, root.NeighborsCount); }
public static int LenNode(IntNode allList)// this function return the length node { int count = 0; while (allList.GetNext() != null) { allList = allList.GetNext(); count++; } return(count); }
public void TestIdentityNeighbor() { var root = new IntNode(0); for (int i = 1; i <= 10; i++) { var neighbor = new IntNode(i); root.AddDirectedEdge(neighbor); Assert.True(root.HasNeighbor(neighbor)); } }
public void TestNeighborByValue() { var root = new IntNode(0); for (int i = 1; i <= 10; i++) { var neighbor = new IntNode(i); root.AddDirectedEdge(neighbor); Assert.True(root.HasNeighbor(root.Find(i))); } }
public static BinaryTree<ushort> GetHuffmanTree(byte[] data, int index, int count) { IntNode[] rawTree = new IntNode[count]; unsafe { fixed(IntNode* ptr = rawTree) { Marshal.Copy(data, index, (IntPtr)ptr, count * sizeof(IntNode)); } } int topIndex = count - 1;//Make into a parameter? return MakeTree(topIndex, rawTree); }
private static BinaryTree<ushort> MakeTree(int headIndex, IntNode[] nodes) { IntNode head = nodes[headIndex]; if (head.IsLeaf) { return new BinaryTree<ushort>(head.Value); } else { return new BinaryTree<ushort>( MakeTree(head.Left, nodes), MakeTree(head.Right, nodes) ); } }
public void GenericClassTest() { // test Node<T> Node<char> head = new Node<char>('C'); head = new Node<char>('b', head); head = new Node<char>('a', head); Console.WriteLine(head.ToString()); // test IntNode. IntNode head2 = new IntNode(3); head2 = new IntNode(2, head2); head2 = new IntNode(1, head2); Console.WriteLine(head2.ToString()); bool sameType = (typeof(Node<int>) == typeof(IntNode)); Console.WriteLine(sameType); sameType = (typeof(Node<DateTime>) == typeof(DateTimeNode)); Console.WriteLine(sameType); }
// throws RecognitionException [1] // $ANTLR end "expr_dm" // $ANTLR start "expr" // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:167:1: expr returns [TigerNode exp] : ( STR | INT | id1= ID ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) | MENOS expr_or | BREAK | NIL | PAR_A exprseq PAR_C idp9= ptocor | IF idif= expr_or THEN idthen= expr_or ifthenelse | WHILE idexp3= expr_or DO iddo= expr_or | FOR id5= ID ASIG idasig= expr_or TO idto= expr_or DO iddo= expr_or | LET decllist IN exprseq END ); public TigerNode expr() { TigerNode exp = null; IToken id1 = null; IToken id5 = null; IToken STR14 = null; IToken INT15 = null; IToken MENOS19 = null; IToken BREAK20 = null; IToken NIL21 = null; IToken PAR_A23 = null; IToken IF25 = null; IToken WHILE26 = null; IToken FOR27 = null; IToken LET30 = null; TigerNode idexp1 = null; TigerNode idexp = null; List<Access> idp4 = null; AssingmentNode ida1 = null; List<Access> idp1 = null; List<Access> idp3 = null; List<Access> idp9 = null; TigerNode idif = null; TigerNode idthen = null; TigerNode idexp3 = null; TigerNode iddo = null; TigerNode idasig = null; TigerNode idto = null; tiger_grammarParser.fieldlist_return fieldlist16 = null; List<TigerNode> exprlist17 = null; TigerNode expr_or18 = null; List<TigerNode> exprseq22 = null; TigerNode ifthenelse24 = null; List<DeclarationNode> decllist28 = null; List<TigerNode> exprseq29 = null; try { // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:167:30: ( STR | INT | id1= ID ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) | MENOS expr_or | BREAK | NIL | PAR_A exprseq PAR_C idp9= ptocor | IF idif= expr_or THEN idthen= expr_or ifthenelse | WHILE idexp3= expr_or DO iddo= expr_or | FOR id5= ID ASIG idasig= expr_or TO idto= expr_or DO iddo= expr_or | LET decllist IN exprseq END ) int alt8 = 11; switch ( input.LA(1) ) { case STR: { alt8 = 1; } break; case INT: { alt8 = 2; } break; case ID: { alt8 = 3; } break; case MENOS: { alt8 = 4; } break; case BREAK: { alt8 = 5; } break; case NIL: { alt8 = 6; } break; case PAR_A: { alt8 = 7; } break; case IF: { alt8 = 8; } break; case WHILE: { alt8 = 9; } break; case FOR: { alt8 = 10; } break; case LET: { alt8 = 11; } break; default: if ( state.backtracking > 0 ) {state.failed = true; return exp;} NoViableAltException nvae_d8s0 = new NoViableAltException("", 8, 0, input); throw nvae_d8s0; } switch (alt8) { case 1 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:168:13: STR { STR14=(IToken)Match(input,STR,FOLLOW_STR_in_expr1153); if (state.failed) return exp; if ( (state.backtracking==0) ) { string s = STR14.Text; string[] t = s.Split('"'); exp = new StringNode(t[1]); exp.Col=STR14.CharPositionInLine; exp.Row=STR14.Line; } } break; case 2 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:175:13: INT { INT15=(IToken)Match(input,INT,FOLLOW_INT_in_expr1172); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new IntNode(int.Parse(INT15.Text)); exp.Col=INT15.CharPositionInLine; exp.Row=INT15.Line; } } break; case 3 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:180:13: id1= ID ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) { id1=(IToken)Match(input,ID,FOLLOW_ID_in_expr1204); if (state.failed) return exp; // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:180:20: ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) int alt7 = 4; alt7 = dfa7.Predict(input); switch (alt7) { case 1 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:181:24: ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or { Match(input,COR_A,FOLLOW_COR_A_in_expr1245); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1249); idexp1 = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,COR_C,FOLLOW_COR_C_in_expr1251); if (state.failed) return exp; Match(input,OF,FOLLOW_OF_in_expr1253); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1257); idexp = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new ArrayNode(id1.Text,idexp1,idexp); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } break; case 2 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:186:24: idp4= ptocor ida1= asig { PushFollow(FOLLOW_ptocor_in_expr1318); idp4 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; PushFollow(FOLLOW_asig_in_expr1322); ida1 = asig(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp4.Count > 0 && ida1 !=null) { exp = ida1; ((AssingmentNode)exp).LeftExpr = new ListLValueNode(new VariableNode(id1.Text),idp4); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else if(idp4.Count > 0) { exp = new ListLValueNode(new VariableNode(id1.Text),idp4); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else if(ida1 !=null) { exp = ida1; ((AssingmentNode)exp).LeftExpr = new VariableNode(id1.Text); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else { exp = new VariableNode(id1.Text); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } } break; case 3 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:211:23: LLAV_A fieldlist LLAV_C idp1= ptocor { Match(input,LLAV_A,FOLLOW_LLAV_A_in_expr1349); if (state.failed) return exp; PushFollow(FOLLOW_fieldlist_in_expr1351); fieldlist16 = fieldlist(); state.followingStackPointer--; if (state.failed) return exp; Match(input,LLAV_C,FOLLOW_LLAV_C_in_expr1353); if (state.failed) return exp; PushFollow(FOLLOW_ptocor_in_expr1357); idp1 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp1.Count > 0) { exp = new ListLValueNode(new RecordNode(id1.Text, ((fieldlist16 != null) ? fieldlist16.listid : null), ((fieldlist16 != null) ? fieldlist16.listexp : null)),idp1); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else{ exp = new RecordNode(id1.Text, ((fieldlist16 != null) ? fieldlist16.listid : null), ((fieldlist16 != null) ? fieldlist16.listexp : null)); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } } break; case 4 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:221:22: PAR_A exprlist PAR_C idp3= ptocor { Match(input,PAR_A,FOLLOW_PAR_A_in_expr1382); if (state.failed) return exp; PushFollow(FOLLOW_exprlist_in_expr1384); exprlist17 = exprlist(); state.followingStackPointer--; if (state.failed) return exp; Match(input,PAR_C,FOLLOW_PAR_C_in_expr1386); if (state.failed) return exp; PushFollow(FOLLOW_ptocor_in_expr1390); idp3 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp3.Count > 0) { exp = new ListLValueNode(new CallFunctionNode(id1.Text, exprlist17),idp3); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else{ exp = new CallFunctionNode(id1.Text, exprlist17); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } } break; } } break; case 4 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:233:13: MENOS expr_or { MENOS19=(IToken)Match(input,MENOS,FOLLOW_MENOS_in_expr1446); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1448); expr_or18 = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new MinusUnaryNode(expr_or18); exp.Col=MENOS19.CharPositionInLine; exp.Row = MENOS19.Line; } } break; case 5 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:239:13: BREAK { BREAK20=(IToken)Match(input,BREAK,FOLLOW_BREAK_in_expr1478); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new BreakNode(); exp.Col=BREAK20.CharPositionInLine; exp.Row = BREAK20.Line; } } break; case 6 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:245:13: NIL { NIL21=(IToken)Match(input,NIL,FOLLOW_NIL_in_expr1508); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new NilNode(); exp.Col=NIL21.CharPositionInLine; exp.Row = NIL21.Line; } } break; case 7 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:251:13: PAR_A exprseq PAR_C idp9= ptocor { PAR_A23=(IToken)Match(input,PAR_A,FOLLOW_PAR_A_in_expr1538); if (state.failed) return exp; PushFollow(FOLLOW_exprseq_in_expr1540); exprseq22 = exprseq(); state.followingStackPointer--; if (state.failed) return exp; Match(input,PAR_C,FOLLOW_PAR_C_in_expr1542); if (state.failed) return exp; PushFollow(FOLLOW_ptocor_in_expr1546); idp9 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp9.Count > 0) { exp = new ListLValueNode(new ExprSeqNode(exprseq22),idp9); exp.Col=PAR_A23.CharPositionInLine; exp.Row = PAR_A23.Line; } else{ exp = new ExprSeqNode(exprseq22); exp.Col=PAR_A23.CharPositionInLine; exp.Row = PAR_A23.Line; } } } break; case 8 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:265:13: IF idif= expr_or THEN idthen= expr_or ifthenelse { IF25=(IToken)Match(input,IF,FOLLOW_IF_in_expr1577); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1581); idif = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,THEN,FOLLOW_THEN_in_expr1583); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1587); idthen = expr_or(); state.followingStackPointer--; if (state.failed) return exp; PushFollow(FOLLOW_ifthenelse_in_expr1589); ifthenelse24 = ifthenelse(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(ifthenelse24!=null) { exp = new IfThenElseNode(idif, idthen, ifthenelse24); } else{ exp = new IfThenNode(idif, idthen); } exp.Col = IF25.CharPositionInLine; exp.Row = IF25.Line; } } break; case 9 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:278:13: WHILE idexp3= expr_or DO iddo= expr_or { WHILE26=(IToken)Match(input,WHILE,FOLLOW_WHILE_in_expr1627); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1631); idexp3 = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,DO,FOLLOW_DO_in_expr1633); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1637); iddo = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new WhileNode(idexp3,iddo); exp.Col = WHILE26.CharPositionInLine; exp.Row = WHILE26.Line; } } break; case 10 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:283:13: FOR id5= ID ASIG idasig= expr_or TO idto= expr_or DO iddo= expr_or { FOR27=(IToken)Match(input,FOR,FOLLOW_FOR_in_expr1665); if (state.failed) return exp; id5=(IToken)Match(input,ID,FOLLOW_ID_in_expr1669); if (state.failed) return exp; Match(input,ASIG,FOLLOW_ASIG_in_expr1671); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1675); idasig = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,TO,FOLLOW_TO_in_expr1677); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1681); idto = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,DO,FOLLOW_DO_in_expr1683); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1687); iddo = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new ForNode(id5.Text,idasig,idto,iddo); exp.Col = FOR27.CharPositionInLine; exp.Row = FOR27.Line; } } break; case 11 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:289:13: LET decllist IN exprseq END { LET30=(IToken)Match(input,LET,FOLLOW_LET_in_expr1716); if (state.failed) return exp; PushFollow(FOLLOW_decllist_in_expr1718); decllist28 = decllist(); state.followingStackPointer--; if (state.failed) return exp; Match(input,IN,FOLLOW_IN_in_expr1720); if (state.failed) return exp; PushFollow(FOLLOW_exprseq_in_expr1722); exprseq29 = exprseq(); state.followingStackPointer--; if (state.failed) return exp; Match(input,END,FOLLOW_END_in_expr1725); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new LetNode(decllist28,exprseq29); exp.Col= LET30.CharPositionInLine; exp.Row = LET30.Line; } } break; } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { } return exp; }
public static Node NewInt(int i) { IntNode node = new IntNode(i); return node; }
public IntNode(IntNode rhs) : base(rhs) { Value = rhs.Value; }