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) { 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) { 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) { bool lexer::is_oct(char c) {
@ -23,7 +23,7 @@ bool lexer::is_oct(char c) {
} }
bool lexer::is_dec(char c) { bool lexer::is_dec(char c) {
return '0'<=c && c<='9'; return std::isdigit(c);
} }
bool lexer::is_str(char c) { bool lexer::is_str(char c) {

View File

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