[svn] r5859: nemerle/trunk/ncc: parsing/PreParserIndent.n
testsuite/positive/indentation-syntax.n
malekith
svnadmin at nemerle.org
Fri Oct 28 00:17:57 CEST 2005
Log:
Handle \ at the end of the line to prevent adding semicolon. Maybe it should also prevent {?.
Author: malekith
Date: Fri Oct 28 00:17:56 2005
New Revision: 5859
Modified:
nemerle/trunk/ncc/parsing/PreParserIndent.n
nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n
Modified: nemerle/trunk/ncc/parsing/PreParserIndent.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParserIndent.n (original)
+++ nemerle/trunk/ncc/parsing/PreParserIndent.n Fri Oct 28 00:17:56 2005
@@ -43,6 +43,7 @@
mutable had_some_real_input : bool;
mutable force_brace_after_newline : bool;
+ mutable skip_semicolon : bool;
indent_strings : Stack [string] = Stack (20);
tokens_pending : Queue [Token] = Queue ();
@@ -71,6 +72,10 @@
unless (lexer_tok is Token.EndOfFile)
had_some_real_input = true;
+ when (skip_semicolon)
+ throw PreParserException (lexer_tok.Location,
+ "unexpected `\\' in middle of a line");
+
match (lexer_tok) {
| Token.EndOfFile =>
insertLocation = lexer_tok.Location;
@@ -86,6 +91,9 @@
tokens_pending.Push (lexer_tok);
+ | Token.Operator ("\\") =>
+ skip_semicolon = true;
+
| BeginBrace
| BeginRound
| BeginSquare
@@ -160,7 +168,7 @@
| tok =>
handle_real_token (tok);
- tokens_pending.Take ()
+ get_token ()
}
}
catch {
@@ -194,6 +202,9 @@
get_token_after_indent (tok, new_indent)
| _ =>
+ def add_semicolon = had_some_real_input && !skip_semicolon;
+ skip_semicolon = false;
+
// If we have not unindented
if (new_indent.Length >= CurrentIndent.Length) {
// Make sure that the beginning of the new indent string
@@ -205,9 +216,10 @@
// If we have remained at the same indentation level
if (new_indent == CurrentIndent) {
- when (had_some_real_input)
+ when (add_semicolon) {
//Message.Debug (tok.Location, $"Generate ';'");
tokens_pending.Push (Token.Semicolon (insertLocation, true));
+ }
handle_real_token (tok);
}
Modified: nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n Fri Oct 28 00:17:56 2005
@@ -6,10 +6,14 @@
// 7. Add two kinds of line-continuation
using System.Console
+using Nemerle.Utility
set namespace Test
set class App
+[Accessor] \
+static some_field : int = 12;
+
static Main() : void
// 3.
Write("Hello")
@@ -37,12 +41,14 @@
def d = a +
c
WriteLine($"c = $c, d = $d")
+ WriteLine(SomeField)
/*
BEGIN-OUTPUT
Hello, World!
n > 0
c = 3, d = 4
+12
END-OUTPUT
*/
More information about the svn
mailing list