Lines Matching refs:buf
120 def __init__(self, buf, pos, message): argument
124 self.line, self.column = Lexer.compute_line_column(buf, pos)
136 def __init__(self, buf, offset=0, path=None): argument
144 self.buf = buf
162 raise LexerError(self.buf, self.start,
169 buf_len = len(self.buf)
172 self.token, self.end, self.literal = self.lex(self.buf, self.start)
182 def compute_line_column(buf, pos): argument
186 prior = buf[0:pos]
206 def decode_oct(buf, offset, start, end): argument
210 if end > len(buf):
211 raise LexerError(buf, offset, 'bad octal escape sequence')
213 codepoint = int(buf[start:end], 8)
215 raise LexerError(buf, offset, 'bad octal escape sequence')
217 raise LexerError(buf, offset, 'bad octal escape sequence')
222 def decode_hex(buf, offset, start, end): argument
226 if end > len(buf):
227 raise LexerError(buf, offset, 'bad hex escape sequence')
229 return int(buf[start:end], 16)
231 raise LexerError(buf, offset, 'bad hex escape sequence')
235 def lex_interpreted_string(cls, buf, offset): argument
248 buf_len = len(buf)
253 match = cls.UNICODE_CHARS_PATTERN.match(buf, pos)
259 char = buf[pos]
261 raise LexerError(buf, pos,
266 char = buf[pos + 1]
268 raise LexerError(buf, pos, 'bad escape sequence')
270 literal += chr(cls.decode_oct(buf, pos, pos + 1, pos + 4))
273 literal += chr(cls.decode_hex(buf, pos, pos + 2, pos + 4))
277 cls.decode_hex(buf, pos, pos + 2, pos + 6))
281 cls.decode_hex(buf, pos, pos + 2, pos + 10))
288 raise LexerError(buf, pos, 'bad escape sequence')
293 raise LexerError(buf, pos, 'unclosed interpreted string literal')
297 def lex_string(cls, buf, offset): argument
309 char = buf[offset]
312 end = buf.index('`', offset + 1)
313 return (end + 1, buf[offset + 1 : end])
315 raise LexerError(buf, len(buf), 'unclosed raw string literal')
317 return cls.lex_interpreted_string(buf, offset)
318 raise LexerError(buf, offset, 'no string literal start character')
348 def lex(cls, buf, offset): argument
361 match = cls.LEXER_MATCHER.match(buf, offset)
363 raise LexerError(buf, offset, 'unknown token')
367 end, literal = cls.lex_string(buf, offset)
371 literal = buf[offset:end]
564 Lexer.compute_line_column(lexer.buf, lexer.start)