4.13 DCG Grammar rules
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • DCG Grammar rules
          • phrase/2
          • phrase/3
          • call_dcg/3
    • Packages
Availability:built-in
Sourcecall_dcg(:DCGBody, ?State0, ?State)
As phrase/3, but without type checking State0 and State. This allows for using DCG rules for threading an arbitrary state variable. This predicate was introduced after type checking was added to phrase/3.86After discussion with Samer Abdallah.

A portable solution for threading state through a DCG can be implemented by wrapping the state in a list and use the DCG semicontext facility. Subsequently, the following predicates may be used to access and modify the state:87This solution was proposed by Markus Triska.

state(S), [S] --> [S].
state(S0, S), [S] --> [S0].