1. A method for converting a context-free grammar to a finite-state automaton representing the context-free grammar, the method comprising: generating a first finite-state automaton from a set of rules associated with the context-free grammar; generating, from the first finite-state automaton, at least one second finite-state automaton; receiving a topology that defines an application of the context-free grammar; generating a third finite-state automaton that represents the received topology; and expanding the third finite-state automaton based on the at least one second finite-state automaton.