Coder Social home page Coder Social logo

ggc's Introduction

ggc

Generative Grammar Compiler

Usage:

./ggc.sh <input.gg >output.py

See examples/test.gg, examples/zizek.gg, and 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 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)

ggc's People

Contributors

enkiv2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tra38

ggc's Issues

License?

I am unsure whether the GGC is meant to be freeware (where you can use the program for whatever you want, but you are not allowed to add any additional features and distribute them to others), or open source (if you intend to allow people to contribute their own changes and versions to GGC, or to create their own forks).

If it is the latter, I would recommend adding a license so people know how they can contribute to the project, without fear of legal liability in the future.

I understand that it is a bit silly to have a License that is likely going to have more lines than the actual code itself, but the consequences seem okay. You could also provide a link to your preferred license if you want.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.