[antlr-interest] paraphrase without lexer

Ric Klaren klaren at cs.utwente.nl
Mon Apr 15 01:47:16 PDT 2002


Hi,

On Sun, Apr 14, 2002 at 10:16:00AM -0700, Terence Parr wrote:
> >>> Does anyone know if it's possible to specify a paraphrase in the
> >>> parser, instead of in the lexer?
> >>
> >> Well, if you're not using the lexer support of ANTLR then it can't help
> >> you with paraphrases and can't transmit anything to the lexer.  With
> >> your own lexer, you are completely on your own I'm afraid.
> >
> > I understand your point; I was hoping that it was possible to specify
> > the paraphrase in the parser (in the token section) because the
> > paraphrase
> > is only used by the parser, not by the lexer.


> Ah...i had not thought about it that way.  You're right.  In principle
> that could work; only problem is that I think ANTLR stores that stuff in
> the lexer ;)

It's stored in the parsers ;)

I see 2 or 3 options. Override reportError and do search and replace on
error strings. Generate your parser and use some script to search and
replace in the parsers tokenNames section.

Third option (I'm currently making an educated guess after having looked at
the code (cppcodegen)) hack antlr a little to make it settable from the
parser. I suspect that it can be done in under 30 lines of code.

RuleBlock.java being the place with the restriction. It may even be
possible that it works if you just remove the lexer check ;)

Also genTokenStrings method in the CodeGenerators.

The more I look at it the more I feel that it works by just removing the
restriction....

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  "I don't have anything against Java - it's the best damn implementation
				  of UCSD Pascal ever released..." --- Larry Smith


 

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



More information about the antlr-interest mailing list