summary refs log tree commit diff stats
path: root/compiler/llstream.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-01-27 23:41:45 +0200
committerZahary Karadjov <zahary@gmail.com>2013-01-27 23:41:45 +0200
commit81a3585872b1a327b62ba528addbee913d6bbe5a (patch)
treeaff8358bc86704edbd89fd56ec4f7b0cd3583bca /compiler/llstream.nim
parent67f37264b3f461fe46f5cfea7c35c0a4f709dcb0 (diff)
parent07585088955c1fe8fb815c40409ed9f5d66fd446 (diff)
downloadNim-81a3585872b1a327b62ba528addbee913d6bbe5a.tar.gz
merged upstream master
Diffstat (limited to 'compiler/llstream.nim')
-rwxr-xr-xcompiler/llstream.nim17
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/llstream.nim b/compiler/llstream.nim
index 1d1722176..8ccf24b99 100755
--- a/compiler/llstream.nim
+++ b/compiler/llstream.nim
@@ -103,17 +103,24 @@ proc continueLine(line: string, inTripleString: bool): bool {.inline.} =
       line[0] == ' ' or
       line.endsWith(LineContinuationOprs+AdditionalLineContinuationOprs)
 
-proc LLreadFromStdin(s: PLLStream, buf: pointer, bufLen: int): int = 
-  var inTripleString = false
+proc countTriples(s: string): int =
+  var i = 0
+  while i < s.len:
+    if s[i] == '"' and s[i+1] == '"' and s[i+2] == '"':
+      inc result
+      inc i, 2
+    inc i
+
+proc LLreadFromStdin(s: PLLStream, buf: pointer, bufLen: int): int =
   s.s = ""
   s.rd = 0
   var line = newStringOfCap(120)
+  var triples = 0
   while ReadLineFromStdin(if s.s.len == 0: ">>> " else: "... ", line): 
     add(s.s, line)
     add(s.s, "\n")
-    if line.contains("\"\"\""):
-      inTripleString = not inTripleString
-    if not continueLine(line, inTripleString): break
+    inc triples, countTriples(line)
+    if not continueLine(line, (triples and 1) == 1): break
   inc(s.lineOffset)
   result = min(bufLen, len(s.s) - s.rd)
   if result > 0: