optimize lexer

This commit is contained in:
ValKmjolnir 2023-08-23 00:59:35 +08:00
parent 00449c2bfb
commit ba629e57d7
1 changed files with 2 additions and 2 deletions

View File

@ -15,7 +15,7 @@ bool lexer::is_id(char c) {
}
bool lexer::is_hex(char c) {
return std::isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c<='F');
return std::isxdigit(c);
}
bool lexer::is_oct(char c) {
@ -127,7 +127,7 @@ token lexer::id_gen() {
u32 begin_line = line;
u32 begin_column = column;
std::string str = "";
while(ptr<res.size() && (is_id(res[ptr])||is_dec(res[ptr]))) {
while(ptr<res.size() && (is_id(res[ptr]) || is_dec(res[ptr]))) {
if (res[ptr]<0) { // utf-8
str += utf8_gen();
} else { // ascii