
Mongrel 2 Routing And The Magnetic Bikeshed - mattyb
http://sheddingbikes.com/posts/1277144478.html
======
silentbicycle
The Lua pattern-matching code he mentions is here
(<http://www.lua.org/source/5.1/lstrlib.c.html#match>). You can browse the
overall source (<http://www.lua.org/source/5.1/>) online, too.

The Lua standard string library includes a minimalistic regex implementation -
it doesn't have full REs because the implementation would probably be larger
than the rest of Lua (!).

For situations where you're better off with a real parser and not just REs,
LPEG (<http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html>) is available as a
library. It's a bit different from both REs and LL(k) / LALR(k) parser
generators (it's a PEG variant), but works quite well in my experience - while
designed with parsing in mind, it scales down quite nicely to typical RE
string stuff.

------
drivingmenuts
I love this line: "I find the average programmer's lack of understanding of
the TST data structure and its variants maddening."

The average programmer is a coal-shoveler, moving data from a hopper to
furnace all day long. Most of the programmers I have met haven't had to do a
binary tree since college and wouldn't know a ternary tree if it was growing
in their garden.

As for parsers ... yeah, not even. I imagine they're not terribly difficult to
write, but I don't know anyone who's even remotely interested in it.

~~~
augustl
If there was a book explaining not only the basics but also the purpose of and
why I should care about binary trees, TSTs, bitwise operations etc., I'd buy
it. Twice!

I am a self taught web app programmer and I'm having a hard time wrapping my
mind around these kinds of things.

~~~
scott_s
Look at the textbooks used in data structure courses at various schools.

------
amalcon
So long as he's apparently requesting this sort of thing, why not use a
Patricia trie instead of a TST? Typical use-cases would probably yield a lot
of single-child nodes in a TST, which a Patricia trie would eliminate. There
would probably be a good amount of memory savings, and the only additional
code complexity would be a strcmp() (edit: which doesn't increase the
_algorithmic_ complexity, since you'd be doing those comparisons anyway).

Using a TST is probably fine; it just looks like this problem cries out for a
Patricia trie.

