Parse.add_listform :
  {separator : string, leftdelim : string, rightdelim : string,
   cons : string, nilstr : string} -> unit

SYNOPSIS
Adds a ``list-form'' to the built-in grammar, allowing the parsing of strings such as [a; b; c] and {}.

LIBRARY
Parse

DESCRIBE
The add_listform function allows the user to augment the HOL parser with rules so that it can turn a string of the form
   <ld> str1 <sep> str2 <sep> ... strn <rd>
into the term
   <cons> t1 (<cons> t2 ... (<cons> tn <nilstr>))
where <ld> is the left delimiter string, <rd> the right delimiter, and <sep> is the separator string from the fields of the record argument to the function. The various stri are strings representing the ti terms. Further, the grammar will also parse <ld> <rd> into <nilstr>.

In common with the add_rule function, there is no requirement that the cons and nilstr fields be the names of constants; the parser/grammar combination will generate variables with these names if there are no corresponding constants.

The HOL pretty-printer is simultaneously aware of the new rule, and terms of the forms above will print appropriately.

FAILURE
Should never fail itself, but subsequent calls to the term parser may well fail if the strings chosen for the various fields above introduce precedence conflicts. For example, it will almost always be impossible to use left and right delimiters that are already present in the grammar, unless they are there as the left and right parts of a closefix.

EXAMPLE
The definition of the ``list-form'' for lists in the HOL distribution is:
   add_listform {separator = ";", leftdelim = "[", rightdelim = "]",
                 cons = "CONS", nilstr = "NIL"};
while the set syntax is defined similarly:
   add_listform {leftdelim = "{", rightdelim = "}", separator = ";",
                 cons = "INSERT", nilstr = "EMPTY"};

USES
Used to make sequential term structures print and parse more pleasingly.

COMMENTS
As with other parsing functions, there is a temp_add_listform version of this function, which has the same effect on the global grammar, but which does not cause this effect to persist when the current theory is exported.

SEEALSO  add_rule

HOL  Kananaskis 0