[Pyparsing] escape sequence in identifieres - with inline sourcecode
Brought to you by:
ptmcg
From: Diez B. R. <de...@we...> - 2010-04-02 13:23:35
|
Hi, it seems as if the ML strips attachments, so here comes the aforementioned example code inline: from pyparsing import * nmstart = Word(srange(r"[_a-zA-Z\\]")) # |{nonascii}|{escape} name = OneOrMore(Word(srange(r"[A-Z_a-z0-9-\\]"))) # TODO: nonascii & escape #numlit = Word(srange("[0-9]")) MINUS = Literal("-") IDENT = Combine(Optional(MINUS) + nmstart + ZeroOrMore(name), adjacent=True) # TODO print IDENT.parseString(r"foo\bar") print IDENT.parseString(r"foo\.bar") The output is (cssprocessor)mac-dir:ablcssprocessor deets$ python /tmp/test.py ['foo\\bar'] ['foo\\'] So you can see there is the whole "\.bar"-stuff missing. Diez |