If I'm reading the source code correctly, nearley uses JSON.stringify to generate the errors it throws.
Unfortunately, as a result, if the token from a custom tokenizer includes a value field of type BigInt, rather than getting a useful error message, the actual error thrown is Type Error: Do not know how to serialize a BigInt, because JSON.stringify cannot serialize BigInts.
Is there a way to have nearley use a custom serializer for tokens when generating errors?
If I'm reading the source code correctly, nearley uses
JSON.stringify
to generate the errors it throws.Unfortunately, as a result, if the token from a custom tokenizer includes a value field of type
BigInt
, rather than getting a useful error message, the actual error thrown isType Error: Do not know how to serialize a BigInt
, becauseJSON.stringify
cannot serializeBigInt
s.Is there a way to have nearley use a custom serializer for tokens when generating errors?