{"id":21053067,"url":"https://github.com/sakateka/plt","last_synced_at":"2025-04-12T17:20:32.817Z","repository":{"id":30616839,"uuid":"114466999","full_name":"sakateka/plt","owner":"sakateka","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-04T19:26:08.000Z","size":329,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T11:44:43.112Z","etag":null,"topics":["cfg","chomsky","cnf","cnf-grammer","context-free-grammar","cyk-algorithm","cyk-parser","dfa","dpda","earley-algorithm","pda","sequence-generation","study"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakateka.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":"2017-12-16T14:32:52.000Z","updated_at":"2024-12-04T19:26:05.000Z","dependencies_parsed_at":"2024-11-19T16:05:08.223Z","dependency_job_id":"ff030921-75ad-4fba-b8eb-a894a8671428","html_url":"https://github.com/sakateka/plt","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakateka%2Fplt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakateka%2Fplt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakateka%2Fplt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakateka%2Fplt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakateka","download_url":"https://codeload.github.com/sakateka/plt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602364,"owners_count":21131625,"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":["cfg","chomsky","cnf","cnf-grammer","context-free-grammar","cyk-algorithm","cyk-parser","dfa","dpda","earley-algorithm","pda","sequence-generation","study"],"created_at":"2024-11-19T16:03:04.777Z","updated_at":"2025-04-12T17:20:32.798Z","avatar_url":"https://github.com/sakateka.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Theory of Programming Languages and Translation Methods\n=======================================================\n- Labs\n- Course works\n\nBuild for Windows\n=================\nInstruction from https://github.com/japaric/rust-cross\n\n```\nStep 0: Our target triple is `x86_64-pc-windows-gnu`\n\nStep 1: Install the C cross toolchain\n$ sudo apt install gcc-mingw-w64-x86-64\n\nStep 2: Install the cross compiled standard crates\n$ rustup target add x86_64-pc-windows-gnu\n\nStep 3: Configure cargo for cross compilation\n$ mkdir -p ~/.cargo\n$ cat \u003e\u003e ~/.cargo/config \u003c\u003cEOF\n\u003e [target.x86_64-pc-windows-gnu]\n\u003e linker = \"x86_64-w64-mingw32-gcc\"\n\u003e EOF\n\nStep 4: Build\n$ cargo build --release --target \"x86_64-pc-windows-gnu\"\n\nStep 5: Check result\n$ file target/x86_64-pc-windows-gnu/release/plt.exe\ntarget/x86_64-pc-windows-gnu/release/plt.exe: PE32+ executable (console) x86-64, for MS Windows\n```\n\n\n### Generation Example\n\n```\ncargo run -- gen sample/cfg/gen.cfg --len_max 4\n...\nbbbc\nbbba\nbbb\nbabb\ncbbb\nbbbb\nabbb\nbcbb\n```\n\n### DFA example\n\n```\ncargo run dfa sample/dfa/dfa.txt -p\n    Finished dev [unoptimized + debuginfo] target(s) in 0.01s\n     Running `target/debug/plt dfa sample/dfa/dfa.txt -p`\na\n-\u003eN-\u003eB\na - OK\naba\n-\u003eN-\u003eB-\u003eC-\u003eB\naba - OK\nababa\n-\u003eN-\u003eB-\u003eC-\u003eB-\u003eC-\u003eB\nababa - OK\nabba\n-\u003eN-\u003eB-\u003eC-\u003eN-\u003eB\nabba - OK\nabbaab\n-\u003eN-\u003eB-\u003eC-\u003eN-\u003eB-\u003eB-\u003eC\nabbaab - EOL but DFA state 'C' at row:1 is not accepting\n```\n\n\n### Grammar simplification\n\n```rust\npub fn simplify(\u0026self) -\u003e CFG {\n    self.remove_epsilon_rules()\n        .remove_unit_rules()\n        .remove_useless_rules()\n        .remove_unreachable_rules()\n}\n```\n\n```\ncat test.cfg\n\u003ce\u003e -\u003e \u003cX\u003e\u003cX\u003e\n\u003cX\u003e -\u003e \u003cX\u003e\u003cX\u003e\n\u003cX\u003e -\u003e \u003cX\u003e(\u003cX\u003e) | \u003cX\u003e(\u003cX\u003e,\u003cX\u003e) | \u003cX\u003e(\u003cX\u003e,\u003cX\u003e,\u003cX\u003e) |\n\ncargo run -- simplify test.cfg\n    Finished dev [unoptimized + debuginfo] target(s) in 0.01s\n     Running `target/debug/plt simplify test.cfg`\n\u003ce\u003e -\u003e  | () | (,) | (,,) | (,,X) | (,X) | (,X,) | (,X,X) | (X) | (X,) | (X,,) | (X,,X) | (X,X) | (X,X,) | (X,X,X) | X() | X(,) | X(,,) | X(,,X) | X(,X) | X(,X,) | X(,X,X) | X(X) | X(X,) | X(X,,) | X(X,,X) | X(X,X) | X(X,X,) | X(X,X,X) | XX\nX -\u003e () | (,) | (,,) | (,,X) | (,X) | (,X,) | (,X,X) | (X) | (X,) | (X,,) | (X,,X) | (X,X) | (X,X,) | (X,X,X) | X() | X(,) | X(,,) | X(,,X) | X(,X) | X(,X,) | X(,X,X) | X(X) | X(X,) | X(X,,) | X(X,,X) | X(X,X) | X(X,X,) | X(X,X,X) | XX\n\n```\n\n```rust\nlet cfg = self\n    .remove_start_from_rhs()\n    .remove_epsilon_rules()\n    .remove_unit_rules()\n    .remove_useless_rules()\n    .remove_unreachable_rules();\n// and then\n// Eliminate all rules having more than two symbols on the right-hand side.\n...\n// and then\n// Eliminate all rules of the form A →  u₁u₂,\n// where u₁ and u₂ are not both variables.\n...\n```\n\n```\ncargo run -- simplify --chomsky test.cfg\n    Finished dev [unoptimized + debuginfo] target(s) in 0.01s\n     Running `target/debug/plt simplify --chomsky test.cfg`\n\u003ce\u003e -\u003e  | \u003c(\u003e\u003c)\u003e | \u003c(\u003e\u003c,)\u003e | \u003c(\u003e\u003c,,)\u003e | \u003c(\u003e\u003c,,X)\u003e | \u003c(\u003e\u003c,X)\u003e | \u003c(\u003e\u003c,X,)\u003e | \u003c(\u003e\u003c,X,X)\u003e | \u003c(\u003e\u003cX)\u003e | \u003c(\u003e\u003cX,)\u003e | \u003c(\u003e\u003cX,,)\u003e | \u003c(\u003e\u003cX,,X)\u003e | \u003c(\u003e\u003cX,X)\u003e | \u003c(\u003e\u003cX,X,)\u003e | \u003c(\u003e\u003cX,X,X)\u003e | X\u003c()\u003e | X\u003c(,)\u003e | X\u003c(,,)\u003e | X\u003c(,,X)\u003e | X\u003c(,X)\u003e | X\u003c(,X,)\u003e | X\u003c(,X,X)\u003e | X\u003c(X)\u003e | X\u003c(X,)\u003e | X\u003c(X,,)\u003e | X\u003c(X,,X)\u003e | X\u003c(X,X)\u003e | X\u003c(X,X,)\u003e | X\u003c(X,X,X)\u003e | XX\n\u003c(\u003e -\u003e (\n\u003c()\u003e -\u003e \u003c(\u003e\u003c)\u003e\n\u003c(,)\u003e -\u003e \u003c(\u003e\u003c,)\u003e\n\u003c(,,)\u003e -\u003e \u003c(\u003e\u003c,,)\u003e\n\u003c(,,X)\u003e -\u003e \u003c(\u003e\u003c,,X)\u003e\n\u003c(,X)\u003e -\u003e \u003c(\u003e\u003c,X)\u003e\n\u003c(,X,)\u003e -\u003e \u003c(\u003e\u003c,X,)\u003e\n\u003c(,X,X)\u003e -\u003e \u003c(\u003e\u003c,X,X)\u003e\n\u003c(X)\u003e -\u003e \u003c(\u003e\u003cX)\u003e\n\u003c(X,)\u003e -\u003e \u003c(\u003e\u003cX,)\u003e\n\u003c(X,,)\u003e -\u003e \u003c(\u003e\u003cX,,)\u003e\n\u003c(X,,X)\u003e -\u003e \u003c(\u003e\u003cX,,X)\u003e\n\u003c(X,X)\u003e -\u003e \u003c(\u003e\u003cX,X)\u003e\n\u003c(X,X,)\u003e -\u003e \u003c(\u003e\u003cX,X,)\u003e\n\u003c(X,X,X)\u003e -\u003e \u003c(\u003e\u003cX,X,X)\u003e\n\u003c)\u003e -\u003e )\n\u003c,\u003e -\u003e ,\n\u003c,)\u003e -\u003e \u003c,\u003e\u003c)\u003e\n\u003c,,)\u003e -\u003e \u003c,\u003e\u003c,)\u003e\n\u003c,,X)\u003e -\u003e \u003c,\u003e\u003c,X)\u003e\n\u003c,X)\u003e -\u003e \u003c,\u003e\u003cX)\u003e\n\u003c,X,)\u003e -\u003e \u003c,\u003e\u003cX,)\u003e\n\u003c,X,X)\u003e -\u003e \u003c,\u003e\u003cX,X)\u003e\nX -\u003e \u003c(\u003e\u003c)\u003e | \u003c(\u003e\u003c,)\u003e | \u003c(\u003e\u003c,,)\u003e | \u003c(\u003e\u003c,,X)\u003e | \u003c(\u003e\u003c,X)\u003e | \u003c(\u003e\u003c,X,)\u003e | \u003c(\u003e\u003c,X,X)\u003e | \u003c(\u003e\u003cX)\u003e | \u003c(\u003e\u003cX,)\u003e | \u003c(\u003e\u003cX,,)\u003e | \u003c(\u003e\u003cX,,X)\u003e | \u003c(\u003e\u003cX,X)\u003e | \u003c(\u003e\u003cX,X,)\u003e | \u003c(\u003e\u003cX,X,X)\u003e | X\u003c()\u003e | X\u003c(,)\u003e | X\u003c(,,)\u003e | X\u003c(,,X)\u003e | X\u003c(,X)\u003e | X\u003c(,X,)\u003e | X\u003c(,X,X)\u003e | X\u003c(X)\u003e | X\u003c(X,)\u003e | X\u003c(X,,)\u003e | X\u003c(X,,X)\u003e | X\u003c(X,X)\u003e | X\u003c(X,X,)\u003e | X\u003c(X,X,X)\u003e | XX\n\u003cX)\u003e -\u003e X\u003c)\u003e\n\u003cX,)\u003e -\u003e X\u003c,)\u003e\n\u003cX,,)\u003e -\u003e X\u003c,,)\u003e\n\u003cX,,X)\u003e -\u003e X\u003c,,X)\u003e\n\u003cX,X)\u003e -\u003e X\u003c,X)\u003e\n\u003cX,X,)\u003e -\u003e X\u003c,X,)\u003e\n\u003cX,X,X)\u003e -\u003e X\u003c,X,X)\u003e\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakateka%2Fplt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakateka%2Fplt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakateka%2Fplt/lists"}