Skip to content

Commit a56ac88

Browse files
authored
bio (#4467)
1 parent 67f5383 commit a56ac88

File tree

9 files changed

+440
-0
lines changed

9 files changed

+440
-0
lines changed

esolang/bio/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# bio Grammar
2+
3+
An ANTLR4 grammar for [BIO](https://esolangs.org/wiki/BIO) files.

esolang/bio/bio.g4

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
BSD License
3+
Copyright (c) 2025, Tom Everett
4+
All rights reserved.
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions
7+
are met:
8+
1. Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
3. Neither the name of Tom Everett nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
30+
31+
32+
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
33+
34+
grammar bio;
35+
36+
program
37+
: instruction* EOF
38+
;
39+
40+
instruction
41+
: incinstruction
42+
| decinstruction
43+
| whileinstruction
44+
| outputinstruction
45+
;
46+
47+
incinstruction
48+
: '0o' block ';'
49+
;
50+
51+
decinstruction
52+
: '1o' block ';'
53+
;
54+
55+
whileinstruction
56+
: '0i' block '{' instruction* '}' ';'
57+
;
58+
59+
outputinstruction
60+
: '1i' block ';'
61+
;
62+
63+
block
64+
: 'x'
65+
| 'y'
66+
| 'z'
67+
;
68+
69+
COMMENT
70+
: '//' ~ [\r\n]+ -> skip
71+
;
72+
73+
WS
74+
: [ \r\n] -> skip
75+
;
76+

esolang/bio/desc.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../_scripts/desc.xsd">
3+
<targets>CSharp;Cpp;Dart;Go;Java;JavaScript;PHP;Python3;TypeScript;Antlr4ng</targets>
4+
</desc>

esolang/bio/examples/example1.txt

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
0ox; //Increment the block x by 1 9 times
2+
0ox;
3+
0ox;
4+
0ox;
5+
0ox;
6+
0ox;
7+
0ox;
8+
0ox;
9+
0ox;
10+
0ix{ //While block x is not 0
11+
0oy; //Increment the block y by 1 8 times
12+
0oy;
13+
0oy;
14+
0oy;
15+
0oy;
16+
0oy;
17+
0oy;
18+
0oy;
19+
1ox; //Decrement block x by 1
20+
};
21+
1iy; //Output block y (H)
22+
0iy{ //Reset block y to 0
23+
1oy;
24+
};
25+
0ox;
26+
0ox;
27+
0ox;
28+
0ox;
29+
0ox;
30+
0ox;
31+
0ox;
32+
0ox;
33+
0ox;
34+
0ox;
35+
0ix{
36+
0oy;
37+
0oy;
38+
0oy;
39+
0oy;
40+
0oy;
41+
0oy;
42+
0oy;
43+
0oy;
44+
0oy;
45+
0oy;
46+
1ox;
47+
};
48+
0oy;
49+
1iy; //Output block y (e)
50+
0iy{
51+
1oy;
52+
};
53+
0ox;
54+
0ox;
55+
0ox;
56+
0ox;
57+
0ox;
58+
0ox;
59+
0ox;
60+
0ox;
61+
0ox;
62+
0ix{
63+
0oy;
64+
0oy;
65+
0oy;
66+
0oy;
67+
0oy;
68+
0oy;
69+
0oy;
70+
0oy;
71+
0oy;
72+
0oy;
73+
0oy;
74+
0oy;
75+
1ox;
76+
};
77+
1iy; //Output block y (l)
78+
1iy; //Output block y again
79+
0iy{
80+
1oy;
81+
};
82+
0ox;
83+
0ox;
84+
0ox;
85+
0ox;
86+
0ox;
87+
0ox;
88+
0ox;
89+
0ox;
90+
0ox;
91+
0ox;
92+
0ix{
93+
0oy;
94+
0oy;
95+
0oy;
96+
0oy;
97+
0oy;
98+
0oy;
99+
0oy;
100+
0oy;
101+
0oy;
102+
0oy;
103+
0oy;
104+
1ox;
105+
};
106+
0oy;
107+
1iy; //Output block y (o)
108+
0iy{
109+
1oy;
110+
};
111+
0ox;
112+
0ox;
113+
0ox;
114+
0ox;
115+
0ix{
116+
0oy;
117+
0oy;
118+
0oy;
119+
0oy;
120+
0oy;
121+
0oy;
122+
0oy;
123+
0oy;
124+
1ox;
125+
};
126+
1iy; //Output block y (space)
127+
0iy{
128+
1oy;
129+
};
130+
0ox;
131+
0ox;
132+
0ox;
133+
0ox;
134+
0ox;
135+
0ox;
136+
0ox;
137+
0ox;
138+
0ix{
139+
0oy;
140+
0oy;
141+
0oy;
142+
0oy;
143+
0oy;
144+
0oy;
145+
0oy;
146+
0oy;
147+
0oy;
148+
0oy;
149+
0oy;
150+
1ox;
151+
};
152+
1oy;
153+
1iy; //Output block y (W)
154+
0iy{
155+
1oy;
156+
};
157+
0ox;
158+
0ox;
159+
0ox;
160+
0ox;
161+
0ox;
162+
0ox;
163+
0ox;
164+
0ox;
165+
0ox;
166+
0ox;
167+
0ix{
168+
0oy;
169+
0oy;
170+
0oy;
171+
0oy;
172+
0oy;
173+
0oy;
174+
0oy;
175+
0oy;
176+
0oy;
177+
0oy;
178+
0oy;
179+
1ox;
180+
};
181+
0oy;
182+
1iy; //Output block y (o)
183+
0iy{
184+
1oy;
185+
};
186+
0ox;
187+
0ox;
188+
0ox;
189+
0ox;
190+
0ox;
191+
0ox;
192+
0ox;
193+
0ox;
194+
0ix{
195+
0oy;
196+
0oy;
197+
0oy;
198+
0oy;
199+
0oy;
200+
0oy;
201+
0oy;
202+
0oy;
203+
0oy;
204+
0oy;
205+
0oy;
206+
0oy;
207+
0oy;
208+
0oy;
209+
1ox;
210+
};
211+
0oy;
212+
0oy;
213+
1iy; //Output block y (r)
214+
0iy{
215+
1oy;
216+
};
217+
0ox;
218+
0ox;
219+
0ox;
220+
0ox;
221+
0ox;
222+
0ox;
223+
0ox;
224+
0ox;
225+
0ox;
226+
0ix{
227+
0oy;
228+
0oy;
229+
0oy;
230+
0oy;
231+
0oy;
232+
0oy;
233+
0oy;
234+
0oy;
235+
0oy;
236+
0oy;
237+
0oy;
238+
0oy;
239+
1ox;
240+
};
241+
1iy; //Output block y (l)
242+
0iy{
243+
1oy;
244+
};
245+
0ox;
246+
0ox;
247+
0ox;
248+
0ox;
249+
0ox;
250+
0ox;
251+
0ox;
252+
0ox;
253+
0ox;
254+
0ox;
255+
0ix{
256+
0oy;
257+
0oy;
258+
0oy;
259+
0oy;
260+
0oy;
261+
0oy;
262+
0oy;
263+
0oy;
264+
0oy;
265+
0oy;
266+
1ox;
267+
};
268+
1iy; //Output block y (d)
269+
0iy{
270+
1oy;
271+
};
272+
0ox;
273+
0ox;
274+
0ox;
275+
0ox;
276+
0ix{
277+
0oy;
278+
0oy;
279+
0oy;
280+
0oy;
281+
0oy;
282+
0oy;
283+
0oy;
284+
0oy;
285+
1ox;
286+
};
287+
0oy;
288+
1iy; //Output block y (!)
289+
0iy{
290+
1oy;
291+
};

esolang/bio/examples/example2.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0ox; 0oy;
2+
0ix{ 1ox; 0oy; };
3+
1iy;

esolang/bio/examples/example3.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0ox; 0ox; 0oy;
2+
0iy{ 0ox; 1oy; };
3+
1ix;

esolang/bio/examples/example4.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0ox; 0ox; 0ox; 0ox; 0ox;
2+
0ix{ 1ox; 0oy; 0oy; 0oy; 0oy; 0oy; };
3+
1iy;

0 commit comments

Comments
 (0)