def _parse_file_specs(self, token_parser: TokenParser) -> Sequence[file_list.FileSpecificationSdv]: ret_val = [] while not token_parser.has_valid_head_matching(_TOKEN_SPEC_LIST_END): ret_val.append(self._file_spec_parser.parse(token_parser)) if not token_parser.has_valid_head_matching(_TOKEN_SPEC_LIST_END): token_parser.require_is_at_eol(self._superfluous_line_contents_message) return ret_val
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_elements(tokens: TokenParser) -> Sequence[Tuple[StringSdv, Optional[FileMatcherSdv]]]: _multiple_files_per_line_error = _MESSAGE_FACTORY.generator_for(_MULTIPLE_FILES_ON_SINGLE_LINE) def is_at_eol_or_end_of_set(): if tokens.is_at_eol: return else: tokens.require_head_is_unquoted_and_equals(syntax.LITERAL_END, _multiple_files_per_line_error) def parse_element() -> Tuple[StringSdv, Optional[FileMatcherSdv]]: file_name = parse_string.parse_string_sdv(tokens.token_stream, _FILE_NAME_STRING_CONFIGURATION) if tokens.head_is_unquoted_and_equals(syntax.FILE_MATCHER_SEPARATOR): tokens.consume_head() file_matcher = parse_file_matcher.parsers().full.parse_from_token_parser(tokens) return file_name, file_matcher else: is_at_eol_or_end_of_set() return file_name, None ret_val = [] while not tokens.has_valid_head_matching(_TOKEN_IS_SET_END): ret_val.append(parse_element()) return ret_val