ragel-guide.txt (ragel-7.0.0.9) | : | ragel-guide.txt (ragel-7.0.0.10) | ||
---|---|---|---|---|
= Ragel State Machine Compiler User Guide | = Ragel State Machine Compiler User Guide | |||
Adrian Thurston <thurston@colm.net> | Adrian Thurston <thurston@colm.net> | |||
Ragel Version 7.0 | Ragel Version 7.0 | |||
:toc: | :toc: | |||
:toclevels: 3 | :toclevels: 3 | |||
:numbered: | :numbered: | |||
.License | .License | |||
This document is part of Ragel, and as such, this document is released | Permission is hereby granted, free of charge, to any person obtaining a c | |||
under the terms of the GNU General Public License as published by the | opy | |||
Free Software Foundation; either version 2 of the License, or (at your | of this software and associated documentation files (the "Software"), to | |||
option) any later version. | deal in the Software without restriction, including without limitation th | |||
e | ||||
Ragel is distributed in the hope that it will be useful, but WITHOUT | rights to use, copy, modify, merge, publish, distribute, sublicense, and/ | |||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | or | |||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | sell copies of the Software, and to permit persons to whom the Software i | |||
for more details. | s | |||
furnished to do so, subject to the following conditions: | ||||
You should have received a copy of the GNU General Public License along | ||||
with Ragel; if not, write to the Free Software Foundation, Inc., 59 | The above copyright notice and this permission notice shall be included i | |||
Temple Place, Suite 330, Boston, MA 02111-1307 USA. | n all | |||
copies or substantial portions of the Software. | ||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS O | ||||
R | ||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL T | ||||
HE | ||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING F | ||||
ROM, | ||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
THE | ||||
SOFTWARE. | ||||
== Introduction | == Introduction | |||
=== Abstract | === Abstract | |||
In today's computing landscape, regular expressions are used heavily for the | In today's computing landscape, regular expressions are used heavily for the | |||
purpose of specifying parsers. They are normally treated as black boxes, linked | purpose of specifying parsers. They are normally treated as black boxes, linked | |||
together with program logic. User code is executed in between invocations of | together with program logic. User code is executed in between invocations of | |||
the regular expression engine. To add code before a pattern terminates, the | the regular expression engine. To add code before a pattern terminates, the | |||
programmer is required to break patterns and paste them back together with | programmer is required to break patterns and paste them back together with | |||
skipping to change at line 3420 | skipping to change at line 3424 | |||
needs to be able to allocate characters from the alphabet space. Ragel uses | needs to be able to allocate characters from the alphabet space. Ragel uses | |||
these allocated characters to express "character C with condition P true" or "C | these allocated characters to express "character C with condition P true" or "C | |||
with P false." Since internally Ragel uses longs to store characters there is | with P false." Since internally Ragel uses longs to store characters there is | |||
no room left in the alphabet space unless an alphabet type smaller than long is | no room left in the alphabet space unless an alphabet type smaller than long is | |||
used. | used. | |||
==== Condition Based Repetition | ==== Condition Based Repetition | |||
New in ragel 7 is a construct designed to simplify the use of conditions to | New in ragel 7 is a construct designed to simplify the use of conditions to | |||
control repetition. While possible to count properly using condition embedding | control repetition. While possible to count properly using condition embedding | |||
operators, there is a corner case that prove difficult. If the zero-width case | operators, there is a corner case that proves difficult. If the zero-width case | |||
is to be accepted properly, some knowledge of what is before and after is | is to be accepted properly, some knowledge of what is before and after is | |||
necessary and tests need to be embedded there. The `:cond()` operator is | necessary and tests need to be embedded there. The `:cond()` operator is | |||
designed to solve this problem, automatically embedding actions such that a | designed to solve this problem, automatically embedding actions such that a | |||
zero count is possible. | zero count is possible. | |||
-------------- | -------------- | |||
:cond( <expression>, | :cond( <expression>, | |||
<init>, <inc>, <min> [ , <max> ] ): | <init>, <inc>, <min> [ , <max> ] ): | |||
-------------- | -------------- | |||
End of changes. 2 change blocks. | ||||
14 lines changed or deleted | 27 lines changed or added |