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 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 self._AddKeywords(['uint8_t', 'uint16_t', 'uint32_t', 'uint64_t']) | 51 self._AddKeywords(['uint8_t', 'uint16_t', 'uint32_t', 'uint64_t']) |
52 self._AddKeywords(['double_t', 'float_t']) | 52 self._AddKeywords(['double_t', 'float_t']) |
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', 'Date', 'DOMString', 'double', | 61 self._DelKeywords(['boolean', 'byte', 'ByteString', 'Date', 'DOMString', |
62 'float', 'long', 'object', 'octet', 'short', 'unsigned']) | 62 'double', 'float', 'long', 'object', 'octet', 'RegExp', |
63 'short', 'unsigned']) | |
63 | 64 |
64 | 65 |
65 # If run by itself, attempt to build the lexer | 66 # If run by itself, attempt to build the lexer |
66 if __name__ == '__main__': | 67 if __name__ == '__main__': |
67 lexer = IDLPPAPILexer() | 68 lexer = IDLPPAPILexer() |
68 lexer.Tokenize(open('test_parser/inline_ppapi.idl').read()) | 69 lexer.Tokenize(open('test_parser/inline_ppapi.idl').read()) |
Nils Barth (inactive)
2014/06/17 05:11:55
For bonus points, could you replace this resource-
| |
69 for tok in lexer.GetTokens(): | 70 for tok in lexer.GetTokens(): |
70 print '\n' + str(tok) | 71 print '\n' + str(tok) |
OLD | NEW |