Reorder and stuff
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -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()); }
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user