The term that has been read is classified into one of the following categories (Kind):
:- export struct(source_term( term, % the read term itself vars, % list of [VarName|Var] pairs (as in readvar/3) annotated % the read term with type and source annotations ... )).For category 'comment', the term is a string containing the comment. For category 'end' and 'end_include', the term is the atom end_of_file. In all these cases, vars is the empty list, and annotated is uninstantiated.
Note that either the vars-field or the annotated field is valid, depending on the setting of the with_annotations-option. If the option is set, the vars field contains an empty list, and the annotated term is in the same format as that returned by read_annotated/2, i.e. a recursive wrapper structure around the read term of the following format:
:- export struct(annotated_term( term, % var, atomic or compound % args of compound terms are annotated type, % term type (see below) file, % file name (atom) line, % line number (integer >= 1) from, to % source position (integers >= 0) ... )).If the with_annotations-option is not set, the annotated-field remains uninstantiated, and the vars-field is a list as detailed in readvar/3.
Notes on module handling: When source_read/3 encounters a module-directive (which is a handled_directive), the corresponding module is implicitly created (unless it exists already, in which case it is either reused or erased and re-created, depending on the setting of the recreate_modules option), and that module becomes the context module for any subsequently read clauses or directives. By default, source_close/2 removes these modules again in order to restore the original state.