Formatting and add Scope
This commit is contained in:
@@ -21,58 +21,59 @@ ADD_EXECUTABLE (lemon grammar/lemon.c)
|
|||||||
ADD_EXECUTABLE (makeheaders grammar/makeheaders.c)
|
ADD_EXECUTABLE (makeheaders grammar/makeheaders.c)
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
COMMAND cp
|
COMMAND cp
|
||||||
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/grammar/grammar.y ${CMAKE_CURRENT_BINARY_DIR}
|
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/grammar/grammar.y ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMAND cp
|
COMMAND cp
|
||||||
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/grammar/lempar.c ${CMAKE_CURRENT_BINARY_DIR}
|
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/grammar/lempar.c ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lemon
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lemon
|
||||||
ARGS -q -m ${CMAKE_CURRENT_BINARY_DIR}/grammar.y
|
ARGS -q -m ${CMAKE_CURRENT_BINARY_DIR}/grammar.y
|
||||||
# ARGS -q ${CMAKE_CURRENT_BINARY_DIR}/grammar.y
|
# ARGS -q ${CMAKE_CURRENT_BINARY_DIR}/grammar.y
|
||||||
COMMAND rm
|
COMMAND rm
|
||||||
ARGS ${CMAKE_CURRENT_BINARY_DIR}/lempar.c
|
ARGS ${CMAKE_CURRENT_BINARY_DIR}/lempar.c
|
||||||
COMMAND rm
|
COMMAND rm
|
||||||
ARGS ${CMAKE_CURRENT_BINARY_DIR}/grammar.y
|
ARGS ${CMAKE_CURRENT_BINARY_DIR}/grammar.y
|
||||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/makeheaders
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/makeheaders
|
||||||
ARGS ${CMAKE_CURRENT_BINARY_DIR}/grammar.c
|
ARGS ${CMAKE_CURRENT_BINARY_DIR}/grammar.c
|
||||||
COMMAND mv
|
COMMAND mv
|
||||||
ARGS ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
ARGS ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
||||||
DEPENDS lemon
|
DEPENDS lemon
|
||||||
DEPENDS makeheaders
|
DEPENDS makeheaders
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/grammar/grammar.y
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/grammar/grammar.y
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.h
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(
|
SET_SOURCE_FILES_PROPERTIES(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp GENERATED
|
${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp GENERATED
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION (SCULLY_DEBUG "Create a debug build")
|
OPTION (SCULLY_DEBUG "Create a debug build")
|
||||||
IF (SCULLY_DEBUG)
|
IF (SCULLY_DEBUG)
|
||||||
ADD_DEFINITIONS ("-g")
|
ADD_DEFINITIONS ("-g")
|
||||||
ENDIF (SCULLY_DEBUG)
|
ENDIF (SCULLY_DEBUG)
|
||||||
|
|
||||||
|
|
||||||
SET(SCULLY_SOURCE
|
SET(SCULLY_SOURCE
|
||||||
src/test.cpp
|
src/test.cpp
|
||||||
|
|
||||||
src/Token.cpp
|
src/Token.cpp
|
||||||
|
|
||||||
src/AST/ASTElement.cpp
|
src/AST/ASTElement.cpp
|
||||||
src/AST/ASTVisitor.cpp
|
src/AST/ASTVisitor.cpp
|
||||||
src/AST/AssignmentExpression.cpp
|
src/AST/AssignmentExpression.cpp
|
||||||
src/AST/BinOp.cpp
|
src/AST/BinOp.cpp
|
||||||
src/AST/ConstantExpression.cpp
|
src/AST/ConstantExpression.cpp
|
||||||
src/AST/Expression.cpp
|
src/AST/Expression.cpp
|
||||||
src/AST/ParameterList.cpp
|
src/AST/ParameterList.cpp
|
||||||
src/AST/Statement.cpp
|
src/AST/Scope.cpp
|
||||||
src/AST/Type.cpp
|
src/AST/Statement.cpp
|
||||||
src/AST/VariableDefinition.cpp
|
src/AST/Type.cpp
|
||||||
src/AST/StatementList.cpp
|
src/AST/VariableDefinition.cpp
|
||||||
src/AST/ValueList.cpp
|
src/AST/StatementList.cpp
|
||||||
src/AST/IfStatement.cpp
|
src/AST/ValueList.cpp
|
||||||
|
src/AST/IfStatement.cpp
|
||||||
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE (scully ${SCULLY_SOURCE})
|
ADD_EXECUTABLE (scully ${SCULLY_SOURCE})
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "AST/Expression.h"
|
#include "AST/Expression.h"
|
||||||
#include "AST/IfStatement.h"
|
#include "AST/IfStatement.h"
|
||||||
#include "AST/ParameterList.h"
|
#include "AST/ParameterList.h"
|
||||||
|
#include "AST/Scope.h"
|
||||||
#include "AST/Statement.h"
|
#include "AST/Statement.h"
|
||||||
#include "AST/StatementList.h"
|
#include "AST/StatementList.h"
|
||||||
#include "AST/Type.h"
|
#include "AST/Type.h"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "ConstantExpression.h"
|
#include "ConstantExpression.h"
|
||||||
#include "IfStatement.h"
|
#include "IfStatement.h"
|
||||||
#include "ParameterList.h"
|
#include "ParameterList.h"
|
||||||
|
#include "Scope.h"
|
||||||
#include "StatementList.h"
|
#include "StatementList.h"
|
||||||
#include "ValueList.h"
|
#include "ValueList.h"
|
||||||
#include "VariableDefinition.h"
|
#include "VariableDefinition.h"
|
||||||
@@ -20,9 +21,10 @@ public:
|
|||||||
virtual void visit(ConstantExpression* e) = 0;
|
virtual void visit(ConstantExpression* e) = 0;
|
||||||
virtual void visit(IfStatement* e) = 0;
|
virtual void visit(IfStatement* e) = 0;
|
||||||
virtual void visit(ParameterList* e) = 0;
|
virtual void visit(ParameterList* e) = 0;
|
||||||
|
virtual void visit(Scope* e) = 0;
|
||||||
|
virtual void visit(StatementList* e) = 0;
|
||||||
virtual void visit(ValueList* e) = 0;
|
virtual void visit(ValueList* e) = 0;
|
||||||
virtual void visit(VariableDefinition* e) = 0;
|
virtual void visit(VariableDefinition* e) = 0;
|
||||||
virtual void visit(StatementList* e) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ASTVISITOR_H
|
#endif // ASTVISITOR_H
|
||||||
|
|||||||
18
inc/AST/Scope.h
Normal file
18
inc/AST/Scope.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef SCOPE_H
|
||||||
|
#define SCOPE_H
|
||||||
|
|
||||||
|
#include "AST/Statement.h"
|
||||||
|
|
||||||
|
class Scope : public Statement {
|
||||||
|
public:
|
||||||
|
Scope(Statement* stmt);
|
||||||
|
virtual ~Scope();
|
||||||
|
|
||||||
|
virtual void accept(ASTVisitor* visitor);
|
||||||
|
|
||||||
|
Statement* getStmt();
|
||||||
|
private:
|
||||||
|
Statement* stmt_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCOPE_H
|
||||||
18
src/AST/Scope.cpp
Normal file
18
src/AST/Scope.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "AST/Scope.h"
|
||||||
|
#include "AST/ASTVisitor.h"
|
||||||
|
|
||||||
|
Scope::Scope(Statement* stmt) : stmt_(stmt) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
Scope::~Scope() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scope::accept(ASTVisitor* visitor) {
|
||||||
|
visitor->visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Statement* Scope::getStmt() {
|
||||||
|
return stmt_;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user