piraha accepts in-string comments on first line of string

Issue #2331 resolved
Roland Haas created an issue

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)

  1. Roland Haas 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 #2333 though 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.

  2. Log in to comment