shithub: mc

Download patch

ref: f2afc8da2339dbfaaa7dd92abf63521ae38e6dd8
parent: 0f2de28c580dd78160230b5b973c903378527623
author: Ori Bernstein <[email protected]>
date: Tue Jul 23 11:40:14 EDT 2013

Allow splitting lines.

--- a/parse/parse.h
+++ b/parse/parse.h
@@ -259,7 +259,6 @@
 
 /* globals */
 extern char *filename;
-extern int ignorenl;    /* are '\n' chars currently stmt separators? */
 extern Tok *curtok;     /* the last token we tokenized */
 extern int line;        /* the last line number we tokenized */
 extern Node *file;      /* the current file we're compiling */
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -19,7 +19,6 @@
 
 char *filename;
 int line;
-int ignorenl;
 Tok *curtok;
 
 /* the file contents are stored globally */
@@ -130,17 +129,24 @@
 static void eatspace(void)
 {
     int c;
+    int ignorenl;
 
+    ignorenl = 0;
     while (1) {
         c = peek();
-        if ((!ignorenl && c == '\n'))
+        if (!ignorenl && c == '\n') {
+            ignorenl = 0;
             break;
-        else if (isspace(c))
+        } else if (c == '\\') {
+            ignorenl = 1;
             next();
-        else if (c == '/' && peekn(1) == '*')
+        } else if (isspace(c) || (ignorenl && c == '\n')) {
+            next();
+        } else if (c == '/' && peekn(1) == '*') {
             eatcomment();
-        else
+        } else {
             break;
+        }
     }
 }
 
--- /dev/null
+++ b/test/splitline.myr
@@ -1,0 +1,6 @@
+use std
+
+const main = {
+	-> 1 + \ /* ignored crap */
+	   2
+}
--- a/test/tests
+++ b/test/tests
@@ -14,6 +14,7 @@
 #	What we compare with. This should be self-
 #	evident.
 B main		E	0
+B splitline     E       3
 B add		E	53
 B mul		E	42
 B div		E	42