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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 # FIXME: Upstream | 326 # FIXME: Upstream |
327 def p_TypeSuffix(self, p): | 327 def p_TypeSuffix(self, p): |
328 """TypeSuffix : '[' ']' TypeSuffix | 328 """TypeSuffix : '[' ']' TypeSuffix |
329 | '?' TypeSuffixStartingWithArray | 329 | '?' TypeSuffixStartingWithArray |
330 |""" | 330 |""" |
331 if len(p) == 4: | 331 if len(p) == 4: |
332 p[0] = self.BuildProduction('Array', p, 1, p[3]) | 332 p[0] = self.BuildProduction('Array', p, 1, p[3]) |
333 elif len(p) == 3: | 333 elif len(p) == 3: |
334 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) | 334 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) |
335 | 335 |
336 # [b76.1] Add support for compound Extended Attribute values (A&B and A|B) | 336 # [94] A=(B,C) |
| 337 # Blink extension: OR attribute lists, A=B|C |
337 def p_ExtendedAttributeIdentList(self, p): | 338 def p_ExtendedAttributeIdentList(self, p): |
338 """ExtendedAttributeIdentList : identifier '=' identifier '&' IdentAndLi
st | 339 """ExtendedAttributeIdentList : identifier '=' '(' identifier ',' Identi
fierList ')' |
339 | identifier '=' identifier '|' IdentOrLis
t""" | 340 | identifier '=' identifier '|' IdentOrLis
t""" |
340 value = self.BuildAttribute('VALUE', p[3] + p[4] + p[5]) | 341 if len(p) == 6: |
341 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 342 value = p[3] + p[4] + p[5] |
| 343 else: |
| 344 value = p[4] + p[5] + p[6] |
342 | 345 |
343 # [b76.2] A&B&C | 346 attribute = self.BuildAttribute('VALUE', value) |
344 def p_IdentAndList(self, p): | 347 p[0] = self.BuildNamed('ExtAttribute', p, 1, attribute) |
345 """IdentAndList : identifier '&' IdentAndList | 348 |
346 | identifier""" | 349 # [89] A,B,C |
| 350 def p_IdentifierList(self, p): |
| 351 """IdentifierList : identifier ',' IdentifierList |
| 352 | identifier""" |
347 if len(p) > 3: | 353 if len(p) > 3: |
348 p[0] = p[1] + p[2] + p[3] | 354 p[0] = p[1] + p[2] + p[3] |
349 else: | 355 else: |
350 p[0] = p[1] | 356 p[0] = p[1] |
351 | 357 |
352 # [b76.3] A|B|C | 358 # [b76.3] A|B|C |
353 def p_IdentOrList(self, p): | 359 def p_IdentOrList(self, p): |
354 """IdentOrList : identifier '|' IdentOrList | 360 """IdentOrList : identifier '|' IdentOrList |
355 | identifier""" | 361 | identifier""" |
356 if len(p) > 3: | 362 if len(p) > 3: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 return 1 | 455 return 1 |
450 blink_idl_lexer.main(argv) | 456 blink_idl_lexer.main(argv) |
451 # Important: rewrite_tables=True causes the cache file to be deleted if it | 457 # Important: rewrite_tables=True causes the cache file to be deleted if it |
452 # exists, thus making sure that PLY doesn't load it instead of regenerating | 458 # exists, thus making sure that PLY doesn't load it instead of regenerating |
453 # the parse table. | 459 # the parse table. |
454 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) | 460 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) |
455 | 461 |
456 | 462 |
457 if __name__ == '__main__': | 463 if __name__ == '__main__': |
458 sys.exit(main(sys.argv)) | 464 sys.exit(main(sys.argv)) |
OLD | NEW |