I'd like to use lex/yacc to read in a delimited text file. This would be pretty trivial stuff for a parser, but different text files have different delimiters, so I'd like to let the user specify whether the text is separated by tabs, spaces, commas, pipes, unicode snowmen, et cetera.
The normal means of using these tools is to write a spec for lex and yacc, compile, and then use the static code for parsing. But is there a way to let the user specify the delimiter (and thus redefine the tokens) at run time?
I'm currently using flex/bison, but am open to suggestions of small and portable alternatives.