From a853ed5ae92bd2575496658056e38b7e89c6f7b9 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Sat, 1 Jun 2013 03:10:16 +0200 Subject: [PATCH] Reorder and stuff --- CMakeLists.txt | 2 +- grammar/grammar.y | 6 ++++-- inc/AST/ASTVisitor.h | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff89305..2883aff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ SET(SCULLY_SOURCE src/AST/Expression.cpp src/AST/ExpressionStatement.cpp src/AST/ForStatement.cpp + src/AST/FunctionCallExpression.cpp src/AST/FunctionDefinition.cpp src/AST/IfStatement.cpp src/AST/ParameterList.cpp @@ -77,7 +78,6 @@ SET(SCULLY_SOURCE src/AST/Type.cpp src/AST/VariableDefinition.cpp src/AST/ValueList.cpp - src/AST/FunctionCallExpression.cpp ${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp ) diff --git a/grammar/grammar.y b/grammar/grammar.y index 260d825..06c8641 100644 --- a/grammar/grammar.y +++ b/grammar/grammar.y @@ -14,9 +14,11 @@ #include "AST/Expression.h" #include "AST/ExpressionStatement.h" #include "AST/ForStatement.h" +#include "AST/FunctionCallExpression.h" #include "AST/FunctionDefinition.h" #include "AST/IfStatement.h" #include "AST/ParameterList.h" +//#include "AST/RandomForStatement.h" #include "AST/RandomIfStatement.h" #include "AST/ReturnStatement.h" #include "AST/Scope.h" @@ -77,7 +79,7 @@ statement(A) ::= T_RIF T_LPAREN expr(P) T_RPAREN statement(S). statement(A) ::= T_FOR T_LPAREN expr(INIT) T_SEMICOLON expr(COND) T_SEMICOLON expr(STEP) T_RPAREN statement(S). { A = new ForStatement(INIT, COND, STEP, S); } statement(A) ::= T_RFOR T_LPAREN expr(INIT) T_SEMICOLON expr(P) T_SEMICOLON expr(STEP) T_RPAREN statement(S). - { A = 0; /* INIT P STEP S */ } + { A = 0; /* new RandomForStatement(INIT, P, STEP, S); */ } statement(A) ::= T_RETURN expr(E) T_SEMICOLON. { A = new ReturnStatement(E); } statement(A) ::= T_BEGIN statements(S) T_END. { A = new Scope(S); } statement(A) ::= vardef(V) T_SEMICOLON. { A = V; } @@ -99,7 +101,7 @@ expr(A) ::= T_CINT(I). { A = new ConstantExpression(I->getText()); } expr(A) ::= T_TRUE. { A = new ConstantExpression("true"); } expr(A) ::= T_FALSE. { A = new ConstantExpression("false"); } expr(A) ::= T_IDENTIFIER(ID) T_LPAREN values(V) T_RPAREN. - { A = 0; /* ID V */ } + { A = new FunctionCallExpression(ID->getText(), V); } %type vardef {VariableDefinition*} vardef(A) ::= type(T) T_IDENTIFIER(ID). { A = new VariableDefinition(T, ID->getText()); } diff --git a/inc/AST/ASTVisitor.h b/inc/AST/ASTVisitor.h index 6ec5d93..8d539f7 100644 --- a/inc/AST/ASTVisitor.h +++ b/inc/AST/ASTVisitor.h @@ -6,6 +6,7 @@ #include "ConstantExpression.h" #include "ExpressionStatement.h" #include "ForStatement.h" +#include "FunctionCallExpression.h" #include "FunctionDefinition.h" #include "IfStatement.h" #include "ParameterList.h" @@ -15,7 +16,6 @@ #include "StatementList.h" #include "ValueList.h" #include "VariableDefinition.h" -#include "FunctionCallExpression.h" class ASTVisitor { @@ -28,6 +28,7 @@ public: virtual void visit(ConstantExpression* e) = 0; virtual void visit(ExpressionStatement* e) = 0; virtual void visit(ForStatement* e) = 0; + virtual void visit(FunctionCallExpression* e) = 0; virtual void visit(FunctionDefinition* e) = 0; virtual void visit(IfStatement* e) = 0; virtual void visit(ParameterList* e) = 0; @@ -37,7 +38,6 @@ public: virtual void visit(StatementList* e) = 0; virtual void visit(ValueList* e) = 0; virtual void visit(VariableDefinition* e) = 0; - virtual void visit(FunctionCallExpression* e) = 0; };