Based on the examples above, if I want to test my own grammar, I need to prepare files in the following format:
# <maybe test case name>
<code here>
==>
<grammar node here>
Then, in a TypeScript test file, I use the fileTests function to run the test.
My question is:
Is this the only way to do it? Because this approach requires me to manually write the <grammar node> structure in every test file.
Is there a way to test using my defined grammar directly—without manually writing the <grammar node> each time?
# Variable declaration
var a = b
, c = d;
const [x] = y = 3;
==>
Script(
VariableDeclaration(var,VariableDefinition,Equals,VariableName,VariableDefinition,Equals,VariableName),
VariableDeclaration(const,ArrayPattern(VariableDefinition),Equals,AssignmentExpression(VariableName,Equals,Number)))