void Start() { ds = GameObject.Find("InitDesign").GetComponent <DesignScript> (); m_camera = GameObject.Find("Main Camera").GetComponent <Camera> (); players = new Player[2]; players[0] = new Player(ds.warplan, true, this); players[1] = new Player(ds.warplan, false, this); units = new List <Unit>(); projectiles = new List <Projectile>(); }
// Use this for initialization void Start() { ds = GameObject.Find("InitDesign").GetComponent <DesignScript> (); image = GetComponent <Image> (); }
void Assoc_ExternalLibraryReference(ref DesignScript.Parser.Associative.FunctionDefinitionNode f) { if (la.val == "(") f.libOpenBrace.SetValue(la.val, la.line, la.col); Expect(9); Expect(4); DesignScript.Parser.Associative.StringNode libName = new DesignScript.Parser.Associative.StringNode(); if (t.kind == _textstring) { libName.value = t.val; libName.Line = t.line; libName.Col = t.col; } else Get(); if (la.val == ")" && f.libOpenBrace.Value != null) f.libCloseBrace.SetValue(la.val, la.line, la.col); else if (la.val != ")") f.libOpenBrace.Value = null; f.libName = libName; Expect(10); }
void Assoc_BitUnaryExpression(out DesignScript.Parser.Associative.UnaryExpressionNode node) { DesignScript.Parser.Associative.UnaryExpressionNode unary = new DesignScript.Parser.Associative.UnaryExpressionNode(); DesignScript.Parser.Associative.IDEHelpNode IDEop = unary.op; Assoc_unaryop(out IDEop); Node exprNode = null; Assoc_Factor(out exprNode); unary.Expression = exprNode; unary.op = IDEop; node = unary; }
void Assoc_BinaryOps(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { if (la.kind == 12 || la.kind == 57) { Assoc_AddOp(ref IDEop); } else if (la.kind == 58 || la.kind == 59 || la.kind == 60) { Assoc_MulOp(ref IDEop); } else if (StartOf(14)) { Assoc_ComparisonOp(ref IDEop); } else if (la.kind == 63 || la.kind == 64) { Assoc_LogicalOp(ref IDEop); } else SynErr(92); }
void Assoc_arrayIndices(out DesignScript.Parser.Associative.ArrayNode array) { array = new DesignScript.Parser.Associative.ArrayNode(); Node exp = null; if (la.val == "[") array.openBracket.SetValue(la.val, la.line, la.col); array.Line = la.line; array.Col = la.col; Expect(7); if (StartOf(9)) { Assoc_Expression(out exp); } array.Expr = exp; array.Type = null; if (la.val == "]" && array.openBracket.Value != null) array.closeBracket.SetValue(la.val, la.line, la.col); else if (la.val != "]") array.openBracket.Value = null; Expect(8); while (la.kind == 7) { DesignScript.Parser.Associative.ArrayNode array2 = new DesignScript.Parser.Associative.ArrayNode(); if (la.val == "[") array2.openBracket.SetValue(la.val, la.line, la.col); array2.Line = la.line; array2.Col = la.col; Get(); exp = null; if (StartOf(9)) { Assoc_Expression(out exp); } array2.Expr = exp; array2.Type = null; if (la.val == "]" && array2.openBracket.Value != null) array2.closeBracket.SetValue(la.val, la.line, la.col); else if (la.val != "]") array2.openBracket.Value = null; array2.Type = array; array = array2; Expect(8); } }
void Assoc_Arguments(ref DesignScript.Parser.Associative.FunctionCallNode f) { if (la.val == "(") f.openParen.SetValue(la.val, la.line, la.col); Expect(9); if (StartOf(9)) { Node n; Assoc_Expression(out n); f.FormalArguments.Add(n); while (WeakSeparator(52,9,10) ) { f.AddComma(t.val, t.line, t.col); Assoc_Expression(out n); f.FormalArguments.Add(n); } } if (la.val == ")" && f.openParen.Value != null) f.closeParen.SetValue(la.val, la.line, la.col); else if (la.val != ")") f.openParen.SetValue(null, 0, 0); Expect(10); }
void Associative_PostFixOp(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { if (la.kind == 66) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 67) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else SynErr(104); }
void Assoc_PatternExpression(out DesignScript.Parser.Associative.Pattern pattern) { DesignScript.Parser.Associative.Pattern p = new DesignScript.Parser.Associative.Pattern(); Expect(13); p.bitOr.SetValue(t.val, t.line, t.col); p.Line = t.line; p.Col = t.col; Node exp = null; Assoc_Expression(out exp); p.Expression = exp; pattern = p; }
void Assoc_negop(out DesignScript.Parser.Associative.IDEHelpNode op) { op = new Associative.IDEHelpNode(Associative.IDEHelpNode.NodeType.PunctuationNode); if (la.kind == 1 || la.kind == 9 || la.kind == 50) { } else if (la.kind == 12) { Get(); op.SetValue(t.val, t.line, t.col); } else SynErr(102); }
void Assoc_NegExpression(out DesignScript.Parser.Associative.UnaryExpressionNode node) { node = new Associative.UnaryExpressionNode() ; DesignScript.Parser.Associative.IDEHelpNode op = node.op; Node exprNode = null; Assoc_negop(out op); if (la.kind == 1 || la.kind == 9 || la.kind == 50) { Assoc_IdentifierList(out exprNode); } else if (la.kind == 9) { Get(); Assoc_Expression(out exprNode); Expect(10); } else SynErr(99); DesignScript.Parser.Associative.UnaryExpressionNode unary = new DesignScript.Parser.Associative.UnaryExpressionNode(); unary.op = op; unary.Expression = exprNode; node = unary; }
void Assoc_MulOp(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { if (la.kind == 58) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 59) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 60) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else SynErr(94); }
void Assoc_MethodSignature(out DesignScript.Parser.Associative.ArgumentSignatureNode argumentSign, out DesignScript.Parser.Associative.Pattern pattern, ref DesignScript.Parser.Associative.IDEHelpNode IDEName, ref DesignScript.Parser.Associative.TypeNode typeNode) { Expect(1); if (t.kind == _ident) IDEName.SetValue(t.val, t.line, t.col); if (la.kind == 54) { Assoc_TypeRestriction(out typeNode); } Assoc_ArgumentSignatureDefinition(out argumentSign); pattern = null; if (la.kind == 13) { Assoc_PatternExpression(out pattern); } }
void Assoc_LogicalOp(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { if (la.kind == 63) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 64) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else SynErr(96); }
void Imperative_TypeRestriction(out DesignScript.Parser.Imperative.TypeNode IDEType) { IDEType = new DesignScript.Parser.Imperative.TypeNode(); ExpectWeak(54, 11); if (t.val == ":") IDEType.colon.setValue(t.col, t.line, t.val); if (StartOf(12)) { if (la.kind == 37) { Get(); } else if (la.kind == 38) { Get(); } else if (la.kind == 39) { Get(); } else { Get(); } IDEType.BuildInTypeSetValue(t.val, t.line, t.col); } else if (la.kind == 1) { Get(); IDEType.UserDefinedTypeSetValue(t.val, t.line, t.col); } else SynErr(131); while (la.kind == 7) { string openBracket = null; string closeBracket = null; if (la.val == "[") openBracket = la.val; int bracket_line = la.line; int bracket_col = la.col; Get(); if (la.val == "]") closeBracket = la.val; Expect(8); if (openBracket != null && closeBracket != null) IDEType.AddBracket(openBracket, bracket_line, bracket_col, closeBracket, t.line, t.col); if (la.kind == 21) { Get(); IDEType.op.setValue(t.col, t.line, t.val); string multiDimOpenBracket = null; string multiDimCloseBracket = null; if (la.val == "[") multiDimOpenBracket = la.val; int bracket2_line = la.line; int bracket2_col = la.col; Expect(7); if (la.val == "]") multiDimCloseBracket = la.val; Expect(8); if (multiDimOpenBracket != null && multiDimCloseBracket != null) IDEType.AddMultiDimNodes(multiDimOpenBracket, bracket2_line, bracket2_col, multiDimCloseBracket, t.line, t.col); } } }
void Imperative_unaryop(out DesignScript.Parser.Imperative.IDEHelpNode op) { op = new DesignScript.Parser.Imperative.IDEHelpNode(DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode); if (la.kind == 11) { Get(); op.setValue(t.col, t.line, t.val); } else if (la.kind == 65) { Get(); op.setValue(t.col, t.line, t.val); #if ENABLE_INC_DEC_FIX } else if (la.kind == 66 || la.kind == 67) { Imperative_PostFixOp(ref op); #endif } else SynErr(121); #if ENABLE_INC_DEC_FIX #else if (la.val == "++" || la.val == "--") Get(); #endif }
void Assoc_rangeStepOperator(ref DesignScript.Parser.Associative.IDEHelpNode stepOp2) { if (la.kind == 65 || la.kind == 68) { if (la.kind == 68) { Get(); stepOp2.SetValue(t.val, t.line, t.col); } else { Get(); stepOp2.SetValue(t.val, t.line, t.col); } } }
void Assoc_AddOp(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { if (la.kind == 57) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 12) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else SynErr(93); }
void Assoc_unaryop(out DesignScript.Parser.Associative.IDEHelpNode IDEop) { IDEop = new Associative.IDEHelpNode(Associative.IDEHelpNode.NodeType.PunctuationNode); if (la.kind == 11) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 65) { Get(); IDEop.SetValue(t.val, t.line, t.col); #if ENABLE_INC_DEC_FIX } else if (la.kind == 66 || la.kind == 67) { Associative_PostFixOp(ref IDEop); #endif } else SynErr(100); #if ENABLE_INC_DEC_FIX #else if (la.val == "++" || la.val == "--") Get(); #endif }
void Assoc_ArgumentSignatureDefinition(out DesignScript.Parser.Associative.ArgumentSignatureNode argumentSign) { DesignScript.Parser.Associative.ArgumentSignatureNode argumentSignature = new DesignScript.Parser.Associative.ArgumentSignatureNode() { Line = la.line, Col = la.col }; while (!(la.kind == 0 || la.kind == 9)) {SynErr(91); Get();} if (la.val == "(") argumentSignature.openBrace.SetValue(la.val, la.line, la.col); Expect(9); if (la.kind == 1) { Node arg; Assoc_FunctionParameterDecl(out arg); argumentSignature.AddArgument(arg); while (WeakSeparator(52,13,10) ) { if (t.val == ",") argumentSignature.AddComma(t.val, t.line, t.col); Assoc_FunctionParameterDecl(out arg); argumentSignature.AddArgument(arg); } } if (la.val == ")" && argumentSignature.openBrace.Value != null) argumentSignature.closeBrace.SetValue(la.val, la.line, la.col); else if (la.val != ")") argumentSignature.openBrace.Value = null; argumentSign = argumentSignature; Expect(10); }
void Imperative_arrayIndices(out DesignScript.Parser.Imperative.ArrayNode array) { array = new DesignScript.Parser.Imperative.ArrayNode(); DesignScript.Parser.Imperative.IDEHelpNode openBracketPos = null; if (la.val == "[") openBracketPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode }; Expect(7); Node node = null; if (StartOf(18)) { Imperative_expr(out node); } array.Col = t.col; array.Line = t.line; array.OpenBracketPos = openBracketPos; array.Expr = node; array.Type = null; if (la.val == "]" && array.OpenBracketPos != null) array.CloseBracketPos.setValue(la.col, la.line, la.val); else if (la.val != "]") array.OpenBracketPos = null; Expect(8); while (la.kind == 7) { DesignScript.Parser.Imperative.IDEHelpNode openBracketPos2 = null; if (la.val == "[") openBracketPos2 = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode }; Get(); node = null; if (StartOf(18)) { Imperative_expr(out node); } DesignScript.Parser.Imperative.ArrayNode array2 = new DesignScript.Parser.Imperative.ArrayNode(); array2.Col = t.col; array2.Line = t.line; array2.OpenBracketPos = openBracketPos2; array2.Expr = node; array2.Type = array; if (la.val == "]" && array2.OpenBracketPos != null) array2.CloseBracketPos.setValue(la.col, la.line, la.val); else if (la.val != "]") array2.OpenBracketPos = null; Expect(8); array = array2; } }
void Assoc_BaseConstructorCall(DesignScript.Parser.Associative.ConstructorDefinitionNode constr) { DesignScript.Parser.Associative.FunctionCallNode f = null; if (la.val == "base") { Get(); constr.CreateBaseConstructorNode(); f = constr.BaseConstructorNode; constr.KwBase.SetValue(t.val, t.line, t.col); } Expect(6); constr.SetDotToken(t); if (la.kind == 1) { Node identNode = null; Assoc_Ident(out identNode); constr.SetBaseConstructor(identNode); } Assoc_Arguments(ref f); }
void Imperative_BitUnaryExpression(out DesignScript.Parser.Imperative.UnaryExpressionNode node) { DesignScript.Parser.Imperative.UnaryExpressionNode unary = new DesignScript.Parser.Imperative.UnaryExpressionNode(); DesignScript.Parser.Imperative.IDEHelpNode IDEop = unary.Operator; Imperative_unaryop(out IDEop); Node exprNode = null; Imperative_factor(out exprNode); unary.Expression = exprNode; unary.Operator = IDEop; node = unary; }
void Assoc_BitOp(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { if (la.kind == 61) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 62) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else if (la.kind == 13) { Get(); IDEop.SetValue(t.val, t.line, t.col); } else SynErr(103); }
void Imperative_NegExpression(out DesignScript.Parser.Imperative.UnaryExpressionNode node) { node = new Imperative.UnaryExpressionNode() ; DesignScript.Parser.Imperative.IDEHelpNode op = node.Operator; Node exprNode = null; Imperative_negop(out op); if (la.kind == 1 || la.kind == 9 || la.kind == 50) { Imperative_identifierList(out exprNode); } else if (la.kind == 9) { Get(); Imperative_expr(out exprNode); Expect(10); } else SynErr(120); DesignScript.Parser.Imperative.UnaryExpressionNode unary = new DesignScript.Parser.Imperative.UnaryExpressionNode(); unary.Operator = op; unary.Expression = exprNode; node = unary; }
void Assoc_ComparisonOp(ref DesignScript.Parser.Associative.IDEHelpNode IDEop) { switch (la.kind) { case 15: { Get(); IDEop.SetValue(t.val, t.line, t.col); break; } case 17: { Get(); IDEop.SetValue(t.val, t.line, t.col); break; } case 14: { Get(); IDEop.SetValue(t.val, t.line, t.col); break; } case 16: { Get(); IDEop.SetValue(t.val, t.line, t.col); break; } case 18: { Get(); IDEop.SetValue(t.val, t.line, t.col); break; } case 19: { Get(); IDEop.SetValue(t.val, t.line, t.col); break; } default: SynErr(95); break; } }
void Imperative_negop(out DesignScript.Parser.Imperative.IDEHelpNode op) { op = new DesignScript.Parser.Imperative.IDEHelpNode(DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode); if (la.kind == 1 || la.kind == 9 || la.kind == 50) { } else if (la.kind == 12) { Get(); op.setValue(t.col, t.line, t.val); } else SynErr(123); }
void Assoc_FunctionalStatement(out Node node, ref DesignScript.Parser.Associative.IDEHelpNode Endline) { DesignScript.Parser.Associative.BinaryExpressionNode expressionNode = new DesignScript.Parser.Associative.BinaryExpressionNode(); while (!(StartOf(5))) {SynErr(85); Get();} Node leftNode = null; isLeft = true; Assoc_DecoratedIdentifier(out leftNode); expressionNode.Line = leftNode.Line; expressionNode.Col = leftNode.Col; expressionNode.LeftNode = leftNode; isLeft = false; node = leftNode; if(!(leftNode is DesignScript.Parser.Associative.PostFixNode)) { Expect(53); Node rightNode = null; if (t.val == "=") { expressionNode.op.SetValue(t.val, t.line, t.col); } else { expressionNode.op.SetValue(null, 0, 0); } if (la.val == "[") { Assoc_LanguageBlock(out rightNode); Endline = null; } else if (HasMoreAssignmentStatements()) { Assoc_FunctionalStatement(out rightNode, ref Endline); } else if (!IsModifierStack()) { Assoc_Expression(out rightNode); while (!(la.kind == 0 || la.kind == 20)) {SynErr(86); Get();} Expect(20); if(t.val == ";") Endline.SetValue(t.val, t.line, t.col); else Endline.SetValue(null, -1, -1); } else if (IsModifierStack()) { DesignScript.Parser.Associative.ModifierStackNode mstack = new DesignScript.Parser.Associative.ModifierStackNode(); if (la.val == "{") { mstack.openSharpBrace.SetValue(la.val, la.line, la.col); mstack.Line = la.line; mstack.Col = la.col; } else { mstack.openSharpBrace.SetValue(null, 0, 0); } Expect(50); string name = null; DesignScript.Parser.Associative.BinaryExpressionNode expression = new DesignScript.Parser.Associative.BinaryExpressionNode(); ; Node expression2 = null; Assoc_Expression(out expression2); if (la.kind == 55) { string _arr = null; int _line = 0; int _col = 0; Get(); if (t.val == "=>") _arr = t.val; _line = t.line; _col = t.col; Expect(1); if (t.kind == _ident) { name = t.val; mstack.AddArrow(_arr, _line, _col, t.val, t.line, t.col); } else { name = null; mstack.AddArrow(_arr, _line, _col, null, 0, 0); } } expression.LeftNode = leftNode; expression.op = expressionNode.op; expression.RightNode = expression2; mstack.AddElementNode(expression, name); while (!(la.kind == 0 || la.kind == 20)) {SynErr(87); Get();} Expect(20); if (t.val == ";") mstack.AddEndLine(t.val, t.line, t.col); else mstack.AddEndLine(null, 0, 0); while (StartOf(6)) { name = null; bool bHasOperator = false; expression = new DesignScript.Parser.Associative.BinaryExpressionNode(); expression2 = null; bHasOperator = true; DesignScript.Parser.Associative.IDEHelpNode IDEop = expression.op; if (StartOf(7)) { Assoc_BinaryOps(ref IDEop); } Assoc_Expression(out expression2); if (la.kind == 55) { string _arr = null; int _line = 0; int _col = 0; Get(); if (t.val == "=>") _arr = t.val; _line = t.line; _col = t.col; Expect(1); if (t.kind == _ident) { name = t.val; mstack.AddArrow(_arr, _line, _col, t.val, t.line, t.col); } else { name = null; mstack.AddArrow(_arr, _line, _col, null, 0, 0); } } if(!bHasOperator) { expression.RightNode = expression2; expression.LeftNode = leftNode; expression.op = expressionNode.op; mstack.AddElementNode(expression, name); } else { expression.LeftNode = leftNode; DesignScript.Parser.Associative.BinaryExpressionNode expression3 = new DesignScript.Parser.Associative.BinaryExpressionNode(); expression3.LeftNode = leftNode; expression3.op = IDEop; expression3.RightNode = expression2; expression.LeftNode = leftNode; expression.RightNode = expression3; expression.op = expressionNode.op; mstack.AddElementNode(expression, name); } Expect(20); if (t.val == ";") mstack.AddEndLine(t.val, t.line, t.col); else mstack.AddEndLine(null, 0, 0); } if (la.val == "}" && mstack.openSharpBrace.Value != null) mstack.closeBrace.SetValue(la.val, la.line, la.col); else if (la.val != "}") mstack.openSharpBrace.SetValue(null, 0, 0); rightNode = mstack; Expect(51); } else SynErr(88); expressionNode.RightNode = rightNode; node = expressionNode; if (rightNode is DesignScript.Parser.Associative.ExprListNode) { DesignScript.Parser.Associative.IdentifierNode identNode = expressionNode.LeftNode as DesignScript.Parser.Associative.IdentifierNode; if (null != identNode) { DesignScript.Parser.Associative.IDEHelpNode identValue = identNode.IdentValue; rightNode.Name = ((null != identValue) ? identValue.Value : null); } } } }
void Imperative_PostFixOp(ref DesignScript.Parser.Imperative.IDEHelpNode op) { if (la.kind == 66) { Get(); op.setValue(t.col, t.line, t.val); } else if (la.kind == 67) { Get(); op.setValue(t.col, t.line, t.val); } else SynErr(130); }