Re: [Pyparsing] escape sequence in identifieres - with inline sourcecode
Brought to you by:
ptmcg
From: spir ☣ <den...@gm...> - 2010-04-06 10:47:34
|
On Fri, 2 Apr 2010 15:23:27 +0200 "Diez B. Roggisch" <de...@we...> wrote: > 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 (Not really sure about your intent.) You seem to be using pyparsing features rather strangely. The 'Word' pattern type allows defining distinct patterns for start and (optional) following characters. Both are character _classes_. You could use it like: nameStartChar = ... nameFollowingChar = ... name = Word(nameStartChar,nameFollowingChar) If you want to generalize name to include a dotted format, then rename the above to namePart and write a pattern including dots. Denis ________________________________ vit esse estrany ☣ spir.wikidot.com |