Improves performance in skipping comment.

This commit is contained in:
falsycat 2021-01-03 00:00:00 +00:00
parent 967dc2cf3f
commit c5cf9aa530
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,4 @@
resolve all TODO in source codes X resolve all TODO in source codes
remove f16/f32/f64 types remove f16/f32/f64 types
partial code generation for C (divide decls and functions) partial code generation for C (divide decls and functions)
release v1.0.1 release v1.0.1

View File

@ -20,11 +20,18 @@ D [0-9]
I [A-Za-z_] I [A-Za-z_]
H [0-9A-Fa-f] H [0-9A-Fa-f]
%x IN_COMMENT
%% %%
[ \t\r\n]+ count_(); [ \t\r\n]+ count_();
"//".* count_(); "//".* count_();
[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] count_(); /* TODO: detect unterminated comment */
<INITIAL>"/*" { count_(); BEGIN(IN_COMMENT); }
<IN_COMMENT>"*/" { count_(); BEGIN(INITIAL); }
<IN_COMMENT>[^\*\n]+ count_();
<IN_COMMENT>"*" count_();
<IN_COMMENT>"\n" count_();
"==" { count_(); return EQUAL; } "==" { count_(); return EQUAL; }
"!=" { count_(); return NEQUAL; } "!=" { count_(); return NEQUAL; }