about summary refs log tree commit diff
path: root/users/flokli/presentations/2023-09-09-nixcon-tvix/cppnix-example-lexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'users/flokli/presentations/2023-09-09-nixcon-tvix/cppnix-example-lexer.cpp')
-rw-r--r--users/flokli/presentations/2023-09-09-nixcon-tvix/cppnix-example-lexer.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/flokli/presentations/2023-09-09-nixcon-tvix/cppnix-example-lexer.cpp b/users/flokli/presentations/2023-09-09-nixcon-tvix/cppnix-example-lexer.cpp
new file mode 100644
index 000000000000..7c52bce8b6d2
--- /dev/null
+++ b/users/flokli/presentations/2023-09-09-nixcon-tvix/cppnix-example-lexer.cpp
@@ -0,0 +1,13 @@
+attrpath
+  : attrpath '.' attr {
+    $$ = $1; $1->push_back(AttrName(data->symbols.create($3)));
+  }
+  | attrpath '.' string_attr
+    { $$ = $1;
+      ExprString * str = dynamic_cast<ExprString *>($3);
+      if (str) {
+          $$->push_back(AttrName(data->symbols.create(str->s)));
+          delete str;
+      } else
+          $$->push_back(AttrName($3));
+    }