Changeset 388 for python/vendor/current/Parser/asdl.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Parser/asdl.py
r2 r388 2 2 3 3 See http://asdl.sourceforge.net/ and 4 http://www.cs.princeton.edu/ ~danwang/Papers/dsl97/dsl97-abstract.html.4 http://www.cs.princeton.edu/research/techreps/TR-554-97 5 5 6 6 Only supports top level module decl, not view. I'm guessing that view … … 11 11 """ 12 12 13 #__metaclass__ = type14 15 13 import os 16 14 import traceback … … 18 16 import spark 19 17 20 class Token :18 class Token(object): 21 19 # spark seems to dispatch in the parser based on a token's 22 20 # type attribute … … 46 44 self.lineno = lineno 47 45 48 class ASDLSyntaxError :46 class ASDLSyntaxError(Exception): 49 47 50 48 def __init__(self, lineno, token=None, msg=None): … … 207 205 def p_field_2(self, (type, _, name)): 208 206 " field ::= Id * Id " 209 return Field(type, name, seq= 1)207 return Field(type, name, seq=True) 210 208 211 209 def p_field_3(self, (type, _, name)): 212 210 " field ::= Id ? Id " 213 return Field(type, name, opt= 1)211 return Field(type, name, opt=True) 214 212 215 213 def p_field_4(self, (type, _)): 216 214 " field ::= Id * " 217 return Field(type, seq= 1)215 return Field(type, seq=True) 218 216 219 217 def p_field_5(self, (type, _)): 220 218 " field ::= Id ? " 221 return Field(type, opt= 1)219 return Field(type, opt=True) 222 220 223 221 builtin_types = ("identifier", "string", "int", "bool", "object") … … 227 225 # piecemeal as they seem helpful 228 226 229 class AST :227 class AST(object): 230 228 pass # a marker class 231 229 … … 259 257 260 258 class Field(AST): 261 def __init__(self, type, name=None, seq= 0, opt=0):259 def __init__(self, type, name=None, seq=False, opt=False): 262 260 self.type = type 263 261 self.name = name … … 267 265 def __repr__(self): 268 266 if self.seq: 269 extra = ", seq= 1"267 extra = ", seq=True" 270 268 elif self.opt: 271 extra = ", opt= 1"269 extra = ", opt=True" 272 270 else: 273 271 extra = "" … … 297 295 class VisitorBase(object): 298 296 299 def __init__(self, skip= 0):297 def __init__(self, skip=False): 300 298 self.cache = {} 301 299 self.skip = skip … … 332 330 333 331 def __init__(self): 334 super(Check, self).__init__(skip= 1)332 super(Check, self).__init__(skip=True) 335 333 self.cons = {} 336 334 self.errors = 0 … … 374 372 375 373 for t in v.types: 376 if not mod.types.has_key(t)and not t in builtin_types:374 if t not in mod.types and not t in builtin_types: 377 375 v.errors += 1 378 376 uses = ", ".join(v.types[t])
Note:
See TracChangeset
for help on using the changeset viewer.