User's Guide
Reference Manual
Release Notes
PDF
Top

Syntax_Tools
Reference Manual
Version 1.6.4

Expand All
Contract All

Table of Contents

- epp_dodger
  - Top of manual page
  - parse/1
  - parse/2
  - parse/3
  - parse_file/1
  - parse_file/2
  - parse_form/2
  - parse_form/3
  - quick_parse/1
  - quick_parse/2
  - quick_parse/3
  - quick_parse_file/1
  - quick_parse_file/2
  - quick_parse_form/2
  - quick_parse_form/3
  - tokens_to_string/1
- erl_comment_scan
  - Top of manual page
  - file/1
  - join_lines/1
  - scan_lines/1
  - string/1
- erl_prettypr
  - Top of manual page
  - best/1
  - best/2
  - format/1
  - format/2
  - get_ctxt_hook/1
  - get_ctxt_linewidth/1
  - get_ctxt_paperwidth/1
  - get_ctxt_precedence/1
  - get_ctxt_user/1
  - layout/1
  - layout/2
  - set_ctxt_hook/2
  - set_ctxt_linewidth/2
  - set_ctxt_paperwidth/2
  - set_ctxt_precedence/2
  - set_ctxt_user/2
- erl_recomment
  - Top of manual page
  - quick_recomment_forms/2
  - recomment_forms/2
  - recomment_tree/2
- erl_syntax
  - Top of manual page
  - abstract/1
  - add_ann/2
  - add_postcomments/2
  - add_precomments/2
  - application/2
  - application/3
  - application_arguments/1
  - application_operator/1
  - arity_qualifier/2
  - arity_qualifier_argument/1
  - arity_qualifier_body/1
  - atom/1
  - atom_literal/1
  - atom_name/1
  - atom_value/1
  - attribute/1
  - attribute/2
  - attribute_arguments/1
  - attribute_name/1
  - binary/1
  - binary_comp/2
  - binary_comp_body/1
  - binary_comp_template/1
  - binary_field/1
  - binary_field/2
  - binary_field/3
  - binary_field_body/1
  - binary_field_size/1
  - binary_field_types/1
  - binary_fields/1
  - binary_generator/2
  - binary_generator_body/1
  - binary_generator_pattern/1
  - block_expr/1
  - block_expr_body/1
  - case_expr/2
  - case_expr_argument/1
  - case_expr_clauses/1
  - catch_expr/1
  - catch_expr_body/1
  - char/1
  - char_literal/1
  - char_value/1
  - class_qualifier/2
  - class_qualifier_argument/1
  - class_qualifier_body/1
  - clause/2
  - clause/3
  - clause_body/1
  - clause_guard/1
  - clause_patterns/1
  - comment/1
  - comment/2
  - comment_padding/1
  - comment_text/1
  - compact_list/1
  - concrete/1
  - cond_expr/1
  - cond_expr_clauses/1
  - conjunction/1
  - conjunction_body/1
  - cons/2
  - copy_ann/2
  - copy_attrs/2
  - copy_comments/2
  - copy_pos/2
  - data/1
  - disjunction/1
  - disjunction_body/1
  - eof_marker/0
  - error_marker/1
  - error_marker_info/1
  - flatten_form_list/1
  - float/1
  - float_literal/1
  - float_value/1
  - form_list/1
  - form_list_elements/1
  - fun_expr/1
  - fun_expr_arity/1
  - fun_expr_clauses/1
  - function/2
  - function_arity/1
  - function_clauses/1
  - function_name/1
  - generator/2
  - generator_body/1
  - generator_pattern/1
  - get_ann/1
  - get_attrs/1
  - get_pos/1
  - get_postcomments/1
  - get_precomments/1
  - has_comments/1
  - if_expr/1
  - if_expr_clauses/1
  - implicit_fun/1
  - implicit_fun/2
  - implicit_fun/3
  - implicit_fun_name/1
  - infix_expr/3
  - infix_expr_left/1
  - infix_expr_operator/1
  - infix_expr_right/1
  - integer/1
  - integer_literal/1
  - integer_value/1
  - is_atom/2
  - is_char/2
  - is_form/1
  - is_integer/2
  - is_leaf/1
  - is_list_skeleton/1
  - is_literal/1
  - is_proper_list/1
  - is_string/2
  - is_tree/1
  - join_comments/2
  - list/1
  - list/2
  - list_comp/2
  - list_comp_body/1
  - list_comp_template/1
  - list_elements/1
  - list_head/1
  - list_length/1
  - list_prefix/1
  - list_suffix/1
  - list_tail/1
  - macro/1
  - macro/2
  - macro_arguments/1
  - macro_name/1
  - make_tree/2
  - match_expr/2
  - match_expr_body/1
  - match_expr_pattern/1
  - meta/1
  - module_qualifier/2
  - module_qualifier_argument/1
  - module_qualifier_body/1
  - nil/0
  - normalize_list/1
  - operator/1
  - operator_literal/1
  - operator_name/1
  - parentheses/1
  - parentheses_body/1
  - prefix_expr/2
  - prefix_expr_argument/1
  - prefix_expr_operator/1
  - qualified_name/1
  - qualified_name_segments/1
  - query_expr/1
  - query_expr_body/1
  - receive_expr/1
  - receive_expr/3
  - receive_expr_action/1
  - receive_expr_clauses/1
  - receive_expr_timeout/1
  - record_access/2
  - record_access/3
  - record_access_argument/1
  - record_access_field/1
  - record_access_type/1
  - record_expr/2
  - record_expr/3
  - record_expr_argument/1
  - record_expr_fields/1
  - record_expr_type/1
  - record_field/1
  - record_field/2
  - record_field_name/1
  - record_field_value/1
  - record_index_expr/2
  - record_index_expr_field/1
  - record_index_expr_type/1
  - remove_comments/1
  - revert/1
  - revert_forms/1
  - rule/2
  - rule_arity/1
  - rule_clauses/1
  - rule_name/1
  - set_ann/2
  - set_attrs/2
  - set_pos/2
  - set_postcomments/2
  - set_precomments/2
  - size_qualifier/2
  - size_qualifier_argument/1
  - size_qualifier_body/1
  - string/1
  - string_literal/1
  - string_value/1
  - subtrees/1
  - text/1
  - text_string/1
  - tree/1
  - tree/2
  - try_after_expr/2
  - try_expr/2
  - try_expr/3
  - try_expr/4
  - try_expr_after/1
  - try_expr_body/1
  - try_expr_clauses/1
  - try_expr_handlers/1
  - tuple/1
  - tuple_elements/1
  - tuple_size/1
  - type/1
  - underscore/0
  - update_tree/2
  - variable/1
  - variable_literal/1
  - variable_name/1
  - warning_marker/1
  - warning_marker_info/1
