yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
880 stars 112 forks source link

PEG grammar for cpp-peglib #221

Closed yhirose closed 2 years ago

yhirose commented 2 years ago

@mingodad, I am impressed with the PEG grammar for cpp-peglib parser you showed in some previous issues. Is it possible for you to contribute it to this project? That could be very useful when I enhance cpp-peglib parser syntax. If it's ok, could you send a pull request which puts the grammar file in grammar folder? (Could the file name be like cpp-peglib.peg?) Thanks for consideration!

mingodad commented 2 years ago

Yes of course you can use it and because it's basically your hardcoded grammar in peglib.h in peg format it's already your.

mingodad commented 2 years ago

Another interesting addition would be to have in cpp-peglib a function to dump the grammar as C++ code/calls like it's used inpeglib.h here https://github.com/yhirose/cpp-peglib/blob/fed85fe14d0d2cf83fc649a72bd55a50f28439b2/peglib.h#L3229 (chpeg has --bytecodec option).

mingodad commented 2 years ago

Also there is this collection of grammars https://github.com/ChrisHixon/chpeg/issues/20 and others that can be made available.

yhirose commented 2 years ago

Thanks for the fine contribution. Also I made a separate issue for the dump function. That sounds a very good idea, so that I can generate the latest cpp-peglib parser grammar at any time.

Also there is this collection of grammars ChrisHixon/chpeg#20 and others that can be made available.

That's wonderful as well. Please send me pull requests whenever you feel the grammars are complete and stable. They can be very good references for others. Please make sure to include your credit (like your copyright statement and original credits if exist) and a license statement (such as MIT) in each grammar file, because I would like to respect rights of the authors. :)

mingodad commented 2 years ago

I just added cpp-peglib to https://en.wikipedia.org/wiki/Comparison_of_parser_generators