def generate_dot(): """Read source code, generate DOT file, and print it to STDOUT. If source file name is not provided on the command line defaults to STDIN. """ if len(sys.argv) != 2: source = sys.stdin.read() else: source = open(sys.argv[1]).read() parser = Parser(Lexer(source), interpreter=Interpreter()) parser.parse() visualizer = ASTVisualizer(parser.root) print visualizer
def _get_parser(self, text): from tinypie.lexer import Lexer from tinypie.parser import Parser from tinypie.scope import GlobalScope class Interpreter(object): global_scope = GlobalScope() parser = Parser(Lexer(text), interpreter=Interpreter()) return parser
def interpret(self, text): """Interprete passed source code.""" parser = Parser(Lexer(text), interpreter=self) parser.parse() tree = parser.root self._block(tree)