Skip to content

Commit 7fa62cb

Browse files
authored
Introduce ABNF grammar for use with abnfgen (#60)
* Introduce ABNF grammar for use with abnfgen * Update Changelog [ci skip]
1 parent 821f329 commit 7fa62cb

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Introduced a stream-based abstraction layer for filesystem operations
1111
- Enabled CI jobs for additional architectures (arm64, ppc64le, s390x)
1212
- Defined the overshifting behavior for the `@` operator
13+
- Defined the tenyr assembly grammar in ABNF (#60)
1314

1415
### Changed
1516
- Updated supported emscripten version to 1.38.46

grammar.abnf

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
program = 1*(insn (";" / %x0a))
2+
3+
insn = register "<-" rhs
4+
insn =/ register "<-" "[" rhs "]"
5+
insn =/ register "->" "[" rhs "]"
6+
insn =/ "[" register "]" "<-" rhs
7+
insn =/ ".word 0x" 1*8(hexdigit)
8+
insn =/ ".zero " 1*2(decdigit-nonzero)
9+
insn =/ ".chars " %x22 1*(%d32 / %d33 / %d35-91 / escape / %d93-126) %x22
10+
11+
escape = "\" ('0' / '\' / 'b' / 'n' / 'n' / 'r' / 't' / 'v')
12+
13+
rhs = register [op register ["+" imm12]]
14+
rhs =/ register [op imm12 ["+" register]]
15+
rhs =/ imm12 [op register ["+" register]]
16+
rhs =/ [register "+"] imm20
17+
register = %d65-80
18+
op = "|" / "|~" / "&" / "&~" / "^" / "^^" / ">>" / ">>>" / "+" / "-" / "*" / "<<" / "==" / "@" / "<" / ">=" / "<=" / ">"
19+
decdigit = %d48-57
20+
decdigit-nonzero = %d49-57
21+
hexdigit = decdigit / %d65-70
22+
23+
nyb-lo = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"
24+
nyb-hi = "8" / "9" / "a" / "b" / "c" / "d" / "e" / "f"
25+
26+
imm12 = ["-"]decdigit-nonzero 0*2(decdigit)
27+
imm12 =/ ["-"]"1" 3(decdigit)
28+
imm12 =/ ["-"]"20" %d48-51 decdigit
29+
imm12 =/ ["-"]"204" nyb-lo
30+
imm12 =/ "-2048"
31+
32+
imm12 =/ ["-"]"0x" 1*2(hexdigit)
33+
imm12 =/ "0x" nyb-lo 2(hexdigit)
34+
imm12 =/ "0xfffff" nyb-hi 2(hexdigit)
35+
36+
imm20 = ["-"]decdigit-nonzero 0*4(decdigit)
37+
imm20 =/ ["-"]"4" 1*5(decdigit)
38+
imm20 =/ ["-"]"5" ("0" / "1") 4(decdigit)
39+
imm20 =/ ["-"]"52" ("0" / "1" / "2" / "3") 3(decdigit)
40+
imm20 =/ ["-"]"524" ("0" / "1") 2(decdigit)
41+
imm20 =/ ["-"]"5242" ("0" / "1" / "2" / "3" / "4" / "5" / "6" / "7") decdigit
42+
imm20 =/ ["-"]"52428" ("0" / "1" / "2" / "3" / "4" / "5" / "6" / "7")
43+
imm20 =/ "-524288"
44+
45+
imm20 =/ ["-"]"0x" 1*4(hexdigit)
46+
imm20 =/ "0x" nyb-lo 4(hexdigit)
47+
imm20 =/ "0xfff" nyb-hi 4(hexdigit)

0 commit comments

Comments
 (0)