示例#1
0
    global indent_level, start_column
    if loc.s < len(loc.buf):
        print('WHITESPACE', loc.s, len(loc.buf), repr(chr(loc.buf[loc.s])))
    else:
        print('WHITESPACE', loc.s, len(loc.buf))
    while loc.s < len(loc.buf):
        c = chr(loc.buf[loc.s])
        if c == '\n':
            start_column = 0
        elif c.isspace():
            start_column += 1
        #TODO Remove # to end of line
        else:  # c is not whitespace, so start_column is new indent level
            return
        loc.s += 1


p = Parser()
print(dir(p))
p.inserted_thing = 'YAH'
#print(p.parse('2+3+4', initial_skip_space_fn=whitespace).getStructure())
#print()

s = open('numbo3.farg', 'r').read()
x = p.parse(s, initial_skip_space_fn=whitespace)
print(x.getStructure())
generate_code(x.getStructure())

#print()
#y = p.parse("   blah\nx\n", initial_skip_space_fn=whitespace)