<html> <p>Ragel compiles executable finite state machines from regular languages. Ragel targets C, C++ and ASM. Ragel state machines can not only recognize byte sequences as regular expression machines do, but can also <em>execute code</em> at arbitrary points in the recognition of a regular language. Code embedding is done using inline operators that do not disrupt the regular language syntax.</p> <p>The core language consists of standard regular expression operators (such as <em>union</em>, <em>concatenation</em> and <em>Kleene star</em>) and action embedding operators. The user’s regular expressions are compiled to a deterministic state machine and the embedded actions are associated with the transitions of the machine. Understanding the formal relationship between regular expressions and deterministic finite automata is key to using Ragel effectively.</p> <p>Ragel also provides operators that let you control any non-determinism that you create, construct scanners, and build state machines using a statechart model. It is also possible to influence the execution of a state machine from inside an embedded action by jumping or calling to other parts of the machine, or reprocessing input.</p> <p>Ragel provides a very flexible interface to the host language that attempts to place minimal restrictions on how the generated code is integrated into the application. The generated code has no dependencies.</p> <p>Ragel code looks like:</p> <pre>action dgt { printf(„DGT: %c\n“, fc); } action dec { printf(„DEC: .\n“); } action exp { printf(„EXP: %c\n“, fc); } action exp_sign { printf(„SGN: %c\n“, fc); } action number { /*NUMBER*/ } number = (
[0-9]+ $dgt ( '.' @dec [0-9]+ $dgt )? ( [eE] ( [+\-] $exp_sign )? [0-9]+ $exp )?
) %number; main := ( number '\n' )*; </pre> <p>.. and it compiles to:</p> <pre>st0:
if ( ++p == pe )
goto out0;
if ( 48 <= (*p) && (*p) <= 57 )
goto tr0;
goto st_err;
tr0:
{ printf("DGT: %c\n", (*p)); }
st1:
if ( ++p == pe )
goto out1;
switch ( (*p) ) {
case 10: goto tr5;
case 46: goto tr7;
case 69: goto st4;
case 101: goto st4;
}
if ( 48 <= (*p) && (*p) <= 57 )
goto tr0;
goto st_err;
</pre> <p>… and it visualizes as:</p> <p><a href=„https://www.colm.net/images/number_lg.png“><img src=„https://www.colm.net/images/number_lg.png“ alt=„number_lg“/></a></p> <h2>What kind of task is Ragel good for?</h2> <ul><li>Writing robust protocol implementations.</li> <li>Parsing data formats.</li> <li>Lexical analysis of programming languages.</li> <li>Validating user input.</li> </ul><h2>Features</h2> <ul><li>Construct finite state machines using: <ul><li>regular language operators</li> <li>state chart operators</li> <li>a scanner operator</li> <li>some mix of the above</li> </ul></li> <li>Embed actions into machines in arbitrary places.</li> <li>Control non-determinism using guarded operators.</li> <li>Minimize state machines using Hopcroft’s algorithm.</li> <li>Visualize output with <a href=„http://www.graphviz.org/“>Graphviz</a>.</li> <li>Use byte, double byte or word-sized alphabets.</li> <li>Generate C, C++ or ASM (GNU, x86_64, System V ABI) code with no dependencies.</li> <li>Choose from table or control flow driven state machines.</li> </ul><h2>Download</h2> <h3>Stable</h3> <p> <strong>March 24, 2017</strong><br/><a href=„https://www.colm.net/files/ragel/ragel-6.10.tar.gz“>ragel-6.10.tar.gz</a> (<a href=„https://www.colm.net/files/ragel/ragel-6.10.tar.gz.asc“>sig</a>) (<a href=„https://www.colm.net/files/thurston.asc“>key</a>)<br/><a href=„https://www.colm.net/files/ragel/ragel-guide-6.10.pdf“>ragel-guide-6.10.pdf</a></p> <h3>Development</h3> <p> <strong>May 11, 2017</strong><br/><a href=„https://www.colm.net/files/ragel/ragel-7.0.0.10.tar.gz“>ragel-7.0.0.10.tar.gz</a> </p><h2>Discussion and GIT Repos</h2> <p>The <a href=„https://www.colm.net/cgi-bin/mailman/listinfo/ragel“>ragel mailing list</a> is back on the colm.net domain.</p> <p>
git clone git://git.colm.net/ragel.git
</p> <h2>License</h2> <p>Beginning with the next development release (> 7.0.0.9) Ragel is licensed under an MIT style license. Ragel 6 remains under GPL v2. Please see the file COPYING in the source.</p> <p><strong>Note:</strong> Part of the Ragel output is copied from Ragel source, covered by the MIT (or GPL v2) license. As an exception, you may use the parts of Ragel output copied from Ragel source without restriction. The remainder of Ragel output is derived from the input and inherits the copyright and license of the input file. Use of Ragel makes absolutely no requirement about the license of generated code.</p> </html>