Files
privacy.sexy/src/application/Parser/Executable/Script/Compiler/Expressions/Parser/CompositeExpressionParser.ts
undergroundwires c138f74460 Refactor to unify scripts/categories as Executable
This commit consolidates scripts and categories under a unified
'Executable' concept. This simplifies the architecture and improves code
readability.

- Introduce subfolders within `src/domain` to segregate domain elements.
- Update class and interface names by removing the 'I' prefix in
  alignment with new coding standards.
- Replace 'Node' with 'Executable' to clarify usage; reserve 'Node'
  exclusively for the UI's tree component.
2024-06-12 12:36:40 +02:00

24 lines
780 B
TypeScript

import { ParameterSubstitutionParser } from '../SyntaxParsers/ParameterSubstitutionParser';
import { WithParser } from '../SyntaxParsers/WithParser';
import type { IExpression } from '../Expression/IExpression';
import type { IExpressionParser } from './IExpressionParser';
const Parsers: readonly IExpressionParser[] = [
new ParameterSubstitutionParser(),
new WithParser(),
] as const;
export class CompositeExpressionParser implements IExpressionParser {
public constructor(private readonly leafs: readonly IExpressionParser[] = Parsers) {
if (!leafs.length) {
throw new Error('missing leafs');
}
}
public findExpressions(code: string): IExpression[] {
return this.leafs.flatMap(
(parser) => parser.findExpressions(code) || [],
);
}
}