Exemple #1
0
        /// <summary>
        /// Parses a var declaration
        /// </summary>
        private IDeclarationNode ParseVarDeclaration()
        {
            Debugger.Write("Parsing Var Declaration");
            Position startPosition = CurrentToken.Position;

            Accept(TokenType.Var);
            IdentifierNode identifier = ParseIdentifier();

            Accept(TokenType.Colon);
            TypeDenoterNode typeDenoter = ParseTypeDenoter();

            return(new VarDeclarationNode(identifier, typeDenoter, startPosition));
        }
Exemple #2
0
        /// <summary>
        /// Parses a variable declaration
        /// </summary>
        /// <returns>An abstract syntax tree representing the variable declaration</returns>
        private IDeclarationNode ParseVarDeclaration()
        {
            Debugger.WriteDebuggingInfo("Parsing Variable Declaration");
            Position StartPosition = CurrentToken.Position;

            Accept(Var);
            IdentifierNode identifier = ParseIdentifier();

            Accept(Colon);
            TypeDenoterNode typeDenoter = ParseTypeDenoter();

            return(new VarDeclarationNode(identifier, typeDenoter, StartPosition));
        }
        /// <summary>
        /// Parses a type denoter declaration
        /// <type-denoter> <identifier>
        /// </summary>
        /// <returns>An abstract syntax tree representing the variable declaration</returns>
        private IDeclarationNode ParseTypeDenoterDeclaration()
        {
            Debugger.Write("Parsing Variable Declaration");
            Position        StartPosition  = CurrentToken.Position;
            TypeDenoterNode varDeclaration = ParseTypeDenoter();
            IdentifierNode  identifier     = ParseIdentifier();

            if (identifier == null)
            {
                return(new ErrorNode(StartPosition));
            }
            else
            {
                return(new VarDeclarationNode(varDeclaration, identifier, StartPosition));
            }
        }
Exemple #4
0
 /// <summary>
 /// Generates code for a type denoter node
 /// </summary>
 /// <param name="typeDenoter">The node to generate code for</param>
 private void GenerateCodeForTypeDenoter(TypeDenoterNode typeDenoter)
 {
     Debugger.Write("Generating code for Type Denoter");
 }
Exemple #5
0
 /// <summary>
 /// Carries out identification on a type denoter node
 /// </summary>
 /// <param name="typeDenoter">The node to perform identification on</param>
 private void PerformIdentificationOnTypeDenoter(TypeDenoterNode typeDenoter)
 {
     PerformIdentification(typeDenoter.Identifier);
 }
 /// <summary>
 /// Creates a new variable declaration node
 /// </summary>
 /// <param name="identifier">The name of the variable</param>
 /// <param name="typeDenoter">The name of the type of the variable</param>
 /// <param name="position">The position in the code where the content associated with the node begins</param>
 public VarDeclarationNode(IdentifierNode identifier, TypeDenoterNode typeDenoter, Position position)
 {
     Identifier  = identifier;
     TypeDenoter = typeDenoter;
     Position    = position;
 }