Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/2635648.2635653acmotherconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article
Open access

Hygienic Macro System for JavaScript and Its Light-weight Implementation Framework

Published: 14 August 2014 Publication History

Abstract

In spite of its soundness, ease of use, and descriptive power, few hygienic macro systems have been incorporated to non-LISP programming languages. The difficulty lies in the self-describing nature of the macro system. Proposed is the design and a systematic implementation framework of hygienic macro systems for general programming languages. In addition to the standard syntax-rules macro features, our macro system incorporates handling of punctuations and keywords, introduces invisible blocks of code called phantom groups, and proposes the notion of suffix pattern to address problems due to recursive macro definitions. These features have been introduced to deal with richer syntax of general programming languages. The proposed implementation framework incorporates staged parser architecture, a parser generation technique using parsing expression grammars, and mutual conversion technique between the macro-enabled host language and Scheme that allows our macro system to delegate actual macro expansion task to a Scheme interpreter, instead of building hygienic macro expander from scratch. ExJS, our prototype implementation of a hygienic macro system for JavaScript, is implemented in less than 2,000 lines of JavaScript and Scheme, and exhibits its flexible syntactic extensibility.

References

[1]
E. Allen, R. Culpepper, J. D. Nielsen, J. Rafkind, and S. Ryu. Growing a syntax. In Proceedings of Workshop on Foundations of Object-Oriented Languages, 2009.
[2]
H. Arai and K. Wakita. An implementation of a hygienic syntactic macro system for javascript: a preliminary report. In Workshop on Self-Sustaining Systems, S3, pages 30--40. ACM, 2010.
[3]
J. Bachrach and K. Playford. D-Expressions: Lisp power, Dylan style. Nov. 1999.
[4]
A. Bawden and J. Rees. Syntactic closures. In LFP '88: Proceedings of the 1988 ACM conference on LISP and functional programming, pages 86--95, New York, NY, USA, 1988. ACM.
[5]
W. Clinger and J. Rees. Macros that work. In POPL '91: Proceedings of the 18th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 155--162, New York, NY, USA, 1991. ACM.
[6]
W. Clinger and J. Rees. Revised4 report on the algorithmic language Scheme, nov 1991.
[7]
D. Crockford. Beautiful Code: Leading Programmers Explain How They Think, chapter 9: Top down operator precedence, pages 129--145. Theory In Practice. O'Reilly, June 2007.
[8]
R. Culpepper and M. Felleisen. Fortifying macros. In in proceedings of the international conference on Functional programming, Baltimore, USA, Sept. 2010.
[9]
D. de Rauglaudre. Camlp5 -- Reference Manual. Institut National de Recherche en Informatique et Automatique, version 6.00 edition, Oct. 2010.
[10]
R. K. Dybvig, R. Hieb, and C. Bruggeman. Syntactic abstraction in scheme. LISP and Symbolic Computation, 5(4):295--326, 1992.
[11]
ECMA Standardizing Information and Communication Systems. ECMAScript language specification (Standard ECMA-262). ECMA International, final draft standard ECMA-262, 5rd edition edition, Sept. 2009.
[12]
M. Flatt, R. B. Findler, and J. Clements. GUI: Racket graphics toolkit. Technical Report PLT-TR-2010-3, PLT Inc., 2010. http://racket-lang.org/tr3/.
[13]
B. Ford. Packrat parsing: Simple, powerful, lazy, linear time. In Proceedings of the 7th ACM SIGPLAN international conference on functional programming (ICFP '02), pages 36--47, Oct. 2002.
[14]
B. Ford. Parsing expression grammars: A recognition-based syntactic foundation. In Proceedings of the 31st annual ACM SIGPLAN - SIGACT symposium on principles of programming languages, pages 111--122, Jan. 2004.
[15]
B. Kernighan and D. M. Ritchie. The C programming language. Prentice Hall, second edition edition, 1988.
[16]
D. E. Knuth. TEX: The Program, volume Volume B of Computers & Typesetting. Addison-Wesley Professional, Jan. 1986.
[17]
E. Kohlbecker, D. P. Friedman, M. Felleisen, and B. Duba. Hygienic macro expansion. In LFP '86: Proceedings of the 1986 ACM conference on LISP and functional programming, pages 151--161, New York, NY, USA, 1986. ACM.
[18]
B. Leavenworth. Syntax macros and extended translation. Communications of the ACM, 9(11):790--793, 1966.
[19]
K. Mori. An implementation of a hygienic macro system for Scala using a Scheme macro expander (in japanese). Master's thesis, Department of Mathematical and Computing Science, Tokyo Institute of Technology, Feb. 2014.
[20]
V. R. Pratt. Top down operator precedence. In POPL '73: Proceedings of the 1st annual ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 41--51, New York, NY, USA, 1973. ACM.
[21]
J. Rafkind and M. Flatt. Honu: syntactic extension for algebraic notation through enforestation. In Proceedings of the 11th International Conference on Generative Programming and Component Engineering, pages 122--131. ACM, 2012.
[22]
R. Seindal, F. Pinard, G. V. Vaughan, and E. Blake. GNU m4 manual. GNU, 1.4.16 edition, 2011.
[23]
A. Shalit, O. Starbuck, and D. Moon. The Dylan Reference Manual. Addison-Wesley Developers Press, Sept. 1996.
[24]
T. Sheard and S. Jones. Template meta-programming for Haskell. In Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, pages 1--16. ACM, 2002.
[25]
K. Skalski, M. Moskal, and P. Olszta. Meta-programming in Nemerle. In Generative Programming and Component Engineering, 2004.
[26]
G. L. Steele, Jr. Common Lisp: the Language. Digital Press, Newton, MA, USA, second edition, 1990.
[27]
D. Weise and R. Crew. Programmable syntax macros. In PLDI '93: Proceedings of the ACM SIGPLAN 1993 conference on Programming language design and implementation, pages 156--165, New York, NY, USA, 1993. ACM.

Cited By

View all
  • (2023)A pred-LL(*) Parsable Typed Higher-Order Macro System for Architecture Description LanguagesProceedings of the 22nd ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3624007.3624052(29-41)Online publication date: 22-Oct-2023
  • (2020)Hygienic macro technologyProceedings of the ACM on Programming Languages10.1145/33863304:HOPL(1-110)Online publication date: 12-Jun-2020
  • (2019)A Survey of Metaprogramming LanguagesACM Computing Surveys10.1145/335458452:6(1-39)Online publication date: 16-Oct-2019
  • Show More Cited By

Index Terms

  1. Hygienic Macro System for JavaScript and Its Light-weight Implementation Framework

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM Other conferences
    ILC '14: Proceedings of ILC 2014 on 8th International Lisp Conference
    August 2014
    108 pages
    ISBN:9781450329316
    DOI:10.1145/2635648
    • General Chair:
    • Marc Feeley,
    • Program Chair:
    • Didier Verna
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    In-Cooperation

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 14 August 2014

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Hygienic Macro Systems
    2. JavaScript
    3. Parser
    4. Parsing Expression Grammar
    5. Program Transformation
    6. Scheme

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    ILC '14
    ILC '14: 2014 International Lisp Conference
    August 14 - 17, 2014
    QC, Montreal, Canada

    Acceptance Rates

    ILC '14 Paper Acceptance Rate 18 of 26 submissions, 69%;
    Overall Acceptance Rate 18 of 26 submissions, 69%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)76
    • Downloads (Last 6 weeks)13
    Reflects downloads up to 29 Nov 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)A pred-LL(*) Parsable Typed Higher-Order Macro System for Architecture Description LanguagesProceedings of the 22nd ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3624007.3624052(29-41)Online publication date: 22-Oct-2023
    • (2020)Hygienic macro technologyProceedings of the ACM on Programming Languages10.1145/33863304:HOPL(1-110)Online publication date: 12-Jun-2020
    • (2019)A Survey of Metaprogramming LanguagesACM Computing Surveys10.1145/335458452:6(1-39)Online publication date: 16-Oct-2019
    • (2016)MacroficationProceedings of the 25th European Symposium on Programming Languages and Systems - Volume 963210.5555/3089528.3089553(644-671)Online publication date: 2-Apr-2016
    • (2016)Macrofication: Refactoring by Reverse Macro ExpansionProgramming Languages and Systems10.1007/978-3-662-49498-1_25(644-671)Online publication date: 2016

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Login options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media