def lexical_hilite(self): self.lexer.tokens.reverse() out = [] for t in self.lexer.tokens: add_br = False attrib = self.theme.Operators if EzhilToken.is_keyword(t.kind): attrib = self.theme.Keywords if (EzhilToken.get_name(t.kind) in ["END", "ELSE"]): out.append('<BR />\n') elif EzhilToken.is_number(t.kind): attrib = self.theme.LiteralNumber elif EzhilToken.is_string(t.kind): attrib = self.theme.LiteralString t.val = '"' + t.val + '"' #FIXME: ideally do some escaping as well elif EzhilToken.is_id(t.kind): attrib = self.theme.Variables elif (t.val in ["@", "பதிப்பி"]): attrib = self.theme.Builtins out.append('<BR />\n') t.val = " " + str(t.val) out.append(self.styler(attrib, t.val)) if (add_br): out.append("<BR />\n") return "".join(out)
def lexical_hilite(self): self.lexer.tokens.reverse() out = [] for t in self.lexer.tokens: add_br = False attrib = self.theme.Operators if EzhilToken.is_keyword(t.kind): attrib = self.theme.Keywords if ( EzhilToken.get_name(t.kind) in ["END", "ELSE"] ): out.append('<BR />\n') elif EzhilToken.is_number(t.kind): attrib = self.theme.LiteralNumber elif EzhilToken.is_string(t.kind): attrib = self.theme.LiteralString t.val = '"'+t.val+'"' #FIXME: ideally do some escaping as well elif EzhilToken.is_id(t.kind): attrib = self.theme.Variables elif( t.val in ["@", "பதிப்பி" ] ): attrib = self.theme.Builtins out.append('<BR />\n') t.val = " " + str(t.val) out.append( self.styler(attrib,t.val) ) if ( add_br ): out.append("<BR />\n") return "".join(out)
def match(self,kind): ## if match return token, else ParseException tok = self.dequeue() if ( tok.kind != kind ): raise ParseException(u"cannot find token "+ \ EzhilToken.get_name(kind) + u" got " \ + unicode(tok) \ + u" instead!") return tok
def match(self, kind): ## if match return token, else ParseException tok = self.dequeue() if (tok.kind != kind): raise ParseException("cannot find token "+ \ EzhilToken.get_name(kind) + " got " \ + str(tok) \ + " instead!") return tok