def parse_statements(text: str) -> List[Any]: source = Source(text) statements = [] while len(source._text) > 0: source.consume_regex(ENCLOSING_WHITESPACE_CHARS) # source.consume_regex(TILL_NEW_LINE_REGEX) # is_consumed = source.consume('\n') # if is_consumed: # statements.append(NewLine()) statement = parse_statement(source) # source.consume_regex(TILL_NEW_LINE_REGEX) # # # is_consumed = source.consume('\n') # if is_consumed: # statements.append(NewLine()) source.consume_regex(ENCLOSING_WHITESPACE_CHARS) statements.append(statement) source.expect_eof() return statements
def test_expect_eof_true(self): text = '' s = Source(text) # not raises InvalidTomlError s.expect_eof()
def test_expect_eof_false(self): text = '121' s = Source(text) with self.assertRaises(ExpectationError): s.expect_eof()