[svn] r6760: nemerle/trunk/ncc: parsing/Lexer.n
testsuite/negative/lexer.n
nazgul
svnadmin at nemerle.org
Sun Oct 15 23:55:29 CEST 2006
Log:
Fix handling of wrong code after line preprocessor directive
Author: nazgul
Date: Sun Oct 15 23:55:12 2006
New Revision: 6760
Modified:
nemerle/trunk/ncc/parsing/Lexer.n
nemerle/trunk/ncc/testsuite/negative/lexer.n
Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n (original)
+++ nemerle/trunk/ncc/parsing/Lexer.n Sun Oct 15 23:55:12 2006
@@ -1109,6 +1109,7 @@
if (c == '/') {
c = read_or_eol ();
unless (c == '/')
+ when (Message.ErrorCount <= 0)
Message.Warning (1696, "Single-line comment or end-of-line expected");
while (c != '\n')
c = read_or_eol ();
@@ -1200,11 +1201,24 @@
throw LexerBase.Error ("expecting line number or `default' indicator")
}
else {
- def num = StringBuilder (c.ToString ());
- while (Char.IsDigit (peek_or_white ()))
- ignore (num.Append (read ()));
-
+ def num = StringBuilder ();
+ def loop () {
+ ignore (num.Append (c));
+ c = peek_or_white ();
+ when (char.IsDigit (c)) {
+ _ = read ();
+ loop ();
+ }
+ }
+ when (char.IsDigit (c))
+ loop ();
+ if (num.Length > 0)
(Int32.Parse (num.ToString ()), read_to_the_end_of_line ().Trim ())
+ else {
+ Message.Error (this.Location, "expecting line number or `default' indicator");
+ _ = read_to_the_end_of_line ();
+ (-1, null)
+ }
};
if (new_line == -1) {
line = line - line_start + line_stack;
Modified: nemerle/trunk/ncc/testsuite/negative/lexer.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/lexer.n (original)
+++ nemerle/trunk/ncc/testsuite/negative/lexer.n Sun Oct 15 23:55:12 2006
@@ -2,6 +2,8 @@
/* */ #define AA // E: preprocessor directives must occur only in lines beginning with whitespaces
+#line // E: expecting line
+
module M {
Main () : void {
printf ("foo \g"); // E: bad escape character
More information about the svn
mailing list