Module:ObjectArg/doc

Lua metamodule which parses complex object values. Exposes a single function,, which accepts a JSON-like string and returns the Lua representation of that string. The syntax of such values is described below. (The  library already provides functions for generating and parsing real JSON strings.)

The function returns 2 values:
 * If the function successfully parses the input string, the first return value contains the represented object and the second return value is.
 * If parsing fails, the first return value is  and the second return value is an error message string.

Tag
A tag is any string not containing the special characters,  ,  ,  ,  , or. Whenever possible, the module converts numeric strings to numbers using the built-in  function (in base 10). ASCII whitespace characters around tags are trimmed.

List
A list consists of zero or more values enclosed in square brackets and separated by semicolons. Values may be empty, in which case the resulting Lua table ceases to be a valid Lua sequence.

Hash
A hash consists of zero or more tag-value pairs enclosed in curly brackets and separated by semicolons. The tag and value are separated by the equals sign. Values may be empty, in which case the resulting Lua table does not contain an element with that value's corresponding key. Keys cannot be empty. Nested hashes coming from template arguments may avoid prematurely terminating the template, by separating consecutive closing curly brackets with whitespace or a semicolon.

Value
A value is either a tag, a list, or a hash. The top-level value is wholly represented by the input string, and cannot be empty.

Formal grammar
The following LL(1) grammar fully specifies the syntax of the strings accepted by this module, except that all ASCII whitespace characters between tokens are trimmed. V → T | [ L ] | { H }

V0 → V  | ε

H → T = V0 H' | ε

H' → ; H  | ε

L → V0 L'

L' → ; L  | ε

T → /[^=;\{\}\[\]]+/