[antlr-interest] adding child node in rewring rule

Юрушкин Михаил yurushkin at rambler.ru
Mon Feb 1 12:48:17 PST 2010


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


More information about the antlr-interest mailing list