There's no best way, you just have to choose one that works for you. The alternative to the two methods you tried is to manually run the machine ( A | B | C ) at every position in the input. As soon as it fails it will stop so you won't get N^2 running time. This is very much like using a scanner. You'll have to keep data around though. You can't do that on one pass of the data for the same reason you need to do some management of ts, te, etc. for a scanner.
-Adrian Smelly Pooh wrote: > Hi, > > What's the best way to search a buffer for a list of patterns using ragel? > > I've tried: > > search = A | B | C; > > main := any* search; > > which works ok but generates a lot of states. > > I've also tried using a scanner like: > > main := |* > A; > B; > C; > any; > *|; > > which also works and generates much fewer states, but I'm not interested > in writing extra code to handle te, ts, eof etc. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > ragel-users mailing list > [email protected] > http://www.complang.org/mailman/listinfo/ragel-users _______________________________________________ ragel-users mailing list [email protected] http://www.complang.org/mailman/listinfo/ragel-users
