Ask for guide to parse comments #349
-
Hi, I'm using PEGTL to parse some kind of language, |
Beta Was this translation helpful? Give feedback.
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, |
Beta Was this translation helpful? Give feedback.
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
ws
rule 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*/
.