Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wrote a page about cpp-peglib #296

Open
berthubert opened this issue Apr 22, 2024 · 2 comments
Open

I wrote a page about cpp-peglib #296

berthubert opened this issue Apr 22, 2024 · 2 comments

Comments

@berthubert
Copy link

Hi! I am so happy with cpp-peglib that I thought more people should hear about it. https://berthub.eu/articles/posts/practical-peg-parsing/ has the post, and I hope I got it all right. It is highly likely that people better versed in PEG and cpp-peglib have suggestions, and if so, I'd love to hear about it!

And maybe once we get it right, it could be an idea to link to this page from the README.

Thank you for cpp-peglib!

@yhirose
Copy link
Owner

yhirose commented Apr 23, 2024

@berthubert thanks for the excellent and beautiful article! I really enjoyed reading it. I wanted to write such a user friendly and enjoyable guide, but my ability as a document writer prevented me from doing it. :)

Please let me know when you write another article on cpp-peglib. I'll also like to it. Thanks a lot!

@mingodad
Copy link
Contributor

mingodad commented May 1, 2024

I'm looking through the link and found that the first example probably can be improved to accept only valid numbers:

Vector      <- '(' Number ( ',' Number )* ')'
Number      <- [+-]?([0-9]*[.][0-9]+/[0-9]+[.]?)
%whitespace <- [\t ]*

Based on a translation that can be viewed here https://mingodad.github.io/parsertl-playground/playground/ :

%token Number

%%

Vector      : '(' Number ( ',' Number )* ')';

%%

%%
[ \t\r\n]+	skip()

"("	'('
")"	')'
","	','

[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)	Number

%%

Input :

(0.123, -.987, 2.4, 3, .98, 4.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants