I have written this grammar:
@top Document { markup+ }
@skip {
whitespaces
}
@tokens {
whitespaces { @whitespace+ }
}
@local tokens {
star { "*" }
@else text
}
markup {
Strong
}
@skip {} {
Strong {
star text star
}
}
However, when I compile the grammar, there is an error message:
$ rollup -c
./src/typst.grammar → ./dist/index.js, ./dist/index.cjs...
[!] (plugin rollup-plugin-lezer) Error: Could not load /home/meowking/proj/personal/lezer-typst/src/typst.grammar: Tokens from a local token group used together with other tokens (star with whitespaces) (/home/meowking/proj/personal/lezer-typst/src/typst.grammar 1:1)
I don’t understand why star
is mixed with whitespaces
since I have used the @skip {}
rule, which should exclude the whitespaces
skip rule. My guess is @skip { whitespaces }
indicates whitespaces is possible to be everywhere in Document
, which conflicts with Document { markup+}
(only allow markup
).
Does anyone know why this problem occurs and how to fix it while using local tokens group?
Thanks!