[antlr-interest] error when using svn:keywords in comment
William H. Schultz
whschultz at cedrus.com
Mon Jun 22 12:06:53 PDT 2009
Here's what works for me:
In the parser/lexer grammar:
@parser::header
{
/// \$Rev: 4766 $
/// \$Author: whschultz $
/// \$Date: 2009-06-19 11:59:22 -0700 (Fri, 19 Jun 2009) $
///
/// Copyright (c) 2009 Cedrus Corporation
/// There is no spoon.
}
In the tree walker:
@header
{
/// \$Rev: 4768 $
/// \$Author: whschultz $
/// \$Date: 2009-06-19 16:31:22 -0700 (Fri, 19 Jun 2009) $
///
/// Copyright (c) 2009 Cedrus Corporation
/// There is no spoon.
}
As you've noted, it does NOT work in "@lexer::header." If I simply
use "@header" in the parser/lexer grammar, nothing goes into the lexer.
On Jun 18, 2009, at 11:45 PM, Ranco Marcus wrote:
> Thanks Ter, however escaping does not work for @lexer::header (see
> grammar below).
>
> An error message is shown (in ANTLRWorks 1.2.3), but the parser and
> lexer are generated correctly.
>
>
> [begin file]
>
> // $Id$ escape not needed
>
> grammar test;
>
> @header
> {
> // \$Id\$ escape needed, and working
> }
>
> @lexer::header
> {
> // \$Id\$ escape needed, but not working (throws 'reference to
> attribute outside of a rule: Id')
> }
>
> // some dummy rules (if no lexer rules are present, the error above is
> not shown)
>
> main
> : EOF
> ;
>
> PLUS
> : '+'
> ;
>
> [end file]
>
>
>
> -----Original Message-----
> From: Terence Parr [mailto:parrt at cs.usfca.edu]
> Sent: Thursday, June 18, 2009 8:35 PM
> To: Ranco Marcus
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] error when using svn:keywords in comment
>
> Try \$
> Ter
> On Jun 18, 2009, at 5:49 AM, Ranco Marcus wrote:
>
>> Hi guys,
>>
>> Specifying an svn:keyword like $Id$ in a comment line results in an
>> error message "reference to attribute outside of a rule: Id". It
>> seems as if ANTLR does not treat the comment as ordinary plain text.
>> Can anybody confirm that this is a bug? Is there a workaround for
>> this?
>>
>> @header
>> {
>> // ... header info ...
>> // $Id$
>> //
>> }
>>
>> Best regards,
>>
>> Ranco Marcus
>> Epirion Knowledge Solutions B.V.
>>
>>
-------------------------------
Hank Schultz
Cedrus Corporation
http://www.cedrus.com/
More information about the antlr-interest
mailing list