help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntactic completion


From: Laurence Finston
Subject: Re: syntactic completion
Date: Thu, 29 Jul 2004 10:46:05 +0200 (MEST)

On Thu, 28 Jul 2004, Murray Hayes wrote:

> I am trying to write a completion generator function for the gnu
> readline library that uses an existing grammar file to generate
> suggestions based on the syntax that has already been entered.
>
> I have gone through the help archives and found some very helpful
> articles that contain source code for listing all the possible
> satisfying rules:
>
> http://lists.gnu.org/archive/html/help-bison/2002-11/msg00006.html
>
>
> I have put these code snippets into a complete working program to
> experiment with but I am still having some problems getting the
> information I need.
>
> The code referenced above places the expect function in the debug
> section which doesn't seem to be run unless there is a problem.  The
> information that I will be getting from readline is a text string that
> holds the line as it has so far been entered and two integers start and
> end which represent where the word to be completed start and end in the
> string.
>
> >From what I have read in the bison manual, it looks like I will have to
> implement an action in every rule to call expect() to extract the rules
> that can satisfy the grammar at the arbitrary point indicated by start.
> Is this true or is there an easier way to interrupt the parsing process
> at a specified point (perhaps with the lexical analyzer)?
>

This doesn't sound good to me.  It is the job of the Bison parser to determine
what rules are valid in any given context.  If the programmer has to write code
in rules for this purpose, then I suggest rethinking the design of your
parser.

One can interrupt the parsing process by returning from `yyparse()'.  The code
that calls it can perform actions based on the return value and call it again,
if desired.

Laurence

> I can supply more information including the program I have that
> implements the expect() function I copied from the archives.  Also, here
> is a link to the relevant manual section on readline:
>
> http://cnswww.cns.cwru.edu/~chet/readline/readline.html#SEC44
>
>
> TIA for any help you can offer.
>
>
> --
> address@hidden
>
>
>
> _______________________________________________
> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]