A parser class for randomizing tables
This parser uses a format developed by Dr. J.M. "Thijs" Krijger matthijs.krijger@gmail.com. The parser class and documentation is written by Niklas Schönberg niko@uplink.fi and released under the GPL.
The class is used with a text string containing the tables (see format.md). The string can be given as the first argument in the constructor, and/or with the populate() method.
A result can then be generated by using the generate() method. This returns the generated result as a string.
The rawData is the table definition you wish to use. It's optional, but must be given at some point before generate() can be used. dataSetName is an optional name given for the data set, this is used with include instructions so that the parser can keep track of which data sets you have included.
This works in very much the same way as the constructor for rawData and dataSetName. The additional reset attribute is used to empty all previously included data sets and start from scratch.
Returns an array containing all records currently in the include stack. The stack is populated by "@dataSetName" instructions in a data set.
Returns one record from the include stack, and removes it from the stack.
Checks to see if a data set is loaded. Returns true or false. This (and most other include methods) only works as long as you provide the names of the data sets when you load them.
Generates and returns a string based on the loaded data set(s). If tableName is defined, that is the initial table. If not, the default table will be used. If keepSet is true, the set data will not be discarded. This means that items from sets can not repeat from the previous call. Variable data is always discarded.
Reads the value of a variable defined by the data set.
Writes a value into a variable. Note that any variable data will be discarded on generate() call, so this is only useful if you read the data with getVar().
Returns the currently active statement. This is basically just instructions on how to parse the data set.
Sets an active statement. Includes, "@dataSetName", are added to the include stack and removed from the active statement. If overwrite is false the statement is not written if not empty.