diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2014-03-16 22:26:22 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2014-03-16 22:26:22 +0200 |
commit | 5658127392c422f4760675fd23844402ea81d975 (patch) | |
tree | 228fb3af3533987cd7a25df2f2f9d23eabf609af /interpreter.py | |
parent | 889e4b03c02dc01f194c9affa230591dce83e0da (diff) | |
download | meson-5658127392c422f4760675fd23844402ea81d975.zip meson-5658127392c422f4760675fd23844402ea81d975.tar.gz meson-5658127392c422f4760675fd23844402ea81d975.tar.bz2 |
Here we go, starting parser transplant.
Diffstat (limited to 'interpreter.py')
-rw-r--r-- | interpreter.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/interpreter.py b/interpreter.py index 3205d4b..d25b251 100644 --- a/interpreter.py +++ b/interpreter.py @@ -13,6 +13,7 @@ # limitations under the License. import mparser +import parsertest as mparser2 import nodes import environment import coredata @@ -608,7 +609,7 @@ class Interpreter(): raise InvalidCode('Builder file is empty.') assert(isinstance(code, str)) try: - self.ast = mparser.build_ast(code) + self.ast = mparser2.Parser(code).parse() except coredata.MesonException as me: me.file = environment.build_filename raise me @@ -665,12 +666,12 @@ class Interpreter(): return self.variables def sanity_check_ast(self): - if not isinstance(self.ast, nodes.CodeBlock): + if not isinstance(self.ast, mparser2.CodeBlockNode): raise InvalidCode('AST is of invalid type. Possibly a bug in the parser.') - if len(self.ast.get_statements()) == 0: + if len(self.ast.lines) == 0: raise InvalidCode('No statements in code.') - first = self.ast.get_statements()[0] - if not isinstance(first, nodes.FunctionCall) or first.get_function_name() != 'project': + first = self.ast.lines[0] + if not isinstance(first, mparser2.FunctionNode) or first.func_name != 'project': raise InvalidCode('First statement must be a call to project') def run(self): @@ -679,18 +680,20 @@ class Interpreter(): def evaluate_codeblock(self, node): if node is None: return - if not isinstance(node, nodes.CodeBlock): + if not isinstance(node, mparser2.CodeBlockNode): e = InvalidCode('Tried to execute a non-codeblock. Possibly a bug in the parser.') - e.lineno = node.lineno() + e.lineno = node.lineno + e.colno = node.colno raise e - statements = node.get_statements() + statements = node.lines i = 0 while i < len(statements): cur = statements[i] try: self.evaluate_statement(cur) except Exception as e: - e.lineno = cur.lineno() + e.lineno = cur.lineno + e.colno = cur.colno e.file = os.path.join(self.subdir, 'meson.build') raise e i += 1 # In THE FUTURE jump over blocks and stuff. |