| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) | 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 decimal_constant = '0|([1-9][0-9]*)' |
| 124 r'(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?' | 124 octal_constant = '0[0-7]+' |
| 125 decimal_constant = \ | 125 hex_constant = hex_prefix+hex_digits |
| 126 '(0'+integer_suffix_opt+')|([1-9][0-9]*'+integer_suffix_opt+')' | |
| 127 octal_constant = '0[0-7]*'+integer_suffix_opt | |
| 128 hex_constant = hex_prefix+hex_digits+integer_suffix_opt | |
| 129 | 126 |
| 130 bad_octal_constant = '0[0-7]*[89]' | 127 bad_octal_constant = '0[0-7]*[89]' |
| 131 | 128 |
| 132 # character constants (K&R2: A.2.5.2) | 129 # character constants (K&R2: A.2.5.2) |
| 133 # Note: a-zA-Z and '.-~^_!=&;,' are allowed as escape chars to support #line | 130 # Note: a-zA-Z and '.-~^_!=&;,' are allowed as escape chars to support #line |
| 134 # directives with Windows paths as filenames (..\..\dir\file) | 131 # directives with Windows paths as filenames (..\..\dir\file) |
| 135 # For the same reason, decimal_escape allows all digit sequences. We want to | 132 # For the same reason, decimal_escape allows all digit sequences. We want to |
| 136 # parse all correct code, even if it means to sometimes parse incorrect | 133 # parse all correct code, even if it means to sometimes parse incorrect |
| 137 # code. | 134 # code. |
| 138 # | 135 # |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 return t | 281 return t |
| 285 | 282 |
| 286 # Ignore C and C++ style comments | 283 # Ignore C and C++ style comments |
| 287 def t_COMMENT(self, t): | 284 def t_COMMENT(self, t): |
| 288 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' | 285 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' |
| 289 pass | 286 pass |
| 290 | 287 |
| 291 def t_error(self, t): | 288 def t_error(self, t): |
| 292 msg = 'Illegal character %s' % repr(t.value[0]) | 289 msg = 'Illegal character %s' % repr(t.value[0]) |
| 293 self._error(msg, t) | 290 self._error(msg, t) |
| OLD | NEW |