bovine: Grammar-to-Lisp Details
2.2 Grammar-to-Lisp Details
===========================
For the bovinator, lexical token matching patterns are _inlined_. When
the grammar-to-lisp converter encounters a lexical token declaration of
the form:
%token <TYPE> TOKEN-NAME MATCH-VALUE
It substitutes every occurrences of TOKEN-NAME in rules, by its
expanded form:
TYPE MATCH-VALUE
For example:
%token <symbol> MOOSE "moose"
find_a_moose: MOOSE
;
Will generate this pseudo equivalent-rule:
find_a_moose: symbol "moose" ;; invalid syntax!
;
Thus, from the bovinator point of view, the COMPONENTS part of a rule
is made up of symbols and strings. A string in the mix means that the
previous symbol must have the additional constraint of exactly matching
it, as described in How Lexical Tokens Match.
*Please Note:*
For the bovinator, this task was mixed into the language definition
to simplify implementation, though Bison’s technique is more
efficient.