This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: staged rewriting via compiler plugins

1 reply
Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.

Just to add some context to my question about re-visiting the parse phase,
the
situation for Java compilers compliant with JSR-269 is depicted in the
attached pdf,
showing that annotation processing my trigger another round of parsing.

A similar workflow can be of value when processing Scala annotations too.
Tips on how to achieve that are welcome.

regards,

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: Re: staged rewriting via compiler plugins
I believe you could do that manually: add a phase after the parser which, when applied to a compilationunit, modifies the compilation unit, creates a new scanner+parser for that unit and runs the new parser. You could for instance replace the default UnitScanner by a custom one to inject your code.
However, is there a reason for not adding the new definitions directly into the AST? By running the plugin after the parser you get name resolution and typin, you really only need to create the trees. This seemsto be simpler.
Lukas

On Wed, Jun 17, 2009 at 12:59, Miguel Garcia <miguel.garcia@tuhh.de> wrote:

Just to add some context to my question about re-visiting the parse phase, the
situation for Java compilers compliant with JSR-269 is depicted in the attached pdf,
showing that annotation processing my trigger another round of parsing.

A similar workflow can be of value when processing Scala annotations too.
Tips on how to achieve that are welcome.

regards,

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland