enum -> enum class in lexer
This makes enum elements scoped which is actually quite useful as I prefer the namespacing that enum's give in C++.
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
/* Copyright (C) 2024 Aryadev Chavali
|
/* Copyright (C) 2024 Aryadev Chavali
|
||||||
|
|
||||||
* You may distribute and modify this code under the terms of the GPLv2
|
* You may distribute and modify this code under the terms of the
|
||||||
* license. You should have received a copy of the GPLv2 license with
|
* GPLv2 license. You should have received a copy of the GPLv2
|
||||||
* this file. If not, please write to: aryadev@aryadevchavali.com.
|
* license with this file. If not, please write to:
|
||||||
|
* aryadev@aryadevchavali.com.
|
||||||
|
|
||||||
* Created: 2024-04-14
|
* Created: 2024-04-14
|
||||||
* Author: Aryadev Chavali
|
* Author: Aryadev Chavali
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
enum token_type_t
|
enum class token_type_t
|
||||||
{
|
{
|
||||||
PP_CONST, // %const(<symbol>)...
|
PP_CONST, // %const(<symbol>)...
|
||||||
PP_USE, // %use <string>
|
PP_USE, // %use <string>
|
||||||
@@ -80,7 +80,7 @@ struct token_t
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &, token_t &);
|
std::ostream &operator<<(std::ostream &, token_t &);
|
||||||
|
|
||||||
enum lerr_t
|
enum class lerr_t
|
||||||
{
|
{
|
||||||
OK = 0,
|
OK = 0,
|
||||||
INVALID_CHAR_LITERAL,
|
INVALID_CHAR_LITERAL,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ int main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
std::cerr << file_name << ":" << line << ":" << col << ":"
|
std::cerr << file_name << ":" << line << ":" << col << ":"
|
||||||
<< lerr_as_cstr(lerr) << std::endl;
|
<< lerr_as_cstr(lerr) << std::endl;
|
||||||
ret = 255 - lerr;
|
ret = 255 - static_cast<int>(lerr);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user