Misc. grammar controls

The fol­low­ing short exam­ples illus­trate the usage of spe­cif­ic con­trols of the infer­ence mech­a­nism in gram­mars of Bol Processor (BP2 and BP3).

_destru

This instruc­tion is use­ful in pat­tern gram­mars con­tain­ing rep­e­ti­tion and pseudo-repetition mark­ers. For instance, the fol­low­ing gram­mar cre­ates a sequence of two occur­rences of vari­able "X" which may fur­ther be derived as "abc" or "de".

S --> (= X)(: X)
X --> abc
X --> de

In the first rule, (= ) is called a mas­ter paren­the­sis and (: ) a slave paren­the­sis — con­tain­ing a copy of the for­mer. This master-slave depen­den­cy is main­tained through­out sub­se­quent derivations.

The only eli­gi­ble final deriva­tions would be "abcabc" or "dede". However, the final string would be dis­played for instance "(= abc)(: abc)". To obtain a usable string in which 'a', 'b', 'c' may be fur­ther instan­ti­at­ed as sound-objects, it is nec­es­sary to remove struc­tur­al mark­ers. The Bol Processor does it auto­mat­i­cal­ly once the final string has been cre­at­ed, i.e. there are no more can­di­date rules for fur­ther deriva­tions. However, the user may want to dis­play strings with­out their mark­ers. Instruction _destru is used to this effect.

Let us con­sid­er for instance "-gr.tryDESTRU":

-se.tryDESTRU
-al.abc
// This gram­mar pro­duces var­i­ous pat­terns on alpha­bet …

RND
gram#1[1] <2-1> S --> (= (= X) S (:X)) (: (= X) S (:X))
gram#1[2] <2-1> X --> Y
gram#1[3] <2-1> X --> Y S Z
gram#1[4] <2-1> X --> Z

ORD
gram#2[1] LEFT S --> lamb­da [This is an eras­ing rule]

LIN
_destru
gram#3[1] X X --> abca
gram#3[2] Z Y --> abc
gram#3[3] Y Z --> cba
gram#3[4] Y Y --> cbbc
gram#3[5] Z Z --> lamb­da [This is an eras­ing rule]

The first rule in sub­gram­mar #1 cre­ates a self-embedding pat­tern in which the start sym­bol S is cre­at­ed again recur­sive­ly. This recur­siv­i­ty might pro­duce unlim­it­ed strings. To avoid this, each rule in sub­gram­mar #1 is assigned ini­tial weight "2" decreased by "1" once the rule has been fired. Therefore, no rule may be used more than 2 times. Subgrammar #2 con­tains a sin­gle rule delet­ing the left-over "S".

Subgrammar #3 destroys the struc­ture by eras­ing all paren­the­ses and master/slave mark­ers, then it rewrites vari­ables "X", "Y", "Z" as strings of ter­mi­nal sym­bols. Tracing the pro­duc­tion shows for instance that workstring

(=(= Z)(=(= Y)(: Y))(:(= Y)(: Y))(: Z))(:(= Z)(=(= Y)(: Y))(:(= Y)(: Y))(: Z))

is replaced with "Z Y Y Y Y Z Z Y Y Y Y ZZ Y Y Y Y Z Z Y Y Y Y Z".

Rewriting is then done strict­ly from left to right due to the LIN instruction.

The fol­low­ing is a series of 10 items pro­duced by this grammar:

abc­cb­bc­cbaabc­cb­bc­c­ba
cbacbacbacbacbacbacbacbacbacbacbac­ba
abc­cb­bc­cbaabc­cb­bc­c­ba
cbaabc­cbaabc
cbacbacbacbacbacbacbacbacbacbacbac­ba
abcab­cab­cab­cab­cab­cab­cabc
abcab­cab­cab­cab­cab­cab­cabc
cbb­cab­cab­cabc­cb­b­cab­cab­cabc­cb­b­cab­cab­cabc­cb­b­cab­cab­cabc
cbacbacbac­ba
cbbc­cb­bc­cbacb­bc­cb­bc­cbacb­bc­cb­bc­cbacb­bc­cb­bc­c­ba

Complex pat­terns are vis­i­ble on the fol­low­ing sound ren­der­ing of the first item using "-so.abc" sound-object prototypes.

Item "abc­cb­bc­cbaabc­cb­bc­c­ba" cre­at­ed by -gr.tryDESTRU

Leave a Reply

Your email address will not be published. Required fields are marked *