typespeed 2.0.13 → 2.0.16
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.
- package/dist/core.decorator.js +0 -1
- package/dist/database.decorator.js +0 -1
- package/dist/default/express-server.class.js +0 -1
- package/dist/default/log-default.class.js +0 -1
- package/dist/default/node-cache.class.js +0 -1
- package/dist/default/rabbitmq.class.js +0 -1
- package/dist/default/read-write-db.class.js +0 -1
- package/dist/default/redis.class.js +0 -1
- package/dist/factory/cache-factory.class.js +0 -1
- package/dist/factory/data-source-factory.class.js +0 -1
- package/dist/factory/log-factory.class.js +0 -1
- package/dist/factory/server-factory.class.js +0 -1
- package/dist/route.decorator.js +0 -1
- package/dist/scaffold/command.js +0 -1
- package/dist/typespeed.d.ts +133 -12
- package/dist/typespeed.js +1 -1
- package/package.json +2 -2
- package/src/typespeed.d.ts +133 -0
- package/src/typespeed.ts +2 -1
- package/test/node_modules/.package-lock.json +112 -4
- package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-ci.yml +17 -0
- package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-publish.yml +30 -0
- package/test/node_modules/@acuminous/bitsyntax/LICENSE +6 -0
- package/test/node_modules/@acuminous/bitsyntax/LICENSE-MIT +21 -0
- package/test/node_modules/@acuminous/bitsyntax/Makefile +15 -0
- package/test/node_modules/@acuminous/bitsyntax/README.md +308 -0
- package/test/node_modules/@acuminous/bitsyntax/index.js +10 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/compile.js +303 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/constructor.js +142 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/grammar.pegjs +67 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/interp.js +232 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/parse.js +32 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/parser.js +1173 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/pattern.js +119 -0
- package/test/node_modules/@acuminous/bitsyntax/package.json +36 -0
- package/test/node_modules/@acuminous/bitsyntax/test/consing.test.js +50 -0
- package/test/node_modules/@acuminous/bitsyntax/test/matching.test.js +193 -0
- package/test/node_modules/@types/node/README.md +1 -1
- package/test/node_modules/@types/node/buffer.d.ts +5 -2
- package/test/node_modules/@types/node/child_process.d.ts +27 -0
- package/test/node_modules/@types/node/globals.d.ts +1 -0
- package/test/node_modules/@types/node/package.json +2 -2
- package/test/node_modules/@types/node/test.d.ts +43 -20
- package/test/node_modules/@types/node/ts4.8/buffer.d.ts +5 -2
- package/test/node_modules/@types/node/ts4.8/child_process.d.ts +27 -0
- package/test/node_modules/@types/node/ts4.8/globals.d.ts +1 -0
- package/test/node_modules/@types/node/ts4.8/test.d.ts +43 -19
- package/test/node_modules/@types/node/ts4.8/url.d.ts +3 -3
- package/test/node_modules/@types/node/ts4.8/util.d.ts +1 -1
- package/test/node_modules/@types/node/url.d.ts +3 -3
- package/test/node_modules/@types/node/util.d.ts +1 -1
- package/test/node_modules/amqplib/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/test/node_modules/amqplib/.github/workflows/test.yml +38 -0
- package/test/node_modules/amqplib/CHANGELOG.md +430 -0
- package/test/node_modules/amqplib/LICENSE +6 -0
- package/test/node_modules/amqplib/LICENSE-MIT +21 -0
- package/test/node_modules/amqplib/Makefile +47 -0
- package/test/node_modules/amqplib/README.md +157 -0
- package/test/node_modules/amqplib/bin/generate-defs.js +722 -0
- package/test/node_modules/amqplib/callback_api.js +22 -0
- package/test/node_modules/amqplib/channel_api.js +16 -0
- package/test/node_modules/amqplib/examples/headers.js +42 -0
- package/test/node_modules/amqplib/examples/receive_generator.js +39 -0
- package/test/node_modules/amqplib/examples/send_generators.js +42 -0
- package/test/node_modules/amqplib/examples/ssl.js +64 -0
- package/test/node_modules/amqplib/examples/tutorials/README.md +93 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log.js +28 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_direct.js +30 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_topic.js +27 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/new_task.js +27 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive.js +30 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs.js +36 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_direct.js +56 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_topic.js +55 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_client.js +49 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_server.js +45 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/send.js +29 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/worker.js +35 -0
- package/test/node_modules/amqplib/examples/tutorials/emit_log.js +19 -0
- package/test/node_modules/amqplib/examples/tutorials/emit_log_direct.js +20 -0
- package/test/node_modules/amqplib/examples/tutorials/emit_log_topic.js +19 -0
- package/test/node_modules/amqplib/examples/tutorials/new_task.js +18 -0
- package/test/node_modules/amqplib/examples/tutorials/package.json +16 -0
- package/test/node_modules/amqplib/examples/tutorials/receive.js +21 -0
- package/test/node_modules/amqplib/examples/tutorials/receive_logs.js +28 -0
- package/test/node_modules/amqplib/examples/tutorials/receive_logs_direct.js +44 -0
- package/test/node_modules/amqplib/examples/tutorials/receive_logs_topic.js +43 -0
- package/test/node_modules/amqplib/examples/tutorials/rpc_client.js +52 -0
- package/test/node_modules/amqplib/examples/tutorials/rpc_server.js +39 -0
- package/test/node_modules/amqplib/examples/tutorials/send.js +23 -0
- package/test/node_modules/amqplib/examples/tutorials/worker.js +28 -0
- package/test/node_modules/amqplib/examples/waitForConfirms.js +22 -0
- package/test/node_modules/amqplib/lib/api_args.js +314 -0
- package/test/node_modules/amqplib/lib/bitset.js +130 -0
- package/test/node_modules/amqplib/lib/callback_model.js +327 -0
- package/test/node_modules/amqplib/lib/channel.js +499 -0
- package/test/node_modules/amqplib/lib/channel_model.js +302 -0
- package/test/node_modules/amqplib/lib/codec.js +321 -0
- package/test/node_modules/amqplib/lib/connect.js +189 -0
- package/test/node_modules/amqplib/lib/connection.js +663 -0
- package/test/node_modules/amqplib/lib/credentials.js +42 -0
- package/test/node_modules/amqplib/lib/defs.js +4966 -0
- package/test/node_modules/amqplib/lib/error.js +24 -0
- package/test/node_modules/amqplib/lib/format.js +40 -0
- package/test/node_modules/amqplib/lib/frame.js +113 -0
- package/test/node_modules/amqplib/lib/heartbeat.js +89 -0
- package/test/node_modules/amqplib/lib/mux.js +129 -0
- package/test/node_modules/amqplib/package.json +37 -0
- package/test/node_modules/amqplib/test/bitset.js +69 -0
- package/test/node_modules/amqplib/test/callback_api.js +312 -0
- package/test/node_modules/amqplib/test/channel.js +621 -0
- package/test/node_modules/amqplib/test/channel_api.js +596 -0
- package/test/node_modules/amqplib/test/codec.js +237 -0
- package/test/node_modules/amqplib/test/connect.js +197 -0
- package/test/node_modules/amqplib/test/connection.js +390 -0
- package/test/node_modules/amqplib/test/data.js +254 -0
- package/test/node_modules/amqplib/test/frame.js +198 -0
- package/test/node_modules/amqplib/test/mux.js +204 -0
- package/test/node_modules/amqplib/test/util.js +219 -0
- package/test/node_modules/buffer-more-ints/.travis.yml +6 -0
- package/test/node_modules/buffer-more-ints/LICENSE +19 -0
- package/test/node_modules/buffer-more-ints/README.md +69 -0
- package/test/node_modules/buffer-more-ints/buffer-more-ints-tests.js +183 -0
- package/test/node_modules/buffer-more-ints/buffer-more-ints.js +432 -0
- package/test/node_modules/buffer-more-ints/package.json +19 -0
- package/test/node_modules/buffer-more-ints/polyfill.js +71 -0
- package/test/node_modules/core-util-is/LICENSE +19 -0
- package/test/node_modules/core-util-is/README.md +3 -0
- package/test/node_modules/core-util-is/lib/util.js +107 -0
- package/test/node_modules/core-util-is/package.json +38 -0
- package/test/node_modules/debug/LICENSE +20 -0
- package/test/node_modules/debug/README.md +481 -0
- package/test/node_modules/debug/package.json +59 -0
- package/test/node_modules/debug/src/browser.js +269 -0
- package/test/node_modules/debug/src/common.js +274 -0
- package/test/node_modules/debug/src/index.js +10 -0
- package/test/node_modules/debug/src/node.js +263 -0
- package/test/node_modules/inherits/LICENSE +16 -0
- package/test/node_modules/inherits/README.md +42 -0
- package/test/node_modules/inherits/inherits.js +9 -0
- package/test/node_modules/inherits/inherits_browser.js +27 -0
- package/test/node_modules/inherits/package.json +29 -0
- package/test/node_modules/isarray/README.md +54 -0
- package/test/node_modules/isarray/build/build.js +209 -0
- package/test/node_modules/isarray/component.json +19 -0
- package/test/node_modules/isarray/index.js +3 -0
- package/test/node_modules/isarray/package.json +25 -0
- package/test/node_modules/ms/index.js +162 -0
- package/test/node_modules/ms/license.md +21 -0
- package/test/node_modules/ms/package.json +37 -0
- package/test/node_modules/ms/readme.md +60 -0
- package/test/node_modules/querystringify/LICENSE +22 -0
- package/test/node_modules/querystringify/README.md +61 -0
- package/test/node_modules/querystringify/index.js +118 -0
- package/test/node_modules/querystringify/package.json +38 -0
- package/test/node_modules/readable-stream/LICENSE +18 -0
- package/test/node_modules/readable-stream/README.md +15 -0
- package/test/node_modules/readable-stream/duplex.js +1 -0
- package/test/node_modules/readable-stream/float.patch +923 -0
- package/test/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
- package/test/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
- package/test/node_modules/readable-stream/lib/_stream_readable.js +951 -0
- package/test/node_modules/readable-stream/lib/_stream_transform.js +209 -0
- package/test/node_modules/readable-stream/lib/_stream_writable.js +477 -0
- package/test/node_modules/readable-stream/package.json +32 -0
- package/test/node_modules/readable-stream/passthrough.js +1 -0
- package/test/node_modules/readable-stream/readable.js +10 -0
- package/test/node_modules/readable-stream/transform.js +1 -0
- package/test/node_modules/readable-stream/writable.js +1 -0
- package/test/node_modules/requires-port/.travis.yml +19 -0
- package/test/node_modules/requires-port/LICENSE +22 -0
- package/test/node_modules/requires-port/README.md +47 -0
- package/test/node_modules/requires-port/index.js +38 -0
- package/test/node_modules/requires-port/package.json +47 -0
- package/test/node_modules/requires-port/test.js +98 -0
- package/test/node_modules/safe-buffer/LICENSE +21 -0
- package/test/node_modules/safe-buffer/README.md +584 -0
- package/test/node_modules/safe-buffer/index.d.ts +187 -0
- package/test/node_modules/safe-buffer/index.js +62 -0
- package/test/node_modules/safe-buffer/package.json +37 -0
- package/test/node_modules/string_decoder/LICENSE +20 -0
- package/test/node_modules/string_decoder/README.md +7 -0
- package/test/node_modules/string_decoder/index.js +221 -0
- package/test/node_modules/string_decoder/package.json +25 -0
- package/test/node_modules/url-parse/LICENSE +22 -0
- package/test/node_modules/url-parse/README.md +153 -0
- package/test/node_modules/url-parse/dist/url-parse.js +755 -0
- package/test/node_modules/url-parse/dist/url-parse.min.js +1 -0
- package/test/node_modules/url-parse/dist/url-parse.min.js.map +1 -0
- package/test/node_modules/url-parse/index.js +589 -0
- package/test/node_modules/url-parse/package.json +49 -0
- package/test/src/test-mq.class.ts +1 -2
- package/tsconfig.json +4 -3
- package/dist/core.decorator.d.ts +0 -18
- package/dist/core.decorator.js.map +0 -1
- package/dist/database.decorator.d.ts +0 -24
- package/dist/database.decorator.js.map +0 -1
- package/dist/default/express-server.class.d.ts +0 -15
- package/dist/default/express-server.class.js.map +0 -1
- package/dist/default/log-default.class.d.ts +0 -6
- package/dist/default/log-default.class.js.map +0 -1
- package/dist/default/node-cache.class.d.ts +0 -13
- package/dist/default/node-cache.class.js.map +0 -1
- package/dist/default/rabbitmq.class.d.ts +0 -9
- package/dist/default/rabbitmq.class.js.map +0 -1
- package/dist/default/read-write-db.class.d.ts +0 -10
- package/dist/default/read-write-db.class.js.map +0 -1
- package/dist/default/redis.class.d.ts +0 -5
- package/dist/default/redis.class.js.map +0 -1
- package/dist/factory/cache-factory.class.d.ts +0 -7
- package/dist/factory/cache-factory.class.js.map +0 -1
- package/dist/factory/data-source-factory.class.d.ts +0 -4
- package/dist/factory/data-source-factory.class.js.map +0 -1
- package/dist/factory/log-factory.class.d.ts +0 -4
- package/dist/factory/log-factory.class.js.map +0 -1
- package/dist/factory/server-factory.class.d.ts +0 -6
- package/dist/factory/server-factory.class.js.map +0 -1
- package/dist/route.decorator.d.ts +0 -8
- package/dist/route.decorator.js.map +0 -1
- package/dist/scaffold/command.d.ts +0 -2
- package/dist/scaffold/command.js.map +0 -1
- package/dist/typespeed.js.map +0 -1
|
@@ -0,0 +1,1173 @@
|
|
|
1
|
+
module.exports = (function(){
|
|
2
|
+
/*
|
|
3
|
+
* Generated by PEG.js 0.7.0.
|
|
4
|
+
*
|
|
5
|
+
* http://pegjs.majda.cz/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function quote(s) {
|
|
9
|
+
/*
|
|
10
|
+
* ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
|
|
11
|
+
* string literal except for the closing quote character, backslash,
|
|
12
|
+
* carriage return, line separator, paragraph separator, and line feed.
|
|
13
|
+
* Any character may appear in the form of an escape sequence.
|
|
14
|
+
*
|
|
15
|
+
* For portability, we also escape escape all control and non-ASCII
|
|
16
|
+
* characters. Note that "\0" and "\v" escape sequences are not used
|
|
17
|
+
* because JSHint does not like the first and IE the second.
|
|
18
|
+
*/
|
|
19
|
+
return '"' + s
|
|
20
|
+
.replace(/\\/g, '\\\\') // backslash
|
|
21
|
+
.replace(/"/g, '\\"') // closing quote character
|
|
22
|
+
.replace(/\x08/g, '\\b') // backspace
|
|
23
|
+
.replace(/\t/g, '\\t') // horizontal tab
|
|
24
|
+
.replace(/\n/g, '\\n') // line feed
|
|
25
|
+
.replace(/\f/g, '\\f') // form feed
|
|
26
|
+
.replace(/\r/g, '\\r') // carriage return
|
|
27
|
+
.replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
|
|
28
|
+
+ '"';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var result = {
|
|
32
|
+
/*
|
|
33
|
+
* Parses the input with a generated parser. If the parsing is successfull,
|
|
34
|
+
* returns a value explicitly or implicitly specified by the grammar from
|
|
35
|
+
* which the parser was generated (see |PEG.buildParser|). If the parsing is
|
|
36
|
+
* unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
|
|
37
|
+
*/
|
|
38
|
+
parse: function(input, startRule) {
|
|
39
|
+
var parseFunctions = {
|
|
40
|
+
"start": parse_start,
|
|
41
|
+
"segmentTail": parse_segmentTail,
|
|
42
|
+
"segment": parse_segment,
|
|
43
|
+
"string": parse_string,
|
|
44
|
+
"chars": parse_chars,
|
|
45
|
+
"char": parse_char,
|
|
46
|
+
"hexDigit": parse_hexDigit,
|
|
47
|
+
"identifier": parse_identifier,
|
|
48
|
+
"number": parse_number,
|
|
49
|
+
"size": parse_size,
|
|
50
|
+
"specifierList": parse_specifierList,
|
|
51
|
+
"specifierTail": parse_specifierTail,
|
|
52
|
+
"specifier": parse_specifier,
|
|
53
|
+
"unit": parse_unit,
|
|
54
|
+
"ws": parse_ws
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (startRule !== undefined) {
|
|
58
|
+
if (parseFunctions[startRule] === undefined) {
|
|
59
|
+
throw new Error("Invalid rule name: " + quote(startRule) + ".");
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
startRule = "start";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var pos = 0;
|
|
66
|
+
var reportFailures = 0;
|
|
67
|
+
var rightmostFailuresPos = 0;
|
|
68
|
+
var rightmostFailuresExpected = [];
|
|
69
|
+
|
|
70
|
+
function padLeft(input, padding, length) {
|
|
71
|
+
var result = input;
|
|
72
|
+
|
|
73
|
+
var padLength = length - input.length;
|
|
74
|
+
for (var i = 0; i < padLength; i++) {
|
|
75
|
+
result = padding + result;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function escape(ch) {
|
|
82
|
+
var charCode = ch.charCodeAt(0);
|
|
83
|
+
var escapeChar;
|
|
84
|
+
var length;
|
|
85
|
+
|
|
86
|
+
if (charCode <= 0xFF) {
|
|
87
|
+
escapeChar = 'x';
|
|
88
|
+
length = 2;
|
|
89
|
+
} else {
|
|
90
|
+
escapeChar = 'u';
|
|
91
|
+
length = 4;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function matchFailed(failure) {
|
|
98
|
+
if (pos < rightmostFailuresPos) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (pos > rightmostFailuresPos) {
|
|
103
|
+
rightmostFailuresPos = pos;
|
|
104
|
+
rightmostFailuresExpected = [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
rightmostFailuresExpected.push(failure);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function parse_start() {
|
|
111
|
+
var result0, result1, result2, result3;
|
|
112
|
+
var pos0, pos1;
|
|
113
|
+
|
|
114
|
+
pos0 = pos;
|
|
115
|
+
pos1 = pos;
|
|
116
|
+
result0 = parse_ws();
|
|
117
|
+
if (result0 !== null) {
|
|
118
|
+
result1 = parse_segment();
|
|
119
|
+
if (result1 !== null) {
|
|
120
|
+
result2 = [];
|
|
121
|
+
result3 = parse_segmentTail();
|
|
122
|
+
while (result3 !== null) {
|
|
123
|
+
result2.push(result3);
|
|
124
|
+
result3 = parse_segmentTail();
|
|
125
|
+
}
|
|
126
|
+
if (result2 !== null) {
|
|
127
|
+
result0 = [result0, result1, result2];
|
|
128
|
+
} else {
|
|
129
|
+
result0 = null;
|
|
130
|
+
pos = pos1;
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
result0 = null;
|
|
134
|
+
pos = pos1;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
result0 = null;
|
|
138
|
+
pos = pos1;
|
|
139
|
+
}
|
|
140
|
+
if (result0 !== null) {
|
|
141
|
+
result0 = (function(offset, head, tail) { tail.unshift(head); return tail; })(pos0, result0[1], result0[2]);
|
|
142
|
+
}
|
|
143
|
+
if (result0 === null) {
|
|
144
|
+
pos = pos0;
|
|
145
|
+
}
|
|
146
|
+
return result0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function parse_segmentTail() {
|
|
150
|
+
var result0, result1, result2, result3;
|
|
151
|
+
var pos0, pos1;
|
|
152
|
+
|
|
153
|
+
pos0 = pos;
|
|
154
|
+
pos1 = pos;
|
|
155
|
+
result0 = parse_ws();
|
|
156
|
+
if (result0 !== null) {
|
|
157
|
+
if (input.charCodeAt(pos) === 44) {
|
|
158
|
+
result1 = ",";
|
|
159
|
+
pos++;
|
|
160
|
+
} else {
|
|
161
|
+
result1 = null;
|
|
162
|
+
if (reportFailures === 0) {
|
|
163
|
+
matchFailed("\",\"");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (result1 !== null) {
|
|
167
|
+
result2 = parse_ws();
|
|
168
|
+
if (result2 !== null) {
|
|
169
|
+
result3 = parse_segment();
|
|
170
|
+
if (result3 !== null) {
|
|
171
|
+
result0 = [result0, result1, result2, result3];
|
|
172
|
+
} else {
|
|
173
|
+
result0 = null;
|
|
174
|
+
pos = pos1;
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
result0 = null;
|
|
178
|
+
pos = pos1;
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
result0 = null;
|
|
182
|
+
pos = pos1;
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
result0 = null;
|
|
186
|
+
pos = pos1;
|
|
187
|
+
}
|
|
188
|
+
if (result0 !== null) {
|
|
189
|
+
result0 = (function(offset, seg) { return seg; })(pos0, result0[3]);
|
|
190
|
+
}
|
|
191
|
+
if (result0 === null) {
|
|
192
|
+
pos = pos0;
|
|
193
|
+
}
|
|
194
|
+
return result0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function parse_segment() {
|
|
198
|
+
var result0, result1, result2;
|
|
199
|
+
var pos0, pos1;
|
|
200
|
+
|
|
201
|
+
pos0 = pos;
|
|
202
|
+
result0 = parse_string();
|
|
203
|
+
if (result0 !== null) {
|
|
204
|
+
result0 = (function(offset, str) { return {string: str}; })(pos0, result0);
|
|
205
|
+
}
|
|
206
|
+
if (result0 === null) {
|
|
207
|
+
pos = pos0;
|
|
208
|
+
}
|
|
209
|
+
if (result0 === null) {
|
|
210
|
+
pos0 = pos;
|
|
211
|
+
pos1 = pos;
|
|
212
|
+
result0 = parse_identifier();
|
|
213
|
+
if (result0 !== null) {
|
|
214
|
+
result1 = parse_size();
|
|
215
|
+
result1 = result1 !== null ? result1 : "";
|
|
216
|
+
if (result1 !== null) {
|
|
217
|
+
result2 = parse_specifierList();
|
|
218
|
+
result2 = result2 !== null ? result2 : "";
|
|
219
|
+
if (result2 !== null) {
|
|
220
|
+
result0 = [result0, result1, result2];
|
|
221
|
+
} else {
|
|
222
|
+
result0 = null;
|
|
223
|
+
pos = pos1;
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
result0 = null;
|
|
227
|
+
pos = pos1;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
result0 = null;
|
|
231
|
+
pos = pos1;
|
|
232
|
+
}
|
|
233
|
+
if (result0 !== null) {
|
|
234
|
+
result0 = (function(offset, v, size, specs) { return {name: v, size: size, specifiers: specs}; })(pos0, result0[0], result0[1], result0[2]);
|
|
235
|
+
}
|
|
236
|
+
if (result0 === null) {
|
|
237
|
+
pos = pos0;
|
|
238
|
+
}
|
|
239
|
+
if (result0 === null) {
|
|
240
|
+
pos0 = pos;
|
|
241
|
+
pos1 = pos;
|
|
242
|
+
result0 = parse_number();
|
|
243
|
+
if (result0 !== null) {
|
|
244
|
+
result1 = parse_size();
|
|
245
|
+
result1 = result1 !== null ? result1 : "";
|
|
246
|
+
if (result1 !== null) {
|
|
247
|
+
result2 = parse_specifierList();
|
|
248
|
+
result2 = result2 !== null ? result2 : "";
|
|
249
|
+
if (result2 !== null) {
|
|
250
|
+
result0 = [result0, result1, result2];
|
|
251
|
+
} else {
|
|
252
|
+
result0 = null;
|
|
253
|
+
pos = pos1;
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
result0 = null;
|
|
257
|
+
pos = pos1;
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
result0 = null;
|
|
261
|
+
pos = pos1;
|
|
262
|
+
}
|
|
263
|
+
if (result0 !== null) {
|
|
264
|
+
result0 = (function(offset, v, size, specs) { return {value: v, size: size, specifiers: specs}; })(pos0, result0[0], result0[1], result0[2]);
|
|
265
|
+
}
|
|
266
|
+
if (result0 === null) {
|
|
267
|
+
pos = pos0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return result0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function parse_string() {
|
|
275
|
+
var result0, result1, result2;
|
|
276
|
+
var pos0, pos1;
|
|
277
|
+
|
|
278
|
+
pos0 = pos;
|
|
279
|
+
pos1 = pos;
|
|
280
|
+
if (input.charCodeAt(pos) === 34) {
|
|
281
|
+
result0 = "\"";
|
|
282
|
+
pos++;
|
|
283
|
+
} else {
|
|
284
|
+
result0 = null;
|
|
285
|
+
if (reportFailures === 0) {
|
|
286
|
+
matchFailed("\"\\\"\"");
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (result0 !== null) {
|
|
290
|
+
if (input.charCodeAt(pos) === 34) {
|
|
291
|
+
result1 = "\"";
|
|
292
|
+
pos++;
|
|
293
|
+
} else {
|
|
294
|
+
result1 = null;
|
|
295
|
+
if (reportFailures === 0) {
|
|
296
|
+
matchFailed("\"\\\"\"");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (result1 !== null) {
|
|
300
|
+
result0 = [result0, result1];
|
|
301
|
+
} else {
|
|
302
|
+
result0 = null;
|
|
303
|
+
pos = pos1;
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
result0 = null;
|
|
307
|
+
pos = pos1;
|
|
308
|
+
}
|
|
309
|
+
if (result0 !== null) {
|
|
310
|
+
result0 = (function(offset) { return ""; })(pos0);
|
|
311
|
+
}
|
|
312
|
+
if (result0 === null) {
|
|
313
|
+
pos = pos0;
|
|
314
|
+
}
|
|
315
|
+
if (result0 === null) {
|
|
316
|
+
pos0 = pos;
|
|
317
|
+
pos1 = pos;
|
|
318
|
+
if (input.charCodeAt(pos) === 34) {
|
|
319
|
+
result0 = "\"";
|
|
320
|
+
pos++;
|
|
321
|
+
} else {
|
|
322
|
+
result0 = null;
|
|
323
|
+
if (reportFailures === 0) {
|
|
324
|
+
matchFailed("\"\\\"\"");
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (result0 !== null) {
|
|
328
|
+
result1 = parse_chars();
|
|
329
|
+
if (result1 !== null) {
|
|
330
|
+
if (input.charCodeAt(pos) === 34) {
|
|
331
|
+
result2 = "\"";
|
|
332
|
+
pos++;
|
|
333
|
+
} else {
|
|
334
|
+
result2 = null;
|
|
335
|
+
if (reportFailures === 0) {
|
|
336
|
+
matchFailed("\"\\\"\"");
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (result2 !== null) {
|
|
340
|
+
result0 = [result0, result1, result2];
|
|
341
|
+
} else {
|
|
342
|
+
result0 = null;
|
|
343
|
+
pos = pos1;
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
result0 = null;
|
|
347
|
+
pos = pos1;
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
result0 = null;
|
|
351
|
+
pos = pos1;
|
|
352
|
+
}
|
|
353
|
+
if (result0 !== null) {
|
|
354
|
+
result0 = (function(offset, chars) { return chars; })(pos0, result0[1]);
|
|
355
|
+
}
|
|
356
|
+
if (result0 === null) {
|
|
357
|
+
pos = pos0;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return result0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function parse_chars() {
|
|
364
|
+
var result0, result1;
|
|
365
|
+
var pos0;
|
|
366
|
+
|
|
367
|
+
pos0 = pos;
|
|
368
|
+
result1 = parse_char();
|
|
369
|
+
if (result1 !== null) {
|
|
370
|
+
result0 = [];
|
|
371
|
+
while (result1 !== null) {
|
|
372
|
+
result0.push(result1);
|
|
373
|
+
result1 = parse_char();
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
result0 = null;
|
|
377
|
+
}
|
|
378
|
+
if (result0 !== null) {
|
|
379
|
+
result0 = (function(offset, chars) { return chars.join(""); })(pos0, result0);
|
|
380
|
+
}
|
|
381
|
+
if (result0 === null) {
|
|
382
|
+
pos = pos0;
|
|
383
|
+
}
|
|
384
|
+
return result0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function parse_char() {
|
|
388
|
+
var result0, result1, result2, result3, result4;
|
|
389
|
+
var pos0, pos1;
|
|
390
|
+
|
|
391
|
+
if (/^[^"\\\0-\x1F]/.test(input.charAt(pos))) {
|
|
392
|
+
result0 = input.charAt(pos);
|
|
393
|
+
pos++;
|
|
394
|
+
} else {
|
|
395
|
+
result0 = null;
|
|
396
|
+
if (reportFailures === 0) {
|
|
397
|
+
matchFailed("[^\"\\\\\\0-\\x1F]");
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (result0 === null) {
|
|
401
|
+
pos0 = pos;
|
|
402
|
+
if (input.substr(pos, 2) === "\\\"") {
|
|
403
|
+
result0 = "\\\"";
|
|
404
|
+
pos += 2;
|
|
405
|
+
} else {
|
|
406
|
+
result0 = null;
|
|
407
|
+
if (reportFailures === 0) {
|
|
408
|
+
matchFailed("\"\\\\\\\"\"");
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (result0 !== null) {
|
|
412
|
+
result0 = (function(offset) { return '"'; })(pos0);
|
|
413
|
+
}
|
|
414
|
+
if (result0 === null) {
|
|
415
|
+
pos = pos0;
|
|
416
|
+
}
|
|
417
|
+
if (result0 === null) {
|
|
418
|
+
pos0 = pos;
|
|
419
|
+
if (input.substr(pos, 2) === "\\\\") {
|
|
420
|
+
result0 = "\\\\";
|
|
421
|
+
pos += 2;
|
|
422
|
+
} else {
|
|
423
|
+
result0 = null;
|
|
424
|
+
if (reportFailures === 0) {
|
|
425
|
+
matchFailed("\"\\\\\\\\\"");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (result0 !== null) {
|
|
429
|
+
result0 = (function(offset) { return "\\"; })(pos0);
|
|
430
|
+
}
|
|
431
|
+
if (result0 === null) {
|
|
432
|
+
pos = pos0;
|
|
433
|
+
}
|
|
434
|
+
if (result0 === null) {
|
|
435
|
+
pos0 = pos;
|
|
436
|
+
if (input.substr(pos, 2) === "\\/") {
|
|
437
|
+
result0 = "\\/";
|
|
438
|
+
pos += 2;
|
|
439
|
+
} else {
|
|
440
|
+
result0 = null;
|
|
441
|
+
if (reportFailures === 0) {
|
|
442
|
+
matchFailed("\"\\\\/\"");
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (result0 !== null) {
|
|
446
|
+
result0 = (function(offset) { return "/"; })(pos0);
|
|
447
|
+
}
|
|
448
|
+
if (result0 === null) {
|
|
449
|
+
pos = pos0;
|
|
450
|
+
}
|
|
451
|
+
if (result0 === null) {
|
|
452
|
+
pos0 = pos;
|
|
453
|
+
if (input.substr(pos, 2) === "\\b") {
|
|
454
|
+
result0 = "\\b";
|
|
455
|
+
pos += 2;
|
|
456
|
+
} else {
|
|
457
|
+
result0 = null;
|
|
458
|
+
if (reportFailures === 0) {
|
|
459
|
+
matchFailed("\"\\\\b\"");
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (result0 !== null) {
|
|
463
|
+
result0 = (function(offset) { return "\b"; })(pos0);
|
|
464
|
+
}
|
|
465
|
+
if (result0 === null) {
|
|
466
|
+
pos = pos0;
|
|
467
|
+
}
|
|
468
|
+
if (result0 === null) {
|
|
469
|
+
pos0 = pos;
|
|
470
|
+
if (input.substr(pos, 2) === "\\f") {
|
|
471
|
+
result0 = "\\f";
|
|
472
|
+
pos += 2;
|
|
473
|
+
} else {
|
|
474
|
+
result0 = null;
|
|
475
|
+
if (reportFailures === 0) {
|
|
476
|
+
matchFailed("\"\\\\f\"");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (result0 !== null) {
|
|
480
|
+
result0 = (function(offset) { return "\f"; })(pos0);
|
|
481
|
+
}
|
|
482
|
+
if (result0 === null) {
|
|
483
|
+
pos = pos0;
|
|
484
|
+
}
|
|
485
|
+
if (result0 === null) {
|
|
486
|
+
pos0 = pos;
|
|
487
|
+
if (input.substr(pos, 2) === "\\n") {
|
|
488
|
+
result0 = "\\n";
|
|
489
|
+
pos += 2;
|
|
490
|
+
} else {
|
|
491
|
+
result0 = null;
|
|
492
|
+
if (reportFailures === 0) {
|
|
493
|
+
matchFailed("\"\\\\n\"");
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (result0 !== null) {
|
|
497
|
+
result0 = (function(offset) { return "\n"; })(pos0);
|
|
498
|
+
}
|
|
499
|
+
if (result0 === null) {
|
|
500
|
+
pos = pos0;
|
|
501
|
+
}
|
|
502
|
+
if (result0 === null) {
|
|
503
|
+
pos0 = pos;
|
|
504
|
+
if (input.substr(pos, 2) === "\\r") {
|
|
505
|
+
result0 = "\\r";
|
|
506
|
+
pos += 2;
|
|
507
|
+
} else {
|
|
508
|
+
result0 = null;
|
|
509
|
+
if (reportFailures === 0) {
|
|
510
|
+
matchFailed("\"\\\\r\"");
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (result0 !== null) {
|
|
514
|
+
result0 = (function(offset) { return "\r"; })(pos0);
|
|
515
|
+
}
|
|
516
|
+
if (result0 === null) {
|
|
517
|
+
pos = pos0;
|
|
518
|
+
}
|
|
519
|
+
if (result0 === null) {
|
|
520
|
+
pos0 = pos;
|
|
521
|
+
if (input.substr(pos, 2) === "\\t") {
|
|
522
|
+
result0 = "\\t";
|
|
523
|
+
pos += 2;
|
|
524
|
+
} else {
|
|
525
|
+
result0 = null;
|
|
526
|
+
if (reportFailures === 0) {
|
|
527
|
+
matchFailed("\"\\\\t\"");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (result0 !== null) {
|
|
531
|
+
result0 = (function(offset) { return "\t"; })(pos0);
|
|
532
|
+
}
|
|
533
|
+
if (result0 === null) {
|
|
534
|
+
pos = pos0;
|
|
535
|
+
}
|
|
536
|
+
if (result0 === null) {
|
|
537
|
+
pos0 = pos;
|
|
538
|
+
pos1 = pos;
|
|
539
|
+
if (input.substr(pos, 2) === "\\u") {
|
|
540
|
+
result0 = "\\u";
|
|
541
|
+
pos += 2;
|
|
542
|
+
} else {
|
|
543
|
+
result0 = null;
|
|
544
|
+
if (reportFailures === 0) {
|
|
545
|
+
matchFailed("\"\\\\u\"");
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (result0 !== null) {
|
|
549
|
+
result1 = parse_hexDigit();
|
|
550
|
+
if (result1 !== null) {
|
|
551
|
+
result2 = parse_hexDigit();
|
|
552
|
+
if (result2 !== null) {
|
|
553
|
+
result3 = parse_hexDigit();
|
|
554
|
+
if (result3 !== null) {
|
|
555
|
+
result4 = parse_hexDigit();
|
|
556
|
+
if (result4 !== null) {
|
|
557
|
+
result0 = [result0, result1, result2, result3, result4];
|
|
558
|
+
} else {
|
|
559
|
+
result0 = null;
|
|
560
|
+
pos = pos1;
|
|
561
|
+
}
|
|
562
|
+
} else {
|
|
563
|
+
result0 = null;
|
|
564
|
+
pos = pos1;
|
|
565
|
+
}
|
|
566
|
+
} else {
|
|
567
|
+
result0 = null;
|
|
568
|
+
pos = pos1;
|
|
569
|
+
}
|
|
570
|
+
} else {
|
|
571
|
+
result0 = null;
|
|
572
|
+
pos = pos1;
|
|
573
|
+
}
|
|
574
|
+
} else {
|
|
575
|
+
result0 = null;
|
|
576
|
+
pos = pos1;
|
|
577
|
+
}
|
|
578
|
+
if (result0 !== null) {
|
|
579
|
+
result0 = (function(offset, h1, h2, h3, h4) {
|
|
580
|
+
return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4));
|
|
581
|
+
})(pos0, result0[1], result0[2], result0[3], result0[4]);
|
|
582
|
+
}
|
|
583
|
+
if (result0 === null) {
|
|
584
|
+
pos = pos0;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return result0;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function parse_hexDigit() {
|
|
599
|
+
var result0;
|
|
600
|
+
|
|
601
|
+
if (/^[0-9a-fA-F]/.test(input.charAt(pos))) {
|
|
602
|
+
result0 = input.charAt(pos);
|
|
603
|
+
pos++;
|
|
604
|
+
} else {
|
|
605
|
+
result0 = null;
|
|
606
|
+
if (reportFailures === 0) {
|
|
607
|
+
matchFailed("[0-9a-fA-F]");
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return result0;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function parse_identifier() {
|
|
614
|
+
var result0, result1, result2;
|
|
615
|
+
var pos0, pos1;
|
|
616
|
+
|
|
617
|
+
pos0 = pos;
|
|
618
|
+
pos1 = pos;
|
|
619
|
+
if (/^[_a-zA-Z]/.test(input.charAt(pos))) {
|
|
620
|
+
result0 = input.charAt(pos);
|
|
621
|
+
pos++;
|
|
622
|
+
} else {
|
|
623
|
+
result0 = null;
|
|
624
|
+
if (reportFailures === 0) {
|
|
625
|
+
matchFailed("[_a-zA-Z]");
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (result0 !== null) {
|
|
629
|
+
result1 = [];
|
|
630
|
+
if (/^[_a-zA-Z0-9]/.test(input.charAt(pos))) {
|
|
631
|
+
result2 = input.charAt(pos);
|
|
632
|
+
pos++;
|
|
633
|
+
} else {
|
|
634
|
+
result2 = null;
|
|
635
|
+
if (reportFailures === 0) {
|
|
636
|
+
matchFailed("[_a-zA-Z0-9]");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
while (result2 !== null) {
|
|
640
|
+
result1.push(result2);
|
|
641
|
+
if (/^[_a-zA-Z0-9]/.test(input.charAt(pos))) {
|
|
642
|
+
result2 = input.charAt(pos);
|
|
643
|
+
pos++;
|
|
644
|
+
} else {
|
|
645
|
+
result2 = null;
|
|
646
|
+
if (reportFailures === 0) {
|
|
647
|
+
matchFailed("[_a-zA-Z0-9]");
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (result1 !== null) {
|
|
652
|
+
result0 = [result0, result1];
|
|
653
|
+
} else {
|
|
654
|
+
result0 = null;
|
|
655
|
+
pos = pos1;
|
|
656
|
+
}
|
|
657
|
+
} else {
|
|
658
|
+
result0 = null;
|
|
659
|
+
pos = pos1;
|
|
660
|
+
}
|
|
661
|
+
if (result0 !== null) {
|
|
662
|
+
result0 = (function(offset, head, tail) { return head + tail.join(''); })(pos0, result0[0], result0[1]);
|
|
663
|
+
}
|
|
664
|
+
if (result0 === null) {
|
|
665
|
+
pos = pos0;
|
|
666
|
+
}
|
|
667
|
+
return result0;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function parse_number() {
|
|
671
|
+
var result0, result1, result2;
|
|
672
|
+
var pos0, pos1;
|
|
673
|
+
|
|
674
|
+
pos0 = pos;
|
|
675
|
+
if (input.charCodeAt(pos) === 48) {
|
|
676
|
+
result0 = "0";
|
|
677
|
+
pos++;
|
|
678
|
+
} else {
|
|
679
|
+
result0 = null;
|
|
680
|
+
if (reportFailures === 0) {
|
|
681
|
+
matchFailed("\"0\"");
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (result0 !== null) {
|
|
685
|
+
result0 = (function(offset) { return 0; })(pos0);
|
|
686
|
+
}
|
|
687
|
+
if (result0 === null) {
|
|
688
|
+
pos = pos0;
|
|
689
|
+
}
|
|
690
|
+
if (result0 === null) {
|
|
691
|
+
pos0 = pos;
|
|
692
|
+
pos1 = pos;
|
|
693
|
+
if (/^[1-9]/.test(input.charAt(pos))) {
|
|
694
|
+
result0 = input.charAt(pos);
|
|
695
|
+
pos++;
|
|
696
|
+
} else {
|
|
697
|
+
result0 = null;
|
|
698
|
+
if (reportFailures === 0) {
|
|
699
|
+
matchFailed("[1-9]");
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (result0 !== null) {
|
|
703
|
+
result1 = [];
|
|
704
|
+
if (/^[0-9]/.test(input.charAt(pos))) {
|
|
705
|
+
result2 = input.charAt(pos);
|
|
706
|
+
pos++;
|
|
707
|
+
} else {
|
|
708
|
+
result2 = null;
|
|
709
|
+
if (reportFailures === 0) {
|
|
710
|
+
matchFailed("[0-9]");
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
while (result2 !== null) {
|
|
714
|
+
result1.push(result2);
|
|
715
|
+
if (/^[0-9]/.test(input.charAt(pos))) {
|
|
716
|
+
result2 = input.charAt(pos);
|
|
717
|
+
pos++;
|
|
718
|
+
} else {
|
|
719
|
+
result2 = null;
|
|
720
|
+
if (reportFailures === 0) {
|
|
721
|
+
matchFailed("[0-9]");
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (result1 !== null) {
|
|
726
|
+
result0 = [result0, result1];
|
|
727
|
+
} else {
|
|
728
|
+
result0 = null;
|
|
729
|
+
pos = pos1;
|
|
730
|
+
}
|
|
731
|
+
} else {
|
|
732
|
+
result0 = null;
|
|
733
|
+
pos = pos1;
|
|
734
|
+
}
|
|
735
|
+
if (result0 !== null) {
|
|
736
|
+
result0 = (function(offset, head, tail) { return parseInt(head + tail.join('')); })(pos0, result0[0], result0[1]);
|
|
737
|
+
}
|
|
738
|
+
if (result0 === null) {
|
|
739
|
+
pos = pos0;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return result0;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function parse_size() {
|
|
746
|
+
var result0, result1;
|
|
747
|
+
var pos0, pos1;
|
|
748
|
+
|
|
749
|
+
pos0 = pos;
|
|
750
|
+
pos1 = pos;
|
|
751
|
+
if (input.charCodeAt(pos) === 58) {
|
|
752
|
+
result0 = ":";
|
|
753
|
+
pos++;
|
|
754
|
+
} else {
|
|
755
|
+
result0 = null;
|
|
756
|
+
if (reportFailures === 0) {
|
|
757
|
+
matchFailed("\":\"");
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (result0 !== null) {
|
|
761
|
+
result1 = parse_number();
|
|
762
|
+
if (result1 !== null) {
|
|
763
|
+
result0 = [result0, result1];
|
|
764
|
+
} else {
|
|
765
|
+
result0 = null;
|
|
766
|
+
pos = pos1;
|
|
767
|
+
}
|
|
768
|
+
} else {
|
|
769
|
+
result0 = null;
|
|
770
|
+
pos = pos1;
|
|
771
|
+
}
|
|
772
|
+
if (result0 !== null) {
|
|
773
|
+
result0 = (function(offset, num) { return num; })(pos0, result0[1]);
|
|
774
|
+
}
|
|
775
|
+
if (result0 === null) {
|
|
776
|
+
pos = pos0;
|
|
777
|
+
}
|
|
778
|
+
if (result0 === null) {
|
|
779
|
+
pos0 = pos;
|
|
780
|
+
pos1 = pos;
|
|
781
|
+
if (input.charCodeAt(pos) === 58) {
|
|
782
|
+
result0 = ":";
|
|
783
|
+
pos++;
|
|
784
|
+
} else {
|
|
785
|
+
result0 = null;
|
|
786
|
+
if (reportFailures === 0) {
|
|
787
|
+
matchFailed("\":\"");
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (result0 !== null) {
|
|
791
|
+
result1 = parse_identifier();
|
|
792
|
+
if (result1 !== null) {
|
|
793
|
+
result0 = [result0, result1];
|
|
794
|
+
} else {
|
|
795
|
+
result0 = null;
|
|
796
|
+
pos = pos1;
|
|
797
|
+
}
|
|
798
|
+
} else {
|
|
799
|
+
result0 = null;
|
|
800
|
+
pos = pos1;
|
|
801
|
+
}
|
|
802
|
+
if (result0 !== null) {
|
|
803
|
+
result0 = (function(offset, id) { return id; })(pos0, result0[1]);
|
|
804
|
+
}
|
|
805
|
+
if (result0 === null) {
|
|
806
|
+
pos = pos0;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return result0;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function parse_specifierList() {
|
|
813
|
+
var result0, result1, result2, result3;
|
|
814
|
+
var pos0, pos1;
|
|
815
|
+
|
|
816
|
+
pos0 = pos;
|
|
817
|
+
pos1 = pos;
|
|
818
|
+
if (input.charCodeAt(pos) === 47) {
|
|
819
|
+
result0 = "/";
|
|
820
|
+
pos++;
|
|
821
|
+
} else {
|
|
822
|
+
result0 = null;
|
|
823
|
+
if (reportFailures === 0) {
|
|
824
|
+
matchFailed("\"/\"");
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
if (result0 !== null) {
|
|
828
|
+
result1 = parse_specifier();
|
|
829
|
+
if (result1 !== null) {
|
|
830
|
+
result2 = [];
|
|
831
|
+
result3 = parse_specifierTail();
|
|
832
|
+
while (result3 !== null) {
|
|
833
|
+
result2.push(result3);
|
|
834
|
+
result3 = parse_specifierTail();
|
|
835
|
+
}
|
|
836
|
+
if (result2 !== null) {
|
|
837
|
+
result0 = [result0, result1, result2];
|
|
838
|
+
} else {
|
|
839
|
+
result0 = null;
|
|
840
|
+
pos = pos1;
|
|
841
|
+
}
|
|
842
|
+
} else {
|
|
843
|
+
result0 = null;
|
|
844
|
+
pos = pos1;
|
|
845
|
+
}
|
|
846
|
+
} else {
|
|
847
|
+
result0 = null;
|
|
848
|
+
pos = pos1;
|
|
849
|
+
}
|
|
850
|
+
if (result0 !== null) {
|
|
851
|
+
result0 = (function(offset, head, tail) { tail.unshift(head); return tail; })(pos0, result0[1], result0[2]);
|
|
852
|
+
}
|
|
853
|
+
if (result0 === null) {
|
|
854
|
+
pos = pos0;
|
|
855
|
+
}
|
|
856
|
+
return result0;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
function parse_specifierTail() {
|
|
860
|
+
var result0, result1;
|
|
861
|
+
var pos0, pos1;
|
|
862
|
+
|
|
863
|
+
pos0 = pos;
|
|
864
|
+
pos1 = pos;
|
|
865
|
+
if (input.charCodeAt(pos) === 45) {
|
|
866
|
+
result0 = "-";
|
|
867
|
+
pos++;
|
|
868
|
+
} else {
|
|
869
|
+
result0 = null;
|
|
870
|
+
if (reportFailures === 0) {
|
|
871
|
+
matchFailed("\"-\"");
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (result0 !== null) {
|
|
875
|
+
result1 = parse_specifier();
|
|
876
|
+
if (result1 !== null) {
|
|
877
|
+
result0 = [result0, result1];
|
|
878
|
+
} else {
|
|
879
|
+
result0 = null;
|
|
880
|
+
pos = pos1;
|
|
881
|
+
}
|
|
882
|
+
} else {
|
|
883
|
+
result0 = null;
|
|
884
|
+
pos = pos1;
|
|
885
|
+
}
|
|
886
|
+
if (result0 !== null) {
|
|
887
|
+
result0 = (function(offset, spec) { return spec; })(pos0, result0[1]);
|
|
888
|
+
}
|
|
889
|
+
if (result0 === null) {
|
|
890
|
+
pos = pos0;
|
|
891
|
+
}
|
|
892
|
+
return result0;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function parse_specifier() {
|
|
896
|
+
var result0;
|
|
897
|
+
|
|
898
|
+
if (input.substr(pos, 6) === "little") {
|
|
899
|
+
result0 = "little";
|
|
900
|
+
pos += 6;
|
|
901
|
+
} else {
|
|
902
|
+
result0 = null;
|
|
903
|
+
if (reportFailures === 0) {
|
|
904
|
+
matchFailed("\"little\"");
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (result0 === null) {
|
|
908
|
+
if (input.substr(pos, 3) === "big") {
|
|
909
|
+
result0 = "big";
|
|
910
|
+
pos += 3;
|
|
911
|
+
} else {
|
|
912
|
+
result0 = null;
|
|
913
|
+
if (reportFailures === 0) {
|
|
914
|
+
matchFailed("\"big\"");
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
if (result0 === null) {
|
|
918
|
+
if (input.substr(pos, 6) === "signed") {
|
|
919
|
+
result0 = "signed";
|
|
920
|
+
pos += 6;
|
|
921
|
+
} else {
|
|
922
|
+
result0 = null;
|
|
923
|
+
if (reportFailures === 0) {
|
|
924
|
+
matchFailed("\"signed\"");
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (result0 === null) {
|
|
928
|
+
if (input.substr(pos, 8) === "unsigned") {
|
|
929
|
+
result0 = "unsigned";
|
|
930
|
+
pos += 8;
|
|
931
|
+
} else {
|
|
932
|
+
result0 = null;
|
|
933
|
+
if (reportFailures === 0) {
|
|
934
|
+
matchFailed("\"unsigned\"");
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (result0 === null) {
|
|
938
|
+
if (input.substr(pos, 7) === "integer") {
|
|
939
|
+
result0 = "integer";
|
|
940
|
+
pos += 7;
|
|
941
|
+
} else {
|
|
942
|
+
result0 = null;
|
|
943
|
+
if (reportFailures === 0) {
|
|
944
|
+
matchFailed("\"integer\"");
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
if (result0 === null) {
|
|
948
|
+
if (input.substr(pos, 6) === "binary") {
|
|
949
|
+
result0 = "binary";
|
|
950
|
+
pos += 6;
|
|
951
|
+
} else {
|
|
952
|
+
result0 = null;
|
|
953
|
+
if (reportFailures === 0) {
|
|
954
|
+
matchFailed("\"binary\"");
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
if (result0 === null) {
|
|
958
|
+
if (input.substr(pos, 5) === "float") {
|
|
959
|
+
result0 = "float";
|
|
960
|
+
pos += 5;
|
|
961
|
+
} else {
|
|
962
|
+
result0 = null;
|
|
963
|
+
if (reportFailures === 0) {
|
|
964
|
+
matchFailed("\"float\"");
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
if (result0 === null) {
|
|
968
|
+
result0 = parse_unit();
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
return result0;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
function parse_unit() {
|
|
980
|
+
var result0, result1;
|
|
981
|
+
var pos0, pos1;
|
|
982
|
+
|
|
983
|
+
pos0 = pos;
|
|
984
|
+
pos1 = pos;
|
|
985
|
+
if (input.substr(pos, 5) === "unit:") {
|
|
986
|
+
result0 = "unit:";
|
|
987
|
+
pos += 5;
|
|
988
|
+
} else {
|
|
989
|
+
result0 = null;
|
|
990
|
+
if (reportFailures === 0) {
|
|
991
|
+
matchFailed("\"unit:\"");
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (result0 !== null) {
|
|
995
|
+
result1 = parse_number();
|
|
996
|
+
if (result1 !== null) {
|
|
997
|
+
result0 = [result0, result1];
|
|
998
|
+
} else {
|
|
999
|
+
result0 = null;
|
|
1000
|
+
pos = pos1;
|
|
1001
|
+
}
|
|
1002
|
+
} else {
|
|
1003
|
+
result0 = null;
|
|
1004
|
+
pos = pos1;
|
|
1005
|
+
}
|
|
1006
|
+
if (result0 !== null) {
|
|
1007
|
+
result0 = (function(offset, num) { return 'unit:' + num; })(pos0, result0[1]);
|
|
1008
|
+
}
|
|
1009
|
+
if (result0 === null) {
|
|
1010
|
+
pos = pos0;
|
|
1011
|
+
}
|
|
1012
|
+
return result0;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
function parse_ws() {
|
|
1016
|
+
var result0, result1;
|
|
1017
|
+
|
|
1018
|
+
result0 = [];
|
|
1019
|
+
if (/^[ \t\n]/.test(input.charAt(pos))) {
|
|
1020
|
+
result1 = input.charAt(pos);
|
|
1021
|
+
pos++;
|
|
1022
|
+
} else {
|
|
1023
|
+
result1 = null;
|
|
1024
|
+
if (reportFailures === 0) {
|
|
1025
|
+
matchFailed("[ \\t\\n]");
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
while (result1 !== null) {
|
|
1029
|
+
result0.push(result1);
|
|
1030
|
+
if (/^[ \t\n]/.test(input.charAt(pos))) {
|
|
1031
|
+
result1 = input.charAt(pos);
|
|
1032
|
+
pos++;
|
|
1033
|
+
} else {
|
|
1034
|
+
result1 = null;
|
|
1035
|
+
if (reportFailures === 0) {
|
|
1036
|
+
matchFailed("[ \\t\\n]");
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return result0;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
function cleanupExpected(expected) {
|
|
1045
|
+
expected.sort();
|
|
1046
|
+
|
|
1047
|
+
var lastExpected = null;
|
|
1048
|
+
var cleanExpected = [];
|
|
1049
|
+
for (var i = 0; i < expected.length; i++) {
|
|
1050
|
+
if (expected[i] !== lastExpected) {
|
|
1051
|
+
cleanExpected.push(expected[i]);
|
|
1052
|
+
lastExpected = expected[i];
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return cleanExpected;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
function computeErrorPosition() {
|
|
1059
|
+
/*
|
|
1060
|
+
* The first idea was to use |String.split| to break the input up to the
|
|
1061
|
+
* error position along newlines and derive the line and column from
|
|
1062
|
+
* there. However IE's |split| implementation is so broken that it was
|
|
1063
|
+
* enough to prevent it.
|
|
1064
|
+
*/
|
|
1065
|
+
|
|
1066
|
+
var line = 1;
|
|
1067
|
+
var column = 1;
|
|
1068
|
+
var seenCR = false;
|
|
1069
|
+
|
|
1070
|
+
for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
|
|
1071
|
+
var ch = input.charAt(i);
|
|
1072
|
+
if (ch === "\n") {
|
|
1073
|
+
if (!seenCR) { line++; }
|
|
1074
|
+
column = 1;
|
|
1075
|
+
seenCR = false;
|
|
1076
|
+
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
|
|
1077
|
+
line++;
|
|
1078
|
+
column = 1;
|
|
1079
|
+
seenCR = true;
|
|
1080
|
+
} else {
|
|
1081
|
+
column++;
|
|
1082
|
+
seenCR = false;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
return { line: line, column: column };
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
var result = parseFunctions[startRule]();
|
|
1091
|
+
|
|
1092
|
+
/*
|
|
1093
|
+
* The parser is now in one of the following three states:
|
|
1094
|
+
*
|
|
1095
|
+
* 1. The parser successfully parsed the whole input.
|
|
1096
|
+
*
|
|
1097
|
+
* - |result !== null|
|
|
1098
|
+
* - |pos === input.length|
|
|
1099
|
+
* - |rightmostFailuresExpected| may or may not contain something
|
|
1100
|
+
*
|
|
1101
|
+
* 2. The parser successfully parsed only a part of the input.
|
|
1102
|
+
*
|
|
1103
|
+
* - |result !== null|
|
|
1104
|
+
* - |pos < input.length|
|
|
1105
|
+
* - |rightmostFailuresExpected| may or may not contain something
|
|
1106
|
+
*
|
|
1107
|
+
* 3. The parser did not successfully parse any part of the input.
|
|
1108
|
+
*
|
|
1109
|
+
* - |result === null|
|
|
1110
|
+
* - |pos === 0|
|
|
1111
|
+
* - |rightmostFailuresExpected| contains at least one failure
|
|
1112
|
+
*
|
|
1113
|
+
* All code following this comment (including called functions) must
|
|
1114
|
+
* handle these states.
|
|
1115
|
+
*/
|
|
1116
|
+
if (result === null || pos !== input.length) {
|
|
1117
|
+
var offset = Math.max(pos, rightmostFailuresPos);
|
|
1118
|
+
var found = offset < input.length ? input.charAt(offset) : null;
|
|
1119
|
+
var errorPosition = computeErrorPosition();
|
|
1120
|
+
|
|
1121
|
+
throw new this.SyntaxError(
|
|
1122
|
+
cleanupExpected(rightmostFailuresExpected),
|
|
1123
|
+
found,
|
|
1124
|
+
offset,
|
|
1125
|
+
errorPosition.line,
|
|
1126
|
+
errorPosition.column
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return result;
|
|
1131
|
+
},
|
|
1132
|
+
|
|
1133
|
+
/* Returns the parser source code. */
|
|
1134
|
+
toSource: function() { return this._source; }
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
/* Thrown when a parser encounters a syntax error. */
|
|
1138
|
+
|
|
1139
|
+
result.SyntaxError = function(expected, found, offset, line, column) {
|
|
1140
|
+
function buildMessage(expected, found) {
|
|
1141
|
+
var expectedHumanized, foundHumanized;
|
|
1142
|
+
|
|
1143
|
+
switch (expected.length) {
|
|
1144
|
+
case 0:
|
|
1145
|
+
expectedHumanized = "end of input";
|
|
1146
|
+
break;
|
|
1147
|
+
case 1:
|
|
1148
|
+
expectedHumanized = expected[0];
|
|
1149
|
+
break;
|
|
1150
|
+
default:
|
|
1151
|
+
expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
|
|
1152
|
+
+ " or "
|
|
1153
|
+
+ expected[expected.length - 1];
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
foundHumanized = found ? quote(found) : "end of input";
|
|
1157
|
+
|
|
1158
|
+
return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
this.name = "SyntaxError";
|
|
1162
|
+
this.expected = expected;
|
|
1163
|
+
this.found = found;
|
|
1164
|
+
this.message = buildMessage(expected, found);
|
|
1165
|
+
this.offset = offset;
|
|
1166
|
+
this.line = line;
|
|
1167
|
+
this.column = column;
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1170
|
+
result.SyntaxError.prototype = Error.prototype;
|
|
1171
|
+
|
|
1172
|
+
return result;
|
|
1173
|
+
})();
|