@futpib/parser 1.0.3 → 1.0.6
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/.claude/settings.local.json +24 -0
- package/.github/workflows/main.yml +1 -0
- package/build/androidPackageParser.js +30 -32
- package/build/arbitraryDalvikBytecode.d.ts +3 -3
- package/build/arbitraryDalvikBytecode.js +33 -27
- package/build/arbitraryDalvikExecutable.js +55 -17
- package/build/arbitraryJava.d.ts +31 -0
- package/build/arbitraryJava.js +532 -0
- package/build/arbitraryJavaScript.d.ts +3 -0
- package/build/arbitraryJavaScript.js +263 -0
- package/build/arbitraryJavascript.d.ts +3 -0
- package/build/arbitraryJavascript.js +263 -0
- package/build/arbitraryZig.d.ts +3 -0
- package/build/arbitraryZig.js +240 -0
- package/build/arbitraryZipStream.d.ts +1 -1
- package/build/arrayParser.js +72 -13
- package/build/backsmali.d.ts +4 -3
- package/build/backsmali.js +26 -6
- package/build/bash.d.ts +89 -0
- package/build/bash.js +1 -0
- package/build/bashParser.d.ts +6 -0
- package/build/bashParser.js +335 -0
- package/build/bashParser.test.d.ts +1 -0
- package/build/bashParser.test.js +343 -0
- package/build/bashParserEdgeCases.test.d.ts +1 -0
- package/build/bashParserEdgeCases.test.js +117 -0
- package/build/dalvikBytecodeParser/addressConversion.d.ts +110 -0
- package/build/dalvikBytecodeParser/addressConversion.js +334 -0
- package/build/dalvikBytecodeParser/formatParsers.d.ts +7 -6
- package/build/dalvikBytecodeParser/formatParsers.js +13 -14
- package/build/dalvikBytecodeParser.d.ts +60 -31
- package/build/dalvikBytecodeParser.js +92 -35
- package/build/dalvikBytecodeParser.test-d.d.ts +1 -0
- package/build/dalvikBytecodeParser.test-d.js +268 -0
- package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +9 -8
- package/build/dalvikBytecodeUnparser/formatUnparsers.js +13 -12
- package/build/dalvikBytecodeUnparser.d.ts +2 -2
- package/build/dalvikBytecodeUnparser.js +23 -23
- package/build/dalvikBytecodeUnparser.test.js +7 -7
- package/build/dalvikExecutable.d.ts +3 -3
- package/build/dalvikExecutable.test-d.d.ts +1 -0
- package/build/dalvikExecutable.test-d.js +59 -0
- package/build/dalvikExecutableParser/typedNumbers.d.ts +18 -0
- package/build/dalvikExecutableParser/typedNumbers.js +3 -0
- package/build/dalvikExecutableParser.d.ts +2 -1
- package/build/dalvikExecutableParser.js +96 -77
- package/build/dalvikExecutableParser.test.js +24 -3
- package/build/dalvikExecutableParserAgainstSmaliParser.test.js +3 -0
- package/build/dalvikExecutableUnparser/poolScanners.d.ts +2 -2
- package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +3 -3
- package/build/dalvikExecutableUnparser/sectionUnparsers.js +26 -11
- package/build/dalvikExecutableUnparser.d.ts +2 -2
- package/build/dalvikExecutableUnparser.test.js +2 -1
- package/build/disjunctionParser.d.ts +5 -3
- package/build/disjunctionParser.js +79 -17
- package/build/disjunctionParser.test-d.d.ts +1 -0
- package/build/disjunctionParser.test-d.js +72 -0
- package/build/elementSwitchParser.d.ts +4 -0
- package/build/{exactElementSwitchParser.js → elementSwitchParser.js} +3 -4
- package/build/elementSwitchParser.test-d.d.ts +1 -0
- package/build/elementSwitchParser.test-d.js +44 -0
- package/build/exactSequenceParser.d.ts +4 -2
- package/build/exactSequenceParser.test-d.d.ts +1 -0
- package/build/exactSequenceParser.test-d.js +36 -0
- package/build/fetchCid.js +2 -66
- package/build/index.d.ts +25 -2
- package/build/index.js +23 -1
- package/build/index.test.js +16 -1
- package/build/inputReader.d.ts +10 -0
- package/build/inputReader.js +36 -0
- package/build/java.d.ts +502 -0
- package/build/java.js +2 -0
- package/build/javaKeyStoreParser.js +14 -17
- package/build/javaParser.d.ts +51 -0
- package/build/javaParser.js +1538 -0
- package/build/javaParser.test.d.ts +1 -0
- package/build/javaParser.test.js +1287 -0
- package/build/javaScript.d.ts +35 -0
- package/build/javaScript.js +1 -0
- package/build/javaScriptParser.d.ts +9 -0
- package/build/javaScriptParser.js +34 -0
- package/build/javaScriptUnparser.d.ts +3 -0
- package/build/javaScriptUnparser.js +4 -0
- package/build/javaScriptUnparser.test.d.ts +1 -0
- package/build/javaScriptUnparser.test.js +24 -0
- package/build/javaUnparser.d.ts +2 -0
- package/build/javaUnparser.js +519 -0
- package/build/javaUnparser.test.d.ts +1 -0
- package/build/javaUnparser.test.js +24 -0
- package/build/javascript.d.ts +35 -0
- package/build/javascript.js +1 -0
- package/build/javascriptParser.d.ts +9 -0
- package/build/javascriptParser.js +34 -0
- package/build/javascriptUnparser.d.ts +3 -0
- package/build/javascriptUnparser.js +4 -0
- package/build/javascriptUnparser.test.d.ts +1 -0
- package/build/javascriptUnparser.test.js +24 -0
- package/build/jsonParser.js +2 -12
- package/build/lazyMessageError.d.ts +3 -0
- package/build/lookaheadParser.js +60 -3
- package/build/negativeLookaheadParser.js +70 -11
- package/build/nonEmptyArrayParser.js +72 -13
- package/build/objectParser.d.ts +12 -0
- package/build/objectParser.js +31 -0
- package/build/objectParser.test-d.d.ts +1 -0
- package/build/objectParser.test-d.js +112 -0
- package/build/objectParser.test.d.ts +1 -0
- package/build/objectParser.test.js +55 -0
- package/build/optionalParser.js +69 -10
- package/build/parser.d.ts +4 -0
- package/build/parser.js +3 -1
- package/build/parser.test.js +114 -1
- package/build/parserConsumedSequenceParser.js +66 -7
- package/build/parserContext.d.ts +6 -0
- package/build/parserContext.js +20 -11
- package/build/parserError.d.ts +119 -27
- package/build/parserError.js +16 -8
- package/build/regexpParser.d.ts +2 -0
- package/build/regexpParser.js +101 -0
- package/build/regexpParser.test.d.ts +1 -0
- package/build/regexpParser.test.js +114 -0
- package/build/regularExpression.d.ts +63 -0
- package/build/regularExpression.js +1 -0
- package/build/regularExpressionParser.d.ts +3 -0
- package/build/regularExpressionParser.js +600 -0
- package/build/regularExpressionParser.test.d.ts +1 -0
- package/build/regularExpressionParser.test.js +89 -0
- package/build/separatedArrayParser.js +73 -14
- package/build/separatedNonEmptyArrayParser.js +73 -14
- package/build/sliceBoundedParser.js +62 -5
- package/build/smaliParser.d.ts +7 -7
- package/build/smaliParser.js +185 -268
- package/build/smaliParser.test.js +58 -0
- package/build/stringEscapes.d.ts +5 -0
- package/build/stringEscapes.js +244 -0
- package/build/symbolicExpression.d.ts +29 -0
- package/build/symbolicExpression.js +1 -0
- package/build/symbolicExpressionParser.d.ts +4 -0
- package/build/symbolicExpressionParser.js +123 -0
- package/build/symbolicExpressionParser.test.d.ts +1 -0
- package/build/symbolicExpressionParser.test.js +289 -0
- package/build/terminatedArrayParser.js +113 -38
- package/build/terminatedArrayParser.test.js +4 -2
- package/build/tupleParser.d.ts +7 -15
- package/build/tupleParser.js +1 -0
- package/build/unionParser.d.ts +5 -3
- package/build/unionParser.js +7 -2
- package/build/unionParser.test-d.d.ts +1 -0
- package/build/unionParser.test-d.js +72 -0
- package/build/unionParser.test.js +10 -11
- package/build/zig.d.ts +280 -0
- package/build/zig.js +2 -0
- package/build/zigParser.d.ts +3 -0
- package/build/zigParser.js +1119 -0
- package/build/zigParser.test.d.ts +1 -0
- package/build/zigParser.test.js +1590 -0
- package/build/zigUnparser.d.ts +2 -0
- package/build/zigUnparser.js +460 -0
- package/build/zigUnparser.test.d.ts +1 -0
- package/build/zigUnparser.test.js +24 -0
- package/build/zipParser.js +19 -32
- package/build/zipUnparser.js +19 -7
- package/build/zipUnparser.test.js +1 -1
- package/node_modules-@types/s-expression/index.d.ts +5 -0
- package/package.json +25 -6
- package/src/androidPackageParser.ts +33 -60
- package/src/arbitraryDalvikBytecode.ts +39 -31
- package/src/arbitraryDalvikExecutable.ts +65 -20
- package/src/arbitraryJava.ts +804 -0
- package/src/arbitraryJavaScript.ts +410 -0
- package/src/arbitraryZig.ts +380 -0
- package/src/arrayParser.ts +1 -3
- package/src/backsmali.ts +35 -4
- package/src/bash.ts +127 -0
- package/src/bashParser.test.ts +590 -0
- package/src/bashParser.ts +498 -0
- package/src/dalvikBytecodeParser/addressConversion.ts +496 -0
- package/src/dalvikBytecodeParser/formatParsers.ts +19 -29
- package/src/dalvikBytecodeParser.test-d.ts +310 -0
- package/src/dalvikBytecodeParser.ts +194 -69
- package/src/dalvikBytecodeUnparser/formatUnparsers.ts +27 -26
- package/src/dalvikBytecodeUnparser.test.ts +7 -7
- package/src/dalvikBytecodeUnparser.ts +31 -30
- package/src/dalvikExecutable.test-d.ts +132 -0
- package/src/dalvikExecutable.ts +3 -3
- package/src/dalvikExecutableParser/typedNumbers.ts +11 -0
- package/src/dalvikExecutableParser.test.ts +37 -3
- package/src/dalvikExecutableParser.test.ts.md +163 -2
- package/src/dalvikExecutableParser.test.ts.snap +0 -0
- package/src/dalvikExecutableParser.ts +121 -139
- package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +4 -0
- package/src/dalvikExecutableUnparser/poolScanners.ts +6 -6
- package/src/dalvikExecutableUnparser/sectionUnparsers.ts +38 -14
- package/src/dalvikExecutableUnparser.test.ts +3 -2
- package/src/dalvikExecutableUnparser.ts +4 -4
- package/src/disjunctionParser.test-d.ts +105 -0
- package/src/disjunctionParser.ts +18 -15
- package/src/elementSwitchParser.test-d.ts +74 -0
- package/src/elementSwitchParser.ts +51 -0
- package/src/exactSequenceParser.test-d.ts +43 -0
- package/src/exactSequenceParser.ts +13 -8
- package/src/fetchCid.ts +2 -76
- package/src/index.test.ts +22 -1
- package/src/index.ts +119 -2
- package/src/inputReader.ts +53 -0
- package/src/java.ts +708 -0
- package/src/javaKeyStoreParser.ts +18 -32
- package/src/javaParser.test.ts +1592 -0
- package/src/javaParser.ts +2640 -0
- package/src/javaScript.ts +36 -0
- package/src/javaScriptParser.ts +57 -0
- package/src/javaScriptUnparser.test.ts +37 -0
- package/src/javaScriptUnparser.ts +7 -0
- package/src/javaUnparser.test.ts +37 -0
- package/src/javaUnparser.ts +640 -0
- package/src/jsonParser.ts +6 -27
- package/src/lookaheadParser.ts +2 -6
- package/src/negativeLookaheadParser.ts +1 -3
- package/src/nonEmptyArrayParser.ts +1 -3
- package/src/objectParser.test-d.ts +152 -0
- package/src/objectParser.test.ts +71 -0
- package/src/objectParser.ts +69 -0
- package/src/optionalParser.ts +1 -3
- package/src/parser.test.ts +151 -4
- package/src/parser.ts +11 -1
- package/src/parserConsumedSequenceParser.ts +2 -4
- package/src/parserContext.ts +26 -11
- package/src/parserError.ts +17 -3
- package/src/regexpParser.test.ts +264 -0
- package/src/regexpParser.ts +126 -0
- package/src/regularExpression.ts +24 -0
- package/src/regularExpressionParser.test.ts +102 -0
- package/src/regularExpressionParser.ts +920 -0
- package/src/separatedArrayParser.ts +1 -3
- package/src/separatedNonEmptyArrayParser.ts +1 -3
- package/src/sliceBoundedParser.test.ts +2 -2
- package/src/sliceBoundedParser.ts +15 -19
- package/src/smaliParser.test.ts +64 -0
- package/src/smaliParser.test.ts.md +12 -12
- package/src/smaliParser.test.ts.snap +0 -0
- package/src/smaliParser.ts +246 -534
- package/src/stringEscapes.ts +253 -0
- package/src/symbolicExpression.ts +17 -0
- package/src/symbolicExpressionParser.test.ts +466 -0
- package/src/symbolicExpressionParser.ts +190 -0
- package/src/terminatedArrayParser.test.ts +9 -6
- package/src/terminatedArrayParser.ts +25 -29
- package/src/tupleParser.ts +21 -18
- package/src/unionParser.test-d.ts +105 -0
- package/src/unionParser.test.ts +18 -17
- package/src/unionParser.ts +28 -16
- package/src/zig.ts +411 -0
- package/src/zigParser.test.ts +1693 -0
- package/src/zigParser.ts +1745 -0
- package/src/zigUnparser.test.ts +37 -0
- package/src/zigUnparser.ts +615 -0
- package/src/zipParser.ts +20 -56
- package/src/zipUnparser.test.ts +1 -1
- package/src/zipUnparser.ts +22 -7
- package/tsconfig.json +2 -2
- package/build/exactElementSwitchParser.d.ts +0 -3
- package/src/exactElementSwitchParser.ts +0 -41
package/src/index.test.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
+
import {
|
|
3
|
+
runParser,
|
|
4
|
+
createExactSequenceParser,
|
|
5
|
+
createTupleParser,
|
|
6
|
+
stringParserInputCompanion,
|
|
7
|
+
} from './index.js';
|
|
2
8
|
|
|
3
|
-
test
|
|
9
|
+
test('exports main parser functions', async t => {
|
|
10
|
+
// Test that runParser is exported and works
|
|
11
|
+
const parser = createExactSequenceParser('hello');
|
|
12
|
+
const result = await runParser(parser, 'hello', stringParserInputCompanion);
|
|
13
|
+
t.is(result, 'hello');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('exports parser combinators', async t => {
|
|
17
|
+
// Test that createTupleParser is exported and works
|
|
18
|
+
const tupleParser = createTupleParser([
|
|
19
|
+
createExactSequenceParser('a'),
|
|
20
|
+
createExactSequenceParser('b'),
|
|
21
|
+
]);
|
|
22
|
+
const result = await runParser(tupleParser, 'ab', stringParserInputCompanion);
|
|
23
|
+
t.deepEqual(result, [ 'a', 'b' ]);
|
|
24
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,69 @@
|
|
|
1
|
-
|
|
2
1
|
export {
|
|
3
2
|
type Parser,
|
|
3
|
+
type ParserOutput,
|
|
4
|
+
type ParserSequence,
|
|
4
5
|
runParser,
|
|
5
|
-
|
|
6
|
+
runParserWithRemainingInput,
|
|
6
7
|
setParserName,
|
|
7
8
|
getParserName,
|
|
9
|
+
cloneParser,
|
|
10
|
+
type RunParserOptions,
|
|
11
|
+
type RunParserWithRemainingInputResult,
|
|
8
12
|
} from './parser.js';
|
|
9
13
|
|
|
10
14
|
export type {
|
|
11
15
|
ParserContext,
|
|
12
16
|
} from './parserContext.js';
|
|
13
17
|
|
|
18
|
+
export {
|
|
19
|
+
type ParserInputCompanion,
|
|
20
|
+
StringParserInputCompanion,
|
|
21
|
+
stringParserInputCompanion,
|
|
22
|
+
Uint8ArrayParserInputCompanion,
|
|
23
|
+
uint8ArrayParserInputCompanion,
|
|
24
|
+
} from './parserInputCompanion.js';
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
type UnparserOutputCompanion,
|
|
28
|
+
StringUnparserOutputCompanion,
|
|
29
|
+
stringUnparserOutputCompanion,
|
|
30
|
+
Uint8ArrayUnparserOutputCompanion,
|
|
31
|
+
uint8ArrayUnparserOutputCompanion,
|
|
32
|
+
} from './unparserOutputCompanion.js';
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
type ParserError,
|
|
36
|
+
type ParserParsingFailedError,
|
|
37
|
+
type ParserParsingJoinError,
|
|
38
|
+
type ParserErrorModule,
|
|
39
|
+
isParserError,
|
|
40
|
+
isParserParsingFailedError,
|
|
41
|
+
isParserParsingJoinError,
|
|
42
|
+
normalParserErrorModule,
|
|
43
|
+
noStackCaptureOverheadParserErrorModule,
|
|
44
|
+
} from './parserError.js';
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
parserCreatorCompose,
|
|
48
|
+
parserCreatorComposeMem,
|
|
49
|
+
} from './parserCreatorCompose.js';
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
promiseCompose,
|
|
53
|
+
} from './promiseCompose.js';
|
|
54
|
+
|
|
55
|
+
export type {
|
|
56
|
+
DeriveSequenceElement,
|
|
57
|
+
} from './sequence.js';
|
|
58
|
+
|
|
14
59
|
export {
|
|
15
60
|
createTupleParser,
|
|
16
61
|
} from './tupleParser.js';
|
|
17
62
|
|
|
63
|
+
export {
|
|
64
|
+
createObjectParser,
|
|
65
|
+
} from './objectParser.js';
|
|
66
|
+
|
|
18
67
|
export {
|
|
19
68
|
createExactSequenceParser,
|
|
20
69
|
} from './exactSequenceParser.js';
|
|
@@ -75,11 +124,75 @@ export {
|
|
|
75
124
|
createDebugLogParser,
|
|
76
125
|
} from './debugLogParser.js';
|
|
77
126
|
|
|
127
|
+
export {
|
|
128
|
+
createNonEmptyArrayParser,
|
|
129
|
+
} from './nonEmptyArrayParser.js';
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
createSeparatedArrayParser,
|
|
133
|
+
} from './separatedArrayParser.js';
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
createSeparatedNonEmptyArrayParser,
|
|
137
|
+
} from './separatedNonEmptyArrayParser.js';
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
createLookaheadParser,
|
|
141
|
+
} from './lookaheadParser.js';
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
createNegativeLookaheadParser,
|
|
145
|
+
} from './negativeLookaheadParser.js';
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
createElementTerminatedSequenceParser,
|
|
149
|
+
} from './elementTerminatedSequenceParser.js';
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
createElementTerminatedSequenceArrayParser,
|
|
153
|
+
} from './elementTerminatedSequenceArrayParser.js';
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
createElementTerminatedArrayParserUnsafe,
|
|
157
|
+
} from './elementTerminatedArrayParser.js';
|
|
158
|
+
|
|
159
|
+
export {
|
|
160
|
+
createSequenceTerminatedSequenceParser,
|
|
161
|
+
} from './sequenceTerminatedSequenceParser.js';
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
createQuantifierParser,
|
|
165
|
+
} from './quantifierParser.js';
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
createSkipToParser,
|
|
169
|
+
} from './skipToParser.js';
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
createDebugLogInputParser,
|
|
173
|
+
} from './debugLogInputParser.js';
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
createElementSwitchParser,
|
|
177
|
+
} from './elementSwitchParser.js';
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
createParserConsumedSequenceParser,
|
|
181
|
+
} from './parserConsumedSequenceParser.js';
|
|
182
|
+
|
|
78
183
|
export {
|
|
79
184
|
type Unparser,
|
|
185
|
+
type UnparserResult,
|
|
80
186
|
runUnparser,
|
|
81
187
|
} from './unparser.js';
|
|
82
188
|
|
|
189
|
+
export {
|
|
190
|
+
type UnparserContext,
|
|
191
|
+
WriteLater,
|
|
192
|
+
WriteEarlier,
|
|
193
|
+
UnparserContextImplementation,
|
|
194
|
+
} from './unparserContext.js';
|
|
195
|
+
|
|
83
196
|
export {
|
|
84
197
|
createArrayUnparser,
|
|
85
198
|
} from './arrayUnparser.js';
|
|
@@ -87,3 +200,7 @@ export {
|
|
|
87
200
|
export {
|
|
88
201
|
createSequenceUnparser,
|
|
89
202
|
} from './sequenceUnparser.js';
|
|
203
|
+
|
|
204
|
+
export {
|
|
205
|
+
createRegExpParser,
|
|
206
|
+
} from './regexpParser.js';
|
package/src/inputReader.ts
CHANGED
|
@@ -7,11 +7,16 @@ import { type InputReaderState } from './inputReaderState.js';
|
|
|
7
7
|
|
|
8
8
|
export type InputReader<Sequence, Element> = {
|
|
9
9
|
get position(): number;
|
|
10
|
+
get furthestReadPosition(): number;
|
|
11
|
+
get furthestPeekedPosition(): number;
|
|
10
12
|
|
|
11
13
|
peek(offset: number): Promise<Element | undefined>;
|
|
12
14
|
peekSequence(start: number, end: number): Promise<Sequence | undefined>;
|
|
13
15
|
skip(offset: number): void;
|
|
14
16
|
|
|
17
|
+
updateFurthestReadPosition(position: number): void;
|
|
18
|
+
updateFurthestPeekedPosition(position: number): void;
|
|
19
|
+
|
|
15
20
|
lookahead(): InputReader<Sequence, Element>;
|
|
16
21
|
|
|
17
22
|
toInputReaderState(): InputReaderState<Sequence>;
|
|
@@ -23,6 +28,8 @@ export class InputReaderImplementation<Sequence, Element> implements InputReader
|
|
|
23
28
|
private readonly _id = inputReaderId++;
|
|
24
29
|
|
|
25
30
|
private _position = 0;
|
|
31
|
+
private _furthestReadPosition = 0;
|
|
32
|
+
private _furthestPeekedPosition = 0;
|
|
26
33
|
private _uncommitedSkipOffset = 0;
|
|
27
34
|
private _inputAsyncIteratorDone = false;
|
|
28
35
|
|
|
@@ -49,9 +56,27 @@ export class InputReaderImplementation<Sequence, Element> implements InputReader
|
|
|
49
56
|
return this._position;
|
|
50
57
|
}
|
|
51
58
|
|
|
59
|
+
get furthestReadPosition() {
|
|
60
|
+
return this._furthestReadPosition;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get furthestPeekedPosition() {
|
|
64
|
+
return this._furthestPeekedPosition;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
updateFurthestReadPosition(position: number) {
|
|
68
|
+
this._furthestReadPosition = Math.max(this._furthestReadPosition, position);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
updateFurthestPeekedPosition(position: number) {
|
|
72
|
+
this._furthestPeekedPosition = Math.max(this._furthestPeekedPosition, position);
|
|
73
|
+
}
|
|
74
|
+
|
|
52
75
|
async peek(offset: number): Promise<Element | undefined> {
|
|
53
76
|
parserImplementationInvariant(offset >= 0, 'offset >= 0');
|
|
54
77
|
|
|
78
|
+
this.updateFurthestPeekedPosition(this._position + offset);
|
|
79
|
+
|
|
55
80
|
offset += this._uncommitedSkipOffset;
|
|
56
81
|
|
|
57
82
|
const element = this._sequenceBuffer.peek(offset);
|
|
@@ -115,6 +140,10 @@ export class InputReaderImplementation<Sequence, Element> implements InputReader
|
|
|
115
140
|
end,
|
|
116
141
|
);
|
|
117
142
|
|
|
143
|
+
if (end > start) {
|
|
144
|
+
this.updateFurthestPeekedPosition(this._position + end - 1);
|
|
145
|
+
}
|
|
146
|
+
|
|
118
147
|
start += this._uncommitedSkipOffset;
|
|
119
148
|
end += this._uncommitedSkipOffset;
|
|
120
149
|
|
|
@@ -137,6 +166,7 @@ export class InputReaderImplementation<Sequence, Element> implements InputReader
|
|
|
137
166
|
parserImplementationInvariant(offset >= 0, 'offset >= 0');
|
|
138
167
|
|
|
139
168
|
this._position += offset;
|
|
169
|
+
this.updateFurthestReadPosition(this._position);
|
|
140
170
|
|
|
141
171
|
if (this._promiseMutex.isLocked) {
|
|
142
172
|
this._uncommitedSkipOffset += offset;
|
|
@@ -185,12 +215,30 @@ class InputReaderLookaheadImplementation<Sequence, Element> implements InputRead
|
|
|
185
215
|
return this._initialInputReaderPosition + this._offset;
|
|
186
216
|
}
|
|
187
217
|
|
|
218
|
+
get furthestReadPosition() {
|
|
219
|
+
return this._inputReader.furthestReadPosition;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
get furthestPeekedPosition() {
|
|
223
|
+
return this._inputReader.furthestPeekedPosition;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
updateFurthestReadPosition(position: number) {
|
|
227
|
+
this._inputReader.updateFurthestReadPosition(position);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
updateFurthestPeekedPosition(position: number) {
|
|
231
|
+
this._inputReader.updateFurthestPeekedPosition(position);
|
|
232
|
+
}
|
|
233
|
+
|
|
188
234
|
async peek(offset: number): Promise<Element | undefined> {
|
|
189
235
|
const inputReaderMovedForward = this._inputReader.position - this._initialInputReaderPosition;
|
|
190
236
|
|
|
191
237
|
this._initialInputReaderPosition = this._inputReader.position;
|
|
192
238
|
this._offset -= inputReaderMovedForward;
|
|
193
239
|
|
|
240
|
+
this.updateFurthestPeekedPosition(this.position + offset);
|
|
241
|
+
|
|
194
242
|
return this._inputReader.peek(this._offset + offset);
|
|
195
243
|
}
|
|
196
244
|
|
|
@@ -200,6 +248,10 @@ class InputReaderLookaheadImplementation<Sequence, Element> implements InputRead
|
|
|
200
248
|
this._initialInputReaderPosition = this._inputReader.position;
|
|
201
249
|
this._offset -= inputReaderMovedForward;
|
|
202
250
|
|
|
251
|
+
if (end > start) {
|
|
252
|
+
this.updateFurthestPeekedPosition(this.position + end - 1);
|
|
253
|
+
}
|
|
254
|
+
|
|
203
255
|
return this._inputReader.peekSequence(this._offset + start, this._offset + end);
|
|
204
256
|
}
|
|
205
257
|
|
|
@@ -207,6 +259,7 @@ class InputReaderLookaheadImplementation<Sequence, Element> implements InputRead
|
|
|
207
259
|
parserImplementationInvariant(offset >= 0, 'offset >= 0');
|
|
208
260
|
|
|
209
261
|
this._offset += offset;
|
|
262
|
+
this.updateFurthestReadPosition(this.position);
|
|
210
263
|
}
|
|
211
264
|
|
|
212
265
|
lookahead(): InputReader<Sequence, Element> {
|