diff --git a/artiq/py2llvm/ast_body.py b/artiq/py2llvm/ast_body.py index 3cba3a976..f9c635cb8 100644 --- a/artiq/py2llvm/ast_body.py +++ b/artiq/py2llvm/ast_body.py @@ -1,4 +1,4 @@ -import ast +from pythonparser import ast import llvmlite.ir as ll diff --git a/artiq/py2llvm/fractions.py b/artiq/py2llvm/fractions.py index c2a9730fa..2b3fa6fd4 100644 --- a/artiq/py2llvm/fractions.py +++ b/artiq/py2llvm/fractions.py @@ -1,5 +1,5 @@ import inspect -import ast +from pythonparser import parse, ast import llvmlite.ir as ll @@ -18,7 +18,7 @@ def _gcd(a, b): def init_module(module): - func_def = ast.parse(inspect.getsource(_gcd)).body[0] + func_def = parse(inspect.getsource(_gcd)).body[0] function, _ = module.compile_function(func_def, {"a": VInt(64), "b": VInt(64)}) function.linkage = "internal" diff --git a/artiq/py2llvm/infer_types.py b/artiq/py2llvm/infer_types.py index d02aeef36..7de53bab8 100644 --- a/artiq/py2llvm/infer_types.py +++ b/artiq/py2llvm/infer_types.py @@ -1,11 +1,12 @@ -import ast +import pythonparser.algorithm +from pythonparser import ast from copy import deepcopy from artiq.py2llvm.ast_body import Visitor from artiq.py2llvm import base_types -class _TypeScanner(ast.NodeVisitor): +class _TypeScanner(pythonparser.algorithm.Visitor): def __init__(self, env, ns): self.exprv = Visitor(env, ns) diff --git a/artiq/test/py2llvm.py b/artiq/test/py2llvm.py index 9f2948db8..7f01d983c 100644 --- a/artiq/test/py2llvm.py +++ b/artiq/test/py2llvm.py @@ -1,5 +1,5 @@ import unittest -import ast +from pythonparser import parse, ast import inspect from fractions import Fraction from ctypes import CFUNCTYPE, c_int, c_int32, c_int64, c_double @@ -43,7 +43,7 @@ def _base_types(choice): def _build_function_types(f): return infer_function_types( - None, ast.parse(inspect.getsource(f)), + None, parse(inspect.getsource(f)), dict()) @@ -111,7 +111,7 @@ class CompiledFunction: def __init__(self, function, param_types): module = Module() - func_def = ast.parse(inspect.getsource(function)).body[0] + func_def = parse(inspect.getsource(function)).body[0] function, retval = module.compile_function(func_def, param_types) argvals = [param_types[arg.arg] for arg in func_def.args.args] diff --git a/setup.py b/setup.py index 13f35efd8..44087dc4c 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import setup, find_packages requirements = [ "sphinx", "sphinx-argparse", "pyserial", "numpy", "scipy", "python-dateutil", "prettytable", "h5py", "pydaqmx", "pyelftools", - "quamash", "pyqtgraph" + "quamash", "pyqtgraph", "pythonparser" ] scripts = [