ini.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define(["require", "exports"], function (require, exports) {
  6. 'use strict';
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.conf = {
  9. comments: {
  10. lineComment: '#'
  11. },
  12. brackets: [
  13. ['{', '}'],
  14. ['[', ']'],
  15. ['(', ')'],
  16. ],
  17. autoClosingPairs: [
  18. { open: '{', close: '}' },
  19. { open: '[', close: ']' },
  20. { open: '(', close: ')' },
  21. { open: '"', close: '"' },
  22. { open: '\'', close: '\'' },
  23. ],
  24. surroundingPairs: [
  25. { open: '{', close: '}' },
  26. { open: '[', close: ']' },
  27. { open: '(', close: ')' },
  28. { open: '"', close: '"' },
  29. { open: '\'', close: '\'' },
  30. ]
  31. };
  32. exports.language = {
  33. defaultToken: '',
  34. tokenPostfix: '.ini',
  35. // we include these common regular expressions
  36. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  37. // The main tokenizer for our languages
  38. tokenizer: {
  39. root: [
  40. // sections
  41. [/^\[[^\]]*\]/, 'metatag'],
  42. // keys
  43. [/(^\w+)(\s*)(\=)/, ['key', '', 'delimiter']],
  44. // whitespace
  45. { include: '@whitespace' },
  46. // numbers
  47. [/\d+/, 'number'],
  48. // strings: recover on non-terminated strings
  49. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  50. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  51. [/"/, 'string', '@string."'],
  52. [/'/, 'string', '@string.\''],
  53. ],
  54. whitespace: [
  55. [/[ \t\r\n]+/, ''],
  56. [/^\s*[#;].*$/, 'comment'],
  57. ],
  58. string: [
  59. [/[^\\"']+/, 'string'],
  60. [/@escapes/, 'string.escape'],
  61. [/\\./, 'string.escape.invalid'],
  62. [/["']/, {
  63. cases: {
  64. '$#==$S2': { token: 'string', next: '@pop' },
  65. '@default': 'string'
  66. }
  67. }]
  68. ],
  69. },
  70. };
  71. });