public ForStatementSyntax(ISyntaxNode parent, JurParser.ForStatementContext context) : base(parent, context) { Iterator = context.initializedVariableDeclaration() != null ? new InitializedVariableDeclarationSyntax(this, context.initializedVariableDeclaration()) : context.inferedVariableDeclaration() != null ? new InferredVariableDeclarationSyntax(this, context.inferedVariableDeclaration()) : (IVariableDeclarationSyntax?)null; Condition = ToExpression(context.expression(0)); Modification = context.expression().Length == 2 ? ToExpression(context.expression(1)) : null; Body = StatementSyntaxFactory.Create(this, context.statement()); ForLoopType = Iterator != null && Modification != null ? ForLoopType.Classic : Iterator != null ? ForLoopType.WhileIterator : Modification != null ? ForLoopType.WhileModify : ForLoopType.While; ImmediateChildren = ImmutableArray.Create <ITreeNode>() .AddIfNotNull(Iterator) .Add(Condition) .AddIfNotNull(Modification) .Add(Body); }
public MainSyntax(ISyntaxNode parent, JurParser.MainContext context) : base(int.MaxValue, parent, context) { Body = StatementSyntaxFactory.Create(this, context.statement()); ImmediateChildren = ImmutableArray.Create <ITreeNode>().Add(Body); }
protected IStatementSyntax ToStatement(JurParser.StatementContext context) { return(StatementSyntaxFactory.Create(this, context)); }
protected ImmutableArray <IStatementSyntax> ToStatements(IEnumerable <JurParser.StatementContext> contexts) { return(contexts.Select(x => StatementSyntaxFactory.Create(this, x)).ToImmutableArray()); }