[antlr-interest] Fortran lexer problem
kferrio at gmail.com
kferrio at gmail.com
Sun Jan 17 13:10:59 PST 2010
Michael... I feel pity for you if have to parse F77. You're going to run into a few problems harder to solve/avoid than this. So if you're just going to discard comments anyway... I suggest you prefilter your input with a tool like 'sed' to strip fixed format comments. Then you can get on with quirky things like Fortran edit descriptors. :)
Kyle
Sent from my Verizon Wireless BlackBerry
-----Original Message-----
From: Юрушкин Михаил <yurushkin at rambler.ru>
Date: Fri, 15 Jan 2010 21:56:21
To: Юрушкин Михаил<yurushkin at rambler.ru>; Jim Idle<jimi at temporal-wave.com>; antlr-interest at antlr.org<antlr-interest at antlr.org>
Subject: Re: [antlr-interest] Fortran lexer problem
I have the following term
LINE_COMMENT
: ({blabla}? ('c' | 'C' | '*') | '!' ) ~('\n')*
{
$channel = HIDDEN;
}
;
but it only pasts the following code at the end:
switch (alt31)
{
case 1:
{
if ( !((blabla)) )
{
CONSTRUCTEX();
EXCEPTION->type =
ANTLR3_FAILED_PREDICATE_EXCEPTION;
EXCEPTION->message = (void *)"blabla";
EXCEPTION->ruleName = (void *)"LINE_COMMENT";
}
if "blabla" is false, an error is occured... but it's not right.
Юрушкин Михаил <yurushkin at rambler.ru> писал(а) в своём письме Fri, 15 Jan
2010 21:27:22 +0300:
> Excuse me, but how can I specify this condition (is it a first symbol and
> symbol='c')?
> Could you send me a piece of lexer grammar?
>
>
> Jim Idle <jimi at temporal-wave.com> писал(а) в своём письме Fri, 15 Jan
> 2010
> 21:20:46 +0300:
>
>> I think Fortran comments that start with C have to have the C in
>> character position 0 (or 1 in Fortran I guess ;-). So your comment rule
>> can be predicated by checking for line position 0 in ANTLR terms.
>>
>> Jim
>>
>>> -----Original Message-----
>>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>>> bounces at antlr.org] On Behalf Of Þðóøêèí Ìèõàèë
>>> Sent: Friday, January 15, 2010 9:51 AM
>>> To: antlr-interest at antlr.org
>>> Subject: [antlr-interest] Fortran lexer problem
>>>
>>> Good day,
>>>
>>> I want to add comments of Fortran 77:
>>>
>>> "c xxxxx";
>>> First symbol in column is 'c' - it means that the following line is a
>>> line
>>> of comment.
>>>
>>> but I also have NAME token, that will conflict with such COMMENT rule.
>>> ('c' can be a name).
>>>
>>> Is it possible to select rule by my own predicate? Are there any other
>>> more clear solvings of
>>> this problem?
>>>
>>>
>>> --
>>> Best regards,
>>> Michael
>>>
>>> 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
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature database 4775 (20100115) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://www.esetnod32.ru
>>
>>
>>
>
>
--
Best regards,
Michael
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