[svn] r6452: nemerle/trunk/ncc/parsing: Lexer.n PreParser.n
nazgul
svnadmin at nemerle.org
Thu Jul 20 22:01:30 CEST 2006
Log:
Fix changes in Lexer in case of indentation syntax. Some cleanup
Author: nazgul
Date: Thu Jul 20 22:01:24 2006
New Revision: 6452
Modified:
nemerle/trunk/ncc/parsing/Lexer.n
nemerle/trunk/ncc/parsing/PreParser.n
Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n (original)
+++ nemerle/trunk/ncc/parsing/Lexer.n Thu Jul 20 22:01:24 2006
@@ -267,54 +267,6 @@
throw PragmaIndent ()
}
}
-
- do_read () : char
- {
- mutable ch = read_from_input ();
- // Message.Debug (Location, $"ch = '$ch'");
-
- match (ch)
- {
- | '\n' => ++line; col = 1;
-
- | '\t' =>
- ++col;
- when (is_check_wrong_chars)
- Message.Warning (10002, this.Location, "tab character found in input stream")
-
- | '\r' =>
- if (peek_from_input_or_white () != '\n')
- ch = '\n'; // \r is alone here, so we change it to newline
- else
- when (is_check_wrong_chars)
- Message.Warning (10002, this.Location, "CR character found in input stream");
-
- | _ => ++col;
- };
-
- when (in_indentation_mode) {
- // Start counting indentation anew after a newline
- if (ch == '\n') {
- // Message.Debug (Location, $"start");
- indent_string = "";
- counting_indentation = true;
- //Message.Debug (Location (file_idx, line, col), "countingIndentation ON");
- }
- else when (counting_indentation) {
- if (ch == '\t' || ch == ' ')
- indent_string += ch.ToString();
- // We have a non-space character, so stop counting indentation
- // and indicate that we have a new line to process
- else {
- // Message.Debug (Location, $"stop");
- counting_indentation = false;
- insert_indent = true;
- }
- }
- }
-
- ch
- }
#endregion
@@ -366,8 +318,8 @@
}
abstract protected read_from_input () : char;
- abstract protected peek_from_input_or_white () : char;
- abstract protected peek_from_input () : char;
+ abstract protected peek_or_white () : char;
+ abstract protected peek () : char;
public abstract Dispose () : void;
@@ -376,19 +328,51 @@
is_check_wrong_chars = Manager.Options.Warnings.IsEnabled (10002);
}
- protected virtual read () : char
+ protected read () : char
{
- do_read ();
- }
+ mutable ch = read_from_input ();
+ // Message.Debug (Location, $"ch = '$ch'");
- protected peek_or_white () : char
+ match (ch)
{
- peek_from_input_or_white ()
- }
+ | '\n' => ++line; col = 1;
- protected peek () : char
- {
- peek_from_input ();
+ | '\t' =>
+ ++col;
+ when (is_check_wrong_chars)
+ Message.Warning (10002, this.Location, "tab character found in input stream")
+
+ | '\r' =>
+ if (peek_or_white () != '\n')
+ ch = '\n'; // \r is alone here, so we change it to newline
+ else
+ when (is_check_wrong_chars)
+ Message.Warning (10002, this.Location, "CR character found in input stream");
+
+ | _ => ++col;
+ };
+
+ when (in_indentation_mode) {
+ // Start counting indentation anew after a newline
+ if (ch == '\n') {
+ // Message.Debug (Location, $"start");
+ indent_string = "";
+ counting_indentation = true;
+ insert_indent = true;
+ //Message.Debug (Location (file_idx, line, col), "countingIndentation ON");
+ }
+ else when (counting_indentation) {
+ if (ch == '\t' || ch == ' ')
+ indent_string += ch.ToString();
+ // We have a non-space character, so stop counting indentation
+ // and indicate that we have a new line to process
+ else {
+ // Message.Debug (Location, $"stop");
+ counting_indentation = false;
+ }
+ }
+ }
+ ch
}
public static IsIdBeginning (ch : char) : bool
@@ -1425,7 +1409,7 @@
}
- override protected peek_from_input () : char
+ override protected peek () : char
{
def inp = reader.Peek ();
if (inp >= 0)
@@ -1434,7 +1418,7 @@
throw LexerBase.Error ("unexpected end of file")
}
- override protected peek_from_input_or_white () : char
+ override protected peek_or_white () : char
{
def inp = reader.Peek ();
if (inp >= 0)
@@ -1560,7 +1544,7 @@
public override Dispose () : void { }
- override protected peek_from_input () : char
+ override protected peek () : char
{
if (pos < reader.Length)
reader[pos]
@@ -1568,7 +1552,7 @@
throw LexerBase.Error ("unexpected end of file")
}
- override protected peek_from_input_or_white () : char
+ override protected peek_or_white () : char
{
if (pos < reader.Length)
reader[pos]
Modified: nemerle/trunk/ncc/parsing/PreParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParser.n (original)
+++ nemerle/trunk/ncc/parsing/PreParser.n Thu Jul 20 22:01:24 2006
@@ -356,7 +356,7 @@
| t => push_back (t); ([x], tok1.Location)
}
| t =>
- Message.Error (t.Location, "expected qualified identifier");
+ Message.Error (t.Location, $"expected qualified identifier, got token $t");
push_back (t);
([], Location.Default)
}
More information about the svn
mailing list