Skip to content

Commit cf840be

Browse files
BlueCocoaGolmote
authored andcommitted
Add support for IchigoJam BASIC (#1246)
* Add support for IchigoJam BASIC Hi. This PR adds support for [IchigoJam](https://ichigojam.net/), which is a board that using its own BASIC language, so I was not extending this from `basic`, but submit as a standalone language. If there're anything necessary to change, please reply to me and I'll respond to you ASAP. * Requested modifications have been made. And after digging into the docs, IchigoJam actually use a very small set of ```basic``` and it adds a different set of markers to its own ```basic``` language, so I just keep this as a standalone language. * fixed the regexp for comment, number, operator and punctuation For IchigoJam, the space is not required to be appeared after the ```'``` or ```REM```. Add support for binary and hex numbers Specified for IchigoJam Add ```[``` and ```]``` for IchigoJam * Add example code for IchigoJam. * Add test-suite for IchigoJam * Add prism-ichigojam.min.js
1 parent 2ece18b commit cf840be

11 files changed

+340
-0
lines changed

components.js

+4
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ var components = {
265265
"title": "HTTP",
266266
"owner": "danielgtaylor"
267267
},
268+
"ichigojam": {
269+
"title": "IchigoJam",
270+
"owner": "BlueCocoa"
271+
},
268272
"icon": {
269273
"title": "Icon",
270274
"owner": "Golmote"

components/prism-ichigojam.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// according to the offical reference (EN)
2+
// https://ichigojam.net/IchigoJam-en.html
3+
Prism.languages.ichigojam = {
4+
'string': /"(?:""|[!#$%&'()*,\/:;<=>?^_ +\-.A-Z\d])*"/i,
5+
'comment': /(?:\B'|REM)(?:[^\n\r]*)/i,
6+
'number': /(?:\B#[0-9A-F]+)|(?:\B`[01]+)|(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?/i,
7+
'keyword': /\b(?:BEEP|BPS|CASE|CLEAR|CLK|CLO|CLP|CLS|CLT|CLV|CONT|COPY|ELSE|END|FILE|FILES|FOR|GOSUB|GSB|GOTO|IF|INPUT|KBD|LED|LET|LIST|LOAD|LOCATE|LRUN|NEW|NEXT|OUT|RIGHT|PLAY|POKE|PRINT|PWM|REM|RENUM|RESET|RETURN|RTN|RUN|SAVE|SCROLL|SLEEP|SRND|STEP|STOP|SUB|TEMPO|THEN|TO|UART|VIDEO|WAIT)(?:\$|\b)/i,
8+
'function': /\b(?:ABS|ANA|ASC|BIN|BTN|DEC|END|FREE|HELP|HEX|I2CR|I2CW|IN|INKEY|LEN|LINE|PEEK|RND|SCR|SOUND|STR|TICK|USR|VER|VPEEK|ZER)(?:\$|\b)/i,
9+
'label': /(?:\B@[^\s]+)/i,
10+
'operator': /<[=>]?|>=?|\|\||&&|[+\-*\/=\|&^~!]|\b(?:AND|NOT|OR)\b/i,
11+
'punctuation': /[\[,;:()\]]/
12+
};

components/prism-ichigojam.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-ichigojam.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<h1>IchigoJam</h1>
2+
<p>To use this language, use the class "language-ichigojam".</p>
3+
4+
<p>Note: this component focuses on IchigoJam, which uses a small subset of basic and introduces its own markers.</p>
5+
6+
<h2>Comments</h2>
7+
<pre><code>' This is a comment
8+
REM This is a remark
9+
'NoSpaceIsOK
10+
REMNOSPACE</code></pre>
11+
12+
<h2>Strings</h2>
13+
<pre><code>"This a string."
14+
"This is a string with ""quotes"" in it."</code></pre>
15+
16+
<h2>Numbers</h2>
17+
<pre><code>42
18+
3.14159
19+
-42
20+
-3.14159
21+
.5
22+
10.
23+
2E10
24+
4.2E-14
25+
-3E+2
26+
#496F726953756B69
27+
`11100010</code></pre>
28+
29+
<h2>IchigoJam Basic example</h2>
30+
<pre><code>A=0
31+
FOR I=1 TO 100 : A=A+I : NEXT
32+
PRINT A</code></pre>
33+
34+
<h2>Known failures</h2>
35+
<p>There are certain edge cases where Prism will fail.
36+
There are always such cases in every regex-based syntax highlighter.
37+
However, Prism dares to be open and honest about them.
38+
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
39+
</p>
40+
41+
<h3>Two double quotes inside a comment</h3>
42+
<pre><code>! This "comment" is broken
43+
REM This "remark" is broken</code></pre>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'Foobar
2+
' Foobar
3+
REMFoobar
4+
REM Foobar
5+
6+
----------------------------------------------------
7+
8+
[
9+
["comment", "'Foobar"],
10+
["comment", "' Foobar"],
11+
["comment", "REMFoobar"],
12+
["comment", "REM Foobar"]
13+
]
14+
15+
----------------------------------------------------
16+
17+
Checks for comments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
ABS
2+
ANA
3+
ASC
4+
BIN
5+
BTN
6+
DEC
7+
FREE
8+
HELP
9+
HEX
10+
I2CR
11+
I2CW
12+
IN
13+
INKEY
14+
LEN
15+
LINE
16+
PEEK
17+
RND
18+
SCR
19+
SOUND
20+
STR
21+
TICK
22+
USR
23+
VER
24+
VPEEK
25+
ZER
26+
27+
----------------------------------------------------
28+
29+
[
30+
["function", "ABS"],
31+
["function", "ANA"],
32+
["function", "ASC"],
33+
["function", "BIN"],
34+
["function", "BTN"],
35+
["function", "DEC"],
36+
["function", "FREE"],
37+
["function", "HELP"],
38+
["function", "HEX"],
39+
["function", "I2CR"],
40+
["function", "I2CW"],
41+
["function", "IN"],
42+
["function", "INKEY"],
43+
["function", "LEN"],
44+
["function", "LINE"],
45+
["function", "PEEK"],
46+
["function", "RND"],
47+
["function", "SCR"],
48+
["function", "SOUND"],
49+
["function", "STR"],
50+
["function", "TICK"],
51+
["function", "USR"],
52+
["function", "VER"],
53+
["function", "VPEEK"],
54+
["function", "ZER"]
55+
]
56+
57+
----------------------------------------------------
58+
59+
Checks for functions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
BEEP
2+
BPS
3+
CASE
4+
CLEAR
5+
CLK
6+
CLO
7+
CLP
8+
CLS
9+
CLT
10+
CLV
11+
CONT
12+
COPY
13+
ELSE
14+
END
15+
FILE
16+
FILES
17+
FOR
18+
GOSUB
19+
GSB
20+
GOTO
21+
IF
22+
INPUT
23+
KBD
24+
LED
25+
LET
26+
LIST
27+
LOAD
28+
LOCATE
29+
LRUN
30+
NEW
31+
NEXT
32+
OUT
33+
RIGHT
34+
PLAY
35+
POKE
36+
PRINT
37+
PWM
38+
RENUM
39+
RESET
40+
RETURN
41+
RTN
42+
RUN
43+
SAVE
44+
SCROLL
45+
SLEEP
46+
SRND
47+
STEP
48+
STOP
49+
SUB
50+
TEMPO
51+
THEN
52+
TO
53+
UART
54+
VIDEO
55+
WAIT
56+
57+
----------------------------------------------------
58+
59+
[
60+
["keyword", "BEEP"],
61+
["keyword", "BPS"],
62+
["keyword", "CASE"],
63+
["keyword", "CLEAR"],
64+
["keyword", "CLK"],
65+
["keyword", "CLO"],
66+
["keyword", "CLP"],
67+
["keyword", "CLS"],
68+
["keyword", "CLT"],
69+
["keyword", "CLV"],
70+
["keyword", "CONT"],
71+
["keyword", "COPY"],
72+
["keyword", "ELSE"],
73+
["keyword", "END"],
74+
["keyword", "FILE"],
75+
["keyword", "FILES"],
76+
["keyword", "FOR"],
77+
["keyword", "GOSUB"],
78+
["keyword", "GSB"],
79+
["keyword", "GOTO"],
80+
["keyword", "IF"],
81+
["keyword", "INPUT"],
82+
["keyword", "KBD"],
83+
["keyword", "LED"],
84+
["keyword", "LET"],
85+
["keyword", "LIST"],
86+
["keyword", "LOAD"],
87+
["keyword", "LOCATE"],
88+
["keyword", "LRUN"],
89+
["keyword", "NEW"],
90+
["keyword", "NEXT"],
91+
["keyword", "OUT"],
92+
["keyword", "RIGHT"],
93+
["keyword", "PLAY"],
94+
["keyword", "POKE"],
95+
["keyword", "PRINT"],
96+
["keyword", "PWM"],
97+
["keyword", "RENUM"],
98+
["keyword", "RESET"],
99+
["keyword", "RETURN"],
100+
["keyword", "RTN"],
101+
["keyword", "RUN"],
102+
["keyword", "SAVE"],
103+
["keyword", "SCROLL"],
104+
["keyword", "SLEEP"],
105+
["keyword", "SRND"],
106+
["keyword", "STEP"],
107+
["keyword", "STOP"],
108+
["keyword", "SUB"],
109+
["keyword", "TEMPO"],
110+
["keyword", "THEN"],
111+
["keyword", "TO"],
112+
["keyword", "UART"],
113+
["keyword", "VIDEO"],
114+
["keyword", "WAIT"]
115+
]
116+
117+
----------------------------------------------------
118+
119+
Checks for keywords.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@PAPERNEKO
2+
@SUKI
3+
4+
----------------------------------------------------
5+
6+
[
7+
["label", "@PAPERNEKO"],
8+
["label", "@SUKI"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for labels.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
42
2+
3.14159
3+
2e8
4+
3.4E-9
5+
0.7E+12
6+
#496F726953756B69
7+
`11100010
8+
9+
----------------------------------------------------
10+
11+
[
12+
["number", "42"],
13+
["number", "3.14159"],
14+
["number", "2e8"],
15+
["number", "3.4E-9"],
16+
["number", "0.7E+12"],
17+
["number", "#496F726953756B69"],
18+
["number", "`11100010"]
19+
]
20+
21+
----------------------------------------------------
22+
23+
Checks for numbers.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<
2+
<=
3+
<>
4+
>
5+
>=
6+
+
7+
-
8+
*
9+
/
10+
^
11+
=
12+
&
13+
~
14+
!
15+
|
16+
AND
17+
NOT
18+
OR
19+
||
20+
&&
21+
22+
----------------------------------------------------
23+
24+
[
25+
["operator", "<"], ["operator", "<="], ["operator", "<>"],
26+
["operator", ">"], ["operator", ">="],
27+
["operator", "+"], ["operator", "-"], ["operator", "*"], ["operator", "/"],
28+
["operator", "^"], ["operator", "="],
29+
["operator", "&"], ["operator", "~"], ["operator", "!"], ["operator", "|"],
30+
["operator", "AND"], ["operator", "NOT"], ["operator", "OR"],
31+
["operator", "||"], ["operator", "&&"]
32+
]
33+
34+
----------------------------------------------------
35+
36+
Checks for operators.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
""
2+
"fo""obar"
3+
4+
----------------------------------------------------
5+
6+
[
7+
["string", "\"\""],
8+
["string", "\"fo\"\"obar\""]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for strings.

0 commit comments

Comments
 (0)