Ceylon Typechecker: How to get a typed syntax tree?

I am trying to programmatically use / implement Ceylon Typechecker to analyze Ceylon source code. In this case, I want to access all the information that the compiler usually consumes. But I'm not going to compile and Im not going to add compiler dependency.

It seems to me that the main entry point to ceylon / typechecker / src / main / Main.java is not a suitable entry point for this use case (getting a typed tree and attached models), because this information, which was collected by visitors in three verification steps, discarded and only errors are printed.

So my question is:

How can I parse and typecheck the compilation unit, and then get 1. a typed syntax tree and 2. related objects of the model of the types that visitors to the analysis in the tree encounter that are associated with the tree.

edited by:

There was (and is) some confusion on my side about three different ASTs.

In README in ceylon / ceylon.ast it says:

¨ ... ceylon.ast.core - Ceylon classes representing the Ceylon AST. Pure Ceylon (independent of the backend). ... ceylon.ast.redhat - converts ceylon.ast.core AST from + to the RedHat compiler (ceylon-spec AST, and also contains functions for compiling ceylon.ast.core AST from the code string (using the RedHat compiler) .. . ¨.

So, there are 3 ASTs: 1. The one generated by antlr, 2. ceylon.ast.core and 3. ceylon.ast.redhat. Why?

+4
1

, :

  • TypeCheckerBuilder , typecheck,
  • TypeChecker (builder.typechecker),
  • typechecker (typeChecker.process()),
  • , typeChecker.phasedUnits. , typeChecker.getPhasedUnits().getPhasedUnits() List<PhasedUnit>, PhasedUnit getCompilationUnit(), Tree.CompilationUnit, AST. AST .

Dart, process() compileDart().

testCompile, , compileDart().

+5

Source: https://habr.com/ru/post/1627825/


All Articles