smalltalk.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. module.exports = function(hljs) {
  2. var VAR_IDENT_RE = '[a-z][a-zA-Z0-9_]*';
  3. var CHAR = {
  4. className: 'string',
  5. begin: '\\$.{1}'
  6. };
  7. var SYMBOL = {
  8. className: 'symbol',
  9. begin: '#' + hljs.UNDERSCORE_IDENT_RE
  10. };
  11. return {
  12. aliases: ['st'],
  13. keywords: 'self super nil true false thisContext', // only 6
  14. contains: [
  15. hljs.COMMENT('"', '"'),
  16. hljs.APOS_STRING_MODE,
  17. {
  18. className: 'type',
  19. begin: '\\b[A-Z][A-Za-z0-9_]*',
  20. relevance: 0
  21. },
  22. {
  23. begin: VAR_IDENT_RE + ':',
  24. relevance: 0
  25. },
  26. hljs.C_NUMBER_MODE,
  27. SYMBOL,
  28. CHAR,
  29. {
  30. // This looks more complicated than needed to avoid combinatorial
  31. // explosion under V8. It effectively means `| var1 var2 ... |` with
  32. // whitespace adjacent to `|` being optional.
  33. begin: '\\|[ ]*' + VAR_IDENT_RE + '([ ]+' + VAR_IDENT_RE + ')*[ ]*\\|',
  34. returnBegin: true, end: /\|/,
  35. illegal: /\S/,
  36. contains: [{begin: '(\\|[ ]*)?' + VAR_IDENT_RE}]
  37. },
  38. {
  39. begin: '\\#\\(', end: '\\)',
  40. contains: [
  41. hljs.APOS_STRING_MODE,
  42. CHAR,
  43. hljs.C_NUMBER_MODE,
  44. SYMBOL
  45. ]
  46. }
  47. ]
  48. };
  49. };