Next: , Previous: , Up: Bovine parser development   [Contents]

3 Optional Lambda Expressions

The OLE (Optional Lambda Expression) is converted into a bovine lambda. This lambda has special short-cuts to simplify reading the semantic action definition. An OLE like this:

( $1 )

results in a lambda return which consists entirely of the string or object found by matching the first (zeroth) element of match. An OLE like this:

( ,(foo $1) )

executes foo on the first argument, and then splices its return into the return list whereas:

( (foo $1) )

executes foo, and that is placed in the return list.

Here are other things that can appear inline:


The first object matched.


The first object spliced into the list (assuming it is a list from a non-terminal).


The first object matched, placed in a list. I.e., ( $1 ).


The symbol foo (exactly as displayed).


A function call to foo which is stuck into the return list.


A function call to foo which is spliced into the return list.


A function call to foo which is stuck into the return list in a list.

(EXPAND $1 nonterminal depth)

A list starting with EXPAND performs a recursive parse on the token passed to it (represented by ‘$1’ above.) The semantic list is a common token to expand, as there are often interesting things in the list. The nonterminal is a symbol in your table which the bovinator will start with when parsing. nonterminal’s definition is the same as any other nonterminal. depth should be at least ‘1’ when descending into a semantic list.

(EXPANDFULL $1 nonterminal depth)

Is like EXPAND, except that the parser will iterate over nonterminal until there are no more matches. (The same way the parser iterates over the starting rule (see Starting Rules). This lets you have much simpler rules in this specific case, and also lets you have positional information in the returned tokens, and error skipping.

(ASSOC symbol1 value1 symbol2 value2 …)

This is used for creating an association list. Each symbol is included in the list if the associated value is non-nil. While the items are all listed explicitly, the created structure is an association list of the form:

((symbol1 . value1) (symbol2 . value2) …)
(TAG name class [attributes])

This creates one tag in the current buffer.


Is a string that represents the tag in the language.


Is the kind of tag being create, such as function, or variable, though any symbol will work.


Is an optional set of labeled values such as :constant-flag t :parent "parenttype".

(TAG-VARIABLE name type default-value [attributes])
(TAG-FUNCTION name type arg-list [attributes])
(TAG-TYPE name type members parents [attributes])
(TAG-INCLUDE name system-flag [attributes])
(TAG-PACKAGE name detail [attributes])
(TAG-CODE name detail [attributes])

Create a tag with name of respectively the class variable, function, type, include, package, and code. See (semantic-appdev)Semantic Application Development, for the lisp functions these translate into.

If the symbol %quotemode backquote is specified, then use ,@ to splice a list in, and , to evaluate the expression. This lets you send $1 as a symbol into a list instead of having it expanded inline.

Next: Examples, Previous: Bovine Grammar Rules, Up: Bovine parser development   [Contents]