If you’re desperate/creative you can used the parseMixed
feature. First, create your base grammar which contains Either
. Then define a second grammar that can parse the contents of Either; in this case Number
and Letter
. Finally, do something like
baseParser.configure({
wrap: parseMixed((node) =>
node.type.is(Either) ? { parser: eitherParser } : null,
),
})
There is extra complexity when dealing with a mixed language, and it isn’t as powerful as an integrated grammar, but hey you’re desperate