----- Original Message ----From:Peter Niederwieser> Hi,> > I have the following problem with my DSL: on one transfer. I'd desire to do AST> transformations before phase SEMANTIC_ANALYSIS because it's simpler (I> don't undergo to give the information that semantic analysis will create).> On the other hand. I'd like to do them afterwards so that I can use the> information that semantic analysis has produced. Now my question is can I> have the best of both worlds by doing the following:> > 1 run semantic analysis> 2 do transformations> 3 run semantic analysis again> > Some quick tests were promising and there's also a comment in> CompilationUnit hive away() that seems to suggest that arrange operations must> be able to cope with multiple invocations: "To support delta compilations,> we always restart the compiler. The individual passes are responsible for> not reprocessing old label". Anyway before going advance down this route do> you evaluate this is a good idea or is it likely going to lead to problems?Of course we can always bypass the compiler phases and invoke the steps directly. Some code appended which duplicates what happens but written in Groovy instead tested OK in 1.1-RC-1. Cheers. Gavin Groverdef sampleScript='''\class Hello{ static cancel main(args){ println "hello world" def g= new Goodbye() g speak() }}class Goodbye extends Hello{ def communicate(){ println "goodbye world" }}'''import org codehaus groovy antlr. SourceBufferimport org codehaus groovy antlr. UnicodeEscapingReaderimport org codehaus groovy antlr parser. GroovyLexerimport org codehaus groovy antlr parser. GroovyRecognizerimport antlr collections. ASTimport org codehaus groovy antlr. AntlrASTProcessSnippetsimport org codehaus groovy antlr. AntlrParserPlugindef reader= new InputStreamReader(new ByteArrayInputStream(sampleScript bytes))def sourceBuffer= new SourceBuffer()def unicodeReader= new UnicodeEscapingReader(reader sourceBuffer)def lexer= new GroovyLexer(unicodeReader)unicodeReader lexer= lexerdef parser= GroovyRecognizer make( lexer )parser sourceBuffer= sourceBufferparser compilationUnit()AST ast= parser aSTString[] tokenNames= parser tokenNamesdef snippets = new AntlrASTProcessSnippets(sourceBuffer)ast= snippets process(ast)def app= new AntlrParserPlugin()app makeModule()app convertGroovy(ast)def grAst= app outputgrAst sortClasses()import org codehaus groovy classgen. VariableScopeVisitormerchandise org codehaus groovy.
Forex Groups - Tips on Trading
Related article:
http://archive.codehaus.org/groovy/user/43771.87371.qm@web52606.mail.re2.yahoo.com
comments | Add comment | Report as Spam
|