D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Patient flex guru



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Any flex guru around patient enough to review some code, and talk me
through some patterns I'm misinterpreting?

I know what I want, and I've written a prototype to prove I understand
enough flex to do it from scratch, but a patch submitted to the never
ending Chess project is choking on some special cases, and fixing
someone elses parser seems to be harder than writting your own :-(

For a flavour, this pattern (amongst others) is causing me grief...

([^\n\r\"\\]|\\.)*

http://www.very-best.de/pgn-spec.htm

This is tag data from PGN, lines ought to look something like;

[tagname "tagdata"]

but some problematic cases seem to cause unexpected side effects.

But my worse problems surround

<*>^\[

Which I figure should pick up any occurence of a "[" at the start of a
line, whenever it occurs? But seems to be skipping when a certain start
condition applies (which handles parenthesis, which of course never
match in the interesting cases....)

Pointers to elegant examples of flex solving real world problems,
especially good examples of catching errors appreciated. Unmatched
parenthesis must be a common pattern, but in this case we have to spot
and fix it before the end of the file, "unexpected end of file" is not
acceptable. And yes(!) the parenthesis counter is reset, at least it is
zero'ed at the start of the pattern section.

Currently the parser is consuming over 70,000 chess games, that an
"obviously worse" parser didn't consume.... My brain is melting.

-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+/XzPGFXfHI9FVgYRAtR0AKDFpHOJga5z2llLjjmxZu5+bMuOOACcC2z7
ZmuCPjYX3sQljdoayn8UPi0=
=zyqO
-----END PGP SIGNATURE-----

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly