This module is the basic Erlang parser which converts tokens into the abstract form of either forms (i.e., top-level constructs), expressions, or terms. Note that a token list must end with the dot token in order to be acceptable to the parse functions (see erl_scan).
parse_form(Tokens) -> {ok, AbsForm} | {error, ErrorInfo}
Tokens = [Token]Token = {Tag,Line} | {Tag,Line,term()}Tag = atom()AbsForm = term()ErrorInfo = see section Error Information below.This function parses Tokens as if it were a form. It returns:
{ok, AbsForm}AbsForm.
{error, ErrorInfo}parse_exprs(Tokens) -> {ok, Expr_list} | {error, ErrorInfo}
Tokens = [Token]Token = {Tag,Line} | {Tag,Line,term()}Tag = atom()Expr_list = [AbsExpr]AbsExpr = term()ErrorInfo = see section Error Information below.This function parses Tokens as if it were a list of expressions. It returns:
{ok, Expr_list}Expr_list is a list
of the form AbsExpr, which is described in the
section Abstract
Form below.
{error, ErrorInfo}parse_term(Tokens) -> {ok, Term} | {error, ErrorInfo}
Tokens = [Token]Token = {Tag,Line} | {Tag,Line,term()}Tag = atom()Term = term()ErrorInfo = see section Error Information below.This function parses Tokens as if it were a term. It returns:
{ok, Term}Term is
the Erlang term corresponding to the token list.
{error, ErrorInfo}format_error(ErrorDescriptor) -> string()
ErrorDescriptor = errordesc()Uses an ErrorDescriptor and returns a string
which describes the error. This function is usually called
implicitly when an ErrorInfo structure is processed
(see below).
tokens(AbsTerm) -> Tokens
tokens(AbsTerm, MoreTokens) -> Tokens
Tokens = MoreTokens = [Token]Token = {Tag,Line} | {Tag,Line,term()}Tag = atom()AbsTerm = term()ErrorInfo = see section Error Information below.This function generates a list of tokens representing the abstract
form AbsTerm of an expression. Optionally, it appends
Moretokens.
AbsTerm = Data = term()Converts the abstract form AbsTerm of a term into a
conventional Erlang data structure (i.e., the term itself).
This is the inverse of abstract/1.
Data = AbsTerm = term()Converts the Erlang data structure Data into an
abstract form of type AbsTerm. This is the inverse of
normalise/1.
To be supplied
The ErrorInfo mentioned above is the standard
ErrorInfo structure which is returned from all IO
modules. It has the format:
{ErrorLine, Module, ErrorDescriptor}A string which describes the error is obtained with the following call:
apply(Module, format_error, ErrorDescriptor)