summaryrefslogtreecommitdiffstats
path: root/llparse-frontend/test/fixtures/implementation/node
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/test/fixtures/implementation/node
parentInitial commit. (diff)
downloadnode-undici-upstream.tar.xz
node-undici-upstream.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/test/fixtures/implementation/node/base.ts39
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/consume.ts8
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/empty.ts8
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/error.ts10
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/index.ts15
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/invoke.ts8
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/pause.ts8
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/sequence.ts15
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/single.ts22
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/span-end.ts8
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/span-start.ts8
-rw-r--r--llparse-frontend/test/fixtures/implementation/node/table-lookup.ts8
12 files changed, 157 insertions, 0 deletions
diff --git a/llparse-frontend/test/fixtures/implementation/node/base.ts b/llparse-frontend/test/fixtures/implementation/node/base.ts
new file mode 100644
index 0000000..c9fd589
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/base.ts
@@ -0,0 +1,39 @@
+import { node } from '../../../../src/frontend';
+
+export abstract class Node<T extends node.Node> {
+ private built: boolean = false;
+
+ constructor(public readonly ref: T) {
+ }
+
+ public build(out: string[]): void {
+ if (this.built) {
+ return;
+ }
+
+ this.built = true;
+ this.doBuild(out);
+
+ if (this.ref.otherwise !== undefined) {
+ (this.ref.otherwise.node as Node<T>).build(out);
+ }
+ }
+
+ protected format(value: string): string {
+ let otherwise: string = '';
+ if (this.ref.otherwise !== undefined) {
+ const otherwiseRef = this.ref.otherwise.node.ref;
+ otherwise = ' otherwise' +
+ `${this.ref.otherwise.noAdvance ? '-no_adv' : ''}=` +
+ `${otherwiseRef.id.name}`;
+ if (this.ref.otherwise.value !== undefined) {
+ otherwise += `:${this.ref.otherwise.value}`;
+ }
+ }
+
+ return `<${this.constructor.name} name=${this.ref.id.name} ` +
+ `${value}${otherwise}/>`;
+ }
+
+ protected abstract doBuild(out: string[]): void;
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/consume.ts b/llparse-frontend/test/fixtures/implementation/node/consume.ts
new file mode 100644
index 0000000..cdc6cef
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/consume.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class Consume extends Node<node.Consume> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(`field=${this.ref.field}`));
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/empty.ts b/llparse-frontend/test/fixtures/implementation/node/empty.ts
new file mode 100644
index 0000000..ef1499b
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/empty.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class Empty extends Node<node.Empty> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(''));
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/error.ts b/llparse-frontend/test/fixtures/implementation/node/error.ts
new file mode 100644
index 0000000..1a4f31d
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/error.ts
@@ -0,0 +1,10 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+class ErrorNode extends Node<node.Error> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(`code=${this.ref.code} reason="${this.ref.reason}"`));
+ }
+}
+
+export { ErrorNode as Error };
diff --git a/llparse-frontend/test/fixtures/implementation/node/index.ts b/llparse-frontend/test/fixtures/implementation/node/index.ts
new file mode 100644
index 0000000..31dbc5e
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/index.ts
@@ -0,0 +1,15 @@
+import { Consume } from './consume';
+import { Empty } from './empty';
+import { Error } from './error';
+import { Invoke } from './invoke';
+import { Pause } from './pause';
+import { Sequence } from './sequence';
+import { Single } from './single';
+import { SpanEnd } from './span-end';
+import { SpanStart } from './span-start';
+import { TableLookup } from './table-lookup';
+
+export default {
+ Consume, Empty, Error, Invoke, Pause, Sequence, Single, SpanEnd,
+ SpanStart, TableLookup,
+};
diff --git a/llparse-frontend/test/fixtures/implementation/node/invoke.ts b/llparse-frontend/test/fixtures/implementation/node/invoke.ts
new file mode 100644
index 0000000..674be5f
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/invoke.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class Invoke extends Node<node.Invoke> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(''));
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/pause.ts b/llparse-frontend/test/fixtures/implementation/node/pause.ts
new file mode 100644
index 0000000..94da63c
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/pause.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class Pause extends Node<node.Pause> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(''));
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/sequence.ts b/llparse-frontend/test/fixtures/implementation/node/sequence.ts
new file mode 100644
index 0000000..bb745f5
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/sequence.ts
@@ -0,0 +1,15 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class Sequence extends Node<node.Sequence> {
+ protected doBuild(out: string[]): void {
+ let str = `select="${this.ref.select.toString('hex')}" ` +
+ `edge="${this.ref.edge!.node.ref.id.name}"`;
+ if (this.ref.edge!.value !== undefined) {
+ str += `:${this.ref.edge!.value}`;
+ }
+ out.push(this.format(str));
+ const edgeNode = this.ref.edge!.node as Node<node.Node>;
+ edgeNode.build(out);
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/single.ts b/llparse-frontend/test/fixtures/implementation/node/single.ts
new file mode 100644
index 0000000..b24ef93
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/single.ts
@@ -0,0 +1,22 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class Single extends Node<node.Single> {
+ protected doBuild(out: string[]): void {
+ const edges: string[] = [];
+ for (const edge of this.ref.edges) {
+ let str = `k${edge.key}${edge.noAdvance ? '-no_adv-' : ''}=` +
+ `${edge.node.ref.id.name}`;
+ if (edge.value !== undefined) {
+ str += `:${edge.value}`;
+ }
+ edges.push(str);
+ }
+ out.push(this.format(edges.join(' ')));
+
+ for (const edge of this.ref.edges) {
+ const edgeNode = edge.node as Node<node.Node>;
+ edgeNode.build(out);
+ }
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/span-end.ts b/llparse-frontend/test/fixtures/implementation/node/span-end.ts
new file mode 100644
index 0000000..dc79b81
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/span-end.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class SpanEnd extends Node<node.SpanEnd> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(''));
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/span-start.ts b/llparse-frontend/test/fixtures/implementation/node/span-start.ts
new file mode 100644
index 0000000..32e373c
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/span-start.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class SpanStart extends Node<node.SpanStart> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(''));
+ }
+}
diff --git a/llparse-frontend/test/fixtures/implementation/node/table-lookup.ts b/llparse-frontend/test/fixtures/implementation/node/table-lookup.ts
new file mode 100644
index 0000000..e6166d0
--- /dev/null
+++ b/llparse-frontend/test/fixtures/implementation/node/table-lookup.ts
@@ -0,0 +1,8 @@
+import { node } from '../../../../src/frontend';
+import { Node } from './base';
+
+export class TableLookup extends Node<node.TableLookup> {
+ protected doBuild(out: string[]): void {
+ out.push(this.format(''));
+ }
+}