{"id":24627873,"url":"https://github.com/stanleystanmarsh/binary-parser","last_synced_at":"2025-03-20T02:28:05.443Z","repository":{"id":266318813,"uuid":"897604571","full_name":"StanleyStanMarsh/binary-parser","owner":"StanleyStanMarsh","description":"The parser of binary expressions","archived":false,"fork":false,"pushed_at":"2025-01-24T01:32:54.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T02:25:58.046Z","etag":null,"topics":["haskell","parser"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StanleyStanMarsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-02T23:10:59.000Z","updated_at":"2025-01-24T01:32:58.000Z","dependencies_parsed_at":"2024-12-03T17:47:39.577Z","dependency_job_id":"4f073f58-e9b6-47e1-83ce-5c16d3142ffa","html_url":"https://github.com/StanleyStanMarsh/binary-parser","commit_stats":null,"previous_names":["stanleystanmarsh/binary-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanleyStanMarsh%2Fbinary-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanleyStanMarsh%2Fbinary-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanleyStanMarsh%2Fbinary-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanleyStanMarsh%2Fbinary-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StanleyStanMarsh","download_url":"https://codeload.github.com/StanleyStanMarsh/binary-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244538044,"owners_count":20468644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","parser"],"created_at":"2025-01-25T05:13:32.179Z","updated_at":"2025-03-20T02:28:05.422Z","avatar_url":"https://github.com/StanleyStanMarsh.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EN - Binary Parser\n\nThis project is a parser that reads lines from a `.txt` file containing values and binary operations. Supported operations include AND (\u0026), OR (|), and XOR (^). The project is written in Haskell and uses the `Lib.hs` library for pure functions and helper operations.\n\n## Formal Parser Description\n\nThe parser is implemented as a deterministic finite automaton (DFA) that recognizes lines such as `  10101   |101   `.\n\n![Finite Automaton Diagram](automata_bin_parser.png)\n\n*In the graph, operation = {\u0026, |, ^} represents the set of valid binary operations.*\n\n### Formal Definition\n\nM = (Q, Σ, δ, q₀, F), where:\n\n- Q = {s₀, s₁, s₂, s₃, s₄, s₅, s₆, s₇} - set of states\n- Σ = {0, 1, space, \u0026, |, ^, other, EOL} - input alphabet\n- q₀ = s₀ - initial state\n- F = {s₆} - set of accepting states\n- δ : Q × Σ → Q - transition function, defined in the following table:\n\n| State    | space | 0,1  | \u0026,\\|,^ | other | EOL  |\n|----------|-------|-------|--------|-------|------|\n| s₀       | s₀    | s₁    | s₇     | s₇    | s₇   |\n| s₁       | s₂    | s₁    | s₇     | s₇    | s₇   |\n| s₂       | s₂    | s₇    | s₃     | s₇    | s₇   |\n| s₃       | s₃    | s₄    | s₇     | s₇    | s₇   |\n| s₄       | s₅    | s₄    | s₇     | s₇    | s₇   |\n| s₅       | s₅    | s₇    | s₇     | s₇    | s₆   |\n| s₆       | s₇    | s₇    | s₇     | s₇    | s₇   |\n| s₇       | s₇    | s₇    | s₇     | s₇    | s₇   |\n\n### State Semantics:\n- s₀: Initial state, awaiting the first binary number\n- s₁: Reading the first binary number\n- s₂: Awaiting a binary operation\n- s₃: Awaiting the second binary number\n- s₄: Reading the second binary number\n- s₅: Awaiting the end of the line\n- s₆: Accepting state\n- s₇: Error state\n\n### Notes:\n- The automaton accepts lines in the format: `[spaces][binary number][spaces][operation][spaces][binary number][spaces]`\n- The state s₇ is an absorbing error state.\n- Any character not in the alphabet is considered 'other' and transitions to the error state s₇.\n- other = {c ∈ UTF-8 | c ∉ {0, 1, space, \u0026, |, ^, EOL}} - all UTF-8 characters not included in the alphabet Σ.\n\n## Installation and Execution\n\nTo run the project, you need to install the Stack package manager for Haskell. Then, follow these steps:\n\n```bash\ngit clone https://github.com/StanleyStanMarsh/binary-parser.git\ncd binary-parser\nstack build\nstack exec binary-parser-exe\n```\n\nWhen the program runs, it will prompt you for a filename to process. Enter the filename and press Enter. The program will parse the file's content and output the computation results to the console.\n\n## Project Structure\n\nThe project contains the following components:\n\n- `app/Main.hs`: The entry point of the application, managing user interaction and invoking core logic from the library.\n- `src/Lib.hs`: A library containing pure functions and helper methods for parsing, bitwise operations, and result computation.\n- `LICENSE`: The license file specifying the BSD-3-Clause License.\n- `automata_bin_parser.png`: A visual representation of the finite automaton used for parsing.\n\n## Input Data Examples\n\nThe input `.txt` file can contain lines in the following format:\n\n- `01010 \u0026 10101`\n- `11011 ^ 00100`\n\nWhen processed, the program evaluates these operations and produces the corresponding results. For instance:\n- `01010 \u0026 10101` would result in `00000`.\n- `11011 ^ 00100` would result in `11111`.\n\n## License\n\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\nThis project is licensed under the BSD-3-Clause License. You can find the complete license details in the [LICENSE](LICENSE) file.\n\n# RU - Binary Parser\n\nЭтот проект представляет собой парсер, который читает строки из текстового файла .txt, содержащие значения и бинарные операции над ними. Поддерживаемые операции включают AND (\u0026), OR (|) и XOR (^). Проект написан на языке Haskell и использует библиотеку Lib.hs для чистых функций и вспомогательных операций.\n\n## Формальное описание парсера\n\nПарсер реализован как детерминированный конечный автомат (ДКА), который распознает строки вида `  10101   |101   `.\n\n![Диаграмма конечного автомата](automata_bin_parser.png)\n\n*На графе operation = {\u0026, |, ^} - множество допустимых бинарных операций*\n\n### Формальное определение\n\nM = (Q, Σ, δ, q₀, F), где:\n\n- Q = {s₀, s₁, s₂, s₃, s₄, s₅, s₆, s₇} - множество состояний автомата\n- Σ = {0, 1, space, \u0026, |, ^, other, EOL} - входной алфавит\n- q₀ = s₀ - начальное состояние\n- F = {s₆} - множество допускающих состояний\n- δ : Q × Σ → Q - функция переходов, определенная следующей таблицей:\n\n| Состояние | space | 0,1 | \u0026,\\|,^ | other | EOL |\n|-----------|-------|-----|--------|--------|-----|\n| s₀        | s₀    | s₁  | s₇     | s₇     | s₇  |\n| s₁        | s₂    | s₁  | s₇     | s₇     | s₇  |\n| s₂        | s₂    | s₇  | s₃     | s₇     | s₇  |\n| s₃        | s₃    | s₄  | s₇     | s₇     | s₇  |\n| s₄        | s₅    | s₄  | s₇     | s₇     | s₇  |\n| s₅        | s₅    | s₇  | s₇     | s₇     | s₆  |\n| s₆        | s₇    | s₇  | s₇     | s₇     | s₇  |\n| s₇        | s₇    | s₇  | s₇     | s₇     | s₇  |\n\n### Семантика состояний:\n- s₀: Начальное состояние, ожидание первого бинарного числа\n- s₁: Чтение первого бинарного числа\n- s₂: Ожидание бинарной операции\n- s₃: Ожидание второго бинарного числа\n- s₄: Чтение второго бинарного числа\n- s₅: Ожидание конца строки\n- s₆: Допускающее состояние\n- s₇: Состояние ошибки\n\n### Примечания:\n- Автомат принимает строки формата: `[пробелы][бинарное число][пробелы][операция][пробелы][бинарное число][пробелы]`\n- Состояние s₇ является поглощающим состоянием ошибки\n- Любой символ, не принадлежащий алфавиту, считается как 'other' и приводит к переходу в состояние ошибки s₇\n- other = {c ∈ UTF-8 | c ∉ {0, 1, space, \u0026, |, ^, EOL}} - все символы UTF-8, не входящие в алфавит Σ\n\n## Установка и запуск\n\nДля запуска проекта необходимо установить пакетный менеджер Stack для Haskell. После этого выполните следующие шаги:\n\n```bash\ngit clone https://github.com/StanleyStanMarsh/binary-parser.git\ncd binary-parser\nstack build\nstack exec binary-parser-exe\n```\n\n\nПри запуске программа запросит у вас имя файла для обработки. Введите название файла и нажмите Enter. Программа произведет синтаксический разбор содержимого файла и выведет результат вычислений на экран.\n\n## Структура проекта\n\nПроект состоит из нескольких файлов:\n\n- `app/Main.hs`: Основной модуль приложения, отвечающий за взаимодействие с пользователем и вызов функций библиотеки.\n- `src/Lib.hs`: Библиотека с чистыми функциями и вспомогательными методами для работы с битами и операциями.\n\n## Примеры входных данных\n\nФайлы могут содержать строки следующего вида:\n\n- 01010 \u0026 10101\n\n- 11011 ^ 00100\n\n\nРезультатом выполнения этой строки будет значение, полученное после применения всех указанных операций к соответствующим битовым строкам.\n\n## Лицензия\n\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\nЭтот проект распространяется под лицензией BSD-3-Clause. См. файл [LICENSE](LICENSE) для получения дополнительной информации.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanleystanmarsh%2Fbinary-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanleystanmarsh%2Fbinary-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanleystanmarsh%2Fbinary-parser/lists"}