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

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

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « bindings/scripts/aggregate_generated_bindings.py ('k') | bindings/scripts/code_generator_v8.py » ('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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 # [b50] Allow optional trailing comma 278 # [b50] Allow optional trailing comma
279 # Blink-only, marked as WONTFIX in Web IDL spec: 279 # Blink-only, marked as WONTFIX in Web IDL spec:
280 # https://www.w3.org/Bugs/Public/show_bug.cgi?id=22156 280 # https://www.w3.org/Bugs/Public/show_bug.cgi?id=22156
281 def p_ExtendedAttributes(self, p): 281 def p_ExtendedAttributes(self, p):
282 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes 282 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes
283 | ',' 283 | ','
284 |""" 284 |"""
285 if len(p) > 3: 285 if len(p) > 3:
286 p[0] = ListFromConcat(p[2], p[3]) 286 p[0] = ListFromConcat(p[2], p[3])
287 287
288 # [b51] Add ExtendedAttributeIdentAndOrIdent 288 # [b51] Add ExtendedAttributeStringLiteral and ExtendedAttributeStringLitera lList
289 def p_ExtendedAttribute(self, p): 289 def p_ExtendedAttribute(self, p):
290 """ExtendedAttribute : ExtendedAttributeNoArgs 290 """ExtendedAttribute : ExtendedAttributeNoArgs
291 | ExtendedAttributeArgList 291 | ExtendedAttributeArgList
292 | ExtendedAttributeIdent 292 | ExtendedAttributeIdent
293 | ExtendedAttributeIdentList 293 | ExtendedAttributeIdentList
294 | ExtendedAttributeStringLiteralList 294 | ExtendedAttributeNamedArgList
295 | ExtendedAttributeNamedArgList""" 295 | ExtendedAttributeStringLiteral
296 | ExtendedAttributeStringLiteralList"""
296 p[0] = p[1] 297 p[0] = p[1]
297 298
298 # [59] 299 # [59]
299 # FIXME: Upstream UnionType 300 # FIXME: Upstream UnionType
300 def p_UnionType(self, p): 301 def p_UnionType(self, p):
301 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ' )'""" 302 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ' )'"""
302 members = ListFromConcat(p[2], p[4], p[5]) 303 members = ListFromConcat(p[2], p[4], p[5])
303 p[0] = self.BuildProduction('UnionType', p, 1, members) 304 p[0] = self.BuildProduction('UnionType', p, 1, members)
304 305
305 # [60] 306 # [60]
(...skipping 20 matching lines...) Expand all
326 # FIXME: Upstream 327 # FIXME: Upstream
327 def p_TypeSuffix(self, p): 328 def p_TypeSuffix(self, p):
328 """TypeSuffix : '[' ']' TypeSuffix 329 """TypeSuffix : '[' ']' TypeSuffix
329 | '?' TypeSuffixStartingWithArray 330 | '?' TypeSuffixStartingWithArray
330 |""" 331 |"""
331 if len(p) == 4: 332 if len(p) == 4:
332 p[0] = self.BuildProduction('Array', p, 1, p[3]) 333 p[0] = self.BuildProduction('Array', p, 1, p[3])
333 elif len(p) == 3: 334 elif len(p) == 3:
334 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) 335 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2])
335 336
336 # [b94] Add support for OR Extended Attribute values "A|B" 337 # Blink extension: Add support for string literal Extended Attribute values
337 def p_ExtendedAttributeIdentList(self, p): 338 def p_ExtendedAttributeStringLiteral(self, p):
338 """ExtendedAttributeIdentList : identifier '=' '(' IdentifierList ')' 339 """ExtendedAttributeStringLiteral : identifier '=' StringLiteral """
339 | identifier '=' identifier '|' IdentOrLis t""" 340 def unwrap_string(ls):
340 if type(p[4]) is list: 341 """Reach in and grab the string literal's "NAME"."""
341 value = self.BuildAttribute('VALUE', ','.join(p[4])) 342 return ls[1].value
342 else: 343
343 value = self.BuildAttribute('VALUE', p[3] + p[4] + p[5]) 344 value = self.BuildAttribute('VALUE', unwrap_string(p[3]))
344 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) 345 p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
345 346
346 # [b94.1] A|B|C 347 # Blink extension: Add support for compound Extended Attribute values over s tring literals ("A","B")
347 def p_IdentOrList(self, p):
348 """IdentOrList : identifier '|' IdentOrList
349 | identifier"""
350 if len(p) > 3:
351 p[0] = p[1] + p[2] + p[3]
352 else:
353 p[0] = p[1]
354
355 # Blink extension: Add support for compound Extended Attribute values over s tring literals ("A"|"B")
356 def p_ExtendedAttributeStringLiteralList(self, p): 348 def p_ExtendedAttributeStringLiteralList(self, p):
357 """ExtendedAttributeStringLiteralList : identifier '=' StringLiteralOrLi st""" 349 """ExtendedAttributeStringLiteralList : identifier '=' '(' StringLiteral List ')' """
358 value = self.BuildAttribute('VALUE', p[3]) 350 value = self.BuildAttribute('VALUE', p[4])
359 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) 351 p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
360 352
361 # Blink extension: one or more string literals. The values aren't propagated as literals, 353 # Blink extension: one or more string literals. The values aren't propagated as literals,
362 # but their by their value only. 354 # but their by their value only.
363 def p_StringLiteralOrList(self, p): 355 def p_StringLiteralList(self, p):
364 """StringLiteralOrList : StringLiteral '|' StringLiteralOrList 356 """StringLiteralList : StringLiteral ',' StringLiteralList
365 | StringLiteral""" 357 | StringLiteral"""
366 def unwrap_string(ls): 358 def unwrap_string(ls):
367 """Reach in and grab the string literal's "NAME".""" 359 """Reach in and grab the string literal's "NAME"."""
368 return ls[1].value 360 return ls[1].value
369 361
370 if len(p) > 3: 362 if len(p) > 3:
371 p[0] = unwrap_string(p[1]) + p[2] + p[3] 363 p[0] = ListFromConcat(unwrap_string(p[1]), p[3])
372 else: 364 else:
373 p[0] = unwrap_string(p[1]) 365 p[0] = ListFromConcat(unwrap_string(p[1]))
374 366
375 def __init__(self, 367 def __init__(self,
376 # common parameters 368 # common parameters
377 debug=False, 369 debug=False,
378 # local parameters 370 # local parameters
379 rewrite_tables=False, 371 rewrite_tables=False,
380 # idl_parser parameters 372 # idl_parser parameters
381 lexer=None, verbose=False, mute_error=False, 373 lexer=None, verbose=False, mute_error=False,
382 # yacc parameters 374 # yacc parameters
383 outputdir='', optimize=True, write_tables=False, 375 outputdir='', optimize=True, write_tables=False,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return 1 435 return 1
444 blink_idl_lexer.main(argv) 436 blink_idl_lexer.main(argv)
445 # Important: rewrite_tables=True causes the cache file to be deleted if it 437 # Important: rewrite_tables=True causes the cache file to be deleted if it
446 # exists, thus making sure that PLY doesn't load it instead of regenerating 438 # exists, thus making sure that PLY doesn't load it instead of regenerating
447 # the parse table. 439 # the parse table.
448 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) 440 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True)
449 441
450 442
451 if __name__ == '__main__': 443 if __name__ == '__main__':
452 sys.exit(main(sys.argv)) 444 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « bindings/scripts/aggregate_generated_bindings.py ('k') | bindings/scripts/code_generator_v8.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698