@dbml/core 2.2.0 → 2.4.0

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 (93) hide show
  1. package/lib/export/DbmlExporter.js +15 -4
  2. package/lib/export/JsonExporter.js +1 -3
  3. package/lib/export/ModelExporter.js +1 -3
  4. package/lib/export/MysqlExporter.js +50 -42
  5. package/lib/export/PostgresExporter.js +64 -49
  6. package/lib/export/SqlServerExporter.js +52 -46
  7. package/lib/model_structure/database.js +73 -28
  8. package/lib/model_structure/dbState.js +1 -3
  9. package/lib/model_structure/element.js +13 -13
  10. package/lib/model_structure/endpoint.js +18 -14
  11. package/lib/model_structure/enum.js +18 -14
  12. package/lib/model_structure/enumValue.js +16 -12
  13. package/lib/model_structure/field.js +47 -13
  14. package/lib/model_structure/indexColumn.js +16 -12
  15. package/lib/model_structure/indexes.js +18 -14
  16. package/lib/model_structure/ref.js +19 -16
  17. package/lib/model_structure/schema.js +24 -36
  18. package/lib/model_structure/table.js +19 -15
  19. package/lib/model_structure/tableGroup.js +18 -14
  20. package/lib/model_structure/utils.js +5 -0
  21. package/lib/parse/Parser.js +2 -4
  22. package/lib/parse/buildParser.js +1 -3
  23. package/lib/parse/dbml/parser.pegjs +64 -20
  24. package/lib/parse/dbmlParser.js +1401 -899
  25. package/lib/parse/mssql/constraint_definition/actions.js +2 -2
  26. package/lib/parse/mssql/fk_definition/actions.js +10 -3
  27. package/lib/parse/mssql/keyword_parsers.js +0 -1
  28. package/lib/parse/mssql/statements/actions.js +9 -6
  29. package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +11 -5
  30. package/lib/parse/mssql/statements/statement_types/create_index/actions.js +6 -1
  31. package/lib/parse/mssql/statements/statement_types/create_table/actions.js +12 -10
  32. package/lib/parse/mssql/utils.js +16 -1
  33. package/lib/parse/mysql/parser.pegjs +57 -34
  34. package/lib/parse/mysqlParser.js +270 -218
  35. package/lib/parse/postgresParser.js +12 -10
  36. package/lib/parse/postgresql/Base_rules.pegjs +45 -10
  37. package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +2 -1
  38. package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +5 -3
  39. package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +1 -1
  40. package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +1 -1
  41. package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +2 -2
  42. package/lib/parse/postgresql/InitializerUtils.pegjs +10 -0
  43. package/lib/parse/postgresql/parser.pegjs +2 -1
  44. package/lib/parse/schemarbParser.js +3 -3
  45. package/package.json +5 -3
  46. package/types/export/ModelExporter.d.ts +5 -0
  47. package/types/export/index.d.ts +5 -0
  48. package/types/import/index.d.ts +5 -0
  49. package/types/index.d.ts +5 -0
  50. package/types/model_structure/database.d.ts +195 -0
  51. package/types/model_structure/dbState.d.ts +14 -0
  52. package/types/model_structure/element.d.ts +21 -0
  53. package/types/model_structure/endpoint.d.ts +55 -0
  54. package/types/model_structure/enum.d.ts +67 -0
  55. package/types/model_structure/enumValue.d.ts +39 -0
  56. package/types/model_structure/field.d.ts +77 -0
  57. package/types/model_structure/indexColumn.d.ts +37 -0
  58. package/types/model_structure/indexes.d.ts +74 -0
  59. package/types/model_structure/ref.d.ts +66 -0
  60. package/types/model_structure/schema.d.ts +188 -0
  61. package/types/model_structure/table.d.ts +118 -0
  62. package/types/model_structure/tableGroup.d.ts +54 -0
  63. package/types/parse/Parser.d.ts +11 -0
  64. package/lib/export/Exporter.js +0 -80
  65. package/lib/export/SchemaExporter.js +0 -99
  66. package/lib/parse/dbml/multiline_content.txt +0 -7
  67. package/lib/parse/dbml/multiline_string.pegjs +0 -17
  68. package/lib/parse/dbml/parser1.json +0 -219
  69. package/lib/parse/dbml/parser1.pegjs +0 -702
  70. package/lib/parse/dbml/parser1_content.txt +0 -29
  71. package/lib/parse/dbml/test_multiline.js +0 -53
  72. package/lib/parse/dbml/test_parser1.js +0 -16
  73. package/lib/parse/mssql/base_utils.js +0 -28
  74. package/lib/parse/mssql/composite_parsers.js +0 -109
  75. package/lib/parse/mssql/statement_types/alter_table/actions.js +0 -29
  76. package/lib/parse/mssql/statement_types/alter_table/add/actions.js +0 -8
  77. package/lib/parse/mssql/statement_types/alter_table/add/index.js +0 -58
  78. package/lib/parse/mssql/statement_types/alter_table/index.js +0 -32
  79. package/lib/parse/mssql/statement_types/create_index/actions.js +0 -25
  80. package/lib/parse/mssql/statement_types/create_index/index.js +0 -50
  81. package/lib/parse/mssql/statement_types/create_table/actions.js +0 -95
  82. package/lib/parse/mssql/statement_types/create_table/index.js +0 -50
  83. package/lib/parse/mssql/statement_types/index.js +0 -13
  84. package/lib/schema/element.js +0 -84
  85. package/lib/schema/endpoint.js +0 -102
  86. package/lib/schema/enum.js +0 -102
  87. package/lib/schema/enumValue.js +0 -70
  88. package/lib/schema/field.js +0 -104
  89. package/lib/schema/indexes.js +0 -74
  90. package/lib/schema/ref.js +0 -93
  91. package/lib/schema/schema.js +0 -245
  92. package/lib/schema/table.js +0 -163
  93. package/lib/schema/tableGroup.js +0 -93
@@ -5,13 +5,23 @@
5
5
  */
6
6
  "use strict";
7
7
 
8
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
8
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
9
 
10
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
11
 
12
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
13
 
14
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
15
+
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
25
 
16
26
  var _ = require("lodash"),
17
27
  pluralize = require("pluralize");
