final SourceBuffer sourceBuffer = new SourceBuffer();
UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(reader,sourceBuffer);
GroovyLexer lexer = new GroovyLexer(unicodeReader);
unicodeReader.setLexer(lexer);
GroovyRecognizer parser = GroovyRecognizer.make(lexer);
parser.setSourceBuffer(sourceBuffer);
tokenNames = parser.getTokenNames();
parser.setFilename(sourceUnit.getName());
// start parsing at the compilationUnit rule
try {
parser.compilationUnit();
}
catch (TokenStreamRecognitionException tsre) {
RecognitionException e = tsre.recog;
SyntaxException se = new SyntaxException(e.getMessage(),e,e.getLine(),e.getColumn());
se.setFatal(true);
sourceUnit.addError(se);
}
catch (RecognitionException e) {
SyntaxException se = new SyntaxException(e.getMessage(),e,e.getLine(),e.getColumn());
se.setFatal(true);
sourceUnit.addError(se);
}
catch (TokenStreamException e) {
sourceUnit.addException(e);
}
ast = parser.getAST();
AntlrASTProcessor snippets = new AntlrASTProcessSnippets(sourceBuffer);
ast = snippets.process(ast);
AccessController.doPrivileged(new PrivilegedAction() {