I’m trying to write a syntax for the Zig language. This is what I have so far (gist, because it’s quite long):
It works fine on this input:
const @"e" = "32";
var b = 42;
var c = "ae" and hurr;
const foo = struct {
const bar = union {
garr, barr
};
foo: u32,
};
fn myfunction(arr: u32, knarr: bool) bool {
var foo = "bar";
}
test "foo" {
var foo = bar;
var bao = far;
var c = d;
const a = struct {
foo: bar,
};
}
However, when I replacevar foo = bar;
in test "foo"
, with var foo = bar{};
, syntax highlighting stops working and Nova starts using 100% CPU. I figure Nova runs into some kind of endless loop while applying the syntax, but I cannot figure out what goes wrong. In particular, I disabled the portion of the syntax that would parse the {}
suffix here, and the error did not go away.
The behavior of the editor is also curios:
For some reason it highlights foo
, the succeeding space, and the final semicolon. I have no idea why this happens but I feel that this might be related to the problem I run into. This doesn’t happen after adding {}
because then the editor stops doing this kind of highlight alltogether.
I am aware that the syntax is quite long so I do not expect someone to tell me what specifically is wrong with it. What I am asking for is how to debug this syntax and whether there may be a Nova bug that leads to the full CPU usage. The extension console does not help me as it doesn’t show how the syntax is applied. An option that details the parser descending/navigating the sublevels of the syntax would be extremely helpful.