Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

erl_format(3erl) [linux man page]

erl_format(3erl)						C Library Functions						  erl_format(3erl)

NAME
erl_format - Create and Match Erlang Terms DESCRIPTION
This module contains two routines - one general function for creating Erlang terms and one for pattern matching Erlang terms. EXPORTS
ETERM * erl_format(FormatStr, ... ) Types char *FormatStr; This is a general function for creating Erlang terms using a format specifier and a corresponding set of arguments, much in the way printf() works. FormatStr is a format specification string. The set of valid format specifiers is as follows: * ~i - Integer * ~f - Floating point * ~a - Atom * ~s - String * ~w - Arbitrary Erlang term For each format specifier that appears in FormatStr , there must be a corresponding argument following FormatStr . An Erlang term is built according to the FormatStr with values and Erlang terms substituted from the corresponding arguments and according to the individual format specifiers. For example: erl_format("[{name,~a},{age,~i},{data,~w}]", "madonna", 21, erl_format("[{adr,~s,~i}]","E-street",42)); This will create an (ETERM *) structure corresponding to the Erlang term: [{name,madonna},{age,21},{data,[{adr,"E-street",42}]}] The function returns an Erlang term, or NULL if FormatStr does not describe a valid Erlang term. int erl_match(Pattern, Term) Types ETERM *Pattern,*Term; This function is used to perform pattern matching similar to that done in Erlang. Refer to an Erlang manual for matching rules and more examples. Pattern is an Erlang term, possibly containing unbound variables. Term is an Erlang term that we wish to match against Pattern . Term and Pattern are compared, and any unbound variables in Pattern are bound to corresponding values in Term . If Term and Pattern can be matched, the function returns a non-zero value and binds any unbound variables in Pattern . If Term Pat- tern do not match, the function returns 0. For example: ETERM *term, *pattern, *pattern2; term1 = erl_format("{14,21}"); term2 = erl_format("{19,19}"); pattern1 = erl_format("{A,B}"); pattern2 = erl_format("{F,F}"); if (erl_match(pattern1, term1)) { /* match succeeds: * A gets bound to 14, * B gets bound to 21 */ ... } if (erl_match(pattern2, term1)) { /* match fails because F cannot be * bound to two separate values, 14 and 21 */ ... } if (erl_match(pattern2, term2)) { /* match succeeds and F gets bound to 19 */ ... } erl_var_content() can be used to retrieve the content of any variables bound as a result of a call to erl_match() . Ericsson AB erl_interface 3.7.3 erl_format(3erl)

Check Out this Related Man Page

erl_lint(3erl)						     Erlang Module Definition						    erl_lint(3erl)

NAME
erl_lint - The Erlang Code Linter DESCRIPTION
This module is used to check Erlang code for illegal syntax and other bugs. It also warns against coding practices which are not recom- mended. The errors detected include: * redefined and undefined functions * unbound and unsafe variables * illegal record usage. Warnings include: * unused functions and imports * unused variables * variables imported into matches * variables exported from if / case / receive * variables shadowed in lambdas and list comprehensions. Some of the warnings are optional, and can be turned on by giving the appropriate option, described below. The functions in this module are invoked automatically by the Erlang compiler and there is no reason to invoke these functions separately unless you have written your own Erlang compiler. EXPORTS
module(AbsForms) -> {ok,Warnings} | {error,Errors,Warnings} module(AbsForms, FileName) -> {ok,Warnings} | {error,Errors,Warnings} module(AbsForms, FileName, CompileOptions) -> {ok,Warnings} | {error,Errors,Warnings} Types AbsForms = [term()] FileName = FileName2 = atom() | string() Warnings = Errors = [{Filename2,[ErrorInfo]}] ErrorInfo = see separate description below. CompileOptions = [term()] This function checks all the forms in a module for errors. It returns: {ok,Warnings} : There were no errors in the module. {error,Errors,Warnings} : There were errors in the module. Since this module is of interest only to the maintainers of the compiler, and to avoid having the same description in two places to avoid the usual maintenance nightmare, the elements of Options that control the warnings are only described in compile(3erl) . The AbsForms of a module which comes from a file that is read through epp , the Erlang pre-processor, can come from many files. This means that any references to errors must include the file name (see epp(3erl) , or parser erl_parse(3erl) ). The warnings and errors returned have the following format: [{FileName2,[ErrorInfo]}] The errors and warnings are listed in the order in which they are encountered in the forms. This means that the errors from one file may be split into different entries in the list of errors. is_guard_test(Expr) -> bool() Types Expr = term() This function tests if Expr is a legal guard test. Expr is an Erlang term representing the abstract form for the expression. erl_parse:parse_exprs(Tokens) can be used to generate a list of Expr . format_error(ErrorDescriptor) -> Chars Types ErrorDescriptor = errordesc() Chars = [char() | Chars] Takes an ErrorDescriptor and returns a string which describes the error or warning. This function is usually called implicitly when processing an ErrorInfo structure (see below). ERROR INFORMATION
The ErrorInfo mentioned above is the standard ErrorInfo structure which is returned from all IO modules. It has the following format: {ErrorLine, Module, ErrorDescriptor} A string which describes the error is obtained with the following call: Module:format_error(ErrorDescriptor) SEE ALSO
erl_parse(3erl) , epp(3erl) Ericsson AB stdlib 1.17.3 erl_lint(3erl)
Man Page