Previous: start Decl, Up: Declarations


2.3.12 use-macros Decl

— %-Decl: %use-macros library {macro-name1 ...}

Declare grammar macros local in this grammar.

library
Is a symbol identifying the Elisp library where to find the macro expanders.
macro-name
Is a symbol identifying a macro. By convention it should be all upper case.

For more information on macros, Grammar Macros.

When the Lisp code generator encounters a %use-macros declaration, it automatically loads (require) the specified library and associates to each macro-name an expander function named library-macro-name.

For instance:

     %use-macros my-grammar-macros {MY-MACRO}

Tells the Lisp code generator to first ‘(require 'my-grammar-macros), then to call the function my-grammar-macros-MY-MACRO to expand calls to the MY-MACRO macro.

Typically, the my-grammar-macros.el library should look like this:

     ...
     
     (defun my-grammar-macros-MY-MACRO (&rest args)
       "Grammar macro that passes ARGS to `format' and return a string."
       `(format ,@args))
     
     ...
     
     ;; Don't forget to provide myself!
     (provide 'my-grammar-macros)