diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-06-11 22:54:11 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-06-11 22:54:11 (GMT) |
commit | 87c8d87b9126d9060fe14c181187d6f16b1ad7f5 (patch) | |
tree | faf8009da7056c41da97119d865030765c91f87d /Parser | |
parent | 6520b685fd03669cf93a879f13e01b6436c299b3 (diff) | |
download | cpython-87c8d87b9126d9060fe14c181187d6f16b1ad7f5.zip cpython-87c8d87b9126d9060fe14c181187d6f16b1ad7f5.tar.gz cpython-87c8d87b9126d9060fe14c181187d6f16b1ad7f5.tar.bz2 |
Merged revisions 73196,73278-73280,73299,73308,73312-73313,73317-73318,73321,73324,73331,73335,73340,73363 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73196 | benjamin.peterson | 2009-06-03 20:40:29 -0500 (Wed, 03 Jun 2009) | 1 line
use the offical api
........
r73278 | benjamin.peterson | 2009-06-07 17:33:11 -0500 (Sun, 07 Jun 2009) | 1 line
inherit from object
........
r73279 | benjamin.peterson | 2009-06-07 17:35:00 -0500 (Sun, 07 Jun 2009) | 1 line
always inherit from an appropiate base class
........
r73280 | benjamin.peterson | 2009-06-07 17:54:35 -0500 (Sun, 07 Jun 2009) | 1 line
use booleans for flags
........
r73299 | georg.brandl | 2009-06-08 13:41:36 -0500 (Mon, 08 Jun 2009) | 1 line
Typo fix.
........
r73308 | benjamin.peterson | 2009-06-08 17:18:32 -0500 (Mon, 08 Jun 2009) | 1 line
remove useless assertion
........
r73312 | benjamin.peterson | 2009-06-08 18:44:13 -0500 (Mon, 08 Jun 2009) | 1 line
remove error checks already done in set_context()
........
r73313 | r.david.murray | 2009-06-08 19:44:22 -0500 (Mon, 08 Jun 2009) | 4 lines
Issue 2947: document how return code handling translates from
os.popen to subprocess. Also fixes reference link in the
os.spawn documentation.
........
r73317 | benjamin.peterson | 2009-06-09 12:24:26 -0500 (Tue, 09 Jun 2009) | 1 line
make ast.c depend on the grammar
........
r73318 | benjamin.peterson | 2009-06-09 12:29:51 -0500 (Tue, 09 Jun 2009) | 1 line
explain why keyword names are not just NAME
........
r73321 | benjamin.peterson | 2009-06-09 16:13:43 -0500 (Tue, 09 Jun 2009) | 1 line
update symbol.py from with statement changes
........
r73324 | amaury.forgeotdarc | 2009-06-09 17:53:16 -0500 (Tue, 09 Jun 2009) | 2 lines
Avoid invoking the parser/compiler just to test the presence of a function.
........
r73331 | benjamin.peterson | 2009-06-10 08:45:31 -0500 (Wed, 10 Jun 2009) | 1 line
fix spelling
........
r73335 | raymond.hettinger | 2009-06-10 11:15:40 -0500 (Wed, 10 Jun 2009) | 1 line
Fix signed/unsigned compiler warning.
........
r73340 | amaury.forgeotdarc | 2009-06-10 15:30:19 -0500 (Wed, 10 Jun 2009) | 2 lines
Fix a typo spotted by Nick Coghlan.
........
r73363 | benjamin.peterson | 2009-06-11 12:51:17 -0500 (Thu, 11 Jun 2009) | 1 line
use multi-with syntax
........
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/asdl.py | 22 | ||||
-rwxr-xr-x | Parser/asdl_c.py | 20 |
2 files changed, 21 insertions, 21 deletions
diff --git a/Parser/asdl.py b/Parser/asdl.py index ce9d0d3..28a7138 100644 --- a/Parser/asdl.py +++ b/Parser/asdl.py @@ -20,7 +20,7 @@ def output(string): sys.stdout.write(string + "\n") -class Token: +class Token(object): # spark seems to dispatch in the parser based on a token's # type attribute def __init__(self, type, lineno): @@ -221,20 +221,20 @@ class ASDLParser(spark.GenericParser, object): def p_field_2(self, info): " field ::= Id * Id " type, _, name = info - return Field(type, name, seq=1) + return Field(type, name, seq=True) def p_field_3(self, info): " field ::= Id ? Id " type, _, name = info - return Field(type, name, opt=1) + return Field(type, name, opt=True) def p_field_4(self, type_): " field ::= Id * " - return Field(type_[0], seq=1) + return Field(type_[0], seq=True) def p_field_5(self, type_): " field ::= Id ? " - return Field(type[0], opt=1) + return Field(type[0], opt=True) builtin_types = ("identifier", "string", "int", "bool", "object") @@ -242,7 +242,7 @@ builtin_types = ("identifier", "string", "int", "bool", "object") # not sure if any of the methods are useful yet, but I'm adding them # piecemeal as they seem helpful -class AST: +class AST(object): pass # a marker class class Module(AST): @@ -274,7 +274,7 @@ class Constructor(AST): return "Constructor(%s, %s)" % (self.name, self.fields) class Field(AST): - def __init__(self, type, name=None, seq=0, opt=0): + def __init__(self, type, name=None, seq=False, opt=False): self.type = type self.name = name self.seq = seq @@ -282,9 +282,9 @@ class Field(AST): def __repr__(self): if self.seq: - extra = ", seq=1" + extra = ", seq=True" elif self.opt: - extra = ", opt=1" + extra = ", opt=True" else: extra = "" if self.name is None: @@ -312,7 +312,7 @@ class Product(AST): class VisitorBase(object): - def __init__(self, skip=0): + def __init__(self, skip=False): self.cache = {} self.skip = skip @@ -347,7 +347,7 @@ class VisitorBase(object): class Check(VisitorBase): def __init__(self): - super(Check, self).__init__(skip=1) + super(Check, self).__init__(skip=True) self.cons = {} self.errors = 0 self.types = {} diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index af0b349..8ccb3ea 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -86,7 +86,7 @@ class EmitVisitor(asdl.VisitorBase): self.file = file super(EmitVisitor, self).__init__() - def emit(self, s, depth, reflow=1): + def emit(self, s, depth, reflow=True): # XXX reflow long lines? if reflow: lines = reflow_lines(s, depth) @@ -255,7 +255,7 @@ class PrototypeVisitor(EmitVisitor): ctype = get_c_type(type) self.emit_function(cons.name, ctype, args, attrs) - def emit_function(self, name, ctype, args, attrs, union=1): + def emit_function(self, name, ctype, args, attrs, union=True): args = args + attrs if args: argstr = ", ".join(["%s %s" % (atype, aname) @@ -267,19 +267,19 @@ class PrototypeVisitor(EmitVisitor): for i in range(1, len(args)+1): margs += ", a%d" % i self.emit("#define %s(%s) _Py_%s(%s)" % (name, margs, name, margs), 0, - reflow = 0) - self.emit("%s _Py_%s(%s);" % (ctype, name, argstr), 0) + reflow=False) + self.emit("%s _Py_%s(%s);" % (ctype, name, argstr), False) def visitProduct(self, prod, name): self.emit_function(name, get_c_type(name), - self.get_args(prod.fields), [], union=0) + self.get_args(prod.fields), [], union=False) class FunctionVisitor(PrototypeVisitor): """Visitor to generate constructor functions for AST.""" - def emit_function(self, name, ctype, args, attrs, union=1): - def emit(s, depth=0, reflow=1): + def emit_function(self, name, ctype, args, attrs, union=True): + def emit(s, depth=0, reflow=True): self.emit(s, depth, reflow) argstr = ", ".join(["%s %s" % (atype, aname) for atype, aname, opt in args + attrs]) @@ -297,7 +297,7 @@ class FunctionVisitor(PrototypeVisitor): emit("PyErr_SetString(PyExc_ValueError,", 2) msg = "field %s is required for %s" % (argname, name) emit(' "%s");' % msg, - 2, reflow=0) + 2, reflow=False) emit('return NULL;', 2) emit('}', 1) @@ -313,7 +313,7 @@ class FunctionVisitor(PrototypeVisitor): emit("") def emit_body_union(self, name, args, attrs): - def emit(s, depth=0, reflow=1): + def emit(s, depth=0, reflow=True): self.emit(s, depth, reflow) emit("p->kind = %s_kind;" % name, 1) for argtype, argname, opt in args: @@ -322,7 +322,7 @@ class FunctionVisitor(PrototypeVisitor): emit("p->%s = %s;" % (argname, argname), 1) def emit_body_struct(self, name, args, attrs): - def emit(s, depth=0, reflow=1): + def emit(s, depth=0, reflow=True): self.emit(s, depth, reflow) for argtype, argname, opt in args: emit("p->%s = %s;" % (argname, argname), 1) |