How can I Isolate a number from a string? #225
-
Please may I get some assistance, I am struggling to select a set of grammars to read the the following:
and extract the strings and numbers, but ignore the comments (!) I have the following so far:
but I am struggling to isolate the numeric values from the ascii comments. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Your grammar is not skipping whitespace or comments, even without comments it will not work. Note that the PEGTL does not automatically skip whitespace (and newlines) for you, it has to be part of the grammar. Check out some of our examples, maybe start with https://github.com/taocpp/PEGTL/blob/master/src/example/pegtl/parse_tree.cpp and see how we use |
Beta Was this translation helpful? Give feedback.
-
Thanks very much. |
Beta Was this translation helpful? Give feedback.
Your grammar is not skipping whitespace or comments, even without comments it will not work. Note that the PEGTL does not automatically skip whitespace (and newlines) for you, it has to be part of the grammar.
Check out some of our examples, maybe start with https://github.com/taocpp/PEGTL/blob/master/src/example/pegtl/parse_tree.cpp and see how we use
pad
andspace
to allow skipping whitespace. Then look for examples likeabnf2pegtl.cpp
where we also skip comments.