I have the following file:
orange
apple
orange
apple
apple
lime
banana
Each type of fruit has a class to match it:
class Banana:
grammar = ....
class Apple:
...
I have to match each fruit unordered, I cannot tell upfront what will be the order. How can I setup a FruitBasket
grammar to match'em?
class FruitBasket:
grammar = ?????
ps: The fruits are actually complicated rules, each fruit type stands for a different code block, such as a function, prototype, global variable, etc.
Use a list:
For example:
Output: