Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an AST with a CAPTURE binding?

I am interested in using the Eclipse JDT to create a CAPTURE binding.

I've read several capture conversion tutorials, but when I copy-paste sample code snippets, I can never find a capture conversion binding in the Abstract Syntax Tree (using the plugin ASTView for visualizing the AST).

How can this be accomplished?

like image 484
John Assymptoth Avatar asked Dec 15 '10 11:12

John Assymptoth


People also ask

How do you create an abstract syntax tree?

The Abstract Syntax Tree is generated using both the list of tokens (from the lexical analysis) and the source code. The AST is generated during the syntax analysis stage of the compilation. Any syntax error would be detected and a syntax error message would then be returned, stopping the compilation process.

What is Java AST?

The AST is a detailed tree representation of the Java source code. The AST defines an API to modify, create, read and delete source code. The main package for the AST is the org. eclipse. jdt.

What is the role of abstract syntax trees in parsing?

An abstract syntax tree (AST) is a way of representing the syntax of a programming language as a hierarchical tree-like structure. This structure is used for generating symbol tables for compilers and later code generation. The tree represents all of the constructs in the language and their subsequent rules.


1 Answers

Example provided by Deepak Azad @ Eclipse Forums:

interface Box<T> {
    public T get();
    public void put( T element);
}

class CaptureTest {
    public void rebox( Box<?> box) {
        box.get(); // return type of get() is a capture binding
    }
}
like image 182
John Assymptoth Avatar answered Oct 02 '22 00:10

John Assymptoth