DCG and phrase/3

DCG and phrase/3

DCG and phrase/3

How to: DCG and phrase/3

Note: This is a work in progress. When it is complete these notes will be removed.

Note: Do not reply to this topic, questions, concerns, comments, etc. are to handled in
Wiki Discussion: Wiki: How to - DCG and phrase/3

Note: This is just to get the topic started and hopefully others to jump in and make this useful. Even if you are brand new to Prolog, this is such a basic and fundamental concept that you can and should join in to help improve the value of this Wiki. Join the discussion at Wiki Discussion: Wiki: How to - DCG and phrase/3

Note: This is a wiki and if you have Trust level: Basic you can edit this by clicking on the pencil icon in the lower right. Capture
These topics also have history so they can be rolled-back if needed.


DCG (SWI-Prolog) (Wikipedia)

library(pure_input): Pure Input from files and streams

Reference: Line_count/2 and phrase_from_file

Prolog DCG Primer

From: Tabled execution (SLG resolution)

Left recursion , a goal calling a variant of itself recursively and thus looping under the normal Prolog SLD resolution is avoided by suspending the variant call and resuming it with answers from the table.

Example with left recursive grammar. Removing left recursion in DCG - Prolog