Term input from strings

Author(s): Francisco Bueno, Daniel Cabeza, Manuel Hermenegildo, Jose F. Morales.

Stability: [devel] This implementation is incomplete


This module implements predicates for reading (parsing) terms from strings or atom codes.

Usage and interface

Documentation on exports

Usage:read_from_string(String,Term)

Read a term Term from String.

Usage:read_from_string(String,Term,Rest)

Read a term Term from String up to Rest (which is the non-parsed rest of the list).

Usage:read_from_string_opts(String,Term,Rest,Opts)

String is parsed into Term up to Rest (which is the non-parsed rest of the list). The options in Opts can be:

variable_names(Ns)
Read variable names in Ns.

Usage:read_from_string_atmvars(String,Term)

Read a term Term from String. Variables are converted to atoms with the name of the variable. It there is some rest of the string left after parsing the term, it is ignored (see read_from_string_atmvars/3).

Usage:read_from_string_atmvars(String,Term,Rest)

Read a term Term from String up to Rest (which is the non-parsed rest of the list). Unquoted uppercase identifiers (variables) are read as atoms instead of variables (thus, the read term is always ground).

Usage:read_from_atom_atmvars(Atom,Term)

Like read_from_string_atmvars/2, but reads the term Term from the atom codes in Atom.

Usage:read_from_atom(Atom,Term)

Read the term Term from the codes in the name of Atom.

Documentation on imports

This module has the following direct dependencies:

Known bugs and planned improvements

  • All predicates except read_from_atom/2 implement an incomplete grammar (e.g., operator priority is ignored). The good implementation should: a) create a read stream from a string, and b) call the standard reader.
  • read_from_atom/2 is implemented using pipe/2, which has deadlock problems (IO is synchronous and pipe buffer size is limited)