I am new to Lezer and parser grammar in general. The only tool I found to rapidly iterate is lezer-playground which seems a bit outdated.
I am trying parse nanDeck script files which is heavily directive based.
I wrote a fairly hacked together grammar by following some examples from php and js grammars but the problem i have is commonly ambiguity and the differentiation of directives and variable assignments which are the same syntax structure.
; this is a comment
[foo] = "bar" ; a variable,
Directive = arguments, [... arguments]
<frame> = x, y, w, h ; a special type of variable that makes a segment on the canvas
[copyHeight] = 1cm ; a length value
<copy> = <frame, TS, [copyHeight]> ; a reference to a frame with using the last height in <frame>s children as the Y of copy
[r]=1.18
[cx]=4.83
[cy]=7.38
LAYER=100 ; like svg G making the opacity 100%
ELLIPSE=[all],[cx],[cy],[r],[r],#000000 ; variables passed into a directive and a color value
ENDLAYER
What I saw with PHP grammar is that it was written with specialization on identifiers for functions like for and if.
link to grammar https://gist.github.com/cmargroff/2a252aa7e3c3a38583a600e3ff0f965e
I make no claims that I 100% know what I was writing.