purebasic.js (4381B)
1 /* 2 Language: PureBASIC 3 Author: Tristano Ajmone <tajmone@gmail.com> 4 Description: Syntax highlighting for PureBASIC (v.5.00-5.60). No inline ASM highlighting. (v.1.2, May 2017) 5 Credits: I've taken inspiration from the PureBasic language file for GeSHi, created by Gustavo Julio Fiorenza (GuShH). 6 Website: https://www.purebasic.com 7 */ 8 9 // Base deafult colors in PB IDE: background: #FFFFDF; foreground: #000000; 10 11 function purebasic(hljs) { 12 var STRINGS = { // PB IDE color: #0080FF (Azure Radiance) 13 className: 'string', 14 begin: '(~)?"', end: '"', 15 illegal: '\\n' 16 }; 17 var CONSTANTS = { // PB IDE color: #924B72 (Cannon Pink) 18 // "#" + a letter or underscore + letters, digits or underscores + (optional) "$" 19 className: 'symbol', 20 begin: '#[a-zA-Z_]\\w*\\$?' 21 }; 22 23 return { 24 name: 'PureBASIC', 25 aliases: ['pb', 'pbi'], 26 keywords: // PB IDE color: #006666 (Blue Stone) + Bold 27 // Keywords from all version of PureBASIC 5.00 upward ... 28 'Align And Array As Break CallDebugger Case CompilerCase CompilerDefault ' + 29 'CompilerElse CompilerElseIf CompilerEndIf CompilerEndSelect CompilerError ' + 30 'CompilerIf CompilerSelect CompilerWarning Continue Data DataSection Debug ' + 31 'DebugLevel Declare DeclareC DeclareCDLL DeclareDLL DeclareModule Default ' + 32 'Define Dim DisableASM DisableDebugger DisableExplicit Else ElseIf EnableASM ' + 33 'EnableDebugger EnableExplicit End EndDataSection EndDeclareModule EndEnumeration ' + 34 'EndIf EndImport EndInterface EndMacro EndModule EndProcedure EndSelect ' + 35 'EndStructure EndStructureUnion EndWith Enumeration EnumerationBinary Extends ' + 36 'FakeReturn For ForEach ForEver Global Gosub Goto If Import ImportC ' + 37 'IncludeBinary IncludeFile IncludePath Interface List Macro MacroExpandedCount ' + 38 'Map Module NewList NewMap Next Not Or Procedure ProcedureC ' + 39 'ProcedureCDLL ProcedureDLL ProcedureReturn Protected Prototype PrototypeC ReDim ' + 40 'Read Repeat Restore Return Runtime Select Shared Static Step Structure ' + 41 'StructureUnion Swap Threaded To UndefineMacro Until Until UnuseModule ' + 42 'UseModule Wend While With XIncludeFile XOr', 43 contains: [ 44 // COMMENTS | PB IDE color: #00AAAA (Persian Green) 45 hljs.COMMENT(';', '$', {relevance: 0}), 46 47 { // PROCEDURES DEFINITIONS 48 className: 'function', 49 begin: '\\b(Procedure|Declare)(C|CDLL|DLL)?\\b', 50 end: '\\(', 51 excludeEnd: true, 52 returnBegin: true, 53 contains: [ 54 { // PROCEDURE KEYWORDS | PB IDE color: #006666 (Blue Stone) + Bold 55 className: 'keyword', 56 begin: '(Procedure|Declare)(C|CDLL|DLL)?', 57 excludeEnd: true 58 }, 59 { // PROCEDURE RETURN TYPE SETTING | PB IDE color: #000000 (Black) 60 className: 'type', 61 begin: '\\.\\w*' 62 // end: ' ', 63 }, 64 hljs.UNDERSCORE_TITLE_MODE // PROCEDURE NAME | PB IDE color: #006666 (Blue Stone) 65 ] 66 }, 67 STRINGS, 68 CONSTANTS 69 ] 70 }; 71 } 72 73 /* ============================================================================== 74 CHANGELOG 75 ============================================================================== 76 - v.1.2 (2017-05-12) 77 -- BUG-FIX: Some keywords were accidentally joyned together. Now fixed. 78 - v.1.1 (2017-04-30) 79 -- Updated to PureBASIC 5.60. 80 -- Keywords list now built by extracting them from the PureBASIC SDK's 81 "SyntaxHilighting.dll" (from each PureBASIC version). Tokens from each 82 version are added to the list, and renamed or removed tokens are kept 83 for the sake of covering all versions of the language from PureBASIC 84 v5.00 upward. (NOTE: currently, there are no renamed or deprecated 85 tokens in the keywords list). For more info, see: 86 -- http://www.purebasic.fr/english/viewtopic.php?&p=506269 87 -- https://github.com/tajmone/purebasic-archives/tree/master/syntax-highlighting/guidelines 88 - v.1.0 (April 2016) 89 -- First release 90 -- Keywords list taken and adapted from GuShH's (Gustavo Julio Fiorenza) 91 PureBasic language file for GeSHi: 92 -- https://github.com/easybook/geshi/blob/master/geshi/purebasic.php 93 */ 94 95 module.exports = purebasic;