[Developers] quoting in par-file strings
Jonathan Thornburg
jthorn at aei.mpg.de
Fri Jun 3 09:59:34 CDT 2005
Hi,
I would like to be able to assign a string containing *both* single
and double quotes, for example
default='order=5' matter='order=2 limiter="Van Leer"'
to a Cactus string parameter (via the normal par-file mechanism).
[Note that the example string is a legal argument to
Util_TableCreateFromString(), and this is in fact what
I want to do with it -- the problem is just getting it
through the Cactus par-file reader/parser.]
Problem #1: So far I haven't found any way to do this. In particular,
with current-CVS Cactus, all of the following generate fatal errors
like this
-> CCTKi_SetParameterSetMask: 2 parsing errors in parameter file
when Cactus initially reads the par file:
MyThorn::MyPar = "default='order=5' matter='order=2 limiter=\"Van Leer\"'"
MyThorn::MyPar = "default='order=5' matter='order=2 limiter=\'Van Leer\''"
MyThorn::MyPar = 'default="order=5" matter="order=2 limiter=\"Van Leer\""'
Problem #2: So far I haven't found any documentation which explains
the quoting conventions used in the Cactus par-file reader/parser.
So... I propose that we explicitly define quoting rules for par files,
which are powerful enough to allow strings such as my example. If we
do this, I'll volunteer to write some documentation explaining the rules.
[Where should this documentation live? The Cactus Users'
Guide section A3.2 "Parameter File Syntax" is an obvious
place. Or maybe a new subsection in chapter E "Appendices"?]
To get the argument^Wdiscussion going, here's a concrete proposal
(based on discussions between Thomas Radke, Erik Schnetter, and myself)
for string-quoting rules. Note that this is for *par* files (parsed by
C code in the flesh when Cactus starts). I'll discuss ccl files
(parsed by Perl code in the CST when Cactus is configured/compiled)
in a following message.
Ok, here are my proposed string quoting rules:
* A string is delimited by either single-quotes ('...')
or double-quotes ("...").
* Within a string delimited by single-quotes, double-quotes may be
used with no need for special quoting
* Within a string delimited by double-quotes, single-quotes may be
used with no need for special quoting
* Backslash quotes the next character, i.e.
* \' gives a single-quote character without delimiting the string
* \" gives a double-quote character without delimiting the string
* \\ gives a backslash character in the string
With these rules, my example string could be assigned to a parameter via
MyThorn::MyPar = "default='order=5' matter='order=2 limiter=\"Van Leer\"'"
Comments?
ciao,
--
-- Jonathan Thornburg <jthorn at aei.mpg.de>
Max-Planck-Institut fuer Gravitationsphysik (Albert-Einstein-Institut),
Golm, Germany, "Old Europe" http://www.aei.mpg.de/~jthorn/home.html
"Washing one's hands of the conflict between the powerful and the
powerless means to side with the powerful, not to be neutral."
-- quote by Freire / poster by Oxfam
More information about the Developers
mailing list