smalltalk.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Language: Smalltalk
  3. Description: Smalltalk is an object-oriented, dynamically typed reflective programming language.
  4. Author: Vladimir Gubarkov <xonixx@gmail.com>
  5. Website: https://en.wikipedia.org/wiki/Smalltalk
  6. Category: system
  7. */
  8. function smalltalk(hljs) {
  9. const VAR_IDENT_RE = '[a-z][a-zA-Z0-9_]*';
  10. const CHAR = {
  11. className: 'string',
  12. begin: '\\$.{1}'
  13. };
  14. const SYMBOL = {
  15. className: 'symbol',
  16. begin: '#' + hljs.UNDERSCORE_IDENT_RE
  17. };
  18. return {
  19. name: 'Smalltalk',
  20. aliases: [ 'st' ],
  21. keywords: [
  22. "self",
  23. "super",
  24. "nil",
  25. "true",
  26. "false",
  27. "thisContext"
  28. ],
  29. contains: [
  30. hljs.COMMENT('"', '"'),
  31. hljs.APOS_STRING_MODE,
  32. {
  33. className: 'type',
  34. begin: '\\b[A-Z][A-Za-z0-9_]*',
  35. relevance: 0
  36. },
  37. {
  38. begin: VAR_IDENT_RE + ':',
  39. relevance: 0
  40. },
  41. hljs.C_NUMBER_MODE,
  42. SYMBOL,
  43. CHAR,
  44. {
  45. // This looks more complicated than needed to avoid combinatorial
  46. // explosion under V8. It effectively means `| var1 var2 ... |` with
  47. // whitespace adjacent to `|` being optional.
  48. begin: '\\|[ ]*' + VAR_IDENT_RE + '([ ]+' + VAR_IDENT_RE + ')*[ ]*\\|',
  49. returnBegin: true,
  50. end: /\|/,
  51. illegal: /\S/,
  52. contains: [ { begin: '(\\|[ ]*)?' + VAR_IDENT_RE } ]
  53. },
  54. {
  55. begin: '#\\(',
  56. end: '\\)',
  57. contains: [
  58. hljs.APOS_STRING_MODE,
  59. CHAR,
  60. hljs.C_NUMBER_MODE,
  61. SYMBOL
  62. ]
  63. }
  64. ]
  65. };
  66. }
  67. export { smalltalk as default };