| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 # p[0] = p[2] | 196 # p[0] = p[2] |
| 197 # | 197 # |
| 198 # Numbering scheme for the rules is: | 198 # Numbering scheme for the rules is: |
| 199 # [1] for Web IDL spec (or additions in base parser) | 199 # [1] for Web IDL spec (or additions in base parser) |
| 200 # These should all be upstreamed to the base parser. | 200 # These should all be upstreamed to the base parser. |
| 201 # [b1] for Blink IDL changes (overrides Web IDL) | 201 # [b1] for Blink IDL changes (overrides Web IDL) |
| 202 # [b1.1] for Blink IDL additions, auxiliary rules for [b1] | 202 # [b1.1] for Blink IDL additions, auxiliary rules for [b1] |
| 203 # Numbers are as per Candidate Recommendation 19 April 2012: | 203 # Numbers are as per Candidate Recommendation 19 April 2012: |
| 204 # http://www.w3.org/TR/2012/CR-WebIDL-20120419/ | 204 # http://www.w3.org/TR/2012/CR-WebIDL-20120419/ |
| 205 | 205 |
| 206 # [3] Override action, since we distinguish callbacks | |
| 207 # FIXME: Upstream | |
| 208 def p_CallbackOrInterface(self, p): | |
| 209 """CallbackOrInterface : CALLBACK CallbackRestOrInterface | |
| 210 | Interface""" | |
| 211 if len(p) > 2: | |
| 212 p[2].AddChildren(self.BuildTrue('CALLBACK')) | |
| 213 p[0] = p[2] | |
| 214 else: | |
| 215 p[0] = p[1] | |
| 216 | |
| 217 # [b27] Add strings, more 'Literal' productions | 206 # [b27] Add strings, more 'Literal' productions |
| 218 # 'Literal's needed because integers and strings are both internally strings | 207 # 'Literal's needed because integers and strings are both internally strings |
| 219 def p_ConstValue(self, p): | 208 def p_ConstValue(self, p): |
| 220 """ConstValue : BooleanLiteral | 209 """ConstValue : BooleanLiteral |
| 221 | FloatLiteral | 210 | FloatLiteral |
| 222 | IntegerLiteral | 211 | IntegerLiteral |
| 223 | StringLiteral | 212 | StringLiteral |
| 224 | null""" | 213 | null""" |
| 225 # Standard is (no 'string', fewer 'Literal's): | 214 # Standard is (no 'string', fewer 'Literal's): |
| 226 # ConstValue : BooleanLiteral | 215 # ConstValue : BooleanLiteral |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 def p_ExtendedAttribute(self, p): | 290 def p_ExtendedAttribute(self, p): |
| 302 """ExtendedAttribute : ExtendedAttributeNoArgs | 291 """ExtendedAttribute : ExtendedAttributeNoArgs |
| 303 | ExtendedAttributeArgList | 292 | ExtendedAttributeArgList |
| 304 | ExtendedAttributeIdent | 293 | ExtendedAttributeIdent |
| 305 | ExtendedAttributeIdentList | 294 | ExtendedAttributeIdentList |
| 306 | ExtendedAttributeNamedArgList | 295 | ExtendedAttributeNamedArgList |
| 307 | ExtendedAttributeStringLiteral | 296 | ExtendedAttributeStringLiteral |
| 308 | ExtendedAttributeStringLiteralList""" | 297 | ExtendedAttributeStringLiteralList""" |
| 309 p[0] = p[1] | 298 p[0] = p[1] |
| 310 | 299 |
| 311 # [70] Override base parser to remove non-standard sized array | |
| 312 # FIXME: Upstream | |
| 313 def p_TypeSuffix(self, p): | |
| 314 """TypeSuffix : '[' ']' TypeSuffix | |
| 315 | '?' TypeSuffixStartingWithArray | |
| 316 |""" | |
| 317 if len(p) == 4: | |
| 318 p[0] = self.BuildProduction('Array', p, 1, p[3]) | |
| 319 elif len(p) == 3: | |
| 320 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) | |
| 321 | |
| 322 # Blink extension: Add support for string literal Extended Attribute values | 300 # Blink extension: Add support for string literal Extended Attribute values |
| 323 def p_ExtendedAttributeStringLiteral(self, p): | 301 def p_ExtendedAttributeStringLiteral(self, p): |
| 324 """ExtendedAttributeStringLiteral : identifier '=' StringLiteral """ | 302 """ExtendedAttributeStringLiteral : identifier '=' StringLiteral """ |
| 325 def unwrap_string(ls): | 303 def unwrap_string(ls): |
| 326 """Reach in and grab the string literal's "NAME".""" | 304 """Reach in and grab the string literal's "NAME".""" |
| 327 return ls[1].value | 305 return ls[1].value |
| 328 | 306 |
| 329 value = self.BuildAttribute('VALUE', unwrap_string(p[3])) | 307 value = self.BuildAttribute('VALUE', unwrap_string(p[3])) |
| 330 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 308 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
| 331 | 309 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 return 1 | 398 return 1 |
| 421 blink_idl_lexer.main(argv) | 399 blink_idl_lexer.main(argv) |
| 422 # Important: rewrite_tables=True causes the cache file to be deleted if it | 400 # Important: rewrite_tables=True causes the cache file to be deleted if it |
| 423 # exists, thus making sure that PLY doesn't load it instead of regenerating | 401 # exists, thus making sure that PLY doesn't load it instead of regenerating |
| 424 # the parse table. | 402 # the parse table. |
| 425 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) | 403 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) |
| 426 | 404 |
| 427 | 405 |
| 428 if __name__ == '__main__': | 406 if __name__ == '__main__': |
| 429 sys.exit(main(sys.argv)) | 407 sys.exit(main(sys.argv)) |
| OLD | NEW |