I was looking at lexar's...
but... I was thinking we need a parser no?
http://pyparsing.wikispaces.com/
found pyparsing
http://stackoverflow.com/questions/1651487/python-parsing-bracketed-blocks
>>> from pyparsing import nestedExpr
>>> txt = "{ { a } { b } { { { c } } } }"
>>>
>>> nestedExpr('{','}').parseString(txt).asList()
[[['a'], ['b'], [[['c']]]]]
>>>
lexer research:
If not
lexar wise I've found:
Pygments
http://pygments.org/docs/lexers/
Ply
http://www.dabeaz.com/ply/
and a big list
https://wiki.python.org/moin/LanguageParsing
So for a bit of background:
A lexer converts text into a sequence of tokens or glyphs. Using a series of regular expressions specified for each token, It would create a function what takes a raw file, and puts out a token structure every time it's called. Effectively it is a stream of tokens. This is something that I think a tool may help with for DF raws.
A parser converts the output of a lexer into rules based on the language grammar. So it has a grammar file that maps the structure of a DF raw to snippets of code that are run whenever a particular token sequence is encountered. It could read in a token and figure out what level token (Cast, creature, objext, etc), and have seperate code for each, including cases like when a cast level token is encountered creature level.
Of course to parse the raws you need both. However, grammar wise, the raws of DF are very simple. So what I'm saying is, you don't necessarily need a parser generator, and it may be simpler not to use one. Unless that is it comes bundled with the lexer anyway, and is easy to use because of that. So definitely look at lexers. Maybe look at parsers too, while you're at it. Often they are bundled together.
EDIT:
On second thought look at parsers too. You're if you're thinking of writing a parser, you should know what tools exist.