Merge: doc: fixed some typos and other misc. corrections
[nit.git] / src / astutil.nit
index c671e87..7e3a068 100644 (file)
@@ -71,7 +71,7 @@ redef class Prod
        # var ast = (new ToolContext).parse_something(text)
        # assert ast isa AExpr
        # ast.parentize_tokens
-       # assert ast.to_xml.write_to_string == """<ABlockExpr><ACallReassignExpr><TId>y</TId> <APlusAssignOp><TPluseq>+=</TPluseq></APlusAssignOp> <ACallExpr><TId>foo</TId></ACallExpr></ACallReassignExpr></ABlockExpr>"""
+       # assert ast.to_xml.write_to_string == """<ACallReassignExpr><AQid><TId>y</TId></AQid> <APlusAssignOp><TPluseq>+=</TPluseq></APlusAssignOp> <ACallExpr><AQid><TId>foo</TId></AQid></ACallExpr></ACallReassignExpr>"""
        # ~~~
        fun to_xml: HTMLTag
        do
@@ -278,13 +278,13 @@ private class PTokenVisitor
                else
                        p = last_token.common_parent(n)
                end
-               assert p isa Prod
-
-               # And apply it to detached tokens between `last_token` and `n`
-               var c = n.prev_token
-               while c != null and c.parent == null do
-                       c.parent = p
-                       c = c.prev_token
+               if p isa Prod then
+                       # And apply it to detached tokens between `last_token` and `n`
+                       var c = n.prev_token
+                       while c != null and c.parent == null do
+                               c.parent = p
+                               c = c.prev_token
+                       end
                end
 
                self.last_token = n