Open berthubert opened 4 months ago
@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!
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.)
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!