Ragel compiles executable finite state machines from regular languages. Ragel targets C, Objective-C, D, C++, Java and Ruby.
Ragel state machines can not only recognize byte sequences as regular expression machines do, but can also execute code 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.
The core language consists of standard regular expression operators (such as union, concatenation and Kleene star) 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.
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.
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.
What kind of task is Ragel good for?
· Writing robust protocol implementations.
· Parsing data formats.
· Lexical analysis of programming languages.
· Validating user input.
Here are some key features of "Ragel":
· Construct finite state machines using: regular language operators, state chart operators, a scanner operator, some mix of the above
· Embed actions into machines in arbitrary places.
· Control non-determinism using guarded operators.
· Minimize state machines using Hopcroft's algorithm.
· Visualize output with Graphviz.
· Use byte, double byte or word-sized alphabets.
· Generate C, C++, Objective-C, D, Java or Ruby code with no dependencies.
· Choose from table or control flow driven state machines.
What's New in This Release: [ read full changelog ]
· The C vim file now supports L,l on the end of literal numbers, other syntax highlighting fixes.
· Added an explicit cast when modifying _trans to eliminate compiler warnings on Windows/VC++
· Fix for ruby 1.9 compatibility.
· Fix for include directories (-I option) on Windows/VC++
· Can now rename data variable in C# code generator.
· Fix for non-char alphtype in C# code generator.
· Fix for signedness of wide char in C code generator. when comparing the wide type against a literal we need to pick the right signedness for the literal.
· Fixed arithmetic overflow in generated C# code. The C# _acts and _nacts vars should not be typed based on the size of the array elements they point to. Fixes a bug reported by Attila SztupÃ¡k.
· Made theL option work for Ruby.
· Enhanced ragel.m4 (from Diego).
· Applied GO patch from Justine Tunney.
· Applied D2 patch from Johannes Pfau.
· Applied Ocaml patch from ygrek.