Library

FST · Rational transduction

Strip # comments

Copy text, dropping everything from a # to the end of its line: a is any ordinary character and n a newline, which ends a comment and is kept. A shell, Python or a configuration-file reader does this before anything else. Two states, and the comment state prints nothing.

codecommenta/a, n/n#/a/, #/n/n
The machine as drawn — 2 states, 6 transitions.

The author’s examples, run

# → rejecta → reject · a## → reject#a → reject### → rejectnnaan#na#aaaa### → reject · nnaanna