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