Reference

Class

RiGrammar

Name

addRule

Description Adds a rule to the existing grammar, replacing any existing rule with the same name.
Example
rg = new RiGrammar();
rg.addRule("start", "$animal");
rg.addRule("animal", "cat | dog | chicken");


// To add weights, specify them inline with brackets

rg.addRule("animal", "cat [4] | dog | chicken");
Parameters
Stringthe rule name
String or String[]the rule definition
Returns
Objectthis RiGrammar object
Syntax
addRule(name, definition);
Platform Java / JavaScript