Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

erl_parse(3erl) [linux man page]

erl_parse(3erl) 					     Erlang Module Definition						   erl_parse(3erl)

NAME
erl_parse - The Erlang Parser DESCRIPTION
This module is the basic Erlang parser which converts tokens into the abstract form of either forms (i.e., top-level constructs), expres- sions, 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(3erl) ). EXPORTS
parse_form(Tokens) -> {ok, AbsForm} | {error, ErrorInfo} Types 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} Types 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} Types 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 Types 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 Types 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 Types 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 Types 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: Module:format_error(ErrorDescriptor) SEE ALSO
io(3erl) , erl_scan(3erl) , ERTS User's Guide Ericsson AB stdlib 1.17.3 erl_parse(3erl)

Check Out this Related Man Page

epp_dodger(3erl)					     Erlang Module Definition						  epp_dodger(3erl)

NAME
epp_dodger - epp_dodger - bypasses the Erlang preprocessor. DESCRIPTION
epp_dodger - bypasses the Erlang preprocessor. This module tokenises and parses most Erlang source code without expanding preprocessor directives and macro applications, as long as these are syntactically "well-behaved". Because the normal parse trees of the erl_parse module cannot represent these things (normally, they are expanded by the Erlang preprocessor epp(3erl) before the parser sees them), an extended syntax tree is created, using the erl_syntax mod- ule. DATA TYPES
errorinfo() = {ErrorLine::integer(), Module::atom(), Descriptor::term()} : This is a so-called Erlang I/O ErrorInfo structure; see the io(3erl) module for details. EXPORTS
parse(Dev::IODevice) -> {ok, Forms} | {error, errorinfo()} Equivalent to parse(IODevice, 1) . parse(Dev::IODevice, L::StartLine) -> {ok, Forms} | {error, errorinfo()} Types IODevice = pid() StartLine = integer() Forms = [syntaxTree() (see module erl_syntax)] Equivalent to parse(IODevice, StartLine, []) . See also: parse/1 . parse(Dev::IODevice, L0::StartLine, Options) -> {ok, Forms} | {error, errorinfo()} Types IODevice = pid() StartLine = integer() Options = [term()] Forms = [syntaxTree() (see module erl_syntax)] Reads and parses program text from an I/O stream. Characters are read from IODevice until end-of-file; apart from this, the behav- iour is the same as for parse_file/2 . StartLine is the initial line number, which should be a positive integer. See also: parse/2 , parse_file/2 , parse_form/2 , quick_parse/3 . parse_file(File) -> {ok, Forms} | {error, errorinfo()} Types File = filename() (see module file) Forms = [syntaxTree() (see module erl_syntax)] Equivalent to parse_file(File, []) . parse_file(File, Options) -> {ok, Forms} | {error, errorinfo()} Types File = filename() (see module file) Options = [term()] Forms = [syntaxTree() (see module erl_syntax)] Reads and parses a file. If successful, {ok, Forms} is returned, where Forms is a list of abstract syntax trees representing the "program forms" of the file (cf. erl_syntax:is_form/1 ). Otherwise, {error, errorinfo()} is returned, typically if the file could not be opened. Note that parse errors show up as error markers in the returned list of forms; they do not cause this function to fail or return {error, errorinfo()} . Options: {no_fail, boolean()} : If true , this makes epp_dodger replace any program forms that could not be parsed with nodes of type text (see erl_syn- tax:text/1 ), representing the raw token sequence of the form, instead of reporting a parse error. The default value is false . {clever, boolean()} : If set to true , this makes epp_dodger try to repair the source code as it seems fit, in certain cases where parsing would oth- erwise fail. Currently, it inserts ++ -operators between string literals and macros where it looks like concatenation was intended. The default value is false . See also: parse/2 , quick_parse_file/1 , erl_syntax:is_form/1 . parse_form(Dev::IODevice, L0::StartLine) -> {ok, Form, LineNo} | {eof, LineNo} | {error, errorinfo(), LineNo} Types IODevice = pid() StartLine = integer() Form = syntaxTree() (see module erl_syntax) LineNo = integer() Equivalent to parse_form(IODevice, StartLine, []) . See also: quick_parse_form/2 . parse_form(Dev::IODevice, L0::StartLine, Options) -> {ok, Form, LineNo} | {eof, LineNo} | {error, errorinfo(), LineNo} Types IODevice = pid() StartLine = integer() Options = [term()] Form = syntaxTree() (see module erl_syntax) LineNo = integer() Reads and parses a single program form from an I/O stream. Characters are read from IODevice until an end-of-form marker is found (a period character followed by whitespace), or until end-of-file; apart from this, the behaviour is similar to that of parse/3 , except that the return values also contain the final line number given that StartLine is the initial line number, and that {eof, LineNo} may be returned. See also: parse/3 , parse_form/2 , quick_parse_form/3 . quick_parse(Dev::IODevice) -> {ok, Forms} | {error, errorinfo()} Equivalent to quick_parse(IODevice, 1) . quick_parse(Dev::IODevice, L::StartLine) -> {ok, Forms} | {error, errorinfo()} Types IODevice = pid() StartLine = integer() Forms = [syntaxTree() (see module erl_syntax)] Equivalent to quick_parse(IODevice, StartLine, []) . See also: quick_parse/1 . quick_parse(Dev::IODevice, L0::StartLine, Options) -> {ok, Forms} | {error, errorinfo()} Types IODevice = pid() StartLine = integer() Options = [term()] Forms = [syntaxTree() (see module erl_syntax)] Similar to parse/3 , but does a more quick-and-dirty processing of the code. See quick_parse_file/2 for details. See also: parse/3 , quick_parse/2 , quick_parse_file/2 , quick_parse_form/2 . quick_parse_file(File) -> {ok, Forms} | {error, errorinfo()} Types File = filename() (see module file) Forms = [syntaxTree() (see module erl_syntax)] Equivalent to quick_parse_file(File, []) . quick_parse_file(File, Options) -> {ok, Forms} | {error, errorinfo()} Types File = filename() (see module file) Options = [term()] Forms = [syntaxTree() (see module erl_syntax)] Similar to parse_file/2 , but does a more quick-and-dirty processing of the code. Macro definitions and other preprocessor direc- tives are discarded, and all macro calls are replaced with atoms. This is useful when only the main structure of the code is of interest, and not the details. Furthermore, the quick-parse method can usually handle more strange cases than the normal, more exact parsing. Options: see parse_file/2 . Note however that for quick_parse_file/2 , the option no_fail is true by default. See also: parse_file/2 , quick_parse/2 . quick_parse_form(Dev::IODevice, L0::StartLine) -> {ok, Form, LineNo} | {eof, LineNo} | {error, errorinfo(), LineNo} Types IODevice = pid() StartLine = integer() Form = syntaxTree() (see module erl_syntax) | none LineNo = integer() Equivalent to quick_parse_form(IODevice, StartLine, []) . See also: parse_form/2 . quick_parse_form(Dev::IODevice, L0::StartLine, Options) -> {ok, Form, LineNo} | {eof, LineNo} | {error, errorinfo(), LineNo} Types IODevice = pid() StartLine = integer() Options = [term()] Form = syntaxTree() (see module erl_syntax) LineNo = integer() Similar to parse_form/3 , but does a more quick-and-dirty processing of the code. See quick_parse_file/2 for details. See also: parse/3 , parse_form/3 , quick_parse_form/2 . tokens_to_string(Tokens::[term()]) -> string() Generates a string corresponding to the given token sequence. The string can be re-tokenized to yield the same token list again. AUTHORS
Richard Carlsson <richardc@it.uu.se > syntax_tools 1.6.7 epp_dodger(3erl)
Man Page