{"id":13621723,"url":"https://github.com/bdusell/pycfg","last_synced_at":"2025-04-09T17:55:41.113Z","repository":{"id":73626697,"uuid":"14659048","full_name":"bdusell/pycfg","owner":"bdusell","description":"Parsing and analysis of arbitrary context-free grammars","archived":false,"fork":false,"pushed_at":"2014-05-14T17:02:27.000Z","size":312,"stargazers_count":8,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-08T08:42:08.652Z","etag":null,"topics":["aho","cfg","context-free-grammar","glr","grammar","lr-parsing","parsing","python","tomita","ullman"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdusell.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}},"created_at":"2013-11-24T09:58:39.000Z","updated_at":"2024-05-31T17:01:14.000Z","dependencies_parsed_at":"2023-02-24T05:30:21.519Z","dependency_job_id":null,"html_url":"https://github.com/bdusell/pycfg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fpycfg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fpycfg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fpycfg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fpycfg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdusell","download_url":"https://codeload.github.com/bdusell/pycfg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248083590,"owners_count":21045122,"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":["aho","cfg","context-free-grammar","glr","grammar","lr-parsing","parsing","python","tomita","ullman"],"created_at":"2024-08-01T21:01:09.917Z","updated_at":"2025-04-09T17:55:41.066Z","avatar_url":"https://github.com/bdusell.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"pycfg\n=====\n\nThis repository contains a Python package, `cfg`, which implements\ndata structures and algorithms for carrying out sophisticated analysis and\nparsing of arbitrary context-free grammars. The main vehicle used for CFG\nparsing is the GLR (Generalized-LR) algorithm discovered by Masaru Tomita.\nSeveral pedagogical parsing algorithms described by Alfred Aho and Jeffrey\nUllman are also included. A tool named `pycfg` provides a command-line\ninterface to CFG analysis algorithms.\n\nContents\n--------\n\nThe file `pycfg` is a command-line utility for analyzing CFGs. It can:\n\n* Convert grammars to Chomsky Normal Form\n* Compute a grammar's first and follow sets\n* Create a diagram of a grammar's DFA of LR(0) items used for LR parsing\n* Compute a grammar's SLR(1) parse table\n* Generate a report in HTML of the steps taken to build the parse table\n* Make you a sandwich, as long as you have root privileges\n\nUse the command\n\n    ./pycfg\n\nwithout arguments to see a full help message.\n\nThe `src/` directory contains the Python packages `cfg` and `util`. Included\nin `cfg` are:\n\n* A class structure for context free grammars, symbols, parse trees, etc.\n* Tomita's GLR parsing algorithm, modified to handle empty production rules\n  and cyclic grammars\n* Algorithms for building first sets, follow sets, and multi-valued SLR parse\n  tables\n* Parsing algorithms described by Aho and Ullman and included for pedagogical\n  purposes\n* Other algorithms such as cycle and left-recursion detection\n\nThe `test/` directory contains unit tests for most components in the\nlibrary. Use\n\n    ./run_tests\n\nto run all of the test cases included here, which should all pass.\n\nThe `demos/` directory contains some standalone Python scripts demonstrating\nthe use of the library.\n\nDemo\n----\n\nThe `demos/` directory has a number of driver programs demonstrating the use\nof various parts of the library. For example, the command\n\n    cd src; python ../demos/glr_demo.py ../demos/grammars/gra.txt\n\nwill bring up a prompt for input symbols to be parsed with respect to the\nambiguous grammar described in `demos/grammars/gra.txt`, and then generate\nand display images of the resulting parse trees. In this case the input\nalphabet consists of the characters 'n' for noun, 'd' for determiner, 'v'\nfor verb, and 'p' for preposition. To run the example\non an ambiguous sentence with six valid parse trees, enter the following\ncharacters at the prompt and then press Ctrl-C, as shown below:\n\n    \u003e\u003e n\n    \u003e\u003e v\n    \u003e\u003e n\n    \u003e\u003e a\n    \u003e\u003e n\n    \u003e\u003e v\n    \u003e\u003e d\n    \u003e\u003e n\n    \u003e\u003e p\n    \u003e\u003e d\n    \u003e\u003e n\n    \u003e\u003e \u003cCtrl-C\u003e\n\nThis corresponds to the sentence \"I saw Jane and Jack hit the man with a\ntelescope.\"\n\nReferences\n----------\n\n* Aho, Alfred V., and Ullman, Jeffrey D. *The Theory of Parsing, Translation,\n  and Compiling: Volume I: Parsing*. Englewood Cliffs, NJ: Prentice-Hall,\n  Inc. 1972.\n* Tomita, Masaru (Ed.). *Generalized LR Parsing*. Boston, MA: Kluwer Academic\n  Publishers. 1991.\n* The Dragon Book.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fpycfg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdusell%2Fpycfg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fpycfg/lists"}