xml dump: add more token attributes
This commit is contained in:
parent
46a0ab1754
commit
c5e9da2984
|
@ -3827,6 +3827,31 @@ void Tokenizer::dump(std::ostream &out) const
|
||||||
out << " <token id=\"" << tok << "\" file=\"" << toxml(list.file(tok)) << "\" linenr=\"" << tok->linenr() << '\"';
|
out << " <token id=\"" << tok << "\" file=\"" << toxml(list.file(tok)) << "\" linenr=\"" << tok->linenr() << '\"';
|
||||||
out << " str=\"" << toxml(tok->str()) << '\"';
|
out << " str=\"" << toxml(tok->str()) << '\"';
|
||||||
out << " scope=\"" << tok->scope() << '\"';
|
out << " scope=\"" << tok->scope() << '\"';
|
||||||
|
if (tok->isName())
|
||||||
|
out << " type=\"name\"";
|
||||||
|
else if (tok->isNumber()) {
|
||||||
|
out << " type=\"number\"";
|
||||||
|
if (MathLib::isInt(tok->str()))
|
||||||
|
out << " isInt=\"True\"";
|
||||||
|
if (MathLib::isFloat(tok->str()))
|
||||||
|
out << " isFloat=\"True\"";
|
||||||
|
} else if (tok->type() == Token::eString)
|
||||||
|
out << " type=\"string\" strlen=\"" << Token::getStrLength(tok) << '\"';
|
||||||
|
else if (tok->type() == Token::eChar)
|
||||||
|
out << " type=\"char\"";
|
||||||
|
else if (tok->isBoolean())
|
||||||
|
out << " type=\"boolean\"";
|
||||||
|
else if (tok->isOp()) {
|
||||||
|
out << " type=\"op\"";
|
||||||
|
if (tok->isArithmeticalOp())
|
||||||
|
out << " isArithmeticalOp=\"True\"";
|
||||||
|
else if (tok->isAssignmentOp())
|
||||||
|
out << " isAssignmentOp=\"True\"";
|
||||||
|
else if (tok->isComparisonOp())
|
||||||
|
out << " isComparisonOp=\"True\"";
|
||||||
|
else if (tok->type() == Token::eLogicalOp)
|
||||||
|
out << " isLogicalOp=\"True\"";
|
||||||
|
}
|
||||||
if (tok->link())
|
if (tok->link())
|
||||||
out << " link=\"" << tok->link() << '\"';
|
out << " link=\"" << tok->link() << '\"';
|
||||||
if (tok->varId() > 0U)
|
if (tok->varId() > 0U)
|
||||||
|
|
|
@ -4,29 +4,41 @@
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
class Token:
|
class Token:
|
||||||
Id = None
|
Id = None
|
||||||
str = None
|
str = None
|
||||||
next = None
|
next = None
|
||||||
previous = None
|
previous = None
|
||||||
scopeId = None
|
scopeId = None
|
||||||
scope = None
|
scope = None
|
||||||
linkId = None
|
isName = None
|
||||||
link = None
|
isNumber = None
|
||||||
varId = None
|
isInt = None
|
||||||
variableId = None
|
isFloat = None
|
||||||
variable = None
|
isString = None
|
||||||
functionId = None
|
strlen = None
|
||||||
function = None
|
isChar = None
|
||||||
valuesId = None
|
isOp = None
|
||||||
values = None
|
isArithmeticalOp = None
|
||||||
astParentId = None
|
isAssignmentOp = None
|
||||||
astParent = None
|
isComparisonOp = None
|
||||||
astOperand1Id = None
|
isLogicalOp = None
|
||||||
astOperand1 = None
|
linkId = None
|
||||||
astOperand2Id = None
|
link = None
|
||||||
astOperand2 = None
|
varId = None
|
||||||
file = None
|
variableId = None
|
||||||
linenr = None
|
variable = None
|
||||||
|
functionId = None
|
||||||
|
function = None
|
||||||
|
valuesId = None
|
||||||
|
values = None
|
||||||
|
astParentId = None
|
||||||
|
astParent = None
|
||||||
|
astOperand1Id = None
|
||||||
|
astOperand1 = None
|
||||||
|
astOperand2Id = None
|
||||||
|
astOperand2 = None
|
||||||
|
file = None
|
||||||
|
linenr = None
|
||||||
|
|
||||||
def __init__(self, element):
|
def __init__(self, element):
|
||||||
self.Id = element.get('id')
|
self.Id = element.get('id')
|
||||||
|
@ -35,6 +47,30 @@ class Token:
|
||||||
self.previous = None
|
self.previous = None
|
||||||
self.scopeId = element.get('scope')
|
self.scopeId = element.get('scope')
|
||||||
self.scope = None
|
self.scope = None
|
||||||
|
type = element.get('type')
|
||||||
|
if type == 'name':
|
||||||
|
self.isName = True
|
||||||
|
elif type == 'number':
|
||||||
|
self.isNumber = True
|
||||||
|
if element.get('isInt'):
|
||||||
|
self.isInt = True
|
||||||
|
elif element.get('isFloat'):
|
||||||
|
self.isFloat = True
|
||||||
|
elif type == 'string':
|
||||||
|
self.isString = True
|
||||||
|
self.strlen = int(element.get('strlen'))
|
||||||
|
elif type == 'char':
|
||||||
|
self.isChar = True
|
||||||
|
elif type == 'op':
|
||||||
|
self.isOp = True
|
||||||
|
if element.get('isArithmeticalOp'):
|
||||||
|
self.isArithmeticalOp = True
|
||||||
|
elif element.get('isAssignmentOp'):
|
||||||
|
self.isAssignmentOp = True
|
||||||
|
elif element.get('isComparisonOp'):
|
||||||
|
self.isComparisonOp = True
|
||||||
|
elif element.get('isLogicalOp'):
|
||||||
|
self.isLogicalOp = True
|
||||||
self.linkId = element.get('link')
|
self.linkId = element.get('link')
|
||||||
self.link = None
|
self.link = None
|
||||||
self.varId = element.get('varId')
|
self.varId = element.get('varId')
|
||||||
|
|
Loading…
Reference in New Issue