• 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
Bidirectional ceylon.ast / RedHat compiler AST conversion
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;
Last Published Nov 19, 2017
Stats Downloads (JVM): 9798
Downloads (JS): 0
Source downloads: 1440
Module links Home
Code repository
Issue tracker
Imported By
Browse
List of published versions
1.3.3 JVM JVM: 1.2.x, 1.3.x (latest) Published Nov 19, 2017 Browse
View docs
1.3.2 JVM JVM: 1.2.x, 1.3.x (latest) Published Mar 24, 2017 Browse
View docs
1.3.1 JVM JVM: 1.2.x, 1.3.x (latest) Published Dec 7, 2016 Browse
View docs
1.3.0 JVM JVM: 1.2.x, 1.3.x (latest) Published Sep 18, 2016 Browse
View docs
1.2.2 JVM JVM: 1.2.x, 1.3.x (latest) Published Apr 8, 2016 Browse
View docs
1.2.1 JVM JVM: 1.2.x, 1.3.x (latest) Published Feb 13, 2016 Browse
View docs
1.2.0 JVM JVM: 1.2.x, 1.3.x (latest) Published Nov 8, 2015 Browse
View docs
1.1.0 JVM JVM: 1.1.0 (outdated) Published Oct 16, 2014 Browse
View docs
You must be logged in to comment.

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