| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ Lexer for PPAPI IDL | 6 """ Lexer for PPAPI IDL |
| 7 | 7 |
| 8 The lexer uses the PLY library to build a tokenizer which understands both | 8 The lexer uses the PLY library to build a tokenizer which understands both |
| 9 WebIDL and Pepper tokens. | 9 WebIDL and Pepper tokens. |
| 10 | 10 |
| 11 WebIDL, and WebIDL regular expressions can be found at: | 11 WebIDL, and WebIDL regular expressions can be found at: |
| 12 http://www.w3.org/TR/2012/CR-WebIDL-20120419/ | 12 http://heycam.github.io/webidl/ |
| 13 PLY can be found at: | 13 PLY can be found at: |
| 14 http://www.dabeaz.com/ply/ | 14 http://www.dabeaz.com/ply/ |
| 15 """ | 15 """ |
| 16 | 16 |
| 17 from idl_lexer import IDLLexer | 17 from idl_lexer import IDLLexer |
| 18 | 18 |
| 19 | 19 |
| 20 # | 20 # |
| 21 # IDL PPAPI Lexer | 21 # IDL PPAPI Lexer |
| 22 # | 22 # |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 # Add handle types | 54 # Add handle types |
| 55 self._AddKeywords(['handle_t', 'PP_FileHandle']) | 55 self._AddKeywords(['handle_t', 'PP_FileHandle']) |
| 56 | 56 |
| 57 # Add pointer types (void*, char*, const char*, const void*) | 57 # Add pointer types (void*, char*, const char*, const void*) |
| 58 self._AddKeywords(['mem_t', 'str_t', 'cstr_t', 'interface_t']) | 58 self._AddKeywords(['mem_t', 'str_t', 'cstr_t', 'interface_t']) |
| 59 | 59 |
| 60 # Remove JS types | 60 # Remove JS types |
| 61 self._DelKeywords(['boolean', 'byte', 'ByteString', 'Date', 'DOMString', | 61 self._DelKeywords(['boolean', 'byte', 'ByteString', 'Date', 'DOMString', |
| 62 'double', 'float', 'long', 'object', 'octet', 'Promise', | 62 'double', 'float', 'long', 'object', 'octet', 'Promise', |
| 63 'RegExp', 'short', 'unsigned']) | 63 'record', 'RegExp', 'short', 'unsigned', 'USVString']) |
| 64 | 64 |
| 65 | 65 |
| 66 # If run by itself, attempt to build the lexer | 66 # If run by itself, attempt to build the lexer |
| 67 if __name__ == '__main__': | 67 if __name__ == '__main__': |
| 68 lexer = IDLPPAPILexer() | 68 lexer = IDLPPAPILexer() |
| 69 lexer.Tokenize(open('test_parser/inline_ppapi.idl').read()) | 69 lexer.Tokenize(open('test_parser/inline_ppapi.idl').read()) |
| 70 for tok in lexer.GetTokens(): | 70 for tok in lexer.GetTokens(): |
| 71 print '\n' + str(tok) | 71 print '\n' + str(tok) |
| OLD | NEW |