Sam,
I understood the answer, but we're talking novice here - if the front
end of my grammar looks like this:
prog: body EOF!
;
body :
parts -> ^(BODY parts)
;
parts :
( (stat
| ifStat
| switchStat
| whileStat
| forStat) )*
;
stat:
(ID OPENP actualParameters CLOSEP DOT ID GETS)
=> str=ID OPENP actualParameters CLOSEP DOT fld=ID GETS expr
-> ^(GETS ?????? ^(STRUCTA $str $fld actualParameters) expr)
| (ID OPENP actualParameters CLOSEP DOT OPENP)
=> str=ID OPENP actualParameters CLOSEP DOT OPENP var=ID
CLOSEP GETS expr
-> ^(GETS ???????? ^(STRUCTAV $str $var actualParameters) expr)
// etc
;
how would I insert the line number at the ???????
DMS
Message: 13
Date: Wed, 10 Aug 2011 10:02:22 -0400
From: David Smith <[email protected]>
Subject: [antlr-interest] Access to line numbers
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"; format=flowed
It seems that the parse tree generated by the parser has a data field
'line' that seems to correspond to the source line when parsing. How
do i access that to include the line number in the tree generated by
my grammar?
DMS
David M. Smith http://www.cc.gatech.edu/fac/David.Smith
Georgia Institute of Technology, College of Computing
Sent from my ASR-33 Teletype
------------------------------
Message: 14
Date: Wed, 10 Aug 2011 09:36:28 -0500
From: "Sam Harwell" <[email protected]>
Subject: Re: [antlr-interest] Access to line numbers
To: "'David Smith'" <[email protected]>,
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Both the Tree and Token interfaces have a method getLine().
Sam
>From: [email protected]
>[mailto:[email protected]] On Behalf Of David Smith
>Sent: Wednesday, August 10, 2011 9:02 AM
...snip...
>List: http://www.antlr.org/mailman/listinfo/antlr-interest
>Unsubscribe:
>http://www.antlr.org/mailman/options/antlr-interest/your-email-address
David M. Smith http://www.cc.gatech.edu/fac/David.Smith
Georgia Institute of Technology, College of Computing
Sent from my ASR-33 Teletype
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.