Re: help with parsing and dcg (swi-prolog in particular)
- From: "Brian Hulley" <brianh@xxxxxxxxxxxx>
- Date: 20 May 2005 14:22:01 -0700
Brian Hulley wrote:
> blindsearch wrote:
> > For a recent project, I was reading in lisp like files,
> > (concept-name (concept-attribute (type stuff))
> > (...)
> > ...
> > ...)
> >
> > I converted the lisp lists to prolog lists wrapped in a predicate
and
> > wrote them to a temp file, then [consult]ed the temp file but
> > I had to make uppercase to lowercase, hypens to underscore, etc. I
> had
> > to keep track of tokens/words so i could place commas, also counted
> the
> > parens so when i got back to zero, I placed a period.
> > The parser read in the file char by char and wrote char by char.
> >
> > I was wondering about using DCG to parse the file. I've read that
> DCG's
> > are excellent for parsing (and written some small examples for
> > sentences) but it doesn't seem feasible to me.
> >
> > Is there a way to take a file and use dcg to parse it?
> > The only way I can think of is that I would have to convert the
file
> to
> > lists and pass the lists to the dcg predicates tokenising stuff in
> the
> > progress. But if I did that, I've done almost all the parser
without
> > dcg bymyself.
> >
> > Any help would be welcome.
>
> If you write one DCG that parses a whole file then all you need is a
> predicate that converts a file to one list of characters - perhaps
> something like:
>
> convert_file_to_list(File,[Char|L]) :-
Apologies for the error- should be:
convert_file_to_list(File,L) :-
.
- References:
- help with parsing and dcg (swi-prolog in particular)
- From: blindsearch
- Re: help with parsing and dcg (swi-prolog in particular)
- From: Brian Hulley
- help with parsing and dcg (swi-prolog in particular)
- Prev by Date: Re: help with parsing and dcg (swi-prolog in particular)
- Next by Date: Re: help with parsing and dcg (swi-prolog in particular)
- Previous by thread: Re: help with parsing and dcg (swi-prolog in particular)
- Next by thread: Re: help with parsing and dcg (swi-prolog in particular)
- Index(es):
Relevant Pages
|
|