[antlr-interest] adding child node in rewring rule

William B. Clodius wclodius at los-alamos.net
Thu Feb 4 18:37:00 PST 2010


What he need to do is if the do in the do statement is followed by an integer literal is walk the tree until he finds the label with that literal and make the end of the statement that begins with that label the end of the do loop. He also needs to read up on Sale's algorithm, although unfortunately the revised version has an error for do loops, or so Waite has told me.

On Feb 4, 2010, at 9:57 AM, Chris DiGiano wrote:

> I would try something like this...
> 
> do_construct
>  :  do_stmt
>        ( ( {blablabla}?=>  execs+=exec_construct ) )*
>        ( ( {blablabla}?=> final_exec_construct_or_end_do ) )
>     -> ^(T_DO_CONSTRUCT $execs* final_exec_construct_or_end_do)
> 
> final_exec_construct_or_end_do
>  : exec_construct -> exec_construct T_ENDDO
>  | end_do -> end_do
>  ;
> 
> Do you really need to repeatedly test blablablabla?
> 
> Chris
> 
> 2010/2/2 Юрушкин Михаил <yurushkin at rambler.ru>:
>> I know about this project. But it (OFP project) doesn't fit to my
>> requirements
>> 1) it's written in java (I need C target)
>> 2) It doesn't create AST. It's important because, in the past I didn't use
>> AST
>> and had many memory leakages. For Java there're no such problem, but it is
>> for C target.
>> 3) They have many fixes (coded in java).
>> 
>> William B. Clodius <wclodius at los-alamos.net> писал(а) в своём письме Wed,
>> 03 Feb 2010 06:34:45 +0300:
>> 
>>> Again I urge you to check out the Open Fortran Parser Project,
>>> http://fortran-parser.sourceforge.net/,
>>> as you are trying to reinvent the wheel. If their license is too
>>> restrictive you might consider the parser portion of g2c, g77, gfortran,
>>> or some of the commercial
>>> compilers.
>>> 
>>> On Feb 1, 2010, at 1:48 PM, Юрушкин Михаил wrote:
>>> 
>>>> Hello,
>>>> Could you help me with following problem:
>>>> 
>>>> I try to parse do_stmts of fortran (incudining non-block)
>>>> 
>>>> there is a part of grammar
>>>> 
>>>> do_construct
>>>>   :  do_stmt
>>>>         ( ( {blablabla}?=>  (exec_construct | end_do) ) )+
>>>>      -> ^(T_DO_CONSTRUCT do_stmt execution_part_construct* T_ENDDO)
>>>> 
>>>> as you can see, (..)+ cycle can be stopped by blablabla predicate.
>>>> 
>>>> What I need:
>>>> if the last stmt is exec_construct, I want to generate the following:
>>>>   ^(T_DO_CONSTRUCT do_stmt execution_part_construct* T_ENDDO)
>>>> 
>>>> If the last stmt is end_do, I want to generate the following:
>>>>   ^(T_DO_CONSTRUCT do_stmt execution_part_construct* end_do)
>>>> 
>>>> what can you suggest?
>>>> thanks a lot
>>>> 
>>>> --
>>>> 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
>> 
>> 
>> --
>> 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