Exemplo n.º 1
0
def parse_string(s):
    """Parse the given string as a pub file and returns the ast."""
    ps = subprocess.Popen([_PARSER],
                          stdin=subprocess.PIPE,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
    raw_ast, stderr = ps.communicate(s)
    if ps.returncode:
        raise subprocess.CalledProcessError(ps.returncode, _PARSER, stderr)
    res = json.loads(raw_ast)
    return mk_file(res)
Exemplo n.º 2
0
def parse(file):
    """Parse the given file as a pub file and returns the ast."""
    res = json.loads(subprocess.check_output([_PARSER, "--", file]))
    return mk_file(res)
Exemplo n.º 3
0
def parse(file):
    """Parse the given file as a pub file and returns the ast."""
    res = json.loads(__pubast_checkoutput([_PARSER, "--", file]))
    return mk_file(res)