Skip to content

Commit

Permalink
Split generating and printing the string regex circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
Shigoto-dev19 committed Jul 20, 2024
1 parent a41bdb2 commit a8b78d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class RegexCompiler {
private initialState: null | number = null;
private acceptState: number;

public stringRegexCircuit: string;

constructor(rawRegex: string, logsEnabled = false) {
this.rawRegex = rawRegex;
this.expandedRegex = parseRawRegex(rawRegex, logsEnabled);
Expand Down Expand Up @@ -491,7 +493,7 @@ export class RegexCompiler {
return revealLines;
}

printRegexCircuit(
generateStringRegexCircuit(
countEnabled: boolean,
revealEnabled: boolean,
transitionInput?: string[] | [number, number][][],
Expand All @@ -503,11 +505,15 @@ export class RegexCompiler {
.concat(this.writeBodyLines())
.concat(this.writeAcceptLines(countEnabled));

const stringRegexCircuit =
this.stringRegexCircuit =
`\n${functionName}(input: UInt8[]) {\n` +
circuitLines.join('\n\t') +
this.writeRevealLines(revealEnabled, transitionInput) +
'\n}';
}

printRegexCircuit(stringRegexCircuit?: string) {
stringRegexCircuit = stringRegexCircuit ?? this.stringRegexCircuit;

const BOLD_GREEN = '\x1b[32;1m';
console.log(
Expand Down

0 comments on commit a8b78d6

Please sign in to comment.