/// <summary> /// Creates a <see cref="Statement"/> object for <paramref name="stmtElement"/>. /// The expression contained within <paramref name="stmtElement"/> will be parsed and placed in /// Statement.Content. /// </summary> /// <param name="stmtElement">The SRC.ExpressionStatement element to parse.</param> /// <param name="context">The context to use.</param> /// <returns>A <see cref="Statement"/> corresponding to <paramref name="stmtElement"/>.</returns> protected override Statement ParseDeclarationStatementElement(XElement stmtElement, ParserContext context) { if (stmtElement == null) { throw new ArgumentNullException("stmtElement"); } if (stmtElement.Name != SRC.DeclarationStatement && stmtElement.Name != SRC.Property) { throw new ArgumentException("Must be a SRC.DeclarationStatement element", "stmtElement"); } if (context == null) { throw new ArgumentNullException("context"); } //first check if this is a property and parse accordingly if (stmtElement.Name == SRC.Property) { return(ParsePropertyDeclarationElement(stmtElement, context)); } else { var stmt = new DeclarationStatement() { ProgrammingLanguage = ParserLanguage, Content = ParseExpression(GetChildExpressions(stmtElement), context) }; stmt.AddLocation(context.CreateLocation(stmtElement)); return(stmt); } }
/// <summary> /// Creates a <see cref="Statement"/> object for <paramref name="stmtElement"/>. /// The expression contained within <paramref name="stmtElement"/> will be parsed and placed in /// Statement.Content. /// </summary> /// <param name="stmtElement">The SRC.DeclarationStatement element to parse.</param> /// <param name="context">The context to use.</param> /// <returns>A <see cref="DeclarationStatement"/> corresponding to <paramref name="stmtElement"/>. /// The return type is <see cref="Statement"/> so that subclasses can return another type, as necessary. </returns> protected override Statement ParseDeclarationStatementElement(XElement stmtElement, ParserContext context) { if (stmtElement == null) { throw new ArgumentNullException("stmtElement"); } if (stmtElement.Name != SRC.DeclarationStatement && stmtElement.Name != SRC.Property) { throw new ArgumentException("Must be a SRC.DeclarationStatement or SRC.Property element", "stmtElement"); } if (context == null) { throw new ArgumentNullException("context"); } var stmt = new DeclarationStatement() { ProgrammingLanguage = ParserLanguage, Content = ParseExpression(GetChildExpressions(stmtElement), context) }; stmt.AddLocation(context.CreateLocation(stmtElement)); return(stmt); }
/// <summary> /// Creates a <see cref="Statement"/> object for <paramref name="stmtElement"/>. /// The expression contained within <paramref name="stmtElement"/> will be parsed and placed in /// Statement.Content. /// </summary> /// <param name="stmtElement">The SRC.DeclarationStatement element to parse.</param> /// <param name="context">The context to use.</param> /// <returns>A <see cref="DeclarationStatement"/> corresponding to <paramref name="stmtElement"/>. /// The return type is <see cref="Statement"/> so that subclasses can return another type, as necessary. </returns> protected override Statement ParseDeclarationStatementElement(XElement stmtElement, ParserContext context) { if (stmtElement == null) throw new ArgumentNullException("stmtElement"); if (stmtElement.Name != SRC.DeclarationStatement && stmtElement.Name != SRC.Property) throw new ArgumentException("Must be a SRC.DeclarationStatement or SRC.Property element", "stmtElement"); if (context == null) throw new ArgumentNullException("context"); var stmt = new DeclarationStatement() { ProgrammingLanguage = ParserLanguage, Content = ParseExpression(GetChildExpressions(stmtElement), context) }; stmt.AddLocation(context.CreateLocation(stmtElement)); return stmt; }
//if(st is AliasStatement) { // Console.WriteLine("is AliasStatement"); // return; // } else if(st is BreakStatement) { // Console.WriteLine("is BreakStatement"); // return; // } else if(st is ContinueStatement) { // Console.WriteLine("is ContinueStatement"); // return; // } else if(st is ExternStatement) { // Console.WriteLine("is ExternStatement"); // return; // } else if(st is GotoStatement) { // Console.WriteLine("is GotoStatement"); // return; // } else if(st is ImportStatement) { // Console.WriteLine("is ImportStatement"); // return; // } else if(st is LabelStatement) { // Console.WriteLine("is LabelStatement"); // return; // } else if(st is ThrowStatement) { // Console.WriteLine("is VariableDeclaration"); // return; // } else { // if(!st.GetType().IsSubclassOf(typeof(Statement))) { // VisitOtherStmt(st); // } // return; // } /// <summary> /// Stores the local defined variable's info and updates if it has been initialized /// </summary> /// <param name="dst"></param> private void AnalyzeDeclarationStatement(DeclarationStatement dst) { //from child in dst.GetDescendantsAndSelf() var allDeclarations = from expression in dst.FindExpressions<VariableDeclaration>(true) select expression; foreach(var vd in allDeclarations) { UpdateByExpression(vd); } }
/// <summary> /// Creates a <see cref="Statement"/> object for <paramref name="stmtElement"/>. /// The expression contained within <paramref name="stmtElement"/> will be parsed and placed in /// Statement.Content. /// </summary> /// <param name="stmtElement">The SRC.ExpressionStatement element to parse.</param> /// <param name="context">The context to use.</param> /// <returns>A <see cref="Statement"/> corresponding to <paramref name="stmtElement"/>.</returns> protected override Statement ParseDeclarationStatementElement(XElement stmtElement, ParserContext context) { if(stmtElement == null) throw new ArgumentNullException("stmtElement"); if (stmtElement.Name != SRC.DeclarationStatement && stmtElement.Name != SRC.Property) throw new ArgumentException("Must be a SRC.DeclarationStatement element", "stmtElement"); if(context == null) throw new ArgumentNullException("context"); //first check if this is a property and parse accordingly if (stmtElement.Name == SRC.Property) { return ParsePropertyDeclarationElement(stmtElement, context); } else { var stmt = new DeclarationStatement() { ProgrammingLanguage = ParserLanguage, Content = ParseExpression(GetChildExpressions(stmtElement), context) }; stmt.AddLocation(context.CreateLocation(stmtElement)); return stmt; } }