https://github.com/genentech/pikca4
https://github.com/genentech/pikca4
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/genentech/pikca4
- Owner: Genentech
- License: mit
- Created: 2022-03-29T14:51:15.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-02T04:00:23.000Z (about 4 years ago)
- Last Synced: 2025-03-30T01:31:56.937Z (about 1 year ago)
- Language: Python
- Size: 140 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Description
It takes a configuration file written in a specific format used by an open source tool to generate a reader that understands machine-readable codes as specified in the provided configuration file, and converts that provided configuration file into another format where a second open source tool is able to render as a visualisation, hence helping coders to learn how to write those machine-readable codes.
### Goal
Takes in any Antlr4 grammar file in, and generates Pikchr outputs.
It's visually helpful and attractive for potential users to understand and use a language.
```mermaid
graph TD;
Example.g4 --> example.pikchr
```
For instance:

### Examples
1. [Antlr4 grammar examples](https://github.com/antlr/grammars-v4)
1. [Pikchr examples](https://pikchr.org/home/doc/trunk/doc/examples.md)
### Usage
CAUTION: lexer rules must be removed first. (Need fix this)
##### Step 0: Build Pikchr command line tool
(See [Pikchr/Downloads](https://pikchr.org/home/doc/trunk/doc/download.md))
```bash
$ git clone https://github.com/drhsqlite/pikchr
$ cd pikchr
$ gcc -DPIKCHR_SHELL -o pikchr pikchr.c -lm # build the pikchr command-line tool
```
##### Step 1: Run pikca4
```bash
$ python main.py -h
usage: g4 To pikchr [-h] [-g GRAMMAR] [-op OUTPUTPIKCHR] [-os OUTPUTSVG]
optional arguments:
-h, --help show this help message and exit
-g GRAMMAR, --grammar GRAMMAR
path of the g4 grammer file
-op OUTPUTPIKCHR, --OutputPikchr OUTPUTPIKCHR
pikchr file folder path
-os OUTPUTSVG, --OutputSVG OUTPUTSVG
svg file folder path
# Example: *.pikchr files will be generated in `generated` at the project root dir
$ python src/main.py -g SQLiteParser.g4
```
##### Step 2: Run Pikchr command line tool
```bash
$ pikchr
usage: pikchr [OPTIONS] FILE ...
Convert Pikchr input files into SVG. Filename "-" means stdin.
Options:
--dont-stop Process all files even if earlier files have errors
--svg-only Omit raw SVG without the HTML wrapper
```