pub fn parse_with(parser: &Tabnas, src: &str) -> Result<Value, Json5Error>Expand description
Parse a JSON5 source with a parser that carries the plugin: the
counterpart of the Go Parse(j, src) and of the parse the
TypeScript plugin wraps.
This is the entry point the plugin’s behaviour is specified against.
It applies the one thing the engine’s own Tabnas::parse cannot do
from inside a plugin, the requireValue rule: with the option on (the
default) an empty source is json5_empty and a whitespace-only or
comments-only one is json5_no_value; with it off, every such source
is the grammar’s declared empty result, null. Everything else,
string line continuations included, is the instance’s own, so
Tabnas::parse reads it the same way and reports the same
positions.
A parser that does not carry the plugin is parsed as it is.
let parser = tabnas_json5::make();
let error = tabnas_json5::parse_with(&parser, "// only a comment").unwrap_err();
assert_eq!(error.code, "json5_no_value");