piraha accepts in-string comments on first line of string
Cactus' parameter files allow things like:
ActiveThorns = "
# PUGH
Carpet
HydroBase
"
ie allow one to comment out lines in a multi-line string by starting it with a “#”. However Piraha does not quite handle this correctly. It accepts
ActiveThorns = "#FooBar"
which is incorrect. #
comments are supposed to be only allowed in lines after the first line. The original commit git hash b6cd766a "Accept comments in multi-line strings in parameter files" of cactus does this but piraha’s string_reparser
function (bad name) does not.
This makes it impossible to set a string to “#” eg if one wanted to let a user specify a comment character for output files.
Comments (5)
-
-
reporter This seems incorrect to me. The C++ code uses
"stringfirstname"
while the peg file has"stringfirstline"
.Note that even when changing them to be consistent, this parameter file:
$bar = "time" Cactus::terminate = "$bar"
fails with
WARNING[L1,P0] (Cactus): Major error in parameter file 'par/tov.par' line 2: Range error setting parameter 'Cactus::terminate' to '$bar'
ie variables are not expanded on the first line (b/c it is always used literally). See
#2333though for whether or not expanding variables in strings is the right thing to do anyway.A better peg file (ignoring the C++ code for brevity of presentation) seems to me to be:
stringparser = ^({var}|{name}|{stringfirstline})*(\n({stringcomment}|{var}|{name}|{any})*)?$
I have updated the branch and pull request with this suggestion.
-
Yes, I realized this after I created it. That’s what you get for working while ill.
-
reporter I believe the updated pull request https://bitbucket.org/cactuscode/cactus/pull-requests/87/fix-issue-2331/diff now contains a fix. @Steven R. Brandt do you agree (see the discussion in the pull request as well)?
-
reporter - changed status to resolved
- Log in to comment
https://bitbucket.org/cactuscode/cactus/pull-requests/87/fix-issue-2331/diff