ini.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. export var conf = {
  6. comments: {
  7. lineComment: '#'
  8. },
  9. brackets: [
  10. ['{', '}'],
  11. ['[', ']'],
  12. ['(', ')']
  13. ],
  14. autoClosingPairs: [
  15. { open: '{', close: '}' },
  16. { open: '[', close: ']' },
  17. { open: '(', close: ')' },
  18. { open: '"', close: '"' },
  19. { open: "'", close: "'" }
  20. ],
  21. surroundingPairs: [
  22. { open: '{', close: '}' },
  23. { open: '[', close: ']' },
  24. { open: '(', close: ')' },
  25. { open: '"', close: '"' },
  26. { open: "'", close: "'" }
  27. ]
  28. };
  29. export var language = {
  30. defaultToken: '',
  31. tokenPostfix: '.ini',
  32. // we include these common regular expressions
  33. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  34. // The main tokenizer for our languages
  35. tokenizer: {
  36. root: [
  37. // sections
  38. [/^\[[^\]]*\]/, 'metatag'],
  39. // keys
  40. [/(^\w+)(\s*)(\=)/, ['key', '', 'delimiter']],
  41. // whitespace
  42. { include: '@whitespace' },
  43. // numbers
  44. [/\d+/, 'number'],
  45. // strings: recover on non-terminated strings
  46. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  47. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  48. [/"/, 'string', '@string."'],
  49. [/'/, 'string', "@string.'"]
  50. ],
  51. whitespace: [
  52. [/[ \t\r\n]+/, ''],
  53. [/^\s*[#;].*$/, 'comment']
  54. ],
  55. string: [
  56. [/[^\\"']+/, 'string'],
  57. [/@escapes/, 'string.escape'],
  58. [/\\./, 'string.escape.invalid'],
  59. [
  60. /["']/,
  61. {
  62. cases: {
  63. '$#==$S2': { token: 'string', next: '@pop' },
  64. '@default': 'string'
  65. }
  66. }
  67. ]
  68. ]
  69. }
  70. };