From 84adefa331c4159d432d22840663c38f155cd4c1 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 20 Nov 2009 14:54:40 +0000 Subject: The R13B03 release. --- lib/stdlib/doc/src/erl_parse.xml | 201 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 lib/stdlib/doc/src/erl_parse.xml (limited to 'lib/stdlib/doc/src/erl_parse.xml') diff --git a/lib/stdlib/doc/src/erl_parse.xml b/lib/stdlib/doc/src/erl_parse.xml new file mode 100644 index 0000000000..739fde7a40 --- /dev/null +++ b/lib/stdlib/doc/src/erl_parse.xml @@ -0,0 +1,201 @@ + + + + +
+ + 1996 + 2007 + Ericsson AB, All Rights Reserved + + + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + + The Initial Developer of the Original Code is Ericsson AB. + + + erl_parse + Robert + Bjarne Däcker + 1 + Bjarne Däcker + + 97-01-24 + B + erl_parse.sgml +
+ erl_parse + The Erlang Parser + +

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. The Abstract Format is described in the ERTS + User's Guide. + 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} + Parse an Erlang form + + 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} + +

The parsing was successful. AbsForm is the + abstract form of the parsed form.

+
+ {error, ErrorInfo} + +

An error occurred.

+
+
+
+
+ + parse_exprs(Tokens) -> {ok, Expr_list} | {error, ErrorInfo} + Parse Erlang expressions + + 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} + +

The parsing was successful. Expr_list is a + list of the abstract forms of the parsed expressions.

+
+ {error, ErrorInfo} + +

An error occurred.

+
+
+
+
+ + parse_term(Tokens) -> {ok, Term} | {error, ErrorInfo} + Parse an Erlang term + + 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} + +

The parsing was successful. Term is + the Erlang term corresponding to the token list.

+
+ {error, ErrorInfo} + +

An error occurred.

+
+
+
+
+ + format_error(ErrorDescriptor) -> Chars + Format an error descriptor + + ErrorDescriptor = errordesc() + Chars = [char() | Chars] + + +

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 + Generate a list of tokens for an expression + + 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.

+
+
+ + normalise(AbsTerm) -> Data + Convert abstract form to an Erlang term + + 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.

+
+
+ + abstract(Data) -> AbsTerm + Convert an Erlang term into an abstract form + + Data = AbsTerm = term() + + +

Converts the Erlang data structure Data into an + abstract form of type AbsTerm. This is the inverse of + normalise/1.

+
+
+
+ +
+ Error Information +

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) +
+ +
+ See Also +

io(3), + erl_scan(3), + ERTS User's Guide

+
+
+ -- cgit v1.2.3