dcsimg
New Java 2 Version 1.3 Grammar!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Terence_Parr
Posted On:   Sunday, August 12, 2001 03:04 PM

Thanks to the help of Allan Jacobs at Sun and Steve Messick at Instantiations (jFactor was written in ANTLR), I have been able to upgrade the ANTLR Java grammar to Java 2 Version 1.3. I not only did that, but cleaned things up a bit, fixed some bugs etc... I merged the ideas from those gentlemen with some "ambiguity removing" tweaks :) They might recognize what I've cobbled together. ;) Java 2 Version 1.3 Grammar . In principle it should read unicode characters in strings and such now too. It'd be great if somebody can test that and see if I'm right. ;) I also made Main.java use buffered IO, making exec time to pa   More>>

Thanks to the help of Allan Jacobs at Sun and Steve Messick at
Instantiations (jFactor was written in ANTLR), I have been able to
upgrade the ANTLR Java grammar to Java 2 Version 1.3. I not only
did that, but cleaned things up a bit, fixed some bugs etc... I
merged the ideas from those gentlemen with some "ambiguity removing"
tweaks :) They might recognize what I've cobbled together. ;)




Java 2 Version 1.3 Grammar .




In principle it should read unicode characters in strings and such now
too. It'd be great if somebody can test that and see if I'm
right. ;)



I also made Main.java use buffered IO, making exec time to parse 1.3
source 2/3 of what it was 3 minutes down to 2 minutes:

			
unbuffered IO:
149.87user 37.65system 3:07.65elapsed 99%CPU
buffered IO:
150.60user 1.47system 1:59.85elapsed 126%CPU


Note that the buffering let more than one CPU kick in. :) This test
was done on a dual 400Mhz 512M VA linux box.




My random scribbles as I hacked:


  • primary didn't include boolean.class kind of thing
  • constructor calls parsed explicitly now:
    see explicitConstructorInvocation
  • add strictfp modifier
  • missing objBlock after new expression in tree grammar
  • merged local class definition alternatives, moved after declaration
  • fixed problem with ClassName.super.field
  • reordered some alternatives to make things more efficient
  • long and double constants were not differentiated from int/float
  • whitespace rule was inefficient: matched only one char
  • add an examples directory with some nasty 1.3 cases
  • made Main.java use buffered IO and a Reader for Unicode support
  • supports unicode?
    Using Unicode charVocabulay makes code file big, but only
    in the bitsets at the end. I need to make ANTLR generate
    unicode bitsets more efficiently.




Let me know if it works for you.    <<Less

Re: New Java 2 Version 1.3 Grammar!

Posted By:   Anonymous  
Posted On:   Tuesday, September 4, 2001 03:04 AM

I recognize that the Java Lexer didn't make any differenz
between Integer and Long.

The Lexer rules NUM_INT checks this correctly but i was
missing that he sets the Token Type correctly.
what about a Line 1143:
( ('l'|'L') { _ttype = NUM_LONG;}

Without this it is a loss of Meta Information and later this
decision has to be done again !?

Christian
About | Sitemap | Contact