On Wednesday, 12 September 2012 at 19:50:22 UTC, Nick Sabalausky
wrote:

On Wed, 12 Sep 2012 21:36:52 +0200
"Eldar Insafutdinov" e.insafutdinov@gmail.com wrote:

I don't quite understand about how exactly to use state
machines here, but I just thought - if there were support for
Regexps how would that fit in?

AIUI:

It would essentially be a lexer.

Vibe.d would collect all the regexes. Then, instead of the
usual regex
approach of building one NFA/DFA for each regex (with one
"Accept"
state each), it would essentially combine them like this:

(regex1)|(regex2)|(regex3)|(etc.)

And each of those parts would have their own separate
"accept" state.

Ie, a lexer.

The main issue that got me started on this thing is that
currently wild-cards are not captured, so something like this
wouldn't work:

 router.get("/assets/*", serveStaticFiles("./public/"));

Currently when the matcher sees wildcard and it just returns a
match. That brings us to the question - do we really want to
support them properly? Sinatra has the following:

 get '/say/*/to/*' do
   # matches /say/hello/to/world
   params[:splat] # => ["hello", "world"]

To do that the parser has to be a lot more sofisticated than it
currently is. The easiest option would be of course just to match
and capture the first * and be done with it.