purebasic.js 4.3 KB

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