Examples
Let, where
- is our set of nonterminals,
- is our ranked alphabet, arities indicated by dummy arguments (i.e. the symbol has arity 2),
- is our starting nonterminal, and
- the set consists of the following productions:
An example derivation is:
.
The tree language generated by is the set of all finite lists of boolean values, that is, happens to equal . The grammar corresponds to the algebraic data type declarations
datatype Bool = false | true datatype BList = nil | cons of Bool * BListin the Standard ML programming language: every member of corresponds to a Standard-ML value of type BList.
For another example, let, using the nonterminal set and the alphabet from above, but extending the production set by, consisting of the following productions:
The language is the set of all finite lists of boolean values that contain at least once. The set has no datatype counterpart in Standard ML, nor in any other functional language. It is a proper subset of .
Read more about this topic: Regular Tree Grammar
Famous quotes containing the word examples:
“In the examples that I here bring in of what I have [read], heard, done or said, I have refrained from daring to alter even the smallest and most indifferent circumstances. My conscience falsifies not an iota; for my knowledge I cannot answer.”
—Michel de Montaigne (15331592)
“Histories are more full of examples of the fidelity of dogs than of friends.”
—Alexander Pope (16881744)
“There are many examples of women that have excelled in learning, and even in war, but this is no reason we should bring em all up to Latin and Greek or else military discipline, instead of needle-work and housewifry.”
—Bernard Mandeville (16701733)