[antlr-interest] Imaginary Node Constructor T[token-ref, "text"] throws error: missing attribute access on rule scope: token-ref
The Researcher
researcher0x00 at gmail.com
Tue Mar 22 16:57:09 PDT 2011
On Tue, Mar 22, 2011 at 7:28 PM, John B. Brodie <jbb at acm.org> wrote:
> On Tue, 2011-03-22 at 17:21 -0400, The Researcher wrote:
> > On Tue, Mar 22, 2011 at 5:14 PM, John B. Brodie <jbb at acm.org> wrote:
> >
> > > On Tue, 2011-03-22 at 16:46 -0400, The Researcher wrote:
> > > > FYI
> > > >
> > > > In using Imaginary Node Constructor T[token-ref,"text"] as
> documented
> > > in
> > > > "The Definitive ANTLR Reference" pg. 176,
> > > > the error "missing attribute access on rule scope: token-ref" was
> > > given.
> > > >
> > > > I was able to use T["text"] as documented in
> > > > http://www.antlr.org/wiki/display/ANTLR3/Tree+construction.
> > > >
> > > > I used the bug report for another bug a few days ago, but never saw
> it
> > > added
> > > > to the bug list, so I am using the interest list here instead.
> > > >
> > >
> > > you need a $ on the token ref. see the example on pg. 176. e.g. this:
> > >
> > > compoundStatement
> > > : lc='[' statement* '}' -> ^(SLIST[$lc] statemment *)
> > > ;
> > >
> > >
> > >
> > > John,
> >
> > Thanks. I did. Here is the error and working text
> >
> > Error:
> >
> > byteExp = offsetAndOrSizeExpression
> > -> ^(OffsetAndOrSize ^(ByteValue $byteExp) ^(BitValue
> > IntegerLiteral[$byteExp,"0"]))
> >
> > Working:
> >
> > byteExp = offsetAndOrSizeExpression
> > -> ^(OffsetAndOrSize ^(ByteValue $byteExp) ^(BitValue
> IntegerLiteral["0"]))
>
> offestAndOrSizeExpression is not a token! so byteExp is not a token
> reference...
>
How true. Thanks
After looking at the book i.e. pg. 176, should it be
T adaptor.create(token-ref)
T["text"] adaptor.create(T, "text")
T[token ref] adaptor.create(T, token-ref)
T[token-ref, "text"] adaptor.create(T, token-ref, "text")
This was not in the errata. http://pragprog.com/titles/tpantlr/errata
Thanks, Eric
>
> >
> > Eric
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list