Reference

Class

RiGrammar

Name

expand

Description Expands a grammar from the supplied rule. If no rule is provided the $start and <start> symbols will be checked respectively.

If a context is needed, it should be passed in when the grammar is created (see 3rd example below).
Example
rg = RiTa.grammar(rules); 
result = rg.expand();

rg = RiTa.grammar(rules);
result = rg.expand(ruleName);

rg = RiTa.grammar(rules, context);
result = rg.expand(ruleName);
Parameters
Stringthe rule name to be expanded (optional)
Object
(or Map in Java)
(optional) options

{boolean} options.trace:
if true, output verbose log to console for debugging (default=false)

{boolean} options.onepass:
if true, run only one pass through the parser (default=false)

{boolean} options.v2Compatible:
if true, use RiScript v2-compatible syntax (default=false)
Returns
Stringthe result of the expansion (or an error if the rule is not found)
Syntax
expand();
expand(ruleName);
Platform Java / JavaScript