4.3.1 Conditional compilation and program transformation
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Loading Prolog source files
          • Conditional compilation and program transformation
            • term_expansion/2
            • expand_term/2
            • goal_expansion/2
            • expand_goal/2
            • compile_aux_clauses/1
            • dcg_translate_rule/2
            • var_property/2
            • Program transformation with source layout info
            • Conditional compilation
    • Packages
Availability:built-in
Sourceexpand_term(+Term1, -Term2)
This predicate is normally called by the compiler on terms read from the input to perform preprocessing. It consists of four steps, where each step processes the output of the previous step.

  1. Test conditional compilation directives and translate all input to [] if we are in a‘false branch' of the conditional compilation. See section 4.3.1.2.

  2. Call term_expansion/2. This predicate is first tried in the module that is being compiled and then in modules from which this module inherits according to default_module/2. The output of the expansion in a module is used as input for the next module. Using the default setup and when compiling a normal application module M, this implies expansion is executed in M, user and finally in system. Library modules inherit directly from system and can thus not be re-interpreted by term expansion rules in user.

  3. Call DCG expansion (dcg_translate_rule/2).

  4. Call expand_goal/2 on each body term that appears in the output of the previous steps.