diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2012-12-26 18:50:49 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2012-12-26 18:50:49 +0200 |
commit | 31f72e0a9170e15e372377aa0064a92f31363079 (patch) | |
tree | 8a3edb42d7bb4177058e774a381fba049a6563d4 /nodes.py | |
parent | 7a6713bfe87b2c8d61f5a0800f08ade01fdf93ea (diff) | |
download | meson-31f72e0a9170e15e372377aa0064a92f31363079.zip meson-31f72e0a9170e15e372377aa0064a92f31363079.tar.gz meson-31f72e0a9170e15e372377aa0064a92f31363079.tar.bz2 |
Build AST.
Diffstat (limited to 'nodes.py')
-rw-r--r-- | nodes.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -68,10 +68,21 @@ class CodeBlock(Statement): def __init__(self): Statement.__init__(self) self.statements = [] + + def prepend(self, statement): + self.statements = [statement] + self.statements + +class Arguments(Statement): + def __init__(self): + Statement.__init__(self) + self.arguments = [] + + def prepend(self, statement): + self.arguments = [statement] + self.arguments def statement_from_expression(expr): - if type(expr) == type(AtomExpression(None)): + if isinstance(expr, AtomExpression): return AtomStatement(expr.value) - if type(expr) == type(StringExpression(None)): + if isinstance(expr, StringExpression): return StringStatement(expr.value) raise RuntimeError('Can not convert unknown expression to a statement.') |