Skip to content

Commit

Permalink
Architectural changes have been made to the AST and are under develop…
Browse files Browse the repository at this point in the history
…ment.
  • Loading branch information
ax-6 committed Mar 1, 2024
1 parent d2d5f1e commit a2b50a0
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 17 deletions.
6 changes: 5 additions & 1 deletion compiler/ast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.10)

include_directories(${PROJECT_SOURCE_DIR})

set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/decl.cc ${CMAKE_CURRENT_SOURCE_DIR}/expr.cc ${CMAKE_CURRENT_SOURCE_DIR}/stmt.cc ${CMAKE_CURRENT_SOURCE_DIR}/type.cc)
set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ast.cc
${CMAKE_CURRENT_SOURCE_DIR}/decl.cc
${CMAKE_CURRENT_SOURCE_DIR}/expr.cc
${CMAKE_CURRENT_SOURCE_DIR}/stmt.cc
${CMAKE_CURRENT_SOURCE_DIR}/type.cc)

add_library(AqCompilerAst STATIC ${SOURCES})

Expand Down
7 changes: 7 additions & 0 deletions compiler/ast/ast.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2024 AQ authors, All Rights Reserved.
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#include "compiler/ast/ast.h"

// TODO: AST
21 changes: 17 additions & 4 deletions compiler/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@
#ifndef AQ_COMPILER_AST_AST_H_
#define AQ_COMPILER_AST_AST_H_

#include "compiler/ast/decl.h"
#include "compiler/ast/expr.h"
#include "compiler/ast/stmt.h"
#include "compiler/ast/type.h"
#include "compiler/compiler.h"

namespace Aq {
class Compiler::Ast {
public:
Ast();
~Ast();

class FuncDecl;
class Expr;
class Stmt;
class Type;

private:
// TODO: Waiting for development.
};
} // namespace Aq

#endif
1 change: 1 addition & 0 deletions compiler/ast/decl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#include "compiler/ast/ast.h"
#include "compiler/ast/decl.h"

// TODO: AST
4 changes: 2 additions & 2 deletions compiler/ast/decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#ifndef AQ_COMPILER_AST_DECL_H_
#define AQ_COMPILER_AST_DECL_H_

#include "compiler/ast/ast.h"
#include "compiler/compiler.h"

namespace Aq {
// TODO: Decl AST
class Compiler::FuncDecl {
class Compiler::Ast::FuncDecl {
public:
FuncDecl();
~FuncDecl();
Expand All @@ -20,7 +21,6 @@ class Compiler::FuncDecl {
FuncDecl& operator=(FuncDecl&&) noexcept = default;

private:
// Type* type;
// std::string name;
// std::vector<Expr*> args;
// Stmt* body;
Expand Down
1 change: 1 addition & 0 deletions compiler/ast/expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#include "compiler/ast/ast.h"
#include "compiler/ast/expr.h"

// TODO: AST
1 change: 1 addition & 0 deletions compiler/ast/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef AQ_COMPILER_AST_EXPR_H_
#define AQ_COMPILER_AST_EXPR_H_

#include "compiler/ast/ast.h"
#include "compiler/compiler.h"

namespace Aq {
Expand Down
1 change: 1 addition & 0 deletions compiler/ast/stmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#include "compiler/ast/ast.h"
#include "compiler/ast/stmt.h"

// TODO: AST
1 change: 1 addition & 0 deletions compiler/ast/stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef AQ_COMPILER_AST_STMT_H_
#define AQ_COMPILER_AST_STMT_H_

#include "compiler/ast/ast.h"
#include "compiler/compiler.h"

namespace Aq {
Expand Down
1 change: 1 addition & 0 deletions compiler/ast/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#include "compiler/ast/ast.h"
#include "compiler/ast/type.h"

// TODO: AST
1 change: 1 addition & 0 deletions compiler/ast/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef AQ_COMPILER_AST_TYPE_H_
#define AQ_COMPILER_AST_TYPE_H_

#include "compiler/ast/ast.h"
#include "compiler/compiler.h"

namespace Aq {
Expand Down
7 changes: 1 addition & 6 deletions compiler/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ Compiler::Compiler(const char* filename) {
Token token;
while (true) {
lexer.LexToken(token);
if (token.type == Token::Type::NONE) {
std::cout << "END OF THE CODE.";
} else {
std::cout << "" << std::endl;
}
if (lexer.IsReadEnd()) {
if (token.type == Token::Type::NONE || lexer.IsReadEnd()) {
break;
}
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ class Compiler {

class Parser;

class FuncDecl;
class Expr;
class Stmt;
class Type;
class Ast;
};
} // namespace Aq

Expand Down

0 comments on commit a2b50a0

Please sign in to comment.