def parse_from_token_parser(self, token_parser: TokenParser) -> ArgumentsResolver: arguments = arguments_resolvers.empty() while not token_parser.is_at_eol: following_arguments = self._parse_element(token_parser) arguments = arguments.new_accumulated(following_arguments) token_parser.consume_current_line_as_string_of_remaining_part_of_current_line() return arguments
def _parse_from_start_str(self, here_doc_start: str, token_parser: TokenParser) -> StringSdv: marker_match = re.fullmatch(string.HERE_DOCUMENT_TOKEN_RE, here_doc_start) if not marker_match: return _raise_not_a_here_doc_exception(here_doc_start) marker = marker_match.group(2) token_parser.report_superfluous_arguments_if_not_at_eol() token_parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) return self._parse_contents(marker, token_parser)
def _parse(self, parser: token_stream_parser.TokenParser) -> AssertPhaseInstruction: expectation_type = parser.consume_optional_negation_operator() path_to_check = parse_file_ref.parse_file_ref_from_token_parser(_REL_OPTION_CONFIG, parser) file_matcher = self._parse_optional_file_matcher(parser) parser.consume_current_line_as_string_of_remaining_part_of_current_line() return _Instruction(expectation_type, path_to_check, file_matcher)
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( self, parser: token_stream_parser.TokenParser) -> AssertPhaseInstruction: expectation_type = parser.consume_optional_negation_operator() path_to_check = self._path_parser.parse_from_token_parser(parser) file_matcher = self._parse_optional_file_matcher(parser) parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) return _Instruction(expectation_type, path_to_check, file_matcher)
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_from_token_parser(self, parser: TokenParser) -> ProgramResolver: instruction_argument = parser.consume_current_line_as_string_of_remaining_part_of_current_line() argument_resolver = string_resolvers.str_constant(instruction_argument) return ProgramResolverForCommand( command_resolvers.for_shell(argument_resolver, validators=[self.validator]), accumulator.empty())
def parse_from_token_parser(self, parser: TokenParser) -> ProgramSdv: instruction_argument = parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) return ProgramSdvForCommand( test_command_sdvs.for_interpret_py_file_that_must_exist( path_sdvs.of_rel_option_with_const_file_name( RelOptionType.REL_ACT, instruction_argument)), AccumulatedComponents.empty())
def parse(token_parser: TokenParser) -> AssertionPart[ComparisonActualFile, FileToCheck]: string_matcher_resolver = parse_string_matcher.parse_string_matcher(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() token_parser.consume_current_line_as_string_of_remaining_part_of_current_line() return assertion_part.compose(ConstructFileToCheckAssertionPart(), StringMatcherAssertionPart(string_matcher_resolver))
def parse_from_token_parser(self, parser: TokenParser) -> ProgramResolver: instruction_argument = parser.consume_current_line_as_string_of_remaining_part_of_current_line() return ProgramResolverForCommand( test_command_resolvers.for_py_source_on_command_line(instruction_argument), accumulator.new_with_validators([self.validator]))
def parse_rest_of_line_as_single_string_and_consume_line(token_parser: TokenParser, strip_space: bool = False) -> StringSdv: argument_string = token_parser.consume_current_line_as_string_of_remaining_part_of_current_line() if strip_space: argument_string = argument_string.strip() return string_sdv_from_string(argument_string)
def parse_from_token_parser(self, parser: TokenParser) -> ProgramSdv: instruction_argument = parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) argument_sdv = string_sdvs.str_constant(instruction_argument) return ProgramSdvForCommand(command_sdvs.for_shell(argument_sdv), AccumulatedComponents.empty())
def parse_from_token_parser(self, parser: TokenParser) -> ProgramSdv: instruction_argument = parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) return ProgramSdvForCommand( test_command_sdvs.for_py_source_on_command_line( instruction_argument), AccumulatedComponents.empty())