Giter VIP home page Giter VIP logo

kgt's Introduction

KGT: Kate's Grammar Tool

Do you want to convert various kinds of BNF to other kinds of BNF? No?
Well imagine if you did! This would be the tool for you.

Input: Various BNF-like syntaxes
Output: Various BNF-like syntaxes, AST dumps, and Railroad Syntax Diagrams

Compilation phases:

phases.svg

  • Bold indicates the input BNF dialects with the most features
  • โœจ indicates presentational formats (these are the good ones!)
  • ๐Ÿงช indicates debugging formats.
    You don't want these unless you're looking at kgt's internals.
  • Other formats provide various subsets of features

Gallery:

Getting started:

See the /examples directory for grammars in various BNF dialects. These have been collated from various sources and are of various quality. BNF dialects tend to be poorly specified, and these examples are an attempt to keep a corpus of known-good examples for each dialect. kgt can't parse them all yet.

kgt reads from stdin in dialect -l ... and writes to stdout in format -e ...:

; kgt -l bnf -e rrutf8 < examples/expr.bnf
expr:
    โ”‚โ”œโ”€โ”€โ•ฎโ”€โ”€ term โ”€โ”€ "+" โ”€โ”€ expr โ”€โ”€โ•ญโ”€โ”€โ”คโ”‚
        โ”‚                         โ”‚
        โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ term โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

term:
    โ”‚โ”œโ”€โ”€โ•ฎโ”€โ”€ factor โ”€โ”€ "*" โ”€โ”€ term โ”€โ”€โ•ญโ”€โ”€โ”คโ”‚
        โ”‚                           โ”‚
        โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ factor โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

factor:
    โ”‚โ”œโ”€โ”€โ•ฎโ”€โ”€ "(" โ”€โ”€ expr โ”€โ”€ ")" โ”€โ”€โ•ญโ”€โ”€โ”คโ”‚
        โ”‚                        โ”‚
        โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ const โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

const:
    โ”‚โ”œโ”€โ”€ integer โ”€โ”€โ”คโ”‚

and the same grammar output as SVG instead:

; kgt -l bnf -e svg < examples/expr.bnf > /tmp/expr.svg

expr.svg

Clone with submodules (contains required .mk files):

; git clone --recursive https://github.com/katef/kgt.git

To build and install:

; pmake -r install

You can override a few things:

; CC=clang PREFIX=$HOME pmake -r install

Building depends on:

  • Any BSD make. This includes OpenBSD, FreeBSD and NetBSD make(1) and sjg's portable bmake (also packaged as pmake).

  • A C compiler. Any should do, but GCC and clang are best supported.

  • ar, ld, and a bunch of other stuff you probably already have.

Ideas, comments or bugs: [email protected]

kgt's People

Contributors

amyjbrown avatar arthursonzogni avatar dhobsd avatar drj11 avatar edk0 avatar katef avatar silentbicycle avatar

Watchers

 avatar

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.