- erl_syntax_lib
  - Top of manual page
  - analyze_application/1
  - analyze_attribute/1
  - analyze_export_attribute/1
  - analyze_file_attribute/1
  - analyze_form/1
  - analyze_forms/1
  - analyze_function/1
  - analyze_function_name/1
  - analyze_implicit_fun/1
  - analyze_import_attribute/1
  - analyze_module_attribute/1
  - analyze_record_attribute/1
  - analyze_record_expr/1
  - analyze_record_field/1
  - analyze_rule/1
  - analyze_wild_attribute/1
  - annotate_bindings/1
  - annotate_bindings/2
  - fold/3
  - fold_subtrees/3
  - foldl_listlist/3
  - function_name_expansions/1
  - is_fail_expr/1
  - limit/2
  - limit/3
  - map/2
  - map_subtrees/2
  - mapfold/3
  - mapfold_subtrees/3
  - mapfoldl_listlist/3
  - new_variable_name/1
  - new_variable_name/2
  - new_variable_names/2
  - new_variable_names/3
  - strip_comments/1
  - to_comment/1
  - to_comment/2
  - to_comment/3
  - variables/1
- erl_tidy
  - Top of manual page
  - dir/0
  - dir/1
  - dir/2
  - file/1
  - file/2
  - module/1
  - module/2
- igor
  - Top of manual page
  - create_stubs/2
  - merge/2
  - merge/3
  - merge_files/3
  - merge_files/4
  - merge_sources/3
  - parse_transform/2
  - rename/2
  - rename/3
- prettypr
  - Top of manual page
  - above/2
  - beside/2
  - best/3
  - break/1
  - empty/0
  - floating/1
  - floating/3
  - follow/2
  - follow/3
  - format/1
  - format/2
  - format/3
  - nest/2
  - null_text/1
  - par/1
  - par/2
  - sep/1
  - text/1
  - text_par/1
  - text_par/2

# epp_dodger

### MODULE

epp_dodger

### MODULE SUMMARY

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(3) before the parser sees them), an extended syntax tree is created, using the erl_syntax module.

### DATA TYPES

errorinfo() = {ErrorLine::integer(), Module::atom(), Descriptor::term()}

  This is a so-called Erlang I/O ErrorInfo structure; see the io(3) 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 behaviour 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_syntax: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 otherwise 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 directives 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.

Richard Carlsson richardc@it.uu.se