File tree 3 files changed +39
-1
lines changed
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ The BitsySwift repository has some
52
52
53
53
While the hope of this repo is to codify the definition of Bitsy in a series of
54
54
runnable tests, it is also useful to define the language informally using words
55
- and examples.
55
+ and examples. For a formal definition of the Bitsy grammar, see [ GRAMMAR.txt ] ( GRAMMAR.txt )
56
56
57
57
### Program Definition
58
58
Original file line number Diff line number Diff line change
1
+ <program> ::= BEGIN <block> END
2
+
3
+ <block> ::= { <if-statement> | <loop> | <break> | <print> | <read> | <assignment> }
4
+
5
+ <if-statement> ::= <if-keyword> <expression> <block> [ ELSE <block> ] END
6
+
7
+ <if-keyword> ::= IFZ | IFP | IFN
8
+
9
+ <loop> ::= LOOP <block> END
10
+
11
+ <break> ::= BREAK
12
+
13
+ <print> ::= PRINT <expression>
14
+
15
+ <read> ::= READ <var-name>
16
+
17
+ <assignment> ::= <var-nam> "=" <expression>
18
+
19
+ <expression> ::= <term> { <add-op> <term> }
20
+
21
+ <term> ::= <signed-factor> { <mul-op> <factor> }
22
+
23
+ <signed-factor> ::= [ add-op ] <factor>
24
+
25
+ <factor> ::= <integer> | <var-name> | "(" <expression> ")"
26
+
27
+ <var-name> ::= <ident-char> { <ident-char> }
28
+
29
+ <integer> ::= <digit> { <digit> }
30
+
31
+ <add-op> ::= "+" | "-"
32
+
33
+ <mul-op> ::= "*" | "/" | "%"
34
+
35
+ <ident-char> ::= "_" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
36
+
37
+ <digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ language design.
7
7
* Read more about the Bitsy language: [ BITSY.md] ( BITSY.md )
8
8
* See the canonical implementation: [ BitsySwift] ( https://github.com/apbendi/bitsy-swift )
9
9
* Read more about why Bitsy exists: [ Introducing Bitsy] ( http://www.scopelift.co/blog/introducing-bitsy-the-first-language-youll-implement-yourself )
10
+ * See the formal language grammar in [ BNF] ( https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form ) notation: [ GRAMMAR] ( GRAMMAR.txt )
10
11
11
12
# BitsySpec
12
13
You can’t perform that action at this time.
0 commit comments