summary refs log tree commit diff stats
path: root/packages/docutils
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-10-03 20:49:43 +0200
committerAraq <rumpf_a@web.de>2012-10-03 20:49:43 +0200
commit9fbee85cc9dd95c1f99e5b55a3d382196eabb7fc (patch)
tree5b38a0d41d876a4c35d979d09a4d3ba8ecd30722 /packages/docutils
parentb28fcdfa93ccf132b878e7dcd26e36d48f107212 (diff)
downloadNim-9fbee85cc9dd95c1f99e5b55a3d382196eabb7fc.tar.gz
first steps for compiler as a service
Diffstat (limited to 'packages/docutils')
-rwxr-xr-xpackages/docutils/rst.nim15
1 files changed, 13 insertions, 2 deletions
diff --git a/packages/docutils/rst.nim b/packages/docutils/rst.nim
index 333ef11d9..debbd2520 100755
--- a/packages/docutils/rst.nim
+++ b/packages/docutils/rst.nim
@@ -818,7 +818,7 @@ proc getDirective(p: var TRstParser): string =
 proc parseComment(p: var TRstParser): PRstNode = 
   case p.tok[p.idx].kind
   of tkIndent, tkEof: 
-    if p.tok[p.idx + 1].kind == tkIndent: 
+    if p.tok[p.idx].kind != tkEof and p.tok[p.idx + 1].kind == tkIndent: 
       inc(p.idx)              # empty comment
     else: 
       var indent = p.tok[p.idx].ival
@@ -1348,9 +1348,20 @@ proc parseSectionWrapper(p: var TRstParser): PRstNode =
   while (result.kind == rnInner) and (len(result) == 1): 
     result = result.sons[0]
   
+proc `$`(t: TToken): string =
+  result = $t.kind & ' ' & (if isNil(t.symbol): "NIL" else: t.symbol)
+
 proc parseDoc(p: var TRstParser): PRstNode = 
   result = parseSectionWrapper(p)
-  if p.tok[p.idx].kind != tkEof: rstMessage(p, meGeneralParseError)
+  if p.tok[p.idx].kind != tkEof: 
+    when false:
+      assert isAllocatedPtr(cast[pointer](p.tok))
+      for i in 0 .. high(p.tok):
+        assert isNil(p.tok[i].symbol) or 
+               isAllocatedPtr(cast[pointer](p.tok[i].symbol))
+      echo "index: ", p.idx, " length: ", high(p.tok), "##",
+          p.tok[p.idx-1], p.tok[p.idx], p.tok[p.idx+1]
+    rstMessage(p, meGeneralParseError)
   
 type
   TDirFlag = enum