@@ -152,25 +162,12 @@ function peg$parse(input, options) {
152
162
  peg$c3 = peg$literalExpectation("(", false),
153
163
  peg$c4 = ")",
154
164
  peg$c5 = peg$literalExpectation(")", false),
155
- peg$c6 = function peg$c6(name, body) {
165
+ peg$c6 = function peg$c6(table_name, body) {
156
166
  var fields = body.fields;
157
- var indexes = body.indexes; // push inline_ref to refs
158
-
167
+ var indexes = body.indexes;
168
+ var bodyRefs = body.refs;
159
169
  fields.forEach(function (field) {
160
- (field.inline_ref || []).forEach(function (ref) {
161
- var endpoints = [{
162
- tableName: name,
163
- fieldNames: [field.name],
164
- relation: "*" //set by default
165
-
166
- }, ref.endpoint];
167
- refs.push({
168
- endpoints: endpoints,
169
- onUpdate: ref.onUpdate,
170
- onDelete: ref.onDelete
171
- });
172
- }); // process enum: rename enum and push to array `enums`
173
-
170
+ // process enum: rename enum and push to array `enums`
174
171
  if (field.type.type_name.toLowerCase() === 'enum') {
175
172
  var enumValuesArr = field.type.args.split(/[\s\r\n\n]*,[\s\r\n\n]*/);
176
173
  var values = [];
@@ -182,22 +179,26 @@ function peg$parse(input, options) {
182
179
  values.push(enumValue);
183
180
  });
184
181
  var _enum = {
185
- name: "".concat(name, "_").concat(field.name, "_enum"),
182
+ name: "".concat(table_name.schemaName ? "".concat(table_name.schemaName, "_") : '').concat(table_name.name, "_").concat(field.name, "_enum"),
186
183
  values: values
187
184
  };
188
185
  enums.push(_enum);
189
186
  field.type.type_name = _enum.name;
190
187
  }
188
+ });
189
+ bodyRefs.forEach(function (ref) {
190
+ ref.endpoints[0].tableName = table_name.name;
191
+ ref.endpoints[0].schemaName = table_name.schemaName;
192
+ ref.endpoints[0].relation = '*';
193
+ refs.push(ref);
191
194
  }); // return statement
192
195
 
193
- return indexes ? {
194
- name: name,
196
+ return indexes ? _objectSpread(_objectSpread({}, table_name), {}, {
195
197
  fields: fields,
196
198
  indexes: indexes
197
- } : {
198
- name: name,
199
+ }) : _objectSpread(_objectSpread({}, table_name), {}, {
199
200
  fields: fields
200
- };
201
+ });
201
202
  },
202
203
  peg$c7 = function peg$c7(lines) {
203
204
  // classify lines into pk, fk, unique, index and fields
@@ -263,7 +264,8 @@ function peg$parse(input, options) {
263
264
  });
264
265
  return {
265
266
  fields: fields,
266
- indexes: indexes
267
+ indexes: indexes,
268
+ refs: fks
267
269
  };
268
270
  },
269
271
  peg$c8 = peg$otherExpectation("fields"),
@@ -305,7 +307,8 @@ function peg$parse(input, options) {
305
307
  fieldNames: fields,
306
308
  relation: "*"
307
309
  }, {
308
- tableName: table2,
310
+ tableName: table2.name,
311
+ schemaName: table2.schemaName,
309
312
  fieldNames: fields2,
310
313
  relation: "1"
311
314
  }]
@@ -627,7 +630,8 @@ function peg$parse(input, options) {
627
630
  }));
628
631
 
629
632
  fks.forEach(function (fk) {
630
- fk.endpoints[0].tableName = table;
633
+ fk.endpoints[0].tableName = table.name;
634
+ fk.endpoints[0].schemaName = table.schemaName;
631
635
  });
632
636
  refs.push.apply(refs, _toConsumableArray(fks));
633
637
 
@@ -637,9 +641,7 @@ function peg$parse(input, options) {
637
641
  return o.pks;
638
642
  }));
639
643
 
