def __init__(self): super().__init__(COMMAND_LINE_ACTOR) self._tp = TextParser({ 'LINE_COMMENT_MARKER': formatting.string_constant(LINE_COMMENT_MARKER), 'PROGRAM': syntax_elements.PROGRAM_SYNTAX_ELEMENT.singular_name, 'STRING_TRANSFORMER': syntax_elements.STRING_TRANSFORMER_SYNTAX_ELEMENT.singular_name, 'PATH': syntax_elements.PATH_SYNTAX_ELEMENT.singular_name, 'path': types.PATH_TYPE_INFO.name, 'executable_file': formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE), 'relativity': formatting.misc_name_with_formatting(misc_texts.RELATIVITY), 'stdout': misc_texts.STDOUT, 'stdin': misc_texts.STDIN, 'os_process': misc_texts.OS_PROCESS_NAME, 'setup_phase': phase_names.SETUP, })
def __init__(self): super().__init__(SOURCE_INTERPRETER_ACTOR) format_map = { 'phase': phase_names.PHASE_NAME_DICTIONARY, 'actor_option': formatting.cli_option(common_cli_options.OPTION_FOR_ACTOR), 'actor_instruction': formatting.InstructionName(ACTOR_INSTRUCTION_NAME), 'shell_command': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND), } self._parser = TextParser(format_map)
def _text_parser() -> TextParser: return TextParser({ 'phase_declaration_for_NAME': section_header('NAME'), 'instr': AnyInstructionNameDictionary(), 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'instruction_description': defs.INSTRUCTION_DESCRIPTION, 'description_delimiter': defs.DESCRIPTION_DELIMITER, 'description_delimiter_char_name': defs.DESCRIPTION_DELIMITER_CHAR_NAME, 'default_phase': phase_names.PHASE_NAME_DICTIONARY[DEFAULT_PHASE.identifier].syntax, 'phase': phase_names.PHASE_NAME_DICTIONARY, 'actor': formatting.concept_(ACTOR_CONCEPT_INFO), 'CONTENTS_EQUALS_ARGUMENT': contents_opts.EQUALS_ARGUMENT, 'CONTENTS_EMPTY_ARGUMENT': contents_opts.EMPTY_ARGUMENT, 'line_comment_char': LINE_COMMENT_MARKER, 'file_inclusion_directive_in_text': formatting.keyword(directives.INCLUDING_DIRECTIVE_INFO.singular_name), 'file_inclusion_directive': directives.INCLUDING_DIRECTIVE_INFO.singular_name, 'shell_command': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND), 'plain_string': misc_texts.PLAIN_STRING, 'instruction__shell_cmd_line': instruction_names.SHELL_INSTRUCTION_NAME, 'instruction__stdout': instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME, 'instruction__stderr': instruction_names.CONTENTS_OF_STDERR_INSTRUCTION_NAME, 'instruction__exit_code': instruction_names.EXIT_CODE_INSTRUCTION_NAME, 'INT_EQUALS_OPERATOR': comparators.EQ.name, 'HERE_DOCUMENT_MARKER_PREFIX': string.HERE_DOCUMENT_MARKER_PREFIX, 'MARKER': 'EOF', 'sds_result_dir': sds.SUB_DIRECTORY__RESULT, 'sds_stdout_file': sds.RESULT_FILE__STDOUT, })
def plain_symbol_name_is_reserved_word(self, primitive_name: str) -> str: formatter = StringFormatter({ 'reserved_word': formatting.misc_name_with_formatting(misc_texts.RESERVED_WORD_NAME), 'syntax_element': self._grammar.concept.syntax_element.name, 'actual': formatting.keyword(primitive_name), }) lines = [formatter.format(self._RESERVED_WORD__HEADER), '', formatter.format(self._RESERVED_WORD__LIST_HEADER), ''] lines += [ self._INDENT + formatting.keyword(reserved_word) for reserved_word in sorted(self._grammar.custom_reserved_words) ] return '\n'.join(lines)
def purpose(self) -> DescriptionWithSubSections: parser = TextParser({ 'phase': phase_names.PHASE_NAME_DICTIONARY, 'the_concept': formatting.conf_param_( conf_params.HDS_ACT_DIRECTORY_CONF_PARAM_INFO), 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'dir_symbol': tcds_symbols.SYMBOL_HDS_ACT, 'rel_option': formatting.cli_option(REL_HDS_ACT_OPTION), 'executable_file': formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE), 'symbol': concepts.SYMBOL_CONCEPT_INFO.name, }) return from_simple_description( Description(self.single_line_description(), parser.fnap(_REST_DESCRIPTION)))
def __init__(self, grammar: Grammar): self.grammar = grammar self.concept_argument = a.Single(a.Multiplicity.MANDATORY, self.grammar.concept.syntax_element) self.infix_operators__list = collection.concat_list( grammar.infix_ops_inc_precedence__seq) self._tp = TextParser({ 'symbol_concept': formatting.concept_name_with_formatting( concepts.SYMBOL_CONCEPT_INFO.name), 'concept_name': self.grammar.concept.name, 'string_type': types.STRING_TYPE_INFO.name, 'BIN_OP_PRECEDENCE': _BIN_OP_PRECEDENCE, 'whitespace': misc_texts.WHITESPACE, 'reserved_word': formatting.misc_name_with_formatting( misc_texts.RESERVED_WORD_NAME), })
def __init__(self): self._tp = TextParser({ 'test_case_file': 'helloworld.case', 'EXECUTABLE_PROGRAM': PROGRAM_NAME, 'program_name': formatting.program_name(PROGRAM_NAME), 'action_to_check': 'helloworld', 'ATC': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO), 'CONTENTS_EQUALS_ARGUMENT': EQUALS_ARGUMENT, 'INT_EQUALS_OPERATOR': comparators.EQ.name, 'act': phase_names.ACT, 'assert': phase_names.ASSERT, 'PASS': exit_values.EXECUTION__PASS.exit_identifier, 'FAIL': exit_values.EXECUTION__FAIL.exit_identifier, 'stdout_instruction': instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME, 'exit_code_instruction': instruction_names.EXIT_CODE_INSTRUCTION_NAME, 'executable_file': formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE), 'console_style': std_tags.CONSOLE_TEXT, 'HERE_DOCUMENT_MARKER_PREFIX': string.HERE_DOCUMENT_MARKER_PREFIX, 'MARKER': 'EOF', })
def __init__(self): super().__init__(concepts.INSTRUCTION_CONCEPT_INFO) self._tp = TextParser({ 'instruction': self.name(), 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'symbol': concepts.SYMBOL_CONCEPT_INFO.name, 'def': InstructionName( instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'act': phase_infos.ACT.name, 'atc': concepts.ACTION_TO_CHECK_CONCEPT_INFO.name, 'assert': phase_infos.ASSERT.name, 'cleanup': phase_infos.CLEANUP.name, 'shell_command_line': formatting.misc_name_with_formatting( misc_texts.SHELL_COMMAND_LINE), })
from exactly_lib.definitions.formatting import misc_name_with_formatting from exactly_lib.util import name SYNTAX_ERROR_NAME = name.a_name(name.name_with_plural_s('syntax error')) FILE_ACCESS_ERROR_NAME = name.a_name(name.name_with_plural_s('file access error')) OS_PROCESS_NAME = misc_name_with_formatting( name.an_name(name.Name('OS process', 'OS processes'))) EXIT_IDENTIFIER = misc_name_with_formatting( name.an_name(name.name_with_plural_s('exit identifier'))) EXIT_CODE = name.an_name(name.name_with_plural_s('exit code')) EXIT_IDENTIFIER_TITLE = EXIT_IDENTIFIER.singular.capitalize() IS_A_SHELL_CMD = """is a shell command (with optional arguments), using Unix shell syntax.""" RELATIVITY = misc_name_with_formatting( name.a_name(name.Name('relativity', 'relativities'))) EXIT_CODE_TITLE = EXIT_CODE.singular.capitalize() TEST_CASE_SPEC_TITLE = 'Specification of test case functionality' TEST_SUITE_SPEC_TITLE = 'Specification of test suite functionality' SYMBOL_COMMAND_SINGLE_LINE_DESCRIPTION = 'Reports the usage of symbols in a test case'
def root(header: str, test_case_help: TestCaseHelp) -> generator.SectionHierarchyGenerator: tp = TextParser({ 'default_suite_file_name': file_names.DEFAULT_SUITE_FILE, 'act': phase_infos.ACT.name, 'assert': phase_infos.ASSERT.name, 'setup': phase_infos.SETUP.name, 'action_to_check': concepts.ACTION_TO_CHECK_CONCEPT_INFO.name, 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'ATC': concepts.ACTION_TO_CHECK_CONCEPT_INFO.acronym, 'actor': concepts.ACTOR_CONCEPT_INFO.name, 'os_process': misc_texts.OS_PROCESS_NAME, 'null_actor': actors.NULL_ACTOR.singular_name, 'shell_command_marker': SHELL_COMMAND_MARKER, 'shell_command': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND), 'shell_command_line': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND_LINE), }) def const_paragraphs(header_: StrOrStringText, initial_paragraphs: List[docs.ParagraphItem]) -> generator.SectionHierarchyGenerator: return h.leaf(header_, sections.constant_contents(docs.section_contents(initial_paragraphs))) def phases_documentation() -> List[ParagraphItem]: return (tp.fnap(_PHASES_INTRO) + [sections_short_list(test_case_help.phase_helps_in_order_of_execution, phase_identifier.DEFAULT_PHASE.section_name, phase_names_plain.SECTION_CONCEPT_NAME)]) act_contents = sections.contents( paragraphs.constant(tp.fnap(_ACT)), [ _act_examples(tp), see_also.SeeAlsoSectionConstructor( see_also.items_of_targets(_act_see_also_targets()) ) ] ) instructions_contents = sections.contents( paragraphs.constant(tp.fnap(_INSTRUCTIONS)), [ see_also.SeeAlsoSectionConstructor( see_also.items_of_targets(_instructions_see_also_targets()) ) ] ) return h.hierarchy( header, children=[ h.child('phases', const_paragraphs('Phases', phases_documentation()) ), h.child('act', h.leaf( tp.text('The {act} phase, {action_to_check:/q} and {actor:s/q}'), act_contents ) ), h.child('instructions', h.leaf(tp.text('{instruction:s/u}'), instructions_contents) ), h.child('suites', h.hierarchy( 'Relation to test suites', children=[ h.child('suite-contents', const_paragraphs('Inclusion of phase contents from suites', tp.fnap(_SUITE_CONTENTS_INCLUSION)) ), h.child('part-of-suite', const_paragraphs('Part of suite', tp.fnap(_PART_OF_SUITE)) ), h.leaf_not_in_toc( see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_suite_see_also_targets()) ) ), ]), ), ] )
syntax_elements.STRING_SYNTAX_ELEMENT, syntax_elements.PROGRAM_ARGUMENT_SYNTAX_ELEMENT, ]), ) def _executable_file_description() -> Sequence[ParagraphItem]: return rel_path_doc.path_element_relativity_paragraphs( parse_act_interpreter.EXE_FILE_RELATIVITIES.options, _TEXT_PARSER.paras(path_syntax.the_path_of('{executable_file:a}.')), ) _TEXT_PARSER = TextParser({ 'executable_file': formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE), 'external_program': misc_texts.EXTERNAL_PROGRAM, 'PATH': syntax_elements.PATH_SYNTAX_ELEMENT.singular_name, 'symbol': concepts.SYMBOL_CONCEPT_INFO.name, 'setup_phase': phase_names.SETUP, }) _MAIN__DESCRIPTION = """\ {external_program:a/u} that interprets a source code file, who's path is given as a command line argument. When the program is applied, the path of the source code file is added as the last argument.
from exactly_lib.definitions.formatting import misc_name_with_formatting from exactly_lib.util.str_ import name STEP_PRE_PROCESSING = misc_name_with_formatting( name.a_name(name.name_with_plural_s('preprocessing'))) STEP_VALIDATION = misc_name_with_formatting( name.a_name(name.name_with_plural_s('validation'))) STEP_EXECUTION = misc_name_with_formatting( name.an_name(name.name_with_plural_s('execution')))
from exactly_lib.definitions import formatting from exactly_lib.definitions.entity import all_entity_types from exactly_lib.definitions.formatting import misc_name_with_formatting from exactly_lib.util.str_ import name WHITESPACE = 'whitespace' RESERVED_WORD_NAME = name.a_name(name.name_with_plural_s('reserved word')) SYNTAX_ERROR_NAME = name.a_name(name.name_with_plural_s('syntax error')) FILE_ACCESS_ERROR_NAME = name.a_name( name.name_with_plural_s('file access error')) EXIT_IDENTIFIER = misc_name_with_formatting( name.an_name(name.name_with_plural_s('exit identifier'))) EXIT_CODE = misc_name_with_formatting( name.an_name(name.name_with_plural_s('exit code'))) EXIT_CODE_TITLE = EXIT_CODE.singular.capitalize() STDOUT = 'stdout' STDERR = 'stderr' STDIN = 'stdin' OS_PROCESS_NAME = misc_name_with_formatting( name.an_name(name.Name('OS process', 'OS processes'))) CURRENT_OS = 'current OS' NEW_LINE_STRING_CONSTANT = formatting.string_constant('\\n')
TEXT_PARSER = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'phase': phase_names.PHASE_NAME_DICTIONARY, 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'test_case_status': formatting.conf_param( conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO.informative_name), 'default_status': test_case_status.NAME_DEFAULT, 'error_in_source': formatting.misc_name_with_formatting(misc_texts.SYNTAX_ERROR_NAME), 'exit_code': formatting.misc_name_with_formatting(misc_texts.EXIT_CODE), 'exit_identifier': formatting.misc_name_with_formatting(misc_texts.EXIT_IDENTIFIER), 'including': formatting.keyword(directives.INCLUDING_DIRECTIVE_INFO.singular_name), }) PREAMBLE = '' REPORTING = """\ Outcome is reported either as {exit_code:a}, or as {exit_code:a} together with {exit_identifier:a} printed as a single line on stdout. """
from exactly_lib.help.entities.utils import programs from exactly_lib.help.entities.utils.se_within_parens import OptionallyWithinParens from exactly_lib.impls import texts from exactly_lib.impls.types.path import relative_path_options_documentation as rel_path_doc from exactly_lib.impls.types.program import syntax_elements as pgm_syntax_elements from exactly_lib.processing import exit_values from exactly_lib.section_document import defs from exactly_lib.type_val_deps.types.path import path_relativities from exactly_lib.util.cli_syntax.elements import argument as a from exactly_lib.util.str_ import name from exactly_lib.util.textformat.structure.core import ParagraphItem from exactly_lib.util.textformat.textformat_parser import TextParser _STDIN_ARGUMENT = a.Named('STDIN') _ARGUMENT_LIST_TYPE = misc_name_with_formatting( name.an_name(name.Name.new_with_plural_s('argument list'))) class _Documentation(SyntaxElementDocumentation): def __init__(self): super().__init__(syntax_elements.PROGRAM_SYNTAX_ELEMENT) self._pgm_and_args = _PgmAndArgs() def main_description_rest_paragraphs(self) -> List[ParagraphItem]: return [] def invokation_variants(self) -> List[InvokationVariant]: return [ invokation_variant_from_args([ a.single_mandatory(self._pgm_and_args.element), a.Single(a.Multiplicity.OPTIONAL, _STDIN_ARGUMENT),
from typing import Sequence from exactly_lib.definitions import formatting, misc_texts from exactly_lib.util.textformat.structure import lists from exactly_lib.util.textformat.structure import structures as docs from exactly_lib.util.textformat.structure.core import ParagraphItem from exactly_lib.util.textformat.textformat_parser import TextParser def atc_examples() -> Sequence[ParagraphItem]: return [ docs.simple_header_only_list( [_TP.text(example) for example in _EXAMPLES], lists.ListType.ITEMIZED_LIST, ) ] _EXAMPLES = [ 'executable program file (with arguments)', 'source code file (with arguments)', 'source code', '{shell_command}', ] _TP = TextParser({ 'shell_command': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND_LINE), })