Skip to content

Compiler Steps

Nathaniel Sabanski edited this page Jan 20, 2016 · 33 revisions

Added by dholton dholton

Pipelines consist of a set of steps that the compiler passes the code through. The source code for all the steps is here.

The order of steps when you compile a script is like this:

  1. First the Boo Parser (and lexer): Boo.Lang.Parser.BooParsingStep.
    • The rules the Boo parser uses are defined in this ANTLR grammar file ** <<<--- CAN'T FIND IT**
    • The boo lexer turns the text script into a set of tokens, and the boo parser converts the tokens into an abstract syntax tree (AST). I'll show examples of this later on. Each step after the parser is basically just working on this AST and transforming it. At the end, the AST is used to produce raw .NET assembly code (IL). The steps that happen after the parser step:
  2. InitializeTypeSystemServices
  3. PreErrorChecking
  4. InitializeNameResolutionService
  5. IntroduceGlobalNamespaces
  6. TransformCallableDefinitions
  7. BindTypeDefinitions
  8. BindNamespaces
  9. BindBaseTypes
  10. BindAndApplyAttributes
  11. ExpandMacros
  12. IntroduceModuleClasses
  13. NormalizeStatementModifiers
  14. NormalizeTypeAndMemberDefinitions
  15. BindTypeDefinitions
  16. BindBaseTypes
  17. ResolveTypeReferences
  18. BindTypeMembers
  19. ProcessInheritedAbstractMembers
  20. ProcessMethodBodiesWithDuckTyping
  21. ProcessAssignmentsToValueTypeMembers
  22. ExpandProperties
  23. StricterErrorChecking
  24. RemoveDeadCode
  25. NormalizeIterationStatements
  26. ProcessSharedLocals
  27. ProcessClosures
  28. ProcessGenerators
  29. InjectCallableConversions
  30. ImplementICallableOnCallableDefinitions
  31. EmitAssembly
  32. and finally SaveAssembly or RunAssembly

For a script that shows what your source code and other info looks like after every step, see http://groups.google.com/group/boolang/browse_frm/thread/4a836759385d9b24/88b28eb44bcadf35?hl=en#88b28eb44bcadf35

I have another version too that shows which nodes are synthetic (generated by the compiler), but it doesn't look like the patch required for this will be committed.

Clone this wiki locally