We attempt to store comments in our AST as statements. Mostly, the places where statements are valid and (full line) comments are valid are the same, so this isn't a problem. However, in the case of the CASE block
select case
case (expr1)
statement
case (expr2)
statement
end select
the user is able to insert comments between the SELECT CASE statement, and the first CASE statement.
These comments are currently thrown away. I wonder if there's a way we could keep them instead.
Production code does use this pattern: the open source WRF-Chem project uses it a number of times (extract):
tracer_select: SELECT CASE(config_flags%tracer_opt)
!
! only mixing one fire(smoke) scalar array
!
CASE (TRACER_SMOKE,TRACER_TEST1,TRACER_TEST2)
CALL wrf_debug(15,'DOING TRACER MIXING, 1 SPECIE ONLY')
do nv=2,num_tracer
do k=kts,kte
pblst(k)=max(epsilc,tracer(i,k,j,nv))
enddo
call vertmx(dtstep,pblst,ekmfull,dryrho_1d, &
zzfull,zz,0.,kts,kte)
do k=kts,kte-1
tracer(i,k,j,nv)=max(epsilc,pblst(k))
enddo
enddo
CASE DEFAULT
! CALL wrf_debug(15,'NOT YET DEFINED')
END SELECT tracer_select
We attempt to store comments in our AST as statements. Mostly, the places where statements are valid and (full line) comments are valid are the same, so this isn't a problem. However, in the case of the CASE block
the user is able to insert comments between the
SELECT CASE
statement, and the firstCASE
statement.These comments are currently thrown away. I wonder if there's a way we could keep them instead.
Production code does use this pattern: the open source WRF-Chem project uses it a number of times (extract):