? Syntax Highlighting for GTKSourceView (gedit) (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
This website has been moved, please see this post

Syntax Highlighting for GTKSourceView (gedit)

  • #1 ✎ 11 dankrause Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Second Year My account is over 2 years old Website I put together a SmileBASIC language definition for GTKSourceView, used by gedit and others in Gnome. It can be found here: https://gist.github.com/dankrause/1a3592efa9a0e9722007 It's not perfect (I didn't spend a ton of time making sure numbers and operators are parsed properly in all the edge cases) but it makes writing SmileBASIC in gedit much nicer. Posted
  • #2 ✎ 1884 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself You can use some of the lists and regexes from my syntax highlighter: http://12me21.github.io/syntax/script.js find("keyword" ,/CONTINUE|RESTORE|ELSEIF|COMMON|LINPUT|REPEAT|RETURN|ENDIF|BREAK|FALSE|GOSUB|INPUT|PRINT|UNTIL|WHILE|CALL|DATA|ELSE|EXEC|GOTO|NEXT|READ|STEP|STOP|SWAP|THEN|TRUE|WEND|AND|DEC|DEF|DIM|DIV|END|FOR|INC|MOD|NOT|OUT|REM|USE|VAR|XOR|IF|ON|OR|TO/igm,text,list); find("function",/EXTFEATURE|BACKCOLOR|BACKTRACE|CLIPBOARD|PCMSTREAM|RANDOMIZE|SPHITINFO|BGMCLEAR|BGMPAUSE|BGSCREEN|CHKLABEL|CLASSIFY|GYROSYNC|HARDWARE|MICSTART|MILLISEC|PRGNAME\$|RINGCOPY|SPCOLVEC|SPUNLINK|TALKSTOP|BGCOLOR|BGCOORD|BGMCONT|BGMPLAY|BGMPRGA|BGMSETD|BGMSTOP|BGSCALE|BGSTART|BREPEAT|BQPARAM|CALLIDX|CHKCALL|CHKFILE|DISPLAY|DLCOPEN|ERRLINE|FADECHK|FONTDEF|FORMAT\$|FREEMEM|GCIRCLE|GPUTCHR|MAINCNT|MICDATA|MICSAVE|MICSIZE|MICSTOP|M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IT|XOFF|ABS|ASC|CLS|COS|DEG|EXP|FFT|KEY|LEN|LOG|MAX|MIN|POW|POP|RAD|RGB|RND|SGN|SIN|SQR|TAN|VAL|XON/igm,text,list); find(false ,/[A-Z_][A-Z0-9_]*[$%#]?/igm,text,list); //must be after keyword and function. Prevents functions/keywords from being highlighted in the middle of user variable/function names find(false ,/(?:\d*\.)?\d+(?=E)/igm,text,list); //must be before number. Causes numbers using E without a digit after to not be highlighted find(false ,/&amp;&amp;|&&/igm,text,list); //must be before number. Makes sure code like 7&&HEAD is not interpreted as a hex number. find("number" ,/\d*\.#?/igm,text,list); // x. and . numbers handled separately find("number" ,/(?:\d*\.)?\d+(?:E[+-]?\d+)?#?|(?:&amp;|&)H[\dA-F]+|(?:&amp;|&)B[01]+|#[A-Z0-9]+/igm,text,list); find("label" ,/@[0-9A-Z_]*/igm,text,list); find("string" ,/\".*?(?:\"|$)/igm,text,list); find("comment" ,/'[^'\n\r]*/igm,text,list); A few other mistakes: REM (not REN) works the same as ' (it can be placed anywhere in the line) The direct mode commands shouldn't be in the error list, since you can define functions with the same names (and PROJECT() is valid in programs) operators should be: - ! * / + << >> < > <= >= == != && || AND OR XOR DIV MOD NOT Posted Edited by 12Me21