sql.js 4.1 KB

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