Repository navigation
Ask for guide to parse comments #349
|
Hi, I'm using PEGTL to parse some kind of language, |
Replies: 1 comment 1 reply
|
Many grammars allow comments in the same places they allow spaces and tabs. So one common way to handle comments is to make a rule that accepts spaces, tabs and comments. For an example see the It allows for space, tab, cr and lf as "whitespace" characters, and for three kinds of comments, |
Many grammars allow comments in the same places they allow spaces and tabs. So one common way to handle comments is to make a rule that accepts spaces, tabs and comments.
For an example see the
wsrule in our taoCONFIG library at https://github.com/taocpp/json/blob/main/include/tao/json/jaxn/internal/grammar.hpp#L32 .It allows for space, tab, cr and lf as "whitespace" characters, and for three kinds of comments,
#and until end-of-line,//and until end-of-line, and non-nesting/*until*/.