prism-pascal.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Based on Free Pascal
  2. /* TODO
  3. Support inline asm ?
  4. */
  5. Prism.languages.pascal = {
  6. 'comment': [
  7. /\(\*[\s\S]+?\*\)/,
  8. /\{[\s\S]+?\}/,
  9. /\/\/.*/
  10. ],
  11. 'string': [
  12. /(?:'(?:''|[^'\n])*'|#[&$%]?[a-f\d]+)+/i,
  13. // Char
  14. /\^[a-z]/i
  15. ],
  16. 'keyword': [
  17. {
  18. // Turbo Pascal
  19. pattern: /(^|(?!&)[\s\S])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i,
  20. lookbehind: true
  21. },
  22. {
  23. // Free Pascal
  24. pattern: /(^|(?!&)[\s\S])\b(?:dispose|exit|false|new|true)\b/i,
  25. lookbehind: true
  26. },
  27. {
  28. // Object Pascal
  29. pattern: /(^|(?!&)[\s\S])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
  30. lookbehind: true
  31. },
  32. {
  33. // Modifiers
  34. pattern: /(^|(?!&)[\s\S])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i,
  35. lookbehind: true
  36. }
  37. ],
  38. 'number': [
  39. // Hexadecimal, octal and binary
  40. /[+-]?(?:[&%]\d+|\$[a-f\d]+)/i,
  41. // Decimal
  42. /([+-]|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
  43. ],
  44. 'operator': [
  45. /\.\.|\*\*|:=|[<>]{2}|[<>+\-*\/]=?|[@^=]/i,
  46. {
  47. pattern: /(^|(?!&)[\s\S])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
  48. lookbehind: true
  49. }
  50. ],
  51. 'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
  52. };