public ScriptTypeConvertExpr(AstNodeArgs args) : base(args) { if (ChildNodes.Count == 2) { if (args.ChildNodes[0] is ScriptExpr && !(args.ChildNodes[1] is ScriptExpr)) { // ( Expr ) _expr = args.ChildNodes[0] as ScriptExpr; _typeExpr = null; } else { //(Type) Expr _typeExpr = args.ChildNodes[0] as ScriptExpr; _expr = args.ChildNodes[1] as ScriptExpr; } } else { throw new ScriptSyntaxErrorException(Strings.GrammarErrorExceptionMessage); } _operator = RuntimeHost.GetBinaryOperator("+"); if (_operator == null) { throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+")); } }
public ScriptFuncContract(AstNodeArgs args) : base(args) { _pre = ChildNodes[0] as ScriptFuncContractPre; _post = ChildNodes[1] as ScriptFuncContractPost; _inv = ChildNodes[2] as ScriptFuncContractInv; }
public ScriptForEachStatement(AstNodeArgs args) : base(args) { _name = (TokenAst)ChildNodes[1]; _expr = (ScriptExpr)ChildNodes[3]; _statement = (ScriptStatement)ChildNodes[4]; }
public ScriptQualifiedName(AstNodeArgs args) : base(args) { IsVariable = false; NextFirst = false; IsVar = false; if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0) { _identifier = ExtractId(((TokenAst)ChildNodes[0]).Text); IsVariable = true; _evaluation = EvaluateIdentifier; _assignment = AssignIdentifier; } else if (ChildNodes[0] is TokenAst && ChildNodes[1].ChildNodes.Count != 0) { _identifier = ExtractId(((TokenAst)ChildNodes[0]).Text); //NOTE: There might be two cases: // 1) a()[]...() // 2) a<>.(NamePart) _modifiers = new List <ScriptAst>(); foreach (ScriptAst node in ChildNodes[1].ChildNodes) { _modifiers.Add(node); } var generic = _modifiers.FirstOrDefault() as ScriptGenericsPostfix; if (generic != null && _modifiers.Count == 1) { //Case 2 _evaluation = EvaluateGenericType; _assignment = null; } else { //Case 1 _evaluation = EvaluateFunctionCall; _assignment = AssignArray; } } else { _namePart = ChildNodes[0] as ScriptQualifiedName; _identifier = ExtractId(((TokenAst)ChildNodes[2]).Text); NextFirst = true; if (ChildNodes.Count == 4 && ChildNodes[3].ChildNodes.Count != 0) { _modifiers = new List <ScriptAst>(); foreach (ScriptAst node in ChildNodes[3].ChildNodes) { _modifiers.Add(node); } } _evaluation = EvaluateNamePart; _assignment = AssignNamePart; } }
public ScriptTypeConvertExpr(AstNodeArgs args) : base(args) { if (ChildNodes.Count == 2) { if (args.ChildNodes[0] is ScriptExpr && !(args.ChildNodes[1] is ScriptExpr)) { // ( Expr ) _expr = args.ChildNodes[0] as ScriptExpr; _typeExpr = null; } else { //(Type) Expr _typeExpr = args.ChildNodes[0] as ScriptExpr; _expr = args.ChildNodes[1] as ScriptExpr; } } else { throw new ScriptSyntaxErrorException(Strings.GrammarErrorExceptionMessage); } _operator = RuntimeHost.GetBinaryOperator("+"); if (_operator == null) throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+")); }
public ScriptArrayResolution(AstNodeArgs args) : base(args) { if (args.ChildNodes.Count != 0) { _args = args.ChildNodes[0] as ScriptExprList; } }
public ScriptTryCatchFinallyStatement(AstNodeArgs args) : base(args) { _tryBlock = ChildNodes[1] as ScriptStatement; _expName = ((TokenAst)ChildNodes[3]).Text; _catchBlock = ChildNodes[4] as ScriptStatement; _finallyBlock = ChildNodes[6] as ScriptStatement; }
public ScriptTryCatchFinallyStatement(AstNodeArgs args) : base(args) { _tryBlock = ChildNodes[1] as ScriptStatement; _expName = ((TokenAst) ChildNodes[3]).Text; _catchBlock = ChildNodes[4] as ScriptStatement; _finallyBlock = ChildNodes[6] as ScriptStatement; }
public ScriptFunctionCall(AstNodeArgs args) : base(args) { if (ChildNodes.Count != 0) { _funcArgs = ChildNodes[0] as ScriptExprList; } }
public ScriptIsExpr(AstNodeArgs args) : base(args) { Debug.Assert(Oper == "is"); _operator = RuntimeHost.GetBinaryOperator(Oper); if (_operator == null) throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "is")); }
public ScriptFlowControlStatement(AstNodeArgs args) : base(args) { var oper = ChildNodes[0] as TokenAst; _operation = oper.Text; Debug.Assert(oper.Text == "return" || oper.Text == "break" || oper.Text == "continue" || oper.Text == "throw"); if (_operation == "return" || _operation == "throw") _expression = (ScriptExpr)ChildNodes[1]; }
public ScriptConstExpr(AstNodeArgs args) : base(args) { var cons = (TokenAst)ChildNodes[0]; Value = cons.Value; if (Value.Equals("true")) Value = true; if (Value.Equals("false")) Value = false; if (Value.Equals("null")) Value = null; }
public ScriptFuncParameters(AstNodeArgs args) : base(args) { if (ChildNodes.Count != 1) return; foreach (var astNode in ChildNodes[0].ChildNodes) { Identifiers.Add(((TokenAst) astNode).Text); } }
public ScriptIfStatement(AstNodeArgs args) : base(args) { _condition = (ScriptCondition)ChildNodes[1]; _statement = (ScriptStatement)ChildNodes[2]; //Else exists if (ChildNodes.Count == 4 && ChildNodes[3].ChildNodes.Count == 2 && ChildNodes[3].ChildNodes[1] is ScriptStatement) { _elseStatement = (ScriptStatement)ChildNodes[3].ChildNodes[1]; } }
public ScriptIfStatement(AstNodeArgs args) : base(args) { _condition = (ScriptCondition) ChildNodes[1]; _statement = (ScriptStatement)ChildNodes[2]; //Else exists if (ChildNodes.Count == 4 && ChildNodes[3].ChildNodes.Count == 2 && ChildNodes[3].ChildNodes[1] is ScriptStatement) { _elseStatement = (ScriptStatement)ChildNodes[3].ChildNodes[1]; } }
public ScriptIsExpr(AstNodeArgs args) : base(args) { Debug.Assert(Oper == "is"); _operator = RuntimeHost.GetBinaryOperator(Oper); if (_operator == null) { throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "is")); } }
public ScriptSwitchStatement(AstNodeArgs args) : base(args) { _cases = new List<ScriptSwitchCaseStatement>(); foreach (ScriptSwitchCaseStatement caseStatement in ChildNodes[0].ChildNodes) { _cases.Add(caseStatement); } if (ChildNodes.Count == 2) _defaultCase = ChildNodes[1] as ScriptSwitchDefaultStatement; }
public ScriptMetaExpr(AstNodeArgs args) : base(args) { var progArgs = new AstNodeArgs { ChildNodes = new AstNodeList { ChildNodes[1] }, Span = args.Span, Term = args.Term }; _metaProg = new ScriptProg(progArgs) { Parent = this }; }
public ScriptForStatement(AstNodeArgs args) : base(args) { _init = (ScriptExpr)args.ChildNodes[1]; _cond = (ScriptExpr)args.ChildNodes[2]; _next = (ScriptExpr)args.ChildNodes[3]; _statement = (ScriptStatement)args.ChildNodes[4]; var body = _statement as ScriptCompoundStatement; if (body != null) body.ShouldCreateScope = false; }
public ScriptFlowControlStatement(AstNodeArgs args) : base(args) { var oper = ChildNodes[0] as TokenAst; _operation = oper.Text; Debug.Assert(oper.Text == "return" || oper.Text == "break" || oper.Text == "continue" || oper.Text == "throw"); if (_operation == "return" || _operation == "throw") { _expression = (ScriptExpr)ChildNodes[1]; } }
public ScriptSwitchStatement(AstNodeArgs args) : base(args) { _cases = new List <ScriptSwitchCaseStatement>(); foreach (ScriptSwitchCaseStatement caseStatement in ChildNodes[0].ChildNodes) { _cases.Add(caseStatement); } if (ChildNodes.Count == 2) { _defaultCase = ChildNodes[1] as ScriptSwitchDefaultStatement; } }
public ScriptFuncParameters(AstNodeArgs args) : base(args) { if (ChildNodes.Count != 1) { return; } foreach (var astNode in ChildNodes[0].ChildNodes) { Identifiers.Add(((TokenAst)astNode).Text); } }
public ScriptConstExpr(AstNodeArgs args) : base(args) { TokenAst constant = (TokenAst)ChildNodes[0]; Value = constant.Value; if (constant.IsKeyword) { if (Value.Equals("true")) Value = true; else if (Value.Equals("false")) Value = false; else if (Value.Equals("null")) Value = null; } }
public ScriptAssignExpr(AstNodeArgs args) : base(args) { var varExpr = args.ChildNodes[0] as ScriptVarExpr; if (varExpr != null) { var id = varExpr.ChildNodes[1] as TokenAst; _nameExpr = new ScriptQualifiedName(new AstNodeArgs(args.Term, args.Span, new AstNodeList { id, new AstNode(new AstNodeArgs(args.Term, new SourceSpan(new SourceLocation(0, 0, 0), 0), new AstNodeList())) })) { IsVar = true }; } else { _nameExpr = (ScriptQualifiedName)args.ChildNodes[0]; } _oper = ((TokenAst)args.ChildNodes[1]).Text; if (args.ChildNodes.Count == 3) _rightExpr = (ScriptExpr)args.ChildNodes[2]; Debug.Assert(_oper == "=" || _oper == ":=" || _oper == "+=" || _oper == "-=" || _oper == "++" || _oper == "--" || _oper == ":="); switch (_oper) { case "=": _assignOperation = Assign; break; case ":=": _assignOperation = AssignEx; break; case "++": _assignOperation = PlusPlus; break; case "--": _assignOperation = MinusMinus; break; case "+=": _assignOperation = PlusEqual; break; case "-=": _assignOperation = MinusEqual; break; default: throw new System.InvalidOperationException(string.Format(Strings.AssignmentOperatorNotSupported, _oper)); } _minus = RuntimeHost.GetBinaryOperator(OperatorCodes.Sub); _plus = RuntimeHost.GetBinaryOperator(OperatorCodes.Add); if (_plus == null || _minus == null) throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+,-")); }
public ScriptUnaryExpr(AstNodeArgs args) : base(args) { if (ChildNodes[0] is ScriptExpr) { _expr = (ScriptExpr)ChildNodes[0]; OperationSymbol = ((TokenAst)ChildNodes[1]).Text; } else { _expr = (ScriptExpr)ChildNodes[1]; OperationSymbol = ((TokenAst)ChildNodes[0]).Text; } }
public ScriptForStatement(AstNodeArgs args) : base(args) { _init = (ScriptExpr)args.ChildNodes[1]; _cond = (ScriptExpr)args.ChildNodes[2]; _next = (ScriptExpr)args.ChildNodes[3]; _statement = (ScriptStatement)args.ChildNodes[4]; var body = _statement as ScriptCompoundStatement; if (body != null) { body.ShouldCreateScope = false; } }
public ScriptBinExpr(AstNodeArgs args) : base(args) { left = (ScriptExpr)ChildNodes[0]; Oper = ((TokenAst)ChildNodes[1]).Text; right = (ScriptExpr)ChildNodes[2]; Value = RuntimeHost.NullValue; if (IsConst) Evaluation = ConstFirstEvaluate; else Evaluation = CompleteEvaluate; OperatorFunction = RuntimeHost.GetBinaryOperator(Oper); if (OperatorFunction == null) throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, Oper)); }
public ScriptMObject(AstNodeArgs args) : base(args) { _objectParts = new List <ScriptMObjectPart>(); if (ChildNodes[0] is ScriptMObjectPart) { var part = (ScriptMObjectPart)ChildNodes[0]; _objectParts.Add(part); } else { foreach (ScriptMObjectPart part in ChildNodes[0].ChildNodes) { _objectParts.Add(part); } } }
public ScriptMObject(AstNodeArgs args) : base(args) { _objectParts = new List<ScriptMObjectPart>(); if (ChildNodes[0] is ScriptMObjectPart) { var part = (ScriptMObjectPart)ChildNodes[0]; _objectParts.Add(part); } else { foreach (ScriptMObjectPart part in ChildNodes[0].ChildNodes) { _objectParts.Add(part); } } }
public ScriptTypeExpr(AstNodeArgs args) : base(args) { if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0) { _identifier = ((TokenAst)ChildNodes[0]).Text; } else if (ChildNodes[0] is ScriptTypeExpr) { _typeExpr = ChildNodes[0] as ScriptTypeExpr; _identifier = ((TokenAst) ChildNodes[2].ChildNodes[0]).Text; _genericsPostfix = ChildNodes[2].ChildNodes[1] as ScriptGenericsPostfix; } else { _genericsPostfix = (ScriptGenericsPostfix)ChildNodes[1]; _identifier = _genericsPostfix.GetGenericTypeName(((TokenAst)ChildNodes[0]).Text); } }
public ScriptTypeExpr(AstNodeArgs args) : base(args) { if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0) { _identifier = ((TokenAst)ChildNodes[0]).Text; } else if (ChildNodes[0] is ScriptTypeExpr) { _typeExpr = ChildNodes[0] as ScriptTypeExpr; _identifier = ((TokenAst)ChildNodes[2].ChildNodes[0]).Text; _genericsPostfix = ChildNodes[2].ChildNodes[1] as ScriptGenericsPostfix; } else { _genericsPostfix = (ScriptGenericsPostfix)ChildNodes[1]; _identifier = _genericsPostfix.GetGenericTypeName(((TokenAst)ChildNodes[0]).Text); } }
public ScriptConstExpr(AstNodeArgs args) : base(args) { var cons = (TokenAst)ChildNodes[0]; Value = cons.Value; if (Value.Equals("true")) { Value = true; } if (Value.Equals("false")) { Value = false; } if (Value.Equals("null")) { Value = null; } }
public ScriptFunctionDefinition(AstNodeArgs args) : base(args) { var funcName = ChildNodes[1] as TokenAst; var index = 0; if (funcName != null) { Name = funcName.Text; } else //Function expression { Name = null; index = 1; } if (ChildNodes.Count == 5 - index) { _contract = ChildNodes[3 - index] as ScriptFuncContract; _parameters = ChildNodes[3 - index] as ScriptFuncParameters; } if (ChildNodes.Count == 6 - index) { _parameters = ChildNodes[2 - index] as ScriptFuncParameters; _globalList = ChildNodes[3 - index] as ScriptGlobalList; _contract = ChildNodes[4 - index] as ScriptFuncContract; } _body = (ScriptCompoundStatement)ChildNodes[ChildNodes.Count - 1]; _body.ShouldCreateScope = false; if (_contract != null) { _contract._function = this; } }
public ScriptBinExpr(AstNodeArgs args) : base(args) { left = (ScriptExpr)ChildNodes[0]; Oper = ((TokenAst)ChildNodes[1]).Text; right = (ScriptExpr)ChildNodes[2]; Value = RuntimeHost.NullValue; if (IsConst) { Evaluation = ConstFirstEvaluate; } else { Evaluation = CompleteEvaluate; } OperatorFunction = RuntimeHost.GetBinaryOperator(Oper); if (OperatorFunction == null) { throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, Oper)); } }
public ScriptConstExpr(AstNodeArgs args) : base(args) { TokenAst constant = (TokenAst)ChildNodes[0]; Value = constant.Value; if (constant.IsKeyword) { if (Value.Equals("true")) { Value = true; } else if (Value.Equals("false")) { Value = false; } else if (Value.Equals("null")) { Value = null; } } }
public ScriptQualifiedName(AstNodeArgs args) : base(args) { IsVariable = false; NextFirst = false; IsVar = false; if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0) { _identifier = ExtractId(((TokenAst)ChildNodes[0]).Text); IsVariable = true; _evaluation = EvaluateIdentifier; _assignment = AssignIdentifier; } else if (ChildNodes[0] is TokenAst && ChildNodes[1].ChildNodes.Count != 0) { _identifier = ExtractId(((TokenAst)ChildNodes[0]).Text); //NOTE: There might be two cases: // 1) a()[]...() // 2) a<>.(NamePart) _modifiers = new List<ScriptAst>(); foreach (ScriptAst node in ChildNodes[1].ChildNodes) _modifiers.Add(node); var generic = _modifiers.FirstOrDefault() as ScriptGenericsPostfix; if (generic != null && _modifiers.Count == 1) { //Case 2 _evaluation = EvaluateGenericType; _assignment = null; } else { //Case 1 _evaluation = EvaluateFunctionCall; _assignment = AssignArray; } } else { _namePart = ChildNodes[0] as ScriptQualifiedName; _identifier = ExtractId(((TokenAst)ChildNodes[2]).Text); NextFirst = true; if (ChildNodes.Count == 4 && ChildNodes[3].ChildNodes.Count != 0) { _modifiers = new List<ScriptAst>(); foreach (ScriptAst node in ChildNodes[3].ChildNodes) { _modifiers.Add(node); } } _evaluation = EvaluateNamePart; _assignment = AssignNamePart; } }
public ScriptArrayConstructor(AstNodeArgs args) : base(args) { _exprList = (ScriptExprList)ChildNodes[0]; }
public ScriptNewArrStmt(AstNodeArgs args) : base(args) { _constrExpr = ChildNodes[1] as ScriptTypeExpr; _arrRank = ChildNodes[2] as ScriptArrayResolution; }
public ScriptFuncContractPost(AstNodeArgs args) : base(args) { _list = ChildNodes[1] as ScriptExprList; }
public ScriptProg(AstNodeArgs args) : base(args) { Elements = ChildNodes[0] as ScriptElements; }
public ScriptMObjectPart(AstNodeArgs args) : base(args) { _name = ((TokenAst)ChildNodes[0]).Text; _expr = ChildNodes[2] as ScriptExpr; }
public ScriptVarExpr(AstNodeArgs args) : base(args) { _symbol = ((TokenAst)ChildNodes[0]).Text; _identifier = ((TokenAst)ChildNodes[1]).Text; }
public ScriptUsingStatement(AstNodeArgs args) : base(args) { _name = args.ChildNodes[1] as ScriptQualifiedName; _statement = args.ChildNodes[2] as ScriptAst; }
public ScriptFunctionCall(AstNodeArgs args) : base(args) { if (ChildNodes.Count != 0) _funcArgs = ChildNodes[0] as ScriptExprList; }
public ScriptSwitchCaseStatement(AstNodeArgs args) : base(args) { _cond = ChildNodes[1] as ScriptExpr; _statement = ChildNodes[3] as ScriptStatement; }
public ScriptAstTemplate(AstNodeArgs args) : base(args) { }
public ScriptNewStmt(AstNodeArgs args) : base(args) { _constrExpr = ChildNodes[1] as ScriptTypeConstructor; }
public ScriptTypeConstructor(AstNodeArgs args) : base(args) { _typeExpr = ChildNodes[0] as ScriptTypeExpr; _callExpr = ChildNodes[1] as ScriptFunctionCall; }
public ScriptCompoundStatement(AstNodeArgs args) : base(args) { ShouldCreateScope = true; }
public ScriptCondition(AstNodeArgs args) : base(args) { _conditionExpression = (ScriptExpr)ChildNodes[0]; }
public ScriptGlobalList(AstNodeArgs args) : base(args) { Parameters = ChildNodes[1] as ScriptFuncParameters; }
public ScriptRefExpr(AstNodeArgs args) : base(args) { _symbol = ((TokenAst)ChildNodes[0]).Text; _identifier = ((TokenAst)ChildNodes[1]).Text; }
public ScriptFuncContractPre(AstNodeArgs args) : base(args) { _list = ChildNodes[1] as ScriptExprList; }
public ScriptTypeExprList(AstNodeArgs args) : base(args) { }