3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-16 17:09:33 +01:00

Update paren.py module to improve parentheses verbosity

This commit is contained in:
Pragmatic Software 2014-12-20 19:44:40 +00:00
parent a09d3c1d63
commit ba59edb040
2 changed files with 7 additions and 5 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 801, BUILD_REVISION => 802,
BUILD_DATE => "2014-12-18", BUILD_DATE => "2014-12-20",
}; };
1; 1;

View File

@ -35,6 +35,9 @@ class CParser(c_parser.CParser):
class CGenerator(c_generator.CGenerator): class CGenerator(c_generator.CGenerator):
def _is_simple_node(self, n):
return isinstance(n, (c_ast.Constant, c_ast.ID, c_ast.FuncCall))
def visit_UnaryOp(self, n): def visit_UnaryOp(self, n):
# don't parenthesize an operand to sizeof if it's not a type # don't parenthesize an operand to sizeof if it's not a type
if n.op == 'sizeof': if n.op == 'sizeof':
@ -79,4 +82,3 @@ if __name__ == "__main__":
print("Usage: paren <expression>") print("Usage: paren <expression>")
else: else:
print('error') print('error')