@abedmurrar/objection 4.0.0-alpha.0 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +103 -67
  2. package/lib/index.mjs +6 -0
  3. package/lib/initialize.js +6 -9
  4. package/lib/model/AjvValidator.js +235 -282
  5. package/lib/model/Model.js +653 -823
  6. package/lib/model/ModifierNotFoundError.js +5 -7
  7. package/lib/model/NotFoundError.js +14 -18
  8. package/lib/model/RelationDoesNotExistError.js +6 -9
  9. package/lib/model/ValidationError.js +33 -41
  10. package/lib/model/Validator.js +15 -21
  11. package/lib/model/getModel.js +1 -3
  12. package/lib/model/graph/ModelGraph.js +44 -64
  13. package/lib/model/graph/ModelGraphBuilder.js +164 -217
  14. package/lib/model/graph/ModelGraphEdge.js +31 -43
  15. package/lib/model/graph/ModelGraphNode.js +192 -231
  16. package/lib/model/inheritModel.js +9 -18
  17. package/lib/model/modelBindKnex.js +48 -62
  18. package/lib/model/modelClone.js +79 -98
  19. package/lib/model/modelColPropMap.js +16 -26
  20. package/lib/model/modelConcurrency.js +24 -0
  21. package/lib/model/modelId.js +44 -49
  22. package/lib/model/modelJsonAttributes.js +56 -76
  23. package/lib/model/modelParseRelations.js +68 -67
  24. package/lib/model/modelQueryProps.js +76 -107
  25. package/lib/model/modelSet.js +92 -112
  26. package/lib/model/modelTableMetadata.js +60 -72
  27. package/lib/model/modelToJson.js +120 -150
  28. package/lib/model/modelUtils.js +30 -37
  29. package/lib/model/modelValidate.js +34 -42
  30. package/lib/model/modelValues.js +78 -91
  31. package/lib/model/modelVisitor.js +22 -29
  32. package/lib/objection.js +42 -67
  33. package/lib/queryBuilder/FunctionBuilder.js +231 -279
  34. package/lib/queryBuilder/InternalOptions.js +19 -24
  35. package/lib/queryBuilder/JoinBuilder.js +116 -149
  36. package/lib/queryBuilder/QueryBuilder.js +1009 -1271
  37. package/lib/queryBuilder/QueryBuilderBase.js +647 -865
  38. package/lib/queryBuilder/QueryBuilderContext.js +14 -21
  39. package/lib/queryBuilder/QueryBuilderContextBase.js +20 -29
  40. package/lib/queryBuilder/QueryBuilderOperationSupport.js +462 -536
  41. package/lib/queryBuilder/QueryBuilderUserContext.js +19 -25
  42. package/lib/queryBuilder/RawBuilder.js +58 -73
  43. package/lib/queryBuilder/ReferenceBuilder.js +232 -270
  44. package/lib/queryBuilder/RelationExpression.js +322 -380
  45. package/lib/queryBuilder/StaticHookArguments.js +94 -106
  46. package/lib/queryBuilder/ValueBuilder.js +100 -112
  47. package/lib/queryBuilder/expressions.js +86 -116
  48. package/lib/queryBuilder/functions/mysql.js +642 -697
  49. package/lib/queryBuilder/graph/GraphAction.js +44 -59
  50. package/lib/queryBuilder/graph/GraphData.js +7 -9
  51. package/lib/queryBuilder/graph/GraphFetcher.js +115 -151
  52. package/lib/queryBuilder/graph/GraphNodeDbExistence.js +114 -152
  53. package/lib/queryBuilder/graph/GraphOperation.js +16 -22
  54. package/lib/queryBuilder/graph/GraphOptions.js +143 -185
  55. package/lib/queryBuilder/graph/GraphUpsert.js +167 -241
  56. package/lib/queryBuilder/graph/delete/GraphDelete.js +8 -13
  57. package/lib/queryBuilder/graph/delete/GraphDeleteAction.js +44 -62
  58. package/lib/queryBuilder/graph/insert/GraphInsert.js +99 -128
  59. package/lib/queryBuilder/graph/insert/GraphInsertAction.js +151 -193
  60. package/lib/queryBuilder/graph/insert/JoinRowGraphInsertAction.js +57 -79
  61. package/lib/queryBuilder/graph/patch/GraphPatch.js +8 -13
  62. package/lib/queryBuilder/graph/patch/GraphPatchAction.js +181 -234
  63. package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsert.js +16 -21
  64. package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsertAction.js +80 -110
  65. package/lib/queryBuilder/join/JoinResultColumn.js +14 -18
  66. package/lib/queryBuilder/join/JoinResultParser.js +88 -101
  67. package/lib/queryBuilder/join/RelationJoiner.js +205 -288
  68. package/lib/queryBuilder/join/TableNode.js +117 -144
  69. package/lib/queryBuilder/join/TableTree.js +60 -76
  70. package/lib/queryBuilder/join/utils.js +10 -16
  71. package/lib/queryBuilder/operations/DelegateOperation.js +93 -133
  72. package/lib/queryBuilder/operations/DeleteOperation.js +33 -37
  73. package/lib/queryBuilder/operations/FindByIdOperation.js +20 -28
  74. package/lib/queryBuilder/operations/FindByIdsOperation.js +17 -23
  75. package/lib/queryBuilder/operations/FindOperation.js +114 -131
  76. package/lib/queryBuilder/operations/FirstOperation.js +14 -19
  77. package/lib/queryBuilder/operations/FromOperation.js +69 -88
  78. package/lib/queryBuilder/operations/InsertAndFetchOperation.js +28 -39
  79. package/lib/queryBuilder/operations/InsertGraphAndFetchOperation.js +25 -35
  80. package/lib/queryBuilder/operations/InsertGraphOperation.js +77 -98
  81. package/lib/queryBuilder/operations/InsertOperation.js +132 -165
  82. package/lib/queryBuilder/operations/InstanceDeleteOperation.js +27 -36
  83. package/lib/queryBuilder/operations/InstanceFindOperation.js +9 -13
  84. package/lib/queryBuilder/operations/InstanceInsertOperation.js +13 -17
  85. package/lib/queryBuilder/operations/InstanceUpdateOperation.js +32 -46
  86. package/lib/queryBuilder/operations/JoinRelatedOperation.js +66 -86
  87. package/lib/queryBuilder/operations/KnexOperation.js +4 -7
  88. package/lib/queryBuilder/operations/MergeOperation.js +32 -45
  89. package/lib/queryBuilder/operations/ObjectionToKnexConvertingOperation.js +131 -150
  90. package/lib/queryBuilder/operations/OnBuildKnexOperation.js +17 -23
  91. package/lib/queryBuilder/operations/OnBuildOperation.js +17 -23
  92. package/lib/queryBuilder/operations/OnErrorOperation.js +17 -23
  93. package/lib/queryBuilder/operations/QueryBuilderOperation.js +231 -270
  94. package/lib/queryBuilder/operations/RangeOperation.js +30 -40
  95. package/lib/queryBuilder/operations/RelateOperation.js +14 -21
  96. package/lib/queryBuilder/operations/ReturningOperation.js +12 -18
  97. package/lib/queryBuilder/operations/RunAfterOperation.js +17 -23
  98. package/lib/queryBuilder/operations/RunBeforeOperation.js +17 -23
  99. package/lib/queryBuilder/operations/UnrelateOperation.js +12 -17
  100. package/lib/queryBuilder/operations/UpdateAndFetchOperation.js +48 -65
  101. package/lib/queryBuilder/operations/UpdateOperation.js +104 -129
  102. package/lib/queryBuilder/operations/UpsertGraphAndFetchOperation.js +25 -35
  103. package/lib/queryBuilder/operations/UpsertGraphOperation.js +36 -55
  104. package/lib/queryBuilder/operations/WhereCompositeOperation.js +30 -39
  105. package/lib/queryBuilder/operations/WhereInOperation.js +34 -36
  106. package/lib/queryBuilder/operations/eager/EagerOperation.js +37 -52
  107. package/lib/queryBuilder/operations/eager/JoinEagerOperation.js +34 -44
  108. package/lib/queryBuilder/operations/eager/NaiveEagerOperation.js +4 -7
  109. package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +193 -251
  110. package/lib/queryBuilder/operations/jsonApi/WhereJsonHasOperation.js +18 -25
  111. package/lib/queryBuilder/operations/jsonApi/WhereJsonNotObjectOperation.js +25 -41
  112. package/lib/queryBuilder/operations/jsonApi/WhereJsonOperation.js +19 -20
  113. package/lib/queryBuilder/operations/jsonApi/WhereJsonOverlapsOperation.js +23 -21
  114. package/lib/queryBuilder/operations/jsonApi/mysqlJsonApi.js +106 -118
  115. package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +79 -108
  116. package/lib/queryBuilder/operations/select/SelectOperation.js +37 -53
  117. package/lib/queryBuilder/operations/select/Selection.js +94 -105
  118. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +68 -101
  119. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeOperation.js +65 -75
  120. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeSqliteOperation.js +75 -84
  121. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.js +760 -859
  122. package/lib/queryBuilder/parsers/relationExpressionParser.js +840 -952
  123. package/lib/queryBuilder/transformations/CompositeQueryTransformation.js +10 -15
  124. package/lib/queryBuilder/transformations/QueryTransformation.js +4 -6
  125. package/lib/queryBuilder/transformations/WrapMysqlModifySubqueryTransformation.js +35 -49
  126. package/lib/queryBuilder/transformations/index.js +3 -9
  127. package/lib/queryBuilder/whereScopes.js +158 -186
  128. package/lib/relations/Relation.js +293 -375
  129. package/lib/relations/RelationDeleteOperation.js +24 -28
  130. package/lib/relations/RelationFindOperation.js +108 -138
  131. package/lib/relations/RelationInsertOperation.js +24 -32
  132. package/lib/relations/RelationOwner.js +175 -209
  133. package/lib/relations/RelationProperty.js +186 -223
  134. package/lib/relations/RelationUpdateOperation.js +23 -29
  135. package/lib/relations/belongsToOne/BelongsToOneDeleteOperation.js +16 -21
  136. package/lib/relations/belongsToOne/BelongsToOneInsertOperation.js +30 -41
  137. package/lib/relations/belongsToOne/BelongsToOneRelateOperation.js +36 -47
  138. package/lib/relations/belongsToOne/BelongsToOneRelation.js +42 -50
  139. package/lib/relations/belongsToOne/BelongsToOneUnrelateOperation.js +43 -58
  140. package/lib/relations/hasMany/HasManyInsertOperation.js +40 -56
  141. package/lib/relations/hasMany/HasManyRelateOperation.js +45 -61
  142. package/lib/relations/hasMany/HasManyRelation.js +38 -46
  143. package/lib/relations/hasMany/HasManyUnrelateOperation.js +25 -32
  144. package/lib/relations/hasOne/HasOneRelation.js +9 -12
  145. package/lib/relations/hasOneThrough/HasOneThroughRelation.js +9 -12
  146. package/lib/relations/manyToMany/ManyToManyModifyMixin.js +73 -95
  147. package/lib/relations/manyToMany/ManyToManyRelation.js +374 -473
  148. package/lib/relations/manyToMany/ManyToManySqliteModifyMixin.js +23 -30
  149. package/lib/relations/manyToMany/delete/ManyToManyDeleteOperation.js +8 -10
  150. package/lib/relations/manyToMany/delete/ManyToManyDeleteOperationBase.js +20 -25
  151. package/lib/relations/manyToMany/delete/ManyToManyDeleteSqliteOperation.js +8 -12
  152. package/lib/relations/manyToMany/find/ManyToManyFindOperation.js +77 -100
  153. package/lib/relations/manyToMany/insert/ManyToManyInsertOperation.js +37 -49
  154. package/lib/relations/manyToMany/relate/ManyToManyRelateOperation.js +58 -74
  155. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperation.js +10 -13
  156. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperationBase.js +26 -33
  157. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateSqliteOperation.js +10 -15
  158. package/lib/relations/manyToMany/update/ManyToManyUpdateOperation.js +8 -10
  159. package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +61 -78
  160. package/lib/relations/manyToMany/update/ManyToManyUpdateSqliteOperation.js +8 -12
  161. package/lib/transaction.js +53 -83
  162. package/lib/utils/assert.js +15 -21
  163. package/lib/utils/buildUtils.js +17 -19
  164. package/lib/utils/classUtils.js +7 -11
  165. package/lib/utils/cloneDeep.js +365 -0
  166. package/lib/utils/createModifier.js +36 -41
  167. package/lib/utils/deprecate.js +8 -12
  168. package/lib/utils/identifierMapping.js +153 -192
  169. package/lib/utils/internalPropUtils.js +4 -8
  170. package/lib/utils/knexUtils.js +61 -56
  171. package/lib/utils/mixin.js +16 -23
  172. package/lib/utils/mysqlJsonPath.js +55 -40
  173. package/lib/utils/normalizeIds.js +110 -127
  174. package/lib/utils/objectUtils.js +236 -338
  175. package/lib/utils/parseFieldExpression.js +66 -44
  176. package/lib/utils/postgresJsonPath.js +48 -62
  177. package/lib/utils/promiseUtils/after.js +10 -13
  178. package/lib/utils/promiseUtils/afterReturn.js +10 -13
  179. package/lib/utils/promiseUtils/index.js +15 -17
  180. package/lib/utils/promiseUtils/isPromise.js +6 -9
  181. package/lib/utils/promiseUtils/map.js +75 -89
  182. package/lib/utils/promiseUtils/mapAfterAllReturn.js +17 -23
  183. package/lib/utils/promiseUtils/try.js +15 -18
  184. package/lib/utils/resolveModel.js +91 -94
  185. package/lib/utils/tmpColumnUtils.js +4 -13
  186. package/package.json +50 -23
  187. package/typings/objection/index.d.mts +362 -0
  188. package/typings/objection/index.d.ts +36 -9
  189. package/lib/.eslintrc.json +0 -8
  190. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.pegjs +0 -97
  191. package/lib/queryBuilder/parsers/relationExpressionParser.pegjs +0 -141
  192. package/lib/utils/clone.js +0 -2329
