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++;