stumped by tricky logic
Roy Smith
roy at panix.com
Sun Jan 29 13:33:52 EST 2006
"Dave" <davidworley at gmail.com> wrote:
> So I'm trying to write a CSS preprocessor.
What you're trying to do is write a parser. I don't know CSS, so I can't
comment on the details, but basically, you're trying to parse a non-trivial
language. It is usually hopeless to try and write a parser using just
pattern-matching. You really need to read up on grammars and parsers to do
this right. Consider, for example, something like
#selector { /* } */ foo; }
getting that right is pretty tricky, and this is far from the most complex
example possible.
I think you might want to start at
http://python.miscellaneousmirror.org/topics/parsing.html, and do a bunch
of reading about parsing theory, before you sit down to start writing code.
More information about the Python-list
mailing list