Skip to content

Commit

Permalink
Addressed some PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-staal committed Mar 7, 2024
1 parent c2b5042 commit 6f51c7e
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion include/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
#include "ast_constant.hpp"
#include "ast_context.hpp"

extern AST::Node* ParseAST(std::string file_name);
extern ast::Node* ParseAST(std::string file_name);
4 changes: 2 additions & 2 deletions include/ast_constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "ast_node.hpp"

namespace AST {
namespace ast {

class IntConstant : public Node
{
Expand All @@ -16,4 +16,4 @@ class IntConstant : public Node
void Print(std::ostream& stream) const override;
};

} // namespace AST
} // namespace ast
6 changes: 3 additions & 3 deletions include/ast_context.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

namespace AST {
// An object of class Context is passed between AST nodes during compilation.
namespace ast {
// An object of class Context is passed between ast nodes during compilation.
// This can be used to pass around information about what's currently being
// compiled (e.g. function scope and variable names).
class Context
{
/* TODO decide what goes inside here */
};

} // namespace AST
} // namespace ast
4 changes: 2 additions & 2 deletions include/ast_direct_declarator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "ast_node.hpp"

namespace AST {
namespace ast {

class DirectDeclarator : public Node
{
Expand All @@ -16,4 +16,4 @@ class DirectDeclarator : public Node
void Print(std::ostream& stream) const override;
};

} // namespace AST
} // namespace ast
4 changes: 2 additions & 2 deletions include/ast_function_definition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ast_node.hpp"
#include "ast_type_specifier.hpp"

namespace AST {
namespace ast {

class FunctionDefinition : public Node
{
Expand All @@ -19,4 +19,4 @@ class FunctionDefinition : public Node
void Print(std::ostream& stream) const override;
};

} // namespace AST
} // namespace ast
4 changes: 2 additions & 2 deletions include/ast_identifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "ast_node.hpp"

namespace AST {
namespace ast {

class Identifier : public Node
{
Expand All @@ -16,4 +16,4 @@ class Identifier : public Node
void Print(std::ostream& stream) const override;
};

} // namespace AST
} // namespace ast
4 changes: 2 additions & 2 deletions include/ast_jump_statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "ast_node.hpp"

namespace AST {
namespace ast {

class ReturnStatement : public Node
{
Expand All @@ -16,4 +16,4 @@ class ReturnStatement : public Node
void Print(std::ostream& stream) const override;
};

} // namespace AST
} // namespace ast
4 changes: 2 additions & 2 deletions include/ast_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "ast_context.hpp"

namespace AST {
namespace ast {

class Node
{
Expand Down Expand Up @@ -34,4 +34,4 @@ class NodeList : public Node
virtual void Print(std::ostream& stream) const override;
};

} // namespace AST
} // namespace ast
2 changes: 1 addition & 1 deletion include/ast_type_specifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string_view>
#include <stdexcept>

namespace AST {
namespace ast {

enum class TypeSpecifier
{
Expand Down
4 changes: 2 additions & 2 deletions src/ast_constant.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_constant.hpp"

namespace AST {
namespace ast {

void IntConstant::EmitRISC(std::ostream& stream, Context& context) const
{
Expand All @@ -12,4 +12,4 @@ void IntConstant::Print(std::ostream& stream) const
stream << value_;
}

} // namespace AST
} // namespace ast
4 changes: 2 additions & 2 deletions src/ast_direct_declarator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_direct_declarator.hpp"

namespace AST {
namespace ast {

void DirectDeclarator::EmitRISC(std::ostream& stream, Context& context) const
{
Expand All @@ -13,4 +13,4 @@ void DirectDeclarator::Print(std::ostream& stream) const
identifier_->Print(stream);
}

} // namespace AST
} // namespace ast
2 changes: 1 addition & 1 deletion src/ast_function_definition.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_function_definition.hpp"

namespace AST {
namespace ast {

void FunctionDefinition::EmitRISC(std::ostream& stream, Context& context) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/ast_identifier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_identifier.hpp"

namespace AST {
namespace ast {

void Identifier::EmitRISC(std::ostream& stream, Context& context) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/ast_jump_statement.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_jump_statement.hpp"

namespace AST {
namespace ast {

void ReturnStatement::EmitRISC(std::ostream& stream, Context& context) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/ast_node.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_node.hpp"

namespace AST {
namespace ast {

void NodeList::PushBack(Node* item)
{
Expand Down
4 changes: 2 additions & 2 deletions src/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "cli.h"
#include "ast.hpp"

using AST::NodePtr;
using ast::NodePtr;

NodePtr Parse(const CommandLineArguments& args);

Expand Down Expand Up @@ -59,7 +59,7 @@ void Compile(const NodePtr& root, const CommandLineArguments& args)
{
// Create a Context. This can be used to pass around information about
// what's currently being compiled (e.g. function scope and variable names).
AST::Context ctx;
ast::Context ctx;

std::cout << "Compiling parsed AST..." << std::endl;
std::ofstream output(args.compile_output_path, std::ios::trunc);
Expand Down
2 changes: 1 addition & 1 deletion src/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%code requires{
#include "ast.hpp"

using namespace AST;
using namespace ast;

extern Node* g_root;
extern FILE* yyin;
Expand Down
10 changes: 5 additions & 5 deletions src/parser_full.y.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
%code requires{
#include "ast.hpp"

extern Node *g_root;
extern FILE *yyin;
extern Node* g_root;
extern FILE* yyin;
int yylex(void);
void yyerror(const char *);
}

// Represents the value associated with any kind of AST node.
%union{
Node *node;
NodeList *nodes;
Node* node;
NodeList* nodes;
int number_int;
double number_float;
std::string *string;
std::string* string;
yytokentype token;
}

Expand Down

0 comments on commit 6f51c7e

Please sign in to comment.