[ragel-users] Ragel syntax

Rinat Ibragimov ibragimovrinat at mail.ru
Mon Feb 4 11:03:15 UTC 2019


>Четверг, 31 января 2019, 18:09 +03:00 от Dénes Lados <lados.denes at gmail.com>:
>
>Hi,
>
>I am confused with the basic syntax of Ragel. Let's see this machine from the ragel guide:
>
>>%%{ machine foo;
>>main :=
>>( ’foo’ | ’bar’ )
>>0 @{ res = 1; };
>>}%%
>
>As far as I can understand this machine looks for the 'foo' or 'bar' strings and sets the variable from the host language 'res' to 1 if a match is found. 

This machine also checks for the terminating NUL character, '\0'.

>
>What I don't understand is what the 0 and the @{} stands for. What the exact meaning of these signs and how they are used to run actions in case of a match?

0 is a byte with code 0. See 2.3 in the guide for details.
@ is finishing action. See 3.1.2 in the guide for details.

Also try to generate a graph by calling Ragel with `-pV` options. Visual representations are really helpful.

>
>Thanks
>Denes Lados
>_______________________________________________
>ragel-users mailing list
>ragel-users at colm.net
>http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users


---
Rinat


More information about the ragel-users mailing list