Skip to content

Ask for guide to parse comments #349

Answered by ColinH
shuizaiku7 asked this question in Q&A
Discussion options

You must be logged in to vote

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 */.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shuizaiku7
Comment options

Answer selected by shuizaiku7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants