File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,17 @@ program
1515 'Partial state transitions to reveal'
1616 )
1717 . option ( '-s, --revealSubpatterns <values...>' , 'Regex subpatterns to reveal' )
18+ . option (
19+ '-n, --functionName <name>' ,
20+ 'Function name to give to the regex circuit'
21+ )
1822 . action ( ( rawRegex , options ) => {
1923 // Extract and set the options
2024 const countEnabled = options . count || false ;
2125 let revealEnabled = false ;
26+ const functionName = options . functionName
27+ ? 'function ' + options . functionName
28+ : '' ;
2229
2330 let revealInput : string [ ] | [ number , number ] [ ] [ ] | undefined = undefined ;
2431
@@ -48,7 +55,12 @@ program
4855 }
4956
5057 // Print the regex circuit based on the options
51- compiler . printRegexCircuit ( countEnabled , revealEnabled , revealInput ) ;
58+ compiler . printRegexCircuit (
59+ countEnabled ,
60+ revealEnabled ,
61+ revealInput ,
62+ functionName
63+ ) ;
5264 } ) ;
5365
5466// Parse the command-line arguments
Original file line number Diff line number Diff line change @@ -494,7 +494,8 @@ export class RegexCompiler {
494494 printRegexCircuit (
495495 countEnabled : boolean ,
496496 revealEnabled : boolean ,
497- transitionInput ?: string [ ] | [ number , number ] [ ] [ ]
497+ transitionInput ?: string [ ] | [ number , number ] [ ] [ ] ,
498+ functionName ?: string
498499 ) {
499500 let circuitLines : string [ ] = [ ] ;
500501 circuitLines = this . writeDeclarationLines ( )
@@ -503,7 +504,7 @@ export class RegexCompiler {
503504 . concat ( this . writeAcceptLines ( countEnabled ) ) ;
504505
505506 const stringRegexCircuit =
506- '\n (input: UInt8[]) {\n' +
507+ `\n ${ functionName } (input: UInt8[]) {\n` +
507508 circuitLines . join ( '\n\t' ) +
508509 this . writeRevealLines ( revealEnabled , transitionInput ) +
509510 '\n}' ;
You can’t perform that action at this time.
0 commit comments