summaryrefslogtreecommitdiffstats
path: root/llparse-frontend/src/node/sequence.ts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
commit0b6210cd37b68b94252cb798598b12974a20e1c1 (patch)
treee371686554a877842d95aa94f100bee552ff2a8e /llparse-frontend/src/node/sequence.ts
parentInitial commit. (diff)
downloadnode-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.tar.xz
node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.zip
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--llparse-frontend/src/node/sequence.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/llparse-frontend/src/node/sequence.ts b/llparse-frontend/src/node/sequence.ts
new file mode 100644
index 0000000..c9105b3
--- /dev/null
+++ b/llparse-frontend/src/node/sequence.ts
@@ -0,0 +1,44 @@
+import * as assert from 'assert';
+import { Buffer } from 'buffer';
+
+import { IUniqueName } from '../utils';
+import { IWrap } from '../wrap';
+import { Node } from './base';
+import { Match } from './match';
+import { Slot } from './slot';
+
+interface ISequenceEdge {
+ node: IWrap<Node>;
+ readonly value: number | undefined;
+}
+
+export interface IReadonlySequenceEdge {
+ readonly node: IWrap<Node>;
+ readonly value: number | undefined;
+}
+
+export class Sequence extends Match {
+ private privEdge?: ISequenceEdge;
+
+ constructor(id: IUniqueName, public readonly select: Buffer) {
+ super(id);
+ }
+
+ public setEdge(node: IWrap<Node>, value?: number | undefined) {
+ assert.strictEqual(this.privEdge, undefined);
+ this.privEdge = { node, value };
+ }
+
+ public get edge(): IReadonlySequenceEdge | undefined {
+ return this.privEdge;
+ }
+
+ protected *buildSlots() {
+ const edge = this.privEdge;
+ if (edge !== undefined) {
+ yield new Slot(edge.node, (value) => edge.node = value);
+ }
+
+ yield* super.buildSlots();
+ }
+}