parse function

Map<String, dynamic> parse(
  1. String text, {
  2. Map<String, String>? env,
})

Parses the given text following the Gura configuration format.

Can be given an optional Map<String, String> env named argument containing key/value pairs to inject into the parser's environment variable snapshot for use within the text to be parsed.

Returns a Map<String, dynamic> containing all key/value pairs from the parsed Gura input.

Example:

String guraFileContents = File("foo_bar.ura").readAsStringSync();
Map<String, dynamic> gura = parse(guraFileContents, env: { 'foo': 'bar' });

Note: If a key in the given env Map already exists in the parser's env snapshot, it will be overwritten with the given Map's key/value

Implementation

Map<String, dynamic> parse(String text, {Map<String, String>? env})
{
	final _GuraParser parser = _GuraParser();

	// Add environment variables to the parser's env snapshot
	if (env != null)
		parser.env.addAll(env);

	return parser.parse(text);
}