-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for IchigoJam BASIC #1246
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlueCocoa Thanks for contributing. This looks very similar to BASIC, so I'd suggest you do extend the original basic
component, and only overwrite the keyword
and function
patterns.
components.js
Outdated
@@ -261,6 +261,10 @@ var components = { | |||
"title": "HTTP", | |||
"owner": "danielgtaylor" | |||
}, | |||
"ichigojam": { | |||
"title": "IchigoJam", | |||
"owner": "Cocoa Oikawa" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please set owner
to your exact Github username, so that we can link to your page from the Prism download page.
components/prism-ichigojam.js
Outdated
@@ -0,0 +1,15 @@ | |||
// according to the offical reference https://ichigojam.net/IchigoJam-BASIC-reference.pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an english version of this reference? If there is we should add it to this comment. If there is not, could you just add (JP)
somewhere in the comment?
components/prism-ichigojam.js
Outdated
@@ -0,0 +1,15 @@ | |||
// according to the offical reference https://ichigojam.net/IchigoJam-BASIC-reference.pdf | |||
Prism.languages.ichigojam = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only differences between IchigoJam BASIC and standard BASIC, AFAICT, lie in the keyword
and function
patterns. You should really extend the original basic
component here.
components/prism-ichigojam.js
Outdated
}, | ||
'number': /(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?/i, | ||
'keyword': /\b(?:AS|BEEP|BLOAD|BSAVE|BPS|CALL(?: ABSOLUTE)?|CASE|CHAIN|CHDIR|CLEAR|CLOSE|CLK|CLO|CLP|CLS|CLT|CLV|COM|COMMON|CONT|COPY|CONST|DATA|DECLARE|DEF(?: FN| SEG|DBL|INT|LNG|SNG|STR)|DIM|DO|DOUBLE|ELSE|ELSEIF|END|ENVIRON|ERASE|ERROR|EXIT|FIELD|FILE|FILES|FOR|FUNCTION|GET|GOSUB|GSB|GOTO|IF|INPUT|INTEGER|IOCTL|KBD|KEY|KILL|LC|LED|LET|LIST|LINE INPUT|LOAD|LOCATE|LOCK|LONG|LOOP|LRUN|LSET|MKDIR|NAME|NEW|NEXT|OFF|ON(?: COM| ERROR| KEY| TIMER)?|OPEN|OPTION BASE|OUT|PLAY|POKE|PRINT|PUT|PWM|READ|REDIM|REM|RENUM|RESET|RESTORE|RESUME|RETURN|RMDIR|RSET|RTN|RUN|SAVE|SCROLL|SHARED|SINGLE|SELECT CASE|SHELL|SLEEP|SRND|STATIC|STEP|STOP|STRING|SUB|SWAP|SWITCH|SYSTEM|TEMPO|THEN|TIMER|TO|TROFF|TRON|TYPE|UART|UNLOCK|UNTIL|USING|VIDEO|VIEW PRINT|WAIT|WEND|WHILE|WRITE)(?:\$|\b)/i, | ||
"function": /\b(?:ABS|ACCESS|ACOS|ANA|ANGLE|AREA|ARITHMETIC|ARRAY|ASC|ASIN|ASK|AT|ATN|BASE|BEGIN|BIN|BREAK|BTN|CAUSE|CEIL|CHR|CLIP|COLLATE|COLOR|CON|COS|COSH|COT|CSC|DATE|DATUM|DEBUG|DEC|DECIMAL|DEF|DEG|DEGREES|DELETE|DET|DEVICE|DISPLAY|DOT|ELAPSED|END|EPS|ERASABLE|EXLINE|EXP|EXTERNAL|EXTYPE|FILETYPE|FIXED|FP|FREE|GO|GRAPH|HANDLER|HELP|HEX|I2CR|I2CW|IDN|IMAGE|IN|INKEY|INT|INTERNAL|IP|IS|KEYED|LANG|LBOUND|LCASE|LEFT|LEN|LENGTH|LINE|LINES|LOG|LOG10|LOG2|LTRIM|MARGIN|MAT|MAX|MAXNUM|MID|MIN|MISSING|MOD|NATIVE|NUL|NUMERIC|OF|OPTION|ORD|ORGANIZATION|OUTIN|OUTPUT|PEEK|PI|POINT|POINTER|POINTS|POS|PROGRAM|PROMPT|RAD|RADIANS|RANDOMIZE|RECORD|RECSIZE|RECTYPE|RELATIVE|REMAINDER|REPEAT|REST|RETRY|REWRITE|RIGHT|RND|ROUND|RTRIM|SAME|SEC|SELECT|SEQUENTIAL|SCR|SET|SETTER|SGN|SIN|SINH|SIZE|SKIP|SOUND|SQR|STANDARD|STATUS|STR|STREAM|STYLE|TAB|TAN|TANH|TEMPLATE|TEXT|THERE|TICK|TIME|TIMEOUT|TRACE|TRANSFORM|TRUNCATE|UBOUND|UCASE|USE|USR|VAL|VARIABLE|VER|VIEWPORT|VPEEK|WHEN|WINDOW|WITH|ZER|ZONEWIDTH)(?:\$|\b)/i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use single quotes around 'function'
, only for consistency.
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.
Hi, I've made some modifications and I decided to keep this as a standalone language after digging into its docs. Because IchigoJam uses a very small set of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlueCocoa Ok, then if you make a whole component for it, let's try to make it adequately specific.
Also, you'll have to add an example file (Take a look at the existing ones) and tests (See existing ones and the Test suite page for info) for this component.
components/prism-ichigojam.js
Outdated
Prism.languages.ichigojam = { | ||
'string': /"(?:""|[!#$%&'()*,\/:;<=>?^_ +\-.A-Z\d])*"/i, | ||
'comment': /\b(?:'|REM)(?:.*)?/i, | ||
'number': /(?:(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?|(?:(?:\B`)(?:0|1)+))/i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parentheses around the whole regexp are not necessary. The same goes for the outer parentheses in
(?:(?:\B`)(?:0|1)+))
.
In fact, the whole part you added does not need any parentheses, if you rewrite it as: \B`[01]+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the documentation also refers to hexadecimal numbers. Don't you want to highlight them too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm so sorry for the regexp, I'm not quite familiar with it. And thank you for your advices, I'm going to change it to the pattern below.
/(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?|(?:\B`[01]+)|(?:\B#[0-9A-F]+)/i
components/prism-ichigojam.js
Outdated
// https://ichigojam.net/IchigoJam-en.html | ||
Prism.languages.ichigojam = { | ||
'string': /"(?:""|[!#$%&'()*,\/:;<=>?^_ +\-.A-Z\d])*"/i, | ||
'comment': /\b(?:'|REM)(?:.*)?/i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused here.
I kinda get that you want the have a word boundary before the REM
, but are you sure you want to remove the one that was after? This would currently make REMABC
be highlighted as a comment, is it intended?
Also, .*
is already a pattern that can match nothing, you don't need to make it optional with ?
.
Please double check this pattern, and see if something like /(?:'|\bREM\b).*/i
wouldn't be more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, based on its docs and real code, commands starting with REM
is all comments, no space required.
And the regex (?:.*)?
is my mistake, I'll correct it in the next commit.
components/prism-ichigojam.js
Outdated
'number': /(?:(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?|(?:(?:\B`)(?:0|1)+))/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, | ||
'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:AND|EQV|IMP|NOT|OR|XOR)\b/i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference you linked seems to enumerate existing operators. Since you make a full component for IchigoJam, you might want to make a specific list and not just copy-paste the one from basic
.
For example, the reference mentions ~
but does not seem to have EQV
or IMP
. Please double check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm going to do a double check for all the parts before the next commit.
components/prism-ichigojam.js
Outdated
'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, | ||
'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:AND|EQV|IMP|NOT|OR|XOR)\b/i, | ||
'punctuation': /[,;:()]/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference you linked mentions array variables using []
notation. You might want to add those chars to the punctuation
pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I forget the punctuation part and I'll just fix it in the next commit.
Thank you for your time on checking all these mistakes and providing the detailed suggestions.
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
@BlueCocoa Nice! Looks good enough to me, I'm merging. Thanks for contributing! |
* gh-pages: (326 commits) Add C++ platform-independent types (PrismJS#1271) Release 1.10.0 Unescaped markup plugin: Make it work with any language (PrismJS#1265) Previewers: New plugin combining previous plugins Previewer: Base, Previewer: Angle, Previewer: Color, Previewer: Easing, Previewer: Gradient and Previewer: Time. Fix PrismJS#913 (PrismJS#1244) Add Elm (elm-lang.org) support (PrismJS#1174) IchigoJam: Remove unneeded escape Run gulp add Io syntax (PrismJS#1251) package.json: add attribute `style` (PrismJS#1256) Add the C++11 raw string feature to the cpp language IchigoJam: Make strings greedy BASIC: Make strings greedy Run gulp Add support for IchigoJam BASIC (PrismJS#1246) Add support for 6502 assembly (PrismJS#1245) fix for autoloader plugin Run gulp and reorder components alphabetically Xeora Language implementation (PrismJS#1239) upgrade autoloader Release 1.9.0 ...
Hi. This PR adds support for IchigoJam, 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.