Skip to content

Commit a900a7a

Browse files
committed
chore: use erasableSyntaxOnly
1 parent 1c14651 commit a900a7a

10 files changed

Lines changed: 46 additions & 19 deletions

File tree

src/api.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import * as frontend from 'llparse-frontend';
2-
3-
import source = frontend.source;
1+
import { source } from 'llparse-frontend';
42

53
import { Compiler, ICompilerOptions, ICompilerResult } from './compiler';
64

@@ -12,6 +10,8 @@ export { source, ICompilerOptions, ICompilerResult };
1210
* LLParse graph builder and compiler.
1311
*/
1412
export class LLParse extends source.Builder {
13+
private readonly prefix: string;
14+
1515
/**
1616
* The prefix controls the names of methods and state struct in generated
1717
* public C headers:
@@ -28,10 +28,11 @@ export class LLParse extends source.Builder {
2828
*
2929
* @param prefix Prefix to be used when generating public API.
3030
*/
31-
constructor(private readonly prefix: string = 'llparse') {
31+
constructor(prefix: string = 'llparse') {
3232
super();
33+
this.prefix = prefix;
3334
}
34-
35+
3536
/**
3637
* Compile LLParse graph to the C code and C headers
3738
*

src/compiler/header-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as frontend from 'llparse-frontend';
2-
import source = frontend.source;
2+
import { source } from 'llparse-frontend';
33

44
export interface IHeaderBuilderOptions {
55
readonly prefix: string;

src/compiler/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as debugAPI from 'debug';
22
import * as frontend from 'llparse-frontend';
3-
4-
import source = frontend.source;
3+
import { source } from 'llparse-frontend';
54

65
import * as cImpl from '../implementation/c';
76
import { HeaderBuilder } from './header-builder';
@@ -50,8 +49,13 @@ export interface ICompilerResult {
5049
}
5150

5251
export class Compiler {
53-
constructor(public readonly prefix: string,
54-
public readonly options: ICompilerOptions) {
52+
public readonly prefix: string;
53+
public readonly options: ICompilerOptions;
54+
55+
constructor(prefix: string,
56+
options: ICompilerOptions) {
57+
this.prefix = prefix;
58+
this.options = options;
5559
}
5660

5761
public compile(root: source.node.Node,

src/implementation/c/code/base.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { Compilation } from '../compilation';
44

55
export abstract class Code<T extends frontend.code.Code> {
66
protected cachedDecl: string | undefined;
7+
public readonly ref: T;
78

8-
constructor(public readonly ref: T) {
9+
constructor(ref: T) {
10+
this.ref = ref;
911
}
1012

1113
public abstract build(ctx: Compilation, out: string[]): void;

src/implementation/c/compilation.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@ export class Compilation {
4242
Map<string, MatchSequence> = new Map();
4343
private readonly resumptionTargets: Set<string> = new Set();
4444

45-
constructor(public readonly prefix: string,
46-
private readonly properties: ReadonlyArray<ICompilationProperty>,
45+
public readonly prefix: string;
46+
private readonly properties: ReadonlyArray<ICompilationProperty>;
47+
private readonly options: ICompilationOptions;
48+
49+
constructor(prefix: string,
50+
properties: ReadonlyArray<ICompilationProperty>,
4751
resumptionTargets: ReadonlySet<WrappedNode>,
48-
private readonly options: ICompilationOptions) {
52+
options: ICompilationOptions) {
53+
this.prefix = prefix;
54+
this.properties = properties;
55+
this.options = options;
56+
4957
for (const node of resumptionTargets) {
5058
this.resumptionTargets.add(STATE_PREFIX + node.ref.id.name);
5159
}

src/implementation/c/helpers/match-sequence.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { Compilation } from '../compilation';
99
type TransformWrap = Transform<frontend.transform.Transform>;
1010

1111
export class MatchSequence {
12-
constructor(private readonly transform: TransformWrap) {
12+
private readonly transform: TransformWrap;
13+
14+
constructor(transform: TransformWrap) {
15+
this.transform = transform;
1316
}
1417

1518
public static buildGlobals(out: string[]): void {

src/implementation/c/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ export interface ICPublicOptions {
2121
}
2222

2323
export class CCompiler {
24+
public readonly options: ICCompilerOptions;
25+
2426
constructor(container: frontend.Container,
25-
public readonly options: ICCompilerOptions) {
27+
options: ICCompilerOptions) {
28+
this.options = options;
2629
container.add(CONTAINER_KEY, { code, node, transform });
2730
}
2831

src/implementation/c/node/base.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ export interface INodeEdge {
1515
export abstract class Node<T extends frontend.node.Node> {
1616
protected cachedDecl: string | undefined;
1717
protected privCompilation: Compilation | undefined;
18+
public readonly ref: T;
1819

19-
constructor(public readonly ref: T) {
20+
constructor(ref: T) {
21+
this.ref = ref;
2022
}
2123

2224
public build(compilation: Compilation): string {

src/implementation/c/transform/base.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import * as frontend from 'llparse-frontend';
33
import { Compilation } from '../compilation';
44

55
export abstract class Transform<T extends frontend.transform.Transform> {
6-
constructor(public readonly ref: T) {
6+
public readonly ref: T;
7+
8+
constructor(ref: T) {
9+
this.ref = ref;
710
}
811

912
public abstract build(ctx: Compilation, value: string): string;

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"pretty": true,
1010
"sourceMap": true,
1111
"noUncheckedIndexedAccess": true,
12-
"noUnusedLocals": true
12+
"noUnusedLocals": true,
13+
"erasableSyntaxOnly": true
1314
},
1415
"include": [
1516
"src/**/*.ts"

0 commit comments

Comments
 (0)