-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
In C/C++, I habitually leave trailing comments on #endifs, namespaces, and nested classes.
It's not strictly necessary to do so in IDL, because it'd be quite strange to have nested preprocessor statements, but I thought I'd report that dust_dds_gen can't parse the following:
#ifndef FOO
#define FOO
// ...
#endif // FOOThis fails with:
thread 'main' (1723130) panicked at build.rs:7:52:
called `Result::unwrap()` on an `Err` value: " --> 6:1\n |\n6 | #endif // FOO\n | ^---\n |\n = expected line"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I had hoped this might be an easy fix by adding
block_comment = @{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" }
line_comment = @{ "//" ~ (!NEWLINE ~ ANY)* }
COMMENT = _{ block_comment | line_comment }
to the Pest grammar, but I think the issue arises from
ifdef_directive = { "#ifdef" ~ identifier ~ NEWLINE ~ line* ~ "#endif" }
requiring the line ends with strictly #endif\n (I get the same kind of failure if I add any trailing whitespace to the #endif).
But I don't think
ifdef_directive = { "#ifdef" ~ identifier ~ NEWLINE ~ line* ~ "#endif" ~ ANY }
is correct either, because then that'd accept
#endif GARBAGE HERESo maybe
ifdef_directive = { "#ifdef" ~ identifier ~ NEWLINE ~ line* ~ "#endif" ~ WHITESPACE* ~ COMMENT? }
Or maybe it's the definition of line that doesn't leave room for trailing whitespace or comments?
I consider this a very low priority issue, but I thought I'd report it anyways.