public override void Visit(BreakStatement node)
 {
     base.Visit(node);
     DebugAssert.IsNonZero(_loopContextStack.Count, "break statement within loop");
     _expressionStack.Push(node, Expression.Break(_loopContextStack.Peek().BreakLabel));
 }
Beispiel #2
0
 public override void Visit(BreakStatement breakStatement)
 {
     base.Visit(breakStatement);
     if(_loopStack.Count == 0)
         _errorCollector.BreakNotAllowedHere(breakStatement.Location);
 }
Beispiel #3
0
 public virtual void Visit(BreakStatement node)
 {
     this.BeforeVisitCatchAll(node);
 }
Beispiel #4
0
 AstNodeBase ParseStatement()
 {
     Token temp;
     AstNodeBase retval;
     Token peekedToken = _lexer.PeekToken();
     switch (peekedToken.HappyTokenKind)
     {
     case HappyTokenKind.KeywordIf:
         retval = this.ParseIf();
         break;
     case HappyTokenKind.KeywordWhile:
         retval = this.ParseWhile();
         break;
     case HappyTokenKind.KeywordFor:
         retval = this.ParseFor();
         break;
     case HappyTokenKind.Verbatim:
         temp = _lexer.NextToken();
         retval = new VerbatimSection(temp.Location, temp.Text);
         break;
     case HappyTokenKind.KeywordReturn:
         retval = ParseReturn();
         this.ExpectEOS();
         break;
     case HappyTokenKind.KeywordDef:
         retval = ParseDef();
         break;
     case HappyTokenKind.Output:
         retval = this.ParseOutputExpression();
         break;
     case HappyTokenKind.KeywordBreak:
         _lexer.NextToken();
         retval = new BreakStatement(peekedToken.Location);
         this.ExpectEOS();
         break;
     case HappyTokenKind.KeywordContinue:
         _lexer.NextToken();
         retval = new ContinueStatement(peekedToken.Location);
         this.ExpectEOS();
         break;
     case HappyTokenKind.Identifier:
     case HappyTokenKind.LiteralString:
     case HappyTokenKind.LiteralDecimalInt32:
     case HappyTokenKind.LiteralBool:
     case HappyTokenKind.LiteralDouble:
     case HappyTokenKind.OperatorOpenParen:
         retval = this.ParseExpression(ExpressionContext.Expression);
         this.ExpectEOS();
         break;
     case HappyTokenKind.BeginTemplate:
         retval = this.ParseExpression(ExpressionContext.Expression);
         break;
     case HappyTokenKind.VerbatimOutputExpressionDelimiter:
         {
             //TODO:  parse multiple output expressions here...
             _lexer.NextToken();
             ExpressionNodeBase exp = this.ParseExpression(ExpressionContext.Expression);
             this.Expect(HappyTokenKind.VerbatimOutputExpressionDelimiter, "$");
             retval = new OutputStatement(new[] { exp });
         }
         break;
     case HappyTokenKind.KeywordSwitch:
         retval = this.ParseSwitch();
         break;
     default:
         temp = _lexer.NextToken();
         retval = new UnexpectedToken(temp.Location);
         _errorCollector.UnexpectedToken(temp);
         break;
     }
     DebugAssert.IsNotNull(retval, "return value is null");
     return retval;
 }