// Build a automaton from the grammar model
ParserAutomaton parserautomaton =
(new ParserAutomatonBuilder(grammar, log)).getParserAutomaton();
// Create a processor for the grammar
ParserProcessor parser = new ParserProcessor();
parser.setLog(log);
parser.setParserAutomaton(parserautomaton);
// Create factory for SAX transformer
SAXTransformerFactory transformerFactoryImpl =
(SAXTransformerFactory)SAXTransformerFactory.newInstance();
// Create serializer to write the SAX stream into a file
TransformerHandler serializer = transformerFactoryImpl.newTransformerHandler();
serializer.setResult(new StreamResult(outFile));
// Connect components into a pipeline
lexer.setContentHandler(parser);
parser.setContentHandler(serializer);
// Push text into this pipeline
// Create locator, which help to find possible syntax errors
LocatorImpl locator = new LocatorImpl();
locator.setSystemId(inFile.toURL().toString());