Statically typed BNF with semantic actions; A frontend of frontend frameworks; Use your grammar everywhere.

Overview

Typed BNF

Given a grammar:

We type inference it:

polyrule : forall 'a. ('a) -> (str, token, 'a)
polyrule2 : forall 'a. ('a) -> (str, token, 'a)

Then we can lower it to a BNF grammar used by other parser framework, no matter which programming language is the target.

Lark Backend

python -m tbnf GRAMMAR.tbnf lark [--outdir OUTDIR=.] [--mod MODULENAME=mylang]  

Antlr Backend

python -m tbnf GRAMMAR.tbnf antlr [--outdir OUTDIR=.] [--mod MODULENAME=mylang]  
You might also like...
This is a repository containing the backend and the frontend of a simple pokédex.

Pokémon This is a repository containing the backend and the frontend of a simple pokédex. This is a work in progress project! Project Structure 🗂 pok

apysc is the Python frontend library to create html and js file, that has ActionScript 3 (as3)-like interface.
apysc is the Python frontend library to create html and js file, that has ActionScript 3 (as3)-like interface.

apysc apysc is the Python frontend library to create HTML and js files, that has ActionScript 3 (as3)-like interface. Notes: Currently developing and

We'll be using HTML, CSS and JavaScript for the frontend

We'll be using HTML, CSS and JavaScript for the frontend. Nothing to install in specific. Open your text-editor and start coding a beautiful front-end.

This repo houses the qhub frontend moving forward.

This repo houses the qhub frontend moving forward. This effort will house a backend written in fastAPI, and a fronend in Vue, with additional components.

Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends.
Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends.

Quiz Application Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends. When they would a

The earliest beta version of pytgcalls on Linux x86_64 and ARM64! Use in production at your own risk!

Public beta test. Use in production at your own risk! tgcalls - a python binding for tgcalls (c++ lib by Telegram); pytgcalls - library connecting pyt

Automatically give thanks to Pypi packages you use in your project!

Automatically give thanks to Pypi packages you use in your project!

🟥This is an overview of how to set up and use DataStore3 in your Roblox experiences

Welcome to DataStore3 👋 This is an overview of how to set up and use DataStore3 in your Roblox experiences What is it? 🤔 DataStore3 is a service tha

Simple AoC helper program you can use to develop your own solutions in python.

AoC-Compabion Simple AoC helper program you can use to develop your own solutions in python. Simply install it in your python environment using pip fr

Comments
  •  use `A` for type parameters instead of `'A`

    use `A` for type parameters instead of `'A`

    This is because we want to support single quote literals such as 'x'. So far we use ANTLR backends to implement the metaparser(parser for Typed BNF itself), which makes it hard for us to achieve contextual lexing.

    opened by thautwarm 0
  • dependencies of lexer definition

    dependencies of lexer definition

    For antlr-csharp backend, such lexer rules work:

    <int> : DIGIT+
    <DIGIT> : [0 .. 9]
    

    <int> can be defined before presenting <DIGIT>, however, this will cause a compile error in ocaml-menhir+sedlex backend:

    let rule_INT_5 = [%sedlex.regexp? Plus (rule_DIGIT_4)]
    let rule_DIGIT_4 = [%sedlex.regexp? ('0' .. '9')]
    

    It's easy to resolve this order but I don't think it deserve a high priority.

    opened by thautwarm 0
Releases(0.2)
  • 0.2(Aug 7, 2022)

    > node tbnf.js  ./runtests/simple_json.tbnf -o ./runtests/julia_simple_json -lang "simple_json" -be julia-fff
    
    > node tbnf.js --help
    usage: tbnf.js [-h] [-o OUTDIR] [-lang LANGUAGE]
                   [-be {python-lark,ocaml-menhir,csharp-antlr,typescript-antlr,julia-fff,purebnf}]
                   [-conf CONFIGPATH]
                   tbnfSourcePath
    
    positional arguments:
      tbnfSourcePath
    
    optional arguments:
      -h, --help            show this help message and exit
      -o OUTDIR, --outDir OUTDIR
      -lang LANGUAGE, --language LANGUAGE
                            name of your own language
      -be {python-lark,ocaml-menhir,csharp-antlr,typescript-antlr,julia-fff,purebnf}, --backend {python-lark,ocaml-menhir,csharp-antlr,typescript-antlr,julia-fff,purebnf}
      -conf CONFIGPATH, --configPath CONFIGPATH
                            path to a config file
    
    Source code(tar.gz)
    Source code(zip)
    tbnf-linux(38.72 MB)
    tbnf-macos(44.25 MB)
    tbnf-win.exe(32.57 MB)
    tbnf.js(2.08 MB)
Owner
Taine Zhao
Taine Zhao
A quick experiment to demonstrate Metamath formula parsing, where the grammar is embedded in a few additional 'syntax axioms'.

Warning: Hacked-up code ahead. (But it seems to work...) What it does This demonstrates an idea which I posted about several times on the Metamath mai

Marnix Klooster 1 Oct 21, 2021
Context-free grammar to Sublime-syntax file

Generate a sublime-syntax file from a non-left-recursive, follow-determined, context-free grammar

Haggai Nuchi 8 Nov 17, 2022
A simple string parser based on CLR to check whether a string is acceptable or not for a given grammar.

A simple string parser based on CLR to check whether a string is acceptable or not for a given grammar.

Bharath M Kulkarni 1 Dec 15, 2021
A frontend to ease the use of pulseaudio's routing capabilities, mimicking voicemeeter's workflow

Pulsemeeter A frontend to ease the use of pulseaudio's routing capabilities, mimicking voicemeeter's workflow Features Create virtual inputs and outpu

Gabriel Carneiro 164 Jan 4, 2023
An ongoing curated list of frameworks, libraries, learning tutorials, software and resources in Python Language.

Python Development Welcome to the world of Python. An ongoing curated list of frameworks, libraries, learning tutorials, software and resources in Pyt

Paul Veillard 2 Dec 24, 2021
Placeholders is a single-unit storage solution for your Frontend.

Placeholder Placeholders is a single-unit file storage solution for your Frontend. Why Placeholder? Generally, when a website/service requests for fil

Tanmoy Sen Gupta 1 Nov 9, 2021
GitHub Actions Version Updater Updates All GitHub Action Versions in a Repository and Creates a Pull Request with the Changes.

GitHub Actions Version Updater GitHub Actions Version Updater is GitHub Action that is used to update other GitHub Actions in a Repository and create

Maksudul Haque 42 Dec 22, 2022
tox-gh is a tox plugin which helps running tox on GitHub Actions with multiple different Python versions on multiple workers in parallel

tox-gh is a tox plugin which helps running tox on GitHub Actions with multiple different Python versions on multiple workers in parallel. This project is inspired by tox-travis.

tox development team 19 Dec 26, 2022
Automated GitHub profile content using the USGS API, Plotly and GitHub Actions.

Top 20 Largest Earthquakes in the Past 24 Hours Location Mag Date and Time (UTC) 92 km SW of Sechura, Peru 5.2 11-05-2021 23:19:50 113 km NNE of Lobuj

Mr. Phantom 28 Oct 31, 2022
Auto check in via GitHub Actions

因为本人毕业离校,本项目交由在校的@hfut-xyc同学接手,请访问hfut-xyc/hfut_auto_check-in获得最新的脚本 本项目遵从GPLv2协定,Copyright (C) 2021, Fw[a]rd 免责声明 根据GPL协定,我、本项目的作者,不会对您使用这个脚本带来的任何后果

Fw[a]rd 3 Jun 27, 2021