Does SWI-Prolog support XSB’s auto_table
?
(page 67,68)
This is very useful for DCG’s as shown here (from XSB manual p. 427):
11.2.1 Definite Clause Grammars and Tabling
Tabling can be used in conjunction with Definite Clause Grammars to get the effect of a more complete parsing strategy. When Prolog is used to evaluate DCG’s, the resulting parsing algorithm is“recursive descent”. Recursive descent parsing, while efficiently implementable, is known to suffer from several deficiencies: 1) its time canbe exponential in the size of the input, and 2) it may not terminate for certain context-free grammars (in particular, those that are left or doubly recursive). By appropriate use of tabling, both of these limitations can be overcome. With appropriate tabling,the resulting parsing algorithm is a variant of Earley’s algorithm and of chart parsing algorithms.
In the simplest cases, one needs only to add the directive
:- auto_table
(seeSection3.10.5) to the source file containing a DCG specification. This should generate any necessary table declarations so that infinite loops are avoided (for context-freegrammars). That is, with a:- auto_table
declaration, left-recursive grammars can be correctly processed.