McMicMac allows the user to completely specify the syntax of the underlying language. This is done by providing different vocabularies, which are collections of expanders for the various parts of the language. Other documentation describes the standard Scheme vocabularies that accompany McMicMac.
A vocabulary consists of micros to manage the treatment of the individual syntactic components: symbols, literals, lists and improper-lists. All sub-types of scalar other than symbol, in addition to vector, are considered ``literals''. In addition, micros and macros can be triggered by a leading object of type symbol in a list.
add-sym-micro
vocab ( read env attr vocab
parsed) void
add-list-micro
vocab ( read env attr vocab
parsed) void
add-ilist-micro
vocab ( read env attr vocab
parsed) void
add-lit-micro
vocab ( read env attr vocab
parsed) void
add-sym-micro installs the expander for individual symbols, add-list-micro the expander that handles a list of tokens, add-ilist-micro that for improper lists of tokens, and add-lit-micro the expander for processing literals. In each case, the first argument is the vocabulary in which to make the change, and the second argument is the actual micro.
add-micro-form
scheme-symbol vocab ( read env attr vocab
parsed) void
add-macro-form
scheme-symbol vocab ( read env read) void
add-micro-form is used to add micros to vocabularies, while add-macro-form adds macros. It should be noted that the first argument to add-micro-form and add-macro-form is a Scheme symbol, not an McMicMac symbol.
NOTE: If a list of tokens is headed by a symbol for which a micro or macro has been defined, then the defined micro or macro is invoked; only otherwise is the micro for lists of tokens invoked.
make-vocabulary
vocab
copy-vocabulary
vocab vocab
merge-vocabulary
vocab vocab vocab
make-vocabulary creates a new vocabulary that contains no micros or macros. Any syntactic input parsed with it will result in a syntax error. copy-vocabulary returns a new vocabulary that contains all the micros and macros contained in the given vocabulary. merge-vocabulary merges two vocabularies; the first argument is destructively updated by each of the entries in the second argument.
NOTE: copy-vocabulary literally makes a copy of the given vocabulary. Any changes made after the copy operation will not be seen by the copy. Thus, the copy should be made only when the programmer is certain the vocabulary being copied has all the appropriate contents.