Boost logo

Boost Users :

Subject: [Boost-users] [Spirit] Comment skipper or first class member of grammar
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2018-12-17 04:31:24


Hello,

I am turning a corner in my Protocol Buffers grammar, and it is now
time for me to consider how best to approach parsing comments.

Chiefly, I am weighing two options, I think:

1) A white-space, comments skipper; if memory serves there has been
discussion about such a thing on either here, Boost mailing list, or
other forums.

2) Or, as with some compiler environments, I'm thinking .NET
Roslyn/C#, in particular, where "comment" elements are first class
members of the grammar/tokens, quite literally, I think.

I'm not quite sure how that would be expressed in terms of synthesized
AST, when you could literally have a comment appearing virtually
anywhere between tokens, especially of the C variety, i.e. /* this is
a comment which may appear virtually anywhere between tokens,
potentially */.

Or the single line C++ variety, for example, // this is a comment
through the rest of this line.
// Yet, there could be multiple lines of these...
optional myVar = true; // And can appear at the end of a line

Thoughts? Suggestions?

My first approach I think would be for (1) the skipper; however, for
what I am wanting to accomplish, I can see there potentially being
some value in capturing the comments and carrying them forward with
the target language adapter.

Best regards,

Michael Powell


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net