Spencer Rathbun

Jan 27, 2012 16:30
K
Jan 27, 2012 16:29
I'll stick around if you've got more questions, but it's back to the grind right now
Jan 27, 2012 16:29
No problem,
Jan 27, 2012 16:28
The example source is free for download, and has a great example of a simple c parser.
Jan 27, 2012 16:27
The best book ever written on the topic is shop.oreilly.com/product/9781565920002.do
Jan 27, 2012 16:26
Totally possible.
Jan 27, 2012 16:24
With the right tool, you can have arbitrary commands associated with each state. So yes, a regex can be used within a state.
Jan 27, 2012 16:24
This is an example from the flex manual for eating all input: flex.sourceforge.net/manual/…
Jan 27, 2012 16:23
Otherwise, it waits in the "just right" state for more input
Jan 27, 2012 16:22
If it is not correct, an error is created and the machine goes back to the ready state.
Jan 27, 2012 16:22
just right
Jan 27, 2012 16:22
too many coins
Jan 27, 2012 16:22
Not enough coins
Jan 27, 2012 16:22
So if I put some coins in the pop machine, then it matches them to:
Jan 27, 2012 16:20
Exactly like that.
Jan 27, 2012 16:20
That moves it to another state, where an arbitrary action can be performed.
Jan 27, 2012 16:20
Upon receiving input, it sees what "rule" the input matches, if any.
Jan 27, 2012 16:19
It sits in a "ready" state, waiting for input
Jan 27, 2012 16:19
A state machine is like a pop dispenser
Jan 27, 2012 16:18
So each regex becomes simple as it only has to match some specific item from the text stream.
Jan 27, 2012 16:17
That is, input -> select -> sql -> ending flag -> back to input stat
Jan 27, 2012 16:17
Because what you really want is a state machine.
Jan 27, 2012 16:16
I've found that lots of people try and do a parser's job with JUST regex
Jan 27, 2012 16:16
No problem
Jan 27, 2012 16:15
The python was just a suggestion for fast turn around.
 
Jan 27, 2012 16:15
Heya