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 re | 5 import re |
6 import sys | 6 import sys |
7 import os.path | 7 import os.path |
8 | 8 |
9 # Try to load the ply module, if not, then assume it is in the third_party | 9 # Try to load the ply module, if not, then assume it is in the third_party |
10 # directory. | 10 # directory. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 octal_or_hex_ordinal_disallowed = r'@((0[0-9]+)|('+hex_prefix+hex_digits+'))' | 165 octal_or_hex_ordinal_disallowed = r'@((0[0-9]+)|('+hex_prefix+hex_digits+'))' |
166 | 166 |
167 ## | 167 ## |
168 ## Rules for the normal state | 168 ## Rules for the normal state |
169 ## | 169 ## |
170 t_ignore = ' \t\r' | 170 t_ignore = ' \t\r' |
171 | 171 |
172 # Newlines | 172 # Newlines |
173 def t_NEWLINE(self, t): | 173 def t_NEWLINE(self, t): |
174 r'\n+' | 174 r'\n+' |
175 t.lexer.lineno += t.value.count("\n") | 175 t.lexer.lineno += len(t.value) |
176 | 176 |
177 # Operators | 177 # Operators |
178 t_PLUS = r'\+' | 178 t_PLUS = r'\+' |
179 t_MINUS = r'-' | 179 t_MINUS = r'-' |
180 t_TIMES = r'\*' | 180 t_TIMES = r'\*' |
181 t_DIVIDE = r'/' | 181 t_DIVIDE = r'/' |
182 t_MOD = r'%' | 182 t_MOD = r'%' |
183 t_OR = r'\|' | 183 t_OR = r'\|' |
184 t_AND = r'&' | 184 t_AND = r'&' |
185 t_NOT = r'~' | 185 t_NOT = r'~' |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 return t | 279 return t |
280 | 280 |
281 # Ignore C and C++ style comments | 281 # Ignore C and C++ style comments |
282 def t_COMMENT(self, t): | 282 def t_COMMENT(self, t): |
283 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' | 283 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' |
284 pass | 284 pass |
285 | 285 |
286 def t_error(self, t): | 286 def t_error(self, t): |
287 msg = 'Illegal character %s' % repr(t.value[0]) | 287 msg = 'Illegal character %s' % repr(t.value[0]) |
288 self._error(msg, t) | 288 self._error(msg, t) |
OLD | NEW |