You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/doc-plan.md
+29-23Lines changed: 29 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,19 +12,23 @@ to MicroCode programs,
12
12
## Syntax
13
13
14
14
MicroCode has a concrete syntax, as detailed below, for the
15
-
purpose of creating programs without the need for visual
15
+
purpose of creating programs without the need for the
16
16
MicroCode editor.
17
17
18
18
In the following, a word in ALLCAPS refers to a non-terminal in
19
19
MicroCode's grammar. All other words are terminal symbols, with
20
-
the following exceptions: <float> is a floating point number;
21
-
<pos> is an integer greater than zero; // designates a comment
22
-
(just for use in this markdown - MicroCode does not support comments);
23
-
the symbols \s, \*, (, ), [, ], and | are part of the grammar
24
-
specification. Words are always separated by whitespace.
25
-
26
-
Note that non-terminals correspond to the tooltips used in MicroCode's
27
-
visual editor (where the underscores are replaced by spaces), which
20
+
the following exceptions:
21
+
22
+
- <float> is a floating point number;
23
+
- <pos> is an integer greater than zero;
24
+
- // designates a comment
25
+
(just for use in this markdown - MicroCode does not support comments);
26
+
- the symbols \s, \*, (, ), [, ], and | are part of the grammar
27
+
specification
28
+
29
+
Words are always separated by whitespace. Note that non-terminals
30
+
correspond to the tooltips used in MicroCode's visual editor
31
+
(where the underscores are replaced by spaces), which
28
32
accounts for their long form.
29
33
30
34
A program (PROG) consists of 5 pages, numbered P_1 to P_5, each with a (possibly
@@ -42,8 +46,7 @@ Each rule has an optional section WHEN and an optional section DO.
42
46
43
47
RULE := when [WHEN] do [DO]
44
48
45
-
The WHEN section specifies a signal of interest and, optionally, a filter on that signal.
46
-
The DO section specifies an action and, optionally, parameters to that action.
49
+
The WHEN section specifies a signal of interest and, optionally, a filter on that signal. The DO section specifies an action and, optionally, parameters to that action.
47
50
48
51
WHEN :=
49
52
| start_page [TS] // fires (once) when control transitions to this page, with optional delay
@@ -55,10 +58,10 @@ The DO section specifies an action and, optionally, parameters to that action.
55
58
| temperature [UD | C] // fire on UD event or comparison C of current temperature (in Celsius)
56
59
| light [UD | C] // fire on UD event or comparison C of current light level (0-255)
57
60
| magnet [UD | C] // fire on UD event or comparison C of current magnetic level
58
-
| radio_receive [C] // fire when number arrives via radio, subject to optional comparison C
59
-
| variable_X_set [C] // fire after variable X has been assigned, subject to optional comparison C
60
-
| variable_Y_set [C] // fire after variable Y has been assigned, subject to optional comparison C
61
-
| variable_Z_set [C] // fire after variable Z has been assigned, subject to optional comparison C
61
+
| radio_receive [C] // fire when number arrives via radio, subject to comparison C
62
+
| variable_X_set [C] // fire after variable X has been assigned, subject to comparison C
63
+
| variable_Y_set [C] // fire after variable Y has been assigned, subject to comparison C
64
+
| variable_Z_set [C] // fire after variable Z has been assigned, subject to comparison C
62
65
63
66
UD := up | down
64
67
TS := (1/4_second | 1_second | 1_random_second | 5_seconds)\* // sum the sequence of times
@@ -89,6 +92,8 @@ An expression E is either atomic A, a binary expression, or a randomly chosen va
89
92
| A * E
90
93
| random_number PE
91
94
95
+
Note that the expression language does not admit parentheses and is right-recursive.
96
+
92
97
An atomic value A is either a floating point number, one of the three variables,
93
98
or the current value of one of the four sensors, or the last value received over radio:
94
99
@@ -98,20 +103,20 @@ or the current value of one of the four sensors, or the last value received over
0 commit comments