optimize code

This commit is contained in:
ValKmjolnir 2023-08-21 21:35:34 +08:00
parent 939b4c4a65
commit 00449c2bfb
2 changed files with 16 additions and 13 deletions

View File

@ -11,11 +11,11 @@ bool lexer::skip(char c) {
}
bool lexer::is_id(char c) {
return (c=='_') || ('a'<=c && c<='z') || ('A'<=c && c<='Z') || (c<0);
return (c=='_') || std::isalpha(c) || (c<0);
}
bool lexer::is_hex(char c) {
return ('0'<=c && c<='9') || ('a'<=c && c<='f') || ('A'<=c && c<='F');
return std::isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c<='F');
}
bool lexer::is_oct(char c) {
@ -23,7 +23,7 @@ bool lexer::is_oct(char c) {
}
bool lexer::is_dec(char c) {
return '0'<=c && c<='9';
return std::isdigit(c);
}
bool lexer::is_str(char c) {

View File

@ -63,7 +63,10 @@ var highlight_style="
font-size: small;
text-align: left;
}
code.key{color: #f895e7;}
code.key {
color: #f895e7;
font-weight: bold;
}
code.id {color: #8abef0;}
code.opr {color: #f895e7;}
code.brace {color: #eafd70;}