Skip to content

estudio-hawara/choo-choo

Repository files navigation

Choo Choo

Choo Choo is a JavaScript library that generates visual railroad diagrams from Extended Backus-Naur Form (EBNF) grammars. Railroad diagrams provide an intuitive, graphical representation of formal language syntax rules, making it easier to understand and document complex grammars.

The library partially supports the ISO/IEC 14977 EBNF syntax and includes features like:

  • Optional sequences [ ... ]
  • Repetitions { ... }
  • Grouping ( ... )
  • Specials ? ... ?
  • Choices |
  • Sequences ,
  • Terminal strings " ... "
  • Comment blocks (* ... *)

Check docs/ebnf.ebnf for specific details of the supported features.

Note

I started writing this library while studying the Parser from scratch course from @dmitrysoshnikov, so you may find several similarities with his approach to recursive descent parser. Following his course[s] will definitely help you understanding this codebase.

Notes

Warning

Until this library is considered battle ready, it won't be uploaded to any package repository. Also, no releases will be created until that point. Use it at your discretion and remember that it's an unfinished piece of software shared without any warrant.

Install

git clone https://github.com/estudio-hawara/choo-choo
cd choo-choo
pnpm install

Tests

Run all the tests

Run the unit test suite to verify functionality:

pnpm run test

Run the coverage checks

Generate a test coverage report to ensure code quality:

pnpm run coverage

# or with full details

pnpm run coverage --verbose

Test manually in Node.js

Open an interative test session from Node:

# node
const Choo = require('./dist/cjs');
const parser = new Choo.Parser;
parser.parse('identifier = "a";');

Build

Recreate all the builds

Build both ESM and CommonJS versions of the library:

pnpm run build

References

About

Small library for creating railroad diagrams from Bakus-Naur Form grammars.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages