Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Metadata

Number:

GEP-2

Title:

AST Builder Support

Version:

1

Type:

Feature

Target:

1.7

Status:

Draft

Leader:

Hamlet D'Arcy

Created:

2009-04-01

Last modification:

2009-04-01

Abstract

Groovy 1.6 introduced the ability to perform local and global AST (Abstract Syntax Tree) transformations, allowing users to read and modify the AST of Groovy code as it is being compiled. Reading information in the AST is relatively easy in Groovy. The core library provides a strongly typed visitor called GroovyCodeVisitor. Nodes can be read and modified using the API provided through the subtypes of ASTNode. Writing new AST nodes is not as simple. The AST generated from source is not always obvious, and using constructor calls to generate trees of nodes can be verbose. This GEP proposes an ASTBuilder object that allows users to easily create AST.

The ASTBuilder object allows AST to be created from Strings containing Groovy source code, from a closure containing Groovy source, and from a closure containing an AST creation DSL.

Approach

General Approach

Examples

The following examples have all been proposed at some point:

1. ASTNode form GString

 2. ASTNode from GString in Closure

 3. ASTNode from Templated GString

4. ASTNode from code block

5.  ASTNode from psuedo-specification

Advantages

Disadvantages

Alternatives

References

Mailing-list discussions

JIRA issues

  • Pending

Reference Implementation

Pending...

  • No labels