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.
24 lines
780 B
TypeScript
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) || [],
|
|
);
|
|
}
|
|
}
|