| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 # definitions come from WebIDL. | 108 # definitions come from WebIDL. |
| 109 def t_ELLIPSIS(self, t): | 109 def t_ELLIPSIS(self, t): |
| 110 r'\.\.\.' | 110 r'\.\.\.' |
| 111 return t | 111 return t |
| 112 | 112 |
| 113 def t_float(self, t): | 113 def t_float(self, t): |
| 114 r'-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+
)' | 114 r'-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+
)' |
| 115 return t | 115 return t |
| 116 | 116 |
| 117 def t_integer(self, t): | 117 def t_integer(self, t): |
| 118 r'-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)' | 118 r'-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)' |
| 119 return t | 119 return t |
| 120 | 120 |
| 121 | 121 |
| 122 # A line ending '\n', we use this to increment the line number | 122 # A line ending '\n', we use this to increment the line number |
| 123 def t_LINE_END(self, t): | 123 def t_LINE_END(self, t): |
| 124 r'\n+' | 124 r'\n+' |
| 125 self.AddLines(len(t.value)) | 125 self.AddLines(len(t.value)) |
| 126 | 126 |
| 127 # We do not process escapes in the IDL strings. Strings are exclusively | 127 # We do not process escapes in the IDL strings. Strings are exclusively |
| 128 # used for attributes and enums, and not used as typical 'C' constants. | 128 # used for attributes and enums, and not used as typical 'C' constants. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 self.keywords = {} | 270 self.keywords = {} |
| 271 self.tokens = [] | 271 self.tokens = [] |
| 272 self._AddConstDefs() | 272 self._AddConstDefs() |
| 273 self._AddTokens(IDLLexer.tokens) | 273 self._AddTokens(IDLLexer.tokens) |
| 274 self._AddKeywords(IDLLexer.keywords) | 274 self._AddKeywords(IDLLexer.keywords) |
| 275 self._lexobj = None | 275 self._lexobj = None |
| 276 | 276 |
| 277 # If run by itself, attempt to build the lexer | 277 # If run by itself, attempt to build the lexer |
| 278 if __name__ == '__main__': | 278 if __name__ == '__main__': |
| 279 lexer = IDLLexer() | 279 lexer = IDLLexer() |
| OLD | NEW |