Re: prolog and recursive descent parsing?

peter.ludemann@gmail.com
Fri, 21 Sep 2007 04:27:31 -0000

          From comp.compilers

Related articles
prolog and recursive descent parsing? carl_thinks_cs@yahoo.com (carl immanuel manalo) (2007-09-16)
Re: prolog and recursive descent parsing? oliverhunt@gmail.com (oliverhunt@gmail.com) (2007-09-18)
Re: prolog and recursive descent parsing? haberg@math.su.se (2007-09-19)
Re: prolog and recursive descent parsing? peter.ludemann@gmail.com (2007-09-21)
| List of all articles for this month |
From: peter.ludemann@gmail.com
Newsgroups: comp.compilers
Date: Fri, 21 Sep 2007 04:27:31 -0000
Organization: Compilers Central
References: 07-09-067
Keywords: prolog, parse
Posted-Date: 21 Sep 2007 02:21:39 EDT

On Sep 16, 4:44 pm, carl immanuel manalo <carl_thinks...@yahoo.com>
wrote:
> How doesprolog use recursive descent parsing to solve problems given
> to it?. Does it make a graph of the parse tree or something?


"Logic Grammars" by Harvey Abramson, Veronica Dahl is a good
reference, although it goes far beyond what most compilers need; one
of the examples involves Latin, where the words can appear in almost
any order (although I seem to remember someone asking how to do that a
little while ago, for declarations ...)


Most parsing in Prolog uses DCG or similar notation. Here's a
tutorial: http://www.w3.org/People/cmsmcq/2004/lgintro.html
Grammar E2 shows how to write an attribute grammar to produce a parse
tree (in Prolog, there's essentially no distinction between an
attribute you bring into a grammar rule and one you emit -- I used
this once to write a parser that could either explain a C declarations
or generate one from pseudo-English).


There are other, more powerful, notations that DCG - DCTG and EDCG
spring to mind. Google can help you find them.


- peter


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.