aboutsummaryrefslogtreecommitdiff
path: root/src/z/parser/js/grammar/root.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-08-04 22:28:25 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-08-04 22:28:25 +0200
commit356c2bc0ccb1794b5ec219079d8c5b85ddcc4c87 (patch)
treedefa9a0e3c46af6e59e3be3d3ac1482c8fad24c8 /src/z/parser/js/grammar/root.zig
parent06d1607aabad0a967c0500efe305de3fa732f8d3 (diff)
add templates to tokenizer
Diffstat (limited to 'src/z/parser/js/grammar/root.zig')
-rw-r--r--src/z/parser/js/grammar/root.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/z/parser/js/grammar/root.zig b/src/z/parser/js/grammar/root.zig
index 03b386e..56f3990 100644
--- a/src/z/parser/js/grammar/root.zig
+++ b/src/z/parser/js/grammar/root.zig
@@ -11,6 +11,7 @@
const std = @import("std");
const parser = @import("../../root.zig");
+
pub const Lexer = parser.Lexer(Grammar);
pub const Token = parser.Token(Grammar);
@@ -28,7 +29,12 @@ pub const Grammar = union(enum) {
identifier: Identifier,
end_of_file: void,
+ pub const Context = struct {
+ template_nesting: usize = 0,
+ };
+
pub inline fn tokenize(comptime lexer: *Lexer) Lexer.Error!void {
+ @setEvalBranchQuota(lexer.buffer.len * 1000);
comptime {
while (lexer.peekChar()) |_| {
Whitespace.tokenize(lexer) catch {
@@ -50,3 +56,10 @@ pub const Grammar = union(enum) {
test {
_ = std.testing.refAllDecls(@This());
}
+
+test "z.js" {
+ comptime var lexer: Lexer = .init(@embedFile("../../../z.js"));
+ Grammar.tokenize(&lexer) catch |err| {
+ std.debug.print("error: {} at {s}", .{ err, lexer.buffer });
+ };
+}