Esempio n. 1
0
import sys
from chatlang_lexer import *
from parser import *

if __name__ == "__main__":
    filename = sys.argv[1]
    code = open(filename).read()
    tokens = chatlang_lexer(code)
    parsed = chatlang_parse(tokens)
    if not parsed:
        sys.stderr.write('Parse error!\n')
        sys.exit(1)
    (ast, ), pos = parsed
    env = {}
    #import pdb;pdb.set_trace();
    ast.eval(env)

    for name in env:
        print name + ':', env[name]
Esempio n. 2
0
import sys
from chatlang_lexer import *
from parser import *

if __name__ == "__main__":
    filename = sys.argv[1]
    code = open(filename).read()
    tokens = chatlang_lexer(code)
    parsed = chatlang_parse(tokens)
    if not parsed:
        sys.stderr.write('Parse error!\n')
        sys.exit(1)
    (ast,), pos = parsed
    env = {}
    #import pdb;pdb.set_trace();
    ast.eval(env)

    for name in env:
        print name+':', env[name]
Esempio n. 3
0
import sys
from chatlang_lexer import *

if __name__ == '__main__':
    filename = sys.argv[1]
    file = open(filename)
    characters = file.read()
    file.close()
    tokens = chatlang_lexer(characters)
    for token in tokens:
        print token
Esempio n. 4
0
import sys
from chatlang_lexer import *

if __name__ == '__main__':
    filename = sys.argv[1]
    with open(filename) as f:
        characters = f.read()
    tokens = chatlang_lexer(characters)
    for token in tokens:
        print token