@@ -1,886 +1,787 @@
1
1
  'use strict';
2
-
3
2
  /*
4
3
  * Generated by PEG.js 0.10.0.
5
4
  *
6
5
  * http://pegjs.org/
7
6
  */
8
-
9
7
  function peg$subclass(child, parent) {
10
- function ctor() {
11
- this.constructor = child;
12
- }
13
- ctor.prototype = parent.prototype;
14
- child.prototype = new ctor();
8
+ function ctor() {
9
+ this.constructor = child;
10
+ }
11
+ ctor.prototype = parent.prototype;
12
+ child.prototype = new ctor();
15
13
  }
16
-
17
14
  function peg$SyntaxError(message, expected, found, location) {
18
- this.message = message;
19
- this.expected = expected;
20
- this.found = found;
21
- this.location = location;
22
- this.name = 'SyntaxError';
23
-
24
- if (typeof Error.captureStackTrace === 'function') {
25
- Error.captureStackTrace(this, peg$SyntaxError);
26
- }
15
+ this.message = message;
16
+ this.expected = expected;
17
+ this.found = found;
18
+ this.location = location;
19
+ this.name = 'SyntaxError';
20
+ if (typeof Error.captureStackTrace === 'function') {
21
+ Error.captureStackTrace(this, peg$SyntaxError);
22
+ }
27
23
  }
28
-
29
24
  peg$subclass(peg$SyntaxError, Error);
