protected void processAST() { AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); }
/** * decorate antlr AST with ending line/col info, and if * possible the snippet of source from the start/end line/col for each node. * @param t the AST to decorate * @return the decorated AST */ public AST process(AST t) { // first visit List l = new ArrayList(); traverse((GroovySourceAST)t,l,null); //System.out.println("l:" + l); // second visit Iterator itr = l.iterator(); if (itr.hasNext()) { itr.next(); /* discard first */ } traverse((GroovySourceAST)t,null,itr); return t; }
public void doStuff(String input) throws Exception { GroovyRecognizer parser; SourceBuffer sourceBuffer = new SourceBuffer(); UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new StringReader(input), sourceBuffer); GroovyLexer lexer = new GroovyLexer(unicodeReader); unicodeReader.setLexer(lexer); parser = GroovyRecognizer.make(lexer); parser.setSourceBuffer(sourceBuffer); String[] tokenNames = parser.getTokenNames(); parser.compilationUnit(); AST ast = parser.getAST(); AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); Visitor visitor = new LineColumnChecker(sourceBuffer, tokenNames); AntlrASTProcessor traverser = new SourceCodeTraversal(visitor); traverser.process(ast); } }
traverse(child,l,itr);
protected void processAST() { AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); }
/** * decorate antlr AST with ending line/col info, and if * possible the snipppet of source from the start/end line/col for each node. * @param t the AST to decorate * @return the decorated AST */ public AST process(AST t) { // first visit List l = new ArrayList(); traverse((GroovySourceAST)t,l,null); //System.out.println("l:" + l); // second visit Iterator itr = l.iterator(); if (itr.hasNext()) { itr.next(); /* discard first */ } traverse((GroovySourceAST)t,null,itr); return t; }
protected void processAST() { AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); }
/** * decorate antlr AST with ending line/col info, and if * possible the snipppet of source from the start/end line/col for each node. * @param t the AST to decorate * @return the decorated AST */ public AST process(AST t) { // first visit List l = new ArrayList(); traverse((GroovySourceAST)t,l,null); //System.out.println("l:" + l); // second visit Iterator itr = l.iterator(); if (itr.hasNext()) { itr.next(); /* discard first */ } traverse((GroovySourceAST)t,null,itr); return t; }
protected void processAST() { AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); }
/** * decorate antlr AST with ending line/col info, and if * possible the snipppet of source from the start/end line/col for each node. * @param t the AST to decorate * @return the decorated AST */ public AST process(AST t) { // first visit List l = new ArrayList(); t = traverse((GroovySourceAST)t,l,null); //System.out.println("l:" + l); // second visit Iterator itr = l.iterator(); if (itr.hasNext()) { itr.next(); /* discard first */ } t = traverse((GroovySourceAST)t,null,itr); return t; }
protected void processAST() { AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); }
/** * decorate antlr AST with ending line/col info, and if * possible the snipppet of source from the start/end line/col for each node. * @param t the AST to decorate * @return the decorated AST */ public AST process(AST t) { // first visit List l = new ArrayList(); traverse((GroovySourceAST)t,l,null); //System.out.println("l:" + l); // second visit Iterator itr = l.iterator(); if (itr.hasNext()) { itr.next(); /* discard first */ } traverse((GroovySourceAST)t,null,itr); return t; }
protected Node doParse(final UnicodeEscapingReader reader) throws Exception { GroovyLexer lexer = new GroovyLexer(reader); reader.setLexer(lexer); GroovyRecognizer parser = GroovyRecognizer.make(lexer); parser.setSourceBuffer(sourceBuffer); tokenNames = parser.getTokenNames(); parser.compilationUnit(); AST ast = parser.getAST(); AntlrASTProcessor processor; // Decorate the AST w/line+col information processor = new AntlrASTProcessSnippets(); ast = processor.process(ast); return node(ast); } }
protected Node doParse(final UnicodeEscapingReader reader) throws Exception { GroovyLexer lexer = new GroovyLexer(reader); reader.setLexer(lexer); GroovyRecognizer parser = GroovyRecognizer.make(lexer); parser.setSourceBuffer(sourceBuffer); tokenNames = parser.getTokenNames(); parser.compilationUnit(); AST ast = parser.getAST(); AntlrASTProcessor processor; // Decorate the AST w/line+col information processor = new AntlrASTProcessSnippets(); ast = processor.process(ast); return node(ast); } }
traverse(child,l,itr);
protected Node doParse(final UnicodeEscapingReader reader) throws Exception { GroovyLexer lexer = new GroovyLexer(reader); reader.setLexer(lexer); GroovyRecognizer parser = GroovyRecognizer.make(lexer); parser.setSourceBuffer(sourceBuffer); tokenNames = parser.getTokenNames(); parser.compilationUnit(); AST ast = parser.getAST(); AntlrASTProcessor processor; // Decorate the AST w/line+col information processor = new AntlrASTProcessSnippets(); ast = processor.process(ast); return node(ast); } }
protected Node doParse(final UnicodeEscapingReader reader) throws Exception { JavaLexer lexer = new JavaLexer(reader); reader.setLexer(lexer); JavaRecognizer parser = JavaRecognizer.make(lexer); parser.setSourceBuffer(sourceBuffer); tokenNames = parser.getTokenNames(); parser.compilationUnit(); AST ast = parser.getAST(); AntlrASTProcessor processor; // Convert the Java AST into Groovy AST processor = new PreOrderTraversal(new Java2GroovyConverter(tokenNames)); processor.process(ast); // Decorate the AST w/line+col information processor = new AntlrASTProcessSnippets(); ast = processor.process(ast); return node(ast); } }
traverse(child,l,itr);