[DGD] Parse_string confusion
Noah Lee Gibbs
angelbob at monkeyspeak.com
Fri Jan 18 20:56:06 CET 2002
On Fri, 18 Jan 2002, Erwin Harte wrote:
> On Fri, Jan 18, 2002 at 01:27:03AM -0800, Noah Lee Gibbs wrote:
> > return !!parse_string("regstring = /[^A-Z]+/\n\nfull: regstring\n", str);
The line above, the one with the return, gives literally the complete
grammar. With the "\n" characters expanded, it looks like this:
regstring = /[^A-Z]+/
full: regstring
That's not what I'd like in a perfect world. What I'd like in a perfect
world is to use it to find out if the string's alphabetic, like this:
regstring = /[A-Za-z]+/
full: regstring
That'd mean that the grammar parsed iff it consisted of a single string
made only of the upper- or lower-case letters with no digits, no spaces
and no punctuation characters.
Input: "snowball" would give a result of ({ "snowball" }), while the input
"Haxx0r", which contains a digit, would fail to parse. The !! in front of
the parse_string call converts to boolean -- if it parses, the function
returns true. If it doesn't parse, the function returns false. In the
original example (which DGD accepts) it will return true for a string
*not* containing any uppercase letters -- the token was /[^A-Z]+/. But I
used that example because, unlike the example I wrote above with the token
/[A-Za-z]+/, parse_string didn't give an error trying to understand the
grammar I gave it. The version in the line with the return above is
accepted by parse_string as a valid grammar. Changing the section of it
in slashes to any of the things I listed as "won't work" means that
parse_string gives an error, claiming it's not a valid grammar. I could
certainly believe I've made some mistake in writing the grammar, but then
parse_string must be only sometimes noticing that mistake.
> Can you give some combinations of:
>
> - Complete grammar used.
> - Input given.
> - Output expected.
>
> Because I'm not quite sure what you're trying to do here. :)
>
> Erwin.
> --
> Erwin Harte <harte at xs4all.nl>
> _________________________________________________________________
> List config page: http://list.imaginary.com/mailman/listinfo/dgd
>
--
angelbob at monkeyspeak.com
See my page of DGD documentation at
"http://www.angelbob.com/projects/DGD_Page.html"
If you post to the DGD list, you may see yourself there!
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list