The Ceylon Typechecker: How to obtain the typed syntax tree?

混江龙づ霸主 提交于 2019-12-05 13:48:23

In short, you'll want to:

  • Configure a TypeCheckerBuilder with the source files you want to typecheck,
  • Obtain a TypeChecker from the builder (builder.typechecker),
  • Invoke the typechecker (typeChecker.process()),
  • Process the results available from typeChecker.phasedUnits. Specifically, typeChecker.getPhasedUnits().getPhasedUnits() will give you a List<PhasedUnit>, and for each PhasedUnit, you can call getCompilationUnit() to obtain its Tree.CompilationUnit, which is the root of the AST. AST nodes also include getters for model objects.

For a detailed example, you can review the code for the Dart backend, working forwards and backwards from the call to process() in the compileDart() function.

See testCompile for example code that calls compileDart().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!