[antlr-interest] Auto- completion feature based on ANTLR

Terence Parr parrt at cs.usfca.edu
Tue Aug 19 10:22:34 PDT 2003


Ruslan,

I will try to post my antlr parser and tree walker very soon so that 
you could generate some information yourself to include in your 
parsers.  You could, for example, serialize the grammar with the build 
in AST stuff and then read it back in when you start the parse.  Maybe 
the traceIn/traceOut function could be used to keep a pointer into the 
grammar tree.  When you need what comes next you could simply walk 
forward in the tree looking for the next tokens.  Well, actually that's 
like computing LL(1) lookahead and is not really totally obvious from 
the trees...

Hmm...ok, maybe this won't be that convenient.

Ter

On Tuesday, August 19, 2003, at 03:52  AM, Ruslan Zasukhin wrote:

> on 8/18/03 21:18, Terence Parr at parrt at cs.usfca.edu wrote:
>
>> Hi.  Auto-completion is not really convenient in the current generated
>> output.  It's kind of like compiling C code w/o the symbol table
>> information (-g option).  The current ANTLR 3 analysis engine I'm
>> working on makes this sort of thing trivial, but of course doesn't
>> exist as a tool yet. :(
>>
>> You might be able to do something interesting with the bitsets used 
>> for
>> prediction.  These say what tokens predict which alternative.  The
>> union of these at any decision point tells you what can come next.  
>> The
>> problem is when there is no decision:
>>
>> a : A B ;
>>
>> from A to B you make no decision and you would not have sets laying
>> around to say "B" can come next.  ON the other hand, you might be able
>> to tweak the code generator to dump a bit more info for these single
>> token matches.
>>
>> Still it won't be convenient.  :(
>
> Yes true.
>
> Terr, as I see the task, we need some simple function
> That must return LIST / Array of next expected tokens.
>
> As tokens we can have
>
> 1) simply strings "select"
> But I think this will not work because
>
> 2) in SQL we can get as next token a FIELD.
> So I need self then construct array of field names that exists in my
> database.
>
> I.e. I think ANTLR should return me { SELECT_TOKEN, FIELD }
> And later I will need just add function
>
> Array<string> BuildStrings( ListOfTokens )
> {
>     for each token from list
>
>     switch( token )
>     {
>         case SELECT: res.add( "select" )
>
>         case FIELD: AddFields( res, ... )
>
>         ...
>     }
> }
>
>
> -- 
> Best regards,
> Ruslan Zasukhin      [ I feel the need...the need for speed ]
> -------------------------------------------------------------
> e-mail: ruslan at paradigmasoft.com
> web: http://www.paradigmasoft.com
>
> To subscribe to the Valentina mail list go to:
> http://lists.macserve.net/mailman/listinfo/valentina
> -------------------------------------------------------------
>
>
>
>
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com link sharing, pure-n-simple




 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list