Next: Order of components in rules, Previous: How Lexical Tokens Match, Up: Bovine Grammar Rules [Contents]

### 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.