640
- var tableAlter = tables.find(function (t) {
641
- return t.name === table;
642
- });
644
+ var tableAlter = findTable(table.schemaName, table.name);
643
645
  var index = {
644
646
  columns: pks.map(function (field) {
645
647
  return {
@@ -711,9 +713,7 @@ function peg$parse(input, options) {
711
713
  if (constraint.toLowerCase() === "unique") index.unique = true;
712
714
  var type = typeInOption || indexType;
713
715
  if (type) index.type = type;
714
- var table = tables.find(function (table) {
715
- return table.name === tableName;
716
- });
716
+ var table = findTable(tableName.schemaName, tableName.name);
717
717
 
718
718
  if (table.indexes) {
719
719
  table.indexes.push(index);
@@ -863,19 +863,40 @@ function peg$parse(input, options) {
863
863
  },
864
864
  peg$c268 = /^[^`]/,
865
865
  peg$c269 = peg$classExpectation(["`"], true, false),
866
- peg$c270 = peg$otherExpectation("valid table name"),
867
- peg$c271 = ".",
868
- peg$c272 = peg$literalExpectation(".", false),
869
- peg$c273 = peg$otherExpectation("type"),
870
- peg$c274 = function peg$c274(c) {
866
+ peg$c270 = ".",
867
+ peg$c271 = peg$literalExpectation(".", false),
868
+ peg$c272 = function peg$c272(names) {
869
+ var dbName = null;
870
+ var schemaName = null;
871
+
872
+ if (names && names.length > 0) {
873
+ if (names.length === 1) schemaName = names[0][0];else {
874
+ dbName = names[0][0];
875
+ schemaName = names[1][0];
876
+ }
877
+ }
878
+
879
+ return {
880
+ dbName: dbName,
881
+ schemaName: schemaName
882
+ };
883
+ },
884
+ peg$c273 = peg$otherExpectation("valid table name"),
885
+ peg$c274 = function peg$c274(pathName, name) {
886
+ return _objectSpread(_objectSpread({}, pathName), {}, {
887
+ name: name
888
+ });
889
+ },
890
+ peg$c275 = peg$otherExpectation("type"),
891
+ peg$c276 = function peg$c276(c) {
871
892
  return c;
872
893
  },
873
- peg$c275 = function peg$c275(c) {
894
+ peg$c277 = function peg$c277(c) {
874
895
  return {
875
896
  type_name: c
876
897
  };
877
898
  },
878
- peg$c276 = function peg$c276(type_name, args) {
899
+ peg$c278 = function peg$c278(type_name, args) {
879
900
  args = args ? args[2] : null;
880
901
 
881
902
  if (type_name.toLowerCase() !== 'enum') {
@@ -887,67 +908,67 @@ function peg$parse(input, options) {
887
908
  args: args
888
909
  };
889
910
  },
890
- peg$c277 = peg$otherExpectation("expression"),
891
- peg$c278 = function peg$c278(factors) {
911
+ peg$c279 = peg$otherExpectation("expression"),
912
+ peg$c280 = function peg$c280(factors) {
892
913
  return removeReduntdantSpNewline(_.flattenDeep(factors).join(""));
893
914
  },
894
- peg$c279 = ",",
895
- peg$c280 = peg$literalExpectation(",", false),
896
- peg$c281 = ");",
897
- peg$c282 = peg$literalExpectation(");", false),
898
- peg$c283 = function peg$c283(factors) {
915
+ peg$c281 = ",",
916
+ peg$c282 = peg$literalExpectation(",", false),
917
+ peg$c283 = ");",
918
+ peg$c284 = peg$literalExpectation(");", false),
919
+ peg$c285 = function peg$c285(factors) {
899
920
  return _.flattenDeep(factors).join("");
900
921
  },
901
- peg$c284 = /^[',.a-z0-9_+-`%]/i,
902
- peg$c285 = peg$classExpectation(["'", ",", ".", ["a", "z"], ["0", "9"], "_", ["+", "`"], "%"], false, true),
903
- peg$c286 = /^['.a-z0-9_+\-]/i,
904
- peg$c287 = peg$classExpectation(["'", ".", ["a", "z"], ["0", "9"], "_", "+", "-"], false, true),
905
- peg$c288 = peg$otherExpectation("letter, number or underscore"),
906
- peg$c289 = /^[a-z0-9_]/i,
907
- peg$c290 = peg$classExpectation([["a", "z"], ["0", "9"], "_"], false, true),
908
- peg$c291 = " ",
909
- peg$c292 = peg$literalExpectation(" ", false),
910
- peg$c293 = "`",
911
- peg$c294 = peg$literalExpectation("`", false),
912
- peg$c295 = "\t",
913
- peg$c296 = peg$literalExpectation("\t", false),
914
- peg$c297 = peg$otherExpectation("endline"),
915
- peg$c298 = peg$otherExpectation("newline"),
916
- peg$c299 = "\r\n",
917
- peg$c300 = peg$literalExpectation("\r\n", false),
918
- peg$c301 = "\n",
919
- peg$c302 = peg$literalExpectation("\n", false),
920
- peg$c303 = peg$otherExpectation("space"),
921
- peg$c304 = peg$otherExpectation("comment"),
922
- peg$c305 = "--",
923
- peg$c306 = peg$literalExpectation("--", false),
924
- peg$c307 = /^[^\n]/,
925
- peg$c308 = peg$classExpectation(["\n"], true, false),
926
- peg$c309 = "/*",
927
- peg$c310 = peg$literalExpectation("/*", false),
928
- peg$c311 = "*/",
929
- peg$c312 = peg$literalExpectation("*/", false),
930
- peg$c313 = peg$otherExpectation("string"),
931
- peg$c314 = function peg$c314(chars) {
922
+ peg$c286 = /^[',.a-z0-9_+-`%]/i,
923
+ peg$c287 = peg$classExpectation(["'", ",", ".", ["a", "z"], ["0", "9"], "_", ["+", "`"], "%"], false, true),
924
+ peg$c288 = /^['.a-z0-9_+\-]/i,
925
+ peg$c289 = peg$classExpectation(["'", ".", ["a", "z"], ["0", "9"], "_", "+", "-"], false, true),
926
+ peg$c290 = peg$otherExpectation("letter, number or underscore"),
927
+ peg$c291 = /^[a-z0-9_]/i,
928
+ peg$c292 = peg$classExpectation([["a", "z"], ["0", "9"], "_"], false, true),
929
+ peg$c293 = " ",
930
+ peg$c294 = peg$literalExpectation(" ", false),
931
+ peg$c295 = "`",
932
+ peg$c296 = peg$literalExpectation("`", false),
933
+ peg$c297 = "\t",
934
+ peg$c298 = peg$literalExpectation("\t", false),
935
+ peg$c299 = peg$otherExpectation("endline"),
936
+ peg$c300 = peg$otherExpectation("newline"),
937
+ peg$c301 = "\r\n",
938
+ peg$c302 = peg$literalExpectation("\r\n", false),
939
+ peg$c303 = "\n",
940
+ peg$c304 = peg$literalExpectation("\n", false),
941
+ peg$c305 = peg$otherExpectation("space"),
942
+ peg$c306 = peg$otherExpectation("comment"),
943
+ peg$c307 = "--",
944
+ peg$c308 = peg$literalExpectation("--", false),
945
+ peg$c309 = /^[^\n]/,
946
+ peg$c310 = peg$classExpectation(["\n"], true, false),
947
+ peg$c311 = "/*",
948
+ peg$c312 = peg$literalExpectation("/*", false),
949
+ peg$c313 = "*/",
950
+ peg$c314 = peg$literalExpectation("*/", false),
951
+ peg$c315 = peg$otherExpectation("string"),
952
+ peg$c316 = function peg$c316(chars) {
932
953
  return chars.join('');
933
954
  },
934
- peg$c315 = "\\",
935
- peg$c316 = peg$literalExpectation("\\", false),
936
- peg$c317 = function peg$c317() {
955
+ peg$c317 = "\\",
956
+ peg$c318 = peg$literalExpectation("\\", false),
957
+ peg$c319 = function peg$c319() {
937
958
  return '"';
938
959
  },
939
- peg$c318 = function peg$c318() {
960
+ peg$c320 = function peg$c320() {
940
961
  return text();
941
962
  },
942
- peg$c319 = function peg$c319() {
963
+ peg$c321 = function peg$c321() {
943
964
  return "'";
944
965
  },
945
- peg$c320 = /^[0-9]/,
946
- peg$c321 = peg$classExpectation([["0", "9"]], false, false),
947
- peg$c322 = function peg$c322(left, right) {
966
+ peg$c322 = /^[0-9]/,
967
+ peg$c323 = peg$classExpectation([["0", "9"]], false, false),
968
+ peg$c324 = function peg$c324(left, right) {
948
969
  return parseFloat(left.join("") + "." + right.join(""));
949
970
  },
950
- peg$c323 = function peg$c323(digits) {
971
+ peg$c325 = function peg$c325(digits) {
951
972
  return parseInt(digits.join(""), 10);
952
973
  },
953
974
  peg$currPos = 0,
@@ -2405,7 +2426,7 @@ function peg$parse(input, options) {
2405
2426
  }
2406
2427
 
2407
2428
  function peg$parseIndexInLineSyntax() {
2408
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
2429
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
2409
2430
  s0 = peg$currPos;
2410
2431
  s1 = peg$parse_();
2411
2432
 
@@ -2433,56 +2454,63 @@ function peg$parse(input, options) {
2433
2454
  }
2434
2455
 
2435
2456
  if (s6 !== peg$FAILED) {
2436
- if (input.charCodeAt(peg$currPos) === 40) {
2437
- s7 = peg$c2;
2438
- peg$currPos++;
2439
- } else {
2440
- s7 = peg$FAILED;
2441
-
2442
- if (peg$silentFails === 0) {
2443
- peg$fail(peg$c3);
2444
- }
2445
- }
2457
+ s7 = peg$parse_();
2446
2458
 
2447
2459
  if (s7 !== peg$FAILED) {
2448
- s8 = peg$parse_();
2460
+ if (input.charCodeAt(peg$currPos) === 40) {
2461
+ s8 = peg$c2;
2462
+ peg$currPos++;
2463
+ } else {
2464
+ s8 = peg$FAILED;
2465
+
2466
+ if (peg$silentFails === 0) {
2467
+ peg$fail(peg$c3);
2468
+ }
2469
+ }
2449
2470
 
2450
2471
  if (s8 !== peg$FAILED) {
2451
- s9 = peg$parseIndexColumnValues();
2472
+ s9 = peg$parse_();
2452
2473
 
2453
2474
  if (s9 !== peg$FAILED) {
2454
- s10 = peg$parse_();
2475
+ s10 = peg$parseIndexColumnValues();
2455
2476
 
2456
2477
  if (s10 !== peg$FAILED) {
2457
- if (input.charCodeAt(peg$currPos) === 41) {
2458
- s11 = peg$c4;
2459
- peg$currPos++;
2460
- } else {
2461
- s11 = peg$FAILED;
2462
-
2463
- if (peg$silentFails === 0) {
2464
- peg$fail(peg$c5);
2465
- }
2466
- }
2478
+ s11 = peg$parse_();
2467
2479
 
2468
2480
  if (s11 !== peg$FAILED) {
2469
- s12 = peg$parseIndexOption();
2481
+ if (input.charCodeAt(peg$currPos) === 41) {
2482
+ s12 = peg$c4;
2483
+ peg$currPos++;
2484
+ } else {
2485
+ s12 = peg$FAILED;
2470
2486
 
2471
- if (s12 === peg$FAILED) {
2472
- s12 = null;
2487
+ if (peg$silentFails === 0) {
2488
+ peg$fail(peg$c5);
2489
+ }
2473
2490
  }
2474
2491
 
2475
2492
  if (s12 !== peg$FAILED) {
2476
- s13 = peg$parseindex_type();
2493
+ s13 = peg$parseIndexOption();
2477
2494
 
2478
2495
  if (s13 === peg$FAILED) {
2479
2496
  s13 = null;
2480
2497
  }
2481
2498
 
2482
2499
  if (s13 !== peg$FAILED) {
2483
- peg$savedPos = s0;
2484
- s1 = peg$c29(s2, s4, s6, s9, s13);
2485
- s0 = s1;
2500
+ s14 = peg$parseindex_type();
2501
+
2502
+ if (s14 === peg$FAILED) {
2503
+ s14 = null;
2504
+ }
2505
+
2506
+ if (s14 !== peg$FAILED) {
2507
+ peg$savedPos = s0;
2508
+ s1 = peg$c29(s2, s4, s6, s10, s14);
2509
+ s0 = s1;
2510
+ } else {
2511
+ peg$currPos = s0;
2512
+ s0 = peg$FAILED;
2513
+ }
2486
2514
  } else {
2487
2515
  peg$currPos = s0;
2488
2516
  s0 = peg$FAILED;
@@ -5230,7 +5258,7 @@ function peg$parse(input, options) {
5230
5258
  s2 = peg$parse_();
5231
5259
 
5232
5260
  if (s2 !== peg$FAILED) {
5233
- s3 = peg$parsename();
5261
+ s3 = peg$parsetable_name();
5234
5262
 
5235
5263
  if (s3 !== peg$FAILED) {
5236
5264
  s4 = peg$parse_();
@@ -5784,7 +5812,7 @@ function peg$parse(input, options) {
5784
5812
  s6 = peg$parse_();
5785
5813
 
5786
5814
  if (s6 !== peg$FAILED) {
5787
- s7 = peg$parsename();
5815
+ s7 = peg$parsetable_name();
5788
5816
 
5789
5817
  if (s7 !== peg$FAILED) {
5790
5818
  s8 = peg$parse_();
@@ -8495,9 +8523,8 @@ function peg$parse(input, options) {
8495
8523
  return s0;
8496
8524
  }
8497
8525
 
8498
- function peg$parsetable_name() {
8526
+ function peg$parsepath_name() {
8499
8527
  var s0, s1, s2, s3, s4, s5, s6;
8500
- peg$silentFails++;
8501
8528
  s0 = peg$currPos;
8502
8529
  s1 = [];
8503
8530
  s2 = peg$currPos;
@@ -8508,13 +8535,13 @@ function peg$parse(input, options) {
8508
8535
 
8509
8536
  if (s4 !== peg$FAILED) {
8510
8537
  if (input.charCodeAt(peg$currPos) === 46) {
8511
- s5 = peg$c271;
8538
+ s5 = peg$c270;
8512
8539
  peg$currPos++;
8513
8540
  } else {
8514
8541
  s5 = peg$FAILED;
8515
8542
 
8516
8543
  if (peg$silentFails === 0) {
8517
- peg$fail(peg$c272);
8544
+ peg$fail(peg$c271);
8518
8545
  }
8519
8546
  }
8520
8547
 
@@ -8551,13 +8578,13 @@ function peg$parse(input, options) {
8551
8578
 
8552
8579
  if (s4 !== peg$FAILED) {
8553
8580
  if (input.charCodeAt(peg$currPos) === 46) {
8554
- s5 = peg$c271;
8581
+ s5 = peg$c270;
8555
8582
  peg$currPos++;
8556
8583
  } else {
8557
8584
  s5 = peg$FAILED;
8558
8585
 
8559
8586
  if (peg$silentFails === 0) {
8560
- peg$fail(peg$c272);
8587
+ peg$fail(peg$c271);
8561
8588
  }
8562
8589
  }
8563
8590
 
@@ -8585,12 +8612,27 @@ function peg$parse(input, options) {
8585
8612
  }
8586
8613
  }
8587
8614
 
8615
+ if (s1 !== peg$FAILED) {
8616
+ peg$savedPos = s0;
8617
+ s1 = peg$c272(s1);
8618
+ }
8619
+
8620
+ s0 = s1;
8621
+ return s0;
8622
+ }
8623
+
8624
+ function peg$parsetable_name() {
8625
+ var s0, s1, s2;
8626
+ peg$silentFails++;
8627
+ s0 = peg$currPos;
8628
+ s1 = peg$parsepath_name();
8629
+
8588
8630
  if (s1 !== peg$FAILED) {
8589
8631
  s2 = peg$parsename();
8590
8632
 
8591
8633
  if (s2 !== peg$FAILED) {
8592
8634
  peg$savedPos = s0;
8593
- s1 = peg$c28(s2);
8635
+ s1 = peg$c274(s1, s2);
8594
8636
  s0 = s1;
8595
8637
  } else {
8596
8638
  peg$currPos = s0;
@@ -8607,7 +8649,7 @@ function peg$parse(input, options) {
8607
8649
  s1 = peg$FAILED;
8608
8650
 
8609
8651
  if (peg$silentFails === 0) {
8610
- peg$fail(peg$c270);
8652
+ peg$fail(peg$c273);
8611
8653
  }
8612
8654
  }
8613
8655
 
@@ -8622,7 +8664,7 @@ function peg$parse(input, options) {
8622
8664
 
8623
8665
  if (s1 !== peg$FAILED) {
8624
8666
  peg$savedPos = s0;
8625
- s1 = peg$c274(s1);
8667
+ s1 = peg$c276(s1);
8626
8668
  }
8627
8669
 
8628
8670
  s0 = s1;
@@ -8633,7 +8675,7 @@ function peg$parse(input, options) {
8633
8675
 
8634
8676
  if (s1 !== peg$FAILED) {
8635
8677
  peg$savedPos = s0;
8636
- s1 = peg$c275(s1);
8678
+ s1 = peg$c277(s1);
8637
8679
  }
8638
8680
 
8639
8681
  s0 = s1;
@@ -8645,7 +8687,7 @@ function peg$parse(input, options) {
8645
8687
  s1 = peg$FAILED;
8646
8688
 
8647
8689
  if (peg$silentFails === 0) {
8648
- peg$fail(peg$c273);
8690
+ peg$fail(peg$c275);
8649
8691
  }
8650
8692
  }
8651
8693
 
@@ -8725,7 +8767,7 @@ function peg$parse(input, options) {
8725
8767
 
8726
8768
  if (s3 !== peg$FAILED) {
8727
8769
  peg$savedPos = s0;
8728
- s1 = peg$c276(s1, s3);
8770
+ s1 = peg$c278(s1, s3);
8729
8771
  s0 = s1;
8730
8772
  } else {
8731
8773
  peg$currPos = s0;
@@ -8757,7 +8799,7 @@ function peg$parse(input, options) {
8757
8799
 
8758
8800
  if (s1 !== peg$FAILED) {
8759
8801
  peg$savedPos = s0;
8760
- s1 = peg$c278(s1);
8802
+ s1 = peg$c280(s1);
8761
8803
  }
8762
8804
 
8763
8805
  s0 = s1;
@@ -8767,7 +8809,7 @@ function peg$parse(input, options) {
8767
8809
  s1 = peg$FAILED;
8768
8810
 
8769
8811
  if (peg$silentFails === 0) {
8770
- peg$fail(peg$c277);
8812
+ peg$fail(peg$c279);
8771
8813
  }
8772
8814
  }
8773
8815
 
@@ -8910,25 +8952,25 @@ function peg$parse(input, options) {
8910
8952
 
8911
8953
  if (s4 === peg$FAILED) {
8912
8954
  if (input.charCodeAt(peg$currPos) === 44) {
8913
- s4 = peg$c279;
8955
+ s4 = peg$c281;
8914
8956
  peg$currPos++;
8915
8957
  } else {
8916
8958
  s4 = peg$FAILED;
8917
8959
 
8918
8960
  if (peg$silentFails === 0) {
8919
- peg$fail(peg$c280);
8961
+ peg$fail(peg$c282);
8920
8962
  }
8921
8963
  }
8922
8964
 
8923
8965
  if (s4 === peg$FAILED) {
8924
- if (input.substr(peg$currPos, 2) === peg$c281) {
8925
- s4 = peg$c281;
8966
+ if (input.substr(peg$currPos, 2) === peg$c283) {
8967
+ s4 = peg$c283;
8926
8968
  peg$currPos += 2;
8927
8969
  } else {
8928
8970
  s4 = peg$FAILED;
8929
8971
 
8930
8972
  if (peg$silentFails === 0) {
8931
- peg$fail(peg$c282);
8973
+ peg$fail(peg$c284);
8932
8974
  }
8933
8975
  }
8934
8976
 
@@ -8937,14 +8979,14 @@ function peg$parse(input, options) {
8937
8979
  s5 = peg$parseendline();
8938
8980
 
8939
8981
  if (s5 !== peg$FAILED) {
8940
- if (input.substr(peg$currPos, 2) === peg$c281) {
8941
- s6 = peg$c281;
8982
+ if (input.substr(peg$currPos, 2) === peg$c283) {
8983
+ s6 = peg$c283;
8942
8984
  peg$currPos += 2;
8943
8985
  } else {
8944
8986
  s6 = peg$FAILED;
8945
8987
 
8946
8988
  if (peg$silentFails === 0) {
8947
- peg$fail(peg$c282);
8989
+ peg$fail(peg$c284);
8948
8990
  }
8949
8991
  }
8950
8992
 
@@ -9039,7 +9081,7 @@ function peg$parse(input, options) {
9039
9081
 
9040
9082
  if (s1 !== peg$FAILED) {
9041
9083
  peg$savedPos = s0;
9042
- s1 = peg$c283(s1);
9084
+ s1 = peg$c285(s1);
9043
9085
  }
9044
9086
 
9045
9087
  s0 = s1;
@@ -9049,14 +9091,14 @@ function peg$parse(input, options) {
9049
9091
  function peg$parseexprChar() {
9050
9092
  var s0;
9051
9093
 
9052
- if (peg$c284.test(input.charAt(peg$currPos))) {
9094
+ if (peg$c286.test(input.charAt(peg$currPos))) {
9053
9095
  s0 = input.charAt(peg$currPos);
9054
9096
  peg$currPos++;
9055
9097
  } else {
9056
9098
  s0 = peg$FAILED;
9057
9099
 
9058
9100
  if (peg$silentFails === 0) {
9059
- peg$fail(peg$c285);
9101
+ peg$fail(peg$c287);
9060
9102
  }
9061
9103
  }
9062
9104
 
@@ -9078,14 +9120,14 @@ function peg$parse(input, options) {
9078
9120
  function peg$parseexprCharNoCommaSpace() {
9079
9121
  var s0;
9080
9122
 
9081
- if (peg$c286.test(input.charAt(peg$currPos))) {
9123
+ if (peg$c288.test(input.charAt(peg$currPos))) {
9082
9124
  s0 = input.charAt(peg$currPos);
9083
9125
  peg$currPos++;
9084
9126
  } else {
9085
9127
  s0 = peg$FAILED;
9086
9128
 
9087
9129
  if (peg$silentFails === 0) {
9088
- peg$fail(peg$c287);
9130
+ peg$fail(peg$c289);
9089
9131
  }
9090
9132
  }
9091
9133
 
@@ -9096,14 +9138,14 @@ function peg$parse(input, options) {
9096
9138
  var s0, s1;
9097
9139
  peg$silentFails++;
9098
9140
 
9099
- if (peg$c289.test(input.charAt(peg$currPos))) {
9141
+ if (peg$c291.test(input.charAt(peg$currPos))) {
9100
9142
  s0 = input.charAt(peg$currPos);
9101
9143
  peg$currPos++;
9102
9144
  } else {
9103
9145
  s0 = peg$FAILED;
9104
9146
 
9105
9147
  if (peg$silentFails === 0) {
9106
- peg$fail(peg$c290);
9148
+ peg$fail(peg$c292);
9107
9149
  }
9108
9150
  }
9109
9151
 
@@ -9113,7 +9155,7 @@ function peg$parse(input, options) {
9113
9155
  s1 = peg$FAILED;
9114
9156
 
9115
9157
  if (peg$silentFails === 0) {
9116
- peg$fail(peg$c288);
9158
+ peg$fail(peg$c290);
9117
9159
  }
9118
9160
  }
9119
9161
 
@@ -9124,13 +9166,13 @@ function peg$parse(input, options) {
9124
9166
  var s0;
9125
9167
 
9126
9168
  if (input.charCodeAt(peg$currPos) === 32) {
9127
- s0 = peg$c291;
9169
+ s0 = peg$c293;
9128
9170
  peg$currPos++;
9129
9171
  } else {
9130
9172
  s0 = peg$FAILED;
9131
9173
 
9132
9174
  if (peg$silentFails === 0) {
9133
- peg$fail(peg$c292);
9175
+ peg$fail(peg$c294);
9134
9176
  }
9135
9177
  }
9136
9178
 
@@ -9141,13 +9183,13 @@ function peg$parse(input, options) {
9141
9183
  var s0;
9142
9184
 
9143
9185
  if (input.charCodeAt(peg$currPos) === 96) {
9144
- s0 = peg$c293;
9186
+ s0 = peg$c295;
9145
9187
  peg$currPos++;
9146
9188
  } else {
9147
9189
  s0 = peg$FAILED;
9148
9190
 
9149
9191
  if (peg$silentFails === 0) {
9150
- peg$fail(peg$c294);
9192
+ peg$fail(peg$c296);
9151
9193
  }
9152
9194
  }
9153
9195
 
@@ -9171,13 +9213,13 @@ function peg$parse(input, options) {
9171
9213
  var s0;
9172
9214
 
9173
9215
  if (input.charCodeAt(peg$currPos) === 44) {
9174
- s0 = peg$c279;
9216
+ s0 = peg$c281;
9175
9217
  peg$currPos++;
9176
9218
  } else {
9177
9219
  s0 = peg$FAILED;
9178
9220
 
9179
9221
  if (peg$silentFails === 0) {
9180
- peg$fail(peg$c280);
9222
+ peg$fail(peg$c282);
9181
9223
  }
9182
9224
  }
9183
9225
 
@@ -9188,13 +9230,13 @@ function peg$parse(input, options) {
9188
9230
  var s0;
9189
9231
 
9190
9232
  if (input.charCodeAt(peg$currPos) === 9) {
9191
- s0 = peg$c295;
9233
+ s0 = peg$c297;
9192
9234
  peg$currPos++;
9193
9235
  } else {
9194
9236
  s0 = peg$FAILED;
9195
9237
 
9196
9238
  if (peg$silentFails === 0) {
9197
- peg$fail(peg$c296);
9239
+ peg$fail(peg$c298);
9198
9240
  }
9199
9241
  }
9200
9242
 
@@ -9251,7 +9293,7 @@ function peg$parse(input, options) {
9251
9293
  s1 = peg$FAILED;
9252
9294
 
9253
9295
  if (peg$silentFails === 0) {
9254
- peg$fail(peg$c297);
9296
+ peg$fail(peg$c299);
9255
9297
  }
9256
9298
  }
9257
9299
 
@@ -9262,26 +9304,26 @@ function peg$parse(input, options) {
9262
9304
  var s0, s1;
9263
9305
  peg$silentFails++;
9264
9306
 
9265
- if (input.substr(peg$currPos, 2) === peg$c299) {
9266
- s0 = peg$c299;
9307
+ if (input.substr(peg$currPos, 2) === peg$c301) {
9308
+ s0 = peg$c301;
9267
9309
  peg$currPos += 2;
9268
9310
  } else {
9269
9311
  s0 = peg$FAILED;
9270
9312
 
9271
9313
  if (peg$silentFails === 0) {
9272
- peg$fail(peg$c300);
9314
+ peg$fail(peg$c302);
9273
9315
  }
9274
9316
  }
9275
9317
 
9276
9318
  if (s0 === peg$FAILED) {
9277
9319
  if (input.charCodeAt(peg$currPos) === 10) {
9278
- s0 = peg$c301;
9320
+ s0 = peg$c303;
9279
9321
  peg$currPos++;
9280
9322
  } else {
9281
9323
  s0 = peg$FAILED;
9282
9324
 
9283
9325
  if (peg$silentFails === 0) {
9284
- peg$fail(peg$c302);
9326
+ peg$fail(peg$c304);
9285
9327
  }
9286
9328
  }
9287
9329
  }
@@ -9292,7 +9334,7 @@ function peg$parse(input, options) {
9292
9334
  s1 = peg$FAILED;
9293
9335
 
9294
9336
  if (peg$silentFails === 0) {
9295
- peg$fail(peg$c298);
9337
+ peg$fail(peg$c300);
9296
9338
  }
9297
9339
  }
9298
9340
 
@@ -9340,7 +9382,7 @@ function peg$parse(input, options) {
9340
9382
  s1 = peg$FAILED;
9341
9383
 
9342
9384
  if (peg$silentFails === 0) {
9343
- peg$fail(peg$c303);
9385
+ peg$fail(peg$c305);
9344
9386
  }
9345
9387
  }
9346
9388
 
@@ -9392,7 +9434,7 @@ function peg$parse(input, options) {
9392
9434
  s1 = peg$FAILED;
9393
9435
 
9394
9436
  if (peg$silentFails === 0) {
9395
- peg$fail(peg$c303);
9437
+ peg$fail(peg$c305);
9396
9438
  }
9397
9439
  }
9398
9440
 
@@ -9404,42 +9446,42 @@ function peg$parse(input, options) {
9404
9446
  peg$silentFails++;
9405
9447
  s0 = peg$currPos;
9406
9448
 
9407
- if (input.substr(peg$currPos, 2) === peg$c305) {
9408
- s1 = peg$c305;
9449
+ if (input.substr(peg$currPos, 2) === peg$c307) {
9450
+ s1 = peg$c307;
9409
9451
  peg$currPos += 2;
9410
9452
  } else {
9411
9453
  s1 = peg$FAILED;
9412
9454
 
9413
9455
  if (peg$silentFails === 0) {
9414
- peg$fail(peg$c306);
9456
+ peg$fail(peg$c308);
9415
9457
  }
9416
9458
  }
9417
9459
 
9418
9460
  if (s1 !== peg$FAILED) {
9419
9461
  s2 = [];
9420
9462
 
9421
- if (peg$c307.test(input.charAt(peg$currPos))) {
9463
+ if (peg$c309.test(input.charAt(peg$currPos))) {
9422
9464
  s3 = input.charAt(peg$currPos);
9423
9465
  peg$currPos++;
9424
9466
  } else {
9425
9467
  s3 = peg$FAILED;
9426
9468
 
9427
9469
  if (peg$silentFails === 0) {
9428
- peg$fail(peg$c308);
9470
+ peg$fail(peg$c310);
9429
9471
  }
9430
9472
  }
9431
9473
 
9432
9474
  while (s3 !== peg$FAILED) {
9433
9475
  s2.push(s3);
9434
9476
 
9435
- if (peg$c307.test(input.charAt(peg$currPos))) {
9477
+ if (peg$c309.test(input.charAt(peg$currPos))) {
9436
9478
  s3 = input.charAt(peg$currPos);
9437
9479
  peg$currPos++;
9438
9480
  } else {
9439
9481
  s3 = peg$FAILED;
9440
9482
 
9441
9483
  if (peg$silentFails === 0) {
9442
- peg$fail(peg$c308);
9484
+ peg$fail(peg$c310);
9443
9485
  }
9444
9486
  }
9445
9487
  }
@@ -9459,14 +9501,14 @@ function peg$parse(input, options) {
9459
9501
  if (s0 === peg$FAILED) {
9460
9502
  s0 = peg$currPos;
9461
9503
 
9462
- if (input.substr(peg$currPos, 2) === peg$c309) {
9463
- s1 = peg$c309;
9504
+ if (input.substr(peg$currPos, 2) === peg$c311) {
9505
+ s1 = peg$c311;
9464
9506
  peg$currPos += 2;
9465
9507
  } else {
9466
9508
  s1 = peg$FAILED;
9467
9509
 
9468
9510
  if (peg$silentFails === 0) {
9469
- peg$fail(peg$c310);
9511
+ peg$fail(peg$c312);
9470
9512
  }
9471
9513
  }
9472
9514
 
@@ -9476,14 +9518,14 @@ function peg$parse(input, options) {
9476
9518
  s4 = peg$currPos;
9477
9519
  peg$silentFails++;
9478
9520
 
9479
- if (input.substr(peg$currPos, 2) === peg$c311) {
9480
- s5 = peg$c311;
9521
+ if (input.substr(peg$currPos, 2) === peg$c313) {
9522
+ s5 = peg$c313;
9481
9523
  peg$currPos += 2;
9482
9524
  } else {
9483
9525
  s5 = peg$FAILED;
9484
9526
 
9485
9527
  if (peg$silentFails === 0) {
9486
- peg$fail(peg$c312);
9528
+ peg$fail(peg$c314);
9487
9529
  }
9488
9530
  }
9489
9531
 
@@ -9526,14 +9568,14 @@ function peg$parse(input, options) {
9526
9568
  s4 = peg$currPos;
9527
9569
  peg$silentFails++;
9528
9570
 
9529
- if (input.substr(peg$currPos, 2) === peg$c311) {
9530
- s5 = peg$c311;
9571
+ if (input.substr(peg$currPos, 2) === peg$c313) {
9572
+ s5 = peg$c313;
9531
9573
  peg$currPos += 2;
9532
9574
  } else {
9533
9575
  s5 = peg$FAILED;
9534
9576
 
9535
9577
  if (peg$silentFails === 0) {
9536
- peg$fail(peg$c312);
9578
+ peg$fail(peg$c314);
9537
9579
  }
9538
9580
  }
9539
9581
 
@@ -9572,14 +9614,14 @@ function peg$parse(input, options) {
9572
9614
  }
9573
9615
 
9574
9616
  if (s2 !== peg$FAILED) {
9575
- if (input.substr(peg$currPos, 2) === peg$c311) {
9576
- s3 = peg$c311;
9617
+ if (input.substr(peg$currPos, 2) === peg$c313) {
9618
+ s3 = peg$c313;
9577
9619
  peg$currPos += 2;
9578
9620
  } else {
9579
9621
  s3 = peg$FAILED;
9580
9622
 
9581
9623
  if (peg$silentFails === 0) {
9582
- peg$fail(peg$c312);
9624
+ peg$fail(peg$c314);
9583
9625
  }
9584
9626
  }
9585
9627
 
@@ -9617,7 +9659,7 @@ function peg$parse(input, options) {
9617
9659
  s1 = peg$FAILED;
9618
9660
 
9619
9661
  if (peg$silentFails === 0) {
9620
- peg$fail(peg$c304);
9662
+ peg$fail(peg$c306);
9621
9663
  }
9622
9664
  }
9623
9665
 
@@ -9663,7 +9705,7 @@ function peg$parse(input, options) {
9663
9705
 
9664
9706
  if (s3 !== peg$FAILED) {
9665
9707
  peg$savedPos = s0;
9666
- s1 = peg$c314(s2);
9708
+ s1 = peg$c316(s2);
9667
9709
  s0 = s1;
9668
9710
  } else {
9669
9711
  peg$currPos = s0;
@@ -9715,7 +9757,7 @@ function peg$parse(input, options) {
9715
9757
 
9716
9758
  if (s3 !== peg$FAILED) {
9717
9759
  peg$savedPos = s0;
9718
- s1 = peg$c314(s2);
9760
+ s1 = peg$c316(s2);
9719
9761
  s0 = s1;
9720
9762
  } else {
9721
9763
  peg$currPos = s0;
@@ -9737,7 +9779,7 @@ function peg$parse(input, options) {
9737
9779
  s1 = peg$FAILED;
9738
9780
 
9739
9781
  if (peg$silentFails === 0) {
9740
- peg$fail(peg$c313);
9782
+ peg$fail(peg$c315);
9741
9783
  }
9742
9784
  }
9743
9785
 
@@ -9749,13 +9791,13 @@ function peg$parse(input, options) {
9749
9791
  s0 = peg$currPos;
9750
9792
 
9751
9793
  if (input.charCodeAt(peg$currPos) === 92) {
9752
- s1 = peg$c315;
9794
+ s1 = peg$c317;
9753
9795
  peg$currPos++;
9754
9796
  } else {
9755
9797
  s1 = peg$FAILED;
9756
9798
 
9757
9799
  if (peg$silentFails === 0) {
9758
- peg$fail(peg$c316);
9800
+ peg$fail(peg$c318);
9759
9801
  }
9760
9802
  }
9761
9803
 
@@ -9773,7 +9815,7 @@ function peg$parse(input, options) {
9773
9815
 
9774
9816
  if (s2 !== peg$FAILED) {
9775
9817
  peg$savedPos = s0;
9776
- s1 = peg$c317();
9818
+ s1 = peg$c319();
9777
9819
  s0 = s1;
9778
9820
  } else {
9779
9821
  peg$currPos = s0;
@@ -9814,7 +9856,7 @@ function peg$parse(input, options) {
9814
9856
 
9815
9857
  if (s2 !== peg$FAILED) {
9816
9858
  peg$savedPos = s0;
9817
- s1 = peg$c318();
9859
+ s1 = peg$c320();
9818
9860
  s0 = s1;
9819
9861
  } else {
9820
9862
  peg$currPos = s0;
@@ -9834,13 +9876,13 @@ function peg$parse(input, options) {
9834
9876
  s0 = peg$currPos;
9835
9877
 
9836
9878
  if (input.charCodeAt(peg$currPos) === 92) {
9837
- s1 = peg$c315;
9879
+ s1 = peg$c317;
9838
9880
  peg$currPos++;
9839
9881
  } else {
9840
9882
  s1 = peg$FAILED;
9841
9883
 
9842
9884
  if (peg$silentFails === 0) {
9843
- peg$fail(peg$c316);
9885
+ peg$fail(peg$c318);
9844
9886
  }
9845
9887
  }
9846
9888
 
@@ -9858,7 +9900,7 @@ function peg$parse(input, options) {
9858
9900
 
9859
9901
  if (s2 !== peg$FAILED) {
9860
9902
  peg$savedPos = s0;
9861
- s1 = peg$c319();
9903
+ s1 = peg$c321();
9862
9904
  s0 = s1;
9863
9905
  } else {
9864
9906
  peg$currPos = s0;
@@ -9899,7 +9941,7 @@ function peg$parse(input, options) {
9899
9941
 
9900
9942
  if (s2 !== peg$FAILED) {
9901
9943
  peg$savedPos = s0;
9902
- s1 = peg$c318();
9944
+ s1 = peg$c320();
9903
9945
  s0 = s1;
9904
9946
  } else {
9905
9947
  peg$currPos = s0;
@@ -9947,14 +9989,14 @@ function peg$parse(input, options) {
9947
9989
  s0 = peg$currPos;
9948
9990
  s1 = [];
9949
9991
 
9950
- if (peg$c320.test(input.charAt(peg$currPos))) {
9992
+ if (peg$c322.test(input.charAt(peg$currPos))) {
9951
9993
  s2 = input.charAt(peg$currPos);
9952
9994
  peg$currPos++;
9953
9995
  } else {
9954
9996
  s2 = peg$FAILED;
9955
9997
 
9956
9998
  if (peg$silentFails === 0) {
9957
- peg$fail(peg$c321);
9999
+ peg$fail(peg$c323);
9958
10000
  }
9959
10001
  }
9960
10002
 
@@ -9962,14 +10004,14 @@ function peg$parse(input, options) {
9962
10004
  while (s2 !== peg$FAILED) {
9963
10005
  s1.push(s2);
9964
10006
 
9965
- if (peg$c320.test(input.charAt(peg$currPos))) {
10007
+ if (peg$c322.test(input.charAt(peg$currPos))) {
9966
10008
  s2 = input.charAt(peg$currPos);
9967
10009
  peg$currPos++;
9968
10010
  } else {
9969
10011
  s2 = peg$FAILED;
9970
10012
 
9971
10013
  if (peg$silentFails === 0) {
9972
- peg$fail(peg$c321);
10014
+ peg$fail(peg$c323);
9973
10015
  }
9974
10016
  }
9975
10017
  }
@@ -9979,27 +10021,27 @@ function peg$parse(input, options) {
9979
10021
 
9980
10022
  if (s1 !== peg$FAILED) {
9981
10023
  if (input.charCodeAt(peg$currPos) === 46) {
9982
- s2 = peg$c271;
10024
+ s2 = peg$c270;
9983
10025
  peg$currPos++;
9984
10026
  } else {
9985
10027
  s2 = peg$FAILED;
9986
10028
 
9987
10029
  if (peg$silentFails === 0) {
9988
- peg$fail(peg$c272);
10030
+ peg$fail(peg$c271);
9989
10031
  }
9990
10032
  }
9991
10033
 
9992
10034
  if (s2 !== peg$FAILED) {
9993
10035
  s3 = [];
9994
10036
 
9995
- if (peg$c320.test(input.charAt(peg$currPos))) {
10037
+ if (peg$c322.test(input.charAt(peg$currPos))) {
9996
10038
  s4 = input.charAt(peg$currPos);
9997
10039
  peg$currPos++;
9998
10040
  } else {
9999
10041
  s4 = peg$FAILED;
10000
10042
 
10001
10043
  if (peg$silentFails === 0) {
10002
- peg$fail(peg$c321);
10044
+ peg$fail(peg$c323);
10003
10045
  }
10004
10046
  }
10005
10047
 
@@ -10007,14 +10049,14 @@ function peg$parse(input, options) {
10007
10049
  while (s4 !== peg$FAILED) {
10008
10050
  s3.push(s4);
10009
10051
 
10010
- if (peg$c320.test(input.charAt(peg$currPos))) {
10052
+ if (peg$c322.test(input.charAt(peg$currPos))) {
10011
10053
  s4 = input.charAt(peg$currPos);
10012
10054
  peg$currPos++;
10013
10055
  } else {
10014
10056
  s4 = peg$FAILED;
10015
10057
 
10016
10058
  if (peg$silentFails === 0) {
10017
- peg$fail(peg$c321);
10059
+ peg$fail(peg$c323);
10018
10060
  }
10019
10061
  }
10020
10062
  }
@@ -10024,7 +10066,7 @@ function peg$parse(input, options) {
10024
10066
 
10025
10067
  if (s3 !== peg$FAILED) {
10026
10068
  peg$savedPos = s0;
10027
- s1 = peg$c322(s1, s3);
10069
+ s1 = peg$c324(s1, s3);
10028
10070
  s0 = s1;
10029
10071
  } else {
10030
10072
  peg$currPos = s0;
@@ -10047,14 +10089,14 @@ function peg$parse(input, options) {
10047
10089
  s0 = peg$currPos;
10048
10090
  s1 = [];
10049
10091
 
10050
- if (peg$c320.test(input.charAt(peg$currPos))) {
10092
+ if (peg$c322.test(input.charAt(peg$currPos))) {
10051
10093
  s2 = input.charAt(peg$currPos);
10052
10094
  peg$currPos++;
10053
10095
  } else {
10054
10096
  s2 = peg$FAILED;
10055
10097
 
10056
10098
  if (peg$silentFails === 0) {
10057
- peg$fail(peg$c321);
10099
+ peg$fail(peg$c323);
10058
10100
  }
10059
10101
  }
10060
10102
 
@@ -10062,14 +10104,14 @@ function peg$parse(input, options) {
10062
10104
  while (s2 !== peg$FAILED) {
10063
10105
  s1.push(s2);
10064
10106
 
10065
- if (peg$c320.test(input.charAt(peg$currPos))) {
10107
+ if (peg$c322.test(input.charAt(peg$currPos))) {
10066
10108
  s2 = input.charAt(peg$currPos);
10067
10109
  peg$currPos++;
10068
10110
  } else {
10069
10111
  s2 = peg$FAILED;
10070
10112
 
10071
10113
  if (peg$silentFails === 0) {
10072
- peg$fail(peg$c321);
10114
+ peg$fail(peg$c323);
10073
10115
  }
10074
10116
  }
10075
10117
  }
@@ -10079,7 +10121,7 @@ function peg$parse(input, options) {
10079
10121
 
10080
10122
  if (s1 !== peg$FAILED) {
10081
10123
  peg$savedPos = s0;
10082
- s1 = peg$c323(s1);
10124
+ s1 = peg$c325(s1);
10083
10125
  }
10084
10126
 
10085
10127
  s0 = s1;
@@ -10090,7 +10132,16 @@ function peg$parse(input, options) {
10090
10132
 
10091
10133
  var tables = [];
10092
10134
  var refs = [];
10093
- var enums = []; // intput:
10135
+ var enums = []; // TODO: support configurable default schema name other than 'public'
10136
+
10137
+ var findTable = function findTable(schemaName, tableName) {
10138
+ var realSchemaName = schemaName || 'public';
10139
+ var table = tables.find(function (table) {
10140
+ var targetSchemaName = table.schemaName || 'public';
10141
+ return targetSchemaName === realSchemaName && table.name === tableName;
10142
+ });
10143
+ return table;
10144
+ }; // intput:
10094
10145
  // `
10095
10146
  // 'created'
10096
10147
  // ,
@@ -10098,6 +10149,7 @@ function peg$parse(input, options) {
10098
10149
  // `
10099
10150
  // => `'created', 'pending', 'done'`
10100
10151
 
10152
+
10101
10153
  var removeReduntdantSpNewline = function removeReduntdantSpNewline(str) {
10102
10154
  var arr = str.split(/[\s\r\n]*,[\s\r\n]*/); // need to trim spaces and newlines of the first and last element
10103
10155