Пример #1
0
        /*
         * Below are the functions used to generate AST nodes.
         * They can throw ParserException to indicate of an error.
         * They can return null to indicate that lexeme did not match.
         * Otherwise they return an AST node.
         * They consume Lexemes.
         *
         * The function names reflect the ones used in the grammar.
         */

        ASTNode NUM()
        {
            var lexeme = Consume(TokenType.NUMBER);
            var node   = new NumberNode(lexeme.token);

            node.lexeme = lexeme;
            return(node);
        }
Пример #2
0
 public NumberValue VisitNumberNode(NumberNode node, Context context)
 {
     return new NumberValue() { Value = (int)node.NumberToken.Value };
 }