30
-
31
25
  peg$SyntaxError.buildMessage = function (expected, found) {
32
- var DESCRIBE_EXPECTATION_FNS = {
33
- literal: function (expectation) {
34
- return '"' + literalEscape(expectation.text) + '"';
35
- },
36
-
37
- class: function (expectation) {
38
- var escapedParts = '',
39
- i;
40
-
41
- for (i = 0; i < expectation.parts.length; i++) {
42
- escapedParts +=
43
- expectation.parts[i] instanceof Array
44
- ? classEscape(expectation.parts[i][0]) + '-' + classEscape(expectation.parts[i][1])
45
- : classEscape(expectation.parts[i]);
46
- }
47
-
48
- return '[' + (expectation.inverted ? '^' : '') + escapedParts + ']';
49
- },
50
-
51
- any: function (expectation) {
52
- return 'any character';
53
- },
54
-
55
- end: function (expectation) {
56
- return 'end of input';
57
- },
58
-
59
- other: function (expectation) {
60
- return expectation.description;
61
- },
62
- };
63
-
64
- function hex(ch) {
65
- return ch.charCodeAt(0).toString(16).toUpperCase();
66
- }
67
-
68
- function literalEscape(s) {
69
- return s
70
- .replace(/\\/g, '\\\\')
71
- .replace(/"/g, '\\"')
72
- .replace(/\0/g, '\\0')
73
- .replace(/\t/g, '\\t')
74
- .replace(/\n/g, '\\n')
75
- .replace(/\r/g, '\\r')
76
- .replace(/[\x00-\x0F]/g, function (ch) {
77
- return '\\x0' + hex(ch);
78
- })
79
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
80
- return '\\x' + hex(ch);
81
- });
82
- }
83
-
84
- function classEscape(s) {
85
- return s
86
- .replace(/\\/g, '\\\\')
87
- .replace(/\]/g, '\\]')
88
- .replace(/\^/g, '\\^')
89
- .replace(/-/g, '\\-')
90
- .replace(/\0/g, '\\0')
91
- .replace(/\t/g, '\\t')
92
- .replace(/\n/g, '\\n')
93
- .replace(/\r/g, '\\r')
94
- .replace(/[\x00-\x0F]/g, function (ch) {
95
- return '\\x0' + hex(ch);
96
- })
97
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
98
- return '\\x' + hex(ch);
99
- });
100
- }
101
-
102
- function describeExpectation(expectation) {
103
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
104
- }
105
-
106
- function describeExpected(expected) {
107
- var descriptions = new Array(expected.length),
108
- i,
109
- j;
110
-
111
- for (i = 0; i < expected.length; i++) {
112
- descriptions[i] = describeExpectation(expected[i]);
113
- }
114
-
115
- descriptions.sort();
116
-
117
- if (descriptions.length > 0) {
118
- for (i = 1, j = 1; i < descriptions.length; i++) {
119
- if (descriptions[i - 1] !== descriptions[i]) {
120
- descriptions[j] = descriptions[i];
121
- j++;
122
- }
123
- }
124
- descriptions.length = j;
125
- }
126
-
127
- switch (descriptions.length) {
128
- case 1:
129
- return descriptions[0];
130
-
131
- case 2:
132
- return descriptions[0] + ' or ' + descriptions[1];
133
-
134
- default:
135
- return (
136
- descriptions.slice(0, -1).join(', ') + ', or ' + descriptions[descriptions.length - 1]
137
- );
138
- }
139
- }
140
-
141
- function describeFound(found) {
142
- return found ? '"' + literalEscape(found) + '"' : 'end of input';
143
- }
144
-
145
- return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.';
26
+ var DESCRIBE_EXPECTATION_FNS = {
27
+ literal: function (expectation) {
28
+ return '"' + literalEscape(expectation.text) + '"';
29
+ },
30
+ class: function (expectation) {
31
+ var escapedParts = '', i;
32
+ for (i = 0; i < expectation.parts.length; i++) {
33
+ escapedParts +=
34
+ expectation.parts[i] instanceof Array
35
+ ? classEscape(expectation.parts[i][0]) + '-' + classEscape(expectation.parts[i][1])
36
+ : classEscape(expectation.parts[i]);
37
+ }
38
+ return '[' + (expectation.inverted ? '^' : '') + escapedParts + ']';
39
+ },
40
+ any: function (expectation) {
41
+ return 'any character';
42
+ },
43
+ end: function (expectation) {
44
+ return 'end of input';
45
+ },
46
+ other: function (expectation) {
47
+ return expectation.description;
48
+ },
49
+ };
50
+ function hex(ch) {
51
+ return ch.charCodeAt(0).toString(16).toUpperCase();
52
+ }
53
+ function literalEscape(s) {
54
+ return s
55
+ .replace(/\\/g, '\\\\')
56
+ .replace(/"/g, '\\"')
57
+ .replace(/\0/g, '\\0')
58
+ .replace(/\t/g, '\\t')
59
+ .replace(/\n/g, '\\n')
60
+ .replace(/\r/g, '\\r')
61
+ .replace(/[\x00-\x0F]/g, function (ch) {
62
+ return '\\x0' + hex(ch);
63
+ })
64
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
65
+ return '\\x' + hex(ch);
66
+ });
67
+ }
68
+ function classEscape(s) {
69
+ return s
70
+ .replace(/\\/g, '\\\\')
71
+ .replace(/\]/g, '\\]')
72
+ .replace(/\^/g, '\\^')
73
+ .replace(/-/g, '\\-')
74
+ .replace(/\0/g, '\\0')
75
+ .replace(/\t/g, '\\t')
76
+ .replace(/\n/g, '\\n')
77
+ .replace(/\r/g, '\\r')
78
+ .replace(/[\x00-\x0F]/g, function (ch) {
79
+ return '\\x0' + hex(ch);
80
+ })
81
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
82
+ return '\\x' + hex(ch);
83
+ });
84
+ }
85
+ function describeExpectation(expectation) {
86
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
87
+ }
88
+ function describeExpected(expected) {
89
+ var descriptions = new Array(expected.length), i, j;
90
+ for (i = 0; i < expected.length; i++) {
91
+ descriptions[i] = describeExpectation(expected[i]);
92
+ }
93
+ descriptions.sort();
94
+ if (descriptions.length > 0) {
95
+ for (i = 1, j = 1; i < descriptions.length; i++) {
96
+ if (descriptions[i - 1] !== descriptions[i]) {
97
+ descriptions[j] = descriptions[i];
98
+ j++;
99
+ }
100
+ }
101
+ descriptions.length = j;
102
+ }
103
+ switch (descriptions.length) {
104
+ case 1:
105
+ return descriptions[0];
106
+ case 2:
107
+ return descriptions[0] + ' or ' + descriptions[1];
108
+ default:
109
+ return (descriptions.slice(0, -1).join(', ') + ', or ' + descriptions[descriptions.length - 1]);
110
+ }
111
+ }
112
+ function describeFound(found) {
113
+ return found ? '"' + literalEscape(found) + '"' : 'end of input';
114
+ }
115
+ return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.';
146
116
  };
