@@ -0,0 +1,1160 @@
+#!/usr/bin/env python3%0A%0Afrom parser import char, End, FileStream, Invalid, parse%0A%0A%0Aclass Header(object):%0A    def __init__(self, name, depth):%0A        self.name = name%0A        self.depth = depth%0A        self.parent = None%0A        self.children = %5B%5D%0A%0A    def __repr__(self):%0A        return %22%3CHeader: %7B%7D%3E%22.format(self.name)%0A%0A    def add_child(self, child):%0A        child.parent = self%0A        self.children.append(child)%0A%0A%0Adef line(s):%0A    dots = 0%0A    while True:%0A        c = s.get()%0A        if c == '.':%0A            dots += 1%0A        elif c == ' ':%0A            break%0A        else:%0A            raise Invalid()%0A    name = ''%0A    while True:%0A        c = s.get()%0A        if c == '%5Cn':%0A            break%0A        name += c%0A    return Header(name, dots)%0A%0A%0Adef list(s):%0A    headers = %5B%5D%0A    try:%0A        while True:%0A            headers.append(parse(s, line, exc=End))%0A    except End:%0A        pass%0A%0A    root = Header('', 0)%0A    depth = 0%0A    prev = root%0A    for curr in headers:%0A        for i in range(prev.depth - curr.depth + 1):%0A            prev = prev.parent%0A        prev.add_child(curr)%0A        prev = curr%0A%0A    return root%0A%0A%0As = FileStream('includes')%0Ax = list(s)%0A

Add include_parser.py