OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ Lexer for PPAPI IDL """ | 7 """ Lexer for PPAPI IDL """ |
8 | 8 |
9 # | 9 # |
10 # IDL Lexer | 10 # IDL Lexer |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 # Lex assumes any value or function in the form of 't_<TYPE>' represents a | 90 # Lex assumes any value or function in the form of 't_<TYPE>' represents a |
91 # regular expression where a match will emit a token of type <TYPE>. In the | 91 # regular expression where a match will emit a token of type <TYPE>. In the |
92 # case of a function, the function is called when a match is made. These | 92 # case of a function, the function is called when a match is made. These |
93 # definitions come from WebIDL. | 93 # definitions come from WebIDL. |
94 | 94 |
95 # 't_ignore' is a special match of items to ignore | 95 # 't_ignore' is a special match of items to ignore |
96 t_ignore = ' \t' | 96 t_ignore = ' \t' |
97 | 97 |
98 # Constant values | 98 # Constant values |
99 t_FLOAT = r'-?(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?|-?\d+[Ee][+-]?\d+' | 99 t_FLOAT = r'-?(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?|-?\d+[Ee][+-]?\d+' |
100 t_INT = r'-?[0-9]+' | 100 t_INT = r'-?[0-9]+[uU]?' |
101 t_OCT = r'-?0[0-7]+' | 101 t_OCT = r'-?0[0-7]+' |
102 t_HEX = r'-?0[Xx][0-9A-Fa-f]+' | 102 t_HEX = r'-?0[Xx][0-9A-Fa-f]+' |
103 t_LSHIFT = r'<<' | 103 t_LSHIFT = r'<<' |
104 t_RSHIFT = r'>>' | 104 t_RSHIFT = r'>>' |
105 | 105 |
106 # A line ending '\n', we use this to increment the line number | 106 # A line ending '\n', we use this to increment the line number |
107 def t_LINE_END(self, t): | 107 def t_LINE_END(self, t): |
108 r'\n+' | 108 r'\n+' |
109 self.AddLines(len(t.value)) | 109 self.AddLines(len(t.value)) |
110 | 110 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 if TestExpect(tokens): | 323 if TestExpect(tokens): |
324 return -1 | 324 return -1 |
325 return 0 | 325 return 0 |
326 | 326 |
327 except lex.LexError as le: | 327 except lex.LexError as le: |
328 sys.stderr.write('%s\n' % str(le)) | 328 sys.stderr.write('%s\n' % str(le)) |
329 return -1 | 329 return -1 |
330 | 330 |
331 if __name__ == '__main__': | 331 if __name__ == '__main__': |
332 sys.exit(Main(sys.argv[1:])) | 332 sys.exit(Main(sys.argv[1:])) |
333 | |
OLD | NEW |