skip to main content
10.1145/155090.155105acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
Article
Free Access

Programmable syntax macros

Published:01 June 1993Publication History

ABSTRACT

Lisp has shown that a programmable syntax macro system acts as an adjunct to the compiler that gives the programmer important and powerful abstraction facilities not provided by the language. Unlike simple token substitution macros, such as are provided by CPP (the C preprocessor), syntax macros operate on Abstract Syntax Trees (ASTs). Programmable syntax macro systems have not yet been developed for syntactically rich languages such as C because rich concrete syntax requires the manual construction of syntactically valid program fragments, which is a tedious, difficult, and error prone process. Also, using two languages, one for writing the program, and one for writing macros, is another source of complexity. This research solves these problems by having the macro language be a minimal extension of the programming language, by introducing explicit code template operators into the macro language, and by using a type system to guarantee, at macro definition time, that all macros and macro functions only produce syntactically valid program fragments. The code template operators make the language context sensitive, which requires changes to the parser. The parser must perform type analysis in order to parse macro definitions, or to parse user code that invokes macros.

References

  1. 1.ANSi Standard on C, X3.159.1989, ANSI, NY, 1990.Google ScholarGoogle Scholar
  2. 2.Cameron, R. D., "Software reuse with metaprogramming systems," Proceedings of the Fifth Annual Pacific Northwest Software Quality Conference, OR, pp. 223- 32, 1987Google ScholarGoogle Scholar
  3. 3.Campbell, W. R., "A compiler definition facility based on the Syntactic Macro," Computer Journal 21(1), pp. 35-41, 1975Google ScholarGoogle ScholarCross RefCross Ref
  4. 4.Cheatham, T. E., "The introduction of definitional facilities into higher level programming languages," pp. 623-637, Proc. AFIPS (Fall Joint Computer Conference, 29), 1966Google ScholarGoogle Scholar
  5. 5.Harbison, S., and Steele, G., C, ARe. ference Manual, Third Edition, Prentice Hall, 1991 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6.Hieb, R., Dybvig, R. K., Bruggeman, C., "Syntactic abstraction in Scheme," University of Indiana Computer Science Technical Report 355, 18 pages, June 1992 (Revised July 1992).Google ScholarGoogle Scholar
  7. 7.Jonker, Todd, Personal Communication, 1992Google ScholarGoogle Scholar
  8. 8.Kohlbecker, Eugene, Friedman, Daniel P., FeHeisen, Matthias, Duba, Bruce, "Hygienic macro expansion," Proceedings of the 1986 ACM Conference on Lisp and Functional Programming, pp. 151-161, ACM Press, NY, 1986 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9.Leavenworth, B. M., "Syntax Macros and Extended Translation," CACM 9(11), pp. 790-793, 1966 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 10.Maddox, William, Semantically-Sensit2ve Macroprocessing Report No. UCB/CSD 89/545, (Master's Thesis), 82 pages, University of California, Berkeley, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11.Samples, Dain, M5, Electronic Announcement oll comp.compilers newsgroup, 1992Google ScholarGoogle Scholar
  12. 12.Steele, G., Common Lisp, The Language, Digital Press, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 13.Strachey, C., "A general purpose macrogenerator," Computer Journal, 8(3), pp. 225-241, 1965Google ScholarGoogle ScholarCross RefCross Ref
  14. 14.Vidart, J., Extensions syntaxiques dans une contexte LL(1), University of Grenoble, Th'ese pour obtenir le grade de Docteur de troisi'eme cycle, 1974Google ScholarGoogle Scholar
  15. 15.Bliss-11 Programmer's Manual, CMU Department of Computer Science, 1974.Google ScholarGoogle Scholar

Index Terms

  1. Programmable syntax macros

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in
          • Published in

            cover image ACM Conferences
            PLDI '93: Proceedings of the ACM SIGPLAN 1993 conference on Programming language design and implementation
            August 1993
            313 pages
            ISBN:0897915984
            DOI:10.1145/155090

            Copyright © 1993 ACM

            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]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 June 1993

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • Article

            Acceptance Rates

            Overall Acceptance Rate406of2,067submissions,20%

            Upcoming Conference

            PLDI '24

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader