| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import imp | 5 import imp |
| 6 import os.path | 6 import os.path |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 # Disable lint check for finding modules: | 9 # Disable lint check for finding modules: |
| 10 # pylint: disable=F0401 | 10 # pylint: disable=F0401 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 'LBRACE', 'RBRACE', # { } | 106 'LBRACE', 'RBRACE', # { } |
| 107 'LANGLE', 'RANGLE', # < > | 107 'LANGLE', 'RANGLE', # < > |
| 108 'SEMI', # ; | 108 'SEMI', # ; |
| 109 'COMMA', 'DOT' # , . | 109 'COMMA', 'DOT' # , . |
| 110 ) | 110 ) |
| 111 | 111 |
| 112 ## | 112 ## |
| 113 ## Regexes for use in tokens | 113 ## Regexes for use in tokens |
| 114 ## | 114 ## |
| 115 | 115 |
| 116 # valid C identifiers (K&R2: A.2.3), plus '$' (supported by some compilers) | 116 # valid C identifiers (K&R2: A.2.3) |
| 117 identifier = r'[a-zA-Z_$][0-9a-zA-Z_$]*' | 117 identifier = r'[a-zA-Z_][0-9a-zA-Z_]*' |
| 118 | 118 |
| 119 hex_prefix = '0[xX]' | 119 hex_prefix = '0[xX]' |
| 120 hex_digits = '[0-9a-fA-F]+' | 120 hex_digits = '[0-9a-fA-F]+' |
| 121 | 121 |
| 122 # integer constants (K&R2: A.2.5.1) | 122 # integer constants (K&R2: A.2.5.1) |
| 123 integer_suffix_opt = \ | 123 integer_suffix_opt = \ |
| 124 r'(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?' | 124 r'(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?' |
| 125 decimal_constant = \ | 125 decimal_constant = \ |
| 126 '(0'+integer_suffix_opt+')|([1-9][0-9]*'+integer_suffix_opt+')' | 126 '(0'+integer_suffix_opt+')|([1-9][0-9]*'+integer_suffix_opt+')' |
| 127 octal_constant = '0[0-7]*'+integer_suffix_opt | 127 octal_constant = '0[0-7]*'+integer_suffix_opt |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 return t | 284 return t |
| 285 | 285 |
| 286 # Ignore C and C++ style comments | 286 # Ignore C and C++ style comments |
| 287 def t_COMMENT(self, t): | 287 def t_COMMENT(self, t): |
| 288 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' | 288 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' |
| 289 pass | 289 pass |
| 290 | 290 |
| 291 def t_error(self, t): | 291 def t_error(self, t): |
| 292 msg = 'Illegal character %s' % repr(t.value[0]) | 292 msg = 'Illegal character %s' % repr(t.value[0]) |
| 293 self._error(msg, t) | 293 self._error(msg, t) |
| OLD | NEW |