33## Syntax
44
55In the following, a word in ALLCAPS refers to a non-terminal in
6- MicroCode's grammar. Words in lowercase are terminal symbols and
7- may have dashes and other symbols in them. <float > is a floating
8- point number; <pos > is an integer greater than zero. Comments follow //.
6+ MicroCode's grammar. All other words are terminal symbols and
7+ may have dashes and other symbols in them, with the following
8+ exceptions: <float > is a floating point number; <pos > is an
9+ integer greater than zero; // designates a comment.
910
1011A program (PROG) consists of 5 pages, number 1-5, each with a possibly empty sequence of
1112rules RULE:
1213
13- PROG := page-1 RULE\ * page-2 RULE\ * page-3 RULE\ * page-4 RULE\ * page-5 RULE\ *
14+ PROG := page-1 RULE* page-2 RULE* page-3 RULE* page-4 RULE* page-5 RULE*
1415
1516Each rule has an option when section WHEN and an optional do section DO.
1617
@@ -36,7 +37,7 @@ Some actions can be repeated.
3637 | variable-Z-set [C] // fire after variable Z has been assigned, subject to optional comparison C
3738
3839 UD := up | down
39- TS := (1/4-second | 1-second | 1-random-second | 5-seconds)\ * // sum the sequence of times
40+ TS := (1/4-second | 1-second | 1-random-second | 5-seconds)* // sum the sequence of times
4041 PK := button-A | button-B | logo | pin-0 | pin-1 | pin-2
4142 MK := shake | tilt-left | tilt-right | ...
4243
@@ -80,19 +81,30 @@ A positive (integer) expression PE is
8081 | <pos> + PE
8182 | <pos> * PE
8283
83- DO :=
84- | show-number [ V]
85- | show-image (image)_ [ repeat [ PE]]
86- | play-sound (sound)_ [ repeat [ PE]]
87- | play-music (notes)\* [ repeat [ PE]]
88- | radio-send [ V]
89- | radio-set-group [ PE]
90- | set-variable-X [ V]
91- | set-variable-Y [ V]
92- | set-variable-Z [ V]
93- | switch-page [ PG]
94-
95- PG := | page-1 | page-2 | page-3 | page-4 | page-5
84+ A DO action
85+
86+ DO :=
87+ | show-number [V]
88+ | show-image (IMAGE)* [repeat [PE]]
89+ | play-sound (SND)* [repeat [PE]]
90+ | play-music (NOTES)* [repeat [PE]]
91+ | radio-send [V]
92+ | radio-set-group [PE]
93+ | set-variable-X [V]
94+ | set-variable-Y [V]
95+ | set-variable-Z [V]
96+ | switch-page [PAGE]
97+
98+ PAGE := | page-1 | page-2 | page-3 | page-4 | page-5
99+ SND := | giggle | happy | hello | mysterious | sad | slide | soaring
100+
101+ An led image is specified inside quotes and consists of 25 digits, either 0 or 1, separated by
102+ a space:
103+
104+ IMAGE := LED-image `(0\s | 1\s)25`
105+
106+
107+ NOTES := (C | D | E | F | G)4
96108
97109## Semantics
98110
0 commit comments