-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
11 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// according to the offical reference (EN) | ||
// https://ichigojam.net/IchigoJam-en.html | ||
Prism.languages.ichigojam = { | ||
'string': /"(?:""|[!#$%&'()*,\/:;<=>?^_ +\-.A-Z\d])*"/i, | ||
'comment': /(?:\B'|REM)(?:[^\n\r]*)/i, | ||
'number': /(?:\B#[0-9A-F]+)|(?:\B`[01]+)|(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?/i, | ||
'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, | ||
'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, | ||
'label': /(?:\B@[^\s]+)/i, | ||
'operator': /<[=>]?|>=?|\|\||&&|[+\-*\/=\|&^~!]|\b(?:AND|NOT|OR)\b/i, | ||
'punctuation': /[\[,;:()\]]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<h1>IchigoJam</h1> | ||
<p>To use this language, use the class "language-ichigojam".</p> | ||
|
||
<p>Note: this component focuses on IchigoJam, which uses a small subset of basic and introduces its own markers.</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>' This is a comment | ||
REM This is a remark | ||
'NoSpaceIsOK | ||
REMNOSPACE</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"This a string." | ||
"This is a string with ""quotes"" in it."</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>42 | ||
3.14159 | ||
-42 | ||
-3.14159 | ||
.5 | ||
10. | ||
2E10 | ||
4.2E-14 | ||
-3E+2 | ||
#496F726953756B69 | ||
`11100010</code></pre> | ||
|
||
<h2>IchigoJam Basic example</h2> | ||
<pre><code>A=0 | ||
FOR I=1 TO 100 : A=A+I : NEXT | ||
PRINT A</code></pre> | ||
|
||
<h2>Known failures</h2> | ||
<p>There are certain edge cases where Prism will fail. | ||
There are always such cases in every regex-based syntax highlighter. | ||
However, Prism dares to be open and honest about them. | ||
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. | ||
</p> | ||
|
||
<h3>Two double quotes inside a comment</h3> | ||
<pre><code>! This "comment" is broken | ||
REM This "remark" is broken</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'Foobar | ||
' Foobar | ||
REMFoobar | ||
REM Foobar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "'Foobar"], | ||
["comment", "' Foobar"], | ||
["comment", "REMFoobar"], | ||
["comment", "REM Foobar"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
ABS | ||
ANA | ||
ASC | ||
BIN | ||
BTN | ||
DEC | ||
FREE | ||
HELP | ||
HEX | ||
I2CR | ||
I2CW | ||
IN | ||
INKEY | ||
LEN | ||
LINE | ||
PEEK | ||
RND | ||
SCR | ||
SOUND | ||
STR | ||
TICK | ||
USR | ||
VER | ||
VPEEK | ||
ZER | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "ABS"], | ||
["function", "ANA"], | ||
["function", "ASC"], | ||
["function", "BIN"], | ||
["function", "BTN"], | ||
["function", "DEC"], | ||
["function", "FREE"], | ||
["function", "HELP"], | ||
["function", "HEX"], | ||
["function", "I2CR"], | ||
["function", "I2CW"], | ||
["function", "IN"], | ||
["function", "INKEY"], | ||
["function", "LEN"], | ||
["function", "LINE"], | ||
["function", "PEEK"], | ||
["function", "RND"], | ||
["function", "SCR"], | ||
["function", "SOUND"], | ||
["function", "STR"], | ||
["function", "TICK"], | ||
["function", "USR"], | ||
["function", "VER"], | ||
["function", "VPEEK"], | ||
["function", "ZER"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
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 | ||
PWM | ||
RENUM | ||
RESET | ||
RETURN | ||
RTN | ||
RUN | ||
SAVE | ||
SCROLL | ||
SLEEP | ||
SRND | ||
STEP | ||
STOP | ||
SUB | ||
TEMPO | ||
THEN | ||
TO | ||
UART | ||
VIDEO | ||
WAIT | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "BEEP"], | ||
["keyword", "BPS"], | ||
["keyword", "CASE"], | ||
["keyword", "CLEAR"], | ||
["keyword", "CLK"], | ||
["keyword", "CLO"], | ||
["keyword", "CLP"], | ||
["keyword", "CLS"], | ||
["keyword", "CLT"], | ||
["keyword", "CLV"], | ||
["keyword", "CONT"], | ||
["keyword", "COPY"], | ||
["keyword", "ELSE"], | ||
["keyword", "END"], | ||
["keyword", "FILE"], | ||
["keyword", "FILES"], | ||
["keyword", "FOR"], | ||
["keyword", "GOSUB"], | ||
["keyword", "GSB"], | ||
["keyword", "GOTO"], | ||
["keyword", "IF"], | ||
["keyword", "INPUT"], | ||
["keyword", "KBD"], | ||
["keyword", "LED"], | ||
["keyword", "LET"], | ||
["keyword", "LIST"], | ||
["keyword", "LOAD"], | ||
["keyword", "LOCATE"], | ||
["keyword", "LRUN"], | ||
["keyword", "NEW"], | ||
["keyword", "NEXT"], | ||
["keyword", "OUT"], | ||
["keyword", "RIGHT"], | ||
["keyword", "PLAY"], | ||
["keyword", "POKE"], | ||
["keyword", "PRINT"], | ||
["keyword", "PWM"], | ||
["keyword", "RENUM"], | ||
["keyword", "RESET"], | ||
["keyword", "RETURN"], | ||
["keyword", "RTN"], | ||
["keyword", "RUN"], | ||
["keyword", "SAVE"], | ||
["keyword", "SCROLL"], | ||
["keyword", "SLEEP"], | ||
["keyword", "SRND"], | ||
["keyword", "STEP"], | ||
["keyword", "STOP"], | ||
["keyword", "SUB"], | ||
["keyword", "TEMPO"], | ||
["keyword", "THEN"], | ||
["keyword", "TO"], | ||
["keyword", "UART"], | ||
["keyword", "VIDEO"], | ||
["keyword", "WAIT"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for keywords. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@PAPERNEKO | ||
@SUKI | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["label", "@PAPERNEKO"], | ||
["label", "@SUKI"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for labels. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
42 | ||
3.14159 | ||
2e8 | ||
3.4E-9 | ||
0.7E+12 | ||
#496F726953756B69 | ||
`11100010 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "42"], | ||
["number", "3.14159"], | ||
["number", "2e8"], | ||
["number", "3.4E-9"], | ||
["number", "0.7E+12"], | ||
["number", "#496F726953756B69"], | ||
["number", "`11100010"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
< | ||
<= | ||
<> | ||
> | ||
>= | ||
+ | ||
- | ||
* | ||
/ | ||
^ | ||
= | ||
& | ||
~ | ||
! | ||
| | ||
AND | ||
NOT | ||
OR | ||
|| | ||
&& | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", "<"], ["operator", "<="], ["operator", "<>"], | ||
["operator", ">"], ["operator", ">="], | ||
["operator", "+"], ["operator", "-"], ["operator", "*"], ["operator", "/"], | ||
["operator", "^"], ["operator", "="], | ||
["operator", "&"], ["operator", "~"], ["operator", "!"], ["operator", "|"], | ||
["operator", "AND"], ["operator", "NOT"], ["operator", "OR"], | ||
["operator", "||"], ["operator", "&&"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for operators. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"" | ||
"fo""obar" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"\""], | ||
["string", "\"fo\"\"obar\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |