Module for reading in Prolog source code with positions, mostly
wrapping prolog_read_source_term/4.
- author
- - James Cash
- To be done
- - Files using quasi-quotations currently aren't supported; need to
teach prolog_read_source_term/4 to load correctly
- file_lines_start_end(+Path:text, -LineCharRange:list) is det
- Construct a mapping of file offsets to line numbers in the file at
Path. LineCharRange will be a list containing terms like
=
line_start_end(LineNumber, LineOffsetStart, LineOffsetEnd)
=
- read_term_positions(+Path:text, -TermsWithPositions:list) is det
- Read in all the terms in the file at Path, using
prolog_read_source_term/4, to a list of dictionaries.
Each dictionary has the following keys:
- term
- The term read in, with variables replace with the term '$var'(VariableName).
- pos
- The position of the term (see [[prolog_read_source_term/4]]).
- subterm
- The position of the subterms in term (see [[prolog_read_source_term/4]]).
- variable_names
- List of Name=Var terms for the variables in Term. Note that the
variables in term have already been replace with
var(Name)
- comments
- Comments in the term, with the same format as prolog_read_source_term/4
- read_term_positions(+Path:text, +Start:integer, +End:integer, -TermsWithPositions:list) is det
- Read in all the terms in the file at Path between Start and End, using
prolog_read_source_term/4, to a list of dictionaries.
Each dictionary has the following keys:
- term
- The term read in, with variables replace with the term '$var'(VariableName).
- pos
- The position of the term (see [[prolog_read_source_term/4]]).
- subterm
- The position of the subterms in term (see [[prolog_read_source_term/4]]).
- variable_names
- List of Name=Var terms for the variables in Term. Note that the
variables in term have already been replace with
var(Name)
- comments
- Comments in the term, with the same format as prolog_read_source_term/4
- file_offset_line_position(+LineCharMap:term, ?Offset:integer, ?Line:integer, ?Column:integer) is semidet
- True when LineCharMap is a term as created by
file_lines_start_end/2, Offset is the offset into the file, Line is
the line number and Column is the character within that line.
Presumably either Offset is ground or Line & Column are.
- find_in_term_with_positions(+Search:callable, +Term, +Positions, -Matches, -Tail) is det
- True when Search is a callable that takes two arguments, a term and its position, and is
true if the term should be included in match, Term is the term in
which to search, Positions is the subterm positions as given from read_term_positions/2,
Matches is a list of the found matching terms, and Tail is the tail of the Matches list.
- subterm_leaf_position(+Term, +Offset, +SubTermPoses, ?Leaf) is semidet
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- position_to_match(Arg1, Arg2, Arg3)