| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT', | 74 'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT', |
| 75 'LOR', 'LAND', 'LNOT', | 75 'LOR', 'LAND', 'LNOT', |
| 76 'LT', 'LE', 'GT', 'GE', 'EQ', 'NE', | 76 'LT', 'LE', 'GT', 'GE', 'EQ', 'NE', |
| 77 | 77 |
| 78 # Assignment | 78 # Assignment |
| 79 'EQUALS', | 79 'EQUALS', |
| 80 | 80 |
| 81 # Conditional operator (?) | 81 # Conditional operator (?) |
| 82 'CONDOP', | 82 'CONDOP', |
| 83 | 83 |
| 84 # Request / response |
| 85 'RESPONSE', |
| 86 |
| 84 # Delimeters | 87 # Delimeters |
| 85 'LPAREN', 'RPAREN', # ( ) | 88 'LPAREN', 'RPAREN', # ( ) |
| 86 'LBRACKET', 'RBRACKET', # [ ] | 89 'LBRACKET', 'RBRACKET', # [ ] |
| 87 'LBRACE', 'RBRACE', # { } | 90 'LBRACE', 'RBRACE', # { } |
| 88 'SEMI', 'COLON', # ; : | 91 'SEMI', 'COLON', # ; : |
| 89 'COMMA', 'DOT' # , . | 92 'COMMA', 'DOT' # , . |
| 90 ) | 93 ) |
| 91 | 94 |
| 92 ## | 95 ## |
| 93 ## Regexes for use in tokens | 96 ## Regexes for use in tokens |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 t_GE = r'>=' | 185 t_GE = r'>=' |
| 183 t_EQ = r'==' | 186 t_EQ = r'==' |
| 184 t_NE = r'!=' | 187 t_NE = r'!=' |
| 185 | 188 |
| 186 # = | 189 # = |
| 187 t_EQUALS = r'=' | 190 t_EQUALS = r'=' |
| 188 | 191 |
| 189 # ? | 192 # ? |
| 190 t_CONDOP = r'\?' | 193 t_CONDOP = r'\?' |
| 191 | 194 |
| 195 # => |
| 196 t_RESPONSE = r'=>' |
| 197 |
| 192 # Delimeters | 198 # Delimeters |
| 193 t_LPAREN = r'\(' | 199 t_LPAREN = r'\(' |
| 194 t_RPAREN = r'\)' | 200 t_RPAREN = r'\)' |
| 195 t_LBRACKET = r'\[' | 201 t_LBRACKET = r'\[' |
| 196 t_RBRACKET = r'\]' | 202 t_RBRACKET = r'\]' |
| 197 t_LBRACE = r'\{' | 203 t_LBRACE = r'\{' |
| 198 t_RBRACE = r'\}' | 204 t_RBRACE = r'\}' |
| 199 t_COMMA = r',' | 205 t_COMMA = r',' |
| 200 t_DOT = r'.' | 206 t_DOT = r'.' |
| 201 t_SEMI = r';' | 207 t_SEMI = r';' |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return t | 278 return t |
| 273 | 279 |
| 274 # Ignore C and C++ style comments | 280 # Ignore C and C++ style comments |
| 275 def t_COMMENT(self, t): | 281 def t_COMMENT(self, t): |
| 276 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' | 282 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' |
| 277 pass | 283 pass |
| 278 | 284 |
| 279 def t_error(self, t): | 285 def t_error(self, t): |
| 280 msg = 'Illegal character %s' % repr(t.value[0]) | 286 msg = 'Illegal character %s' % repr(t.value[0]) |
| 281 self._error(msg, t) | 287 self._error(msg, t) |
| OLD | NEW |