Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: Source/bindings/scripts/unstable/blink_idl_parser.py

Issue 127903002: Empty reflected attributes and string literals in extended attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: docstring formatting Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/scripts/idl_parser.pm ('k') | Source/bindings/tests/idls/TestObject.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 """Reach in and grab the string literal's "NAME"."""
388 return ls[1].value
389
390 if len(p) > 3:
391 p[0] = unwrap_string(p[1]) + p[2] + p[3]
392 else:
393 p[0] = unwrap_string(p[1])
394
374 def __dir__(self): 395 def __dir__(self):
375 # Remove REMOVED_RULES from listing so yacc doesn't parse them 396 # Remove REMOVED_RULES from listing so yacc doesn't parse them
376 # FIXME: Upstream 397 # FIXME: Upstream
377 keys = set(self.__dict__.keys() + dir(self.__class__)) 398 keys = set(self.__dict__.keys() + dir(self.__class__))
378 for rule in REMOVED_RULES: 399 for rule in REMOVED_RULES:
379 production_name = 'p_' + rule 400 production_name = 'p_' + rule
380 if production_name in keys: 401 if production_name in keys:
381 keys.remove(production_name) 402 keys.remove(production_name)
382 return list(keys) 403 return list(keys)
383 404
(...skipping 11 matching lines...) Expand all
395 self._parse_errors = 0 416 self._parse_errors = 0
396 self._parse_warnings = 0 417 self._parse_warnings = 0
397 self._last_error_msg = None 418 self._last_error_msg = None
398 self._last_error_lineno = 0 419 self._last_error_lineno = 0
399 self._last_error_pos = 0 420 self._last_error_pos = 0
400 421
401 422
402 # If run by itself, attempt to build the parser 423 # If run by itself, attempt to build the parser
403 if __name__ == '__main__': 424 if __name__ == '__main__':
404 parser = BlinkIDLParser() 425 parser = BlinkIDLParser()
OLDNEW
« no previous file with comments | « Source/bindings/scripts/idl_parser.pm ('k') | Source/bindings/tests/idls/TestObject.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698