Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Redesigning the CoffeeScript Compiler

Redesigning the CoffeeScript Compiler

Michael Ficarra

August 28, 2012
Tweet

More Decks by Michael Ficarra

Other Decks in Programming

Transcript

  1. “Tell the audience what you're going to say, say it;

    then tell them what you've said.” -- Dale Carnegie Here's what you're going to learn: • Tools that are a composition of independent operations should make accessible useful, standardised intermediate representations • Declarative optimisation and compilation rules can be startlingly powerful, terse, and (logically) pure • My project is on track to finish in September
  2. • Preprocessor ◦ creates context-free CoffeeScript for the parser ◦

    enforces a consistent indentation style ◦ ensures pairing characters are matched • Parser ◦ preserves raw parse value for all parses ◦ preserves line/column source information for all parses ◦ parses all forms of all constructs supported by the compiler • Optimiser ◦ tree-walking optimisation infrastructure in place ◦ plenty of optimisation rules; room for more • Compiler ◦ tree-walking compilation infrastructure ◦ compilation rules for all but 5 features Project Status: Completed
  3. • Extensibility of compilation/optimisation rules • Better CLI ◦ more

    "standard" option parsing ◦ defaults to stdio ◦ options for output of each IR ◦ built-in minification/beautification with graceful degredation • Fixes most of the 78(!) verified, open bugs ◦ nearly all parsing bugs ◦ code generation bugs (particularly regarding precedence) • Nice build system (thanks, Myles) • Test suite infrastructure • Code coverage infrastructure Project Status: Completed
  4. • General tidying up, marked throughout the code-base • Errors

    generated by the preprocessor need improvement ◦ doesn't yet track/report offending line/column numbers ◦ doesn't include surrounding context in errors ◦ doesn't remember opening char position when EOF reached • Complete test suite ◦ already ported over ~50% of jashkenas/coffee-script ◦ porting process is a little slow, lower priority for now Project Status: Needs Some Work
  5. • Source mappings ◦ Source information is already captured ◦

    Needs to propagate through optimiser/compiler rules ◦ Starting on this today ◦ Hope to add this logic in a generalised (DRY) way • Port REPL from jashkenas/coffee-script • Self-host ◦ Most of the project's source files already supported ◦ Failings due mostly to too-clever implicit object usage • Allow escodegen to format according to a user-provided spec Project Status: Not Yet Started