Skip to content

Commit f3d87a7

Browse files
committed
feat: initial version
1 parent 20c8387 commit f3d87a7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/compiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { RegexElement } from './types';
22
import { characterClasses, isCharacterClass } from './character-classes';
3+
import { compileChoiceOf } from './components/choiceOf';
34
import { baseQuantifiers, isBaseQuantifier } from './quantifiers/base';
45
import { compileRepeat } from './quantifiers/repeat';
56

@@ -38,6 +39,10 @@ function compileSingle(element: RegexElement): string {
3839
return characterClasses[element.type];
3940
}
4041

42+
if (element.type === 'choiceOf') {
43+
return compileChoiceOf(element)
44+
}
45+
4146
const compiledChildren = compileList(element.children);
4247

4348
if (element.type === 'repeat') {

src/components/choiceOf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export function choiceOf(...children: string[]): ChoiceOf {
88
};
99
}
1010

11-
export function compileChoiceOf(component: ChoiceOf): string {
12-
return wrapGroup(component.children.join('|'));
11+
export function compileChoiceOf(element: ChoiceOf): string {
12+
return wrapGroup(element.children.join('|'));
1313
}

0 commit comments

Comments
 (0)