about summary refs log tree commit diff
path: root/users/tazjin/presentations/tvix-eval-2023/cppnix-example-lexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/presentations/tvix-eval-2023/cppnix-example-lexer.cpp')
-rw-r--r--users/tazjin/presentations/tvix-eval-2023/cppnix-example-lexer.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/tazjin/presentations/tvix-eval-2023/cppnix-example-lexer.cpp b/users/tazjin/presentations/tvix-eval-2023/cppnix-example-lexer.cpp
new file mode 100644
index 0000000000..7c52bce8b6
--- /dev/null
+++ b/users/tazjin/presentations/tvix-eval-2023/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));
+    }