[Spirit] Comment skipper or first class member of grammar

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Spirit] Comment skipper or first class member of grammar

Boost - Users mailing list
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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit] Comment skipper or first class member of grammar

Boost - Users mailing list
On Sun, Dec 16, 2018 at 11:31 PM Michael Powell <[hidden email]> wrote:

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

Is there a Confix parser for Spirit Qi? I see there is possible a
utility there for Classic, but I'm not sure I see one for Qi?

> 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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users