def parse(self, token_parser: TokenParser) -> List[ELEMENT]: ret_val = [] while not token_parser.is_at_eol: if token_parser.remaining_part_of_current_line.strip() == defs.CONTINUATION_TOKEN: token_parser.consume_current_line_as_string_of_remaining_part_of_current_line() continue if token_parser.has_valid_head_matching(defs.IS_STOP_AT_TOKEN): break sym_name_or_element = self._element_parser.parse(token_parser) ret_val.append(self._mk_element.reduce(sym_name_or_element)) if token_parser.is_at_eol: token_parser.consume_remaining_part_of_current_line_as_string() return ret_val
def _parse_contents(marker: str, token_parser: TokenParser) -> StringSdv: here_doc = [] while token_parser.has_current_line: line = token_parser.consume_remaining_part_of_current_line_as_string( ) if line == marker: return _sdv_from_lines(here_doc) here_doc.append(line) token_parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) return _raise_end_marker_not_found(marker)
def parse_rest_of_line_as_single_string(token_parser: TokenParser, strip_space: bool = False) -> StringSdv: argument_string = token_parser.consume_remaining_part_of_current_line_as_string() if strip_space: argument_string = argument_string.strip() return string_sdv_from_string(argument_string)