# GSiril

## Rule-based touches

### Wrong and Home

Some touches can be described more conveniently using rules than simply as a sequence of calls or methods. An example is the standard 720 of, say, Cambridge Surprise Minor. One way of describing this is simply as a sequence of bobs and plains:

`prove 3( p,p,b,p,b, p,p,b,p,p );`

This, however, is quite some way from the natural description of the touch as Wrong, Home, Wrong, twice repeated. GSiril's rules provide a way of doing this.

```6 bells;

m = &-3-4-2-3-4-5;

p = +2, "  @";
b = +4, "- @";

W = repeat( m, {/*6/:  b, break; p} )
H = repeat( m, {/*6?/: b, break; p} )

finish = repeat(m, p, {/123456/: break})

prove 3(W,H,W)```

### The `repeat` and `break` constructs

This example introduces several new pieces of syntax. The `repeat` and `break` constructs are typically used together and provide a way of repeating a piece of place notation (or any expression) until the `break` keyword is reached (or until the touch becomes false or the proof is otherwise terminated).

### Alternatives blocks

To make this indefinite repetition useful, some sort of conditional syntax is required. This is done with an alternatives block which provides a way of selecting one of several expressions to execute based on the current row. An example of the syntax for an alternatives block is

`{ test1 : expression1 ; test2 : expression2 ; expression }`

The list of alternatives is contained within braces, `{ }`, and separated by semicolons (`;`). Each alternative comprises a test, a colon (`:`), and an expression to execute if the test succeeds. When GSiril executes an alternatives block, it tries each test in order until it finds one the succeeds. It then executes the associated expression, and ignores the remaining alternatives. It is common for the final alternative to omit the test and following colon, in which case if provides a fall-back in case all the tests fail.

A test is simply a pattern against which the current row is matched. It is written between a pair of forward-slashes (`/ /`). In addition to bell symbols which simply match that bell, the pattern may contain some special symbols. A `?` is used to match exactly one unspecified bell; a `*` is used to match any number of bells (including zero bells). Finally, a list of bells can be enclosed in brackets, `[ ]`, to mean one of those bells. So, for example, `/*[456][456]78/` will match any 8-bell CRU.

### Dixon's

A less orthodox application for these rules is for proving compositions of methods such as Dixon's Bob Minor. Dixon's is not a method in the conventional sense; instead, it is described entirely by rules. These are: plain hunt, except when the treble leads when seconds are made, or when the 2 or 4 leads when fourths are made. This can be described concisely using GSiril in the following way.

```// 720 Dixon's Bob Minor.   Comp. A.E.Holroyd.

6 bells;

lead = repeat( +x, { /1*/: break; /[24]*/: +14; +16 } );

p = lead, +12,   "  @";
b = lead, +14,   "- @";
s = lead, +1234, "s @";

prove 4p,s,4p,b,4p,p,4p,b,
4p,b,4p,b,4p,s,4p,b,
4p,b,4p,b,4p,p,4p,b
```

### Magic blocks

Finally, a more complicated example. This a composition of 20 Spliced Treble-Dodging Minor by Philip Saddleton in which there is a change of overwork at each half-lead and a change of underwork at each lead end. The overwork is chosen by looking at which bell is making seconds at the lead end, the underwork by the bell making fifths at the half-lead.

```// 720 Spliced Treble Dodging Minor.   Comp. P.A.B.Saddleton.

6 bells;

printlh = over,under,"\n  @ \", over;
printhl = under, " @ \";

mid1 = +-2-; // p.n. when treble is dodging 3-4 up
mid2 = +-2-; // p.n. when treble is dodging 3-4 down

// Overworks
A = +4.5-3.2,   (over="A\"), printlh, +3-5.4,  mid1;  // George Orwell
B = +4-34-2,    (over="B\"), printlh, +-34-4,  mid1;  // Westminster
C = +4.3-3.2,   (over="C\"), printlh, +3-3.4,  mid1;  // London
D = +4.3-34.2,  (over="D\"), printlh, +34-3.4, mid1;  // Carlisle
E = +4-3-2,     (over="E\"), printlh, +-3-4,   mid1;  // Cambridge

// Underworks
a = +3-34-5,    (under="a\"),printhl, +-34-3,  mid2;  // S2 (aka Rhyl)
b = +3.4-4.5,   (under="b\"),printhl, +4-4.3,  mid2;  // Chelsea
c = +3.2-4.5,   (under="c\"),printhl, +4-2.3,  mid2;  // Kelso
d = +3.4-34.5,  (under="d\"),printhl, +34-4.3, mid2;  // Beverley
e = +3-4-5,     (under="e\"),printhl, +-4-3,   mid2;  // Cambridge

// Opening half-lead -- start midway through a D overwork
firstsection = "  @ D\", +34-3.4

// Which bells pivot for which over/underworks?
above = { /2*/: D; /3*/: C; /4*/: E; /5*/: B; /6*/: A; };
below = { /*2/: e; /*3/: c; /*4/: d; /*5/: b; /*6/: a; };

// Tidy up and exit when rounds occurs
rounds = over,under,"", break;

prove firstsection, mid1, repeat (below, above);

```