From 98f2fc833757bf56cea0e54e2e91f3c8e7b7d11a Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 28 Apr 2012 11:51:47 -0300 Subject: [PATCH] b2/lang.l: reset lineno for new file and count newlines in comment --- b2/lang.l | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/b2/lang.l b/b2/lang.l index 55be66b..be252dd 100644 --- a/b2/lang.l +++ b/b2/lang.l @@ -24,13 +24,14 @@ extern int yyparse(void); static int start_token; static int expose_nl; -static int lineno = 1; +static int lineno; void parse_hierarchy(void) { start_token = START_HIERARCHY; expose_nl = 0; + lineno = 1; yyparse(); } @@ -39,6 +40,7 @@ void parse_characteristics(void) { start_token = START_CHAR; expose_nl = 1; + lineno = 1; yyparse(); } @@ -62,7 +64,9 @@ void parse_characteristics(void) ">=" return TOK_GE; "//"[^\n]* ; -"/*"([^*]|("*"+([^*/])))*"*"+"/" ; +"/*"([^*]|("*"+([^*/])))*"*"+"/" { const char *s = yytext; + while (*s) + lineno += *s++ == '\n'; } [ \t] ; \n { lineno++;