Re: help with parsing and dcg (swi-prolog in particular)
- From: "Brian Hulley" <brianh@xxxxxxxxxxxx>
- Date: 21 May 2005 01:06:16 -0700
Brian Hulley wrote:
> blindsearch wrote:
> > I don't think a single list could handle it. The file I was reading
> in
> > was 2.5mb, there were 8199 frames.
>
You could also modify the convert_file_to_list predicate so that it
counted parentheses - when the opening bracket is closed, you stop
reading from the file and return the list which should contain the
chars for a single concept (assuming the original file is bracketed
correctly, which from your first post seemed to be the case)
Thus your main loop would be something like:
go :-
see(File),
get_byte(Char),
start_with(Char).
start_with(-1) :- seen. % end of file
start_with(Char) :-
get_next_concept_list(Char,List,NextChar),
phrase(concept(Concept), List, Remainder), % ignore remainder (?)
write(Concept),nl,
start_with(NextChar).
Garbage collection will ensure that you don't run out of space in this
kind of loop (using tail recursion).
Regards, Brian.
.
- Follow-Ups:
- Re: help with parsing and dcg (swi-prolog in particular)
- From: Jan Wielemaker
- Re: help with parsing and dcg (swi-prolog in particular)
- From: blindsearch
- Re: help with parsing and dcg (swi-prolog in particular)
- 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
- Re: 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
|
|