Closed milahu closed 2 years ago
aah! whitespace ...
this works
# add
1+2
==>
Nix(Add(Int,Int))
You get this if you set strict
to true. There is no syntax tree when a strict parse fails.
can we make @lezer/generator/dist/test.js more verbose?
run: function (parser) {
var strict = !/⚠|\.\.\./.test(expected);
if (parser.configure && (strict || config))
parser = parser.configure(__assign({ strict: strict }, config));
//testTree(parser.parse(text), expected, mayIgnore);
let actual;
try {
// FIXME parser.configure is redundant
actual = parser.configure(__assign({ strict: strict }, config)).parse(text);
}
catch (e) {
// https://github.com/lezer-parser/lr/blob/main/src/parse.ts#L300
if (e.message.startsWith("No parse at ")) {
const pos = parseInt(e.message.slice("No parse at ".length));
e.message += `\n ${text}\n ${" ".repeat(pos)}^`;
}
throw e;
}
testTree(actual, expected, mayIgnore);
}
sample output
1) expression
add:
SyntaxError: No parse at 1
1 + 2
^
at Parse.advance
at Parser.parse
at run
at Context.<anonymous>
at processImmediate
im trying to parse the nix language and im failing to parse
1 + 2
running
npm run test
throwswhich is not helpful, and i found no docs for this error
how can i see the actual vs expected syntax tree?
reproduce
nix.grammar
expression.txt