Logo Search packages:      
Sourcecode: zope-backtalk version File versions

def BackTalk::Syntax::Parser::__call__ (   self,
  toktype,
  toktext,
  srow,
  scol,
  erow,
  ecol,
  line 
)

Token handler.

Definition at line 86 of file Syntax.py.

00086                                                                         :
        """ Token handler.
        """
        if 0:
            print "type", toktype, token.tok_name[toktype], "text", toktext,
            print "start", srow,scol, "end", erow,ecol, "<br>"

        # calculate new positions
        oldpos = self.pos
        newpos = self.lines[srow] + scol
        self.pos = newpos + len(toktext)

        # handle newlines
        if toktype in [token.NEWLINE, tokenize.NL]:
            self.out = self.out + '\n'
            return

        # send the original whitespace, if needed
        if newpos > oldpos:
            self.out = self.out + self.raw[oldpos:newpos]

        # skip indenting tokens
        if toktype in [token.INDENT, token.DEDENT]:
            self.pos = newpos
            return

        # map token type to a color group
        if token.LPAR <= toktype and toktype <= token.OP:
            toktype = token.OP
        elif dtmlkeyword.iskeyword(toktext):
            toktype = _KEYWORD
        elif dtmlkeyword.isresword(toktext):
            toktype = _RESWORD
        elif toktype == token.NAME and keyword.iskeyword(toktext):
            toktype = _KEYWORD

        color = _colors.get(toktype, _colors[_TEXT])
        style = _styles.get(toktype, _styles[_TEXT])

        # send text
        self.out = self.out + '<font color="%s"%s>' % (color, style)
        self.out = self.out + cgi.escape(toktext)
        self.out = self.out + '</font>'
        self.out = self.out + '</font>'


Generated by  Doxygen 1.6.0   Back to index