Try to read a Prolog term form an arbitrary location inside a
file. Due to Prolog's dynamic syntax, e.g., due to operator
declarations that may change anywhere inside the file, this is
theoreticaly impossible. Therefore, this predicate is
fundamentally heuristic and may fail. This predicate is used
by e.g., clause_info/4 and by PceEmacs to colour the current
clause.
This predicate has two ways to find the right syntax. If the
file is loaded, it can be passed the module using the module
option. This deals with module files that define the used
operators globally for the file. Second, there is a hook
prolog:alternate_syntax/4 that can be used to temporary redefine
the syntax.
The options below are processed in addition to the options of
read_term/3. Note that the line
and offset
options are
mutually exclusive.
- line(+Line)
- If present, start reading at line Line.
- offset(+Characters)
- Use seek/4 to go to the indicated location. See seek/4
for limitations of seeking in text-files.
- module(+Module)
- Use syntax from the given module. Default is the current
`source module'.
- operators(+List)
- List of additional operator declarations to enforce while
reading the term.
- error(-Error)
- If no correct parse can be found, unify Error with a term
Offset:Message that indicates the (character) location of
the error and the related message. Adding this option
makes read_source_term_at_location/3 deterministic (
det
).
- See also
- - Use read_source_term/4 to read a file from the start.
- - prolog:alternate_syntax/4 for locally scoped operators.