aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2021-07-24 14:14:32 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2021-07-25 21:36:52 +0300
commitbf41d56597349a7047f2034e3e3e00d4502220cc (patch)
treea3d0e03a3c71c037a38eea4977e1ebf42b0e1c07 /mesonbuild
parent61ec2158609dcd30b9f4e0389cae558fdcdd298d (diff)
downloadmeson-bf41d56597349a7047f2034e3e3e00d4502220cc.zip
meson-bf41d56597349a7047f2034e3e3e00d4502220cc.tar.gz
meson-bf41d56597349a7047f2034e3e3e00d4502220cc.tar.bz2
ast: Add dummy "support" for fstrings in the ast package
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/ast/interpreter.py4
-rw-r--r--mesonbuild/ast/printer.py7
-rw-r--r--mesonbuild/ast/visitor.py3
3 files changed, 14 insertions, 0 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index 99c6979..19b3a1d 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -197,6 +197,10 @@ class AstInterpreter(InterpreterBase):
def method_call(self, node: BaseNode) -> bool:
return True
+ def evaluate_fstring(self, node: mparser.FormatStringNode) -> str:
+ assert(isinstance(node, mparser.FormatStringNode))
+ return node.value
+
def evaluate_arithmeticstatement(self, cur: ArithmeticNode) -> int:
self.evaluate_statement(cur.left)
self.evaluate_statement(cur.right)
diff --git a/mesonbuild/ast/printer.py b/mesonbuild/ast/printer.py
index f535c2f..f185449 100644
--- a/mesonbuild/ast/printer.py
+++ b/mesonbuild/ast/printer.py
@@ -70,6 +70,10 @@ class AstPrinter(AstVisitor):
assert isinstance(node.value, str)
self.append("'" + node.value + "'", node)
+ def visit_FormatStringNode(self, node: mparser.FormatStringNode) -> None:
+ assert isinstance(node.value, str)
+ self.append("f'" + node.value + "'", node)
+
def visit_ContinueNode(self, node: mparser.ContinueNode) -> None:
self.append('continue', node)
@@ -256,6 +260,9 @@ class AstJSONPrinter(AstVisitor):
def visit_StringNode(self, node: mparser.StringNode) -> None:
self.gen_ElementaryNode(node)
+ def visit_FormatStringNode(self, node: mparser.FormatStringNode) -> None:
+ self.gen_ElementaryNode(node)
+
def visit_ArrayNode(self, node: mparser.ArrayNode) -> None:
self._accept('args', node.args)
self.setbase(node)
diff --git a/mesonbuild/ast/visitor.py b/mesonbuild/ast/visitor.py
index 0f2265c..34a76a8 100644
--- a/mesonbuild/ast/visitor.py
+++ b/mesonbuild/ast/visitor.py
@@ -36,6 +36,9 @@ class AstVisitor:
def visit_StringNode(self, node: mparser.StringNode) -> None:
self.visit_default_func(node)
+ def visit_FormatStringNode(self, node: mparser.FormatStringNode) -> None:
+ self.visit_default_func(node)
+
def visit_ContinueNode(self, node: mparser.ContinueNode) -> None:
self.visit_default_func(node)