Search in sources :

Example 1 with AntlrASTProcessSnippets

use of org.codehaus.groovy.antlr.AntlrASTProcessSnippets in project groovy by apache.

the class LineColumnTest method doStuff.

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);
}
Also used : AST(antlr.collections.AST) SourceBuffer(org.codehaus.groovy.antlr.SourceBuffer) AntlrASTProcessor(org.codehaus.groovy.antlr.AntlrASTProcessor) UnicodeEscapingReader(org.codehaus.groovy.antlr.UnicodeEscapingReader) GroovyLexer(org.codehaus.groovy.antlr.parser.GroovyLexer) AntlrASTProcessSnippets(org.codehaus.groovy.antlr.AntlrASTProcessSnippets) StringReader(java.io.StringReader) GroovyRecognizer(org.codehaus.groovy.antlr.parser.GroovyRecognizer)

Example 2 with AntlrASTProcessSnippets

use of org.codehaus.groovy.antlr.AntlrASTProcessSnippets in project groovy-core by groovy.

the class LineColumnTest method doStuff.

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);
}
Also used : AST(antlr.collections.AST) SourceBuffer(org.codehaus.groovy.antlr.SourceBuffer) AntlrASTProcessor(org.codehaus.groovy.antlr.AntlrASTProcessor) UnicodeEscapingReader(org.codehaus.groovy.antlr.UnicodeEscapingReader) GroovyLexer(org.codehaus.groovy.antlr.parser.GroovyLexer) AntlrASTProcessSnippets(org.codehaus.groovy.antlr.AntlrASTProcessSnippets) StringReader(java.io.StringReader) GroovyRecognizer(org.codehaus.groovy.antlr.parser.GroovyRecognizer)

Aggregations

AST (antlr.collections.AST)2 StringReader (java.io.StringReader)2 AntlrASTProcessSnippets (org.codehaus.groovy.antlr.AntlrASTProcessSnippets)2 AntlrASTProcessor (org.codehaus.groovy.antlr.AntlrASTProcessor)2 SourceBuffer (org.codehaus.groovy.antlr.SourceBuffer)2 UnicodeEscapingReader (org.codehaus.groovy.antlr.UnicodeEscapingReader)2 GroovyLexer (org.codehaus.groovy.antlr.parser.GroovyLexer)2 GroovyRecognizer (org.codehaus.groovy.antlr.parser.GroovyRecognizer)2