I plan to write a parser for PDDL (Planning Domain Description
Language) in Prolog. As a description, I have a BNF and an ANTLR
input.
Currently, I know only little on how to write a parser in Prolog. I
had some
lectures back in university but we used C. Maybe of best help would
be an
existing parser that I can modify or a "cookbook". The Prolog dialect
I use is ECLiPSe.
Thanks,
Ulrich
BNF PDDL 3.0: http://www.cs.yale.edu/homes/dvm/papers/pddl-bnf.pdf
PDDL grammar for ANTLR v3: http://www.antlr.org/grammar/1172246598728/Pddl.g
Hi Ulrich, I am trying the same like you. May be we could try to join
efforts in that task...
>
> Currently, I know only little on how to write a parser in Prolog. I
I have writen a minimalist DCG [http://en.wikipedia.org/wiki/
Definite_clause_grammar] to parse a PDDL domain description file, but
this implies too many efforts, and too many time lost debuguing the
program.
Another option is to discard the first one :S , and try some antlr
approach. I think this could be more simpler than DCG aproach, but
implies to learn antlr (i'm currently studying this one).
> had some
> lectures back in university but we used C. Maybe of best help would
> be an
> existing parser that I can modify or a "cookbook". The Prolog dialect
> I use is ECLiPSe.
I'm usind Ciao Prolog.
In case you stick to writing a DCG for parsing, you can use
the DCG directly for reading from a file.
In SWI-Prolog:
:- use_module(library(pio)).
... --> [] | [_], ... .
nt -->
( "a" | "b" ),
... .
?- phrase_from_file(nt, filex).
This succeeds if filex starts with an a or b.