[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AW: Parsing Specific Productions
I think you misunderstood me, I'll try to be more specific :-)
Let's supose that in certain grammar you have a main production, let's
call it P1, and you have an internal production called P2.
Due to P2 is part of a bigger production P1, I can only reach it by
parsing P1, an example of that is the Java grammar, taking P1 as the
production of a class, and P2 the production of a method.
I want to still using the same grammar to parse P2 separately of P1, in
JavaCC you can do it just by calling the associated method created to
parse the production P2, and it returns its corresponding "AST"
(associates to P2).
Taking the Java example I would like to parse a class file and generate
its corresponding AST and also to parse a method and getting its AST.
blah, blah, blah
public void method1( blah blah bla )
blah blah blah blah
So, just by using the same compiler I want to get both AST, one for the
class definition, and the second one for the method definition.
As I said, that is possible to do it in JavaCC and I don't know how to
do the same in SableCC.
Again, I would appreciate any advice :-)
> Thomas Leonhardt wrote:
> I don't know if I got the point. But why don't you use
> the DepthFirstVisitor, extend it with your own class which
> only implements the visitor methods you're interessted in.
> > -----Ursprungliche Nachricht-----
> > Von: firstname.lastname@example.org
> > [mailto:email@example.com]Im Auftrag von Patricio
> > Salinas Caro
> > Gesendet: Mittwoch, 23. Mai 2001 12:35
> > An: firstname.lastname@example.org
> > Betreff: Parsing Specific Productions
> > Hello,
> > Does anyone knows how to parse an specific production instead
> > of doing it
> > for the whole grammar?
> > I mean, let's take for instance the Java grammar, I would
> > like to parse
> > class files and also methods body separately. I know that is
> > possible to
> > do it in JavaCC (it is straight forward once you have your grammar)
> > because you just call the method associated with the production, but
> > don't know how to do the same in SableCC.
> > Is it clear what am asking for? I would appreciate any advice.
> > Thanks in advance and Best Regards,
> > Patricio Salinas
> > ps: I read the documentation some time ago (the thesis report), and
> > don't remember anything related with that.