erl_anno
Abstract Datatype for the Annotations of the Erlang Compiler
This module implements an abstract type that is used by the Erlang Compiler and its helper modules for holding data such as column, line number, and text. The data type is a collection of annotations as described in the following.
The Erlang Token Scanner returns tokens with a subset of the following annotations, depending on the options:
column
The column where the token begins.
location
The line and column where the token begins, or just the line if the column unknown.
text
The token's text.
From the above the following annotation is derived:
line
The line where the token begins.
Furthermore, the following annotations are supported by this module, and used by various modules:
file
A filename.
generated
A Boolean indicating if the abstract code is compiler generated. The Erlang Compiler does not emit warnings for such code.
record
A Boolean indicating if the origin of the abstract code is a record. Used by Dialyzer to assign types to tuple elements.
The functions
column(),
end_location(),
line(),
location(), and
text()
in the erl_scan
module can be used for inspecting
annotations in tokens.
The functions
map_anno(),
fold_anno(),
mapfold_anno(),
new_anno(),
anno_from_term(), and
anno_to_term() in the erl_parse
module can be
used for manipulating annotations in abstract code.
Types
anno()
A collection of annotations.
anno_term() = term()
The term representing a collection of annotations. It is
either a location()
or a list of key-value pairs.
column() = integer() >= 1
line() = integer() >= 0
To be changed to a non-negative integer in Erlang/OTP 19.0.
text() = string()
Functions
column(Anno) -> column() | undefined
Anno = anno()
column() = integer() >= 1
Returns the column of the annotations
end_location(Anno) -> location() | undefined
Anno = anno()
Returns the end location of the text of the
annotations undefined
is returned.
file(Anno) -> filename() | undefined
Anno = anno()
filename() = file:filename_all()
Returns the filename of the annotations undefined
is returned.
from_term(Term) -> Anno
Term = anno_term()
Anno = anno()
Returns annotations with the representation
See also to_term().
generated(Anno) -> generated()
Anno = anno()
generated() = boolean()
Returns true
if the annotations false
.
is_anno(Term) -> boolean()
Term = any()
Returns true
if false
otherwise.
line(Anno) -> line()
Anno = anno()
line() = integer() >= 0
Returns the line of the annotations
new(Location) -> anno()
Location = location()
Creates a new collection of annotations given a location.
set_file(File, Anno) -> Anno
File = filename()
Anno = anno()
filename() = file:filename_all()
Modifies the filename of the annotations
set_generated(Generated, Anno) -> Anno
Generated = generated()
Anno = anno()
generated() = boolean()
Modifies the generated marker of the annotations
set_line(Line, Anno) -> Anno
line() = integer() >= 0
Modifies the line of the annotations
set_location(Location, Anno) -> Anno
Location = location()
Anno = anno()
Modifies the location of the annotations
set_record(Record, Anno) -> Anno
record() = boolean()
Modifies the record marker of the annotations
set_text(Text, Anno) -> Anno
text() = string()
Modifies the text of the annotations
text(Anno) -> text() | undefined
Anno = anno()
text() = string()
Returns the text of the annotations undefined
is returned.
to_term(Anno) -> anno_term()
Anno = anno()
Returns the term representing the annotations
See also from_term().