An implementation of a hygienic syntactic macro system for JavaScript: a preliminary report

  • Authors:
  • Hiroshi Arai;Ken Wakita

  • Affiliations:
  • Tokyo Institute of Technology;Tokyo Institute of Technology

  • Venue:
  • Workshop on Self-Sustaining Systems
  • Year:
  • 2010

Quantified Score

Hi-index 0.00

Visualization

Abstract

The article describes an implementation scheme of a hygienic syntactic macro system for JavaScript. Instead of implementing the complex logic of a hygienic macro system from scratch, the proposed method heavily relies on an existing Scheme implementation of its hygienic syntactic macro system. A program written in our macro-enhanced version of JavaScript is first translated into a Scheme program. It is then macro-expanded by a macro expander of Scheme into a macro-free Scheme code. Finally, it is translated back to Javascript, which at this point is free of macros. To deal with the macro-enhanced syntax, an extensible parser architecture based on top-down operator precedence is proposed. A prototype hygienic macro system, including both the parser and the two-way translator, is implemented by only 2,000 lines of Scheme code.