OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # | 8 # |
9 # IDL Lexer | 9 # IDL Lexer |
10 # | 10 # |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 return t | 115 return t |
116 | 116 |
117 # A C or C++ style comment: /* xxx */ or // | 117 # A C or C++ style comment: /* xxx */ or // |
118 def t_COMMENT(self, t): | 118 def t_COMMENT(self, t): |
119 r'(/\*(.|\n)*?\*/)|(//.*)' | 119 r'(/\*(.|\n)*?\*/)|(//.*)' |
120 self.AddLines(t.value.count('\n')) | 120 self.AddLines(t.value.count('\n')) |
121 return t | 121 return t |
122 | 122 |
123 # Return a "preprocessor" inline block | 123 # Return a "preprocessor" inline block |
124 def t_INLINE(self, t): | 124 def t_INLINE(self, t): |
125 r'\#inline (.|\n)*\#endinl.*' | 125 r'\#inline (.|\n)*?\#endinl.*' |
126 self.AddLines(t.value.count('\n')) | 126 self.AddLines(t.value.count('\n')) |
127 return t | 127 return t |
128 | 128 |
129 # A symbol or keyword. | 129 # A symbol or keyword. |
130 def t_KEYWORD_SYMBOL(self, t): | 130 def t_KEYWORD_SYMBOL(self, t): |
131 r'[A-Za-z][A-Za-z_0-9]*' | 131 r'[A-Za-z][A-Za-z_0-9]*' |
132 | 132 |
133 #All non-keywords are assumed to be symbols | 133 #All non-keywords are assumed to be symbols |
134 t.type = self.keywords.get(t.value, 'SYMBOL') | 134 t.type = self.keywords.get(t.value, 'SYMBOL') |
135 return t | 135 return t |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return -1 | 320 return -1 |
321 return 0 | 321 return 0 |
322 | 322 |
323 except lex.LexError as le: | 323 except lex.LexError as le: |
324 sys.stderr.write('%s\n' % str(le)) | 324 sys.stderr.write('%s\n' % str(le)) |
325 return -1 | 325 return -1 |
326 | 326 |
327 | 327 |
328 if __name__ == '__main__': | 328 if __name__ == '__main__': |
329 sys.exit(Main(sys.argv[1:])) | 329 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |