Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enkiv2/ggc
Generative Grammar Compiler
https://github.com/enkiv2/ggc
Last synced: 1 day ago
JSON representation
Generative Grammar Compiler
- Host: GitHub
- URL: https://github.com/enkiv2/ggc
- Owner: enkiv2
- License: other
- Created: 2015-09-29T19:22:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-01T13:07:21.000Z (about 8 years ago)
- Last Synced: 2024-08-02T05:07:14.165Z (3 months ago)
- Language: Groff
- Size: 36.1 KB
- Stars: 19
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# ggc
Generative Grammar CompilerUsage:
./ggc.sh output.py
See [examples/test.gg](examples/test.gg), [examples/zizek.gg](examples/zizek.gg), and [examples/herosjourney.gg](examples/herosjourney.gg) for examples of grammars of varying complexity.
Notes:
* Anonymous rules are possible by enclosing options in braces ({})
* Named rules can be substituted using a single dollar sign before the named rule. If two dollar signs are used, then a cached expansion of that rule will be used instead (and everywhere that the double-dollarsign version is used will be the same).
* Lines beginning with '#' are comments, unless they begin with '#include' -- in which case, the second (space-separated) token is a filename to include. This filename cannot include spaces, because the spaces cannot be escaped.
* Duplicated spaces or separators will not be deduplicated; this is a FEATURE.
* Arbitrary python code can be inserted into a rule, if you're clever about it. (See the definition for HeroPronoun in [herosjourney](examples/herosjourney.gg) as an example.) This is currently the only way to do conditionals. This code is not sanitized or sandboxed. Obviously, you should manually check any untrusted grammar.Bugs:
* Recursive grammars are not possible, because the generated python code will generate all possible components immediately, whether or not they are used.
* Mismatched braces are neither detected nor handled gracefully. (WONTFIX)