[antlr-interest] preserve whitespace example
Benoit Fouletier
benblo+ANTLR at gmail.com
Wed Jun 24 09:39:37 PDT 2009
I'm trying to convert the preserve whitespace
example<http://www.antlr.org/article/whitespace/index.html> to
v3. I've followed the migration guidelines on the wiki but I still have
problems:
- lexer: *options { charVocabulary = '\3'..'\377'; }* ... deprecated in
v3?
- treewalker: lots of # that I'm supposed to convert to $, or to rewrite
rules... I'm quite lost!
- overall I'm not sure how I'm supposed to combine the 3 grammars:
- if I just copy-paste lexer and parser into one grammar, it compiles
but raises an EarlyExitException on execution...
- ... then if I also paste the tree, rules are duplicated.
- if I keep separate files, and import the lexer from the parser, I
get "*literal has no associated rule: 'if'*"...
- ... then I import the parser from the tree, and it sees that rules
are overridden (ANTLRWorks is awesome btw!), but I still don't
know what to
do with all the # stuff.
I've attached all my grammars & input text...
Ben
PS: I've also tried to use the v2v3
converter, which raises an exception. I don't even know if the
converter fails to run, or if it
chokes on the grammar.
I believe I exported the classpath correctly since I don't get
the NoClassDefFoundError...
MacPro:v2 to v3 converter Ben$ export
CLASSPATH="$CLASSPATH:/Users/Ben/Desktop/ANTLR/lib/antlr-2.7.7.jar:/Users/Ben/Desktop/ANTLR/lib/antlr-3.1.3.jar:/Users/Ben/Desktop/ANTLR/lib/antlr-runtime-3.1.3.jar:/Users/Ben/Desktop/ANTLR/lib/gunit.jar:/Users/Ben/Desktop/ANTLR/lib/stringtemplate-3.2.jar"
*
*MacPro:v2 to v3 converter Ben$ java v3me originals/InstrLexer.g
*Exception in thread "main" java.lang.NoSuchFieldError: type** **at
ANTLRLexer.mT48(ANTLRLexer.java:140)** **at
ANTLRLexer.mTokens(ANTLRLexer.java:2822)*
* **at org.antlr.runtime.Lexer.nextToken(Lexer.java:84)*
* **at
org.antlr.runtime.CommonTokenStream.fillBuffer(CommonTokenStream.java:95)*
* **at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:238)*
* **at org.antlr.runtime.CommonTokenStream.LA(CommonTokenStream.java:300)*
* **at ANTLRParser.antlrGrammar(ANTLRParser.java:124)*
* **at v3me.main(v3me.java:25)*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090624/4329277d/attachment.html
-------------- next part --------------
// start comment
// another comment
a = 2;
g();
{
a=3*4;
}
if 3 then f(4 + b);
else {
b =a; // assign
}
// final
-------------- next part --------------
A non-text attachment was scrubbed...
Name: originals.zip
Type: application/zip
Size: 1750 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090624/4329277d/attachment.zip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: converted.zip
Type: application/zip
Size: 1789 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090624/4329277d/attachment-0001.zip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: combined.zip
Type: application/zip
Size: 763 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090624/4329277d/attachment-0002.zip
More information about the antlr-interest
mailing list