am 84336795: am eec57b37: Merge "Add support for the ternary operator to the header scrubber."
* commit '843367953f40ee84bcc53e08a60c82215303e1fb': Add support for the ternary operator to the header scrubber.
This commit is contained in:
commit
8acd5dd2f8
@ -554,19 +554,21 @@ class CppExpr:
|
|||||||
where "op" is a string describing the operation"""
|
where "op" is a string describing the operation"""
|
||||||
|
|
||||||
unaries = [ "!", "~" ]
|
unaries = [ "!", "~" ]
|
||||||
binaries = [ "+", "-", "<", "<=", ">=", ">", "&&", "||", "*", "/", "%", "&", "|", "^", "<<", ">>", "==", "!=" ]
|
binaries = [ "+", "-", "<", "<=", ">=", ">", "&&", "||", "*", "/", "%", "&", "|", "^", "<<", ">>", "==", "!=", "?", ":" ]
|
||||||
precedences = { "||": 1,
|
precedences = {
|
||||||
"&&": 2,
|
"?": 1, ":": 1,
|
||||||
"|": 3,
|
"||": 2,
|
||||||
"^": 4,
|
"&&": 3,
|
||||||
"&": 5,
|
"|": 4,
|
||||||
"==":6, "!=":6,
|
"^": 5,
|
||||||
"<":7, "<=":7, ">":7, ">=":7,
|
"&": 6,
|
||||||
"<<":8, ">>":8,
|
"==": 7, "!=": 7,
|
||||||
"+":9, "-":9,
|
"<": 8, "<=": 8, ">": 8, ">=": 8,
|
||||||
"*":10, "/":10, "%":10,
|
"<<": 9, ">>": 9,
|
||||||
"!":11, "~":12
|
"+": 10, "-": 10,
|
||||||
}
|
"*": 11, "/": 11, "%": 11,
|
||||||
|
"!": 12, "~": 12
|
||||||
|
}
|
||||||
|
|
||||||
re_cpp_constant = re.compile(r"((\d|\w|_)+)")
|
re_cpp_constant = re.compile(r"((\d|\w|_)+)")
|
||||||
|
|
||||||
@ -581,7 +583,7 @@ class CppExpr:
|
|||||||
if debugCppExpr:
|
if debugCppExpr:
|
||||||
print "CppExpr: got " + repr(self.expr)
|
print "CppExpr: got " + repr(self.expr)
|
||||||
if self.i != self.n:
|
if self.i != self.n:
|
||||||
print 'crap at end of input (%d != %d)' % (self.i, self.n)
|
print 'crap at end of input (%d != %d): %s' % (self.i, self.n, repr(tokens))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@ -778,6 +780,10 @@ class CppExpr:
|
|||||||
self.nextToken()
|
self.nextToken()
|
||||||
primary = self.parseExpression(0)
|
primary = self.parseExpression(0)
|
||||||
self.expectId(tokRPAREN)
|
self.expectId(tokRPAREN)
|
||||||
|
elif op.id == "?":
|
||||||
|
self.nextToken()
|
||||||
|
primary = self.parseExpression(0)
|
||||||
|
self.expectId(":")
|
||||||
elif op.id == tokNUMBER:
|
elif op.id == tokNUMBER:
|
||||||
primary = self.is_number()
|
primary = self.is_number()
|
||||||
elif op.id == tokIDENT:
|
elif op.id == tokIDENT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user