Is using a FSM a good design for general text parsing?
Posted
by eSKay
on Stack Overflow
See other posts from Stack Overflow
or by eSKay
Published on 2010-05-05T20:10:35Z
Indexed on
2010/05/05
20:18 UTC
Read the original article
Hit count: 337
I am reading a file that is filled with hex numbers. I have to identify a particular pattern, say "aaad" (without quotes) from it. Every time I see the pattern, I generate some data to some other file.
This would be a very common case in designing programs - parsing and looking for a particular pattern.
I have designed it as a Finite State Machine and structured structured it in C using switch-case
to change states. This was the first implementation that occured to me.
- DESIGN: Are there some better designs possible?
- IMPLEMENTATION: Do you see some problems with using a switch case as I mentioned?
© Stack Overflow or respective owner