[antlr-interest] A newbie question and is this mailing listablack hole for

Foolish Ewe foolishewe at hotmail.com
Tue Oct 24 13:26:33 PDT 2006


Hello Loring:

Thanks for your patience with my rookie questions.  On a side note I 
discovered
a trick to directly access the lexer in the parser (wrap ANTLR's constructor 
with
my own constructor, which preserves a reference to the lexer).  However, I 
also
confirmed that the parser's handling of the token and its string occurs 
quite a
bit after it is scanned, so the timing of the actions invocations in the 
parser
can occur too late for the scanner.


I guess the options are:
1) Manual hoisting (as per your original hint).  I'm still trying it in a 
small example, but I'm not
    really having any joy currently.  I'm not sure if there is any smart way 
to do it :-(
    Some rules (like month: ("jan" | "feb" | ... | "dec")) become complex, 
and I'm not sure
    if that semantic predicate in turn has to be hoisted :-(.
    So while it can be done i guess, but there may be more hoisting I had 
hoped,
    and in fact was indicated in the simple example shown.  I'll know better 
when I
    start trying.  Looking at the language, I think there are terminals that 
on the left hand side
    of multiple productions, so it appears that recognition will have to be 
done thoughout the code
    (every single place a key word is used in a production from what I can 
tell)
    instead of in one place where the key word is defined. :-(.
2) Trying a newer version of ANTLR (3.x) - I'm not sure about that for 
ANTLR's stabiity and
    local reasons (e.g. we are an eclipse shop here, and I'm not sure ANTLR 
3.x has eclipse
    plugins, etc.)  I'm inclined to investigate this one if it is likely to 
be quick, however
    the ANTLR 3 docs aren't very fleshed out yet.  Any howtos on getting 
started in Windows XP?

Thanks:

Bill

>From: Loring Craymer <lgcraymer at yahoo.com>
>To: Foolish Ewe <foolishewe at hotmail.com>, antlr-interest at antlr.org,  
>dave at badgers-in-foil.co.uk
>CC: FoolishEwe at hotmail.com
>Subject: Re: [antlr-interest] A newbie question and is this mailing 
>listablack hole for
>Date: Tue, 24 Oct 2006 10:27:30 -0700 (PDT)
>
>
>
>--- Foolish Ewe <foolishewe at hotmail.com> wrote:
> > 1) Are my assumptions wrong? Is using the parser to
> > control lexer a bad
> > idea?
>
>Yes.  The problem is lookahead--decisions are made
>based on not only the next token but sometimes several
>more after that.  "Now" for the parser could be 5
>tokens in the "past" for the lexer.  That is probably
>why you encountered unexpected results when you tried
>to add feedback.
>
> >     Is it really the right thing to push the
> > scanner's work back on the
> > parser?
>
>Separating functionality between parser and lexer is
>sometimes a challenge.  Sometimes it is a case of
>"whatever works"; other times, there is a clear
>boundary.  Judgement improves with experience; I
>cannot think of a set of hard and fast rules.  Messy
>problems sometimes have messy solutions!
>
>--Loring
>
> > 2) If I'm right, what is the name of the handle to
> > lexer of type L in P of
> > type parser?
> > 3) If I'm right, what is the syntax for referencing
> > lexer.recognizeKeyWords
> > in parser?
> >
> > Regards:
> >
> > Bill M.
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces 
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us



More information about the antlr-interest mailing list