[ragel-users] Parallel machines
Adrian Thurston
thurston at colm.net
Sat Dec 29 03:57:35 UTC 2018
Hi, yes it is possible, scanners execute in parallel, however you don't
get all the guarantees you normally get when you simply union. There may
be some backtracking and leaving actions don't always execute. This
second issue is something I'm hoping to fix with ragel 8.
If you want to do things in parallel as is the case with a normal union,
you can scan using the ** operator. This is a kleene star that favours
staying in the machine over starting to match a new token. If that
doesn't work for you, you can implement the scanning functionality
yourself, just using ragel to match a single token from the current
starting location. Simply union all your patterns and wrap that in a
loop.
On 2018-12-16 15:33, Filipp Andronov wrote:
> Good day,
>
> Please help me to understand if the following thing is possible with using ragel. I have a database of UTF-8 patterns, which I've compiled in ragel machine with using a bit of python magic.
>
> From that compiled databse Im able to build a scanner:
> main := |*
> Database => {issue_token; fbreak}
> any; # ignore unmatched
> *|
>
> Having a stream of recognized tokens, I'd like to calculate some properties of each token, like how many runes are inside, different Unicode Scripts bounds and Class bounds. Right now Im doing that by a separate scan of found tokens text, but could it be done better and embbed inside scanner itself?
>
> For each property I could easealy generate FSM from UnicodeData files but have no idea how to compose machines to run in parallel?
>
> Idially a such combined machine would analyse input stream and call actions like:
> - PatternStart
> - New rune
> - New Class
> - New rune
> - New Class
> - New Script
> - PatternFound
>
> But some other approximation is fine too :)
> --
>
> Thanks and regards,
>
> Philip Andronov
> ------------------------------------------
> Leading software engineer,
> mail.ru [2]
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users [1]
Links:
------
[1] http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users
[2] http://mail.ru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20181229/51cb48cd/attachment.html>
More information about the ragel-users
mailing list