Skip to content

Commit

Permalink
Fix comparison of integers of different signs
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-rZM committed Jan 28, 2025
1 parent 8619f3d commit 1402d2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions include/symbol_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ struct symbol_table {
st_{{EOL_, {TERMINAL, EOL_}}, {EPSILON_, {TERMINAL, EPSILON_}}};

/// @brief Token types, mapping each symbol to a unique integer ID.
inline static std::unordered_map<std::string, int> token_types_{{EOL_, 1}};
inline static std::unordered_map<std::string, unsigned long> token_types_{{EOL_, 1}};

/// @brief Reverse mapping from integer token IDs back to symbols.
inline static std::unordered_map<int, std::string> token_types_r_{
inline static std::unordered_map<unsigned long, std::string> token_types_r_{
{1, EOL_}};

/// @brief Tracks insertion order of token types.
inline static std::vector<int> order_{1};
inline static std::vector<unsigned long> order_{1};

/// @brief Current index for assigning new token IDs, starting from 2.
inline static int i_{2};
inline static unsigned long i_{2};

/**
* @brief Adds a terminal symbol with its associated regex to the symbol
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lexer::lexer(std::string filename)
}

template <typename Lexer> lexer::parse_input<Lexer>::parse_input() {
int i{1};
unsigned long i{1};
std::string token_type{symbol_table::token_types_r_.at(i)};
this->self.add("\\" + symbol_table::EOL_, i);
++i;
Expand Down

0 comments on commit 1402d2d

Please sign in to comment.