Esempio n. 1
0
        /// <summary>
        /// Gets a VariableDeclarationAST
        /// </summary>
        /// <returns>VariableDeclarationAST</returns>
        private AST VariableDeclaration()
        {
            this.ConsumeToken(TokenType.VAR);
            VariableAST variable = new VariableAST(this.currentToken);

            this.ConsumeToken(TokenType.IDTOKEN);
            this.ConsumeToken(TokenType.TWODOT);
            TypeAST type = (TypeAST)this.TypeSpec();

            if (this.currentToken.type == TokenType.SEMICOLON)
            {
                return(new VariableDeclarationAST(variable, type, this.currentToken));
            }
            else
            {
                this.ConsumeToken(TokenType.ASSIGN);
                return(new VariableDeclarationAST(variable, type, this.currentToken, this.Expression()));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Traverses type AST
 /// </summary>
 /// <param name="ast">TypeAST</param>
 private void VisitTypeAST(TypeAST ast)
 {
     return;
 }
 public VariableDeclarationAST(VariableAST varNode, TypeAST typeNode, Token token, AST assignValue = null) : base(token)
 {
     this.assignedValue = assignValue;
     this.varNode       = varNode;
     this.typeNode      = typeNode;
 }