[previous] [up] [next]     [contents] [index]
Next: Reporting Errors Up: Parser Previous: Attribute

Vocabulary

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''[footnote]. In addition, micros and macros can be triggered by a leading object of type symbol in a list.

tex2html_wrap_inline1697 add-sym-micro
vocab tex2html_wrap_inline1701 ( read env attr vocab parsed) tex2html_wrap_inline1699 void
tex2html_wrap_inline1697 add-list-micro
vocab tex2html_wrap_inline1701 ( read env attr vocab parsed) tex2html_wrap_inline1699 void
tex2html_wrap_inline1697 add-ilist-micro
vocab tex2html_wrap_inline1701 ( read env attr vocab parsed) tex2html_wrap_inline1699 void
tex2html_wrap_inline1697 add-lit-micro
vocab tex2html_wrap_inline1701 ( read env attr vocab parsed) tex2html_wrap_inline1699 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.

tex2html_wrap_inline1697 add-micro-form
scheme-symbol tex2html_wrap_inline1701 vocab tex2html_wrap_inline1701 ( read env attr vocab parsed) tex2html_wrap_inline1699 void
tex2html_wrap_inline1697 add-macro-form
scheme-symbol tex2html_wrap_inline1701 vocab tex2html_wrap_inline1701 ( read env read) tex2html_wrap_inline1699 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.

tex2html_wrap_inline1697 make-vocabulary
tex2html_wrap_inline1699 vocab
tex2html_wrap_inline1697 copy-vocabulary
vocab tex2html_wrap_inline1699 vocab
tex2html_wrap_inline1697 merge-vocabulary
vocab tex2html_wrap_inline1701 vocab tex2html_wrap_inline1699 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.


[previous] [up] [next]     [contents] [index]
Next: Reporting Errors Up: Parser Previous: Attribute

PLT