From aa800e4201ed11264a51be710f7ab4a72316579c Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 8 Jun 2025 20:25:19 +0100 Subject: [PATCH] Switch to using header guards instead of pragma once --- cclox_src/error_handler.hh | 5 ++++- cclox_src/interpreter.cc | 2 +- cclox_src/interpreter.hh | 5 ++++- cclox_src/{ => scanner}/object.cc | 0 cclox_src/{ => scanner}/object.hh | 5 ++++- cclox_src/{ => scanner}/scanner.cc | 2 +- cclox_src/{ => scanner}/scanner.hh | 5 ++++- cclox_src/{ => scanner}/token.cc | 0 cclox_src/{ => scanner}/token.hh | 5 ++++- cclox_src/tokenizer.cc | 8 ++++++++ cclox_src/tokenizer.hh | 8 ++++++++ 11 files changed, 38 insertions(+), 7 deletions(-) rename cclox_src/{ => scanner}/object.cc (100%) rename cclox_src/{ => scanner}/object.hh (94%) rename cclox_src/{ => scanner}/scanner.cc (99%) rename cclox_src/{ => scanner}/scanner.hh (93%) rename cclox_src/{ => scanner}/token.cc (100%) rename cclox_src/{ => scanner}/token.hh (95%) create mode 100644 cclox_src/tokenizer.cc create mode 100644 cclox_src/tokenizer.hh diff --git a/cclox_src/error_handler.hh b/cclox_src/error_handler.hh index 503ac03..5d22a85 100644 --- a/cclox_src/error_handler.hh +++ b/cclox_src/error_handler.hh @@ -1,4 +1,5 @@ -#pragma once +#ifndef ERROR_HANDLER_HH +#define ERROR_HANDLER_HH #include @@ -9,3 +10,5 @@ struct ErrorHandler { bool had_error; }; + +#endif diff --git a/cclox_src/interpreter.cc b/cclox_src/interpreter.cc index bb6b9f0..a495c02 100644 --- a/cclox_src/interpreter.cc +++ b/cclox_src/interpreter.cc @@ -1,6 +1,6 @@ #include "interpreter.hh" #include "error_handler.hh" -#include "scanner.hh" +#include "tokenizer.hh" #include #include #include diff --git a/cclox_src/interpreter.hh b/cclox_src/interpreter.hh index 8917050..43bf306 100644 --- a/cclox_src/interpreter.hh +++ b/cclox_src/interpreter.hh @@ -1,3 +1,6 @@ -#pragma once +#ifndef INTERPRETER_HH +#define INTERPRETER_HH void run_interpreter(int argc, char *argv[]); + +#endif diff --git a/cclox_src/object.cc b/cclox_src/scanner/object.cc similarity index 100% rename from cclox_src/object.cc rename to cclox_src/scanner/object.cc diff --git a/cclox_src/object.hh b/cclox_src/scanner/object.hh similarity index 94% rename from cclox_src/object.hh rename to cclox_src/scanner/object.hh index 00dfa55..605cc6a 100644 --- a/cclox_src/object.hh +++ b/cclox_src/scanner/object.hh @@ -1,4 +1,5 @@ -#pragma once +#ifndef OBJECT_HH +#define OBJECT_HH #include #include @@ -33,3 +34,5 @@ struct Object { std::ostream &operator<<(std::ostream &os, const ObjectType &type); std::ostream &operator<<(std::ostream &os, const Object &obj); + +#endif diff --git a/cclox_src/scanner.cc b/cclox_src/scanner/scanner.cc similarity index 99% rename from cclox_src/scanner.cc rename to cclox_src/scanner/scanner.cc index 2bd0668..57f0bf4 100644 --- a/cclox_src/scanner.cc +++ b/cclox_src/scanner/scanner.cc @@ -1,7 +1,7 @@ #include "scanner.hh" #include "token.hh" -#include "error_handler.hh" #include "object.hh" +#include "../error_handler.hh" #include #include diff --git a/cclox_src/scanner.hh b/cclox_src/scanner/scanner.hh similarity index 93% rename from cclox_src/scanner.hh rename to cclox_src/scanner/scanner.hh index e819094..00febb6 100644 --- a/cclox_src/scanner.hh +++ b/cclox_src/scanner/scanner.hh @@ -1,4 +1,5 @@ -#pragma once +#ifndef SCANNER_HH +#define SCANNER_HH #include "token.hh" #include @@ -29,3 +30,5 @@ struct Scanner { std::size_t start, current, line; std::unordered_map keywords; }; + +#endif diff --git a/cclox_src/token.cc b/cclox_src/scanner/token.cc similarity index 100% rename from cclox_src/token.cc rename to cclox_src/scanner/token.cc diff --git a/cclox_src/token.hh b/cclox_src/scanner/token.hh similarity index 95% rename from cclox_src/token.hh rename to cclox_src/scanner/token.hh index ed88260..032e13e 100644 --- a/cclox_src/token.hh +++ b/cclox_src/scanner/token.hh @@ -1,4 +1,5 @@ -#pragma once +#ifndef TOKEN_HH +#define TOKEN_HH #include "object.hh" #include @@ -39,3 +40,5 @@ struct Token { std::ostream &operator<<(std::ostream &os, const TokenType &type); std::ostream &operator<<(std::ostream &os, const Token &token); + +#endif diff --git a/cclox_src/tokenizer.cc b/cclox_src/tokenizer.cc new file mode 100644 index 0000000..5d142a9 --- /dev/null +++ b/cclox_src/tokenizer.cc @@ -0,0 +1,8 @@ +#ifndef TOKENIZER_CC +#define TOKENIZER_CC + +#include "scanner/object.cc" +#include "scanner/token.cc" +#include "scanner/scanner.cc" + +#endif diff --git a/cclox_src/tokenizer.hh b/cclox_src/tokenizer.hh new file mode 100644 index 0000000..546936e --- /dev/null +++ b/cclox_src/tokenizer.hh @@ -0,0 +1,8 @@ +#ifndef TOKENIZER_HH +#define TOKENIZER_HH + +#include "scanner/object.hh" +#include "scanner/token.hh" +#include "scanner/scanner.hh" + +#endif