summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkugwa <kugwa2000@gmail.com>2015-11-09 16:03:40 +0800
committerkugwa <kugwa2000@gmail.com>2015-11-09 16:03:40 +0800
commitd7d90d6fbcafaf67e181a4046f2bedde851d1baa (patch)
tree0912f7980ed68dc40b52e8f55e3a638e3097b5eb
parentc2254537345aa1220a101393b903627ea4c70959 (diff)
downloadcompiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.tar
compiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.tar.gz
compiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.tar.bz2
compiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.tar.lz
compiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.tar.xz
compiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.tar.zst
compiler2015-d7d90d6fbcafaf67e181a4046f2bedde851d1baa.zip
Change the action of the comment token
Don't print comment. line_number increases when there are newlines in the comment.
-rw-r--r--src/lexer.l7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lexer.l b/src/lexer.l
index c670529..45e696b 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -109,7 +109,12 @@ ERROR .
{CONST_FLOAT} {}
{CONST_STRING} {}
-{COMMENT} puts(yytext);
+{COMMENT} {
+ int i;
+ for (i = 0; yytext[i]; i++)
+ if (yytext[i] == '\n')
+ line_number++;
+ }
{OP_ASSIGN} {}
{OP_OR} {}
{OP_AND} {}