Unit Test Parsing #340
-
Is there an example that exists to demonstrate how to unit test parsing of concrete syntax? I'm accustomed to using injecting a ParseHelper with Xtext to invoke lexing and parsing, and then validating the result, but I assume that I'd need to write my own ParseHelper for Langium, but I'm not really sure where to start. Greg |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @ballcoach12, we actually provide a You can see how it works in action: It basically creates a curried function based on an instance of |
Beta Was this translation helpful? Give feedback.
Hi @ballcoach12,
we actually provide a
parseHelper
function, but it's exported from thelangium/lib/test
path of the framework.You can see how it works in action:
https://github.com/langium/langium/blob/850f92226032aaa74a4695d5d8847a9a3026332f/packages/langium/test/parser/token-builder.test.ts#L27
It basically creates a curried function based on an instance of
LangiumServices
. Afterwards you can throw in any text and get aLangiumDocument
back.