tags:

views:

34

answers:

2

Hi, I'm investigating a possible design. Is their a way or established mechanism, or pattern, to select a set of arbitary methods to excute depending on some input. For example, if you were trying to implement a lexer, and you didn't want to go so far as implementing using lex, or even going a far as implementing an LL(1) or LR(k) parser.

So, you have some input. Say, A B C, then a mechanism would select MethodA, MethodB, MethodC, then the second input was A then D, so the code mechanism would select MethodA, then MethodD for execution.

What tools, patters, engines, parsers code would enable that kind of scenario.

It could be the case that I can see the forest for trees, or whatever that phrase is, but their must be a standard way of doing it. Bob.

+2  A: 

This sounds like it could be handled by the Chain of Responsibility pattern to me.

TrueWill
Thats wat I was looking for. Thanks.
scope_creep
A: 

From your problem description, I can't think of a "standard" way to do it.

You could use reflection to build a table of the available methods and then map them to possible inputs or input ranges.

CesarGon
Reflection is not really performant and would be far too slow for the usage scenario I have in mind. Thanks.
scope_creep
I see. So you would need to know the methods beforehand.
CesarGon