Home > Archive > Prolog > June 2005 > Does anyone have DCG examples?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Does anyone have DCG examples?
|
|
|
| Does anyone have DCG examples?
I look over the internet, but all i can find are English Grammars and all of them are the same.
If anyone have more examples, please reply.
Thanks
--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
| |
| Paulo Moura 2005-06-09, 8:57 am |
|
MiKE wrote:
> Does anyone have DCG examples?
> I look over the internet, but all i can find are English Grammars and all of them are the same.
> If anyone have more examples, please reply.
Logtalk (http://www.logtalk.org/) includes a set of DCGs examples in
its current distribution. Logtalk itself includes its own DCG tranlater
so that you get consistent results no matter the Prolog compiler you're
using.
Cheers,
Paulo
| |
| C. M. Sperberg-McQueen 2005-06-10, 8:57 pm |
| "MiKE" <mike_stewart@netcabo.pt> writes:
> Does anyone have DCG examples?
> I look over the internet, but all i can find are
> English Grammars and all of them are the same.
> If anyone have more examples, please reply.
You're right; it does seem fairly hard to find
DCG examples using Google. There are a lot more
in books.
A brief introduction to logic grammars I wrote for
the benefit of my colleagues on the XML Schema
Working Group is at
http://www.w3.org/People/cmsmcq/2004/lgintro.html
You will be disappointed to see that its first
example is yet another variant of the trivial
English grammar you're already tired of. But
there is at least one other DCG example in the
paper, which is not (as far as I know) a
duplicate of any examples you'll find elsewhere.
The list of further reading mentions several
books that have examples (although most of them
are books about NLP); in addition to those
mentioned there, you should look at Richard
O'Keefe's The Craft of Prolog (Cambridge: MIT
Press, 1990), especially chapter 8, but DCG
notation is used in passing in other places,
as well, for things far distant from English
grammars.
A more substantial example is at
http://www.w3.org/People/cmsmcq/2004/podcg.html
but it's not a conventional DCG grammar; it
uses DCG to represent content models in an
XML Schema, and the assumed input is the output
from the SWI SGML parser, in what I call
Antjewierden/Wielemaker Form.
And if it's of any interest, a DCG translation
of the generic URI grammar of RFC 3986 can be
had from http://www.w3.org/People/cmsmcq/2005/rfc3986.dcg
(it's just a recognizer, does no useful work, but
if you want examples ...).
-C. M. Sperberg-McQueen
|
|
|
|
|