misspelling ActiveThorns in parfiles results in unhelpful error message

Issue #1401 closed
Roland Haas created an issue

the attached parfile (which misspells ActiveThorns as ActiveThrons) causes the error message:

Activating thorn Cactus...Success -> active implementation Cactus
ERROR IN PARAMETER FILE:
In rule 'file::set::par' Line=1, Column=13
ActiveThrons = "Cactus"
             ^
Expected one of the following characters: [ \t\r\n#:]
WARNING level 0 in thorn Cactus processor 0 host horizon.tapir.caltech.edu
  (line 167 of /mnt/data/rhaas/postdoc/gr/Zelmani/src/main/ProcessParameterDatabase.c): 
  -> CCTKi_SetParameterSetMask: 1 parsing errors in parameter file
WARNING level 0 in thorn Cactus processor 0 host horizon.tapir.caltech.edu
  (line 167 of /mnt/data/rhaas/postdoc/gr/Zelmani/src/main/ProcessParameterDatabase.c): 
  -> CCTKi_SetParameterSetMask: 1 parsing errors in parameter file

which does not provide a hint for the cause of the error.

Keyword:

Comments (11)

  1. Steven R. Brandt
    • changed status to open
    • removed comment

    I thought about a number of ways to solve this, most of them involved teaching the grammar to identify error patterns. These struck me as ugly solutions.

    The attached fix suggests that we look at where the failure occurred in the parsing tree, and what the character was that was found, and use that information to provide an output message.

        if(m2->inrule_max == "file::set::par" && m2->foundChar() =='=') {
            std::cout << "Invalid assignment." << std::endl;
            std::cout << "Valid assignments are: " << std::endl;
            std::cout << "ActiveThorns = \"...\"" << std::endl;
            std::cout << "Arrangement::Thorn = ..." << std::endl;
        }
    

    This says that if we were part way parsing a parameter pattern and encountered an "=" (this corresponds to a c-identifier that is followed by an =) we print an error message describing what valid assignments are.

  2. Roland Haas reporter
    • removed comment

    This is better, yes. Would it also be possible to output the part to the left of the "=" sign:

      std::cout << "But received: \"" << leftofequal << ::std::end;
    

    These error messages should also all go to std::cerr, shouldn't they?

    Aren't global parameters (discouraged, unused but still in Cactus) set as:

    MyGlobalParameter = somevalue
    

    ? The user guide is not clear how they are supposed to be set. We can of course deprecate global parameters (and only allow ActiveThorns). Apparently they were never used, not even for something like a cctk_debug parameter.

  3. Steven R. Brandt
    • removed comment

    Neither Frank nor I knew global parameters existed. My guess is deprecating them is a good idea.

  4. Roland Haas reporter
    • removed comment

    Just removing them violates our policies for removing features. However testing this just now it seems that (using the Piraha parser) global parameters are currently broken so we can be relatively sure that no one was using them (they seem to work if I turn off piraha with piraha_active = 0 in ParseFile.c).

    So, given that we de facto no longer support global parameters, we should remove them from the documentation and I am fine with changing the error message either as comment.2 or comment.3 indicate. I think that error messages should use CCTK_VWarn(1,...) rather than std::cout though so that they appear in the error stream and that registered callbacks can catch them.

  5. Steven R. Brandt
    • removed comment

    This updated patch does the things you ask, except I use CCTK_Warn(0,...) as this has to be fatal error.

    A failed Piraha parse doesn't create a parse tree, which meant I didn't have the data you asked for. With this change, however, it's possible do a second pass with the matchesTo(pos) that will succeed of position pos is reached. When supplied with the maximum position reached by the failed parse, this obtains a successful parse and thus a tree.

  6. Steven R. Brandt
    • removed comment

    New error message is output instead of old. It includes the LHS from the parameter file:

       if(m2->inrule_max == "file::set::par" && m2->foundChar() =='=') {
            msg << std::endl;
            msg << "Invalid assignment." << std::endl;
            msg << "Valid assignments are: " << std::endl;
            msg << "ActiveThorns = \"...\"" << std::endl;
            msg << "Arrangement::Thorn = ..." << std::endl;
            ...
            msg << "You wrote: " << gr->substring() << " = ..." << std::endl;
        } else {
            m2->showError(msg); // default error message
        }
    
  7. Log in to comment