Skip to content

Commit 25339f1

Browse files
committed
fix: use global initializer instead of per-parse initializer
1 parent cce099f commit 25339f1

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

lib/parser.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@
44

55
"use strict";
66

7+
8+
const Types = require('./types');
9+
10+
function optional(obj) {
11+
obj.optional = true;
12+
13+
return obj;
14+
}
15+
16+
function repeatable(obj) {
17+
obj.repeatable = true;
18+
19+
return obj;
20+
}
21+
22+
function nullable(obj, modifier) {
23+
if (modifier) {
24+
obj.nullable = (modifier === '?' ? true : false);
25+
}
26+
27+
return obj;
28+
}
29+
730
class peg$SyntaxError extends SyntaxError {
831
constructor(message, expected, found, location) {
932
super(message);
@@ -5006,29 +5029,6 @@ function peg$parse(input, options) {
50065029
return s0;
50075030
}
50085031

5009-
5010-
const Types = require('./types');
5011-
5012-
function optional(obj) {
5013-
obj.optional = true;
5014-
5015-
return obj;
5016-
}
5017-
5018-
function repeatable(obj) {
5019-
obj.repeatable = true;
5020-
5021-
return obj;
5022-
}
5023-
5024-
function nullable(obj, modifier) {
5025-
if (modifier) {
5026-
obj.nullable = (modifier === '?' ? true : false);
5027-
}
5028-
5029-
return obj;
5030-
}
5031-
50325032
peg$result = peg$startRuleFunction();
50335033

50345034
const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);

lib/parser.pegjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license MIT License <http://opensource.org/licenses/mit-license.php/>
1010
*/
1111

12-
{
12+
{{
1313
const Types = require('./types');
1414

1515
function optional(obj) {
@@ -31,7 +31,7 @@
3131

3232
return obj;
3333
}
34-
}
34+
}}
3535

3636
TypeExpression
3737
= TypeUnionLegacySyntax

0 commit comments

Comments
 (0)