basic.js (2362B)
1 /* 2 Language: BASIC 3 Author: Raphaël Assénat <raph@raphnet.net> 4 Description: Based on the BASIC reference from the Tandy 1000 guide 5 Website: https://en.wikipedia.org/wiki/Tandy_1000 6 */ 7 8 /** @type LanguageFn */ 9 function basic(hljs) { 10 return { 11 name: 'BASIC', 12 case_insensitive: true, 13 illegal: '^\.', 14 // Support explicitly typed variables that end with $%! or #. 15 keywords: { 16 $pattern: '[a-zA-Z][a-zA-Z0-9_\$\%\!\#]*', 17 keyword: 18 'ABS ASC AND ATN AUTO|0 BEEP BLOAD|10 BSAVE|10 CALL CALLS CDBL CHAIN CHDIR CHR$|10 CINT CIRCLE ' + 19 'CLEAR CLOSE CLS COLOR COM COMMON CONT COS CSNG CSRLIN CVD CVI CVS DATA DATE$ ' + 20 'DEFDBL DEFINT DEFSNG DEFSTR DEF|0 SEG USR DELETE DIM DRAW EDIT END ENVIRON ENVIRON$ ' + 21 'EOF EQV ERASE ERDEV ERDEV$ ERL ERR ERROR EXP FIELD FILES FIX FOR|0 FRE GET GOSUB|10 GOTO ' + 22 'HEX$ IF THEN ELSE|0 INKEY$ INP INPUT INPUT# INPUT$ INSTR IMP INT IOCTL IOCTL$ KEY ON ' + 23 'OFF LIST KILL LEFT$ LEN LET LINE LLIST LOAD LOC LOCATE LOF LOG LPRINT USING LSET ' + 24 'MERGE MID$ MKDIR MKD$ MKI$ MKS$ MOD NAME NEW NEXT NOISE NOT OCT$ ON OR PEN PLAY STRIG OPEN OPTION ' + 25 'BASE OUT PAINT PALETTE PCOPY PEEK PMAP POINT POKE POS PRINT PRINT] PSET PRESET ' + 26 'PUT RANDOMIZE READ REM RENUM RESET|0 RESTORE RESUME RETURN|0 RIGHT$ RMDIR RND RSET ' + 27 'RUN SAVE SCREEN SGN SHELL SIN SOUND SPACE$ SPC SQR STEP STICK STOP STR$ STRING$ SWAP ' + 28 'SYSTEM TAB TAN TIME$ TIMER TROFF TRON TO USR VAL VARPTR VARPTR$ VIEW WAIT WHILE ' + 29 'WEND WIDTH WINDOW WRITE XOR' 30 }, 31 contains: [ 32 hljs.QUOTE_STRING_MODE, 33 hljs.COMMENT('REM', '$', {relevance: 10}), 34 hljs.COMMENT('\'', '$', {relevance: 0}), 35 { 36 // Match line numbers 37 className: 'symbol', 38 begin: '^[0-9]+\ ', 39 relevance: 10 40 }, 41 { 42 // Match typed numeric constants (1000, 12.34!, 1.2e5, 1.5#, 1.2D2) 43 className: 'number', 44 begin: '\\b([0-9]+[0-9edED\.]*[#\!]?)', 45 relevance: 0 46 }, 47 { 48 // Match hexadecimal numbers (&Hxxxx) 49 className: 'number', 50 begin: '(\&[hH][0-9a-fA-F]{1,4})' 51 }, 52 { 53 // Match octal numbers (&Oxxxxxx) 54 className: 'number', 55 begin: '(\&[oO][0-7]{1,6})' 56 } 57 ] 58 }; 59 } 60 61 module.exports = basic;