Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
    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
Beispiel #4
0
 def interpret(self, text):
     """Interprete passed source code."""
     parser = Parser(Lexer(text), interpreter=self)
     parser.parse()
     tree = parser.root
     self._block(tree)
Beispiel #5
0
 def interpret(self, text):
     """Interprete passed source code."""
     parser = Parser(Lexer(text), interpreter=self)
     parser.parse()
     tree = parser.root
     self._block(tree)