From 1109dac6f8ad292192301a8df5207333d1479ea1 Mon Sep 17 00:00:00 2001 From: johanknol Date: Sun, 24 Jun 2001 17:31:29 +0000 Subject: [PATCH] a better fix for the \ line numbering issue git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@940 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCC.lex | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/src/SDCC.lex b/src/SDCC.lex index 9607a9d4..92061f16 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -44,7 +44,6 @@ extern char *filename ; extern char *fullSrcFileName ; int yylineno = 1 ; void count() ; -void comment(); int process_pragma(char *); #undef yywrap @@ -118,7 +117,6 @@ struct options save_options ; } *asmp++ = '\n' ; } -"/*" { comment(); } "at" { count(); TKEYWORD(AT) ; } "auto" { count(); return(AUTO); } "bit" { count(); TKEYWORD(BIT) ; } @@ -248,6 +246,7 @@ struct options save_options ; \\ { char ch=input(); if (ch!='\n') { + // that could have been removed by the preprocessor anyway werror (W_STRAY_BACKSLASH, column); unput(ch); } @@ -307,25 +306,6 @@ int checkCurrFile ( char *s) return 0; } -void comment() -{ - char c, c1; - - loop: - while ((c = input()) != '*' && c) { - if ( c == '\n') { - lineno=++yylineno; - } - } - - if (c && (c1 = input()) != '/') { - unput(c1); - goto loop; - } -} - - - int column = 0; int plineIdx=0; @@ -382,13 +362,10 @@ char *stringLiteral () { /* if it is a \ then escape char's are allowed */ if (ch == '\\') { ch=input(); - if (ch=='\r') { - // input() translates \n into \r\n - if ((ch=input())!='\n') { - unput (ch); - } + if (ch=='\n') { /* \ is a continuator */ lineno=++yylineno; + column=0; continue; } *str++ = '\\'; /* backslash in place */ @@ -397,14 +374,11 @@ char *stringLiteral () { } /* if new line we have a new line break, which is illegal */ - if (ch == '\r') { - // input() translates \n into \r\n - if ((ch=input())!='\n') { - unput (ch); - } + if (ch == '\n') { werror (W_NEWLINE_IN_STRING); *str++ = '\n'; lineno=++yylineno; + column=0; continue; } @@ -419,6 +393,9 @@ char *stringLiteral () { if ((ch=input())!='\n') { werror (W_STRAY_BACKSLASH, column); unput(ch); + } else { + lineno=++yylineno; + column=0; } break; case '\n': @@ -429,7 +406,7 @@ char *stringLiteral () { if (!ch) break; - + if (ch != '\"') { unput(ch) ; break ; -- 2.47.2