[antlr-interest] Constructors

Ric Klaren klaren at cs.utwente.nl
Mon Jun 10 01:49:40 PDT 2002


On Sun, Jun 09, 2002 at 09:50:51PM -0000, johnclarke72 wrote:
> I know how to define extra methods within my grammar but how can I 
> write my own Constructors within a grammar. Essentially I want to add 
> two constructors (one that has no parameters and another that has 
> parameters).

Just add them:

header { // headerstuff }

{ // for c++ this goes into the generated .cpp file
// extra constructor implementation
MyParser::MyParser( .. .. .. )
{
}

}
class MyParser extends Parser;
{
// for java the implementation goes here as well (i think)
MyParser( .. .. .. .. );

}

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 'And this 'rebooting' business? Give it a good kicking, do you?' 'Oh, no,
  of course, we ... that is ... well, yes, in fact,' said Ponder. 'Adrian
    goes round the back and ... er ... prods it with his foot. But in a
     technical way,' he added. --- From: Hogfather by Terry Pratchett.


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list