(lines, pos, regex, token_type)
| 241 | |
| 242 | |
| 243 | def ParseToken(lines, pos, regex, token_type): |
| 244 | line = lines[pos.line][pos.column:] |
| 245 | m = regex.search(line) |
| 246 | if m and not m.start(): |
| 247 | return MakeToken(lines, pos, pos + m.end(), token_type) |
| 248 | else: |
| 249 | print 'ERROR: %s expected at %s.' % (token_type, pos) |
| 250 | sys.exit(1) |
| 251 | |
| 252 | |
| 253 | ID_REGEX = re.compile(r'[_A-Za-z]\w*') |
no test coverage detected