Can arguments in an command invocation end in a line comment?

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

Can arguments in an command invocation end in a line comment?

Maris Razvan
In the latest CMake documentation, the "language" section, the "Source
Files" paragraph there is the following sentence:

    "Note that any source file line not inside Command Arguments or a
Bracket Comment can end in a Line Comment."

I think that source file lines inside "Command Arguments" can end in a
"Line Comment" because the grammar specified in the "Command
Invocations" paragraph states that a "line_ending" (which may contain
a "line_comment") can separate arguments.

Also, the following code snippet works as expected in cmake 3.11.4:

    foreach(arg arg1
                     arg2 #line-comment
               )
      message("${arg}")
    endforeach()

Am I misunderstanding the above quote or is it inaccurate?

Thank you!
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Can arguments in an command invocation end in a line comment?

Maris Razvan
I apologize for the spelling error in the subject of this thread.

I was told that this sentence actually states that lines inside a
(single) command argument cannot end in a line comment.
I initially thought that "Command Arguments" in this sentence means
the "section" that contains all the arguments in a command invocation,
as the wording implies that there may be multiple lines inside the
referred "Command Arguments".
However, a bracketed or a quoted argument can span several lines, so
the sentence means that one cannot have comments in a bracketed or
quoted argument (the grammar does not allow unescaped "#" inside an
unquoted argument, so I think the sentence does not refer to this
case).

Is this correct?

On Tue, May 7, 2019 at 9:47 PM Maris Razvan <[hidden email]> wrote:

>
> In the latest CMake documentation, the "language" section, the "Source
> Files" paragraph there is the following sentence:
>
>     "Note that any source file line not inside Command Arguments or a
> Bracket Comment can end in a Line Comment."
>
> I think that source file lines inside "Command Arguments" can end in a
> "Line Comment" because the grammar specified in the "Command
> Invocations" paragraph states that a "line_ending" (which may contain
> a "line_comment") can separate arguments.
>
> Also, the following code snippet works as expected in cmake 3.11.4:
>
>     foreach(arg arg1
>                      arg2 #line-comment
>                )
>       message("${arg}")
>     endforeach()
>
> Am I misunderstanding the above quote or is it inaccurate?
>
> Thank you!
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Can arguments in an command invocation end in a line comment?

CMake mailing list
On Wed, 2019-05-08 at 00:52 +0300, Maris Razvan wrote:
I apologize for the spelling error in the subject of this thread.


I was told that this sentence actually states that lines inside a
(single) command argument cannot end in a line comment.
I initially thought that "Command Arguments" in this sentence means
the "section" that contains all the arguments in a command
invocation,
as the wording implies that there may be multiple lines inside the
referred "Command Arguments".
However, a bracketed or a quoted argument can span several lines, so
the sentence means that one cannot have comments in a bracketed or
quoted argument (the grammar does not allow unescaped "#" inside an
unquoted argument, so I think the sentence does not refer to this
case).


Is this correct?

This is valid:

my_command(
  ARG1 # This comment is not part of an argument
    # Neither is this
  ARG2
  )

This is also valid:

my_command(
  "ARG1
    # But this comment IS part of an argument
    "
  [==[ARG2
    # And so is this
    ]==]
  )

Hope that helps,

Kyle
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake