Bulletproofing operator overloads using generated data
This commit is contained in:
56
meta.py
56
meta.py
@@ -5,40 +5,46 @@ def pascal_to_snake(v):
|
||||
name = snake_case_pattern.sub('_', v).lower()
|
||||
return name
|
||||
|
||||
BINARY_EXPR = 1
|
||||
UNARY_EXPR = 2
|
||||
|
||||
token_simple_expr = [
|
||||
["Mul", "*"],
|
||||
["Div", "/"],
|
||||
["Mod", "%"],
|
||||
["LeftShift", "<<"],
|
||||
["RightShift", ">>"],
|
||||
["Mul", "*", BINARY_EXPR],
|
||||
["Div", "/", BINARY_EXPR],
|
||||
["Mod", "%", BINARY_EXPR],
|
||||
["LeftShift", "<<", BINARY_EXPR],
|
||||
["RightShift", ">>", BINARY_EXPR],
|
||||
["FirstMul = TK_Mul", "SPECIAL"],
|
||||
["LastMul = TK_RightShift", "SPECIAL"],
|
||||
["Add", "+"],
|
||||
["Sub", "-"],
|
||||
["Add", "+", BINARY_EXPR | UNARY_EXPR],
|
||||
["Sub", "-", BINARY_EXPR | UNARY_EXPR],
|
||||
["FirstAdd = TK_Add", "SPECIAL"],
|
||||
["LastAdd = TK_Sub", "SPECIAL"],
|
||||
["Equals", "=="],
|
||||
["LesserThenOrEqual", "<="],
|
||||
["GreaterThenOrEqual", ">="],
|
||||
["LesserThen", "<"],
|
||||
["GreaterThen", ">"],
|
||||
["NotEquals", "!="],
|
||||
["Equals", "==", BINARY_EXPR],
|
||||
["LesserThenOrEqual", "<=", BINARY_EXPR],
|
||||
["GreaterThenOrEqual", ">=", BINARY_EXPR],
|
||||
["LesserThen", "<", BINARY_EXPR],
|
||||
["GreaterThen", ">", BINARY_EXPR],
|
||||
["NotEquals", "!=", BINARY_EXPR],
|
||||
["FirstCompare = TK_Equals", "SPECIAL"],
|
||||
["LastCompare = TK_NotEquals", "SPECIAL"],
|
||||
["BitAnd", "&"],
|
||||
["BitOr", "|"],
|
||||
["BitXor", "^"],
|
||||
["And", "&&"],
|
||||
["Or", "||"],
|
||||
["BitAnd", "&", BINARY_EXPR],
|
||||
["BitOr", "|", BINARY_EXPR],
|
||||
["BitXor", "^", BINARY_EXPR],
|
||||
["And", "&&", BINARY_EXPR],
|
||||
["Or", "||", BINARY_EXPR],
|
||||
["FirstLogical = TK_BitAnd", "SPECIAL"],
|
||||
["LastLogical = TK_Or", "SPECIAL"],
|
||||
|
||||
["Neg", "~"],
|
||||
["Not", "!"],
|
||||
["Decrement", "--"],
|
||||
["Increment", "++"],
|
||||
["PostDecrement", "--"],
|
||||
["PostIncrement", "++"],
|
||||
["Neg", "~", UNARY_EXPR],
|
||||
["Not", "!", UNARY_EXPR],
|
||||
]
|
||||
|
||||
token_inc_expr = [
|
||||
["Decrement", "--", UNARY_EXPR],
|
||||
["Increment", "++", UNARY_EXPR],
|
||||
["PostDecrement", "--", UNARY_EXPR],
|
||||
["PostIncrement", "++", UNARY_EXPR],
|
||||
]
|
||||
|
||||
token_assign_expr = [
|
||||
@@ -89,7 +95,7 @@ token_rest = [
|
||||
["Keyword", "[Keyword]"],
|
||||
]
|
||||
|
||||
token_kinds = token_simple_expr + token_assign_expr + token_rest
|
||||
token_kinds = token_simple_expr + token_inc_expr + token_assign_expr + token_rest
|
||||
|
||||
keywords = [
|
||||
"struct",
|
||||
|
||||
Reference in New Issue
Block a user