All Projects → katef → Kgt

katef / Kgt

Licence: bsd-2-clause
BNF wrangling and railroad diagrams

Programming Languages

c
50402 projects - #5 most used programming language
grammar
57 projects

Projects that are alternatives of or similar to Kgt

Cppsharp
Tools and libraries to glue C/C++ APIs to high-level languages
Stars: ✭ 2,221 (+611.86%)
Mutual labels:  syntax-tree, parser, parsing
Libdparse
Library for lexing and parsing D source code
Stars: ✭ 91 (-70.83%)
Mutual labels:  syntax-tree, parser, parsing
Covfefe
A parser for nondeterministic context free languages
Stars: ✭ 49 (-84.29%)
Mutual labels:  parsing, parser-library, syntax-tree
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (-30.45%)
Mutual labels:  syntax-tree, parser, parsing
autumn
A Java parser combinator library written with an unmatched feature set.
Stars: ✭ 112 (-64.1%)
Mutual labels:  parsing, parser-library
Never
Never: statically typed, embeddable functional programming language.
Stars: ✭ 248 (-20.51%)
Mutual labels:  compiler, compilers
metal
A Java library for parsing binary data formats, using declarative descriptions.
Stars: ✭ 13 (-95.83%)
Mutual labels:  parsing, parser-library
librxvm
non-backtracking NFA-based regular expression library, for C and Python
Stars: ✭ 57 (-81.73%)
Mutual labels:  parsing, compilers
Fast
Find in AST - Search and refactor code directly in Abstract Syntax Tree as you do with grep for strings
Stars: ✭ 194 (-37.82%)
Mutual labels:  compiler, syntax-tree
langua
A suite of language tools
Stars: ✭ 29 (-90.71%)
Mutual labels:  syntax, syntax-tree
Concrete-Syntax-Tree
Concrete Syntax Trees represent s-expressions with source information
Stars: ✭ 48 (-84.62%)
Mutual labels:  parsing, syntax-tree
Saltwater
A C compiler written in Rust, with a focus on good error messages.
Stars: ✭ 219 (-29.81%)
Mutual labels:  compiler, parser
Xdpw
XD Pascal: A small embeddable self-hosting Pascal compiler for Windows. Supports Go-style methods and interfaces
Stars: ✭ 199 (-36.22%)
Mutual labels:  compiler, parser
postcss-jsx
PostCSS syntax for parsing CSS in JS literals
Stars: ✭ 73 (-76.6%)
Mutual labels:  syntax, parsing
Cub
The Cub Programming Language
Stars: ✭ 198 (-36.54%)
Mutual labels:  compiler, parser
cppcombinator
parser combinator and AST generator in c++17
Stars: ✭ 20 (-93.59%)
Mutual labels:  parsing, compilers
cs-resources
Curated Computer Science and Programming Resource Guide
Stars: ✭ 42 (-86.54%)
Mutual labels:  parsing, compilers
Dart Petitparser
Dynamic parser combinators in Dart.
Stars: ✭ 266 (-14.74%)
Mutual labels:  parser-library, parser
Nearley
📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
Stars: ✭ 3,089 (+890.06%)
Mutual labels:  parser, parsing
Lexical syntax analysis
编译原理词法分析器&语法分析器LR(1)实现 C++
Stars: ✭ 173 (-44.55%)
Mutual labels:  compiler, syntax

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]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].