[antlr-interest] TokenStreamSelector/includeFile example for 3.0?
Peter White
pwhite at peter-white.info
Mon Feb 5 16:38:31 PST 2007
Hello,
I've written a simple filtering grammar to extract instances of our
custom JSP tags from our JSP pages and I've been unable to parse JSP
includes "in-line" successfully. Initially, I tried to include files by
using the following "include" method in my lexer class but that only
resulted in the exception following my code snippet.
@lexer::members {
public void include(String filename) {
if (filename.endsWith("top.jspf\"")) return;
indent();
// Might need to escape filename...
String relativePath = filename.substring(1, filename.length()-1);
String absolutePath = BASE_DIR + "/" + relativePath;
System.out.println("<!-- Including: " + absolutePath + " -->");
try {
UITagLexer lex = new UITagLexer(new ANTLRFileStream(absolutePath));
CommonTokenStream tokens = new CommonTokenStream(lex);
UITagParser g = new UITagParser(tokens);
g.document();
} catch (IOException e) {
e.printStackTrace();
} catch (RecognitionException e) {
e.printStackTrace();
}
}
}
org.antlr.runtime.debug.DebugParser.reportError(DebugParser.java:87):
java.net.BindException: Address already in use: JVM_Bind
After searching the mail archives, I realized the above approach
wouldn't work and I came across several references to the includeFile
example so I downloaded the source to 2.7.7 to examine it. I've noticed
that TokenStreamSelector.java isn't included in the 3.0 beta source
distribution and was wondering if there's some other mechanism for
achieving the same results in 3.0. My apologies if this is currently
documented somewhere - I searched the ANTLR website and mail archives
and didn't see anything.
Any pointers in the right direction would be greatly appreciated!
Thanks,
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070205/0051f14b/attachment.html
More information about the antlr-interest
mailing list