From 6f51c7eca43911e5a7d4a3e1440f7b03f72588de Mon Sep 17 00:00:00 2001 From: Simon Staal Date: Thu, 7 Mar 2024 22:45:56 +0000 Subject: [PATCH] Addressed some PR comments --- include/ast.hpp | 2 +- include/ast_constant.hpp | 4 ++-- include/ast_context.hpp | 6 +++--- include/ast_direct_declarator.hpp | 4 ++-- include/ast_function_definition.hpp | 4 ++-- include/ast_identifier.hpp | 4 ++-- include/ast_jump_statement.hpp | 4 ++-- include/ast_node.hpp | 4 ++-- include/ast_type_specifier.hpp | 2 +- src/ast_constant.cpp | 4 ++-- src/ast_direct_declarator.cpp | 4 ++-- src/ast_function_definition.cpp | 2 +- src/ast_identifier.cpp | 2 +- src/ast_jump_statement.cpp | 2 +- src/ast_node.cpp | 2 +- src/compiler.cpp | 4 ++-- src/parser.y | 2 +- src/parser_full.y.example | 10 +++++----- 18 files changed, 33 insertions(+), 33 deletions(-) diff --git a/include/ast.hpp b/include/ast.hpp index a3d618b..3c3321d 100644 --- a/include/ast.hpp +++ b/include/ast.hpp @@ -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); diff --git a/include/ast_constant.hpp b/include/ast_constant.hpp index 455bf98..7f30138 100644 --- a/include/ast_constant.hpp +++ b/include/ast_constant.hpp @@ -2,7 +2,7 @@ #include "ast_node.hpp" -namespace AST { +namespace ast { class IntConstant : public Node { @@ -16,4 +16,4 @@ class IntConstant : public Node void Print(std::ostream& stream) const override; }; -} // namespace AST +} // namespace ast diff --git a/include/ast_context.hpp b/include/ast_context.hpp index e2393ee..a00dae9 100644 --- a/include/ast_context.hpp +++ b/include/ast_context.hpp @@ -1,7 +1,7 @@ #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 @@ -9,4 +9,4 @@ class Context /* TODO decide what goes inside here */ }; -} // namespace AST +} // namespace ast diff --git a/include/ast_direct_declarator.hpp b/include/ast_direct_declarator.hpp index d48611f..389ff9f 100644 --- a/include/ast_direct_declarator.hpp +++ b/include/ast_direct_declarator.hpp @@ -2,7 +2,7 @@ #include "ast_node.hpp" -namespace AST { +namespace ast { class DirectDeclarator : public Node { @@ -16,4 +16,4 @@ class DirectDeclarator : public Node void Print(std::ostream& stream) const override; }; -} // namespace AST +} // namespace ast diff --git a/include/ast_function_definition.hpp b/include/ast_function_definition.hpp index 703e527..f96c33d 100644 --- a/include/ast_function_definition.hpp +++ b/include/ast_function_definition.hpp @@ -3,7 +3,7 @@ #include "ast_node.hpp" #include "ast_type_specifier.hpp" -namespace AST { +namespace ast { class FunctionDefinition : public Node { @@ -19,4 +19,4 @@ class FunctionDefinition : public Node void Print(std::ostream& stream) const override; }; -} // namespace AST +} // namespace ast diff --git a/include/ast_identifier.hpp b/include/ast_identifier.hpp index 2ec2577..d0539ae 100644 --- a/include/ast_identifier.hpp +++ b/include/ast_identifier.hpp @@ -2,7 +2,7 @@ #include "ast_node.hpp" -namespace AST { +namespace ast { class Identifier : public Node { @@ -16,4 +16,4 @@ class Identifier : public Node void Print(std::ostream& stream) const override; }; -} // namespace AST +} // namespace ast diff --git a/include/ast_jump_statement.hpp b/include/ast_jump_statement.hpp index 4340e8f..a0d0108 100644 --- a/include/ast_jump_statement.hpp +++ b/include/ast_jump_statement.hpp @@ -2,7 +2,7 @@ #include "ast_node.hpp" -namespace AST { +namespace ast { class ReturnStatement : public Node { @@ -16,4 +16,4 @@ class ReturnStatement : public Node void Print(std::ostream& stream) const override; }; -} // namespace AST +} // namespace ast diff --git a/include/ast_node.hpp b/include/ast_node.hpp index 7710040..76b4fbd 100644 --- a/include/ast_node.hpp +++ b/include/ast_node.hpp @@ -6,7 +6,7 @@ #include "ast_context.hpp" -namespace AST { +namespace ast { class Node { @@ -34,4 +34,4 @@ class NodeList : public Node virtual void Print(std::ostream& stream) const override; }; -} // namespace AST +} // namespace ast diff --git a/include/ast_type_specifier.hpp b/include/ast_type_specifier.hpp index 40e373b..35d9c5d 100644 --- a/include/ast_type_specifier.hpp +++ b/include/ast_type_specifier.hpp @@ -3,7 +3,7 @@ #include #include -namespace AST { +namespace ast { enum class TypeSpecifier { diff --git a/src/ast_constant.cpp b/src/ast_constant.cpp index 7e21695..21759c0 100644 --- a/src/ast_constant.cpp +++ b/src/ast_constant.cpp @@ -1,6 +1,6 @@ #include "ast_constant.hpp" -namespace AST { +namespace ast { void IntConstant::EmitRISC(std::ostream& stream, Context& context) const { @@ -12,4 +12,4 @@ void IntConstant::Print(std::ostream& stream) const stream << value_; } -} // namespace AST +} // namespace ast diff --git a/src/ast_direct_declarator.cpp b/src/ast_direct_declarator.cpp index 8c5f7ea..ab0e19c 100644 --- a/src/ast_direct_declarator.cpp +++ b/src/ast_direct_declarator.cpp @@ -1,6 +1,6 @@ #include "ast_direct_declarator.hpp" -namespace AST { +namespace ast { void DirectDeclarator::EmitRISC(std::ostream& stream, Context& context) const { @@ -13,4 +13,4 @@ void DirectDeclarator::Print(std::ostream& stream) const identifier_->Print(stream); } -} // namespace AST +} // namespace ast diff --git a/src/ast_function_definition.cpp b/src/ast_function_definition.cpp index 11e1adb..17cc200 100644 --- a/src/ast_function_definition.cpp +++ b/src/ast_function_definition.cpp @@ -1,6 +1,6 @@ #include "ast_function_definition.hpp" -namespace AST { +namespace ast { void FunctionDefinition::EmitRISC(std::ostream& stream, Context& context) const { diff --git a/src/ast_identifier.cpp b/src/ast_identifier.cpp index b4cd8b0..b598fe1 100644 --- a/src/ast_identifier.cpp +++ b/src/ast_identifier.cpp @@ -1,6 +1,6 @@ #include "ast_identifier.hpp" -namespace AST { +namespace ast { void Identifier::EmitRISC(std::ostream& stream, Context& context) const { diff --git a/src/ast_jump_statement.cpp b/src/ast_jump_statement.cpp index 9799a77..bd90e85 100644 --- a/src/ast_jump_statement.cpp +++ b/src/ast_jump_statement.cpp @@ -1,6 +1,6 @@ #include "ast_jump_statement.hpp" -namespace AST { +namespace ast { void ReturnStatement::EmitRISC(std::ostream& stream, Context& context) const { diff --git a/src/ast_node.cpp b/src/ast_node.cpp index a64fe27..50fecfb 100644 --- a/src/ast_node.cpp +++ b/src/ast_node.cpp @@ -1,6 +1,6 @@ #include "ast_node.hpp" -namespace AST { +namespace ast { void NodeList::PushBack(Node* item) { diff --git a/src/compiler.cpp b/src/compiler.cpp index bbb8880..2794b94 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -4,7 +4,7 @@ #include "cli.h" #include "ast.hpp" -using AST::NodePtr; +using ast::NodePtr; NodePtr Parse(const CommandLineArguments& args); @@ -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); diff --git a/src/parser.y b/src/parser.y index 9dd1fe8..f3f286e 100644 --- a/src/parser.y +++ b/src/parser.y @@ -7,7 +7,7 @@ %code requires{ #include "ast.hpp" - using namespace AST; + using namespace ast; extern Node* g_root; extern FILE* yyin; diff --git a/src/parser_full.y.example b/src/parser_full.y.example index 29a4148..1861858 100644 --- a/src/parser_full.y.example +++ b/src/parser_full.y.example @@ -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; }