147
-
148
117
  function peg$parse(input, options) {
149
- options = options !== void 0 ? options : {};
150
-
151
- var peg$FAILED = {},
152
- peg$startRuleFunctions = { start: peg$parsestart },
153
- peg$startRuleFunction = peg$parsestart,
154
- peg$c0 = ':',
155
- peg$c1 = peg$literalExpectation(':', false),
156
- peg$c2 = function (column, refs) {
157
- var access = [];
158
- if (refs) {
159
- var firstAccess = refs[1];
160
- access = refs[2];
161
- access.unshift(firstAccess);
162
- }
163
- return { columnName: column, access: access };
164
- },
165
- peg$c3 = '[',
166
- peg$c4 = peg$literalExpectation('[', false),
167
- peg$c5 = '"',
168
- peg$c6 = peg$literalExpectation('"', false),
169
- peg$c7 = "'",
170
- peg$c8 = peg$literalExpectation("'", false),
171
- peg$c9 = ']',
172
- peg$c10 = peg$literalExpectation(']', false),
173
- peg$c11 = function (key) {
174
- return { type: 'object', ref: Array.isArray(key) ? key[1] : key };
175
- },
176
- peg$c12 = function (index) {
177
- return { type: 'array', ref: parseInt(index, 10) };
178
- },
179
- peg$c13 = function (key) {
180
- return { type: 'object', ref: key };
181
- },
182
- peg$c14 = '.',
183
- peg$c15 = peg$literalExpectation('.', false),
184
- peg$c16 = /^[^\][]/,
185
- peg$c17 = peg$classExpectation([']', '['], true, false),
186
- peg$c18 = function (chars) {
187
- return chars.join('');
188
- },
189
- peg$c19 = /^[^:]/,
190
- peg$c20 = peg$classExpectation([':'], true, false),
191
- peg$c21 = /^[^"]/,
192
- peg$c22 = peg$classExpectation(['"'], true, false),
193
- peg$c23 = /^[^']/,
194
- peg$c24 = peg$classExpectation(["'"], true, false),
195
- peg$c25 = /^[^.\][]/,
196
- peg$c26 = peg$classExpectation(['.', ']', '['], true, false),
197
- peg$c27 = /^[0-9]/,
198
- peg$c28 = peg$classExpectation([['0', '9']], false, false),
199
- peg$c29 = function (digits) {
200
- return digits.join('');
201
- },
202
- peg$currPos = 0,
203
- peg$savedPos = 0,
204
- peg$posDetailsCache = [{ line: 1, column: 1 }],
205
- peg$maxFailPos = 0,
206
- peg$maxFailExpected = [],
207
- peg$silentFails = 0,
208
- peg$result;
209
-
210
- if ('startRule' in options) {
211
- if (!(options.startRule in peg$startRuleFunctions)) {
212
- throw new Error('Can\'t start parsing from rule "' + options.startRule + '".');
213
- }
214
-
215
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
216
- }
217
-
218
- function text() {
219
- return input.substring(peg$savedPos, peg$currPos);
220
- }
221
-
222
- function location() {
223
- return peg$computeLocation(peg$savedPos, peg$currPos);
224
- }
225
-
226
- function expected(description, location) {
227
- location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
228
-
229
- throw peg$buildStructuredError(
230
- [peg$otherExpectation(description)],
231
- input.substring(peg$savedPos, peg$currPos),
232
- location,
233
- );
234
- }
235
-
236
- function error(message, location) {
237
- location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
238
-
239
- throw peg$buildSimpleError(message, location);
240
- }
241
-
242
- function peg$literalExpectation(text, ignoreCase) {
243
- return { type: 'literal', text: text, ignoreCase: ignoreCase };
244
- }
245
-
246
- function peg$classExpectation(parts, inverted, ignoreCase) {
247
- return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase };
248
- }
249
-
250
- function peg$anyExpectation() {
251
- return { type: 'any' };
252
- }
253
-
254
- function peg$endExpectation() {
255
- return { type: 'end' };
256
- }
257
-
258
- function peg$otherExpectation(description) {
259
- return { type: 'other', description: description };
260
- }
261
-
262
- function peg$computePosDetails(pos) {
263
- var details = peg$posDetailsCache[pos],
264
- p;
265
-
266
- if (details) {
267
- return details;
268
- } else {
269
- p = pos - 1;
270
- while (!peg$posDetailsCache[p]) {
271
- p--;
272
- }
273
-
274
- details = peg$posDetailsCache[p];
275
- details = {
276
- line: details.line,
277
- column: details.column,
278
- };
279
-
280
- while (p < pos) {
281
- if (input.charCodeAt(p) === 10) {
282
- details.line++;
283
- details.column = 1;
284
- } else {
285
- details.column++;
286
- }
287
-
288
- p++;
289
- }
290
-
291
- peg$posDetailsCache[pos] = details;
292
- return details;
293
- }
294
- }
295
-
296
- function peg$computeLocation(startPos, endPos) {
297
- var startPosDetails = peg$computePosDetails(startPos),
298
- endPosDetails = peg$computePosDetails(endPos);
299
-
300
- return {
301
- start: {
302
- offset: startPos,
303
- line: startPosDetails.line,
304
- column: startPosDetails.column,
305
- },
306
- end: {
307
- offset: endPos,
308
- line: endPosDetails.line,
309
- column: endPosDetails.column,
310
- },
311
- };
312
- }
313
-
314
- function peg$fail(expected) {
315
- if (peg$currPos < peg$maxFailPos) {
316
- return;
317
- }
318
-
319
- if (peg$currPos > peg$maxFailPos) {
320
- peg$maxFailPos = peg$currPos;
321
- peg$maxFailExpected = [];
322
- }
323
-
324
- peg$maxFailExpected.push(expected);
325
- }
326
-
327
- function peg$buildSimpleError(message, location) {
328
- return new peg$SyntaxError(message, null, null, location);
329
- }
330
-
331
- function peg$buildStructuredError(expected, found, location) {
332
- return new peg$SyntaxError(
333
- peg$SyntaxError.buildMessage(expected, found),
334
- expected,
335
- found,
336
- location,
337
- );
338
- }
339
-
340
- function peg$parsestart() {
341
- var s0, s1, s2, s3, s4, s5, s6;
342
-
343
- s0 = peg$currPos;
344
- s1 = peg$parsestringWithoutColon();
345
- if (s1 !== peg$FAILED) {
346
- s2 = peg$currPos;
347
- if (input.charCodeAt(peg$currPos) === 58) {
348
- s3 = peg$c0;
349
- peg$currPos++;
350
- } else {
351
- s3 = peg$FAILED;
352
- if (peg$silentFails === 0) {
353
- peg$fail(peg$c1);
354
- }
355
- }
356
- if (s3 !== peg$FAILED) {
357
- s4 = peg$parsebracketIndexRef();
358
- if (s4 === peg$FAILED) {
359
- s4 = peg$parsebracketStringRef();
360
- if (s4 === peg$FAILED) {
361
- s4 = peg$parsecolonReference();
362
- }
363
- }
364
- if (s4 !== peg$FAILED) {
365
- s5 = [];
366
- s6 = peg$parsebracketIndexRef();
367
- if (s6 === peg$FAILED) {
368
- s6 = peg$parsebracketStringRef();
369
- if (s6 === peg$FAILED) {
370
- s6 = peg$parsedotReference();
371
- }
372
- }
373
- while (s6 !== peg$FAILED) {
374
- s5.push(s6);
375
- s6 = peg$parsebracketIndexRef();
376
- if (s6 === peg$FAILED) {
377
- s6 = peg$parsebracketStringRef();
378
- if (s6 === peg$FAILED) {
379
- s6 = peg$parsedotReference();
380
- }
381
- }
382
- }
383
- if (s5 !== peg$FAILED) {
384
- s3 = [s3, s4, s5];
385
- s2 = s3;
386
- } else {
387
- peg$currPos = s2;
388
- s2 = peg$FAILED;
389
- }
390
- } else {
391
- peg$currPos = s2;
392
- s2 = peg$FAILED;
393
- }
394
- } else {
395
- peg$currPos = s2;
396
- s2 = peg$FAILED;
397
- }
398
- if (s2 === peg$FAILED) {
399
- s2 = null;
400
- }
401
- if (s2 !== peg$FAILED) {
402
- peg$savedPos = s0;
403
- s1 = peg$c2(s1, s2);
118
+ options = options !== void 0 ? options : {};
119
+ var peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = ':', peg$c1 = peg$literalExpectation(':', false), peg$c2 = function (column, refs) {
120
+ var access = [];
121
+ if (refs) {
122
+ var firstAccess = refs[1];
123
+ access = refs[2];
124
+ access.unshift(firstAccess);
125
+ }
126
+ return { columnName: column, access: access };
127
+ }, peg$c3 = '[', peg$c4 = peg$literalExpectation('[', false), peg$c5 = '"', peg$c6 = peg$literalExpectation('"', false), peg$c7 = "'", peg$c8 = peg$literalExpectation("'", false), peg$c9 = ']', peg$c10 = peg$literalExpectation(']', false), peg$c11 = function (key) {
128
+ return { type: 'object', ref: Array.isArray(key) ? key[1] : key };
129
+ }, peg$c12 = function (index) {
130
+ return { type: 'array', ref: parseInt(index, 10) };
131
+ }, peg$c13 = function (key) {
132
+ return { type: 'object', ref: key };
133
+ }, peg$c14 = '.', peg$c15 = peg$literalExpectation('.', false), peg$c16 = /^[^\][]/, peg$c17 = peg$classExpectation([']', '['], true, false), peg$c18 = function (chars) {
134
+ return chars.join('');
135
+ }, peg$c19 = /^[^:]/, peg$c20 = peg$classExpectation([':'], true, false), peg$c21 = /^[^"]/, peg$c22 = peg$classExpectation(['"'], true, false), peg$c23 = /^[^']/, peg$c24 = peg$classExpectation(["'"], true, false), peg$c25 = /^[^.\][]/, peg$c26 = peg$classExpectation(['.', ']', '['], true, false), peg$c27 = /^[0-9]/, peg$c28 = peg$classExpectation([['0', '9']], false, false), peg$c29 = function (digits) {
136
+ return digits.join('');
137
+ }, peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result;
138
+ if ('startRule' in options) {
139
+ if (!(options.startRule in peg$startRuleFunctions)) {
140
+ throw new Error('Can\'t start parsing from rule "' + options.startRule + '".');
141
+ }
142
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
143
+ }
144
+ function text() {
145
+ return input.substring(peg$savedPos, peg$currPos);
146
+ }
147
+ function location() {
148
+ return peg$computeLocation(peg$savedPos, peg$currPos);
149
+ }
150
+ function expected(description, location) {
151
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
152
+ throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
153
+ }
154
+ function error(message, location) {
155
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
156
+ throw peg$buildSimpleError(message, location);
157
+ }
158
+ function peg$literalExpectation(text, ignoreCase) {
159
+ return { type: 'literal', text: text, ignoreCase: ignoreCase };
160
+ }
161
+ function peg$classExpectation(parts, inverted, ignoreCase) {
162
+ return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase };
163
+ }
164
+ function peg$anyExpectation() {
165
+ return { type: 'any' };
166
+ }
167
+ function peg$endExpectation() {
168
+ return { type: 'end' };
169
+ }
170
+ function peg$otherExpectation(description) {
171
+ return { type: 'other', description: description };
172
+ }
173
+ function peg$computePosDetails(pos) {
174
+ var details = peg$posDetailsCache[pos], p;
175
+ if (details) {
176
+ return details;
177
+ }
178
+ else {
179
+ p = pos - 1;
180
+ while (!peg$posDetailsCache[p]) {
181
+ p--;
182
+ }
183
+ details = peg$posDetailsCache[p];
184
+ details = {
185
+ line: details.line,
186
+ column: details.column,
187
+ };
188
+ while (p < pos) {
189
+ if (input.charCodeAt(p) === 10) {
190
+ details.line++;
191
+ details.column = 1;
192
+ }
193
+ else {
194
+ details.column++;
195
+ }
196
+ p++;
197
+ }
198
+ peg$posDetailsCache[pos] = details;
199
+ return details;
200
+ }
201
+ }
202
+ function peg$computeLocation(startPos, endPos) {
203
+ var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos);
204
+ return {
205
+ start: {
206
+ offset: startPos,
207
+ line: startPosDetails.line,
208
+ column: startPosDetails.column,
209
+ },
210
+ end: {
211
+ offset: endPos,
212
+ line: endPosDetails.line,
213
+ column: endPosDetails.column,
214
+ },
215
+ };
216
+ }
217
+ function peg$fail(expected) {
218
+ if (peg$currPos < peg$maxFailPos) {
219
+ return;
220
+ }
221
+ if (peg$currPos > peg$maxFailPos) {
222
+ peg$maxFailPos = peg$currPos;
223
+ peg$maxFailExpected = [];
224
+ }
225
+ peg$maxFailExpected.push(expected);
226
+ }
227
+ function peg$buildSimpleError(message, location) {
228
+ return new peg$SyntaxError(message, null, null, location);
229
+ }
230
+ function peg$buildStructuredError(expected, found, location) {
231
+ return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
232
+ }
233
+ function peg$parsestart() {
234
+ var s0, s1, s2, s3, s4, s5, s6;
235
+ s0 = peg$currPos;
236
+ s1 = peg$parsestringWithoutColon();
237
+ if (s1 !== peg$FAILED) {
238
+ s2 = peg$currPos;
239
+ if (input.charCodeAt(peg$currPos) === 58) {
240
+ s3 = peg$c0;
241
+ peg$currPos++;
242
+ }
243
+ else {
244
+ s3 = peg$FAILED;
245
+ if (peg$silentFails === 0) {
246
+ peg$fail(peg$c1);
247
+ }
248
+ }
249
+ if (s3 !== peg$FAILED) {
250
+ s4 = peg$parsebracketIndexRef();
251
+ if (s4 === peg$FAILED) {
252
+ s4 = peg$parsebracketStringRef();
253
+ if (s4 === peg$FAILED) {
254
+ s4 = peg$parsecolonReference();
255
+ }
256
+ }
257
+ if (s4 !== peg$FAILED) {
258
+ s5 = [];
259
+ s6 = peg$parsebracketIndexRef();
260
+ if (s6 === peg$FAILED) {
261
+ s6 = peg$parsebracketStringRef();
262
+ if (s6 === peg$FAILED) {
263
+ s6 = peg$parsedotReference();
264
+ }
265
+ }
266
+ while (s6 !== peg$FAILED) {
267
+ s5.push(s6);
268
+ s6 = peg$parsebracketIndexRef();
269
+ if (s6 === peg$FAILED) {
270
+ s6 = peg$parsebracketStringRef();
271
+ if (s6 === peg$FAILED) {
272
+ s6 = peg$parsedotReference();
273
+ }
274
+ }
275
+ }
276
+ if (s5 !== peg$FAILED) {
277
+ s3 = [s3, s4, s5];
278
+ s2 = s3;
279
+ }
280
+ else {
281
+ peg$currPos = s2;
282
+ s2 = peg$FAILED;
283
+ }
284
+ }
285
+ else {
286
+ peg$currPos = s2;
287
+ s2 = peg$FAILED;
288
+ }
289
+ }
290
+ else {
291
+ peg$currPos = s2;
292
+ s2 = peg$FAILED;
293
+ }
294
+ if (s2 === peg$FAILED) {
295
+ s2 = null;
296
+ }
297
+ if (s2 !== peg$FAILED) {
298
+ peg$savedPos = s0;
299
+ s1 = peg$c2(s1, s2);
300
+ s0 = s1;
301
+ }
302
+ else {
303
+ peg$currPos = s0;
304
+ s0 = peg$FAILED;
305
+ }
306
+ }
307
+ else {
308
+ peg$currPos = s0;
309
+ s0 = peg$FAILED;
310
+ }
311
+ return s0;
312
+ }
313
+ function peg$parsebracketStringRef() {
314
+ var s0, s1, s2, s3, s4, s5;
315
+ s0 = peg$currPos;
316
+ if (input.charCodeAt(peg$currPos) === 91) {
317
+ s1 = peg$c3;
318
+ peg$currPos++;
319
+ }
320
+ else {
321
+ s1 = peg$FAILED;
322
+ if (peg$silentFails === 0) {
323
+ peg$fail(peg$c4);
324
+ }
325
+ }
326
+ if (s1 !== peg$FAILED) {
327
+ s2 = peg$currPos;
328
+ if (input.charCodeAt(peg$currPos) === 34) {
329
+ s3 = peg$c5;
330
+ peg$currPos++;
331
+ }
332
+ else {
333
+ s3 = peg$FAILED;
334
+ if (peg$silentFails === 0) {
335
+ peg$fail(peg$c6);
336
+ }
337
+ }
338
+ if (s3 !== peg$FAILED) {
339
+ s4 = peg$parsestringWithoutDoubleQuotes();
340
+ if (s4 !== peg$FAILED) {
341
+ if (input.charCodeAt(peg$currPos) === 34) {
342
+ s5 = peg$c5;
343
+ peg$currPos++;
344
+ }
345
+ else {
346
+ s5 = peg$FAILED;
347
+ if (peg$silentFails === 0) {
348
+ peg$fail(peg$c6);
349
+ }
350
+ }
351
+ if (s5 !== peg$FAILED) {
352
+ s3 = [s3, s4, s5];
353
+ s2 = s3;
354
+ }
355
+ else {
356
+ peg$currPos = s2;
357
+ s2 = peg$FAILED;
358
+ }
359
+ }
360
+ else {
361
+ peg$currPos = s2;
362
+ s2 = peg$FAILED;
363
+ }
364
+ }
365
+ else {
366
+ peg$currPos = s2;
367
+ s2 = peg$FAILED;
368
+ }
369
+ if (s2 === peg$FAILED) {
370
+ s2 = peg$currPos;
371
+ if (input.charCodeAt(peg$currPos) === 39) {
372
+ s3 = peg$c7;
373
+ peg$currPos++;
374
+ }
375
+ else {
376
+ s3 = peg$FAILED;
377
+ if (peg$silentFails === 0) {
378
+ peg$fail(peg$c8);
379
+ }
380
+ }
381
+ if (s3 !== peg$FAILED) {
382
+ s4 = peg$parsestringWithoutSingleQuotes();
383
+ if (s4 !== peg$FAILED) {
384
+ if (input.charCodeAt(peg$currPos) === 39) {
385
+ s5 = peg$c7;
386
+ peg$currPos++;
387
+ }
388
+ else {
389
+ s5 = peg$FAILED;
390
+ if (peg$silentFails === 0) {
391
+ peg$fail(peg$c8);
392
+ }
393
+ }
394
+ if (s5 !== peg$FAILED) {
395
+ s3 = [s3, s4, s5];
396
+ s2 = s3;
397
+ }
398
+ else {
399
+ peg$currPos = s2;
400
+ s2 = peg$FAILED;
401
+ }
402
+ }
403
+ else {
404
+ peg$currPos = s2;
405
+ s2 = peg$FAILED;
406
+ }
407
+ }
408
+ else {
409
+ peg$currPos = s2;
410
+ s2 = peg$FAILED;
411
+ }
412
+ if (s2 === peg$FAILED) {
413
+ s2 = peg$parsestringWithoutSquareBrackets();
414
+ }
415
+ }
416
+ if (s2 !== peg$FAILED) {
417
+ if (input.charCodeAt(peg$currPos) === 93) {
418
+ s3 = peg$c9;
419
+ peg$currPos++;
420
+ }
421
+ else {
422
+ s3 = peg$FAILED;
423
+ if (peg$silentFails === 0) {
424
+ peg$fail(peg$c10);
425
+ }
426
+ }
427
+ if (s3 !== peg$FAILED) {
428
+ peg$savedPos = s0;
429
+ s1 = peg$c11(s2);
430
+ s0 = s1;
431
+ }
432
+ else {
433
+ peg$currPos = s0;
434
+ s0 = peg$FAILED;
435
+ }
436
+ }
437
+ else {
438
+ peg$currPos = s0;
439
+ s0 = peg$FAILED;
440
+ }
441
+ }
442
+ else {
443
+ peg$currPos = s0;
444
+ s0 = peg$FAILED;
445
+ }
446
+ return s0;
447
+ }
448
+ function peg$parsebracketIndexRef() {
449
+ var s0, s1, s2, s3;
450
+ s0 = peg$currPos;
451
+ if (input.charCodeAt(peg$currPos) === 91) {
452
+ s1 = peg$c3;
453
+ peg$currPos++;
454
+ }
455
+ else {
456
+ s1 = peg$FAILED;
457
+ if (peg$silentFails === 0) {
458
+ peg$fail(peg$c4);
459
+ }
460
+ }
461
+ if (s1 !== peg$FAILED) {
462
+ s2 = peg$parseinteger();
463
+ if (s2 !== peg$FAILED) {
464
+ if (input.charCodeAt(peg$currPos) === 93) {
465
+ s3 = peg$c9;
466
+ peg$currPos++;
467
+ }
468
+ else {
469
+ s3 = peg$FAILED;
470
+ if (peg$silentFails === 0) {
471
+ peg$fail(peg$c10);
472
+ }
473
+ }
474
+ if (s3 !== peg$FAILED) {
475
+ peg$savedPos = s0;
476
+ s1 = peg$c12(s2);
477
+ s0 = s1;
478
+ }
479
+ else {
480
+ peg$currPos = s0;
481
+ s0 = peg$FAILED;
482
+ }
483
+ }
484
+ else {
485
+ peg$currPos = s0;
486
+ s0 = peg$FAILED;
487
+ }
488
+ }
489
+ else {
490
+ peg$currPos = s0;
491
+ s0 = peg$FAILED;
492
+ }
493
+ return s0;
494
+ }
495
+ function peg$parsecolonReference() {
496
+ var s0, s1;
497
+ s0 = peg$currPos;
498
+ s1 = peg$parsestringWithoutSquareBracketsOrDots();
499
+ if (s1 !== peg$FAILED) {
500
+ peg$savedPos = s0;
501
+ s1 = peg$c13(s1);
502
+ }
404
503
  s0 = s1;
405
- } else {
406
- peg$currPos = s0;
407
- s0 = peg$FAILED;
408
- }
409
- } else {
410
- peg$currPos = s0;
411
- s0 = peg$FAILED;
412
- }
413
-
414
- return s0;
415
- }
416
-
417
- function peg$parsebracketStringRef() {
418
- var s0, s1, s2, s3, s4, s5;
419
-
420
- s0 = peg$currPos;
421
- if (input.charCodeAt(peg$currPos) === 91) {
422
- s1 = peg$c3;
423
- peg$currPos++;
424
- } else {
425
- s1 = peg$FAILED;
426
- if (peg$silentFails === 0) {
427
- peg$fail(peg$c4);
428
- }
429
- }
430
- if (s1 !== peg$FAILED) {
431
- s2 = peg$currPos;
432
- if (input.charCodeAt(peg$currPos) === 34) {
433
- s3 = peg$c5;
434
- peg$currPos++;
435
- } else {
436
- s3 = peg$FAILED;
437
- if (peg$silentFails === 0) {
438
- peg$fail(peg$c6);
439
- }
440
- }
441
- if (s3 !== peg$FAILED) {
442
- s4 = peg$parsestringWithoutDoubleQuotes();
443
- if (s4 !== peg$FAILED) {
444
- if (input.charCodeAt(peg$currPos) === 34) {
445
- s5 = peg$c5;
504
+ return s0;
505
+ }
506
+ function peg$parsedotReference() {
507
+ var s0, s1, s2;
508
+ s0 = peg$currPos;
509
+ if (input.charCodeAt(peg$currPos) === 46) {
510
+ s1 = peg$c14;
446
511
  peg$currPos++;
447
- } else {
448
- s5 = peg$FAILED;
512
+ }
513
+ else {
514
+ s1 = peg$FAILED;
449
515
  if (peg$silentFails === 0) {
450
- peg$fail(peg$c6);
451
- }
452
- }
453
- if (s5 !== peg$FAILED) {
454
- s3 = [s3, s4, s5];
455
- s2 = s3;
456
- } else {
457
- peg$currPos = s2;
458
- s2 = peg$FAILED;
459
- }
460
- } else {
461
- peg$currPos = s2;
462
- s2 = peg$FAILED;
463
- }
464
- } else {
465
- peg$currPos = s2;
466
- s2 = peg$FAILED;
467
- }
468
- if (s2 === peg$FAILED) {
469
- s2 = peg$currPos;
470
- if (input.charCodeAt(peg$currPos) === 39) {
471
- s3 = peg$c7;
472
- peg$currPos++;
473
- } else {
474
- s3 = peg$FAILED;
475
- if (peg$silentFails === 0) {
476
- peg$fail(peg$c8);
477
- }
478
- }
479
- if (s3 !== peg$FAILED) {
480
- s4 = peg$parsestringWithoutSingleQuotes();
481
- if (s4 !== peg$FAILED) {
482
- if (input.charCodeAt(peg$currPos) === 39) {
483
- s5 = peg$c7;
484
- peg$currPos++;
485
- } else {
486
- s5 = peg$FAILED;
487
- if (peg$silentFails === 0) {
488
- peg$fail(peg$c8);
489
- }
490
- }
491
- if (s5 !== peg$FAILED) {
492
- s3 = [s3, s4, s5];
493
- s2 = s3;
494
- } else {
495
- peg$currPos = s2;
496
- s2 = peg$FAILED;
497
- }
498
- } else {
499
- peg$currPos = s2;
516
+ peg$fail(peg$c15);
517
+ }
518
+ }
519
+ if (s1 !== peg$FAILED) {
520
+ s2 = peg$parsestringWithoutSquareBracketsOrDots();
521
+ if (s2 !== peg$FAILED) {
522
+ peg$savedPos = s0;
523
+ s1 = peg$c13(s2);
524
+ s0 = s1;
525
+ }
526
+ else {
527
+ peg$currPos = s0;
528
+ s0 = peg$FAILED;
529
+ }
530
+ }
531
+ else {
532
+ peg$currPos = s0;
533
+ s0 = peg$FAILED;
534
+ }
535
+ return s0;
536
+ }
537
+ function peg$parsestringWithoutSquareBrackets() {
538
+ var s0, s1, s2;
539
+ s0 = peg$currPos;
540
+ s1 = [];
541
+ if (peg$c16.test(input.charAt(peg$currPos))) {
542
+ s2 = input.charAt(peg$currPos);
543
+ peg$currPos++;
544
+ }
545
+ else {
500
546
  s2 = peg$FAILED;
501
- }
502
- } else {
503
- peg$currPos = s2;
504
- s2 = peg$FAILED;
505
- }
506
- if (s2 === peg$FAILED) {
507
- s2 = peg$parsestringWithoutSquareBrackets();
508
- }
509
- }
510
- if (s2 !== peg$FAILED) {
511
- if (input.charCodeAt(peg$currPos) === 93) {
512
- s3 = peg$c9;
513
- peg$currPos++;
514
- } else {
515
- s3 = peg$FAILED;
516
- if (peg$silentFails === 0) {
517
- peg$fail(peg$c10);
518
- }
519
- }
520
- if (s3 !== peg$FAILED) {
521
- peg$savedPos = s0;
522
- s1 = peg$c11(s2);
523
- s0 = s1;
524
- } else {
525
- peg$currPos = s0;
526
- s0 = peg$FAILED;
527
- }
528
- } else {
529
- peg$currPos = s0;
530
- s0 = peg$FAILED;
531
- }
532
- } else {
533
- peg$currPos = s0;
534
- s0 = peg$FAILED;
535
- }
536
-
537
- return s0;
538
- }
539
-
540
- function peg$parsebracketIndexRef() {
541
- var s0, s1, s2, s3;
542
-
543
- s0 = peg$currPos;
544
- if (input.charCodeAt(peg$currPos) === 91) {
545
- s1 = peg$c3;
546
- peg$currPos++;
547
- } else {
548
- s1 = peg$FAILED;
549
- if (peg$silentFails === 0) {
550
- peg$fail(peg$c4);
551
- }
552
- }
553
- if (s1 !== peg$FAILED) {
554
- s2 = peg$parseinteger();
555
- if (s2 !== peg$FAILED) {
556
- if (input.charCodeAt(peg$currPos) === 93) {
557
- s3 = peg$c9;
558
- peg$currPos++;
559
- } else {
560
- s3 = peg$FAILED;
561
- if (peg$silentFails === 0) {
562
- peg$fail(peg$c10);
563
- }
564
- }
565
- if (s3 !== peg$FAILED) {
566
- peg$savedPos = s0;
567
- s1 = peg$c12(s2);
568
- s0 = s1;
569
- } else {
570
- peg$currPos = s0;
571
- s0 = peg$FAILED;
572
- }
573
- } else {
574
- peg$currPos = s0;
575
- s0 = peg$FAILED;
576
- }
577
- } else {
578
- peg$currPos = s0;
579
- s0 = peg$FAILED;
580
- }
581
-
582
- return s0;
583
- }
584
-
585
- function peg$parsecolonReference() {
586
- var s0, s1;
587
-
588
- s0 = peg$currPos;
589
- s1 = peg$parsestringWithoutSquareBracketsOrDots();
590
- if (s1 !== peg$FAILED) {
591
- peg$savedPos = s0;
592
- s1 = peg$c13(s1);
593
- }
594
- s0 = s1;
595
-
596
- return s0;
597
- }
598
-
599
- function peg$parsedotReference() {
600
- var s0, s1, s2;
601
-
602
- s0 = peg$currPos;
603
- if (input.charCodeAt(peg$currPos) === 46) {
604
- s1 = peg$c14;
605
- peg$currPos++;
606
- } else {
607
- s1 = peg$FAILED;
608
- if (peg$silentFails === 0) {
609
- peg$fail(peg$c15);
610
- }
611
- }
612
- if (s1 !== peg$FAILED) {
613
- s2 = peg$parsestringWithoutSquareBracketsOrDots();
614
- if (s2 !== peg$FAILED) {
615
- peg$savedPos = s0;
616
- s1 = peg$c13(s2);
547
+ if (peg$silentFails === 0) {
548
+ peg$fail(peg$c17);
549
+ }
550
+ }
551
+ if (s2 !== peg$FAILED) {
552
+ while (s2 !== peg$FAILED) {
553
+ s1.push(s2);
554
+ if (peg$c16.test(input.charAt(peg$currPos))) {
555
+ s2 = input.charAt(peg$currPos);
556
+ peg$currPos++;
557
+ }
558
+ else {
559
+ s2 = peg$FAILED;
560
+ if (peg$silentFails === 0) {
561
+ peg$fail(peg$c17);
562
+ }
563
+ }
564
+ }
565
+ }
566
+ else {
567
+ s1 = peg$FAILED;
568
+ }
569
+ if (s1 !== peg$FAILED) {
570
+ peg$savedPos = s0;
571
+ s1 = peg$c18(s1);
572
+ }
617
573
  s0 = s1;
618
- } else {
619
- peg$currPos = s0;
620
- s0 = peg$FAILED;
621
- }
622
- } else {
623
- peg$currPos = s0;
624
- s0 = peg$FAILED;
625
- }
626
-
627
- return s0;
628
- }
629
-
630
- function peg$parsestringWithoutSquareBrackets() {
631
- var s0, s1, s2;
632
-
633
- s0 = peg$currPos;
634
- s1 = [];
635
- if (peg$c16.test(input.charAt(peg$currPos))) {
636
- s2 = input.charAt(peg$currPos);
637
- peg$currPos++;
638
- } else {
639
- s2 = peg$FAILED;
640
- if (peg$silentFails === 0) {
641
- peg$fail(peg$c17);
642
- }
643
- }
644
- if (s2 !== peg$FAILED) {
645
- while (s2 !== peg$FAILED) {
646
- s1.push(s2);
647
- if (peg$c16.test(input.charAt(peg$currPos))) {
648
- s2 = input.charAt(peg$currPos);
649
- peg$currPos++;
650
- } else {
651
- s2 = peg$FAILED;
652
- if (peg$silentFails === 0) {
653
- peg$fail(peg$c17);
654
- }
655
- }
656
- }
657
- } else {
658
- s1 = peg$FAILED;
659
- }
660
- if (s1 !== peg$FAILED) {
661
- peg$savedPos = s0;
662
- s1 = peg$c18(s1);
663
- }
664
- s0 = s1;
665
-
666
- return s0;
667
- }
668
-
669
- function peg$parsestringWithoutColon() {
670
- var s0, s1, s2;
671
-
672
- s0 = peg$currPos;
673
- s1 = [];
674
- if (peg$c19.test(input.charAt(peg$currPos))) {
675
- s2 = input.charAt(peg$currPos);
676
- peg$currPos++;
677
- } else {
678
- s2 = peg$FAILED;
679
- if (peg$silentFails === 0) {
680
- peg$fail(peg$c20);
681
- }
682
- }
683
- if (s2 !== peg$FAILED) {
684
- while (s2 !== peg$FAILED) {
685
- s1.push(s2);
574
+ return s0;
575
+ }
576
+ function peg$parsestringWithoutColon() {
577
+ var s0, s1, s2;
578
+ s0 = peg$currPos;
579
+ s1 = [];
686
580
  if (peg$c19.test(input.charAt(peg$currPos))) {
687
- s2 = input.charAt(peg$currPos);
688
- peg$currPos++;
689
- } else {
690
- s2 = peg$FAILED;
691
- if (peg$silentFails === 0) {
692
- peg$fail(peg$c20);
693
- }
694
- }
695
- }
696
- } else {
697
- s1 = peg$FAILED;
698
- }
699
- if (s1 !== peg$FAILED) {
700
- peg$savedPos = s0;
701
- s1 = peg$c18(s1);
702
- }
703
- s0 = s1;
704
-
705
- return s0;
706
- }
707
-
708
- function peg$parsestringWithoutDoubleQuotes() {
709
- var s0, s1, s2;
710
-
711
- s0 = peg$currPos;
712
- s1 = [];
713
- if (peg$c21.test(input.charAt(peg$currPos))) {
714
- s2 = input.charAt(peg$currPos);
715
- peg$currPos++;
716
- } else {
717
- s2 = peg$FAILED;
718
- if (peg$silentFails === 0) {
719
- peg$fail(peg$c22);
720
- }
721
- }
722
- if (s2 !== peg$FAILED) {
723
- while (s2 !== peg$FAILED) {
724
- s1.push(s2);
581
+ s2 = input.charAt(peg$currPos);
582
+ peg$currPos++;
583
+ }
584
+ else {
585
+ s2 = peg$FAILED;
586
+ if (peg$silentFails === 0) {
587
+ peg$fail(peg$c20);
588
+ }
589
+ }
590
+ if (s2 !== peg$FAILED) {
591
+ while (s2 !== peg$FAILED) {
592
+ s1.push(s2);
593
+ if (peg$c19.test(input.charAt(peg$currPos))) {
594
+ s2 = input.charAt(peg$currPos);
595
+ peg$currPos++;
596
+ }
597
+ else {
598
+ s2 = peg$FAILED;
599
+ if (peg$silentFails === 0) {
600
+ peg$fail(peg$c20);
601
+ }
602
+ }
603
+ }
604
+ }
605
+ else {
606
+ s1 = peg$FAILED;
607
+ }
608
+ if (s1 !== peg$FAILED) {
609
+ peg$savedPos = s0;
610
+ s1 = peg$c18(s1);
611
+ }
612
+ s0 = s1;
613
+ return s0;
614
+ }
615
+ function peg$parsestringWithoutDoubleQuotes() {
616
+ var s0, s1, s2;
617
+ s0 = peg$currPos;
618
+ s1 = [];
725
619
  if (peg$c21.test(input.charAt(peg$currPos))) {
726
- s2 = input.charAt(peg$currPos);
727
- peg$currPos++;
728
- } else {
729
- s2 = peg$FAILED;
730
- if (peg$silentFails === 0) {
731
- peg$fail(peg$c22);
732
- }
733
- }
734
- }
735
- } else {
736
- s1 = peg$FAILED;
737
- }
738
- if (s1 !== peg$FAILED) {
739
- peg$savedPos = s0;
740
- s1 = peg$c18(s1);
741
- }
742
- s0 = s1;
743
-
744
- return s0;
745
- }
746
-
747
- function peg$parsestringWithoutSingleQuotes() {
748
- var s0, s1, s2;
749
-
750
- s0 = peg$currPos;
751
- s1 = [];
752
- if (peg$c23.test(input.charAt(peg$currPos))) {
753
- s2 = input.charAt(peg$currPos);
754
- peg$currPos++;
755
- } else {
756
- s2 = peg$FAILED;
757
- if (peg$silentFails === 0) {
758
- peg$fail(peg$c24);
759
- }
760
- }
761
- if (s2 !== peg$FAILED) {
762
- while (s2 !== peg$FAILED) {
763
- s1.push(s2);
620
+ s2 = input.charAt(peg$currPos);
621
+ peg$currPos++;
622
+ }
623
+ else {
624
+ s2 = peg$FAILED;
625
+ if (peg$silentFails === 0) {
626
+ peg$fail(peg$c22);
627
+ }
628
+ }
629
+ if (s2 !== peg$FAILED) {
630
+ while (s2 !== peg$FAILED) {
631
+ s1.push(s2);
632
+ if (peg$c21.test(input.charAt(peg$currPos))) {
633
+ s2 = input.charAt(peg$currPos);
634
+ peg$currPos++;
635
+ }
636
+ else {
637
+ s2 = peg$FAILED;
638
+ if (peg$silentFails === 0) {
639
+ peg$fail(peg$c22);
640
+ }
641
+ }
642
+ }
643
+ }
644
+ else {
645
+ s1 = peg$FAILED;
646
+ }
647
+ if (s1 !== peg$FAILED) {
648
+ peg$savedPos = s0;
649
+ s1 = peg$c18(s1);
650
+ }
651
+ s0 = s1;
652
+ return s0;
653
+ }
654
+ function peg$parsestringWithoutSingleQuotes() {
655
+ var s0, s1, s2;
656
+ s0 = peg$currPos;
657
+ s1 = [];
764
658
  if (peg$c23.test(input.charAt(peg$currPos))) {
765
- s2 = input.charAt(peg$currPos);
766
- peg$currPos++;
767
- } else {
768
- s2 = peg$FAILED;
769
- if (peg$silentFails === 0) {
770
- peg$fail(peg$c24);
771
- }
772
- }
773
- }
774
- } else {
775
- s1 = peg$FAILED;
776
- }
777
- if (s1 !== peg$FAILED) {
778
- peg$savedPos = s0;
779
- s1 = peg$c18(s1);
780
- }
781
- s0 = s1;
782
-
783
- return s0;
784
- }
785
-
786
- function peg$parsestringWithoutSquareBracketsOrDots() {
787
- var s0, s1, s2;
788
-
789
- s0 = peg$currPos;
790
- s1 = [];
791
- if (peg$c25.test(input.charAt(peg$currPos))) {
792
- s2 = input.charAt(peg$currPos);
793
- peg$currPos++;
794
- } else {
795
- s2 = peg$FAILED;
796
- if (peg$silentFails === 0) {
797
- peg$fail(peg$c26);
798
- }
799
- }
800
- if (s2 !== peg$FAILED) {
801
- while (s2 !== peg$FAILED) {
802
- s1.push(s2);
659
+ s2 = input.charAt(peg$currPos);
660
+ peg$currPos++;
661
+ }
662
+ else {
663
+ s2 = peg$FAILED;
664
+ if (peg$silentFails === 0) {
665
+ peg$fail(peg$c24);
666
+ }
667
+ }
668
+ if (s2 !== peg$FAILED) {
669
+ while (s2 !== peg$FAILED) {
670
+ s1.push(s2);
671
+ if (peg$c23.test(input.charAt(peg$currPos))) {
672
+ s2 = input.charAt(peg$currPos);
673
+ peg$currPos++;
674
+ }
675
+ else {
676
+ s2 = peg$FAILED;
677
+ if (peg$silentFails === 0) {
678
+ peg$fail(peg$c24);
679
+ }
680
+ }
681
+ }
682
+ }
683
+ else {
684
+ s1 = peg$FAILED;
685
+ }
686
+ if (s1 !== peg$FAILED) {
687
+ peg$savedPos = s0;
688
+ s1 = peg$c18(s1);
689
+ }
690
+ s0 = s1;
691
+ return s0;
692
+ }
693
+ function peg$parsestringWithoutSquareBracketsOrDots() {
694
+ var s0, s1, s2;
695
+ s0 = peg$currPos;
696
+ s1 = [];
803
697
  if (peg$c25.test(input.charAt(peg$currPos))) {
804
- s2 = input.charAt(peg$currPos);
805
- peg$currPos++;
806
- } else {
807
- s2 = peg$FAILED;
808
- if (peg$silentFails === 0) {
809
- peg$fail(peg$c26);
810
- }
811
- }
812
- }
813
- } else {
814
- s1 = peg$FAILED;
815
- }
816
- if (s1 !== peg$FAILED) {
817
- peg$savedPos = s0;
818
- s1 = peg$c18(s1);
819
- }
820
- s0 = s1;
821
-
822
- return s0;
823
- }
824
-
825
- function peg$parseinteger() {
826
- var s0, s1, s2;
827
-
828
- s0 = peg$currPos;
829
- s1 = [];
830
- if (peg$c27.test(input.charAt(peg$currPos))) {
831
- s2 = input.charAt(peg$currPos);
832
- peg$currPos++;
833
- } else {
834
- s2 = peg$FAILED;
835
- if (peg$silentFails === 0) {
836
- peg$fail(peg$c28);
837
- }
838
- }
839
- if (s2 !== peg$FAILED) {
840
- while (s2 !== peg$FAILED) {
841
- s1.push(s2);
698
+ s2 = input.charAt(peg$currPos);
699
+ peg$currPos++;
700
+ }
701
+ else {
702
+ s2 = peg$FAILED;
703
+ if (peg$silentFails === 0) {
704
+ peg$fail(peg$c26);
705
+ }
706
+ }
707
+ if (s2 !== peg$FAILED) {
708
+ while (s2 !== peg$FAILED) {
709
+ s1.push(s2);
710
+ if (peg$c25.test(input.charAt(peg$currPos))) {
711
+ s2 = input.charAt(peg$currPos);
712
+ peg$currPos++;
713
+ }
714
+ else {
715
+ s2 = peg$FAILED;
716
+ if (peg$silentFails === 0) {
717
+ peg$fail(peg$c26);
718
+ }
719
+ }
720
+ }
721
+ }
722
+ else {
723
+ s1 = peg$FAILED;
724
+ }
725
+ if (s1 !== peg$FAILED) {
726
+ peg$savedPos = s0;
727
+ s1 = peg$c18(s1);
728
+ }
729
+ s0 = s1;
730
+ return s0;
731
+ }
732
+ function peg$parseinteger() {
733
+ var s0, s1, s2;
734
+ s0 = peg$currPos;
735
+ s1 = [];
842
736
  if (peg$c27.test(input.charAt(peg$currPos))) {
843
- s2 = input.charAt(peg$currPos);
844
- peg$currPos++;
845
- } else {
846
- s2 = peg$FAILED;
847
- if (peg$silentFails === 0) {
848
- peg$fail(peg$c28);
849
- }
850
- }
851
- }
852
- } else {
853
- s1 = peg$FAILED;
854
- }
855
- if (s1 !== peg$FAILED) {
856
- peg$savedPos = s0;
857
- s1 = peg$c29(s1);
858
- }
859
- s0 = s1;
860
-
861
- return s0;
862
- }
863
-
864
- peg$result = peg$startRuleFunction();
865
-
866
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
867
- return peg$result;
868
- } else {
869
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
870
- peg$fail(peg$endExpectation());
871
- }
872
-
873
- throw peg$buildStructuredError(
874
- peg$maxFailExpected,
875
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
876
- peg$maxFailPos < input.length
877
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
878
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos),
879
- );
880
- }
737
+ s2 = input.charAt(peg$currPos);
738
+ peg$currPos++;
739
+ }
740
+ else {
741
+ s2 = peg$FAILED;
742
+ if (peg$silentFails === 0) {
743
+ peg$fail(peg$c28);
744
+ }
745
+ }
746
+ if (s2 !== peg$FAILED) {
747
+ while (s2 !== peg$FAILED) {
748
+ s1.push(s2);
749
+ if (peg$c27.test(input.charAt(peg$currPos))) {
750
+ s2 = input.charAt(peg$currPos);
751
+ peg$currPos++;
752
+ }
753
+ else {
754
+ s2 = peg$FAILED;
755
+ if (peg$silentFails === 0) {
756
+ peg$fail(peg$c28);
757
+ }
758
+ }
759
+ }
760
+ }
761
+ else {
762
+ s1 = peg$FAILED;
763
+ }
764
+ if (s1 !== peg$FAILED) {
765
+ peg$savedPos = s0;
766
+ s1 = peg$c29(s1);
767
+ }
768
+ s0 = s1;
769
+ return s0;
770
+ }
771
+ peg$result = peg$startRuleFunction();
772
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
773
+ return peg$result;
774
+ }
775
+ else {
776
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
777
+ peg$fail(peg$endExpectation());
778
+ }
779
+ throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
780
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
781
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
782
+ }
881
783
  }
882
-
883
784
  module.exports = {
884
- SyntaxError: peg$SyntaxError,
885
- parse: peg$parse,
785
+ SyntaxError: peg$SyntaxError,
786
+ parse: peg$parse,
886
787
  };