Skip to content

Commit 67f5383

Browse files
authored
Skull (#4466)
1 parent 88a1f47 commit 67f5383

File tree

8 files changed

+214
-0
lines changed

8 files changed

+214
-0
lines changed

esolang/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<module>loop</module>
2121
<module>nanofuck</module>
2222
<module>sickbay</module>
23+
<module>skull</module>
2324
<module>snowball</module>
2425
<module>wheel</module>
2526
</modules>

esolang/skull/README.md

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

esolang/skull/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/skull/examples/example1.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
:ASC: // set mode to ASCII (without this code the program would just output every cell as a number)
2+
{0[+72]} // set cell 0 to the ASCII value 72 (H)
3+
{1[+101]} // set cell 1 to the ASCII value 101(e)
4+
{2[+108]} // set cell 2 to the ASCII value 108(l)
5+
{3[+111]} // set cell 3 to the ASCII value 111(o)
6+
{4[+32]} // set cell 4 to the ASCII value 32 (space)
7+
{5[+87]} // set cell 5 to the ASCII value 87 (W)
8+
{6[+114]} // set cell 6 to the ASCII value 114(r)
9+
{7[+100]} // set cell 7 to the ASCII value 100(d)
10+
{8[+33]} // set cell 8 to the ASCII value 33 (!)
11+
{9[+10]} // set cell 9 to the ASCII value 10 (newline)
12+
|0| // H
13+
|1| // e
14+
|2| // l
15+
|2| // l
16+
|3| // o
17+
|4| //
18+
|5| // W
19+
|3| // o
20+
|6| // r
21+
|2| // l
22+
|7| // d
23+
|8| // !
24+
|9| // newline

esolang/skull/examples/example2.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:NUM: // set mode to NUM
2+
{0[+4]} // set cell 0 to 4
3+
{1[+2]} // set cell 1 to 2
4+
{0{ // while cell 0 is not 0
5+
{0[-1]} // subtract cell 0 by 1
6+
{1[+1]} // add 1 to cell 1
7+
}} // end while
8+
|1| // print cell 1 (6)

esolang/skull/examples/example3.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
:NUM: // set mode to NUM
2+
{0[+7]} // set cell 0 to 7
3+
{1[+3]} // set cell 1 to 3
4+
5+
{2[+43]} // set cell 2 to 43
6+
{3[+61]} // set cell 3 to 61
7+
|0| // print cell 0
8+
:ASC:
9+
|2| // print cell 2 (+)
10+
:NUM:
11+
|1| // print cell 1
12+
{0{ // while cell 0 is not 0
13+
{0[-1]} // subtract cell 0 by 1
14+
{1[+1]} // add 1 to cell 1
15+
}} // end while
16+
:ASC:
17+
|3| // print cell 3 (=)
18+
:NUM:
19+
|1| // print cell 1 (10)
20+

esolang/skull/pom.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>skull</artifactId>
5+
<packaging>jar</packaging>
6+
<name>khubla.com Skull grammar</name>
7+
<parent>
8+
<groupId>org.antlr.grammars</groupId>
9+
<artifactId>esolangparent</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
</parent>
12+
<build>
13+
<plugins>
14+
<plugin>
15+
<groupId>org.antlr</groupId>
16+
<artifactId>antlr4-maven-plugin</artifactId>
17+
<version>${antlr.version}</version>
18+
<configuration>
19+
<sourceDirectory>${basedir}</sourceDirectory>
20+
<includes>
21+
<include>skull.g4</include>
22+
</includes>
23+
<visitor>true</visitor>
24+
<listener>true</listener>
25+
</configuration>
26+
<executions>
27+
<execution>
28+
<goals>
29+
<goal>antlr4</goal>
30+
</goals>
31+
</execution>
32+
</executions>
33+
</plugin>
34+
<plugin>
35+
<groupId>com.khubla.antlr</groupId>
36+
<artifactId>antlr4test-maven-plugin</artifactId>
37+
<version>${antlr4test-maven-plugin.version}</version>
38+
<configuration>
39+
<verbose>false</verbose>
40+
<showTree>false</showTree>
41+
<entryPoint>skull</entryPoint>
42+
<grammarName>skull</grammarName>
43+
<packageName></packageName>
44+
<exampleFiles>examples/</exampleFiles>
45+
</configuration>
46+
<executions>
47+
<execution>
48+
<goals>
49+
<goal>test</goal>
50+
</goals>
51+
</execution>
52+
</executions>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
</project>

esolang/skull/skull.g4

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

0 commit comments

Comments
 (0)