History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ANTLR-110
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Terence Parr
Reporter: Terence Parr
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ANTLR v3

write generated code directly to stream not to string first

Created: 16/Apr/07 01:21 PM   Updated: 17/Apr/07 10:03 AM
Component/s: ANTLR Core
Affects Version/s: 3.0b7
Fix Version/s: 3.0b8


 Description  « Hide
Mimic ST:

public String toString(int lineWidth) {
StringWriter out = new StringWriter();
// Write the output to a StringWriter
StringTemplateWriter wr = group.getStringTemplateWriter(out);
wr.setLineWidth(lineWidth);
try {
write(wr);
}
catch (IOException io) {
error("Got IOException writing to writer "+wr.getClass().getName());
}
// reset so next toString() does not wrap; normally this is a new writer
// each time, but just in case they override the group to reuse the
// writer.
wr.setLineWidth(StringTemplateWriter.NO_WRAP);
return out.toString();
}

to write directly to output file instead of to string first. as you can see we go to string first:

public void write(StringTemplate code, String fileName) throws IOException {
Writer w = tool.getOutputFile(grammar, fileName);
long start = System.currentTimeMillis();
String output = code.toString(lineWidth);
//String output = code.toString();
long stop = System.currentTimeMillis();
//System.out.println("render time for "+fileName+": "+(int)(stop-start)+"ms");
w.write(output);
w.close();
}


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Terence Parr - 17/Apr/07 10:03 AM
writing to file directly now.