def it_can_discard_its_current_lexeme(self): lexer = Lexer("foobar") lexer._pos = 3 lexer._ignore() assert lexer._peek == "b"
def it_can_accept_a_run_of_chars_in_a_charset(self): lexer = Lexer("ohsofoobaric") lexer._accept_run("fhos") assert lexer._pos == 7
def it_can_accept_a_run_of_chars_not_in_a_charset(self): lexer = Lexer('x:foo="bar"') lexer._accept_until("=") assert lexer._pos == 5
def emit_fixture(self, Token_, token_): lexer = Lexer("foobar") lexer._pos = 3 terminal_symbol, lexeme = 42, "foo" Token_.return_value = token_ return lexer, terminal_symbol, lexeme, Token_, token_, lexer._pos
def it_can_backup_to_reverse_a_next(self): lexer = Lexer("a") lexer._next() lexer._backup() assert lexer._pos == 0
def next_fixture(self, request): input_, expected_value, expected_pos = request.param lexer = Lexer(input_) return lexer, expected_value, expected_pos
def it_raises_if_default_start_state_method_is_used(self): lexer = Lexer(None) with pytest.raises(NotImplementedError): lexer._lex_start()
def it_can_discard_its_current_lexeme(self): lexer = Lexer('foobar') lexer._pos = 3 lexer._ignore() assert lexer._peek == 'b'
def it_knows_how_many_characters_are_in_the_input(self): lexer = Lexer('barfoo') assert lexer._len == 6
def it_can_accept_a_run_of_chars_in_a_charset(self): lexer = Lexer('ohsofoobaric') lexer._accept_run('fhos') assert lexer._pos == 7
def it_can_accept_a_run_of_chars_not_in_a_charset(self): lexer = Lexer('x:foo="bar"') lexer._accept_until('=') assert lexer._pos == 5
def it_can_backup_to_reverse_a_next(self): lexer = Lexer('a') lexer._next() lexer._backup() assert lexer._pos == 0
def skip_fixture(self, request): input_, n, new_pos, exception = request.param lexer = Lexer(input_) return lexer, n, new_pos, exception
def peek_fixture(self, request): input_, expected_value = request.param lexer = Lexer(input_) return lexer, expected_value
def it_knows_how_many_characters_are_in_its_current_lexeme(self): lexer = Lexer("foobar") lexer._pos = 3 assert lexer._llen == 3
def it_knows_how_many_characters_are_in_its_current_lexeme(self): lexer = Lexer('foobar') lexer._pos = 3 assert lexer._llen == 3
def emit_fixture(self, Token_, token_): lexer = Lexer('foobar') lexer._pos = 3 terminal_symbol, lexeme = 42, 'foo' Token_.return_value = token_ return lexer, terminal_symbol, lexeme, Token_, token_, lexer._pos