/samples/scalate-presentation/src/highlight/languages/lisp.js

http://github.com/scalate/scalate · JavaScript · 95 lines · 89 code · 1 blank · 5 comment · 0 complexity · f8fb9c4c62b9597ddf0168f5522af940 MD5 · raw file

  1. /*
  2. Language: Lisp
  3. Description: Generic lisp syntax
  4. Author: Vasily Polovnyov <vast@whiteants.net>
  5. */
  6. hljs.LANGUAGES.lisp = function(){
  7. var LISP_IDENT_RE = '[a-zA-Z_\\-\\+\\*\\/\\<\\=\\>\\&\\#][a-zA-Z0-9_\\-\\+\\*\\/\\<\\=\\>\\&\\#]*'
  8. var LISP_SIMPLE_NUMBER_RE = '(\\-|\\+)?\\d+(\\.\\d+|\\/\\d+)?((d|e|f|l|s)(\\+|\\-)?\\d+)?'
  9. return {
  10. case_insensitive: true,
  11. defaultMode: {
  12. lexems: [LISP_IDENT_RE],
  13. contains: ['literal', 'number', 'string', 'comment', 'quoted', 'list'],
  14. illegal: '[^\\s]'
  15. },
  16. modes: [
  17. {
  18. className: 'string',
  19. begin: '"', end: '"',
  20. contains: ['escape'],
  21. relevance: 0
  22. },
  23. hljs.BACKSLASH_ESCAPE,
  24. {
  25. className: 'number',
  26. begin: LISP_SIMPLE_NUMBER_RE, end: '^'
  27. },
  28. {
  29. className: 'number',
  30. begin: '#b[0-1]+(/[0-1]+)?', end: '^'
  31. },
  32. {
  33. className: 'number',
  34. begin: '#o[0-7]+(/[0-7]+)?', end: '^'
  35. },
  36. {
  37. className: 'number',
  38. begin: '#x[0-9a-f]+(/[0-9a-f]+)?', end: '^'
  39. },
  40. {
  41. className: 'number',
  42. begin: '#c\\(' + LISP_SIMPLE_NUMBER_RE + ' +' + LISP_SIMPLE_NUMBER_RE, end: '\\)'
  43. },
  44. {
  45. className: 'comment',
  46. begin: ';', end: '$'
  47. },
  48. {
  49. className: 'quoted',
  50. begin: '[\'`]\\(', end: '\\)',
  51. contains: ['number', 'string', 'variable', 'keyword', 'quoted_list']
  52. },
  53. {
  54. className: 'quoted',
  55. begin: '\\(quote ', end: '\\)',
  56. contains: ['number', 'string', 'variable', 'keyword', 'quoted_list'],
  57. lexems: [LISP_IDENT_RE],
  58. keywords: {'title': {'quote': 1}}
  59. },
  60. {
  61. className: 'quoted_list',
  62. begin: '\\(', end: '\\)',
  63. contains: ['quoted_list', 'literal', 'number', 'string']
  64. },
  65. {
  66. className: 'list',
  67. begin: '\\(', end: '\\)',
  68. contains: ['title','body']
  69. },
  70. {
  71. className: 'title',
  72. begin: LISP_IDENT_RE, end: '^',
  73. endsWithParent: true
  74. },
  75. {
  76. className: 'body',
  77. begin: '^', endsWithParent: true, excludeEnd: true,
  78. contains: ['quoted', 'list', 'literal', 'number', 'string', 'comment', 'variable', 'keyword']
  79. },
  80. {
  81. className: 'keyword',
  82. begin: '[:&]' + LISP_IDENT_RE, end: '^'
  83. },
  84. {
  85. className: 'variable',
  86. begin: '\\*', end: '\\*'
  87. },
  88. {
  89. className: 'literal',
  90. begin: '\\b(t{1}|nil)\\b', end: '^'
  91. }
  92. ]
  93. };
  94. }();