jitcraft/SemanticAnalysis.h
author David Anderson <dvander@alliedmods.net>
Thu Jun 28 00:54:45 2012 -0700 (2012-06-28)
changeset 9 73781c5a59d7
parent 7 0478c27ba82c
child 10 0c3bcd50e361
permissions -rw-r--r--
Added support for do/while loops.
     1 /*
     2  * Copyright (C) 2012 David Anderson
     3  *
     4  * This file is part of JITCraft.
     5  *
     6  * JITCraft is free software: you can redistribute it and/or modify it under
     7  * the terms of the GNU General Public License as published by the Free
     8  * Software Foundation, either version 3 of the License, or (at your option)
     9  * any later version.
    10  * 
    11  * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
    12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License along with
    16  * JITCraft. If not, see http://www.gnu.org/licenses/.
    17  */
    18 #ifndef _include_semantic_analysis_h_
    19 #define _include_semantic_analysis_h_
    20 
    21 #include <assert.h>
    22 #include "AST.h"
    23 
    24 namespace jc {
    25 
    26 class SemanticAnalysis : public AstVisitor
    27 {
    28     ParseTree *tree_;
    29 
    30   private:
    31     void error() {
    32         assert(false);
    33     }
    34     void typeError(Expression *expr, const char *expected) {
    35         assert(false);
    36     }
    37     Type *visitForLoad(Expression *expression);
    38     Type *visitForRef(Expression *expression);
    39 
    40   public:
    41     SemanticAnalysis(ParseTree *tree);
    42     bool analyze();
    43 
    44   public:
    45     void visit(NameProxy *name);
    46     void visit(Assignment *node);
    47     void visit(BinaryExpression *node);
    48     void visit(ReturnStatement *node);
    49     void visit(ForStatement *node);
    50     void visit(BlockStatement *node);
    51     void visit(VariableDeclaration *node);
    52     void visit(IntegerLiteral *node);
    53     void visit(ExpressionStatement *node);
    54     void visit(FunctionStatement *node);
    55     void visit(CallExpression *node);
    56     void visit(IfStatement *node);
    57     void visit(IndexExpression *node);
    58     void visit(EnumStatement *node);
    59     void visit(FloatLiteral *node);
    60     void visit(WhileStatement *node);
    61 };
    62 
    63 } // namespace jc
    64 
    65 #endif // _include_semantic_analysis_h_