A GNU GPL Free peg grammar parser generator in C generating C99 C parsers with extra features

mooigraph 6a1bf1c0f9 doc update 2 years ago
doc d26014d4e3 updated readme 2 years ago
orig d26014d4e3 updated readme 2 years ago
src a8fcbe133e update paccrat.org 2 years ago
.gitignore 092a1a38b7 Initial commit 2 years ago
LICENSE 092a1a38b7 Initial commit 2 years ago
Makefile.am f62d9ce403 initial 2 years ago
README.md 6a1bf1c0f9 doc update 2 years ago
TODO 6a1bf1c0f9 doc update 2 years ago
autogen.sh f62d9ce403 initial 2 years ago
config.h d26014d4e3 updated readme 2 years ago
configure.ac d26014d4e3 updated readme 2 years ago
dmake f62d9ce403 initial 2 years ago
faq.md f62d9ce403 initial 2 years ago
screenshot.png f62d9ce403 initial 2 years ago

README.md

paccgpl

A GNU GPL Free peg grammar parser generator in C generating C99 C parsers with extra features

This is a GNU GPL Version 3+ Free peg grammar parser generator written in C
A peg grammar parser generator is a LL parser generator with infinitive look ahead
This is a autoconf'ed fork of the unmaintained pacc tool at packrat.org
This is renamed to paccgpl to avoid confusion with the original pacc program
This is additional tool for parsers and it is better to use GNU GPL Free tools

The grammar of this pacc tool is written in pacc itself in src/pacc.pacc
The peg grammar can replace the usual bison+flex tools because it includes lexing
The peg grammar can be edited for use with pegjs to generate a javascript parser
The peg grammar can be used to parse textual or binary data files
This parser generator tool does allow the use of utf8 chars in the input grammar
This parser generator tool can generate parsers for other languages changing src/emit.c
The generated parser is public domain becuase it is machine generated source and machine cannot own copyright

The src directory has the updated source which is worked on
The orig directory has the unmodified C sources of pacc version 0.3
The doc directory has the editable manual as texi source and info, man and pdf versions
The faq.md file has answers on frequently asked questions if any

To compile:
./autogen.sh
./configure
make

also:
make clean
make cleaner
make indent
./dmake

Usage: paccgpl [OPTION]... FILE  
  
Operation modes:  
  -h, --help               display this help and exit  
  -v, --version            report version number and exit  
  -D, --dump-ast=WHEN      dump the parse tree at various points  
  
Parser:  
  -n, --name=NAME          name the grammar (default: paccgpl)  
  -f, --feed=FILE          write extra feed parser to FILE  
  
Output:  
  -d, --define[=FILE]      also produce a header file (default: BASE.h)  
  -o, --output=FILE        write output to FILE (default: BASE.c)  
  

This is how the machine generated source code looks

int pacc_wrap(  
    __attribute__((unused)) const char *ign0,  
    __attribute__((unused)) char *ign1,  
    __attribute__((unused)) size_t ign2,  
    struct s_node **result) {  
struct s_node *n, *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7;  
n = s_new(call); n->text = "_"; p3 = n;  
n = cons(s_new(lit), p3); n->text = "*"; p3 = n;  
n = s_kid(seq, p3); p2 = n;  
n = cons(s_new(type), p2); n->text = "void"; p2 = n;  
n = s_kid(rule, p2); n->text = "Star"; p1 = n;  
n = s_new(call); n->text = "_"; p3 = n;  

The TODO file has the topics to improve in this source
Because Tobold Leto Goodwin from the pacc tool cannot be reached the email is set to

Links:
tcl tk has it own peg parser at https://wiki.tcl-lang.org/page/Parser+Tools
screenshot

SPDX-License-Identifier: GPL-3.0+
License-Filename: LICENSE

Made in 🇳🇱