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

http://github.com/scalate/scalate · JavaScript · 106 lines · 101 code · 2 blank · 3 comment · 0 complexity · 41cbd36f2a223be42a7060b633e1ec29 MD5 · raw file

  1. /*
  2. Language: SQL
  3. */
  4. hljs.LANGUAGES.sql =
  5. {
  6. case_insensitive: true,
  7. defaultMode:
  8. {
  9. contains: ['operator', 'comment'],
  10. illegal: '[^\\s]'
  11. },
  12. modes: [
  13. {
  14. className: 'operator',
  15. begin: '(begin|start|commit|rollback|savepoint|lock|alter|create|drop|rename|call|delete|do|handler|insert|load|replace|select|truncate|update|set|show|pragma)\\b', end: ';|$',
  16. contains: ['string', 'number', 'newline'],
  17. lexems: ['[a-zA-Z][a-zA-Z0-9_\\.]*'],
  18. keywords: {
  19. 'keyword': {
  20. 'all': 1, 'partial': 1, 'global': 1, 'month': 1,
  21. 'current_timestamp': 1, 'using': 1, 'go': 1, 'revoke': 1,
  22. 'smallint': 1, 'indicator': 1, 'end-exec': 1, 'disconnect': 1,
  23. 'zone': 1, 'with': 1, 'character': 1, 'assertion': 1, 'to': 1,
  24. 'add': 1, 'current_user': 1, 'usage': 1, 'input': 1, 'local': 1,
  25. 'alter': 1, 'match': 1, 'collate': 1, 'real': 1, 'then': 1,
  26. 'rollback': 1, 'get': 1, 'read': 1, 'timestamp': 1,
  27. 'session_user': 1, 'not': 1, 'integer': 1, 'bit': 1, 'unique': 1,
  28. 'day': 1, 'minute': 1, 'desc': 1, 'insert': 1, 'execute': 1,
  29. 'like': 1, 'ilike': 2, 'level': 1, 'decimal': 1, 'drop': 1,
  30. 'continue': 1, 'isolation': 1, 'found': 1, 'where': 1,
  31. 'constraints': 1, 'domain': 1, 'right': 1, 'national': 1, 'some': 1,
  32. 'module': 1, 'transaction': 1, 'relative': 1, 'second': 1,
  33. 'connect': 1, 'escape': 1, 'close': 1, 'system_user': 1, 'for': 1,
  34. 'deferred': 1, 'section': 1, 'cast': 1, 'current': 1, 'sqlstate': 1,
  35. 'allocate': 1, 'intersect': 1, 'deallocate': 1, 'numeric': 1,
  36. 'public': 1, 'preserve': 1, 'full': 1, 'goto': 1, 'initially': 1,
  37. 'asc': 1, 'no': 1, 'key': 1, 'output': 1, 'collation': 1, 'group': 1,
  38. 'by': 1, 'union': 1, 'session': 1, 'both': 1, 'last': 1,
  39. 'language': 1, 'constraint': 1, 'column': 1, 'of': 1, 'space': 1,
  40. 'foreign': 1, 'deferrable': 1, 'prior': 1, 'connection': 1,
  41. 'unknown': 1, 'action': 1, 'commit': 1, 'view': 1, 'or': 1,
  42. 'first': 1, 'into': 1, 'float': 1, 'year': 1, 'primary': 1,
  43. 'cascaded': 1, 'except': 1, 'restrict': 1, 'set': 1, 'references': 1,
  44. 'names': 1, 'table': 1, 'outer': 1, 'open': 1, 'select': 1,
  45. 'size': 1, 'are': 1, 'rows': 1, 'from': 1, 'prepare': 1,
  46. 'distinct': 1, 'leading': 1, 'create': 1, 'only': 1, 'next': 1,
  47. 'inner': 1, 'authorization': 1, 'schema': 1, 'corresponding': 1,
  48. 'option': 1, 'declare': 1, 'precision': 1, 'immediate': 1, 'else': 1,
  49. 'timezone_minute': 1, 'external': 1, 'varying': 1, 'translation': 1,
  50. 'true': 1, 'case': 1, 'exception': 1, 'join': 1, 'hour': 1,
  51. 'default': 1, 'double': 1, 'scroll': 1, 'value': 1, 'cursor': 1,
  52. 'descriptor': 1, 'values': 1, 'dec': 1, 'fetch': 1, 'procedure': 1,
  53. 'delete': 1, 'and': 1, 'false': 1, 'int': 1, 'is': 1, 'describe': 1,
  54. 'char': 1, 'as': 1, 'at': 1, 'in': 1, 'varchar': 1, 'null': 1,
  55. 'trailing': 1, 'any': 1, 'absolute': 1, 'current_time': 1, 'end': 1,
  56. 'grant': 1, 'privileges': 1, 'when': 1, 'cross': 1, 'check': 1,
  57. 'write': 1, 'current_date': 1, 'pad': 1, 'begin': 1, 'temporary': 1,
  58. 'exec': 1, 'time': 1, 'update': 1, 'catalog': 1, 'user': 1, 'sql': 1,
  59. 'date': 1, 'on': 1, 'identity': 1, 'timezone_hour': 1, 'natural': 1,
  60. 'whenever': 1, 'interval': 1, 'work': 1, 'order': 1, 'cascade': 1,
  61. 'diagnostics': 1, 'nchar': 1, 'having': 1, 'left': 1, 'call': 1,
  62. 'do': 1, 'handler': 1, 'load': 1, 'replace': 1, 'truncate': 1,
  63. 'start': 1, 'lock': 1, 'show': 1, 'pragma': 1},
  64. 'aggregate': {'count': 1, 'sum': 1, 'min': 1, 'max': 1, 'avg': 1}
  65. }
  66. },
  67. {
  68. className: 'newline',
  69. begin: '\\n', end: '^', noMarkup: true
  70. },
  71. hljs.C_NUMBER_MODE,
  72. hljs.C_BLOCK_COMMENT_MODE,
  73. {
  74. className: 'comment',
  75. begin: '--', end: '$'
  76. },
  77. {
  78. className: 'string',
  79. begin: '\'', end: '\'',
  80. contains: ['escape', 'squote'],
  81. relevance: 0
  82. },
  83. {
  84. className: 'squote',
  85. begin: '\'\'', end: '^', noMarkup: true
  86. },
  87. {
  88. className: 'string',
  89. begin: '"', end: '"',
  90. contains: [ 'escape', 'dquote'],
  91. relevance: 0
  92. },
  93. {
  94. className: 'dquote',
  95. begin: '""', end: '^', noMarkup: true
  96. },
  97. {
  98. className: 'string',
  99. begin: '`', end: '`',
  100. contains: ['escape']
  101. },
  102. hljs.BACKSLASH_ESCAPE
  103. ]
  104. };