• Modules
    • By category
    • By name
    • Most popular
    • Most downloaded
    • Repository
  • Register
  • Log in
  • Help
    • Start using Ceylon Herd
    • Publish your first module
    • Module publishing guidelines
    • All about Ceylon
    • Keyboard Shortcuts

    • s Focus search module bar
      ? Open this information panel
      j Move selection down
      k Move selection up
      enter Open current selection
Module info
Name
lucaswerkmeister / ceylon.ast.redhat / 1.3.0
Bidirectional ceylon.ast / RedHat compiler AST conversion
Backends JVM
Maven coordinates
Compatible Ceylon release JVM: 1.2.x, 1.3.x (latest)
Published Sep 18, 2016
Stats Downloads (JVM): 299
Source downloads: 212
Authors Lucas Werkmeister <mail@lucaswerkmeister.de>
License http://www.apache.org/licenses/LICENSE-2.0.html
Description

This module defines a bidirectional conversion between ceylon.ast and the RedHat compiler AST, as well as functions that directly parse code to ceylon.ast nodes using the RedHat compiler.

ceylon.ast → RedHat AST:

that.transform(RedHatTransformer(SimpleTokenFactory()))

RedHat AST → ceylon.ast:

compilationUnitToCeylon(that)

Code → ceylon.ast:

parseCompilationUnit(code)

For the latter two, there are also functions for (almost) every other node type, e. g. expressionToCeylon, parseType, etc.

All XToCeylon and parseX functions also take a second parameter:

Anything(JNode,Node) update = noop

This function is invoked once for every [[ceylon.ast.core::Node]] created with the original RedHat AST node (above aliased to JNode) and the new ceylon.ast Node as arguments. It can be used to copy information from the old AST to the new one, for example:

Key<Token[]> tokensKey = ScopedKey<Token[]>(`module`, "tokens");
value cu = parseCompilationUnit {
    code;
    void update(JNode orig, Node res) {
        res.set(tokensKey, [orig.mainToken, orig.mainEndToken].coalesced);
    }
};
// later
assert (exists tokens = cu.get(tokensKey));

The default is noop, i. e., to do nothing. Another useful argument provided by this module is attachOriginalNode, which allows you to later retrieve the original node from originalNodeKey:

value cu = parseCompilationUnit {
    code;
    update = attachOriginalNode;
};
// later
assert (exists orig = cu.get(originalNodeKey));
value tokens = [orig.mainToken, orig.mainEndToken].coalesced;
Dependencies
ceylon.ast.core/1.3.0 shared
ceylon.interop.java/1.3.0
ceylon.language/1.3.0
com.redhat.ceylon.typechecker/1.3.0 shared
Usage
  • Import
 import ceylon.ast.redhat "1.3.0";
Module links Members
Imported By
Home
Code repository
Issue tracker
Browse
Download .car
No .js archive
Download source archive
Download module documentation
View API documentation

Ceylon Herd v1.24 Copyright 2012-2023 Red Hat. About