aboutsummaryrefslogtreecommitdiff
path: root/nodes.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2012-12-26 18:50:49 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2012-12-26 18:50:49 +0200
commit31f72e0a9170e15e372377aa0064a92f31363079 (patch)
tree8a3edb42d7bb4177058e774a381fba049a6563d4 /nodes.py
parent7a6713bfe87b2c8d61f5a0800f08ade01fdf93ea (diff)
downloadmeson-31f72e0a9170e15e372377aa0064a92f31363079.zip
meson-31f72e0a9170e15e372377aa0064a92f31363079.tar.gz
meson-31f72e0a9170e15e372377aa0064a92f31363079.tar.bz2
Build AST.
Diffstat (limited to 'nodes.py')
-rw-r--r--nodes.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/nodes.py b/nodes.py
index 0a2f154..850cffb 100644
--- a/nodes.py
+++ b/nodes.py
@@ -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.')