parent
a1a6066a33
commit
10abc6661a
|
@ -1,4 +1,4 @@
|
|||
import sys
|
||||
import re, sys
|
||||
from lex3 import Token
|
||||
|
||||
color_list = []
|
||||
|
@ -16,6 +16,21 @@ color_dict ={}
|
|||
for i in range(0, len(color_list)):
|
||||
color_dict[color_names[i]] = color_list[i]
|
||||
|
||||
def token_match(self, token, name, data=None):
|
||||
return token.fqname() == name and data is None or token.string == data
|
||||
def token_match2(self, token, name, regex):
|
||||
return token.fqname() == name and regex.match(token.string)
|
||||
def token_vmatch(self, token, *pairs):
|
||||
for (name, data) in pairs:
|
||||
if token_match(token, name, data):
|
||||
return True
|
||||
return False
|
||||
def token_vmatch2(self, token, *pairs):
|
||||
for (name, regex) in pairs:
|
||||
if token_match(token, name, regex):
|
||||
return True
|
||||
return False
|
||||
|
||||
class Highlighter:
|
||||
def __init__(self, lexer):
|
||||
self.lexer = lexer
|
||||
|
|
Loading…
Reference in New Issue