From 0b6210cd37b68b94252cb798598b12974a20e1c1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 21 May 2024 22:56:19 +0200 Subject: Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3. Signed-off-by: Daniel Baumann --- .../test/fixtures/implementation/node/base.ts | 39 ++++++++++++++++++++++ .../test/fixtures/implementation/node/consume.ts | 8 +++++ .../test/fixtures/implementation/node/empty.ts | 8 +++++ .../test/fixtures/implementation/node/error.ts | 10 ++++++ .../test/fixtures/implementation/node/index.ts | 15 +++++++++ .../test/fixtures/implementation/node/invoke.ts | 8 +++++ .../test/fixtures/implementation/node/pause.ts | 8 +++++ .../test/fixtures/implementation/node/sequence.ts | 15 +++++++++ .../test/fixtures/implementation/node/single.ts | 22 ++++++++++++ .../test/fixtures/implementation/node/span-end.ts | 8 +++++ .../fixtures/implementation/node/span-start.ts | 8 +++++ .../fixtures/implementation/node/table-lookup.ts | 8 +++++ 12 files changed, 157 insertions(+) create mode 100644 llparse-frontend/test/fixtures/implementation/node/base.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/consume.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/empty.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/error.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/index.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/invoke.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/pause.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/sequence.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/single.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/span-end.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/span-start.ts create mode 100644 llparse-frontend/test/fixtures/implementation/node/table-lookup.ts (limited to 'llparse-frontend/test/fixtures/implementation/node') 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 { + 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).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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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; + 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 { + 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; + 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 { + 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 { + 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 { + protected doBuild(out: string[]): void { + out.push(this.format('')); + } +} -- cgit v1.2.3