[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grammar question



>   public void caseAAWord(AAWord node)


Oops... This should be "inXXX()":

   public void inAAWord(AAWord node)

instead, so that the code could deal nicely with recursive productions!


>   {
>     if(a)
>       throw new RuntimeException("more than one A");
>       // or better, you declare your own runtime-exception type.
>     a = true;
>   }
> 
>   // same for B and C
> }
> 
> now, in your "main", after parsing, you do something like:
> 
>   ast.apply(new Weeder);
> 
> Hope this helps.
> 
> Etienne


-- 
Etienne M. Gagnon                    http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/