A construction that assigns a Boolean 1D TQFT with defects to a finite state\nautomaton was recently developed by Gustafson, Im, Kaldawy, Khovanov, and Lihn.\nWe show that the construction is functorial with respect to the category of\nfinite state automata with transducers as morphisms. Certain classes of\nsubregular languages correspond to additional cohomological structures on the\nassociated TQFTs. We also show that the construction generalizes to\ncontext-free grammars through a categorical version of the\nChomsky-Sch\\"utzenberger representation theorem, due to Melli\\`es and\nZeilberger. The corresponding TQFTs are then described as morphisms of colored\noperads on an operad of cobordisms with defects.\n