W3C home > Mailing lists > Public > www-archive@w3.org > August 2002

Pre-processing Scanner-subclass Code

From: Sean B. Palmer <sean@mysterylights.com>
Date: Fri, 16 Aug 2002 00:05:16 +0100
Message-ID: <007c01c244b0$3b128ec0$9a560150@localhost>
To: "Dan Connolly" <connolly@w3.org>
Cc: <www-archive@w3.org>

class Scanner(_Scanner):
    def __init__(self, patterns, ignore, input):
        _Scanner.__init__(self, patterns, ignore, input)
        self.preProcess()

    def preProcess(self):
        B_LIT = r'"""[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
        A_LIT = r'"[^"\\]*(?:\\.[^"\\]*)*"'
        Token = re.compile(r'(%s|%s|<[^>]*>|\.\s*}|[^\s#]+)' % (B_LIT,
A_LIT))
        self.input = ' '.join([re.sub(r'^\.\s*}$', '}', token)
                             for token in Token.findall(self.input)])

For yappsrt.py--class Scanner needs to be renamed _Scanner.

--
Kindest Regards,
Sean B. Palmer
@prefix : <http://purl.org/net/swn#> .
:Sean :homepage <http://purl.org/net/sbp/> .
Received on Thursday, 15 August 2002 19:05:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 7 November 2012 14:17:22 GMT