Switch to using header guards instead of pragma once

This commit is contained in:
Abdelrahman Said 2025-06-08 20:25:19 +01:00
parent 9cbb61939d
commit aa800e4201
11 changed files with 38 additions and 7 deletions

View File

@ -1,4 +1,5 @@
#pragma once #ifndef ERROR_HANDLER_HH
#define ERROR_HANDLER_HH
#include <string> #include <string>
@ -9,3 +10,5 @@ struct ErrorHandler {
bool had_error; bool had_error;
}; };
#endif

View File

@ -1,6 +1,6 @@
#include "interpreter.hh" #include "interpreter.hh"
#include "error_handler.hh" #include "error_handler.hh"
#include "scanner.hh" #include "tokenizer.hh"
#include <cstdint> #include <cstdint>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>

View File

@ -1,3 +1,6 @@
#pragma once #ifndef INTERPRETER_HH
#define INTERPRETER_HH
void run_interpreter(int argc, char *argv[]); void run_interpreter(int argc, char *argv[]);
#endif

View File

@ -1,4 +1,5 @@
#pragma once #ifndef OBJECT_HH
#define OBJECT_HH
#include <cstdint> #include <cstdint>
#include <iostream> #include <iostream>
@ -33,3 +34,5 @@ struct Object {
std::ostream &operator<<(std::ostream &os, const ObjectType &type); std::ostream &operator<<(std::ostream &os, const ObjectType &type);
std::ostream &operator<<(std::ostream &os, const Object &obj); std::ostream &operator<<(std::ostream &os, const Object &obj);
#endif

View File

@ -1,7 +1,7 @@
#include "scanner.hh" #include "scanner.hh"
#include "token.hh" #include "token.hh"
#include "error_handler.hh"
#include "object.hh" #include "object.hh"
#include "../error_handler.hh"
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -1,4 +1,5 @@
#pragma once #ifndef SCANNER_HH
#define SCANNER_HH
#include "token.hh" #include "token.hh"
#include <cstddef> #include <cstddef>
@ -29,3 +30,5 @@ struct Scanner {
std::size_t start, current, line; std::size_t start, current, line;
std::unordered_map<std::string, TokenType> keywords; std::unordered_map<std::string, TokenType> keywords;
}; };
#endif

View File

@ -1,4 +1,5 @@
#pragma once #ifndef TOKEN_HH
#define TOKEN_HH
#include "object.hh" #include "object.hh"
#include <cstdint> #include <cstdint>
@ -39,3 +40,5 @@ struct Token {
std::ostream &operator<<(std::ostream &os, const TokenType &type); std::ostream &operator<<(std::ostream &os, const TokenType &type);
std::ostream &operator<<(std::ostream &os, const Token &token); std::ostream &operator<<(std::ostream &os, const Token &token);
#endif

8
cclox_src/tokenizer.cc Normal file
View File

@ -0,0 +1,8 @@
#ifndef TOKENIZER_CC
#define TOKENIZER_CC
#include "scanner/object.cc"
#include "scanner/token.cc"
#include "scanner/scanner.cc"
#endif

8
cclox_src/tokenizer.hh Normal file
View File

@ -0,0 +1,8 @@
#ifndef TOKENIZER_HH
#define TOKENIZER_HH
#include "scanner/object.hh"
#include "scanner/token.hh"
#include "scanner/scanner.hh"
#endif