forked from abrobston/jscc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypedef.js
348 lines (331 loc) · 9.12 KB
/
typedef.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/*
* Contains type definitions for Closure's benefit. Used as a
* start file when optimizing with requirejs.
*/
"use strict";
/**
* The root namespace. Re-add the const tag after Closure bug #1235 is fixed.
* @namespace
*/
this["jscc"] = {};
//>>excludeStart("jsccNamespacePreDefined", pragmas.jsccNamespacePreDefined);
var jscc = this["jscc"];
//>>excludeEnd("jsccNamespacePreDefined");
//>>includeStart("jsccNamespacePreDefined", pragmas.jsccNamespacePreDefined);
jscc = this["jscc"];
//>>includeEnd("jsccNamespacePreDefined");
/**
* The namespace to which enum definitions belong.
* @namespace
*/
jscc["enums"] = {};
/**
* The namespace to which certain classes belong.
* @namespace
*/
jscc["classes"] = {};
jscc.enums = jscc["enums"];
jscc.classes = jscc["classes"];
/*
* To avoid type errors with enums, add the enum module code here. The enum modules
* will simply return the enum objects when the closure pragma is defined. There
* really should be a better solution than this, and maybe there is.
*/
/**
* Indicates the associativity of a symbol.
* @enum {number}
*/
jscc.enums.ASSOC = {
/**
* The associativity has not yet been set.
*/
NONE: 0,
/**
* The symbol is left-associative.
*/
LEFT: 1,
/**
* The symbol is right-associative.
*/
RIGHT: 2,
/**
* The symbol is non-associative.
*/
NOASSOC: 3
};
/**
* Identifies the type of an edge in an automation graph.
* @enum {number}
*/
jscc.enums.EDGE = {
FREE: 0,
EPSILON: 1,
CHAR: 2
};
/**
* Indicates whether the executable environment is a
* console-based Javascript engine or a web environment.
* @enum {number}
*/
jscc.enums.EXEC = {
/**
* A console-based Javascript engine is in use.
*/
CONSOLE: 0,
/**
* A web-browser-based Javascript engine is in use.
*/
WEB: 1
};
/**
* Specifies the minimum logging level.
* @enum {number}
*/
jscc.enums.LOG_LEVEL = {
/**
* Log all messages.
*/
TRACE: 0,
/**
* Log debug messages and higher.
*/
DEBUG: 1,
/**
* Log info messages and higher.
*/
INFO: 2,
/**
* Log warning messages and higher.
*/
WARN: 3,
/**
* Log error and fatal messages.
*/
ERROR: 4,
/**
* Log only fatal messages.
*/
FATAL: 5
};
// Export from Closure, as this enumeration may be used in the
// mainOptions typedef.
jscc.enums.LOG_LEVEL['TRACE'] = jscc.enums.LOG_LEVEL.TRACE;
jscc.enums.LOG_LEVEL['DEBUG'] = jscc.enums.LOG_LEVEL.DEBUG;
jscc.enums.LOG_LEVEL['INFO'] = jscc.enums.LOG_LEVEL.INFO;
jscc.enums.LOG_LEVEL['WARN'] = jscc.enums.LOG_LEVEL.WARN;
jscc.enums.LOG_LEVEL['ERROR'] = jscc.enums.LOG_LEVEL.ERROR;
jscc.enums.LOG_LEVEL['FATAL'] = jscc.enums.LOG_LEVEL.FATAL;
jscc.enums['LOG_LEVEL'] = jscc.enums.LOG_LEVEL;
/**
* Indicates an output mode for the parser.
* @enum {number}
*/
jscc.enums.MODE_GEN = {
/**
* Output is plain text.
*/
TEXT: 0,
/**
* Output is JavaScript code.
*/
JS: 1,
/**
* Output is HTML-formatted.
*/
HTML: 2
};
/**
* Identifies a special symbol. Special symbols include
* end-of-file, whitespace, and error symbols. Use
* NONE to indicate a non-special symbol.
* @enum {number}
*/
jscc.enums.SPECIAL = {
/**
* Identifies a non-special symbol.
*/
NONE: 0,
/**
* Identifies an end-of-file symbol.
*/
EOF: 1,
/**
* Identifies a whitespace symbol.
*/
WHITESPACE: 2,
/**
* Identifies an error symbol.
*/
ERROR: 3
};
/**
* Identifies a symbol as nonterminating or terminating.
* @enum {number}
*/
jscc.enums.SYM = {
/**
* The symbol is nonterminating.
*/
NONTERM: 0,
/**
* The symbol is terminating.
*/
TERM: 1
};
/*
* Some option-override, fictional types.
*/
/**
* @typedef {{id: ?number, kind: ?jscc.enums.SYM, label: ?string, prods: ?Array<number>, first:
* ?Array, associativity: ?jscc.enums.ASSOC, level: ?number, code: ?string, special: ?jscc.enums.SPECIAL,
* defined: ?boolean, "nullable": ?boolean}}
*/
var SymbolOptions;
/**
* @typedef {{id: ?number, lhs: ?number, rhs: ?Array<!number>, level: ?number, code: ?string}}
*/
var ProductionOptions;
/**
* @typedef {{kernel: ?Array<!jscc.classes.Item>, epsilon: ?Array<!jscc.classes.Item>, def_act: ?number, done:
* ?boolean, closed: ?boolean, actionrow: ?Array<!jscc.classes.TableEntry>, gotorow:
* ?Array<!jscc.classes.TableEntry>}}
*/
var StateOptions;
/**
* @typedef {{prod: ?number, dot_offset: ?number, lookahead: ?Array<!number>}}
*/
var ItemOptions;
/**
* @typedef {{edge: ?jscc.enums.EDGE, ccl: ?jscc.bitset, follow: ?number, follow2: ?number, accept: ?number,
* weight: ?number}}
*/
var NfaOptions;
/**
* @typedef {{line: ?Array, nfa_set: ?Array<!number>, accept: ?number, done: ?boolean, group: ?number}}
*/
var DfaOptions;
/**
* @typedef {{out_file: ?string, src_file: ?string, tpl_file: ?string, input: ?(string|function():!string),
* template: ?(string|function():!string), outputCallback: ?function(string):void, dump_nfa: ?boolean,
* dump_dfa: ?boolean, verbose: ?boolean, logLevel: ?(string|jscc.enums.LOG_LEVEL)}}
* @property {?string} out_file - The path of the output file. Defaults to
* the empty string, which means to print to standard output (or the engine's equivalent).
* @property {?string} src_file - The path of the input grammar file.
* Defaults to the empty string, which means to read from standard input (or
* the engine's equivalent).
* @property {?string} tpl_file - The path of the input template file.
* Defaults to the module's default template file, which is intended for generic
* compilation tasks.
* @property {?(string|function():!string)} input - If a string, the contents of the
* input grammar. If a function with no arguments, a function that returns
* the contents of the grammar. When input is specified, src_file is ignored.
* @property {?(string|function():!string)} template - If a string, the contents of the
* template. If a function with no arguments, a function that returns the contents
* of the template. When template is specified, tpl_file is ignored.
* @property {?function(string):void} outputCallback - A function with a parameter
* that will be called with the output. When outputCallback is specified,
* out_file is ignored.
* @property {?boolean} dump_nfa - Whether to output the nondeterministic finite
* automata for debugging purposes. Defaults to false.
* @property {?boolean} dump_dfa - Whether to output the deterministic finite
* automata for debugging purposes. Defaults to false.
* @property {?boolean} verbose - Make debugging output chattier. Defaults to
* false.
* @property {?(string|jscc.enums.LOG_LEVEL)} logLevel - The logging
* level. Can be the name of one of the {@link module:jscc.enums.LOG_LEVEL} values
* or one of the values themselves. Defaults to WARN.
* @property {?boolean} throwIfErrors - Whether to throw an exception before completion
* of the main method if there are any errors.
* @property {?boolean} exitIfErrors - Whether to exit the process with a non-zero exit
* code if there are any errors, provided that the platform permits doing so. Intended
* for use with shell scripts.
*/
var mainOptions;
//>>includeStart("amdclean", pragmas.amdclean);
/**
* @typedef {(function(!string):*|Object)}
*/
//>>includeEnd("amdclean");
//>>excludeStart("amdclean", pragmas.amdclean);
/**
* @typedef {function(!string):*}
*/
//>>excludeEnd("amdclean");
var reqParameter;
/**
* @typedef {function((undefined|string|Array<string>|{deps: (string|Array<string>), callback: (string|Function)}), (string|Function|Array<string>)=, (string|Function)=, (string|boolean)=, boolean=):almondRequire}
*/
var almondRequire;
var almondRequireExtension =
/**
* @lends {almondRequire}
*/
({
/**
* @type {!Object<string, *>}
*/
_defined: {},
/**
* @param {Object<string, *>} cfg
* @returns {almondRequire}
*/
config: function(cfg) {
}
});
/**
* @typedef {string}
*/
var stringWithErrorMessage;
var stringWithErrorMessageExtension =
/**
* @lends {stringWithErrorMessage}
*/
({
/**
* @type {string}
*/
ERROR_MSG: ""
});
/**
* @typedef {function(string):boolean}
*/
var hasObject;
var hasObjectExtension =
/**
* @lends {hasObject}
*/
({
/**
* @param {string} name
* @param {function(...*):boolean} test
* @param {boolean=} now
*/
add: function(name, test, now) {
},
/**
* @param {T} el
* @returns {T}
* @template T
*/
clearElement: function(el) {
},
/**
* @param {string} name
* @param {*} el
* @returns {boolean}
*/
cssprop: function(name, el) {
},
/**
* @param {*} obj
* @param {*=} property
* @returns {boolean}
*/
isHostType: function(obj, property) {
},
/**
* @returns {Object<string, (boolean|stringWithErrorMessage)>}
*/
all: function() {
}
});