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:
parent
a09d3c1d63
commit
ba59edb040
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 801,
|
||||
BUILD_DATE => "2014-12-18",
|
||||
BUILD_REVISION => 802,
|
||||
BUILD_DATE => "2014-12-20",
|
||||
};
|
||||
|
||||
1;
|
||||
|
@ -4,7 +4,7 @@ from __future__ import print_function
|
||||
import sys
|
||||
|
||||
from pycparser import c_parser, c_generator, c_ast, plyparser
|
||||
from pycparser.ply import yacc
|
||||
from pycparser.ply import yacc
|
||||
|
||||
with open("paren/stddef") as f:
|
||||
STDDEF = f.read()
|
||||
@ -19,7 +19,7 @@ class CParser(c_parser.CParser):
|
||||
errorlog=yacc.NullLogger(),
|
||||
optimize=kw.get('yacc_optimize', True),
|
||||
tabmodule=kw.get('yacctab', 'yacctab'))
|
||||
|
||||
|
||||
def parse(self, text, filename='', debuglevel=0):
|
||||
self.clex.filename = filename
|
||||
self.clex.reset_lineno()
|
||||
@ -35,6 +35,9 @@ class CParser(c_parser.CParser):
|
||||
|
||||
|
||||
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):
|
||||
# don't parenthesize an operand to sizeof if it's not a type
|
||||
if n.op == 'sizeof':
|
||||
@ -79,4 +82,3 @@ if __name__ == "__main__":
|
||||
print("Usage: paren <expression>")
|
||||
else:
|
||||
print('error')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user