Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 |""" | 298 |""" |
| 299 if len(p) > 3: | 299 if len(p) > 3: |
| 300 p[0] = ListFromConcat(p[2], p[3]) | 300 p[0] = ListFromConcat(p[2], p[3]) |
| 301 | 301 |
| 302 # [b51] Add ExtendedAttributeIdentAndOrIdent | 302 # [b51] Add ExtendedAttributeIdentAndOrIdent |
| 303 def p_ExtendedAttribute(self, p): | 303 def p_ExtendedAttribute(self, p): |
| 304 """ExtendedAttribute : ExtendedAttributeNoArgs | 304 """ExtendedAttribute : ExtendedAttributeNoArgs |
| 305 | ExtendedAttributeArgList | 305 | ExtendedAttributeArgList |
| 306 | ExtendedAttributeIdent | 306 | ExtendedAttributeIdent |
| 307 | ExtendedAttributeIdentList | 307 | ExtendedAttributeIdentList |
| 308 | ExtendedAttributeStringLiteralList | |
| 308 | ExtendedAttributeNamedArgList""" | 309 | ExtendedAttributeNamedArgList""" |
| 309 p[0] = p[1] | 310 p[0] = p[1] |
| 310 | 311 |
| 311 # [59] | 312 # [59] |
| 312 # FIXME: Upstream UnionType | 313 # FIXME: Upstream UnionType |
| 313 def p_UnionType(self, p): | 314 def p_UnionType(self, p): |
| 314 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ' )'""" | 315 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ' )'""" |
| 315 members = ListFromConcat(p[2], p[4], p[5]) | 316 members = ListFromConcat(p[2], p[4], p[5]) |
| 316 p[0] = self.BuildProduction('UnionType', p, 1, members) | 317 p[0] = self.BuildProduction('UnionType', p, 1, members) |
| 317 | 318 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 | 365 |
| 365 # [b76.3] A|B|C | 366 # [b76.3] A|B|C |
| 366 def p_IdentOrList(self, p): | 367 def p_IdentOrList(self, p): |
| 367 """IdentOrList : identifier '|' IdentOrList | 368 """IdentOrList : identifier '|' IdentOrList |
| 368 | identifier""" | 369 | identifier""" |
| 369 if len(p) > 3: | 370 if len(p) > 3: |
| 370 p[0] = p[1] + p[2] + p[3] | 371 p[0] = p[1] + p[2] + p[3] |
| 371 else: | 372 else: |
| 372 p[0] = p[1] | 373 p[0] = p[1] |
| 373 | 374 |
| 375 # Blink extension: Add support for compound Extended Attribute values over s tring literals ("A"|"B") | |
| 376 def p_ExtendedAttributeStringLiteralList(self, p): | |
| 377 """ExtendedAttributeStringLiteralList : identifier '=' StringLiteralOrLi st""" | |
| 378 value = self.BuildAttribute('VALUE', p[3]) | |
| 379 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | |
| 380 | |
| 381 # Blink extension: one or more string literals. The values aren't propagated as literals, | |
| 382 # but their by their value only. | |
| 383 def p_StringLiteralOrList(self, p): | |
| 384 """StringLiteralOrList : StringLiteral '|' StringLiteralOrList | |
| 385 | StringLiteral""" | |
| 386 def unwrap_string(ls): | |
| 387 """ | |
|
Nils Barth (inactive)
2014/01/09 11:24:27
One-line docstring please:
http://www.python.org/d
sof
2014/01/09 11:42:35
thanks, updated.
| |
| 388 Reach in and grab the string literal's "NAME". | |
| 389 """ | |
| 390 return ls[1].value | |
| 391 | |
| 392 if len(p) > 3: | |
| 393 p[0] = unwrap_string(p[1]) + p[2] + p[3] | |
| 394 else: | |
| 395 p[0] = unwrap_string(p[1]) | |
| 396 | |
| 374 def __dir__(self): | 397 def __dir__(self): |
| 375 # Remove REMOVED_RULES from listing so yacc doesn't parse them | 398 # Remove REMOVED_RULES from listing so yacc doesn't parse them |
| 376 # FIXME: Upstream | 399 # FIXME: Upstream |
| 377 keys = set(self.__dict__.keys() + dir(self.__class__)) | 400 keys = set(self.__dict__.keys() + dir(self.__class__)) |
| 378 for rule in REMOVED_RULES: | 401 for rule in REMOVED_RULES: |
| 379 production_name = 'p_' + rule | 402 production_name = 'p_' + rule |
| 380 if production_name in keys: | 403 if production_name in keys: |
| 381 keys.remove(production_name) | 404 keys.remove(production_name) |
| 382 return list(keys) | 405 return list(keys) |
| 383 | 406 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 395 self._parse_errors = 0 | 418 self._parse_errors = 0 |
| 396 self._parse_warnings = 0 | 419 self._parse_warnings = 0 |
| 397 self._last_error_msg = None | 420 self._last_error_msg = None |
| 398 self._last_error_lineno = 0 | 421 self._last_error_lineno = 0 |
| 399 self._last_error_pos = 0 | 422 self._last_error_pos = 0 |
| 400 | 423 |
| 401 | 424 |
| 402 # If run by itself, attempt to build the parser | 425 # If run by itself, attempt to build the parser |
| 403 if __name__ == '__main__': | 426 if __name__ == '__main__': |
| 404 parser = BlinkIDLParser() | 427 parser = BlinkIDLParser() |
| OLD | NEW |