28 lines
979 B
Python
28 lines
979 B
Python
|
class tokenprinter:
|
||
|
def __init__(self, value):
|
||
|
self.value = value;
|
||
|
|
||
|
def children(self):
|
||
|
vtyp = str(self.value['type'])
|
||
|
if (vtyp == "EMPTY"): return [];
|
||
|
fieldOfType = { 'STRING':'string', 'FLOAT':'flt', 'INT':'integer',
|
||
|
'OPERATOR':'op', 'LIDENT':'lident', 'FIDENT':'fident',
|
||
|
'LOCATION':'location', 'EEK':'err', 'FUNCALL':'funcall',
|
||
|
'BOOL':'bl', 'STYLE':'style' };
|
||
|
name = fieldOfType[vtyp];
|
||
|
return [("u."+name, self.value['u'][name])]
|
||
|
|
||
|
def to_string(self):
|
||
|
vtyp = str(self.value['type'])
|
||
|
if (vtyp == "EMPTY"): return '<Empty Token>';
|
||
|
return '<Token>'
|
||
|
|
||
|
def ppfortoken(value):
|
||
|
"Return the token pretty-printer if 'value' is a Token."
|
||
|
typename = str(value.type.strip_typedefs().unqualified())
|
||
|
|
||
|
if (typename == 'struct Token_struc'): return tokenprinter(value)
|
||
|
return None
|
||
|
|
||
|
gdb.pretty_printers.append(ppfortoken)
|