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

@ -48,28 +48,31 @@ http.establish("127.0.0.1",8080);
var highlight_style="
<style>
body{
body {
background: #303030;
}
pre{
pre {
background: #303030;
font-family: 'Courier New', Courier, monospace;
font-size: small;
color: #d4d4d4;
}
code{
code {
color: white;
font-family: 'Courier New', Courier, monospace;
font-size: small;
text-align: left;
}
code.key{color: #f895e7;}
code.id{color: #8abef0;}
code.opr{color: #f895e7;}
code.brace{color: #eafd70;}
code.str{color: #a5ffd0;}
code.num{color: #ff9a41;}
code.note{color: #808080;}
code.key {
color: #f895e7;
font-weight: bold;
}
code.id {color: #8abef0;}
code.opr {color: #f895e7;}
code.brace {color: #eafd70;}
code.str {color: #a5ffd0;}
code.num {color: #ff9a41;}
code.note {color: #808080;}
</style>";
var html_read_file=func(filename){