From c5cf9aa53070cc7339a9ff02641fe1f1846b931d Mon Sep 17 00:00:00 2001 From: falsycat Date: Sun, 3 Jan 2021 00:00:00 +0000 Subject: [PATCH] Improves performance in skipping comment. --- TODO.TXT | 2 +- biner.l | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/TODO.TXT b/TODO.TXT index ed861b3..976313c 100644 --- a/TODO.TXT +++ b/TODO.TXT @@ -1,4 +1,4 @@ - resolve all TODO in source codes +X resolve all TODO in source codes remove f16/f32/f64 types partial code generation for C (divide decls and functions) release v1.0.1 diff --git a/biner.l b/biner.l index c98bf4b..a58ce7c 100644 --- a/biner.l +++ b/biner.l @@ -20,11 +20,18 @@ D [0-9] I [A-Za-z_] H [0-9A-Fa-f] +%x IN_COMMENT + %% [ \t\r\n]+ count_(); "//".* count_(); -[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] count_(); /* TODO: detect unterminated comment */ + +"/*" { count_(); BEGIN(IN_COMMENT); } +"*/" { count_(); BEGIN(INITIAL); } +[^\*\n]+ count_(); +"*" count_(); +"\n" count_(); "==" { count_(); return EQUAL; } "!=" { count_(); return NEQUAL; }