public SwitchStatement(HappySourceLocation startsAt, HappySourceLocation endsAt, ExpressionNodeBase switchExpression, SwitchCase[] cases, StatementBlock defaultCase) : base(startsAt, endsAt) { this.SwitchExpression = switchExpression; this.Cases = cases; this.DefaultStatementBlock = defaultCase; }
public IfStatement(HappySourceLocation startsAt, ExpressionNodeBase value, StatementBlock trueStatementBlock, StatementBlock falseStatementBlock) : base(startsAt, falseStatementBlock != null ? falseStatementBlock.Location : trueStatementBlock.Location) { _condition = value; _trueStatementBlock = trueStatementBlock; _falseStatementBlock = falseStatementBlock; }
public ForStatement(HappySourceLocation span, Identifier loopVariable, ExpressionNodeBase enumerable, ExpressionNodeBase between, ExpressionNodeBase where, StatementBlock loopBody) : base(span, loopBody.Location) { _loopVariable = loopVariable; _enumerable = enumerable; _between = between; _where = where != null ? new ForWhereClause(where.Location, _loopVariable.Text, where) : null; _loopBody = loopBody; }
public override void AfterVisit(StatementBlock node) { List<Expression> expressions = _expressionStack.Pop(node.Statements.Length); if (expressions.Count == 0) expressions.Add(Expression.Empty()); if (node.GetExtension<StatementBlockExtensions>().AnalyzeSymbolsExternally) _expressionStack.Push(node, MaybeBlock(expressions)); else _expressionStack.Push(node, MaybeBlock(node.GetExtension<ScopeExtension>().SymbolTable.GetParameterExpressions(), expressions)); base.AfterVisit(node); }
public virtual void BeforeVisit(StatementBlock node) { this.BeforeVisitCatchAll(node); }
public virtual void AfterVisit(StatementBlock node) { this.AfterVisitCatchAll(node); }
public WhileStatement(HappySourceLocation startsAt, ExpressionNodeBase condition, StatementBlock block) : base(startsAt, block.Location) { Block = block; this.Condition = condition; }
public AnonymousTemplate(StatementBlock body) : base(body.Location) { this.Body = body; }
public Function(HappySourceLocation startsAt, Identifier name, FunctionParameterList parameterList, StatementBlock body) : base(startsAt, body.Location, name) { _parameterList = parameterList; _body = body; }
public override void AfterVisit(StatementBlock node) { PopAndAssert(node.GetExtension<ScopeExtension>().SymbolTable); }
public override void BeforeVisit(StatementBlock node) { node.GetExtension<ScopeExtension>().SymbolTable = new HappySymbolTable("Block", this.TopSymbolTable); _scopeStack.Push(node.GetExtension<ScopeExtension>().SymbolTable); }
StatementBlock ParseSwitchCase(StatementBlock defaultStatementBlock, List<SwitchCase> cases) { List<ExpressionNodeBase> caseValues = new List<ExpressionNodeBase>(); List<AstNodeBase> statements = new List<AstNodeBase>(); Token caseLabelKeyword = this.Expect(HappyTokenKind.KeywordCase, HappyTokenKind.KeywordDefault, "case or default"); if (caseLabelKeyword.HappyTokenKind == HappyTokenKind.KeywordCase) { do { caseValues.Add(this.ParseExpression(ExpressionContext.Expression)); this.Expect(HappyTokenKind.Colon, ":"); } while(this.EatNextTokenIf(HappyTokenKind.KeywordCase)); } else { this.Expect(HappyTokenKind.Colon, ":"); if (defaultStatementBlock != null) _errorCollector.DefaultCaseSpecifiedMoreThanOnce(caseLabelKeyword.Location); } while(_lexer.PeekToken().HappyTokenKind != HappyTokenKind.KeywordBreak) { statements.Add(this.ParseStatement()); if (_lexer.PeekToken().HappyTokenKind == HappyTokenKind.CloseBrace) _errorCollector.SwitchCaseMissingBreak(_lexer.PeekToken().Location); } _lexer.NextToken(); //eat break keyword var endsAt = this.Expect(HappyTokenKind.EndOfStatement, ";").Location; var caseStatements = statements.ToArray(); if(caseLabelKeyword.HappyTokenKind == HappyTokenKind.KeywordCase) cases.Add(new SwitchCase(caseValues.ToArray(), new StatementBlock(caseLabelKeyword.Location, endsAt, caseStatements))); else defaultStatementBlock = new StatementBlock(caseLabelKeyword.Location, endsAt, caseStatements); return defaultStatementBlock; }
public SwitchCase(ExpressionNodeBase[] caseValues, StatementBlock statements) : base(statements.Location) { this.CaseValues = caseValues; this.CaseStatementBlock = statements; }