In preparation for doing derivative parsing, it'd be nice to make concatenation, alternation, kleene star, and complement a flyweights.
Empty Set and Empty String are already Singletons, meaning we don't need to allocate memory each time we ask for an instance. Symbol will soon be a flyweight, meaning we only allocate space when we ask for a unique character.
If the remaining regular expression classes (concatenation, alternation, kleene star and complement) are flyweights, it would mean that we only allocate space when we request a unique object. This may seem a bit excessive, but when doing derivative parsing, we generate a new regular expression each time we match a character. Allocating and deallocating space unnecessarily will slow things down.
This is an issue to take on with more than one person, and once derivative parsing is implemented, to verify things work properly.
In preparation for doing derivative parsing, it'd be nice to make concatenation, alternation, kleene star, and complement a flyweights.
Empty Set and Empty String are already Singletons, meaning we don't need to allocate memory each time we ask for an instance. Symbol will soon be a flyweight, meaning we only allocate space when we ask for a unique character.
If the remaining regular expression classes (concatenation, alternation, kleene star and complement) are flyweights, it would mean that we only allocate space when we request a unique object. This may seem a bit excessive, but when doing derivative parsing, we generate a new regular expression each time we match a character. Allocating and deallocating space unnecessarily will slow things down.
This is an issue to take on with more than one person, and once derivative parsing is implemented, to verify things work properly.