[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to create additional to CST attribute in AST ?
Thank you very much for such quick response !
I had to find this solution by myself
Best regards,
Viktor
--- Etienne Gagnon <egagnon@xxxxxxxxxxx> wrote:
> Hi Victor,
>
> Yes, this is possible. SableCC is rejecting "NULL"
> because the id
> element is not optional. You simply need to make it
> optional:
>
> lib_elem =
> {program} [name]:tk_identifier [id]:tk_identifier?
> ;
>
> (Note the additional "?")
>
> SableCC does check that CST->AST transformations
> match the
> "multiplicity" of elements (not optional, "?", "*",
> and "+").
>
> Have fun!
>
>
> Etienne
>
> Viktor Suvorov wrote:
> > I want to add attribute into AST class, which have
> no
> > relation to grammar. This attribute will be filled
> > during semantic analyses stage.
> >...
> > I would like to add additional field "id" which
> can
> > store "tk_identifier" to production lib_elem in
> AST:
> >
> > lib_elem = {program} [name]:tk_identifier
> > [id]:tk_identifier
> > ;
> >
> > Is it possible to modify CST production lib_elem
> in
> > such way, that grammar would be valid ?
> Constructions
> > like
> >
> > lib_elem {-> lib_elem} = tk_program
> > [name]:tk_identifier tk_endprogram {-> New
> > lib_elem.program(name, Null)}
> > ;
> >
>
> --
> Etienne M. Gagnon, Ph.D.
> http://www.info2.uqam.ca/~egagnon/
> SableVM:
> http://www.sablevm.org/
> SableCC:
> http://www.sablecc.org/
> > _______________________________________________
> SableCC-user mailing list
> SableCC-user@xxxxxxxxxxx
>
http://sablecc.org/lists/control/listinfo/sablecc-user
>
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com