Esempio n. 1
0
 public virtual void Visit(UnexpectedToken node)
 {
     this.BeforeVisitCatchAll(node);
 }
Esempio n. 2
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;
 }