[DGD] Re: parse string difficulties
Robert Forshaw
iouswuoibev at hotmail.com
Sun Mar 28 23:33:13 CEST 2004
It seems my limited understanding has been reconfirmed, since now I'm
thinking about extending the datafile interpretation, I don't know what to
do next. This is essentially the grammar that Erwin wrote, plus a few small
changes:
"whitespace = /[\b\r\t ]+/\n" +
"newline = /\n/\n" +
"word = /[a-zA-Z0-9,\"]+/\n" +
"operator = /[\\.\\+\\=\\-]+/\n" +
"SENTENCE : OPERATION ? dop_a\n" +
"SENTENCE : SENTENCE OPERATION ? dop_b\n" +
"OPERATION : word operator word newline ? dop_1\n" +
"OPERATION : word operator newline ? dop_2\n" +
"OPERATION : operator word newline ? dop_3\n"
Note that the "word" regexp now accepts " and , as valid symbols. What I
want is, to add a fourth element to an 'OPERATION' element, and if it sees
',' or '"' in an operator (specifically, the suffix-parameter), it will
assume a certain type. If its a comma, it will assume an array, and set the
third element as a comma delimited array and the fourth element as "array",
if it is in double quotes, it will assume a string, and set the third
element as a string (as it would normally) and the fourth element as
"string". And finally have it normally assumes integer, setting the fourth
element to "int", unless it contains symbols "a-Z" in which case it again
assumes a string (and sets the fourth element accordingly). It seems very
complicated and I'm not sure where to begin... I'm wondering whether it
would be better to break it down into several parse_string operations, but
ideally I'd like to at least know how it would be done with a single
parse_string...
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list