diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/tools/ragel6 | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/ragel6')
83 files changed, 21716 insertions, 21716 deletions
diff --git a/contrib/tools/ragel6/AUTHORS b/contrib/tools/ragel6/AUTHORS index 7ca82d06ab..f270e1228f 100644 --- a/contrib/tools/ragel6/AUTHORS +++ b/contrib/tools/ragel6/AUTHORS @@ -1 +1 @@ -See CREDITS. +See CREDITS. diff --git a/contrib/tools/ragel6/COPYING b/contrib/tools/ragel6/COPYING index ec0507be1e..17e5a4414e 100644 --- a/contrib/tools/ragel6/COPYING +++ b/contrib/tools/ragel6/COPYING @@ -1,340 +1,340 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/contrib/tools/ragel6/CREDITS b/contrib/tools/ragel6/CREDITS index e91a677d63..b9e7273395 100644 --- a/contrib/tools/ragel6/CREDITS +++ b/contrib/tools/ragel6/CREDITS @@ -1,50 +1,50 @@ - - Ragel State Machine Compiler -- CREDITS - ======================================= - - -* Ragel was designed and written by Adrian Thurston <thurston@complang.org>. - -Many others have helped out along the way. My apolgies to anyone who has been -missed. - -* Many thanks to Arbor Networks for supporting development of Ragel. - -* Objective-C output and valuable feedback contributed by Erich Ocean. - -* D output and many great ideas contributed by Alan West. - -* Conditionals inspired by David Helder. - -* Java code generation contributions, bug reports, fixes, test cases - and suggestions from Colin Fleming. - -* Useful discussions and bug reports due to Carlos Antunes. - -* Ruby code generation contributed by Victor Hugo Borja. - -* C# code generation contributed by Daniel Tang. - -* Go code generation contributed by Justine Tunney. Significantly expanded by - Anton Ageev - -* D2 patch from Johannes Pfau. - -* OCaml patch from ygrek. - -* Feedback, Packaging, and Fixes provided by: - - Bob Tennent, Robert Lemmen, Tobias Jahn, Cris Bailiff, Buddy Betts, - Scott Dixon, Steven Handerson, Michael Somos, Bob Paddock, Istvan Buki, - David Drai, Matthias Rahlf, Zinx Verituse, Markus W. Weissmann, - Marc Liyanage, Erich Ocean, Alan West, Steven Kibbler, Laurent Boulard, - Jon Oberheide, David Helder, Lexington Luthor, Jason Jobe, Colin Fleming, - Carlos Antunes, Steve Horne, Matt Mower, Josef Goettgens, Zed Shaw, - Marcus Rueckert, Jeremy Hinegardner, Aaron Campbell, Josh Purinton, - Judson Lester, Barry Arthur, Tim Potter, Ryan Phelps, David Waite, - Kenny MacDermid, MenTaLguY, Manoj Rajagopalan, Tim Chklovski, - Mikkel Fahnøe Jørgensen, Andrei Polushin, Evan Phoenix, David Balmain, - Ross Thomas, Mitchell Foral, John D. Mitchell, Diego 'Flameeyes' Pettenò, - Jose Quinteiro, William Morgan, _why, Iñaki Baz Castillo, Attila Sztupák, - Ismael Luceno, Josh Stern, Denis Naumov, Anton Ageev, Kamil Klimkiewicz, - Hesham Wahba, Phil Carmody + + Ragel State Machine Compiler -- CREDITS + ======================================= + + +* Ragel was designed and written by Adrian Thurston <thurston@complang.org>. + +Many others have helped out along the way. My apolgies to anyone who has been +missed. + +* Many thanks to Arbor Networks for supporting development of Ragel. + +* Objective-C output and valuable feedback contributed by Erich Ocean. + +* D output and many great ideas contributed by Alan West. + +* Conditionals inspired by David Helder. + +* Java code generation contributions, bug reports, fixes, test cases + and suggestions from Colin Fleming. + +* Useful discussions and bug reports due to Carlos Antunes. + +* Ruby code generation contributed by Victor Hugo Borja. + +* C# code generation contributed by Daniel Tang. + +* Go code generation contributed by Justine Tunney. Significantly expanded by + Anton Ageev + +* D2 patch from Johannes Pfau. + +* OCaml patch from ygrek. + +* Feedback, Packaging, and Fixes provided by: + + Bob Tennent, Robert Lemmen, Tobias Jahn, Cris Bailiff, Buddy Betts, + Scott Dixon, Steven Handerson, Michael Somos, Bob Paddock, Istvan Buki, + David Drai, Matthias Rahlf, Zinx Verituse, Markus W. Weissmann, + Marc Liyanage, Erich Ocean, Alan West, Steven Kibbler, Laurent Boulard, + Jon Oberheide, David Helder, Lexington Luthor, Jason Jobe, Colin Fleming, + Carlos Antunes, Steve Horne, Matt Mower, Josef Goettgens, Zed Shaw, + Marcus Rueckert, Jeremy Hinegardner, Aaron Campbell, Josh Purinton, + Judson Lester, Barry Arthur, Tim Potter, Ryan Phelps, David Waite, + Kenny MacDermid, MenTaLguY, Manoj Rajagopalan, Tim Chklovski, + Mikkel Fahnøe Jørgensen, Andrei Polushin, Evan Phoenix, David Balmain, + Ross Thomas, Mitchell Foral, John D. Mitchell, Diego 'Flameeyes' Pettenò, + Jose Quinteiro, William Morgan, _why, Iñaki Baz Castillo, Attila Sztupák, + Ismael Luceno, Josh Stern, Denis Naumov, Anton Ageev, Kamil Klimkiewicz, + Hesham Wahba, Phil Carmody diff --git a/contrib/tools/ragel6/ChangeLog b/contrib/tools/ragel6/ChangeLog index d55394e986..ea21e87646 100644 --- a/contrib/tools/ragel6/ChangeLog +++ b/contrib/tools/ragel6/ChangeLog @@ -1,1680 +1,1680 @@ -Ragel 6.10 - Mar 24, 2017 -========================= - -C codegen: test P vs PE in goto/call/ret statements in EOF actions, just - before re-entering. If at the end of the input block then the EOF check is - jumped to. This change prevents overrunning the buffer if control flow is - issued in an EOF action without fixing the input pointer first. If a program - properly issues an fhold before the control flow the program won't be - affected. - -Updated action label generation. The previous set of conditions for - generating the label didn't cover actions coming from the eofAction pointer - (eof trans covered since it points into the set of transitions). - -Use separate signed/unsigned values for host type min/max. Using separate - values avoids the need to type cast before the data goes into FsmCtx structs. - Keep it in native types until it is used. - -Optionally do not generate entry point variables. Adds noentry write option - for data. - -Various warning elimination and build updates. - -Ragel 6.9 - Oct 13, 2014 -======================== - -updated command-line synopsis - -ocaml: fix missing semicolon - -ocaml: support -G1 - -ocaml: choose a unique name for type state - -ruby: reduce the amount of calls to GET_WIDE_KEY() - -union test case: warning fix - -omit line directives around expression-oriented write statements - -use AS_IF and test command to check if the DIST file is present - -added missing std:: using - -go: added '//line' directive support - -Ragel 6.8 - Feb 11, 2013 -======================== - - -The -G2 code generator for Go1 was rewritten. Table, flat and switch-based - code generators were added. (Anton Ageev) - -The CXXFLAGS variable is not longer set in the configure script. - -Ragel 6.7 - May 22, 2011 -======================== - -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 the -L 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. - -Ragel 6.6 - Dec 2, 2009 -======================= - -Applied a number of patches from Diego Elio 'Flameeyes' Pettenò. Should not - be modifying the program's arguments. Problem raised by const correctness in - gcc 4.4. Other const-correctness and include fixes provided. - -Fixed improper allocation of checks in makeIncludePathChecks. - -Fixed segfault when there are no machine instantiations. - -Fixed wrong line directives. Line directives need to use the fileName stored - in the InputLoc stuctures from the parse trees, not the root source file, - otherwise actions in included files will have the wrong source file names - associated with the text. - -Made a number of build system improvements. We locate the DIST file using - $srcdir and source it. It contains settings for build_parsers and - build_manual. This allows the user of a dist to enable only one. - -Added missing files to doc/Makefile.am and examples/Makefile.am. - -Added checks for pdflatex and fig2dev is build_manual is on. - -Use automake --foreign so we don't need to have INSTALL and NEWS present. - -Ragel VIM syntax files should be specialized by host language. Updated the - VIM syntax files. - -Added examples to the dist. Added unicode2ragel.rb to EXTRA_DIST in contrib. - -Moved unicode2ragel.rb to the contrib directory. - -Ragel 6.5 - May 18, 2009 -======================== - -Fixed a bug in graphviz generation. Ragel crashed when using -V and -M and - the specified machine referenced another machine that wasn't included in the - build. - -The name "CS" is in use on OpenSolaris, changed to vCS to ease compiling - Ragel there. - -Converted to automake. - -REALLY fixed a bug that was intended to be fixed in 6.4: - Fixed a problem reading hex numbers that have the high bit set when the - alphabet is signed and we are on 64 bit. This was reported by _why. The - fix was provided by Wialliam Morgan. The literal 0xffffffff was used for - a fully set long when -1L should be used instead. - A null patch (whitespace changes) must have gotten checked after I was - testing with and without the critical one-line patch and I forgot to enable - make sure it was enabled in the final checkin version. - -Ragel 6.4 - Mar 22, 2009 -======================== - -Moved back to a single executable. The old intermediate format can still be - generated using the -x option. Ragel was split into frontend and backend - programs in version 5.0. This was done to encourage interoperability with - other tools. Since then, ragel has been made to work with qfsm, with ragel - producing the intermediate format and qfsm consuming it. However, there has - been no use of Ragel as a consumer of state machine data, with Ragel used as - a code generator for DFAs. This is not surprising given that much of the - complexity of Ragel is in the frontend, where the regular language to DFA - compilation happens. Since the full benefits of the split have not - materialized, and the split increases the complexity for users, Ragel has - been made once again into a single executable. - -Applied a fix to the documentation Makefile from John D. Mitchell. - -Use CXXFLAGS instead of CFLAGS for C++ compiling. Patch from Diego - 'Flameeyes' Pettenò. - -Added support for DESTDIR variable. Patch from Diego 'Flameeyes' Pettenò. - -Added a script called unicode2ragel.rb for generating unicode machines to - the examples directory. From Rakan El-Khalil. - -Fixed a copy-paste error in the documentation that was reported by Jose - Quinteiro. - -Added three new write commands: - write start; - write first_final; - write error; - These generate a reference to the start, first final and error state. When - there are many different machine specifications in one file it is easy to - get the prefix for these wrong (especially when you do a lot of copy-pasting - of boilerplate). The problem can be avoided by using write commands. - -Fixed a problem reading hex numbers that have the high bit set when the - alphabet is signed and we are on 64 bit. This was reported by _why. The fix - was provided by Wialliam Morgan. The literal 0xffffffff was used for a fully - set long when -1L should be used instead. - -Ragel 6.3 - Aug 29, 2008 -======================== - -Fixed an assertion that is too strong. In the condition code we need to copy - transitions that have non-empty lmActionTable arrays so we don't assert - emptiness in the constructor. Lift out the assertion and copy the array in - the constructor. - -Fixed and improved multiple include prevention. We now track the entire - include history of a parser state to prevent duplicates. - -Fixed crash on failed lookup of goto/call/etc target. - -Ragel 6.2 - May 9, 2008 -======================= - -Bug fix: The lm_switch actions needs to set p from tokend when there is no - user action. - -Bug fix: when not using indicies we can't use a transitions's id to identify - the eof transition to take. Instead add the transition to the end of the - transition list and store its position in a new var called pos. The pos var - is then used as the index. - -Bug fix: an fnext followed by an fbreak in -G2 was not working. The fbreak - was not aware that the fnext causes the cs variable to be forced active. In - this case fbreak does not need to save cs because it is already current. - -Bug fix: need to compute the low and high character-space keys from the - condition-trans overlap when computing an expansion. Can't use the range - supplied from the condition overlap since they may not match. An incorrect - machine that accepted 1(!cond1, !cond2) was generated for the following - grammar. This bug was reported by Tim Chklovski. - c = 2 @matched_c; - sc1 = 1..2 when cond1; - sc2 = 1..2 when cond2; - main := sc1 | c | sc2; - -Bug fix: error messages in start label analysis of join operations were - causing assertion failures because location info was not set. Fixed by - adding locations. - -Include and import file searching now searches for the file name given based - on the location of the current file, not ragel's current path. - Additional search locations can be given using the -I option. - -Rubinius code generation was updated to the latest Rubinius. Patch from Evan - Phoenix. - -Switched from strcasecmp to strcmp for testing long arguments. - -Applied a patch from Andrei Polushin for setting the error message format. - --error-format=gnu (default) - --error-fromat=msvc - -Now using the _WIN32 define instead of _WIN32. Other MSVC compilation - improvments from Andrei Polushin. - -Added the hyperref package to the manual. - -Ragel 6.1 - Mar 26, 2008 -======================== - -Scanners now ensure that any leaving actions at the end of a pattern are - executed. They are always executed before the pattern action. - -Added an option -d for turning off the removal of duplicate actions from - actions lists. - -Need to unset the final state status of the start state in kleene star if it - is set. It is possible to crash ragel when the warning is ignored. - -In the dot file generation we need to print any actions that are in - State::eofTrans. These come from scanners only. - -Use @docdir@ for the docdir Makefile variable. - -Check for ar and ranlib in the configure script. - -Ragel 6.0 - Jan 12, 2008 -======================== - -Removed the 'noend' write option from examples/atoi.rl. This example is - referenced a lot as a first example and as such it shouldn't contain a - special purpose write option like 'noend'. - -Introcuded the "eof" variable for indicating the end of file. The p variable - is checked against eof when the processing loop reaches the end of a block. - If p == eof at this time then the EOF actions are executed. The variable is - required only when EOF actions have been emebedded. - -The "write eof" command is no longer needed and was removed. - -Scanners now use EOF actions to generate tokens. This eliminates the need to - flush the last token. - -Restructured the Java driver; a switch statement with fallthrough cases are - now used to emulate gotos. - -Ruby code generation was also restructured. Gotos are elmulated using a - series of if tests. - -Went back to 3.X semantics for >, % and error actions. The > operator also - embeds a leaving action/priority into the start state if it is final. If EOF - happens in a state with a leaving operator then the leaving action is - executed. If EOF happens in a non-final state that has an error action, the - error action is executed. - -The "ragel" program now executes frontend and backend processes separately, - connecting them with a temporary file in the current directory. Without the - -x option the "ragel" program marshals arguments and calls the frontend and - backend. With the -x option the "ragel" program acts as the frontend only. - -Added name finding for executables. If any forward slash is found in argv0 - then it is assumed that the path is explicit and the path to the backend - executable should be derived from that. Whe check that location and also go - up one then inside a directory of the same name in case we are executing - from the source tree. If no forward slash is found it is assumed the file is - being run from the installed location. The PREFIX supplied during - configuration is used. - -On windows GetModuleFileNameEx is used to find out where the the current - process's binary is. That location is searched first. If that fails then we - go up one directory and look for the executable inside a directory of the - same name in case we are executing from the source tree. - -Changed the -l option in rlgen-cd to -L because it is covered in the - frontend. Added a passthrough in the frontend for the backend options. - -Dot file generation can now be invoked using the -V option to ragel. We - now require an input file. If standard in is used then we don't have a file - name on which to base the output. - -Able to build native windows executables using Cygwin+MinGW. - -Patch from David Waite: Large arrays are now created by copying in the data - from smaller arrays using System.arraycopy(). This eliminates the debug data - associated with explicit initialization statements. It is also much easier - on the java compiler which can run out of memory compiling very large - machines. The downside is that it takes slightly longer to initialize static - data at run time. - -The fbreak statement now advances p. - -In the :> :>> and <: operators it was possible for the priority assignment - to be bypassed via the zero length string. In :> this was fixed - automatically with the semantics change to the entering priority operator. - If the start state is final it now embeds a leaving action into it, - preventing persistance through the zero length string. In :>> and <: this - was fixed explicitly. With <: the entering priority operator was used and - with :> a special exception was added. Since it uses the finishing - transition operator it also adds a leaving priority to the start state if it - is final. - -Ranlib is now run on the archives. Patch from Kenny MacDermid. - -The case statement syntax in ruby code generation used a form depreciated in - Ruby 1.9. Updated it. - -Made a number of fixes that eliminate warnings in GCC 4.3. Mostly concern - the now depreciate automatic conversion of string contsants to "char*" type. - Other fixes include adding parenthesis around && within ||. - -The "tokstart" and "tokend" variables were changed to "ts" and "te". - -Ragel 5.25 - Dec 24, 2007 -========================= - -Fixed segfault reported by Ryan Phelps. Affected Java and Ruby code - generation. The dataExpr variable was not initialized. - -Fixed incorrect case label in test/runtests. Caused Objective-C tests to be - ignored. - -Added missing include to common.cpp. - -Ragel 5.24 - Sep 16, 2007 -========================= - -Applied patch from Victor Hugo Borja <vic@rubyforge.org>. This patch - implements -T1 -F0 -F1 and -G0 in the ruby code generator. Goto-driven code - generation is experimental and requires rubinius asm directives (specify - with --rbx option). These code generators pass all the ruby tests. - -If the condition embedding code runs out of available characters in the - keyspace an error message is emitted. - -The first example that appeared in the manual used the special-purpose - 'noend' write option. This caused confusion. Now a basic example appears - first. - -Added two new statements: prepush and postpop. These are code blocks that - are written out during call and return statements. The prepush code is - written immediately before pushing the current state to the state stack - during a call. The postpop code is written immediately after popping the - current state during return. These can be used to implement a dynamically - resizable stack. - -Ragel 5.23 - Jul 24, 2007 -========================= - -Eliminated the use of callcc as an alternative to goto. Instead, the named - breaks implementation used in the Java code generator is imitated using - control flow variables. - -Improved the error message given when there is a write statement but no - machine instantiations and hence no state machine. - -Documentation improvements: updates to "Machine Instantiation", "Write Init" - and "Write Exports" sectons. Added the "Variables Used by Ragel" section. - -Renamed "Entering Actions" to "Starting Actions." - -Other documentation updates. - -Ragel 5.22 - June 14, 2007 -========================== - -Bug fix: need to isolate the start state of a scanner before setting the - to-state and from-state actions which clear and set tokstart. This affected - very simple scanners only. Most scanners have an isolated start state due to - the pattern structure. - -Bug fix: when -S or -M was given the ragel version number was not emitted, - causing the backend to reject the intermediate format. From Tim Potter. - -The p varialbe is now set up at the beginning of a scanner action, rather - than at the end. This leaves scanner actions free to manipulate p and - removes the need for the special holdTE and execTE (TE for tokend) versions - of hold and exec. It also removes the need to set p = tokend-1 immediately - before any control flow. We loose the ability to determine where in the - input stream a scanner action is executed, however this information is of - little use because it is primarily an artifact of the scanner implementation - (sometimes the last char, other times later on). The gains of this change - are consistency and simplicity. - -The "data" variable (used in Java and Ruby code generation only) can now be - overridden using the variable statement. - -Ragel 5.21 - May 9, 2007 -======================== - -Fixed an inconsistency in the value of p following an error. In the C - directly executable code (rlgen-cd -G2) p is left at the character where - the error occurred, which is correct. In all other code generators it was - left at the following character. This was fixed. Now in all code generators - p is left at the character where the error occurred. - -Bug fix: when fhold was used in scanner pattern actions which get executed - on the last character of the pattern (pattern matches which do not require - any lookahead), fhold was modifying p instead of tokend. This was fixed and - the patact.rl test was modified to cover the case. - -Fixed typos in the guide, improved the state action embedding operator - section and added subsections on the variable, import, and export - statements. - -Implemented a better solution than the pri hack for resolving the '-' - ambiguity: force a shortest match of term. - -Fixed bugs in the binary searching for condition keys in both the Ruby and - Java code generation. - -Can now embed the negative sense of a condition. Added a language- - independent test case for this feature and the necessary transformation - support. - -Added new condition embedding syntax: - expr inwhen cond - The transitions into the machine (starting transitions). - expr outwhen cond - The pending transitions out of the machine. - -The argument to the variable statement which affects the name of the current - state variable was changed from "curstate" to "cs" (the default name used - for the current state) - -Implemented the other variables names in the variable statement. Now all - variables (p, pe, cs, top, stack, act, tokstart, tokend) can be renamed. - -Parse errors in the intermediate XML file now cause the backend to exit - immediately rather then forge on. The recovery infrastructure isn't there - and segfaults are likely. - -When no input is given to the backend program, it should not print an error - message, it should just return a non-zero exit status. The assumption is - that the frontend printed an error. - -The version number is now included in the intermediate file. An error is - emitted if there is a mismatch. - -The alphabet type is now communicated from the frontend to the backend using - a one-word internal name instead of an array offset. - -The Ruby host language types had been just copied from Java. Reduced them to - two basic types: char and int, both signed with the usual C sizes. - -Ragel 5.20 - Apr 7, 2007 -======================== - -The cs variable is now always initialized, unless the "nocs" option is given - to the write init command. If there is no main machine, cs is initialized to - the entry point defined by the last machine instantiation. - -A number of fixes were made to the Ruby code generator. - -The frontend now scans ruby comments and regular expressions. - -A transformation for Ruby was added to the language-independent test suite. - The Ruby code generator passes on all the language-independent tests. - -A new Ruby test and two language-independent tests were added. - -Some portability fixes were made (Patches from Josef Goettgens and Aaron - Campbell). - -Fixed a make dependency bug which caused a problem for parallel building - (Patch from Jeremy Hinegardner). - -Ragel 5.19 - Mar 14, 2007 -========================= - -Added an import statement to ragel. This statement takes a literal string as - an argument, interprets it as a file name, then scrapes the file for - sequences of tokens that match the following forms. Tokens inside ragel - sections are ignored. An example is in test/import1.rl - name = number - name = lit_string - "define" name number - "define" name lit_string - -Added an export mechanism which writes defines for single character machines - that have been tagged with the export keyword in their definition. Defines - are used for C, ints for D, Java and Ruby. Examples of the export feature - are in test/export*.rl. - -All machine instantiations are now always generated, even if they are not - referenced. In the backend, entry points for all instantiations are written - out alongside start, error and first final states. - -If the main machine is not present then do not emit an error. Generate the - machine without a start state and do not initialize cs in the write init - code. - -Added an option -l to rlgen-cd which inhibits the writing of #line - directives. - -Added a new syntax for verbose embeddings. This adds parentheses: - $from(action_name); - Verbose embeddings without parentheses can make code difficult to read - because they force a space in the middle of an action embedding. There is a - tendency to associtate spaces with concatenation. Without syntax - highlighting to make it clear that the embedding type is a keyword, the - problem is especially bad. The danger is that a verbose embedding could be - read as an embedding of the keyword representing the empbedding type. With - parentheses, verbose embeddings read much more clearly. - -Conditions now have a forced order when more than one is executed on a - single character. Previously ordering relied on pointers, which caused - results to vary by compiler. Ordering is now done using conditon action - declaration order. This fixes the failure of cond4.rl which occured with - g++ 4.1 and other compiler versions. - -In the port from flex to ragel, the name separator :: in Ragel code was - lost. Added it back. - -In the examples directory switched from rlcodegen to rlgen-cd. Silenced a - warning in statechart.rl. - -In the root makefile the distclean target was fixed. It was calling clean in - the subdirs. In docs, the clean target was not deleting the new manpages for - the rlgen-* programs. Fixed. - -Portability and other fixes from Josef Goettgens were applied. - -The @datadir@ and @mandir@ variables are made use of in doc/Makefile.in for - specifying where documentation should be installed. Patch from Marcus - Rueckert. - -Ragel 5.18 - Feb 13, 2007 -========================= - -There is now a 100% correspondence between state id numbers in the - intermediate XML file, Graphviz dot files and generated code. This was - achieved by moving code which determines if the error state is necessary - into the frontend, and then assigning state numbers before writing out the - intermediate file. - -Backened class structure was reorganized to make it easier to add new code - generators without having to also modify the existing code generators. - -The C and D code generation executable was changed to rlgen-cd. - -The Java code generation was split out into it's own exectuable (rlgen-java) - to allow it to freely diverge from the C/D-based code generation. - -The graphviz dot file generation was also split out to it's own executable - (rlgen-dot). - -The Ruby code generation patch from Victor Hugo Borja was added. This is - highly experimental code and is not yet completely functional. It is in the - executable rlgen-ruby. - -The problem with large state machine machines in Java was fixed. This - problem was discovered by Colin Fleming, who also contributed a patch. - Rather than specify arrays as comma-separated lists of literals, array - initialization is now done in a static function. This is the approach used - by the Java compiler. Unlike the compiler Ragel is careful split large - initilization functions. - -The manual was expanded and reorganized somewhat. - -Eliminated per-example directories in examples/. - -Made some fixes to the pullscan.rl example. - -In the frontend CR characters are now treated as whitespace. - -Updated to the latest aapl. This completely eliminates the shallowCopy - function. With that, a definitive memory leak is fixed. - -Control codes with escape sequences are now printable characters (-p - option). Also, the space character is now printed as SP. - -Fixed the null dereference and consequential segfault which occurred when - trying to create empty machines with [] and // and /a[]b/. - -Fixed the segfault which occured when a machine reference failed. - -Discontinuing ragel.spec. It is more appropriate for this to be written by - package maintenance developers. - -Ragel 5.17 - Jan 28, 2007 -========================= - -The scanners and parsers in both the frontend and backend programs were - completely rewritten using Ragel and Kelbt. - -The '%when condition' syntax was functioning like '$when condition'. This - was fixed. - -In the Vim syntax file fixes to the matching of embedding operators were - made. Also, improvements to the sync patterns were made. - -Added pullscan.rl to the examples directory. It is an example of doing - pull-based scanning. Also, xmlscan.rl in rlcodegen is a pull scanner. - -The introduction chapter of the manual was improved. The manually-drawn - figures for the examples were replaced with graphviz-drawn figures. - -Ragel 5.16 - Nov 20, 2006 -========================= - -Policy change: the fhold and fexec directives did not function correctly in - scanner pattern actions. In this context manipulations of p may be lost or - made invalid. In the previous version of Ragel they were banned because of - this. Instead of banning these directives they have been fixed. The fexec - and fhold directives now manipulate tokend, which is now always used to - update p when the action terminates. - -Ragel 5.15 - Oct 31, 2006 -========================= - -A language independent test harness was introduced. Test cases can be - written using a custom mini-language in the embedded actions. This - mini-language is then translated to C, D and Java when generating the - language-specific test cases. - -Several existing tests have been ported to the language-independent format - and a number of new language-independent test cases have been added. - -The state-based embedding operators which access states that are not the - start state and are not final (the 'middle' states) have changed. They - were: - <@/ eof action into middle states - <@! error action into middle states - <@^ local error action into middle states - <@~ to-state action into middle states - <@* from-state action into middle states - They are now: - <>/ eof action into middle states - <>! error action into middle states - <>^ local error action into middle states - <>~ to-state action into middle states - <>* from-state action into middle states - -The verbose form of embeddings using the <- operator have been removed. - This syntax was difficult to remember. - -A new verbose form of state-based embedding operators have been added. - These are like the symbol versions, except they replace the symbols: - / ! ^ ~ * - with literal keywords: - eof err lerr to from - -The following words have been promoted to keywords: - when eof err lerr to from - -The write statment now gets its own lexical scope in the scanner to ensure - that commands are passed through as is (not affected by keywords). - -Bug fix: in the code generation of fret in scanner actions the adjustment to - p that is needed in some cases (dependent on content of patterns) was not - happening. - -The fhold directive, which decrements p, cannot be permitted in the pattern - action of a scanner item because it will not behave consistently. At the end - of a pattern action p could be decremented, set to a new value or left - alone. This depends on the contents of the scanner's patterns. The user - cannot be expected to predict what will happen to p. - -Conditions in D code require a cast to the widec type when computing widec. - -Like Java, D code also needs if (true) branches for control flow in actions - in order to fool the unreachable code detector. This is now abstracted in - all code generators using the CTRL_FLOW() function. - -The NULL_ITEM value in java code should be -1. This is needed for - maintaining tokstart. - -Ragel 5.14 - Oct 1, 2006 -======================== - -Fixed the check for use of fcall in actions embedded within longest match - items. It was emitting an error if an item's longest-match action had an - fcall, which is allowed. This bug was introduced while fixing a segfault in - version 5.8. - -A new minimization option was added: MinimizeMostOps (-l). This option - minimizes at every operation except on chains of expressions and chains of - terms (eg, union and concat). On these chains it minimizes only at the last - operation. This makes test cases with many states compile faster, without - killing the performance on grammars like strings2.rl. - -The -l minimiziation option was made the default. - -Fixes to Java code: Use of the fc value did not work, now fixed. Static data - is now declared with the final keyword. Patch from Colin Fleming. Conditions - now work when generating Java code. - -The option -p was added to rlcodegen which causes printable characters to be - printed in GraphViz output. Patch from Colin Fleming. - -The "element" keyword no longer exists, removed from vim syntax file. - Updated keyword highlighting. - -The host language selection is now made in the frontend. - -Native host language types are now used when specifying the alphtype. - Previously all languages used the set defined by C, and these were mapped to - the appropriate type in the backend. - -Ragel 5.13 - Sep 7, 2006 -======================== - -Fixed a careless error which broke Java code generation. - -Ragel 5.12 - Sep 7, 2006 -======================== - -The -o flag did not work in combination with -V. This was fixed. - -The split code generation format uses only the required number of digits - when writing out the number in the file name of each part. - -The -T0, -F0 and -G0 codegens should write out the action list iteration - variables only when there are regular, to state or from state actions. The - code gens should not use anyActions(). - -If two states have the same EOF actions, they are written out in the finish - routine as one case. - -The split and in-place goto formats would sometimes generate _out when it is - not needed. This was fixed. - -Improved the basic partitioning in the split code gen. The last partition - would sometimes be empty. This was fixed. - -Use of 'fcall *' was not causing top to be initialized. Fixed. - -Implemented a Java backend, specified with -J. Only the table-based format - is supported. - -Implemented range compression in the frontend. This has no effect on the - generated code, however it reduces the work of the backend and any programs - that read the intermediate format. - -Ragel 5.11 - Aug 10, 2006 -========================= - -Added a variable to the configure.in script which allows the building of - the parsers to be turned off (BUILD_PARSERS). Parser building is off by - default for released versions. - -Removed configure tests for bison defines header file. Use --defines=file - instead. - -Configure script doesn't test for bison, flex and gperf when building of the - parsers is turned off. - -Removed check for YYLTYPE structure from configure script. Since shipped - code will not build parsers by default, we don't need to be as accomodating - of other versions of bison. - -Added a missing include that showed up with g++ 2.95.3. - -Failed configure test for Objective-C compiler is now silent. - -Ragel 5.10 - Jul 31, 2006 -========================= - -Moved the check for error state higher in the table-based processing loop. - -Replaced naive implementations of condition searching with proper ones. In - the table-based formats the searching is also table-based. In the directly - executed formats the searching is also directly executable. - -The minimization process was made aware of conditions. - -A problem with the condition implementation was fixed. Previously we were - taking pointers to transitions and then using them after a call to - outTransCopy, which was a bad idea because they may be changed by the call. - -Added test mailbox3.rl which is based on mailbox2.rl but includes conditions - for restricting header and message body lengths. - -Eliminated the initial one-character backup of p just before resuming - execution. - -Added the -s option to the frontend for printing statistics. This currently - includes just the number of states. - -Sped up the generation of the in-place goto-driven (-G2) code style. - -Implemented a split version of in-place goto-driven code style. This code - generation style is suitable for producing fast implementations of very - large machines. Partitioning is currently naive. In the future a - high-quality partitioning program will be employed. The flag for accessing - this feature is -Pn, where n is the number of partitions. - -Converted mailbox1.rl, strings2.rl and cppscan1.rl tests to support the - split code generation. - -Fixes and updates were made to the runtests script: added -c for compiling - only, changed the -me option to -e, and added support for testing the split - code style. - -Ragel 5.9 - Jul 19, 2006 -======================== - -Fixed a bug in the include system which caused malformed output from the - frontend when the include was made from a multi-line machine spec and the - included file ended in a single line spec (or vice versa). - -Static data is now const. - -Actions which referenced states but were not embedded caused the frontend to - segfault, now fixed. - -Manual now built with pdflatex. - -The manual was reorganized and expanded. Chapter sequence is now: - Introduction, Constructing Machines, Embedding Actions, Controlling - Nondeterminism and Interfacing to the Host program. - -Ragel 5.8 - Jun 17, 2006 -======================== - -The internal representation of the alphabet type has been encapsulated - into a class and all operations on it have been defined as C++ operators. - -The condition implementation now supports range transitions. This allows - conditions to be embedded into arbitrary machines. Conditions are still - exprimental. - -More condition embedding operators were added - 1. Isolate the start state and embed a condition into all transitions - leaving it: - >when cond OR >?cond - 2. Embed a condition into all transitions: - when cond OR $when cond OR $?cond - 3. Embed a condition into pending out transitions: - %when cond OR %?cond - -Improvements were made to the determinization process to support pending out - conditions. - -The Vim sytax file was fixed so that :> doesn't cause the match of a label. - -The test suite was converted to a single-file format which uses less disk - space than the old directory-per-test format. - -Ragel 5.7 - May 14, 2006 -======================== - -Conditions will not be embedded like actions because they involve a - manipulation of the state machine they are specified in. They have therefore - been taken out of the verbose action embedding form (using the <- compound - symbol). A new syntax for specifying conditions has been created: - m = '\n' when {i==4}; - -Fixed a bug which prevented state machine commands like fcurs, fcall, fret, - etc, from being accounted for in from-state actions and to-state actions. - This prevented some necessary support code from being generated. - -Implemented condition testing in remaining code generators. - -Configure script now checks for gperf, which is required for building. - -Added support for case-insensitive literal strings (in addition to regexes). - A case-insensitive string is made by appending an 'i' to the literal, as in - 'cmd'i or "cmd"i. - -Fixed a bug which caused all or expressions inside of all regular - expressions to be case-insensitive. For example /[fo]o bar/ would make the - [fo] part case-insensitive even though no 'i' was given following the - regular expression. - -Ragel 5.6 - Apr 1, 2006 -======================= - -Added a left-guarded concatenation operator. This operator <: is equivalent - to ( expr1 $1 . expr2 >0 ). It is useful if you want to prefix a sequence - with a sequence of a subset of the characters it matches. For example, one - can consume leading whitespace before tokenizing a sequence of whitespace - separated words: ( ' '* <: ( ' '+ | [a-z]+ )** ) - -Removed context embedding code, which has been dead since 5.0. +Ragel 6.10 - Mar 24, 2017 +========================= + -C codegen: test P vs PE in goto/call/ret statements in EOF actions, just + before re-entering. If at the end of the input block then the EOF check is + jumped to. This change prevents overrunning the buffer if control flow is + issued in an EOF action without fixing the input pointer first. If a program + properly issues an fhold before the control flow the program won't be + affected. + -Updated action label generation. The previous set of conditions for + generating the label didn't cover actions coming from the eofAction pointer + (eof trans covered since it points into the set of transitions). + -Use separate signed/unsigned values for host type min/max. Using separate + values avoids the need to type cast before the data goes into FsmCtx structs. + Keep it in native types until it is used. + -Optionally do not generate entry point variables. Adds noentry write option + for data. + -Various warning elimination and build updates. + +Ragel 6.9 - Oct 13, 2014 +======================== + -updated command-line synopsis + -ocaml: fix missing semicolon + -ocaml: support -G1 + -ocaml: choose a unique name for type state + -ruby: reduce the amount of calls to GET_WIDE_KEY() + -union test case: warning fix + -omit line directives around expression-oriented write statements + -use AS_IF and test command to check if the DIST file is present + -added missing std:: using + -go: added '//line' directive support + +Ragel 6.8 - Feb 11, 2013 +======================== + + -The -G2 code generator for Go1 was rewritten. Table, flat and switch-based + code generators were added. (Anton Ageev) + -The CXXFLAGS variable is not longer set in the configure script. + +Ragel 6.7 - May 22, 2011 +======================== + -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 the -L 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. + +Ragel 6.6 - Dec 2, 2009 +======================= + -Applied a number of patches from Diego Elio 'Flameeyes' Pettenò. Should not + be modifying the program's arguments. Problem raised by const correctness in + gcc 4.4. Other const-correctness and include fixes provided. + -Fixed improper allocation of checks in makeIncludePathChecks. + -Fixed segfault when there are no machine instantiations. + -Fixed wrong line directives. Line directives need to use the fileName stored + in the InputLoc stuctures from the parse trees, not the root source file, + otherwise actions in included files will have the wrong source file names + associated with the text. + -Made a number of build system improvements. We locate the DIST file using + $srcdir and source it. It contains settings for build_parsers and + build_manual. This allows the user of a dist to enable only one. + -Added missing files to doc/Makefile.am and examples/Makefile.am. + -Added checks for pdflatex and fig2dev is build_manual is on. + -Use automake --foreign so we don't need to have INSTALL and NEWS present. + -Ragel VIM syntax files should be specialized by host language. Updated the + VIM syntax files. + -Added examples to the dist. Added unicode2ragel.rb to EXTRA_DIST in contrib. + -Moved unicode2ragel.rb to the contrib directory. + +Ragel 6.5 - May 18, 2009 +======================== + -Fixed a bug in graphviz generation. Ragel crashed when using -V and -M and + the specified machine referenced another machine that wasn't included in the + build. + -The name "CS" is in use on OpenSolaris, changed to vCS to ease compiling + Ragel there. + -Converted to automake. + -REALLY fixed a bug that was intended to be fixed in 6.4: + Fixed a problem reading hex numbers that have the high bit set when the + alphabet is signed and we are on 64 bit. This was reported by _why. The + fix was provided by Wialliam Morgan. The literal 0xffffffff was used for + a fully set long when -1L should be used instead. + A null patch (whitespace changes) must have gotten checked after I was + testing with and without the critical one-line patch and I forgot to enable + make sure it was enabled in the final checkin version. + +Ragel 6.4 - Mar 22, 2009 +======================== + -Moved back to a single executable. The old intermediate format can still be + generated using the -x option. Ragel was split into frontend and backend + programs in version 5.0. This was done to encourage interoperability with + other tools. Since then, ragel has been made to work with qfsm, with ragel + producing the intermediate format and qfsm consuming it. However, there has + been no use of Ragel as a consumer of state machine data, with Ragel used as + a code generator for DFAs. This is not surprising given that much of the + complexity of Ragel is in the frontend, where the regular language to DFA + compilation happens. Since the full benefits of the split have not + materialized, and the split increases the complexity for users, Ragel has + been made once again into a single executable. + -Applied a fix to the documentation Makefile from John D. Mitchell. + -Use CXXFLAGS instead of CFLAGS for C++ compiling. Patch from Diego + 'Flameeyes' Pettenò. + -Added support for DESTDIR variable. Patch from Diego 'Flameeyes' Pettenò. + -Added a script called unicode2ragel.rb for generating unicode machines to + the examples directory. From Rakan El-Khalil. + -Fixed a copy-paste error in the documentation that was reported by Jose + Quinteiro. + -Added three new write commands: + write start; + write first_final; + write error; + These generate a reference to the start, first final and error state. When + there are many different machine specifications in one file it is easy to + get the prefix for these wrong (especially when you do a lot of copy-pasting + of boilerplate). The problem can be avoided by using write commands. + -Fixed a problem reading hex numbers that have the high bit set when the + alphabet is signed and we are on 64 bit. This was reported by _why. The fix + was provided by Wialliam Morgan. The literal 0xffffffff was used for a fully + set long when -1L should be used instead. + +Ragel 6.3 - Aug 29, 2008 +======================== + -Fixed an assertion that is too strong. In the condition code we need to copy + transitions that have non-empty lmActionTable arrays so we don't assert + emptiness in the constructor. Lift out the assertion and copy the array in + the constructor. + -Fixed and improved multiple include prevention. We now track the entire + include history of a parser state to prevent duplicates. + -Fixed crash on failed lookup of goto/call/etc target. + +Ragel 6.2 - May 9, 2008 +======================= + -Bug fix: The lm_switch actions needs to set p from tokend when there is no + user action. + -Bug fix: when not using indicies we can't use a transitions's id to identify + the eof transition to take. Instead add the transition to the end of the + transition list and store its position in a new var called pos. The pos var + is then used as the index. + -Bug fix: an fnext followed by an fbreak in -G2 was not working. The fbreak + was not aware that the fnext causes the cs variable to be forced active. In + this case fbreak does not need to save cs because it is already current. + -Bug fix: need to compute the low and high character-space keys from the + condition-trans overlap when computing an expansion. Can't use the range + supplied from the condition overlap since they may not match. An incorrect + machine that accepted 1(!cond1, !cond2) was generated for the following + grammar. This bug was reported by Tim Chklovski. + c = 2 @matched_c; + sc1 = 1..2 when cond1; + sc2 = 1..2 when cond2; + main := sc1 | c | sc2; + -Bug fix: error messages in start label analysis of join operations were + causing assertion failures because location info was not set. Fixed by + adding locations. + -Include and import file searching now searches for the file name given based + on the location of the current file, not ragel's current path. + Additional search locations can be given using the -I option. + -Rubinius code generation was updated to the latest Rubinius. Patch from Evan + Phoenix. + -Switched from strcasecmp to strcmp for testing long arguments. + -Applied a patch from Andrei Polushin for setting the error message format. + --error-format=gnu (default) + --error-fromat=msvc + -Now using the _WIN32 define instead of _WIN32. Other MSVC compilation + improvments from Andrei Polushin. + -Added the hyperref package to the manual. + +Ragel 6.1 - Mar 26, 2008 +======================== + -Scanners now ensure that any leaving actions at the end of a pattern are + executed. They are always executed before the pattern action. + -Added an option -d for turning off the removal of duplicate actions from + actions lists. + -Need to unset the final state status of the start state in kleene star if it + is set. It is possible to crash ragel when the warning is ignored. + -In the dot file generation we need to print any actions that are in + State::eofTrans. These come from scanners only. + -Use @docdir@ for the docdir Makefile variable. + -Check for ar and ranlib in the configure script. + +Ragel 6.0 - Jan 12, 2008 +======================== + -Removed the 'noend' write option from examples/atoi.rl. This example is + referenced a lot as a first example and as such it shouldn't contain a + special purpose write option like 'noend'. + -Introcuded the "eof" variable for indicating the end of file. The p variable + is checked against eof when the processing loop reaches the end of a block. + If p == eof at this time then the EOF actions are executed. The variable is + required only when EOF actions have been emebedded. + -The "write eof" command is no longer needed and was removed. + -Scanners now use EOF actions to generate tokens. This eliminates the need to + flush the last token. + -Restructured the Java driver; a switch statement with fallthrough cases are + now used to emulate gotos. + -Ruby code generation was also restructured. Gotos are elmulated using a + series of if tests. + -Went back to 3.X semantics for >, % and error actions. The > operator also + embeds a leaving action/priority into the start state if it is final. If EOF + happens in a state with a leaving operator then the leaving action is + executed. If EOF happens in a non-final state that has an error action, the + error action is executed. + -The "ragel" program now executes frontend and backend processes separately, + connecting them with a temporary file in the current directory. Without the + -x option the "ragel" program marshals arguments and calls the frontend and + backend. With the -x option the "ragel" program acts as the frontend only. + -Added name finding for executables. If any forward slash is found in argv0 + then it is assumed that the path is explicit and the path to the backend + executable should be derived from that. Whe check that location and also go + up one then inside a directory of the same name in case we are executing + from the source tree. If no forward slash is found it is assumed the file is + being run from the installed location. The PREFIX supplied during + configuration is used. + -On windows GetModuleFileNameEx is used to find out where the the current + process's binary is. That location is searched first. If that fails then we + go up one directory and look for the executable inside a directory of the + same name in case we are executing from the source tree. + -Changed the -l option in rlgen-cd to -L because it is covered in the + frontend. Added a passthrough in the frontend for the backend options. + -Dot file generation can now be invoked using the -V option to ragel. We + now require an input file. If standard in is used then we don't have a file + name on which to base the output. + -Able to build native windows executables using Cygwin+MinGW. + -Patch from David Waite: Large arrays are now created by copying in the data + from smaller arrays using System.arraycopy(). This eliminates the debug data + associated with explicit initialization statements. It is also much easier + on the java compiler which can run out of memory compiling very large + machines. The downside is that it takes slightly longer to initialize static + data at run time. + -The fbreak statement now advances p. + -In the :> :>> and <: operators it was possible for the priority assignment + to be bypassed via the zero length string. In :> this was fixed + automatically with the semantics change to the entering priority operator. + If the start state is final it now embeds a leaving action into it, + preventing persistance through the zero length string. In :>> and <: this + was fixed explicitly. With <: the entering priority operator was used and + with :> a special exception was added. Since it uses the finishing + transition operator it also adds a leaving priority to the start state if it + is final. + -Ranlib is now run on the archives. Patch from Kenny MacDermid. + -The case statement syntax in ruby code generation used a form depreciated in + Ruby 1.9. Updated it. + -Made a number of fixes that eliminate warnings in GCC 4.3. Mostly concern + the now depreciate automatic conversion of string contsants to "char*" type. + Other fixes include adding parenthesis around && within ||. + -The "tokstart" and "tokend" variables were changed to "ts" and "te". + +Ragel 5.25 - Dec 24, 2007 +========================= + -Fixed segfault reported by Ryan Phelps. Affected Java and Ruby code + generation. The dataExpr variable was not initialized. + -Fixed incorrect case label in test/runtests. Caused Objective-C tests to be + ignored. + -Added missing include to common.cpp. + +Ragel 5.24 - Sep 16, 2007 +========================= + -Applied patch from Victor Hugo Borja <vic@rubyforge.org>. This patch + implements -T1 -F0 -F1 and -G0 in the ruby code generator. Goto-driven code + generation is experimental and requires rubinius asm directives (specify + with --rbx option). These code generators pass all the ruby tests. + -If the condition embedding code runs out of available characters in the + keyspace an error message is emitted. + -The first example that appeared in the manual used the special-purpose + 'noend' write option. This caused confusion. Now a basic example appears + first. + -Added two new statements: prepush and postpop. These are code blocks that + are written out during call and return statements. The prepush code is + written immediately before pushing the current state to the state stack + during a call. The postpop code is written immediately after popping the + current state during return. These can be used to implement a dynamically + resizable stack. + +Ragel 5.23 - Jul 24, 2007 +========================= + -Eliminated the use of callcc as an alternative to goto. Instead, the named + breaks implementation used in the Java code generator is imitated using + control flow variables. + -Improved the error message given when there is a write statement but no + machine instantiations and hence no state machine. + -Documentation improvements: updates to "Machine Instantiation", "Write Init" + and "Write Exports" sectons. Added the "Variables Used by Ragel" section. + -Renamed "Entering Actions" to "Starting Actions." + -Other documentation updates. + +Ragel 5.22 - June 14, 2007 +========================== + -Bug fix: need to isolate the start state of a scanner before setting the + to-state and from-state actions which clear and set tokstart. This affected + very simple scanners only. Most scanners have an isolated start state due to + the pattern structure. + -Bug fix: when -S or -M was given the ragel version number was not emitted, + causing the backend to reject the intermediate format. From Tim Potter. + -The p varialbe is now set up at the beginning of a scanner action, rather + than at the end. This leaves scanner actions free to manipulate p and + removes the need for the special holdTE and execTE (TE for tokend) versions + of hold and exec. It also removes the need to set p = tokend-1 immediately + before any control flow. We loose the ability to determine where in the + input stream a scanner action is executed, however this information is of + little use because it is primarily an artifact of the scanner implementation + (sometimes the last char, other times later on). The gains of this change + are consistency and simplicity. + -The "data" variable (used in Java and Ruby code generation only) can now be + overridden using the variable statement. + +Ragel 5.21 - May 9, 2007 +======================== + -Fixed an inconsistency in the value of p following an error. In the C + directly executable code (rlgen-cd -G2) p is left at the character where + the error occurred, which is correct. In all other code generators it was + left at the following character. This was fixed. Now in all code generators + p is left at the character where the error occurred. + -Bug fix: when fhold was used in scanner pattern actions which get executed + on the last character of the pattern (pattern matches which do not require + any lookahead), fhold was modifying p instead of tokend. This was fixed and + the patact.rl test was modified to cover the case. + -Fixed typos in the guide, improved the state action embedding operator + section and added subsections on the variable, import, and export + statements. + -Implemented a better solution than the pri hack for resolving the '-' + ambiguity: force a shortest match of term. + -Fixed bugs in the binary searching for condition keys in both the Ruby and + Java code generation. + -Can now embed the negative sense of a condition. Added a language- + independent test case for this feature and the necessary transformation + support. + -Added new condition embedding syntax: + expr inwhen cond - The transitions into the machine (starting transitions). + expr outwhen cond - The pending transitions out of the machine. + -The argument to the variable statement which affects the name of the current + state variable was changed from "curstate" to "cs" (the default name used + for the current state) + -Implemented the other variables names in the variable statement. Now all + variables (p, pe, cs, top, stack, act, tokstart, tokend) can be renamed. + -Parse errors in the intermediate XML file now cause the backend to exit + immediately rather then forge on. The recovery infrastructure isn't there + and segfaults are likely. + -When no input is given to the backend program, it should not print an error + message, it should just return a non-zero exit status. The assumption is + that the frontend printed an error. + -The version number is now included in the intermediate file. An error is + emitted if there is a mismatch. + -The alphabet type is now communicated from the frontend to the backend using + a one-word internal name instead of an array offset. + -The Ruby host language types had been just copied from Java. Reduced them to + two basic types: char and int, both signed with the usual C sizes. + +Ragel 5.20 - Apr 7, 2007 +======================== + -The cs variable is now always initialized, unless the "nocs" option is given + to the write init command. If there is no main machine, cs is initialized to + the entry point defined by the last machine instantiation. + -A number of fixes were made to the Ruby code generator. + -The frontend now scans ruby comments and regular expressions. + -A transformation for Ruby was added to the language-independent test suite. + The Ruby code generator passes on all the language-independent tests. + -A new Ruby test and two language-independent tests were added. + -Some portability fixes were made (Patches from Josef Goettgens and Aaron + Campbell). + -Fixed a make dependency bug which caused a problem for parallel building + (Patch from Jeremy Hinegardner). + +Ragel 5.19 - Mar 14, 2007 +========================= + -Added an import statement to ragel. This statement takes a literal string as + an argument, interprets it as a file name, then scrapes the file for + sequences of tokens that match the following forms. Tokens inside ragel + sections are ignored. An example is in test/import1.rl + name = number + name = lit_string + "define" name number + "define" name lit_string + -Added an export mechanism which writes defines for single character machines + that have been tagged with the export keyword in their definition. Defines + are used for C, ints for D, Java and Ruby. Examples of the export feature + are in test/export*.rl. + -All machine instantiations are now always generated, even if they are not + referenced. In the backend, entry points for all instantiations are written + out alongside start, error and first final states. + -If the main machine is not present then do not emit an error. Generate the + machine without a start state and do not initialize cs in the write init + code. + -Added an option -l to rlgen-cd which inhibits the writing of #line + directives. + -Added a new syntax for verbose embeddings. This adds parentheses: + $from(action_name); + Verbose embeddings without parentheses can make code difficult to read + because they force a space in the middle of an action embedding. There is a + tendency to associtate spaces with concatenation. Without syntax + highlighting to make it clear that the embedding type is a keyword, the + problem is especially bad. The danger is that a verbose embedding could be + read as an embedding of the keyword representing the empbedding type. With + parentheses, verbose embeddings read much more clearly. + -Conditions now have a forced order when more than one is executed on a + single character. Previously ordering relied on pointers, which caused + results to vary by compiler. Ordering is now done using conditon action + declaration order. This fixes the failure of cond4.rl which occured with + g++ 4.1 and other compiler versions. + -In the port from flex to ragel, the name separator :: in Ragel code was + lost. Added it back. + -In the examples directory switched from rlcodegen to rlgen-cd. Silenced a + warning in statechart.rl. + -In the root makefile the distclean target was fixed. It was calling clean in + the subdirs. In docs, the clean target was not deleting the new manpages for + the rlgen-* programs. Fixed. + -Portability and other fixes from Josef Goettgens were applied. + -The @datadir@ and @mandir@ variables are made use of in doc/Makefile.in for + specifying where documentation should be installed. Patch from Marcus + Rueckert. + +Ragel 5.18 - Feb 13, 2007 +========================= + -There is now a 100% correspondence between state id numbers in the + intermediate XML file, Graphviz dot files and generated code. This was + achieved by moving code which determines if the error state is necessary + into the frontend, and then assigning state numbers before writing out the + intermediate file. + -Backened class structure was reorganized to make it easier to add new code + generators without having to also modify the existing code generators. + -The C and D code generation executable was changed to rlgen-cd. + -The Java code generation was split out into it's own exectuable (rlgen-java) + to allow it to freely diverge from the C/D-based code generation. + -The graphviz dot file generation was also split out to it's own executable + (rlgen-dot). + -The Ruby code generation patch from Victor Hugo Borja was added. This is + highly experimental code and is not yet completely functional. It is in the + executable rlgen-ruby. + -The problem with large state machine machines in Java was fixed. This + problem was discovered by Colin Fleming, who also contributed a patch. + Rather than specify arrays as comma-separated lists of literals, array + initialization is now done in a static function. This is the approach used + by the Java compiler. Unlike the compiler Ragel is careful split large + initilization functions. + -The manual was expanded and reorganized somewhat. + -Eliminated per-example directories in examples/. + -Made some fixes to the pullscan.rl example. + -In the frontend CR characters are now treated as whitespace. + -Updated to the latest aapl. This completely eliminates the shallowCopy + function. With that, a definitive memory leak is fixed. + -Control codes with escape sequences are now printable characters (-p + option). Also, the space character is now printed as SP. + -Fixed the null dereference and consequential segfault which occurred when + trying to create empty machines with [] and // and /a[]b/. + -Fixed the segfault which occured when a machine reference failed. + -Discontinuing ragel.spec. It is more appropriate for this to be written by + package maintenance developers. + +Ragel 5.17 - Jan 28, 2007 +========================= + -The scanners and parsers in both the frontend and backend programs were + completely rewritten using Ragel and Kelbt. + -The '%when condition' syntax was functioning like '$when condition'. This + was fixed. + -In the Vim syntax file fixes to the matching of embedding operators were + made. Also, improvements to the sync patterns were made. + -Added pullscan.rl to the examples directory. It is an example of doing + pull-based scanning. Also, xmlscan.rl in rlcodegen is a pull scanner. + -The introduction chapter of the manual was improved. The manually-drawn + figures for the examples were replaced with graphviz-drawn figures. -Ragel 5.5 - Mar 28, 2006 -======================== - -Implemented a case-insensitive option for regular expressions: /get/i. - -If no input file is given to the ragel program it reads from standard input. - -The label of the start state has been changed from START to IN to save on - required screen space. - -Bug fix: \0 was not working in literal strings, due to a change that reduced - memory usage by concatenating components of literal strings. Token data - length is now passed from the scanner to the paser so that we do not need to - rely on null termination. - -Ragel 5.4 - Mar 12, 2006 -======================== - -Eliminated the default transition from the frontend implementation. This - default transition was a space-saving optimization that at best could reduce - the number of allocated transitions by one half. Unfortunately it - complicated the implementation and this stood in the way of introducing - conditionals. The default transition may be reintroduced in the future. - -Added entry-guarded concatenation. This operator :>, is syntactic sugar - for expr1 $0 . expr >1. This operator terminates the matching of the first - machine when a first character of the second machine is matched. For - example in any* . ';' we never leave the any* machine. If we use any* :> ';' - then the any* machine is terminiated upon matching the semi-colon. - -Added finish-guarded concatenation. This operator :>>, is syntactic sugar - for expr1 $0 . expr @1. This operator is like entry guarded concatenation - except the first machine is terminated when the second machine enters a - final state. This is useful for delaying the guard until a full pattern is - matched. For example as in '/*' any* :>> '*/'. - -Added strong subtraction. Where regular subtraction removes from the first - machine any strings that are matched by the second machine, strong - subtraction removes any strings from the first that contain any strings of - the second as a substring. Strong subtraction is syntactic sugar for - expr1 - ( any* expr2 any* ). - -Eliminated the use of priorities from the examples. Replaced with - subtraction, guarded concatenation and longest-match kleene star. - -Did some initial work on supporting conditional transitions. Far from - complete and very buggy. This code will only be active when conditionals are - used. - -Ragel 5.3 - Jan 27, 2006 -======================== - -Added missing semi-colons that cause the build to fail when using older - versions of Bison. - -Fix for D code: if the contents of an fexec is a single word, the generated - code will get interpreted as a C-style cast. Adding two brackets prevents - this. Can now turn eliminate the "access this.;" in cppscan5 that was used to - get around this problem. - -Improved some of the tag names in the intermediate format. - -Added unsigned long to the list of supported alphabet types. - -Added ids of actions and action lists to XML intermediate format. Makes it - more human readable. - -Updated to latest Aapl package. - -Ragel 5.2 - Jan 6, 2006 -======================== - -Ragel emits an error if the target of fentry, fcall, fgoto or fnext is inside - a longest match operator, or if an action embedding in a longest match - machine uses fcall. The fcall command can still be used in pattern actions. - -Made improvements to the clang, rlscan, awkemu and cppscan examples. - -Some fixes to generated label names: they should all be prefixed with _. - -A fix to the Vim syntax highlighting script was made - -Many fixes and updates to the documentation. All important features and - concepts are now documented. A second chapter describing Ragel's use - was added. - -Ragel 5.1 - Dec 22, 2005 -======================== - -Fixes to the matching of section delimiters in Vim syntax file. - -If there is a longest match machine, the tokend var is now initialized by - write init. This is not necessary for correct functionality, however - prevents compiler warnings. - -The rlscan example was ported to the longest match operator and changed to - emit XML data. - -Fix to the error handling in the frontend: if there are errors in the lookup - of names at machine generation time then do not emit anything. - -If not compiling the full machine in the frontend (by using -M), avoid - errors and segfaults caused by names that are not part of the compiled - machine. - -Longest match bug fix: need to init tokstart when returing from fsm calls - that are inside longest match actions. - -In Graphviz drawing, the arrow into the start state is not a real - transition, do not draw to-state actions on the label. - -A bug fix to the handling of non-tag data within an XML tag was made. - -Backend exit value fixed: since the parser now accepts nothing so as to - avoid a redundant parse error when the frontend dies, we must force an - error. The backend should now be properly reporting errors. - -The longest match machine now has it's start state set final. An LM machine - is in a final state when it has not matched anything, when it has matched - and accepted a token and is ready for another, and when it has matched a - token but is waiting for some lookahead before determining what to do about - it (similar to kleene star). - -Element statement removed from some tests. - -Entry point names are propagated to the backend and used to label the entry - point arrows in Graphviz output. - -Ragel 5.0 - Dec 17, 2005 -======================== - (additional details in V5 release notes) - -Ragel has been split into two executables: A frontend which compiles - machines and emits them in an XML format, and a backend which generates code - or a Graphviz dot file from the XML input. The purpose of this split is to - allow Ragel to interface with other tools by means of the XML intermediate - format and to reduce complexity by strictly separating the previously - entangled phases. The intermediate format will provide a better platform - inspecting compiled machines and for extending Ragel to support other host - languages. - -The host language interface has been reduced significantly. Ragel no longer - expects the machine to be implemented as a structure or class and does not - generate functions corresponding to initialization, execution and EOF. - Instead, Ragel just generates the code of these components, allowing all of - them to be placed in a single function if desired. The user specifies a - machine in the usual manner, then indicates at which place in the program - text the state machine code is to be generated. This is done using the write - statement. It is possible to specify to Ragel how it should access the - variables it needs (such as the current state) using the access statement. - -The host language embedding delimiters have been changed. Single line - machines start with '%%' and end at newline. Multiline machines start with - '%%{' and end with '}%%'. The machine name is given with the machine - statement at the very beginning of the specification. This purpose of this - change is to make it easier separate Ragel code from the host language. This - will ease the addition of supported host languages. - -The structure and class parsing which was previously able to extract a - machine's name has been removed since this feature is dependent on the host - language and inhibits the move towards a more language-independent frontend. - -The init, element and interface statements have been made obsolete by the - new host language interface and have been removed. - -The fexec action statement has been changed to take only the new position to - move to. This statement is more useful for moving backwards and reparsing - input than for specifying a whole new buffer entirely and has been shifted - to this new use. Giving it only one argument also simplifies the parsing of - host code embedded in a Ragel specification. This will ease the addition of - supported host languages. - -Introduced the fbreak statement, which allows one to stop processing data - immediately. The machine ends up in the state that the current transition - was to go to. The current character is not changed. - -Introduced the noend option for writing the execute code. This inhibits - checking if we have reached pe. The machine will run until it goes into the - error state or fbreak is hit. This allows one to parse null-terminate - strings without first computing the length. - -The execute code now breaks out of the processing loop when it moves into - the error state. Previously it would run until pe was hit. Breaking out - makes the noend option useful when an error is encountered and allows - user code to determine where in the input the error occured. It also - eliminates needlessly iterating the input buffer. - -Introduced the noerror, nofinal and noprefix options for writing the machine - data. The first two inhibit the writing of the error state and the - first-final state should they not be needed. The noprefix eliminates the - prefixing of the data items with the machine name. - -Support for the D language has been added. This is specified in the backend - with the -D switch. - -Since the new host language interface has been reduced considerably, Ragel - no longer needs to distinguish between C-based languages. Support for C, C++ - and Objective-C has been folded into one option in the backend: -C - -The code generator has been made independent of the languages that it - supports by pushing the language dependent apsects down into the lower - levels of the code generator. - -Many improvements to the longest match construction were made. It is no - longer considered experimental. A longest match machine must appear at the - top level of a machine instantiation. Since it does not generate a pure - state machine (it may need to backtrack), it cannot be used as an operand to - other operators. - -References to the current character and current state are now completely - banned in EOF actions. - -Ragel 4.2 - Sep 16, 2005 -======================== - (additional details in V4 release notes) - -Fixed a bug in the longest match operator. In some states it's possible that - we either match a token or match nothing at all. In these states we need to - consult the LmSwitch on error so it must be prepared to execute an error - handler. We therefore need to init act to this error value (which is zero). - We can compute if we need to do this and the code generator emits the - initialization only if necessary. - -Changed the definition of the token end of longest match actions. It now - points to one past the last token. This makes computing the token length - easier because you don't have to add one. The longest match variables token - start, action identifier and token end are now properly initialized in - generated code. They don't need to be initialized in the user's code. - -Implemented to-state and from-state actions. These actions are executed on - transitions into the state (after the in transition's actions) and on - transitions out of the state (before the out transition's actions). See V4 - release notes for more information. - -Since there are no longer any action embedding operators that embed both on - transitions and on EOF, any actions that exist in both places will be there - because the user has explicitly done so. Presuming this case is rare, and - with code duplication in the hands of the user, we therefore give the EOF - actions their own action switch in the finish() function. This is further - motivated by the fact that the best solution is to do the same for to-state - and from-state actions in the main loop. - -Longest match actions can now be specified using a named action. Since a - word following a longest match item conflicts with the concatenation of a - named machine, the => symbol must come immediately before a named action. - -The longest match operator permits action and machine definitions in the - middle of a longest match construction. These are parsed as if they came - before the machine definition they are contained in. Permitting action and - machine definitions in a longest match construction allows objects to be - defined closer to their use. - -The longest match operator can now handle longest match items with no - action, where previously Ragel segfaulted. - -Updated to Aapl post 2.12. - -Fixed a bug in epsilon transition name lookups. After doing a name lookup - the result was stored in the parse tree. This is wrong because if a machine - is used more than once, each time it may resolve to different targets, - however it will be stored in the same place. We now store name resolutions - in a separated data structure so that each walk of a parse tree uses the - name resolved during the corresponding walk in the name lookup pass. - -The operators used to embed context and actions into states have been - modified. The V4 release notes contain the full details. - -Added zlen builtin machine to represent the zero length machine. Eventually - the name "null" will be phased out in favour of zlen because it is unclear - whether null matches the zero length string or if it does not match any - string at all (as does the empty builtin). - -Added verbose versions of action, context and priority embedding. See the V4 - release notes for the full details. A small example: - machine <- all exec { foo(); } <- final eof act1 - -Bugfix for machines with epsilon ops, but no join operations. I had - wrongfully assumed that because epsilon ops can only increase connectivity, - that no states are ever merged and therefore a call to fillInStates() is not - necessary. In reality, epsilon transitions within one machine can induce the - merging of states. In the following, state 2 follows two paths on 'i': - main := 'h' -> i 'i h' i: 'i'; - -Changed the license of the guide from a custom "do not propagate modified - versions of this document" license to the GPL. - -Ragel 4.1 - Jun 26, 2005 -======================== - (additional details in V4 release notes) - -A bug in include processing was fixed. Surrounding code in an include file - was being passed through to the output when it should be ignored. Includes - are only for including portions of another machine into he current. This - went unnoticed because all tested includes were wrapped in #ifndef ... - #endif directives and so did not affect the compilation of the file making - the include. - -Fixes were made to Vim syntax highlighting file. - -Duplicate actions are now removed from action lists. - -The character-level negation operator ^ was added. This operator produces a - machine that matches single characters that are not matched by the machine - it is applied to. This unary prefix operator has the same precedence level - as !. - -The use of + to specify the a positive literal number was discontinued. - -The parser now assigns the subtraction operator a higher precedence than - the negation of literal number. +Ragel 5.16 - Nov 20, 2006 +========================= + -Policy change: the fhold and fexec directives did not function correctly in + scanner pattern actions. In this context manipulations of p may be lost or + made invalid. In the previous version of Ragel they were banned because of + this. Instead of banning these directives they have been fixed. The fexec + and fhold directives now manipulate tokend, which is now always used to + update p when the action terminates. + +Ragel 5.15 - Oct 31, 2006 +========================= + -A language independent test harness was introduced. Test cases can be + written using a custom mini-language in the embedded actions. This + mini-language is then translated to C, D and Java when generating the + language-specific test cases. + -Several existing tests have been ported to the language-independent format + and a number of new language-independent test cases have been added. + -The state-based embedding operators which access states that are not the + start state and are not final (the 'middle' states) have changed. They + were: + <@/ eof action into middle states + <@! error action into middle states + <@^ local error action into middle states + <@~ to-state action into middle states + <@* from-state action into middle states + They are now: + <>/ eof action into middle states + <>! error action into middle states + <>^ local error action into middle states + <>~ to-state action into middle states + <>* from-state action into middle states + -The verbose form of embeddings using the <- operator have been removed. + This syntax was difficult to remember. + -A new verbose form of state-based embedding operators have been added. + These are like the symbol versions, except they replace the symbols: + / ! ^ ~ * + with literal keywords: + eof err lerr to from + -The following words have been promoted to keywords: + when eof err lerr to from + -The write statment now gets its own lexical scope in the scanner to ensure + that commands are passed through as is (not affected by keywords). + -Bug fix: in the code generation of fret in scanner actions the adjustment to + p that is needed in some cases (dependent on content of patterns) was not + happening. + -The fhold directive, which decrements p, cannot be permitted in the pattern + action of a scanner item because it will not behave consistently. At the end + of a pattern action p could be decremented, set to a new value or left + alone. This depends on the contents of the scanner's patterns. The user + cannot be expected to predict what will happen to p. + -Conditions in D code require a cast to the widec type when computing widec. + -Like Java, D code also needs if (true) branches for control flow in actions + in order to fool the unreachable code detector. This is now abstracted in + all code generators using the CTRL_FLOW() function. + -The NULL_ITEM value in java code should be -1. This is needed for + maintaining tokstart. + +Ragel 5.14 - Oct 1, 2006 +======================== + -Fixed the check for use of fcall in actions embedded within longest match + items. It was emitting an error if an item's longest-match action had an + fcall, which is allowed. This bug was introduced while fixing a segfault in + version 5.8. + -A new minimization option was added: MinimizeMostOps (-l). This option + minimizes at every operation except on chains of expressions and chains of + terms (eg, union and concat). On these chains it minimizes only at the last + operation. This makes test cases with many states compile faster, without + killing the performance on grammars like strings2.rl. + -The -l minimiziation option was made the default. + -Fixes to Java code: Use of the fc value did not work, now fixed. Static data + is now declared with the final keyword. Patch from Colin Fleming. Conditions + now work when generating Java code. + -The option -p was added to rlcodegen which causes printable characters to be + printed in GraphViz output. Patch from Colin Fleming. + -The "element" keyword no longer exists, removed from vim syntax file. + Updated keyword highlighting. + -The host language selection is now made in the frontend. + -Native host language types are now used when specifying the alphtype. + Previously all languages used the set defined by C, and these were mapped to + the appropriate type in the backend. + +Ragel 5.13 - Sep 7, 2006 +======================== + -Fixed a careless error which broke Java code generation. + +Ragel 5.12 - Sep 7, 2006 +======================== + -The -o flag did not work in combination with -V. This was fixed. + -The split code generation format uses only the required number of digits + when writing out the number in the file name of each part. + -The -T0, -F0 and -G0 codegens should write out the action list iteration + variables only when there are regular, to state or from state actions. The + code gens should not use anyActions(). + -If two states have the same EOF actions, they are written out in the finish + routine as one case. + -The split and in-place goto formats would sometimes generate _out when it is + not needed. This was fixed. + -Improved the basic partitioning in the split code gen. The last partition + would sometimes be empty. This was fixed. + -Use of 'fcall *' was not causing top to be initialized. Fixed. + -Implemented a Java backend, specified with -J. Only the table-based format + is supported. + -Implemented range compression in the frontend. This has no effect on the + generated code, however it reduces the work of the backend and any programs + that read the intermediate format. + +Ragel 5.11 - Aug 10, 2006 +========================= + -Added a variable to the configure.in script which allows the building of + the parsers to be turned off (BUILD_PARSERS). Parser building is off by + default for released versions. + -Removed configure tests for bison defines header file. Use --defines=file + instead. + -Configure script doesn't test for bison, flex and gperf when building of the + parsers is turned off. + -Removed check for YYLTYPE structure from configure script. Since shipped + code will not build parsers by default, we don't need to be as accomodating + of other versions of bison. + -Added a missing include that showed up with g++ 2.95.3. + -Failed configure test for Objective-C compiler is now silent. + +Ragel 5.10 - Jul 31, 2006 +========================= + -Moved the check for error state higher in the table-based processing loop. + -Replaced naive implementations of condition searching with proper ones. In + the table-based formats the searching is also table-based. In the directly + executed formats the searching is also directly executable. + -The minimization process was made aware of conditions. + -A problem with the condition implementation was fixed. Previously we were + taking pointers to transitions and then using them after a call to + outTransCopy, which was a bad idea because they may be changed by the call. + -Added test mailbox3.rl which is based on mailbox2.rl but includes conditions + for restricting header and message body lengths. + -Eliminated the initial one-character backup of p just before resuming + execution. + -Added the -s option to the frontend for printing statistics. This currently + includes just the number of states. + -Sped up the generation of the in-place goto-driven (-G2) code style. + -Implemented a split version of in-place goto-driven code style. This code + generation style is suitable for producing fast implementations of very + large machines. Partitioning is currently naive. In the future a + high-quality partitioning program will be employed. The flag for accessing + this feature is -Pn, where n is the number of partitions. + -Converted mailbox1.rl, strings2.rl and cppscan1.rl tests to support the + split code generation. + -Fixes and updates were made to the runtests script: added -c for compiling + only, changed the -me option to -e, and added support for testing the split + code style. -Ragel 4.0 - May 26, 2005 -======================== - (additional details in V4 release notes) - -Operators now strictly embed into a machine either on a specific class of - characters or on EOF, but never both. This gives a cleaner association - between the operators and the physical state machine entitites they operate - on. This change is made up of several parts: - 1. '%' operator embeds only into leaving characters. - 2. All global and local error operators only embed on error character - transitions, their action will not be triggerend on EOF in non-final - states. - 3. EOF action embedding operators have been added for all classes of states - to make up for functionality removed from other operators. These are - >/ $/ @/ %/. - 4. Start transition operator '>' no longer implicitly embeds into leaving - transtions when start state is final. - -Ragel now emits warnings about the improper use of statements and values in - action code that is embedded as an EOF action. Warnings are emitted for fpc, - fc, fexec, fbuf and fblen. - -Added a longest match construction operator |* machine opt-action; ... *|. - This is for repetition where an ability to revert to a shorter, previously - matched item is required. This is the same behaviour as flex and re2c. The - longest match operator is not a pure FSM construction, it introduces - transitions that implicitly hold the current character or reset execution to - a previous location in the input. Use of this operator requires the caller - of the machine to occasionally hold onto data after a call to the exectute - routine. Use of machines generated with this operator as the input to other - operators may have undefined results. See examples/cppscan for an example. - This is very experimental code. - -Action ids are only assigned to actions that are referenced in the final - constructed machine, preventing gaps in the action id sequence. Previously - an action id was assigned if the action was referenced during parsing. - -Machine specifications now begin with %% and are followed with an optional - name and either a single Ragel statement or a sequence of statements - enclosed in {}. - -Ragel no longer generates the FSM's structure or class. It is up to the user - to declare the structure and to give it a variable named curs of type - integer. If the machine uses the call stack the user must also declare a - array of integers named stack and an integer variable named top. - -In the case of Objective-C, Ragel no longer generates the interface or - implementation directives, allowing the user to declare additional methods. - -If a machine specification does not have a name then Ragel tries to find a - name for it by first checking if the specification is inside a struct, class - or interface. If it is not then it uses the name of the previous machine - specification. If still no name is found then this is an error. - -Fsm specifications now persist in memory and statements accumulate. - -Ragel now has an include statement for including the statements of a machine - spec in another file (perhaps because it is the corresponding header file). - The include statement can also be used to draw in the statements of another - fsm spec in the current file. - -The fstack statement is now obsolete and has been removed. - -A new statement, simply 'interface;', indicates that ragel should generate - the machine's interface. If Ragel sees the main machine it generates the - code sections of the machine. Previously, the header portion was generated - if the (now removed) struct statement was found and code was generated if - any machine definition was found. - -Fixed a bug in the resolution of fsm name references in actions. The name - resolution code did not recurse into inline code items with children - (fgoto*, fcall*, fnext*, and fexec), causing a segfault at code generation - time. - -Cleaned up the code generators. FsmCodeGen was made into a virtual base - class allowing for the language/output-style specific classes to inherit - both a language specific and style-specific base class while retaining only - one copy of FsmCodeGen. Language specific output can now be moved into the - language specific code generators, requiring less duplication of code in the - language/output-style specific leaf classes. - -Fixed bugs in fcall* implementation of IpgGoto code generation. - -If the element type has not been defined Ragel now uses a constant version - of the alphtype, not the exact alphtype. In most cases the data pointer of - the execute routine should be const. A non-const element type can still be - defined with the element statement. - -The fc special value now uses getkey for retrieving the current char rather - than *_p, which is wrong if the element type is a structure. - -User guide converted to TeX and updated for new 4.0 syntax and semantics. - -Ragel 3.7 - Oct 31, 2004 -======================== - -Bug fix: unreferenced machine instantiations causing segfault due to name - tree and parse tree walk becomming out of syncronization. - -Rewrote representation of inline code blocks using a tree data structure. - This allows special keywords such as fbuf to be used as the operatands of - other fsm commands. - -Documentation updates. - -When deciding whether or not to generate machine instantiations, search the - entire name tree beneath the instantiation for references, not just the - root. - -Removed stray ';' in keller2.rl - -Added fexec for restarting the machine with new buffer data (state stays the - same), fbuf for retrieving the the start of the buf, and fblen for - retrieving the orig buffer length. - -Implemented test/cppscan2 using fexec. This allows token emitting and restart - to stay inside the execute routine, instead of leaving and re-entering on - every token. - -Changed examples/cppscan to use fexec and thereby go much faster. - -Implemented flex and re2c versions of examples/cppscan. Ragel version - goes faster than flex version but not as fast as re2c version. - -Merged in Objective-C patch from Erich Ocean. - -Turned off syncing with stdio in C++ tests to make them go faster. - -Renamed C++ code generaion classes with the Cpp Prefix instead of CC to make - them easier to read. - -In the finish function emit fbuf as 0 cast to a pointer to the element type - so it's type is not interpreted as an integer. - -The number -128 underflows char alphabets on some architectures. Removed - uses of it in tests. - -Disabled the keller2 test because it causes problems on many architectures - due to its large size and compilation requirements. - -Ragel 3.6 - Jul 10, 2004 -======================== - -Many documentation updates. - -When resolving names, return a set of values so that a reference in an - action block that is embedded more than once won't report distinct entry - points that are actually the same. - -Implemented flat tables. Stores a linear array of indicies into the - transition array and only a low and high key value. Faster than binary - searching for keys but not usable for large alphabets. - -Fixed bug in deleting of transitions leftover from converstion from bst to - list implementation of transitions. Other code cleanup. - -In table based output calculate the cost of using an index. Don't use if - cheaper. - -Changed fstate() value available in init and action code to to fentry() to - reflect the fact that the values returned are intended to be used as targets - in fgoto, fnext and fcall statements. The returned state is not a unique - state representing the label. There can be any number of states representing - a label. - -Added keller2 test, C++ scanning tests and C++ scanning example. - -In table based output split up transitions into targets and actions. This - allows actions to be omitted. - -Broke the components of the state array into separate arrays. Requires - adding some fields where they could previously be omitted, however allows - finer grained control over the sizes of items and an overal size reduction. - Also means that state numbers are not an offset into the state array but - instead a sequence of numbers, meaning the context array does not have any - wasted bits. - -Action lists and transition also have their types chosen to be the smallest - possible for accomodating the contained values. - -Changed curs state stored in fsm struct from _cs to curs. Keep fsm->curs == - -1 while in machine. Added tests curs1 and curs2. - -Implemented the notion of context. Context can be embedded in states using - >:, $:, @: and %: operators. These embed a named context into start states, - all states, non-start/non-final and final states. If the context is declared - using a context statment - context name; - then the context can be quered for any state using fsm_name_ctx_name(state) - in C code and fsm_name::ctx_name(state) in C++ code. This feature makes it - possible to determine what "part" of the machine is currently active. - -Fixed crash on machine generation of graphs with no final state. If there - is no reference to a final state in a join operation, don't generate one. - -Updated Vim sytax: added labels to inline code, added various C++ keywords. - Don't highlight name separations as labels. Added switch labels, improved - alphtype, element and getkey. - -Fixed line info in error reporting of bad epsilon trans. - -Fixed fstate() for tab code gen. - -Removed references to malloc.h. - -Ragel 3.5 - May 29, 2004 -======================== - -When parse errors occur, the partially generated output file is deleted and - an non-zero exit status is returned. - -Updated Vim syntax file. - -Implemented the setting of the element type that is passed to the execute - routine as well as method for specifying how ragel should retrive the key - from the element type. This lets ragel process arbitrary structures inside - of which is the key that is parsed. - element struct Element; - getkey fpc->character; - -The current state is now implemented with an int across all machines. This - simplifies working with current state variables. For example this allows a - call stack to be implemented in user code. - -Implemented a method for retrieving the current state, the target state, and - any named states. - fcurs -retrieve the current state - ftargs -retrieve the target state - fstate(name) -retrieve a named state. - -Implemented a mechanism for jumping to and calling to a state stored in a - variable. - fgoto *<expr>; -goto the state returned by the C/C++ expression. - fcall *<expr>; -call the state returned by the C/C++ expression. - -Implemented a mechanism for specifying the next state without immediately - transfering control there (any code following statement is executed). - fnext label; -set the state pointed to by label as the next state. - fnext *<expr>; -set the state returned by the C/C++ expression as the - next. - -Action references are determined from the final machine instead of during - the parse tree walk. Some actions can be referenced in the parse tree but not - show up in the final machine. Machine analysis is now done based on this new - computation. - -Named state lookup now employs a breadth-first search in the lookup and - allows the user to fully qualify names, making it possible to specify - jumps/calls into parts of the machine deep in the name hierarchy. Each part - of name (separated by ::) employs a breadth first search from it's starting - point. - -Name references now must always refer to a single state. Since references to - multiple states is not normally intended, it no longer happens - automatically. This frees the programmer from thinking about whether or not - a state reference is unique. It also avoids the added complexity of - determining when to merge the targets of multiple references. The effect of - references to multiple states can be explicitly created using the join - operator and epsilon transitions. - -M option was split into -S and -M. -S specifies the machine spec to generate - for graphviz output and dumping. -M specifies the machine definition or - instantiation. - -Machine function parameters are now prefixed with and underscore to - avoid the hiding of class members. - -Ragel 3.4 - May 8, 2004 -======================= - -Added the longest match kleene star operator **, which is synonymous - with ( ( <machine> ) $0 %1 ) *. - -Epsilon operators distinguish between leaving transitions (going to an - another expression in a comma separated list) and non-leaving transitions. - Leaving actions and priorities are appropriately transferred. - -Relative priority of following ops changed to: - 1. Action/Priority - 2. Epsilon - 3. Label - If label is done first then the isolation of the start state in > operators - will cause the label to point to the old start state that doesn't have the - new action/priority. - -Merged >! and >~, @! and @~, %! and %~, and $! and $~ operators to have one - set of global error action operators (>!, @!, %! and $!) that are invoked on - error by unexpected characters as well as by unexepected EOF. - -Added the fpc keyword for use in action code. This is a pointer to the - current character. *fpc == fc. If an action is invoked on EOF then fpc == 0. - -Added >^, @^, %^, and $^ local error operators. Global error operators (>!, - @!, $!, and %!) cause actions to be invoked if the final machine fails. - Local error actions cause actions to be invoked if if the current machine - fails. - -Changed error operators to mean embed global/local error actions in: - >! and !^ -the start state. - @! and @^ -states that are not the start state and are not final. - %! and %^ -final states. - $! and $^ -all states. - -Added >@! which is synonymous >! then @! - -Added >@^ which is synonymous >^ then @^ - -Added @%! which is synonymous @! then %! - -Added @%^ which is synonymous >^ then @^ - -FsmGraph representation of transition lists was changed from a mapping of - alphabet key -> transition objects using a BST to simply a list of - transition objects. Since the transitions are no longer divided by - single/range, the fast finding of transition objects by key is no longer - required functionality and can be eliminated. This new implementation uses - the same amount of memory however causes less allocations. It also make more - sense for supporting error transitions with actions. Previously an error - transition was represented by a null value in the BST. - -Regular expression ranges are checked to ensure that lower <= upper. - -Added printf-like example. - -Added atoi2, erract2, and gotcallret to the test suite. - -Improved build test to support make -jN and simplified the compiling and - running of tests. - -Ragel 3.3 - Mar 7, 2004 -======================= - -Portability bug fixes were made. Minimum and maximum integer values are - now taken from the system. An alignment problem on 64bit systems - was fixed. - -Ragel 3.2 - Feb 28, 2004 -======================== - -Added a Vim syntax file. - -Eliminated length var from generated execute code in favour of an end - pointer. Using length requires two variables be read and written. Using an - end pointer requires one variable read and written and one read. Results in - more optimizable code. - -Minimization is now on by default. - -States are ordered in output by depth first search. - -Bug in minimization fixed. States were not being distinguished based on - error actions. - -Added null and empty builtin machines. - -Added EOF error action operators. These are >~, >@, $~, and %~. EOF error - operators embed actions to take if the EOF is seen and interpreted as an - error. The operators correspond to the following states: - -the start state - -any state with a transition to a final state - -any state with a transiion out - -a final state - -Fixed bug in generation of unreference machine vars using -M. Unreferenced - vars don't have a name tree built underneath when starting from - instantiations. Need to instead build the name tree starting at the var. - -Calls, returns, holds and references to fc in out action code are now - handled for ipgoto output. - -Only actions referenced by an instantiated machine expression are put into - the action index and written out. - -Added rlscan, an example that lexes Ragel input. - -Ragel 3.1 - Feb 18, 2004 -======================== - -Duplicates in OR literals are removed and no longer cause an assertion - failure. - -Duplicate entry points used in goto and call statements are made into - deterministic entry points. - -Base FsmGraph code moved from aapl into ragel, as an increasing amount - of specialization is required. Too much time was spent attempting to - keep it as a general purpose template. - -FsmGraph code de-templatized and heirarchy squashed to a single class. - -Single transitions taken out of FsmGraph code. In the machine construction - stage, transitions are now implemented only with ranges and default - transtions. This reduces memory consumption, simplifies code and prevents - covered transitions. However it requires the automated selection of single - transitions to keep goto-driven code lean. - -Machine reduction completely rewritten to be in-place. As duplicate - transitions and actions are found and the machine is converted to a format - suitable for writing as C code or as GraphViz input, the memory allocated - for states and transitions is reused, instead of newly allocated. - -New reduction code consolodates ranges, selects a default transition, and - selects single transitions with the goal of joining ranges that are split by - any number of single characters. - -Line directive changed from "# <num> <file>" to the more common format - "#line <num> <file>". - -Operator :! changed to @!. This should have happened in last release. - -Added params example. - -Ragel 3.0 - Jan 22, 2004 -======================== - -Ragel now parses the contents of struct statements and action code. - -The keyword fc replaces the use of *p to reference the current character in - action code. - -Machine instantiations other than main are allowed. - -Call, jump and return statements are now available in action code. This - facility makes it possible to jump to an error handling machine, call a - sub-machine for parsing a field or to follow paths through a machine as - determined by arbitrary C code. - -Added labels to the language. Labels can be used anywhere in a machine - expression to define an entry point. Also references to machine definitions - cause the implicit creation of a label. - -Added epsilon transitions to the language. Epsilon operators may reference - labels in the current name scope resolved when join operators are evaluated - and at the root of the expression tree of machine assignment/instantiation. - -Added the comma operator, which joins machines together without drawing any - transitions between them. This operator is useful in combination with - labels, the epsilon operator and user code transitions for defining machines - using the named state and transition list paradigm. It is also useful for - invoking transitions based on some analysis of the input or on the - environment. - -Added >!, :!, $!, %! operators for specifying actions to take should the - machine fail. These operators embed actions to execute if the machine - fails in - -the start state - -any state with a transition to a final state - -any state with a transiion out - -a final state - The general rule is that if an action embedding operator embeds an action - into a set of transitions T, then the error-counterpart with a ! embeds an - action into the error transition taken when any transition T is a candidate, - but does not match the input. - -The finishing augmentation operator ':' has been changed to '@'. This - frees the ':' symbol for machine labels and avoids hacks to the parser to - allow the use of ':' for both labels and finishing augmentations. The best - hack required that label names be distinct from machine definition names as - in main := word : word; This restriction is not good because labels are - local to the machine that they are used in whereas machine names are global - entities. Label name choices should not be restricted by the set of names - that are in use for machines. - -Named priority syntax now requires parenthesis surrounding the name and - value pair. This avoids grammar ambiguities now that the ',' operator has - been introduced and makes it more clear that the name and value are an - asscociated pair. - -Backslashes are escaped in line directive paths. - -Ragel 2.2 - Oct 6, 2003 -======================= - -Added {n}, {,n}, {n,} {n,m} repetition operators. - <expr> {n} -- exactly n repetitions - <expr> {,n} -- zero to n repetitions - <expr> {n,} -- n or more repetitions - <expr> {n,m} -- n to m repetitions - -Bug in binary search table in Aapl fixed. Fixes crashing on machines that - add to action tables that are implicitly shared among transitions. - -Tests using obsolete minimization algorithms are no longer built and run by - default. - -Added atoi and concurrent from examples to the test suite. - -Ragel 2.1 - Sep 22, 2003 -======================== - -Bug in priority comparison code fixed. Segfaulted on some input with many - embedded priorities. - -Added two new examples. - -Ragel 2.0 - Sep 7, 2003 -======================= - -Optional (?), One or More (+) and Kleene Star (*) operators changed from - prefix to postfix. Rationale is that postfix version is far more common in - regular expression implementations and will be more readily understood. - -All priority values attached to transitions are now accompanied by a name. - Transitions no longer have default priority values of zero assigned - to them. Only transitions that have different priority values assigned - to the same name influence the NFA-DFA conversion. This scheme reduces - side-effects of priorities. - -Removed the %! statement for unsetting pending out priorities. With - named priorities, it is not necessary to clear the priorities of a - machine with $0 %! because non-colliding names can be used to avoid - side-effects. - -Removed the clear keyword, which was for removing actions from a machine. - Not required functionality and it is non-intuitive to have a language - feature that undoes previous definitions. - -Removed the ^ modifier to repetition and concatenation operators. This - undocumented feature prevented out transitions and out priorities from being - transfered from final states to transitions leaving machines. Not required - functionality and complicates the language unnecessarily. - -Keyword 'func' changed to 'action' as a part of the phasing out of the term - 'function' in favour of 'action'. Rationale is that the term 'function' - implies that the code is called like a C function, which is not necessarily - the case. The term 'action' is far more common in state machine compiler - implementations. - -Added the instantiation statement, which looks like a standard variable - assignment except := is used instead of =. Instantiations go into the - same graph dictionary as definitions. In the the future, instantiations - will be used as the target for gotos and calls in action code. - -The main graph should now be explicitly instantiated. If it is not, - a warning is issued. - -Or literal basic machines ([] outside of regular expressions) now support - negation and ranges. - -C and C++ interfaces lowercased. In the C interface an underscore now - separates the fsm machine and the function name. Rationale is that lowercased - library and generated routines are more common. - C output: - int fsm_init( struct clang *fsm ); - int fsm_execute( struct clang *fsm, char *data, int dlen ); - int fsm_finish( struct clang *fsm ); - C++ output: - int fsm::init( ); - int fsm::execute( char *data, int dlen ); - int fsm::finish( ); - -Init, execute and finish all return -1 if the machine is in the error state - and can never accept, 0 if the machine is in a non-accepting state that has a - path to a final state and 1 if the machine is in an accepting state. - -Accept routine eliminated. Determining whether or not the machine accepts is - done by examining the return value of the finish routine. - -In C output, fsm structure is no longer a typedef, so referencing requires - the struct keyword. This is to stay in line with C language conventions. - -In C++ output, constructor is no longer written by ragel. As a consequence, - init routine is not called automatically. Allows constructor to be supplied - by user as well as the return value of init to be examined without calling it - twice. - -Static start state and private structures are taken out of C++ classes. - -Ragel 1.5.4 - Jul 14, 2003 -========================== - -Workaround for building with bison 1.875, which produces an - optimization that doesn't build with newer version gcc. - -Ragel 1.5.3 - Jul 10, 2003 -========================== - -Fixed building with versions of flex that recognize YY_NO_UNPUT. - -Fixed version numbers in ragel.spec file. - -Ragel 1.5.2 - Jul 7, 2003 -========================= - -Transition actions and out actions displayed in the graphviz output. - -Transitions on negative numbers handled in graphviz output. - -Warning generated when using bison 1.875 now squashed. - -Ragel 1.5.1 - Jun 21, 2003 -========================== - -Bugs fixed: Don't delete the output objects when writing to standard out. - Copy mem into parser buffer with memcpy, not strcpy. Fixes buffer mem errror. - -Fixes for compiling with Sun WorkShop 6 compilers. - -Ragel 1.5.0 - Jun 10, 2003 -========================== - -Line directives written to the output so that errors in the action code - are properly reported in the ragel input file. - -Simple graphviz dot file output format is supported. Shows states and - transitions. Does not yet show actions. - -Options -p and -f dropped in favour of -d output format. - -Added option -M for specifying the machine to dump with -d or the graph to - generate with -V. - -Error recovery implemented. - -Proper line and column number tracking implemented in the scanner. - -All action/function code is now embedded in the main Execute routine. Avoids - duplication of action code in the Finish routine and the need to call - ExecFuncs which resulted in huge code bloat. Will also allow actions to - modify cs when fsm goto, call and return is supported in action code. - -Fsm spec can have no statements, nothing will be generated. - -Bug fix: Don't accept ] as the opening of a .-. range a reg exp. - -Regular expression or set ranges (ie /[0-9]/) are now handled by the parser - and consequently must be well-formed. The following now generates a parser - error: /[+-]/ and must be rewritten as /[+\-]/. Also fixes a bug whereby ] - might be accepted as the opening of a .-. range causing /[0-9]-[0-9]/ to - parse incorrectly. - -\v, \f, and \r are now treated as whitespace in an fsm spec. - -Ragel 1.4.1 - Nov 19, 2002 -========================== - -Compile fixes. The last release (integer alphabets) was so exciting - that usual portability checks got bypassed. - -Ragel 1.4.0 - Nov 19, 2002 -========================== - -Arbitrary integer alphabets are now fully supported! A new language - construct: - 'alphtype <type>' added for specifying the type of the alphabet. Default - is 'char'. Possible alphabet types are: - char, unsigned char, short, unsigned short, int, unsigned int - -Literal machines specified in decimal format can now be negative when the - alphabet is a signed type. - -Literal machines (strings, decimal and hex) have their values checked for - overflow/underflow against the size of the alphabet type. - -Table driven and goto driven output redesigned to support ranges. Table - driven uses a binary search for locating single characters and ranges. Goto - driven uses a switch statement for single characters and nested if blocks for - ranges. - -Switch driven output removed due to a lack of consistent advantages. Most of - the time the switch driven FSM is of no use because the goto FSM makes - smaller and faster code. Under certain circumstances it can produce smaller - code than a goto driven fsm and be almost as fast, but some sporadic case - does not warrant maintaining it. - -Many warnings changed to errors. - -Added option -p for printing the final fsm before minimization. This lets - priorities be seen. Priorties are all reset to 0 before minimization. The - exiting option -f prints the final fsm after minimization. - -Fixed a bug in the clang test and example that resulted in redundant actions - being executed. - -Ragel 1.3.4 - Nov 6, 2002 -========================= - -Fixes to Chapter 1 of the guide. - -Brought back the examples and made them current. - -MSVC is no longer supported for compiling windows binaries because its - support for the C++ standard is frustratingly inadequate, it will cost money - to upgrade if it ever gets better, and MinGW is a much better alternative. - -The build system now supports the --host= option for building ragel - for another system (used for cross compiling a windows binary with MinGW). - -Various design changes and fixes towards the goal of arbitrary integer - alphabets and the handling of larger state machines were made. - -The new shared vector class is now used for action lists in transitions and - states to reduce memory allocations. - -An avl tree is now used for the reduction of transitions and functions of an - fsm graph before making the final machine. The tree allows better scalability - and performance by not requiring consecutively larger heap allocations. - -Final stages in the separation of fsm graph code from action embedding and - priority assignment is complete. Makes the base graph leaner and easier to reuse - in other projects (like Keller). - -Ragel 1.3.3 - Oct 22, 2002 -========================== - -More diagrams were added to section 1.7.1 of the user guide. - -FSM Graph code was reworked to spearate the regex/nfa/minimizaion graph - algorithms from the manipulation of state and transition properties. - -An rpm spec file from Cris Bailiff was added. This allows an rpm for ragel - to be built with the command 'rpm -ta ragel-x.x.x.tar.gz' - -Fixes to the build system and corresponding doc updates in the README. - -Removed autil and included the one needed source file directly in the top - level ragel directory. - -Fixed a bug that nullified the 20 times speedup in large compilations - claimed by the last version. - -Removed awk from the doc build (it was added with the last release -- though - not mentioned in the changelog). - -Install of man page was moved to the doc dir. The install also installs the - user guide to $(PREFIX)/share/doc/ragel/ - -Ragel 1.3.2 - Oct 16, 2002 -========================== - -Added option -v (or --version) to show version information. - -The subtract operator no longer removes transition data from the machine - being subtracted. This is left up to the user for the purpose of making it - possible to transfer transitions using subtract and also for speeding up the - subtract routine. Note that it is possible to explicitly clear transition - data before a doing a subtract. - -Rather severe typo bug fixed. Bug was related to transitions with higher - priorities taking precedence. A wrong ptr was being returned. It appears to - have worked most of the time becuase the old ptr was deleted and the new one - allocated immediatly after so the old ptr often pointed to the same space. - Just luck though. - -Bug in the removing of dead end paths was fixed. If the start state - has in transitions then those paths were not followed when finding states to - keep. Would result in non-dead end states being removed from the graph. - -In lists and in ranges are no longer maintained as a bst with the key as the - alphabet character and the value as a list of transitions coming in on that - char. There is one list for each of inList, inRange and inDefault. Now that - the required functionality of the graph is well known it is safe to remove - these lists to gain in speed and footprint. They shouldn't be needed. - -IsolateStartState() runs on modification of start data only if the start - state is not already isolated, which is now possible with the new in list - representation. - -Concat, Or and Star operators now use an approximation to - removeUnreachableStates that does not require a traversal of the entire - graph. This combined with an 'on-the-fly' management of final bits and final - state status results is a dramatic speed increase when compiling machines - that use those operators heavily. The strings2 test goes 20 times faster. - -Before the final minimization, after all fsm operations are complete, - priority data is reset which enables better minimization in cases where - priorities would otherwise separate similar states. - -Ragel 1.3.1 - Oct 2, 2002 -========================= - -Range transitions are now used to implement machines made with /[a-z]/ and - the .. operator as well as most of the builtin machines. The ranges are not - yet reflected in the output code, they are expanded as if they came from the - regular single transitions. This is one step closer to arbitrary integer - output. - -The builtin machine 'any' was added. It is equiv to the builtin extend, - matching any characters. - -The builtin machine 'cntrl' now includes newline. - -The builtin machine 'space' now includes newline. - -The builtin machine 'ascii' is now the range 0-127, not all characters. - -A man page was written. - -A proper user guide was started. Chapter 1: Specifying Ragel Programs - was written. It even has some diagrams :) - -Ragel 1.3.0 - Sep 4, 2002 -========================= - -NULL keyword no longer used in table output. - -Though not yet in use, underlying graph structure changed to support range - transitions. As a result, most of the code that walks transition lists is now - implemented with an iterator that hides the complexity of the transition - lists and ranges. Range transitions will be used to implement /[a-z]/ style - machines and machines made with the .. operator. Previously a single - transition would be used for each char in the range, which is very costly. - Ranges eliminate much of the space complexity and allow for the .. operator - to be used with very large (integer) alphabets. - -New minimization similar to Hopcroft's alg. It does not require n^2 space and - runs close to O(n*log(n)) (an exact analysis of the alg is very hard). It is - much better than the stable and approx minimization and obsoletes them both. - An exact implementation of Hopcroft's alg is desirable but not possible - because the ragel implementation does not assume a finite alphabet, which - Hopcroft's requires. Ragel will support arbitrary integer alphabets which - must be treated as an infinite set for implementation considerations. - -New option -m using above described minimization to replace all previous - minimization options. Old options sill work but are obsolete and not - advertised with -h. - -Bug fixed in goto style output. The error exit set the current state to 0, - which is actually a valid state. If the machine was entered again it would go - into the first state, very wrong. If the first state happened to be final then - an immediate finish would accept when in fact it should fail. - -Slightly better fsm minimization now capable due to clearing of the - transition ordering numbers just prior to minimization. - -Ragel 1.2.2 - May 25, 2002 -========================== - -Configuration option --prefix now works when installing. - -cc file extension changed to cpp for better portability. - -Unlink of output file upon error no longer happens, removes dependency on - unlink system command. - -All multiline strings removed: not standard c++. - -Awk build dependency removed. - -MSVC 6.0 added to the list of supported compilers (with some tweaking of - bison and flex output). - -Ragel 1.2.1 - May 13, 2002 -========================== - -Automatic dependencies were fixed, they were not working correctly. - -Updated AUTHORS file to reflect contributors. - -Code is more C++ standards compliant: compiles with g++ 3.0 - -Fixed bugs that only showed up in g++ 3.0 - -Latest (unreleased) Aapl. - -Configuration script bails out if bison++ is installed. Ragel will not - compile with bison++ because it is coded in c++ and bison++ automatically - generates a c++ parser. Ragel uses a c-style bison parser. - -Ragel 1.2.0 - May 3, 2002 -========================= - -Underlying graph structure now supports default transitions. The result is - that a transition does not need to be made for each char of the alphabet - when making 'extend' or '/./' machines. Ragel compiles machines that - use the aforementioned primitives WAY faster. - -The ugly hacks needed to pick default transitions now go away due to - the graph supporting default transitions directly. - -If -e is given, but minimization is not turned on, print a warning. - -Makefiles use automatic dependencies. - -Ragel 1.1.0 - Apr 15, 2002 -========================== - -Added goto fsm: much faster than any other fsm style. - -Default operator (if two machines are side by side with no operator - between them) is concatenation. First showed up in 1.0.4. - -The fsm machine no longer auotmatically builds the flat table for - transition indicies. Instead it keeps the key,ptr pair. In tabcodegen - the flat table is produced. This way very large alphabets with sparse - transitions will not consume large amounts of mem. This is also in prep - for fsm graph getting a default transition. - -Generated code contains a statement explicitly stating that ragel fsms - are NOT covered by the GPL. Technically, Ragel copies part of itself - to the output to make the generic fsm execution routine (for table driven - fsms only) and so the output could be considered under the GPL. But this - code is very trivial and could easlily be rewritten. The actual fsm data - is subject to the copyright of the source. To promote the use of Ragel, - a special exception is made for the part of the output copied from Ragel: - it may be used without restriction. - -Much more elegant code generation scheme is employed. Code generation - class members need only put the 'codegen' keyword after their 'void' type - in order to be automatically registerd to handle macros of the same name. - An awk script recognises this keyword and generates an appropriate driver. - -Ragel gets a test suite. - -Postfunc and prefunc go away because they are not supported by non - loop-driven fsms (goto, switch) and present duplicate functionality. - Universal funcs can be implemented by using $ operator. - -Automatic dependencies used in build system, no more make depend target. - -Code generation section in docs. - -Uses the latests aapl. - -Ragel 1.0.5 - Mar 3, 2002 -========================= - -Bugfix in SetErrorState that caused an assertion failure when compiling - simple machines that did not have full transition tables (and thus did - not show up on any example machines). Assertion failure did not occur - when using the switch statement code as ragel does not call SetErrorState - in that case. - -Fixed some missing includes, now compiles on redhat. - -Moved the FsmMachTrans Compare class out of FsmMachTrans. Some compilers - don't deal with nested classes in templates too well. - -Removed old unused BASEREF in fsmgraph and ragel now compiles using - egcs-2.91.66 and presumably SUNWspro. The baseref is no longer needed - because states do not support being elements in multiple lists. I would - rather be able to support more compilers than have this feature. - -Started a README with compilation notes. Started an AUTHORS file. - -Started the user documentation. Describes basic machines and operators. - -Ragel 1.0.4 - Mar 1, 2002 -========================= - -Ported to the version of Aapl just after 2.2.0 release. See - http://www.ragel.ca/aapl/ for details on aapl. - -Fixed a bug in the clang example: the newline machine was not stared. - -Added explanations to the clang and mailbox examples. This should - help people that want to learn the lanuage as the manual is far from - complete. - -Ragel 1.0.3 - Feb 2, 2002 -========================= - -Added aapl to the ragel tree. No longer requires you to download - and build aapl separately. Should avoid discouraging impatient users - from compiling ragel. - -Added the examples to the ragel tree. - -Added configure script checks for bison and flex. - -Fixed makefile so as not to die with newer versions of bison that - write the header of the parser to a .hh file. - -Started ChangeLog file. - -Ragel 1.0.2 - Jan 30, 2002 -========================== - -Bug fix in calculating highIndex for table based code. Was using - the length of out tranisition table rather than the value at the - end. - -If high/low index are at the limits, output a define in their place, - not the high/low values themselves so as not to cause compiler warnings. - -If the resulting machines don't have any indicies or functions, then - omit the empty unrefereced static arrays so as not to cause compiler - warnings about unused static vars. - -Fixed variable sized indicies support. The header cannot have any - reference to INDEX_TYPE as that info is not known at the time the header - data is written. Forces us to use a void * for pointers to indicies. In - the c++ versions we are forced to make much of the data non-member - static data in the code portion for the same reason. - -Ragel 1.0.1 - Jan 28, 2002 -========================== - -Exe name change from reglang to ragel. - -Added ftabcodegen output code style which uses a table for states and - transitions but uses a switch statement for the function execution. - -Reformatted options in usage dump to look better. - -Support escape sequences in [] sections of regular expressions. - -Ragel 1.0 - Jan 25, 2002 -======================== - -Initial release. +Ragel 5.9 - Jul 19, 2006 +======================== + -Fixed a bug in the include system which caused malformed output from the + frontend when the include was made from a multi-line machine spec and the + included file ended in a single line spec (or vice versa). + -Static data is now const. + -Actions which referenced states but were not embedded caused the frontend to + segfault, now fixed. + -Manual now built with pdflatex. + -The manual was reorganized and expanded. Chapter sequence is now: + Introduction, Constructing Machines, Embedding Actions, Controlling + Nondeterminism and Interfacing to the Host program. + +Ragel 5.8 - Jun 17, 2006 +======================== + -The internal representation of the alphabet type has been encapsulated + into a class and all operations on it have been defined as C++ operators. + -The condition implementation now supports range transitions. This allows + conditions to be embedded into arbitrary machines. Conditions are still + exprimental. + -More condition embedding operators were added + 1. Isolate the start state and embed a condition into all transitions + leaving it: + >when cond OR >?cond + 2. Embed a condition into all transitions: + when cond OR $when cond OR $?cond + 3. Embed a condition into pending out transitions: + %when cond OR %?cond + -Improvements were made to the determinization process to support pending out + conditions. + -The Vim sytax file was fixed so that :> doesn't cause the match of a label. + -The test suite was converted to a single-file format which uses less disk + space than the old directory-per-test format. + +Ragel 5.7 - May 14, 2006 +======================== + -Conditions will not be embedded like actions because they involve a + manipulation of the state machine they are specified in. They have therefore + been taken out of the verbose action embedding form (using the <- compound + symbol). A new syntax for specifying conditions has been created: + m = '\n' when {i==4}; + -Fixed a bug which prevented state machine commands like fcurs, fcall, fret, + etc, from being accounted for in from-state actions and to-state actions. + This prevented some necessary support code from being generated. + -Implemented condition testing in remaining code generators. + -Configure script now checks for gperf, which is required for building. + -Added support for case-insensitive literal strings (in addition to regexes). + A case-insensitive string is made by appending an 'i' to the literal, as in + 'cmd'i or "cmd"i. + -Fixed a bug which caused all or expressions inside of all regular + expressions to be case-insensitive. For example /[fo]o bar/ would make the + [fo] part case-insensitive even though no 'i' was given following the + regular expression. + +Ragel 5.6 - Apr 1, 2006 +======================= + -Added a left-guarded concatenation operator. This operator <: is equivalent + to ( expr1 $1 . expr2 >0 ). It is useful if you want to prefix a sequence + with a sequence of a subset of the characters it matches. For example, one + can consume leading whitespace before tokenizing a sequence of whitespace + separated words: ( ' '* <: ( ' '+ | [a-z]+ )** ) + -Removed context embedding code, which has been dead since 5.0. + +Ragel 5.5 - Mar 28, 2006 +======================== + -Implemented a case-insensitive option for regular expressions: /get/i. + -If no input file is given to the ragel program it reads from standard input. + -The label of the start state has been changed from START to IN to save on + required screen space. + -Bug fix: \0 was not working in literal strings, due to a change that reduced + memory usage by concatenating components of literal strings. Token data + length is now passed from the scanner to the paser so that we do not need to + rely on null termination. + +Ragel 5.4 - Mar 12, 2006 +======================== + -Eliminated the default transition from the frontend implementation. This + default transition was a space-saving optimization that at best could reduce + the number of allocated transitions by one half. Unfortunately it + complicated the implementation and this stood in the way of introducing + conditionals. The default transition may be reintroduced in the future. + -Added entry-guarded concatenation. This operator :>, is syntactic sugar + for expr1 $0 . expr >1. This operator terminates the matching of the first + machine when a first character of the second machine is matched. For + example in any* . ';' we never leave the any* machine. If we use any* :> ';' + then the any* machine is terminiated upon matching the semi-colon. + -Added finish-guarded concatenation. This operator :>>, is syntactic sugar + for expr1 $0 . expr @1. This operator is like entry guarded concatenation + except the first machine is terminated when the second machine enters a + final state. This is useful for delaying the guard until a full pattern is + matched. For example as in '/*' any* :>> '*/'. + -Added strong subtraction. Where regular subtraction removes from the first + machine any strings that are matched by the second machine, strong + subtraction removes any strings from the first that contain any strings of + the second as a substring. Strong subtraction is syntactic sugar for + expr1 - ( any* expr2 any* ). + -Eliminated the use of priorities from the examples. Replaced with + subtraction, guarded concatenation and longest-match kleene star. + -Did some initial work on supporting conditional transitions. Far from + complete and very buggy. This code will only be active when conditionals are + used. + +Ragel 5.3 - Jan 27, 2006 +======================== + -Added missing semi-colons that cause the build to fail when using older + versions of Bison. + -Fix for D code: if the contents of an fexec is a single word, the generated + code will get interpreted as a C-style cast. Adding two brackets prevents + this. Can now turn eliminate the "access this.;" in cppscan5 that was used to + get around this problem. + -Improved some of the tag names in the intermediate format. + -Added unsigned long to the list of supported alphabet types. + -Added ids of actions and action lists to XML intermediate format. Makes it + more human readable. + -Updated to latest Aapl package. + +Ragel 5.2 - Jan 6, 2006 +======================== + -Ragel emits an error if the target of fentry, fcall, fgoto or fnext is inside + a longest match operator, or if an action embedding in a longest match + machine uses fcall. The fcall command can still be used in pattern actions. + -Made improvements to the clang, rlscan, awkemu and cppscan examples. + -Some fixes to generated label names: they should all be prefixed with _. + -A fix to the Vim syntax highlighting script was made + -Many fixes and updates to the documentation. All important features and + concepts are now documented. A second chapter describing Ragel's use + was added. + +Ragel 5.1 - Dec 22, 2005 +======================== + -Fixes to the matching of section delimiters in Vim syntax file. + -If there is a longest match machine, the tokend var is now initialized by + write init. This is not necessary for correct functionality, however + prevents compiler warnings. + -The rlscan example was ported to the longest match operator and changed to + emit XML data. + -Fix to the error handling in the frontend: if there are errors in the lookup + of names at machine generation time then do not emit anything. + -If not compiling the full machine in the frontend (by using -M), avoid + errors and segfaults caused by names that are not part of the compiled + machine. + -Longest match bug fix: need to init tokstart when returing from fsm calls + that are inside longest match actions. + -In Graphviz drawing, the arrow into the start state is not a real + transition, do not draw to-state actions on the label. + -A bug fix to the handling of non-tag data within an XML tag was made. + -Backend exit value fixed: since the parser now accepts nothing so as to + avoid a redundant parse error when the frontend dies, we must force an + error. The backend should now be properly reporting errors. + -The longest match machine now has it's start state set final. An LM machine + is in a final state when it has not matched anything, when it has matched + and accepted a token and is ready for another, and when it has matched a + token but is waiting for some lookahead before determining what to do about + it (similar to kleene star). + -Element statement removed from some tests. + -Entry point names are propagated to the backend and used to label the entry + point arrows in Graphviz output. + +Ragel 5.0 - Dec 17, 2005 +======================== + (additional details in V5 release notes) + -Ragel has been split into two executables: A frontend which compiles + machines and emits them in an XML format, and a backend which generates code + or a Graphviz dot file from the XML input. The purpose of this split is to + allow Ragel to interface with other tools by means of the XML intermediate + format and to reduce complexity by strictly separating the previously + entangled phases. The intermediate format will provide a better platform + inspecting compiled machines and for extending Ragel to support other host + languages. + -The host language interface has been reduced significantly. Ragel no longer + expects the machine to be implemented as a structure or class and does not + generate functions corresponding to initialization, execution and EOF. + Instead, Ragel just generates the code of these components, allowing all of + them to be placed in a single function if desired. The user specifies a + machine in the usual manner, then indicates at which place in the program + text the state machine code is to be generated. This is done using the write + statement. It is possible to specify to Ragel how it should access the + variables it needs (such as the current state) using the access statement. + -The host language embedding delimiters have been changed. Single line + machines start with '%%' and end at newline. Multiline machines start with + '%%{' and end with '}%%'. The machine name is given with the machine + statement at the very beginning of the specification. This purpose of this + change is to make it easier separate Ragel code from the host language. This + will ease the addition of supported host languages. + -The structure and class parsing which was previously able to extract a + machine's name has been removed since this feature is dependent on the host + language and inhibits the move towards a more language-independent frontend. + -The init, element and interface statements have been made obsolete by the + new host language interface and have been removed. + -The fexec action statement has been changed to take only the new position to + move to. This statement is more useful for moving backwards and reparsing + input than for specifying a whole new buffer entirely and has been shifted + to this new use. Giving it only one argument also simplifies the parsing of + host code embedded in a Ragel specification. This will ease the addition of + supported host languages. + -Introduced the fbreak statement, which allows one to stop processing data + immediately. The machine ends up in the state that the current transition + was to go to. The current character is not changed. + -Introduced the noend option for writing the execute code. This inhibits + checking if we have reached pe. The machine will run until it goes into the + error state or fbreak is hit. This allows one to parse null-terminate + strings without first computing the length. + -The execute code now breaks out of the processing loop when it moves into + the error state. Previously it would run until pe was hit. Breaking out + makes the noend option useful when an error is encountered and allows + user code to determine where in the input the error occured. It also + eliminates needlessly iterating the input buffer. + -Introduced the noerror, nofinal and noprefix options for writing the machine + data. The first two inhibit the writing of the error state and the + first-final state should they not be needed. The noprefix eliminates the + prefixing of the data items with the machine name. + -Support for the D language has been added. This is specified in the backend + with the -D switch. + -Since the new host language interface has been reduced considerably, Ragel + no longer needs to distinguish between C-based languages. Support for C, C++ + and Objective-C has been folded into one option in the backend: -C + -The code generator has been made independent of the languages that it + supports by pushing the language dependent apsects down into the lower + levels of the code generator. + -Many improvements to the longest match construction were made. It is no + longer considered experimental. A longest match machine must appear at the + top level of a machine instantiation. Since it does not generate a pure + state machine (it may need to backtrack), it cannot be used as an operand to + other operators. + -References to the current character and current state are now completely + banned in EOF actions. + +Ragel 4.2 - Sep 16, 2005 +======================== + (additional details in V4 release notes) + -Fixed a bug in the longest match operator. In some states it's possible that + we either match a token or match nothing at all. In these states we need to + consult the LmSwitch on error so it must be prepared to execute an error + handler. We therefore need to init act to this error value (which is zero). + We can compute if we need to do this and the code generator emits the + initialization only if necessary. + -Changed the definition of the token end of longest match actions. It now + points to one past the last token. This makes computing the token length + easier because you don't have to add one. The longest match variables token + start, action identifier and token end are now properly initialized in + generated code. They don't need to be initialized in the user's code. + -Implemented to-state and from-state actions. These actions are executed on + transitions into the state (after the in transition's actions) and on + transitions out of the state (before the out transition's actions). See V4 + release notes for more information. + -Since there are no longer any action embedding operators that embed both on + transitions and on EOF, any actions that exist in both places will be there + because the user has explicitly done so. Presuming this case is rare, and + with code duplication in the hands of the user, we therefore give the EOF + actions their own action switch in the finish() function. This is further + motivated by the fact that the best solution is to do the same for to-state + and from-state actions in the main loop. + -Longest match actions can now be specified using a named action. Since a + word following a longest match item conflicts with the concatenation of a + named machine, the => symbol must come immediately before a named action. + -The longest match operator permits action and machine definitions in the + middle of a longest match construction. These are parsed as if they came + before the machine definition they are contained in. Permitting action and + machine definitions in a longest match construction allows objects to be + defined closer to their use. + -The longest match operator can now handle longest match items with no + action, where previously Ragel segfaulted. + -Updated to Aapl post 2.12. + -Fixed a bug in epsilon transition name lookups. After doing a name lookup + the result was stored in the parse tree. This is wrong because if a machine + is used more than once, each time it may resolve to different targets, + however it will be stored in the same place. We now store name resolutions + in a separated data structure so that each walk of a parse tree uses the + name resolved during the corresponding walk in the name lookup pass. + -The operators used to embed context and actions into states have been + modified. The V4 release notes contain the full details. + -Added zlen builtin machine to represent the zero length machine. Eventually + the name "null" will be phased out in favour of zlen because it is unclear + whether null matches the zero length string or if it does not match any + string at all (as does the empty builtin). + -Added verbose versions of action, context and priority embedding. See the V4 + release notes for the full details. A small example: + machine <- all exec { foo(); } <- final eof act1 + -Bugfix for machines with epsilon ops, but no join operations. I had + wrongfully assumed that because epsilon ops can only increase connectivity, + that no states are ever merged and therefore a call to fillInStates() is not + necessary. In reality, epsilon transitions within one machine can induce the + merging of states. In the following, state 2 follows two paths on 'i': + main := 'h' -> i 'i h' i: 'i'; + -Changed the license of the guide from a custom "do not propagate modified + versions of this document" license to the GPL. + +Ragel 4.1 - Jun 26, 2005 +======================== + (additional details in V4 release notes) + -A bug in include processing was fixed. Surrounding code in an include file + was being passed through to the output when it should be ignored. Includes + are only for including portions of another machine into he current. This + went unnoticed because all tested includes were wrapped in #ifndef ... + #endif directives and so did not affect the compilation of the file making + the include. + -Fixes were made to Vim syntax highlighting file. + -Duplicate actions are now removed from action lists. + -The character-level negation operator ^ was added. This operator produces a + machine that matches single characters that are not matched by the machine + it is applied to. This unary prefix operator has the same precedence level + as !. + -The use of + to specify the a positive literal number was discontinued. + -The parser now assigns the subtraction operator a higher precedence than + the negation of literal number. + +Ragel 4.0 - May 26, 2005 +======================== + (additional details in V4 release notes) + -Operators now strictly embed into a machine either on a specific class of + characters or on EOF, but never both. This gives a cleaner association + between the operators and the physical state machine entitites they operate + on. This change is made up of several parts: + 1. '%' operator embeds only into leaving characters. + 2. All global and local error operators only embed on error character + transitions, their action will not be triggerend on EOF in non-final + states. + 3. EOF action embedding operators have been added for all classes of states + to make up for functionality removed from other operators. These are + >/ $/ @/ %/. + 4. Start transition operator '>' no longer implicitly embeds into leaving + transtions when start state is final. + -Ragel now emits warnings about the improper use of statements and values in + action code that is embedded as an EOF action. Warnings are emitted for fpc, + fc, fexec, fbuf and fblen. + -Added a longest match construction operator |* machine opt-action; ... *|. + This is for repetition where an ability to revert to a shorter, previously + matched item is required. This is the same behaviour as flex and re2c. The + longest match operator is not a pure FSM construction, it introduces + transitions that implicitly hold the current character or reset execution to + a previous location in the input. Use of this operator requires the caller + of the machine to occasionally hold onto data after a call to the exectute + routine. Use of machines generated with this operator as the input to other + operators may have undefined results. See examples/cppscan for an example. + This is very experimental code. + -Action ids are only assigned to actions that are referenced in the final + constructed machine, preventing gaps in the action id sequence. Previously + an action id was assigned if the action was referenced during parsing. + -Machine specifications now begin with %% and are followed with an optional + name and either a single Ragel statement or a sequence of statements + enclosed in {}. + -Ragel no longer generates the FSM's structure or class. It is up to the user + to declare the structure and to give it a variable named curs of type + integer. If the machine uses the call stack the user must also declare a + array of integers named stack and an integer variable named top. + -In the case of Objective-C, Ragel no longer generates the interface or + implementation directives, allowing the user to declare additional methods. + -If a machine specification does not have a name then Ragel tries to find a + name for it by first checking if the specification is inside a struct, class + or interface. If it is not then it uses the name of the previous machine + specification. If still no name is found then this is an error. + -Fsm specifications now persist in memory and statements accumulate. + -Ragel now has an include statement for including the statements of a machine + spec in another file (perhaps because it is the corresponding header file). + The include statement can also be used to draw in the statements of another + fsm spec in the current file. + -The fstack statement is now obsolete and has been removed. + -A new statement, simply 'interface;', indicates that ragel should generate + the machine's interface. If Ragel sees the main machine it generates the + code sections of the machine. Previously, the header portion was generated + if the (now removed) struct statement was found and code was generated if + any machine definition was found. + -Fixed a bug in the resolution of fsm name references in actions. The name + resolution code did not recurse into inline code items with children + (fgoto*, fcall*, fnext*, and fexec), causing a segfault at code generation + time. + -Cleaned up the code generators. FsmCodeGen was made into a virtual base + class allowing for the language/output-style specific classes to inherit + both a language specific and style-specific base class while retaining only + one copy of FsmCodeGen. Language specific output can now be moved into the + language specific code generators, requiring less duplication of code in the + language/output-style specific leaf classes. + -Fixed bugs in fcall* implementation of IpgGoto code generation. + -If the element type has not been defined Ragel now uses a constant version + of the alphtype, not the exact alphtype. In most cases the data pointer of + the execute routine should be const. A non-const element type can still be + defined with the element statement. + -The fc special value now uses getkey for retrieving the current char rather + than *_p, which is wrong if the element type is a structure. + -User guide converted to TeX and updated for new 4.0 syntax and semantics. + +Ragel 3.7 - Oct 31, 2004 +======================== + -Bug fix: unreferenced machine instantiations causing segfault due to name + tree and parse tree walk becomming out of syncronization. + -Rewrote representation of inline code blocks using a tree data structure. + This allows special keywords such as fbuf to be used as the operatands of + other fsm commands. + -Documentation updates. + -When deciding whether or not to generate machine instantiations, search the + entire name tree beneath the instantiation for references, not just the + root. + -Removed stray ';' in keller2.rl + -Added fexec for restarting the machine with new buffer data (state stays the + same), fbuf for retrieving the the start of the buf, and fblen for + retrieving the orig buffer length. + -Implemented test/cppscan2 using fexec. This allows token emitting and restart + to stay inside the execute routine, instead of leaving and re-entering on + every token. + -Changed examples/cppscan to use fexec and thereby go much faster. + -Implemented flex and re2c versions of examples/cppscan. Ragel version + goes faster than flex version but not as fast as re2c version. + -Merged in Objective-C patch from Erich Ocean. + -Turned off syncing with stdio in C++ tests to make them go faster. + -Renamed C++ code generaion classes with the Cpp Prefix instead of CC to make + them easier to read. + -In the finish function emit fbuf as 0 cast to a pointer to the element type + so it's type is not interpreted as an integer. + -The number -128 underflows char alphabets on some architectures. Removed + uses of it in tests. + -Disabled the keller2 test because it causes problems on many architectures + due to its large size and compilation requirements. + +Ragel 3.6 - Jul 10, 2004 +======================== + -Many documentation updates. + -When resolving names, return a set of values so that a reference in an + action block that is embedded more than once won't report distinct entry + points that are actually the same. + -Implemented flat tables. Stores a linear array of indicies into the + transition array and only a low and high key value. Faster than binary + searching for keys but not usable for large alphabets. + -Fixed bug in deleting of transitions leftover from converstion from bst to + list implementation of transitions. Other code cleanup. + -In table based output calculate the cost of using an index. Don't use if + cheaper. + -Changed fstate() value available in init and action code to to fentry() to + reflect the fact that the values returned are intended to be used as targets + in fgoto, fnext and fcall statements. The returned state is not a unique + state representing the label. There can be any number of states representing + a label. + -Added keller2 test, C++ scanning tests and C++ scanning example. + -In table based output split up transitions into targets and actions. This + allows actions to be omitted. + -Broke the components of the state array into separate arrays. Requires + adding some fields where they could previously be omitted, however allows + finer grained control over the sizes of items and an overal size reduction. + Also means that state numbers are not an offset into the state array but + instead a sequence of numbers, meaning the context array does not have any + wasted bits. + -Action lists and transition also have their types chosen to be the smallest + possible for accomodating the contained values. + -Changed curs state stored in fsm struct from _cs to curs. Keep fsm->curs == + -1 while in machine. Added tests curs1 and curs2. + -Implemented the notion of context. Context can be embedded in states using + >:, $:, @: and %: operators. These embed a named context into start states, + all states, non-start/non-final and final states. If the context is declared + using a context statment + context name; + then the context can be quered for any state using fsm_name_ctx_name(state) + in C code and fsm_name::ctx_name(state) in C++ code. This feature makes it + possible to determine what "part" of the machine is currently active. + -Fixed crash on machine generation of graphs with no final state. If there + is no reference to a final state in a join operation, don't generate one. + -Updated Vim sytax: added labels to inline code, added various C++ keywords. + Don't highlight name separations as labels. Added switch labels, improved + alphtype, element and getkey. + -Fixed line info in error reporting of bad epsilon trans. + -Fixed fstate() for tab code gen. + -Removed references to malloc.h. + +Ragel 3.5 - May 29, 2004 +======================== + -When parse errors occur, the partially generated output file is deleted and + an non-zero exit status is returned. + -Updated Vim syntax file. + -Implemented the setting of the element type that is passed to the execute + routine as well as method for specifying how ragel should retrive the key + from the element type. This lets ragel process arbitrary structures inside + of which is the key that is parsed. + element struct Element; + getkey fpc->character; + -The current state is now implemented with an int across all machines. This + simplifies working with current state variables. For example this allows a + call stack to be implemented in user code. + -Implemented a method for retrieving the current state, the target state, and + any named states. + fcurs -retrieve the current state + ftargs -retrieve the target state + fstate(name) -retrieve a named state. + -Implemented a mechanism for jumping to and calling to a state stored in a + variable. + fgoto *<expr>; -goto the state returned by the C/C++ expression. + fcall *<expr>; -call the state returned by the C/C++ expression. + -Implemented a mechanism for specifying the next state without immediately + transfering control there (any code following statement is executed). + fnext label; -set the state pointed to by label as the next state. + fnext *<expr>; -set the state returned by the C/C++ expression as the + next. + -Action references are determined from the final machine instead of during + the parse tree walk. Some actions can be referenced in the parse tree but not + show up in the final machine. Machine analysis is now done based on this new + computation. + -Named state lookup now employs a breadth-first search in the lookup and + allows the user to fully qualify names, making it possible to specify + jumps/calls into parts of the machine deep in the name hierarchy. Each part + of name (separated by ::) employs a breadth first search from it's starting + point. + -Name references now must always refer to a single state. Since references to + multiple states is not normally intended, it no longer happens + automatically. This frees the programmer from thinking about whether or not + a state reference is unique. It also avoids the added complexity of + determining when to merge the targets of multiple references. The effect of + references to multiple states can be explicitly created using the join + operator and epsilon transitions. + -M option was split into -S and -M. -S specifies the machine spec to generate + for graphviz output and dumping. -M specifies the machine definition or + instantiation. + -Machine function parameters are now prefixed with and underscore to + avoid the hiding of class members. + +Ragel 3.4 - May 8, 2004 +======================= + -Added the longest match kleene star operator **, which is synonymous + with ( ( <machine> ) $0 %1 ) *. + -Epsilon operators distinguish between leaving transitions (going to an + another expression in a comma separated list) and non-leaving transitions. + Leaving actions and priorities are appropriately transferred. + -Relative priority of following ops changed to: + 1. Action/Priority + 2. Epsilon + 3. Label + If label is done first then the isolation of the start state in > operators + will cause the label to point to the old start state that doesn't have the + new action/priority. + -Merged >! and >~, @! and @~, %! and %~, and $! and $~ operators to have one + set of global error action operators (>!, @!, %! and $!) that are invoked on + error by unexpected characters as well as by unexepected EOF. + -Added the fpc keyword for use in action code. This is a pointer to the + current character. *fpc == fc. If an action is invoked on EOF then fpc == 0. + -Added >^, @^, %^, and $^ local error operators. Global error operators (>!, + @!, $!, and %!) cause actions to be invoked if the final machine fails. + Local error actions cause actions to be invoked if if the current machine + fails. + -Changed error operators to mean embed global/local error actions in: + >! and !^ -the start state. + @! and @^ -states that are not the start state and are not final. + %! and %^ -final states. + $! and $^ -all states. + -Added >@! which is synonymous >! then @! + -Added >@^ which is synonymous >^ then @^ + -Added @%! which is synonymous @! then %! + -Added @%^ which is synonymous >^ then @^ + -FsmGraph representation of transition lists was changed from a mapping of + alphabet key -> transition objects using a BST to simply a list of + transition objects. Since the transitions are no longer divided by + single/range, the fast finding of transition objects by key is no longer + required functionality and can be eliminated. This new implementation uses + the same amount of memory however causes less allocations. It also make more + sense for supporting error transitions with actions. Previously an error + transition was represented by a null value in the BST. + -Regular expression ranges are checked to ensure that lower <= upper. + -Added printf-like example. + -Added atoi2, erract2, and gotcallret to the test suite. + -Improved build test to support make -jN and simplified the compiling and + running of tests. + +Ragel 3.3 - Mar 7, 2004 +======================= + -Portability bug fixes were made. Minimum and maximum integer values are + now taken from the system. An alignment problem on 64bit systems + was fixed. + +Ragel 3.2 - Feb 28, 2004 +======================== + -Added a Vim syntax file. + -Eliminated length var from generated execute code in favour of an end + pointer. Using length requires two variables be read and written. Using an + end pointer requires one variable read and written and one read. Results in + more optimizable code. + -Minimization is now on by default. + -States are ordered in output by depth first search. + -Bug in minimization fixed. States were not being distinguished based on + error actions. + -Added null and empty builtin machines. + -Added EOF error action operators. These are >~, >@, $~, and %~. EOF error + operators embed actions to take if the EOF is seen and interpreted as an + error. The operators correspond to the following states: + -the start state + -any state with a transition to a final state + -any state with a transiion out + -a final state + -Fixed bug in generation of unreference machine vars using -M. Unreferenced + vars don't have a name tree built underneath when starting from + instantiations. Need to instead build the name tree starting at the var. + -Calls, returns, holds and references to fc in out action code are now + handled for ipgoto output. + -Only actions referenced by an instantiated machine expression are put into + the action index and written out. + -Added rlscan, an example that lexes Ragel input. + +Ragel 3.1 - Feb 18, 2004 +======================== + -Duplicates in OR literals are removed and no longer cause an assertion + failure. + -Duplicate entry points used in goto and call statements are made into + deterministic entry points. + -Base FsmGraph code moved from aapl into ragel, as an increasing amount + of specialization is required. Too much time was spent attempting to + keep it as a general purpose template. + -FsmGraph code de-templatized and heirarchy squashed to a single class. + -Single transitions taken out of FsmGraph code. In the machine construction + stage, transitions are now implemented only with ranges and default + transtions. This reduces memory consumption, simplifies code and prevents + covered transitions. However it requires the automated selection of single + transitions to keep goto-driven code lean. + -Machine reduction completely rewritten to be in-place. As duplicate + transitions and actions are found and the machine is converted to a format + suitable for writing as C code or as GraphViz input, the memory allocated + for states and transitions is reused, instead of newly allocated. + -New reduction code consolodates ranges, selects a default transition, and + selects single transitions with the goal of joining ranges that are split by + any number of single characters. + -Line directive changed from "# <num> <file>" to the more common format + "#line <num> <file>". + -Operator :! changed to @!. This should have happened in last release. + -Added params example. + +Ragel 3.0 - Jan 22, 2004 +======================== + -Ragel now parses the contents of struct statements and action code. + -The keyword fc replaces the use of *p to reference the current character in + action code. + -Machine instantiations other than main are allowed. + -Call, jump and return statements are now available in action code. This + facility makes it possible to jump to an error handling machine, call a + sub-machine for parsing a field or to follow paths through a machine as + determined by arbitrary C code. + -Added labels to the language. Labels can be used anywhere in a machine + expression to define an entry point. Also references to machine definitions + cause the implicit creation of a label. + -Added epsilon transitions to the language. Epsilon operators may reference + labels in the current name scope resolved when join operators are evaluated + and at the root of the expression tree of machine assignment/instantiation. + -Added the comma operator, which joins machines together without drawing any + transitions between them. This operator is useful in combination with + labels, the epsilon operator and user code transitions for defining machines + using the named state and transition list paradigm. It is also useful for + invoking transitions based on some analysis of the input or on the + environment. + -Added >!, :!, $!, %! operators for specifying actions to take should the + machine fail. These operators embed actions to execute if the machine + fails in + -the start state + -any state with a transition to a final state + -any state with a transiion out + -a final state + The general rule is that if an action embedding operator embeds an action + into a set of transitions T, then the error-counterpart with a ! embeds an + action into the error transition taken when any transition T is a candidate, + but does not match the input. + -The finishing augmentation operator ':' has been changed to '@'. This + frees the ':' symbol for machine labels and avoids hacks to the parser to + allow the use of ':' for both labels and finishing augmentations. The best + hack required that label names be distinct from machine definition names as + in main := word : word; This restriction is not good because labels are + local to the machine that they are used in whereas machine names are global + entities. Label name choices should not be restricted by the set of names + that are in use for machines. + -Named priority syntax now requires parenthesis surrounding the name and + value pair. This avoids grammar ambiguities now that the ',' operator has + been introduced and makes it more clear that the name and value are an + asscociated pair. + -Backslashes are escaped in line directive paths. + +Ragel 2.2 - Oct 6, 2003 +======================= + -Added {n}, {,n}, {n,} {n,m} repetition operators. + <expr> {n} -- exactly n repetitions + <expr> {,n} -- zero to n repetitions + <expr> {n,} -- n or more repetitions + <expr> {n,m} -- n to m repetitions + -Bug in binary search table in Aapl fixed. Fixes crashing on machines that + add to action tables that are implicitly shared among transitions. + -Tests using obsolete minimization algorithms are no longer built and run by + default. + -Added atoi and concurrent from examples to the test suite. + +Ragel 2.1 - Sep 22, 2003 +======================== + -Bug in priority comparison code fixed. Segfaulted on some input with many + embedded priorities. + -Added two new examples. + +Ragel 2.0 - Sep 7, 2003 +======================= + -Optional (?), One or More (+) and Kleene Star (*) operators changed from + prefix to postfix. Rationale is that postfix version is far more common in + regular expression implementations and will be more readily understood. + -All priority values attached to transitions are now accompanied by a name. + Transitions no longer have default priority values of zero assigned + to them. Only transitions that have different priority values assigned + to the same name influence the NFA-DFA conversion. This scheme reduces + side-effects of priorities. + -Removed the %! statement for unsetting pending out priorities. With + named priorities, it is not necessary to clear the priorities of a + machine with $0 %! because non-colliding names can be used to avoid + side-effects. + -Removed the clear keyword, which was for removing actions from a machine. + Not required functionality and it is non-intuitive to have a language + feature that undoes previous definitions. + -Removed the ^ modifier to repetition and concatenation operators. This + undocumented feature prevented out transitions and out priorities from being + transfered from final states to transitions leaving machines. Not required + functionality and complicates the language unnecessarily. + -Keyword 'func' changed to 'action' as a part of the phasing out of the term + 'function' in favour of 'action'. Rationale is that the term 'function' + implies that the code is called like a C function, which is not necessarily + the case. The term 'action' is far more common in state machine compiler + implementations. + -Added the instantiation statement, which looks like a standard variable + assignment except := is used instead of =. Instantiations go into the + same graph dictionary as definitions. In the the future, instantiations + will be used as the target for gotos and calls in action code. + -The main graph should now be explicitly instantiated. If it is not, + a warning is issued. + -Or literal basic machines ([] outside of regular expressions) now support + negation and ranges. + -C and C++ interfaces lowercased. In the C interface an underscore now + separates the fsm machine and the function name. Rationale is that lowercased + library and generated routines are more common. + C output: + int fsm_init( struct clang *fsm ); + int fsm_execute( struct clang *fsm, char *data, int dlen ); + int fsm_finish( struct clang *fsm ); + C++ output: + int fsm::init( ); + int fsm::execute( char *data, int dlen ); + int fsm::finish( ); + -Init, execute and finish all return -1 if the machine is in the error state + and can never accept, 0 if the machine is in a non-accepting state that has a + path to a final state and 1 if the machine is in an accepting state. + -Accept routine eliminated. Determining whether or not the machine accepts is + done by examining the return value of the finish routine. + -In C output, fsm structure is no longer a typedef, so referencing requires + the struct keyword. This is to stay in line with C language conventions. + -In C++ output, constructor is no longer written by ragel. As a consequence, + init routine is not called automatically. Allows constructor to be supplied + by user as well as the return value of init to be examined without calling it + twice. + -Static start state and private structures are taken out of C++ classes. + +Ragel 1.5.4 - Jul 14, 2003 +========================== + -Workaround for building with bison 1.875, which produces an + optimization that doesn't build with newer version gcc. + +Ragel 1.5.3 - Jul 10, 2003 +========================== + -Fixed building with versions of flex that recognize YY_NO_UNPUT. + -Fixed version numbers in ragel.spec file. + +Ragel 1.5.2 - Jul 7, 2003 +========================= + -Transition actions and out actions displayed in the graphviz output. + -Transitions on negative numbers handled in graphviz output. + -Warning generated when using bison 1.875 now squashed. + +Ragel 1.5.1 - Jun 21, 2003 +========================== + -Bugs fixed: Don't delete the output objects when writing to standard out. + Copy mem into parser buffer with memcpy, not strcpy. Fixes buffer mem errror. + -Fixes for compiling with Sun WorkShop 6 compilers. + +Ragel 1.5.0 - Jun 10, 2003 +========================== + -Line directives written to the output so that errors in the action code + are properly reported in the ragel input file. + -Simple graphviz dot file output format is supported. Shows states and + transitions. Does not yet show actions. + -Options -p and -f dropped in favour of -d output format. + -Added option -M for specifying the machine to dump with -d or the graph to + generate with -V. + -Error recovery implemented. + -Proper line and column number tracking implemented in the scanner. + -All action/function code is now embedded in the main Execute routine. Avoids + duplication of action code in the Finish routine and the need to call + ExecFuncs which resulted in huge code bloat. Will also allow actions to + modify cs when fsm goto, call and return is supported in action code. + -Fsm spec can have no statements, nothing will be generated. + -Bug fix: Don't accept ] as the opening of a .-. range a reg exp. + -Regular expression or set ranges (ie /[0-9]/) are now handled by the parser + and consequently must be well-formed. The following now generates a parser + error: /[+-]/ and must be rewritten as /[+\-]/. Also fixes a bug whereby ] + might be accepted as the opening of a .-. range causing /[0-9]-[0-9]/ to + parse incorrectly. + -\v, \f, and \r are now treated as whitespace in an fsm spec. + +Ragel 1.4.1 - Nov 19, 2002 +========================== + -Compile fixes. The last release (integer alphabets) was so exciting + that usual portability checks got bypassed. + +Ragel 1.4.0 - Nov 19, 2002 +========================== + -Arbitrary integer alphabets are now fully supported! A new language + construct: + 'alphtype <type>' added for specifying the type of the alphabet. Default + is 'char'. Possible alphabet types are: + char, unsigned char, short, unsigned short, int, unsigned int + -Literal machines specified in decimal format can now be negative when the + alphabet is a signed type. + -Literal machines (strings, decimal and hex) have their values checked for + overflow/underflow against the size of the alphabet type. + -Table driven and goto driven output redesigned to support ranges. Table + driven uses a binary search for locating single characters and ranges. Goto + driven uses a switch statement for single characters and nested if blocks for + ranges. + -Switch driven output removed due to a lack of consistent advantages. Most of + the time the switch driven FSM is of no use because the goto FSM makes + smaller and faster code. Under certain circumstances it can produce smaller + code than a goto driven fsm and be almost as fast, but some sporadic case + does not warrant maintaining it. + -Many warnings changed to errors. + -Added option -p for printing the final fsm before minimization. This lets + priorities be seen. Priorties are all reset to 0 before minimization. The + exiting option -f prints the final fsm after minimization. + -Fixed a bug in the clang test and example that resulted in redundant actions + being executed. + +Ragel 1.3.4 - Nov 6, 2002 +========================= + -Fixes to Chapter 1 of the guide. + -Brought back the examples and made them current. + -MSVC is no longer supported for compiling windows binaries because its + support for the C++ standard is frustratingly inadequate, it will cost money + to upgrade if it ever gets better, and MinGW is a much better alternative. + -The build system now supports the --host= option for building ragel + for another system (used for cross compiling a windows binary with MinGW). + -Various design changes and fixes towards the goal of arbitrary integer + alphabets and the handling of larger state machines were made. + -The new shared vector class is now used for action lists in transitions and + states to reduce memory allocations. + -An avl tree is now used for the reduction of transitions and functions of an + fsm graph before making the final machine. The tree allows better scalability + and performance by not requiring consecutively larger heap allocations. + -Final stages in the separation of fsm graph code from action embedding and + priority assignment is complete. Makes the base graph leaner and easier to reuse + in other projects (like Keller). + +Ragel 1.3.3 - Oct 22, 2002 +========================== + -More diagrams were added to section 1.7.1 of the user guide. + -FSM Graph code was reworked to spearate the regex/nfa/minimizaion graph + algorithms from the manipulation of state and transition properties. + -An rpm spec file from Cris Bailiff was added. This allows an rpm for ragel + to be built with the command 'rpm -ta ragel-x.x.x.tar.gz' + -Fixes to the build system and corresponding doc updates in the README. + -Removed autil and included the one needed source file directly in the top + level ragel directory. + -Fixed a bug that nullified the 20 times speedup in large compilations + claimed by the last version. + -Removed awk from the doc build (it was added with the last release -- though + not mentioned in the changelog). + -Install of man page was moved to the doc dir. The install also installs the + user guide to $(PREFIX)/share/doc/ragel/ + +Ragel 1.3.2 - Oct 16, 2002 +========================== + -Added option -v (or --version) to show version information. + -The subtract operator no longer removes transition data from the machine + being subtracted. This is left up to the user for the purpose of making it + possible to transfer transitions using subtract and also for speeding up the + subtract routine. Note that it is possible to explicitly clear transition + data before a doing a subtract. + -Rather severe typo bug fixed. Bug was related to transitions with higher + priorities taking precedence. A wrong ptr was being returned. It appears to + have worked most of the time becuase the old ptr was deleted and the new one + allocated immediatly after so the old ptr often pointed to the same space. + Just luck though. + -Bug in the removing of dead end paths was fixed. If the start state + has in transitions then those paths were not followed when finding states to + keep. Would result in non-dead end states being removed from the graph. + -In lists and in ranges are no longer maintained as a bst with the key as the + alphabet character and the value as a list of transitions coming in on that + char. There is one list for each of inList, inRange and inDefault. Now that + the required functionality of the graph is well known it is safe to remove + these lists to gain in speed and footprint. They shouldn't be needed. + -IsolateStartState() runs on modification of start data only if the start + state is not already isolated, which is now possible with the new in list + representation. + -Concat, Or and Star operators now use an approximation to + removeUnreachableStates that does not require a traversal of the entire + graph. This combined with an 'on-the-fly' management of final bits and final + state status results is a dramatic speed increase when compiling machines + that use those operators heavily. The strings2 test goes 20 times faster. + -Before the final minimization, after all fsm operations are complete, + priority data is reset which enables better minimization in cases where + priorities would otherwise separate similar states. + +Ragel 1.3.1 - Oct 2, 2002 +========================= + -Range transitions are now used to implement machines made with /[a-z]/ and + the .. operator as well as most of the builtin machines. The ranges are not + yet reflected in the output code, they are expanded as if they came from the + regular single transitions. This is one step closer to arbitrary integer + output. + -The builtin machine 'any' was added. It is equiv to the builtin extend, + matching any characters. + -The builtin machine 'cntrl' now includes newline. + -The builtin machine 'space' now includes newline. + -The builtin machine 'ascii' is now the range 0-127, not all characters. + -A man page was written. + -A proper user guide was started. Chapter 1: Specifying Ragel Programs + was written. It even has some diagrams :) + +Ragel 1.3.0 - Sep 4, 2002 +========================= + -NULL keyword no longer used in table output. + -Though not yet in use, underlying graph structure changed to support range + transitions. As a result, most of the code that walks transition lists is now + implemented with an iterator that hides the complexity of the transition + lists and ranges. Range transitions will be used to implement /[a-z]/ style + machines and machines made with the .. operator. Previously a single + transition would be used for each char in the range, which is very costly. + Ranges eliminate much of the space complexity and allow for the .. operator + to be used with very large (integer) alphabets. + -New minimization similar to Hopcroft's alg. It does not require n^2 space and + runs close to O(n*log(n)) (an exact analysis of the alg is very hard). It is + much better than the stable and approx minimization and obsoletes them both. + An exact implementation of Hopcroft's alg is desirable but not possible + because the ragel implementation does not assume a finite alphabet, which + Hopcroft's requires. Ragel will support arbitrary integer alphabets which + must be treated as an infinite set for implementation considerations. + -New option -m using above described minimization to replace all previous + minimization options. Old options sill work but are obsolete and not + advertised with -h. + -Bug fixed in goto style output. The error exit set the current state to 0, + which is actually a valid state. If the machine was entered again it would go + into the first state, very wrong. If the first state happened to be final then + an immediate finish would accept when in fact it should fail. + -Slightly better fsm minimization now capable due to clearing of the + transition ordering numbers just prior to minimization. + +Ragel 1.2.2 - May 25, 2002 +========================== + -Configuration option --prefix now works when installing. + -cc file extension changed to cpp for better portability. + -Unlink of output file upon error no longer happens, removes dependency on + unlink system command. + -All multiline strings removed: not standard c++. + -Awk build dependency removed. + -MSVC 6.0 added to the list of supported compilers (with some tweaking of + bison and flex output). + +Ragel 1.2.1 - May 13, 2002 +========================== + -Automatic dependencies were fixed, they were not working correctly. + -Updated AUTHORS file to reflect contributors. + -Code is more C++ standards compliant: compiles with g++ 3.0 + -Fixed bugs that only showed up in g++ 3.0 + -Latest (unreleased) Aapl. + -Configuration script bails out if bison++ is installed. Ragel will not + compile with bison++ because it is coded in c++ and bison++ automatically + generates a c++ parser. Ragel uses a c-style bison parser. + +Ragel 1.2.0 - May 3, 2002 +========================= + -Underlying graph structure now supports default transitions. The result is + that a transition does not need to be made for each char of the alphabet + when making 'extend' or '/./' machines. Ragel compiles machines that + use the aforementioned primitives WAY faster. + -The ugly hacks needed to pick default transitions now go away due to + the graph supporting default transitions directly. + -If -e is given, but minimization is not turned on, print a warning. + -Makefiles use automatic dependencies. + +Ragel 1.1.0 - Apr 15, 2002 +========================== + -Added goto fsm: much faster than any other fsm style. + -Default operator (if two machines are side by side with no operator + between them) is concatenation. First showed up in 1.0.4. + -The fsm machine no longer auotmatically builds the flat table for + transition indicies. Instead it keeps the key,ptr pair. In tabcodegen + the flat table is produced. This way very large alphabets with sparse + transitions will not consume large amounts of mem. This is also in prep + for fsm graph getting a default transition. + -Generated code contains a statement explicitly stating that ragel fsms + are NOT covered by the GPL. Technically, Ragel copies part of itself + to the output to make the generic fsm execution routine (for table driven + fsms only) and so the output could be considered under the GPL. But this + code is very trivial and could easlily be rewritten. The actual fsm data + is subject to the copyright of the source. To promote the use of Ragel, + a special exception is made for the part of the output copied from Ragel: + it may be used without restriction. + -Much more elegant code generation scheme is employed. Code generation + class members need only put the 'codegen' keyword after their 'void' type + in order to be automatically registerd to handle macros of the same name. + An awk script recognises this keyword and generates an appropriate driver. + -Ragel gets a test suite. + -Postfunc and prefunc go away because they are not supported by non + loop-driven fsms (goto, switch) and present duplicate functionality. + Universal funcs can be implemented by using $ operator. + -Automatic dependencies used in build system, no more make depend target. + -Code generation section in docs. + -Uses the latests aapl. + +Ragel 1.0.5 - Mar 3, 2002 +========================= + -Bugfix in SetErrorState that caused an assertion failure when compiling + simple machines that did not have full transition tables (and thus did + not show up on any example machines). Assertion failure did not occur + when using the switch statement code as ragel does not call SetErrorState + in that case. + -Fixed some missing includes, now compiles on redhat. + -Moved the FsmMachTrans Compare class out of FsmMachTrans. Some compilers + don't deal with nested classes in templates too well. + -Removed old unused BASEREF in fsmgraph and ragel now compiles using + egcs-2.91.66 and presumably SUNWspro. The baseref is no longer needed + because states do not support being elements in multiple lists. I would + rather be able to support more compilers than have this feature. + -Started a README with compilation notes. Started an AUTHORS file. + -Started the user documentation. Describes basic machines and operators. + +Ragel 1.0.4 - Mar 1, 2002 +========================= + -Ported to the version of Aapl just after 2.2.0 release. See + http://www.ragel.ca/aapl/ for details on aapl. + -Fixed a bug in the clang example: the newline machine was not stared. + -Added explanations to the clang and mailbox examples. This should + help people that want to learn the lanuage as the manual is far from + complete. + +Ragel 1.0.3 - Feb 2, 2002 +========================= + -Added aapl to the ragel tree. No longer requires you to download + and build aapl separately. Should avoid discouraging impatient users + from compiling ragel. + -Added the examples to the ragel tree. + -Added configure script checks for bison and flex. + -Fixed makefile so as not to die with newer versions of bison that + write the header of the parser to a .hh file. + -Started ChangeLog file. + +Ragel 1.0.2 - Jan 30, 2002 +========================== + -Bug fix in calculating highIndex for table based code. Was using + the length of out tranisition table rather than the value at the + end. + -If high/low index are at the limits, output a define in their place, + not the high/low values themselves so as not to cause compiler warnings. + -If the resulting machines don't have any indicies or functions, then + omit the empty unrefereced static arrays so as not to cause compiler + warnings about unused static vars. + -Fixed variable sized indicies support. The header cannot have any + reference to INDEX_TYPE as that info is not known at the time the header + data is written. Forces us to use a void * for pointers to indicies. In + the c++ versions we are forced to make much of the data non-member + static data in the code portion for the same reason. + +Ragel 1.0.1 - Jan 28, 2002 +========================== + -Exe name change from reglang to ragel. + -Added ftabcodegen output code style which uses a table for states and + transitions but uses a switch statement for the function execution. + -Reformatted options in usage dump to look better. + -Support escape sequences in [] sections of regular expressions. + +Ragel 1.0 - Jan 25, 2002 +======================== + -Initial release. diff --git a/contrib/tools/ragel6/DIST b/contrib/tools/ragel6/DIST index 85d0524832..020dc32bb7 100644 --- a/contrib/tools/ragel6/DIST +++ b/contrib/tools/ragel6/DIST @@ -1,6 +1,6 @@ -#!/bin/sh - -# Change to yes to enable building of parsers or manual. Reconfigure -# afterwards. -build_parsers=no; -build_manual=no; +#!/bin/sh + +# Change to yes to enable building of parsers or manual. Reconfigure +# afterwards. +build_parsers=no; +build_manual=no; diff --git a/contrib/tools/ragel6/README b/contrib/tools/ragel6/README index d05b863e26..214b96aae4 100644 --- a/contrib/tools/ragel6/README +++ b/contrib/tools/ragel6/README @@ -1,32 +1,32 @@ - - Ragel State Machine Compiler -- README - ====================================== - -1. Build Requirements ---------------------- - - * Make - * g++ - -If you would like to modify Ragel and need to build Ragel's scanners and -parsers from the specifications then set "build_parsers=yes" the DIST file and -reconfigure. This variable is normally set to "no" in the distribution tarballs -and "yes" in version control. You will need the following programs: - - * ragel (the most recent version) - * kelbt (the most recent version) - -To build the user guide set "build_manual=yes" in the DIST file and -reconfigure. You will need the following extra programs: - - * fig2dev - * pdflatex - -2. Compilation and Installation -------------------------------- - -Ragel uses autoconf and automake. - -$ ./configure --prefix=PREFIX -$ make -$ make install + + Ragel State Machine Compiler -- README + ====================================== + +1. Build Requirements +--------------------- + + * Make + * g++ + +If you would like to modify Ragel and need to build Ragel's scanners and +parsers from the specifications then set "build_parsers=yes" the DIST file and +reconfigure. This variable is normally set to "no" in the distribution tarballs +and "yes" in version control. You will need the following programs: + + * ragel (the most recent version) + * kelbt (the most recent version) + +To build the user guide set "build_manual=yes" in the DIST file and +reconfigure. You will need the following extra programs: + + * fig2dev + * pdflatex + +2. Compilation and Installation +------------------------------- + +Ragel uses autoconf and automake. + +$ ./configure --prefix=PREFIX +$ make +$ make install diff --git a/contrib/tools/ragel6/TODO b/contrib/tools/ragel6/TODO index 85c5440ff0..868eb10d30 100644 --- a/contrib/tools/ragel6/TODO +++ b/contrib/tools/ragel6/TODO @@ -1,102 +1,102 @@ -Guard against including a ragel file more than once (newsgroup). - -Line numbers in included files refer to the master file. This needs to be -fixed -- from Manoj. - -Remove old action embedding and condition setting syntax. - -fbreak should advance the current char. Depreciate fbreak and add - fctl_break; - fctl_return <expr>; - fctl_goto <label>; -This is needed for better support of pull scanners. - -Eliminate tokend, replace it with the marker variable and add ftokend/ftoklen. - -Add the accept action embedding operator: like eof but only for states that end -up final. Add the combined pending/accept action. This becomes a good idea when -eof action execution is moved into the main loop. - -Add a prefix operator which sets every state final. - -Minimization should remove a condition when the character allows both -the positive and negative sense of the condition. This happens in: -test_every_10_chars = ( ( c when test_len ) c{0,9} )**; -In this example there is non-determinsm that is killed by the priorities, but -since conditions are expanded before priorities are tested, many transitions -end up with test_len || !test_len. - -Should be possible to include scanner definitions in another scanner. - -Need an "entry name;" feature, causing name to get written out with the other -entry points in the data. - -Possibly bring back the old semantics of > in a new operator, or allow it to be -defined somehow. - -When priorities are embedded without a name, the name of the current machine is -used. Perhaps a unique name for each instance of the current machine should be -used instead. This idea could work well if applied to user-defined embeddings. - -User defined embeddings <-name(a1,a2,...). -User defined operators expr1 <name> expr2. - -Doesn't make make sense for [] to be the lambda (zero-length) machine. This -should be the empty set (the empty machine). But then would it be invalid in a -regular expression? - -The |> guarded operator and the <| guarded operator need to be added. - -An option to turn off the removal of duplicate actions might be useful for -analyzing unintentional nondeterminism. - -Might be a good idea to add in some protection against using up all of a -system's memory. This protection could then be removed by people when someone -is sure they want to use a lot of memory. - - -If a scanner can be optimized into a pure state machine, maybe permit it to be -referenced as a machine definition. Alternately: inline scanners with an -explicit exit pattern. - -The split codegen needs a profiler connected to a graph partitioning algorithm. - -Die a graceful death when rlcodegen -F receives large alphabets. - -It's not currently possible to have more than one machine in a single function -because of label conflicts. Labels should have a unique prefix. - -Emit a warning when a subtraction has no effect. - -Emit a warning when unnamed priorities are used in longest match machines. -These priorities may unexpectedly interact across longest-match items. Changing -the language such that unwated interaction cannot happen would require naming -longest-match items. - -Testing facilities: Quick easy way to query which strings are accepted. -Enumerate all accepted strings. From Nicholas Maxwell Lester. - -Add more examples, add more tests and write more documentation. - -A debugger would be nice. Ragel could emit a special debug version that -prompted for debug commands that allowed the user to step through the machine -and get details about where they are in their RL. - -A quick and easy alternative would be a trace code generation option. This -would open a trace file and list all the active machines at each step of the -input. - -Frontend should allow the redefinition of fsm section delimiters. - -Do more to obscure ragel's private variables. Just a leading underscore is not -enough. Maybe something more like __ri__. - -Some talk about capturing data: - -Separate tokstart/tokend from the backtracking. One var for preservation, -called preserve. Write delcarations; produces the necessary variables used by -ragel. Move pattern start pattern end concepts into the general? The -variables which may need to influence the preserve is dependent on the state. -States have a concept of which variables are in use. Can be used for length -restrictions. If there is an exit pattern, it is the explicit way out, -otherwise the start state and all final states are a way out. +Guard against including a ragel file more than once (newsgroup). + +Line numbers in included files refer to the master file. This needs to be +fixed -- from Manoj. + +Remove old action embedding and condition setting syntax. + +fbreak should advance the current char. Depreciate fbreak and add + fctl_break; + fctl_return <expr>; + fctl_goto <label>; +This is needed for better support of pull scanners. + +Eliminate tokend, replace it with the marker variable and add ftokend/ftoklen. + +Add the accept action embedding operator: like eof but only for states that end +up final. Add the combined pending/accept action. This becomes a good idea when +eof action execution is moved into the main loop. + +Add a prefix operator which sets every state final. + +Minimization should remove a condition when the character allows both +the positive and negative sense of the condition. This happens in: +test_every_10_chars = ( ( c when test_len ) c{0,9} )**; +In this example there is non-determinsm that is killed by the priorities, but +since conditions are expanded before priorities are tested, many transitions +end up with test_len || !test_len. + +Should be possible to include scanner definitions in another scanner. + +Need an "entry name;" feature, causing name to get written out with the other +entry points in the data. + +Possibly bring back the old semantics of > in a new operator, or allow it to be +defined somehow. + +When priorities are embedded without a name, the name of the current machine is +used. Perhaps a unique name for each instance of the current machine should be +used instead. This idea could work well if applied to user-defined embeddings. + +User defined embeddings <-name(a1,a2,...). +User defined operators expr1 <name> expr2. + +Doesn't make make sense for [] to be the lambda (zero-length) machine. This +should be the empty set (the empty machine). But then would it be invalid in a +regular expression? + +The |> guarded operator and the <| guarded operator need to be added. + +An option to turn off the removal of duplicate actions might be useful for +analyzing unintentional nondeterminism. + +Might be a good idea to add in some protection against using up all of a +system's memory. This protection could then be removed by people when someone +is sure they want to use a lot of memory. + + +If a scanner can be optimized into a pure state machine, maybe permit it to be +referenced as a machine definition. Alternately: inline scanners with an +explicit exit pattern. + +The split codegen needs a profiler connected to a graph partitioning algorithm. + +Die a graceful death when rlcodegen -F receives large alphabets. + +It's not currently possible to have more than one machine in a single function +because of label conflicts. Labels should have a unique prefix. + +Emit a warning when a subtraction has no effect. + +Emit a warning when unnamed priorities are used in longest match machines. +These priorities may unexpectedly interact across longest-match items. Changing +the language such that unwated interaction cannot happen would require naming +longest-match items. + +Testing facilities: Quick easy way to query which strings are accepted. +Enumerate all accepted strings. From Nicholas Maxwell Lester. + +Add more examples, add more tests and write more documentation. + +A debugger would be nice. Ragel could emit a special debug version that +prompted for debug commands that allowed the user to step through the machine +and get details about where they are in their RL. + +A quick and easy alternative would be a trace code generation option. This +would open a trace file and list all the active machines at each step of the +input. + +Frontend should allow the redefinition of fsm section delimiters. + +Do more to obscure ragel's private variables. Just a leading underscore is not +enough. Maybe something more like __ri__. + +Some talk about capturing data: + +Separate tokstart/tokend from the backtracking. One var for preservation, +called preserve. Write delcarations; produces the necessary variables used by +ragel. Move pattern start pattern end concepts into the general? The +variables which may need to influence the preserve is dependent on the state. +States have a concept of which variables are in use. Can be used for length +restrictions. If there is an exit pattern, it is the explicit way out, +otherwise the start state and all final states are a way out. diff --git a/contrib/tools/ragel6/cdcodegen.cpp b/contrib/tools/ragel6/cdcodegen.cpp index 9e784e3f58..12a8d9316f 100644 --- a/contrib/tools/ragel6/cdcodegen.cpp +++ b/contrib/tools/ragel6/cdcodegen.cpp @@ -329,48 +329,48 @@ string FsmCodeGen::KEY( Key key ) return ret.str(); } -bool FsmCodeGen::isAlphTypeSigned() -{ - return keyOps->isSigned; -} - -bool FsmCodeGen::isWideAlphTypeSigned() -{ - string ret; - if ( redFsm->maxKey <= keyOps->maxKey ) - return isAlphTypeSigned(); - else { - long long maxKeyVal = redFsm->maxKey.getLongLong(); - HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); - return wideType->isSigned; - } -} - -string FsmCodeGen::WIDE_KEY( RedStateAp *state, Key key ) -{ - if ( state->stateCondList.length() > 0 ) { - ostringstream ret; - if ( isWideAlphTypeSigned() ) - ret << key.getVal(); - else - ret << (unsigned long) key.getVal() << 'u'; - return ret.str(); - } - else { - return KEY( key ); - } -} - -void FsmCodeGen::EOF_CHECK( ostream &ret ) -{ - ret << - " if ( " << P() << " == " << PE() << " )\n" - " goto _test_eof;\n"; - - testEofUsed = true; -} - - +bool FsmCodeGen::isAlphTypeSigned() +{ + return keyOps->isSigned; +} + +bool FsmCodeGen::isWideAlphTypeSigned() +{ + string ret; + if ( redFsm->maxKey <= keyOps->maxKey ) + return isAlphTypeSigned(); + else { + long long maxKeyVal = redFsm->maxKey.getLongLong(); + HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); + return wideType->isSigned; + } +} + +string FsmCodeGen::WIDE_KEY( RedStateAp *state, Key key ) +{ + if ( state->stateCondList.length() > 0 ) { + ostringstream ret; + if ( isWideAlphTypeSigned() ) + ret << key.getVal(); + else + ret << (unsigned long) key.getVal() << 'u'; + return ret.str(); + } + else { + return KEY( key ); + } +} + +void FsmCodeGen::EOF_CHECK( ostream &ret ) +{ + ret << + " if ( " << P() << " == " << PE() << " )\n" + " goto _test_eof;\n"; + + testEofUsed = true; +} + + void FsmCodeGen::EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ) { /* The parser gives fexec two children. The double brackets are for D @@ -405,7 +405,7 @@ void FsmCodeGen::LM_SWITCH( ostream &ret, GenInlineItem *item, ret << " break;\n"; } - if ( (hostLang->lang == HostLang::D || hostLang->lang == HostLang::D2) && !haveDefault ) + if ( (hostLang->lang == HostLang::D || hostLang->lang == HostLang::D2) && !haveDefault ) ret << " default: break;"; ret << @@ -664,7 +664,7 @@ void FsmCodeGen::STATE_IDS() out << "\n"; - if ( !noEntry && entryPointNames.length() > 0 ) { + if ( !noEntry && entryPointNames.length() > 0 ) { for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << " = " << entryPointIds[en.pos()] << "};\n"; @@ -697,11 +697,11 @@ string CCodeGen::PTR_CONST() return "const "; } -string CCodeGen::PTR_CONST_END() -{ - return ""; -} - +string CCodeGen::PTR_CONST_END() +{ + return ""; +} + std::ostream &CCodeGen::OPEN_ARRAY( string type, string name ) { out << "#if defined(__GNUC__)\n"; @@ -789,11 +789,11 @@ string DCodeGen::PTR_CONST() return ""; } -string DCodeGen::PTR_CONST_END() -{ - return ""; -} - +string DCodeGen::PTR_CONST_END() +{ + return ""; +} + std::ostream &DCodeGen::OPEN_ARRAY( string type, string name ) { out << "static const " << type << "[] " << name << " = [\n"; @@ -852,112 +852,112 @@ void DCodeGen::writeExports() * End D-specific code. */ -/* - * D2 Specific - */ - -string D2CodeGen::NULL_ITEM() -{ - return "null"; -} - -string D2CodeGen::POINTER() -{ - // multiple items seperated by commas can also be pointer types. - return "* "; -} - -string D2CodeGen::PTR_CONST() -{ - return "const("; -} - -string D2CodeGen::PTR_CONST_END() -{ - return ")"; -} - -std::ostream &D2CodeGen::OPEN_ARRAY( string type, string name ) -{ - out << "enum " << type << "[] " << name << " = [\n"; - return out; -} - -std::ostream &D2CodeGen::CLOSE_ARRAY() -{ - return out << "];\n"; -} - -std::ostream &D2CodeGen::STATIC_VAR( string type, string name ) -{ - out << "enum " << type << " " << name; - return out; -} - -string D2CodeGen::ARR_OFF( string ptr, string offset ) -{ - return "&" + ptr + "[" + offset + "]"; -} - -string D2CodeGen::CAST( string type ) -{ - return "cast(" + type + ")"; -} - -string D2CodeGen::UINT( ) -{ - return "uint"; -} - -std::ostream &D2CodeGen::SWITCH_DEFAULT() -{ - out << " default: break;\n"; - return out; -} - -string D2CodeGen::CTRL_FLOW() -{ - return "if (true) "; -} - -void D2CodeGen::writeExports() -{ - if ( exportList.length() > 0 ) { - for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) { - out << "enum " << ALPH_TYPE() << " " << DATA_PREFIX() << - "ex_" << ex->name << " = " << KEY(ex->key) << ";\n"; - } - out << "\n"; - } -} - -void D2CodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item, - int targState, bool inFinish, bool csForced ) -{ - if ( item->children->length() > 0 ) { - /* Write the block and close it off. */ - ret << "{{"; - INLINE_LIST( ret, item->children, targState, inFinish, csForced ); - ret << "}}"; - } -} - -void D2CodeGen::ACTION( ostream &ret, GenAction *action, int targState, - bool inFinish, bool csForced ) -{ - /* Write the preprocessor line info for going into the source file. */ - cdLineDirective( ret, action->loc.fileName, action->loc.line ); - - /* Write the block and close it off. */ - ret << "\t{{"; - INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced ); - ret << "}}\n"; -} - -/* - * End D2-specific code. - */ - +/* + * D2 Specific + */ + +string D2CodeGen::NULL_ITEM() +{ + return "null"; +} + +string D2CodeGen::POINTER() +{ + // multiple items seperated by commas can also be pointer types. + return "* "; +} + +string D2CodeGen::PTR_CONST() +{ + return "const("; +} + +string D2CodeGen::PTR_CONST_END() +{ + return ")"; +} + +std::ostream &D2CodeGen::OPEN_ARRAY( string type, string name ) +{ + out << "enum " << type << "[] " << name << " = [\n"; + return out; +} + +std::ostream &D2CodeGen::CLOSE_ARRAY() +{ + return out << "];\n"; +} + +std::ostream &D2CodeGen::STATIC_VAR( string type, string name ) +{ + out << "enum " << type << " " << name; + return out; +} + +string D2CodeGen::ARR_OFF( string ptr, string offset ) +{ + return "&" + ptr + "[" + offset + "]"; +} + +string D2CodeGen::CAST( string type ) +{ + return "cast(" + type + ")"; +} + +string D2CodeGen::UINT( ) +{ + return "uint"; +} + +std::ostream &D2CodeGen::SWITCH_DEFAULT() +{ + out << " default: break;\n"; + return out; +} + +string D2CodeGen::CTRL_FLOW() +{ + return "if (true) "; +} + +void D2CodeGen::writeExports() +{ + if ( exportList.length() > 0 ) { + for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) { + out << "enum " << ALPH_TYPE() << " " << DATA_PREFIX() << + "ex_" << ex->name << " = " << KEY(ex->key) << ";\n"; + } + out << "\n"; + } +} + +void D2CodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item, + int targState, bool inFinish, bool csForced ) +{ + if ( item->children->length() > 0 ) { + /* Write the block and close it off. */ + ret << "{{"; + INLINE_LIST( ret, item->children, targState, inFinish, csForced ); + ret << "}}"; + } +} + +void D2CodeGen::ACTION( ostream &ret, GenAction *action, int targState, + bool inFinish, bool csForced ) +{ + /* Write the preprocessor line info for going into the source file. */ + cdLineDirective( ret, action->loc.fileName, action->loc.line ); + + /* Write the block and close it off. */ + ret << "\t{{"; + INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced ); + ret << "}}\n"; +} + +/* + * End D2-specific code. + */ + void FsmCodeGen::finishRagelDef() { if ( codeStyle == GenGoto || codeStyle == GenFGoto || diff --git a/contrib/tools/ragel6/cdcodegen.h b/contrib/tools/ragel6/cdcodegen.h index b9a84906d5..567ee85887 100644 --- a/contrib/tools/ragel6/cdcodegen.h +++ b/contrib/tools/ragel6/cdcodegen.h @@ -73,18 +73,18 @@ protected: string GET_WIDE_KEY( RedStateAp *state ); string TABS( int level ); string KEY( Key key ); - string WIDE_KEY( RedStateAp *state, Key key ); + string WIDE_KEY( RedStateAp *state, Key key ); string LDIR_PATH( char *path ); - virtual void ACTION( ostream &ret, GenAction *action, int targState, + virtual void ACTION( ostream &ret, GenAction *action, int targState, bool inFinish, bool csForced ); void CONDITION( ostream &ret, GenAction *condition ); string ALPH_TYPE(); string WIDE_ALPH_TYPE(); string ARRAY_TYPE( unsigned long maxVal ); - bool isAlphTypeSigned(); - bool isWideAlphTypeSigned(); - + bool isAlphTypeSigned(); + bool isWideAlphTypeSigned(); + virtual string ARR_OFF( string ptr, string offset ) = 0; virtual string CAST( string type ) = 0; virtual string UINT() = 0; @@ -131,8 +131,8 @@ protected: string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } - void EOF_CHECK( ostream &ret ); - + void EOF_CHECK( ostream &ret ); + void INLINE_LIST( ostream &ret, GenInlineList *inlineList, int targState, bool inFinish, bool csForced ); virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; @@ -155,7 +155,7 @@ protected: void SET_TOKSTART( ostream &ret, GenInlineItem *item ); void SET_TOKEND( ostream &ret, GenInlineItem *item ); void GET_TOKEND( ostream &ret, GenInlineItem *item ); - virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, + virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, int targState, bool inFinish, bool csForced ); void STATE_IDS(); @@ -163,7 +163,7 @@ protected: string FIRST_FINAL_STATE(); virtual string PTR_CONST() = 0; - virtual string PTR_CONST_END() = 0; + virtual string PTR_CONST_END() = 0; virtual ostream &OPEN_ARRAY( string type, string name ) = 0; virtual ostream &CLOSE_ARRAY() = 0; virtual ostream &STATIC_VAR( string type, string name ) = 0; @@ -202,7 +202,7 @@ public: virtual string CAST( string type ); virtual string UINT(); virtual string PTR_CONST(); - virtual string PTR_CONST_END(); + virtual string PTR_CONST_END(); virtual string CTRL_FLOW(); virtual void writeExports(); @@ -223,36 +223,36 @@ public: virtual string CAST( string type ); virtual string UINT(); virtual string PTR_CONST(); - virtual string PTR_CONST_END(); + virtual string PTR_CONST_END(); virtual string CTRL_FLOW(); virtual void writeExports(); }; -class D2CodeGen : virtual public FsmCodeGen -{ -public: - D2CodeGen( ostream &out ) : FsmCodeGen(out) {} - - virtual string NULL_ITEM(); - virtual string POINTER(); - virtual ostream &SWITCH_DEFAULT(); - virtual ostream &OPEN_ARRAY( string type, string name ); - virtual ostream &CLOSE_ARRAY(); - virtual ostream &STATIC_VAR( string type, string name ); - virtual string ARR_OFF( string ptr, string offset ); - virtual string CAST( string type ); - virtual string UINT(); - virtual string PTR_CONST(); - virtual string PTR_CONST_END(); - virtual string CTRL_FLOW(); - - virtual void writeExports(); - virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, - int targState, bool inFinish, bool csForced ); - virtual void ACTION( ostream &ret, GenAction *action, int targState, - bool inFinish, bool csForced ); - -}; - +class D2CodeGen : virtual public FsmCodeGen +{ +public: + D2CodeGen( ostream &out ) : FsmCodeGen(out) {} + + virtual string NULL_ITEM(); + virtual string POINTER(); + virtual ostream &SWITCH_DEFAULT(); + virtual ostream &OPEN_ARRAY( string type, string name ); + virtual ostream &CLOSE_ARRAY(); + virtual ostream &STATIC_VAR( string type, string name ); + virtual string ARR_OFF( string ptr, string offset ); + virtual string CAST( string type ); + virtual string UINT(); + virtual string PTR_CONST(); + virtual string PTR_CONST_END(); + virtual string CTRL_FLOW(); + + virtual void writeExports(); + virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, + int targState, bool inFinish, bool csForced ); + virtual void ACTION( ostream &ret, GenAction *action, int targState, + bool inFinish, bool csForced ); + +}; + #endif diff --git a/contrib/tools/ragel6/cdfflat.cpp b/contrib/tools/ragel6/cdfflat.cpp index 79cc5be3cb..5e78749095 100644 --- a/contrib/tools/ragel6/cdfflat.cpp +++ b/contrib/tools/ragel6/cdfflat.cpp @@ -257,12 +257,12 @@ void FFlatCodeGen::writeExec() out << ";\n"; out << - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << PTR_CONST_END() << POINTER() << "_inds;\n"; + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << PTR_CONST_END() << POINTER() << "_inds;\n"; if ( redFsm->anyConditions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxCond) << PTR_CONST_END() << POINTER() << "_conds;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxCond) << PTR_CONST_END() << POINTER() << "_conds;\n" " " << WIDE_ALPH_TYPE() << " _widec;\n"; } diff --git a/contrib/tools/ragel6/cdfflat.h b/contrib/tools/ragel6/cdfflat.h index e5cbfbd9e9..04ee887596 100644 --- a/contrib/tools/ragel6/cdfflat.h +++ b/contrib/tools/ragel6/cdfflat.h @@ -72,14 +72,14 @@ struct DFFlatCodeGen FsmCodeGen(out), FFlatCodeGen(out), DCodeGen(out) {} }; -/* - * D2FFlatCodeGen - */ -struct D2FFlatCodeGen - : public FFlatCodeGen, public D2CodeGen -{ - D2FFlatCodeGen( ostream &out ) : - FsmCodeGen(out), FFlatCodeGen(out), D2CodeGen(out) {} -}; - +/* + * D2FFlatCodeGen + */ +struct D2FFlatCodeGen + : public FFlatCodeGen, public D2CodeGen +{ + D2FFlatCodeGen( ostream &out ) : + FsmCodeGen(out), FFlatCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdfgoto.h b/contrib/tools/ragel6/cdfgoto.h index 27e980e9ea..d642f5369e 100644 --- a/contrib/tools/ragel6/cdfgoto.h +++ b/contrib/tools/ragel6/cdfgoto.h @@ -72,14 +72,14 @@ struct DFGotoCodeGen FsmCodeGen(out), FGotoCodeGen(out), DCodeGen(out) {} }; -/* - * class DFGotoCodeGen - */ -struct D2FGotoCodeGen - : public FGotoCodeGen, public D2CodeGen -{ - D2FGotoCodeGen( ostream &out ) : - FsmCodeGen(out), FGotoCodeGen(out), D2CodeGen(out) {} -}; - +/* + * class DFGotoCodeGen + */ +struct D2FGotoCodeGen + : public FGotoCodeGen, public D2CodeGen +{ + D2FGotoCodeGen( ostream &out ) : + FsmCodeGen(out), FGotoCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdflat.cpp b/contrib/tools/ragel6/cdflat.cpp index b28a95a660..450b621d8b 100644 --- a/contrib/tools/ragel6/cdflat.cpp +++ b/contrib/tools/ragel6/cdflat.cpp @@ -454,32 +454,32 @@ void FlatCodeGen::LOCATE_TRANS() void FlatCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = " << gotoDest << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{"; + + ret << vCS() << " = " << gotoDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void FlatCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = ("; + ret << "{"; + + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); "; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "); "; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void FlatCodeGen::CURS( ostream &ret, bool inFinish ) @@ -511,17 +511,17 @@ void FlatCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{"; + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -536,14 +536,14 @@ void FlatCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << ");"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - ret << "}"; - + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -559,12 +559,12 @@ void FlatCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void FlatCodeGen::BREAK( ostream &ret, int targState, bool csForced ) @@ -734,17 +734,17 @@ void FlatCodeGen::writeExec() redFsm->anyRegActions() || redFsm->anyFromStateActions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "_acts;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "_acts;\n" " " << UINT() << " _nacts;\n"; } out << - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << PTR_CONST_END() << POINTER() << "_inds;\n"; + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << PTR_CONST_END() << POINTER() << "_inds;\n"; if ( redFsm->anyConditions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxCond) << PTR_CONST_END() << POINTER() << "_conds;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxCond) << PTR_CONST_END() << POINTER() << "_conds;\n" " " << WIDE_ALPH_TYPE() << " _widec;\n"; } @@ -863,7 +863,7 @@ void FlatCodeGen::writeExec() if ( redFsm->anyEofActions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "__acts = " << ARR_OFF( A(), EA() + "[" + vCS() + "]" ) << ";\n" " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" diff --git a/contrib/tools/ragel6/cdflat.h b/contrib/tools/ragel6/cdflat.h index 96c65cb1eb..c66c6924d4 100644 --- a/contrib/tools/ragel6/cdflat.h +++ b/contrib/tools/ragel6/cdflat.h @@ -105,14 +105,14 @@ struct DFlatCodeGen FsmCodeGen(out), FlatCodeGen(out), DCodeGen(out) {} }; -/* - * D2FlatCodeGen - */ -struct D2FlatCodeGen - : public FlatCodeGen, public D2CodeGen -{ - D2FlatCodeGen( ostream &out ) : - FsmCodeGen(out), FlatCodeGen(out), D2CodeGen(out) {} -}; - +/* + * D2FlatCodeGen + */ +struct D2FlatCodeGen + : public FlatCodeGen, public D2CodeGen +{ + D2FlatCodeGen( ostream &out ) : + FsmCodeGen(out), FlatCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdftable.cpp b/contrib/tools/ragel6/cdftable.cpp index f5584e5d97..fe93204504 100644 --- a/contrib/tools/ragel6/cdftable.cpp +++ b/contrib/tools/ragel6/cdftable.cpp @@ -304,7 +304,7 @@ void FTabCodeGen::writeExec() out << ";\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" " int _trans;\n"; if ( redFsm->anyConditions() ) diff --git a/contrib/tools/ragel6/cdftable.h b/contrib/tools/ragel6/cdftable.h index 4a8264ce75..cb5523766d 100644 --- a/contrib/tools/ragel6/cdftable.h +++ b/contrib/tools/ragel6/cdftable.h @@ -74,14 +74,14 @@ struct DFTabCodeGen FsmCodeGen(out), FTabCodeGen(out), DCodeGen(out) {} }; -/* - * class D2FTabCodeGen - */ -struct D2FTabCodeGen - : public FTabCodeGen, public D2CodeGen -{ - D2FTabCodeGen( ostream &out ) : - FsmCodeGen(out), FTabCodeGen(out), D2CodeGen(out) {} -}; - +/* + * class D2FTabCodeGen + */ +struct D2FTabCodeGen + : public FTabCodeGen, public D2CodeGen +{ + D2FTabCodeGen( ostream &out ) : + FsmCodeGen(out), FTabCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdgoto.cpp b/contrib/tools/ragel6/cdgoto.cpp index 86b3d23fef..498663fcbe 100644 --- a/contrib/tools/ragel6/cdgoto.cpp +++ b/contrib/tools/ragel6/cdgoto.cpp @@ -118,7 +118,7 @@ void GotoCodeGen::emitSingleSwitch( RedStateAp *state ) if ( numSingles == 1 ) { /* If there is a single single key then write it out as an if. */ out << "\tif ( " << GET_WIDE_KEY(state) << " == " << - WIDE_KEY(state, data[0].lowKey) << " )\n\t\t"; + WIDE_KEY(state, data[0].lowKey) << " )\n\t\t"; /* Virtual function for writing the target of the transition. */ TRANS_GOTO(data[0].value, 0) << "\n"; @@ -129,7 +129,7 @@ void GotoCodeGen::emitSingleSwitch( RedStateAp *state ) /* Write out the single indicies. */ for ( int j = 0; j < numSingles; j++ ) { - out << "\t\tcase " << WIDE_KEY(state, data[j].lowKey) << ": "; + out << "\t\tcase " << WIDE_KEY(state, data[j].lowKey) << ": "; TRANS_GOTO(data[j].value, 0) << "\n"; } @@ -158,10 +158,10 @@ void GotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int h if ( anyLower && anyHigher ) { /* Can go lower and higher than mid. */ out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " < " << - WIDE_KEY(state, data[mid].lowKey) << " ) {\n"; + WIDE_KEY(state, data[mid].lowKey) << " ) {\n"; emitRangeBSearch( state, level+1, low, mid-1 ); out << TABS(level) << "} else if ( " << GET_WIDE_KEY(state) << " > " << - WIDE_KEY(state, data[mid].highKey) << " ) {\n"; + WIDE_KEY(state, data[mid].highKey) << " ) {\n"; emitRangeBSearch( state, level+1, mid+1, high ); out << TABS(level) << "} else\n"; TRANS_GOTO(data[mid].value, level+1) << "\n"; @@ -169,7 +169,7 @@ void GotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int h else if ( anyLower && !anyHigher ) { /* Can go lower than mid but not higher. */ out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " < " << - WIDE_KEY(state, data[mid].lowKey) << " ) {\n"; + WIDE_KEY(state, data[mid].lowKey) << " ) {\n"; emitRangeBSearch( state, level+1, low, mid-1 ); /* if the higher is the highest in the alphabet then there is no @@ -180,14 +180,14 @@ void GotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int h } else { out << TABS(level) << "} else if ( " << GET_WIDE_KEY(state) << " <= " << - WIDE_KEY(state, data[mid].highKey) << " )\n"; + WIDE_KEY(state, data[mid].highKey) << " )\n"; TRANS_GOTO(data[mid].value, level+1) << "\n"; } } else if ( !anyLower && anyHigher ) { /* Can go higher than mid but not lower. */ out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " > " << - WIDE_KEY(state, data[mid].highKey) << " ) {\n"; + WIDE_KEY(state, data[mid].highKey) << " ) {\n"; emitRangeBSearch( state, level+1, mid+1, high ); /* If the lower end is the lowest in the alphabet then there is no @@ -198,7 +198,7 @@ void GotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int h } else { out << TABS(level) << "} else if ( " << GET_WIDE_KEY(state) << " >= " << - WIDE_KEY(state, data[mid].lowKey) << " )\n"; + WIDE_KEY(state, data[mid].lowKey) << " )\n"; TRANS_GOTO(data[mid].value, level+1) << "\n"; } } @@ -206,18 +206,18 @@ void GotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int h /* Cannot go higher or lower than mid. It's mid or bust. What * tests to do depends on limits of alphabet. */ if ( !limitLow && !limitHigh ) { - out << TABS(level) << "if ( " << WIDE_KEY(state, data[mid].lowKey) << " <= " << + out << TABS(level) << "if ( " << WIDE_KEY(state, data[mid].lowKey) << " <= " << GET_WIDE_KEY(state) << " && " << GET_WIDE_KEY(state) << " <= " << - WIDE_KEY(state, data[mid].highKey) << " )\n"; + WIDE_KEY(state, data[mid].highKey) << " )\n"; TRANS_GOTO(data[mid].value, level+1) << "\n"; } else if ( limitLow && !limitHigh ) { out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " <= " << - WIDE_KEY(state, data[mid].highKey) << " )\n"; + WIDE_KEY(state, data[mid].highKey) << " )\n"; TRANS_GOTO(data[mid].value, level+1) << "\n"; } else if ( !limitLow && limitHigh ) { - out << TABS(level) << "if ( " << WIDE_KEY(state, data[mid].lowKey) << " <= " << + out << TABS(level) << "if ( " << WIDE_KEY(state, data[mid].lowKey) << " <= " << GET_WIDE_KEY(state) << " )\n"; TRANS_GOTO(data[mid].value, level+1) << "\n"; } @@ -543,32 +543,32 @@ std::ostream &GotoCodeGen::FINISH_CASES() void GotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = " << gotoDest << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{"; + + ret << vCS() << " = " << gotoDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void GotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = ("; + ret << "{"; + + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << ");"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void GotoCodeGen::CURS( ostream &ret, bool inFinish ) @@ -600,17 +600,17 @@ void GotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{"; + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -622,19 +622,19 @@ void GotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << ");"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; - + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -649,11 +649,11 @@ void GotoCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - ret << "}"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + ret << "}"; } void GotoCodeGen::BREAK( ostream &ret, int targState, bool csForced ) @@ -709,7 +709,7 @@ void GotoCodeGen::writeExec() || redFsm->anyFromStateActions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "_acts;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "_acts;\n" " " << UINT() << " _nacts;\n"; } @@ -815,7 +815,7 @@ void GotoCodeGen::writeExec() if ( redFsm->anyEofActions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "__acts = " << ARR_OFF( A(), EA() + "[" + vCS() + "]" ) << ";\n" " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" diff --git a/contrib/tools/ragel6/cdgoto.h b/contrib/tools/ragel6/cdgoto.h index e0869c8d9d..c00bbc7e9a 100644 --- a/contrib/tools/ragel6/cdgoto.h +++ b/contrib/tools/ragel6/cdgoto.h @@ -106,14 +106,14 @@ struct DGotoCodeGen FsmCodeGen(out), GotoCodeGen(out), DCodeGen(out) {} }; -/* - * class D2GotoCodeGen - */ -struct D2GotoCodeGen - : public GotoCodeGen, public D2CodeGen -{ - D2GotoCodeGen( ostream &out ) : - FsmCodeGen(out), GotoCodeGen(out), D2CodeGen(out) {} -}; - +/* + * class D2GotoCodeGen + */ +struct D2GotoCodeGen + : public GotoCodeGen, public D2CodeGen +{ + D2GotoCodeGen( ostream &out ) : + FsmCodeGen(out), GotoCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdipgoto.cpp b/contrib/tools/ragel6/cdipgoto.cpp index 7735f631b6..8e0e021adf 100644 --- a/contrib/tools/ragel6/cdipgoto.cpp +++ b/contrib/tools/ragel6/cdipgoto.cpp @@ -29,30 +29,30 @@ bool IpGotoCodeGen::useAgainLabel() { - return redFsm->anyActionRets() || - redFsm->anyActionByValControl() || + return redFsm->anyActionRets() || + redFsm->anyActionByValControl() || redFsm->anyRegNextStmt(); } -void IpGotoCodeGen::EOF_CHECK( ostream &ret, int gotoDest ) -{ - ret << - " if ( " << P() << " == " << PE() << " )\n" - " goto _test_eof" << gotoDest << ";\n"; - - testEofUsed = true; -} - +void IpGotoCodeGen::EOF_CHECK( ostream &ret, int gotoDest ) +{ + ret << + " if ( " << P() << " == " << PE() << " )\n" + " goto _test_eof" << gotoDest << ";\n"; + + testEofUsed = true; +} + void IpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret, gotoDest ); - - ret << CTRL_FLOW() << "goto st" << gotoDest << ";"; - - ret << "}"; + ret << "{"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret, gotoDest ); + + ret << CTRL_FLOW() << "goto st" << gotoDest << ";"; + + ret << "}"; } void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) @@ -62,15 +62,15 @@ void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFini INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret, callDest ); - - ret << CTRL_FLOW() << "goto st" << callDest << ";"; - - ret << "}"; + ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << ";"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret, callDest ); + + ret << CTRL_FLOW() << "goto st" << callDest << ";"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -82,19 +82,19 @@ void IpGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targStat INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << targState << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << targState << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << ");"; - - if ( inFinish && !noEnd ) - FsmCodeGen::EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; - + ret << ");"; + + if ( inFinish && !noEnd ) + FsmCodeGen::EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -109,27 +109,27 @@ void IpGotoCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - if ( inFinish && !noEnd ) - FsmCodeGen::EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + if ( inFinish && !noEnd ) + FsmCodeGen::EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void IpGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = ("; + ret << "{"; + + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << ");"; - - if ( inFinish && !noEnd ) - FsmCodeGen::EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - ret << "}"; + ret << ");"; + + if ( inFinish && !noEnd ) + FsmCodeGen::EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + ret << "}"; } void IpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) @@ -394,13 +394,13 @@ void IpGotoCodeGen::setLabelsNeeded() } } } - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofAction != 0 ) { - for ( GenActionTable::Iter item = st->eofAction->key; item.lte(); item++ ) - setLabelsNeeded( item->value->inlineList ); - } - } + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofAction != 0 ) { + for ( GenActionTable::Iter item = st->eofAction->key; item.lte(); item++ ) + setLabelsNeeded( item->value->inlineList ); + } + } } if ( !noEnd ) { diff --git a/contrib/tools/ragel6/cdipgoto.h b/contrib/tools/ragel6/cdipgoto.h index 4e92926e25..710f07fb37 100644 --- a/contrib/tools/ragel6/cdipgoto.h +++ b/contrib/tools/ragel6/cdipgoto.h @@ -60,8 +60,8 @@ public: protected: bool useAgainLabel(); - void EOF_CHECK( ostream &ret, int gotoDest ); - + void EOF_CHECK( ostream &ret, int gotoDest ); + /* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for * each state. */ bool IN_TRANS_ACTIONS( RedStateAp *state ); @@ -94,14 +94,14 @@ struct DIpGotoCodeGen FsmCodeGen(out), IpGotoCodeGen(out), DCodeGen(out) {} }; -/* - * class D2IpGotoCodeGen - */ -struct D2IpGotoCodeGen - : public IpGotoCodeGen, public D2CodeGen -{ - D2IpGotoCodeGen( ostream &out ) : - FsmCodeGen(out), IpGotoCodeGen(out), D2CodeGen(out) {} -}; - +/* + * class D2IpGotoCodeGen + */ +struct D2IpGotoCodeGen + : public IpGotoCodeGen, public D2CodeGen +{ + D2IpGotoCodeGen( ostream &out ) : + FsmCodeGen(out), IpGotoCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdsplit.h b/contrib/tools/ragel6/cdsplit.h index 03dea78b50..47358bab71 100644 --- a/contrib/tools/ragel6/cdsplit.h +++ b/contrib/tools/ragel6/cdsplit.h @@ -67,14 +67,14 @@ struct DSplitCodeGen FsmCodeGen(out), SplitCodeGen(out), DCodeGen(out) {} }; -/* - * class D2SplitCodeGen - */ -struct D2SplitCodeGen - : public SplitCodeGen, public D2CodeGen -{ - D2SplitCodeGen( ostream &out ) : - FsmCodeGen(out), SplitCodeGen(out), D2CodeGen(out) {} -}; - +/* + * class D2SplitCodeGen + */ +struct D2SplitCodeGen + : public SplitCodeGen, public D2CodeGen +{ + D2SplitCodeGen( ostream &out ) : + FsmCodeGen(out), SplitCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/cdtable.cpp b/contrib/tools/ragel6/cdtable.cpp index 6bcb79ea84..ee80af800f 100644 --- a/contrib/tools/ragel6/cdtable.cpp +++ b/contrib/tools/ragel6/cdtable.cpp @@ -619,9 +619,9 @@ void TabCodeGen::LOCATE_TRANS() "\n" " _klen = " << SL() << "[" << vCS() << "];\n" " if ( _klen > 0 ) {\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + _klen - 1;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + _klen - 1;\n" " while (1) {\n" " if ( _upper < _lower )\n" " break;\n" @@ -632,7 +632,7 @@ void TabCodeGen::LOCATE_TRANS() " else if ( " << GET_WIDE_KEY() << " > *_mid )\n" " _lower = _mid + 1;\n" " else {\n" - " _trans += " << CAST(UINT()) << "(_mid - _keys);\n" + " _trans += " << CAST(UINT()) << "(_mid - _keys);\n" " goto _match;\n" " }\n" " }\n" @@ -642,9 +642,9 @@ void TabCodeGen::LOCATE_TRANS() "\n" " _klen = " << RL() << "[" << vCS() << "];\n" " if ( _klen > 0 ) {\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n" " while (1) {\n" " if ( _upper < _lower )\n" " break;\n" @@ -655,7 +655,7 @@ void TabCodeGen::LOCATE_TRANS() " else if ( " << GET_WIDE_KEY() << " > _mid[1] )\n" " _lower = _mid + 2;\n" " else {\n" - " _trans += " << CAST(UINT()) << "((_mid - _keys)>>1);\n" + " _trans += " << CAST(UINT()) << "((_mid - _keys)>>1);\n" " goto _match;\n" " }\n" " }\n" @@ -666,31 +666,31 @@ void TabCodeGen::LOCATE_TRANS() void TabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = " << gotoDest << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{"; + + ret << vCS() << " = " << gotoDest << ";"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void TabCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { - ret << "{"; - ret << vCS() << " = ("; + ret << "{"; + ret << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); "; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "); "; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void TabCodeGen::CURS( ostream &ret, bool inFinish ) @@ -722,15 +722,15 @@ void TabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{" << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -742,19 +742,19 @@ void TabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, INLINE_LIST( ret, prePushExpr, 0, false, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << ");"; - - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; - + ret << ");"; + + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -770,12 +770,12 @@ void TabCodeGen::RET( ostream &ret, bool inFinish ) ret << "}"; } - if ( inFinish && !noEnd ) - EOF_CHECK( ret ); - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + if ( inFinish && !noEnd ) + EOF_CHECK( ret ); + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void TabCodeGen::BREAK( ostream &ret, int targState, bool csForced ) @@ -912,9 +912,9 @@ void TabCodeGen::COND_TRANSLATE() " _klen = " << CL() << "[" << vCS() << "];\n" " _keys = " << ARR_OFF( CK(), "(" + CO() + "[" + vCS() + "]*2)" ) << ";\n" " if ( _klen > 0 ) {\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n" " while (1) {\n" " if ( _upper < _lower )\n" " break;\n" @@ -981,13 +981,13 @@ void TabCodeGen::writeExec() || redFsm->anyFromStateActions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "_acts;\n" " " << UINT() << " _nacts;\n"; } out << - " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" + " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n" "\n"; if ( !noEnd ) { @@ -1108,7 +1108,7 @@ void TabCodeGen::writeExec() if ( redFsm->anyEofActions() ) { out << - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << PTR_CONST_END() << POINTER() << "__acts = " << ARR_OFF( A(), EA() + "[" + vCS() + "]" ) << ";\n" " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" diff --git a/contrib/tools/ragel6/cdtable.h b/contrib/tools/ragel6/cdtable.h index b8df71b0cb..3953f71b43 100644 --- a/contrib/tools/ragel6/cdtable.h +++ b/contrib/tools/ragel6/cdtable.h @@ -111,14 +111,14 @@ struct DTabCodeGen FsmCodeGen(out), TabCodeGen(out), DCodeGen(out) {} }; -/* - * D2TabCodeGen - */ -struct D2TabCodeGen - : public TabCodeGen, public D2CodeGen -{ - D2TabCodeGen( ostream &out ) : - FsmCodeGen(out), TabCodeGen(out), D2CodeGen(out) {} -}; - +/* + * D2TabCodeGen + */ +struct D2TabCodeGen + : public TabCodeGen, public D2CodeGen +{ + D2TabCodeGen( ostream &out ) : + FsmCodeGen(out), TabCodeGen(out), D2CodeGen(out) {} +}; + #endif diff --git a/contrib/tools/ragel6/common.cpp b/contrib/tools/ragel6/common.cpp index 8e9f8ed02c..4cf79303f4 100644 --- a/contrib/tools/ragel6/common.cpp +++ b/contrib/tools/ragel6/common.cpp @@ -27,14 +27,14 @@ HostType hostTypesC[] = { - { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, sizeof(char) }, - { "unsigned", "char", "uchar", false, true, false, 0, 0, 0, UCHAR_MAX, sizeof(unsigned char) }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, - { "unsigned", "short", "ushort", false, true, false, 0, 0, 0, USHRT_MAX, sizeof(unsigned short) }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, - { "unsigned", "int", "uint", false, true, false, 0, 0, 0, UINT_MAX, sizeof(unsigned int) }, - { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, - { "unsigned", "long", "ulong", false, true, false, 0, 0, 0, ULONG_MAX, sizeof(unsigned long) } + { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, sizeof(char) }, + { "unsigned", "char", "uchar", false, true, false, 0, 0, 0, UCHAR_MAX, sizeof(unsigned char) }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, + { "unsigned", "short", "ushort", false, true, false, 0, 0, 0, USHRT_MAX, sizeof(unsigned short) }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, + { "unsigned", "int", "uint", false, true, false, 0, 0, 0, UINT_MAX, sizeof(unsigned int) }, + { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, + { "unsigned", "long", "ulong", false, true, false, 0, 0, 0, ULONG_MAX, sizeof(unsigned long) } }; #define S8BIT_MIN -128 @@ -49,90 +49,90 @@ HostType hostTypesC[] = #define U16BIT_MIN 0 #define U16BIT_MAX 65535 -#define S31BIT_MIN -1073741824L -#define S31BIT_MAX 1073741823L - -#define S32BIT_MIN -2147483648L -#define S32BIT_MAX 2147483647L +#define S31BIT_MIN -1073741824L +#define S31BIT_MAX 1073741823L +#define S32BIT_MIN -2147483648L +#define S32BIT_MAX 2147483647L + #define U32BIT_MIN 0 -#define U32BIT_MAX 4294967295UL +#define U32BIT_MAX 4294967295UL -#define S64BIT_MIN -9223372036854775807LL -#define S64BIT_MAX 9223372036854775807LL +#define S64BIT_MIN -9223372036854775807LL +#define S64BIT_MAX 9223372036854775807LL #define U64BIT_MIN 0 -#define U64BIT_MAX 18446744073709551615ULL +#define U64BIT_MAX 18446744073709551615ULL HostType hostTypesD[] = { - { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, - { "ubyte", 0, "ubyte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, - { "char", 0, "char", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, - { "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, - { "wchar", 0, "wchar", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, - { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, 4 }, - { "dchar", 0, "dchar", false, true, false, 0, 0, 0, UINT_MAX, 4 } -}; - -HostType hostTypesGo[] = -{ - { "byte", 0, "uint8", false, true, false, 0, 0, U8BIT_MIN, U8BIT_MAX, 1 }, - { "int8", 0, "int8", true, true, false, S8BIT_MIN, S8BIT_MAX, 0, 0, 1 }, - { "uint8", 0, "uint8", false, true, false, 0, 0, U8BIT_MIN, U8BIT_MAX, 1 }, - { "int16", 0, "int16", true, true, false, S16BIT_MIN, S16BIT_MAX, 0, 0, 2 }, - { "uint16", 0, "uint16", false, true, false, 0, 0, U16BIT_MIN, U16BIT_MAX, 2 }, - { "int32", 0, "int32", true, true, false, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 }, - { "uint32", 0, "uint32", false, true, false, 0, 0, U32BIT_MIN, U32BIT_MAX, 4 }, - { "int64", 0, "int64", true, true, false, S64BIT_MIN, S64BIT_MAX, 0, 0, 8 }, - { "uint64", 0, "uint64", false, true, false, 0, 0, U64BIT_MIN, U64BIT_MAX, 8 }, - { "rune", 0, "int32", true, true, true, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 } + { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "ubyte", 0, "ubyte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, + { "char", 0, "char", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, + { "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "wchar", 0, "wchar", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, + { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, 4 }, + { "dchar", 0, "dchar", false, true, false, 0, 0, 0, UINT_MAX, 4 } }; +HostType hostTypesGo[] = +{ + { "byte", 0, "uint8", false, true, false, 0, 0, U8BIT_MIN, U8BIT_MAX, 1 }, + { "int8", 0, "int8", true, true, false, S8BIT_MIN, S8BIT_MAX, 0, 0, 1 }, + { "uint8", 0, "uint8", false, true, false, 0, 0, U8BIT_MIN, U8BIT_MAX, 1 }, + { "int16", 0, "int16", true, true, false, S16BIT_MIN, S16BIT_MAX, 0, 0, 2 }, + { "uint16", 0, "uint16", false, true, false, 0, 0, U16BIT_MIN, U16BIT_MAX, 2 }, + { "int32", 0, "int32", true, true, false, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 }, + { "uint32", 0, "uint32", false, true, false, 0, 0, U32BIT_MIN, U32BIT_MAX, 4 }, + { "int64", 0, "int64", true, true, false, S64BIT_MIN, S64BIT_MAX, 0, 0, 8 }, + { "uint64", 0, "uint64", false, true, false, 0, 0, U64BIT_MIN, U64BIT_MAX, 8 }, + { "rune", 0, "int32", true, true, true, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 } +}; + HostType hostTypesJava[] = { - { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, - { "char", 0, "char", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, + { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, + { "char", 0, "char", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, }; /* What are the appropriate types for ruby? */ HostType hostTypesRuby[] = { - { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, + { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, }; HostType hostTypesCSharp[] = { - { "sbyte", 0, "sbyte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, - { "byte", 0, "byte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, - { "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, - { "char", 0, "char", false, true, true, 0, 0, 0, USHRT_MAX, 2 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, - { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, 4 }, - { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, 8 }, - { "ulong", 0, "ulong", false, true, false, 0, 0, 0, ULONG_MAX, 8 } + { "sbyte", 0, "sbyte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 }, + { "byte", 0, "byte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 }, + { "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 }, + { "char", 0, "char", false, true, true, 0, 0, 0, USHRT_MAX, 2 }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 }, + { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, 4 }, + { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, 8 }, + { "ulong", 0, "ulong", false, true, false, 0, 0, 0, ULONG_MAX, 8 } }; -HostType hostTypesOCaml[] = -{ - { "int", 0, "int", true, true, false, S31BIT_MIN, S31BIT_MAX, 0, 0, 4 }, -}; - -HostLang hostLangC = { HostLang::C, hostTypesC, 8, hostTypesC+0, true }; -HostLang hostLangD = { HostLang::D, hostTypesD, 9, hostTypesD+2, true }; -HostLang hostLangD2 = { HostLang::D2, hostTypesD, 9, hostTypesD+2, true }; -HostLang hostLangGo = { HostLang::Go, hostTypesGo, 10, hostTypesGo+0, false }; -HostLang hostLangJava = { HostLang::Java, hostTypesJava, 4, hostTypesJava+2, false }; -HostLang hostLangRuby = { HostLang::Ruby, hostTypesRuby, 2, hostTypesRuby+0, false }; -HostLang hostLangCSharp = { HostLang::CSharp, hostTypesCSharp, 9, hostTypesCSharp+4, true }; -HostLang hostLangOCaml = { HostLang::OCaml, hostTypesOCaml, 1, hostTypesOCaml+0, false }; - +HostType hostTypesOCaml[] = +{ + { "int", 0, "int", true, true, false, S31BIT_MIN, S31BIT_MAX, 0, 0, 4 }, +}; + +HostLang hostLangC = { HostLang::C, hostTypesC, 8, hostTypesC+0, true }; +HostLang hostLangD = { HostLang::D, hostTypesD, 9, hostTypesD+2, true }; +HostLang hostLangD2 = { HostLang::D2, hostTypesD, 9, hostTypesD+2, true }; +HostLang hostLangGo = { HostLang::Go, hostTypesGo, 10, hostTypesGo+0, false }; +HostLang hostLangJava = { HostLang::Java, hostTypesJava, 4, hostTypesJava+2, false }; +HostLang hostLangRuby = { HostLang::Ruby, hostTypesRuby, 2, hostTypesRuby+0, false }; +HostLang hostLangCSharp = { HostLang::CSharp, hostTypesCSharp, 9, hostTypesCSharp+4, true }; +HostLang hostLangOCaml = { HostLang::OCaml, hostTypesOCaml, 1, hostTypesOCaml+0, false }; + HostLang *hostLang = &hostLangC; HostType *findAlphType( const char *s1 ) diff --git a/contrib/tools/ragel6/common.h b/contrib/tools/ragel6/common.h index 3ee71d26b0..76c3ea49b6 100644 --- a/contrib/tools/ragel6/common.h +++ b/contrib/tools/ragel6/common.h @@ -114,12 +114,12 @@ struct HostType const char *data2; const char *internalName; bool isSigned; - bool isOrd; - bool isChar; - long long sMinVal; - long long sMaxVal; - unsigned long long uMinVal; - unsigned long long uMaxVal; + bool isOrd; + bool isChar; + long long sMinVal; + long long sMaxVal; + unsigned long long uMinVal; + unsigned long long uMaxVal; unsigned int size; }; @@ -128,7 +128,7 @@ struct HostLang /* Target language. */ enum Lang { - C, D, D2, Go, Java, Ruby, CSharp, OCaml + C, D, D2, Go, Java, Ruby, CSharp, OCaml }; Lang lang; @@ -142,12 +142,12 @@ extern HostLang *hostLang; extern HostLang hostLangC; extern HostLang hostLangD; -extern HostLang hostLangD2; -extern HostLang hostLangGo; +extern HostLang hostLangD2; +extern HostLang hostLangGo; extern HostLang hostLangJava; extern HostLang hostLangRuby; extern HostLang hostLangCSharp; -extern HostLang hostLangOCaml; +extern HostLang hostLangOCaml; HostType *findAlphType( const char *s1 ); HostType *findAlphType( const char *s1, const char *s2 ); @@ -176,12 +176,12 @@ struct KeyOps this->alphType = alphType; isSigned = alphType->isSigned; if ( isSigned ) { - minKey = (long) alphType->sMinVal; - maxKey = (long) alphType->sMaxVal; + minKey = (long) alphType->sMinVal; + maxKey = (long) alphType->sMaxVal; } else { - minKey = (long) (unsigned long) alphType->uMinVal; - maxKey = (long) (unsigned long) alphType->uMaxVal; + minKey = (long) (unsigned long) alphType->uMinVal; + maxKey = (long) (unsigned long) alphType->uMaxVal; } } @@ -202,25 +202,25 @@ struct KeyOps HostType *typeSubsumes( long long maxVal ) { - HostType *hostTypes = hostLang->hostTypes; - + HostType *hostTypes = hostLang->hostTypes; + for ( int i = 0; i < hostLang->numHostTypes; i++ ) { - long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[i].sMaxVal : hostTypes[i].uMaxVal; - if ( maxVal <= typeMaxVal ) - return &hostLang->hostTypes[i]; + long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[i].sMaxVal : hostTypes[i].uMaxVal; + if ( maxVal <= typeMaxVal ) + return &hostLang->hostTypes[i]; } - + return 0; } HostType *typeSubsumes( bool isSigned, long long maxVal ) { - HostType *hostTypes = hostLang->hostTypes; - + HostType *hostTypes = hostLang->hostTypes; + for ( int i = 0; i < hostLang->numHostTypes; i++ ) { - long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[i].sMaxVal : hostTypes[i].uMaxVal; - if ( ( ( isSigned && hostTypes[i].isSigned ) || !isSigned ) && - maxVal <= typeMaxVal ) + long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[i].sMaxVal : hostTypes[i].uMaxVal; + if ( ( ( isSigned && hostTypes[i].isSigned ) || !isSigned ) && + maxVal <= typeMaxVal ) return hostLang->hostTypes + i; } return 0; diff --git a/contrib/tools/ragel6/config.h b/contrib/tools/ragel6/config.h index 8629850b31..4298aecef9 100644 --- a/contrib/tools/ragel6/config.h +++ b/contrib/tools/ragel6/config.h @@ -1,5 +1,5 @@ /* ragel/config.h. Generated from config.h.in by configure. */ -/* ragel/config.h.in. Generated from configure.ac by autoheader. */ +/* ragel/config.h.in. Generated from configure.ac by autoheader. */ /* Name of package */ #define PACKAGE "ragel" @@ -11,16 +11,16 @@ #define PACKAGE_NAME "ragel" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "ragel 6.10" +#define PACKAGE_STRING "ragel 6.10" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "ragel" -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + /* Define to the version of this package. */ -#define PACKAGE_VERSION "6.10" +#define PACKAGE_VERSION "6.10" /* Version number of package */ -#define VERSION "6.10" +#define VERSION "6.10" diff --git a/contrib/tools/ragel6/cscodegen.cpp b/contrib/tools/ragel6/cscodegen.cpp index 37eb5211de..7ff9ba5b54 100644 --- a/contrib/tools/ragel6/cscodegen.cpp +++ b/contrib/tools/ragel6/cscodegen.cpp @@ -340,10 +340,10 @@ string CSharpFsmCodeGen::ALPHA_KEY( Key key ) if (key.getVal() > 0xFFFF) { ret << key.getVal(); } else { - if ( keyOps->alphType->isChar ) - ret << "'\\u" << std::hex << std::setw(4) << std::setfill('0') << key.getVal() << "'"; - else - ret << key.getVal(); + if ( keyOps->alphType->isChar ) + ret << "'\\u" << std::hex << std::setw(4) << std::setfill('0') << key.getVal() << "'"; + else + ret << key.getVal(); } //ret << "(char) " << key.getVal(); return ret.str(); @@ -635,7 +635,7 @@ void CSharpFsmCodeGen::STATE_IDS() out << "\n"; - if ( !noEntry && entryPointNames.length() > 0 ) { + if ( !noEntry && entryPointNames.length() > 0 ) { for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << " = " << entryPointIds[en.pos()] << ";\n"; @@ -674,12 +674,12 @@ string CSharpCodeGen::GET_KEY() } else { /* Expression for retrieving the key, use simple dereference. */ - if ( dataExpr == 0 ) - ret << "data"; - else - INLINE_LIST( ret, dataExpr, 0, false ); - - ret << "[" << P() << "]"; + if ( dataExpr == 0 ) + ret << "data"; + else + INLINE_LIST( ret, dataExpr, 0, false ); + + ret << "[" << P() << "]"; } return ret.str(); } diff --git a/contrib/tools/ragel6/csflat.cpp b/contrib/tools/ragel6/csflat.cpp index 4d5bafa124..eca9de1a1b 100644 --- a/contrib/tools/ragel6/csflat.cpp +++ b/contrib/tools/ragel6/csflat.cpp @@ -267,11 +267,11 @@ std::ostream &CSharpFlatCodeGen::COND_KEYS() /* Output one last number so we don't have to figure out when the last * entry is and avoid writing a comma. */ - if ( keyOps->alphType->isChar ) - out << "(char) " << 0 << "\n"; - else - out << 0 << "\n"; - + if ( keyOps->alphType->isChar ) + out << "(char) " << 0 << "\n"; + else + out << 0 << "\n"; + return out; } @@ -356,11 +356,11 @@ std::ostream &CSharpFlatCodeGen::KEYS() /* Output one last number so we don't have to figure out when the last * entry is and avoid writing a comma. */ - if ( keyOps->alphType->isChar ) - out << "(char) " << 0 << "\n"; - else - out << 0 << "\n"; - + if ( keyOps->alphType->isChar ) + out << "(char) " << 0 << "\n"; + else + out << 0 << "\n"; + return out; } @@ -724,8 +724,8 @@ void CSharpFlatCodeGen::writeExec() redFsm->anyRegActions() || redFsm->anyFromStateActions() ) { out << - " int _acts;\n" - " int _nacts;\n"; + " int _acts;\n" + " int _nacts;\n"; } out << diff --git a/contrib/tools/ragel6/csflat.h b/contrib/tools/ragel6/csflat.h index a576cd953f..68bd6f3c57 100644 --- a/contrib/tools/ragel6/csflat.h +++ b/contrib/tools/ragel6/csflat.h @@ -85,7 +85,7 @@ protected: virtual void writeExec(); void initVarTypes(); - string slenType, transType, indsType, condsType; + string slenType, transType, indsType, condsType; }; #endif diff --git a/contrib/tools/ragel6/cstable.cpp b/contrib/tools/ragel6/cstable.cpp index 13c9e738ca..058ae0878c 100644 --- a/contrib/tools/ragel6/cstable.cpp +++ b/contrib/tools/ragel6/cstable.cpp @@ -372,11 +372,11 @@ std::ostream &CSharpTabCodeGen::COND_KEYS() /* Output one last number so we don't have to figure out when the last * entry is and avoid writing a comma. */ - if ( keyOps->alphType->isChar ) - out << "(char) " << 0 << "\n"; - else - out << 0 << "\n"; - + if ( keyOps->alphType->isChar ) + out << "(char) " << 0 << "\n"; + else + out << 0 << "\n"; + return out; } @@ -428,11 +428,11 @@ std::ostream &CSharpTabCodeGen::KEYS() /* Output one last number so we don't have to figure out when the last * entry is and avoid writing a comma. */ - if ( keyOps->alphType->isChar ) - out << "(char) " << 0 << "\n"; - else - out << 0 << "\n"; - + if ( keyOps->alphType->isChar ) + out << "(char) " << 0 << "\n"; + else + out << 0 << "\n"; + return out; } @@ -618,22 +618,22 @@ std::ostream &CSharpTabCodeGen::TRANS_ACTIONS_WI() void CSharpTabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) { - ret << "{" << vCS() << " = " << gotoDest << ";"; - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{" << vCS() << " = " << gotoDest << ";"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void CSharpTabCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) { ret << "{" << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << ");"; - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << ");"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void CSharpTabCodeGen::CURS( ostream &ret, bool inFinish ) @@ -665,14 +665,14 @@ void CSharpTabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inF INLINE_LIST( ret, prePushExpr, 0, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << "{"; + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = " << callDest << ";"; + + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } @@ -684,35 +684,35 @@ void CSharpTabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targS INLINE_LIST( ret, prePushExpr, 0, false ); } - ret << "{"; - - ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; + ret << "{"; + + ret << STACK() << "[" << TOP() << "++] = " << vCS() << "; " << vCS() << " = ("; INLINE_LIST( ret, ilItem->children, targState, inFinish ); - ret << ");"; - - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << ");"; + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; + if ( prePushExpr != 0 ) ret << "}"; } void CSharpTabCodeGen::RET( ostream &ret, bool inFinish ) { - ret << "{"; - - ret << vCS() << " = " << STACK() << "[--" << TOP() << "]; "; + ret << "{"; + ret << vCS() << " = " << STACK() << "[--" << TOP() << "]; "; + if ( postPopExpr != 0 ) { ret << "{"; INLINE_LIST( ret, postPopExpr, 0, false ); ret << "}"; } - ret << CTRL_FLOW() << "goto _again;"; - - ret << "}"; + ret << CTRL_FLOW() << "goto _again;"; + + ret << "}"; } void CSharpTabCodeGen::BREAK( ostream &ret, int targState ) @@ -978,8 +978,8 @@ void CSharpTabCodeGen::writeExec() || redFsm->anyFromStateActions() ) { out << - " int _acts;\n" - " int _nacts;\n"; + " int _acts;\n" + " int _nacts;\n"; } out << @@ -1106,9 +1106,9 @@ void CSharpTabCodeGen::writeExec() if ( redFsm->anyEofActions() ) { out << - " int __acts = " << + " int __acts = " << EA() << "[" << vCS() << "]" << ";\n" - " int __nacts = " << + " int __nacts = " << A() << "[__acts++];\n" " while ( __nacts-- > 0 ) {\n" " switch ( " << A() << "[__acts++] ) {\n"; diff --git a/contrib/tools/ragel6/dotcodegen.cpp b/contrib/tools/ragel6/dotcodegen.cpp index 7a83c46c0d..30c33ce0ea 100644 --- a/contrib/tools/ragel6/dotcodegen.cpp +++ b/contrib/tools/ragel6/dotcodegen.cpp @@ -33,9 +33,9 @@ using std::cerr; using std::endl; /* Override this so that write statement processing is ignored */ -bool GraphvizDotGen::writeStatement( InputLoc &, int, char ** ) +bool GraphvizDotGen::writeStatement( InputLoc &, int, char ** ) { - return false; + return false; } std::ostream &GraphvizDotGen::KEY( Key key ) diff --git a/contrib/tools/ragel6/dotcodegen.h b/contrib/tools/ragel6/dotcodegen.h index 97dd3afa41..1f61d8497f 100644 --- a/contrib/tools/ragel6/dotcodegen.h +++ b/contrib/tools/ragel6/dotcodegen.h @@ -35,7 +35,7 @@ public: void writeDotFile( ); virtual void finishRagelDef(); - virtual bool writeStatement( InputLoc &, int, char ** ); + virtual bool writeStatement( InputLoc &, int, char ** ); private: /* Writing labels and actions. */ diff --git a/contrib/tools/ragel6/fsmgraph.h b/contrib/tools/ragel6/fsmgraph.h index c7e676b309..703b2c1e41 100644 --- a/contrib/tools/ragel6/fsmgraph.h +++ b/contrib/tools/ragel6/fsmgraph.h @@ -859,7 +859,7 @@ template <class ListItem1, class ListItem2> PairIter<ListItem1, ListItem2>::Pair #define CO_RETURN(label) \ itState = label; \ return; \ - entry##label: {} + entry##label: {} /* Return and re-entry for the co-routine iterators. This should ALWAYS be * used inside of a block. */ @@ -867,7 +867,7 @@ template <class ListItem1, class ListItem2> PairIter<ListItem1, ListItem2>::Pair itState = label; \ userState = uState; \ return; \ - entry##label: {} + entry##label: {} /* Advance to the next transition. When returns, trans points to the next * transition, unless there are no more, in which case end() returns true. */ diff --git a/contrib/tools/ragel6/gendata.cpp b/contrib/tools/ragel6/gendata.cpp index 737a53c7d8..1d009e571d 100644 --- a/contrib/tools/ragel6/gendata.cpp +++ b/contrib/tools/ragel6/gendata.cpp @@ -49,22 +49,22 @@ #include "javacodegen.h" -#include "gocodegen.h" -#include "gotable.h" -#include "goftable.h" -#include "goflat.h" -#include "gofflat.h" -#include "gogoto.h" -#include "gofgoto.h" -#include "goipgoto.h" - -#include "mltable.h" -#include "mlftable.h" -#include "mlflat.h" -#include "mlfflat.h" -#include "mlgoto.h" -#include "mlfgoto.h" - +#include "gocodegen.h" +#include "gotable.h" +#include "goftable.h" +#include "goflat.h" +#include "gofflat.h" +#include "gogoto.h" +#include "gofgoto.h" +#include "goipgoto.h" + +#include "mltable.h" +#include "mlftable.h" +#include "mlflat.h" +#include "mlfflat.h" +#include "mlgoto.h" +#include "mlfgoto.h" + #include "rubytable.h" #include "rubyftable.h" #include "rubyflat.h" @@ -161,35 +161,35 @@ CodeGenData *cdMakeCodeGen( const char *sourceFileName, const char *fsmName, ost } break; - case HostLang::D2: - switch ( codeStyle ) { - case GenTables: - codeGen = new D2TabCodeGen(out); - break; - case GenFTables: - codeGen = new D2FTabCodeGen(out); - break; - case GenFlat: - codeGen = new D2FlatCodeGen(out); - break; - case GenFFlat: - codeGen = new D2FFlatCodeGen(out); - break; - case GenGoto: - codeGen = new D2GotoCodeGen(out); - break; - case GenFGoto: - codeGen = new D2FGotoCodeGen(out); - break; - case GenIpGoto: - codeGen = new D2IpGotoCodeGen(out); - break; - case GenSplit: - codeGen = new D2SplitCodeGen(out); - break; - } - break; - + case HostLang::D2: + switch ( codeStyle ) { + case GenTables: + codeGen = new D2TabCodeGen(out); + break; + case GenFTables: + codeGen = new D2FTabCodeGen(out); + break; + case GenFlat: + codeGen = new D2FlatCodeGen(out); + break; + case GenFFlat: + codeGen = new D2FFlatCodeGen(out); + break; + case GenGoto: + codeGen = new D2GotoCodeGen(out); + break; + case GenFGoto: + codeGen = new D2FGotoCodeGen(out); + break; + case GenIpGoto: + codeGen = new D2IpGotoCodeGen(out); + break; + case GenSplit: + codeGen = new D2SplitCodeGen(out); + break; + } + break; + default: break; } @@ -211,44 +211,44 @@ CodeGenData *javaMakeCodeGen( const char *sourceFileName, const char *fsmName, o } /* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *goMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) -{ - CodeGenData *codeGen = 0; - - switch ( codeStyle ) { - case GenTables: - codeGen = new GoTabCodeGen(out); - break; - case GenFTables: - codeGen = new GoFTabCodeGen(out); - break; - case GenFlat: - codeGen = new GoFlatCodeGen(out); - break; - case GenFFlat: - codeGen = new GoFFlatCodeGen(out); - break; - case GenGoto: - codeGen = new GoGotoCodeGen(out); - break; - case GenFGoto: - codeGen = new GoFGotoCodeGen(out); - break; - case GenIpGoto: - codeGen = new GoIpGotoCodeGen(out); - break; - default: - cerr << "Invalid output style, only -T0, -T1, -F0, -F1, -G0, -G1 and -G2 are supported for Go.\n"; - exit(1); - } - - codeGen->sourceFileName = sourceFileName; - codeGen->fsmName = fsmName; - - return codeGen; -} - -/* Invoked by the parser when a ragel definition is opened. */ +CodeGenData *goMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) +{ + CodeGenData *codeGen = 0; + + switch ( codeStyle ) { + case GenTables: + codeGen = new GoTabCodeGen(out); + break; + case GenFTables: + codeGen = new GoFTabCodeGen(out); + break; + case GenFlat: + codeGen = new GoFlatCodeGen(out); + break; + case GenFFlat: + codeGen = new GoFFlatCodeGen(out); + break; + case GenGoto: + codeGen = new GoGotoCodeGen(out); + break; + case GenFGoto: + codeGen = new GoFGotoCodeGen(out); + break; + case GenIpGoto: + codeGen = new GoIpGotoCodeGen(out); + break; + default: + cerr << "Invalid output style, only -T0, -T1, -F0, -F1, -G0, -G1 and -G2 are supported for Go.\n"; + exit(1); + } + + codeGen->sourceFileName = sourceFileName; + codeGen->fsmName = fsmName; + + return codeGen; +} + +/* Invoked by the parser when a ragel definition is opened. */ CodeGenData *rubyMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *codeGen = 0; @@ -325,42 +325,42 @@ CodeGenData *csharpMakeCodeGen( const char *sourceFileName, const char *fsmName, return codeGen; } -/* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *ocamlMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) -{ - CodeGenData *codeGen = 0; - - switch ( codeStyle ) { - case GenTables: - codeGen = new OCamlTabCodeGen(out); - break; - case GenFTables: - codeGen = new OCamlFTabCodeGen(out); - break; - case GenFlat: - codeGen = new OCamlFlatCodeGen(out); - break; - case GenFFlat: - codeGen = new OCamlFFlatCodeGen(out); - break; - case GenGoto: - codeGen = new OCamlGotoCodeGen(out); - break; - case GenFGoto: - codeGen = new OCamlFGotoCodeGen(out); - break; - default: - cerr << "I only support the -T0 -T1 -F0 -F1 -G0 and -G1 output styles for OCaml.\n"; - exit(1); - } - - codeGen->sourceFileName = sourceFileName; - codeGen->fsmName = fsmName; - - return codeGen; -} - - +/* Invoked by the parser when a ragel definition is opened. */ +CodeGenData *ocamlMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) +{ + CodeGenData *codeGen = 0; + + switch ( codeStyle ) { + case GenTables: + codeGen = new OCamlTabCodeGen(out); + break; + case GenFTables: + codeGen = new OCamlFTabCodeGen(out); + break; + case GenFlat: + codeGen = new OCamlFlatCodeGen(out); + break; + case GenFFlat: + codeGen = new OCamlFFlatCodeGen(out); + break; + case GenGoto: + codeGen = new OCamlGotoCodeGen(out); + break; + case GenFGoto: + codeGen = new OCamlFGotoCodeGen(out); + break; + default: + cerr << "I only support the -T0 -T1 -F0 -F1 -G0 and -G1 output styles for OCaml.\n"; + exit(1); + } + + codeGen->sourceFileName = sourceFileName; + codeGen->fsmName = fsmName; + + return codeGen; +} + + CodeGenData *makeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *cgd = 0; @@ -370,18 +370,18 @@ CodeGenData *makeCodeGen( const char *sourceFileName, const char *fsmName, ostre cgd = cdMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangD ) cgd = cdMakeCodeGen( sourceFileName, fsmName, out ); - else if ( hostLang == &hostLangD2 ) - cgd = cdMakeCodeGen( sourceFileName, fsmName, out ); - else if ( hostLang == &hostLangGo ) - cgd = goMakeCodeGen( sourceFileName, fsmName, out ); + else if ( hostLang == &hostLangD2 ) + cgd = cdMakeCodeGen( sourceFileName, fsmName, out ); + else if ( hostLang == &hostLangGo ) + cgd = goMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangJava ) cgd = javaMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangRuby ) cgd = rubyMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangCSharp ) cgd = csharpMakeCodeGen( sourceFileName, fsmName, out ); - else if ( hostLang == &hostLangOCaml ) - cgd = ocamlMakeCodeGen( sourceFileName, fsmName, out ); + else if ( hostLang == &hostLangOCaml ) + cgd = ocamlMakeCodeGen( sourceFileName, fsmName, out ); return cgd; } @@ -392,18 +392,18 @@ void lineDirective( ostream &out, const char *fileName, int line ) cdLineDirective( out, fileName, line ); else if ( hostLang == &hostLangD ) cdLineDirective( out, fileName, line ); - else if ( hostLang == &hostLangD2 ) - cdLineDirective( out, fileName, line ); - else if ( hostLang == &hostLangGo ) - goLineDirective( out, fileName, line ); + else if ( hostLang == &hostLangD2 ) + cdLineDirective( out, fileName, line ); + else if ( hostLang == &hostLangGo ) + goLineDirective( out, fileName, line ); else if ( hostLang == &hostLangJava ) javaLineDirective( out, fileName, line ); else if ( hostLang == &hostLangRuby ) rubyLineDirective( out, fileName, line ); else if ( hostLang == &hostLangCSharp ) csharpLineDirective( out, fileName, line ); - else if ( hostLang == &hostLangOCaml ) - ocamlLineDirective( out, fileName, line ); + else if ( hostLang == &hostLangOCaml ) + ocamlLineDirective( out, fileName, line ); } } @@ -452,7 +452,7 @@ CodeGenData::CodeGenData( ostream &out ) noPrefix(false), noFinal(false), noError(false), - noEntry(false), + noEntry(false), noCS(false) {} @@ -838,10 +838,10 @@ void CodeGenData::analyzeAction( GenAction *act, GenInlineList *inlineList ) redFsm->bAnyActionCalls = true; else if ( item->type == GenInlineItem::Ret ) redFsm->bAnyActionRets = true; - - if ( item->type == GenInlineItem::CallExpr || item->type == GenInlineItem::GotoExpr ) - redFsm->bAnyActionByValControl = true; - + + if ( item->type == GenInlineItem::CallExpr || item->type == GenInlineItem::GotoExpr ) + redFsm->bAnyActionByValControl = true; + } /* Check for various things in regular actions. */ @@ -1067,16 +1067,16 @@ void CodeGenData::write_option_error( InputLoc &loc, char *arg ) source_warning(loc) << "unrecognized write option \"" << arg << "\"" << endl; } -/* returns true if the following section should generate line directives. */ -bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) +/* returns true if the following section should generate line directives. */ +bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) { - bool followLineDirective = false; + bool followLineDirective = false; if ( strcmp( args[0], "data" ) == 0 ) { - out << '\n'; - genLineDirective( out ); - followLineDirective = true; - + out << '\n'; + genLineDirective( out ); + followLineDirective = true; + for ( int i = 1; i < nargs; i++ ) { if ( strcmp( args[i], "noerror" ) == 0 ) noError = true; @@ -1084,18 +1084,18 @@ bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) noPrefix = true; else if ( strcmp( args[i], "nofinal" ) == 0 ) noFinal = true; - else if ( strcmp( args[i], "noentry" ) == 0 ) - noEntry = true; + else if ( strcmp( args[i], "noentry" ) == 0 ) + noEntry = true; else write_option_error( loc, args[i] ); } writeData(); } else if ( strcmp( args[0], "init" ) == 0 ) { - out << '\n'; - genLineDirective( out ); - followLineDirective = true; - + out << '\n'; + genLineDirective( out ); + followLineDirective = true; + for ( int i = 1; i < nargs; i++ ) { if ( strcmp( args[i], "nocs" ) == 0 ) noCS = true; @@ -1105,10 +1105,10 @@ bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) writeInit(); } else if ( strcmp( args[0], "exec" ) == 0 ) { - out << '\n'; - genLineDirective( out ); - followLineDirective = true; - + out << '\n'; + genLineDirective( out ); + followLineDirective = true; + for ( int i = 1; i < nargs; i++ ) { if ( strcmp( args[i], "noend" ) == 0 ) noEnd = true; @@ -1118,10 +1118,10 @@ bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) writeExec(); } else if ( strcmp( args[0], "exports" ) == 0 ) { - out << '\n'; - genLineDirective( out ); - followLineDirective = true; - + out << '\n'; + genLineDirective( out ); + followLineDirective = true; + for ( int i = 1; i < nargs; i++ ) write_option_error( loc, args[i] ); writeExports(); @@ -1146,7 +1146,7 @@ bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) source_error(loc) << "unrecognized write command \"" << args[0] << "\"" << endl; } - return followLineDirective; + return followLineDirective; } ostream &CodeGenData::source_warning( const InputLoc &loc ) diff --git a/contrib/tools/ragel6/gendata.h b/contrib/tools/ragel6/gendata.h index 6c3d3852a1..f2642b50b4 100644 --- a/contrib/tools/ragel6/gendata.h +++ b/contrib/tools/ragel6/gendata.h @@ -45,10 +45,10 @@ typedef AvlMapEl<char *, CodeGenData*> CodeGenMapEl; void cdLineDirective( ostream &out, const char *fileName, int line ); void javaLineDirective( ostream &out, const char *fileName, int line ); -void goLineDirective( ostream &out, const char *fileName, int line ); +void goLineDirective( ostream &out, const char *fileName, int line ); void rubyLineDirective( ostream &out, const char *fileName, int line ); void csharpLineDirective( ostream &out, const char *fileName, int line ); -void ocamlLineDirective( ostream &out, const char *fileName, int line ); +void ocamlLineDirective( ostream &out, const char *fileName, int line ); void genLineDirective( ostream &out ); void lineDirective( ostream &out, const char *fileName, int line ); @@ -74,7 +74,7 @@ struct CodeGenData /* This can also be overwridden to modify the processing of write * statements. */ - virtual bool writeStatement( InputLoc &loc, int nargs, char **args ); + virtual bool writeStatement( InputLoc &loc, int nargs, char **args ); /********************/ @@ -129,7 +129,7 @@ struct CodeGenData bool noPrefix; bool noFinal; bool noError; - bool noEntry; + bool noEntry; bool noCS; void createMachine(); diff --git a/contrib/tools/ragel6/gocodegen.cpp b/contrib/tools/ragel6/gocodegen.cpp index d28f0f098a..2a12825b47 100644 --- a/contrib/tools/ragel6/gocodegen.cpp +++ b/contrib/tools/ragel6/gocodegen.cpp @@ -1,775 +1,775 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "gocodegen.h" -#include "ragel.h" -#include "redfsm.h" -#include "gendata.h" -#include <sstream> -#include <string> -#include <assert.h> - - -using std::ostream; -using std::ostringstream; -using std::string; -using std::cerr; -using std::endl; -using std::istream; -using std::ifstream; -using std::ostream; -using std::ios; -using std::cin; -using std::cout; -using std::cerr; -using std::endl; - -/* - * Go Specific - */ - -void goLineDirective( ostream &out, const char *fileName, int line ) -{ - out << "//line " << fileName << ":" << line << endl; -} - -void GoCodeGen::genLineDirective( ostream &out ) -{ - std::streambuf *sbuf = out.rdbuf(); - output_filter *filter = static_cast<output_filter*>(sbuf); - goLineDirective( out, filter->fileName, filter->line + 1 ); -} - -unsigned int GoCodeGen::arrayTypeSize( unsigned long maxVal ) -{ - long long maxValLL = (long long) maxVal; - HostType *arrayType = keyOps->typeSubsumes( maxValLL ); - assert( arrayType != 0 ); - return arrayType->size; -} - -string GoCodeGen::ARRAY_TYPE( unsigned long maxVal ) -{ - long long maxValLL = (long long) maxVal; - HostType *arrayType = keyOps->typeSubsumes( maxValLL ); - assert( arrayType != 0 ); - - string ret = arrayType->data1; - if ( arrayType->data2 != 0 ) { - ret += " "; - ret += arrayType->data2; - } - return ret; -} - - -/* Write out the fsm name. */ -string GoCodeGen::FSM_NAME() -{ - return fsmName; -} - -/* Emit the offset of the start state as a decimal integer. */ -string GoCodeGen::START_STATE_ID() -{ - ostringstream ret; - ret << redFsm->startState->id; - return ret.str(); -}; - -/* Write out the array of actions. */ -std::ostream &GoCodeGen::ACTIONS_ARRAY() -{ - out << " 0, "; - int totalActions = 1; - for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { - /* Write out the length, which will never be the last character. */ - out << act->key.length() << ", "; - if ( totalActions++ % IALL == 0 ) - out << endl << " "; - - for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) { - out << item->value->actionId << ", "; - if ( ! (act.last() && item.last()) ) { - if ( totalActions++ % IALL == 0 ) - out << endl << " "; - } - } - } - out << endl; - return out; -} - - -string GoCodeGen::ACCESS() -{ - ostringstream ret; - if ( accessExpr != 0 ) - INLINE_LIST( ret, accessExpr, 0, false, false ); - return ret.str(); -} - - -string GoCodeGen::P() -{ - ostringstream ret; - if ( pExpr == 0 ) - ret << "p"; - else { - ret << "("; - INLINE_LIST( ret, pExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::PE() -{ - ostringstream ret; - if ( peExpr == 0 ) - ret << "pe"; - else { - ret << "("; - INLINE_LIST( ret, peExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::vEOF() -{ - ostringstream ret; - if ( eofExpr == 0 ) - ret << "eof"; - else { - ret << "("; - INLINE_LIST( ret, eofExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::vCS() -{ - ostringstream ret; - if ( csExpr == 0 ) - ret << ACCESS() << "cs"; - else { - /* Emit the user supplied method of retrieving the key. */ - ret << "("; - INLINE_LIST( ret, csExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::TOP() -{ - ostringstream ret; - if ( topExpr == 0 ) - ret << ACCESS() + "top"; - else { - ret << "("; - INLINE_LIST( ret, topExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::STACK() -{ - ostringstream ret; - if ( stackExpr == 0 ) - ret << ACCESS() + "stack"; - else { - ret << "("; - INLINE_LIST( ret, stackExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::ACT() -{ - ostringstream ret; - if ( actExpr == 0 ) - ret << ACCESS() + "act"; - else { - ret << "("; - INLINE_LIST( ret, actExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::TOKSTART() -{ - ostringstream ret; - if ( tokstartExpr == 0 ) - ret << ACCESS() + "ts"; - else { - ret << "("; - INLINE_LIST( ret, tokstartExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::TOKEND() -{ - ostringstream ret; - if ( tokendExpr == 0 ) - ret << ACCESS() + "te"; - else { - ret << "("; - INLINE_LIST( ret, tokendExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::GET_WIDE_KEY() -{ - if ( redFsm->anyConditions() ) - return "_widec"; - else - return GET_KEY(); -} - -string GoCodeGen::GET_WIDE_KEY( RedStateAp *state ) -{ - if ( state->stateCondList.length() > 0 ) - return "_widec"; - else - return GET_KEY(); -} - -string GoCodeGen::GET_KEY() -{ - ostringstream ret; - if ( getKeyExpr != 0 ) { - /* Emit the user supplied method of retrieving the key. */ - ret << "("; - INLINE_LIST( ret, getKeyExpr, 0, false, false ); - ret << ")"; - } - else { - /* Expression for retrieving the key, use simple dereference. */ - ret << DATA() << "[" << P() << "]"; - } - return ret.str(); -} - -/* Write out level number of tabs. Makes the nested binary search nice - * looking. */ -string GoCodeGen::TABS( int level ) -{ - string result; - while ( level-- > 0 ) - result += "\t"; - return result; -} - -/* Write out a key from the fsm code gen. Depends on wether or not the key is - * signed. */ -string GoCodeGen::KEY( Key key ) -{ - ostringstream ret; - if ( keyOps->isSigned || !hostLang->explicitUnsigned ) - ret << key.getVal(); - else - ret << (unsigned long) key.getVal() << 'u'; - return ret.str(); -} - -bool GoCodeGen::isAlphTypeSigned() -{ - return keyOps->isSigned; -} - -bool GoCodeGen::isWideAlphTypeSigned() -{ - string ret; - if ( redFsm->maxKey <= keyOps->maxKey ) - return isAlphTypeSigned(); - else { - long long maxKeyVal = redFsm->maxKey.getLongLong(); - HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); - return wideType->isSigned; - } -} - -string GoCodeGen::WIDE_KEY( RedStateAp *state, Key key ) -{ - if ( state->stateCondList.length() > 0 ) { - ostringstream ret; - if ( isWideAlphTypeSigned() ) - ret << key.getVal(); - else - ret << (unsigned long) key.getVal() << 'u'; - return ret.str(); - } - else { - return KEY( key ); - } -} - - - -void GoCodeGen::EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ) -{ - /* The parser gives fexec two children. The double brackets are for D - * code. If the inline list is a single word it will get interpreted as a - * C-style cast by the D compiler. */ - ret << P() << " = ("; - INLINE_LIST( ret, item->children, targState, inFinish, false ); - ret << ") - 1" << endl; -} - -void GoCodeGen::LM_SWITCH( ostream &ret, GenInlineItem *item, - int targState, int inFinish, bool csForced ) -{ - ret << - " switch " << ACT() << " {" << endl; - - for ( GenInlineList::Iter lma = *item->children; lma.lte(); lma++ ) { - /* Write the case label, the action and the case break. */ - if ( lma->lmId < 0 ) { - ret << " default:" << endl; - } - else - ret << " case " << lma->lmId << ":" << endl; - - /* Write the block and close it off. */ - ret << " {"; - INLINE_LIST( ret, lma->children, targState, inFinish, csForced ); - ret << "}" << endl; - } - - ret << - " }" << endl << - " "; -} - -void GoCodeGen::SET_ACT( ostream &ret, GenInlineItem *item ) -{ - ret << ACT() << " = " << item->lmId << ";"; -} - -void GoCodeGen::SET_TOKEND( ostream &ret, GenInlineItem *item ) -{ - /* The tokend action sets tokend. */ - ret << TOKEND() << " = " << P(); - if ( item->offset != 0 ) - out << "+" << item->offset; - out << endl; -} - -void GoCodeGen::GET_TOKEND( ostream &ret, GenInlineItem *item ) -{ - ret << TOKEND(); -} - -void GoCodeGen::INIT_TOKSTART( ostream &ret, GenInlineItem *item ) -{ - ret << TOKSTART() << " = " << NULL_ITEM() << endl; -} - -void GoCodeGen::INIT_ACT( ostream &ret, GenInlineItem *item ) -{ - ret << ACT() << " = 0" << endl; -} - -void GoCodeGen::SET_TOKSTART( ostream &ret, GenInlineItem *item ) -{ - ret << TOKSTART() << " = " << P() << endl; -} - -void GoCodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item, - int targState, bool inFinish, bool csForced ) -{ - if ( item->children->length() > 0 ) { - /* Write the block and close it off. */ - ret << "{"; - INLINE_LIST( ret, item->children, targState, inFinish, csForced ); - ret << "}"; - } -} - - -/* Write out an inline tree structure. Walks the list and possibly calls out - * to virtual functions than handle language specific items in the tree. */ -void GoCodeGen::INLINE_LIST( ostream &ret, GenInlineList *inlineList, - int targState, bool inFinish, bool csForced ) -{ - for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { - switch ( item->type ) { - case GenInlineItem::Text: - ret << item->data; - break; - case GenInlineItem::Goto: - GOTO( ret, item->targState->id, inFinish ); - break; - case GenInlineItem::Call: - CALL( ret, item->targState->id, targState, inFinish ); - break; - case GenInlineItem::Next: - NEXT( ret, item->targState->id, inFinish ); - break; - case GenInlineItem::Ret: - RET( ret, inFinish ); - break; - case GenInlineItem::PChar: - ret << P(); - break; - case GenInlineItem::Char: - ret << GET_KEY(); - break; - case GenInlineItem::Hold: - ret << P() << "--" << endl; - break; - case GenInlineItem::Exec: - EXEC( ret, item, targState, inFinish ); - break; - case GenInlineItem::Curs: - CURS( ret, inFinish ); - break; - case GenInlineItem::Targs: - TARGS( ret, inFinish, targState ); - break; - case GenInlineItem::Entry: - ret << item->targState->id; - break; - case GenInlineItem::GotoExpr: - GOTO_EXPR( ret, item, inFinish ); - break; - case GenInlineItem::CallExpr: - CALL_EXPR( ret, item, targState, inFinish ); - break; - case GenInlineItem::NextExpr: - NEXT_EXPR( ret, item, inFinish ); - break; - case GenInlineItem::LmSwitch: - LM_SWITCH( ret, item, targState, inFinish, csForced ); - break; - case GenInlineItem::LmSetActId: - SET_ACT( ret, item ); - break; - case GenInlineItem::LmSetTokEnd: - SET_TOKEND( ret, item ); - break; - case GenInlineItem::LmGetTokEnd: - GET_TOKEND( ret, item ); - break; - case GenInlineItem::LmInitTokStart: - INIT_TOKSTART( ret, item ); - break; - case GenInlineItem::LmInitAct: - INIT_ACT( ret, item ); - break; - case GenInlineItem::LmSetTokStart: - SET_TOKSTART( ret, item ); - break; - case GenInlineItem::SubAction: - SUB_ACTION( ret, item, targState, inFinish, csForced ); - break; - case GenInlineItem::Break: - BREAK( ret, targState, csForced ); - break; - } - } -} -/* Write out paths in line directives. Escapes any special characters. */ -string GoCodeGen::LDIR_PATH( char *path ) -{ - ostringstream ret; - for ( char *pc = path; *pc != 0; pc++ ) { - if ( *pc == '\\' ) - ret << "\\\\"; - else - ret << *pc; - } - return ret.str(); -} - -void GoCodeGen::ACTION( ostream &ret, GenAction *action, int targState, - bool inFinish, bool csForced ) -{ - /* Write the preprocessor line info for going into the source file. */ - goLineDirective( ret, action->loc.fileName, action->loc.line ); - - /* Write the block and close it off. */ - INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced ); - ret << endl; -} - -void GoCodeGen::CONDITION( ostream &ret, GenAction *condition ) -{ - INLINE_LIST( ret, condition->inlineList, 0, false, false ); -} - -string GoCodeGen::ERROR_STATE() -{ - ostringstream ret; - if ( redFsm->errState != 0 ) - ret << redFsm->errState->id; - else - ret << "-1"; - return ret.str(); -} - -string GoCodeGen::FIRST_FINAL_STATE() -{ - ostringstream ret; - if ( redFsm->firstFinState != 0 ) - ret << redFsm->firstFinState->id; - else - ret << redFsm->nextStateId; - return ret.str(); -} - -void GoCodeGen::writeInit() -{ - out << " {" << endl; - - if ( !noCS ) - out << " " << vCS() << " = " << START() << endl; - - /* If there are any calls, then the stack top needs initialization. */ - if ( redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << " " << TOP() << " = 0" << endl; - - if ( hasLongestMatch ) { - out << - " " << TOKSTART() << " = " << NULL_ITEM() << endl << - " " << TOKEND() << " = " << NULL_ITEM() << endl << - " " << ACT() << " = 0" << endl; - } - out << " }" << endl; -} - -string GoCodeGen::DATA() -{ - ostringstream ret; - if ( dataExpr == 0 ) - ret << ACCESS() + "data"; - else { - ret << "("; - INLINE_LIST( ret, dataExpr, 0, false, false ); - ret << ")"; - } - return ret.str(); -} - -string GoCodeGen::DATA_PREFIX() -{ - if ( !noPrefix ) - return FSM_NAME() + "_"; - return ""; -} - -/* Emit the alphabet data type. */ -string GoCodeGen::ALPH_TYPE() -{ - string ret = keyOps->alphType->data1; - if ( keyOps->alphType->data2 != 0 ) { - ret += " "; - ret += + keyOps->alphType->data2; - } - return ret; -} - -/* Emit the alphabet data type. */ -string GoCodeGen::WIDE_ALPH_TYPE() -{ - string ret; - if ( redFsm->maxKey <= keyOps->maxKey ) - ret = ALPH_TYPE(); - else { - long long maxKeyVal = redFsm->maxKey.getLongLong(); - HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); - assert( wideType != 0 ); - - ret = wideType->data1; - if ( wideType->data2 != 0 ) { - ret += " "; - ret += wideType->data2; - } - } - return ret; -} - -void GoCodeGen::STATE_IDS() -{ - if ( redFsm->startState != 0 ) - CONST( "int", START() ) << " = " << START_STATE_ID() << endl; - - if ( !noFinal ) - CONST( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << endl; - - if ( !noError ) - CONST( "int", ERROR() ) << " = " << ERROR_STATE() << endl; - - out << endl; - - if ( !noEntry && entryPointNames.length() > 0 ) { - for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { - CONST( "int", DATA_PREFIX() + "en_" + *en ) << - " = " << entryPointIds[en.pos()] << endl; - } - out << endl; - } -} - -void GoCodeGen::writeStart() -{ - out << START_STATE_ID(); -} - -void GoCodeGen::writeFirstFinal() -{ - out << FIRST_FINAL_STATE(); -} - -void GoCodeGen::writeError() -{ - out << ERROR_STATE(); -} - -void GoCodeGen::finishRagelDef() -{ - if ( codeStyle == GenGoto || codeStyle == GenFGoto || - codeStyle == GenIpGoto || codeStyle == GenSplit ) - { - /* For directly executable machines there is no required state - * ordering. Choose a depth-first ordering to increase the - * potential for fall-throughs. */ - redFsm->depthFirstOrdering(); - } - else { - /* The frontend will do this for us, but it may be a good idea to - * force it if the intermediate file is edited. */ - redFsm->sortByStateId(); - } - - /* Choose default transitions and the single transition. */ - redFsm->chooseDefaultSpan(); - - /* Maybe do flat expand, otherwise choose single. */ - if ( codeStyle == GenFlat || codeStyle == GenFFlat ) - redFsm->makeFlat(); - else - redFsm->chooseSingle(); - - /* If any errors have occured in the input file then don't write anything. */ - if ( gblErrorCount > 0 ) - return; - - if ( codeStyle == GenSplit ) - redFsm->partitionFsm( numSplitPartitions ); - - if ( codeStyle == GenIpGoto || codeStyle == GenSplit ) - redFsm->setInTrans(); - - /* Anlayze Machine will find the final action reference counts, among - * other things. We will use these in reporting the usage - * of fsm directives in action code. */ - analyzeMachine(); - - /* Determine if we should use indicies. */ - calcIndexSize(); -} - -ostream &GoCodeGen::source_warning( const InputLoc &loc ) -{ - cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: "; - return cerr; -} - -ostream &GoCodeGen::source_error( const InputLoc &loc ) -{ - gblErrorCount += 1; - assert( sourceFileName != 0 ); - cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": "; - return cerr; -} - - -/* - * Go implementation. - * - */ - -std::ostream &GoCodeGen::OPEN_ARRAY( string type, string name ) -{ - out << "var " << name << " []" << type << " = []" << type << "{" << endl; - return out; -} - -std::ostream &GoCodeGen::CLOSE_ARRAY() -{ - return out << "}" << endl; -} - -std::ostream &GoCodeGen::STATIC_VAR( string type, string name ) -{ - out << "var " << name << " " << type; - return out; -} - -std::ostream &GoCodeGen::CONST( string type, string name ) -{ - out << "const " << name << " " << type; - return out; -} - -string GoCodeGen::UINT( ) -{ - return "uint"; -} - -string GoCodeGen::INT() -{ - return "int"; -} - -string GoCodeGen::CAST( string type, string expr ) -{ - return type + "(" + expr + ")"; -} - -string GoCodeGen::NULL_ITEM() -{ - return "0"; -} - -void GoCodeGen::writeExports() -{ - if ( exportList.length() > 0 ) { - for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) { - out << "const " << DATA_PREFIX() << "ex_" << ex->name << " = " << - KEY(ex->key) << endl; - } - out << endl; - } -} +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gocodegen.h" +#include "ragel.h" +#include "redfsm.h" +#include "gendata.h" +#include <sstream> +#include <string> +#include <assert.h> + + +using std::ostream; +using std::ostringstream; +using std::string; +using std::cerr; +using std::endl; +using std::istream; +using std::ifstream; +using std::ostream; +using std::ios; +using std::cin; +using std::cout; +using std::cerr; +using std::endl; + +/* + * Go Specific + */ + +void goLineDirective( ostream &out, const char *fileName, int line ) +{ + out << "//line " << fileName << ":" << line << endl; +} + +void GoCodeGen::genLineDirective( ostream &out ) +{ + std::streambuf *sbuf = out.rdbuf(); + output_filter *filter = static_cast<output_filter*>(sbuf); + goLineDirective( out, filter->fileName, filter->line + 1 ); +} + +unsigned int GoCodeGen::arrayTypeSize( unsigned long maxVal ) +{ + long long maxValLL = (long long) maxVal; + HostType *arrayType = keyOps->typeSubsumes( maxValLL ); + assert( arrayType != 0 ); + return arrayType->size; +} + +string GoCodeGen::ARRAY_TYPE( unsigned long maxVal ) +{ + long long maxValLL = (long long) maxVal; + HostType *arrayType = keyOps->typeSubsumes( maxValLL ); + assert( arrayType != 0 ); + + string ret = arrayType->data1; + if ( arrayType->data2 != 0 ) { + ret += " "; + ret += arrayType->data2; + } + return ret; +} + + +/* Write out the fsm name. */ +string GoCodeGen::FSM_NAME() +{ + return fsmName; +} + +/* Emit the offset of the start state as a decimal integer. */ +string GoCodeGen::START_STATE_ID() +{ + ostringstream ret; + ret << redFsm->startState->id; + return ret.str(); +}; + +/* Write out the array of actions. */ +std::ostream &GoCodeGen::ACTIONS_ARRAY() +{ + out << " 0, "; + int totalActions = 1; + for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { + /* Write out the length, which will never be the last character. */ + out << act->key.length() << ", "; + if ( totalActions++ % IALL == 0 ) + out << endl << " "; + + for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) { + out << item->value->actionId << ", "; + if ( ! (act.last() && item.last()) ) { + if ( totalActions++ % IALL == 0 ) + out << endl << " "; + } + } + } + out << endl; + return out; +} + + +string GoCodeGen::ACCESS() +{ + ostringstream ret; + if ( accessExpr != 0 ) + INLINE_LIST( ret, accessExpr, 0, false, false ); + return ret.str(); +} + + +string GoCodeGen::P() +{ + ostringstream ret; + if ( pExpr == 0 ) + ret << "p"; + else { + ret << "("; + INLINE_LIST( ret, pExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::PE() +{ + ostringstream ret; + if ( peExpr == 0 ) + ret << "pe"; + else { + ret << "("; + INLINE_LIST( ret, peExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::vEOF() +{ + ostringstream ret; + if ( eofExpr == 0 ) + ret << "eof"; + else { + ret << "("; + INLINE_LIST( ret, eofExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::vCS() +{ + ostringstream ret; + if ( csExpr == 0 ) + ret << ACCESS() << "cs"; + else { + /* Emit the user supplied method of retrieving the key. */ + ret << "("; + INLINE_LIST( ret, csExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::TOP() +{ + ostringstream ret; + if ( topExpr == 0 ) + ret << ACCESS() + "top"; + else { + ret << "("; + INLINE_LIST( ret, topExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::STACK() +{ + ostringstream ret; + if ( stackExpr == 0 ) + ret << ACCESS() + "stack"; + else { + ret << "("; + INLINE_LIST( ret, stackExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::ACT() +{ + ostringstream ret; + if ( actExpr == 0 ) + ret << ACCESS() + "act"; + else { + ret << "("; + INLINE_LIST( ret, actExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::TOKSTART() +{ + ostringstream ret; + if ( tokstartExpr == 0 ) + ret << ACCESS() + "ts"; + else { + ret << "("; + INLINE_LIST( ret, tokstartExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::TOKEND() +{ + ostringstream ret; + if ( tokendExpr == 0 ) + ret << ACCESS() + "te"; + else { + ret << "("; + INLINE_LIST( ret, tokendExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::GET_WIDE_KEY() +{ + if ( redFsm->anyConditions() ) + return "_widec"; + else + return GET_KEY(); +} + +string GoCodeGen::GET_WIDE_KEY( RedStateAp *state ) +{ + if ( state->stateCondList.length() > 0 ) + return "_widec"; + else + return GET_KEY(); +} + +string GoCodeGen::GET_KEY() +{ + ostringstream ret; + if ( getKeyExpr != 0 ) { + /* Emit the user supplied method of retrieving the key. */ + ret << "("; + INLINE_LIST( ret, getKeyExpr, 0, false, false ); + ret << ")"; + } + else { + /* Expression for retrieving the key, use simple dereference. */ + ret << DATA() << "[" << P() << "]"; + } + return ret.str(); +} + +/* Write out level number of tabs. Makes the nested binary search nice + * looking. */ +string GoCodeGen::TABS( int level ) +{ + string result; + while ( level-- > 0 ) + result += "\t"; + return result; +} + +/* Write out a key from the fsm code gen. Depends on wether or not the key is + * signed. */ +string GoCodeGen::KEY( Key key ) +{ + ostringstream ret; + if ( keyOps->isSigned || !hostLang->explicitUnsigned ) + ret << key.getVal(); + else + ret << (unsigned long) key.getVal() << 'u'; + return ret.str(); +} + +bool GoCodeGen::isAlphTypeSigned() +{ + return keyOps->isSigned; +} + +bool GoCodeGen::isWideAlphTypeSigned() +{ + string ret; + if ( redFsm->maxKey <= keyOps->maxKey ) + return isAlphTypeSigned(); + else { + long long maxKeyVal = redFsm->maxKey.getLongLong(); + HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); + return wideType->isSigned; + } +} + +string GoCodeGen::WIDE_KEY( RedStateAp *state, Key key ) +{ + if ( state->stateCondList.length() > 0 ) { + ostringstream ret; + if ( isWideAlphTypeSigned() ) + ret << key.getVal(); + else + ret << (unsigned long) key.getVal() << 'u'; + return ret.str(); + } + else { + return KEY( key ); + } +} + + + +void GoCodeGen::EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ) +{ + /* The parser gives fexec two children. The double brackets are for D + * code. If the inline list is a single word it will get interpreted as a + * C-style cast by the D compiler. */ + ret << P() << " = ("; + INLINE_LIST( ret, item->children, targState, inFinish, false ); + ret << ") - 1" << endl; +} + +void GoCodeGen::LM_SWITCH( ostream &ret, GenInlineItem *item, + int targState, int inFinish, bool csForced ) +{ + ret << + " switch " << ACT() << " {" << endl; + + for ( GenInlineList::Iter lma = *item->children; lma.lte(); lma++ ) { + /* Write the case label, the action and the case break. */ + if ( lma->lmId < 0 ) { + ret << " default:" << endl; + } + else + ret << " case " << lma->lmId << ":" << endl; + + /* Write the block and close it off. */ + ret << " {"; + INLINE_LIST( ret, lma->children, targState, inFinish, csForced ); + ret << "}" << endl; + } + + ret << + " }" << endl << + " "; +} + +void GoCodeGen::SET_ACT( ostream &ret, GenInlineItem *item ) +{ + ret << ACT() << " = " << item->lmId << ";"; +} + +void GoCodeGen::SET_TOKEND( ostream &ret, GenInlineItem *item ) +{ + /* The tokend action sets tokend. */ + ret << TOKEND() << " = " << P(); + if ( item->offset != 0 ) + out << "+" << item->offset; + out << endl; +} + +void GoCodeGen::GET_TOKEND( ostream &ret, GenInlineItem *item ) +{ + ret << TOKEND(); +} + +void GoCodeGen::INIT_TOKSTART( ostream &ret, GenInlineItem *item ) +{ + ret << TOKSTART() << " = " << NULL_ITEM() << endl; +} + +void GoCodeGen::INIT_ACT( ostream &ret, GenInlineItem *item ) +{ + ret << ACT() << " = 0" << endl; +} + +void GoCodeGen::SET_TOKSTART( ostream &ret, GenInlineItem *item ) +{ + ret << TOKSTART() << " = " << P() << endl; +} + +void GoCodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item, + int targState, bool inFinish, bool csForced ) +{ + if ( item->children->length() > 0 ) { + /* Write the block and close it off. */ + ret << "{"; + INLINE_LIST( ret, item->children, targState, inFinish, csForced ); + ret << "}"; + } +} + + +/* Write out an inline tree structure. Walks the list and possibly calls out + * to virtual functions than handle language specific items in the tree. */ +void GoCodeGen::INLINE_LIST( ostream &ret, GenInlineList *inlineList, + int targState, bool inFinish, bool csForced ) +{ + for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { + switch ( item->type ) { + case GenInlineItem::Text: + ret << item->data; + break; + case GenInlineItem::Goto: + GOTO( ret, item->targState->id, inFinish ); + break; + case GenInlineItem::Call: + CALL( ret, item->targState->id, targState, inFinish ); + break; + case GenInlineItem::Next: + NEXT( ret, item->targState->id, inFinish ); + break; + case GenInlineItem::Ret: + RET( ret, inFinish ); + break; + case GenInlineItem::PChar: + ret << P(); + break; + case GenInlineItem::Char: + ret << GET_KEY(); + break; + case GenInlineItem::Hold: + ret << P() << "--" << endl; + break; + case GenInlineItem::Exec: + EXEC( ret, item, targState, inFinish ); + break; + case GenInlineItem::Curs: + CURS( ret, inFinish ); + break; + case GenInlineItem::Targs: + TARGS( ret, inFinish, targState ); + break; + case GenInlineItem::Entry: + ret << item->targState->id; + break; + case GenInlineItem::GotoExpr: + GOTO_EXPR( ret, item, inFinish ); + break; + case GenInlineItem::CallExpr: + CALL_EXPR( ret, item, targState, inFinish ); + break; + case GenInlineItem::NextExpr: + NEXT_EXPR( ret, item, inFinish ); + break; + case GenInlineItem::LmSwitch: + LM_SWITCH( ret, item, targState, inFinish, csForced ); + break; + case GenInlineItem::LmSetActId: + SET_ACT( ret, item ); + break; + case GenInlineItem::LmSetTokEnd: + SET_TOKEND( ret, item ); + break; + case GenInlineItem::LmGetTokEnd: + GET_TOKEND( ret, item ); + break; + case GenInlineItem::LmInitTokStart: + INIT_TOKSTART( ret, item ); + break; + case GenInlineItem::LmInitAct: + INIT_ACT( ret, item ); + break; + case GenInlineItem::LmSetTokStart: + SET_TOKSTART( ret, item ); + break; + case GenInlineItem::SubAction: + SUB_ACTION( ret, item, targState, inFinish, csForced ); + break; + case GenInlineItem::Break: + BREAK( ret, targState, csForced ); + break; + } + } +} +/* Write out paths in line directives. Escapes any special characters. */ +string GoCodeGen::LDIR_PATH( char *path ) +{ + ostringstream ret; + for ( char *pc = path; *pc != 0; pc++ ) { + if ( *pc == '\\' ) + ret << "\\\\"; + else + ret << *pc; + } + return ret.str(); +} + +void GoCodeGen::ACTION( ostream &ret, GenAction *action, int targState, + bool inFinish, bool csForced ) +{ + /* Write the preprocessor line info for going into the source file. */ + goLineDirective( ret, action->loc.fileName, action->loc.line ); + + /* Write the block and close it off. */ + INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced ); + ret << endl; +} + +void GoCodeGen::CONDITION( ostream &ret, GenAction *condition ) +{ + INLINE_LIST( ret, condition->inlineList, 0, false, false ); +} + +string GoCodeGen::ERROR_STATE() +{ + ostringstream ret; + if ( redFsm->errState != 0 ) + ret << redFsm->errState->id; + else + ret << "-1"; + return ret.str(); +} + +string GoCodeGen::FIRST_FINAL_STATE() +{ + ostringstream ret; + if ( redFsm->firstFinState != 0 ) + ret << redFsm->firstFinState->id; + else + ret << redFsm->nextStateId; + return ret.str(); +} + +void GoCodeGen::writeInit() +{ + out << " {" << endl; + + if ( !noCS ) + out << " " << vCS() << " = " << START() << endl; + + /* If there are any calls, then the stack top needs initialization. */ + if ( redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << " " << TOP() << " = 0" << endl; + + if ( hasLongestMatch ) { + out << + " " << TOKSTART() << " = " << NULL_ITEM() << endl << + " " << TOKEND() << " = " << NULL_ITEM() << endl << + " " << ACT() << " = 0" << endl; + } + out << " }" << endl; +} + +string GoCodeGen::DATA() +{ + ostringstream ret; + if ( dataExpr == 0 ) + ret << ACCESS() + "data"; + else { + ret << "("; + INLINE_LIST( ret, dataExpr, 0, false, false ); + ret << ")"; + } + return ret.str(); +} + +string GoCodeGen::DATA_PREFIX() +{ + if ( !noPrefix ) + return FSM_NAME() + "_"; + return ""; +} + +/* Emit the alphabet data type. */ +string GoCodeGen::ALPH_TYPE() +{ + string ret = keyOps->alphType->data1; + if ( keyOps->alphType->data2 != 0 ) { + ret += " "; + ret += + keyOps->alphType->data2; + } + return ret; +} + +/* Emit the alphabet data type. */ +string GoCodeGen::WIDE_ALPH_TYPE() +{ + string ret; + if ( redFsm->maxKey <= keyOps->maxKey ) + ret = ALPH_TYPE(); + else { + long long maxKeyVal = redFsm->maxKey.getLongLong(); + HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); + assert( wideType != 0 ); + + ret = wideType->data1; + if ( wideType->data2 != 0 ) { + ret += " "; + ret += wideType->data2; + } + } + return ret; +} + +void GoCodeGen::STATE_IDS() +{ + if ( redFsm->startState != 0 ) + CONST( "int", START() ) << " = " << START_STATE_ID() << endl; + + if ( !noFinal ) + CONST( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << endl; + + if ( !noError ) + CONST( "int", ERROR() ) << " = " << ERROR_STATE() << endl; + + out << endl; + + if ( !noEntry && entryPointNames.length() > 0 ) { + for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { + CONST( "int", DATA_PREFIX() + "en_" + *en ) << + " = " << entryPointIds[en.pos()] << endl; + } + out << endl; + } +} + +void GoCodeGen::writeStart() +{ + out << START_STATE_ID(); +} + +void GoCodeGen::writeFirstFinal() +{ + out << FIRST_FINAL_STATE(); +} + +void GoCodeGen::writeError() +{ + out << ERROR_STATE(); +} + +void GoCodeGen::finishRagelDef() +{ + if ( codeStyle == GenGoto || codeStyle == GenFGoto || + codeStyle == GenIpGoto || codeStyle == GenSplit ) + { + /* For directly executable machines there is no required state + * ordering. Choose a depth-first ordering to increase the + * potential for fall-throughs. */ + redFsm->depthFirstOrdering(); + } + else { + /* The frontend will do this for us, but it may be a good idea to + * force it if the intermediate file is edited. */ + redFsm->sortByStateId(); + } + + /* Choose default transitions and the single transition. */ + redFsm->chooseDefaultSpan(); + + /* Maybe do flat expand, otherwise choose single. */ + if ( codeStyle == GenFlat || codeStyle == GenFFlat ) + redFsm->makeFlat(); + else + redFsm->chooseSingle(); + + /* If any errors have occured in the input file then don't write anything. */ + if ( gblErrorCount > 0 ) + return; + + if ( codeStyle == GenSplit ) + redFsm->partitionFsm( numSplitPartitions ); + + if ( codeStyle == GenIpGoto || codeStyle == GenSplit ) + redFsm->setInTrans(); + + /* Anlayze Machine will find the final action reference counts, among + * other things. We will use these in reporting the usage + * of fsm directives in action code. */ + analyzeMachine(); + + /* Determine if we should use indicies. */ + calcIndexSize(); +} + +ostream &GoCodeGen::source_warning( const InputLoc &loc ) +{ + cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: "; + return cerr; +} + +ostream &GoCodeGen::source_error( const InputLoc &loc ) +{ + gblErrorCount += 1; + assert( sourceFileName != 0 ); + cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": "; + return cerr; +} + + +/* + * Go implementation. + * + */ + +std::ostream &GoCodeGen::OPEN_ARRAY( string type, string name ) +{ + out << "var " << name << " []" << type << " = []" << type << "{" << endl; + return out; +} + +std::ostream &GoCodeGen::CLOSE_ARRAY() +{ + return out << "}" << endl; +} + +std::ostream &GoCodeGen::STATIC_VAR( string type, string name ) +{ + out << "var " << name << " " << type; + return out; +} + +std::ostream &GoCodeGen::CONST( string type, string name ) +{ + out << "const " << name << " " << type; + return out; +} + +string GoCodeGen::UINT( ) +{ + return "uint"; +} + +string GoCodeGen::INT() +{ + return "int"; +} + +string GoCodeGen::CAST( string type, string expr ) +{ + return type + "(" + expr + ")"; +} + +string GoCodeGen::NULL_ITEM() +{ + return "0"; +} + +void GoCodeGen::writeExports() +{ + if ( exportList.length() > 0 ) { + for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) { + out << "const " << DATA_PREFIX() << "ex_" << ex->name << " = " << + KEY(ex->key) << endl; + } + out << endl; + } +} diff --git a/contrib/tools/ragel6/gocodegen.h b/contrib/tools/ragel6/gocodegen.h index 50e8804b55..e7df71591f 100644 --- a/contrib/tools/ragel6/gocodegen.h +++ b/contrib/tools/ragel6/gocodegen.h @@ -1,181 +1,181 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOCODEGEN_H -#define _GOCODEGEN_H - -#include <iostream> -#include <string> -#include <stdio.h> -#include "common.h" -#include "gendata.h" - -using std::string; -using std::ostream; - -/* Integer array line length. */ -#define IALL 8 - -/* Forwards. */ -struct RedFsmAp; -struct RedStateAp; -struct CodeGenData; -struct GenAction; -struct NameInst; -struct GenInlineItem; -struct GenInlineList; -struct RedAction; -struct LongestMatch; -struct LongestMatchPart; - -class GoCodeGen : public CodeGenData -{ -public: - GoCodeGen( ostream &out ) - : CodeGenData(out) {} - - virtual ~GoCodeGen() {} - - virtual void finishRagelDef(); - virtual void writeInit(); - virtual void writeStart(); - virtual void writeFirstFinal(); - virtual void writeError(); - virtual void writeExports(); -protected: - string FSM_NAME(); - string START_STATE_ID(); - ostream &ACTIONS_ARRAY(); - string GET_WIDE_KEY(); - string GET_WIDE_KEY( RedStateAp *state ); - string TABS( int level ); - string KEY( Key key ); - string WIDE_KEY( RedStateAp *state, Key key ); - string LDIR_PATH( char *path ); - virtual void ACTION( ostream &ret, GenAction *action, int targState, - bool inFinish, bool csForced ); - void CONDITION( ostream &ret, GenAction *condition ); - string ALPH_TYPE(); - string WIDE_ALPH_TYPE(); - string ARRAY_TYPE( unsigned long maxVal ); - - bool isAlphTypeSigned(); - bool isWideAlphTypeSigned(); - - virtual string CAST( string type, string expr ); - virtual string UINT(); - virtual string INT(); - virtual string NULL_ITEM(); - virtual string GET_KEY(); - - string P(); - string PE(); - string vEOF(); - - string ACCESS(); - string vCS(); - string STACK(); - string TOP(); - string TOKSTART(); - string TOKEND(); - string ACT(); - string DATA(); - - string DATA_PREFIX(); - string PM() { return "_" + DATA_PREFIX() + "partition_map"; } - string C() { return "_" + DATA_PREFIX() + "cond_spaces"; } - string CK() { return "_" + DATA_PREFIX() + "cond_keys"; } - string K() { return "_" + DATA_PREFIX() + "trans_keys"; } - string I() { return "_" + DATA_PREFIX() + "indicies"; } - string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; } - string KO() { return "_" + DATA_PREFIX() + "key_offsets"; } - string IO() { return "_" + DATA_PREFIX() + "index_offsets"; } - string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; } - string SL() { return "_" + DATA_PREFIX() + "single_lengths"; } - string RL() { return "_" + DATA_PREFIX() + "range_lengths"; } - string A() { return "_" + DATA_PREFIX() + "actions"; } - string TA() { return "_" + DATA_PREFIX() + "trans_actions"; } - string TT() { return "_" + DATA_PREFIX() + "trans_targs"; } - string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; } - string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; } - string EA() { return "_" + DATA_PREFIX() + "eof_actions"; } - string ET() { return "_" + DATA_PREFIX() + "eof_trans"; } - string SP() { return "_" + DATA_PREFIX() + "key_spans"; } - string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; } - string START() { return DATA_PREFIX() + "start"; } - string ERROR() { return DATA_PREFIX() + "error"; } - string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } - string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } - - void INLINE_LIST( ostream &ret, GenInlineList *inlineList, - int targState, bool inFinish, bool csForced ); - virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; - virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0; - virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0; - virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; - virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; - virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, - int targState, bool inFinish ) = 0; - virtual void RET( ostream &ret, bool inFinish ) = 0; - virtual void BREAK( ostream &ret, int targState, bool csForced ) = 0; - virtual void CURS( ostream &ret, bool inFinish ) = 0; - virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0; - void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ); - void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState, - int inFinish, bool csForced ); - void SET_ACT( ostream &ret, GenInlineItem *item ); - void INIT_TOKSTART( ostream &ret, GenInlineItem *item ); - void INIT_ACT( ostream &ret, GenInlineItem *item ); - void SET_TOKSTART( ostream &ret, GenInlineItem *item ); - void SET_TOKEND( ostream &ret, GenInlineItem *item ); - void GET_TOKEND( ostream &ret, GenInlineItem *item ); - virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, - int targState, bool inFinish, bool csForced ); - void STATE_IDS(); - - string ERROR_STATE(); - string FIRST_FINAL_STATE(); - - virtual ostream &OPEN_ARRAY( string type, string name ); - virtual ostream &CLOSE_ARRAY(); - virtual ostream &STATIC_VAR( string type, string name ); - virtual ostream &CONST( string type, string name ); - - ostream &source_warning(const InputLoc &loc); - ostream &source_error(const InputLoc &loc); - - unsigned int arrayTypeSize( unsigned long maxVal ); - - bool outLabelUsed; - bool testEofUsed; - bool againLabelUsed; - bool useIndicies; - - void genLineDirective( ostream &out ); - -public: - /* Determine if we should use indicies. */ - virtual void calcIndexSize() {} -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOCODEGEN_H +#define _GOCODEGEN_H + +#include <iostream> +#include <string> +#include <stdio.h> +#include "common.h" +#include "gendata.h" + +using std::string; +using std::ostream; + +/* Integer array line length. */ +#define IALL 8 + +/* Forwards. */ +struct RedFsmAp; +struct RedStateAp; +struct CodeGenData; +struct GenAction; +struct NameInst; +struct GenInlineItem; +struct GenInlineList; +struct RedAction; +struct LongestMatch; +struct LongestMatchPart; + +class GoCodeGen : public CodeGenData +{ +public: + GoCodeGen( ostream &out ) + : CodeGenData(out) {} + + virtual ~GoCodeGen() {} + + virtual void finishRagelDef(); + virtual void writeInit(); + virtual void writeStart(); + virtual void writeFirstFinal(); + virtual void writeError(); + virtual void writeExports(); +protected: + string FSM_NAME(); + string START_STATE_ID(); + ostream &ACTIONS_ARRAY(); + string GET_WIDE_KEY(); + string GET_WIDE_KEY( RedStateAp *state ); + string TABS( int level ); + string KEY( Key key ); + string WIDE_KEY( RedStateAp *state, Key key ); + string LDIR_PATH( char *path ); + virtual void ACTION( ostream &ret, GenAction *action, int targState, + bool inFinish, bool csForced ); + void CONDITION( ostream &ret, GenAction *condition ); + string ALPH_TYPE(); + string WIDE_ALPH_TYPE(); + string ARRAY_TYPE( unsigned long maxVal ); + + bool isAlphTypeSigned(); + bool isWideAlphTypeSigned(); + + virtual string CAST( string type, string expr ); + virtual string UINT(); + virtual string INT(); + virtual string NULL_ITEM(); + virtual string GET_KEY(); + + string P(); + string PE(); + string vEOF(); + + string ACCESS(); + string vCS(); + string STACK(); + string TOP(); + string TOKSTART(); + string TOKEND(); + string ACT(); + string DATA(); + + string DATA_PREFIX(); + string PM() { return "_" + DATA_PREFIX() + "partition_map"; } + string C() { return "_" + DATA_PREFIX() + "cond_spaces"; } + string CK() { return "_" + DATA_PREFIX() + "cond_keys"; } + string K() { return "_" + DATA_PREFIX() + "trans_keys"; } + string I() { return "_" + DATA_PREFIX() + "indicies"; } + string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; } + string KO() { return "_" + DATA_PREFIX() + "key_offsets"; } + string IO() { return "_" + DATA_PREFIX() + "index_offsets"; } + string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; } + string SL() { return "_" + DATA_PREFIX() + "single_lengths"; } + string RL() { return "_" + DATA_PREFIX() + "range_lengths"; } + string A() { return "_" + DATA_PREFIX() + "actions"; } + string TA() { return "_" + DATA_PREFIX() + "trans_actions"; } + string TT() { return "_" + DATA_PREFIX() + "trans_targs"; } + string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; } + string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; } + string EA() { return "_" + DATA_PREFIX() + "eof_actions"; } + string ET() { return "_" + DATA_PREFIX() + "eof_trans"; } + string SP() { return "_" + DATA_PREFIX() + "key_spans"; } + string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; } + string START() { return DATA_PREFIX() + "start"; } + string ERROR() { return DATA_PREFIX() + "error"; } + string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } + string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } + + void INLINE_LIST( ostream &ret, GenInlineList *inlineList, + int targState, bool inFinish, bool csForced ); + virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; + virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0; + virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0; + virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; + virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; + virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, + int targState, bool inFinish ) = 0; + virtual void RET( ostream &ret, bool inFinish ) = 0; + virtual void BREAK( ostream &ret, int targState, bool csForced ) = 0; + virtual void CURS( ostream &ret, bool inFinish ) = 0; + virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0; + void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ); + void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState, + int inFinish, bool csForced ); + void SET_ACT( ostream &ret, GenInlineItem *item ); + void INIT_TOKSTART( ostream &ret, GenInlineItem *item ); + void INIT_ACT( ostream &ret, GenInlineItem *item ); + void SET_TOKSTART( ostream &ret, GenInlineItem *item ); + void SET_TOKEND( ostream &ret, GenInlineItem *item ); + void GET_TOKEND( ostream &ret, GenInlineItem *item ); + virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, + int targState, bool inFinish, bool csForced ); + void STATE_IDS(); + + string ERROR_STATE(); + string FIRST_FINAL_STATE(); + + virtual ostream &OPEN_ARRAY( string type, string name ); + virtual ostream &CLOSE_ARRAY(); + virtual ostream &STATIC_VAR( string type, string name ); + virtual ostream &CONST( string type, string name ); + + ostream &source_warning(const InputLoc &loc); + ostream &source_error(const InputLoc &loc); + + unsigned int arrayTypeSize( unsigned long maxVal ); + + bool outLabelUsed; + bool testEofUsed; + bool againLabelUsed; + bool useIndicies; + + void genLineDirective( ostream &out ); + +public: + /* Determine if we should use indicies. */ + virtual void calcIndexSize() {} +}; + +#endif diff --git a/contrib/tools/ragel6/gofflat.cpp b/contrib/tools/ragel6/gofflat.cpp index 59e729c76b..4dfd6ca5ce 100644 --- a/contrib/tools/ragel6/gofflat.cpp +++ b/contrib/tools/ragel6/gofflat.cpp @@ -1,380 +1,380 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "gofflat.h" -#include "redfsm.h" -#include "gendata.h" - -using std::endl; - -std::ostream &GoFFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &GoFFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &GoFFlatCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->actListId+1; - out << act; - return out; -} - -/* Write out the function for a transition. */ -std::ostream &GoFFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - int action = 0; - if ( trans->action != 0 ) - action = trans->action->actListId+1; - out << action; - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFFlatCodeGen::TO_STATE_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numToStateRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFFlatCodeGen::FROM_STATE_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numFromStateRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoFFlatCodeGen::EOF_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numEofRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, true, false ); - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFFlatCodeGen::ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -void GoFFlatCodeGen::writeData() -{ - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); - COND_KEY_SPANS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); - CONDS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); - COND_INDEX_OFFSET(); - CLOSE_ARRAY() << - endl; - } - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); - KEY_SPANS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); - FLAT_INDEX_OFFSET(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - endl; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - endl; - } - - STATE_IDS(); -} - -void GoFFlatCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << - " {" << endl << - " var _slen " << INT() << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << endl; - - out << " var _trans " << INT() << endl; - - if ( redFsm->anyConditions() ) - out << " var _cond " << INT() << endl; - - out << - " var _keys " << INT() << endl << - " var _inds " << INT() << endl; - - if ( redFsm->anyConditions() ) { - out << - " var _conds " << INT() << endl << - " var _widec " << WIDE_ALPH_TYPE() << endl; - } - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - out << "_resume:" << endl; - - if ( redFsm->anyFromStateActions() ) { - out << - " switch " << FSA() << "[" << vCS() << "] {" << endl; - FROM_STATE_ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - LOCATE_TRANS(); - - if ( redFsm->anyEofTrans() ) - out << "_eof_trans:" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " _ps = " << vCS() << endl; - - out << - " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << - endl; - - if ( redFsm->anyRegActions() ) { - out << - " if " << TA() << "[_trans] == 0 {" << endl << - " goto _again" << endl << - " }" << endl << - endl << - " switch " << TA() << "[_trans] {" << endl; - ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || - redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "_again:" << endl; - - if ( redFsm->anyToStateActions() ) { - out << - " switch " << TSA() << "[" << vCS() << "] {" << endl; - TO_STATE_ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - if ( !noEnd ) { - out << - " if " << P() << "++; " << P() << " != " << PE() << " {" - " goto _resume" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl << - " goto _resume" << endl; - } - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << ET() << "[" << vCS() << "] > 0 {" << endl << - " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << - " goto _eof_trans" << endl << - " }" << endl; - } - - if ( redFsm->anyEofActions() ) { - out << - " switch " << EA() << "[" << vCS() << "] {" << endl; - EOF_ACTION_SWITCH(2); - out << - " }" << endl; - } - - out << - " }" << endl << - endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << " }" << endl; -} +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "gofflat.h" +#include "redfsm.h" +#include "gendata.h" + +using std::endl; + +std::ostream &GoFFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &GoFFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &GoFFlatCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->actListId+1; + out << act; + return out; +} + +/* Write out the function for a transition. */ +std::ostream &GoFFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + int action = 0; + if ( trans->action != 0 ) + action = trans->action->actListId+1; + out << action; + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFFlatCodeGen::TO_STATE_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numToStateRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFFlatCodeGen::FROM_STATE_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numFromStateRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoFFlatCodeGen::EOF_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numEofRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, true, false ); + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFFlatCodeGen::ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +void GoFFlatCodeGen::writeData() +{ + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); + COND_KEY_SPANS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); + CONDS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); + COND_INDEX_OFFSET(); + CLOSE_ARRAY() << + endl; + } + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); + KEY_SPANS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); + FLAT_INDEX_OFFSET(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + endl; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + endl; + } + + STATE_IDS(); +} + +void GoFFlatCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << + " {" << endl << + " var _slen " << INT() << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << endl; + + out << " var _trans " << INT() << endl; + + if ( redFsm->anyConditions() ) + out << " var _cond " << INT() << endl; + + out << + " var _keys " << INT() << endl << + " var _inds " << INT() << endl; + + if ( redFsm->anyConditions() ) { + out << + " var _conds " << INT() << endl << + " var _widec " << WIDE_ALPH_TYPE() << endl; + } + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + out << "_resume:" << endl; + + if ( redFsm->anyFromStateActions() ) { + out << + " switch " << FSA() << "[" << vCS() << "] {" << endl; + FROM_STATE_ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + LOCATE_TRANS(); + + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " _ps = " << vCS() << endl; + + out << + " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << + endl; + + if ( redFsm->anyRegActions() ) { + out << + " if " << TA() << "[_trans] == 0 {" << endl << + " goto _again" << endl << + " }" << endl << + endl << + " switch " << TA() << "[_trans] {" << endl; + ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || + redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "_again:" << endl; + + if ( redFsm->anyToStateActions() ) { + out << + " switch " << TSA() << "[" << vCS() << "] {" << endl; + TO_STATE_ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + if ( !noEnd ) { + out << + " if " << P() << "++; " << P() << " != " << PE() << " {" + " goto _resume" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl << + " goto _resume" << endl; + } + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << ET() << "[" << vCS() << "] > 0 {" << endl << + " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << + " goto _eof_trans" << endl << + " }" << endl; + } + + if ( redFsm->anyEofActions() ) { + out << + " switch " << EA() << "[" << vCS() << "] {" << endl; + EOF_ACTION_SWITCH(2); + out << + " }" << endl; + } + + out << + " }" << endl << + endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << " }" << endl; +} diff --git a/contrib/tools/ragel6/gofflat.h b/contrib/tools/ragel6/gofflat.h index bd3bde4cbf..3560b9d09c 100644 --- a/contrib/tools/ragel6/gofflat.h +++ b/contrib/tools/ragel6/gofflat.h @@ -1,58 +1,58 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOFFLAT_H -#define _GOFFLAT_H - -#include <iostream> -#include "goflat.h" - -/* Forwards. */ -struct CodeGenData; - -/* - * FFlatCodeGen - */ -class GoFFlatCodeGen - : public GoFlatCodeGen -{ -public: - GoFFlatCodeGen( ostream &out ) - : GoFlatCodeGen(out) {} - -protected: - std::ostream &TO_STATE_ACTION_SWITCH( int level ); - std::ostream &FROM_STATE_ACTION_SWITCH( int level ); - std::ostream &EOF_ACTION_SWITCH( int level ); - std::ostream &ACTION_SWITCH( int level ); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOFFLAT_H +#define _GOFFLAT_H + +#include <iostream> +#include "goflat.h" + +/* Forwards. */ +struct CodeGenData; + +/* + * FFlatCodeGen + */ +class GoFFlatCodeGen + : public GoFlatCodeGen +{ +public: + GoFFlatCodeGen( ostream &out ) + : GoFlatCodeGen(out) {} + +protected: + std::ostream &TO_STATE_ACTION_SWITCH( int level ); + std::ostream &FROM_STATE_ACTION_SWITCH( int level ); + std::ostream &EOF_ACTION_SWITCH( int level ); + std::ostream &ACTION_SWITCH( int level ); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/gofgoto.cpp b/contrib/tools/ragel6/gofgoto.cpp index 4f6ce36883..ea07b53e9a 100644 --- a/contrib/tools/ragel6/gofgoto.cpp +++ b/contrib/tools/ragel6/gofgoto.cpp @@ -1,297 +1,297 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "gofgoto.h" -#include "redfsm.h" -#include "gendata.h" -#include "bstmap.h" - -using std::endl; - -std::ostream &GoFGotoCodeGen::EXEC_ACTIONS() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - /* We are at the start of a glob, write the case. */ - out << "f" << redAct->actListId << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - - out << TABS(1) << "goto _again" << endl; - } - } - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFGotoCodeGen::TO_STATE_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numToStateRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFGotoCodeGen::FROM_STATE_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numFromStateRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoFGotoCodeGen::EOF_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numEofRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, true, false ); - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &GoFGotoCodeGen::FINISH_CASES() -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* States that are final and have an out action need a case. */ - if ( st->eofAction != 0 ) { - /* Write the case label. */ - out << TABS(2) << "case " << st->id << ":" << endl; - - /* Jump to the func. */ - out << TABS(3) << "goto f" << st->eofAction->actListId << endl; - } - } - - return out; -} - -unsigned int GoFGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->actListId+1; - return act; -} - -unsigned int GoFGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->actListId+1; - return act; -} - -unsigned int GoFGotoCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->actListId+1; - return act; -} - -void GoFGotoCodeGen::writeData() -{ - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - STATE_IDS(); -} - -void GoFGotoCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << " {" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << " = 0" << endl; - - if ( redFsm->anyConditions() ) - out << " var _widec " << WIDE_ALPH_TYPE() << endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - out << "_resume:" << endl; - - if ( redFsm->anyFromStateActions() ) { - out << - " switch " << FSA() << "[" << vCS() << "] {" << endl; - FROM_STATE_ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - out << - " switch " << vCS() << " {" << endl; - STATE_GOTOS(1); - out << - " }" << endl << - endl; - TRANSITIONS() << - endl; - - if ( redFsm->anyRegActions() ) - EXEC_ACTIONS() << endl; - - out << "_again:" << endl; - - if ( redFsm->anyToStateActions() ) { - out << - " switch " << TSA() << "[" << vCS() << "] {" << endl; - TO_STATE_ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - if ( !noEnd ) { - out << - " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << - " goto _resume" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl << - " goto _resume" << endl; - } - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl; - - if ( redFsm->anyEofTrans() ) { - out << - " switch " << vCS() << " {" << endl; - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) - out << - " case " << st->id << ":" << endl << - " goto tr" << st->eofTrans->id << endl; - } - - out << - " }" << endl; - } - - if ( redFsm->anyEofActions() ) { - out << - " switch " << EA() << "[" << vCS() << "] {" << endl; - EOF_ACTION_SWITCH(2); - out << - " }" << endl; - } - - out << - " }" << endl << - endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << " }" << endl; -} +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "gofgoto.h" +#include "redfsm.h" +#include "gendata.h" +#include "bstmap.h" + +using std::endl; + +std::ostream &GoFGotoCodeGen::EXEC_ACTIONS() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + /* We are at the start of a glob, write the case. */ + out << "f" << redAct->actListId << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + + out << TABS(1) << "goto _again" << endl; + } + } + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFGotoCodeGen::TO_STATE_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numToStateRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFGotoCodeGen::FROM_STATE_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numFromStateRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoFGotoCodeGen::EOF_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numEofRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, true, false ); + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &GoFGotoCodeGen::FINISH_CASES() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* States that are final and have an out action need a case. */ + if ( st->eofAction != 0 ) { + /* Write the case label. */ + out << TABS(2) << "case " << st->id << ":" << endl; + + /* Jump to the func. */ + out << TABS(3) << "goto f" << st->eofAction->actListId << endl; + } + } + + return out; +} + +unsigned int GoFGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->actListId+1; + return act; +} + +unsigned int GoFGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->actListId+1; + return act; +} + +unsigned int GoFGotoCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->actListId+1; + return act; +} + +void GoFGotoCodeGen::writeData() +{ + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + STATE_IDS(); +} + +void GoFGotoCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << " {" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << " = 0" << endl; + + if ( redFsm->anyConditions() ) + out << " var _widec " << WIDE_ALPH_TYPE() << endl; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + out << "_resume:" << endl; + + if ( redFsm->anyFromStateActions() ) { + out << + " switch " << FSA() << "[" << vCS() << "] {" << endl; + FROM_STATE_ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + out << + " switch " << vCS() << " {" << endl; + STATE_GOTOS(1); + out << + " }" << endl << + endl; + TRANSITIONS() << + endl; + + if ( redFsm->anyRegActions() ) + EXEC_ACTIONS() << endl; + + out << "_again:" << endl; + + if ( redFsm->anyToStateActions() ) { + out << + " switch " << TSA() << "[" << vCS() << "] {" << endl; + TO_STATE_ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + if ( !noEnd ) { + out << + " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << + " goto _resume" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl << + " goto _resume" << endl; + } + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl; + + if ( redFsm->anyEofTrans() ) { + out << + " switch " << vCS() << " {" << endl; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << + " case " << st->id << ":" << endl << + " goto tr" << st->eofTrans->id << endl; + } + + out << + " }" << endl; + } + + if ( redFsm->anyEofActions() ) { + out << + " switch " << EA() << "[" << vCS() << "] {" << endl; + EOF_ACTION_SWITCH(2); + out << + " }" << endl; + } + + out << + " }" << endl << + endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << " }" << endl; +} diff --git a/contrib/tools/ragel6/gofgoto.h b/contrib/tools/ragel6/gofgoto.h index c53e450436..6daa634cb1 100644 --- a/contrib/tools/ragel6/gofgoto.h +++ b/contrib/tools/ragel6/gofgoto.h @@ -1,54 +1,54 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOFGOTO_H -#define _GOFGOTO_H - -#include <iostream> -#include "gogoto.h" - -/* Forwards. */ -struct CodeGenData; - - -class GoFGotoCodeGen - : public GoGotoCodeGen -{ -public: - GoFGotoCodeGen( ostream &out ) - : GoGotoCodeGen(out) {} - - std::ostream &EXEC_ACTIONS(); - std::ostream &TO_STATE_ACTION_SWITCH( int level ); - std::ostream &FROM_STATE_ACTION_SWITCH( int level ); - std::ostream &FINISH_CASES(); - std::ostream &EOF_ACTION_SWITCH( int level ); - unsigned int TO_STATE_ACTION( RedStateAp *state ); - unsigned int FROM_STATE_ACTION( RedStateAp *state ); - unsigned int EOF_ACTION( RedStateAp *state ); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOFGOTO_H +#define _GOFGOTO_H + +#include <iostream> +#include "gogoto.h" + +/* Forwards. */ +struct CodeGenData; + + +class GoFGotoCodeGen + : public GoGotoCodeGen +{ +public: + GoFGotoCodeGen( ostream &out ) + : GoGotoCodeGen(out) {} + + std::ostream &EXEC_ACTIONS(); + std::ostream &TO_STATE_ACTION_SWITCH( int level ); + std::ostream &FROM_STATE_ACTION_SWITCH( int level ); + std::ostream &FINISH_CASES(); + std::ostream &EOF_ACTION_SWITCH( int level ); + unsigned int TO_STATE_ACTION( RedStateAp *state ); + unsigned int FROM_STATE_ACTION( RedStateAp *state ); + unsigned int EOF_ACTION( RedStateAp *state ); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/goflat.cpp b/contrib/tools/ragel6/goflat.cpp index bc7f51c6e7..e65abb01d2 100644 --- a/contrib/tools/ragel6/goflat.cpp +++ b/contrib/tools/ragel6/goflat.cpp @@ -1,764 +1,764 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "goflat.h" -#include "redfsm.h" -#include "gendata.h" - -using std::endl; - -std::ostream &GoFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->location+1; - out << act; - return out; -} - -std::ostream &GoFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->location+1; - out << act; - return out; -} - -std::ostream &GoFlatCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->location+1; - out << act; - return out; -} - -std::ostream &GoFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - /* If there are actions, emit them. Otherwise emit zero. */ - int act = 0; - if ( trans->action != 0 ) - act = trans->action->location+1; - out << act; - return out; -} - -std::ostream &GoFlatCodeGen::TO_STATE_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numToStateRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoFlatCodeGen::FROM_STATE_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numFromStateRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoFlatCodeGen::EOF_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numEofRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, true, false ); - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &GoFlatCodeGen::ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numTransRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &GoFlatCodeGen::FLAT_INDEX_OFFSET() -{ - out << " "; - int totalStateNum = 0, curIndOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the index offset. */ - out << curIndOffset << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - - /* Move the index offset ahead. */ - if ( st->transList != 0 ) - curIndOffset += keyOps->span( st->lowKey, st->highKey ); - - if ( st->defTrans != 0 ) - curIndOffset += 1; - } - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::KEY_SPANS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - unsigned long long span = 0; - if ( st->transList != 0 ) - span = keyOps->span( st->lowKey, st->highKey ); - out << span << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::TO_STATE_ACTIONS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - TO_STATE_ACTION(st); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::FROM_STATE_ACTIONS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - FROM_STATE_ACTION(st); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::EOF_ACTIONS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - EOF_ACTION(st); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::EOF_TRANS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - - long trans = 0; - if ( st->eofTrans != 0 ) { - assert( st->eofTrans->pos >= 0 ); - trans = st->eofTrans->pos+1; - } - out << trans << ", "; - - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - - -std::ostream &GoFlatCodeGen::COND_KEYS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Emit just cond low key and cond high key. */ - out << KEY( st->condLowKey ) << ", "; - out << KEY( st->condHighKey ) << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::COND_KEY_SPANS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - unsigned long long span = 0; - if ( st->condList != 0 ) - span = keyOps->span( st->condLowKey, st->condHighKey ); - out << span << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::CONDS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->condList != 0 ) { - /* Walk the singles. */ - unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey ); - for ( unsigned long long pos = 0; pos < span; pos++ ) { - if ( st->condList[pos] != 0 ) - out << st->condList[pos]->condSpaceId + 1 << ", "; - else - out << "0, "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - } - } - - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::COND_INDEX_OFFSET() -{ - out << " "; - int totalStateNum = 0; - int curIndOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the index offset. */ - out << curIndOffset << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - - /* Move the index offset ahead. */ - if ( st->condList != 0 ) - curIndOffset += keyOps->span( st->condLowKey, st->condHighKey ); - } - out << endl; - return out; -} - - -std::ostream &GoFlatCodeGen::KEYS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Emit just low key and high key. */ - out << KEY( st->lowKey ) << ", "; - out << KEY( st->highKey ) << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::INDICIES() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->transList != 0 ) { - /* Walk the singles. */ - unsigned long long span = keyOps->span( st->lowKey, st->highKey ); - for ( unsigned long long pos = 0; pos < span; pos++ ) { - out << st->transList[pos]->id << ", "; - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - - /* The state's default index goes next. */ - if ( st->defTrans != 0 ) { - out << st->defTrans->id << ", "; - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoFlatCodeGen::TRANS_TARGS() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << " "; - int totalStates = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Save the position. Needed for eofTargs. */ - RedTransAp *trans = transPtrs[t]; - trans->pos = t; - - /* Write out the target state. */ - out << trans->targ->id << ", "; - if ( t < redFsm->transSet.length()-1 ) { - if ( ++totalStates % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] transPtrs; - return out; -} - - -std::ostream &GoFlatCodeGen::TRANS_ACTIONS() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << " "; - int totalAct = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Write the function for the transition. */ - RedTransAp *trans = transPtrs[t]; - TRANS_ACTION( trans ); - out << ", "; - if ( t < redFsm->transSet.length()-1 ) { - if ( ++totalAct % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] transPtrs; - return out; -} - -void GoFlatCodeGen::LOCATE_TRANS() -{ - out << - " _keys = " << CAST(INT(), vCS() + " << 1") << endl << - " _inds = " << CAST(INT(), IO() + "[" + vCS() + "]") << endl << - endl << - " _slen = " << CAST(INT(), SP() + "[" + vCS() + "]") << endl << - " if _slen > 0 && " << K() << "[_keys] <= " << GET_WIDE_KEY() << " && " << - GET_WIDE_KEY() << " <= " << K() << "[_keys + 1]" << " {" << endl << - " _trans = " << CAST(INT(), I() + "[_inds + " + CAST(INT(), GET_WIDE_KEY() + " - " + K() + "[_keys]") + "]") << endl << - " } else {" << endl << - " _trans = " << CAST(INT(), I() + "[_inds + _slen]") << endl << - " }" << endl << - endl; -} - -void GoFlatCodeGen::writeData() -{ - /* If there are any transtion functions then output the array. If there - * are none, don't bother emitting an empty array that won't be used. */ - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); - ACTIONS_ARRAY(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); - COND_KEY_SPANS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); - CONDS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); - COND_INDEX_OFFSET(); - CLOSE_ARRAY() << - endl; - } - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); - KEY_SPANS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); - FLAT_INDEX_OFFSET(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - endl; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - endl; - } - - STATE_IDS(); -} - -void GoFlatCodeGen::COND_TRANSLATE() -{ - out << - " _widec = " << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << endl; - - out << - " _keys = " << CAST(INT(), vCS() + " << 1") << endl << - " _conds = " << CAST(INT(), CO() + "[" + vCS() + "]") << endl << - endl << - " _slen = " << CAST(INT(), CSP() + "[" + vCS() + "]") << endl << - " if _slen > 0 && " << CK() << "[_keys]" << " <= " << GET_WIDE_KEY() << " && " << - GET_WIDE_KEY() << " <= " << CK() << "[_keys + 1] {" << endl << - " _cond = " << CAST(INT(), C() + "[_conds + " + CAST(INT(), GET_WIDE_KEY() + " - " + CK() + "[_keys]") + "]") << endl << - " } else {" << endl << - " _cond = 0" << endl << - " }" << endl << - endl; - - out << - " switch _cond {" << endl; - for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { - GenCondSpace *condSpace = csi; - out << " case " << condSpace->condSpaceId + 1 << ":" << endl; - out << TABS(2) << "_widec = " << - KEY(condSpace->baseKey) << " + (" << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << - " - " << KEY(keyOps->minKey) << ")" << endl; - - for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { - out << TABS(2) << "if "; - CONDITION( out, *csi ); - Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); - out << " {" << endl << - " _widec += " << condValOffset << endl << - " }" << endl; - } - } - - out << - " }" << endl; -} - -void GoFlatCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << - " {" << endl << - " var _slen " << INT() << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << endl; - - out << - " var _trans " << INT() << endl; - - if ( redFsm->anyConditions() ) - out << " var _cond " << INT() << endl; - - if ( redFsm->anyToStateActions() || - redFsm->anyRegActions() || redFsm->anyFromStateActions() ) - { - out << - " var _acts " << INT() << endl << - " var _nacts " << UINT() << endl; - } - - out << - " var _keys " << INT() << endl << - " var _inds " << INT() << endl; - - if ( redFsm->anyConditions() ) { - out << - " var _conds " << INT() << endl << - " var _widec " << WIDE_ALPH_TYPE() << endl; - } - - out << endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - out << "_resume:" << endl; - - if ( redFsm->anyFromStateActions() ) { - out << - " _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - FROM_STATE_ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << - endl; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - LOCATE_TRANS(); - - if ( redFsm->anyEofTrans() ) - out << "_eof_trans:" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " _ps = " << vCS() << endl; - - out << - " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << - endl; - - if ( redFsm->anyRegActions() ) { - out << - " if " << TA() << "[_trans] == 0 {" << endl << - " goto _again" << endl << - " }" << endl << - endl << - " _acts = " << CAST(INT(), TA() + "[_trans]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << - endl; - } - - if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || - redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "_again:" << endl; - - if ( redFsm->anyToStateActions() ) { - out << - " _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - TO_STATE_ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << - endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - if ( !noEnd ) { - out << - " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << - " goto _resume" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl << - " goto _resume" << endl; - } - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << ET() << "[" << vCS() << "] > 0 {" << endl << - " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << - " goto _eof_trans" << endl << - " }" << endl; - } - - if ( redFsm->anyEofActions() ) { - out << - " __acts := " << CAST(INT(), EA() + "[" + vCS() + "]") << endl << - " __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl << - " for ; __nacts > 0; __nacts-- {" << endl << - " __acts++" << endl << - " switch " << A() << "[__acts - 1]" << " {" << endl; - EOF_ACTION_SWITCH(3); - out << - " }" << endl << - " }" << endl; - } - - out << - " }" << endl << - endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << " }" << endl; -} +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "goflat.h" +#include "redfsm.h" +#include "gendata.h" + +using std::endl; + +std::ostream &GoFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->location+1; + out << act; + return out; +} + +std::ostream &GoFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->location+1; + out << act; + return out; +} + +std::ostream &GoFlatCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->location+1; + out << act; + return out; +} + +std::ostream &GoFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + /* If there are actions, emit them. Otherwise emit zero. */ + int act = 0; + if ( trans->action != 0 ) + act = trans->action->location+1; + out << act; + return out; +} + +std::ostream &GoFlatCodeGen::TO_STATE_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numToStateRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoFlatCodeGen::FROM_STATE_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numFromStateRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoFlatCodeGen::EOF_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numEofRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, true, false ); + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &GoFlatCodeGen::ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numTransRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &GoFlatCodeGen::FLAT_INDEX_OFFSET() +{ + out << " "; + int totalStateNum = 0, curIndOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the index offset. */ + out << curIndOffset << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + + /* Move the index offset ahead. */ + if ( st->transList != 0 ) + curIndOffset += keyOps->span( st->lowKey, st->highKey ); + + if ( st->defTrans != 0 ) + curIndOffset += 1; + } + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::KEY_SPANS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + unsigned long long span = 0; + if ( st->transList != 0 ) + span = keyOps->span( st->lowKey, st->highKey ); + out << span << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::TO_STATE_ACTIONS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + TO_STATE_ACTION(st); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::FROM_STATE_ACTIONS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + FROM_STATE_ACTION(st); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::EOF_ACTIONS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + EOF_ACTION(st); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::EOF_TRANS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + + long trans = 0; + if ( st->eofTrans != 0 ) { + assert( st->eofTrans->pos >= 0 ); + trans = st->eofTrans->pos+1; + } + out << trans << ", "; + + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + + +std::ostream &GoFlatCodeGen::COND_KEYS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Emit just cond low key and cond high key. */ + out << KEY( st->condLowKey ) << ", "; + out << KEY( st->condHighKey ) << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::COND_KEY_SPANS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + unsigned long long span = 0; + if ( st->condList != 0 ) + span = keyOps->span( st->condLowKey, st->condHighKey ); + out << span << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::CONDS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->condList != 0 ) { + /* Walk the singles. */ + unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey ); + for ( unsigned long long pos = 0; pos < span; pos++ ) { + if ( st->condList[pos] != 0 ) + out << st->condList[pos]->condSpaceId + 1 << ", "; + else + out << "0, "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + } + } + + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::COND_INDEX_OFFSET() +{ + out << " "; + int totalStateNum = 0; + int curIndOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the index offset. */ + out << curIndOffset << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + + /* Move the index offset ahead. */ + if ( st->condList != 0 ) + curIndOffset += keyOps->span( st->condLowKey, st->condHighKey ); + } + out << endl; + return out; +} + + +std::ostream &GoFlatCodeGen::KEYS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Emit just low key and high key. */ + out << KEY( st->lowKey ) << ", "; + out << KEY( st->highKey ) << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::INDICIES() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->transList != 0 ) { + /* Walk the singles. */ + unsigned long long span = keyOps->span( st->lowKey, st->highKey ); + for ( unsigned long long pos = 0; pos < span; pos++ ) { + out << st->transList[pos]->id << ", "; + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + + /* The state's default index goes next. */ + if ( st->defTrans != 0 ) { + out << st->defTrans->id << ", "; + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoFlatCodeGen::TRANS_TARGS() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << " "; + int totalStates = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Save the position. Needed for eofTargs. */ + RedTransAp *trans = transPtrs[t]; + trans->pos = t; + + /* Write out the target state. */ + out << trans->targ->id << ", "; + if ( t < redFsm->transSet.length()-1 ) { + if ( ++totalStates % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] transPtrs; + return out; +} + + +std::ostream &GoFlatCodeGen::TRANS_ACTIONS() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << " "; + int totalAct = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Write the function for the transition. */ + RedTransAp *trans = transPtrs[t]; + TRANS_ACTION( trans ); + out << ", "; + if ( t < redFsm->transSet.length()-1 ) { + if ( ++totalAct % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] transPtrs; + return out; +} + +void GoFlatCodeGen::LOCATE_TRANS() +{ + out << + " _keys = " << CAST(INT(), vCS() + " << 1") << endl << + " _inds = " << CAST(INT(), IO() + "[" + vCS() + "]") << endl << + endl << + " _slen = " << CAST(INT(), SP() + "[" + vCS() + "]") << endl << + " if _slen > 0 && " << K() << "[_keys] <= " << GET_WIDE_KEY() << " && " << + GET_WIDE_KEY() << " <= " << K() << "[_keys + 1]" << " {" << endl << + " _trans = " << CAST(INT(), I() + "[_inds + " + CAST(INT(), GET_WIDE_KEY() + " - " + K() + "[_keys]") + "]") << endl << + " } else {" << endl << + " _trans = " << CAST(INT(), I() + "[_inds + _slen]") << endl << + " }" << endl << + endl; +} + +void GoFlatCodeGen::writeData() +{ + /* If there are any transtion functions then output the array. If there + * are none, don't bother emitting an empty array that won't be used. */ + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); + ACTIONS_ARRAY(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); + COND_KEY_SPANS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); + CONDS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); + COND_INDEX_OFFSET(); + CLOSE_ARRAY() << + endl; + } + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); + KEY_SPANS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); + FLAT_INDEX_OFFSET(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + endl; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + endl; + } + + STATE_IDS(); +} + +void GoFlatCodeGen::COND_TRANSLATE() +{ + out << + " _widec = " << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << endl; + + out << + " _keys = " << CAST(INT(), vCS() + " << 1") << endl << + " _conds = " << CAST(INT(), CO() + "[" + vCS() + "]") << endl << + endl << + " _slen = " << CAST(INT(), CSP() + "[" + vCS() + "]") << endl << + " if _slen > 0 && " << CK() << "[_keys]" << " <= " << GET_WIDE_KEY() << " && " << + GET_WIDE_KEY() << " <= " << CK() << "[_keys + 1] {" << endl << + " _cond = " << CAST(INT(), C() + "[_conds + " + CAST(INT(), GET_WIDE_KEY() + " - " + CK() + "[_keys]") + "]") << endl << + " } else {" << endl << + " _cond = 0" << endl << + " }" << endl << + endl; + + out << + " switch _cond {" << endl; + for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { + GenCondSpace *condSpace = csi; + out << " case " << condSpace->condSpaceId + 1 << ":" << endl; + out << TABS(2) << "_widec = " << + KEY(condSpace->baseKey) << " + (" << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << + " - " << KEY(keyOps->minKey) << ")" << endl; + + for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { + out << TABS(2) << "if "; + CONDITION( out, *csi ); + Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); + out << " {" << endl << + " _widec += " << condValOffset << endl << + " }" << endl; + } + } + + out << + " }" << endl; +} + +void GoFlatCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << + " {" << endl << + " var _slen " << INT() << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << endl; + + out << + " var _trans " << INT() << endl; + + if ( redFsm->anyConditions() ) + out << " var _cond " << INT() << endl; + + if ( redFsm->anyToStateActions() || + redFsm->anyRegActions() || redFsm->anyFromStateActions() ) + { + out << + " var _acts " << INT() << endl << + " var _nacts " << UINT() << endl; + } + + out << + " var _keys " << INT() << endl << + " var _inds " << INT() << endl; + + if ( redFsm->anyConditions() ) { + out << + " var _conds " << INT() << endl << + " var _widec " << WIDE_ALPH_TYPE() << endl; + } + + out << endl; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + out << "_resume:" << endl; + + if ( redFsm->anyFromStateActions() ) { + out << + " _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + FROM_STATE_ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << + endl; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + LOCATE_TRANS(); + + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " _ps = " << vCS() << endl; + + out << + " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << + endl; + + if ( redFsm->anyRegActions() ) { + out << + " if " << TA() << "[_trans] == 0 {" << endl << + " goto _again" << endl << + " }" << endl << + endl << + " _acts = " << CAST(INT(), TA() + "[_trans]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << + endl; + } + + if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || + redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "_again:" << endl; + + if ( redFsm->anyToStateActions() ) { + out << + " _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + TO_STATE_ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << + endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + if ( !noEnd ) { + out << + " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << + " goto _resume" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl << + " goto _resume" << endl; + } + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << ET() << "[" << vCS() << "] > 0 {" << endl << + " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << + " goto _eof_trans" << endl << + " }" << endl; + } + + if ( redFsm->anyEofActions() ) { + out << + " __acts := " << CAST(INT(), EA() + "[" + vCS() + "]") << endl << + " __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl << + " for ; __nacts > 0; __nacts-- {" << endl << + " __acts++" << endl << + " switch " << A() << "[__acts - 1]" << " {" << endl; + EOF_ACTION_SWITCH(3); + out << + " }" << endl << + " }" << endl; + } + + out << + " }" << endl << + endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << " }" << endl; +} diff --git a/contrib/tools/ragel6/goflat.h b/contrib/tools/ragel6/goflat.h index 5216e85c75..1c8ec9e249 100644 --- a/contrib/tools/ragel6/goflat.h +++ b/contrib/tools/ragel6/goflat.h @@ -1,80 +1,80 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOFLAT_H -#define _GOFLAT_H - -#include <iostream> -#include "gotablish.h" - -/* Forwards. */ -struct CodeGenData; -struct NameInst; -struct RedTransAp; -struct RedStateAp; - -/* - * GoFlatCodeGen - */ -class GoFlatCodeGen - : public GoTablishCodeGen -{ -public: - GoFlatCodeGen( ostream &out ) - : GoTablishCodeGen(out) {} - - virtual ~GoFlatCodeGen() { } - -protected: - std::ostream &TO_STATE_ACTION_SWITCH( int level ); - std::ostream &FROM_STATE_ACTION_SWITCH( int level ); - std::ostream &EOF_ACTION_SWITCH( int level ); - std::ostream &ACTION_SWITCH( int level ); - std::ostream &KEYS(); - std::ostream &INDICIES(); - std::ostream &FLAT_INDEX_OFFSET(); - std::ostream &KEY_SPANS(); - std::ostream &TO_STATE_ACTIONS(); - std::ostream &FROM_STATE_ACTIONS(); - std::ostream &EOF_ACTIONS(); - std::ostream &EOF_TRANS(); - std::ostream &TRANS_TARGS(); - std::ostream &TRANS_ACTIONS(); - void LOCATE_TRANS(); - - std::ostream &COND_INDEX_OFFSET(); - void COND_TRANSLATE(); - std::ostream &CONDS(); - std::ostream &COND_KEYS(); - std::ostream &COND_KEY_SPANS(); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOFLAT_H +#define _GOFLAT_H + +#include <iostream> +#include "gotablish.h" + +/* Forwards. */ +struct CodeGenData; +struct NameInst; +struct RedTransAp; +struct RedStateAp; + +/* + * GoFlatCodeGen + */ +class GoFlatCodeGen + : public GoTablishCodeGen +{ +public: + GoFlatCodeGen( ostream &out ) + : GoTablishCodeGen(out) {} + + virtual ~GoFlatCodeGen() { } + +protected: + std::ostream &TO_STATE_ACTION_SWITCH( int level ); + std::ostream &FROM_STATE_ACTION_SWITCH( int level ); + std::ostream &EOF_ACTION_SWITCH( int level ); + std::ostream &ACTION_SWITCH( int level ); + std::ostream &KEYS(); + std::ostream &INDICIES(); + std::ostream &FLAT_INDEX_OFFSET(); + std::ostream &KEY_SPANS(); + std::ostream &TO_STATE_ACTIONS(); + std::ostream &FROM_STATE_ACTIONS(); + std::ostream &EOF_ACTIONS(); + std::ostream &EOF_TRANS(); + std::ostream &TRANS_TARGS(); + std::ostream &TRANS_ACTIONS(); + void LOCATE_TRANS(); + + std::ostream &COND_INDEX_OFFSET(); + void COND_TRANSLATE(); + std::ostream &CONDS(); + std::ostream &COND_KEYS(); + std::ostream &COND_KEY_SPANS(); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/goftable.cpp b/contrib/tools/ragel6/goftable.cpp index 318f8783c9..8338ccf63c 100644 --- a/contrib/tools/ragel6/goftable.cpp +++ b/contrib/tools/ragel6/goftable.cpp @@ -1,441 +1,441 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "goftable.h" -#include "redfsm.h" -#include "gendata.h" - -using std::endl; - -/* Determine if we should use indicies or not. */ -void GoFTabCodeGen::calcIndexSize() -{ - int sizeWithInds = 0, sizeWithoutInds = 0; - - /* Calculate cost of using with indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; - } - sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); - if ( redFsm->anyActions() ) - sizeWithInds += arrayTypeSize(redFsm->maxActListId) * redFsm->transSet.length(); - - /* Calculate the cost of not using indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; - if ( redFsm->anyActions() ) - sizeWithoutInds += arrayTypeSize(redFsm->maxActListId) * totalIndex; - } - - /* If using indicies reduces the size, use them. */ - useIndicies = sizeWithInds < sizeWithoutInds; -} - -std::ostream &GoFTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &GoFTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &GoFTabCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->actListId+1; - out << act; - return out; -} - - -/* Write out the function for a transition. */ -std::ostream &GoFTabCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - int action = 0; - if ( trans->action != 0 ) - action = trans->action->actListId+1; - out << action; - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFTabCodeGen::TO_STATE_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numToStateRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - - out << endl; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFTabCodeGen::FROM_STATE_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numFromStateRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - - out << endl; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoFTabCodeGen::EOF_ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numEofRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, true, false ); - - out << endl; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &GoFTabCodeGen::ACTION_SWITCH( int level ) -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - /* Write the entry label. */ - out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false, false ); - - out << endl; - } - } - - genLineDirective( out ); - return out; -} - -void GoFTabCodeGen::writeData() -{ - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); - COND_OFFSETS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); - COND_LENS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); - COND_SPACES(); - CLOSE_ARRAY() << - endl; - } - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); - KEY_OFFSETS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); - SINGLE_LENS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); - RANGE_LENS(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); - INDEX_OFFSETS(); - CLOSE_ARRAY() << - endl; - - if ( useIndicies ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS_WI(); - CLOSE_ARRAY() << - endl; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); - TRANS_ACTIONS_WI(); - CLOSE_ARRAY() << - endl; - } - } - else { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - endl; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - endl; - } - - STATE_IDS(); -} - -void GoFTabCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << - " {" << endl << - " var _klen " << INT() << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << endl; - - out << - " var _keys " << INT() << endl << - " var _trans " << INT() << endl; - - if ( redFsm->anyConditions() ) - out << " var _widec " << WIDE_ALPH_TYPE() << endl; - - out << endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - out << "_resume:" << endl; - - if ( redFsm->anyFromStateActions() ) { - out << - " switch " << FSA() << "[" << vCS() << "] {" << endl; - FROM_STATE_ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - LOCATE_TRANS(); - - out << "_match:" << endl; - - if ( useIndicies ) - out << " _trans = " << CAST(INT(), I() + "[_trans]") << endl; - - if ( redFsm->anyEofTrans() ) - out << "_eof_trans:" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " _ps = " << vCS() << endl; - - out << - " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << - endl; - - if ( redFsm->anyRegActions() ) { - out << - " if " << TA() << "[_trans] == 0 {" << endl << - " goto _again" << endl << - " }" << endl << - endl << - " switch " << TA() << "[_trans] {" << endl; - ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || - redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "_again:" << endl; - - if ( redFsm->anyToStateActions() ) { - out << - " switch " << TSA() << "[" << vCS() << "] {" << endl; - TO_STATE_ACTION_SWITCH(1); - out << - " }" << endl << - endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - if ( !noEnd ) { - out << - " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << - " goto _resume" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl << - " goto _resume" << endl; - } - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << ET() << "[" << vCS() << "] > 0 {" << endl << - " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << - " goto _eof_trans" << endl << - " }" << endl; - } - - if ( redFsm->anyEofActions() ) { - out << - " switch " << EA() << "[" << vCS() << "] {" << endl; - EOF_ACTION_SWITCH(2); - out << - " }" << endl; - } - - out << - " }" << endl << - endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << " }" << endl; -} +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "goftable.h" +#include "redfsm.h" +#include "gendata.h" + +using std::endl; + +/* Determine if we should use indicies or not. */ +void GoFTabCodeGen::calcIndexSize() +{ + int sizeWithInds = 0, sizeWithoutInds = 0; + + /* Calculate cost of using with indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; + } + sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); + if ( redFsm->anyActions() ) + sizeWithInds += arrayTypeSize(redFsm->maxActListId) * redFsm->transSet.length(); + + /* Calculate the cost of not using indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; + if ( redFsm->anyActions() ) + sizeWithoutInds += arrayTypeSize(redFsm->maxActListId) * totalIndex; + } + + /* If using indicies reduces the size, use them. */ + useIndicies = sizeWithInds < sizeWithoutInds; +} + +std::ostream &GoFTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &GoFTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &GoFTabCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->actListId+1; + out << act; + return out; +} + + +/* Write out the function for a transition. */ +std::ostream &GoFTabCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + int action = 0; + if ( trans->action != 0 ) + action = trans->action->actListId+1; + out << action; + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFTabCodeGen::TO_STATE_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numToStateRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + + out << endl; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFTabCodeGen::FROM_STATE_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numFromStateRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + + out << endl; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoFTabCodeGen::EOF_ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numEofRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, true, false ); + + out << endl; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &GoFTabCodeGen::ACTION_SWITCH( int level ) +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + /* Write the entry label. */ + out << TABS(level) << "case " << redAct->actListId+1 << ":" << endl; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false, false ); + + out << endl; + } + } + + genLineDirective( out ); + return out; +} + +void GoFTabCodeGen::writeData() +{ + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); + COND_OFFSETS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); + COND_LENS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); + COND_SPACES(); + CLOSE_ARRAY() << + endl; + } + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); + KEY_OFFSETS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); + SINGLE_LENS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); + RANGE_LENS(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); + INDEX_OFFSETS(); + CLOSE_ARRAY() << + endl; + + if ( useIndicies ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS_WI(); + CLOSE_ARRAY() << + endl; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); + TRANS_ACTIONS_WI(); + CLOSE_ARRAY() << + endl; + } + } + else { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + endl; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + endl; + } + + STATE_IDS(); +} + +void GoFTabCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << + " {" << endl << + " var _klen " << INT() << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << endl; + + out << + " var _keys " << INT() << endl << + " var _trans " << INT() << endl; + + if ( redFsm->anyConditions() ) + out << " var _widec " << WIDE_ALPH_TYPE() << endl; + + out << endl; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + out << "_resume:" << endl; + + if ( redFsm->anyFromStateActions() ) { + out << + " switch " << FSA() << "[" << vCS() << "] {" << endl; + FROM_STATE_ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + LOCATE_TRANS(); + + out << "_match:" << endl; + + if ( useIndicies ) + out << " _trans = " << CAST(INT(), I() + "[_trans]") << endl; + + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " _ps = " << vCS() << endl; + + out << + " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << + endl; + + if ( redFsm->anyRegActions() ) { + out << + " if " << TA() << "[_trans] == 0 {" << endl << + " goto _again" << endl << + " }" << endl << + endl << + " switch " << TA() << "[_trans] {" << endl; + ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || + redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "_again:" << endl; + + if ( redFsm->anyToStateActions() ) { + out << + " switch " << TSA() << "[" << vCS() << "] {" << endl; + TO_STATE_ACTION_SWITCH(1); + out << + " }" << endl << + endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + if ( !noEnd ) { + out << + " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << + " goto _resume" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl << + " goto _resume" << endl; + } + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << ET() << "[" << vCS() << "] > 0 {" << endl << + " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << + " goto _eof_trans" << endl << + " }" << endl; + } + + if ( redFsm->anyEofActions() ) { + out << + " switch " << EA() << "[" << vCS() << "] {" << endl; + EOF_ACTION_SWITCH(2); + out << + " }" << endl; + } + + out << + " }" << endl << + endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << " }" << endl; +} diff --git a/contrib/tools/ragel6/goftable.h b/contrib/tools/ragel6/goftable.h index 524b6a2174..a17a20a752 100644 --- a/contrib/tools/ragel6/goftable.h +++ b/contrib/tools/ragel6/goftable.h @@ -1,59 +1,59 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOFTABLE_H -#define _GOFTABLE_H - -#include <iostream> -#include "gotable.h" - -/* Forwards. */ -struct CodeGenData; - -/* - * GoFTabCode - */ -class GoFTabCodeGen - : public GoTabCodeGen -{ -public: - GoFTabCodeGen( ostream &out ) - : GoTabCodeGen(out) {} - -protected: - std::ostream &TO_STATE_ACTION_SWITCH( int level ); - std::ostream &FROM_STATE_ACTION_SWITCH( int level ); - std::ostream &EOF_ACTION_SWITCH( int level ); - std::ostream &ACTION_SWITCH( int level ); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - - virtual void writeData(); - virtual void writeExec(); - virtual void calcIndexSize(); -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOFTABLE_H +#define _GOFTABLE_H + +#include <iostream> +#include "gotable.h" + +/* Forwards. */ +struct CodeGenData; + +/* + * GoFTabCode + */ +class GoFTabCodeGen + : public GoTabCodeGen +{ +public: + GoFTabCodeGen( ostream &out ) + : GoTabCodeGen(out) {} + +protected: + std::ostream &TO_STATE_ACTION_SWITCH( int level ); + std::ostream &FROM_STATE_ACTION_SWITCH( int level ); + std::ostream &EOF_ACTION_SWITCH( int level ); + std::ostream &ACTION_SWITCH( int level ); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + + virtual void writeData(); + virtual void writeExec(); + virtual void calcIndexSize(); +}; + +#endif diff --git a/contrib/tools/ragel6/gogoto.cpp b/contrib/tools/ragel6/gogoto.cpp index 757308afa1..e2a04e43de 100644 --- a/contrib/tools/ragel6/gogoto.cpp +++ b/contrib/tools/ragel6/gogoto.cpp @@ -1,734 +1,734 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "gogoto.h" -#include "redfsm.h" -#include "bstmap.h" -#include "gendata.h" - -using std::endl; - -/* Emit the goto to take for a given transition. */ -std::ostream &GoGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level ) -{ - out << TABS(level) << "goto tr" << trans->id << ";"; - return out; -} - -int GoGotoCodeGen::TRANS_NR( RedTransAp *trans ) -{ - return trans->id; -} - -std::ostream &GoGotoCodeGen::TO_STATE_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numToStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoGotoCodeGen::FROM_STATE_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numFromStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoGotoCodeGen::EOF_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numEofRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, true, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoGotoCodeGen::ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numTransRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -void GoGotoCodeGen::GOTO_HEADER( RedStateAp *state, int level ) -{ - /* Label the state. */ - out << TABS(level) << "case " << state->id << ":" << endl; -} - -void GoGotoCodeGen::emitSingleSwitch( RedStateAp *state, int level ) -{ - /* Load up the singles. */ - int numSingles = state->outSingle.length(); - RedTransEl *data = state->outSingle.data; - - if ( numSingles == 1 ) { - /* If there is a single single key then write it out as an if. */ - out << TABS(level) << "if " << GET_WIDE_KEY(state) << " == " << - WIDE_KEY(state, data[0].lowKey) << " {" << endl; - - /* Virtual function for writing the target of the transition. */ - TRANS_GOTO(data[0].value, level + 1) << endl; - out << TABS(level) << "}" << endl; - } - else if ( numSingles > 1 ) { - /* Write out single keys in a switch if there is more than one. */ - out << TABS(level) << "switch " << GET_WIDE_KEY(state) << " {" << endl; - - /* Write out the single indicies. */ - for ( int j = 0; j < numSingles; j++ ) { - out << TABS(level) << "case " << WIDE_KEY(state, data[j].lowKey) << ":" << endl; - TRANS_GOTO(data[j].value, level + 1) << endl; - } - - /* Close off the transition switch. */ - out << TABS(level) << "}" << endl; - } -} - -void GoGotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int high ) -{ - /* Get the mid position, staying on the lower end of the range. */ - int mid = (low + high) >> 1; - RedTransEl *data = state->outRange.data; - - /* Determine if we need to look higher or lower. */ - bool anyLower = mid > low; - bool anyHigher = mid < high; - - /* Determine if the keys at mid are the limits of the alphabet. */ - bool limitLow = data[mid].lowKey == keyOps->minKey; - bool limitHigh = data[mid].highKey == keyOps->maxKey; - - if ( anyLower && anyHigher ) { - /* Can go lower and higher than mid. */ - out << TABS(level) << "switch {" << endl; - out << TABS(level) << "case " << GET_WIDE_KEY(state) << " < " << - WIDE_KEY(state, data[mid].lowKey) << ":" << endl; - emitRangeBSearch( state, level+1, low, mid-1 ); - out << TABS(level) << "case " << GET_WIDE_KEY(state) << " > " << - WIDE_KEY(state, data[mid].highKey) << ":" << endl; - emitRangeBSearch( state, level+1, mid+1, high ); - out << TABS(level) << "default:" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - out << TABS(level) << "}" << endl; - } - else if ( anyLower && !anyHigher ) { - /* Can go lower than mid but not higher. */ - out << TABS(level) << "switch {" << endl; - out << TABS(level) << "case " << GET_WIDE_KEY(state) << " < " << - WIDE_KEY(state, data[mid].lowKey) << ":" << endl; - emitRangeBSearch( state, level+1, low, mid-1 ); - - /* if the higher is the highest in the alphabet then there is no - * sense testing it. */ - if ( limitHigh ) { - out << TABS(level) << "default:" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - } - else { - out << TABS(level) << "case " << GET_WIDE_KEY(state) << " <= " << - WIDE_KEY(state, data[mid].highKey) << ":" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - } - out << TABS(level) << "}" << endl; - } - else if ( !anyLower && anyHigher ) { - /* Can go higher than mid but not lower. */ - out << TABS(level) << "switch {" << endl; - out << TABS(level) << "case " << GET_WIDE_KEY(state) << " > " << - WIDE_KEY(state, data[mid].highKey) << ":" << endl; - emitRangeBSearch( state, level+1, mid+1, high ); - - /* If the lower end is the lowest in the alphabet then there is no - * sense testing it. */ - if ( limitLow ) { - out << TABS(level) << "default:" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - } - else { - out << TABS(level) << "case " << GET_WIDE_KEY(state) << " >= " << - WIDE_KEY(state, data[mid].lowKey) << ":" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - } - out << TABS(level) << "}" << endl; - } - else { - /* Cannot go higher or lower than mid. It's mid or bust. What - * tests to do depends on limits of alphabet. */ - if ( !limitLow && !limitHigh ) { - out << TABS(level) << "if " << WIDE_KEY(state, data[mid].lowKey) << " <= " << - GET_WIDE_KEY(state) << " && " << GET_WIDE_KEY(state) << " <= " << - WIDE_KEY(state, data[mid].highKey) << " {" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - out << TABS(level) << "}" << endl; - } - else if ( limitLow && !limitHigh ) { - out << TABS(level) << "if " << GET_WIDE_KEY(state) << " <= " << - WIDE_KEY(state, data[mid].highKey) << " {" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - out << TABS(level) << "}" << endl; - } - else if ( !limitLow && limitHigh ) { - out << TABS(level) << "if " << WIDE_KEY(state, data[mid].lowKey) << " <= " << - GET_WIDE_KEY(state) << " {" << endl; - TRANS_GOTO(data[mid].value, level+1) << endl; - out << TABS(level) << "}" << endl; - } - else { - /* Both high and low are at the limit. No tests to do. */ - TRANS_GOTO(data[mid].value, level) << endl; - } - } -} - -void GoGotoCodeGen::STATE_GOTO_ERROR( int level ) -{ - /* Label the state and bail immediately. */ - outLabelUsed = true; - RedStateAp *state = redFsm->errState; - out << TABS(level) << "case " << state->id << ":" << endl; - out << TABS(level + 1) << "goto _out" << endl; -} - -void GoGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level ) -{ - GenCondSpace *condSpace = stateCond->condSpace; - out << TABS(level) << "_widec = " << - KEY(condSpace->baseKey) << " + (" << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << - " - " << KEY(keyOps->minKey) << ")" << endl; - - for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { - out << TABS(level) << "if "; - CONDITION( out, *csi ); - Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); - out << " {" << endl; - out << TABS(level + 1) << "_widec += " << condValOffset << endl; - out << TABS(level) << "}" << endl; - } -} - -void GoGotoCodeGen::emitCondBSearch( RedStateAp *state, int level, int low, int high ) -{ - /* Get the mid position, staying on the lower end of the range. */ - int mid = (low + high) >> 1; - GenStateCond **data = state->stateCondVect.data; - - /* Determine if we need to look higher or lower. */ - bool anyLower = mid > low; - bool anyHigher = mid < high; - - /* Determine if the keys at mid are the limits of the alphabet. */ - bool limitLow = data[mid]->lowKey == keyOps->minKey; - bool limitHigh = data[mid]->highKey == keyOps->maxKey; - - if ( anyLower && anyHigher ) { - /* Can go lower and higher than mid. */ - out << TABS(level) << "switch {" << endl; - out << TABS(level) << "case " << GET_KEY() << " < " << - KEY(data[mid]->lowKey) << ":" << endl; - emitCondBSearch( state, level+1, low, mid-1 ); - out << TABS(level) << "case " << GET_KEY() << " > " << - KEY(data[mid]->highKey) << ":" << endl; - emitCondBSearch( state, level+1, mid+1, high ); - out << TABS(level) << "default:" << endl; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}" << endl; - } - else if ( anyLower && !anyHigher ) { - /* Can go lower than mid but not higher. */ - out << TABS(level) << "switch {" << endl; - out << TABS(level) << "case " << GET_KEY() << " < " << - KEY(data[mid]->lowKey) << ":" << endl; - emitCondBSearch( state, level+1, low, mid-1 ); - - /* if the higher is the highest in the alphabet then there is no - * sense testing it. */ - if ( limitHigh ) { - out << TABS(level) << "default:" << endl; - COND_TRANSLATE(data[mid], level+1); - } - else { - out << TABS(level) << "case " << GET_KEY() << " <= " << - KEY(data[mid]->highKey) << ":" << endl; - COND_TRANSLATE(data[mid], level+1); - } - out << TABS(level) << "}" << endl; - } - else if ( !anyLower && anyHigher ) { - /* Can go higher than mid but not lower. */ - out << TABS(level) << "switch {" << endl; - out << TABS(level) << "case " << GET_KEY() << " > " << - KEY(data[mid]->highKey) << ":" << endl; - emitCondBSearch( state, level+1, mid+1, high ); - - /* If the lower end is the lowest in the alphabet then there is no - * sense testing it. */ - if ( limitLow ) { - out << TABS(level) << "default:" << endl; - COND_TRANSLATE(data[mid], level+1); - } - else { - out << TABS(level) << "case " << GET_KEY() << " >= " << - KEY(data[mid]->lowKey) << ":" << endl; - COND_TRANSLATE(data[mid], level+1); - } - out << TABS(level) << "}" << endl; - } - else { - /* Cannot go higher or lower than mid. It's mid or bust. What - * tests to do depends on limits of alphabet. */ - if ( !limitLow && !limitHigh ) { - out << TABS(level) << "if " << KEY(data[mid]->lowKey) << " <= " << - GET_KEY() << " && " << GET_KEY() << " <= " << - KEY(data[mid]->highKey) << " {" << endl; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}" << endl; - } - else if ( limitLow && !limitHigh ) { - out << TABS(level) << "if " << GET_KEY() << " <= " << - KEY(data[mid]->highKey) << " {" << endl; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}" << endl; - } - else if ( !limitLow && limitHigh ) { - out << TABS(level) << "if " << KEY(data[mid]->lowKey) << " <= " << - GET_KEY() << " {" << endl; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}" << endl; - } - else { - /* Both high and low are at the limit. No tests to do. */ - COND_TRANSLATE(data[mid], level); - } - } -} - -std::ostream &GoGotoCodeGen::STATE_GOTOS( int level ) -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st == redFsm->errState ) - STATE_GOTO_ERROR(level); - else { - /* Writing code above state gotos. */ - GOTO_HEADER( st, level ); - - if ( st->stateCondVect.length() > 0 ) { - out << TABS(level + 1) << "_widec = " << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << endl; - emitCondBSearch( st, level + 1, 0, st->stateCondVect.length() - 1 ); - } - - /* Try singles. */ - if ( st->outSingle.length() > 0 ) - emitSingleSwitch( st, level + 1 ); - - /* Default case is to binary search for the ranges, if that fails then */ - if ( st->outRange.length() > 0 ) - emitRangeBSearch( st, level + 1, 0, st->outRange.length() - 1 ); - - /* Write the default transition. */ - TRANS_GOTO( st->defTrans, level + 1 ) << endl; - } - } - return out; -} - -std::ostream &GoGotoCodeGen::TRANSITIONS() -{ - /* Emit any transitions that have functions and that go to - * this state. */ - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) { - /* Write the label for the transition so it can be jumped to. */ - out << " tr" << trans->id << ": "; - - /* Destination state. */ - if ( trans->action != 0 && trans->action->anyCurStateRef() ) - out << "_ps = " << vCS() << ";"; - out << vCS() << " = " << trans->targ->id << "; "; - - if ( trans->action != 0 ) { - /* Write out the transition func. */ - out << "goto f" << trans->action->actListId << endl; - } - else { - /* No code to execute, just loop around. */ - out << "goto _again" << endl; - } - } - return out; -} - -std::ostream &GoGotoCodeGen::EXEC_FUNCS() -{ - /* Make labels that set acts and jump to execFuncs. Loop func indicies. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - out << " f" << redAct->actListId << ": " << - "_acts = " << (redAct->location + 1) << ";" - " goto execFuncs" << endl; - } - } - - out << - endl << - "execFuncs:" << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << - " goto _again" << endl; - return out; -} - -unsigned int GoGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->location+1; - return act; -} - -unsigned int GoGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->location+1; - return act; -} - -unsigned int GoGotoCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->location+1; - return act; -} - -std::ostream &GoGotoCodeGen::TO_STATE_ACTIONS() -{ - /* Take one off for the psuedo start state. */ - int numStates = redFsm->stateList.length(); - unsigned int *vals = new unsigned int[numStates]; - memset( vals, 0, sizeof(unsigned int)*numStates ); - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - vals[st->id] = TO_STATE_ACTION(st); - - out << " "; - for ( int st = 0; st < redFsm->nextStateId; st++ ) { - /* Write any eof action. */ - out << vals[st] << ", "; - if ( st < numStates-1 ) { - if ( (st+1) % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] vals; - return out; -} - -std::ostream &GoGotoCodeGen::FROM_STATE_ACTIONS() -{ - /* Take one off for the psuedo start state. */ - int numStates = redFsm->stateList.length(); - unsigned int *vals = new unsigned int[numStates]; - memset( vals, 0, sizeof(unsigned int)*numStates ); - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - vals[st->id] = FROM_STATE_ACTION(st); - - out << " "; - for ( int st = 0; st < redFsm->nextStateId; st++ ) { - /* Write any eof action. */ - out << vals[st] << ", "; - if ( st < numStates-1 ) { - if ( (st+1) % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] vals; - return out; -} - -std::ostream &GoGotoCodeGen::EOF_ACTIONS() -{ - /* Take one off for the psuedo start state. */ - int numStates = redFsm->stateList.length(); - unsigned int *vals = new unsigned int[numStates]; - memset( vals, 0, sizeof(unsigned int)*numStates ); - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - vals[st->id] = EOF_ACTION(st); - - out << " "; - for ( int st = 0; st < redFsm->nextStateId; st++ ) { - /* Write any eof action. */ - out << vals[st] << ", "; - if ( st < numStates-1 ) { - if ( (st+1) % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] vals; - return out; -} - -std::ostream &GoGotoCodeGen::FINISH_CASES() -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* States that are final and have an out action need a case. */ - if ( st->eofAction != 0 ) { - /* Write the case label. */ - out << TABS(2) << "case " << st->id << ":" << endl; - - /* Write the goto func. */ - out << TABS(3) << "goto f" << st->eofAction->actListId << endl; - } - } - - return out; -} - -void GoGotoCodeGen::writeData() -{ - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); - ACTIONS_ARRAY(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - endl; - } - - STATE_IDS(); -} - -void GoGotoCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << " {" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << " = 0" << endl; - - if ( redFsm->anyToStateActions() || redFsm->anyRegActions() - || redFsm->anyFromStateActions() ) - { - out << - " var _acts " << INT() << endl << - " var _nacts " << UINT() << endl; - } - - if ( redFsm->anyConditions() ) - out << " var _widec " << WIDE_ALPH_TYPE() << endl; - - out << endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - out << "_resume:" << endl; - - if ( redFsm->anyFromStateActions() ) { - out << - " _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - FROM_STATE_ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << - endl; - } - - out << - " switch " << vCS() << " {" << endl; - STATE_GOTOS(1); - out << - " }" << endl << - endl; - TRANSITIONS() << - endl; - - if ( redFsm->anyRegActions() ) - EXEC_FUNCS() << endl; - - out << "_again:" << endl; - - if ( redFsm->anyToStateActions() ) { - out << - " _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - TO_STATE_ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << - endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - if ( !noEnd ) { - out << - " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << - " goto _resume" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl << - " goto _resume" << endl; - } - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl; - - if ( redFsm->anyEofTrans() ) { - out << - " switch " << vCS() << " {" << endl; - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) - out << - " case " << st->id << ":" << endl << - " goto tr" << st->eofTrans->id << endl; - } - - out << - " }" << endl; - } - - if ( redFsm->anyEofActions() ) { - out << - " __acts := " << CAST(INT(), EA() + "[" + vCS() + "]") << endl << - " __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl << - " for ; __nacts > 0; __nacts-- {" << endl << - " __acts++" << endl << - " switch " << A() << "[__acts - 1]" << " {" << endl; - EOF_ACTION_SWITCH(3); - out << - " }" << endl << - " }" << endl; - } - - out << - " }" << endl << - endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << " }" << endl; -} +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "gogoto.h" +#include "redfsm.h" +#include "bstmap.h" +#include "gendata.h" + +using std::endl; + +/* Emit the goto to take for a given transition. */ +std::ostream &GoGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level ) +{ + out << TABS(level) << "goto tr" << trans->id << ";"; + return out; +} + +int GoGotoCodeGen::TRANS_NR( RedTransAp *trans ) +{ + return trans->id; +} + +std::ostream &GoGotoCodeGen::TO_STATE_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numToStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoGotoCodeGen::FROM_STATE_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numFromStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoGotoCodeGen::EOF_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numEofRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, true, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoGotoCodeGen::ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numTransRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +void GoGotoCodeGen::GOTO_HEADER( RedStateAp *state, int level ) +{ + /* Label the state. */ + out << TABS(level) << "case " << state->id << ":" << endl; +} + +void GoGotoCodeGen::emitSingleSwitch( RedStateAp *state, int level ) +{ + /* Load up the singles. */ + int numSingles = state->outSingle.length(); + RedTransEl *data = state->outSingle.data; + + if ( numSingles == 1 ) { + /* If there is a single single key then write it out as an if. */ + out << TABS(level) << "if " << GET_WIDE_KEY(state) << " == " << + WIDE_KEY(state, data[0].lowKey) << " {" << endl; + + /* Virtual function for writing the target of the transition. */ + TRANS_GOTO(data[0].value, level + 1) << endl; + out << TABS(level) << "}" << endl; + } + else if ( numSingles > 1 ) { + /* Write out single keys in a switch if there is more than one. */ + out << TABS(level) << "switch " << GET_WIDE_KEY(state) << " {" << endl; + + /* Write out the single indicies. */ + for ( int j = 0; j < numSingles; j++ ) { + out << TABS(level) << "case " << WIDE_KEY(state, data[j].lowKey) << ":" << endl; + TRANS_GOTO(data[j].value, level + 1) << endl; + } + + /* Close off the transition switch. */ + out << TABS(level) << "}" << endl; + } +} + +void GoGotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int high ) +{ + /* Get the mid position, staying on the lower end of the range. */ + int mid = (low + high) >> 1; + RedTransEl *data = state->outRange.data; + + /* Determine if we need to look higher or lower. */ + bool anyLower = mid > low; + bool anyHigher = mid < high; + + /* Determine if the keys at mid are the limits of the alphabet. */ + bool limitLow = data[mid].lowKey == keyOps->minKey; + bool limitHigh = data[mid].highKey == keyOps->maxKey; + + if ( anyLower && anyHigher ) { + /* Can go lower and higher than mid. */ + out << TABS(level) << "switch {" << endl; + out << TABS(level) << "case " << GET_WIDE_KEY(state) << " < " << + WIDE_KEY(state, data[mid].lowKey) << ":" << endl; + emitRangeBSearch( state, level+1, low, mid-1 ); + out << TABS(level) << "case " << GET_WIDE_KEY(state) << " > " << + WIDE_KEY(state, data[mid].highKey) << ":" << endl; + emitRangeBSearch( state, level+1, mid+1, high ); + out << TABS(level) << "default:" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + out << TABS(level) << "}" << endl; + } + else if ( anyLower && !anyHigher ) { + /* Can go lower than mid but not higher. */ + out << TABS(level) << "switch {" << endl; + out << TABS(level) << "case " << GET_WIDE_KEY(state) << " < " << + WIDE_KEY(state, data[mid].lowKey) << ":" << endl; + emitRangeBSearch( state, level+1, low, mid-1 ); + + /* if the higher is the highest in the alphabet then there is no + * sense testing it. */ + if ( limitHigh ) { + out << TABS(level) << "default:" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + } + else { + out << TABS(level) << "case " << GET_WIDE_KEY(state) << " <= " << + WIDE_KEY(state, data[mid].highKey) << ":" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + } + out << TABS(level) << "}" << endl; + } + else if ( !anyLower && anyHigher ) { + /* Can go higher than mid but not lower. */ + out << TABS(level) << "switch {" << endl; + out << TABS(level) << "case " << GET_WIDE_KEY(state) << " > " << + WIDE_KEY(state, data[mid].highKey) << ":" << endl; + emitRangeBSearch( state, level+1, mid+1, high ); + + /* If the lower end is the lowest in the alphabet then there is no + * sense testing it. */ + if ( limitLow ) { + out << TABS(level) << "default:" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + } + else { + out << TABS(level) << "case " << GET_WIDE_KEY(state) << " >= " << + WIDE_KEY(state, data[mid].lowKey) << ":" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + } + out << TABS(level) << "}" << endl; + } + else { + /* Cannot go higher or lower than mid. It's mid or bust. What + * tests to do depends on limits of alphabet. */ + if ( !limitLow && !limitHigh ) { + out << TABS(level) << "if " << WIDE_KEY(state, data[mid].lowKey) << " <= " << + GET_WIDE_KEY(state) << " && " << GET_WIDE_KEY(state) << " <= " << + WIDE_KEY(state, data[mid].highKey) << " {" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + out << TABS(level) << "}" << endl; + } + else if ( limitLow && !limitHigh ) { + out << TABS(level) << "if " << GET_WIDE_KEY(state) << " <= " << + WIDE_KEY(state, data[mid].highKey) << " {" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + out << TABS(level) << "}" << endl; + } + else if ( !limitLow && limitHigh ) { + out << TABS(level) << "if " << WIDE_KEY(state, data[mid].lowKey) << " <= " << + GET_WIDE_KEY(state) << " {" << endl; + TRANS_GOTO(data[mid].value, level+1) << endl; + out << TABS(level) << "}" << endl; + } + else { + /* Both high and low are at the limit. No tests to do. */ + TRANS_GOTO(data[mid].value, level) << endl; + } + } +} + +void GoGotoCodeGen::STATE_GOTO_ERROR( int level ) +{ + /* Label the state and bail immediately. */ + outLabelUsed = true; + RedStateAp *state = redFsm->errState; + out << TABS(level) << "case " << state->id << ":" << endl; + out << TABS(level + 1) << "goto _out" << endl; +} + +void GoGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level ) +{ + GenCondSpace *condSpace = stateCond->condSpace; + out << TABS(level) << "_widec = " << + KEY(condSpace->baseKey) << " + (" << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << + " - " << KEY(keyOps->minKey) << ")" << endl; + + for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { + out << TABS(level) << "if "; + CONDITION( out, *csi ); + Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); + out << " {" << endl; + out << TABS(level + 1) << "_widec += " << condValOffset << endl; + out << TABS(level) << "}" << endl; + } +} + +void GoGotoCodeGen::emitCondBSearch( RedStateAp *state, int level, int low, int high ) +{ + /* Get the mid position, staying on the lower end of the range. */ + int mid = (low + high) >> 1; + GenStateCond **data = state->stateCondVect.data; + + /* Determine if we need to look higher or lower. */ + bool anyLower = mid > low; + bool anyHigher = mid < high; + + /* Determine if the keys at mid are the limits of the alphabet. */ + bool limitLow = data[mid]->lowKey == keyOps->minKey; + bool limitHigh = data[mid]->highKey == keyOps->maxKey; + + if ( anyLower && anyHigher ) { + /* Can go lower and higher than mid. */ + out << TABS(level) << "switch {" << endl; + out << TABS(level) << "case " << GET_KEY() << " < " << + KEY(data[mid]->lowKey) << ":" << endl; + emitCondBSearch( state, level+1, low, mid-1 ); + out << TABS(level) << "case " << GET_KEY() << " > " << + KEY(data[mid]->highKey) << ":" << endl; + emitCondBSearch( state, level+1, mid+1, high ); + out << TABS(level) << "default:" << endl; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}" << endl; + } + else if ( anyLower && !anyHigher ) { + /* Can go lower than mid but not higher. */ + out << TABS(level) << "switch {" << endl; + out << TABS(level) << "case " << GET_KEY() << " < " << + KEY(data[mid]->lowKey) << ":" << endl; + emitCondBSearch( state, level+1, low, mid-1 ); + + /* if the higher is the highest in the alphabet then there is no + * sense testing it. */ + if ( limitHigh ) { + out << TABS(level) << "default:" << endl; + COND_TRANSLATE(data[mid], level+1); + } + else { + out << TABS(level) << "case " << GET_KEY() << " <= " << + KEY(data[mid]->highKey) << ":" << endl; + COND_TRANSLATE(data[mid], level+1); + } + out << TABS(level) << "}" << endl; + } + else if ( !anyLower && anyHigher ) { + /* Can go higher than mid but not lower. */ + out << TABS(level) << "switch {" << endl; + out << TABS(level) << "case " << GET_KEY() << " > " << + KEY(data[mid]->highKey) << ":" << endl; + emitCondBSearch( state, level+1, mid+1, high ); + + /* If the lower end is the lowest in the alphabet then there is no + * sense testing it. */ + if ( limitLow ) { + out << TABS(level) << "default:" << endl; + COND_TRANSLATE(data[mid], level+1); + } + else { + out << TABS(level) << "case " << GET_KEY() << " >= " << + KEY(data[mid]->lowKey) << ":" << endl; + COND_TRANSLATE(data[mid], level+1); + } + out << TABS(level) << "}" << endl; + } + else { + /* Cannot go higher or lower than mid. It's mid or bust. What + * tests to do depends on limits of alphabet. */ + if ( !limitLow && !limitHigh ) { + out << TABS(level) << "if " << KEY(data[mid]->lowKey) << " <= " << + GET_KEY() << " && " << GET_KEY() << " <= " << + KEY(data[mid]->highKey) << " {" << endl; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}" << endl; + } + else if ( limitLow && !limitHigh ) { + out << TABS(level) << "if " << GET_KEY() << " <= " << + KEY(data[mid]->highKey) << " {" << endl; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}" << endl; + } + else if ( !limitLow && limitHigh ) { + out << TABS(level) << "if " << KEY(data[mid]->lowKey) << " <= " << + GET_KEY() << " {" << endl; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}" << endl; + } + else { + /* Both high and low are at the limit. No tests to do. */ + COND_TRANSLATE(data[mid], level); + } + } +} + +std::ostream &GoGotoCodeGen::STATE_GOTOS( int level ) +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st == redFsm->errState ) + STATE_GOTO_ERROR(level); + else { + /* Writing code above state gotos. */ + GOTO_HEADER( st, level ); + + if ( st->stateCondVect.length() > 0 ) { + out << TABS(level + 1) << "_widec = " << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << endl; + emitCondBSearch( st, level + 1, 0, st->stateCondVect.length() - 1 ); + } + + /* Try singles. */ + if ( st->outSingle.length() > 0 ) + emitSingleSwitch( st, level + 1 ); + + /* Default case is to binary search for the ranges, if that fails then */ + if ( st->outRange.length() > 0 ) + emitRangeBSearch( st, level + 1, 0, st->outRange.length() - 1 ); + + /* Write the default transition. */ + TRANS_GOTO( st->defTrans, level + 1 ) << endl; + } + } + return out; +} + +std::ostream &GoGotoCodeGen::TRANSITIONS() +{ + /* Emit any transitions that have functions and that go to + * this state. */ + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) { + /* Write the label for the transition so it can be jumped to. */ + out << " tr" << trans->id << ": "; + + /* Destination state. */ + if ( trans->action != 0 && trans->action->anyCurStateRef() ) + out << "_ps = " << vCS() << ";"; + out << vCS() << " = " << trans->targ->id << "; "; + + if ( trans->action != 0 ) { + /* Write out the transition func. */ + out << "goto f" << trans->action->actListId << endl; + } + else { + /* No code to execute, just loop around. */ + out << "goto _again" << endl; + } + } + return out; +} + +std::ostream &GoGotoCodeGen::EXEC_FUNCS() +{ + /* Make labels that set acts and jump to execFuncs. Loop func indicies. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + out << " f" << redAct->actListId << ": " << + "_acts = " << (redAct->location + 1) << ";" + " goto execFuncs" << endl; + } + } + + out << + endl << + "execFuncs:" << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << + " goto _again" << endl; + return out; +} + +unsigned int GoGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->location+1; + return act; +} + +unsigned int GoGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->location+1; + return act; +} + +unsigned int GoGotoCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->location+1; + return act; +} + +std::ostream &GoGotoCodeGen::TO_STATE_ACTIONS() +{ + /* Take one off for the psuedo start state. */ + int numStates = redFsm->stateList.length(); + unsigned int *vals = new unsigned int[numStates]; + memset( vals, 0, sizeof(unsigned int)*numStates ); + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + vals[st->id] = TO_STATE_ACTION(st); + + out << " "; + for ( int st = 0; st < redFsm->nextStateId; st++ ) { + /* Write any eof action. */ + out << vals[st] << ", "; + if ( st < numStates-1 ) { + if ( (st+1) % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] vals; + return out; +} + +std::ostream &GoGotoCodeGen::FROM_STATE_ACTIONS() +{ + /* Take one off for the psuedo start state. */ + int numStates = redFsm->stateList.length(); + unsigned int *vals = new unsigned int[numStates]; + memset( vals, 0, sizeof(unsigned int)*numStates ); + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + vals[st->id] = FROM_STATE_ACTION(st); + + out << " "; + for ( int st = 0; st < redFsm->nextStateId; st++ ) { + /* Write any eof action. */ + out << vals[st] << ", "; + if ( st < numStates-1 ) { + if ( (st+1) % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] vals; + return out; +} + +std::ostream &GoGotoCodeGen::EOF_ACTIONS() +{ + /* Take one off for the psuedo start state. */ + int numStates = redFsm->stateList.length(); + unsigned int *vals = new unsigned int[numStates]; + memset( vals, 0, sizeof(unsigned int)*numStates ); + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + vals[st->id] = EOF_ACTION(st); + + out << " "; + for ( int st = 0; st < redFsm->nextStateId; st++ ) { + /* Write any eof action. */ + out << vals[st] << ", "; + if ( st < numStates-1 ) { + if ( (st+1) % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] vals; + return out; +} + +std::ostream &GoGotoCodeGen::FINISH_CASES() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* States that are final and have an out action need a case. */ + if ( st->eofAction != 0 ) { + /* Write the case label. */ + out << TABS(2) << "case " << st->id << ":" << endl; + + /* Write the goto func. */ + out << TABS(3) << "goto f" << st->eofAction->actListId << endl; + } + } + + return out; +} + +void GoGotoCodeGen::writeData() +{ + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); + ACTIONS_ARRAY(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + endl; + } + + STATE_IDS(); +} + +void GoGotoCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << " {" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << " = 0" << endl; + + if ( redFsm->anyToStateActions() || redFsm->anyRegActions() + || redFsm->anyFromStateActions() ) + { + out << + " var _acts " << INT() << endl << + " var _nacts " << UINT() << endl; + } + + if ( redFsm->anyConditions() ) + out << " var _widec " << WIDE_ALPH_TYPE() << endl; + + out << endl; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + out << "_resume:" << endl; + + if ( redFsm->anyFromStateActions() ) { + out << + " _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + FROM_STATE_ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << + endl; + } + + out << + " switch " << vCS() << " {" << endl; + STATE_GOTOS(1); + out << + " }" << endl << + endl; + TRANSITIONS() << + endl; + + if ( redFsm->anyRegActions() ) + EXEC_FUNCS() << endl; + + out << "_again:" << endl; + + if ( redFsm->anyToStateActions() ) { + out << + " _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + TO_STATE_ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << + endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + if ( !noEnd ) { + out << + " if " << P() << "++; " << P() << " != " << PE() << " {" << endl << + " goto _resume" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl << + " goto _resume" << endl; + } + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl; + + if ( redFsm->anyEofTrans() ) { + out << + " switch " << vCS() << " {" << endl; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << + " case " << st->id << ":" << endl << + " goto tr" << st->eofTrans->id << endl; + } + + out << + " }" << endl; + } + + if ( redFsm->anyEofActions() ) { + out << + " __acts := " << CAST(INT(), EA() + "[" + vCS() + "]") << endl << + " __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl << + " for ; __nacts > 0; __nacts-- {" << endl << + " __acts++" << endl << + " switch " << A() << "[__acts - 1]" << " {" << endl; + EOF_ACTION_SWITCH(3); + out << + " }" << endl << + " }" << endl; + } + + out << + " }" << endl << + endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << " }" << endl; +} diff --git a/contrib/tools/ragel6/gogoto.h b/contrib/tools/ragel6/gogoto.h index 18d058e54d..72c61271d7 100644 --- a/contrib/tools/ragel6/gogoto.h +++ b/contrib/tools/ragel6/gogoto.h @@ -1,83 +1,83 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOGOTO_H -#define _GOGOTO_H - -#include <iostream> -#include "gotablish.h" - -/* Forwards. */ -struct CodeGenData; -struct NameInst; -struct RedTransAp; -struct RedStateAp; -struct GenStateCond; - -/* - * Goto driven fsm. - */ -class GoGotoCodeGen - : public GoTablishCodeGen -{ -public: - GoGotoCodeGen( ostream &out ) - : GoTablishCodeGen(out) {} - -protected: - std::ostream &TO_STATE_ACTION_SWITCH( int level ); - std::ostream &FROM_STATE_ACTION_SWITCH( int level ); - std::ostream &EOF_ACTION_SWITCH( int level ); - std::ostream &ACTION_SWITCH( int level ); - std::ostream &STATE_GOTOS( int level ); - std::ostream &TRANSITIONS(); - std::ostream &EXEC_FUNCS(); - std::ostream &FINISH_CASES(); - - virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); - virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); - virtual unsigned int EOF_ACTION( RedStateAp *state ); - - std::ostream &TO_STATE_ACTIONS(); - std::ostream &FROM_STATE_ACTIONS(); - std::ostream &EOF_ACTIONS(); - - void COND_TRANSLATE( GenStateCond *stateCond, int level ); - void emitCondBSearch( RedStateAp *state, int level, int low, int high ); - void STATE_CONDS( RedStateAp *state, bool genDefault ); - - virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); - virtual int TRANS_NR( RedTransAp *trans ); - - void emitSingleSwitch( RedStateAp *state, int level ); - void emitRangeBSearch( RedStateAp *state, int level, int low, int high ); - - /* Called from STATE_GOTOS just before writing the gotos */ - virtual void GOTO_HEADER( RedStateAp *state, int level ); - virtual void STATE_GOTO_ERROR( int level ); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOGOTO_H +#define _GOGOTO_H + +#include <iostream> +#include "gotablish.h" + +/* Forwards. */ +struct CodeGenData; +struct NameInst; +struct RedTransAp; +struct RedStateAp; +struct GenStateCond; + +/* + * Goto driven fsm. + */ +class GoGotoCodeGen + : public GoTablishCodeGen +{ +public: + GoGotoCodeGen( ostream &out ) + : GoTablishCodeGen(out) {} + +protected: + std::ostream &TO_STATE_ACTION_SWITCH( int level ); + std::ostream &FROM_STATE_ACTION_SWITCH( int level ); + std::ostream &EOF_ACTION_SWITCH( int level ); + std::ostream &ACTION_SWITCH( int level ); + std::ostream &STATE_GOTOS( int level ); + std::ostream &TRANSITIONS(); + std::ostream &EXEC_FUNCS(); + std::ostream &FINISH_CASES(); + + virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); + virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); + virtual unsigned int EOF_ACTION( RedStateAp *state ); + + std::ostream &TO_STATE_ACTIONS(); + std::ostream &FROM_STATE_ACTIONS(); + std::ostream &EOF_ACTIONS(); + + void COND_TRANSLATE( GenStateCond *stateCond, int level ); + void emitCondBSearch( RedStateAp *state, int level, int low, int high ); + void STATE_CONDS( RedStateAp *state, bool genDefault ); + + virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); + virtual int TRANS_NR( RedTransAp *trans ); + + void emitSingleSwitch( RedStateAp *state, int level ); + void emitRangeBSearch( RedStateAp *state, int level, int low, int high ); + + /* Called from STATE_GOTOS just before writing the gotos */ + virtual void GOTO_HEADER( RedStateAp *state, int level ); + virtual void STATE_GOTO_ERROR( int level ); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/goipgoto.cpp b/contrib/tools/ragel6/goipgoto.cpp index 153197e049..00184e19c9 100644 --- a/contrib/tools/ragel6/goipgoto.cpp +++ b/contrib/tools/ragel6/goipgoto.cpp @@ -1,477 +1,477 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "goipgoto.h" -#include "redfsm.h" -#include "gendata.h" -#include "bstmap.h" - -using std::endl; - -bool GoIpGotoCodeGen::useAgainLabel() -{ - return redFsm->anyRegActionRets() || - redFsm->anyRegActionByValControl() || - redFsm->anyRegNextStmt(); -} - -void GoIpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) -{ - ret << "{" << "goto st" << gotoDest << " }"; -} - -void GoIpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "{"; - INLINE_LIST( ret, prePushExpr, 0, false, false ); - } - - ret << "{" << STACK() << "[" << TOP() << "] = " << targState << - "; " << TOP() << "++; " << "goto st" << callDest << " }"; - - if ( prePushExpr != 0 ) - ret << "}"; -} - -void GoIpGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "{"; - INLINE_LIST( ret, prePushExpr, 0, false, false ); - } - - ret << "{" << STACK() << "[" << TOP() << "] = " << targState << "; " << TOP() << "++; " << vCS() << " = ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << "goto _again }"; - - if ( prePushExpr != 0 ) - ret << "}"; -} - -void GoIpGotoCodeGen::RET( ostream &ret, bool inFinish ) -{ - ret << "{" << TOP() << "--; " << vCS() << " = " << STACK() << "[" << TOP() << "];"; - - if ( postPopExpr != 0 ) { - ret << "{"; - INLINE_LIST( ret, postPopExpr, 0, false, false ); - ret << "}"; - } - - ret << "goto _again }"; -} - -void GoIpGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << "{" << vCS() << " = ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << "); " << "goto _again }"; -} - -void GoIpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) -{ - ret << vCS() << " = " << nextDest << ";"; -} - -void GoIpGotoCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << vCS() << " = ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << ");"; -} - -void GoIpGotoCodeGen::CURS( ostream &ret, bool inFinish ) -{ - ret << "(_ps)"; -} - -void GoIpGotoCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) -{ - ret << targState; -} - -void GoIpGotoCodeGen::BREAK( ostream &ret, int targState, bool csForced ) -{ - outLabelUsed = true; - ret << "{" << P() << "++; "; - if ( !csForced ) - ret << vCS() << " = " << targState << "; "; - ret << "goto _out }"; -} - -bool GoIpGotoCodeGen::IN_TRANS_ACTIONS( RedStateAp *state ) -{ - bool anyWritten = false; - - /* Emit any transitions that have actions and that go to this state. */ - for ( int it = 0; it < state->numInTrans; it++ ) { - RedTransAp *trans = state->inTrans[it]; - if ( trans->action != 0 && trans->labelNeeded ) { - /* Remember that we wrote an action so we know to write the - * line directive for going back to the output. */ - anyWritten = true; - - /* Write the label for the transition so it can be jumped to. */ - out << "tr" << trans->id << ":" << endl; - - /* If the action contains a next, then we must preload the current - * state since the action may or may not set it. */ - if ( trans->action->anyNextStmt() ) - out << " " << vCS() << " = " << trans->targ->id << endl; - - /* Write each action in the list. */ - for ( GenActionTable::Iter item = trans->action->key; item.lte(); item++ ) { - ACTION( out, item->value, trans->targ->id, false, - trans->action->anyNextStmt() ); - } - - /* If the action contains a next then we need to reload, otherwise - * jump directly to the target state. */ - if ( trans->action->anyNextStmt() ) - out << " goto _again" << endl; - else - out << " goto st" << trans->targ->id << endl; - } - } - - return anyWritten; -} - -std::ostream &GoIpGotoCodeGen::STATE_GOTOS_SWITCH( int level ) -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - out << TABS(level) << "case " << st->id << ":" << endl; - out << TABS(level + 1) << "goto st_case_" << st->id << endl; - } - return out; -} - -/* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for each - * state. */ -void GoIpGotoCodeGen::GOTO_HEADER( RedStateAp *state, int level ) -{ - bool anyWritten = IN_TRANS_ACTIONS( state ); - - if ( state->labelNeeded ) - out << TABS(level) << "st" << state->id << ":" << endl; - - if ( state->toStateAction != 0 ) { - /* Remember that we wrote an action. Write every action in the list. */ - anyWritten = true; - for ( GenActionTable::Iter item = state->toStateAction->key; item.lte(); item++ ) { - ACTION( out, item->value, state->id, false, - state->toStateAction->anyNextStmt() ); - } - } - - /* Advance and test buffer pos. */ - if ( state->labelNeeded ) { - if ( !noEnd ) { - out << - TABS(level + 1) << "if " << P() << "++; " << P() << " == " << PE() << " {" << endl << - TABS(level + 2) << "goto _test_eof" << state->id << endl << - TABS(level + 1) << "}" << endl; - } - else { - out << - TABS(level + 1) << P() << "++" << endl; - } - } - - /* Give the state a label. */ - out << TABS(level) << "st_case_" << state->id << ":" << endl; - - if ( state->fromStateAction != 0 ) { - /* Remember that we wrote an action. Write every action in the list. */ - anyWritten = true; - for ( GenActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ ) { - ACTION( out, item->value, state->id, false, - state->fromStateAction->anyNextStmt() ); - } - } - - if ( anyWritten ) - genLineDirective( out ); - - /* Record the prev state if necessary. */ - if ( state->anyRegCurStateRef() ) - out << TABS(level + 1) << "_ps = " << state->id << endl; -} - -void GoIpGotoCodeGen::STATE_GOTO_ERROR( int level ) -{ - /* In the error state we need to emit some stuff that usually goes into - * the header. */ - RedStateAp *state = redFsm->errState; - bool anyWritten = IN_TRANS_ACTIONS( state ); - - /* No case label needed since we don't switch on the error state. */ - if ( anyWritten ) - genLineDirective( out ); - - out << "st_case_" << state->id << ":" << endl; - if ( state->labelNeeded ) - out << TABS(level) << "st" << state->id << ":" << endl; - - /* Break out here. */ - outLabelUsed = true; - out << TABS(level + 1) << vCS() << " = " << state->id << endl; - out << TABS(level + 1) << "goto _out" << endl; -} - - -/* Emit the goto to take for a given transition. */ -std::ostream &GoIpGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level ) -{ - if ( trans->action != 0 ) { - /* Go to the transition which will go to the state. */ - out << TABS(level) << "goto tr" << trans->id; - } - else { - /* Go directly to the target state. */ - out << TABS(level) << "goto st" << trans->targ->id; - } - return out; -} - -int GoIpGotoCodeGen::TRANS_NR( RedTransAp *trans ) -{ - if ( trans->action != 0 ) { - /* Go to the transition which will go to the state. */ - return trans->id + redFsm->stateList.length(); - } - else { - /* Go directly to the target state. */ - return trans->targ->id; - } -} - -std::ostream &GoIpGotoCodeGen::EXIT_STATES() -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->outNeeded ) { - testEofUsed = true; - out << " _test_eof" << st->id << ": " << vCS() << " = " << - st->id << "; goto _test_eof" << endl; - } - } - return out; -} - -std::ostream &GoIpGotoCodeGen::AGAIN_CASES( int level ) -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "goipgoto.h" +#include "redfsm.h" +#include "gendata.h" +#include "bstmap.h" + +using std::endl; + +bool GoIpGotoCodeGen::useAgainLabel() +{ + return redFsm->anyRegActionRets() || + redFsm->anyRegActionByValControl() || + redFsm->anyRegNextStmt(); +} + +void GoIpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) +{ + ret << "{" << "goto st" << gotoDest << " }"; +} + +void GoIpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "{"; + INLINE_LIST( ret, prePushExpr, 0, false, false ); + } + + ret << "{" << STACK() << "[" << TOP() << "] = " << targState << + "; " << TOP() << "++; " << "goto st" << callDest << " }"; + + if ( prePushExpr != 0 ) + ret << "}"; +} + +void GoIpGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "{"; + INLINE_LIST( ret, prePushExpr, 0, false, false ); + } + + ret << "{" << STACK() << "[" << TOP() << "] = " << targState << "; " << TOP() << "++; " << vCS() << " = ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); + ret << "); " << "goto _again }"; + + if ( prePushExpr != 0 ) + ret << "}"; +} + +void GoIpGotoCodeGen::RET( ostream &ret, bool inFinish ) +{ + ret << "{" << TOP() << "--; " << vCS() << " = " << STACK() << "[" << TOP() << "];"; + + if ( postPopExpr != 0 ) { + ret << "{"; + INLINE_LIST( ret, postPopExpr, 0, false, false ); + ret << "}"; + } + + ret << "goto _again }"; +} + +void GoIpGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << "{" << vCS() << " = ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); + ret << "); " << "goto _again }"; +} + +void GoIpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) +{ + ret << vCS() << " = " << nextDest << ";"; +} + +void GoIpGotoCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << vCS() << " = ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); + ret << ");"; +} + +void GoIpGotoCodeGen::CURS( ostream &ret, bool inFinish ) +{ + ret << "(_ps)"; +} + +void GoIpGotoCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) +{ + ret << targState; +} + +void GoIpGotoCodeGen::BREAK( ostream &ret, int targState, bool csForced ) +{ + outLabelUsed = true; + ret << "{" << P() << "++; "; + if ( !csForced ) + ret << vCS() << " = " << targState << "; "; + ret << "goto _out }"; +} + +bool GoIpGotoCodeGen::IN_TRANS_ACTIONS( RedStateAp *state ) +{ + bool anyWritten = false; + + /* Emit any transitions that have actions and that go to this state. */ + for ( int it = 0; it < state->numInTrans; it++ ) { + RedTransAp *trans = state->inTrans[it]; + if ( trans->action != 0 && trans->labelNeeded ) { + /* Remember that we wrote an action so we know to write the + * line directive for going back to the output. */ + anyWritten = true; + + /* Write the label for the transition so it can be jumped to. */ + out << "tr" << trans->id << ":" << endl; + + /* If the action contains a next, then we must preload the current + * state since the action may or may not set it. */ + if ( trans->action->anyNextStmt() ) + out << " " << vCS() << " = " << trans->targ->id << endl; + + /* Write each action in the list. */ + for ( GenActionTable::Iter item = trans->action->key; item.lte(); item++ ) { + ACTION( out, item->value, trans->targ->id, false, + trans->action->anyNextStmt() ); + } + + /* If the action contains a next then we need to reload, otherwise + * jump directly to the target state. */ + if ( trans->action->anyNextStmt() ) + out << " goto _again" << endl; + else + out << " goto st" << trans->targ->id << endl; + } + } + + return anyWritten; +} + +std::ostream &GoIpGotoCodeGen::STATE_GOTOS_SWITCH( int level ) +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + out << TABS(level) << "case " << st->id << ":" << endl; + out << TABS(level + 1) << "goto st_case_" << st->id << endl; + } + return out; +} + +/* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for each + * state. */ +void GoIpGotoCodeGen::GOTO_HEADER( RedStateAp *state, int level ) +{ + bool anyWritten = IN_TRANS_ACTIONS( state ); + + if ( state->labelNeeded ) + out << TABS(level) << "st" << state->id << ":" << endl; + + if ( state->toStateAction != 0 ) { + /* Remember that we wrote an action. Write every action in the list. */ + anyWritten = true; + for ( GenActionTable::Iter item = state->toStateAction->key; item.lte(); item++ ) { + ACTION( out, item->value, state->id, false, + state->toStateAction->anyNextStmt() ); + } + } + + /* Advance and test buffer pos. */ + if ( state->labelNeeded ) { + if ( !noEnd ) { + out << + TABS(level + 1) << "if " << P() << "++; " << P() << " == " << PE() << " {" << endl << + TABS(level + 2) << "goto _test_eof" << state->id << endl << + TABS(level + 1) << "}" << endl; + } + else { + out << + TABS(level + 1) << P() << "++" << endl; + } + } + + /* Give the state a label. */ + out << TABS(level) << "st_case_" << state->id << ":" << endl; + + if ( state->fromStateAction != 0 ) { + /* Remember that we wrote an action. Write every action in the list. */ + anyWritten = true; + for ( GenActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ ) { + ACTION( out, item->value, state->id, false, + state->fromStateAction->anyNextStmt() ); + } + } + + if ( anyWritten ) + genLineDirective( out ); + + /* Record the prev state if necessary. */ + if ( state->anyRegCurStateRef() ) + out << TABS(level + 1) << "_ps = " << state->id << endl; +} + +void GoIpGotoCodeGen::STATE_GOTO_ERROR( int level ) +{ + /* In the error state we need to emit some stuff that usually goes into + * the header. */ + RedStateAp *state = redFsm->errState; + bool anyWritten = IN_TRANS_ACTIONS( state ); + + /* No case label needed since we don't switch on the error state. */ + if ( anyWritten ) + genLineDirective( out ); + + out << "st_case_" << state->id << ":" << endl; + if ( state->labelNeeded ) + out << TABS(level) << "st" << state->id << ":" << endl; + + /* Break out here. */ + outLabelUsed = true; + out << TABS(level + 1) << vCS() << " = " << state->id << endl; + out << TABS(level + 1) << "goto _out" << endl; +} + + +/* Emit the goto to take for a given transition. */ +std::ostream &GoIpGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level ) +{ + if ( trans->action != 0 ) { + /* Go to the transition which will go to the state. */ + out << TABS(level) << "goto tr" << trans->id; + } + else { + /* Go directly to the target state. */ + out << TABS(level) << "goto st" << trans->targ->id; + } + return out; +} + +int GoIpGotoCodeGen::TRANS_NR( RedTransAp *trans ) +{ + if ( trans->action != 0 ) { + /* Go to the transition which will go to the state. */ + return trans->id + redFsm->stateList.length(); + } + else { + /* Go directly to the target state. */ + return trans->targ->id; + } +} + +std::ostream &GoIpGotoCodeGen::EXIT_STATES() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->outNeeded ) { + testEofUsed = true; + out << " _test_eof" << st->id << ": " << vCS() << " = " << + st->id << "; goto _test_eof" << endl; + } + } + return out; +} + +std::ostream &GoIpGotoCodeGen::AGAIN_CASES( int level ) +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + out << + TABS(level) << "case " << st->id << ":" << endl << + TABS(level + 1) << "goto st" << st->id << endl; + } + return out; +} + +std::ostream &GoIpGotoCodeGen::FINISH_CASES( int level ) +{ + bool anyWritten = false; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofAction != 0 ) { + if ( st->eofAction->eofRefs == 0 ) + st->eofAction->eofRefs = new IntSet; + st->eofAction->eofRefs->insert( st->id ); + } + } + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << TABS(level) << "case " << st->id << ":" << endl << + TABS(level + 1) << "goto tr" << st->eofTrans->id << endl; + } + + for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { + if ( act->eofRefs != 0 ) { + out << TABS(level) << "case "; + for ( IntSet::Iter pst = *act->eofRefs; pst.lte(); pst++ ) { + out << *pst; + if ( !pst.last() ) + out << ", "; + } + out << ":" << endl; + + /* Remember that we wrote a trans so we know to write the + * line directive for going back to the output. */ + anyWritten = true; + + /* Write each action in the eof action list. */ + for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) + ACTION( out, item->value, STATE_ERR_STATE, true, false ); + } + } + + if ( anyWritten ) + genLineDirective( out ); + return out; +} + +void GoIpGotoCodeGen::setLabelsNeeded( GenInlineList *inlineList ) +{ + for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { + switch ( item->type ) { + case GenInlineItem::Goto: case GenInlineItem::Call: { + /* Mark the target as needing a label. */ + item->targState->labelNeeded = true; + break; + } + default: break; + } + + if ( item->children != 0 ) + setLabelsNeeded( item->children ); + } +} + +/* Set up labelNeeded flag for each state. */ +void GoIpGotoCodeGen::setLabelsNeeded() +{ + /* If we use the _again label, then we the _again switch, which uses all + * labels. */ + if ( useAgainLabel() ) { + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + st->labelNeeded = true; + } + else { + /* Do not use all labels by default, init all labelNeeded vars to false. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + st->labelNeeded = false; + + /* Walk all transitions and set only those that have targs. */ + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) { + /* If there is no action with a next statement, then the label will be + * needed. */ + if ( trans->action == 0 || !trans->action->anyNextStmt() ) + trans->targ->labelNeeded = true; + + /* Need labels for states that have goto or calls in action code + * invoked on characters (ie, not from out action code). */ + if ( trans->action != 0 ) { + /* Loop the actions. */ + for ( GenActionTable::Iter act = trans->action->key; act.lte(); act++ ) { + /* Get the action and walk it's tree. */ + setLabelsNeeded( act->value->inlineList ); + } + } + } + } + + if ( !noEnd ) { + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st != redFsm->errState ) + st->outNeeded = st->labelNeeded; + } + } +} + +void GoIpGotoCodeGen::writeData() +{ + STATE_IDS(); +} + +void GoIpGotoCodeGen::writeExec() +{ + /* Must set labels immediately before writing because we may depend on the + * noend write option. */ + setLabelsNeeded(); + testEofUsed = false; + outLabelUsed = false; + + out << " {" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << " = 0" << endl; + + if ( redFsm->anyConditions() ) + out << " var _widec " << WIDE_ALPH_TYPE() << endl; + + if ( !noEnd ) { + testEofUsed = true; out << - TABS(level) << "case " << st->id << ":" << endl << - TABS(level + 1) << "goto st" << st->id << endl; - } - return out; -} - -std::ostream &GoIpGotoCodeGen::FINISH_CASES( int level ) -{ - bool anyWritten = false; - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofAction != 0 ) { - if ( st->eofAction->eofRefs == 0 ) - st->eofAction->eofRefs = new IntSet; - st->eofAction->eofRefs->insert( st->id ); - } - } - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) - out << TABS(level) << "case " << st->id << ":" << endl << - TABS(level + 1) << "goto tr" << st->eofTrans->id << endl; - } - - for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { - if ( act->eofRefs != 0 ) { - out << TABS(level) << "case "; - for ( IntSet::Iter pst = *act->eofRefs; pst.lte(); pst++ ) { - out << *pst; - if ( !pst.last() ) - out << ", "; - } - out << ":" << endl; - - /* Remember that we wrote a trans so we know to write the - * line directive for going back to the output. */ - anyWritten = true; - - /* Write each action in the eof action list. */ - for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) - ACTION( out, item->value, STATE_ERR_STATE, true, false ); - } - } - - if ( anyWritten ) - genLineDirective( out ); - return out; -} - -void GoIpGotoCodeGen::setLabelsNeeded( GenInlineList *inlineList ) -{ - for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { - switch ( item->type ) { - case GenInlineItem::Goto: case GenInlineItem::Call: { - /* Mark the target as needing a label. */ - item->targState->labelNeeded = true; - break; - } - default: break; - } - - if ( item->children != 0 ) - setLabelsNeeded( item->children ); - } -} - -/* Set up labelNeeded flag for each state. */ -void GoIpGotoCodeGen::setLabelsNeeded() -{ - /* If we use the _again label, then we the _again switch, which uses all - * labels. */ - if ( useAgainLabel() ) { - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - st->labelNeeded = true; - } - else { - /* Do not use all labels by default, init all labelNeeded vars to false. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - st->labelNeeded = false; - - /* Walk all transitions and set only those that have targs. */ - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) { - /* If there is no action with a next statement, then the label will be - * needed. */ - if ( trans->action == 0 || !trans->action->anyNextStmt() ) - trans->targ->labelNeeded = true; - - /* Need labels for states that have goto or calls in action code - * invoked on characters (ie, not from out action code). */ - if ( trans->action != 0 ) { - /* Loop the actions. */ - for ( GenActionTable::Iter act = trans->action->key; act.lte(); act++ ) { - /* Get the action and walk it's tree. */ - setLabelsNeeded( act->value->inlineList ); - } - } - } - } - - if ( !noEnd ) { - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st != redFsm->errState ) - st->outNeeded = st->labelNeeded; - } - } -} - -void GoIpGotoCodeGen::writeData() -{ - STATE_IDS(); -} - -void GoIpGotoCodeGen::writeExec() -{ - /* Must set labels immediately before writing because we may depend on the - * noend write option. */ - setLabelsNeeded(); - testEofUsed = false; - outLabelUsed = false; - - out << " {" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << " = 0" << endl; - - if ( redFsm->anyConditions() ) - out << " var _widec " << WIDE_ALPH_TYPE() << endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( useAgainLabel() ) { - out << - " goto _resume" << endl << - endl << - "_again:" << endl << - " switch " << vCS() << " {" << endl; - AGAIN_CASES(1) << - " }" << endl << - endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << "++; " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl; - } - out << "_resume:" << endl; - } - - out << - " switch " << vCS() << " {" << endl; - STATE_GOTOS_SWITCH(1); - out << - " }" << endl; - out << " goto st_out" << endl; - STATE_GOTOS(1); - out << " st_out:" << endl; - EXIT_STATES() << - endl; - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl << - " switch " << vCS() << " {" << endl; - FINISH_CASES(2); - out << - " }" << endl << - " }" << endl << - endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << - " }" << endl; -} + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( useAgainLabel() ) { + out << + " goto _resume" << endl << + endl << + "_again:" << endl << + " switch " << vCS() << " {" << endl; + AGAIN_CASES(1) << + " }" << endl << + endl; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << "++; " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl; + } + out << "_resume:" << endl; + } + + out << + " switch " << vCS() << " {" << endl; + STATE_GOTOS_SWITCH(1); + out << + " }" << endl; + out << " goto st_out" << endl; + STATE_GOTOS(1); + out << " st_out:" << endl; + EXIT_STATES() << + endl; + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl << + " switch " << vCS() << " {" << endl; + FINISH_CASES(2); + out << + " }" << endl << + " }" << endl << + endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << + " }" << endl; +} diff --git a/contrib/tools/ragel6/goipgoto.h b/contrib/tools/ragel6/goipgoto.h index cceaee0c63..0afc5bbb42 100644 --- a/contrib/tools/ragel6/goipgoto.h +++ b/contrib/tools/ragel6/goipgoto.h @@ -1,75 +1,75 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOIPGOTO_H -#define _GOIPGOTO_H - -#include <iostream> -#include "gogoto.h" - -/* Forwards. */ -struct CodeGenData; - -class GoIpGotoCodeGen - : public GoGotoCodeGen -{ -public: - GoIpGotoCodeGen( ostream &out ) - : GoGotoCodeGen(out) {} - - std::ostream &EXIT_STATES(); - std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); - int TRANS_NR( RedTransAp *trans ); - std::ostream &FINISH_CASES( int level ); - std::ostream &AGAIN_CASES( int level ); - std::ostream &STATE_GOTOS_SWITCH( int level ); - - void GOTO( ostream &ret, int gotoDest, bool inFinish ); - void CALL( ostream &ret, int callDest, int targState, bool inFinish ); - void NEXT( ostream &ret, int nextDest, bool inFinish ); - void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); - void RET( ostream &ret, bool inFinish ); - void CURS( ostream &ret, bool inFinish ); - void TARGS( ostream &ret, bool inFinish, int targState ); - void BREAK( ostream &ret, int targState, bool csForced ); - - virtual void writeData(); - virtual void writeExec(); - -protected: - bool useAgainLabel(); - - /* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for - * each state. */ - bool IN_TRANS_ACTIONS( RedStateAp *state ); - void GOTO_HEADER( RedStateAp *state, int level ); - void STATE_GOTO_ERROR( int level ); - - /* Set up labelNeeded flag for each state. */ - void setLabelsNeeded( GenInlineList *inlineList ); - void setLabelsNeeded(); -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOIPGOTO_H +#define _GOIPGOTO_H + +#include <iostream> +#include "gogoto.h" + +/* Forwards. */ +struct CodeGenData; + +class GoIpGotoCodeGen + : public GoGotoCodeGen +{ +public: + GoIpGotoCodeGen( ostream &out ) + : GoGotoCodeGen(out) {} + + std::ostream &EXIT_STATES(); + std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); + int TRANS_NR( RedTransAp *trans ); + std::ostream &FINISH_CASES( int level ); + std::ostream &AGAIN_CASES( int level ); + std::ostream &STATE_GOTOS_SWITCH( int level ); + + void GOTO( ostream &ret, int gotoDest, bool inFinish ); + void CALL( ostream &ret, int callDest, int targState, bool inFinish ); + void NEXT( ostream &ret, int nextDest, bool inFinish ); + void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); + void RET( ostream &ret, bool inFinish ); + void CURS( ostream &ret, bool inFinish ); + void TARGS( ostream &ret, bool inFinish, int targState ); + void BREAK( ostream &ret, int targState, bool csForced ); + + virtual void writeData(); + virtual void writeExec(); + +protected: + bool useAgainLabel(); + + /* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for + * each state. */ + bool IN_TRANS_ACTIONS( RedStateAp *state ); + void GOTO_HEADER( RedStateAp *state, int level ); + void STATE_GOTO_ERROR( int level ); + + /* Set up labelNeeded flag for each state. */ + void setLabelsNeeded( GenInlineList *inlineList ); + void setLabelsNeeded(); +}; + +#endif diff --git a/contrib/tools/ragel6/gotable.cpp b/contrib/tools/ragel6/gotable.cpp index 01152d39bf..c909b8abca 100644 --- a/contrib/tools/ragel6/gotable.cpp +++ b/contrib/tools/ragel6/gotable.cpp @@ -1,977 +1,977 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <sstream> -#include "ragel.h" -#include "gotable.h" -#include "redfsm.h" -#include "gendata.h" - -using std::endl; - -/* Determine if we should use indicies or not. */ -void GoTabCodeGen::calcIndexSize() -{ - int sizeWithInds = 0, sizeWithoutInds = 0; - - /* Calculate cost of using with indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; - } - sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); - if ( redFsm->anyActions() ) - sizeWithInds += arrayTypeSize(redFsm->maxActionLoc) * redFsm->transSet.length(); - - /* Calculate the cost of not using indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; - if ( redFsm->anyActions() ) - sizeWithoutInds += arrayTypeSize(redFsm->maxActionLoc) * totalIndex; - } - - /* If using indicies reduces the size, use them. */ - useIndicies = sizeWithInds < sizeWithoutInds; -} - -std::ostream &GoTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->location+1; - out << act; - return out; -} - -std::ostream &GoTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->location+1; - out << act; - return out; -} - -std::ostream &GoTabCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->location+1; - out << act; - return out; -} - - -std::ostream &GoTabCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - /* If there are actions, emit them. Otherwise emit zero. */ - int act = 0; - if ( trans->action != 0 ) - act = trans->action->location+1; - out << act; - return out; -} - -std::ostream &GoTabCodeGen::TO_STATE_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numToStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoTabCodeGen::FROM_STATE_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numFromStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &GoTabCodeGen::EOF_ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numEofRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, true, false ); - } - } - - genLineDirective(out); - return out; -} - - -std::ostream &GoTabCodeGen::ACTION_SWITCH( int level ) -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numTransRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << TABS(level) << "case " << act->actionId << ":" << endl; - ACTION( out, act, 0, false, false ); - } - } - - genLineDirective(out); - return out; -} - -std::ostream &GoTabCodeGen::COND_OFFSETS() -{ - out << " "; - int totalStateNum = 0, curKeyOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the key offset. */ - out << curKeyOffset; - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - - /* Move the key offset ahead. */ - curKeyOffset += st->stateCondList.length(); - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::KEY_OFFSETS() -{ - out << " "; - int totalStateNum = 0, curKeyOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the key offset. */ - out << curKeyOffset; - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - - /* Move the key offset ahead. */ - curKeyOffset += st->outSingle.length() + st->outRange.length()*2; - } - out << endl; - return out; -} - - -std::ostream &GoTabCodeGen::INDEX_OFFSETS() -{ - out << " "; - int totalStateNum = 0, curIndOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the index offset. */ - out << curIndOffset; - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - - /* Move the index offset ahead. */ - curIndOffset += st->outSingle.length() + st->outRange.length(); - if ( st->defTrans != 0 ) - curIndOffset += 1; - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::COND_LENS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - out << st->stateCondList.length(); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - - -std::ostream &GoTabCodeGen::SINGLE_LENS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - out << st->outSingle.length(); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::RANGE_LENS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Emit length of range index. */ - out << st->outRange.length(); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::TO_STATE_ACTIONS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - TO_STATE_ACTION(st); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::FROM_STATE_ACTIONS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - FROM_STATE_ACTION(st); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::EOF_ACTIONS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - EOF_ACTION(st); - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::EOF_TRANS() -{ - out << " "; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - long trans = 0; - if ( st->eofTrans != 0 ) { - assert( st->eofTrans->pos >= 0 ); - trans = st->eofTrans->pos+1; - } - out << trans; - - out << ", "; - if ( !st.last() ) { - if ( ++totalStateNum % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - return out; -} - - -std::ostream &GoTabCodeGen::COND_KEYS() -{ - out << " "; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Loop the state's transitions. */ - for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { - /* Lower key. */ - out << KEY( sc->lowKey ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - - /* Upper key. */ - out << KEY( sc->highKey ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::COND_SPACES() -{ - out << " "; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Loop the state's transitions. */ - for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { - /* Cond Space id. */ - out << sc->condSpace->condSpaceId << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::KEYS() -{ - out << " "; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Loop the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - out << KEY( stel->lowKey ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* Loop the state's transitions. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - /* Lower key. */ - out << KEY( rtel->lowKey ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - - /* Upper key. */ - out << KEY( rtel->highKey ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::INDICIES() -{ - out << " "; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Walk the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - out << stel->value->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* Walk the ranges. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - out << rtel->value->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* The state's default index goes next. */ - if ( st->defTrans != 0 ) { - out << st->defTrans->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::TRANS_TARGS() -{ - out << " "; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Walk the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - RedTransAp *trans = stel->value; - out << trans->targ->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* Walk the ranges. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - RedTransAp *trans = rtel->value; - out << trans->targ->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* The state's default target state. */ - if ( st->defTrans != 0 ) { - RedTransAp *trans = st->defTrans; - out << trans->targ->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - /* Add any eof transitions that have not yet been written out above. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) { - RedTransAp *trans = st->eofTrans; - trans->pos = totalTrans; - out << trans->targ->id << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - - out << endl; - return out; -} - - -std::ostream &GoTabCodeGen::TRANS_ACTIONS() -{ - out << " "; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Walk the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - RedTransAp *trans = stel->value; - TRANS_ACTION( trans ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* Walk the ranges. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - RedTransAp *trans = rtel->value; - TRANS_ACTION( trans ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - - /* The state's default index goes next. */ - if ( st->defTrans != 0 ) { - RedTransAp *trans = st->defTrans; - TRANS_ACTION( trans ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - /* Add any eof transitions that have not yet been written out above. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) { - RedTransAp *trans = st->eofTrans; - TRANS_ACTION( trans ) << ", "; - if ( ++totalTrans % IALL == 0 ) - out << endl << " "; - } - } - - out << endl; - return out; -} - -std::ostream &GoTabCodeGen::TRANS_TARGS_WI() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << " "; - int totalStates = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Record the position, need this for eofTrans. */ - RedTransAp *trans = transPtrs[t]; - trans->pos = t; - - /* Write out the target state. */ - out << trans->targ->id << ", "; - if ( t < redFsm->transSet.length()-1 ) { - if ( ++totalStates % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] transPtrs; - return out; -} - - -std::ostream &GoTabCodeGen::TRANS_ACTIONS_WI() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << " "; - int totalAct = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Write the function for the transition. */ - RedTransAp *trans = transPtrs[t]; - TRANS_ACTION( trans ); - out << ", "; - if ( t < redFsm->transSet.length()-1 ) { - if ( ++totalAct % IALL == 0 ) - out << endl << " "; - } - } - out << endl; - delete[] transPtrs; - return out; -} - -void GoTabCodeGen::writeData() -{ - /* If there are any transtion functions then output the array. If there - * are none, don't bother emitting an empty array that won't be used. */ - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); - ACTIONS_ARRAY(); - CLOSE_ARRAY() << endl; - } - - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); - COND_OFFSETS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); - COND_LENS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); - COND_SPACES(); - CLOSE_ARRAY() << endl; - } - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); - KEY_OFFSETS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); - SINGLE_LENS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); - RANGE_LENS(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); - INDEX_OFFSETS(); - CLOSE_ARRAY() << endl; - - if ( useIndicies ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << endl; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS_WI(); - CLOSE_ARRAY() << endl; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); - TRANS_ACTIONS_WI(); - CLOSE_ARRAY() << endl; - } - } - else { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << endl; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << endl; - } - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << endl; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << endl; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << endl; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << endl; - } - - STATE_IDS(); -} - -void GoTabCodeGen::LOCATE_TRANS() -{ - out << - " _keys = " << CAST(INT(), KO() + "[" + vCS() + "]") << endl << - " _trans = " << CAST(INT(), IO() + "[" + vCS() + "]") << endl << - endl << - " _klen = " << CAST(INT(), SL() + "[" + vCS() + "]") << endl << - " if _klen > 0 {" << endl << - " _lower := " << CAST(INT(), "_keys") << endl << - " var _mid " << INT() << endl << - " _upper := " << CAST(INT(), "_keys + _klen - 1") << endl << - " for {" << endl << - " if _upper < _lower {" << endl << - " break" << endl << - " }" << endl << - endl << - " _mid = _lower + ((_upper - _lower) >> 1)" << endl << - " switch {" << endl << - " case " << GET_WIDE_KEY() << " < " << K() << "[_mid]" << ":" << endl << - " _upper = _mid - 1" << endl << - " case " << GET_WIDE_KEY() << " > " << K() << "[_mid]" << ":" << endl << - " _lower = _mid + 1" << endl << - " default:" << endl << - " _trans += " << CAST(INT(), "_mid - " + CAST(INT(), "_keys")) << endl << - " goto _match" << endl << - " }" << endl << - " }" << endl << - " _keys += _klen" << endl << - " _trans += _klen" << endl << - " }" << endl << - endl << - " _klen = " << CAST(INT(), RL() + "[" + vCS() + "]") << endl << - " if _klen > 0 {" << endl << - " _lower := " << CAST(INT(), "_keys") << endl << - " var _mid " << INT() << endl << - " _upper := " << CAST(INT(), "_keys + (_klen << 1) - 2") << endl << - " for {" << endl << - " if _upper < _lower {" << endl << - " break" << endl << - " }" << endl << - endl << - " _mid = _lower + (((_upper - _lower) >> 1) & ^1)" << endl << - " switch {" << endl << - " case " << GET_WIDE_KEY() << " < " << K() << "[_mid]" << ":" << endl << - " _upper = _mid - 2" << endl << - " case " << GET_WIDE_KEY() << " > " << K() << "[_mid + 1]" << ":" << endl << - " _lower = _mid + 2" << endl << - " default:" << endl << - " _trans += " << CAST(INT(), "(_mid - " + CAST(INT(), "_keys") + ") >> 1") << endl << - " goto _match" << endl << - " }" << endl << - " }" << endl << - " _trans += _klen" << endl << - " }" << endl << - endl; -} - -void GoTabCodeGen::COND_TRANSLATE() -{ - out << - " _widec = " << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << endl << - " _klen = " << CAST(INT(), CL() + "[" + vCS() + "]") << endl << - " _keys = " << CAST(INT(), CO() + "[" + vCS() + "] * 2") << endl << - " if _klen > 0 {" << endl << - " _lower := " << CAST(INT(), "_keys") << endl << - " var _mid " << INT() << endl << - " _upper := " << CAST(INT(), "_keys + (_klen << 1) - 2") << endl << - " COND_LOOP:" << endl << - " for {" << endl << - " if _upper < _lower {" << endl << - " break" << endl << - " }" << endl << - endl << - " _mid = _lower + (((_upper - _lower) >> 1) & ^1)" << endl << - " switch {" << endl << - " case " << GET_WIDE_KEY() << " < " << CAST(WIDE_ALPH_TYPE(), CK() + "[_mid]") << ":" << endl << - " _upper = _mid - 2" << endl << - " case " << GET_WIDE_KEY() << " > " << CAST(WIDE_ALPH_TYPE(), CK() + "[_mid + 1]") << ":" << endl << - " _lower = _mid + 2" << endl << - " default:" << endl << - " switch " << C() << "[" << CAST(INT(), CO() + "[" + vCS() + "]") << - " + ((_mid - _keys)>>1)] {" << endl; - - for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { - GenCondSpace *condSpace = csi; - out << TABS(4) << "case " << condSpace->condSpaceId << ":" << endl; - out << TABS(5) << "_widec = " << KEY(condSpace->baseKey) << " + (" << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << - " - " << KEY(keyOps->minKey) << ")" << endl; - - for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { - out << TABS(5) << "if "; - CONDITION( out, *csi ); - Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); - out << " {" << endl << TABS(6) << "_widec += " << condValOffset << endl << TABS(5) << "}" << endl; - } - } - - out << - " }" << endl << - " break COND_LOOP" << endl << - " }" << endl << - " }" << endl << - " }" << endl << - endl; -} - -void GoTabCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << - " {" << endl << - " var _klen " << INT() << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " var _ps " << INT() << endl; - - out << - " var _trans " << INT() << endl; - - if ( redFsm->anyConditions() ) - out << " var _widec " << WIDE_ALPH_TYPE() << endl; - - if ( redFsm->anyToStateActions() || redFsm->anyRegActions() - || redFsm->anyFromStateActions() ) - { - out << - " var _acts " << INT() << endl << - " var _nacts " << UINT() << endl; - } - - out << - " var _keys " << INT() << endl; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " == " << PE() << " {" << endl << - " goto _test_eof" << endl << - " }" << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - out << "_resume:" << endl; - - if ( redFsm->anyFromStateActions() ) { - out << - " _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts - 1]" << " {" << endl; - FROM_STATE_ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << endl; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - LOCATE_TRANS(); - - out << "_match:" << endl; - - if ( useIndicies ) - out << " _trans = " << CAST(INT(), I() + "[_trans]") << endl; - - if ( redFsm->anyEofTrans() ) - out << "_eof_trans:" << endl; - - if ( redFsm->anyRegCurStateRef() ) - out << " _ps = " << vCS() << endl; - - out << - " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << endl; - - if ( redFsm->anyRegActions() ) { - out << - " if " << TA() << "[_trans] == 0 {" << endl << - " goto _again" << endl << - " }" << endl << - endl << - " _acts = " << CAST(INT(), TA() + "[_trans]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts-1]" << " {" << endl; - ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << endl; - } - - if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || - redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "_again:" << endl; - - if ( redFsm->anyToStateActions() ) { - out << - " _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl << - " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << - " for ; _nacts > 0; _nacts-- {" << endl << - " _acts++" << endl << - " switch " << A() << "[_acts-1] {" << endl; - TO_STATE_ACTION_SWITCH(2); - out << - " }" << endl << - " }" << endl << endl; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << - " goto _out" << endl << - " }" << endl; - } - - if ( !noEnd ) { - out << - " " << P() << "++" << endl << - " if " << P() << " != " << PE() << " {" << endl << - " goto _resume" << endl << - " }" << endl; - } - else { - out << - " " << P() << "++" << endl << - " goto _resume" << endl; - } - - if ( testEofUsed ) - out << " _test_eof: {}" << endl; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " == " << vEOF() << " {" << endl; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << ET() << "[" << vCS() << "] > 0 {" << endl << - " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << - " goto _eof_trans" << endl << - " }" << endl; - } - - if ( redFsm->anyEofActions() ) { - out << - " __acts := " << EA() << "[" << vCS() << "]" << endl << - " __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl << - " for ; __nacts > 0; __nacts-- {" << endl << - " __acts++" << endl << - " switch " << A() << "[__acts-1] {" << endl; - EOF_ACTION_SWITCH(3); - out << - " }" << endl << - " }" << endl; - } - - out << - " }" << endl << endl; - } - - if ( outLabelUsed ) - out << " _out: {}" << endl; - - out << " }" << endl; -} +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <sstream> +#include "ragel.h" +#include "gotable.h" +#include "redfsm.h" +#include "gendata.h" + +using std::endl; + +/* Determine if we should use indicies or not. */ +void GoTabCodeGen::calcIndexSize() +{ + int sizeWithInds = 0, sizeWithoutInds = 0; + + /* Calculate cost of using with indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; + } + sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); + if ( redFsm->anyActions() ) + sizeWithInds += arrayTypeSize(redFsm->maxActionLoc) * redFsm->transSet.length(); + + /* Calculate the cost of not using indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; + if ( redFsm->anyActions() ) + sizeWithoutInds += arrayTypeSize(redFsm->maxActionLoc) * totalIndex; + } + + /* If using indicies reduces the size, use them. */ + useIndicies = sizeWithInds < sizeWithoutInds; +} + +std::ostream &GoTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->location+1; + out << act; + return out; +} + +std::ostream &GoTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->location+1; + out << act; + return out; +} + +std::ostream &GoTabCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->location+1; + out << act; + return out; +} + + +std::ostream &GoTabCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + /* If there are actions, emit them. Otherwise emit zero. */ + int act = 0; + if ( trans->action != 0 ) + act = trans->action->location+1; + out << act; + return out; +} + +std::ostream &GoTabCodeGen::TO_STATE_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numToStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoTabCodeGen::FROM_STATE_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numFromStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &GoTabCodeGen::EOF_ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numEofRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, true, false ); + } + } + + genLineDirective(out); + return out; +} + + +std::ostream &GoTabCodeGen::ACTION_SWITCH( int level ) +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numTransRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << TABS(level) << "case " << act->actionId << ":" << endl; + ACTION( out, act, 0, false, false ); + } + } + + genLineDirective(out); + return out; +} + +std::ostream &GoTabCodeGen::COND_OFFSETS() +{ + out << " "; + int totalStateNum = 0, curKeyOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the key offset. */ + out << curKeyOffset; + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + + /* Move the key offset ahead. */ + curKeyOffset += st->stateCondList.length(); + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::KEY_OFFSETS() +{ + out << " "; + int totalStateNum = 0, curKeyOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the key offset. */ + out << curKeyOffset; + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + + /* Move the key offset ahead. */ + curKeyOffset += st->outSingle.length() + st->outRange.length()*2; + } + out << endl; + return out; +} + + +std::ostream &GoTabCodeGen::INDEX_OFFSETS() +{ + out << " "; + int totalStateNum = 0, curIndOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the index offset. */ + out << curIndOffset; + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + + /* Move the index offset ahead. */ + curIndOffset += st->outSingle.length() + st->outRange.length(); + if ( st->defTrans != 0 ) + curIndOffset += 1; + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::COND_LENS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + out << st->stateCondList.length(); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + + +std::ostream &GoTabCodeGen::SINGLE_LENS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + out << st->outSingle.length(); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::RANGE_LENS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Emit length of range index. */ + out << st->outRange.length(); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::TO_STATE_ACTIONS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + TO_STATE_ACTION(st); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::FROM_STATE_ACTIONS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + FROM_STATE_ACTION(st); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::EOF_ACTIONS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + EOF_ACTION(st); + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::EOF_TRANS() +{ + out << " "; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + long trans = 0; + if ( st->eofTrans != 0 ) { + assert( st->eofTrans->pos >= 0 ); + trans = st->eofTrans->pos+1; + } + out << trans; + + out << ", "; + if ( !st.last() ) { + if ( ++totalStateNum % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + return out; +} + + +std::ostream &GoTabCodeGen::COND_KEYS() +{ + out << " "; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Loop the state's transitions. */ + for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { + /* Lower key. */ + out << KEY( sc->lowKey ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + + /* Upper key. */ + out << KEY( sc->highKey ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::COND_SPACES() +{ + out << " "; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Loop the state's transitions. */ + for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { + /* Cond Space id. */ + out << sc->condSpace->condSpaceId << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::KEYS() +{ + out << " "; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Loop the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + out << KEY( stel->lowKey ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* Loop the state's transitions. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + /* Lower key. */ + out << KEY( rtel->lowKey ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + + /* Upper key. */ + out << KEY( rtel->highKey ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::INDICIES() +{ + out << " "; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Walk the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + out << stel->value->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* Walk the ranges. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + out << rtel->value->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* The state's default index goes next. */ + if ( st->defTrans != 0 ) { + out << st->defTrans->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::TRANS_TARGS() +{ + out << " "; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Walk the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + RedTransAp *trans = stel->value; + out << trans->targ->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* Walk the ranges. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + RedTransAp *trans = rtel->value; + out << trans->targ->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* The state's default target state. */ + if ( st->defTrans != 0 ) { + RedTransAp *trans = st->defTrans; + out << trans->targ->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + /* Add any eof transitions that have not yet been written out above. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) { + RedTransAp *trans = st->eofTrans; + trans->pos = totalTrans; + out << trans->targ->id << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + + out << endl; + return out; +} + + +std::ostream &GoTabCodeGen::TRANS_ACTIONS() +{ + out << " "; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Walk the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + RedTransAp *trans = stel->value; + TRANS_ACTION( trans ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* Walk the ranges. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + RedTransAp *trans = rtel->value; + TRANS_ACTION( trans ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + + /* The state's default index goes next. */ + if ( st->defTrans != 0 ) { + RedTransAp *trans = st->defTrans; + TRANS_ACTION( trans ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + /* Add any eof transitions that have not yet been written out above. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) { + RedTransAp *trans = st->eofTrans; + TRANS_ACTION( trans ) << ", "; + if ( ++totalTrans % IALL == 0 ) + out << endl << " "; + } + } + + out << endl; + return out; +} + +std::ostream &GoTabCodeGen::TRANS_TARGS_WI() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << " "; + int totalStates = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Record the position, need this for eofTrans. */ + RedTransAp *trans = transPtrs[t]; + trans->pos = t; + + /* Write out the target state. */ + out << trans->targ->id << ", "; + if ( t < redFsm->transSet.length()-1 ) { + if ( ++totalStates % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] transPtrs; + return out; +} + + +std::ostream &GoTabCodeGen::TRANS_ACTIONS_WI() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << " "; + int totalAct = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Write the function for the transition. */ + RedTransAp *trans = transPtrs[t]; + TRANS_ACTION( trans ); + out << ", "; + if ( t < redFsm->transSet.length()-1 ) { + if ( ++totalAct % IALL == 0 ) + out << endl << " "; + } + } + out << endl; + delete[] transPtrs; + return out; +} + +void GoTabCodeGen::writeData() +{ + /* If there are any transtion functions then output the array. If there + * are none, don't bother emitting an empty array that won't be used. */ + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); + ACTIONS_ARRAY(); + CLOSE_ARRAY() << endl; + } + + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); + COND_OFFSETS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); + COND_LENS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); + COND_SPACES(); + CLOSE_ARRAY() << endl; + } + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); + KEY_OFFSETS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); + SINGLE_LENS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); + RANGE_LENS(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); + INDEX_OFFSETS(); + CLOSE_ARRAY() << endl; + + if ( useIndicies ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << endl; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS_WI(); + CLOSE_ARRAY() << endl; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); + TRANS_ACTIONS_WI(); + CLOSE_ARRAY() << endl; + } + } + else { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << endl; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << endl; + } + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << endl; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << endl; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << endl; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << endl; + } + + STATE_IDS(); +} + +void GoTabCodeGen::LOCATE_TRANS() +{ + out << + " _keys = " << CAST(INT(), KO() + "[" + vCS() + "]") << endl << + " _trans = " << CAST(INT(), IO() + "[" + vCS() + "]") << endl << + endl << + " _klen = " << CAST(INT(), SL() + "[" + vCS() + "]") << endl << + " if _klen > 0 {" << endl << + " _lower := " << CAST(INT(), "_keys") << endl << + " var _mid " << INT() << endl << + " _upper := " << CAST(INT(), "_keys + _klen - 1") << endl << + " for {" << endl << + " if _upper < _lower {" << endl << + " break" << endl << + " }" << endl << + endl << + " _mid = _lower + ((_upper - _lower) >> 1)" << endl << + " switch {" << endl << + " case " << GET_WIDE_KEY() << " < " << K() << "[_mid]" << ":" << endl << + " _upper = _mid - 1" << endl << + " case " << GET_WIDE_KEY() << " > " << K() << "[_mid]" << ":" << endl << + " _lower = _mid + 1" << endl << + " default:" << endl << + " _trans += " << CAST(INT(), "_mid - " + CAST(INT(), "_keys")) << endl << + " goto _match" << endl << + " }" << endl << + " }" << endl << + " _keys += _klen" << endl << + " _trans += _klen" << endl << + " }" << endl << + endl << + " _klen = " << CAST(INT(), RL() + "[" + vCS() + "]") << endl << + " if _klen > 0 {" << endl << + " _lower := " << CAST(INT(), "_keys") << endl << + " var _mid " << INT() << endl << + " _upper := " << CAST(INT(), "_keys + (_klen << 1) - 2") << endl << + " for {" << endl << + " if _upper < _lower {" << endl << + " break" << endl << + " }" << endl << + endl << + " _mid = _lower + (((_upper - _lower) >> 1) & ^1)" << endl << + " switch {" << endl << + " case " << GET_WIDE_KEY() << " < " << K() << "[_mid]" << ":" << endl << + " _upper = _mid - 2" << endl << + " case " << GET_WIDE_KEY() << " > " << K() << "[_mid + 1]" << ":" << endl << + " _lower = _mid + 2" << endl << + " default:" << endl << + " _trans += " << CAST(INT(), "(_mid - " + CAST(INT(), "_keys") + ") >> 1") << endl << + " goto _match" << endl << + " }" << endl << + " }" << endl << + " _trans += _klen" << endl << + " }" << endl << + endl; +} + +void GoTabCodeGen::COND_TRANSLATE() +{ + out << + " _widec = " << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << endl << + " _klen = " << CAST(INT(), CL() + "[" + vCS() + "]") << endl << + " _keys = " << CAST(INT(), CO() + "[" + vCS() + "] * 2") << endl << + " if _klen > 0 {" << endl << + " _lower := " << CAST(INT(), "_keys") << endl << + " var _mid " << INT() << endl << + " _upper := " << CAST(INT(), "_keys + (_klen << 1) - 2") << endl << + " COND_LOOP:" << endl << + " for {" << endl << + " if _upper < _lower {" << endl << + " break" << endl << + " }" << endl << + endl << + " _mid = _lower + (((_upper - _lower) >> 1) & ^1)" << endl << + " switch {" << endl << + " case " << GET_WIDE_KEY() << " < " << CAST(WIDE_ALPH_TYPE(), CK() + "[_mid]") << ":" << endl << + " _upper = _mid - 2" << endl << + " case " << GET_WIDE_KEY() << " > " << CAST(WIDE_ALPH_TYPE(), CK() + "[_mid + 1]") << ":" << endl << + " _lower = _mid + 2" << endl << + " default:" << endl << + " switch " << C() << "[" << CAST(INT(), CO() + "[" + vCS() + "]") << + " + ((_mid - _keys)>>1)] {" << endl; + + for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { + GenCondSpace *condSpace = csi; + out << TABS(4) << "case " << condSpace->condSpaceId << ":" << endl; + out << TABS(5) << "_widec = " << KEY(condSpace->baseKey) << " + (" << CAST(WIDE_ALPH_TYPE(), GET_KEY()) << + " - " << KEY(keyOps->minKey) << ")" << endl; + + for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { + out << TABS(5) << "if "; + CONDITION( out, *csi ); + Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); + out << " {" << endl << TABS(6) << "_widec += " << condValOffset << endl << TABS(5) << "}" << endl; + } + } + + out << + " }" << endl << + " break COND_LOOP" << endl << + " }" << endl << + " }" << endl << + " }" << endl << + endl; +} + +void GoTabCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << + " {" << endl << + " var _klen " << INT() << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " var _ps " << INT() << endl; + + out << + " var _trans " << INT() << endl; + + if ( redFsm->anyConditions() ) + out << " var _widec " << WIDE_ALPH_TYPE() << endl; + + if ( redFsm->anyToStateActions() || redFsm->anyRegActions() + || redFsm->anyFromStateActions() ) + { + out << + " var _acts " << INT() << endl << + " var _nacts " << UINT() << endl; + } + + out << + " var _keys " << INT() << endl; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " == " << PE() << " {" << endl << + " goto _test_eof" << endl << + " }" << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + out << "_resume:" << endl; + + if ( redFsm->anyFromStateActions() ) { + out << + " _acts = " << CAST(INT(), FSA() + "[" + vCS() + "]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts - 1]" << " {" << endl; + FROM_STATE_ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << endl; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + LOCATE_TRANS(); + + out << "_match:" << endl; + + if ( useIndicies ) + out << " _trans = " << CAST(INT(), I() + "[_trans]") << endl; + + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:" << endl; + + if ( redFsm->anyRegCurStateRef() ) + out << " _ps = " << vCS() << endl; + + out << + " " << vCS() << " = " << CAST(INT(), TT() + "[_trans]") << endl << endl; + + if ( redFsm->anyRegActions() ) { + out << + " if " << TA() << "[_trans] == 0 {" << endl << + " goto _again" << endl << + " }" << endl << + endl << + " _acts = " << CAST(INT(), TA() + "[_trans]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts-1]" << " {" << endl; + ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << endl; + } + + if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || + redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "_again:" << endl; + + if ( redFsm->anyToStateActions() ) { + out << + " _acts = " << CAST(INT(), TSA() + "[" + vCS() + "]") << endl << + " _nacts = " << CAST(UINT(), A() + "[_acts]") << "; _acts++" << endl << + " for ; _nacts > 0; _nacts-- {" << endl << + " _acts++" << endl << + " switch " << A() << "[_acts-1] {" << endl; + TO_STATE_ACTION_SWITCH(2); + out << + " }" << endl << + " }" << endl << endl; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " == " << redFsm->errState->id << " {" << endl << + " goto _out" << endl << + " }" << endl; + } + + if ( !noEnd ) { + out << + " " << P() << "++" << endl << + " if " << P() << " != " << PE() << " {" << endl << + " goto _resume" << endl << + " }" << endl; + } + else { + out << + " " << P() << "++" << endl << + " goto _resume" << endl; + } + + if ( testEofUsed ) + out << " _test_eof: {}" << endl; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " == " << vEOF() << " {" << endl; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << ET() << "[" << vCS() << "] > 0 {" << endl << + " _trans = " << CAST(INT(), ET() + "[" + vCS() + "] - 1") << endl << + " goto _eof_trans" << endl << + " }" << endl; + } + + if ( redFsm->anyEofActions() ) { + out << + " __acts := " << EA() << "[" << vCS() << "]" << endl << + " __nacts := " << CAST(UINT(), A() + "[__acts]") << "; __acts++" << endl << + " for ; __nacts > 0; __nacts-- {" << endl << + " __acts++" << endl << + " switch " << A() << "[__acts-1] {" << endl; + EOF_ACTION_SWITCH(3); + out << + " }" << endl << + " }" << endl; + } + + out << + " }" << endl << endl; + } + + if ( outLabelUsed ) + out << " _out: {}" << endl; + + out << " }" << endl; +} diff --git a/contrib/tools/ragel6/gotable.h b/contrib/tools/ragel6/gotable.h index a62b8a0906..2e369138db 100644 --- a/contrib/tools/ragel6/gotable.h +++ b/contrib/tools/ragel6/gotable.h @@ -1,76 +1,76 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOTABLE_H -#define _GOTABLE_H - -#include <iostream> -#include "gotablish.h" - -class GoTabCodeGen - : public GoTablishCodeGen -{ -public: - GoTabCodeGen( ostream &out ) - : GoTablishCodeGen(out) {} - - virtual ~GoTabCodeGen() { } - virtual void writeData(); - virtual void writeExec(); - -protected: - std::ostream &TO_STATE_ACTION_SWITCH( int level ); - std::ostream &FROM_STATE_ACTION_SWITCH( int level ); - std::ostream &EOF_ACTION_SWITCH( int level ); - std::ostream &ACTION_SWITCH( int level ); - - std::ostream &COND_KEYS(); - std::ostream &COND_SPACES(); - std::ostream &KEYS(); - std::ostream &INDICIES(); - std::ostream &COND_OFFSETS(); - std::ostream &KEY_OFFSETS(); - std::ostream &INDEX_OFFSETS(); - std::ostream &COND_LENS(); - std::ostream &SINGLE_LENS(); - std::ostream &RANGE_LENS(); - std::ostream &TO_STATE_ACTIONS(); - std::ostream &FROM_STATE_ACTIONS(); - std::ostream &EOF_ACTIONS(); - std::ostream &EOF_TRANS(); - std::ostream &TRANS_TARGS(); - std::ostream &TRANS_ACTIONS(); - std::ostream &TRANS_TARGS_WI(); - std::ostream &TRANS_ACTIONS_WI(); - void LOCATE_TRANS(); - - void COND_TRANSLATE(); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - virtual void calcIndexSize(); -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOTABLE_H +#define _GOTABLE_H + +#include <iostream> +#include "gotablish.h" + +class GoTabCodeGen + : public GoTablishCodeGen +{ +public: + GoTabCodeGen( ostream &out ) + : GoTablishCodeGen(out) {} + + virtual ~GoTabCodeGen() { } + virtual void writeData(); + virtual void writeExec(); + +protected: + std::ostream &TO_STATE_ACTION_SWITCH( int level ); + std::ostream &FROM_STATE_ACTION_SWITCH( int level ); + std::ostream &EOF_ACTION_SWITCH( int level ); + std::ostream &ACTION_SWITCH( int level ); + + std::ostream &COND_KEYS(); + std::ostream &COND_SPACES(); + std::ostream &KEYS(); + std::ostream &INDICIES(); + std::ostream &COND_OFFSETS(); + std::ostream &KEY_OFFSETS(); + std::ostream &INDEX_OFFSETS(); + std::ostream &COND_LENS(); + std::ostream &SINGLE_LENS(); + std::ostream &RANGE_LENS(); + std::ostream &TO_STATE_ACTIONS(); + std::ostream &FROM_STATE_ACTIONS(); + std::ostream &EOF_ACTIONS(); + std::ostream &EOF_TRANS(); + std::ostream &TRANS_TARGS(); + std::ostream &TRANS_ACTIONS(); + std::ostream &TRANS_TARGS_WI(); + std::ostream &TRANS_ACTIONS_WI(); + void LOCATE_TRANS(); + + void COND_TRANSLATE(); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + virtual void calcIndexSize(); +}; + +#endif diff --git a/contrib/tools/ragel6/gotablish.cpp b/contrib/tools/ragel6/gotablish.cpp index 218ab47908..55f60326c6 100644 --- a/contrib/tools/ragel6/gotablish.cpp +++ b/contrib/tools/ragel6/gotablish.cpp @@ -1,111 +1,111 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "gotablish.h" - -using std::endl; - -void GoTablishCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) -{ - ret << vCS() << " = " << gotoDest << endl << - "goto _again" << endl; -} - -void GoTablishCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << vCS() << " = ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << ")" << endl << "goto _again" << endl; -} - -void GoTablishCodeGen::CURS( ostream &ret, bool inFinish ) -{ - ret << "(_ps)"; -} - -void GoTablishCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) -{ - ret << "(" << vCS() << ")"; -} - -void GoTablishCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) -{ - ret << vCS() << " = " << nextDest << endl; -} - -void GoTablishCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << vCS() << " = ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); - ret << ")" << endl; -} - -void GoTablishCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "{ "; - INLINE_LIST( ret, prePushExpr, 0, false, false ); - } - - ret << STACK() << "[" << TOP() << "] = " << vCS() << "; " << TOP() << "++; " << - vCS() << " = " << callDest << "; " << "goto _again" << endl; - - if ( prePushExpr != 0 ) - ret << " }"; -} - -void GoTablishCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "{"; - INLINE_LIST( ret, prePushExpr, 0, false, false ); - } - - ret << STACK() << "[" << TOP() << "] = " << vCS() << "; " << TOP() << "++; " << vCS() << " = ("; - INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); - ret << "); " << "goto _again" << endl; - - if ( prePushExpr != 0 ) - ret << "}"; -} - -void GoTablishCodeGen::RET( ostream &ret, bool inFinish ) -{ - ret << TOP() << "--; " << vCS() << " = " << STACK() << "[" << - TOP() << "]" << endl; - - if ( postPopExpr != 0 ) { - ret << "{ "; - INLINE_LIST( ret, postPopExpr, 0, false, false ); - ret << " }" << endl; - } - - ret << "goto _again" << endl; -} - -void GoTablishCodeGen::BREAK( ostream &ret, int targState, bool csForced ) -{ - outLabelUsed = true; - ret << P() << "++; " << "goto _out" << endl; -} +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "gotablish.h" + +using std::endl; + +void GoTablishCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) +{ + ret << vCS() << " = " << gotoDest << endl << + "goto _again" << endl; +} + +void GoTablishCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << vCS() << " = ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); + ret << ")" << endl << "goto _again" << endl; +} + +void GoTablishCodeGen::CURS( ostream &ret, bool inFinish ) +{ + ret << "(_ps)"; +} + +void GoTablishCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) +{ + ret << "(" << vCS() << ")"; +} + +void GoTablishCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) +{ + ret << vCS() << " = " << nextDest << endl; +} + +void GoTablishCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << vCS() << " = ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish, false ); + ret << ")" << endl; +} + +void GoTablishCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "{ "; + INLINE_LIST( ret, prePushExpr, 0, false, false ); + } + + ret << STACK() << "[" << TOP() << "] = " << vCS() << "; " << TOP() << "++; " << + vCS() << " = " << callDest << "; " << "goto _again" << endl; + + if ( prePushExpr != 0 ) + ret << " }"; +} + +void GoTablishCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "{"; + INLINE_LIST( ret, prePushExpr, 0, false, false ); + } + + ret << STACK() << "[" << TOP() << "] = " << vCS() << "; " << TOP() << "++; " << vCS() << " = ("; + INLINE_LIST( ret, ilItem->children, targState, inFinish, false ); + ret << "); " << "goto _again" << endl; + + if ( prePushExpr != 0 ) + ret << "}"; +} + +void GoTablishCodeGen::RET( ostream &ret, bool inFinish ) +{ + ret << TOP() << "--; " << vCS() << " = " << STACK() << "[" << + TOP() << "]" << endl; + + if ( postPopExpr != 0 ) { + ret << "{ "; + INLINE_LIST( ret, postPopExpr, 0, false, false ); + ret << " }" << endl; + } + + ret << "goto _again" << endl; +} + +void GoTablishCodeGen::BREAK( ostream &ret, int targState, bool csForced ) +{ + outLabelUsed = true; + ret << P() << "++; " << "goto _out" << endl; +} diff --git a/contrib/tools/ragel6/gotablish.h b/contrib/tools/ragel6/gotablish.h index 9e79b11796..40a50b4a21 100644 --- a/contrib/tools/ragel6/gotablish.h +++ b/contrib/tools/ragel6/gotablish.h @@ -1,48 +1,48 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GOTABLISH_H -#define _GOTABLISH_H - -#include "gocodegen.h" - -class GoTablishCodeGen - : public GoCodeGen -{ -public: - GoTablishCodeGen( ostream &out ) - : GoCodeGen(out) {} -protected: - virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ); - virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ); - virtual void NEXT( ostream &ret, int nextDest, bool inFinish ); - virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); - virtual void CURS( ostream &ret, bool inFinish ); - virtual void TARGS( ostream &ret, bool inFinish, int targState ); - virtual void RET( ostream &ret, bool inFinish ); - virtual void BREAK( ostream &ret, int targState, bool csForced ); -}; - -#endif +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. + * + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GOTABLISH_H +#define _GOTABLISH_H + +#include "gocodegen.h" + +class GoTablishCodeGen + : public GoCodeGen +{ +public: + GoTablishCodeGen( ostream &out ) + : GoCodeGen(out) {} +protected: + virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ); + virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ); + virtual void NEXT( ostream &ret, int nextDest, bool inFinish ); + virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); + virtual void CURS( ostream &ret, bool inFinish ); + virtual void TARGS( ostream &ret, bool inFinish, int targState ); + virtual void RET( ostream &ret, bool inFinish ); + virtual void BREAK( ostream &ret, int targState, bool csForced ); +}; + +#endif diff --git a/contrib/tools/ragel6/inputdata.cpp b/contrib/tools/ragel6/inputdata.cpp index 7d8322ff70..95767717bd 100644 --- a/contrib/tools/ragel6/inputdata.cpp +++ b/contrib/tools/ragel6/inputdata.cpp @@ -46,7 +46,7 @@ void InputData::cdDefaultFileName( const char *inputFile ) switch ( hostLang->lang ) { case HostLang::C: defExtension = ".c"; break; case HostLang::D: defExtension = ".d"; break; - case HostLang::D2: defExtension = ".d"; break; + case HostLang::D2: defExtension = ".d"; break; default: break; } outputFileName = fileNameFromStem( inputFile, defExtension ); @@ -55,15 +55,15 @@ void InputData::cdDefaultFileName( const char *inputFile ) } /* Invoked by the parser when the root element is opened. */ -void InputData::goDefaultFileName( const char *inputFile ) -{ - /* If the output format is code and no output file name is given, then - * make a default. */ - if ( outputFileName == 0 ) - outputFileName = fileNameFromStem( inputFile, ".go" ); -} - -/* Invoked by the parser when the root element is opened. */ +void InputData::goDefaultFileName( const char *inputFile ) +{ + /* If the output format is code and no output file name is given, then + * make a default. */ + if ( outputFileName == 0 ) + outputFileName = fileNameFromStem( inputFile, ".go" ); +} + +/* Invoked by the parser when the root element is opened. */ void InputData::javaDefaultFileName( const char *inputFile ) { /* If the output format is code and no output file name is given, then @@ -95,39 +95,39 @@ void InputData::csharpDefaultFileName( const char *inputFile ) } } -/* Invoked by the parser when the root element is opened. */ -void InputData::ocamlDefaultFileName( const char *inputFile ) -{ - /* If the output format is code and no output file name is given, then - * make a default. */ - if ( outputFileName == 0 ) - outputFileName = fileNameFromStem( inputFile, ".ml" ); -} - +/* Invoked by the parser when the root element is opened. */ +void InputData::ocamlDefaultFileName( const char *inputFile ) +{ + /* If the output format is code and no output file name is given, then + * make a default. */ + if ( outputFileName == 0 ) + outputFileName = fileNameFromStem( inputFile, ".ml" ); +} + void InputData::makeOutputStream() { if ( ! generateDot && ! generateXML ) { switch ( hostLang->lang ) { case HostLang::C: case HostLang::D: - case HostLang::D2: + case HostLang::D2: cdDefaultFileName( inputFileName ); break; case HostLang::Java: javaDefaultFileName( inputFileName ); break; - case HostLang::Go: - goDefaultFileName( inputFileName ); - break; + case HostLang::Go: + goDefaultFileName( inputFileName ); + break; case HostLang::Ruby: rubyDefaultFileName( inputFileName ); break; case HostLang::CSharp: csharpDefaultFileName( inputFileName ); break; - case HostLang::OCaml: - ocamlDefaultFileName( inputFileName ); - break; + case HostLang::OCaml: + ocamlDefaultFileName( inputFileName ); + break; } } @@ -252,24 +252,24 @@ void InputData::writeOutput() else if ( generateDot ) static_cast<GraphvizDotGen*>(dotGenParser->pd->cgd)->writeDotFile(); else { - bool hostLineDirective = true; + bool hostLineDirective = true; for ( InputItemList::Iter ii = inputItems; ii.lte(); ii++ ) { if ( ii->type == InputItem::Write ) { CodeGenData *cgd = ii->pd->cgd; ::keyOps = &cgd->thisKeyOps; - hostLineDirective = cgd->writeStatement( ii->loc, - ii->writeArgs.length()-1, ii->writeArgs.data ); + hostLineDirective = cgd->writeStatement( ii->loc, + ii->writeArgs.length()-1, ii->writeArgs.data ); } else { - if ( hostLineDirective ) { - /* Write statements can turn off host line directives for - * host sections that follow them. */ - *outStream << '\n'; - lineDirective( *outStream, inputFileName, ii->loc.line ); - } + if ( hostLineDirective ) { + /* Write statements can turn off host line directives for + * host sections that follow them. */ + *outStream << '\n'; + lineDirective( *outStream, inputFileName, ii->loc.line ); + } *outStream << ii->data.str(); - hostLineDirective = true; + hostLineDirective = true; } } } diff --git a/contrib/tools/ragel6/inputdata.h b/contrib/tools/ragel6/inputdata.h index 09a62c15ac..27db567b93 100644 --- a/contrib/tools/ragel6/inputdata.h +++ b/contrib/tools/ragel6/inputdata.h @@ -93,11 +93,11 @@ struct InputData void terminateAllParsers(); void cdDefaultFileName( const char *inputFile ); - void goDefaultFileName( const char *inputFile ); + void goDefaultFileName( const char *inputFile ); void javaDefaultFileName( const char *inputFile ); void rubyDefaultFileName( const char *inputFile ); void csharpDefaultFileName( const char *inputFile ); - void ocamlDefaultFileName( const char *inputFile ); + void ocamlDefaultFileName( const char *inputFile ); void writeLanguage( std::ostream &out ); void writeXML( std::ostream &out ); diff --git a/contrib/tools/ragel6/javacodegen.cpp b/contrib/tools/ragel6/javacodegen.cpp index 99fbbbcf4b..dc4d134e00 100644 --- a/contrib/tools/ragel6/javacodegen.cpp +++ b/contrib/tools/ragel6/javacodegen.cpp @@ -54,7 +54,7 @@ using std::cin; using std::cout; using std::cerr; using std::endl; -using std::setiosflags; +using std::setiosflags; void javaLineDirective( ostream &out, const char *fileName, int line ) { @@ -984,7 +984,7 @@ void JavaTabCodeGen::writeData() out << "\n"; - if ( !noEntry && entryPointNames.length() > 0 ) { + if ( !noEntry && entryPointNames.length() > 0 ) { for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << " = " << entryPointIds[en.pos()] << ";\n"; diff --git a/contrib/tools/ragel6/main.cpp b/contrib/tools/ragel6/main.cpp index 1fd36c6f9d..01d25b3402 100644 --- a/contrib/tools/ragel6/main.cpp +++ b/contrib/tools/ragel6/main.cpp @@ -122,20 +122,20 @@ void usage() "host language:\n" " -C The host language is C, C++, Obj-C or Obj-C++ (default)\n" " -D The host language is D\n" -" -Z The host language is Go\n" +" -Z The host language is Go\n" " -J The host language is Java\n" " -R The host language is Ruby\n" " -A The host language is C#\n" -" -O The host language is OCaml\n" -"line directives: (C/D/Ruby/C#/OCaml)\n" +" -O The host language is OCaml\n" +"line directives: (C/D/Ruby/C#/OCaml)\n" " -L Inhibit writing of #line directives\n" -"code style: (C/D/Java/Ruby/C#/OCaml)\n" +"code style: (C/D/Java/Ruby/C#/OCaml)\n" " -T0 Table driven FSM (default)\n" -"code style: (C/D/Ruby/C#/OCaml)\n" +"code style: (C/D/Ruby/C#/OCaml)\n" " -T1 Faster table driven FSM\n" " -F0 Flat table driven FSM\n" " -F1 Faster flat table-driven FSM\n" -"code style: (C/D/C#/OCaml)\n" +"code style: (C/D/C#/OCaml)\n" " -G0 Goto-driven FSM\n" " -G1 Faster goto-driven FSM\n" "code style: (C/D)\n" @@ -220,7 +220,7 @@ void escapeLineDirectivePath( std::ostream &out, char *path ) void processArgs( int argc, const char **argv, InputData &id ) { - ParamCheck pc("xo:dnmleabjkS:M:I:CDEJZRAOvHh?-:sT:F:G:P:LpV", argc, argv); + ParamCheck pc("xo:dnmleabjkS:M:I:CDEJZRAOvHh?-:sT:F:G:P:LpV", argc, argv); /* FIXME: Need to check code styles VS langauge. */ @@ -318,12 +318,12 @@ void processArgs( int argc, const char **argv, InputData &id ) case 'D': hostLang = &hostLangD; break; - case 'E': - hostLang = &hostLangD2; - break; - case 'Z': - hostLang = &hostLangGo; - break; + case 'E': + hostLang = &hostLangD2; + break; + case 'Z': + hostLang = &hostLangGo; + break; case 'J': hostLang = &hostLangJava; break; @@ -333,9 +333,9 @@ void processArgs( int argc, const char **argv, InputData &id ) case 'A': hostLang = &hostLangCSharp; break; - case 'O': - hostLang = &hostLangOCaml; - break; + case 'O': + hostLang = &hostLangOCaml; + break; /* Version and help. */ case 'v': diff --git a/contrib/tools/ragel6/mlcodegen.cpp b/contrib/tools/ragel6/mlcodegen.cpp index 166e45347c..2b725b4340 100644 --- a/contrib/tools/ragel6/mlcodegen.cpp +++ b/contrib/tools/ragel6/mlcodegen.cpp @@ -1,744 +1,744 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "mlcodegen.h" -#include "redfsm.h" -#include "gendata.h" -#include <sstream> -#include <iomanip> -#include <string> -#include <assert.h> - -using std::ostream; -using std::ostringstream; -using std::string; -using std::cerr; -using std::endl; - -using std::istream; -using std::ifstream; -using std::ostream; -using std::ios; -using std::cin; -using std::cout; -using std::cerr; -using std::endl; - -void ocamlLineDirective( ostream &out, const char *fileName, int line ) -{ - if ( noLineDirectives ) - return; - - /* Write the line info for to the input file. */ - out << "# " << line << " \""; - for ( const char *pc = fileName; *pc != 0; pc++ ) { - if ( *pc == '\\' || *pc == '"' ) - out << "\\"; - out << *pc; - } - out << "\"\n"; -} - -void OCamlCodeGen::genLineDirective( ostream &out ) -{ - std::streambuf *sbuf = out.rdbuf(); - output_filter *filter = static_cast<output_filter*>(sbuf); - ocamlLineDirective( out, filter->fileName, filter->line + 1 ); -} - - -/* Init code gen with in parameters. */ -OCamlCodeGen::OCamlCodeGen( ostream &out ) -: - CodeGenData(out) -{ -} - -unsigned int OCamlCodeGen::arrayTypeSize( unsigned long maxVal ) -{ - long long maxValLL = (long long) maxVal; - HostType *arrayType = keyOps->typeSubsumes( maxValLL ); - assert( arrayType != 0 ); - return arrayType->size; -} - -string OCamlCodeGen::ARRAY_TYPE( unsigned long maxVal ) -{ - return ARRAY_TYPE( maxVal, false ); -} - -string OCamlCodeGen::ARRAY_TYPE( unsigned long maxVal, bool forceSigned ) -{ - long long maxValLL = (long long) maxVal; - HostType *arrayType; - if (forceSigned) - arrayType = keyOps->typeSubsumes(true, maxValLL); - else - arrayType = keyOps->typeSubsumes( maxValLL ); - assert( arrayType != 0 ); - - string ret = arrayType->data1; - if ( arrayType->data2 != 0 ) { - ret += " "; - ret += arrayType->data2; - } - return ret; -} - -/* Write out the fsm name. */ -string OCamlCodeGen::FSM_NAME() -{ - return fsmName; -} - -/* Emit the offset of the start state as a decimal integer. */ -string OCamlCodeGen::START_STATE_ID() -{ - ostringstream ret; - ret << redFsm->startState->id; - return ret.str(); -}; - -/* Write out the array of actions. */ -std::ostream &OCamlCodeGen::ACTIONS_ARRAY() -{ - out << "\t0; "; - int totalActions = 1; - for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { - /* Write out the length, which will never be the last character. */ - out << act->key.length() << ARR_SEP(); - /* Put in a line break every 8 */ - if ( totalActions++ % 8 == 7 ) - out << "\n\t"; - - for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) { - out << item->value->actionId; - if ( ! (act.last() && item.last()) ) - out << ARR_SEP(); - - /* Put in a line break every 8 */ - if ( totalActions++ % 8 == 7 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - - -/* -string OCamlCodeGen::ACCESS() -{ - ostringstream ret; - if ( accessExpr != 0 ) - INLINE_LIST( ret, accessExpr, 0, false ); - return ret.str(); -} -*/ - -string OCamlCodeGen::make_access(char const* name, GenInlineList* x, bool prefix = true) -{ - ostringstream ret; - if ( x == 0 ) - { - if (prefix && accessExpr != 0) - { - INLINE_LIST( ret, accessExpr, 0, false); - ret << name; - } - else - ret << name << ".contents"; // ref cell - } - else { - ret << "("; - INLINE_LIST( ret, x, 0, false ); - ret << ")"; - } - return ret.str(); -} - -string OCamlCodeGen::P() { return make_access("p", pExpr, false); } -string OCamlCodeGen::PE() { return make_access("pe", peExpr, false); } -string OCamlCodeGen::vEOF() { return make_access("eof", eofExpr, false); } -string OCamlCodeGen::vCS() { return make_access("cs", csExpr); } -string OCamlCodeGen::TOP() { return make_access("top", topExpr); } -string OCamlCodeGen::STACK() { return make_access("stack", stackExpr); } -string OCamlCodeGen::ACT() { return make_access("act", actExpr); } -string OCamlCodeGen::TOKSTART() { return make_access("ts", tokstartExpr); } -string OCamlCodeGen::TOKEND() { return make_access("te", tokendExpr); } - -string OCamlCodeGen::GET_WIDE_KEY() -{ - if ( redFsm->anyConditions() ) - return "_widec"; - else - { ostringstream ret; ret << "Char.code " << GET_KEY(); return ret.str(); } -} - -string OCamlCodeGen::GET_WIDE_KEY( RedStateAp *state ) -{ - if ( state->stateCondList.length() > 0 ) - return "_widec"; - else - { ostringstream ret; ret << "Char.code " << GET_KEY(); return ret.str(); } -} - -/* Write out level number of tabs. Makes the nested binary search nice - * looking. */ -string OCamlCodeGen::TABS( int level ) -{ - string result; - while ( level-- > 0 ) - result += "\t"; - return result; -} - -/* Write out a key from the fsm code gen. Depends on wether or not the key is - * signed. */ -string OCamlCodeGen::KEY( Key key ) -{ - ostringstream ret; - if ( keyOps->isSigned || !hostLang->explicitUnsigned ) - ret << key.getVal(); - else - ret << (unsigned long) key.getVal() << 'u'; - return ret.str(); -} - -string OCamlCodeGen::ALPHA_KEY( Key key ) -{ - ostringstream ret; - ret << key.getVal(); - /* - if (key.getVal() > 0xFFFF) { - ret << key.getVal(); - } else { - ret << "'\\u" << std::hex << std::setw(4) << std::setfill('0') << - key.getVal() << "'"; - } - */ - //ret << "(char) " << key.getVal(); - return ret.str(); -} - -void OCamlCodeGen::EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ) -{ -// The parser gives fexec two children. - ret << "begin " << P() << " <- "; - INLINE_LIST( ret, item->children, targState, inFinish ); - ret << " - 1 end; "; -} - -void OCamlCodeGen::LM_SWITCH( ostream &ret, GenInlineItem *item, - int targState, int inFinish ) -{ - bool catch_all = false; - ret << - " begin match " << ACT() << " with\n"; - - for ( GenInlineList::Iter lma = *item->children; lma.lte(); lma++ ) { - /* Write the case label, the action and the case break. */ - if ( lma->lmId < 0 ) - { - catch_all = true; - ret << " | _ ->\n"; - } - else - ret << " | " << lma->lmId << " ->\n"; - - /* Write the block and close it off. */ - ret << " begin "; - INLINE_LIST( ret, lma->children, targState, inFinish ); - ret << " end\n"; - } - - if (!catch_all) - ret << " | _ -> assert false\n"; - - ret << - " end;\n" - "\t"; -} - -void OCamlCodeGen::SET_ACT( ostream &ret, GenInlineItem *item ) -{ - ret << ACT() << " <- " << item->lmId << "; "; -} - -void OCamlCodeGen::SET_TOKEND( ostream &ret, GenInlineItem *item ) -{ - /* The tokend action sets tokend. */ - ret << TOKEND() << " <- " << P(); - if ( item->offset != 0 ) - out << "+" << item->offset; - out << "; "; -} - -void OCamlCodeGen::GET_TOKEND( ostream &ret, GenInlineItem *item ) -{ - ret << TOKEND(); -} - -void OCamlCodeGen::INIT_TOKSTART( ostream &ret, GenInlineItem *item ) -{ - ret << TOKSTART() << " <- " << NULL_ITEM() << "; "; -} - -void OCamlCodeGen::INIT_ACT( ostream &ret, GenInlineItem *item ) -{ - ret << ACT() << " <- 0;"; -} - -void OCamlCodeGen::SET_TOKSTART( ostream &ret, GenInlineItem *item ) -{ - ret << TOKSTART() << " <- " << P() << "; "; -} - -void OCamlCodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item, - int targState, bool inFinish ) -{ - if ( item->children->length() > 0 ) { - /* Write the block and close it off. */ - ret << "begin "; - INLINE_LIST( ret, item->children, targState, inFinish ); - ret << " end"; - } -} - - -/* Write out an inline tree structure. Walks the list and possibly calls out - * to virtual functions than handle language specific items in the tree. */ -void OCamlCodeGen::INLINE_LIST( ostream &ret, GenInlineList *inlineList, - int targState, bool inFinish ) -{ - for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { - switch ( item->type ) { - case GenInlineItem::Text: - ret << item->data; - break; - case GenInlineItem::Goto: - GOTO( ret, item->targState->id, inFinish ); - break; - case GenInlineItem::Call: - CALL( ret, item->targState->id, targState, inFinish ); - break; - case GenInlineItem::Next: - NEXT( ret, item->targState->id, inFinish ); - break; - case GenInlineItem::Ret: - RET( ret, inFinish ); - break; - case GenInlineItem::PChar: - ret << P(); - break; - case GenInlineItem::Char: - ret << GET_KEY(); - break; - case GenInlineItem::Hold: - ret << P() << " <- " << P() << " - 1; "; - break; - case GenInlineItem::Exec: - EXEC( ret, item, targState, inFinish ); - break; - case GenInlineItem::Curs: - CURS( ret, inFinish ); - break; - case GenInlineItem::Targs: - TARGS( ret, inFinish, targState ); - break; - case GenInlineItem::Entry: - ret << item->targState->id; - break; - case GenInlineItem::GotoExpr: - GOTO_EXPR( ret, item, inFinish ); - break; - case GenInlineItem::CallExpr: - CALL_EXPR( ret, item, targState, inFinish ); - break; - case GenInlineItem::NextExpr: - NEXT_EXPR( ret, item, inFinish ); - break; - case GenInlineItem::LmSwitch: - LM_SWITCH( ret, item, targState, inFinish ); - break; - case GenInlineItem::LmSetActId: - SET_ACT( ret, item ); - break; - case GenInlineItem::LmSetTokEnd: - SET_TOKEND( ret, item ); - break; - case GenInlineItem::LmGetTokEnd: - GET_TOKEND( ret, item ); - break; - case GenInlineItem::LmInitTokStart: - INIT_TOKSTART( ret, item ); - break; - case GenInlineItem::LmInitAct: - INIT_ACT( ret, item ); - break; - case GenInlineItem::LmSetTokStart: - SET_TOKSTART( ret, item ); - break; - case GenInlineItem::SubAction: - SUB_ACTION( ret, item, targState, inFinish ); - break; - case GenInlineItem::Break: - BREAK( ret, targState ); - break; - } - } -} -/* Write out paths in line directives. Escapes any special characters. */ -string OCamlCodeGen::LDIR_PATH( char *path ) -{ - ostringstream ret; - for ( char *pc = path; *pc != 0; pc++ ) { - if ( *pc == '\\' ) - ret << "\\\\"; - else - ret << *pc; - } - return ret.str(); -} - -void OCamlCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish ) -{ - /* Write the preprocessor line info for going into the source file. */ - ocamlLineDirective( ret, action->loc.fileName, action->loc.line ); - - /* Write the block and close it off. */ - ret << "\t\tbegin "; - INLINE_LIST( ret, action->inlineList, targState, inFinish ); - ret << " end;\n"; -} - -void OCamlCodeGen::CONDITION( ostream &ret, GenAction *condition ) -{ - ret << "\n"; - ocamlLineDirective( ret, condition->loc.fileName, condition->loc.line ); - INLINE_LIST( ret, condition->inlineList, 0, false ); -} - -string OCamlCodeGen::ERROR_STATE() -{ - ostringstream ret; - if ( redFsm->errState != 0 ) - ret << redFsm->errState->id; - else - ret << "-1"; - return ret.str(); -} - -string OCamlCodeGen::FIRST_FINAL_STATE() -{ - ostringstream ret; - if ( redFsm->firstFinState != 0 ) - ret << redFsm->firstFinState->id; - else - ret << redFsm->nextStateId; - return ret.str(); -} - -void OCamlCodeGen::writeInit() -{ - out << " begin\n"; - - if ( !noCS ) - out << "\t" << vCS() << " <- " << START() << ";\n"; - - /* If there are any calls, then the stack top needs initialization. */ - if ( redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "\t" << TOP() << " <- 0;\n"; - - if ( hasLongestMatch ) { - out << - " " << TOKSTART() << " <- " << NULL_ITEM() << ";\n" - " " << TOKEND() << " <- " << NULL_ITEM() << ";\n" - " " << ACT() << " <- 0;\n"; - } - out << " end;\n"; -} - -string OCamlCodeGen::PRE_INCR(string val) -{ - ostringstream ret; - ret << "(" << val << " <- " << val << " + 1; " << val << ")"; - return ret.str(); -} - -string OCamlCodeGen::POST_INCR(string val) -{ - ostringstream ret; - ret << "(let temp = " << val << " in " << val << " <- " << val << " + 1; temp)"; - return ret.str(); -} - -string OCamlCodeGen::PRE_DECR(string val) -{ - ostringstream ret; - ret << "(" << val << " <- " << val << " - 1; " << val << ")"; - return ret.str(); -} - -string OCamlCodeGen::POST_DECR(string val) -{ - ostringstream ret; - ret << "(let temp = " << val << " in " << val << " <- " << val << " - 1; temp)"; - return ret.str(); -} - -string OCamlCodeGen::DATA_PREFIX() -{ - if ( data_prefix.empty() ) // init - { - data_prefix = string(fsmName) + "_"; - if (data_prefix.size() > 0) - data_prefix[0] = ::tolower(data_prefix[0]); // uncapitalize - } - if ( !noPrefix ) - return data_prefix; - return ""; -} - -/* Emit the alphabet data type. */ -string OCamlCodeGen::ALPH_TYPE() -{ - string ret = keyOps->alphType->data1; - if ( keyOps->alphType->data2 != 0 ) { - ret += " "; - ret += + keyOps->alphType->data2; - } - return ret; -} - -/* Emit the alphabet data type. */ -string OCamlCodeGen::WIDE_ALPH_TYPE() -{ - string ret; - if ( redFsm->maxKey <= keyOps->maxKey ) - ret = ALPH_TYPE(); - else { - long long maxKeyVal = redFsm->maxKey.getLongLong(); - HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); - assert( wideType != 0 ); - - ret = wideType->data1; - if ( wideType->data2 != 0 ) { - ret += " "; - ret += wideType->data2; - } - } - return ret; -} - -void OCamlCodeGen::STATE_IDS() -{ - if ( redFsm->startState != 0 ) - STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << TOP_SEP (); - - if ( !noFinal ) - STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << TOP_SEP(); - - if ( !noError ) - STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << TOP_SEP(); - - out << "\n"; - - if ( !noEntry && entryPointNames.length() > 0 ) { - for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { - STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << - " = " << entryPointIds[en.pos()] << TOP_SEP(); - } - out << "\n"; - } -} - - -void OCamlCodeGen::writeStart() -{ - out << START_STATE_ID(); -} - -void OCamlCodeGen::writeFirstFinal() -{ - out << FIRST_FINAL_STATE(); -} - -void OCamlCodeGen::writeError() -{ - out << ERROR_STATE(); -} - -string OCamlCodeGen::GET_KEY() -{ - ostringstream ret; - if ( getKeyExpr != 0 ) { - /* Emit the user supplied method of retrieving the key. */ - ret << "("; - INLINE_LIST( ret, getKeyExpr, 0, false ); - ret << ")"; - } - else { - /* Expression for retrieving the key, use simple dereference. */ - ret << "data.[" << P() << "]"; - } - return ret.str(); -} -string OCamlCodeGen::NULL_ITEM() -{ - return "-1"; -} - -string OCamlCodeGen::POINTER() -{ - // XXX C# has no pointers - // multiple items seperated by commas can also be pointer types. - return " "; -} - -string OCamlCodeGen::PTR_CONST() -{ - return ""; -} - -std::ostream &OCamlCodeGen::OPEN_ARRAY( string type, string name ) -{ - out << "let " << name << " : " << type << " array = [|" << endl; - return out; -} - -std::ostream &OCamlCodeGen::CLOSE_ARRAY() -{ - return out << "|]" << TOP_SEP(); -} - -string OCamlCodeGen::TOP_SEP() -{ - return "\n"; // original syntax -} - -string OCamlCodeGen::ARR_SEP() -{ - return "; "; -} - -string OCamlCodeGen::AT(const string& array, const string& index) -{ - ostringstream ret; - ret << array << ".(" << index << ")"; - return ret.str(); -} - -std::ostream &OCamlCodeGen::STATIC_VAR( string type, string name ) -{ - out << "let " << name << " : " << type; - return out; -} - -string OCamlCodeGen::ARR_OFF( string ptr, string offset ) -{ - // XXX C# can't do pointer arithmetic - return "&" + ptr + "[" + offset + "]"; -} - -string OCamlCodeGen::CAST( string type ) -{ - return ""; -// return "(" + type + ")"; -} - -string OCamlCodeGen::UINT( ) -{ - return "uint"; -} - -std::ostream &OCamlCodeGen::SWITCH_DEFAULT() -{ - out << " | _ -> ()\n"; - return out; -} - -string OCamlCodeGen::CTRL_FLOW() -{ - return "if true then "; -} - -void OCamlCodeGen::finishRagelDef() -{ - if ( codeStyle == GenGoto || codeStyle == GenFGoto || - codeStyle == GenIpGoto || codeStyle == GenSplit ) - { - /* For directly executable machines there is no required state - * ordering. Choose a depth-first ordering to increase the - * potential for fall-throughs. */ - redFsm->depthFirstOrdering(); - } - else { - /* The frontend will do this for us, but it may be a good idea to - * force it if the intermediate file is edited. */ - redFsm->sortByStateId(); - } - - /* Choose default transitions and the single transition. */ - redFsm->chooseDefaultSpan(); - - /* Maybe do flat expand, otherwise choose single. */ - if ( codeStyle == GenFlat || codeStyle == GenFFlat ) - redFsm->makeFlat(); - else - redFsm->chooseSingle(); - - /* If any errors have occured in the input file then don't write anything. */ - if ( gblErrorCount > 0 ) - return; - - if ( codeStyle == GenSplit ) - redFsm->partitionFsm( numSplitPartitions ); - - if ( codeStyle == GenIpGoto || codeStyle == GenSplit ) - redFsm->setInTrans(); - - /* Anlayze Machine will find the final action reference counts, among - * other things. We will use these in reporting the usage - * of fsm directives in action code. */ - analyzeMachine(); - - /* Determine if we should use indicies. */ - calcIndexSize(); -} - -ostream &OCamlCodeGen::source_warning( const InputLoc &loc ) -{ - cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: "; - return cerr; -} - -ostream &OCamlCodeGen::source_error( const InputLoc &loc ) -{ - gblErrorCount += 1; - assert( sourceFileName != 0 ); - cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": "; - return cerr; -} - + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "mlcodegen.h" +#include "redfsm.h" +#include "gendata.h" +#include <sstream> +#include <iomanip> +#include <string> +#include <assert.h> + +using std::ostream; +using std::ostringstream; +using std::string; +using std::cerr; +using std::endl; + +using std::istream; +using std::ifstream; +using std::ostream; +using std::ios; +using std::cin; +using std::cout; +using std::cerr; +using std::endl; + +void ocamlLineDirective( ostream &out, const char *fileName, int line ) +{ + if ( noLineDirectives ) + return; + + /* Write the line info for to the input file. */ + out << "# " << line << " \""; + for ( const char *pc = fileName; *pc != 0; pc++ ) { + if ( *pc == '\\' || *pc == '"' ) + out << "\\"; + out << *pc; + } + out << "\"\n"; +} + +void OCamlCodeGen::genLineDirective( ostream &out ) +{ + std::streambuf *sbuf = out.rdbuf(); + output_filter *filter = static_cast<output_filter*>(sbuf); + ocamlLineDirective( out, filter->fileName, filter->line + 1 ); +} + + +/* Init code gen with in parameters. */ +OCamlCodeGen::OCamlCodeGen( ostream &out ) +: + CodeGenData(out) +{ +} + +unsigned int OCamlCodeGen::arrayTypeSize( unsigned long maxVal ) +{ + long long maxValLL = (long long) maxVal; + HostType *arrayType = keyOps->typeSubsumes( maxValLL ); + assert( arrayType != 0 ); + return arrayType->size; +} + +string OCamlCodeGen::ARRAY_TYPE( unsigned long maxVal ) +{ + return ARRAY_TYPE( maxVal, false ); +} + +string OCamlCodeGen::ARRAY_TYPE( unsigned long maxVal, bool forceSigned ) +{ + long long maxValLL = (long long) maxVal; + HostType *arrayType; + if (forceSigned) + arrayType = keyOps->typeSubsumes(true, maxValLL); + else + arrayType = keyOps->typeSubsumes( maxValLL ); + assert( arrayType != 0 ); + + string ret = arrayType->data1; + if ( arrayType->data2 != 0 ) { + ret += " "; + ret += arrayType->data2; + } + return ret; +} + +/* Write out the fsm name. */ +string OCamlCodeGen::FSM_NAME() +{ + return fsmName; +} + +/* Emit the offset of the start state as a decimal integer. */ +string OCamlCodeGen::START_STATE_ID() +{ + ostringstream ret; + ret << redFsm->startState->id; + return ret.str(); +}; + +/* Write out the array of actions. */ +std::ostream &OCamlCodeGen::ACTIONS_ARRAY() +{ + out << "\t0; "; + int totalActions = 1; + for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { + /* Write out the length, which will never be the last character. */ + out << act->key.length() << ARR_SEP(); + /* Put in a line break every 8 */ + if ( totalActions++ % 8 == 7 ) + out << "\n\t"; + + for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) { + out << item->value->actionId; + if ( ! (act.last() && item.last()) ) + out << ARR_SEP(); + + /* Put in a line break every 8 */ + if ( totalActions++ % 8 == 7 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + + +/* +string OCamlCodeGen::ACCESS() +{ + ostringstream ret; + if ( accessExpr != 0 ) + INLINE_LIST( ret, accessExpr, 0, false ); + return ret.str(); +} +*/ + +string OCamlCodeGen::make_access(char const* name, GenInlineList* x, bool prefix = true) +{ + ostringstream ret; + if ( x == 0 ) + { + if (prefix && accessExpr != 0) + { + INLINE_LIST( ret, accessExpr, 0, false); + ret << name; + } + else + ret << name << ".contents"; // ref cell + } + else { + ret << "("; + INLINE_LIST( ret, x, 0, false ); + ret << ")"; + } + return ret.str(); +} + +string OCamlCodeGen::P() { return make_access("p", pExpr, false); } +string OCamlCodeGen::PE() { return make_access("pe", peExpr, false); } +string OCamlCodeGen::vEOF() { return make_access("eof", eofExpr, false); } +string OCamlCodeGen::vCS() { return make_access("cs", csExpr); } +string OCamlCodeGen::TOP() { return make_access("top", topExpr); } +string OCamlCodeGen::STACK() { return make_access("stack", stackExpr); } +string OCamlCodeGen::ACT() { return make_access("act", actExpr); } +string OCamlCodeGen::TOKSTART() { return make_access("ts", tokstartExpr); } +string OCamlCodeGen::TOKEND() { return make_access("te", tokendExpr); } + +string OCamlCodeGen::GET_WIDE_KEY() +{ + if ( redFsm->anyConditions() ) + return "_widec"; + else + { ostringstream ret; ret << "Char.code " << GET_KEY(); return ret.str(); } +} + +string OCamlCodeGen::GET_WIDE_KEY( RedStateAp *state ) +{ + if ( state->stateCondList.length() > 0 ) + return "_widec"; + else + { ostringstream ret; ret << "Char.code " << GET_KEY(); return ret.str(); } +} + +/* Write out level number of tabs. Makes the nested binary search nice + * looking. */ +string OCamlCodeGen::TABS( int level ) +{ + string result; + while ( level-- > 0 ) + result += "\t"; + return result; +} + +/* Write out a key from the fsm code gen. Depends on wether or not the key is + * signed. */ +string OCamlCodeGen::KEY( Key key ) +{ + ostringstream ret; + if ( keyOps->isSigned || !hostLang->explicitUnsigned ) + ret << key.getVal(); + else + ret << (unsigned long) key.getVal() << 'u'; + return ret.str(); +} + +string OCamlCodeGen::ALPHA_KEY( Key key ) +{ + ostringstream ret; + ret << key.getVal(); + /* + if (key.getVal() > 0xFFFF) { + ret << key.getVal(); + } else { + ret << "'\\u" << std::hex << std::setw(4) << std::setfill('0') << + key.getVal() << "'"; + } + */ + //ret << "(char) " << key.getVal(); + return ret.str(); +} + +void OCamlCodeGen::EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ) +{ +// The parser gives fexec two children. + ret << "begin " << P() << " <- "; + INLINE_LIST( ret, item->children, targState, inFinish ); + ret << " - 1 end; "; +} + +void OCamlCodeGen::LM_SWITCH( ostream &ret, GenInlineItem *item, + int targState, int inFinish ) +{ + bool catch_all = false; + ret << + " begin match " << ACT() << " with\n"; + + for ( GenInlineList::Iter lma = *item->children; lma.lte(); lma++ ) { + /* Write the case label, the action and the case break. */ + if ( lma->lmId < 0 ) + { + catch_all = true; + ret << " | _ ->\n"; + } + else + ret << " | " << lma->lmId << " ->\n"; + + /* Write the block and close it off. */ + ret << " begin "; + INLINE_LIST( ret, lma->children, targState, inFinish ); + ret << " end\n"; + } + + if (!catch_all) + ret << " | _ -> assert false\n"; + + ret << + " end;\n" + "\t"; +} + +void OCamlCodeGen::SET_ACT( ostream &ret, GenInlineItem *item ) +{ + ret << ACT() << " <- " << item->lmId << "; "; +} + +void OCamlCodeGen::SET_TOKEND( ostream &ret, GenInlineItem *item ) +{ + /* The tokend action sets tokend. */ + ret << TOKEND() << " <- " << P(); + if ( item->offset != 0 ) + out << "+" << item->offset; + out << "; "; +} + +void OCamlCodeGen::GET_TOKEND( ostream &ret, GenInlineItem *item ) +{ + ret << TOKEND(); +} + +void OCamlCodeGen::INIT_TOKSTART( ostream &ret, GenInlineItem *item ) +{ + ret << TOKSTART() << " <- " << NULL_ITEM() << "; "; +} + +void OCamlCodeGen::INIT_ACT( ostream &ret, GenInlineItem *item ) +{ + ret << ACT() << " <- 0;"; +} + +void OCamlCodeGen::SET_TOKSTART( ostream &ret, GenInlineItem *item ) +{ + ret << TOKSTART() << " <- " << P() << "; "; +} + +void OCamlCodeGen::SUB_ACTION( ostream &ret, GenInlineItem *item, + int targState, bool inFinish ) +{ + if ( item->children->length() > 0 ) { + /* Write the block and close it off. */ + ret << "begin "; + INLINE_LIST( ret, item->children, targState, inFinish ); + ret << " end"; + } +} + + +/* Write out an inline tree structure. Walks the list and possibly calls out + * to virtual functions than handle language specific items in the tree. */ +void OCamlCodeGen::INLINE_LIST( ostream &ret, GenInlineList *inlineList, + int targState, bool inFinish ) +{ + for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { + switch ( item->type ) { + case GenInlineItem::Text: + ret << item->data; + break; + case GenInlineItem::Goto: + GOTO( ret, item->targState->id, inFinish ); + break; + case GenInlineItem::Call: + CALL( ret, item->targState->id, targState, inFinish ); + break; + case GenInlineItem::Next: + NEXT( ret, item->targState->id, inFinish ); + break; + case GenInlineItem::Ret: + RET( ret, inFinish ); + break; + case GenInlineItem::PChar: + ret << P(); + break; + case GenInlineItem::Char: + ret << GET_KEY(); + break; + case GenInlineItem::Hold: + ret << P() << " <- " << P() << " - 1; "; + break; + case GenInlineItem::Exec: + EXEC( ret, item, targState, inFinish ); + break; + case GenInlineItem::Curs: + CURS( ret, inFinish ); + break; + case GenInlineItem::Targs: + TARGS( ret, inFinish, targState ); + break; + case GenInlineItem::Entry: + ret << item->targState->id; + break; + case GenInlineItem::GotoExpr: + GOTO_EXPR( ret, item, inFinish ); + break; + case GenInlineItem::CallExpr: + CALL_EXPR( ret, item, targState, inFinish ); + break; + case GenInlineItem::NextExpr: + NEXT_EXPR( ret, item, inFinish ); + break; + case GenInlineItem::LmSwitch: + LM_SWITCH( ret, item, targState, inFinish ); + break; + case GenInlineItem::LmSetActId: + SET_ACT( ret, item ); + break; + case GenInlineItem::LmSetTokEnd: + SET_TOKEND( ret, item ); + break; + case GenInlineItem::LmGetTokEnd: + GET_TOKEND( ret, item ); + break; + case GenInlineItem::LmInitTokStart: + INIT_TOKSTART( ret, item ); + break; + case GenInlineItem::LmInitAct: + INIT_ACT( ret, item ); + break; + case GenInlineItem::LmSetTokStart: + SET_TOKSTART( ret, item ); + break; + case GenInlineItem::SubAction: + SUB_ACTION( ret, item, targState, inFinish ); + break; + case GenInlineItem::Break: + BREAK( ret, targState ); + break; + } + } +} +/* Write out paths in line directives. Escapes any special characters. */ +string OCamlCodeGen::LDIR_PATH( char *path ) +{ + ostringstream ret; + for ( char *pc = path; *pc != 0; pc++ ) { + if ( *pc == '\\' ) + ret << "\\\\"; + else + ret << *pc; + } + return ret.str(); +} + +void OCamlCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish ) +{ + /* Write the preprocessor line info for going into the source file. */ + ocamlLineDirective( ret, action->loc.fileName, action->loc.line ); + + /* Write the block and close it off. */ + ret << "\t\tbegin "; + INLINE_LIST( ret, action->inlineList, targState, inFinish ); + ret << " end;\n"; +} + +void OCamlCodeGen::CONDITION( ostream &ret, GenAction *condition ) +{ + ret << "\n"; + ocamlLineDirective( ret, condition->loc.fileName, condition->loc.line ); + INLINE_LIST( ret, condition->inlineList, 0, false ); +} + +string OCamlCodeGen::ERROR_STATE() +{ + ostringstream ret; + if ( redFsm->errState != 0 ) + ret << redFsm->errState->id; + else + ret << "-1"; + return ret.str(); +} + +string OCamlCodeGen::FIRST_FINAL_STATE() +{ + ostringstream ret; + if ( redFsm->firstFinState != 0 ) + ret << redFsm->firstFinState->id; + else + ret << redFsm->nextStateId; + return ret.str(); +} + +void OCamlCodeGen::writeInit() +{ + out << " begin\n"; + + if ( !noCS ) + out << "\t" << vCS() << " <- " << START() << ";\n"; + + /* If there are any calls, then the stack top needs initialization. */ + if ( redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "\t" << TOP() << " <- 0;\n"; + + if ( hasLongestMatch ) { + out << + " " << TOKSTART() << " <- " << NULL_ITEM() << ";\n" + " " << TOKEND() << " <- " << NULL_ITEM() << ";\n" + " " << ACT() << " <- 0;\n"; + } + out << " end;\n"; +} + +string OCamlCodeGen::PRE_INCR(string val) +{ + ostringstream ret; + ret << "(" << val << " <- " << val << " + 1; " << val << ")"; + return ret.str(); +} + +string OCamlCodeGen::POST_INCR(string val) +{ + ostringstream ret; + ret << "(let temp = " << val << " in " << val << " <- " << val << " + 1; temp)"; + return ret.str(); +} + +string OCamlCodeGen::PRE_DECR(string val) +{ + ostringstream ret; + ret << "(" << val << " <- " << val << " - 1; " << val << ")"; + return ret.str(); +} + +string OCamlCodeGen::POST_DECR(string val) +{ + ostringstream ret; + ret << "(let temp = " << val << " in " << val << " <- " << val << " - 1; temp)"; + return ret.str(); +} + +string OCamlCodeGen::DATA_PREFIX() +{ + if ( data_prefix.empty() ) // init + { + data_prefix = string(fsmName) + "_"; + if (data_prefix.size() > 0) + data_prefix[0] = ::tolower(data_prefix[0]); // uncapitalize + } + if ( !noPrefix ) + return data_prefix; + return ""; +} + +/* Emit the alphabet data type. */ +string OCamlCodeGen::ALPH_TYPE() +{ + string ret = keyOps->alphType->data1; + if ( keyOps->alphType->data2 != 0 ) { + ret += " "; + ret += + keyOps->alphType->data2; + } + return ret; +} + +/* Emit the alphabet data type. */ +string OCamlCodeGen::WIDE_ALPH_TYPE() +{ + string ret; + if ( redFsm->maxKey <= keyOps->maxKey ) + ret = ALPH_TYPE(); + else { + long long maxKeyVal = redFsm->maxKey.getLongLong(); + HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal ); + assert( wideType != 0 ); + + ret = wideType->data1; + if ( wideType->data2 != 0 ) { + ret += " "; + ret += wideType->data2; + } + } + return ret; +} + +void OCamlCodeGen::STATE_IDS() +{ + if ( redFsm->startState != 0 ) + STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << TOP_SEP (); + + if ( !noFinal ) + STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << TOP_SEP(); + + if ( !noError ) + STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << TOP_SEP(); + + out << "\n"; + + if ( !noEntry && entryPointNames.length() > 0 ) { + for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { + STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << + " = " << entryPointIds[en.pos()] << TOP_SEP(); + } + out << "\n"; + } +} + + +void OCamlCodeGen::writeStart() +{ + out << START_STATE_ID(); +} + +void OCamlCodeGen::writeFirstFinal() +{ + out << FIRST_FINAL_STATE(); +} + +void OCamlCodeGen::writeError() +{ + out << ERROR_STATE(); +} + +string OCamlCodeGen::GET_KEY() +{ + ostringstream ret; + if ( getKeyExpr != 0 ) { + /* Emit the user supplied method of retrieving the key. */ + ret << "("; + INLINE_LIST( ret, getKeyExpr, 0, false ); + ret << ")"; + } + else { + /* Expression for retrieving the key, use simple dereference. */ + ret << "data.[" << P() << "]"; + } + return ret.str(); +} +string OCamlCodeGen::NULL_ITEM() +{ + return "-1"; +} + +string OCamlCodeGen::POINTER() +{ + // XXX C# has no pointers + // multiple items seperated by commas can also be pointer types. + return " "; +} + +string OCamlCodeGen::PTR_CONST() +{ + return ""; +} + +std::ostream &OCamlCodeGen::OPEN_ARRAY( string type, string name ) +{ + out << "let " << name << " : " << type << " array = [|" << endl; + return out; +} + +std::ostream &OCamlCodeGen::CLOSE_ARRAY() +{ + return out << "|]" << TOP_SEP(); +} + +string OCamlCodeGen::TOP_SEP() +{ + return "\n"; // original syntax +} + +string OCamlCodeGen::ARR_SEP() +{ + return "; "; +} + +string OCamlCodeGen::AT(const string& array, const string& index) +{ + ostringstream ret; + ret << array << ".(" << index << ")"; + return ret.str(); +} + +std::ostream &OCamlCodeGen::STATIC_VAR( string type, string name ) +{ + out << "let " << name << " : " << type; + return out; +} + +string OCamlCodeGen::ARR_OFF( string ptr, string offset ) +{ + // XXX C# can't do pointer arithmetic + return "&" + ptr + "[" + offset + "]"; +} + +string OCamlCodeGen::CAST( string type ) +{ + return ""; +// return "(" + type + ")"; +} + +string OCamlCodeGen::UINT( ) +{ + return "uint"; +} + +std::ostream &OCamlCodeGen::SWITCH_DEFAULT() +{ + out << " | _ -> ()\n"; + return out; +} + +string OCamlCodeGen::CTRL_FLOW() +{ + return "if true then "; +} + +void OCamlCodeGen::finishRagelDef() +{ + if ( codeStyle == GenGoto || codeStyle == GenFGoto || + codeStyle == GenIpGoto || codeStyle == GenSplit ) + { + /* For directly executable machines there is no required state + * ordering. Choose a depth-first ordering to increase the + * potential for fall-throughs. */ + redFsm->depthFirstOrdering(); + } + else { + /* The frontend will do this for us, but it may be a good idea to + * force it if the intermediate file is edited. */ + redFsm->sortByStateId(); + } + + /* Choose default transitions and the single transition. */ + redFsm->chooseDefaultSpan(); + + /* Maybe do flat expand, otherwise choose single. */ + if ( codeStyle == GenFlat || codeStyle == GenFFlat ) + redFsm->makeFlat(); + else + redFsm->chooseSingle(); + + /* If any errors have occured in the input file then don't write anything. */ + if ( gblErrorCount > 0 ) + return; + + if ( codeStyle == GenSplit ) + redFsm->partitionFsm( numSplitPartitions ); + + if ( codeStyle == GenIpGoto || codeStyle == GenSplit ) + redFsm->setInTrans(); + + /* Anlayze Machine will find the final action reference counts, among + * other things. We will use these in reporting the usage + * of fsm directives in action code. */ + analyzeMachine(); + + /* Determine if we should use indicies. */ + calcIndexSize(); +} + +ostream &OCamlCodeGen::source_warning( const InputLoc &loc ) +{ + cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: "; + return cerr; +} + +ostream &OCamlCodeGen::source_error( const InputLoc &loc ) +{ + gblErrorCount += 1; + assert( sourceFileName != 0 ); + cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": "; + return cerr; +} + diff --git a/contrib/tools/ragel6/mlcodegen.h b/contrib/tools/ragel6/mlcodegen.h index 9ca49164de..b22690f29e 100644 --- a/contrib/tools/ragel6/mlcodegen.h +++ b/contrib/tools/ragel6/mlcodegen.h @@ -1,206 +1,206 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MLCODEGEN_H -#define _MLCODEGEN_H - -#include <iostream> -#include <string> -#include <stdio.h> -#include "common.h" -#include "gendata.h" - -using std::string; -using std::ostream; - -/* Forwards. */ -/* -struct RedFsmAp; -struct RedStateAp; -struct CodeGenData; -struct GenAction; -struct NameInst; -struct GenInlineItem; -struct GenInlineList; -struct RedAction; -struct LongestMatch; -struct LongestMatchPart; -*/ - -/* Integer array line length. */ -#define IALL 8 - -//string itoa( int i ); - -/* - * class OCamlCodeGen - */ -class OCamlCodeGen : public CodeGenData -{ -public: - OCamlCodeGen( ostream &out ); - virtual ~OCamlCodeGen() {} - - virtual void finishRagelDef(); - virtual void writeInit(); - virtual void writeStart(); - virtual void writeFirstFinal(); - virtual void writeError(); - -protected: - string data_prefix; - - string FSM_NAME(); - string START_STATE_ID(); - ostream &ACTIONS_ARRAY(); - string GET_WIDE_KEY(); - string GET_WIDE_KEY( RedStateAp *state ); - string TABS( int level ); - string KEY( Key key ); - string ALPHA_KEY( Key key ); - string LDIR_PATH( char *path ); - void ACTION( ostream &ret, GenAction *action, int targState, bool inFinish ); - void CONDITION( ostream &ret, GenAction *condition ); - string ALPH_TYPE(); - string WIDE_ALPH_TYPE(); - string ARRAY_TYPE( unsigned long maxVal ); - string ARRAY_TYPE( unsigned long maxVal, bool forceSigned ); - - virtual string ARR_OFF( string ptr, string offset ); - virtual string CAST( string type ); - virtual string UINT(); - virtual string NULL_ITEM(); - virtual string POINTER(); - virtual string GET_KEY(); - virtual ostream &SWITCH_DEFAULT(); - - string P(); - string PE(); - string vEOF(); - -// string ACCESS(); - string vCS(); - string STACK(); - string TOP(); - string TOKSTART(); - string TOKEND(); - string ACT(); - - // ++x - string PRE_INCR(string); - string PRE_DECR(string); - - // x++ - string POST_INCR(string); - string POST_DECR(string); - - string DATA_PREFIX(); - string PM() { return "_" + DATA_PREFIX() + "partition_map"; } - string C() { return "_" + DATA_PREFIX() + "cond_spaces"; } - string CK() { return "_" + DATA_PREFIX() + "cond_keys"; } - string K() { return "_" + DATA_PREFIX() + "trans_keys"; } - string I() { return "_" + DATA_PREFIX() + "indicies"; } - string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; } - string KO() { return "_" + DATA_PREFIX() + "key_offsets"; } - string IO() { return "_" + DATA_PREFIX() + "index_offsets"; } - string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; } - string SL() { return "_" + DATA_PREFIX() + "single_lengths"; } - string RL() { return "_" + DATA_PREFIX() + "range_lengths"; } - string A() { return "_" + DATA_PREFIX() + "actions"; } - string TA() { return "_" + DATA_PREFIX() + "trans_actions"; } - string TT() { return "_" + DATA_PREFIX() + "trans_targs"; } - string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; } - string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; } - string EA() { return "_" + DATA_PREFIX() + "eof_actions"; } - string ET() { return "_" + DATA_PREFIX() + "eof_trans"; } - string SP() { return "_" + DATA_PREFIX() + "key_spans"; } - string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; } - string TYPE_STATE() { return "_" + DATA_PREFIX() + "state"; } - string START() { return DATA_PREFIX() + "start"; } - string ERROR() { return DATA_PREFIX() + "error"; } - string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } - string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } - - void INLINE_LIST( ostream &ret, GenInlineList *inlineList, int targState, bool inFinish ); - virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; - virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0; - virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0; - virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; - virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; - virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, - int targState, bool inFinish ) = 0; - virtual void RET( ostream &ret, bool inFinish ) = 0; - virtual void BREAK( ostream &ret, int targState ) = 0; - virtual void CURS( ostream &ret, bool inFinish ) = 0; - virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0; - void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ); - void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState, int inFinish ); - void SET_ACT( ostream &ret, GenInlineItem *item ); - void INIT_TOKSTART( ostream &ret, GenInlineItem *item ); - void INIT_ACT( ostream &ret, GenInlineItem *item ); - void SET_TOKSTART( ostream &ret, GenInlineItem *item ); - void SET_TOKEND( ostream &ret, GenInlineItem *item ); - void GET_TOKEND( ostream &ret, GenInlineItem *item ); - void SUB_ACTION( ostream &ret, GenInlineItem *item, - int targState, bool inFinish ); - void STATE_IDS(); - - string ERROR_STATE(); - string FIRST_FINAL_STATE(); - - virtual string PTR_CONST(); - virtual ostream &OPEN_ARRAY( string type, string name ); - virtual ostream &CLOSE_ARRAY(); - virtual ostream &STATIC_VAR( string type, string name ); - - virtual string CTRL_FLOW(); - - // toplevel phrase separator - string TOP_SEP(); - // array elements separator - string ARR_SEP(); - // access array - string AT(const string& array, const string& index); - - string make_access(char const* name, GenInlineList* x, bool prefix); - - ostream &source_warning(const InputLoc &loc); - ostream &source_error(const InputLoc &loc); - - unsigned int arrayTypeSize( unsigned long maxVal ); - - bool outLabelUsed; - bool testEofUsed; - bool againLabelUsed; - bool useIndicies; - -public: - /* Determine if we should use indicies. */ - virtual void calcIndexSize() {} - - void genLineDirective( ostream &out ); -}; - -#define MAX(a, b) (a > b ? a : b) - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MLCODEGEN_H +#define _MLCODEGEN_H + +#include <iostream> +#include <string> +#include <stdio.h> +#include "common.h" +#include "gendata.h" + +using std::string; +using std::ostream; + +/* Forwards. */ +/* +struct RedFsmAp; +struct RedStateAp; +struct CodeGenData; +struct GenAction; +struct NameInst; +struct GenInlineItem; +struct GenInlineList; +struct RedAction; +struct LongestMatch; +struct LongestMatchPart; +*/ + +/* Integer array line length. */ +#define IALL 8 + +//string itoa( int i ); + +/* + * class OCamlCodeGen + */ +class OCamlCodeGen : public CodeGenData +{ +public: + OCamlCodeGen( ostream &out ); + virtual ~OCamlCodeGen() {} + + virtual void finishRagelDef(); + virtual void writeInit(); + virtual void writeStart(); + virtual void writeFirstFinal(); + virtual void writeError(); + +protected: + string data_prefix; + + string FSM_NAME(); + string START_STATE_ID(); + ostream &ACTIONS_ARRAY(); + string GET_WIDE_KEY(); + string GET_WIDE_KEY( RedStateAp *state ); + string TABS( int level ); + string KEY( Key key ); + string ALPHA_KEY( Key key ); + string LDIR_PATH( char *path ); + void ACTION( ostream &ret, GenAction *action, int targState, bool inFinish ); + void CONDITION( ostream &ret, GenAction *condition ); + string ALPH_TYPE(); + string WIDE_ALPH_TYPE(); + string ARRAY_TYPE( unsigned long maxVal ); + string ARRAY_TYPE( unsigned long maxVal, bool forceSigned ); + + virtual string ARR_OFF( string ptr, string offset ); + virtual string CAST( string type ); + virtual string UINT(); + virtual string NULL_ITEM(); + virtual string POINTER(); + virtual string GET_KEY(); + virtual ostream &SWITCH_DEFAULT(); + + string P(); + string PE(); + string vEOF(); + +// string ACCESS(); + string vCS(); + string STACK(); + string TOP(); + string TOKSTART(); + string TOKEND(); + string ACT(); + + // ++x + string PRE_INCR(string); + string PRE_DECR(string); + + // x++ + string POST_INCR(string); + string POST_DECR(string); + + string DATA_PREFIX(); + string PM() { return "_" + DATA_PREFIX() + "partition_map"; } + string C() { return "_" + DATA_PREFIX() + "cond_spaces"; } + string CK() { return "_" + DATA_PREFIX() + "cond_keys"; } + string K() { return "_" + DATA_PREFIX() + "trans_keys"; } + string I() { return "_" + DATA_PREFIX() + "indicies"; } + string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; } + string KO() { return "_" + DATA_PREFIX() + "key_offsets"; } + string IO() { return "_" + DATA_PREFIX() + "index_offsets"; } + string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; } + string SL() { return "_" + DATA_PREFIX() + "single_lengths"; } + string RL() { return "_" + DATA_PREFIX() + "range_lengths"; } + string A() { return "_" + DATA_PREFIX() + "actions"; } + string TA() { return "_" + DATA_PREFIX() + "trans_actions"; } + string TT() { return "_" + DATA_PREFIX() + "trans_targs"; } + string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; } + string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; } + string EA() { return "_" + DATA_PREFIX() + "eof_actions"; } + string ET() { return "_" + DATA_PREFIX() + "eof_trans"; } + string SP() { return "_" + DATA_PREFIX() + "key_spans"; } + string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; } + string TYPE_STATE() { return "_" + DATA_PREFIX() + "state"; } + string START() { return DATA_PREFIX() + "start"; } + string ERROR() { return DATA_PREFIX() + "error"; } + string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } + string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } + + void INLINE_LIST( ostream &ret, GenInlineList *inlineList, int targState, bool inFinish ); + virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; + virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0; + virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0; + virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; + virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; + virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, + int targState, bool inFinish ) = 0; + virtual void RET( ostream &ret, bool inFinish ) = 0; + virtual void BREAK( ostream &ret, int targState ) = 0; + virtual void CURS( ostream &ret, bool inFinish ) = 0; + virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0; + void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ); + void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState, int inFinish ); + void SET_ACT( ostream &ret, GenInlineItem *item ); + void INIT_TOKSTART( ostream &ret, GenInlineItem *item ); + void INIT_ACT( ostream &ret, GenInlineItem *item ); + void SET_TOKSTART( ostream &ret, GenInlineItem *item ); + void SET_TOKEND( ostream &ret, GenInlineItem *item ); + void GET_TOKEND( ostream &ret, GenInlineItem *item ); + void SUB_ACTION( ostream &ret, GenInlineItem *item, + int targState, bool inFinish ); + void STATE_IDS(); + + string ERROR_STATE(); + string FIRST_FINAL_STATE(); + + virtual string PTR_CONST(); + virtual ostream &OPEN_ARRAY( string type, string name ); + virtual ostream &CLOSE_ARRAY(); + virtual ostream &STATIC_VAR( string type, string name ); + + virtual string CTRL_FLOW(); + + // toplevel phrase separator + string TOP_SEP(); + // array elements separator + string ARR_SEP(); + // access array + string AT(const string& array, const string& index); + + string make_access(char const* name, GenInlineList* x, bool prefix); + + ostream &source_warning(const InputLoc &loc); + ostream &source_error(const InputLoc &loc); + + unsigned int arrayTypeSize( unsigned long maxVal ); + + bool outLabelUsed; + bool testEofUsed; + bool againLabelUsed; + bool useIndicies; + +public: + /* Determine if we should use indicies. */ + virtual void calcIndexSize() {} + + void genLineDirective( ostream &out ); +}; + +#define MAX(a, b) (a > b ? a : b) + +#endif diff --git a/contrib/tools/ragel6/mlfflat.cpp b/contrib/tools/ragel6/mlfflat.cpp index 2e14543a37..231f67b5b8 100644 --- a/contrib/tools/ragel6/mlfflat.cpp +++ b/contrib/tools/ragel6/mlfflat.cpp @@ -1,419 +1,419 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "mlfflat.h" -#include "redfsm.h" -#include "gendata.h" - -std::ostream &OCamlFFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &OCamlFFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &OCamlFFlatCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->actListId+1; - out << act; - return out; -} - -/* Write out the function for a transition. */ -std::ostream &OCamlFFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - int action = 0; - if ( trans->action != 0 ) - action = trans->action->actListId+1; - out << action; - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFFlatCodeGen::TO_STATE_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numToStateRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFFlatCodeGen::FROM_STATE_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numFromStateRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlFFlatCodeGen::EOF_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numEofRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, true ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFFlatCodeGen::ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -void OCamlFFlatCodeGen::writeData() -{ - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); - COND_KEY_SPANS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); - CONDS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); - COND_INDEX_OFFSET(); - CLOSE_ARRAY() << - "\n"; - } - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); - KEY_SPANS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); - FLAT_INDEX_OFFSET(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - "\n"; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - "\n"; - } - - STATE_IDS(); - - out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; }" - << TOP_SEP(); - - out << "exception Goto_match" << TOP_SEP(); - out << "exception Goto_again" << TOP_SEP(); - out << "exception Goto_eof_trans" << TOP_SEP(); -} - -void OCamlFFlatCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - initVarTypes(); - - out << - " begin\n"; -// " " << slenType << " _slen"; - -// if ( redFsm->anyRegCurStateRef() ) -// out << ", _ps"; - -// out << ";\n"; -// out << " " << transType << " _trans"; - -// if ( redFsm->anyConditions() ) -// out << ", _cond"; - -// out << ";\n"; - -// out << -// " " << "int _keys;\n" -// " " << indsType << " _inds;\n"; - /* - " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << POINTER() << "_inds;\n";*/ - - out << - " let state = { keys = 0; trans = 0; } in\n" - " let rec do_start () =\n"; - -// if ( redFsm->anyConditions() ) { -// out << -// " " << condsType << " _conds;\n" -// " " << WIDE_ALPH_TYPE() << " _widec;\n"; -// } - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " = " << PE() << " then\n" - " do_test_eof ()\n" - "\telse\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " = " << redFsm->errState->id << " then\n" - " do_out ()\n" - "\telse\n"; - } - out << "\tdo_resume ()\n"; - - out << "and do_resume () =\n"; - - if ( redFsm->anyFromStateActions() ) { - out << - " begin match " << AT( FSA(), vCS() ) << " with\n"; - FROM_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - "\n"; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - out << "\tbegin try\n"; - LOCATE_TRANS(); - out << "\twith Goto_match -> () end;\n"; - - out << "\tdo_eof_trans ()\n"; - -// if ( redFsm->anyEofTrans() ) - out << "and do_eof_trans () =\n"; - - if ( redFsm->anyRegCurStateRef() ) - out << " let ps = " << vCS() << " in\n"; - - out << - " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" - "\n"; - - if ( redFsm->anyRegActions() ) { - out << - " begin try if " << AT( TA() , "state.trans" ) << " = 0 then\n" - " raise Goto_again;\n" - "\n" - " match " << AT( TA(), "state.trans" ) << " with\n"; - ACTION_SWITCH(); - SWITCH_DEFAULT() << - " with Goto_again -> () end;\n" - "\n"; - } - out << "\tdo_again ()\n"; - -// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || -// redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "\tand do_again () =\n"; - - if ( redFsm->anyToStateActions() ) { - out << - " begin match " << AT( TSA(), vCS() ) << " with\n"; - TO_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - "\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "mlfflat.h" +#include "redfsm.h" +#include "gendata.h" + +std::ostream &OCamlFFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &OCamlFFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &OCamlFFlatCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->actListId+1; + out << act; + return out; +} + +/* Write out the function for a transition. */ +std::ostream &OCamlFFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + int action = 0; + if ( trans->action != 0 ) + action = trans->action->actListId+1; + out << action; + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFFlatCodeGen::TO_STATE_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numToStateRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFFlatCodeGen::FROM_STATE_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numFromStateRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlFFlatCodeGen::EOF_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numEofRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, true ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFFlatCodeGen::ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +void OCamlFFlatCodeGen::writeData() +{ + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); + COND_KEY_SPANS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); + CONDS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); + COND_INDEX_OFFSET(); + CLOSE_ARRAY() << + "\n"; + } + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); + KEY_SPANS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); + FLAT_INDEX_OFFSET(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + "\n"; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + + STATE_IDS(); + + out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; }" + << TOP_SEP(); + + out << "exception Goto_match" << TOP_SEP(); + out << "exception Goto_again" << TOP_SEP(); + out << "exception Goto_eof_trans" << TOP_SEP(); +} + +void OCamlFFlatCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + initVarTypes(); + + out << + " begin\n"; +// " " << slenType << " _slen"; + +// if ( redFsm->anyRegCurStateRef() ) +// out << ", _ps"; + +// out << ";\n"; +// out << " " << transType << " _trans"; + +// if ( redFsm->anyConditions() ) +// out << ", _cond"; + +// out << ";\n"; + +// out << +// " " << "int _keys;\n" +// " " << indsType << " _inds;\n"; + /* + " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << POINTER() << "_inds;\n";*/ + + out << + " let state = { keys = 0; trans = 0; } in\n" + " let rec do_start () =\n"; + +// if ( redFsm->anyConditions() ) { +// out << +// " " << condsType << " _conds;\n" +// " " << WIDE_ALPH_TYPE() << " _widec;\n"; +// } + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " = " << PE() << " then\n" + " do_test_eof ()\n" + "\telse\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " = " << redFsm->errState->id << " then\n" + " do_out ()\n" + "\telse\n"; + } + out << "\tdo_resume ()\n"; + + out << "and do_resume () =\n"; + + if ( redFsm->anyFromStateActions() ) { out << - " match " << vCS() << " with\n" - "\t| " << redFsm->errState->id << " -> do_out ()\n" - "\t| _ ->\n"; - } - - out << "\t" << P() << " <- " << P() << " + 1;\n"; - - if ( !noEnd ) { - out << - " if " << P() << " <> " << PE() << " then\n" - " do_resume ()\n" - "\telse do_test_eof ()\n"; - } - else { - out << - " do_resume ()\n"; - } - -// if ( testEofUsed ) - out << "and do_test_eof () =\n"; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " = " << vEOF() << " then\n" - " begin try\n"; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << AT( ET(), vCS() ) << " > 0 then\n" - " begin\n" - " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" - " raise Goto_eof_trans;\n" - " end;\n"; - } - - if ( redFsm->anyEofActions() ) { - out << - " begin match " << AT( EA(), vCS() ) << " with\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n"; - } - + " begin match " << AT( FSA(), vCS() ) << " with\n"; + FROM_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + "\n"; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + out << "\tbegin try\n"; + LOCATE_TRANS(); + out << "\twith Goto_match -> () end;\n"; + + out << "\tdo_eof_trans ()\n"; + +// if ( redFsm->anyEofTrans() ) + out << "and do_eof_trans () =\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " let ps = " << vCS() << " in\n"; + + out << + " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" + "\n"; + + if ( redFsm->anyRegActions() ) { + out << + " begin try if " << AT( TA() , "state.trans" ) << " = 0 then\n" + " raise Goto_again;\n" + "\n" + " match " << AT( TA(), "state.trans" ) << " with\n"; + ACTION_SWITCH(); + SWITCH_DEFAULT() << + " with Goto_again -> () end;\n" + "\n"; + } + out << "\tdo_again ()\n"; + +// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || +// redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "\tand do_again () =\n"; + + if ( redFsm->anyToStateActions() ) { out << - " with Goto_again -> do_again ()\n" - " | Goto_eof_trans -> do_eof_trans () end\n" - "\n"; - } - else - { - out << "\t()\n"; - } - - if ( outLabelUsed ) - out << " and do_out () = ()\n"; - - out << "\tin do_start ()\n"; - out << " end;\n"; -} - + " begin match " << AT( TSA(), vCS() ) << " with\n"; + TO_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + "\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " match " << vCS() << " with\n" + "\t| " << redFsm->errState->id << " -> do_out ()\n" + "\t| _ ->\n"; + } + + out << "\t" << P() << " <- " << P() << " + 1;\n"; + + if ( !noEnd ) { + out << + " if " << P() << " <> " << PE() << " then\n" + " do_resume ()\n" + "\telse do_test_eof ()\n"; + } + else { + out << + " do_resume ()\n"; + } + +// if ( testEofUsed ) + out << "and do_test_eof () =\n"; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " = " << vEOF() << " then\n" + " begin try\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << AT( ET(), vCS() ) << " > 0 then\n" + " begin\n" + " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" + " raise Goto_eof_trans;\n" + " end;\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " begin match " << AT( EA(), vCS() ) << " with\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n"; + } + + out << + " with Goto_again -> do_again ()\n" + " | Goto_eof_trans -> do_eof_trans () end\n" + "\n"; + } + else + { + out << "\t()\n"; + } + + if ( outLabelUsed ) + out << " and do_out () = ()\n"; + + out << "\tin do_start ()\n"; + out << " end;\n"; +} + diff --git a/contrib/tools/ragel6/mlfflat.h b/contrib/tools/ragel6/mlfflat.h index 242e6b911a..9e27de982e 100644 --- a/contrib/tools/ragel6/mlfflat.h +++ b/contrib/tools/ragel6/mlfflat.h @@ -1,55 +1,55 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MLFFLAT_H -#define _MLFFLAT_H - -#include <iostream> -#include "mlflat.h" - -/* Forwards. */ -//struct CodeGenData; - -/* - * OCamlFFlatCodeGen - */ -class OCamlFFlatCodeGen : public OCamlFlatCodeGen -{ -public: - OCamlFFlatCodeGen( ostream &out ) : OCamlFlatCodeGen(out) {} -private: - std::ostream &TO_STATE_ACTION_SWITCH(); - std::ostream &FROM_STATE_ACTION_SWITCH(); - std::ostream &EOF_ACTION_SWITCH(); - std::ostream &ACTION_SWITCH(); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MLFFLAT_H +#define _MLFFLAT_H + +#include <iostream> +#include "mlflat.h" + +/* Forwards. */ +//struct CodeGenData; + +/* + * OCamlFFlatCodeGen + */ +class OCamlFFlatCodeGen : public OCamlFlatCodeGen +{ +public: + OCamlFFlatCodeGen( ostream &out ) : OCamlFlatCodeGen(out) {} +private: + std::ostream &TO_STATE_ACTION_SWITCH(); + std::ostream &FROM_STATE_ACTION_SWITCH(); + std::ostream &EOF_ACTION_SWITCH(); + std::ostream &ACTION_SWITCH(); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/mlfgoto.cpp b/contrib/tools/ragel6/mlfgoto.cpp index b66d66ec2c..57eaecd1b4 100644 --- a/contrib/tools/ragel6/mlfgoto.cpp +++ b/contrib/tools/ragel6/mlfgoto.cpp @@ -1,311 +1,311 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "mlfgoto.h" -#include "redfsm.h" -#include "gendata.h" -#include "bstmap.h" - -std::ostream &OCamlFGotoCodeGen::EXEC_ACTIONS() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - /* We are at the start of a glob, write the case. */ - out << "and f" << redAct->actListId << " () =\n"; - out << "\tbegin try\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\twith Goto_again -> () end;\n"; - out << "\tdo_again ()\n"; - } - } - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFGotoCodeGen::TO_STATE_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numToStateRefs > 0 ) { - /* Write the entry label. */ - out << "\t|" << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - -// out << "\tbreak;\n"; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFGotoCodeGen::FROM_STATE_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numFromStateRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - -// out << "\tbreak;\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlFGotoCodeGen::EOF_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numEofRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, true ); - -// out << "\tbreak;\n"; - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &OCamlFGotoCodeGen::FINISH_CASES() -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* States that are final and have an out action need a case. */ - if ( st->eofAction != 0 ) { - /* Write the case label. */ - out << "\t\t| " << st->id << " -> "; - - /* Jump to the func. */ - out << "f" << st->eofAction->actListId << " ()\n"; - } - } - - return out; -} - -unsigned int OCamlFGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->actListId+1; - return act; -} - -unsigned int OCamlFGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->actListId+1; - return act; -} - -unsigned int OCamlFGotoCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->actListId+1; - return act; -} - -void OCamlFGotoCodeGen::writeData() -{ - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - STATE_IDS(); - - out << "exception Goto_again" << TOP_SEP(); -} - -void OCamlFGotoCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << " begin\n"; - - if ( redFsm->anyRegCurStateRef() ) - out << " let _ps = ref 0 in\n"; - - if ( redFsm->anyConditions() ) - out << " let _widec : " << WIDE_ALPH_TYPE() << " = ref 0 in\n"; - - out << "\n"; - out << "\tlet rec do_start () =\n"; - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " = " << PE() << " then\n" - " do_test_eof ()\n" - "\telse\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "mlfgoto.h" +#include "redfsm.h" +#include "gendata.h" +#include "bstmap.h" + +std::ostream &OCamlFGotoCodeGen::EXEC_ACTIONS() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + /* We are at the start of a glob, write the case. */ + out << "and f" << redAct->actListId << " () =\n"; + out << "\tbegin try\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\twith Goto_again -> () end;\n"; + out << "\tdo_again ()\n"; + } + } + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFGotoCodeGen::TO_STATE_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numToStateRefs > 0 ) { + /* Write the entry label. */ + out << "\t|" << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + +// out << "\tbreak;\n"; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFGotoCodeGen::FROM_STATE_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numFromStateRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + +// out << "\tbreak;\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlFGotoCodeGen::EOF_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numEofRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, true ); + +// out << "\tbreak;\n"; + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &OCamlFGotoCodeGen::FINISH_CASES() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* States that are final and have an out action need a case. */ + if ( st->eofAction != 0 ) { + /* Write the case label. */ + out << "\t\t| " << st->id << " -> "; + + /* Jump to the func. */ + out << "f" << st->eofAction->actListId << " ()\n"; + } + } + + return out; +} + +unsigned int OCamlFGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->actListId+1; + return act; +} + +unsigned int OCamlFGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->actListId+1; + return act; +} + +unsigned int OCamlFGotoCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->actListId+1; + return act; +} + +void OCamlFGotoCodeGen::writeData() +{ + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + STATE_IDS(); + + out << "exception Goto_again" << TOP_SEP(); +} + +void OCamlFGotoCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << " begin\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " let _ps = ref 0 in\n"; + + if ( redFsm->anyConditions() ) + out << " let _widec : " << WIDE_ALPH_TYPE() << " = ref 0 in\n"; + + out << "\n"; + out << "\tlet rec do_start () =\n"; + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " = " << PE() << " then\n" + " do_test_eof ()\n" + "\telse\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " = " << redFsm->errState->id << " then\n" + " do_out ()\n" + "\telse\n"; + } + out << "\tdo_resume ()\n"; + + out << "and do_resume () =\n"; + + if ( redFsm->anyFromStateActions() ) { out << - " if " << vCS() << " = " << redFsm->errState->id << " then\n" - " do_out ()\n" - "\telse\n"; - } - out << "\tdo_resume ()\n"; - - out << "and do_resume () =\n"; - - if ( redFsm->anyFromStateActions() ) { - out << - " begin match " << AT(FSA(),vCS()) << " with\n"; - FROM_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - "\n"; - } - - out << - " begin match " << vCS() << " with\n"; - STATE_GOTOS(); - SWITCH_DEFAULT() << - " end\n" - "\n"; - TRANSITIONS() << - "\n"; - - if ( redFsm->anyRegActions() ) - EXEC_ACTIONS() << "\n"; - - out << "\tand do_again () =\n"; - - if ( redFsm->anyToStateActions() ) { - out << - " begin match " << AT(TSA(), vCS()) << " with\n"; - TO_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - "\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; + " begin match " << AT(FSA(),vCS()) << " with\n"; + FROM_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + "\n"; + } + + out << + " begin match " << vCS() << " with\n"; + STATE_GOTOS(); + SWITCH_DEFAULT() << + " end\n" + "\n"; + TRANSITIONS() << + "\n"; + + if ( redFsm->anyRegActions() ) + EXEC_ACTIONS() << "\n"; + + out << "\tand do_again () =\n"; + + if ( redFsm->anyToStateActions() ) { out << - " match " << vCS() << " with\n" << - " | " << redFsm->errState->id << " -> do_out ()\n" - " | _ ->\n"; - } - - out << "\t" << P() << " <- " << P() << " + 1;\n"; - - if ( !noEnd ) { + " begin match " << AT(TSA(), vCS()) << " with\n"; + TO_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + "\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " match " << vCS() << " with\n" << + " | " << redFsm->errState->id << " -> do_out ()\n" + " | _ ->\n"; + } + + out << "\t" << P() << " <- " << P() << " + 1;\n"; + + if ( !noEnd ) { + out << + " if " << P() << " <> " << PE() << " then\n" + " do_resume ()\n" + "\telse do_test_eof ()\n"; + } + else { + out << + " do_resume ()\n"; + } + +// if ( testEofUsed ) + out << "and do_test_eof () =\n"; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << - " if " << P() << " <> " << PE() << " then\n" - " do_resume ()\n" - "\telse do_test_eof ()\n"; - } - else { + " if " << P() << " = " << vEOF() << " then\n" + " begin\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " match " << vCS() << " with\n"; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << " | " << st->id << " -> tr" << st->eofTrans->id << " ()\n"; + } + + SWITCH_DEFAULT() << ";\n"; // fall through + } + + if ( redFsm->anyEofActions() ) { + out << + " try match " << AT(EA(), vCS()) << " with\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " \n" + " with Goto_again -> do_again () \n"; + } + out << - " do_resume ()\n"; - } - -// if ( testEofUsed ) - out << "and do_test_eof () =\n"; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " = " << vEOF() << " then\n" - " begin\n"; - - if ( redFsm->anyEofTrans() ) { - out << - " match " << vCS() << " with\n"; - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) - out << " | " << st->id << " -> tr" << st->eofTrans->id << " ()\n"; - } - - SWITCH_DEFAULT() << ";\n"; // fall through - } - - if ( redFsm->anyEofActions() ) { - out << - " try match " << AT(EA(), vCS()) << " with\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " \n" - " with Goto_again -> do_again () \n"; - } - - out << - " end\n" - "\n"; - } - else - out << "\t()\n"; - - if ( outLabelUsed ) - out << "\tand do_out () = ()\n"; - - out << "\tin do_start ()\n"; - out << " end;\n"; -} + " end\n" + "\n"; + } + else + out << "\t()\n"; + + if ( outLabelUsed ) + out << "\tand do_out () = ()\n"; + + out << "\tin do_start ()\n"; + out << " end;\n"; +} diff --git a/contrib/tools/ragel6/mlfgoto.h b/contrib/tools/ragel6/mlfgoto.h index bccbd5523f..cca72c0ce1 100644 --- a/contrib/tools/ragel6/mlfgoto.h +++ b/contrib/tools/ragel6/mlfgoto.h @@ -1,51 +1,51 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MLFGOTO_H -#define _MLFGOTO_H - -#include <iostream> -#include "mlgoto.h" - -/* - * class OCamlFGotoCodeGen - */ -class OCamlFGotoCodeGen : virtual public OCamlGotoCodeGen -{ -public: - OCamlFGotoCodeGen( ostream &out ) : OCamlCodeGen(out), OCamlGotoCodeGen(out) {} - - std::ostream &EXEC_ACTIONS(); - std::ostream &TO_STATE_ACTION_SWITCH(); - std::ostream &FROM_STATE_ACTION_SWITCH(); - std::ostream &FINISH_CASES(); - std::ostream &EOF_ACTION_SWITCH(); - unsigned int TO_STATE_ACTION( RedStateAp *state ); - unsigned int FROM_STATE_ACTION( RedStateAp *state ); - unsigned int EOF_ACTION( RedStateAp *state ); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MLFGOTO_H +#define _MLFGOTO_H + +#include <iostream> +#include "mlgoto.h" + +/* + * class OCamlFGotoCodeGen + */ +class OCamlFGotoCodeGen : virtual public OCamlGotoCodeGen +{ +public: + OCamlFGotoCodeGen( ostream &out ) : OCamlCodeGen(out), OCamlGotoCodeGen(out) {} + + std::ostream &EXEC_ACTIONS(); + std::ostream &TO_STATE_ACTION_SWITCH(); + std::ostream &FROM_STATE_ACTION_SWITCH(); + std::ostream &FINISH_CASES(); + std::ostream &EOF_ACTION_SWITCH(); + unsigned int TO_STATE_ACTION( RedStateAp *state ); + unsigned int FROM_STATE_ACTION( RedStateAp *state ); + unsigned int EOF_ACTION( RedStateAp *state ); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/mlflat.cpp b/contrib/tools/ragel6/mlflat.cpp index b97aa15a8c..88eed1fc88 100644 --- a/contrib/tools/ragel6/mlflat.cpp +++ b/contrib/tools/ragel6/mlflat.cpp @@ -1,911 +1,911 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <sstream> -#include "ragel.h" -#include "mlflat.h" -#include "redfsm.h" -#include "gendata.h" - -std::ostream &OCamlFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->location+1; - out << act; - return out; -} - -std::ostream &OCamlFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->location+1; - out << act; - return out; -} - -std::ostream &OCamlFlatCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->location+1; - out << act; - return out; -} - -std::ostream &OCamlFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - /* If there are actions, emit them. Otherwise emit zero. */ - int act = 0; - if ( trans->action != 0 ) - act = trans->action->location+1; - out << act; - return out; -} - -std::ostream &OCamlFlatCodeGen::TO_STATE_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numToStateRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlFlatCodeGen::FROM_STATE_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numFromStateRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlFlatCodeGen::EOF_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numEofRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, true ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &OCamlFlatCodeGen::ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numTransRefs > 0 ) { - /* Write the case label, the action and the case break */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &OCamlFlatCodeGen::FLAT_INDEX_OFFSET() -{ - out << "\t"; - int totalStateNum = 0, curIndOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the index offset. */ - out << curIndOffset; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - - /* Move the index offset ahead. */ - if ( st->transList != 0 ) - curIndOffset += keyOps->span( st->lowKey, st->highKey ); - - if ( st->defTrans != 0 ) - curIndOffset += 1; - } - out << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::KEY_SPANS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - unsigned long long span = 0; - if ( st->transList != 0 ) - span = keyOps->span( st->lowKey, st->highKey ); - out << span; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::TO_STATE_ACTIONS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - TO_STATE_ACTION(st); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::FROM_STATE_ACTIONS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - FROM_STATE_ACTION(st); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::EOF_ACTIONS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - EOF_ACTION(st); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::EOF_TRANS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - - long trans = 0; - if ( st->eofTrans != 0 ) { - assert( st->eofTrans->pos >= 0 ); - trans = st->eofTrans->pos+1; - } - out << trans; - - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - - -std::ostream &OCamlFlatCodeGen::COND_KEYS() -{ - out << '\t'; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Emit just cond low key and cond high key. */ - out << ALPHA_KEY( st->condLowKey ) << ARR_SEP(); - out << ALPHA_KEY( st->condHighKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << /*"(char) " <<*/ 0 << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::COND_KEY_SPANS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - unsigned long long span = 0; - if ( st->condList != 0 ) - span = keyOps->span( st->condLowKey, st->condHighKey ); - out << span; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::CONDS() -{ - int totalTrans = 0; - out << '\t'; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->condList != 0 ) { - /* Walk the singles. */ - unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey ); - for ( unsigned long long pos = 0; pos < span; pos++ ) { - if ( st->condList[pos] != 0 ) - out << st->condList[pos]->condSpaceId + 1 << ARR_SEP(); - else - out << "0" << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::COND_INDEX_OFFSET() -{ - out << "\t"; - int totalStateNum = 0, curIndOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the index offset. */ - out << curIndOffset; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - - /* Move the index offset ahead. */ - if ( st->condList != 0 ) - curIndOffset += keyOps->span( st->condLowKey, st->condHighKey ); - } - out << "\n"; - return out; -} - - -std::ostream &OCamlFlatCodeGen::KEYS() -{ - out << '\t'; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Emit just low key and high key. */ - out << ALPHA_KEY( st->lowKey ) << ARR_SEP(); - out << ALPHA_KEY( st->highKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << /*"(char) " <<*/ 0 << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::INDICIES() -{ - int totalTrans = 0; - out << '\t'; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->transList != 0 ) { - /* Walk the singles. */ - unsigned long long span = keyOps->span( st->lowKey, st->highKey ); - for ( unsigned long long pos = 0; pos < span; pos++ ) { - out << st->transList[pos]->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - /* The state's default index goes next. */ - if ( st->defTrans != 0 ) - out << st->defTrans->id << ARR_SEP(); - - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlFlatCodeGen::TRANS_TARGS() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << '\t'; - int totalStates = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Record the position, need this for eofTrans. */ - RedTransAp *trans = transPtrs[t]; - trans->pos = t; - - /* Write out the target state. */ - out << trans->targ->id; - if ( t < redFsm->transSet.length()-1 ) { - out << ARR_SEP(); - if ( ++totalStates % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] transPtrs; - return out; -} - - -std::ostream &OCamlFlatCodeGen::TRANS_ACTIONS() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << '\t'; - int totalAct = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Write the function for the transition. */ - RedTransAp *trans = transPtrs[t]; - TRANS_ACTION( trans ); - if ( t < redFsm->transSet.length()-1 ) { - out << ARR_SEP(); - if ( ++totalAct % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] transPtrs; - return out; -} - -void OCamlFlatCodeGen::LOCATE_TRANS() -{ - std::ostringstream temp; - temp << "inds + (\n" - " if slen > 0 && " << AT( K(), "keys" ) << " <= " << GET_WIDE_KEY() << " &&\n" - " " << GET_WIDE_KEY() << " <= " << AT( K(), "keys+1" ) << " then\n" - " " << GET_WIDE_KEY() << " - " << AT(K(), "keys" ) << " else slen)"; - out << - " let keys = " << vCS() << " lsl 1 in\n" - " let inds = " << AT( IO(), vCS() ) << " in\n" - "\n" - " let slen = " << AT( SP(), vCS() ) << " in\n" - " state.trans <- " << AT( I(), temp.str() ) << ";\n" - "\n"; -} - -void OCamlFlatCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) -{ - ret << "begin " << vCS() << " <- " << gotoDest << "; " << - CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlFlatCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << "begin " << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << "); " << CTRL_FLOW() << " raise Goto_again end"; -} - -void OCamlFlatCodeGen::CURS( ostream &ret, bool inFinish ) -{ - ret << "(_ps)"; -} - -void OCamlFlatCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) -{ - ret << "(" << vCS() << ")"; -} - -void OCamlFlatCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) -{ - ret << vCS() << " <- " << nextDest << ";"; -} - -void OCamlFlatCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << ");"; -} - -void OCamlFlatCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, prePushExpr, 0, false ); - } - - ret << "begin " << AT( STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; "; - ret << vCS() << " <- " << callDest << "; " << CTRL_FLOW() << "raise Goto_again end "; - - if ( prePushExpr != 0 ) - ret << "end"; -} - -void OCamlFlatCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, prePushExpr, 0, false ); - } - - ret << "begin " << AT(STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; " << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, targState, inFinish ); - ret << "); " << CTRL_FLOW() << "raise Goto_again end "; - - if ( prePushExpr != 0 ) - ret << "end"; -} - -void OCamlFlatCodeGen::RET( ostream &ret, bool inFinish ) -{ - ret << "begin " << vCS() << " <- " << AT(STACK(), PRE_DECR(TOP()) ) << "; "; - - if ( postPopExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, postPopExpr, 0, false ); - ret << "end "; - } - - ret << CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlFlatCodeGen::BREAK( ostream &ret, int targState ) -{ - outLabelUsed = true; - ret << "begin " << P() << " <- " << P() << " + 1; " << CTRL_FLOW() << "raise Goto_out end"; -} - -void OCamlFlatCodeGen::writeData() -{ - /* If there are any transtion functions then output the array. If there - * are none, don't bother emitting an empty array that won't be used. */ - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); - ACTIONS_ARRAY(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); - COND_KEY_SPANS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); - CONDS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); - COND_INDEX_OFFSET(); - CLOSE_ARRAY() << - "\n"; - } - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); - KEY_SPANS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); - FLAT_INDEX_OFFSET(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - "\n"; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - "\n"; - } - - STATE_IDS(); - - out << "type " << TYPE_STATE() << " = { mutable trans : int; mutable acts : int; mutable nacts : int; }" - << TOP_SEP(); - - out << "exception Goto_match" << TOP_SEP(); - out << "exception Goto_again" << TOP_SEP(); - out << "exception Goto_eof_trans" << TOP_SEP(); -} - -void OCamlFlatCodeGen::COND_TRANSLATE() -{ + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <sstream> +#include "ragel.h" +#include "mlflat.h" +#include "redfsm.h" +#include "gendata.h" + +std::ostream &OCamlFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->location+1; + out << act; + return out; +} + +std::ostream &OCamlFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->location+1; + out << act; + return out; +} + +std::ostream &OCamlFlatCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->location+1; + out << act; + return out; +} + +std::ostream &OCamlFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + /* If there are actions, emit them. Otherwise emit zero. */ + int act = 0; + if ( trans->action != 0 ) + act = trans->action->location+1; + out << act; + return out; +} + +std::ostream &OCamlFlatCodeGen::TO_STATE_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numToStateRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlFlatCodeGen::FROM_STATE_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numFromStateRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlFlatCodeGen::EOF_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numEofRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, true ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &OCamlFlatCodeGen::ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numTransRefs > 0 ) { + /* Write the case label, the action and the case break */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &OCamlFlatCodeGen::FLAT_INDEX_OFFSET() +{ + out << "\t"; + int totalStateNum = 0, curIndOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the index offset. */ + out << curIndOffset; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + + /* Move the index offset ahead. */ + if ( st->transList != 0 ) + curIndOffset += keyOps->span( st->lowKey, st->highKey ); + + if ( st->defTrans != 0 ) + curIndOffset += 1; + } + out << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::KEY_SPANS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + unsigned long long span = 0; + if ( st->transList != 0 ) + span = keyOps->span( st->lowKey, st->highKey ); + out << span; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::TO_STATE_ACTIONS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + TO_STATE_ACTION(st); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::FROM_STATE_ACTIONS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + FROM_STATE_ACTION(st); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::EOF_ACTIONS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + EOF_ACTION(st); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::EOF_TRANS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + + long trans = 0; + if ( st->eofTrans != 0 ) { + assert( st->eofTrans->pos >= 0 ); + trans = st->eofTrans->pos+1; + } + out << trans; + + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + + +std::ostream &OCamlFlatCodeGen::COND_KEYS() +{ + out << '\t'; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Emit just cond low key and cond high key. */ + out << ALPHA_KEY( st->condLowKey ) << ARR_SEP(); + out << ALPHA_KEY( st->condHighKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << /*"(char) " <<*/ 0 << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::COND_KEY_SPANS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + unsigned long long span = 0; + if ( st->condList != 0 ) + span = keyOps->span( st->condLowKey, st->condHighKey ); + out << span; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::CONDS() +{ + int totalTrans = 0; + out << '\t'; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->condList != 0 ) { + /* Walk the singles. */ + unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey ); + for ( unsigned long long pos = 0; pos < span; pos++ ) { + if ( st->condList[pos] != 0 ) + out << st->condList[pos]->condSpaceId + 1 << ARR_SEP(); + else + out << "0" << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::COND_INDEX_OFFSET() +{ + out << "\t"; + int totalStateNum = 0, curIndOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the index offset. */ + out << curIndOffset; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + + /* Move the index offset ahead. */ + if ( st->condList != 0 ) + curIndOffset += keyOps->span( st->condLowKey, st->condHighKey ); + } + out << "\n"; + return out; +} + + +std::ostream &OCamlFlatCodeGen::KEYS() +{ + out << '\t'; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Emit just low key and high key. */ + out << ALPHA_KEY( st->lowKey ) << ARR_SEP(); + out << ALPHA_KEY( st->highKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << /*"(char) " <<*/ 0 << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::INDICIES() +{ + int totalTrans = 0; + out << '\t'; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->transList != 0 ) { + /* Walk the singles. */ + unsigned long long span = keyOps->span( st->lowKey, st->highKey ); + for ( unsigned long long pos = 0; pos < span; pos++ ) { + out << st->transList[pos]->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + /* The state's default index goes next. */ + if ( st->defTrans != 0 ) + out << st->defTrans->id << ARR_SEP(); + + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlFlatCodeGen::TRANS_TARGS() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << '\t'; + int totalStates = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Record the position, need this for eofTrans. */ + RedTransAp *trans = transPtrs[t]; + trans->pos = t; + + /* Write out the target state. */ + out << trans->targ->id; + if ( t < redFsm->transSet.length()-1 ) { + out << ARR_SEP(); + if ( ++totalStates % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] transPtrs; + return out; +} + + +std::ostream &OCamlFlatCodeGen::TRANS_ACTIONS() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << '\t'; + int totalAct = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Write the function for the transition. */ + RedTransAp *trans = transPtrs[t]; + TRANS_ACTION( trans ); + if ( t < redFsm->transSet.length()-1 ) { + out << ARR_SEP(); + if ( ++totalAct % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] transPtrs; + return out; +} + +void OCamlFlatCodeGen::LOCATE_TRANS() +{ + std::ostringstream temp; + temp << "inds + (\n" + " if slen > 0 && " << AT( K(), "keys" ) << " <= " << GET_WIDE_KEY() << " &&\n" + " " << GET_WIDE_KEY() << " <= " << AT( K(), "keys+1" ) << " then\n" + " " << GET_WIDE_KEY() << " - " << AT(K(), "keys" ) << " else slen)"; + out << + " let keys = " << vCS() << " lsl 1 in\n" + " let inds = " << AT( IO(), vCS() ) << " in\n" + "\n" + " let slen = " << AT( SP(), vCS() ) << " in\n" + " state.trans <- " << AT( I(), temp.str() ) << ";\n" + "\n"; +} + +void OCamlFlatCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) +{ + ret << "begin " << vCS() << " <- " << gotoDest << "; " << + CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlFlatCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << "begin " << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish ); + ret << "); " << CTRL_FLOW() << " raise Goto_again end"; +} + +void OCamlFlatCodeGen::CURS( ostream &ret, bool inFinish ) +{ + ret << "(_ps)"; +} + +void OCamlFlatCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) +{ + ret << "(" << vCS() << ")"; +} + +void OCamlFlatCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) +{ + ret << vCS() << " <- " << nextDest << ";"; +} + +void OCamlFlatCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish ); + ret << ");"; +} + +void OCamlFlatCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, prePushExpr, 0, false ); + } + + ret << "begin " << AT( STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; "; + ret << vCS() << " <- " << callDest << "; " << CTRL_FLOW() << "raise Goto_again end "; + + if ( prePushExpr != 0 ) + ret << "end"; +} + +void OCamlFlatCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, prePushExpr, 0, false ); + } + + ret << "begin " << AT(STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; " << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, targState, inFinish ); + ret << "); " << CTRL_FLOW() << "raise Goto_again end "; + + if ( prePushExpr != 0 ) + ret << "end"; +} + +void OCamlFlatCodeGen::RET( ostream &ret, bool inFinish ) +{ + ret << "begin " << vCS() << " <- " << AT(STACK(), PRE_DECR(TOP()) ) << "; "; + + if ( postPopExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, postPopExpr, 0, false ); + ret << "end "; + } + + ret << CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlFlatCodeGen::BREAK( ostream &ret, int targState ) +{ + outLabelUsed = true; + ret << "begin " << P() << " <- " << P() << " + 1; " << CTRL_FLOW() << "raise Goto_out end"; +} + +void OCamlFlatCodeGen::writeData() +{ + /* If there are any transtion functions then output the array. If there + * are none, don't bother emitting an empty array that won't be used. */ + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); + ACTIONS_ARRAY(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); + COND_KEY_SPANS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); + CONDS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); + COND_INDEX_OFFSET(); + CLOSE_ARRAY() << + "\n"; + } + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); + KEY_SPANS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); + FLAT_INDEX_OFFSET(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + "\n"; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + + STATE_IDS(); + + out << "type " << TYPE_STATE() << " = { mutable trans : int; mutable acts : int; mutable nacts : int; }" + << TOP_SEP(); + + out << "exception Goto_match" << TOP_SEP(); + out << "exception Goto_again" << TOP_SEP(); + out << "exception Goto_eof_trans" << TOP_SEP(); +} + +void OCamlFlatCodeGen::COND_TRANSLATE() +{ + out << + " _widec = " << GET_KEY() << ";\n"; + + out << + " _keys = " << vCS() << "<<1;\n" + " _conds = " << CO() << "[" << vCS() << "];\n" +// " _keys = " << ARR_OFF( CK(), "(" + vCS() + "<<1)" ) << ";\n" +// " _conds = " << ARR_OFF( C(), CO() + "[" + vCS() + "]" ) << ";\n" + "\n" + " _slen = " << CSP() << "[" << vCS() << "];\n" + " if (_slen > 0 && " << CK() << "[_keys] <=" + << GET_WIDE_KEY() << " &&\n" + " " << GET_WIDE_KEY() << " <= " << CK() << "[_keys+1])\n" + " _cond = " << C() << "[_conds+" << GET_WIDE_KEY() << " - " << + CK() << "[_keys]];\n" + " else\n" + " _cond = 0;" + "\n"; + /* XXX This version of the code doesn't work because Mono is weird. Works + * fine in Microsoft's csc, even though the bug report filed claimed it + * didn't. + " _slen = " << CSP() << "[" << vCS() << "];\n" + " _cond = _slen > 0 && " << CK() << "[_keys] <=" + << GET_WIDE_KEY() << " &&\n" + " " << GET_WIDE_KEY() << " <= " << CK() << "[_keys+1] ?\n" + " " << C() << "[_conds+" << GET_WIDE_KEY() << " - " << CK() + << "[_keys]] : 0;\n" + "\n"; + */ out << - " _widec = " << GET_KEY() << ";\n"; - - out << - " _keys = " << vCS() << "<<1;\n" - " _conds = " << CO() << "[" << vCS() << "];\n" -// " _keys = " << ARR_OFF( CK(), "(" + vCS() + "<<1)" ) << ";\n" -// " _conds = " << ARR_OFF( C(), CO() + "[" + vCS() + "]" ) << ";\n" - "\n" - " _slen = " << CSP() << "[" << vCS() << "];\n" - " if (_slen > 0 && " << CK() << "[_keys] <=" - << GET_WIDE_KEY() << " &&\n" - " " << GET_WIDE_KEY() << " <= " << CK() << "[_keys+1])\n" - " _cond = " << C() << "[_conds+" << GET_WIDE_KEY() << " - " << - CK() << "[_keys]];\n" - " else\n" - " _cond = 0;" - "\n"; - /* XXX This version of the code doesn't work because Mono is weird. Works - * fine in Microsoft's csc, even though the bug report filed claimed it - * didn't. - " _slen = " << CSP() << "[" << vCS() << "];\n" - " _cond = _slen > 0 && " << CK() << "[_keys] <=" - << GET_WIDE_KEY() << " &&\n" - " " << GET_WIDE_KEY() << " <= " << CK() << "[_keys+1] ?\n" - " " << C() << "[_conds+" << GET_WIDE_KEY() << " - " << CK() - << "[_keys]] : 0;\n" - "\n"; - */ - out << - " switch ( _cond ) {\n"; - for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { - GenCondSpace *condSpace = csi; - out << " case " << condSpace->condSpaceId + 1 << ": {\n"; - out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << - KEY(condSpace->baseKey) << " + (" << GET_KEY() << - " - " << KEY(keyOps->minKey) << "));\n"; - - for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { - out << TABS(2) << "if ( "; - CONDITION( out, *csi ); - Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); - out << " ) _widec += " << condValOffset << ";\n"; - } - - out << " }\n"; - out << " break;\n"; - } - - SWITCH_DEFAULT(); - - out << - " }\n"; -} - -void OCamlFlatCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - initVarTypes(); - + " switch ( _cond ) {\n"; + for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { + GenCondSpace *condSpace = csi; + out << " case " << condSpace->condSpaceId + 1 << ": {\n"; + out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << + KEY(condSpace->baseKey) << " + (" << GET_KEY() << + " - " << KEY(keyOps->minKey) << "));\n"; + + for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { + out << TABS(2) << "if ( "; + CONDITION( out, *csi ); + Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); + out << " ) _widec += " << condValOffset << ";\n"; + } + + out << " }\n"; + out << " break;\n"; + } + + SWITCH_DEFAULT(); + out << - " begin\n"; -// " " << slenType << " _slen"; - -// if ( redFsm->anyRegCurStateRef() ) -// out << ", _ps"; - + " }\n"; +} + +void OCamlFlatCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + initVarTypes(); + + out << + " begin\n"; +// " " << slenType << " _slen"; + +// if ( redFsm->anyRegCurStateRef() ) +// out << ", _ps"; + +// out << +// " " << transType << " _trans"; + +// if ( redFsm->anyConditions() ) +// out << ", _cond"; +// out << ";\n"; + +// if ( redFsm->anyToStateActions() || +// redFsm->anyRegActions() || redFsm->anyFromStateActions() ) +// { +// out << +// " int _acts;\n" +// " int _nacts;\n"; +// } + // out << -// " " << transType << " _trans"; - -// if ( redFsm->anyConditions() ) -// out << ", _cond"; -// out << ";\n"; - -// if ( redFsm->anyToStateActions() || -// redFsm->anyRegActions() || redFsm->anyFromStateActions() ) -// { -// out << -// " int _acts;\n" -// " int _nacts;\n"; -// } - -// out << -// " " << "int _keys;\n" -// " " << indsType << " _inds;\n"; - /* - " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << POINTER() << "_inds;\n";*/ - - if ( redFsm->anyConditions() ) { - out << - " " << condsType << " _conds;\n" - " " << WIDE_ALPH_TYPE() << " _widec;\n"; - } - - out << "\n"; - - out << - " let state = { trans = 0; acts = 0; nacts = 0; } in\n" - " let rec do_start () =\n"; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " = " << PE() << " then\n" - " do_test_eof ()\n" - "\telse\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; +// " " << "int _keys;\n" +// " " << indsType << " _inds;\n"; + /* + " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n" + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << POINTER() << "_inds;\n";*/ + + if ( redFsm->anyConditions() ) { + out << + " " << condsType << " _conds;\n" + " " << WIDE_ALPH_TYPE() << " _widec;\n"; + } + + out << "\n"; + + out << + " let state = { trans = 0; acts = 0; nacts = 0; } in\n" + " let rec do_start () =\n"; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " = " << PE() << " then\n" + " do_test_eof ()\n" + "\telse\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " = " << redFsm->errState->id << " then\n" + " do_out ()\n" + "\telse\n"; + } + + out << "\tdo_resume ()\n"; + + out << "and do_resume () =\n"; + + if ( redFsm->anyFromStateActions() ) { out << - " if " << vCS() << " = " << redFsm->errState->id << " then\n" - " do_out ()\n" - "\telse\n"; - } - - out << "\tdo_resume ()\n"; - - out << "and do_resume () =\n"; - - if ( redFsm->anyFromStateActions() ) { - out << - " state.acts <- " << AT( FSA(), vCS() ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - FROM_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n" - " done;\n" - "\n"; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - -// out << "\tbegin try\n"; - LOCATE_TRANS(); -// out << "\twith Goto_match -> () end;\n"; - - out << "\tdo_eof_trans ()\n"; - -// if ( redFsm->anyEofTrans() ) - out << "and do_eof_trans () =\n"; - - if ( redFsm->anyRegCurStateRef() ) - out << " let ps = " << vCS() << " in\n"; - - out << - " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" - "\n"; - - if ( redFsm->anyRegActions() ) { - out << - "\tbegin try\n" - " match " << AT( TA(), "state.trans" ) << " with\n" - "\t| 0 -> raise Goto_again\n" - "\t| _ ->\n" - " state.acts <- " << AT( TA(), "state.trans" ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - " done\n" - "\twith Goto_again -> () end;\n"; - } - out << "\tdo_again ()\n"; - -// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || -// redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "\tand do_again () =\n"; - - if ( redFsm->anyToStateActions() ) { - out << - " state.acts <- " << AT( TSA(), vCS() ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - TO_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n" - " done;\n" - "\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " match " << vCS() << " with\n" - "\t| " << redFsm->errState->id << " -> do_out ()\n" - "\t| _ ->\n"; - } - - out << "\t" << P() << " <- " << P() << " + 1;\n"; - - if ( !noEnd ) { - out << - " if " << P() << " <> " << PE() << " then\n" - " do_resume ()\n" - "\telse do_test_eof ()\n"; - } - else { - out << - " do_resume ()\n"; - } - -// if ( testEofUsed ) - out << "and do_test_eof () =\n"; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + " state.acts <- " << AT( FSA(), vCS() ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + FROM_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n" + " done;\n" + "\n"; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + +// out << "\tbegin try\n"; + LOCATE_TRANS(); +// out << "\twith Goto_match -> () end;\n"; + + out << "\tdo_eof_trans ()\n"; + +// if ( redFsm->anyEofTrans() ) + out << "and do_eof_trans () =\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " let ps = " << vCS() << " in\n"; + + out << + " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" + "\n"; + + if ( redFsm->anyRegActions() ) { out << - " if " << P() << " = " << vEOF() << " then\n" - " begin try\n"; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << AT( ET(), vCS() ) << " > 0 then\n" - " begin\n" - " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" - " raise Goto_eof_trans;\n" - " end;\n"; - } - - if ( redFsm->anyEofActions() ) { - out << - " let __acts = ref " << AT( EA(), vCS() ) << " in\n" - " let __nacts = ref " << AT( A(), "!__acts" ) << " in\n" - " incr __acts;\n" - " while !__nacts > 0 do\n" - " decr __nacts;\n" - " begin match " << AT( A(), POST_INCR("__acts.contents") ) << " with\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - " done\n"; - } - + "\tbegin try\n" + " match " << AT( TA(), "state.trans" ) << " with\n" + "\t| 0 -> raise Goto_again\n" + "\t| _ ->\n" + " state.acts <- " << AT( TA(), "state.trans" ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + " done\n" + "\twith Goto_again -> () end;\n"; + } + out << "\tdo_again ()\n"; + +// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || +// redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "\tand do_again () =\n"; + + if ( redFsm->anyToStateActions() ) { out << - " with Goto_again -> do_again ()\n" - " | Goto_eof_trans -> do_eof_trans () end\n" - "\n"; - } - else - { - out << "\t()\n"; - } - - if ( outLabelUsed ) - out << " and do_out () = ()\n"; - - out << "\tin do_start ()\n"; - out << " end;\n"; -} - -void OCamlFlatCodeGen::initVarTypes() -{ - slenType = ARRAY_TYPE(MAX(redFsm->maxSpan, redFsm->maxCondSpan)); - transType = ARRAY_TYPE(redFsm->maxIndex+1); - indsType = ARRAY_TYPE(redFsm->maxFlatIndexOffset); - condsType = ARRAY_TYPE(redFsm->maxCondIndexOffset); -} + " state.acts <- " << AT( TSA(), vCS() ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + TO_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n" + " done;\n" + "\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " match " << vCS() << " with\n" + "\t| " << redFsm->errState->id << " -> do_out ()\n" + "\t| _ ->\n"; + } + + out << "\t" << P() << " <- " << P() << " + 1;\n"; + + if ( !noEnd ) { + out << + " if " << P() << " <> " << PE() << " then\n" + " do_resume ()\n" + "\telse do_test_eof ()\n"; + } + else { + out << + " do_resume ()\n"; + } + +// if ( testEofUsed ) + out << "and do_test_eof () =\n"; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " = " << vEOF() << " then\n" + " begin try\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << AT( ET(), vCS() ) << " > 0 then\n" + " begin\n" + " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" + " raise Goto_eof_trans;\n" + " end;\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " let __acts = ref " << AT( EA(), vCS() ) << " in\n" + " let __nacts = ref " << AT( A(), "!__acts" ) << " in\n" + " incr __acts;\n" + " while !__nacts > 0 do\n" + " decr __nacts;\n" + " begin match " << AT( A(), POST_INCR("__acts.contents") ) << " with\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + " done\n"; + } + + out << + " with Goto_again -> do_again ()\n" + " | Goto_eof_trans -> do_eof_trans () end\n" + "\n"; + } + else + { + out << "\t()\n"; + } + + if ( outLabelUsed ) + out << " and do_out () = ()\n"; + + out << "\tin do_start ()\n"; + out << " end;\n"; +} + +void OCamlFlatCodeGen::initVarTypes() +{ + slenType = ARRAY_TYPE(MAX(redFsm->maxSpan, redFsm->maxCondSpan)); + transType = ARRAY_TYPE(redFsm->maxIndex+1); + indsType = ARRAY_TYPE(redFsm->maxFlatIndexOffset); + condsType = ARRAY_TYPE(redFsm->maxCondIndexOffset); +} diff --git a/contrib/tools/ragel6/mlflat.h b/contrib/tools/ragel6/mlflat.h index 6da18198d8..26d01bbf64 100644 --- a/contrib/tools/ragel6/mlflat.h +++ b/contrib/tools/ragel6/mlflat.h @@ -1,91 +1,91 @@ -/* - * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2004-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MLFLAT_H -#define _MLFLAT_H - -#include <iostream> -#include "mlcodegen.h" - -/* Forwards. */ -//struct CodeGenData; -//struct NameInst; -//struct RedTransAp; -//struct RedStateAp; - -/* - * OCamlFlatCodeGen - */ -class OCamlFlatCodeGen : public OCamlCodeGen -{ -public: - OCamlFlatCodeGen( ostream &out ) : OCamlCodeGen(out) {} - virtual ~OCamlFlatCodeGen() { } - -protected: - std::ostream &TO_STATE_ACTION_SWITCH(); - std::ostream &FROM_STATE_ACTION_SWITCH(); - std::ostream &EOF_ACTION_SWITCH(); - std::ostream &ACTION_SWITCH(); - std::ostream &KEYS(); - std::ostream &INDICIES(); - std::ostream &FLAT_INDEX_OFFSET(); - std::ostream &KEY_SPANS(); - std::ostream &TO_STATE_ACTIONS(); - std::ostream &FROM_STATE_ACTIONS(); - std::ostream &EOF_ACTIONS(); - std::ostream &EOF_TRANS(); - std::ostream &TRANS_TARGS(); - std::ostream &TRANS_ACTIONS(); - void LOCATE_TRANS(); - - std::ostream &COND_INDEX_OFFSET(); - void COND_TRANSLATE(); - std::ostream &CONDS(); - std::ostream &COND_KEYS(); - std::ostream &COND_KEY_SPANS(); - - void GOTO( ostream &ret, int gotoDest, bool inFinish ); - void CALL( ostream &ret, int callDest, int targState, bool inFinish ); - void NEXT( ostream &ret, int nextDest, bool inFinish ); - void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); - void CURS( ostream &ret, bool inFinish ); - void TARGS( ostream &ret, bool inFinish, int targState ); - void RET( ostream &ret, bool inFinish ); - void BREAK( ostream &ret, int targState ); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - - virtual void writeData(); - virtual void writeExec(); - - void initVarTypes(); - string slenType, transType, indsType, condsType; -}; - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MLFLAT_H +#define _MLFLAT_H + +#include <iostream> +#include "mlcodegen.h" + +/* Forwards. */ +//struct CodeGenData; +//struct NameInst; +//struct RedTransAp; +//struct RedStateAp; + +/* + * OCamlFlatCodeGen + */ +class OCamlFlatCodeGen : public OCamlCodeGen +{ +public: + OCamlFlatCodeGen( ostream &out ) : OCamlCodeGen(out) {} + virtual ~OCamlFlatCodeGen() { } + +protected: + std::ostream &TO_STATE_ACTION_SWITCH(); + std::ostream &FROM_STATE_ACTION_SWITCH(); + std::ostream &EOF_ACTION_SWITCH(); + std::ostream &ACTION_SWITCH(); + std::ostream &KEYS(); + std::ostream &INDICIES(); + std::ostream &FLAT_INDEX_OFFSET(); + std::ostream &KEY_SPANS(); + std::ostream &TO_STATE_ACTIONS(); + std::ostream &FROM_STATE_ACTIONS(); + std::ostream &EOF_ACTIONS(); + std::ostream &EOF_TRANS(); + std::ostream &TRANS_TARGS(); + std::ostream &TRANS_ACTIONS(); + void LOCATE_TRANS(); + + std::ostream &COND_INDEX_OFFSET(); + void COND_TRANSLATE(); + std::ostream &CONDS(); + std::ostream &COND_KEYS(); + std::ostream &COND_KEY_SPANS(); + + void GOTO( ostream &ret, int gotoDest, bool inFinish ); + void CALL( ostream &ret, int callDest, int targState, bool inFinish ); + void NEXT( ostream &ret, int nextDest, bool inFinish ); + void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); + void CURS( ostream &ret, bool inFinish ); + void TARGS( ostream &ret, bool inFinish, int targState ); + void RET( ostream &ret, bool inFinish ); + void BREAK( ostream &ret, int targState ); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + + virtual void writeData(); + virtual void writeExec(); + + void initVarTypes(); + string slenType, transType, indsType, condsType; +}; + +#endif diff --git a/contrib/tools/ragel6/mlftable.cpp b/contrib/tools/ragel6/mlftable.cpp index 15a9885eec..214f5c4ce7 100644 --- a/contrib/tools/ragel6/mlftable.cpp +++ b/contrib/tools/ragel6/mlftable.cpp @@ -1,462 +1,462 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "mlftable.h" -#include "redfsm.h" -#include "gendata.h" - -/* Determine if we should use indicies or not. */ -void OCamlFTabCodeGen::calcIndexSize() -{ - int sizeWithInds = 0, sizeWithoutInds = 0; - - /* Calculate cost of using with indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; - } - sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); - if ( redFsm->anyActions() ) - sizeWithInds += arrayTypeSize(redFsm->maxActListId) * redFsm->transSet.length(); - - /* Calculate the cost of not using indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; - if ( redFsm->anyActions() ) - sizeWithoutInds += arrayTypeSize(redFsm->maxActListId) * totalIndex; - } - - /* If using indicies reduces the size, use them. */ - useIndicies = sizeWithInds < sizeWithoutInds; -} - -std::ostream &OCamlFTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &OCamlFTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->actListId+1; - out << act; - return out; -} - -std::ostream &OCamlFTabCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->actListId+1; - out << act; - return out; -} - - -/* Write out the function for a transition. */ -std::ostream &OCamlFTabCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - int action = 0; - if ( trans->action != 0 ) - action = trans->action->actListId+1; - out << action; - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFTabCodeGen::TO_STATE_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numToStateRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFTabCodeGen::FROM_STATE_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numFromStateRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlFTabCodeGen::EOF_ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numEofRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, true ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -/* Write out the function switch. This switch is keyed on the values - * of the func index. */ -std::ostream &OCamlFTabCodeGen::ACTION_SWITCH() -{ - /* Loop the actions. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - /* Write the entry label. */ - out << "\t| " << redAct->actListId+1 << " ->\n"; - - /* Write each action in the list of action items. */ - for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) - ACTION( out, item->value, 0, false ); - - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -void OCamlFTabCodeGen::writeData() -{ - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); - COND_OFFSETS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); - COND_LENS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); - COND_SPACES(); - CLOSE_ARRAY() << - "\n"; - } - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); - KEY_OFFSETS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); - SINGLE_LENS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); - RANGE_LENS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); - INDEX_OFFSETS(); - CLOSE_ARRAY() << - "\n"; - - if ( useIndicies ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS_WI(); - CLOSE_ARRAY() << - "\n"; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); - TRANS_ACTIONS_WI(); - CLOSE_ARRAY() << - "\n"; - } - } - else { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - "\n"; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - "\n"; - } - - STATE_IDS(); - - out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; }" - << TOP_SEP(); - - out << "exception Goto_match" << TOP_SEP(); - out << "exception Goto_again" << TOP_SEP(); - out << "exception Goto_eof_trans" << TOP_SEP(); -} - -void OCamlFTabCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - initVarTypes(); - - out << - " begin\n"; - -// if ( redFsm->anyRegCurStateRef() ) -// out << klenType ", _ps"; - - out << - " let state = { keys = 0; trans = 0; } in\n" - " let rec do_start () =\n"; - -// if ( redFsm->anyConditions() ) -// out << " " << WIDE_ALPH_TYPE() << " _widec;\n"; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " = " << PE() << " then\n" - " do_test_eof ()\n" - "\telse\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " = " << redFsm->errState->id << " then\n" - " do_out ()\n" - "\telse\n"; - } - out << "\tdo_resume ()\n"; - - out << "and do_resume () =\n"; - - if ( redFsm->anyFromStateActions() ) { - out << - " begin match " << AT( FSA(), vCS() ) << " with\n"; - FROM_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - "\n"; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - out << "\tbegin try\n"; - LOCATE_TRANS(); - out << "\twith Goto_match -> () end;\n"; - + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "mlftable.h" +#include "redfsm.h" +#include "gendata.h" + +/* Determine if we should use indicies or not. */ +void OCamlFTabCodeGen::calcIndexSize() +{ + int sizeWithInds = 0, sizeWithoutInds = 0; + + /* Calculate cost of using with indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; + } + sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); + if ( redFsm->anyActions() ) + sizeWithInds += arrayTypeSize(redFsm->maxActListId) * redFsm->transSet.length(); + + /* Calculate the cost of not using indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; + if ( redFsm->anyActions() ) + sizeWithoutInds += arrayTypeSize(redFsm->maxActListId) * totalIndex; + } + + /* If using indicies reduces the size, use them. */ + useIndicies = sizeWithInds < sizeWithoutInds; +} + +std::ostream &OCamlFTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &OCamlFTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->actListId+1; + out << act; + return out; +} + +std::ostream &OCamlFTabCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->actListId+1; + out << act; + return out; +} + + +/* Write out the function for a transition. */ +std::ostream &OCamlFTabCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + int action = 0; + if ( trans->action != 0 ) + action = trans->action->actListId+1; + out << action; + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFTabCodeGen::TO_STATE_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numToStateRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFTabCodeGen::FROM_STATE_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numFromStateRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlFTabCodeGen::EOF_ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numEofRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, true ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +/* Write out the function switch. This switch is keyed on the values + * of the func index. */ +std::ostream &OCamlFTabCodeGen::ACTION_SWITCH() +{ + /* Loop the actions. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + /* Write the entry label. */ + out << "\t| " << redAct->actListId+1 << " ->\n"; + + /* Write each action in the list of action items. */ + for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) + ACTION( out, item->value, 0, false ); + + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +void OCamlFTabCodeGen::writeData() +{ + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); + COND_OFFSETS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); + COND_LENS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); + COND_SPACES(); + CLOSE_ARRAY() << + "\n"; + } + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); + KEY_OFFSETS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); + SINGLE_LENS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); + RANGE_LENS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); + INDEX_OFFSETS(); + CLOSE_ARRAY() << + "\n"; + + if ( useIndicies ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS_WI(); + CLOSE_ARRAY() << + "\n"; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); + TRANS_ACTIONS_WI(); + CLOSE_ARRAY() << + "\n"; + } + } + else { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + "\n"; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + + STATE_IDS(); + + out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; }" + << TOP_SEP(); + + out << "exception Goto_match" << TOP_SEP(); + out << "exception Goto_again" << TOP_SEP(); + out << "exception Goto_eof_trans" << TOP_SEP(); +} + +void OCamlFTabCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + initVarTypes(); + + out << + " begin\n"; + +// if ( redFsm->anyRegCurStateRef() ) +// out << klenType ", _ps"; + out << - "\tdo_match ()\n"; - - out << "and do_match () =\n"; - - if ( useIndicies ) - out << " state.trans <- " << CAST(transType) << AT( I(), "state.trans" ) << ";\n"; - - out << "\tdo_eof_trans ()\n"; - -// if ( redFsm->anyEofTrans() ) - out << "and do_eof_trans () =\n"; - - if ( redFsm->anyRegCurStateRef() ) - out << " let ps = " << vCS() << " in\n"; - - out << - " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" - "\n"; - - if ( redFsm->anyRegActions() ) { - out << - " begin try if " << AT( TA() , "state.trans" ) << " = 0 then\n" - " raise Goto_again;\n" - "\n" - " match " << AT( TA(), "state.trans" ) << " with\n"; - ACTION_SWITCH(); - SWITCH_DEFAULT() << - " with Goto_again -> () end;\n" - "\n"; - } - out << "\tdo_again ()\n"; - -// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || -// redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "\tand do_again () =\n"; - - if ( redFsm->anyToStateActions() ) { - out << - " begin match " << AT( TSA(), vCS() ) << " with\n"; - TO_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - "\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; + " let state = { keys = 0; trans = 0; } in\n" + " let rec do_start () =\n"; + +// if ( redFsm->anyConditions() ) +// out << " " << WIDE_ALPH_TYPE() << " _widec;\n"; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " = " << PE() << " then\n" + " do_test_eof ()\n" + "\telse\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " = " << redFsm->errState->id << " then\n" + " do_out ()\n" + "\telse\n"; + } + out << "\tdo_resume ()\n"; + + out << "and do_resume () =\n"; + + if ( redFsm->anyFromStateActions() ) { out << - " match " << vCS() << " with\n" - "\t| " << redFsm->errState->id << " -> do_out ()\n" - "\t| _ ->\n"; - } - - out << "\t" << P() << " <- " << P() << " + 1;\n"; - - if ( !noEnd ) { - out << - " if " << P() << " <> " << PE() << " then\n" - " do_resume ()\n" - "\telse do_test_eof ()\n"; - } - else { - out << - " do_resume ()\n"; - } - -// if ( testEofUsed ) - out << "and do_test_eof () =\n"; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { - out << - " if " << P() << " = " << vEOF() << " then\n" - " begin try\n"; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << AT( ET(), vCS() ) << " > 0 then\n" - " begin\n" - " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" - " raise Goto_eof_trans;\n" - " end;\n"; - } - - if ( redFsm->anyEofActions() ) { - out << - " begin match " << AT( EA(), vCS() ) << " with\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n"; - } - + " begin match " << AT( FSA(), vCS() ) << " with\n"; + FROM_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + "\n"; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + out << "\tbegin try\n"; + LOCATE_TRANS(); + out << "\twith Goto_match -> () end;\n"; + + out << + "\tdo_match ()\n"; + + out << "and do_match () =\n"; + + if ( useIndicies ) + out << " state.trans <- " << CAST(transType) << AT( I(), "state.trans" ) << ";\n"; + + out << "\tdo_eof_trans ()\n"; + +// if ( redFsm->anyEofTrans() ) + out << "and do_eof_trans () =\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " let ps = " << vCS() << " in\n"; + + out << + " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" + "\n"; + + if ( redFsm->anyRegActions() ) { + out << + " begin try if " << AT( TA() , "state.trans" ) << " = 0 then\n" + " raise Goto_again;\n" + "\n" + " match " << AT( TA(), "state.trans" ) << " with\n"; + ACTION_SWITCH(); + SWITCH_DEFAULT() << + " with Goto_again -> () end;\n" + "\n"; + } + out << "\tdo_again ()\n"; + +// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || +// redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "\tand do_again () =\n"; + + if ( redFsm->anyToStateActions() ) { out << - " with Goto_again -> do_again ()\n" - " | Goto_eof_trans -> do_eof_trans () end\n" - "\n"; - } - else - { - out << "\t()\n"; - } - - if ( outLabelUsed ) - out << " and do_out () = ()\n"; - - out << "\tin do_start ()\n"; - out << " end;\n"; -} - + " begin match " << AT( TSA(), vCS() ) << " with\n"; + TO_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + "\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " match " << vCS() << " with\n" + "\t| " << redFsm->errState->id << " -> do_out ()\n" + "\t| _ ->\n"; + } + + out << "\t" << P() << " <- " << P() << " + 1;\n"; + + if ( !noEnd ) { + out << + " if " << P() << " <> " << PE() << " then\n" + " do_resume ()\n" + "\telse do_test_eof ()\n"; + } + else { + out << + " do_resume ()\n"; + } + +// if ( testEofUsed ) + out << "and do_test_eof () =\n"; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " = " << vEOF() << " then\n" + " begin try\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << AT( ET(), vCS() ) << " > 0 then\n" + " begin\n" + " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" + " raise Goto_eof_trans;\n" + " end;\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " begin match " << AT( EA(), vCS() ) << " with\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n"; + } + + out << + " with Goto_again -> do_again ()\n" + " | Goto_eof_trans -> do_eof_trans () end\n" + "\n"; + } + else + { + out << "\t()\n"; + } + + if ( outLabelUsed ) + out << " and do_out () = ()\n"; + + out << "\tin do_start ()\n"; + out << " end;\n"; +} + diff --git a/contrib/tools/ragel6/mlftable.h b/contrib/tools/ragel6/mlftable.h index da88e849fe..91fd452f58 100644 --- a/contrib/tools/ragel6/mlftable.h +++ b/contrib/tools/ragel6/mlftable.h @@ -1,56 +1,56 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MLFTABLE_H -#define _MLFTABLE_H - -#include <iostream> -#include "mltable.h" - -/* Forwards. */ -//struct CodeGenData; - - -/* - * OCamlFTabCodeGen - */ -class OCamlFTabCodeGen : public OCamlTabCodeGen -{ -public: - OCamlFTabCodeGen( ostream &out ) : OCamlTabCodeGen(out) {} -private: - std::ostream &TO_STATE_ACTION_SWITCH(); - std::ostream &FROM_STATE_ACTION_SWITCH(); - std::ostream &EOF_ACTION_SWITCH(); - std::ostream &ACTION_SWITCH(); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - virtual void writeData(); - virtual void writeExec(); - virtual void calcIndexSize(); -}; - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MLFTABLE_H +#define _MLFTABLE_H + +#include <iostream> +#include "mltable.h" + +/* Forwards. */ +//struct CodeGenData; + + +/* + * OCamlFTabCodeGen + */ +class OCamlFTabCodeGen : public OCamlTabCodeGen +{ +public: + OCamlFTabCodeGen( ostream &out ) : OCamlTabCodeGen(out) {} +private: + std::ostream &TO_STATE_ACTION_SWITCH(); + std::ostream &FROM_STATE_ACTION_SWITCH(); + std::ostream &EOF_ACTION_SWITCH(); + std::ostream &ACTION_SWITCH(); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + virtual void writeData(); + virtual void writeExec(); + virtual void calcIndexSize(); +}; + +#endif diff --git a/contrib/tools/ragel6/mlgoto.cpp b/contrib/tools/ragel6/mlgoto.cpp index 65570d8d86..38608a5b68 100644 --- a/contrib/tools/ragel6/mlgoto.cpp +++ b/contrib/tools/ragel6/mlgoto.cpp @@ -1,821 +1,821 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "mlgoto.h" -#include "redfsm.h" -#include "bstmap.h" -#include "gendata.h" - -/* Emit the goto to take for a given transition. */ -std::ostream &OCamlGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level ) -{ - out << TABS(level) << "tr" << trans->id << " ()"; - return out; -} - -std::ostream &OCamlGotoCodeGen::TO_STATE_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numToStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlGotoCodeGen::FROM_STATE_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numFromStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlGotoCodeGen::EOF_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numEofRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, true ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlGotoCodeGen::ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numTransRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - out << "\t()\n"; - } - } - - genLineDirective( out ); - return out; -} - -void OCamlGotoCodeGen::GOTO_HEADER( RedStateAp *state ) -{ - /* Label the state. */ - out << "| " << state->id << " ->\n"; -} - - -void OCamlGotoCodeGen::emitSingleSwitch( RedStateAp *state ) -{ - /* Load up the singles. */ - int numSingles = state->outSingle.length(); - RedTransEl *data = state->outSingle.data; - - if ( numSingles == 1 ) { - /* If there is a single single key then write it out as an if. */ - out << "\tif " << GET_WIDE_KEY(state) << " = " << - KEY(data[0].lowKey) << " then\n\t\t"; - - /* Virtual function for writing the target of the transition. */ - TRANS_GOTO(data[0].value, 0) << " else\n"; - } - else if ( numSingles > 1 ) { - /* Write out single keys in a switch if there is more than one. */ - out << "\tmatch " << GET_WIDE_KEY(state) << " with\n"; - - /* Write out the single indicies. */ - for ( int j = 0; j < numSingles; j++ ) { - out << "\t\t| " << ALPHA_KEY(data[j].lowKey) << " -> "; - TRANS_GOTO(data[j].value, 0) << "\n"; - } - - out << "\t\t| _ ->\n"; - } -} - -void OCamlGotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int high, RedTransAp* def) -{ - /* Get the mid position, staying on the lower end of the range. */ - int mid = (low + high) >> 1; - RedTransEl *data = state->outRange.data; - - /* Determine if we need to look higher or lower. */ - bool anyLower = mid > low; - bool anyHigher = mid < high; - - /* Determine if the keys at mid are the limits of the alphabet. */ - bool limitLow = data[mid].lowKey == keyOps->minKey; - bool limitHigh = data[mid].highKey == keyOps->maxKey; - - if ( anyLower && anyHigher ) { - /* Can go lower and higher than mid. */ - out << TABS(level) << "if " << GET_WIDE_KEY(state) << " < " << - KEY(data[mid].lowKey) << " then begin\n"; - emitRangeBSearch( state, level+1, low, mid-1, def ); - out << TABS(level) << " end else if " << GET_WIDE_KEY(state) << " > " << - KEY(data[mid].highKey) << " then begin\n"; - emitRangeBSearch( state, level+1, mid+1, high, def ); - out << TABS(level) << " end else\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n"; - } - else if ( anyLower && !anyHigher ) { - /* Can go lower than mid but not higher. */ - out << TABS(level) << "if " << GET_WIDE_KEY(state) << " < " << - KEY(data[mid].lowKey) << " then begin\n"; - emitRangeBSearch( state, level+1, low, mid-1, def ); - - /* if the higher is the highest in the alphabet then there is no - * sense testing it. */ - if ( limitHigh ) { - out << TABS(level) << " end else\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n"; - } - else { - out << TABS(level) << " end else if " << GET_WIDE_KEY(state) << " <= " << - KEY(data[mid].highKey) << " then\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; - TRANS_GOTO(def, level+1) << "\n"; - } - } - else if ( !anyLower && anyHigher ) { - /* Can go higher than mid but not lower. */ - out << TABS(level) << "if " << GET_WIDE_KEY(state) << " > " << - KEY(data[mid].highKey) << " then begin\n"; - emitRangeBSearch( state, level+1, mid+1, high, def ); - - /* If the lower end is the lowest in the alphabet then there is no - * sense testing it. */ - if ( limitLow ) { - out << TABS(level) << " end else\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n"; - } - else { - out << TABS(level) << " end else if " << GET_WIDE_KEY(state) << " >= " << - KEY(data[mid].lowKey) << " then\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; - TRANS_GOTO(def, level+1) << "\n"; - } - } - else { - /* Cannot go higher or lower than mid. It's mid or bust. What - * tests to do depends on limits of alphabet. */ - if ( !limitLow && !limitHigh ) { - out << TABS(level) << "if " << KEY(data[mid].lowKey) << " <= " << - GET_WIDE_KEY(state) << " && " << GET_WIDE_KEY(state) << " <= " << - KEY(data[mid].highKey) << " then\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; - TRANS_GOTO(def, level+1) << "\n"; - } - else if ( limitLow && !limitHigh ) { - out << TABS(level) << "if " << GET_WIDE_KEY(state) << " <= " << - KEY(data[mid].highKey) << " then\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; - TRANS_GOTO(def, level+1) << "\n"; - } - else if ( !limitLow && limitHigh ) { - out << TABS(level) << "if " << KEY(data[mid].lowKey) << " <= " << - GET_WIDE_KEY(state) << " then\n"; - TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; - TRANS_GOTO(def, level+1) << "\n"; - } - else { - /* Both high and low are at the limit. No tests to do. */ - TRANS_GOTO(data[mid].value, level+1) << "\n"; - } - } -} - -void OCamlGotoCodeGen::STATE_GOTO_ERROR() -{ - /* Label the state and bail immediately. */ - outLabelUsed = true; - RedStateAp *state = redFsm->errState; - out << "| " << state->id << " ->\n"; - out << " do_out ()\n"; -} - -void OCamlGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level ) -{ - GenCondSpace *condSpace = stateCond->condSpace; - out << TABS(level) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << - KEY(condSpace->baseKey) << " + (" << GET_KEY() << - " - " << KEY(keyOps->minKey) << "));\n"; - - for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { - out << TABS(level) << "if ( "; - CONDITION( out, *csi ); - Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); - out << " ) _widec += " << condValOffset << ";\n"; - } -} - -void OCamlGotoCodeGen::emitCondBSearch( RedStateAp *state, int level, int low, int high ) -{ - /* Get the mid position, staying on the lower end of the range. */ - int mid = (low + high) >> 1; - GenStateCond **data = state->stateCondVect.data; - - /* Determine if we need to look higher or lower. */ - bool anyLower = mid > low; - bool anyHigher = mid < high; - - /* Determine if the keys at mid are the limits of the alphabet. */ - bool limitLow = data[mid]->lowKey == keyOps->minKey; - bool limitHigh = data[mid]->highKey == keyOps->maxKey; - - if ( anyLower && anyHigher ) { - /* Can go lower and higher than mid. */ - out << TABS(level) << "if ( " << GET_KEY() << " < " << - KEY(data[mid]->lowKey) << " ) {\n"; - emitCondBSearch( state, level+1, low, mid-1 ); - out << TABS(level) << "} else if ( " << GET_KEY() << " > " << - KEY(data[mid]->highKey) << " ) {\n"; - emitCondBSearch( state, level+1, mid+1, high ); - out << TABS(level) << "} else {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - else if ( anyLower && !anyHigher ) { - /* Can go lower than mid but not higher. */ - out << TABS(level) << "if ( " << GET_KEY() << " < " << - KEY(data[mid]->lowKey) << " ) {\n"; - emitCondBSearch( state, level+1, low, mid-1 ); - - /* if the higher is the highest in the alphabet then there is no - * sense testing it. */ - if ( limitHigh ) { - out << TABS(level) << "} else {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - else { - out << TABS(level) << "} else if ( " << GET_KEY() << " <= " << - KEY(data[mid]->highKey) << " ) {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - } - else if ( !anyLower && anyHigher ) { - /* Can go higher than mid but not lower. */ - out << TABS(level) << "if ( " << GET_KEY() << " > " << - KEY(data[mid]->highKey) << " ) {\n"; - emitCondBSearch( state, level+1, mid+1, high ); - - /* If the lower end is the lowest in the alphabet then there is no - * sense testing it. */ - if ( limitLow ) { - out << TABS(level) << "} else {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - else { - out << TABS(level) << "} else if ( " << GET_KEY() << " >= " << - KEY(data[mid]->lowKey) << " ) {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - } - else { - /* Cannot go higher or lower than mid. It's mid or bust. What - * tests to do depends on limits of alphabet. */ - if ( !limitLow && !limitHigh ) { - out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " << - GET_KEY() << " && " << GET_KEY() << " <= " << - KEY(data[mid]->highKey) << " ) {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - else if ( limitLow && !limitHigh ) { - out << TABS(level) << "if ( " << GET_KEY() << " <= " << - KEY(data[mid]->highKey) << " ) {\n"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - else if ( !limitLow && limitHigh ) { - out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " << - GET_KEY() << " )\n {"; - COND_TRANSLATE(data[mid], level+1); - out << TABS(level) << "}\n"; - } - else { - /* Both high and low are at the limit. No tests to do. */ - COND_TRANSLATE(data[mid], level); - } - } -} - -std::ostream &OCamlGotoCodeGen::STATE_GOTOS() -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st == redFsm->errState ) - STATE_GOTO_ERROR(); - else { - /* Writing code above state gotos. */ - GOTO_HEADER( st ); - out << "\tbegin\n"; - - if ( st->stateCondVect.length() > 0 ) { - out << " _widec = " << GET_KEY() << ";\n"; - emitCondBSearch( st, 1, 0, st->stateCondVect.length() - 1 ); - } - - /* Try singles. */ - if ( st->outSingle.length() > 0 ) - emitSingleSwitch( st ); - - /* Default case is to binary search for the ranges, if that fails then */ - if ( st->outRange.length() > 0 ) - emitRangeBSearch( st, 1, 0, st->outRange.length() - 1, st->defTrans ); - else - /* Write the default transition. */ - TRANS_GOTO( st->defTrans, 1 ) << "\n"; - - out << "\tend\n"; - } - } - return out; -} - -std::ostream &OCamlGotoCodeGen::TRANSITIONS() -{ - /* Emit any transitions that have functions and that go to - * this state. */ - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) { - /* Write the label for the transition so it can be jumped to. */ - out << " and tr" << trans->id << " () = "; - - /* Destination state. */ - if ( trans->action != 0 && trans->action->anyCurStateRef() ) - out << "_ps = " << vCS() << ";"; - out << vCS() << " <- " << trans->targ->id << "; "; - - if ( trans->action != 0 ) { - /* Write out the transition func. */ - out << "f" << trans->action->actListId << " ()\n"; - } - else { - /* No code to execute, just loop around. */ - out << "do_again ()\n"; - } - } - return out; -} - -std::ostream &OCamlGotoCodeGen::EXEC_FUNCS() -{ - /* Make labels that set acts and jump to execFuncs. Loop func indicies. */ - for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { - if ( redAct->numTransRefs > 0 ) { - out << " and f" << redAct->actListId << " () = " << - "state.acts <- " << itoa( redAct->location+1 ) << "; " - "execFuncs ()\n"; - } - } - - out << - "\n" - "and execFuncs () =\n" - " state.nacts <- " << AT( A(), POST_INCR( "state.acts") ) << ";\n" - " begin try while " << POST_DECR("state.nacts") << " > 0 do\n" - " match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - ACTION_SWITCH(); - SWITCH_DEFAULT() << - " done with Goto_again -> () end;\n" - " do_again ()\n"; - return out; -} - -unsigned int OCamlGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->location+1; - return act; -} - -unsigned int OCamlGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->location+1; - return act; -} - -unsigned int OCamlGotoCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->location+1; - return act; -} - -std::ostream &OCamlGotoCodeGen::TO_STATE_ACTIONS() -{ - /* Take one off for the psuedo start state. */ - int numStates = redFsm->stateList.length(); - unsigned int *vals = new unsigned int[numStates]; - memset( vals, 0, sizeof(unsigned int)*numStates ); - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - vals[st->id] = TO_STATE_ACTION(st); - - out << "\t"; - for ( int st = 0; st < redFsm->nextStateId; st++ ) { - /* Write any eof action. */ - out << vals[st]; - if ( st < numStates-1 ) { - out << ARR_SEP(); - if ( (st+1) % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] vals; - return out; -} - -std::ostream &OCamlGotoCodeGen::FROM_STATE_ACTIONS() -{ - /* Take one off for the psuedo start state. */ - int numStates = redFsm->stateList.length(); - unsigned int *vals = new unsigned int[numStates]; - memset( vals, 0, sizeof(unsigned int)*numStates ); - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - vals[st->id] = FROM_STATE_ACTION(st); - - out << "\t"; - for ( int st = 0; st < redFsm->nextStateId; st++ ) { - /* Write any eof action. */ - out << vals[st]; - if ( st < numStates-1 ) { - out << ARR_SEP(); - if ( (st+1) % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] vals; - return out; -} - -std::ostream &OCamlGotoCodeGen::EOF_ACTIONS() -{ - /* Take one off for the psuedo start state. */ - int numStates = redFsm->stateList.length(); - unsigned int *vals = new unsigned int[numStates]; - memset( vals, 0, sizeof(unsigned int)*numStates ); - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) - vals[st->id] = EOF_ACTION(st); - - out << "\t"; - for ( int st = 0; st < redFsm->nextStateId; st++ ) { - /* Write any eof action. */ - out << vals[st]; - if ( st < numStates-1 ) { - out << ARR_SEP(); - if ( (st+1) % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] vals; - return out; -} - -std::ostream &OCamlGotoCodeGen::FINISH_CASES() -{ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* States that are final and have an out action need a case. */ - if ( st->eofAction != 0 ) { - /* Write the case label. */ - out << "\t\t| " << st->id << " -> "; - - /* Write the goto func. */ - out << "f" << st->eofAction->actListId << " ()\n"; - } - } - - return out; -} - -void OCamlGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) -{ - ret << "begin " << vCS() << " <- " << gotoDest << "; " << - CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << "begin " << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << "); " << CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlGotoCodeGen::CURS( ostream &ret, bool inFinish ) -{ - ret << "(_ps)"; -} - -void OCamlGotoCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) -{ - ret << "(" << vCS() << ")"; -} - -void OCamlGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) -{ - ret << vCS() << " <- " << nextDest << ";"; -} - -void OCamlGotoCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << ");"; -} - -void OCamlGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, prePushExpr, 0, false ); - } - - ret << "begin " << AT( STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; "; - ret << vCS() << " <- " << callDest << "; " << CTRL_FLOW() << "raise Goto_again end "; - - if ( prePushExpr != 0 ) - ret << "end"; -} - -void OCamlGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, prePushExpr, 0, false ); - } - - ret << "begin " << AT(STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; " << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, targState, inFinish ); - ret << "); " << CTRL_FLOW() << "raise Goto_again end "; - - if ( prePushExpr != 0 ) - ret << "end"; -} - -void OCamlGotoCodeGen::RET( ostream &ret, bool inFinish ) -{ - ret << "begin " << vCS() << " <- " << AT(STACK(), PRE_DECR(TOP()) ) << "; "; - - if ( postPopExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, postPopExpr, 0, false ); - ret << "end "; - } - - ret << CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlGotoCodeGen::BREAK( ostream &ret, int targState ) -{ - outLabelUsed = true; - ret << "begin " << P() << " <- " << P() << " + 1; " << CTRL_FLOW() << "raise Goto_out end"; -} - -void OCamlGotoCodeGen::writeData() -{ - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); - ACTIONS_ARRAY(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - STATE_IDS(); - - out << "type " << TYPE_STATE() << " = { mutable acts : " << ARRAY_TYPE(redFsm->maxActionLoc) << - " ; mutable nacts : " << ARRAY_TYPE(redFsm->maxActArrItem) << "; }" - << TOP_SEP(); - - out << "exception Goto_again" << TOP_SEP(); -} - -void OCamlGotoCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - - out << " begin\n"; - -// if ( redFsm->anyRegCurStateRef() ) -// out << " int _ps = 0;\n"; - - if ( redFsm->anyToStateActions() || redFsm->anyRegActions() - || redFsm->anyFromStateActions() ) - { - out << " let state = { acts = 0; nacts = 0; } in\n"; - } - -// if ( redFsm->anyConditions() ) -// out << " " << WIDE_ALPH_TYPE() << " _widec;\n"; - - out << "\n"; - out << " let rec do_start () =\n"; - - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " = " << PE() << " then\n" - " do_test_eof ()\n" - "\telse\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " = " << redFsm->errState->id << " then\n" - " do_out ()\n" - "\telse\n"; - } - out << "\tdo_resume ()\n"; - - out << "and do_resume () =\n"; - - if ( redFsm->anyFromStateActions() ) { - out << - " state.acts <- " << AT( FSA(), vCS() ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - FROM_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n" - " done;\n" - "\n"; - } - - out << - " begin match " << vCS() << " with\n"; - STATE_GOTOS(); - SWITCH_DEFAULT() << - " end\n" - "\n"; - TRANSITIONS() << - "\n"; - - if ( redFsm->anyRegActions() ) - EXEC_FUNCS() << "\n"; - -// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || -// redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "\tand do_again () =\n"; - - if ( redFsm->anyToStateActions() ) { - out << - " state.acts <- " << AT( TSA(), vCS() ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - TO_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n" - " done;\n" - "\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " match " << vCS() << " with\n" - "\t| " << redFsm->errState->id << " -> do_out ()\n" - "\t| _ ->\n"; - } - - out << "\t" << P() << " <- " << P() << " + 1;\n"; - - if ( !noEnd ) { + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "mlgoto.h" +#include "redfsm.h" +#include "bstmap.h" +#include "gendata.h" + +/* Emit the goto to take for a given transition. */ +std::ostream &OCamlGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level ) +{ + out << TABS(level) << "tr" << trans->id << " ()"; + return out; +} + +std::ostream &OCamlGotoCodeGen::TO_STATE_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numToStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlGotoCodeGen::FROM_STATE_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numFromStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlGotoCodeGen::EOF_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numEofRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, true ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlGotoCodeGen::ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numTransRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + out << "\t()\n"; + } + } + + genLineDirective( out ); + return out; +} + +void OCamlGotoCodeGen::GOTO_HEADER( RedStateAp *state ) +{ + /* Label the state. */ + out << "| " << state->id << " ->\n"; +} + + +void OCamlGotoCodeGen::emitSingleSwitch( RedStateAp *state ) +{ + /* Load up the singles. */ + int numSingles = state->outSingle.length(); + RedTransEl *data = state->outSingle.data; + + if ( numSingles == 1 ) { + /* If there is a single single key then write it out as an if. */ + out << "\tif " << GET_WIDE_KEY(state) << " = " << + KEY(data[0].lowKey) << " then\n\t\t"; + + /* Virtual function for writing the target of the transition. */ + TRANS_GOTO(data[0].value, 0) << " else\n"; + } + else if ( numSingles > 1 ) { + /* Write out single keys in a switch if there is more than one. */ + out << "\tmatch " << GET_WIDE_KEY(state) << " with\n"; + + /* Write out the single indicies. */ + for ( int j = 0; j < numSingles; j++ ) { + out << "\t\t| " << ALPHA_KEY(data[j].lowKey) << " -> "; + TRANS_GOTO(data[j].value, 0) << "\n"; + } + + out << "\t\t| _ ->\n"; + } +} + +void OCamlGotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int high, RedTransAp* def) +{ + /* Get the mid position, staying on the lower end of the range. */ + int mid = (low + high) >> 1; + RedTransEl *data = state->outRange.data; + + /* Determine if we need to look higher or lower. */ + bool anyLower = mid > low; + bool anyHigher = mid < high; + + /* Determine if the keys at mid are the limits of the alphabet. */ + bool limitLow = data[mid].lowKey == keyOps->minKey; + bool limitHigh = data[mid].highKey == keyOps->maxKey; + + if ( anyLower && anyHigher ) { + /* Can go lower and higher than mid. */ + out << TABS(level) << "if " << GET_WIDE_KEY(state) << " < " << + KEY(data[mid].lowKey) << " then begin\n"; + emitRangeBSearch( state, level+1, low, mid-1, def ); + out << TABS(level) << " end else if " << GET_WIDE_KEY(state) << " > " << + KEY(data[mid].highKey) << " then begin\n"; + emitRangeBSearch( state, level+1, mid+1, high, def ); + out << TABS(level) << " end else\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n"; + } + else if ( anyLower && !anyHigher ) { + /* Can go lower than mid but not higher. */ + out << TABS(level) << "if " << GET_WIDE_KEY(state) << " < " << + KEY(data[mid].lowKey) << " then begin\n"; + emitRangeBSearch( state, level+1, low, mid-1, def ); + + /* if the higher is the highest in the alphabet then there is no + * sense testing it. */ + if ( limitHigh ) { + out << TABS(level) << " end else\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n"; + } + else { + out << TABS(level) << " end else if " << GET_WIDE_KEY(state) << " <= " << + KEY(data[mid].highKey) << " then\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; + TRANS_GOTO(def, level+1) << "\n"; + } + } + else if ( !anyLower && anyHigher ) { + /* Can go higher than mid but not lower. */ + out << TABS(level) << "if " << GET_WIDE_KEY(state) << " > " << + KEY(data[mid].highKey) << " then begin\n"; + emitRangeBSearch( state, level+1, mid+1, high, def ); + + /* If the lower end is the lowest in the alphabet then there is no + * sense testing it. */ + if ( limitLow ) { + out << TABS(level) << " end else\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n"; + } + else { + out << TABS(level) << " end else if " << GET_WIDE_KEY(state) << " >= " << + KEY(data[mid].lowKey) << " then\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; + TRANS_GOTO(def, level+1) << "\n"; + } + } + else { + /* Cannot go higher or lower than mid. It's mid or bust. What + * tests to do depends on limits of alphabet. */ + if ( !limitLow && !limitHigh ) { + out << TABS(level) << "if " << KEY(data[mid].lowKey) << " <= " << + GET_WIDE_KEY(state) << " && " << GET_WIDE_KEY(state) << " <= " << + KEY(data[mid].highKey) << " then\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; + TRANS_GOTO(def, level+1) << "\n"; + } + else if ( limitLow && !limitHigh ) { + out << TABS(level) << "if " << GET_WIDE_KEY(state) << " <= " << + KEY(data[mid].highKey) << " then\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; + TRANS_GOTO(def, level+1) << "\n"; + } + else if ( !limitLow && limitHigh ) { + out << TABS(level) << "if " << KEY(data[mid].lowKey) << " <= " << + GET_WIDE_KEY(state) << " then\n"; + TRANS_GOTO(data[mid].value, level+1) << "\n" << TABS(level) << "else\n"; + TRANS_GOTO(def, level+1) << "\n"; + } + else { + /* Both high and low are at the limit. No tests to do. */ + TRANS_GOTO(data[mid].value, level+1) << "\n"; + } + } +} + +void OCamlGotoCodeGen::STATE_GOTO_ERROR() +{ + /* Label the state and bail immediately. */ + outLabelUsed = true; + RedStateAp *state = redFsm->errState; + out << "| " << state->id << " ->\n"; + out << " do_out ()\n"; +} + +void OCamlGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level ) +{ + GenCondSpace *condSpace = stateCond->condSpace; + out << TABS(level) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << + KEY(condSpace->baseKey) << " + (" << GET_KEY() << + " - " << KEY(keyOps->minKey) << "));\n"; + + for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { + out << TABS(level) << "if ( "; + CONDITION( out, *csi ); + Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); + out << " ) _widec += " << condValOffset << ";\n"; + } +} + +void OCamlGotoCodeGen::emitCondBSearch( RedStateAp *state, int level, int low, int high ) +{ + /* Get the mid position, staying on the lower end of the range. */ + int mid = (low + high) >> 1; + GenStateCond **data = state->stateCondVect.data; + + /* Determine if we need to look higher or lower. */ + bool anyLower = mid > low; + bool anyHigher = mid < high; + + /* Determine if the keys at mid are the limits of the alphabet. */ + bool limitLow = data[mid]->lowKey == keyOps->minKey; + bool limitHigh = data[mid]->highKey == keyOps->maxKey; + + if ( anyLower && anyHigher ) { + /* Can go lower and higher than mid. */ + out << TABS(level) << "if ( " << GET_KEY() << " < " << + KEY(data[mid]->lowKey) << " ) {\n"; + emitCondBSearch( state, level+1, low, mid-1 ); + out << TABS(level) << "} else if ( " << GET_KEY() << " > " << + KEY(data[mid]->highKey) << " ) {\n"; + emitCondBSearch( state, level+1, mid+1, high ); + out << TABS(level) << "} else {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + else if ( anyLower && !anyHigher ) { + /* Can go lower than mid but not higher. */ + out << TABS(level) << "if ( " << GET_KEY() << " < " << + KEY(data[mid]->lowKey) << " ) {\n"; + emitCondBSearch( state, level+1, low, mid-1 ); + + /* if the higher is the highest in the alphabet then there is no + * sense testing it. */ + if ( limitHigh ) { + out << TABS(level) << "} else {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + else { + out << TABS(level) << "} else if ( " << GET_KEY() << " <= " << + KEY(data[mid]->highKey) << " ) {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + } + else if ( !anyLower && anyHigher ) { + /* Can go higher than mid but not lower. */ + out << TABS(level) << "if ( " << GET_KEY() << " > " << + KEY(data[mid]->highKey) << " ) {\n"; + emitCondBSearch( state, level+1, mid+1, high ); + + /* If the lower end is the lowest in the alphabet then there is no + * sense testing it. */ + if ( limitLow ) { + out << TABS(level) << "} else {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + else { + out << TABS(level) << "} else if ( " << GET_KEY() << " >= " << + KEY(data[mid]->lowKey) << " ) {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + } + else { + /* Cannot go higher or lower than mid. It's mid or bust. What + * tests to do depends on limits of alphabet. */ + if ( !limitLow && !limitHigh ) { + out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " << + GET_KEY() << " && " << GET_KEY() << " <= " << + KEY(data[mid]->highKey) << " ) {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + else if ( limitLow && !limitHigh ) { + out << TABS(level) << "if ( " << GET_KEY() << " <= " << + KEY(data[mid]->highKey) << " ) {\n"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + else if ( !limitLow && limitHigh ) { + out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " << + GET_KEY() << " )\n {"; + COND_TRANSLATE(data[mid], level+1); + out << TABS(level) << "}\n"; + } + else { + /* Both high and low are at the limit. No tests to do. */ + COND_TRANSLATE(data[mid], level); + } + } +} + +std::ostream &OCamlGotoCodeGen::STATE_GOTOS() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st == redFsm->errState ) + STATE_GOTO_ERROR(); + else { + /* Writing code above state gotos. */ + GOTO_HEADER( st ); + out << "\tbegin\n"; + + if ( st->stateCondVect.length() > 0 ) { + out << " _widec = " << GET_KEY() << ";\n"; + emitCondBSearch( st, 1, 0, st->stateCondVect.length() - 1 ); + } + + /* Try singles. */ + if ( st->outSingle.length() > 0 ) + emitSingleSwitch( st ); + + /* Default case is to binary search for the ranges, if that fails then */ + if ( st->outRange.length() > 0 ) + emitRangeBSearch( st, 1, 0, st->outRange.length() - 1, st->defTrans ); + else + /* Write the default transition. */ + TRANS_GOTO( st->defTrans, 1 ) << "\n"; + + out << "\tend\n"; + } + } + return out; +} + +std::ostream &OCamlGotoCodeGen::TRANSITIONS() +{ + /* Emit any transitions that have functions and that go to + * this state. */ + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) { + /* Write the label for the transition so it can be jumped to. */ + out << " and tr" << trans->id << " () = "; + + /* Destination state. */ + if ( trans->action != 0 && trans->action->anyCurStateRef() ) + out << "_ps = " << vCS() << ";"; + out << vCS() << " <- " << trans->targ->id << "; "; + + if ( trans->action != 0 ) { + /* Write out the transition func. */ + out << "f" << trans->action->actListId << " ()\n"; + } + else { + /* No code to execute, just loop around. */ + out << "do_again ()\n"; + } + } + return out; +} + +std::ostream &OCamlGotoCodeGen::EXEC_FUNCS() +{ + /* Make labels that set acts and jump to execFuncs. Loop func indicies. */ + for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { + if ( redAct->numTransRefs > 0 ) { + out << " and f" << redAct->actListId << " () = " << + "state.acts <- " << itoa( redAct->location+1 ) << "; " + "execFuncs ()\n"; + } + } + + out << + "\n" + "and execFuncs () =\n" + " state.nacts <- " << AT( A(), POST_INCR( "state.acts") ) << ";\n" + " begin try while " << POST_DECR("state.nacts") << " > 0 do\n" + " match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + ACTION_SWITCH(); + SWITCH_DEFAULT() << + " done with Goto_again -> () end;\n" + " do_again ()\n"; + return out; +} + +unsigned int OCamlGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->location+1; + return act; +} + +unsigned int OCamlGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->location+1; + return act; +} + +unsigned int OCamlGotoCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->location+1; + return act; +} + +std::ostream &OCamlGotoCodeGen::TO_STATE_ACTIONS() +{ + /* Take one off for the psuedo start state. */ + int numStates = redFsm->stateList.length(); + unsigned int *vals = new unsigned int[numStates]; + memset( vals, 0, sizeof(unsigned int)*numStates ); + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + vals[st->id] = TO_STATE_ACTION(st); + + out << "\t"; + for ( int st = 0; st < redFsm->nextStateId; st++ ) { + /* Write any eof action. */ + out << vals[st]; + if ( st < numStates-1 ) { + out << ARR_SEP(); + if ( (st+1) % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] vals; + return out; +} + +std::ostream &OCamlGotoCodeGen::FROM_STATE_ACTIONS() +{ + /* Take one off for the psuedo start state. */ + int numStates = redFsm->stateList.length(); + unsigned int *vals = new unsigned int[numStates]; + memset( vals, 0, sizeof(unsigned int)*numStates ); + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + vals[st->id] = FROM_STATE_ACTION(st); + + out << "\t"; + for ( int st = 0; st < redFsm->nextStateId; st++ ) { + /* Write any eof action. */ + out << vals[st]; + if ( st < numStates-1 ) { + out << ARR_SEP(); + if ( (st+1) % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] vals; + return out; +} + +std::ostream &OCamlGotoCodeGen::EOF_ACTIONS() +{ + /* Take one off for the psuedo start state. */ + int numStates = redFsm->stateList.length(); + unsigned int *vals = new unsigned int[numStates]; + memset( vals, 0, sizeof(unsigned int)*numStates ); + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) + vals[st->id] = EOF_ACTION(st); + + out << "\t"; + for ( int st = 0; st < redFsm->nextStateId; st++ ) { + /* Write any eof action. */ + out << vals[st]; + if ( st < numStates-1 ) { + out << ARR_SEP(); + if ( (st+1) % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] vals; + return out; +} + +std::ostream &OCamlGotoCodeGen::FINISH_CASES() +{ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* States that are final and have an out action need a case. */ + if ( st->eofAction != 0 ) { + /* Write the case label. */ + out << "\t\t| " << st->id << " -> "; + + /* Write the goto func. */ + out << "f" << st->eofAction->actListId << " ()\n"; + } + } + + return out; +} + +void OCamlGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) +{ + ret << "begin " << vCS() << " <- " << gotoDest << "; " << + CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlGotoCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << "begin " << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish ); + ret << "); " << CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlGotoCodeGen::CURS( ostream &ret, bool inFinish ) +{ + ret << "(_ps)"; +} + +void OCamlGotoCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) +{ + ret << "(" << vCS() << ")"; +} + +void OCamlGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) +{ + ret << vCS() << " <- " << nextDest << ";"; +} + +void OCamlGotoCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish ); + ret << ");"; +} + +void OCamlGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, prePushExpr, 0, false ); + } + + ret << "begin " << AT( STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; "; + ret << vCS() << " <- " << callDest << "; " << CTRL_FLOW() << "raise Goto_again end "; + + if ( prePushExpr != 0 ) + ret << "end"; +} + +void OCamlGotoCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, prePushExpr, 0, false ); + } + + ret << "begin " << AT(STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; " << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, targState, inFinish ); + ret << "); " << CTRL_FLOW() << "raise Goto_again end "; + + if ( prePushExpr != 0 ) + ret << "end"; +} + +void OCamlGotoCodeGen::RET( ostream &ret, bool inFinish ) +{ + ret << "begin " << vCS() << " <- " << AT(STACK(), PRE_DECR(TOP()) ) << "; "; + + if ( postPopExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, postPopExpr, 0, false ); + ret << "end "; + } + + ret << CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlGotoCodeGen::BREAK( ostream &ret, int targState ) +{ + outLabelUsed = true; + ret << "begin " << P() << " <- " << P() << " + 1; " << CTRL_FLOW() << "raise Goto_out end"; +} + +void OCamlGotoCodeGen::writeData() +{ + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); + ACTIONS_ARRAY(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + STATE_IDS(); + + out << "type " << TYPE_STATE() << " = { mutable acts : " << ARRAY_TYPE(redFsm->maxActionLoc) << + " ; mutable nacts : " << ARRAY_TYPE(redFsm->maxActArrItem) << "; }" + << TOP_SEP(); + + out << "exception Goto_again" << TOP_SEP(); +} + +void OCamlGotoCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + + out << " begin\n"; + +// if ( redFsm->anyRegCurStateRef() ) +// out << " int _ps = 0;\n"; + + if ( redFsm->anyToStateActions() || redFsm->anyRegActions() + || redFsm->anyFromStateActions() ) + { + out << " let state = { acts = 0; nacts = 0; } in\n"; + } + +// if ( redFsm->anyConditions() ) +// out << " " << WIDE_ALPH_TYPE() << " _widec;\n"; + + out << "\n"; + out << " let rec do_start () =\n"; + + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " = " << PE() << " then\n" + " do_test_eof ()\n" + "\telse\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " = " << redFsm->errState->id << " then\n" + " do_out ()\n" + "\telse\n"; + } + out << "\tdo_resume ()\n"; + + out << "and do_resume () =\n"; + + if ( redFsm->anyFromStateActions() ) { out << - " if " << P() << " <> " << PE() << " then\n" - " do_resume ()\n" - "\telse do_test_eof ()\n"; - } - else { + " state.acts <- " << AT( FSA(), vCS() ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + FROM_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n" + " done;\n" + "\n"; + } + + out << + " begin match " << vCS() << " with\n"; + STATE_GOTOS(); + SWITCH_DEFAULT() << + " end\n" + "\n"; + TRANSITIONS() << + "\n"; + + if ( redFsm->anyRegActions() ) + EXEC_FUNCS() << "\n"; + +// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || +// redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "\tand do_again () =\n"; + + if ( redFsm->anyToStateActions() ) { out << - " do_resume ()\n"; - } - -// if ( testEofUsed ) - out << "and do_test_eof () =\n"; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + " state.acts <- " << AT( TSA(), vCS() ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + TO_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n" + " done;\n" + "\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " match " << vCS() << " with\n" + "\t| " << redFsm->errState->id << " -> do_out ()\n" + "\t| _ ->\n"; + } + + out << "\t" << P() << " <- " << P() << " + 1;\n"; + + if ( !noEnd ) { + out << + " if " << P() << " <> " << PE() << " then\n" + " do_resume ()\n" + "\telse do_test_eof ()\n"; + } + else { + out << + " do_resume ()\n"; + } + +// if ( testEofUsed ) + out << "and do_test_eof () =\n"; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " = " << vEOF() << " then\n" + " begin\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " match " << vCS() << " with\n"; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << " | " << st->id << " -> tr" << st->eofTrans->id << " ()\n"; + } + + out << "\t| _ -> ();\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " let __acts = ref " << AT( EA(), vCS() ) << " in\n" + " let __nacts = ref " << AT( A(), "!__acts" ) << " in\n" + " incr __acts;\n" + " begin try while !__nacts > 0 do\n" + " decr __nacts;\n" + " begin match " << AT( A(), POST_INCR("__acts.contents") ) << " with\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + " done with Goto_again -> do_again () end;\n"; + } + out << - " if " << P() << " = " << vEOF() << " then\n" - " begin\n"; - - if ( redFsm->anyEofTrans() ) { - out << - " match " << vCS() << " with\n"; - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) - out << " | " << st->id << " -> tr" << st->eofTrans->id << " ()\n"; - } - - out << "\t| _ -> ();\n"; - } - - if ( redFsm->anyEofActions() ) { - out << - " let __acts = ref " << AT( EA(), vCS() ) << " in\n" - " let __nacts = ref " << AT( A(), "!__acts" ) << " in\n" - " incr __acts;\n" - " begin try while !__nacts > 0 do\n" - " decr __nacts;\n" - " begin match " << AT( A(), POST_INCR("__acts.contents") ) << " with\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - " done with Goto_again -> do_again () end;\n"; - } - - out << - " end\n" - "\n"; - } - else - { - out << "\t()\n"; - } - - if ( outLabelUsed ) - out << " and do_out () = ()\n"; - - out << "\tin do_start ()\n"; - out << " end;\n"; -} + " end\n" + "\n"; + } + else + { + out << "\t()\n"; + } + + if ( outLabelUsed ) + out << " and do_out () = ()\n"; + + out << "\tin do_start ()\n"; + out << " end;\n"; +} diff --git a/contrib/tools/ragel6/mlgoto.h b/contrib/tools/ragel6/mlgoto.h index 50aeb32a2f..f4713aa546 100644 --- a/contrib/tools/ragel6/mlgoto.h +++ b/contrib/tools/ragel6/mlgoto.h @@ -1,89 +1,89 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MLGOTO_H -#define _MLGOTO_H - -#include <iostream> -#include "mlcodegen.h" - -/* Forwards. */ -//struct CodeGenData; -//struct NameInst; -//struct RedTransAp; -//struct RedStateAp; -//struct GenStateCond; - -/* - * OCamlGotoCodeGen - */ -class OCamlGotoCodeGen : virtual public OCamlCodeGen -{ -public: - OCamlGotoCodeGen( ostream &out ) : OCamlCodeGen(out) {} - std::ostream &TO_STATE_ACTION_SWITCH(); - std::ostream &FROM_STATE_ACTION_SWITCH(); - std::ostream &EOF_ACTION_SWITCH(); - std::ostream &ACTION_SWITCH(); - std::ostream &STATE_GOTOS(); - std::ostream &TRANSITIONS(); - std::ostream &EXEC_FUNCS(); - std::ostream &FINISH_CASES(); - - void GOTO( ostream &ret, int gotoDest, bool inFinish ); - void CALL( ostream &ret, int callDest, int targState, bool inFinish ); - void NEXT( ostream &ret, int nextDest, bool inFinish ); - void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); - void CURS( ostream &ret, bool inFinish ); - void TARGS( ostream &ret, bool inFinish, int targState ); - void RET( ostream &ret, bool inFinish ); - void BREAK( ostream &ret, int targState ); - - virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); - virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); - virtual unsigned int EOF_ACTION( RedStateAp *state ); - - std::ostream &TO_STATE_ACTIONS(); - std::ostream &FROM_STATE_ACTIONS(); - std::ostream &EOF_ACTIONS(); - - void COND_TRANSLATE( GenStateCond *stateCond, int level ); - void emitCondBSearch( RedStateAp *state, int level, int low, int high ); - void STATE_CONDS( RedStateAp *state, bool genDefault ); - - virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); - - void emitSingleSwitch( RedStateAp *state ); - void emitRangeBSearch( RedStateAp *state, int level, int low, int high, RedTransAp* def ); - - /* Called from STATE_GOTOS just before writing the gotos */ - virtual void GOTO_HEADER( RedStateAp *state ); - virtual void STATE_GOTO_ERROR(); - - virtual void writeData(); - virtual void writeExec(); -}; - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MLGOTO_H +#define _MLGOTO_H + +#include <iostream> +#include "mlcodegen.h" + +/* Forwards. */ +//struct CodeGenData; +//struct NameInst; +//struct RedTransAp; +//struct RedStateAp; +//struct GenStateCond; + +/* + * OCamlGotoCodeGen + */ +class OCamlGotoCodeGen : virtual public OCamlCodeGen +{ +public: + OCamlGotoCodeGen( ostream &out ) : OCamlCodeGen(out) {} + std::ostream &TO_STATE_ACTION_SWITCH(); + std::ostream &FROM_STATE_ACTION_SWITCH(); + std::ostream &EOF_ACTION_SWITCH(); + std::ostream &ACTION_SWITCH(); + std::ostream &STATE_GOTOS(); + std::ostream &TRANSITIONS(); + std::ostream &EXEC_FUNCS(); + std::ostream &FINISH_CASES(); + + void GOTO( ostream &ret, int gotoDest, bool inFinish ); + void CALL( ostream &ret, int callDest, int targState, bool inFinish ); + void NEXT( ostream &ret, int nextDest, bool inFinish ); + void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); + void CURS( ostream &ret, bool inFinish ); + void TARGS( ostream &ret, bool inFinish, int targState ); + void RET( ostream &ret, bool inFinish ); + void BREAK( ostream &ret, int targState ); + + virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); + virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); + virtual unsigned int EOF_ACTION( RedStateAp *state ); + + std::ostream &TO_STATE_ACTIONS(); + std::ostream &FROM_STATE_ACTIONS(); + std::ostream &EOF_ACTIONS(); + + void COND_TRANSLATE( GenStateCond *stateCond, int level ); + void emitCondBSearch( RedStateAp *state, int level, int low, int high ); + void STATE_CONDS( RedStateAp *state, bool genDefault ); + + virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); + + void emitSingleSwitch( RedStateAp *state ); + void emitRangeBSearch( RedStateAp *state, int level, int low, int high, RedTransAp* def ); + + /* Called from STATE_GOTOS just before writing the gotos */ + virtual void GOTO_HEADER( RedStateAp *state ); + virtual void STATE_GOTO_ERROR(); + + virtual void writeData(); + virtual void writeExec(); +}; + +#endif diff --git a/contrib/tools/ragel6/mltable.cpp b/contrib/tools/ragel6/mltable.cpp index 8f70b7cc77..46ee8d97ae 100644 --- a/contrib/tools/ragel6/mltable.cpp +++ b/contrib/tools/ragel6/mltable.cpp @@ -1,1131 +1,1131 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ragel.h" -#include "mltable.h" -#include "redfsm.h" -#include "gendata.h" - -/* Determine if we should use indicies or not. */ -void OCamlTabCodeGen::calcIndexSize() -{ - int sizeWithInds = 0, sizeWithoutInds = 0; - - /* Calculate cost of using with indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; - } - sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); - if ( redFsm->anyActions() ) - sizeWithInds += arrayTypeSize(redFsm->maxActionLoc) * redFsm->transSet.length(); - - /* Calculate the cost of not using indicies. */ - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - int totalIndex = st->outSingle.length() + st->outRange.length() + - (st->defTrans == 0 ? 0 : 1); - sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; - if ( redFsm->anyActions() ) - sizeWithoutInds += arrayTypeSize(redFsm->maxActionLoc) * totalIndex; - } - - /* If using indicies reduces the size, use them. */ - useIndicies = sizeWithInds < sizeWithoutInds; -} - -std::ostream &OCamlTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->toStateAction != 0 ) - act = state->toStateAction->location+1; - out << act; - return out; -} - -std::ostream &OCamlTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->fromStateAction != 0 ) - act = state->fromStateAction->location+1; - out << act; - return out; -} - -std::ostream &OCamlTabCodeGen::EOF_ACTION( RedStateAp *state ) -{ - int act = 0; - if ( state->eofAction != 0 ) - act = state->eofAction->location+1; - out << act; - return out; -} - - -std::ostream &OCamlTabCodeGen::TRANS_ACTION( RedTransAp *trans ) -{ - /* If there are actions, emit them. Otherwise emit zero. */ - int act = 0; - if ( trans->action != 0 ) - act = trans->action->location+1; - out << act; - return out; -} - -std::ostream &OCamlTabCodeGen::TO_STATE_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numToStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlTabCodeGen::FROM_STATE_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numFromStateRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlTabCodeGen::EOF_ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numEofRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " ->\n"; - ACTION( out, act, 0, true ); - } - } - - genLineDirective( out ); - return out; -} - - -std::ostream &OCamlTabCodeGen::ACTION_SWITCH() -{ - /* Walk the list of functions, printing the cases. */ - for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { - /* Write out referenced actions. */ - if ( act->numTransRefs > 0 ) { - /* Write the case label, the action and the case break. */ - out << "\t| " << act->actionId << " -> \n"; - ACTION( out, act, 0, false ); - } - } - - genLineDirective( out ); - return out; -} - -std::ostream &OCamlTabCodeGen::COND_OFFSETS() -{ - out << "\t"; - int totalStateNum = 0, curKeyOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the key offset. */ - out << curKeyOffset; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - - /* Move the key offset ahead. */ - curKeyOffset += st->stateCondList.length(); - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::KEY_OFFSETS() -{ - out << "\t"; - int totalStateNum = 0, curKeyOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the key offset. */ - out << curKeyOffset; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - - /* Move the key offset ahead. */ - curKeyOffset += st->outSingle.length() + st->outRange.length()*2; - } - out << "\n"; - return out; -} - - -std::ostream &OCamlTabCodeGen::INDEX_OFFSETS() -{ - out << "\t"; - int totalStateNum = 0, curIndOffset = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write the index offset. */ - out << curIndOffset; - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - - /* Move the index offset ahead. */ - curIndOffset += st->outSingle.length() + st->outRange.length(); - if ( st->defTrans != 0 ) - curIndOffset += 1; - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::COND_LENS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - out << st->stateCondList.length(); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - - -std::ostream &OCamlTabCodeGen::SINGLE_LENS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write singles length. */ - out << st->outSingle.length(); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::RANGE_LENS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Emit length of range index. */ - out << st->outRange.length(); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::TO_STATE_ACTIONS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - TO_STATE_ACTION(st); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::FROM_STATE_ACTIONS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - FROM_STATE_ACTION(st); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::EOF_ACTIONS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - EOF_ACTION(st); - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::EOF_TRANS() -{ - out << "\t"; - int totalStateNum = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Write any eof action. */ - long trans = 0; - if ( st->eofTrans != 0 ) { - assert( st->eofTrans->pos >= 0 ); - trans = st->eofTrans->pos+1; - } - out << trans; - - if ( !st.last() ) { - out << ARR_SEP(); - if ( ++totalStateNum % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - return out; -} - - -std::ostream &OCamlTabCodeGen::COND_KEYS() -{ - out << '\t'; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Loop the state's transitions. */ - for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { - /* Lower key. */ - out << ALPHA_KEY( sc->lowKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - - /* Upper key. */ - out << ALPHA_KEY( sc->highKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::COND_SPACES() -{ - out << '\t'; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Loop the state's transitions. */ - for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { - /* Cond Space id. */ - out << sc->condSpace->condSpaceId << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::KEYS() -{ - out << '\t'; - int totalTrans = 0; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Loop the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - out << ALPHA_KEY( stel->lowKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Loop the state's transitions. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - /* Lower key. */ - out << ALPHA_KEY( rtel->lowKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - - /* Upper key. */ - out << ALPHA_KEY( rtel->highKey ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::INDICIES() -{ - int totalTrans = 0; - out << '\t'; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Walk the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - out << stel->value->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Walk the ranges. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - out << rtel->value->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* The state's default index goes next. */ - if ( st->defTrans != 0 ) { - out << st->defTrans->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::TRANS_TARGS() -{ - int totalTrans = 0; - out << '\t'; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Walk the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - RedTransAp *trans = stel->value; - out << trans->targ->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Walk the ranges. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - RedTransAp *trans = rtel->value; - out << trans->targ->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* The state's default target state. */ - if ( st->defTrans != 0 ) { - RedTransAp *trans = st->defTrans; - out << trans->targ->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) { - RedTransAp *trans = st->eofTrans; - trans->pos = totalTrans; - out << trans->targ->id << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - - -std::ostream &OCamlTabCodeGen::TRANS_ACTIONS() -{ - int totalTrans = 0; - out << '\t'; - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - /* Walk the singles. */ - for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { - RedTransAp *trans = stel->value; - TRANS_ACTION( trans ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* Walk the ranges. */ - for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { - RedTransAp *trans = rtel->value; - TRANS_ACTION( trans ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - - /* The state's default index goes next. */ - if ( st->defTrans != 0 ) { - RedTransAp *trans = st->defTrans; - TRANS_ACTION( trans ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { - if ( st->eofTrans != 0 ) { - RedTransAp *trans = st->eofTrans; - TRANS_ACTION( trans ) << ARR_SEP(); - if ( ++totalTrans % IALL == 0 ) - out << "\n\t"; - } - } - - /* Output one last number so we don't have to figure out when the last - * entry is and avoid writing a comma. */ - out << 0 << "\n"; - return out; -} - -std::ostream &OCamlTabCodeGen::TRANS_TARGS_WI() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << '\t'; - int totalStates = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Record the position, need this for eofTrans. */ - RedTransAp *trans = transPtrs[t]; - trans->pos = t; - - /* Write out the target state. */ - out << trans->targ->id; - if ( t < redFsm->transSet.length()-1 ) { - out << ARR_SEP(); - if ( ++totalStates % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] transPtrs; - return out; -} - - -std::ostream &OCamlTabCodeGen::TRANS_ACTIONS_WI() -{ - /* Transitions must be written ordered by their id. */ - RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; - for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) - transPtrs[trans->id] = trans; - - /* Keep a count of the num of items in the array written. */ - out << '\t'; - int totalAct = 0; - for ( int t = 0; t < redFsm->transSet.length(); t++ ) { - /* Write the function for the transition. */ - RedTransAp *trans = transPtrs[t]; - TRANS_ACTION( trans ); - if ( t < redFsm->transSet.length()-1 ) { - out << ARR_SEP(); - if ( ++totalAct % IALL == 0 ) - out << "\n\t"; - } - } - out << "\n"; - delete[] transPtrs; - return out; -} - -void OCamlTabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) -{ - ret << "begin " << vCS() << " <- " << gotoDest << "; " << - CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlTabCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << "begin " << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << "); " << CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlTabCodeGen::CURS( ostream &ret, bool inFinish ) -{ - ret << "(_ps)"; -} - -void OCamlTabCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) -{ - ret << "(" << vCS() << ")"; -} - -void OCamlTabCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) -{ - ret << vCS() << " <- " << nextDest << ";"; -} - -void OCamlTabCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) -{ - ret << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, 0, inFinish ); - ret << ");"; -} - -void OCamlTabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, prePushExpr, 0, false ); - } - - ret << "begin " << AT( STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; "; - ret << vCS() << " <- " << callDest << "; " << CTRL_FLOW() << "raise Goto_again end "; - - if ( prePushExpr != 0 ) - ret << "end"; -} - -void OCamlTabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) -{ - if ( prePushExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, prePushExpr, 0, false ); - } - - ret << "begin " << AT(STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; " << vCS() << " <- ("; - INLINE_LIST( ret, ilItem->children, targState, inFinish ); - ret << "); " << CTRL_FLOW() << "raise Goto_again end "; - - if ( prePushExpr != 0 ) - ret << "end"; -} - -void OCamlTabCodeGen::RET( ostream &ret, bool inFinish ) -{ - ret << "begin " << vCS() << " <- " << AT(STACK(), PRE_DECR(TOP()) ) << "; "; - - if ( postPopExpr != 0 ) { - ret << "begin "; - INLINE_LIST( ret, postPopExpr, 0, false ); - ret << "end "; - } - - ret << CTRL_FLOW() << "raise Goto_again end"; -} - -void OCamlTabCodeGen::BREAK( ostream &ret, int targState ) -{ - outLabelUsed = true; - ret << "begin " << P() << " <- " << P() << " + 1; " << CTRL_FLOW() << "raise Goto_out end"; -} - -void OCamlTabCodeGen::writeData() -{ - /* If there are any transtion functions then output the array. If there - * are none, don't bother emitting an empty array that won't be used. */ - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); - ACTIONS_ARRAY(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyConditions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); - COND_OFFSETS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); - COND_LENS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); - COND_KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); - COND_SPACES(); - CLOSE_ARRAY() << - "\n"; - } - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); - KEY_OFFSETS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); - KEYS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); - SINGLE_LENS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); - RANGE_LENS(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); - INDEX_OFFSETS(); - CLOSE_ARRAY() << - "\n"; - - if ( useIndicies ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); - INDICIES(); - CLOSE_ARRAY() << - "\n"; - - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS_WI(); - CLOSE_ARRAY() << - "\n"; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); - TRANS_ACTIONS_WI(); - CLOSE_ARRAY() << - "\n"; - } - } - else { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); - TRANS_TARGS(); - CLOSE_ARRAY() << - "\n"; - - if ( redFsm->anyActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); - TRANS_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - } - - if ( redFsm->anyToStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); - TO_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyFromStateActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); - FROM_STATE_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofActions() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); - EOF_ACTIONS(); - CLOSE_ARRAY() << - "\n"; - } - - if ( redFsm->anyEofTrans() ) { - OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); - EOF_TRANS(); - CLOSE_ARRAY() << - "\n"; - } - - STATE_IDS(); - - out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; mutable acts : int; mutable nacts : int; }" - << TOP_SEP(); - - out << "exception Goto_match" << TOP_SEP(); - out << "exception Goto_again" << TOP_SEP(); - out << "exception Goto_eof_trans" << TOP_SEP(); -} - -void OCamlTabCodeGen::LOCATE_TRANS() -{ - out << - " state.keys <- " << AT( KO(), vCS() ) << ";\n" - " state.trans <- " << CAST(transType) << AT( IO(), vCS() ) << ";\n" - "\n" - " let klen = " << AT( SL(), vCS() ) << " in\n" - " if klen > 0 then begin\n" - " let lower : " << signedKeysType << " ref = ref state.keys in\n" + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ragel.h" +#include "mltable.h" +#include "redfsm.h" +#include "gendata.h" + +/* Determine if we should use indicies or not. */ +void OCamlTabCodeGen::calcIndexSize() +{ + int sizeWithInds = 0, sizeWithoutInds = 0; + + /* Calculate cost of using with indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; + } + sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); + if ( redFsm->anyActions() ) + sizeWithInds += arrayTypeSize(redFsm->maxActionLoc) * redFsm->transSet.length(); + + /* Calculate the cost of not using indicies. */ + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + int totalIndex = st->outSingle.length() + st->outRange.length() + + (st->defTrans == 0 ? 0 : 1); + sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; + if ( redFsm->anyActions() ) + sizeWithoutInds += arrayTypeSize(redFsm->maxActionLoc) * totalIndex; + } + + /* If using indicies reduces the size, use them. */ + useIndicies = sizeWithInds < sizeWithoutInds; +} + +std::ostream &OCamlTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->toStateAction != 0 ) + act = state->toStateAction->location+1; + out << act; + return out; +} + +std::ostream &OCamlTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->fromStateAction != 0 ) + act = state->fromStateAction->location+1; + out << act; + return out; +} + +std::ostream &OCamlTabCodeGen::EOF_ACTION( RedStateAp *state ) +{ + int act = 0; + if ( state->eofAction != 0 ) + act = state->eofAction->location+1; + out << act; + return out; +} + + +std::ostream &OCamlTabCodeGen::TRANS_ACTION( RedTransAp *trans ) +{ + /* If there are actions, emit them. Otherwise emit zero. */ + int act = 0; + if ( trans->action != 0 ) + act = trans->action->location+1; + out << act; + return out; +} + +std::ostream &OCamlTabCodeGen::TO_STATE_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numToStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlTabCodeGen::FROM_STATE_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numFromStateRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlTabCodeGen::EOF_ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numEofRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " ->\n"; + ACTION( out, act, 0, true ); + } + } + + genLineDirective( out ); + return out; +} + + +std::ostream &OCamlTabCodeGen::ACTION_SWITCH() +{ + /* Walk the list of functions, printing the cases. */ + for ( GenActionList::Iter act = actionList; act.lte(); act++ ) { + /* Write out referenced actions. */ + if ( act->numTransRefs > 0 ) { + /* Write the case label, the action and the case break. */ + out << "\t| " << act->actionId << " -> \n"; + ACTION( out, act, 0, false ); + } + } + + genLineDirective( out ); + return out; +} + +std::ostream &OCamlTabCodeGen::COND_OFFSETS() +{ + out << "\t"; + int totalStateNum = 0, curKeyOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the key offset. */ + out << curKeyOffset; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + + /* Move the key offset ahead. */ + curKeyOffset += st->stateCondList.length(); + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::KEY_OFFSETS() +{ + out << "\t"; + int totalStateNum = 0, curKeyOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the key offset. */ + out << curKeyOffset; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + + /* Move the key offset ahead. */ + curKeyOffset += st->outSingle.length() + st->outRange.length()*2; + } + out << "\n"; + return out; +} + + +std::ostream &OCamlTabCodeGen::INDEX_OFFSETS() +{ + out << "\t"; + int totalStateNum = 0, curIndOffset = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write the index offset. */ + out << curIndOffset; + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + + /* Move the index offset ahead. */ + curIndOffset += st->outSingle.length() + st->outRange.length(); + if ( st->defTrans != 0 ) + curIndOffset += 1; + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::COND_LENS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + out << st->stateCondList.length(); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + + +std::ostream &OCamlTabCodeGen::SINGLE_LENS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write singles length. */ + out << st->outSingle.length(); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::RANGE_LENS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Emit length of range index. */ + out << st->outRange.length(); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::TO_STATE_ACTIONS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + TO_STATE_ACTION(st); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::FROM_STATE_ACTIONS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + FROM_STATE_ACTION(st); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::EOF_ACTIONS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + EOF_ACTION(st); + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::EOF_TRANS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + long trans = 0; + if ( st->eofTrans != 0 ) { + assert( st->eofTrans->pos >= 0 ); + trans = st->eofTrans->pos+1; + } + out << trans; + + if ( !st.last() ) { + out << ARR_SEP(); + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + + +std::ostream &OCamlTabCodeGen::COND_KEYS() +{ + out << '\t'; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Loop the state's transitions. */ + for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { + /* Lower key. */ + out << ALPHA_KEY( sc->lowKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + + /* Upper key. */ + out << ALPHA_KEY( sc->highKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::COND_SPACES() +{ + out << '\t'; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Loop the state's transitions. */ + for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) { + /* Cond Space id. */ + out << sc->condSpace->condSpaceId << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::KEYS() +{ + out << '\t'; + int totalTrans = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Loop the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + out << ALPHA_KEY( stel->lowKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Loop the state's transitions. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + /* Lower key. */ + out << ALPHA_KEY( rtel->lowKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + + /* Upper key. */ + out << ALPHA_KEY( rtel->highKey ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::INDICIES() +{ + int totalTrans = 0; + out << '\t'; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Walk the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + out << stel->value->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Walk the ranges. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + out << rtel->value->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* The state's default index goes next. */ + if ( st->defTrans != 0 ) { + out << st->defTrans->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::TRANS_TARGS() +{ + int totalTrans = 0; + out << '\t'; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Walk the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + RedTransAp *trans = stel->value; + out << trans->targ->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Walk the ranges. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + RedTransAp *trans = rtel->value; + out << trans->targ->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* The state's default target state. */ + if ( st->defTrans != 0 ) { + RedTransAp *trans = st->defTrans; + out << trans->targ->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) { + RedTransAp *trans = st->eofTrans; + trans->pos = totalTrans; + out << trans->targ->id << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + + +std::ostream &OCamlTabCodeGen::TRANS_ACTIONS() +{ + int totalTrans = 0; + out << '\t'; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Walk the singles. */ + for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) { + RedTransAp *trans = stel->value; + TRANS_ACTION( trans ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* Walk the ranges. */ + for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) { + RedTransAp *trans = rtel->value; + TRANS_ACTION( trans ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + + /* The state's default index goes next. */ + if ( st->defTrans != 0 ) { + RedTransAp *trans = st->defTrans; + TRANS_ACTION( trans ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) { + RedTransAp *trans = st->eofTrans; + TRANS_ACTION( trans ) << ARR_SEP(); + if ( ++totalTrans % IALL == 0 ) + out << "\n\t"; + } + } + + /* Output one last number so we don't have to figure out when the last + * entry is and avoid writing a comma. */ + out << 0 << "\n"; + return out; +} + +std::ostream &OCamlTabCodeGen::TRANS_TARGS_WI() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << '\t'; + int totalStates = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Record the position, need this for eofTrans. */ + RedTransAp *trans = transPtrs[t]; + trans->pos = t; + + /* Write out the target state. */ + out << trans->targ->id; + if ( t < redFsm->transSet.length()-1 ) { + out << ARR_SEP(); + if ( ++totalStates % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] transPtrs; + return out; +} + + +std::ostream &OCamlTabCodeGen::TRANS_ACTIONS_WI() +{ + /* Transitions must be written ordered by their id. */ + RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()]; + for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) + transPtrs[trans->id] = trans; + + /* Keep a count of the num of items in the array written. */ + out << '\t'; + int totalAct = 0; + for ( int t = 0; t < redFsm->transSet.length(); t++ ) { + /* Write the function for the transition. */ + RedTransAp *trans = transPtrs[t]; + TRANS_ACTION( trans ); + if ( t < redFsm->transSet.length()-1 ) { + out << ARR_SEP(); + if ( ++totalAct % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + delete[] transPtrs; + return out; +} + +void OCamlTabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish ) +{ + ret << "begin " << vCS() << " <- " << gotoDest << "; " << + CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlTabCodeGen::GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << "begin " << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish ); + ret << "); " << CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlTabCodeGen::CURS( ostream &ret, bool inFinish ) +{ + ret << "(_ps)"; +} + +void OCamlTabCodeGen::TARGS( ostream &ret, bool inFinish, int targState ) +{ + ret << "(" << vCS() << ")"; +} + +void OCamlTabCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish ) +{ + ret << vCS() << " <- " << nextDest << ";"; +} + +void OCamlTabCodeGen::NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) +{ + ret << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, 0, inFinish ); + ret << ");"; +} + +void OCamlTabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, prePushExpr, 0, false ); + } + + ret << "begin " << AT( STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; "; + ret << vCS() << " <- " << callDest << "; " << CTRL_FLOW() << "raise Goto_again end "; + + if ( prePushExpr != 0 ) + ret << "end"; +} + +void OCamlTabCodeGen::CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ) +{ + if ( prePushExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, prePushExpr, 0, false ); + } + + ret << "begin " << AT(STACK(), POST_INCR(TOP()) ) << " <- " << vCS() << "; " << vCS() << " <- ("; + INLINE_LIST( ret, ilItem->children, targState, inFinish ); + ret << "); " << CTRL_FLOW() << "raise Goto_again end "; + + if ( prePushExpr != 0 ) + ret << "end"; +} + +void OCamlTabCodeGen::RET( ostream &ret, bool inFinish ) +{ + ret << "begin " << vCS() << " <- " << AT(STACK(), PRE_DECR(TOP()) ) << "; "; + + if ( postPopExpr != 0 ) { + ret << "begin "; + INLINE_LIST( ret, postPopExpr, 0, false ); + ret << "end "; + } + + ret << CTRL_FLOW() << "raise Goto_again end"; +} + +void OCamlTabCodeGen::BREAK( ostream &ret, int targState ) +{ + outLabelUsed = true; + ret << "begin " << P() << " <- " << P() << " + 1; " << CTRL_FLOW() << "raise Goto_out end"; +} + +void OCamlTabCodeGen::writeData() +{ + /* If there are any transtion functions then output the array. If there + * are none, don't bother emitting an empty array that won't be used. */ + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() ); + ACTIONS_ARRAY(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyConditions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); + COND_OFFSETS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); + COND_LENS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); + COND_KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); + COND_SPACES(); + CLOSE_ARRAY() << + "\n"; + } + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); + KEY_OFFSETS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); + KEYS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); + SINGLE_LENS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); + RANGE_LENS(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); + INDEX_OFFSETS(); + CLOSE_ARRAY() << + "\n"; + + if ( useIndicies ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); + INDICIES(); + CLOSE_ARRAY() << + "\n"; + + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS_WI(); + CLOSE_ARRAY() << + "\n"; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); + TRANS_ACTIONS_WI(); + CLOSE_ARRAY() << + "\n"; + } + } + else { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); + TRANS_TARGS(); + CLOSE_ARRAY() << + "\n"; + + if ( redFsm->anyActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() ); + TRANS_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + } + + if ( redFsm->anyToStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); + TO_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyFromStateActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); + FROM_STATE_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofActions() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); + EOF_ACTIONS(); + CLOSE_ARRAY() << + "\n"; + } + + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + + STATE_IDS(); + + out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; mutable acts : int; mutable nacts : int; }" + << TOP_SEP(); + + out << "exception Goto_match" << TOP_SEP(); + out << "exception Goto_again" << TOP_SEP(); + out << "exception Goto_eof_trans" << TOP_SEP(); +} + +void OCamlTabCodeGen::LOCATE_TRANS() +{ + out << + " state.keys <- " << AT( KO(), vCS() ) << ";\n" + " state.trans <- " << CAST(transType) << AT( IO(), vCS() ) << ";\n" + "\n" + " let klen = " << AT( SL(), vCS() ) << " in\n" + " if klen > 0 then begin\n" + " let lower : " << signedKeysType << " ref = ref state.keys in\n" + " let upper : " << signedKeysType << " ref = ref " << CAST(signedKeysType) << + "(state.keys + klen - 1) in\n" + " while !upper >= !lower do\n" + " let mid = " << CAST(signedKeysType) << " (!lower + ((!upper - !lower) / 2)) in\n" + " if " << GET_WIDE_KEY() << " < " << AT( K(), "mid" ) << " then\n" + " upper := " << CAST(signedKeysType) << " (mid - 1)\n" + " else if " << GET_WIDE_KEY() << " > " << AT( K(), "mid" ) << " then\n" + " lower := " << CAST(signedKeysType) << " (mid + 1)\n" + " else begin\n" + " state.trans <- state.trans + " << CAST(transType) << " (mid - state.keys);\n" + " raise Goto_match;\n" + " end\n" + " done;\n" + " state.keys <- state.keys + " << CAST(keysType) << " klen;\n" + " state.trans <- state.trans + " << CAST(transType) << " klen;\n" + " end;\n" + "\n" + " let klen = " << AT( RL(), vCS() ) << " in\n" + " if klen > 0 then begin\n" + " let lower : " << signedKeysType << " ref = ref state.keys in\n" " let upper : " << signedKeysType << " ref = ref " << CAST(signedKeysType) << - "(state.keys + klen - 1) in\n" - " while !upper >= !lower do\n" - " let mid = " << CAST(signedKeysType) << " (!lower + ((!upper - !lower) / 2)) in\n" - " if " << GET_WIDE_KEY() << " < " << AT( K(), "mid" ) << " then\n" - " upper := " << CAST(signedKeysType) << " (mid - 1)\n" - " else if " << GET_WIDE_KEY() << " > " << AT( K(), "mid" ) << " then\n" - " lower := " << CAST(signedKeysType) << " (mid + 1)\n" - " else begin\n" - " state.trans <- state.trans + " << CAST(transType) << " (mid - state.keys);\n" - " raise Goto_match;\n" - " end\n" - " done;\n" - " state.keys <- state.keys + " << CAST(keysType) << " klen;\n" - " state.trans <- state.trans + " << CAST(transType) << " klen;\n" - " end;\n" - "\n" - " let klen = " << AT( RL(), vCS() ) << " in\n" - " if klen > 0 then begin\n" - " let lower : " << signedKeysType << " ref = ref state.keys in\n" - " let upper : " << signedKeysType << " ref = ref " << CAST(signedKeysType) << - "(state.keys + (klen * 2) - 2) in\n" - " while !upper >= !lower do\n" - " let mid = " << CAST(signedKeysType) << " (!lower + (((!upper - !lower) / 2) land (lnot 1))) in\n" - " if " << GET_WIDE_KEY() << " < " << AT( K() , "mid" ) << " then\n" - " upper := " << CAST(signedKeysType) << " (mid - 2)\n" - " else if " << GET_WIDE_KEY() << " > " << AT( K(), "mid+1" ) << " then\n" - " lower := " << CAST(signedKeysType) << " (mid + 2)\n" - " else begin\n" - " state.trans <- state.trans + " << CAST(transType) << "((mid - state.keys) / 2);\n" - " raise Goto_match;\n" - " end\n" - " done;\n" - " state.trans <- state.trans + " << CAST(transType) << " klen;\n" - " end;\n" - "\n"; -} - -void OCamlTabCodeGen::COND_TRANSLATE() -{ + "(state.keys + (klen * 2) - 2) in\n" + " while !upper >= !lower do\n" + " let mid = " << CAST(signedKeysType) << " (!lower + (((!upper - !lower) / 2) land (lnot 1))) in\n" + " if " << GET_WIDE_KEY() << " < " << AT( K() , "mid" ) << " then\n" + " upper := " << CAST(signedKeysType) << " (mid - 2)\n" + " else if " << GET_WIDE_KEY() << " > " << AT( K(), "mid+1" ) << " then\n" + " lower := " << CAST(signedKeysType) << " (mid + 2)\n" + " else begin\n" + " state.trans <- state.trans + " << CAST(transType) << "((mid - state.keys) / 2);\n" + " raise Goto_match;\n" + " end\n" + " done;\n" + " state.trans <- state.trans + " << CAST(transType) << " klen;\n" + " end;\n" + "\n"; +} + +void OCamlTabCodeGen::COND_TRANSLATE() +{ + out << + " _widec = " << GET_KEY() << ";\n" + " _klen = " << CL() << "[" << vCS() << "];\n" + " _keys = " << CAST(keysType) << " ("<< CO() << "[" << vCS() << "]*2);\n" + " if ( _klen > 0 ) {\n" + " " << signedKeysType << " _lower = _keys;\n" + " " << signedKeysType << " _mid;\n" + " " << signedKeysType << " _upper = " << CAST(signedKeysType) << + " (_keys + (_klen<<1) - 2);\n" + " while (true) {\n" + " if ( _upper < _lower )\n" + " break;\n" + "\n" + " _mid = " << CAST(signedKeysType) << + " (_lower + (((_upper-_lower) >> 1) & ~1));\n" + " if ( " << GET_WIDE_KEY() << " < " << CK() << "[_mid] )\n" + " _upper = " << CAST(signedKeysType) << " (_mid - 2);\n" + " else if ( " << GET_WIDE_KEY() << " > " << CK() << "[_mid+1] )\n" + " _lower = " << CAST(signedKeysType) << " (_mid + 2);\n" + " else {\n" + " switch ( " << C() << "[" << CO() << "[" << vCS() << "]" + " + ((_mid - _keys)>>1)] ) {\n"; + + for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { + GenCondSpace *condSpace = csi; + out << " case " << condSpace->condSpaceId << ": {\n"; + out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << + KEY(condSpace->baseKey) << " + (" << GET_KEY() << + " - " << KEY(keyOps->minKey) << "));\n"; + + for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { + out << TABS(2) << "if ( "; + CONDITION( out, *csi ); + Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); + out << " ) _widec += " << condValOffset << ";\n"; + } + + out << + " break;\n" + " }\n"; + } + + SWITCH_DEFAULT(); + + out << + " }\n" + " break;\n" + " }\n" + " }\n" + " }\n" + "\n"; +} + +void OCamlTabCodeGen::writeExec() +{ + testEofUsed = false; + outLabelUsed = false; + initVarTypes(); + out << - " _widec = " << GET_KEY() << ";\n" - " _klen = " << CL() << "[" << vCS() << "];\n" - " _keys = " << CAST(keysType) << " ("<< CO() << "[" << vCS() << "]*2);\n" - " if ( _klen > 0 ) {\n" - " " << signedKeysType << " _lower = _keys;\n" - " " << signedKeysType << " _mid;\n" - " " << signedKeysType << " _upper = " << CAST(signedKeysType) << - " (_keys + (_klen<<1) - 2);\n" - " while (true) {\n" - " if ( _upper < _lower )\n" - " break;\n" - "\n" - " _mid = " << CAST(signedKeysType) << - " (_lower + (((_upper-_lower) >> 1) & ~1));\n" - " if ( " << GET_WIDE_KEY() << " < " << CK() << "[_mid] )\n" - " _upper = " << CAST(signedKeysType) << " (_mid - 2);\n" - " else if ( " << GET_WIDE_KEY() << " > " << CK() << "[_mid+1] )\n" - " _lower = " << CAST(signedKeysType) << " (_mid + 2);\n" - " else {\n" - " switch ( " << C() << "[" << CO() << "[" << vCS() << "]" - " + ((_mid - _keys)>>1)] ) {\n"; - - for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { - GenCondSpace *condSpace = csi; - out << " case " << condSpace->condSpaceId << ": {\n"; - out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << - KEY(condSpace->baseKey) << " + (" << GET_KEY() << - " - " << KEY(keyOps->minKey) << "));\n"; - - for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { - out << TABS(2) << "if ( "; - CONDITION( out, *csi ); - Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); - out << " ) _widec += " << condValOffset << ";\n"; - } - - out << - " break;\n" - " }\n"; - } - - SWITCH_DEFAULT(); - + " begin\n"; +// " " << klenType << " _klen"; + +// if ( redFsm->anyRegCurStateRef() ) +// out << ", _ps"; + +/* + out << " " << transType << " _trans;\n"; + + if ( redFsm->anyConditions() ) + out << " " << WIDE_ALPH_TYPE() << " _widec;\n"; + + if ( redFsm->anyToStateActions() || redFsm->anyRegActions() + || redFsm->anyFromStateActions() ) + { + out << + " int _acts;\n" + " int _nacts;\n"; + } + out << - " }\n" - " break;\n" - " }\n" - " }\n" - " }\n" - "\n"; -} - -void OCamlTabCodeGen::writeExec() -{ - testEofUsed = false; - outLabelUsed = false; - initVarTypes(); - - out << - " begin\n"; -// " " << klenType << " _klen"; - -// if ( redFsm->anyRegCurStateRef() ) -// out << ", _ps"; - -/* - out << " " << transType << " _trans;\n"; - - if ( redFsm->anyConditions() ) - out << " " << WIDE_ALPH_TYPE() << " _widec;\n"; - - if ( redFsm->anyToStateActions() || redFsm->anyRegActions() - || redFsm->anyFromStateActions() ) - { - out << - " int _acts;\n" - " int _nacts;\n"; - } - - out << - " " << keysType << " _keys;\n" - "\n"; -// " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n" -*/ - - out << - " let state = { keys = 0; trans = 0; acts = 0; nacts = 0; } in\n" - " let rec do_start () =\n"; - if ( !noEnd ) { - testEofUsed = true; - out << - " if " << P() << " = " << PE() << " then\n" - " do_test_eof ()\n" - "\telse\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " if " << vCS() << " = " << redFsm->errState->id << " then\n" - " do_out ()\n" - "\telse\n"; - } - out << "\tdo_resume ()\n"; - - out << "and do_resume () =\n"; - - if ( redFsm->anyFromStateActions() ) { - out << - " state.acts <- " << AT( FSA(), vCS() ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - FROM_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n" - " done;\n" - "\n"; - } - - if ( redFsm->anyConditions() ) - COND_TRANSLATE(); - - out << "\tbegin try\n"; - LOCATE_TRANS(); - out << "\twith Goto_match -> () end;\n"; - + " " << keysType << " _keys;\n" + "\n"; +// " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n" +*/ + out << - "\tdo_match ()\n"; - - out << "and do_match () =\n"; - - if ( useIndicies ) - out << " state.trans <- " << CAST(transType) << AT( I(), "state.trans" ) << ";\n"; - - out << "\tdo_eof_trans ()\n"; - -// if ( redFsm->anyEofTrans() ) - out << "and do_eof_trans () =\n"; - - if ( redFsm->anyRegCurStateRef() ) - out << " let ps = " << vCS() << " in\n"; - - out << - " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" - "\n"; - - if ( redFsm->anyRegActions() ) { - out << - "\tbegin try\n" - " match " << AT( TA(), "state.trans" ) << " with\n" - "\t| 0 -> raise Goto_again\n" - "\t| _ ->\n" - " state.acts <- " << AT( TA(), "state.trans" ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - " done\n" - "\twith Goto_again -> () end;\n"; - } - out << "\tdo_again ()\n"; - -// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || -// redFsm->anyActionCalls() || redFsm->anyActionRets() ) - out << "\tand do_again () =\n"; - - if ( redFsm->anyToStateActions() ) { - out << - " state.acts <- " << AT( TSA(), vCS() ) << ";\n" - " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" - " while " << POST_DECR("state.nacts") << " > 0 do\n" - " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; - TO_STATE_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end\n" - " done;\n" - "\n"; - } - - if ( redFsm->errState != 0 ) { - outLabelUsed = true; - out << - " match " << vCS() << " with\n" - "\t| " << redFsm->errState->id << " -> do_out ()\n" - "\t| _ ->\n"; - } - - out << "\t" << P() << " <- " << P() << " + 1;\n"; - - if ( !noEnd ) { + " let state = { keys = 0; trans = 0; acts = 0; nacts = 0; } in\n" + " let rec do_start () =\n"; + if ( !noEnd ) { + testEofUsed = true; + out << + " if " << P() << " = " << PE() << " then\n" + " do_test_eof ()\n" + "\telse\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " if " << vCS() << " = " << redFsm->errState->id << " then\n" + " do_out ()\n" + "\telse\n"; + } + out << "\tdo_resume ()\n"; + + out << "and do_resume () =\n"; + + if ( redFsm->anyFromStateActions() ) { out << - " if " << P() << " <> " << PE() << " then\n" - " do_resume ()\n" - "\telse do_test_eof ()\n"; - } - else { - out << - " do_resume ()\n"; - } - -// if ( testEofUsed ) - out << "and do_test_eof () =\n"; - - if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + " state.acts <- " << AT( FSA(), vCS() ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + FROM_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n" + " done;\n" + "\n"; + } + + if ( redFsm->anyConditions() ) + COND_TRANSLATE(); + + out << "\tbegin try\n"; + LOCATE_TRANS(); + out << "\twith Goto_match -> () end;\n"; + + out << + "\tdo_match ()\n"; + + out << "and do_match () =\n"; + + if ( useIndicies ) + out << " state.trans <- " << CAST(transType) << AT( I(), "state.trans" ) << ";\n"; + + out << "\tdo_eof_trans ()\n"; + +// if ( redFsm->anyEofTrans() ) + out << "and do_eof_trans () =\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " let ps = " << vCS() << " in\n"; + + out << + " " << vCS() << " <- " << AT( TT() ,"state.trans" ) << ";\n" + "\n"; + + if ( redFsm->anyRegActions() ) { out << - " if " << P() << " = " << vEOF() << " then\n" - " begin try\n"; - - if ( redFsm->anyEofTrans() ) { - out << - " if " << AT( ET(), vCS() ) << " > 0 then\n" - " begin\n" - " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" - " raise Goto_eof_trans;\n" - " end;\n"; - } - - if ( redFsm->anyEofActions() ) { - out << - " let __acts = ref " << AT( EA(), vCS() ) << " in\n" - " let __nacts = ref " << AT( A(), "!__acts" ) << " in\n" - " incr __acts;\n" - " while !__nacts > 0 do\n" - " decr __nacts;\n" - " begin match " << AT( A(), POST_INCR("__acts.contents") ) << " with\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " end;\n" - " done\n"; - } - + "\tbegin try\n" + " match " << AT( TA(), "state.trans" ) << " with\n" + "\t| 0 -> raise Goto_again\n" + "\t| _ ->\n" + " state.acts <- " << AT( TA(), "state.trans" ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + " done\n" + "\twith Goto_again -> () end;\n"; + } + out << "\tdo_again ()\n"; + +// if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || +// redFsm->anyActionCalls() || redFsm->anyActionRets() ) + out << "\tand do_again () =\n"; + + if ( redFsm->anyToStateActions() ) { out << - " with Goto_again -> do_again ()\n" - " | Goto_eof_trans -> do_eof_trans () end\n" - "\n"; - } - else - { - out << "\t()\n"; - } - - if ( outLabelUsed ) - out << " and do_out () = ()\n"; - - out << "\tin do_start ()\n"; - out << " end;\n"; -} - -void OCamlTabCodeGen::initVarTypes() -{ - int klenMax = MAX(MAX(redFsm->maxCondLen, redFsm->maxRangeLen), - redFsm->maxSingleLen); - int keysMax = MAX(MAX(redFsm->maxKeyOffset, klenMax), - redFsm->maxCondOffset); - int transMax = MAX(MAX(redFsm->maxIndex+1, redFsm->maxIndexOffset), keysMax); - transMax = MAX(transMax, klenMax); - transType = ARRAY_TYPE(transMax); - klenType = ARRAY_TYPE(klenMax); - keysType = ARRAY_TYPE(keysMax); - signedKeysType = ARRAY_TYPE(keysMax, true); -} + " state.acts <- " << AT( TSA(), vCS() ) << ";\n" + " state.nacts <- " << AT( A(), POST_INCR("state.acts") ) << ";\n" + " while " << POST_DECR("state.nacts") << " > 0 do\n" + " begin match " << AT( A(), POST_INCR("state.acts") ) << " with\n"; + TO_STATE_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end\n" + " done;\n" + "\n"; + } + + if ( redFsm->errState != 0 ) { + outLabelUsed = true; + out << + " match " << vCS() << " with\n" + "\t| " << redFsm->errState->id << " -> do_out ()\n" + "\t| _ ->\n"; + } + + out << "\t" << P() << " <- " << P() << " + 1;\n"; + + if ( !noEnd ) { + out << + " if " << P() << " <> " << PE() << " then\n" + " do_resume ()\n" + "\telse do_test_eof ()\n"; + } + else { + out << + " do_resume ()\n"; + } + +// if ( testEofUsed ) + out << "and do_test_eof () =\n"; + + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { + out << + " if " << P() << " = " << vEOF() << " then\n" + " begin try\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if " << AT( ET(), vCS() ) << " > 0 then\n" + " begin\n" + " state.trans <- " << CAST(transType) << "(" << AT( ET(), vCS() ) << " - 1);\n" + " raise Goto_eof_trans;\n" + " end;\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " let __acts = ref " << AT( EA(), vCS() ) << " in\n" + " let __nacts = ref " << AT( A(), "!__acts" ) << " in\n" + " incr __acts;\n" + " while !__nacts > 0 do\n" + " decr __nacts;\n" + " begin match " << AT( A(), POST_INCR("__acts.contents") ) << " with\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " end;\n" + " done\n"; + } + + out << + " with Goto_again -> do_again ()\n" + " | Goto_eof_trans -> do_eof_trans () end\n" + "\n"; + } + else + { + out << "\t()\n"; + } + + if ( outLabelUsed ) + out << " and do_out () = ()\n"; + + out << "\tin do_start ()\n"; + out << " end;\n"; +} + +void OCamlTabCodeGen::initVarTypes() +{ + int klenMax = MAX(MAX(redFsm->maxCondLen, redFsm->maxRangeLen), + redFsm->maxSingleLen); + int keysMax = MAX(MAX(redFsm->maxKeyOffset, klenMax), + redFsm->maxCondOffset); + int transMax = MAX(MAX(redFsm->maxIndex+1, redFsm->maxIndexOffset), keysMax); + transMax = MAX(transMax, klenMax); + transType = ARRAY_TYPE(transMax); + klenType = ARRAY_TYPE(klenMax); + keysType = ARRAY_TYPE(keysMax); + signedKeysType = ARRAY_TYPE(keysMax, true); +} diff --git a/contrib/tools/ragel6/mltable.h b/contrib/tools/ragel6/mltable.h index 505d378a89..d235424b95 100644 --- a/contrib/tools/ragel6/mltable.h +++ b/contrib/tools/ragel6/mltable.h @@ -1,102 +1,102 @@ -/* - * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> - * 2004 Erich Ocean <eric.ocean@ampede.com> - * 2005 Alan West <alan@alanz.com> - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. +/* + * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> + * 2004 Erich Ocean <eric.ocean@ampede.com> + * 2005 Alan West <alan@alanz.com> + */ + +/* This file is part of Ragel. * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _OCAMLTABCODEGEN_H -#define _OCAMLTABCODEGEN_H - -#include <iostream> -#include "mlcodegen.h" - -/* Forwards. */ -/* -struct CodeGenData; -struct NameInst; -struct RedTransAp; -struct RedStateAp; -*/ - -/* - * OCamlTabCodeGen - */ -class OCamlTabCodeGen : public OCamlCodeGen -{ -public: - OCamlTabCodeGen( ostream &out ) : OCamlCodeGen(out) {} - virtual ~OCamlTabCodeGen() { } - virtual void writeData(); - virtual void writeExec(); - -protected: - std::ostream &TO_STATE_ACTION_SWITCH(); - std::ostream &FROM_STATE_ACTION_SWITCH(); - std::ostream &EOF_ACTION_SWITCH(); - std::ostream &ACTION_SWITCH(); - - std::ostream &COND_KEYS(); - std::ostream &COND_SPACES(); - std::ostream &KEYS(); - std::ostream &INDICIES(); - std::ostream &COND_OFFSETS(); - std::ostream &KEY_OFFSETS(); - std::ostream &INDEX_OFFSETS(); - std::ostream &COND_LENS(); - std::ostream &SINGLE_LENS(); - std::ostream &RANGE_LENS(); - std::ostream &TO_STATE_ACTIONS(); - std::ostream &FROM_STATE_ACTIONS(); - std::ostream &EOF_ACTIONS(); - std::ostream &EOF_TRANS(); - std::ostream &TRANS_TARGS(); - std::ostream &TRANS_ACTIONS(); - std::ostream &TRANS_TARGS_WI(); - std::ostream &TRANS_ACTIONS_WI(); - - void LOCATE_TRANS(); - - void COND_TRANSLATE(); - - void GOTO( ostream &ret, int gotoDest, bool inFinish ); - void CALL( ostream &ret, int callDest, int targState, bool inFinish ); - void NEXT( ostream &ret, int nextDest, bool inFinish ); - void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); - void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); - void CURS( ostream &ret, bool inFinish ); - void TARGS( ostream &ret, bool inFinish, int targState ); - void RET( ostream &ret, bool inFinish ); - void BREAK( ostream &ret, int targState ); - - virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); - virtual std::ostream &EOF_ACTION( RedStateAp *state ); - virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); - virtual void calcIndexSize(); - - void initVarTypes(); - string klenType; - string keysType; - string signedKeysType; - string transType; -}; - -#endif + * Ragel is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Ragel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _OCAMLTABCODEGEN_H +#define _OCAMLTABCODEGEN_H + +#include <iostream> +#include "mlcodegen.h" + +/* Forwards. */ +/* +struct CodeGenData; +struct NameInst; +struct RedTransAp; +struct RedStateAp; +*/ + +/* + * OCamlTabCodeGen + */ +class OCamlTabCodeGen : public OCamlCodeGen +{ +public: + OCamlTabCodeGen( ostream &out ) : OCamlCodeGen(out) {} + virtual ~OCamlTabCodeGen() { } + virtual void writeData(); + virtual void writeExec(); + +protected: + std::ostream &TO_STATE_ACTION_SWITCH(); + std::ostream &FROM_STATE_ACTION_SWITCH(); + std::ostream &EOF_ACTION_SWITCH(); + std::ostream &ACTION_SWITCH(); + + std::ostream &COND_KEYS(); + std::ostream &COND_SPACES(); + std::ostream &KEYS(); + std::ostream &INDICIES(); + std::ostream &COND_OFFSETS(); + std::ostream &KEY_OFFSETS(); + std::ostream &INDEX_OFFSETS(); + std::ostream &COND_LENS(); + std::ostream &SINGLE_LENS(); + std::ostream &RANGE_LENS(); + std::ostream &TO_STATE_ACTIONS(); + std::ostream &FROM_STATE_ACTIONS(); + std::ostream &EOF_ACTIONS(); + std::ostream &EOF_TRANS(); + std::ostream &TRANS_TARGS(); + std::ostream &TRANS_ACTIONS(); + std::ostream &TRANS_TARGS_WI(); + std::ostream &TRANS_ACTIONS_WI(); + + void LOCATE_TRANS(); + + void COND_TRANSLATE(); + + void GOTO( ostream &ret, int gotoDest, bool inFinish ); + void CALL( ostream &ret, int callDest, int targState, bool inFinish ); + void NEXT( ostream &ret, int nextDest, bool inFinish ); + void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); + void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); + void CURS( ostream &ret, bool inFinish ); + void TARGS( ostream &ret, bool inFinish, int targState ); + void RET( ostream &ret, bool inFinish ); + void BREAK( ostream &ret, int targState ); + + virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); + virtual std::ostream &EOF_ACTION( RedStateAp *state ); + virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); + virtual void calcIndexSize(); + + void initVarTypes(); + string klenType; + string keysType; + string signedKeysType; + string transType; +}; + +#endif diff --git a/contrib/tools/ragel6/parsedata.cpp b/contrib/tools/ragel6/parsedata.cpp index eafe73e524..3a4d611eb7 100644 --- a/contrib/tools/ragel6/parsedata.cpp +++ b/contrib/tools/ragel6/parsedata.cpp @@ -126,49 +126,49 @@ Key makeFsmKeyHex( char *str, const InputLoc &loc, ParseData *pd ) Key makeFsmKeyDec( char *str, const InputLoc &loc, ParseData *pd ) { - if ( keyOps->alphType->isSigned ) { - /* Convert the number to a decimal. First reset errno so we can check - * for overflow or underflow. */ - errno = 0; - long long minVal = keyOps->alphType->sMinVal; - long long maxVal = keyOps->alphType->sMaxVal; - - long long ll = strtoll( str, 0, 10 ); - - /* Check for underflow. */ - if ( ( errno == ERANGE && ll < 0 ) || ll < minVal) { - error(loc) << "literal " << str << " underflows the alphabet type" << endl; - ll = minVal; - } - /* Check for overflow. */ - else if ( ( errno == ERANGE && ll > 0 ) || ll > maxVal ) { - error(loc) << "literal " << str << " overflows the alphabet type" << endl; - ll = maxVal; - } - - return Key( (long)ll ); + if ( keyOps->alphType->isSigned ) { + /* Convert the number to a decimal. First reset errno so we can check + * for overflow or underflow. */ + errno = 0; + long long minVal = keyOps->alphType->sMinVal; + long long maxVal = keyOps->alphType->sMaxVal; + + long long ll = strtoll( str, 0, 10 ); + + /* Check for underflow. */ + if ( ( errno == ERANGE && ll < 0 ) || ll < minVal) { + error(loc) << "literal " << str << " underflows the alphabet type" << endl; + ll = minVal; + } + /* Check for overflow. */ + else if ( ( errno == ERANGE && ll > 0 ) || ll > maxVal ) { + error(loc) << "literal " << str << " overflows the alphabet type" << endl; + ll = maxVal; + } + + return Key( (long)ll ); } - else { - /* Convert the number to a decimal. First reset errno so we can check - * for overflow or underflow. */ - errno = 0; - unsigned long long minVal = keyOps->alphType->uMinVal; - unsigned long long maxVal = keyOps->alphType->uMaxVal; - - unsigned long long ull = strtoull( str, 0, 10 ); - - /* Check for underflow. */ - if ( ( errno == ERANGE && ull < 0 ) || ull < minVal) { - error(loc) << "literal " << str << " underflows the alphabet type" << endl; - ull = minVal; - } - /* Check for overflow. */ - else if ( ( errno == ERANGE && ull > 0 ) || ull > maxVal ) { - error(loc) << "literal " << str << " overflows the alphabet type" << endl; - ull = maxVal; - } - - return Key( (unsigned long)ull ); + else { + /* Convert the number to a decimal. First reset errno so we can check + * for overflow or underflow. */ + errno = 0; + unsigned long long minVal = keyOps->alphType->uMinVal; + unsigned long long maxVal = keyOps->alphType->uMaxVal; + + unsigned long long ull = strtoull( str, 0, 10 ); + + /* Check for underflow. */ + if ( ( errno == ERANGE && ull < 0 ) || ull < minVal) { + error(loc) << "literal " << str << " underflows the alphabet type" << endl; + ull = minVal; + } + /* Check for overflow. */ + else if ( ( errno == ERANGE && ull > 0 ) || ull > maxVal ) { + error(loc) << "literal " << str << " overflows the alphabet type" << endl; + ull = maxVal; + } + + return Key( (unsigned long)ull ); } } diff --git a/contrib/tools/ragel6/parsetree.h b/contrib/tools/ragel6/parsetree.h index 954542e94d..f6f8d50ba7 100644 --- a/contrib/tools/ragel6/parsetree.h +++ b/contrib/tools/ragel6/parsetree.h @@ -385,11 +385,11 @@ struct Expression /* Construct with an expression on the left and a term on the right. */ Expression( Expression *expression, Term *term, Type type ) : expression(expression), term(term), - type(type), prev(this), next(this) { } + type(type), prev(this), next(this) { } /* Construct with only a term. */ Expression( Term *term ) : - expression(0), term(term), + expression(0), term(term), type(TermType) , prev(this), next(this) { } /* Construct with a builtin type. */ diff --git a/contrib/tools/ragel6/redfsm.cpp b/contrib/tools/ragel6/redfsm.cpp index 5b02d996c1..0dbfb30e4c 100644 --- a/contrib/tools/ragel6/redfsm.cpp +++ b/contrib/tools/ragel6/redfsm.cpp @@ -56,7 +56,7 @@ RedFsmAp::RedFsmAp() bAnyActionGotos(false), bAnyActionCalls(false), bAnyActionRets(false), - bAnyActionByValControl(false), + bAnyActionByValControl(false), bAnyRegActionRets(false), bAnyRegActionByValControl(false), bAnyRegNextStmt(false), diff --git a/contrib/tools/ragel6/redfsm.h b/contrib/tools/ragel6/redfsm.h index badca23eb9..c2af33e986 100644 --- a/contrib/tools/ragel6/redfsm.h +++ b/contrib/tools/ragel6/redfsm.h @@ -421,7 +421,7 @@ struct RedFsmAp bool bAnyActionGotos; bool bAnyActionCalls; bool bAnyActionRets; - bool bAnyActionByValControl; + bool bAnyActionByValControl; bool bAnyRegActionRets; bool bAnyRegActionByValControl; bool bAnyRegNextStmt; @@ -457,7 +457,7 @@ struct RedFsmAp bool anyActionGotos() { return bAnyActionGotos; } bool anyActionCalls() { return bAnyActionCalls; } bool anyActionRets() { return bAnyActionRets; } - bool anyActionByValControl() { return bAnyActionByValControl; } + bool anyActionByValControl() { return bAnyActionByValControl; } bool anyRegActionRets() { return bAnyRegActionRets; } bool anyRegActionByValControl() { return bAnyRegActionByValControl; } bool anyRegNextStmt() { return bAnyRegNextStmt; } diff --git a/contrib/tools/ragel6/rlparse.cpp b/contrib/tools/ragel6/rlparse.cpp index 35b3fff054..672703d1f5 100644 --- a/contrib/tools/ragel6/rlparse.cpp +++ b/contrib/tools/ragel6/rlparse.cpp @@ -4016,50 +4016,50 @@ commit_upwards: } switch ( lel->reduction ) { case 17: { -Token *__ref0 = (Token*)&rhs[1]->user.token; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Token *__ref2 = (Token*)&rhs[1]->user.token; +Token *__ref0 = (Token*)&rhs[1]->user.token; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Token *__ref2 = (Token*)&rhs[1]->user.token; #line 61 "rlparse.kl" - LengthDef *lengthDef = new LengthDef( (__ref0)->data ); + LengthDef *lengthDef = new LengthDef( (__ref0)->data ); pd->lengthDefList.append( lengthDef ); /* Generic creation of machine for instantiation and assignment. */ MachineDef *machineDef = new MachineDef( lengthDef ); - tryMachineDef( (__ref1)->loc, (__ref2)->data, machineDef, false ); + tryMachineDef( (__ref1)->loc, (__ref2)->data, machineDef, false ); -#line 4031 "rlparse.cpp" +#line 4031 "rlparse.cpp" } break; case 18: { -Token *__ref0 = (Token*)&rhs[1]->user.token; -Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; +Token *__ref0 = (Token*)&rhs[1]->user.token; +Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; #line 72 "rlparse.kl" if ( pd->prePushExpr != 0 ) { /* Recover by just ignoring the duplicate. */ - error((__ref0)->loc) << "pre_push code already defined" << endl; + error((__ref0)->loc) << "pre_push code already defined" << endl; } - pd->prePushExpr = (__ref1)->inlineList; + pd->prePushExpr = (__ref1)->inlineList; -#line 4046 "rlparse.cpp" +#line 4046 "rlparse.cpp" } break; case 19: { -Token *__ref0 = (Token*)&rhs[1]->user.token; -Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; +Token *__ref0 = (Token*)&rhs[1]->user.token; +Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; #line 84 "rlparse.kl" if ( pd->postPopExpr != 0 ) { /* Recover by just ignoring the duplicate. */ - error((__ref0)->loc) << "post_pop code already defined" << endl; + error((__ref0)->loc) << "post_pop code already defined" << endl; } - pd->postPopExpr = (__ref1)->inlineList; + pd->postPopExpr = (__ref1)->inlineList; -#line 4061 "rlparse.cpp" +#line 4061 "rlparse.cpp" } break; case 20: { #line 95 "rlparse.kl" @@ -4067,21 +4067,21 @@ case 20: { exportContext.append( true ); -#line 4069 "rlparse.cpp" +#line 4069 "rlparse.cpp" } break; case 21: { -Parser_Lel_opt_export *__ref0 = (Parser_Lel_opt_export*)&redLel->user.opt_export; +Parser_Lel_opt_export *__ref0 = (Parser_Lel_opt_export*)&redLel->user.opt_export; #line 104 "rlparse.kl" - (__ref0)->isSet = true; + (__ref0)->isSet = true; -#line 4076 "rlparse.cpp" +#line 4076 "rlparse.cpp" } break; case 22: { -Parser_Lel_opt_export *__ref0 = (Parser_Lel_opt_export*)&redLel->user.opt_export; +Parser_Lel_opt_export *__ref0 = (Parser_Lel_opt_export*)&redLel->user.opt_export; #line 105 "rlparse.kl" - (__ref0)->isSet = false; + (__ref0)->isSet = false; -#line 4083 "rlparse.cpp" +#line 4083 "rlparse.cpp" } break; case 23: { #line 108 "rlparse.kl" @@ -4089,105 +4089,105 @@ case 23: { exportContext.remove( exportContext.length()-1 ); -#line 4091 "rlparse.cpp" +#line 4091 "rlparse.cpp" } break; case 24: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_join *__ref2 = (Parser_Lel_join*)&rhs[3]->user.join; -Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_token_type *__ref4 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_opt_export *__ref5 = (Parser_Lel_opt_export*)&rhs[0]->user.opt_export; -Parser_Lel_join *__ref6 = (Parser_Lel_join*)&rhs[3]->user.join; -Token *__ref7 = (Token*)&rhs[2]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_join *__ref2 = (Parser_Lel_join*)&rhs[3]->user.join; +Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_token_type *__ref4 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_opt_export *__ref5 = (Parser_Lel_opt_export*)&rhs[0]->user.opt_export; +Parser_Lel_join *__ref6 = (Parser_Lel_join*)&rhs[3]->user.join; +Token *__ref7 = (Token*)&rhs[2]->user.token; #line 113 "rlparse.kl" /* Main machine must be an instance. */ bool isInstance = false; - if ( strcmp((__ref0)->token.data, mainMachine) == 0 ) { - warning((__ref1)->token.loc) << + if ( strcmp((__ref0)->token.data, mainMachine) == 0 ) { + warning((__ref1)->token.loc) << "main machine will be implicitly instantiated" << endl; isInstance = true; } /* Generic creation of machine for instantiation and assignment. */ - MachineDef *machineDef = new MachineDef( (__ref2)->join ); - tryMachineDef( (__ref3)->token.loc, (__ref4)->token.data, machineDef, isInstance ); + MachineDef *machineDef = new MachineDef( (__ref2)->join ); + tryMachineDef( (__ref3)->token.loc, (__ref4)->token.data, machineDef, isInstance ); - if ( (__ref5)->isSet ) + if ( (__ref5)->isSet ) exportContext.remove( exportContext.length()-1 ); - (__ref6)->join->loc = (__ref7)->loc; + (__ref6)->join->loc = (__ref7)->loc; -#line 4122 "rlparse.cpp" +#line 4122 "rlparse.cpp" } break; case 25: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_join_or_lm *__ref2 = (Parser_Lel_join_or_lm*)&rhs[3]->user.join_or_lm; -Parser_Lel_opt_export *__ref3 = (Parser_Lel_opt_export*)&rhs[0]->user.opt_export; -Parser_Lel_join_or_lm *__ref4 = (Parser_Lel_join_or_lm*)&rhs[3]->user.join_or_lm; -Parser_Lel_join_or_lm *__ref5 = (Parser_Lel_join_or_lm*)&rhs[3]->user.join_or_lm; -Token *__ref6 = (Token*)&rhs[2]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_join_or_lm *__ref2 = (Parser_Lel_join_or_lm*)&rhs[3]->user.join_or_lm; +Parser_Lel_opt_export *__ref3 = (Parser_Lel_opt_export*)&rhs[0]->user.opt_export; +Parser_Lel_join_or_lm *__ref4 = (Parser_Lel_join_or_lm*)&rhs[3]->user.join_or_lm; +Parser_Lel_join_or_lm *__ref5 = (Parser_Lel_join_or_lm*)&rhs[3]->user.join_or_lm; +Token *__ref6 = (Token*)&rhs[2]->user.token; #line 133 "rlparse.kl" /* Generic creation of machine for instantiation and assignment. */ - tryMachineDef( (__ref0)->token.loc, (__ref1)->token.data, (__ref2)->machineDef, true ); + tryMachineDef( (__ref0)->token.loc, (__ref1)->token.data, (__ref2)->machineDef, true ); - if ( (__ref3)->isSet ) + if ( (__ref3)->isSet ) exportContext.remove( exportContext.length()-1 ); /* Pass a location to join_or_lm */ - if ( (__ref4)->machineDef->join != 0 ) - (__ref5)->machineDef->join->loc = (__ref6)->loc; + if ( (__ref4)->machineDef->join != 0 ) + (__ref5)->machineDef->join->loc = (__ref6)->loc; -#line 4145 "rlparse.cpp" +#line 4145 "rlparse.cpp" } break; case 26: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref3 = (Token*)&rhs[0]->user.token; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref3 = (Token*)&rhs[0]->user.token; #line 153 "rlparse.kl" /* Make/get the priority key. The name may have already been referenced * and therefore exist. */ PriorDictEl *priorDictEl; - if ( pd->priorDict.insert( (__ref0)->data, pd->nextPriorKey, &priorDictEl ) ) + if ( pd->priorDict.insert( (__ref0)->data, pd->nextPriorKey, &priorDictEl ) ) pd->nextPriorKey += 1; pd->curDefPriorKey = priorDictEl->value; /* Make/get the local error key. */ LocalErrDictEl *localErrDictEl; - if ( pd->localErrDict.insert( (__ref1)->data, pd->nextLocalErrKey, &localErrDictEl ) ) + if ( pd->localErrDict.insert( (__ref1)->data, pd->nextLocalErrKey, &localErrDictEl ) ) pd->nextLocalErrKey += 1; pd->curDefLocalErrKey = localErrDictEl->value; - (__ref2)->token = *(__ref3); + (__ref2)->token = *(__ref3); -#line 4170 "rlparse.cpp" +#line 4170 "rlparse.cpp" } break; case 27: { -Token *__ref0 = (Token*)&rhs[1]->user.token; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Token *__ref2 = (Token*)&rhs[1]->user.token; -Token *__ref3 = (Token*)&rhs[2]->user.token; -Token *__ref4 = (Token*)&rhs[1]->user.token; -Parser_Lel_inline_list *__ref5 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; +Token *__ref0 = (Token*)&rhs[1]->user.token; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Token *__ref2 = (Token*)&rhs[1]->user.token; +Token *__ref3 = (Token*)&rhs[2]->user.token; +Token *__ref4 = (Token*)&rhs[1]->user.token; +Parser_Lel_inline_list *__ref5 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; #line 171 "rlparse.kl" - if ( pd->actionDict.find( (__ref0)->data ) ) { + if ( pd->actionDict.find( (__ref0)->data ) ) { /* Recover by just ignoring the duplicate. */ - error((__ref1)->loc) << "action \"" << (__ref2)->data << "\" already defined" << endl; + error((__ref1)->loc) << "action \"" << (__ref2)->data << "\" already defined" << endl; } else { //cerr << "NEW ACTION " << $2->data << " " << $4->inlineList << endl; /* Add the action to the list of actions. */ - Action *newAction = new Action( (__ref3)->loc, (__ref4)->data, - (__ref5)->inlineList, pd->nextCondId++ ); + Action *newAction = new Action( (__ref3)->loc, (__ref4)->data, + (__ref5)->inlineList, pd->nextCondId++ ); /* Insert to list and dict. */ pd->actionList.append( newAction ); @@ -4195,2314 +4195,2314 @@ Parser_Lel_inline_list *__ref5 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_l } -#line 4197 "rlparse.cpp" +#line 4197 "rlparse.cpp" } break; case 28: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Token *__ref2 = (Token*)&rhs[2]->user.token; -Token *__ref3 = (Token*)&rhs[1]->user.token; -Token *__ref4 = (Token*)&rhs[1]->user.token; -Token *__ref5 = (Token*)&rhs[2]->user.token; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Token *__ref2 = (Token*)&rhs[2]->user.token; +Token *__ref3 = (Token*)&rhs[1]->user.token; +Token *__ref4 = (Token*)&rhs[1]->user.token; +Token *__ref5 = (Token*)&rhs[2]->user.token; #line 191 "rlparse.kl" - if ( ! pd->setAlphType( (__ref0)->loc, (__ref1)->data, (__ref2)->data ) ) { + if ( ! pd->setAlphType( (__ref0)->loc, (__ref1)->data, (__ref2)->data ) ) { // Recover by ignoring the alphtype statement. - error((__ref3)->loc) << "\"" << (__ref4)->data << - " " << (__ref5)->data << "\" is not a valid alphabet type" << endl; + error((__ref3)->loc) << "\"" << (__ref4)->data << + " " << (__ref5)->data << "\" is not a valid alphabet type" << endl; } -#line 4215 "rlparse.cpp" +#line 4215 "rlparse.cpp" } break; case 29: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Token *__ref2 = (Token*)&rhs[1]->user.token; -Token *__ref3 = (Token*)&rhs[1]->user.token; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Token *__ref2 = (Token*)&rhs[1]->user.token; +Token *__ref3 = (Token*)&rhs[1]->user.token; #line 200 "rlparse.kl" - if ( ! pd->setAlphType( (__ref0)->loc, (__ref1)->data ) ) { + if ( ! pd->setAlphType( (__ref0)->loc, (__ref1)->data ) ) { // Recover by ignoring the alphtype statement. - error((__ref2)->loc) << "\"" << (__ref3)->data << + error((__ref2)->loc) << "\"" << (__ref3)->data << "\" is not a valid alphabet type" << endl; } -#line 4231 "rlparse.cpp" +#line 4231 "rlparse.cpp" } break; case 30: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[2]->user.token_type; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; -Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&rhs[2]->user.token_type; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[2]->user.token_type; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[1]->user.token_type; +Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&rhs[2]->user.token_type; #line 210 "rlparse.kl" // Save the upper and lower ends of the range and emit the line number. - pd->lowerNum = (__ref0)->token.data; - pd->upperNum = (__ref1)->token.data; - pd->rangeLowLoc = (__ref2)->token.loc; - pd->rangeHighLoc = (__ref3)->token.loc; + pd->lowerNum = (__ref0)->token.data; + pd->upperNum = (__ref1)->token.data; + pd->rangeLowLoc = (__ref2)->token.loc; + pd->rangeHighLoc = (__ref3)->token.loc; -#line 4247 "rlparse.cpp" +#line 4247 "rlparse.cpp" } break; case 31: { -Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; +Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 219 "rlparse.kl" - pd->getKeyExpr = (__ref0)->inlineList; + pd->getKeyExpr = (__ref0)->inlineList; -#line 4256 "rlparse.cpp" +#line 4256 "rlparse.cpp" } break; case 32: { -Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; +Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 224 "rlparse.kl" - pd->accessExpr = (__ref0)->inlineList; + pd->accessExpr = (__ref0)->inlineList; -#line 4265 "rlparse.cpp" +#line 4265 "rlparse.cpp" } break; case 33: { -Token *__ref0 = (Token*)&rhs[2]->user.token; -Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; -Token *__ref2 = (Token*)&rhs[2]->user.token; +Token *__ref0 = (Token*)&rhs[2]->user.token; +Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; +Token *__ref2 = (Token*)&rhs[2]->user.token; #line 229 "rlparse.kl" /* FIXME: Need to implement the rest of this. */ - bool wasSet = pd->setVariable( (__ref0)->data, (__ref1)->inlineList ); + bool wasSet = pd->setVariable( (__ref0)->data, (__ref1)->inlineList ); if ( !wasSet ) - error((__ref2)->loc) << "bad variable name" << endl; + error((__ref2)->loc) << "bad variable name" << endl; -#line 4279 "rlparse.cpp" +#line 4279 "rlparse.cpp" } break; case 36: { -Parser_Lel_join_or_lm *__ref0 = (Parser_Lel_join_or_lm*)&redLel->user.join_or_lm; -Parser_Lel_join *__ref1 = (Parser_Lel_join*)&rhs[0]->user.join; +Parser_Lel_join_or_lm *__ref0 = (Parser_Lel_join_or_lm*)&redLel->user.join_or_lm; +Parser_Lel_join *__ref1 = (Parser_Lel_join*)&rhs[0]->user.join; #line 249 "rlparse.kl" - (__ref0)->machineDef = new MachineDef( (__ref1)->join ); + (__ref0)->machineDef = new MachineDef( (__ref1)->join ); -#line 4289 "rlparse.cpp" +#line 4289 "rlparse.cpp" } break; case 37: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Parser_Lel_lm_part_list *__ref1 = (Parser_Lel_lm_part_list*)&rhs[1]->user.lm_part_list; -Parser_Lel_lm_part_list *__ref2 = (Parser_Lel_lm_part_list*)&rhs[1]->user.lm_part_list; -Parser_Lel_join_or_lm *__ref3 = (Parser_Lel_join_or_lm*)&redLel->user.join_or_lm; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Parser_Lel_lm_part_list *__ref1 = (Parser_Lel_lm_part_list*)&rhs[1]->user.lm_part_list; +Parser_Lel_lm_part_list *__ref2 = (Parser_Lel_lm_part_list*)&rhs[1]->user.lm_part_list; +Parser_Lel_join_or_lm *__ref3 = (Parser_Lel_join_or_lm*)&redLel->user.join_or_lm; #line 253 "rlparse.kl" /* Create a new factor going to a longest match structure. Record * in the parse data that we have a longest match. */ - LongestMatch *lm = new LongestMatch( (__ref0)->loc, (__ref1)->lmPartList ); + LongestMatch *lm = new LongestMatch( (__ref0)->loc, (__ref1)->lmPartList ); pd->lmList.append( lm ); - for ( LmPartList::Iter lmp = *((__ref2)->lmPartList); lmp.lte(); lmp++ ) + for ( LmPartList::Iter lmp = *((__ref2)->lmPartList); lmp.lte(); lmp++ ) lmp->longestMatch = lm; - (__ref3)->machineDef = new MachineDef( lm ); + (__ref3)->machineDef = new MachineDef( lm ); -#line 4307 "rlparse.cpp" +#line 4307 "rlparse.cpp" } break; case 38: { -Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&rhs[1]->user.longest_match_part; -Parser_Lel_lm_part_list *__ref1 = (Parser_Lel_lm_part_list*)&rhs[0]->user.lm_part_list; -Parser_Lel_longest_match_part *__ref2 = (Parser_Lel_longest_match_part*)&rhs[1]->user.longest_match_part; -Parser_Lel_lm_part_list *__ref3 = (Parser_Lel_lm_part_list*)&redLel->user.lm_part_list; -Parser_Lel_lm_part_list *__ref4 = (Parser_Lel_lm_part_list*)&rhs[0]->user.lm_part_list; +Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&rhs[1]->user.longest_match_part; +Parser_Lel_lm_part_list *__ref1 = (Parser_Lel_lm_part_list*)&rhs[0]->user.lm_part_list; +Parser_Lel_longest_match_part *__ref2 = (Parser_Lel_longest_match_part*)&rhs[1]->user.longest_match_part; +Parser_Lel_lm_part_list *__ref3 = (Parser_Lel_lm_part_list*)&redLel->user.lm_part_list; +Parser_Lel_lm_part_list *__ref4 = (Parser_Lel_lm_part_list*)&rhs[0]->user.lm_part_list; #line 270 "rlparse.kl" - if ( (__ref0)->lmPart != 0 ) - (__ref1)->lmPartList->append( (__ref2)->lmPart ); - (__ref3)->lmPartList = (__ref4)->lmPartList; + if ( (__ref0)->lmPart != 0 ) + (__ref1)->lmPartList->append( (__ref2)->lmPart ); + (__ref3)->lmPartList = (__ref4)->lmPartList; -#line 4322 "rlparse.cpp" +#line 4322 "rlparse.cpp" } break; case 39: { -Parser_Lel_lm_part_list *__ref0 = (Parser_Lel_lm_part_list*)&redLel->user.lm_part_list; -Parser_Lel_longest_match_part *__ref1 = (Parser_Lel_longest_match_part*)&rhs[0]->user.longest_match_part; -Parser_Lel_lm_part_list *__ref2 = (Parser_Lel_lm_part_list*)&redLel->user.lm_part_list; -Parser_Lel_longest_match_part *__ref3 = (Parser_Lel_longest_match_part*)&rhs[0]->user.longest_match_part; +Parser_Lel_lm_part_list *__ref0 = (Parser_Lel_lm_part_list*)&redLel->user.lm_part_list; +Parser_Lel_longest_match_part *__ref1 = (Parser_Lel_longest_match_part*)&rhs[0]->user.longest_match_part; +Parser_Lel_lm_part_list *__ref2 = (Parser_Lel_lm_part_list*)&redLel->user.lm_part_list; +Parser_Lel_longest_match_part *__ref3 = (Parser_Lel_longest_match_part*)&rhs[0]->user.longest_match_part; #line 277 "rlparse.kl" /* Create a new list with the part. */ - (__ref0)->lmPartList = new LmPartList; - if ( (__ref1)->lmPart != 0 ) - (__ref2)->lmPartList->append( (__ref3)->lmPart ); + (__ref0)->lmPartList = new LmPartList; + if ( (__ref1)->lmPart != 0 ) + (__ref2)->lmPartList->append( (__ref3)->lmPart ); -#line 4337 "rlparse.cpp" +#line 4337 "rlparse.cpp" } break; case 40: { -Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; +Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; #line 290 "rlparse.kl" - (__ref0)->lmPart = 0; + (__ref0)->lmPart = 0; -#line 4344 "rlparse.cpp" +#line 4344 "rlparse.cpp" } break; case 41: { -Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; +Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; #line 292 "rlparse.kl" - (__ref0)->lmPart = 0; + (__ref0)->lmPart = 0; -#line 4351 "rlparse.cpp" +#line 4351 "rlparse.cpp" } break; case 42: { -Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; -Parser_Lel_opt_lm_part_action *__ref1 = (Parser_Lel_opt_lm_part_action*)&rhs[1]->user.opt_lm_part_action; -Parser_Lel_longest_match_part *__ref2 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; -Parser_Lel_join *__ref3 = (Parser_Lel_join*)&rhs[0]->user.join; -Token *__ref4 = (Token*)&rhs[2]->user.token; -Parser_Lel_join *__ref5 = (Parser_Lel_join*)&rhs[0]->user.join; -Token *__ref6 = (Token*)&rhs[2]->user.token; +Parser_Lel_longest_match_part *__ref0 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; +Parser_Lel_opt_lm_part_action *__ref1 = (Parser_Lel_opt_lm_part_action*)&rhs[1]->user.opt_lm_part_action; +Parser_Lel_longest_match_part *__ref2 = (Parser_Lel_longest_match_part*)&redLel->user.longest_match_part; +Parser_Lel_join *__ref3 = (Parser_Lel_join*)&rhs[0]->user.join; +Token *__ref4 = (Token*)&rhs[2]->user.token; +Parser_Lel_join *__ref5 = (Parser_Lel_join*)&rhs[0]->user.join; +Token *__ref6 = (Token*)&rhs[2]->user.token; #line 294 "rlparse.kl" - (__ref0)->lmPart = 0; - Action *action = (__ref1)->action; + (__ref0)->lmPart = 0; + Action *action = (__ref1)->action; if ( action != 0 ) action->isLmAction = true; - (__ref2)->lmPart = new LongestMatchPart( (__ref3)->join, action, - (__ref4)->loc, pd->nextLongestMatchId++ ); + (__ref2)->lmPart = new LongestMatchPart( (__ref3)->join, action, + (__ref4)->loc, pd->nextLongestMatchId++ ); /* Provide a location to join. Unfortunately We don't * have the start of the join as in other occurances. Use the end. */ - (__ref5)->join->loc = (__ref6)->loc; + (__ref5)->join->loc = (__ref6)->loc; -#line 4375 "rlparse.cpp" +#line 4375 "rlparse.cpp" } break; case 43: { -Parser_Lel_opt_lm_part_action *__ref0 = (Parser_Lel_opt_lm_part_action*)&redLel->user.opt_lm_part_action; -Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[1]->user.action_ref; +Parser_Lel_opt_lm_part_action *__ref0 = (Parser_Lel_opt_lm_part_action*)&redLel->user.opt_lm_part_action; +Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[1]->user.action_ref; #line 313 "rlparse.kl" - (__ref0)->action = (__ref1)->action; + (__ref0)->action = (__ref1)->action; -#line 4385 "rlparse.cpp" +#line 4385 "rlparse.cpp" } break; case 44: { -Parser_Lel_opt_lm_part_action *__ref0 = (Parser_Lel_opt_lm_part_action*)&redLel->user.opt_lm_part_action; -Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[0]->user.action_ref; +Parser_Lel_opt_lm_part_action *__ref0 = (Parser_Lel_opt_lm_part_action*)&redLel->user.opt_lm_part_action; +Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[0]->user.action_ref; #line 317 "rlparse.kl" - (__ref0)->action = (__ref1)->action; + (__ref0)->action = (__ref1)->action; -#line 4395 "rlparse.cpp" +#line 4395 "rlparse.cpp" } break; case 45: { -Parser_Lel_opt_lm_part_action *__ref0 = (Parser_Lel_opt_lm_part_action*)&redLel->user.opt_lm_part_action; +Parser_Lel_opt_lm_part_action *__ref0 = (Parser_Lel_opt_lm_part_action*)&redLel->user.opt_lm_part_action; #line 321 "rlparse.kl" - (__ref0)->action = 0; + (__ref0)->action = 0; -#line 4404 "rlparse.cpp" +#line 4404 "rlparse.cpp" } break; case 46: { -Parser_Lel_join *__ref0 = (Parser_Lel_join*)&rhs[0]->user.join; -Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[2]->user.expression; -Parser_Lel_join *__ref2 = (Parser_Lel_join*)&redLel->user.join; -Parser_Lel_join *__ref3 = (Parser_Lel_join*)&rhs[0]->user.join; +Parser_Lel_join *__ref0 = (Parser_Lel_join*)&rhs[0]->user.join; +Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[2]->user.expression; +Parser_Lel_join *__ref2 = (Parser_Lel_join*)&redLel->user.join; +Parser_Lel_join *__ref3 = (Parser_Lel_join*)&rhs[0]->user.join; #line 332 "rlparse.kl" /* Append the expression to the list and return it. */ - (__ref0)->join->exprList.append( (__ref1)->expression ); - (__ref2)->join = (__ref3)->join; + (__ref0)->join->exprList.append( (__ref1)->expression ); + (__ref2)->join = (__ref3)->join; -#line 4418 "rlparse.cpp" +#line 4418 "rlparse.cpp" } break; case 47: { -Parser_Lel_join *__ref0 = (Parser_Lel_join*)&redLel->user.join; -Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; +Parser_Lel_join *__ref0 = (Parser_Lel_join*)&redLel->user.join; +Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; #line 338 "rlparse.kl" - (__ref0)->join = new Join( (__ref1)->expression ); + (__ref0)->join = new Join( (__ref1)->expression ); -#line 4428 "rlparse.cpp" +#line 4428 "rlparse.cpp" } break; case 48: { -Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; -Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; -Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; +Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; +Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; +Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; #line 348 "rlparse.kl" - (__ref0)->expression = new Expression( (__ref1)->expression, - (__ref2)->term, Expression::OrType ); + (__ref0)->expression = new Expression( (__ref1)->expression, + (__ref2)->term, Expression::OrType ); -#line 4440 "rlparse.cpp" +#line 4440 "rlparse.cpp" } break; case 49: { -Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; -Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; -Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; +Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; +Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; +Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; #line 353 "rlparse.kl" - (__ref0)->expression = new Expression( (__ref1)->expression, - (__ref2)->term, Expression::IntersectType ); + (__ref0)->expression = new Expression( (__ref1)->expression, + (__ref2)->term, Expression::IntersectType ); -#line 4452 "rlparse.cpp" +#line 4452 "rlparse.cpp" } break; case 50: { -Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; -Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; -Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; +Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; +Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; +Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; #line 358 "rlparse.kl" - (__ref0)->expression = new Expression( (__ref1)->expression, - (__ref2)->term, Expression::SubtractType ); + (__ref0)->expression = new Expression( (__ref1)->expression, + (__ref2)->term, Expression::SubtractType ); -#line 4464 "rlparse.cpp" +#line 4464 "rlparse.cpp" } break; case 51: { -Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; -Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; -Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; +Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; +Parser_Lel_expression *__ref1 = (Parser_Lel_expression*)&rhs[0]->user.expression; +Parser_Lel_term_short *__ref2 = (Parser_Lel_term_short*)&rhs[2]->user.term_short; #line 363 "rlparse.kl" - (__ref0)->expression = new Expression( (__ref1)->expression, - (__ref2)->term, Expression::StrongSubtractType ); + (__ref0)->expression = new Expression( (__ref1)->expression, + (__ref2)->term, Expression::StrongSubtractType ); -#line 4476 "rlparse.cpp" +#line 4476 "rlparse.cpp" } break; case 52: { -Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; -Parser_Lel_term_short *__ref1 = (Parser_Lel_term_short*)&rhs[0]->user.term_short; +Parser_Lel_expression *__ref0 = (Parser_Lel_expression*)&redLel->user.expression; +Parser_Lel_term_short *__ref1 = (Parser_Lel_term_short*)&rhs[0]->user.term_short; #line 368 "rlparse.kl" - (__ref0)->expression = new Expression( (__ref1)->term ); + (__ref0)->expression = new Expression( (__ref1)->term ); -#line 4486 "rlparse.cpp" +#line 4486 "rlparse.cpp" } break; case 53: { -Parser_Lel_term_short *__ref0 = (Parser_Lel_term_short*)&redLel->user.term_short; -Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; +Parser_Lel_term_short *__ref0 = (Parser_Lel_term_short*)&redLel->user.term_short; +Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; #line 389 "rlparse.kl" - (__ref0)->term = (__ref1)->term; + (__ref0)->term = (__ref1)->term; -#line 4496 "rlparse.cpp" +#line 4496 "rlparse.cpp" } break; case 54: { -Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; -Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; -Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[1]->user.factor_with_label; +Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; +Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; +Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[1]->user.factor_with_label; #line 399 "rlparse.kl" - (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug ); + (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug ); -#line 4507 "rlparse.cpp" +#line 4507 "rlparse.cpp" } break; case 55: { -Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; -Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; -Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; +Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; +Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; +Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; #line 403 "rlparse.kl" - (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug ); + (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug ); -#line 4518 "rlparse.cpp" +#line 4518 "rlparse.cpp" } break; case 56: { -Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; -Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; -Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; +Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; +Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; +Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; #line 407 "rlparse.kl" - (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug, Term::RightStartType ); + (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug, Term::RightStartType ); -#line 4529 "rlparse.cpp" +#line 4529 "rlparse.cpp" } break; case 57: { -Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; -Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; -Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; +Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; +Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; +Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; #line 411 "rlparse.kl" - (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug, Term::RightFinishType ); + (__ref0)->term = new Term( (__ref1)->term, (__ref2)->factorWithAug, Term::RightFinishType ); -#line 4540 "rlparse.cpp" +#line 4540 "rlparse.cpp" } break; case 58: { -Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; -Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; -Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; +Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; +Parser_Lel_term *__ref1 = (Parser_Lel_term*)&rhs[0]->user.term; +Parser_Lel_factor_with_label *__ref2 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; #line 415 "rlparse.kl" - (__ref0)->term = new Term( (__ref1)->term, - (__ref2)->factorWithAug, Term::LeftType ); + (__ref0)->term = new Term( (__ref1)->term, + (__ref2)->factorWithAug, Term::LeftType ); -#line 4552 "rlparse.cpp" +#line 4552 "rlparse.cpp" } break; case 59: { -Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; -Parser_Lel_factor_with_label *__ref1 = (Parser_Lel_factor_with_label*)&rhs[0]->user.factor_with_label; +Parser_Lel_term *__ref0 = (Parser_Lel_term*)&redLel->user.term; +Parser_Lel_factor_with_label *__ref1 = (Parser_Lel_factor_with_label*)&rhs[0]->user.factor_with_label; #line 420 "rlparse.kl" - (__ref0)->term = new Term( (__ref1)->factorWithAug ); + (__ref0)->term = new Term( (__ref1)->factorWithAug ); -#line 4562 "rlparse.cpp" +#line 4562 "rlparse.cpp" } break; case 60: { -Parser_Lel_factor_with_label *__ref0 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Parser_Lel_factor_with_label *__ref3 = (Parser_Lel_factor_with_label*)&redLel->user.factor_with_label; -Parser_Lel_factor_with_label *__ref4 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; +Parser_Lel_factor_with_label *__ref0 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor_with_label *__ref3 = (Parser_Lel_factor_with_label*)&redLel->user.factor_with_label; +Parser_Lel_factor_with_label *__ref4 = (Parser_Lel_factor_with_label*)&rhs[2]->user.factor_with_label; #line 430 "rlparse.kl" /* Add the label to the list and pass the factor up. */ - (__ref0)->factorWithAug->labels.prepend( Label((__ref1)->loc, (__ref2)->data) ); - (__ref3)->factorWithAug = (__ref4)->factorWithAug; + (__ref0)->factorWithAug->labels.prepend( Label((__ref1)->loc, (__ref2)->data) ); + (__ref3)->factorWithAug = (__ref4)->factorWithAug; -#line 4577 "rlparse.cpp" +#line 4577 "rlparse.cpp" } break; case 61: { -Parser_Lel_factor_with_label *__ref0 = (Parser_Lel_factor_with_label*)&redLel->user.factor_with_label; -Parser_Lel_factor_with_ep *__ref1 = (Parser_Lel_factor_with_ep*)&rhs[0]->user.factor_with_ep; +Parser_Lel_factor_with_label *__ref0 = (Parser_Lel_factor_with_label*)&redLel->user.factor_with_label; +Parser_Lel_factor_with_ep *__ref1 = (Parser_Lel_factor_with_ep*)&rhs[0]->user.factor_with_ep; #line 436 "rlparse.kl" - (__ref0)->factorWithAug = (__ref1)->factorWithAug; + (__ref0)->factorWithAug = (__ref1)->factorWithAug; -#line 4587 "rlparse.cpp" +#line 4587 "rlparse.cpp" } break; case 62: { -Parser_Lel_factor_with_ep *__ref0 = (Parser_Lel_factor_with_ep*)&rhs[0]->user.factor_with_ep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_ep *__ref2 = (Parser_Lel_factor_with_ep*)&redLel->user.factor_with_ep; -Parser_Lel_factor_with_ep *__ref3 = (Parser_Lel_factor_with_ep*)&rhs[0]->user.factor_with_ep; +Parser_Lel_factor_with_ep *__ref0 = (Parser_Lel_factor_with_ep*)&rhs[0]->user.factor_with_ep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_ep *__ref2 = (Parser_Lel_factor_with_ep*)&redLel->user.factor_with_ep; +Parser_Lel_factor_with_ep *__ref3 = (Parser_Lel_factor_with_ep*)&rhs[0]->user.factor_with_ep; #line 446 "rlparse.kl" /* Add the target to the list and return the factor object. */ - (__ref0)->factorWithAug->epsilonLinks.append( EpsilonLink( (__ref1)->loc, nameRef ) ); - (__ref2)->factorWithAug = (__ref3)->factorWithAug; + (__ref0)->factorWithAug->epsilonLinks.append( EpsilonLink( (__ref1)->loc, nameRef ) ); + (__ref2)->factorWithAug = (__ref3)->factorWithAug; -#line 4601 "rlparse.cpp" +#line 4601 "rlparse.cpp" } break; case 63: { -Parser_Lel_factor_with_ep *__ref0 = (Parser_Lel_factor_with_ep*)&redLel->user.factor_with_ep; -Parser_Lel_factor_with_aug *__ref1 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_ep *__ref0 = (Parser_Lel_factor_with_ep*)&redLel->user.factor_with_ep; +Parser_Lel_factor_with_aug *__ref1 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 452 "rlparse.kl" - (__ref0)->factorWithAug = (__ref1)->factorWithAug; + (__ref0)->factorWithAug = (__ref1)->factorWithAug; -#line 4611 "rlparse.cpp" +#line 4611 "rlparse.cpp" } break; case 64: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 462 "rlparse.kl" /* Append the action to the factorWithAug, record the refernce from * factorWithAug to the action and pass up the factorWithAug. */ - (__ref0)->factorWithAug->actions.append( - ParserAction( (__ref1)->loc, (__ref2)->augType, 0, (__ref3)->action ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->actions.append( + ParserAction( (__ref1)->loc, (__ref2)->augType, 0, (__ref3)->action ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4629 "rlparse.cpp" +#line 4629 "rlparse.cpp" } break; case 65: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_priority_aug *__ref2 = (Parser_Lel_priority_aug*)&rhs[2]->user.priority_aug; -Parser_Lel_factor_with_aug *__ref3 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_priority_aug *__ref2 = (Parser_Lel_priority_aug*)&rhs[2]->user.priority_aug; +Parser_Lel_factor_with_aug *__ref3 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 470 "rlparse.kl" /* Append the named priority to the factorWithAug and pass it up. */ - (__ref0)->factorWithAug->priorityAugs.append( - PriorityAug( (__ref1)->augType, pd->curDefPriorKey, (__ref2)->priorityNum ) ); - (__ref3)->factorWithAug = (__ref4)->factorWithAug; + (__ref0)->factorWithAug->priorityAugs.append( + PriorityAug( (__ref1)->augType, pd->curDefPriorKey, (__ref2)->priorityNum ) ); + (__ref3)->factorWithAug = (__ref4)->factorWithAug; -#line 4645 "rlparse.cpp" +#line 4645 "rlparse.cpp" } break; case 66: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_priority_name *__ref2 = (Parser_Lel_priority_name*)&rhs[3]->user.priority_name; -Parser_Lel_priority_aug *__ref3 = (Parser_Lel_priority_aug*)&rhs[5]->user.priority_aug; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_priority_name *__ref2 = (Parser_Lel_priority_name*)&rhs[3]->user.priority_name; +Parser_Lel_priority_aug *__ref3 = (Parser_Lel_priority_aug*)&rhs[5]->user.priority_aug; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 477 "rlparse.kl" /* Append the priority using a default name. */ - (__ref0)->factorWithAug->priorityAugs.append( - PriorityAug( (__ref1)->augType, (__ref2)->priorityName, (__ref3)->priorityNum ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->priorityAugs.append( + PriorityAug( (__ref1)->augType, (__ref2)->priorityName, (__ref3)->priorityNum ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4662 "rlparse.cpp" +#line 4662 "rlparse.cpp" } break; case 67: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 484 "rlparse.kl" - (__ref0)->factorWithAug->conditions.append( ConditionTest( (__ref1)->loc, - (__ref2)->augType, (__ref3)->action, true ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->conditions.append( ConditionTest( (__ref1)->loc, + (__ref2)->augType, (__ref3)->action, true ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4678 "rlparse.cpp" +#line 4678 "rlparse.cpp" } break; case 68: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[3]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[3]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 490 "rlparse.kl" - (__ref0)->factorWithAug->conditions.append( ConditionTest( (__ref1)->loc, - (__ref2)->augType, (__ref3)->action, false ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->conditions.append( ConditionTest( (__ref1)->loc, + (__ref2)->augType, (__ref3)->action, false ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4694 "rlparse.cpp" +#line 4694 "rlparse.cpp" } break; case 69: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 496 "rlparse.kl" /* Append the action, pass it up. */ - (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, - (__ref2)->augType, 0, (__ref3)->action ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, + (__ref2)->augType, 0, (__ref3)->action ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4711 "rlparse.cpp" +#line 4711 "rlparse.cpp" } break; case 70: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 503 "rlparse.kl" /* Append the action, pass it up. */ - (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, - (__ref2)->augType, 0, (__ref3)->action ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, + (__ref2)->augType, 0, (__ref3)->action ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4728 "rlparse.cpp" +#line 4728 "rlparse.cpp" } break; case 71: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 510 "rlparse.kl" /* Append the action, pass it up. */ - (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, - (__ref2)->augType, 0, (__ref3)->action ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, + (__ref2)->augType, 0, (__ref3)->action ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4745 "rlparse.cpp" +#line 4745 "rlparse.cpp" } break; case 72: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 517 "rlparse.kl" /* Append the action to the factorWithAug, record the refernce from * factorWithAug to the action and pass up the factorWithAug. */ - (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, - (__ref2)->augType, pd->curDefLocalErrKey, (__ref3)->action ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, + (__ref2)->augType, pd->curDefLocalErrKey, (__ref3)->action ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4763 "rlparse.cpp" +#line 4763 "rlparse.cpp" } break; case 73: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; -Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_action_ref *__ref3 = (Parser_Lel_action_ref*)&rhs[2]->user.action_ref; +Parser_Lel_factor_with_aug *__ref4 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 525 "rlparse.kl" /* Append the action to the factorWithAug, record the refernce from * factorWithAug to the action and pass up the factorWithAug. */ - (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, - (__ref2)->augType, pd->curDefLocalErrKey, (__ref3)->action ) ); - (__ref4)->factorWithAug = (__ref5)->factorWithAug; + (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, + (__ref2)->augType, pd->curDefLocalErrKey, (__ref3)->action ) ); + (__ref4)->factorWithAug = (__ref5)->factorWithAug; -#line 4781 "rlparse.cpp" +#line 4781 "rlparse.cpp" } break; case 74: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; -Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; -Parser_Lel_local_err_name *__ref3 = (Parser_Lel_local_err_name*)&rhs[3]->user.local_err_name; -Parser_Lel_action_ref *__ref4 = (Parser_Lel_action_ref*)&rhs[5]->user.action_ref; -Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_aug *__ref6 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; +Parser_Lel_aug_type *__ref1 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&rhs[1]->user.aug_type; +Parser_Lel_local_err_name *__ref3 = (Parser_Lel_local_err_name*)&rhs[3]->user.local_err_name; +Parser_Lel_action_ref *__ref4 = (Parser_Lel_action_ref*)&rhs[5]->user.action_ref; +Parser_Lel_factor_with_aug *__ref5 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_aug *__ref6 = (Parser_Lel_factor_with_aug*)&rhs[0]->user.factor_with_aug; #line 533 "rlparse.kl" /* Append the action to the factorWithAug, record the refernce from * factorWithAug to the action and pass up the factorWithAug. */ - (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, - (__ref2)->augType, (__ref3)->error_name, (__ref4)->action ) ); - (__ref5)->factorWithAug = (__ref6)->factorWithAug; + (__ref0)->factorWithAug->actions.append( ParserAction( (__ref1)->loc, + (__ref2)->augType, (__ref3)->error_name, (__ref4)->action ) ); + (__ref5)->factorWithAug = (__ref6)->factorWithAug; -#line 4800 "rlparse.cpp" +#line 4800 "rlparse.cpp" } break; case 75: { -Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; -Parser_Lel_factor_with_rep *__ref1 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_with_aug *__ref0 = (Parser_Lel_factor_with_aug*)&redLel->user.factor_with_aug; +Parser_Lel_factor_with_rep *__ref1 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; #line 541 "rlparse.kl" - (__ref0)->factorWithAug = new FactorWithAug( (__ref1)->factorWithRep ); + (__ref0)->factorWithAug = new FactorWithAug( (__ref1)->factorWithRep ); -#line 4810 "rlparse.cpp" +#line 4810 "rlparse.cpp" } break; case 76: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 554 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_finish; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_finish; -#line 4819 "rlparse.cpp" +#line 4819 "rlparse.cpp" } break; case 77: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 555 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; -#line 4828 "rlparse.cpp" +#line 4828 "rlparse.cpp" } break; case 78: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 556 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; -#line 4837 "rlparse.cpp" +#line 4837 "rlparse.cpp" } break; case 79: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 557 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; -#line 4846 "rlparse.cpp" +#line 4846 "rlparse.cpp" } break; case 80: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 562 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; -#line 4855 "rlparse.cpp" +#line 4855 "rlparse.cpp" } break; case 81: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 563 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; -#line 4864 "rlparse.cpp" +#line 4864 "rlparse.cpp" } break; case 82: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 564 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; -#line 4873 "rlparse.cpp" +#line 4873 "rlparse.cpp" } break; case 83: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 565 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; -#line 4882 "rlparse.cpp" +#line 4882 "rlparse.cpp" } break; case 84: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 566 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; -#line 4891 "rlparse.cpp" +#line 4891 "rlparse.cpp" } break; case 85: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 567 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; -#line 4900 "rlparse.cpp" +#line 4900 "rlparse.cpp" } break; case 86: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 568 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all; -#line 4909 "rlparse.cpp" +#line 4909 "rlparse.cpp" } break; case 87: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 569 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start; -#line 4918 "rlparse.cpp" +#line 4918 "rlparse.cpp" } break; case 88: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 570 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_leave; -#line 4927 "rlparse.cpp" +#line 4927 "rlparse.cpp" } break; case 89: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 579 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_to_state; -#line 4936 "rlparse.cpp" +#line 4936 "rlparse.cpp" } break; case 90: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 581 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_to_state; -#line 4945 "rlparse.cpp" +#line 4945 "rlparse.cpp" } break; case 91: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 584 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_to_state; -#line 4954 "rlparse.cpp" +#line 4954 "rlparse.cpp" } break; case 92: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 586 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_to_state; -#line 4963 "rlparse.cpp" +#line 4963 "rlparse.cpp" } break; case 93: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 589 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_to_state; -#line 4972 "rlparse.cpp" +#line 4972 "rlparse.cpp" } break; case 94: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 591 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_to_state; -#line 4981 "rlparse.cpp" +#line 4981 "rlparse.cpp" } break; case 95: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 594 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_to_state; -#line 4990 "rlparse.cpp" +#line 4990 "rlparse.cpp" } break; case 96: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 596 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_to_state; -#line 4999 "rlparse.cpp" +#line 4999 "rlparse.cpp" } break; case 97: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 599 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_to_state; -#line 5008 "rlparse.cpp" +#line 5008 "rlparse.cpp" } break; case 98: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 601 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_to_state; -#line 5017 "rlparse.cpp" +#line 5017 "rlparse.cpp" } break; case 99: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 604 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_to_state; -#line 5026 "rlparse.cpp" +#line 5026 "rlparse.cpp" } break; case 100: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 606 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_to_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_to_state; -#line 5035 "rlparse.cpp" +#line 5035 "rlparse.cpp" } break; case 101: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 615 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_from_state; -#line 5044 "rlparse.cpp" +#line 5044 "rlparse.cpp" } break; case 102: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 617 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_from_state; -#line 5053 "rlparse.cpp" +#line 5053 "rlparse.cpp" } break; case 103: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 620 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_from_state; -#line 5062 "rlparse.cpp" +#line 5062 "rlparse.cpp" } break; case 104: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 622 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_from_state; -#line 5071 "rlparse.cpp" +#line 5071 "rlparse.cpp" } break; case 105: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 625 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_from_state; -#line 5080 "rlparse.cpp" +#line 5080 "rlparse.cpp" } break; case 106: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 627 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_from_state; -#line 5089 "rlparse.cpp" +#line 5089 "rlparse.cpp" } break; case 107: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 630 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_from_state; -#line 5098 "rlparse.cpp" +#line 5098 "rlparse.cpp" } break; case 108: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 632 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_from_state; -#line 5107 "rlparse.cpp" +#line 5107 "rlparse.cpp" } break; case 109: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 635 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_from_state; -#line 5116 "rlparse.cpp" +#line 5116 "rlparse.cpp" } break; case 110: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 637 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_from_state; -#line 5125 "rlparse.cpp" +#line 5125 "rlparse.cpp" } break; case 111: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 640 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_from_state; -#line 5134 "rlparse.cpp" +#line 5134 "rlparse.cpp" } break; case 112: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 642 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_from_state; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_from_state; -#line 5143 "rlparse.cpp" +#line 5143 "rlparse.cpp" } break; case 113: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 651 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_eof; -#line 5152 "rlparse.cpp" +#line 5152 "rlparse.cpp" } break; case 114: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 653 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_eof; -#line 5161 "rlparse.cpp" +#line 5161 "rlparse.cpp" } break; case 115: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 656 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_eof; -#line 5170 "rlparse.cpp" +#line 5170 "rlparse.cpp" } break; case 116: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 658 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_eof; -#line 5179 "rlparse.cpp" +#line 5179 "rlparse.cpp" } break; case 117: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 661 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_eof; -#line 5188 "rlparse.cpp" +#line 5188 "rlparse.cpp" } break; case 118: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 663 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_eof; -#line 5197 "rlparse.cpp" +#line 5197 "rlparse.cpp" } break; case 119: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 666 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_eof; -#line 5206 "rlparse.cpp" +#line 5206 "rlparse.cpp" } break; case 120: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 668 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_eof; -#line 5215 "rlparse.cpp" +#line 5215 "rlparse.cpp" } break; case 121: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 671 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_eof; -#line 5224 "rlparse.cpp" +#line 5224 "rlparse.cpp" } break; case 122: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 673 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_eof; -#line 5233 "rlparse.cpp" +#line 5233 "rlparse.cpp" } break; case 123: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 676 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_eof; -#line 5242 "rlparse.cpp" +#line 5242 "rlparse.cpp" } break; case 124: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 678 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_eof; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_eof; -#line 5251 "rlparse.cpp" +#line 5251 "rlparse.cpp" } break; case 125: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 687 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_gbl_error; -#line 5260 "rlparse.cpp" +#line 5260 "rlparse.cpp" } break; case 126: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 689 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_gbl_error; -#line 5269 "rlparse.cpp" +#line 5269 "rlparse.cpp" } break; case 127: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 692 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_gbl_error; -#line 5278 "rlparse.cpp" +#line 5278 "rlparse.cpp" } break; case 128: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 694 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_gbl_error; -#line 5287 "rlparse.cpp" +#line 5287 "rlparse.cpp" } break; case 129: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 697 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_gbl_error; -#line 5296 "rlparse.cpp" +#line 5296 "rlparse.cpp" } break; case 130: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 699 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_gbl_error; -#line 5305 "rlparse.cpp" +#line 5305 "rlparse.cpp" } break; case 131: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 702 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_gbl_error; -#line 5314 "rlparse.cpp" +#line 5314 "rlparse.cpp" } break; case 132: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 704 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_gbl_error; -#line 5323 "rlparse.cpp" +#line 5323 "rlparse.cpp" } break; case 133: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 707 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_gbl_error; -#line 5332 "rlparse.cpp" +#line 5332 "rlparse.cpp" } break; case 134: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 709 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_gbl_error; -#line 5341 "rlparse.cpp" +#line 5341 "rlparse.cpp" } break; case 135: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 712 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_gbl_error; -#line 5350 "rlparse.cpp" +#line 5350 "rlparse.cpp" } break; case 136: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 714 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_gbl_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_gbl_error; -#line 5359 "rlparse.cpp" +#line 5359 "rlparse.cpp" } break; case 137: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 724 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_local_error; -#line 5368 "rlparse.cpp" +#line 5368 "rlparse.cpp" } break; case 138: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 726 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_start_local_error; -#line 5377 "rlparse.cpp" +#line 5377 "rlparse.cpp" } break; case 139: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 729 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_local_error; -#line 5386 "rlparse.cpp" +#line 5386 "rlparse.cpp" } break; case 140: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 731 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_start_local_error; -#line 5395 "rlparse.cpp" +#line 5395 "rlparse.cpp" } break; case 141: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 734 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_local_error; -#line 5404 "rlparse.cpp" +#line 5404 "rlparse.cpp" } break; case 142: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 736 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_all_local_error; -#line 5413 "rlparse.cpp" +#line 5413 "rlparse.cpp" } break; case 143: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 739 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_local_error; -#line 5422 "rlparse.cpp" +#line 5422 "rlparse.cpp" } break; case 144: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 741 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_final_local_error; -#line 5431 "rlparse.cpp" +#line 5431 "rlparse.cpp" } break; case 145: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 744 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_local_error; -#line 5440 "rlparse.cpp" +#line 5440 "rlparse.cpp" } break; case 146: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 746 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_not_final_local_error; -#line 5449 "rlparse.cpp" +#line 5449 "rlparse.cpp" } break; case 147: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 749 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_local_error; -#line 5458 "rlparse.cpp" +#line 5458 "rlparse.cpp" } break; case 148: { -Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Parser_Lel_aug_type *__ref0 = (Parser_Lel_aug_type*)&redLel->user.aug_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_aug_type *__ref2 = (Parser_Lel_aug_type*)&redLel->user.aug_type; #line 751 "rlparse.kl" - (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_local_error; + (__ref0)->loc = (__ref1)->loc; (__ref2)->augType = at_middle_local_error; -#line 5467 "rlparse.cpp" +#line 5467 "rlparse.cpp" } break; case 149: { -Parser_Lel_action_ref *__ref0 = (Parser_Lel_action_ref*)&redLel->user.action_ref; -Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[0]->user.action_ref; +Parser_Lel_action_ref *__ref0 = (Parser_Lel_action_ref*)&redLel->user.action_ref; +Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[0]->user.action_ref; #line 764 "rlparse.kl" - (__ref0)->action = (__ref1)->action; + (__ref0)->action = (__ref1)->action; -#line 5475 "rlparse.cpp" +#line 5475 "rlparse.cpp" } break; case 150: { -Parser_Lel_action_ref *__ref0 = (Parser_Lel_action_ref*)&redLel->user.action_ref; -Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[1]->user.action_ref; +Parser_Lel_action_ref *__ref0 = (Parser_Lel_action_ref*)&redLel->user.action_ref; +Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[1]->user.action_ref; #line 765 "rlparse.kl" - (__ref0)->action = (__ref1)->action; + (__ref0)->action = (__ref1)->action; -#line 5483 "rlparse.cpp" +#line 5483 "rlparse.cpp" } break; case 151: { -Parser_Lel_action_ref *__ref0 = (Parser_Lel_action_ref*)&redLel->user.action_ref; -Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[0]->user.action_ref; +Parser_Lel_action_ref *__ref0 = (Parser_Lel_action_ref*)&redLel->user.action_ref; +Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&rhs[0]->user.action_ref; #line 766 "rlparse.kl" - (__ref0)->action = (__ref1)->action; + (__ref0)->action = (__ref1)->action; -#line 5491 "rlparse.cpp" +#line 5491 "rlparse.cpp" } break; case 152: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&redLel->user.action_ref; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Token *__ref3 = (Token*)&rhs[0]->user.token; -Parser_Lel_action_ref *__ref4 = (Parser_Lel_action_ref*)&redLel->user.action_ref; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Parser_Lel_action_ref *__ref1 = (Parser_Lel_action_ref*)&redLel->user.action_ref; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Token *__ref3 = (Token*)&rhs[0]->user.token; +Parser_Lel_action_ref *__ref4 = (Parser_Lel_action_ref*)&redLel->user.action_ref; #line 771 "rlparse.kl" /* Set the name in the actionDict. */ - Action *action = pd->actionDict.find( (__ref0)->data ); + Action *action = pd->actionDict.find( (__ref0)->data ); if ( action != 0 ) { /* Pass up the action element */ - (__ref1)->action = action; + (__ref1)->action = action; } else { /* Will recover by returning null as the action. */ - error((__ref2)->loc) << "action lookup of \"" << (__ref3)->data << "\" failed" << endl; - (__ref4)->action = 0; + error((__ref2)->loc) << "action lookup of \"" << (__ref3)->data << "\" failed" << endl; + (__ref4)->action = 0; } -#line 5514 "rlparse.cpp" +#line 5514 "rlparse.cpp" } break; case 153: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; -Parser_Lel_action_ref *__ref2 = (Parser_Lel_action_ref*)&redLel->user.action_ref; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; +Parser_Lel_action_ref *__ref2 = (Parser_Lel_action_ref*)&redLel->user.action_ref; #line 788 "rlparse.kl" /* Create the action, add it to the list and pass up. */ - Action *newAction = new Action( (__ref0)->loc, 0, (__ref1)->inlineList, pd->nextCondId++ ); + Action *newAction = new Action( (__ref0)->loc, 0, (__ref1)->inlineList, pd->nextCondId++ ); pd->actionList.append( newAction ); - (__ref2)->action = newAction; + (__ref2)->action = newAction; -#line 5528 "rlparse.cpp" +#line 5528 "rlparse.cpp" } break; case 154: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Parser_Lel_priority_name *__ref1 = (Parser_Lel_priority_name*)&redLel->user.priority_name; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Parser_Lel_priority_name *__ref1 = (Parser_Lel_priority_name*)&redLel->user.priority_name; #line 803 "rlparse.kl" // Lookup/create the priority key. PriorDictEl *priorDictEl; - if ( pd->priorDict.insert( (__ref0)->data, pd->nextPriorKey, &priorDictEl ) ) + if ( pd->priorDict.insert( (__ref0)->data, pd->nextPriorKey, &priorDictEl ) ) pd->nextPriorKey += 1; // Use the inserted/found priority key. - (__ref1)->priorityName = priorDictEl->value; + (__ref1)->priorityName = priorDictEl->value; -#line 5544 "rlparse.cpp" +#line 5544 "rlparse.cpp" } break; case 155: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_priority_aug *__ref3 = (Parser_Lel_priority_aug*)&redLel->user.priority_aug; -Parser_Lel_token_type *__ref4 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref5 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_priority_aug *__ref6 = (Parser_Lel_priority_aug*)&redLel->user.priority_aug; -Parser_Lel_priority_aug *__ref7 = (Parser_Lel_priority_aug*)&redLel->user.priority_aug; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_priority_aug *__ref3 = (Parser_Lel_priority_aug*)&redLel->user.priority_aug; +Parser_Lel_token_type *__ref4 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref5 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_priority_aug *__ref6 = (Parser_Lel_priority_aug*)&redLel->user.priority_aug; +Parser_Lel_priority_aug *__ref7 = (Parser_Lel_priority_aug*)&redLel->user.priority_aug; #line 820 "rlparse.kl" // Convert the priority number to a long. Check for overflow. errno = 0; //cerr << "PRIOR AUG: " << $1->token.data << endl; - long aug = strtol( (__ref0)->token.data, 0, 10 ); + long aug = strtol( (__ref0)->token.data, 0, 10 ); if ( errno == ERANGE && aug == LONG_MAX ) { /* Priority number too large. Recover by setting the priority to 0. */ - error((__ref1)->token.loc) << "priority number " << (__ref2)->token.data << + error((__ref1)->token.loc) << "priority number " << (__ref2)->token.data << " overflows" << endl; - (__ref3)->priorityNum = 0; + (__ref3)->priorityNum = 0; } else if ( errno == ERANGE && aug == LONG_MIN ) { /* Priority number too large in the neg. Recover by using 0. */ - error((__ref4)->token.loc) << "priority number " << (__ref5)->token.data << + error((__ref4)->token.loc) << "priority number " << (__ref5)->token.data << " underflows" << endl; - (__ref6)->priorityNum = 0; + (__ref6)->priorityNum = 0; } else { /* No overflow or underflow. */ - (__ref7)->priorityNum = aug; + (__ref7)->priorityNum = aug; } -#line 5579 "rlparse.cpp" +#line 5579 "rlparse.cpp" } break; case 156: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 846 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 5589 "rlparse.cpp" +#line 5589 "rlparse.cpp" } break; case 157: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref4 = (Token*)&rhs[1]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref4 = (Token*)&rhs[1]->user.token; #line 850 "rlparse.kl" - (__ref0)->token.set( "+", 1 ); - (__ref1)->token.loc = (__ref2)->loc; - (__ref3)->token.append( *(__ref4) ); + (__ref0)->token.set( "+", 1 ); + (__ref1)->token.loc = (__ref2)->loc; + (__ref3)->token.append( *(__ref4) ); -#line 5604 "rlparse.cpp" +#line 5604 "rlparse.cpp" } break; case 158: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref4 = (Token*)&rhs[1]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref4 = (Token*)&rhs[1]->user.token; #line 856 "rlparse.kl" - (__ref0)->token.set( "-", 1 ); - (__ref1)->token.loc = (__ref2)->loc; - (__ref3)->token.append( *(__ref4) ); + (__ref0)->token.set( "-", 1 ); + (__ref1)->token.loc = (__ref2)->loc; + (__ref3)->token.append( *(__ref4) ); -#line 5619 "rlparse.cpp" +#line 5619 "rlparse.cpp" } break; case 159: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Parser_Lel_local_err_name *__ref1 = (Parser_Lel_local_err_name*)&redLel->user.local_err_name; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Parser_Lel_local_err_name *__ref1 = (Parser_Lel_local_err_name*)&redLel->user.local_err_name; #line 868 "rlparse.kl" /* Lookup/create the priority key. */ LocalErrDictEl *localErrDictEl; - if ( pd->localErrDict.insert( (__ref0)->data, pd->nextLocalErrKey, &localErrDictEl ) ) + if ( pd->localErrDict.insert( (__ref0)->data, pd->nextLocalErrKey, &localErrDictEl ) ) pd->nextLocalErrKey += 1; /* Use the inserted/found priority key. */ - (__ref1)->error_name = localErrDictEl->value; + (__ref1)->error_name = localErrDictEl->value; -#line 5635 "rlparse.cpp" +#line 5635 "rlparse.cpp" } break; case 160: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; #line 889 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, 0, 0, FactorWithRep::StarType ); -#line 5647 "rlparse.cpp" +#line 5647 "rlparse.cpp" } break; case 161: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; #line 894 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, 0, 0, FactorWithRep::StarStarType ); -#line 5659 "rlparse.cpp" +#line 5659 "rlparse.cpp" } break; case 162: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; #line 899 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, 0, 0, FactorWithRep::OptionalType ); -#line 5671 "rlparse.cpp" +#line 5671 "rlparse.cpp" } break; case 163: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; #line 904 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, 0, 0, FactorWithRep::PlusType ); -#line 5683 "rlparse.cpp" +#line 5683 "rlparse.cpp" } break; case 164: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; -Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[2]->user.factor_rep_num; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[2]->user.factor_rep_num; #line 909 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, - (__ref3)->rep, 0, FactorWithRep::ExactType ); + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref3)->rep, 0, FactorWithRep::ExactType ); -#line 5696 "rlparse.cpp" +#line 5696 "rlparse.cpp" } break; case 165: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; -Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[3]->user.factor_rep_num; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[3]->user.factor_rep_num; #line 914 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, - 0, (__ref3)->rep, FactorWithRep::MaxType ); + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + 0, (__ref3)->rep, FactorWithRep::MaxType ); -#line 5709 "rlparse.cpp" +#line 5709 "rlparse.cpp" } break; case 166: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; -Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[2]->user.factor_rep_num; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[2]->user.factor_rep_num; #line 919 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, - (__ref3)->rep, 0, FactorWithRep::MinType ); + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref3)->rep, 0, FactorWithRep::MinType ); -#line 5722 "rlparse.cpp" +#line 5722 "rlparse.cpp" } break; case 167: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; -Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[2]->user.factor_rep_num; -Parser_Lel_factor_rep_num *__ref4 = (Parser_Lel_factor_rep_num*)&rhs[4]->user.factor_rep_num; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Parser_Lel_factor_with_rep *__ref2 = (Parser_Lel_factor_with_rep*)&rhs[0]->user.factor_with_rep; +Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&rhs[2]->user.factor_rep_num; +Parser_Lel_factor_rep_num *__ref4 = (Parser_Lel_factor_rep_num*)&rhs[4]->user.factor_rep_num; #line 924 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, - (__ref3)->rep, (__ref4)->rep, FactorWithRep::RangeType ); + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->loc, (__ref2)->factorWithRep, + (__ref3)->rep, (__ref4)->rep, FactorWithRep::RangeType ); -#line 5736 "rlparse.cpp" +#line 5736 "rlparse.cpp" } break; case 168: { -Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; -Parser_Lel_factor_with_neg *__ref1 = (Parser_Lel_factor_with_neg*)&rhs[0]->user.factor_with_neg; +Parser_Lel_factor_with_rep *__ref0 = (Parser_Lel_factor_with_rep*)&redLel->user.factor_with_rep; +Parser_Lel_factor_with_neg *__ref1 = (Parser_Lel_factor_with_neg*)&rhs[0]->user.factor_with_neg; #line 929 "rlparse.kl" - (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->factorWithNeg ); + (__ref0)->factorWithRep = new FactorWithRep( (__ref1)->factorWithNeg ); -#line 5746 "rlparse.cpp" +#line 5746 "rlparse.cpp" } break; case 169: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&redLel->user.factor_rep_num; -Parser_Lel_factor_rep_num *__ref4 = (Parser_Lel_factor_rep_num*)&redLel->user.factor_rep_num; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor_rep_num *__ref3 = (Parser_Lel_factor_rep_num*)&redLel->user.factor_rep_num; +Parser_Lel_factor_rep_num *__ref4 = (Parser_Lel_factor_rep_num*)&redLel->user.factor_rep_num; #line 939 "rlparse.kl" // Convert the priority number to a long. Check for overflow. errno = 0; - long rep = strtol( (__ref0)->data, 0, 10 ); + long rep = strtol( (__ref0)->data, 0, 10 ); if ( errno == ERANGE && rep == LONG_MAX ) { // Repetition too large. Recover by returing repetition 1. */ - error((__ref1)->loc) << "repetition number " << (__ref2)->data << " overflows" << endl; - (__ref3)->rep = 1; + error((__ref1)->loc) << "repetition number " << (__ref2)->data << " overflows" << endl; + (__ref3)->rep = 1; } else { // Cannot be negative, so no overflow. - (__ref4)->rep = rep; + (__ref4)->rep = rep; } -#line 5770 "rlparse.cpp" +#line 5770 "rlparse.cpp" } break; case 170: { -Parser_Lel_factor_with_neg *__ref0 = (Parser_Lel_factor_with_neg*)&redLel->user.factor_with_neg; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_factor_with_neg *__ref2 = (Parser_Lel_factor_with_neg*)&rhs[1]->user.factor_with_neg; +Parser_Lel_factor_with_neg *__ref0 = (Parser_Lel_factor_with_neg*)&redLel->user.factor_with_neg; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor_with_neg *__ref2 = (Parser_Lel_factor_with_neg*)&rhs[1]->user.factor_with_neg; #line 965 "rlparse.kl" - (__ref0)->factorWithNeg = new FactorWithNeg( (__ref1)->loc, - (__ref2)->factorWithNeg, FactorWithNeg::NegateType ); + (__ref0)->factorWithNeg = new FactorWithNeg( (__ref1)->loc, + (__ref2)->factorWithNeg, FactorWithNeg::NegateType ); -#line 5782 "rlparse.cpp" +#line 5782 "rlparse.cpp" } break; case 171: { -Parser_Lel_factor_with_neg *__ref0 = (Parser_Lel_factor_with_neg*)&redLel->user.factor_with_neg; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_factor_with_neg *__ref2 = (Parser_Lel_factor_with_neg*)&rhs[1]->user.factor_with_neg; +Parser_Lel_factor_with_neg *__ref0 = (Parser_Lel_factor_with_neg*)&redLel->user.factor_with_neg; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor_with_neg *__ref2 = (Parser_Lel_factor_with_neg*)&rhs[1]->user.factor_with_neg; #line 970 "rlparse.kl" - (__ref0)->factorWithNeg = new FactorWithNeg( (__ref1)->loc, - (__ref2)->factorWithNeg, FactorWithNeg::CharNegateType ); + (__ref0)->factorWithNeg = new FactorWithNeg( (__ref1)->loc, + (__ref2)->factorWithNeg, FactorWithNeg::CharNegateType ); -#line 5794 "rlparse.cpp" +#line 5794 "rlparse.cpp" } break; case 172: { -Parser_Lel_factor_with_neg *__ref0 = (Parser_Lel_factor_with_neg*)&redLel->user.factor_with_neg; -Parser_Lel_factor *__ref1 = (Parser_Lel_factor*)&rhs[0]->user.factor; +Parser_Lel_factor_with_neg *__ref0 = (Parser_Lel_factor_with_neg*)&redLel->user.factor_with_neg; +Parser_Lel_factor *__ref1 = (Parser_Lel_factor*)&rhs[0]->user.factor; #line 975 "rlparse.kl" - (__ref0)->factorWithNeg = new FactorWithNeg( (__ref1)->factor ); + (__ref0)->factorWithNeg = new FactorWithNeg( (__ref1)->factor ); -#line 5804 "rlparse.cpp" +#line 5804 "rlparse.cpp" } break; case 173: { -Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 985 "rlparse.kl" /* Create a new factor node going to a concat literal. */ - (__ref0)->factor = new Factor( new Literal( *(__ref1), Literal::LitString ) ); + (__ref0)->factor = new Factor( new Literal( *(__ref1), Literal::LitString ) ); -#line 5815 "rlparse.cpp" +#line 5815 "rlparse.cpp" } break; case 174: { -Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; #line 990 "rlparse.kl" /* Create a new factor node going to a literal number. */ - (__ref0)->factor = new Factor( new Literal( (__ref1)->token, Literal::Number ) ); + (__ref0)->factor = new Factor( new Literal( (__ref1)->token, Literal::Number ) ); -#line 5826 "rlparse.cpp" +#line 5826 "rlparse.cpp" } break; case 175: { -Token *__ref0 = (Token*)&rhs[0]->user.token; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Parser_Lel_factor *__ref3 = (Parser_Lel_factor*)&redLel->user.factor; -Token *__ref4 = (Token*)&rhs[0]->user.token; -Parser_Lel_factor *__ref5 = (Parser_Lel_factor*)&redLel->user.factor; -Parser_Lel_factor *__ref6 = (Parser_Lel_factor*)&redLel->user.factor; -Token *__ref7 = (Token*)&rhs[0]->user.token; +Token *__ref0 = (Token*)&rhs[0]->user.token; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor *__ref3 = (Parser_Lel_factor*)&redLel->user.factor; +Token *__ref4 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor *__ref5 = (Parser_Lel_factor*)&redLel->user.factor; +Parser_Lel_factor *__ref6 = (Parser_Lel_factor*)&redLel->user.factor; +Token *__ref7 = (Token*)&rhs[0]->user.token; #line 995 "rlparse.kl" /* Find the named graph. */ - GraphDictEl *gdNode = pd->graphDict.find( (__ref0)->data ); + GraphDictEl *gdNode = pd->graphDict.find( (__ref0)->data ); if ( gdNode == 0 ) { /* Recover by returning null as the factor node. */ - error((__ref1)->loc) << "graph lookup of \"" << (__ref2)->data << "\" failed" << endl; - (__ref3)->factor = 0; + error((__ref1)->loc) << "graph lookup of \"" << (__ref2)->data << "\" failed" << endl; + (__ref3)->factor = 0; } else if ( gdNode->isInstance ) { /* Recover by retuning null as the factor node. */ - error((__ref4)->loc) << "references to graph instantiations not allowed " + error((__ref4)->loc) << "references to graph instantiations not allowed " "in expressions" << endl; - (__ref5)->factor = 0; + (__ref5)->factor = 0; } else { /* Create a factor node that is a lookup of an expression. */ - (__ref6)->factor = new Factor( (__ref7)->loc, gdNode->value ); + (__ref6)->factor = new Factor( (__ref7)->loc, gdNode->value ); } -#line 5858 "rlparse.cpp" +#line 5858 "rlparse.cpp" } break; case 176: { -Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; +Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; #line 1015 "rlparse.kl" /* Create a new factor node going to an OR expression. */ - (__ref0)->factor = new Factor( new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::OrBlock ) ); + (__ref0)->factor = new Factor( new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::OrBlock ) ); -#line 5870 "rlparse.cpp" +#line 5870 "rlparse.cpp" } break; case 177: { -Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; +Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; #line 1020 "rlparse.kl" /* Create a new factor node going to a negated OR expression. */ - (__ref0)->factor = new Factor( new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::NegOrBlock ) ); + (__ref0)->factor = new Factor( new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::NegOrBlock ) ); -#line 5882 "rlparse.cpp" +#line 5882 "rlparse.cpp" } break; case 178: { -Token *__ref0 = (Token*)&rhs[2]->user.token; -Token *__ref1 = (Token*)&rhs[2]->user.token; -Parser_Lel_regular_expr *__ref2 = (Parser_Lel_regular_expr*)&rhs[1]->user.regular_expr; -Parser_Lel_factor *__ref3 = (Parser_Lel_factor*)&redLel->user.factor; -Parser_Lel_regular_expr *__ref4 = (Parser_Lel_regular_expr*)&rhs[1]->user.regular_expr; +Token *__ref0 = (Token*)&rhs[2]->user.token; +Token *__ref1 = (Token*)&rhs[2]->user.token; +Parser_Lel_regular_expr *__ref2 = (Parser_Lel_regular_expr*)&rhs[1]->user.regular_expr; +Parser_Lel_factor *__ref3 = (Parser_Lel_factor*)&redLel->user.factor; +Parser_Lel_regular_expr *__ref4 = (Parser_Lel_regular_expr*)&rhs[1]->user.regular_expr; #line 1025 "rlparse.kl" - if ( (__ref0)->length > 1 ) { - for ( char *p = (__ref1)->data; *p != 0; p++ ) { + if ( (__ref0)->length > 1 ) { + for ( char *p = (__ref1)->data; *p != 0; p++ ) { if ( *p == 'i' ) - (__ref2)->regExpr->caseInsensitive = true; + (__ref2)->regExpr->caseInsensitive = true; } } /* Create a new factor node going to a regular exp. */ - (__ref3)->factor = new Factor( (__ref4)->regExpr ); + (__ref3)->factor = new Factor( (__ref4)->regExpr ); -#line 5903 "rlparse.cpp" +#line 5903 "rlparse.cpp" } break; case 179: { -Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; -Parser_Lel_range_lit *__ref1 = (Parser_Lel_range_lit*)&rhs[0]->user.range_lit; -Parser_Lel_range_lit *__ref2 = (Parser_Lel_range_lit*)&rhs[2]->user.range_lit; +Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; +Parser_Lel_range_lit *__ref1 = (Parser_Lel_range_lit*)&rhs[0]->user.range_lit; +Parser_Lel_range_lit *__ref2 = (Parser_Lel_range_lit*)&rhs[2]->user.range_lit; #line 1037 "rlparse.kl" /* Create a new factor node going to a range. */ - (__ref0)->factor = new Factor( new Range( (__ref1)->literal, (__ref2)->literal ) ); + (__ref0)->factor = new Factor( new Range( (__ref1)->literal, (__ref2)->literal ) ); -#line 5915 "rlparse.cpp" +#line 5915 "rlparse.cpp" } break; case 180: { -Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; -Parser_Lel_join *__ref1 = (Parser_Lel_join*)&rhs[1]->user.join; -Parser_Lel_join *__ref2 = (Parser_Lel_join*)&rhs[1]->user.join; -Token *__ref3 = (Token*)&rhs[0]->user.token; +Parser_Lel_factor *__ref0 = (Parser_Lel_factor*)&redLel->user.factor; +Parser_Lel_join *__ref1 = (Parser_Lel_join*)&rhs[1]->user.join; +Parser_Lel_join *__ref2 = (Parser_Lel_join*)&rhs[1]->user.join; +Token *__ref3 = (Token*)&rhs[0]->user.token; #line 1042 "rlparse.kl" /* Create a new factor going to a parenthesized join. */ - (__ref0)->factor = new Factor( (__ref1)->join ); - (__ref2)->join->loc = (__ref3)->loc; + (__ref0)->factor = new Factor( (__ref1)->join ); + (__ref2)->join->loc = (__ref3)->loc; -#line 5929 "rlparse.cpp" +#line 5929 "rlparse.cpp" } break; case 181: { -Parser_Lel_range_lit *__ref0 = (Parser_Lel_range_lit*)&redLel->user.range_lit; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_range_lit *__ref0 = (Parser_Lel_range_lit*)&redLel->user.range_lit; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1055 "rlparse.kl" /* Range literas must have only one char. We restrict this in the parse tree. */ - (__ref0)->literal = new Literal( *(__ref1), Literal::LitString ); + (__ref0)->literal = new Literal( *(__ref1), Literal::LitString ); -#line 5940 "rlparse.cpp" +#line 5940 "rlparse.cpp" } break; case 182: { -Parser_Lel_range_lit *__ref0 = (Parser_Lel_range_lit*)&redLel->user.range_lit; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_range_lit *__ref0 = (Parser_Lel_range_lit*)&redLel->user.range_lit; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; #line 1060 "rlparse.kl" /* Create a new literal number. */ - (__ref0)->literal = new Literal( (__ref1)->token, Literal::Number ); + (__ref0)->literal = new Literal( (__ref1)->token, Literal::Number ); -#line 5951 "rlparse.cpp" +#line 5951 "rlparse.cpp" } break; case 183: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1069 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 5961 "rlparse.cpp" +#line 5961 "rlparse.cpp" } break; case 184: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref4 = (Token*)&rhs[1]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref3 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref4 = (Token*)&rhs[1]->user.token; #line 1073 "rlparse.kl" - (__ref0)->token.set( "-", 1 ); - (__ref1)->token.loc = (__ref2)->loc; - (__ref3)->token.append( *(__ref4) ); + (__ref0)->token.set( "-", 1 ); + (__ref1)->token.loc = (__ref2)->loc; + (__ref3)->token.append( *(__ref4) ); -#line 5976 "rlparse.cpp" +#line 5976 "rlparse.cpp" } break; case 185: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1079 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 5986 "rlparse.cpp" +#line 5986 "rlparse.cpp" } break; case 186: { -Parser_Lel_regular_expr_item *__ref0 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; -Parser_Lel_regular_expr_item *__ref1 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; -Parser_Lel_regular_expr *__ref2 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; -Parser_Lel_regular_expr *__ref3 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; -Parser_Lel_regular_expr *__ref4 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; -Parser_Lel_regular_expr *__ref5 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; -Parser_Lel_regular_expr_item *__ref6 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; -Parser_Lel_regular_expr_item *__ref7 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; -Parser_Lel_regular_expr *__ref8 = (Parser_Lel_regular_expr*)&redLel->user.regular_expr; -Parser_Lel_regular_expr *__ref9 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; -Parser_Lel_regular_expr *__ref10 = (Parser_Lel_regular_expr*)&redLel->user.regular_expr; -Parser_Lel_regular_expr *__ref11 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; -Parser_Lel_regular_expr_item *__ref12 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; +Parser_Lel_regular_expr_item *__ref0 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; +Parser_Lel_regular_expr_item *__ref1 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; +Parser_Lel_regular_expr *__ref2 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; +Parser_Lel_regular_expr *__ref3 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; +Parser_Lel_regular_expr *__ref4 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; +Parser_Lel_regular_expr *__ref5 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; +Parser_Lel_regular_expr_item *__ref6 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; +Parser_Lel_regular_expr_item *__ref7 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; +Parser_Lel_regular_expr *__ref8 = (Parser_Lel_regular_expr*)&redLel->user.regular_expr; +Parser_Lel_regular_expr *__ref9 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; +Parser_Lel_regular_expr *__ref10 = (Parser_Lel_regular_expr*)&redLel->user.regular_expr; +Parser_Lel_regular_expr *__ref11 = (Parser_Lel_regular_expr*)&rhs[0]->user.regular_expr; +Parser_Lel_regular_expr_item *__ref12 = (Parser_Lel_regular_expr_item*)&rhs[1]->user.regular_expr_item; #line 1094 "rlparse.kl" /* An optimization to lessen the tree size. If a non-starred char is * directly under the left side on the right and the right side is * another non-starred char then paste them together and return the * left side. Otherwise just put the two under a new reg exp node. */ - if ( (__ref0)->reItem->type == ReItem::Data && !(__ref1)->reItem->star && - (__ref2)->regExpr->type == RegExpr::RecurseItem && - (__ref3)->regExpr->item->type == ReItem::Data && !(__ref4)->regExpr->item->star ) + if ( (__ref0)->reItem->type == ReItem::Data && !(__ref1)->reItem->star && + (__ref2)->regExpr->type == RegExpr::RecurseItem && + (__ref3)->regExpr->item->type == ReItem::Data && !(__ref4)->regExpr->item->star ) { /* Append the right side to the right side of the left and toss the * right side. */ - (__ref5)->regExpr->item->token.append( (__ref6)->reItem->token ); - delete (__ref7)->reItem; - (__ref8)->regExpr = (__ref9)->regExpr; + (__ref5)->regExpr->item->token.append( (__ref6)->reItem->token ); + delete (__ref7)->reItem; + (__ref8)->regExpr = (__ref9)->regExpr; } else { - (__ref10)->regExpr = new RegExpr( (__ref11)->regExpr, (__ref12)->reItem ); + (__ref10)->regExpr = new RegExpr( (__ref11)->regExpr, (__ref12)->reItem ); } -#line 6023 "rlparse.cpp" +#line 6023 "rlparse.cpp" } break; case 187: { -Parser_Lel_regular_expr *__ref0 = (Parser_Lel_regular_expr*)&redLel->user.regular_expr; +Parser_Lel_regular_expr *__ref0 = (Parser_Lel_regular_expr*)&redLel->user.regular_expr; #line 1114 "rlparse.kl" /* Can't optimize the tree. */ - (__ref0)->regExpr = new RegExpr(); + (__ref0)->regExpr = new RegExpr(); -#line 6033 "rlparse.cpp" +#line 6033 "rlparse.cpp" } break; case 188: { -Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&rhs[0]->user.regular_expr_char; -Parser_Lel_regular_expr_item *__ref1 = (Parser_Lel_regular_expr_item*)&redLel->user.regular_expr_item; -Parser_Lel_regular_expr_char *__ref2 = (Parser_Lel_regular_expr_char*)&rhs[0]->user.regular_expr_char; +Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&rhs[0]->user.regular_expr_char; +Parser_Lel_regular_expr_item *__ref1 = (Parser_Lel_regular_expr_item*)&redLel->user.regular_expr_item; +Parser_Lel_regular_expr_char *__ref2 = (Parser_Lel_regular_expr_char*)&rhs[0]->user.regular_expr_char; #line 1126 "rlparse.kl" - (__ref0)->reItem->star = true; - (__ref1)->reItem = (__ref2)->reItem; + (__ref0)->reItem->star = true; + (__ref1)->reItem = (__ref2)->reItem; -#line 6045 "rlparse.cpp" +#line 6045 "rlparse.cpp" } break; case 189: { -Parser_Lel_regular_expr_item *__ref0 = (Parser_Lel_regular_expr_item*)&redLel->user.regular_expr_item; -Parser_Lel_regular_expr_char *__ref1 = (Parser_Lel_regular_expr_char*)&rhs[0]->user.regular_expr_char; +Parser_Lel_regular_expr_item *__ref0 = (Parser_Lel_regular_expr_item*)&redLel->user.regular_expr_item; +Parser_Lel_regular_expr_char *__ref1 = (Parser_Lel_regular_expr_char*)&rhs[0]->user.regular_expr_char; #line 1131 "rlparse.kl" - (__ref0)->reItem = (__ref1)->reItem; + (__ref0)->reItem = (__ref1)->reItem; -#line 6055 "rlparse.cpp" +#line 6055 "rlparse.cpp" } break; case 190: { -Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; +Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; #line 1143 "rlparse.kl" - (__ref0)->reItem = new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::OrBlock ); + (__ref0)->reItem = new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::OrBlock ); -#line 6066 "rlparse.cpp" +#line 6066 "rlparse.cpp" } break; case 191: { -Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; +Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[1]->user.regular_expr_or_data; #line 1147 "rlparse.kl" - (__ref0)->reItem = new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::NegOrBlock ); + (__ref0)->reItem = new ReItem( (__ref1)->loc, (__ref2)->reOrBlock, ReItem::NegOrBlock ); -#line 6077 "rlparse.cpp" +#line 6077 "rlparse.cpp" } break; case 192: { -Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1151 "rlparse.kl" - (__ref0)->reItem = new ReItem( (__ref1)->loc, ReItem::Dot ); + (__ref0)->reItem = new ReItem( (__ref1)->loc, ReItem::Dot ); -#line 6087 "rlparse.cpp" +#line 6087 "rlparse.cpp" } break; case 193: { -Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_char *__ref0 = (Parser_Lel_regular_expr_char*)&redLel->user.regular_expr_char; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Token *__ref2 = (Token*)&rhs[0]->user.token; #line 1155 "rlparse.kl" - (__ref0)->reItem = new ReItem( (__ref1)->loc, *(__ref2) ); + (__ref0)->reItem = new ReItem( (__ref1)->loc, *(__ref2) ); -#line 6098 "rlparse.cpp" +#line 6098 "rlparse.cpp" } break; case 194: { -Parser_Lel_regular_expr_or_char *__ref0 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; -Parser_Lel_regular_expr_or_data *__ref1 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_data *__ref3 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_char *__ref4 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; -Parser_Lel_regular_expr_or_char *__ref5 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; -Parser_Lel_regular_expr_or_data *__ref6 = (Parser_Lel_regular_expr_or_data*)&redLel->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_data *__ref7 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_data *__ref8 = (Parser_Lel_regular_expr_or_data*)&redLel->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_data *__ref9 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; -Parser_Lel_regular_expr_or_char *__ref10 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; +Parser_Lel_regular_expr_or_char *__ref0 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; +Parser_Lel_regular_expr_or_data *__ref1 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_data *__ref2 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_data *__ref3 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_char *__ref4 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; +Parser_Lel_regular_expr_or_char *__ref5 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; +Parser_Lel_regular_expr_or_data *__ref6 = (Parser_Lel_regular_expr_or_data*)&redLel->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_data *__ref7 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_data *__ref8 = (Parser_Lel_regular_expr_or_data*)&redLel->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_data *__ref9 = (Parser_Lel_regular_expr_or_data*)&rhs[0]->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_char *__ref10 = (Parser_Lel_regular_expr_or_char*)&rhs[1]->user.regular_expr_or_char; #line 1167 "rlparse.kl" /* An optimization to lessen the tree size. If an or char is directly * under the left side on the right and the right side is another or * char then paste them together and return the left side. Otherwise * just put the two under a new or data node. */ - if ( (__ref0)->reOrItem->type == ReOrItem::Data && - (__ref1)->reOrBlock->type == ReOrBlock::RecurseItem && - (__ref2)->reOrBlock->item->type == ReOrItem::Data ) + if ( (__ref0)->reOrItem->type == ReOrItem::Data && + (__ref1)->reOrBlock->type == ReOrBlock::RecurseItem && + (__ref2)->reOrBlock->item->type == ReOrItem::Data ) { /* Append the right side to right side of the left and toss the * right side. */ - (__ref3)->reOrBlock->item->token.append( (__ref4)->reOrItem->token ); - delete (__ref5)->reOrItem; - (__ref6)->reOrBlock = (__ref7)->reOrBlock; + (__ref3)->reOrBlock->item->token.append( (__ref4)->reOrItem->token ); + delete (__ref5)->reOrItem; + (__ref6)->reOrBlock = (__ref7)->reOrBlock; } else { /* Can't optimize, put the left and right under a new node. */ - (__ref8)->reOrBlock = new ReOrBlock( (__ref9)->reOrBlock, (__ref10)->reOrItem ); + (__ref8)->reOrBlock = new ReOrBlock( (__ref9)->reOrBlock, (__ref10)->reOrItem ); } -#line 6134 "rlparse.cpp" +#line 6134 "rlparse.cpp" } break; case 195: { -Parser_Lel_regular_expr_or_data *__ref0 = (Parser_Lel_regular_expr_or_data*)&redLel->user.regular_expr_or_data; +Parser_Lel_regular_expr_or_data *__ref0 = (Parser_Lel_regular_expr_or_data*)&redLel->user.regular_expr_or_data; #line 1188 "rlparse.kl" - (__ref0)->reOrBlock = new ReOrBlock(); + (__ref0)->reOrBlock = new ReOrBlock(); -#line 6143 "rlparse.cpp" +#line 6143 "rlparse.cpp" } break; case 196: { -Parser_Lel_regular_expr_or_char *__ref0 = (Parser_Lel_regular_expr_or_char*)&redLel->user.regular_expr_or_char; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Token *__ref2 = (Token*)&rhs[0]->user.token; +Parser_Lel_regular_expr_or_char *__ref0 = (Parser_Lel_regular_expr_or_char*)&redLel->user.regular_expr_or_char; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Token *__ref2 = (Token*)&rhs[0]->user.token; #line 1200 "rlparse.kl" - (__ref0)->reOrItem = new ReOrItem( (__ref1)->loc, *(__ref2) ); + (__ref0)->reOrItem = new ReOrItem( (__ref1)->loc, *(__ref2) ); -#line 6154 "rlparse.cpp" +#line 6154 "rlparse.cpp" } break; case 197: { -Parser_Lel_regular_expr_or_char *__ref0 = (Parser_Lel_regular_expr_or_char*)&redLel->user.regular_expr_or_char; -Token *__ref1 = (Token*)&rhs[1]->user.token; -Token *__ref2 = (Token*)&rhs[0]->user.token; -Token *__ref3 = (Token*)&rhs[2]->user.token; +Parser_Lel_regular_expr_or_char *__ref0 = (Parser_Lel_regular_expr_or_char*)&redLel->user.regular_expr_or_char; +Token *__ref1 = (Token*)&rhs[1]->user.token; +Token *__ref2 = (Token*)&rhs[0]->user.token; +Token *__ref3 = (Token*)&rhs[2]->user.token; #line 1204 "rlparse.kl" - (__ref0)->reOrItem = new ReOrItem( (__ref1)->loc, (__ref2)->data[0], (__ref3)->data[0] ); + (__ref0)->reOrItem = new ReOrItem( (__ref1)->loc, (__ref2)->data[0], (__ref3)->data[0] ); -#line 6166 "rlparse.cpp" +#line 6166 "rlparse.cpp" } break; case 198: { -Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; -Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; -Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&redLel->user.inline_list; -Parser_Lel_inline_item *__ref3 = (Parser_Lel_inline_item*)&rhs[1]->user.inline_item; +Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; +Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; +Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&redLel->user.inline_list; +Parser_Lel_inline_item *__ref3 = (Parser_Lel_inline_item*)&rhs[1]->user.inline_item; #line 1221 "rlparse.kl" /* Append the item to the list, return the list. */ - (__ref0)->inlineList = (__ref1)->inlineList; - (__ref2)->inlineList->append( (__ref3)->inlineItem ); + (__ref0)->inlineList = (__ref1)->inlineList; + (__ref2)->inlineList->append( (__ref3)->inlineItem ); -#line 6180 "rlparse.cpp" +#line 6180 "rlparse.cpp" } break; case 199: { -Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; +Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; #line 1228 "rlparse.kl" /* Start with empty list. */ - (__ref0)->inlineList = new InlineList; + (__ref0)->inlineList = new InlineList; -#line 6190 "rlparse.cpp" +#line 6190 "rlparse.cpp" } break; case 200: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; #line 1243 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); -#line 6201 "rlparse.cpp" +#line 6201 "rlparse.cpp" } break; case 201: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; #line 1249 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); -#line 6212 "rlparse.cpp" +#line 6212 "rlparse.cpp" } break; case 202: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_item *__ref1 = (Parser_Lel_inline_item*)&rhs[0]->user.inline_item; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_item *__ref1 = (Parser_Lel_inline_item*)&rhs[0]->user.inline_item; #line 1255 "rlparse.kl" /* Pass the inline item up. */ - (__ref0)->inlineItem = (__ref1)->inlineItem; + (__ref0)->inlineItem = (__ref1)->inlineItem; -#line 6223 "rlparse.cpp" +#line 6223 "rlparse.cpp" } break; case 203: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1262 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6231 "rlparse.cpp" +#line 6231 "rlparse.cpp" } break; case 204: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1263 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6239 "rlparse.cpp" +#line 6239 "rlparse.cpp" } break; case 205: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1264 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6247 "rlparse.cpp" +#line 6247 "rlparse.cpp" } break; case 206: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1265 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6255 "rlparse.cpp" +#line 6255 "rlparse.cpp" } break; case 207: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1266 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6263 "rlparse.cpp" +#line 6263 "rlparse.cpp" } break; case 208: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1267 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6271 "rlparse.cpp" +#line 6271 "rlparse.cpp" } break; case 209: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_item *__ref1 = (Parser_Lel_inline_item*)&rhs[0]->user.inline_item; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_item *__ref1 = (Parser_Lel_inline_item*)&rhs[0]->user.inline_item; #line 1271 "rlparse.kl" /* Pass up interpreted items of inline expressions. */ - (__ref0)->inlineItem = (__ref1)->inlineItem; + (__ref0)->inlineItem = (__ref1)->inlineItem; -#line 6282 "rlparse.cpp" +#line 6282 "rlparse.cpp" } break; case 210: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1276 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Hold ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Hold ); -#line 6292 "rlparse.cpp" +#line 6292 "rlparse.cpp" } break; case 211: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 1280 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Exec ); - (__ref2)->inlineItem->children = (__ref3)->inlineList; + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Exec ); + (__ref2)->inlineItem->children = (__ref3)->inlineList; -#line 6305 "rlparse.cpp" +#line 6305 "rlparse.cpp" } break; case 212: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1285 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, new NameRef(nameRef), InlineItem::Goto ); -#line 6316 "rlparse.cpp" +#line 6316 "rlparse.cpp" } break; case 213: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; #line 1290 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::GotoExpr ); - (__ref2)->inlineItem->children = (__ref3)->inlineList; + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::GotoExpr ); + (__ref2)->inlineItem->children = (__ref3)->inlineList; -#line 6329 "rlparse.cpp" +#line 6329 "rlparse.cpp" } break; case 214: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1295 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, new NameRef(nameRef), InlineItem::Next ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, new NameRef(nameRef), InlineItem::Next ); -#line 6339 "rlparse.cpp" +#line 6339 "rlparse.cpp" } break; case 215: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; #line 1299 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::NextExpr ); - (__ref2)->inlineItem->children = (__ref3)->inlineList; + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::NextExpr ); + (__ref2)->inlineItem->children = (__ref3)->inlineList; -#line 6352 "rlparse.cpp" +#line 6352 "rlparse.cpp" } break; case 216: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1304 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, new NameRef(nameRef), InlineItem::Call ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, new NameRef(nameRef), InlineItem::Call ); -#line 6362 "rlparse.cpp" +#line 6362 "rlparse.cpp" } break; case 217: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; -Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref2 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[2]->user.inline_list; #line 1308 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::CallExpr ); - (__ref2)->inlineItem->children = (__ref3)->inlineList; + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::CallExpr ); + (__ref2)->inlineItem->children = (__ref3)->inlineList; -#line 6375 "rlparse.cpp" +#line 6375 "rlparse.cpp" } break; case 218: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1313 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Ret ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Ret ); -#line 6385 "rlparse.cpp" +#line 6385 "rlparse.cpp" } break; case 219: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1317 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Break ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Break ); -#line 6395 "rlparse.cpp" +#line 6395 "rlparse.cpp" } break; case 220: { -Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; -Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; -Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&redLel->user.inline_list; -Parser_Lel_inline_item *__ref3 = (Parser_Lel_inline_item*)&rhs[1]->user.inline_item; +Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; +Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; +Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&redLel->user.inline_list; +Parser_Lel_inline_item *__ref3 = (Parser_Lel_inline_item*)&rhs[1]->user.inline_item; #line 1325 "rlparse.kl" - (__ref0)->inlineList = (__ref1)->inlineList; - (__ref2)->inlineList->append( (__ref3)->inlineItem ); + (__ref0)->inlineList = (__ref1)->inlineList; + (__ref2)->inlineList->append( (__ref3)->inlineItem ); -#line 6408 "rlparse.cpp" +#line 6408 "rlparse.cpp" } break; case 221: { -Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; +Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; #line 1330 "rlparse.kl" /* Init the list used for this expr. */ - (__ref0)->inlineList = new InlineList; + (__ref0)->inlineList = new InlineList; -#line 6418 "rlparse.cpp" +#line 6418 "rlparse.cpp" } break; case 222: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; #line 1339 "rlparse.kl" /* Return a text segment. */ - (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); -#line 6430 "rlparse.cpp" +#line 6430 "rlparse.cpp" } break; case 223: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; -Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_token_type *__ref1 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; +Parser_Lel_token_type *__ref2 = (Parser_Lel_token_type*)&rhs[0]->user.token_type; #line 1345 "rlparse.kl" /* Return a text segment, must heap alloc the text. */ - (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->token.loc, (__ref2)->token.data, InlineItem::Text ); -#line 6442 "rlparse.cpp" +#line 6442 "rlparse.cpp" } break; case 224: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Parser_Lel_inline_item *__ref1 = (Parser_Lel_inline_item*)&rhs[0]->user.inline_item; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Parser_Lel_inline_item *__ref1 = (Parser_Lel_inline_item*)&rhs[0]->user.inline_item; #line 1351 "rlparse.kl" /* Pass the inline item up. */ - (__ref0)->inlineItem = (__ref1)->inlineItem; + (__ref0)->inlineItem = (__ref1)->inlineItem; -#line 6453 "rlparse.cpp" +#line 6453 "rlparse.cpp" } break; case 237: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1381 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::PChar ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::PChar ); -#line 6463 "rlparse.cpp" +#line 6463 "rlparse.cpp" } break; case 238: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1386 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Char ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Char ); -#line 6473 "rlparse.cpp" +#line 6473 "rlparse.cpp" } break; case 239: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1391 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Curs ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Curs ); -#line 6483 "rlparse.cpp" +#line 6483 "rlparse.cpp" } break; case 240: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1396 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Targs ); + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, InlineItem::Targs ); -#line 6493 "rlparse.cpp" +#line 6493 "rlparse.cpp" } break; case 241: { -Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_inline_item *__ref0 = (Parser_Lel_inline_item*)&redLel->user.inline_item; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1401 "rlparse.kl" - (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, + (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, new NameRef(nameRef), InlineItem::Entry ); -#line 6504 "rlparse.cpp" +#line 6504 "rlparse.cpp" } break; case 243: { #line 1412 "rlparse.kl" @@ -6510,7 +6510,7 @@ case 243: { nameRef.empty(); -#line 6512 "rlparse.cpp" +#line 6512 "rlparse.cpp" } break; case 245: { #line 1422 "rlparse.kl" @@ -6520,7 +6520,7 @@ case 245: { nameRef.setAs( 0 ); -#line 6522 "rlparse.cpp" +#line 6522 "rlparse.cpp" } break; case 246: { #line 1428 "rlparse.kl" @@ -6528,25 +6528,25 @@ case 246: { nameRef.empty(); -#line 6530 "rlparse.cpp" +#line 6530 "rlparse.cpp" } break; case 247: { -Token *__ref0 = (Token*)&rhs[2]->user.token; +Token *__ref0 = (Token*)&rhs[2]->user.token; #line 1435 "rlparse.kl" - nameRef.append( (__ref0)->data ); + nameRef.append( (__ref0)->data ); -#line 6539 "rlparse.cpp" +#line 6539 "rlparse.cpp" } break; case 248: { -Token *__ref0 = (Token*)&rhs[0]->user.token; +Token *__ref0 = (Token*)&rhs[0]->user.token; #line 1440 "rlparse.kl" - nameRef.append( (__ref0)->data ); + nameRef.append( (__ref0)->data ); -#line 6548 "rlparse.cpp" +#line 6548 "rlparse.cpp" } break; } } @@ -6636,100 +6636,100 @@ commit_base: } switch ( reduction ) { case 225: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1358 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6643 "rlparse.cpp" +#line 6643 "rlparse.cpp" } break; case 226: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1359 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6651 "rlparse.cpp" +#line 6651 "rlparse.cpp" } break; case 227: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1360 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6659 "rlparse.cpp" +#line 6659 "rlparse.cpp" } break; case 228: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1361 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6667 "rlparse.cpp" +#line 6667 "rlparse.cpp" } break; case 229: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1362 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6675 "rlparse.cpp" +#line 6675 "rlparse.cpp" } break; case 230: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1363 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6683 "rlparse.cpp" +#line 6683 "rlparse.cpp" } break; case 231: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1364 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6691 "rlparse.cpp" +#line 6691 "rlparse.cpp" } break; case 232: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1371 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6699 "rlparse.cpp" +#line 6699 "rlparse.cpp" } break; case 233: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1372 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6707 "rlparse.cpp" +#line 6707 "rlparse.cpp" } break; case 234: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1373 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6715 "rlparse.cpp" +#line 6715 "rlparse.cpp" } break; case 235: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1374 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6723 "rlparse.cpp" +#line 6723 "rlparse.cpp" } break; case 236: { -Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; -Token *__ref1 = (Token*)&rhs[0]->user.token; +Parser_Lel_token_type *__ref0 = (Parser_Lel_token_type*)&redLel->user.token_type; +Token *__ref1 = (Token*)&rhs[0]->user.token; #line 1375 "rlparse.kl" - (__ref0)->token = *(__ref1); + (__ref0)->token = *(__ref1); -#line 6731 "rlparse.cpp" +#line 6731 "rlparse.cpp" } break; } #ifdef KELBT_LOG_ACTIONS diff --git a/contrib/tools/ragel6/rlscan.cpp b/contrib/tools/ragel6/rlscan.cpp index 5e2fc36645..181dbde1f4 100644 --- a/contrib/tools/ragel6/rlscan.cpp +++ b/contrib/tools/ragel6/rlscan.cpp @@ -1,8 +1,8 @@ -#line 1 "rlscan.rl" +#line 1 "rlscan.rl" /* * Copyright 2006-2007 Adrian Thurston <thurston@complang.org> - * Copyright 2011 Josef Goettgens + * Copyright 2011 Josef Goettgens */ /* This file is part of Ragel. @@ -51,19 +51,19 @@ enum InlineBlockType */ -#line 125 "rlscan.rl" +#line 125 "rlscan.rl" -#line 65 "rlscan.cpp" -static const int inline_token_scan_start = 2; -static const int inline_token_scan_first_final = 2; -static const int inline_token_scan_error = -1; +#line 65 "rlscan.cpp" +static const int inline_token_scan_start = 2; +static const int inline_token_scan_first_final = 2; +static const int inline_token_scan_error = -1; -static const int inline_token_scan_en_main = 2; +static const int inline_token_scan_en_main = 2; -#line 128 "rlscan.rl" +#line 128 "rlscan.rl" void Scanner::flushImport() { @@ -72,7 +72,7 @@ void Scanner::flushImport() int *eof = 0; -#line 82 "rlscan.cpp" +#line 82 "rlscan.cpp" { tok_cs = inline_token_scan_start; tok_ts = 0; @@ -80,33 +80,33 @@ void Scanner::flushImport() tok_act = 0; } -#line 90 "rlscan.cpp" +#line 90 "rlscan.cpp" { if ( p == pe ) goto _test_eof; - switch ( tok_cs ) - { -tr0: -#line 123 "rlscan.rl" - {{p = (( tok_te))-1;}} - goto st2; -tr1: -#line 109 "rlscan.rl" + switch ( tok_cs ) + { +tr0: +#line 123 "rlscan.rl" + {{p = (( tok_te))-1;}} + goto st2; +tr1: +#line 109 "rlscan.rl" { tok_te = p+1;{ int base = tok_ts - token_data; - int nameOff = 0; - int litOff = 2; + int nameOff = 0; + int litOff = 2; directToParser( inclToParser, fileName, line, column, TK_Word, token_strings[base+nameOff], token_lens[base+nameOff] ); directToParser( inclToParser, fileName, line, column, '=', 0, 0 ); - directToParser( inclToParser, fileName, line, column, TK_Literal, - token_strings[base+litOff], token_lens[base+litOff] ); + directToParser( inclToParser, fileName, line, column, TK_Literal, + token_strings[base+litOff], token_lens[base+litOff] ); directToParser( inclToParser, fileName, line, column, ';', 0, 0 ); }} - goto st2; -tr2: -#line 81 "rlscan.rl" + goto st2; +tr2: +#line 81 "rlscan.rl" { tok_te = p+1;{ int base = tok_ts - token_data; int nameOff = 0; @@ -119,9 +119,9 @@ tr2: token_strings[base+numOff], token_lens[base+numOff] ); directToParser( inclToParser, fileName, line, column, ';', 0, 0 ); }} - goto st2; -tr3: -#line 95 "rlscan.rl" + goto st2; +tr3: +#line 95 "rlscan.rl" { tok_te = p+1;{ int base = tok_ts - token_data; int nameOff = 1; @@ -134,107 +134,107 @@ tr3: token_strings[base+litOff], token_lens[base+litOff] ); directToParser( inclToParser, fileName, line, column, ';', 0, 0 ); }} - goto st2; -tr4: -#line 67 "rlscan.rl" + goto st2; +tr4: +#line 67 "rlscan.rl" { tok_te = p+1;{ int base = tok_ts - token_data; - int nameOff = 1; - int numOff = 2; + int nameOff = 1; + int numOff = 2; directToParser( inclToParser, fileName, line, column, TK_Word, token_strings[base+nameOff], token_lens[base+nameOff] ); directToParser( inclToParser, fileName, line, column, '=', 0, 0 ); - directToParser( inclToParser, fileName, line, column, TK_UInt, - token_strings[base+numOff], token_lens[base+numOff] ); + directToParser( inclToParser, fileName, line, column, TK_UInt, + token_strings[base+numOff], token_lens[base+numOff] ); directToParser( inclToParser, fileName, line, column, ';', 0, 0 ); }} - goto st2; -tr5: -#line 123 "rlscan.rl" + goto st2; +tr5: +#line 123 "rlscan.rl" { tok_te = p+1;} - goto st2; -tr8: -#line 123 "rlscan.rl" + goto st2; +tr8: +#line 123 "rlscan.rl" { tok_te = p;p--;} - goto st2; -st2: + goto st2; +st2: #line 1 "NONE" { tok_ts = 0;} - if ( ++p == pe ) - goto _test_eof2; -case 2: -#line 1 "NONE" - { tok_ts = p;} -#line 176 "rlscan.cpp" - switch( (*p) ) { - case 128: goto tr6; - case 131: goto tr7; - } - goto tr5; -tr6: -#line 1 "NONE" - { tok_te = p+1;} - goto st3; -st3: - if ( ++p == pe ) - goto _test_eof3; -case 3: -#line 190 "rlscan.cpp" - if ( (*p) == 61 ) - goto st0; - goto tr8; -st0: - if ( ++p == pe ) - goto _test_eof0; -case 0: - switch( (*p) ) { - case 129: goto tr1; - case 130: goto tr2; - } - goto tr0; -tr7: -#line 1 "NONE" - { tok_te = p+1;} - goto st4; -st4: - if ( ++p == pe ) - goto _test_eof4; -case 4: -#line 211 "rlscan.cpp" - if ( (*p) == 128 ) - goto st1; - goto tr8; -st1: - if ( ++p == pe ) - goto _test_eof1; -case 1: - switch( (*p) ) { - case 129: goto tr3; - case 130: goto tr4; - } - goto tr0; - } - _test_eof2: tok_cs = 2; goto _test_eof; - _test_eof3: tok_cs = 3; goto _test_eof; - _test_eof0: tok_cs = 0; goto _test_eof; - _test_eof4: tok_cs = 4; goto _test_eof; - _test_eof1: tok_cs = 1; goto _test_eof; + if ( ++p == pe ) + goto _test_eof2; +case 2: +#line 1 "NONE" + { tok_ts = p;} +#line 176 "rlscan.cpp" + switch( (*p) ) { + case 128: goto tr6; + case 131: goto tr7; + } + goto tr5; +tr6: +#line 1 "NONE" + { tok_te = p+1;} + goto st3; +st3: + if ( ++p == pe ) + goto _test_eof3; +case 3: +#line 190 "rlscan.cpp" + if ( (*p) == 61 ) + goto st0; + goto tr8; +st0: + if ( ++p == pe ) + goto _test_eof0; +case 0: + switch( (*p) ) { + case 129: goto tr1; + case 130: goto tr2; + } + goto tr0; +tr7: +#line 1 "NONE" + { tok_te = p+1;} + goto st4; +st4: + if ( ++p == pe ) + goto _test_eof4; +case 4: +#line 211 "rlscan.cpp" + if ( (*p) == 128 ) + goto st1; + goto tr8; +st1: + if ( ++p == pe ) + goto _test_eof1; +case 1: + switch( (*p) ) { + case 129: goto tr3; + case 130: goto tr4; + } + goto tr0; + } + _test_eof2: tok_cs = 2; goto _test_eof; + _test_eof3: tok_cs = 3; goto _test_eof; + _test_eof0: tok_cs = 0; goto _test_eof; + _test_eof4: tok_cs = 4; goto _test_eof; + _test_eof1: tok_cs = 1; goto _test_eof; _test_eof: {} if ( p == eof ) { - switch ( tok_cs ) { - case 3: goto tr8; - case 0: goto tr0; - case 4: goto tr8; - case 1: goto tr0; + switch ( tok_cs ) { + case 3: goto tr8; + case 0: goto tr0; + case 4: goto tr8; + case 1: goto tr0; } } } -#line 139 "rlscan.rl" +#line 139 "rlscan.rl" if ( tok_ts == 0 ) @@ -311,27 +311,27 @@ void Scanner::pass() */ -#line 321 "rlscan.cpp" -static const int section_parse_start = 10; -static const int section_parse_first_final = 10; -static const int section_parse_error = 0; +#line 321 "rlscan.cpp" +static const int section_parse_start = 10; +static const int section_parse_first_final = 10; +static const int section_parse_error = 0; -static const int section_parse_en_main = 10; +static const int section_parse_en_main = 10; -#line 218 "rlscan.rl" +#line 218 "rlscan.rl" void Scanner::init( ) { -#line 336 "rlscan.cpp" +#line 336 "rlscan.cpp" { cs = section_parse_start; } -#line 224 "rlscan.rl" +#line 224 "rlscan.rl" } bool Scanner::active() @@ -485,7 +485,7 @@ void Scanner::handleImport() } -#line 461 "rlscan.rl" +#line 461 "rlscan.rl" void Scanner::token( int type, char c ) @@ -525,154 +525,154 @@ void Scanner::processToken( int type, char *tokdata, int toklen ) } -#line 535 "rlscan.cpp" +#line 535 "rlscan.cpp" { if ( p == pe ) goto _test_eof; - switch ( cs ) - { -tr2: -#line 391 "rlscan.rl" - { handleMachine(); } - goto st10; -tr6: -#line 392 "rlscan.rl" - { handleInclude(); } - goto st10; -tr10: -#line 393 "rlscan.rl" - { handleImport(); } - goto st10; -tr13: -#line 433 "rlscan.rl" - { - if ( active() && machineSpec == 0 && machineName == 0 ) - id.inputItems.tail->writeArgs.append( 0 ); - } - goto st10; -tr14: -#line 444 "rlscan.rl" - { - /* Send the token off to the parser. */ - if ( active() ) - directToParser( parser, fileName, line, column, type, tokdata, toklen ); - } - goto st10; -st10: - if ( ++p == pe ) - goto _test_eof10; -case 10: -#line 572 "rlscan.cpp" - switch( (*p) ) { - case 191: goto st1; - case 192: goto st3; - case 193: goto st6; - case 194: goto tr18; - } - goto tr14; -st1: - if ( ++p == pe ) - goto _test_eof1; -case 1: - if ( (*p) == 128 ) - goto tr1; - goto tr0; -tr0: -#line 386 "rlscan.rl" + switch ( cs ) + { +tr2: +#line 391 "rlscan.rl" + { handleMachine(); } + goto st10; +tr6: +#line 392 "rlscan.rl" + { handleInclude(); } + goto st10; +tr10: +#line 393 "rlscan.rl" + { handleImport(); } + goto st10; +tr13: +#line 433 "rlscan.rl" + { + if ( active() && machineSpec == 0 && machineName == 0 ) + id.inputItems.tail->writeArgs.append( 0 ); + } + goto st10; +tr14: +#line 444 "rlscan.rl" + { + /* Send the token off to the parser. */ + if ( active() ) + directToParser( parser, fileName, line, column, type, tokdata, toklen ); + } + goto st10; +st10: + if ( ++p == pe ) + goto _test_eof10; +case 10: +#line 572 "rlscan.cpp" + switch( (*p) ) { + case 191: goto st1; + case 192: goto st3; + case 193: goto st6; + case 194: goto tr18; + } + goto tr14; +st1: + if ( ++p == pe ) + goto _test_eof1; +case 1: + if ( (*p) == 128 ) + goto tr1; + goto tr0; +tr0: +#line 386 "rlscan.rl" { scan_error() << "bad machine statement" << endl; } - goto st0; -tr3: -#line 387 "rlscan.rl" + goto st0; +tr3: +#line 387 "rlscan.rl" { scan_error() << "bad include statement" << endl; } - goto st0; -tr8: -#line 388 "rlscan.rl" + goto st0; +tr8: +#line 388 "rlscan.rl" { scan_error() << "bad import statement" << endl; } - goto st0; -tr11: -#line 389 "rlscan.rl" + goto st0; +tr11: +#line 389 "rlscan.rl" { scan_error() << "bad write statement" << endl; } - goto st0; -#line 603 "rlscan.cpp" -st0: -cs = 0; - goto _out; -tr1: -#line 383 "rlscan.rl" - { word = tokdata; word_len = toklen; } - goto st2; -st2: - if ( ++p == pe ) - goto _test_eof2; -case 2: -#line 615 "rlscan.cpp" - if ( (*p) == 59 ) - goto tr2; - goto tr0; -st3: - if ( ++p == pe ) - goto _test_eof3; -case 3: - switch( (*p) ) { - case 128: goto tr4; - case 129: goto tr5; - } - goto tr3; -tr4: -#line 382 "rlscan.rl" - { word = lit = 0; word_len = lit_len = 0; } -#line 383 "rlscan.rl" - { word = tokdata; word_len = toklen; } - goto st4; -st4: - if ( ++p == pe ) - goto _test_eof4; -case 4: -#line 638 "rlscan.cpp" - switch( (*p) ) { - case 59: goto tr6; - case 129: goto tr7; - } - goto tr3; -tr5: -#line 382 "rlscan.rl" - { word = lit = 0; word_len = lit_len = 0; } -#line 384 "rlscan.rl" - { lit = tokdata; lit_len = toklen; } - goto st5; -tr7: -#line 384 "rlscan.rl" - { lit = tokdata; lit_len = toklen; } - goto st5; -st5: - if ( ++p == pe ) - goto _test_eof5; -case 5: -#line 658 "rlscan.cpp" - if ( (*p) == 59 ) - goto tr6; - goto tr3; -st6: - if ( ++p == pe ) - goto _test_eof6; -case 6: - if ( (*p) == 129 ) - goto tr9; - goto tr8; -tr9: -#line 384 "rlscan.rl" - { lit = tokdata; lit_len = toklen; } - goto st7; -st7: - if ( ++p == pe ) - goto _test_eof7; -case 7: -#line 677 "rlscan.cpp" - if ( (*p) == 59 ) - goto tr10; - goto tr8; -tr18: -#line 413 "rlscan.rl" + goto st0; +#line 603 "rlscan.cpp" +st0: +cs = 0; + goto _out; +tr1: +#line 383 "rlscan.rl" + { word = tokdata; word_len = toklen; } + goto st2; +st2: + if ( ++p == pe ) + goto _test_eof2; +case 2: +#line 615 "rlscan.cpp" + if ( (*p) == 59 ) + goto tr2; + goto tr0; +st3: + if ( ++p == pe ) + goto _test_eof3; +case 3: + switch( (*p) ) { + case 128: goto tr4; + case 129: goto tr5; + } + goto tr3; +tr4: +#line 382 "rlscan.rl" + { word = lit = 0; word_len = lit_len = 0; } +#line 383 "rlscan.rl" + { word = tokdata; word_len = toklen; } + goto st4; +st4: + if ( ++p == pe ) + goto _test_eof4; +case 4: +#line 638 "rlscan.cpp" + switch( (*p) ) { + case 59: goto tr6; + case 129: goto tr7; + } + goto tr3; +tr5: +#line 382 "rlscan.rl" + { word = lit = 0; word_len = lit_len = 0; } +#line 384 "rlscan.rl" + { lit = tokdata; lit_len = toklen; } + goto st5; +tr7: +#line 384 "rlscan.rl" + { lit = tokdata; lit_len = toklen; } + goto st5; +st5: + if ( ++p == pe ) + goto _test_eof5; +case 5: +#line 658 "rlscan.cpp" + if ( (*p) == 59 ) + goto tr6; + goto tr3; +st6: + if ( ++p == pe ) + goto _test_eof6; +case 6: + if ( (*p) == 129 ) + goto tr9; + goto tr8; +tr9: +#line 384 "rlscan.rl" + { lit = tokdata; lit_len = toklen; } + goto st7; +st7: + if ( ++p == pe ) + goto _test_eof7; +case 7: +#line 677 "rlscan.cpp" + if ( (*p) == 59 ) + goto tr10; + goto tr8; +tr18: +#line 413 "rlscan.rl" { if ( active() && machineSpec == 0 && machineName == 0 ) { InputItem *inputItem = new InputItem; @@ -685,77 +685,77 @@ tr18: id.inputItems.append( inputItem ); } } - goto st8; -st8: - if ( ++p == pe ) - goto _test_eof8; -case 8: -#line 700 "rlscan.cpp" - if ( (*p) == 128 ) - goto tr12; - goto tr11; -tr12: -#line 427 "rlscan.rl" + goto st8; +st8: + if ( ++p == pe ) + goto _test_eof8; +case 8: +#line 700 "rlscan.cpp" + if ( (*p) == 128 ) + goto tr12; + goto tr11; +tr12: +#line 427 "rlscan.rl" { if ( active() && machineSpec == 0 && machineName == 0 ) id.inputItems.tail->writeArgs.append( strdup(tokdata) ); } - goto st9; -st9: - if ( ++p == pe ) - goto _test_eof9; -case 9: -#line 715 "rlscan.cpp" - switch( (*p) ) { - case 59: goto tr13; - case 128: goto tr12; - } - goto tr11; - } - _test_eof10: cs = 10; goto _test_eof; - _test_eof1: cs = 1; goto _test_eof; - _test_eof2: cs = 2; goto _test_eof; - _test_eof3: cs = 3; goto _test_eof; - _test_eof4: cs = 4; goto _test_eof; - _test_eof5: cs = 5; goto _test_eof; - _test_eof6: cs = 6; goto _test_eof; - _test_eof7: cs = 7; goto _test_eof; - _test_eof8: cs = 8; goto _test_eof; - _test_eof9: cs = 9; goto _test_eof; + goto st9; +st9: + if ( ++p == pe ) + goto _test_eof9; +case 9: +#line 715 "rlscan.cpp" + switch( (*p) ) { + case 59: goto tr13; + case 128: goto tr12; + } + goto tr11; + } + _test_eof10: cs = 10; goto _test_eof; + _test_eof1: cs = 1; goto _test_eof; + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; _test_eof: {} if ( p == eof ) { - switch ( cs ) { - case 1: - case 2: -#line 386 "rlscan.rl" + switch ( cs ) { + case 1: + case 2: +#line 386 "rlscan.rl" { scan_error() << "bad machine statement" << endl; } break; - case 3: - case 4: - case 5: -#line 387 "rlscan.rl" + case 3: + case 4: + case 5: +#line 387 "rlscan.rl" { scan_error() << "bad include statement" << endl; } break; - case 6: - case 7: -#line 388 "rlscan.rl" + case 6: + case 7: +#line 388 "rlscan.rl" { scan_error() << "bad import statement" << endl; } break; - case 8: - case 9: -#line 389 "rlscan.rl" + case 8: + case 9: +#line 389 "rlscan.rl" { scan_error() << "bad write statement" << endl; } break; -#line 758 "rlscan.cpp" +#line 758 "rlscan.cpp" } } _out: {} } -#line 502 "rlscan.rl" +#line 502 "rlscan.rl" updateCol(); @@ -811,18 +811,18 @@ bool isAbsolutePath( const char *path ) #endif } -inline char* resolvePath(const char* rel, const char* abs) { - const size_t l1 = strlen(rel); - const size_t l2 = strlen(abs); - char* ret = new char[l1 + l2 + 1]; - - const char* p = strrchr(abs, '/') + 1; - const size_t l3 = p - abs; - - memcpy(ret, abs, l3); - strcpy(ret + l3, rel); - - return ret; +inline char* resolvePath(const char* rel, const char* abs) { + const size_t l1 = strlen(rel); + const size_t l2 = strlen(abs); + char* ret = new char[l1 + l2 + 1]; + + const char* p = strrchr(abs, '/') + 1; + const size_t l3 = p - abs; + + memcpy(ret, abs, l3); + strcpy(ret + l3, rel); + + return ret; } char **Scanner::makeIncludePathChecks( const char *thisFileName, @@ -848,7 +848,7 @@ char **Scanner::makeIncludePathChecks( const char *thisFileName, if ( lastSlash == 0 ) checks[nextCheck++] = data; else { - checks[nextCheck++] = resolvePath(data, thisFileName); + checks[nextCheck++] = resolvePath(data, thisFileName); } /* Search from the include paths given on the command line. */ @@ -879,16 +879,16 @@ ifstream *Scanner::tryOpenInclude( char **pathChecks, long &found ) found = check - pathChecks; return inFile; } - - /* - * 03/26/2011 jg: - * Don't rely on sloppy runtime behaviour: reset the state of the stream explicitly. - * If inFile->open() fails, which happens when include dirs are tested, the fail bit - * is set by the runtime library. Currently the VS runtime library opens new files, - * but when it comes to reading it refuses to work. - */ - inFile->clear(); - + + /* + * 03/26/2011 jg: + * Don't rely on sloppy runtime behaviour: reset the state of the stream explicitly. + * If inFile->open() fails, which happens when include dirs are tested, the fail bit + * is set by the runtime library. Currently the VS runtime library opens new files, + * but when it comes to reading it refuses to work. + */ + inFile->clear(); + check += 1; } @@ -898,26 +898,26 @@ ifstream *Scanner::tryOpenInclude( char **pathChecks, long &found ) } -#line 1173 "rlscan.rl" +#line 1173 "rlscan.rl" -#line 904 "rlscan.cpp" -static const int rlscan_start = 38; -static const int rlscan_first_final = 38; -static const int rlscan_error = 0; +#line 904 "rlscan.cpp" +static const int rlscan_start = 38; +static const int rlscan_first_final = 38; +static const int rlscan_error = 0; -static const int rlscan_en_inline_code_ruby = 52; -static const int rlscan_en_inline_code = 95; -static const int rlscan_en_or_literal = 137; -static const int rlscan_en_ragel_re_literal = 139; -static const int rlscan_en_write_statement = 143; -static const int rlscan_en_parser_def = 146; -static const int rlscan_en_main_ruby = 253; -static const int rlscan_en_main = 38; +static const int rlscan_en_inline_code_ruby = 52; +static const int rlscan_en_inline_code = 95; +static const int rlscan_en_or_literal = 137; +static const int rlscan_en_ragel_re_literal = 139; +static const int rlscan_en_write_statement = 143; +static const int rlscan_en_parser_def = 146; +static const int rlscan_en_main_ruby = 253; +static const int rlscan_en_main = 38; -#line 1176 "rlscan.rl" +#line 1176 "rlscan.rl" void Scanner::do_scan() { @@ -938,7 +938,7 @@ void Scanner::do_scan() /* Init the section parser and the character scanner. */ init(); -#line 940 "rlscan.cpp" +#line 940 "rlscan.cpp" { cs = rlscan_start; top = 0; @@ -947,7 +947,7 @@ void Scanner::do_scan() act = 0; } -#line 1196 "rlscan.rl" +#line 1196 "rlscan.rl" /* Set up the start state. FIXME: After 5.20 is released the nocs write * init option should be used, the main machine eliminated and this statement moved @@ -993,736 +993,736 @@ void Scanner::do_scan() } -#line 995 "rlscan.cpp" +#line 995 "rlscan.cpp" { if ( p == pe ) goto _test_eof; - goto _resume; - -_again: - switch ( cs ) { - case 38: goto st38; - case 39: goto st39; - case 40: goto st40; - case 1: goto st1; - case 2: goto st2; - case 41: goto st41; - case 42: goto st42; - case 43: goto st43; - case 3: goto st3; - case 4: goto st4; - case 44: goto st44; - case 5: goto st5; - case 6: goto st6; - case 7: goto st7; - case 45: goto st45; - case 46: goto st46; - case 47: goto st47; - case 48: goto st48; - case 49: goto st49; - case 50: goto st50; - case 51: goto st51; - case 52: goto st52; - case 53: goto st53; - case 54: goto st54; - case 8: goto st8; - case 9: goto st9; - case 55: goto st55; - case 10: goto st10; - case 56: goto st56; - case 11: goto st11; - case 12: goto st12; - case 57: goto st57; - case 13: goto st13; - case 14: goto st14; - case 58: goto st58; - case 59: goto st59; - case 15: goto st15; - case 60: goto st60; - case 61: goto st61; - case 62: goto st62; - case 63: goto st63; - case 64: goto st64; - case 65: goto st65; - case 66: goto st66; - case 67: goto st67; - case 68: goto st68; - case 69: goto st69; - case 70: goto st70; - case 71: goto st71; - case 72: goto st72; - case 73: goto st73; - case 74: goto st74; - case 75: goto st75; - case 76: goto st76; - case 77: goto st77; - case 78: goto st78; - case 79: goto st79; - case 80: goto st80; - case 81: goto st81; - case 82: goto st82; - case 83: goto st83; - case 84: goto st84; - case 85: goto st85; - case 86: goto st86; - case 87: goto st87; - case 88: goto st88; - case 89: goto st89; - case 90: goto st90; - case 91: goto st91; - case 92: goto st92; - case 93: goto st93; - case 94: goto st94; - case 95: goto st95; - case 96: goto st96; - case 97: goto st97; - case 16: goto st16; - case 17: goto st17; - case 98: goto st98; - case 18: goto st18; - case 19: goto st19; - case 99: goto st99; - case 20: goto st20; - case 21: goto st21; - case 22: goto st22; - case 100: goto st100; - case 101: goto st101; - case 23: goto st23; - case 102: goto st102; - case 103: goto st103; - case 104: goto st104; - case 105: goto st105; - case 106: goto st106; - case 107: goto st107; - case 108: goto st108; - case 109: goto st109; - case 110: goto st110; - case 111: goto st111; - case 112: goto st112; - case 113: goto st113; - case 114: goto st114; - case 115: goto st115; - case 116: goto st116; - case 117: goto st117; - case 118: goto st118; - case 119: goto st119; - case 120: goto st120; - case 121: goto st121; - case 122: goto st122; - case 123: goto st123; - case 124: goto st124; - case 125: goto st125; - case 126: goto st126; - case 127: goto st127; - case 128: goto st128; - case 129: goto st129; - case 130: goto st130; - case 131: goto st131; - case 132: goto st132; - case 133: goto st133; - case 134: goto st134; - case 135: goto st135; - case 136: goto st136; - case 137: goto st137; - case 138: goto st138; - case 139: goto st139; - case 140: goto st140; - case 141: goto st141; - case 142: goto st142; - case 143: goto st143; - case 0: goto st0; - case 144: goto st144; - case 145: goto st145; - case 146: goto st146; - case 147: goto st147; - case 148: goto st148; - case 24: goto st24; - case 149: goto st149; - case 25: goto st25; - case 150: goto st150; - case 26: goto st26; - case 151: goto st151; - case 152: goto st152; - case 153: goto st153; - case 27: goto st27; - case 28: goto st28; - case 154: goto st154; - case 155: goto st155; - case 156: goto st156; - case 157: goto st157; - case 158: goto st158; - case 29: goto st29; - case 159: goto st159; - case 160: goto st160; - case 161: goto st161; - case 162: goto st162; - case 163: goto st163; - case 164: goto st164; - case 165: goto st165; - case 166: goto st166; - case 167: goto st167; - case 168: goto st168; - case 169: goto st169; - case 170: goto st170; - case 171: goto st171; - case 172: goto st172; - case 173: goto st173; - case 174: goto st174; - case 175: goto st175; - case 176: goto st176; - case 177: goto st177; - case 178: goto st178; - case 179: goto st179; - case 180: goto st180; - case 181: goto st181; - case 182: goto st182; - case 183: goto st183; - case 184: goto st184; - case 185: goto st185; - case 186: goto st186; - case 187: goto st187; - case 188: goto st188; - case 189: goto st189; - case 190: goto st190; - case 191: goto st191; - case 192: goto st192; - case 193: goto st193; - case 194: goto st194; - case 195: goto st195; - case 196: goto st196; - case 197: goto st197; - case 198: goto st198; - case 199: goto st199; - case 200: goto st200; - case 201: goto st201; - case 202: goto st202; - case 203: goto st203; - case 204: goto st204; - case 205: goto st205; - case 206: goto st206; - case 207: goto st207; - case 208: goto st208; - case 209: goto st209; - case 210: goto st210; - case 211: goto st211; - case 212: goto st212; - case 213: goto st213; - case 214: goto st214; - case 215: goto st215; - case 216: goto st216; - case 217: goto st217; - case 218: goto st218; - case 219: goto st219; - case 220: goto st220; - case 221: goto st221; - case 222: goto st222; - case 223: goto st223; - case 224: goto st224; - case 225: goto st225; - case 226: goto st226; - case 227: goto st227; - case 228: goto st228; - case 229: goto st229; - case 230: goto st230; - case 231: goto st231; - case 232: goto st232; - case 233: goto st233; - case 234: goto st234; - case 235: goto st235; - case 236: goto st236; - case 237: goto st237; - case 238: goto st238; - case 239: goto st239; - case 240: goto st240; - case 241: goto st241; - case 242: goto st242; - case 243: goto st243; - case 244: goto st244; - case 245: goto st245; - case 246: goto st246; - case 247: goto st247; - case 248: goto st248; - case 249: goto st249; - case 250: goto st250; - case 251: goto st251; - case 252: goto st252; - case 30: goto st30; - case 253: goto st253; - case 254: goto st254; - case 255: goto st255; - case 31: goto st31; - case 32: goto st32; - case 256: goto st256; - case 33: goto st33; - case 257: goto st257; - case 258: goto st258; - case 259: goto st259; - case 34: goto st34; - case 35: goto st35; - case 260: goto st260; - case 36: goto st36; - case 37: goto st37; - case 261: goto st261; - case 262: goto st262; - default: break; - } - - if ( ++p == pe ) - goto _test_eof; + goto _resume; + +_again: + switch ( cs ) { + case 38: goto st38; + case 39: goto st39; + case 40: goto st40; + case 1: goto st1; + case 2: goto st2; + case 41: goto st41; + case 42: goto st42; + case 43: goto st43; + case 3: goto st3; + case 4: goto st4; + case 44: goto st44; + case 5: goto st5; + case 6: goto st6; + case 7: goto st7; + case 45: goto st45; + case 46: goto st46; + case 47: goto st47; + case 48: goto st48; + case 49: goto st49; + case 50: goto st50; + case 51: goto st51; + case 52: goto st52; + case 53: goto st53; + case 54: goto st54; + case 8: goto st8; + case 9: goto st9; + case 55: goto st55; + case 10: goto st10; + case 56: goto st56; + case 11: goto st11; + case 12: goto st12; + case 57: goto st57; + case 13: goto st13; + case 14: goto st14; + case 58: goto st58; + case 59: goto st59; + case 15: goto st15; + case 60: goto st60; + case 61: goto st61; + case 62: goto st62; + case 63: goto st63; + case 64: goto st64; + case 65: goto st65; + case 66: goto st66; + case 67: goto st67; + case 68: goto st68; + case 69: goto st69; + case 70: goto st70; + case 71: goto st71; + case 72: goto st72; + case 73: goto st73; + case 74: goto st74; + case 75: goto st75; + case 76: goto st76; + case 77: goto st77; + case 78: goto st78; + case 79: goto st79; + case 80: goto st80; + case 81: goto st81; + case 82: goto st82; + case 83: goto st83; + case 84: goto st84; + case 85: goto st85; + case 86: goto st86; + case 87: goto st87; + case 88: goto st88; + case 89: goto st89; + case 90: goto st90; + case 91: goto st91; + case 92: goto st92; + case 93: goto st93; + case 94: goto st94; + case 95: goto st95; + case 96: goto st96; + case 97: goto st97; + case 16: goto st16; + case 17: goto st17; + case 98: goto st98; + case 18: goto st18; + case 19: goto st19; + case 99: goto st99; + case 20: goto st20; + case 21: goto st21; + case 22: goto st22; + case 100: goto st100; + case 101: goto st101; + case 23: goto st23; + case 102: goto st102; + case 103: goto st103; + case 104: goto st104; + case 105: goto st105; + case 106: goto st106; + case 107: goto st107; + case 108: goto st108; + case 109: goto st109; + case 110: goto st110; + case 111: goto st111; + case 112: goto st112; + case 113: goto st113; + case 114: goto st114; + case 115: goto st115; + case 116: goto st116; + case 117: goto st117; + case 118: goto st118; + case 119: goto st119; + case 120: goto st120; + case 121: goto st121; + case 122: goto st122; + case 123: goto st123; + case 124: goto st124; + case 125: goto st125; + case 126: goto st126; + case 127: goto st127; + case 128: goto st128; + case 129: goto st129; + case 130: goto st130; + case 131: goto st131; + case 132: goto st132; + case 133: goto st133; + case 134: goto st134; + case 135: goto st135; + case 136: goto st136; + case 137: goto st137; + case 138: goto st138; + case 139: goto st139; + case 140: goto st140; + case 141: goto st141; + case 142: goto st142; + case 143: goto st143; + case 0: goto st0; + case 144: goto st144; + case 145: goto st145; + case 146: goto st146; + case 147: goto st147; + case 148: goto st148; + case 24: goto st24; + case 149: goto st149; + case 25: goto st25; + case 150: goto st150; + case 26: goto st26; + case 151: goto st151; + case 152: goto st152; + case 153: goto st153; + case 27: goto st27; + case 28: goto st28; + case 154: goto st154; + case 155: goto st155; + case 156: goto st156; + case 157: goto st157; + case 158: goto st158; + case 29: goto st29; + case 159: goto st159; + case 160: goto st160; + case 161: goto st161; + case 162: goto st162; + case 163: goto st163; + case 164: goto st164; + case 165: goto st165; + case 166: goto st166; + case 167: goto st167; + case 168: goto st168; + case 169: goto st169; + case 170: goto st170; + case 171: goto st171; + case 172: goto st172; + case 173: goto st173; + case 174: goto st174; + case 175: goto st175; + case 176: goto st176; + case 177: goto st177; + case 178: goto st178; + case 179: goto st179; + case 180: goto st180; + case 181: goto st181; + case 182: goto st182; + case 183: goto st183; + case 184: goto st184; + case 185: goto st185; + case 186: goto st186; + case 187: goto st187; + case 188: goto st188; + case 189: goto st189; + case 190: goto st190; + case 191: goto st191; + case 192: goto st192; + case 193: goto st193; + case 194: goto st194; + case 195: goto st195; + case 196: goto st196; + case 197: goto st197; + case 198: goto st198; + case 199: goto st199; + case 200: goto st200; + case 201: goto st201; + case 202: goto st202; + case 203: goto st203; + case 204: goto st204; + case 205: goto st205; + case 206: goto st206; + case 207: goto st207; + case 208: goto st208; + case 209: goto st209; + case 210: goto st210; + case 211: goto st211; + case 212: goto st212; + case 213: goto st213; + case 214: goto st214; + case 215: goto st215; + case 216: goto st216; + case 217: goto st217; + case 218: goto st218; + case 219: goto st219; + case 220: goto st220; + case 221: goto st221; + case 222: goto st222; + case 223: goto st223; + case 224: goto st224; + case 225: goto st225; + case 226: goto st226; + case 227: goto st227; + case 228: goto st228; + case 229: goto st229; + case 230: goto st230; + case 231: goto st231; + case 232: goto st232; + case 233: goto st233; + case 234: goto st234; + case 235: goto st235; + case 236: goto st236; + case 237: goto st237; + case 238: goto st238; + case 239: goto st239; + case 240: goto st240; + case 241: goto st241; + case 242: goto st242; + case 243: goto st243; + case 244: goto st244; + case 245: goto st245; + case 246: goto st246; + case 247: goto st247; + case 248: goto st248; + case 249: goto st249; + case 250: goto st250; + case 251: goto st251; + case 252: goto st252; + case 30: goto st30; + case 253: goto st253; + case 254: goto st254; + case 255: goto st255; + case 31: goto st31; + case 32: goto st32; + case 256: goto st256; + case 33: goto st33; + case 257: goto st257; + case 258: goto st258; + case 259: goto st259; + case 34: goto st34; + case 35: goto st35; + case 260: goto st260; + case 36: goto st36; + case 37: goto st37; + case 261: goto st261; + case 262: goto st262; + default: break; + } + + if ( ++p == pe ) + goto _test_eof; _resume: - switch ( cs ) - { -tr0: -#line 1171 "rlscan.rl" - {{p = ((te))-1;}{ pass( *ts, 0, 0 ); }} - goto st38; -tr3: -#line 1155 "rlscan.rl" - {te = p+1;{ pass( IMP_Literal, ts, te ); }} - goto st38; -tr11: -#line 1154 "rlscan.rl" - {te = p+1;{ pass(); }} - goto st38; -tr13: -#line 641 "rlscan.rl" + switch ( cs ) { - lastnl = p; - column = 0; - line++; - } -#line 1154 "rlscan.rl" - {te = p+1;{ pass(); }} - goto st38; -tr71: -#line 1171 "rlscan.rl" - {te = p+1;{ pass( *ts, 0, 0 ); }} - goto st38; -tr72: -#line 1170 "rlscan.rl" - {te = p+1;} - goto st38; -tr82: -#line 1169 "rlscan.rl" - {te = p;p--;{ pass(); }} - goto st38; -tr83: -#line 1171 "rlscan.rl" - {te = p;p--;{ pass( *ts, 0, 0 ); }} - goto st38; -tr85: -#line 1163 "rlscan.rl" - {te = p;p--;{ - updateCol(); - singleLineSpec = true; - startSection(); - {stack[top++] = 38; goto st146;} - }} - goto st38; -tr86: -#line 1157 "rlscan.rl" - {te = p+1;{ - updateCol(); - singleLineSpec = false; - startSection(); - {stack[top++] = 38; goto st146;} - }} - goto st38; -tr87: -#line 1153 "rlscan.rl" - {te = p;p--;{ pass( IMP_UInt, ts, te ); }} - goto st38; -tr88: +tr0: +#line 1171 "rlscan.rl" + {{p = ((te))-1;}{ pass( *ts, 0, 0 ); }} + goto st38; +tr3: +#line 1155 "rlscan.rl" + {te = p+1;{ pass( IMP_Literal, ts, te ); }} + goto st38; +tr11: +#line 1154 "rlscan.rl" + {te = p+1;{ pass(); }} + goto st38; +tr13: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } +#line 1154 "rlscan.rl" + {te = p+1;{ pass(); }} + goto st38; +tr71: +#line 1171 "rlscan.rl" + {te = p+1;{ pass( *ts, 0, 0 ); }} + goto st38; +tr72: +#line 1170 "rlscan.rl" + {te = p+1;} + goto st38; +tr82: +#line 1169 "rlscan.rl" + {te = p;p--;{ pass(); }} + goto st38; +tr83: +#line 1171 "rlscan.rl" + {te = p;p--;{ pass( *ts, 0, 0 ); }} + goto st38; +tr85: +#line 1163 "rlscan.rl" + {te = p;p--;{ + updateCol(); + singleLineSpec = true; + startSection(); + {stack[top++] = 38; goto st146;} + }} + goto st38; +tr86: +#line 1157 "rlscan.rl" + {te = p+1;{ + updateCol(); + singleLineSpec = false; + startSection(); + {stack[top++] = 38; goto st146;} + }} + goto st38; +tr87: +#line 1153 "rlscan.rl" + {te = p;p--;{ pass( IMP_UInt, ts, te ); }} + goto st38; +tr88: #line 1 "NONE" - { switch( act ) { - case 176: - {{p = ((te))-1;} pass( IMP_Define, 0, 0 ); } + { switch( act ) { + case 176: + {{p = ((te))-1;} pass( IMP_Define, 0, 0 ); } break; - case 177: - {{p = ((te))-1;} pass( IMP_Word, ts, te ); } - break; - } - } - goto st38; -tr89: -#line 1152 "rlscan.rl" - {te = p;p--;{ pass( IMP_Word, ts, te ); }} - goto st38; -st38: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof38; -case 38: -#line 1 "NONE" - {ts = p;} -#line 1358 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr72; - case 9: goto st39; - case 10: goto tr74; - case 32: goto st39; - case 34: goto tr75; - case 37: goto st41; - case 39: goto tr77; - case 47: goto tr78; - case 95: goto tr80; - case 100: goto st47; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st45; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr71; -tr74: -#line 641 "rlscan.rl" + case 177: + {{p = ((te))-1;} pass( IMP_Word, ts, te ); } + break; + } + } + goto st38; +tr89: +#line 1152 "rlscan.rl" + {te = p;p--;{ pass( IMP_Word, ts, te ); }} + goto st38; +st38: +#line 1 "NONE" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof38; +case 38: +#line 1 "NONE" + {ts = p;} +#line 1358 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr72; + case 9: goto st39; + case 10: goto tr74; + case 32: goto st39; + case 34: goto tr75; + case 37: goto st41; + case 39: goto tr77; + case 47: goto tr78; + case 95: goto tr80; + case 100: goto st47; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st45; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr71; +tr74: +#line 641 "rlscan.rl" { lastnl = p; column = 0; line++; } - goto st39; -st39: - if ( ++p == pe ) - goto _test_eof39; -case 39: -#line 1392 "rlscan.cpp" - switch( (*p) ) { - case 9: goto st39; - case 10: goto tr74; - case 32: goto st39; - } - goto tr82; -tr75: + goto st39; +st39: + if ( ++p == pe ) + goto _test_eof39; +case 39: +#line 1392 "rlscan.cpp" + switch( (*p) ) { + case 9: goto st39; + case 10: goto tr74; + case 32: goto st39; + } + goto tr82; +tr75: #line 1 "NONE" {te = p+1;} - goto st40; -st40: - if ( ++p == pe ) - goto _test_eof40; -case 40: -#line 1407 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr2; - case 34: goto tr3; - case 92: goto st2; - } - goto st1; -tr2: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st1; -st1: - if ( ++p == pe ) - goto _test_eof1; -case 1: -#line 1426 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr2; - case 34: goto tr3; - case 92: goto st2; - } - goto st1; -st2: - if ( ++p == pe ) - goto _test_eof2; -case 2: - if ( (*p) == 10 ) - goto tr2; - goto st1; -st41: - if ( ++p == pe ) - goto _test_eof41; -case 41: - if ( (*p) == 37 ) - goto st42; - goto tr83; -st42: - if ( ++p == pe ) - goto _test_eof42; -case 42: - if ( (*p) == 123 ) - goto tr86; - goto tr85; -tr77: -#line 1 "NONE" - {te = p+1;} - goto st43; -st43: - if ( ++p == pe ) - goto _test_eof43; -case 43: -#line 1462 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr6; - case 39: goto tr3; - case 92: goto st4; - } - goto st3; -tr6: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st3; -st3: - if ( ++p == pe ) - goto _test_eof3; -case 3: -#line 1481 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr6; - case 39: goto tr3; - case 92: goto st4; - } - goto st3; -st4: - if ( ++p == pe ) - goto _test_eof4; -case 4: - if ( (*p) == 10 ) - goto tr6; - goto st3; -tr78: -#line 1 "NONE" - {te = p+1;} - goto st44; -st44: - if ( ++p == pe ) - goto _test_eof44; -case 44: -#line 1503 "rlscan.cpp" - switch( (*p) ) { - case 42: goto st5; - case 47: goto st7; - } - goto tr83; -tr9: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st5; -st5: - if ( ++p == pe ) - goto _test_eof5; -case 5: -#line 1521 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr9; - case 42: goto st6; - } - goto st5; -st6: - if ( ++p == pe ) - goto _test_eof6; -case 6: - switch( (*p) ) { - case 10: goto tr9; - case 42: goto st6; - case 47: goto tr11; - } - goto st5; -st7: - if ( ++p == pe ) - goto _test_eof7; -case 7: - if ( (*p) == 10 ) - goto tr13; - goto st7; -st45: - if ( ++p == pe ) - goto _test_eof45; -case 45: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st45; - goto tr87; -tr80: -#line 1 "NONE" - {te = p+1;} -#line 1152 "rlscan.rl" - {act = 177;} - goto st46; -tr94: -#line 1 "NONE" - {te = p+1;} -#line 1151 "rlscan.rl" - {act = 176;} - goto st46; -st46: - if ( ++p == pe ) - goto _test_eof46; -case 46: -#line 1567 "rlscan.cpp" - if ( (*p) == 95 ) - goto tr80; - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr80; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr88; -st47: - if ( ++p == pe ) - goto _test_eof47; -case 47: - switch( (*p) ) { - case 95: goto tr80; - case 101: goto st48; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr80; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr89; -st48: - if ( ++p == pe ) - goto _test_eof48; -case 48: - switch( (*p) ) { - case 95: goto tr80; - case 102: goto st49; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr80; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr89; -st49: - if ( ++p == pe ) - goto _test_eof49; -case 49: - switch( (*p) ) { - case 95: goto tr80; - case 105: goto st50; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr80; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr89; -st50: - if ( ++p == pe ) - goto _test_eof50; -case 50: - switch( (*p) ) { - case 95: goto tr80; - case 110: goto st51; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr80; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr89; -st51: - if ( ++p == pe ) - goto _test_eof51; -case 51: - switch( (*p) ) { - case 95: goto tr80; - case 101: goto tr94; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr80; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr80; - } else - goto tr80; - goto tr89; -tr14: -#line 770 "rlscan.rl" - {{p = ((te))-1;}{ token( IL_Symbol, ts, te ); }} - goto st52; -tr17: -#line 716 "rlscan.rl" + goto st40; +st40: + if ( ++p == pe ) + goto _test_eof40; +case 40: +#line 1407 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr2; + case 34: goto tr3; + case 92: goto st2; + } + goto st1; +tr2: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st1; +st1: + if ( ++p == pe ) + goto _test_eof1; +case 1: +#line 1426 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr2; + case 34: goto tr3; + case 92: goto st2; + } + goto st1; +st2: + if ( ++p == pe ) + goto _test_eof2; +case 2: + if ( (*p) == 10 ) + goto tr2; + goto st1; +st41: + if ( ++p == pe ) + goto _test_eof41; +case 41: + if ( (*p) == 37 ) + goto st42; + goto tr83; +st42: + if ( ++p == pe ) + goto _test_eof42; +case 42: + if ( (*p) == 123 ) + goto tr86; + goto tr85; +tr77: +#line 1 "NONE" + {te = p+1;} + goto st43; +st43: + if ( ++p == pe ) + goto _test_eof43; +case 43: +#line 1462 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr6; + case 39: goto tr3; + case 92: goto st4; + } + goto st3; +tr6: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st3; +st3: + if ( ++p == pe ) + goto _test_eof3; +case 3: +#line 1481 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr6; + case 39: goto tr3; + case 92: goto st4; + } + goto st3; +st4: + if ( ++p == pe ) + goto _test_eof4; +case 4: + if ( (*p) == 10 ) + goto tr6; + goto st3; +tr78: +#line 1 "NONE" + {te = p+1;} + goto st44; +st44: + if ( ++p == pe ) + goto _test_eof44; +case 44: +#line 1503 "rlscan.cpp" + switch( (*p) ) { + case 42: goto st5; + case 47: goto st7; + } + goto tr83; +tr9: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st5; +st5: + if ( ++p == pe ) + goto _test_eof5; +case 5: +#line 1521 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr9; + case 42: goto st6; + } + goto st5; +st6: + if ( ++p == pe ) + goto _test_eof6; +case 6: + switch( (*p) ) { + case 10: goto tr9; + case 42: goto st6; + case 47: goto tr11; + } + goto st5; +st7: + if ( ++p == pe ) + goto _test_eof7; +case 7: + if ( (*p) == 10 ) + goto tr13; + goto st7; +st45: + if ( ++p == pe ) + goto _test_eof45; +case 45: + if ( 48 <= (*p) && (*p) <= 57 ) + goto st45; + goto tr87; +tr80: +#line 1 "NONE" + {te = p+1;} +#line 1152 "rlscan.rl" + {act = 177;} + goto st46; +tr94: +#line 1 "NONE" + {te = p+1;} +#line 1151 "rlscan.rl" + {act = 176;} + goto st46; +st46: + if ( ++p == pe ) + goto _test_eof46; +case 46: +#line 1567 "rlscan.cpp" + if ( (*p) == 95 ) + goto tr80; + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr80; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr88; +st47: + if ( ++p == pe ) + goto _test_eof47; +case 47: + switch( (*p) ) { + case 95: goto tr80; + case 101: goto st48; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr80; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr89; +st48: + if ( ++p == pe ) + goto _test_eof48; +case 48: + switch( (*p) ) { + case 95: goto tr80; + case 102: goto st49; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr80; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr89; +st49: + if ( ++p == pe ) + goto _test_eof49; +case 49: + switch( (*p) ) { + case 95: goto tr80; + case 105: goto st50; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr80; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr89; +st50: + if ( ++p == pe ) + goto _test_eof50; +case 50: + switch( (*p) ) { + case 95: goto tr80; + case 110: goto st51; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr80; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr89; +st51: + if ( ++p == pe ) + goto _test_eof51; +case 51: + switch( (*p) ) { + case 95: goto tr80; + case 101: goto tr94; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr80; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr80; + } else + goto tr80; + goto tr89; +tr14: +#line 770 "rlscan.rl" + {{p = ((te))-1;}{ token( IL_Symbol, ts, te ); }} + goto st52; +tr17: +#line 716 "rlscan.rl" {te = p+1;{ token( IL_Literal, ts, te ); }} - goto st52; -tr20: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } -#line 723 "rlscan.rl" - {te = p+1;{ token( IL_Comment, ts, te ); }} - goto st52; -tr27: -#line 712 "rlscan.rl" - {{p = ((te))-1;}{ token( TK_UInt, ts, te ); }} - goto st52; -tr95: -#line 770 "rlscan.rl" - {te = p+1;{ token( IL_Symbol, ts, te ); }} - goto st52; -tr96: -#line 765 "rlscan.rl" + goto st52; +tr20: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } +#line 723 "rlscan.rl" + {te = p+1;{ token( IL_Comment, ts, te ); }} + goto st52; +tr27: +#line 712 "rlscan.rl" + {{p = ((te))-1;}{ token( TK_UInt, ts, te ); }} + goto st52; +tr95: +#line 770 "rlscan.rl" + {te = p+1;{ token( IL_Symbol, ts, te ); }} + goto st52; +tr96: +#line 765 "rlscan.rl" {te = p+1;{ - scan_error() << "unterminated code block" << endl; - }} - goto st52; -tr102: -#line 745 "rlscan.rl" - {te = p+1;{ token( *ts, ts, te ); }} - goto st52; -tr103: -#line 740 "rlscan.rl" - {te = p+1;{ + scan_error() << "unterminated code block" << endl; + }} + goto st52; +tr102: +#line 745 "rlscan.rl" + {te = p+1;{ token( *ts, ts, te ); }} + goto st52; +tr103: +#line 740 "rlscan.rl" + {te = p+1;{ whitespaceOn = true; token( *ts, ts, te ); }} - goto st52; -tr108: -#line 733 "rlscan.rl" - {te = p+1;{ + goto st52; +tr108: +#line 733 "rlscan.rl" + {te = p+1;{ whitespaceOn = true; token( *ts, ts, te ); - if ( inlineBlockType == SemiTerminated ) - {cs = stack[--top];goto _again;} + if ( inlineBlockType == SemiTerminated ) + {cs = stack[--top];goto _again;} }} - goto st52; -tr111: -#line 747 "rlscan.rl" + goto st52; +tr111: +#line 747 "rlscan.rl" {te = p+1;{ token( IL_Symbol, ts, te ); curly_count += 1; }} - goto st52; -tr112: -#line 752 "rlscan.rl" + goto st52; +tr112: +#line 752 "rlscan.rl" {te = p+1;{ if ( --curly_count == 0 && inlineBlockType == CurlyDelimited ) { /* Inline code block ends. */ @@ -1735,31 +1735,31 @@ tr112: token( IL_Symbol, ts, te ); } }} - goto st52; -tr113: -#line 718 "rlscan.rl" + goto st52; +tr113: +#line 718 "rlscan.rl" {te = p;p--;{ if ( whitespaceOn ) token( IL_WhiteSpace, ts, te ); }} - goto st52; -tr114: -#line 770 "rlscan.rl" + goto st52; +tr114: +#line 770 "rlscan.rl" {te = p;p--;{ token( IL_Symbol, ts, te ); }} - goto st52; -tr115: -#line 712 "rlscan.rl" - {te = p;p--;{ token( TK_UInt, ts, te ); }} - goto st52; -tr117: -#line 713 "rlscan.rl" - {te = p;p--;{ token( TK_Hex, ts, te ); }} - goto st52; -tr118: -#line 725 "rlscan.rl" - {te = p+1;{ token( TK_NameSep, ts, te ); }} - goto st52; -tr119: + goto st52; +tr115: +#line 712 "rlscan.rl" + {te = p;p--;{ token( TK_UInt, ts, te ); }} + goto st52; +tr117: +#line 713 "rlscan.rl" + {te = p;p--;{ token( TK_Hex, ts, te ); }} + goto st52; +tr118: +#line 725 "rlscan.rl" + {te = p+1;{ token( TK_NameSep, ts, te ); }} + goto st52; +tr119: #line 1 "NONE" { switch( act ) { case 1: @@ -1821,977 +1821,977 @@ tr119: break; } } - goto st52; -tr120: -#line 710 "rlscan.rl" - {te = p;p--;{ token( TK_Word, ts, te ); }} - goto st52; -tr134: -#line 675 "rlscan.rl" - {te = p;p--;{ token( KW_Char ); }} - goto st52; -st52: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof52; -case 52: -#line 1 "NONE" - {ts = p;} -#line 1840 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr96; - case 9: goto st53; - case 10: goto tr98; - case 32: goto st53; - case 34: goto tr99; - case 35: goto tr100; - case 39: goto tr101; - case 40: goto tr102; - case 44: goto tr102; - case 47: goto tr104; - case 48: goto tr105; - case 58: goto st61; - case 59: goto tr108; - case 95: goto tr109; - case 102: goto st63; - case 123: goto tr111; - case 125: goto tr112; - } - if ( (*p) < 49 ) { - if ( 41 <= (*p) && (*p) <= 42 ) - goto tr103; - } else if ( (*p) > 57 ) { - if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else if ( (*p) >= 65 ) - goto tr109; - } else - goto st59; - goto tr95; -tr98: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st53; -st53: - if ( ++p == pe ) - goto _test_eof53; -case 53: -#line 1884 "rlscan.cpp" - switch( (*p) ) { - case 9: goto st53; - case 10: goto tr98; - case 32: goto st53; - } - goto tr113; -tr99: -#line 1 "NONE" - {te = p+1;} - goto st54; -st54: - if ( ++p == pe ) - goto _test_eof54; -case 54: -#line 1899 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr16; - case 34: goto tr17; - case 92: goto st9; - } - goto st8; -tr16: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st8; -st8: - if ( ++p == pe ) - goto _test_eof8; -case 8: -#line 1918 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr16; - case 34: goto tr17; - case 92: goto st9; - } - goto st8; -st9: - if ( ++p == pe ) - goto _test_eof9; -case 9: - if ( (*p) == 10 ) - goto tr16; - goto st8; -tr100: -#line 1 "NONE" - {te = p+1;} - goto st55; -st55: - if ( ++p == pe ) - goto _test_eof55; -case 55: -#line 1940 "rlscan.cpp" - if ( (*p) == 10 ) - goto tr20; - goto st10; -st10: - if ( ++p == pe ) - goto _test_eof10; -case 10: - if ( (*p) == 10 ) - goto tr20; - goto st10; -tr101: -#line 1 "NONE" - {te = p+1;} - goto st56; -st56: - if ( ++p == pe ) - goto _test_eof56; -case 56: -#line 1959 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr22; - case 39: goto tr17; - case 92: goto st12; - } - goto st11; -tr22: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st11; -st11: - if ( ++p == pe ) - goto _test_eof11; -case 11: -#line 1978 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr22; - case 39: goto tr17; - case 92: goto st12; - } - goto st11; -st12: - if ( ++p == pe ) - goto _test_eof12; -case 12: - if ( (*p) == 10 ) - goto tr22; - goto st11; -tr104: -#line 1 "NONE" - {te = p+1;} - goto st57; -st57: - if ( ++p == pe ) - goto _test_eof57; -case 57: -#line 2000 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr25; - case 47: goto tr17; - case 92: goto st14; - } - goto st13; -tr25: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st13; -st13: - if ( ++p == pe ) - goto _test_eof13; -case 13: -#line 2019 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr25; - case 47: goto tr17; - case 92: goto st14; - } - goto st13; -st14: - if ( ++p == pe ) - goto _test_eof14; -case 14: - if ( (*p) == 10 ) - goto tr25; - goto st13; -tr105: -#line 1 "NONE" - {te = p+1;} - goto st58; -st58: - if ( ++p == pe ) - goto _test_eof58; -case 58: -#line 2041 "rlscan.cpp" - if ( (*p) == 120 ) - goto st15; - if ( 48 <= (*p) && (*p) <= 57 ) - goto st59; - goto tr115; -st59: - if ( ++p == pe ) - goto _test_eof59; -case 59: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st59; - goto tr115; -st15: - if ( ++p == pe ) - goto _test_eof15; -case 15: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st60; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto st60; - } else - goto st60; - goto tr27; -st60: - if ( ++p == pe ) - goto _test_eof60; -case 60: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st60; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto st60; - } else - goto st60; - goto tr117; -st61: - if ( ++p == pe ) - goto _test_eof61; -case 61: - if ( (*p) == 58 ) - goto tr118; - goto tr114; -tr109: -#line 1 "NONE" - {te = p+1;} -#line 710 "rlscan.rl" - {act = 13;} - goto st62; -tr133: -#line 1 "NONE" - {te = p+1;} -#line 705 "rlscan.rl" - {act = 12;} - goto st62; -tr138: -#line 1 "NONE" - {te = p+1;} -#line 697 "rlscan.rl" - {act = 10;} - goto st62; -tr140: -#line 1 "NONE" - {te = p+1;} -#line 676 "rlscan.rl" - {act = 3;} - goto st62; -tr145: -#line 1 "NONE" - {te = p+1;} -#line 678 "rlscan.rl" - {act = 5;} - goto st62; -tr147: -#line 1 "NONE" - {te = p+1;} -#line 688 "rlscan.rl" - {act = 7;} - goto st62; -tr150: -#line 1 "NONE" - {te = p+1;} -#line 689 "rlscan.rl" - {act = 8;} - goto st62; -tr153: -#line 1 "NONE" - {te = p+1;} -#line 684 "rlscan.rl" - {act = 6;} - goto st62; -tr156: -#line 1 "NONE" - {te = p+1;} -#line 693 "rlscan.rl" - {act = 9;} - goto st62; -tr157: -#line 1 "NONE" - {te = p+1;} -#line 674 "rlscan.rl" - {act = 1;} - goto st62; -tr159: -#line 1 "NONE" - {te = p+1;} -#line 701 "rlscan.rl" - {act = 11;} - goto st62; -tr163: -#line 1 "NONE" - {te = p+1;} -#line 677 "rlscan.rl" - {act = 4;} - goto st62; -st62: - if ( ++p == pe ) - goto _test_eof62; -case 62: -#line 2163 "rlscan.cpp" - if ( (*p) == 95 ) - goto tr109; - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr119; -st63: - if ( ++p == pe ) - goto _test_eof63; -case 63: - switch( (*p) ) { - case 95: goto tr109; - case 98: goto st64; - case 99: goto st68; - case 101: goto st73; - case 103: goto st79; - case 104: goto st82; - case 110: goto st85; - case 112: goto st88; - case 114: goto st89; - case 116: goto st91; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st64: - if ( ++p == pe ) - goto _test_eof64; -case 64: - switch( (*p) ) { - case 95: goto tr109; - case 114: goto st65; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st65: - if ( ++p == pe ) - goto _test_eof65; -case 65: - switch( (*p) ) { - case 95: goto tr109; - case 101: goto st66; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st66: - if ( ++p == pe ) - goto _test_eof66; -case 66: - switch( (*p) ) { - case 95: goto tr109; - case 97: goto st67; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st67: - if ( ++p == pe ) - goto _test_eof67; -case 67: - switch( (*p) ) { - case 95: goto tr109; - case 107: goto tr133; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st68: - if ( ++p == pe ) - goto _test_eof68; -case 68: - switch( (*p) ) { - case 95: goto tr109; - case 97: goto st69; - case 117: goto st71; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr134; -st69: - if ( ++p == pe ) - goto _test_eof69; -case 69: - switch( (*p) ) { - case 95: goto tr109; - case 108: goto st70; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st70: - if ( ++p == pe ) - goto _test_eof70; -case 70: - switch( (*p) ) { - case 95: goto tr109; - case 108: goto tr138; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st71: - if ( ++p == pe ) - goto _test_eof71; -case 71: - switch( (*p) ) { - case 95: goto tr109; - case 114: goto st72; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st72: - if ( ++p == pe ) - goto _test_eof72; -case 72: - switch( (*p) ) { - case 95: goto tr109; - case 115: goto tr140; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st73: - if ( ++p == pe ) - goto _test_eof73; -case 73: - switch( (*p) ) { - case 95: goto tr109; - case 110: goto st74; - case 120: goto st77; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st74: - if ( ++p == pe ) - goto _test_eof74; -case 74: - switch( (*p) ) { - case 95: goto tr109; - case 116: goto st75; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st75: - if ( ++p == pe ) - goto _test_eof75; -case 75: - switch( (*p) ) { - case 95: goto tr109; - case 114: goto st76; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st76: - if ( ++p == pe ) - goto _test_eof76; -case 76: - switch( (*p) ) { - case 95: goto tr109; - case 121: goto tr145; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st77: - if ( ++p == pe ) - goto _test_eof77; -case 77: - switch( (*p) ) { - case 95: goto tr109; - case 101: goto st78; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st78: - if ( ++p == pe ) - goto _test_eof78; -case 78: - switch( (*p) ) { - case 95: goto tr109; - case 99: goto tr147; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st79: - if ( ++p == pe ) - goto _test_eof79; -case 79: - switch( (*p) ) { - case 95: goto tr109; - case 111: goto st80; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st80: - if ( ++p == pe ) - goto _test_eof80; -case 80: - switch( (*p) ) { - case 95: goto tr109; - case 116: goto st81; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st81: - if ( ++p == pe ) - goto _test_eof81; -case 81: - switch( (*p) ) { - case 95: goto tr109; - case 111: goto tr150; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st82: - if ( ++p == pe ) - goto _test_eof82; -case 82: - switch( (*p) ) { - case 95: goto tr109; - case 111: goto st83; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st83: - if ( ++p == pe ) - goto _test_eof83; -case 83: - switch( (*p) ) { - case 95: goto tr109; - case 108: goto st84; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st84: - if ( ++p == pe ) - goto _test_eof84; -case 84: - switch( (*p) ) { - case 95: goto tr109; - case 100: goto tr153; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st85: - if ( ++p == pe ) - goto _test_eof85; -case 85: - switch( (*p) ) { - case 95: goto tr109; - case 101: goto st86; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st86: - if ( ++p == pe ) - goto _test_eof86; -case 86: - switch( (*p) ) { - case 95: goto tr109; - case 120: goto st87; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st87: - if ( ++p == pe ) - goto _test_eof87; -case 87: - switch( (*p) ) { - case 95: goto tr109; - case 116: goto tr156; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st88: - if ( ++p == pe ) - goto _test_eof88; -case 88: - switch( (*p) ) { - case 95: goto tr109; - case 99: goto tr157; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st89: - if ( ++p == pe ) - goto _test_eof89; -case 89: - switch( (*p) ) { - case 95: goto tr109; - case 101: goto st90; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st90: - if ( ++p == pe ) - goto _test_eof90; -case 90: - switch( (*p) ) { - case 95: goto tr109; - case 116: goto tr159; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st91: - if ( ++p == pe ) - goto _test_eof91; -case 91: - switch( (*p) ) { - case 95: goto tr109; - case 97: goto st92; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st92: - if ( ++p == pe ) - goto _test_eof92; -case 92: - switch( (*p) ) { - case 95: goto tr109; - case 114: goto st93; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st93: - if ( ++p == pe ) - goto _test_eof93; -case 93: - switch( (*p) ) { - case 95: goto tr109; - case 103: goto st94; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -st94: - if ( ++p == pe ) - goto _test_eof94; -case 94: - switch( (*p) ) { - case 95: goto tr109; - case 115: goto tr163; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr109; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr109; - } else - goto tr109; - goto tr120; -tr29: -#line 873 "rlscan.rl" - {{p = ((te))-1;}{ token( IL_Symbol, ts, te ); }} - goto st95; -tr32: -#line 819 "rlscan.rl" + goto st52; +tr120: +#line 710 "rlscan.rl" + {te = p;p--;{ token( TK_Word, ts, te ); }} + goto st52; +tr134: +#line 675 "rlscan.rl" + {te = p;p--;{ token( KW_Char ); }} + goto st52; +st52: +#line 1 "NONE" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof52; +case 52: +#line 1 "NONE" + {ts = p;} +#line 1840 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr96; + case 9: goto st53; + case 10: goto tr98; + case 32: goto st53; + case 34: goto tr99; + case 35: goto tr100; + case 39: goto tr101; + case 40: goto tr102; + case 44: goto tr102; + case 47: goto tr104; + case 48: goto tr105; + case 58: goto st61; + case 59: goto tr108; + case 95: goto tr109; + case 102: goto st63; + case 123: goto tr111; + case 125: goto tr112; + } + if ( (*p) < 49 ) { + if ( 41 <= (*p) && (*p) <= 42 ) + goto tr103; + } else if ( (*p) > 57 ) { + if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else if ( (*p) >= 65 ) + goto tr109; + } else + goto st59; + goto tr95; +tr98: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st53; +st53: + if ( ++p == pe ) + goto _test_eof53; +case 53: +#line 1884 "rlscan.cpp" + switch( (*p) ) { + case 9: goto st53; + case 10: goto tr98; + case 32: goto st53; + } + goto tr113; +tr99: +#line 1 "NONE" + {te = p+1;} + goto st54; +st54: + if ( ++p == pe ) + goto _test_eof54; +case 54: +#line 1899 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr16; + case 34: goto tr17; + case 92: goto st9; + } + goto st8; +tr16: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st8; +st8: + if ( ++p == pe ) + goto _test_eof8; +case 8: +#line 1918 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr16; + case 34: goto tr17; + case 92: goto st9; + } + goto st8; +st9: + if ( ++p == pe ) + goto _test_eof9; +case 9: + if ( (*p) == 10 ) + goto tr16; + goto st8; +tr100: +#line 1 "NONE" + {te = p+1;} + goto st55; +st55: + if ( ++p == pe ) + goto _test_eof55; +case 55: +#line 1940 "rlscan.cpp" + if ( (*p) == 10 ) + goto tr20; + goto st10; +st10: + if ( ++p == pe ) + goto _test_eof10; +case 10: + if ( (*p) == 10 ) + goto tr20; + goto st10; +tr101: +#line 1 "NONE" + {te = p+1;} + goto st56; +st56: + if ( ++p == pe ) + goto _test_eof56; +case 56: +#line 1959 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr22; + case 39: goto tr17; + case 92: goto st12; + } + goto st11; +tr22: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st11; +st11: + if ( ++p == pe ) + goto _test_eof11; +case 11: +#line 1978 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr22; + case 39: goto tr17; + case 92: goto st12; + } + goto st11; +st12: + if ( ++p == pe ) + goto _test_eof12; +case 12: + if ( (*p) == 10 ) + goto tr22; + goto st11; +tr104: +#line 1 "NONE" + {te = p+1;} + goto st57; +st57: + if ( ++p == pe ) + goto _test_eof57; +case 57: +#line 2000 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr25; + case 47: goto tr17; + case 92: goto st14; + } + goto st13; +tr25: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st13; +st13: + if ( ++p == pe ) + goto _test_eof13; +case 13: +#line 2019 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr25; + case 47: goto tr17; + case 92: goto st14; + } + goto st13; +st14: + if ( ++p == pe ) + goto _test_eof14; +case 14: + if ( (*p) == 10 ) + goto tr25; + goto st13; +tr105: +#line 1 "NONE" + {te = p+1;} + goto st58; +st58: + if ( ++p == pe ) + goto _test_eof58; +case 58: +#line 2041 "rlscan.cpp" + if ( (*p) == 120 ) + goto st15; + if ( 48 <= (*p) && (*p) <= 57 ) + goto st59; + goto tr115; +st59: + if ( ++p == pe ) + goto _test_eof59; +case 59: + if ( 48 <= (*p) && (*p) <= 57 ) + goto st59; + goto tr115; +st15: + if ( ++p == pe ) + goto _test_eof15; +case 15: + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st60; + } else if ( (*p) > 70 ) { + if ( 97 <= (*p) && (*p) <= 102 ) + goto st60; + } else + goto st60; + goto tr27; +st60: + if ( ++p == pe ) + goto _test_eof60; +case 60: + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st60; + } else if ( (*p) > 70 ) { + if ( 97 <= (*p) && (*p) <= 102 ) + goto st60; + } else + goto st60; + goto tr117; +st61: + if ( ++p == pe ) + goto _test_eof61; +case 61: + if ( (*p) == 58 ) + goto tr118; + goto tr114; +tr109: +#line 1 "NONE" + {te = p+1;} +#line 710 "rlscan.rl" + {act = 13;} + goto st62; +tr133: +#line 1 "NONE" + {te = p+1;} +#line 705 "rlscan.rl" + {act = 12;} + goto st62; +tr138: +#line 1 "NONE" + {te = p+1;} +#line 697 "rlscan.rl" + {act = 10;} + goto st62; +tr140: +#line 1 "NONE" + {te = p+1;} +#line 676 "rlscan.rl" + {act = 3;} + goto st62; +tr145: +#line 1 "NONE" + {te = p+1;} +#line 678 "rlscan.rl" + {act = 5;} + goto st62; +tr147: +#line 1 "NONE" + {te = p+1;} +#line 688 "rlscan.rl" + {act = 7;} + goto st62; +tr150: +#line 1 "NONE" + {te = p+1;} +#line 689 "rlscan.rl" + {act = 8;} + goto st62; +tr153: +#line 1 "NONE" + {te = p+1;} +#line 684 "rlscan.rl" + {act = 6;} + goto st62; +tr156: +#line 1 "NONE" + {te = p+1;} +#line 693 "rlscan.rl" + {act = 9;} + goto st62; +tr157: +#line 1 "NONE" + {te = p+1;} +#line 674 "rlscan.rl" + {act = 1;} + goto st62; +tr159: +#line 1 "NONE" + {te = p+1;} +#line 701 "rlscan.rl" + {act = 11;} + goto st62; +tr163: +#line 1 "NONE" + {te = p+1;} +#line 677 "rlscan.rl" + {act = 4;} + goto st62; +st62: + if ( ++p == pe ) + goto _test_eof62; +case 62: +#line 2163 "rlscan.cpp" + if ( (*p) == 95 ) + goto tr109; + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr119; +st63: + if ( ++p == pe ) + goto _test_eof63; +case 63: + switch( (*p) ) { + case 95: goto tr109; + case 98: goto st64; + case 99: goto st68; + case 101: goto st73; + case 103: goto st79; + case 104: goto st82; + case 110: goto st85; + case 112: goto st88; + case 114: goto st89; + case 116: goto st91; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st64: + if ( ++p == pe ) + goto _test_eof64; +case 64: + switch( (*p) ) { + case 95: goto tr109; + case 114: goto st65; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st65: + if ( ++p == pe ) + goto _test_eof65; +case 65: + switch( (*p) ) { + case 95: goto tr109; + case 101: goto st66; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st66: + if ( ++p == pe ) + goto _test_eof66; +case 66: + switch( (*p) ) { + case 95: goto tr109; + case 97: goto st67; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st67: + if ( ++p == pe ) + goto _test_eof67; +case 67: + switch( (*p) ) { + case 95: goto tr109; + case 107: goto tr133; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st68: + if ( ++p == pe ) + goto _test_eof68; +case 68: + switch( (*p) ) { + case 95: goto tr109; + case 97: goto st69; + case 117: goto st71; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr134; +st69: + if ( ++p == pe ) + goto _test_eof69; +case 69: + switch( (*p) ) { + case 95: goto tr109; + case 108: goto st70; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st70: + if ( ++p == pe ) + goto _test_eof70; +case 70: + switch( (*p) ) { + case 95: goto tr109; + case 108: goto tr138; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st71: + if ( ++p == pe ) + goto _test_eof71; +case 71: + switch( (*p) ) { + case 95: goto tr109; + case 114: goto st72; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st72: + if ( ++p == pe ) + goto _test_eof72; +case 72: + switch( (*p) ) { + case 95: goto tr109; + case 115: goto tr140; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st73: + if ( ++p == pe ) + goto _test_eof73; +case 73: + switch( (*p) ) { + case 95: goto tr109; + case 110: goto st74; + case 120: goto st77; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st74: + if ( ++p == pe ) + goto _test_eof74; +case 74: + switch( (*p) ) { + case 95: goto tr109; + case 116: goto st75; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st75: + if ( ++p == pe ) + goto _test_eof75; +case 75: + switch( (*p) ) { + case 95: goto tr109; + case 114: goto st76; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st76: + if ( ++p == pe ) + goto _test_eof76; +case 76: + switch( (*p) ) { + case 95: goto tr109; + case 121: goto tr145; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st77: + if ( ++p == pe ) + goto _test_eof77; +case 77: + switch( (*p) ) { + case 95: goto tr109; + case 101: goto st78; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st78: + if ( ++p == pe ) + goto _test_eof78; +case 78: + switch( (*p) ) { + case 95: goto tr109; + case 99: goto tr147; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st79: + if ( ++p == pe ) + goto _test_eof79; +case 79: + switch( (*p) ) { + case 95: goto tr109; + case 111: goto st80; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st80: + if ( ++p == pe ) + goto _test_eof80; +case 80: + switch( (*p) ) { + case 95: goto tr109; + case 116: goto st81; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st81: + if ( ++p == pe ) + goto _test_eof81; +case 81: + switch( (*p) ) { + case 95: goto tr109; + case 111: goto tr150; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st82: + if ( ++p == pe ) + goto _test_eof82; +case 82: + switch( (*p) ) { + case 95: goto tr109; + case 111: goto st83; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st83: + if ( ++p == pe ) + goto _test_eof83; +case 83: + switch( (*p) ) { + case 95: goto tr109; + case 108: goto st84; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st84: + if ( ++p == pe ) + goto _test_eof84; +case 84: + switch( (*p) ) { + case 95: goto tr109; + case 100: goto tr153; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st85: + if ( ++p == pe ) + goto _test_eof85; +case 85: + switch( (*p) ) { + case 95: goto tr109; + case 101: goto st86; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st86: + if ( ++p == pe ) + goto _test_eof86; +case 86: + switch( (*p) ) { + case 95: goto tr109; + case 120: goto st87; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st87: + if ( ++p == pe ) + goto _test_eof87; +case 87: + switch( (*p) ) { + case 95: goto tr109; + case 116: goto tr156; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st88: + if ( ++p == pe ) + goto _test_eof88; +case 88: + switch( (*p) ) { + case 95: goto tr109; + case 99: goto tr157; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st89: + if ( ++p == pe ) + goto _test_eof89; +case 89: + switch( (*p) ) { + case 95: goto tr109; + case 101: goto st90; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st90: + if ( ++p == pe ) + goto _test_eof90; +case 90: + switch( (*p) ) { + case 95: goto tr109; + case 116: goto tr159; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st91: + if ( ++p == pe ) + goto _test_eof91; +case 91: + switch( (*p) ) { + case 95: goto tr109; + case 97: goto st92; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st92: + if ( ++p == pe ) + goto _test_eof92; +case 92: + switch( (*p) ) { + case 95: goto tr109; + case 114: goto st93; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st93: + if ( ++p == pe ) + goto _test_eof93; +case 93: + switch( (*p) ) { + case 95: goto tr109; + case 103: goto st94; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +st94: + if ( ++p == pe ) + goto _test_eof94; +case 94: + switch( (*p) ) { + case 95: goto tr109; + case 115: goto tr163; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr109; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr109; + } else + goto tr109; + goto tr120; +tr29: +#line 873 "rlscan.rl" + {{p = ((te))-1;}{ token( IL_Symbol, ts, te ); }} + goto st95; +tr32: +#line 819 "rlscan.rl" {te = p+1;{ token( IL_Literal, ts, te ); }} - goto st95; -tr40: -#line 826 "rlscan.rl" + goto st95; +tr40: +#line 826 "rlscan.rl" {te = p+1;{ token( IL_Comment, ts, te ); }} - goto st95; -tr42: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } -#line 826 "rlscan.rl" - {te = p+1;{ token( IL_Comment, ts, te ); }} - goto st95; -tr43: -#line 815 "rlscan.rl" - {{p = ((te))-1;}{ token( TK_UInt, ts, te ); }} - goto st95; -tr164: -#line 873 "rlscan.rl" - {te = p+1;{ token( IL_Symbol, ts, te ); }} - goto st95; -tr165: -#line 868 "rlscan.rl" + goto st95; +tr42: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } +#line 826 "rlscan.rl" + {te = p+1;{ token( IL_Comment, ts, te ); }} + goto st95; +tr43: +#line 815 "rlscan.rl" + {{p = ((te))-1;}{ token( TK_UInt, ts, te ); }} + goto st95; +tr164: +#line 873 "rlscan.rl" + {te = p+1;{ token( IL_Symbol, ts, te ); }} + goto st95; +tr165: +#line 868 "rlscan.rl" {te = p+1;{ - scan_error() << "unterminated code block" << endl; - }} - goto st95; -tr170: -#line 848 "rlscan.rl" - {te = p+1;{ token( *ts, ts, te ); }} - goto st95; -tr171: -#line 843 "rlscan.rl" - {te = p+1;{ + scan_error() << "unterminated code block" << endl; + }} + goto st95; +tr170: +#line 848 "rlscan.rl" + {te = p+1;{ token( *ts, ts, te ); }} + goto st95; +tr171: +#line 843 "rlscan.rl" + {te = p+1;{ whitespaceOn = true; token( *ts, ts, te ); }} - goto st95; -tr176: -#line 836 "rlscan.rl" - {te = p+1;{ + goto st95; +tr176: +#line 836 "rlscan.rl" + {te = p+1;{ whitespaceOn = true; token( *ts, ts, te ); - if ( inlineBlockType == SemiTerminated ) - {cs = stack[--top];goto _again;} + if ( inlineBlockType == SemiTerminated ) + {cs = stack[--top];goto _again;} }} - goto st95; -tr179: -#line 850 "rlscan.rl" + goto st95; +tr179: +#line 850 "rlscan.rl" {te = p+1;{ token( IL_Symbol, ts, te ); curly_count += 1; }} - goto st95; -tr180: -#line 855 "rlscan.rl" + goto st95; +tr180: +#line 855 "rlscan.rl" {te = p+1;{ if ( --curly_count == 0 && inlineBlockType == CurlyDelimited ) { /* Inline code block ends. */ @@ -2804,31 +2804,31 @@ tr180: token( IL_Symbol, ts, te ); } }} - goto st95; -tr181: -#line 821 "rlscan.rl" + goto st95; +tr181: +#line 821 "rlscan.rl" {te = p;p--;{ if ( whitespaceOn ) token( IL_WhiteSpace, ts, te ); }} - goto st95; -tr182: -#line 873 "rlscan.rl" + goto st95; +tr182: +#line 873 "rlscan.rl" {te = p;p--;{ token( IL_Symbol, ts, te ); }} - goto st95; -tr183: -#line 815 "rlscan.rl" - {te = p;p--;{ token( TK_UInt, ts, te ); }} - goto st95; -tr185: -#line 816 "rlscan.rl" - {te = p;p--;{ token( TK_Hex, ts, te ); }} - goto st95; -tr186: -#line 828 "rlscan.rl" - {te = p+1;{ token( TK_NameSep, ts, te ); }} - goto st95; -tr187: + goto st95; +tr183: +#line 815 "rlscan.rl" + {te = p;p--;{ token( TK_UInt, ts, te ); }} + goto st95; +tr185: +#line 816 "rlscan.rl" + {te = p;p--;{ token( TK_Hex, ts, te ); }} + goto st95; +tr186: +#line 828 "rlscan.rl" + {te = p+1;{ token( TK_NameSep, ts, te ); }} + goto st95; +tr187: #line 1 "NONE" { switch( act ) { case 27: @@ -2890,1253 +2890,1253 @@ tr187: break; } } - goto st95; -tr188: -#line 813 "rlscan.rl" - {te = p;p--;{ token( TK_Word, ts, te ); }} - goto st95; -tr202: -#line 778 "rlscan.rl" - {te = p;p--;{ token( KW_Char ); }} - goto st95; -st95: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof95; -case 95: -#line 1 "NONE" - {ts = p;} -#line 2909 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr165; - case 9: goto st96; - case 10: goto tr167; - case 32: goto st96; - case 34: goto tr168; - case 39: goto tr169; - case 40: goto tr170; - case 44: goto tr170; - case 47: goto tr172; - case 48: goto tr173; - case 58: goto st103; - case 59: goto tr176; - case 95: goto tr177; - case 102: goto st105; - case 123: goto tr179; - case 125: goto tr180; - } - if ( (*p) < 49 ) { - if ( 41 <= (*p) && (*p) <= 42 ) - goto tr171; - } else if ( (*p) > 57 ) { - if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else if ( (*p) >= 65 ) - goto tr177; - } else - goto st101; - goto tr164; -tr167: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st96; -st96: - if ( ++p == pe ) - goto _test_eof96; -case 96: -#line 2952 "rlscan.cpp" - switch( (*p) ) { - case 9: goto st96; - case 10: goto tr167; - case 32: goto st96; - } - goto tr181; -tr168: -#line 1 "NONE" - {te = p+1;} - goto st97; -st97: - if ( ++p == pe ) - goto _test_eof97; -case 97: -#line 2967 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr31; - case 34: goto tr32; - case 92: goto st17; - } - goto st16; -tr31: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st16; -st16: - if ( ++p == pe ) - goto _test_eof16; -case 16: -#line 2986 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr31; - case 34: goto tr32; - case 92: goto st17; - } - goto st16; -st17: - if ( ++p == pe ) - goto _test_eof17; -case 17: - if ( (*p) == 10 ) - goto tr31; - goto st16; -tr169: -#line 1 "NONE" - {te = p+1;} - goto st98; -st98: - if ( ++p == pe ) - goto _test_eof98; -case 98: -#line 3008 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr35; - case 39: goto tr32; - case 92: goto st19; - } - goto st18; -tr35: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st18; -st18: - if ( ++p == pe ) - goto _test_eof18; -case 18: -#line 3027 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr35; - case 39: goto tr32; - case 92: goto st19; - } - goto st18; -st19: - if ( ++p == pe ) - goto _test_eof19; -case 19: - if ( (*p) == 10 ) - goto tr35; - goto st18; -tr172: -#line 1 "NONE" - {te = p+1;} - goto st99; -st99: - if ( ++p == pe ) - goto _test_eof99; -case 99: -#line 3049 "rlscan.cpp" - switch( (*p) ) { - case 42: goto st20; - case 47: goto st22; - } - goto tr182; -tr38: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st20; -st20: - if ( ++p == pe ) - goto _test_eof20; -case 20: -#line 3067 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr38; - case 42: goto st21; - } - goto st20; -st21: - if ( ++p == pe ) - goto _test_eof21; -case 21: - switch( (*p) ) { - case 10: goto tr38; - case 42: goto st21; - case 47: goto tr40; - } - goto st20; -st22: - if ( ++p == pe ) - goto _test_eof22; -case 22: - if ( (*p) == 10 ) - goto tr42; - goto st22; -tr173: -#line 1 "NONE" - {te = p+1;} - goto st100; -st100: - if ( ++p == pe ) - goto _test_eof100; -case 100: -#line 3098 "rlscan.cpp" - if ( (*p) == 120 ) - goto st23; - if ( 48 <= (*p) && (*p) <= 57 ) - goto st101; - goto tr183; -st101: - if ( ++p == pe ) - goto _test_eof101; -case 101: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st101; - goto tr183; -st23: - if ( ++p == pe ) - goto _test_eof23; -case 23: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st102; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto st102; - } else - goto st102; - goto tr43; -st102: - if ( ++p == pe ) - goto _test_eof102; -case 102: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st102; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto st102; - } else - goto st102; - goto tr185; -st103: - if ( ++p == pe ) - goto _test_eof103; -case 103: - if ( (*p) == 58 ) - goto tr186; - goto tr182; -tr177: -#line 1 "NONE" - {te = p+1;} -#line 813 "rlscan.rl" - {act = 39;} - goto st104; -tr201: -#line 1 "NONE" - {te = p+1;} -#line 808 "rlscan.rl" - {act = 38;} - goto st104; -tr206: -#line 1 "NONE" - {te = p+1;} -#line 800 "rlscan.rl" - {act = 36;} - goto st104; -tr208: -#line 1 "NONE" - {te = p+1;} -#line 779 "rlscan.rl" - {act = 29;} - goto st104; -tr213: -#line 1 "NONE" - {te = p+1;} -#line 781 "rlscan.rl" - {act = 31;} - goto st104; -tr215: -#line 1 "NONE" - {te = p+1;} -#line 791 "rlscan.rl" - {act = 33;} - goto st104; -tr218: -#line 1 "NONE" - {te = p+1;} -#line 792 "rlscan.rl" - {act = 34;} - goto st104; -tr221: -#line 1 "NONE" - {te = p+1;} -#line 787 "rlscan.rl" - {act = 32;} - goto st104; -tr224: -#line 1 "NONE" - {te = p+1;} -#line 796 "rlscan.rl" - {act = 35;} - goto st104; -tr225: -#line 1 "NONE" - {te = p+1;} -#line 777 "rlscan.rl" - {act = 27;} - goto st104; -tr227: -#line 1 "NONE" - {te = p+1;} -#line 804 "rlscan.rl" - {act = 37;} - goto st104; -tr231: -#line 1 "NONE" - {te = p+1;} -#line 780 "rlscan.rl" - {act = 30;} - goto st104; -st104: - if ( ++p == pe ) - goto _test_eof104; -case 104: -#line 3220 "rlscan.cpp" - if ( (*p) == 95 ) - goto tr177; - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr187; -st105: - if ( ++p == pe ) - goto _test_eof105; -case 105: - switch( (*p) ) { - case 95: goto tr177; - case 98: goto st106; - case 99: goto st110; - case 101: goto st115; - case 103: goto st121; - case 104: goto st124; - case 110: goto st127; - case 112: goto st130; - case 114: goto st131; - case 116: goto st133; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st106: - if ( ++p == pe ) - goto _test_eof106; -case 106: - switch( (*p) ) { - case 95: goto tr177; - case 114: goto st107; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st107: - if ( ++p == pe ) - goto _test_eof107; -case 107: - switch( (*p) ) { - case 95: goto tr177; - case 101: goto st108; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st108: - if ( ++p == pe ) - goto _test_eof108; -case 108: - switch( (*p) ) { - case 95: goto tr177; - case 97: goto st109; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st109: - if ( ++p == pe ) - goto _test_eof109; -case 109: - switch( (*p) ) { - case 95: goto tr177; - case 107: goto tr201; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st110: - if ( ++p == pe ) - goto _test_eof110; -case 110: - switch( (*p) ) { - case 95: goto tr177; - case 97: goto st111; - case 117: goto st113; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr202; -st111: - if ( ++p == pe ) - goto _test_eof111; -case 111: - switch( (*p) ) { - case 95: goto tr177; - case 108: goto st112; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st112: - if ( ++p == pe ) - goto _test_eof112; -case 112: - switch( (*p) ) { - case 95: goto tr177; - case 108: goto tr206; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st113: - if ( ++p == pe ) - goto _test_eof113; -case 113: - switch( (*p) ) { - case 95: goto tr177; - case 114: goto st114; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st114: - if ( ++p == pe ) - goto _test_eof114; -case 114: - switch( (*p) ) { - case 95: goto tr177; - case 115: goto tr208; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st115: - if ( ++p == pe ) - goto _test_eof115; -case 115: - switch( (*p) ) { - case 95: goto tr177; - case 110: goto st116; - case 120: goto st119; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st116: - if ( ++p == pe ) - goto _test_eof116; -case 116: - switch( (*p) ) { - case 95: goto tr177; - case 116: goto st117; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st117: - if ( ++p == pe ) - goto _test_eof117; -case 117: - switch( (*p) ) { - case 95: goto tr177; - case 114: goto st118; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st118: - if ( ++p == pe ) - goto _test_eof118; -case 118: - switch( (*p) ) { - case 95: goto tr177; - case 121: goto tr213; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st119: - if ( ++p == pe ) - goto _test_eof119; -case 119: - switch( (*p) ) { - case 95: goto tr177; - case 101: goto st120; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st120: - if ( ++p == pe ) - goto _test_eof120; -case 120: - switch( (*p) ) { - case 95: goto tr177; - case 99: goto tr215; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st121: - if ( ++p == pe ) - goto _test_eof121; -case 121: - switch( (*p) ) { - case 95: goto tr177; - case 111: goto st122; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st122: - if ( ++p == pe ) - goto _test_eof122; -case 122: - switch( (*p) ) { - case 95: goto tr177; - case 116: goto st123; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st123: - if ( ++p == pe ) - goto _test_eof123; -case 123: - switch( (*p) ) { - case 95: goto tr177; - case 111: goto tr218; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st124: - if ( ++p == pe ) - goto _test_eof124; -case 124: - switch( (*p) ) { - case 95: goto tr177; - case 111: goto st125; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st125: - if ( ++p == pe ) - goto _test_eof125; -case 125: - switch( (*p) ) { - case 95: goto tr177; - case 108: goto st126; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st126: - if ( ++p == pe ) - goto _test_eof126; -case 126: - switch( (*p) ) { - case 95: goto tr177; - case 100: goto tr221; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st127: - if ( ++p == pe ) - goto _test_eof127; -case 127: - switch( (*p) ) { - case 95: goto tr177; - case 101: goto st128; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st128: - if ( ++p == pe ) - goto _test_eof128; -case 128: - switch( (*p) ) { - case 95: goto tr177; - case 120: goto st129; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st129: - if ( ++p == pe ) - goto _test_eof129; -case 129: - switch( (*p) ) { - case 95: goto tr177; - case 116: goto tr224; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st130: - if ( ++p == pe ) - goto _test_eof130; -case 130: - switch( (*p) ) { - case 95: goto tr177; - case 99: goto tr225; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st131: - if ( ++p == pe ) - goto _test_eof131; -case 131: - switch( (*p) ) { - case 95: goto tr177; - case 101: goto st132; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st132: - if ( ++p == pe ) - goto _test_eof132; -case 132: - switch( (*p) ) { - case 95: goto tr177; - case 116: goto tr227; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st133: - if ( ++p == pe ) - goto _test_eof133; -case 133: - switch( (*p) ) { - case 95: goto tr177; - case 97: goto st134; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st134: - if ( ++p == pe ) - goto _test_eof134; -case 134: - switch( (*p) ) { - case 95: goto tr177; - case 114: goto st135; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st135: - if ( ++p == pe ) - goto _test_eof135; -case 135: - switch( (*p) ) { - case 95: goto tr177; - case 103: goto st136; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -st136: - if ( ++p == pe ) - goto _test_eof136; -case 136: - switch( (*p) ) { - case 95: goto tr177; - case 115: goto tr231; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr177; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr177; - } else - goto tr177; - goto tr188; -tr232: -#line 900 "rlscan.rl" - {te = p+1;{ token( RE_Char, ts, te ); }} - goto st137; -tr233: -#line 895 "rlscan.rl" + goto st95; +tr188: +#line 813 "rlscan.rl" + {te = p;p--;{ token( TK_Word, ts, te ); }} + goto st95; +tr202: +#line 778 "rlscan.rl" + {te = p;p--;{ token( KW_Char ); }} + goto st95; +st95: +#line 1 "NONE" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof95; +case 95: +#line 1 "NONE" + {ts = p;} +#line 2909 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr165; + case 9: goto st96; + case 10: goto tr167; + case 32: goto st96; + case 34: goto tr168; + case 39: goto tr169; + case 40: goto tr170; + case 44: goto tr170; + case 47: goto tr172; + case 48: goto tr173; + case 58: goto st103; + case 59: goto tr176; + case 95: goto tr177; + case 102: goto st105; + case 123: goto tr179; + case 125: goto tr180; + } + if ( (*p) < 49 ) { + if ( 41 <= (*p) && (*p) <= 42 ) + goto tr171; + } else if ( (*p) > 57 ) { + if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else if ( (*p) >= 65 ) + goto tr177; + } else + goto st101; + goto tr164; +tr167: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st96; +st96: + if ( ++p == pe ) + goto _test_eof96; +case 96: +#line 2952 "rlscan.cpp" + switch( (*p) ) { + case 9: goto st96; + case 10: goto tr167; + case 32: goto st96; + } + goto tr181; +tr168: +#line 1 "NONE" + {te = p+1;} + goto st97; +st97: + if ( ++p == pe ) + goto _test_eof97; +case 97: +#line 2967 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr31; + case 34: goto tr32; + case 92: goto st17; + } + goto st16; +tr31: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st16; +st16: + if ( ++p == pe ) + goto _test_eof16; +case 16: +#line 2986 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr31; + case 34: goto tr32; + case 92: goto st17; + } + goto st16; +st17: + if ( ++p == pe ) + goto _test_eof17; +case 17: + if ( (*p) == 10 ) + goto tr31; + goto st16; +tr169: +#line 1 "NONE" + {te = p+1;} + goto st98; +st98: + if ( ++p == pe ) + goto _test_eof98; +case 98: +#line 3008 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr35; + case 39: goto tr32; + case 92: goto st19; + } + goto st18; +tr35: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st18; +st18: + if ( ++p == pe ) + goto _test_eof18; +case 18: +#line 3027 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr35; + case 39: goto tr32; + case 92: goto st19; + } + goto st18; +st19: + if ( ++p == pe ) + goto _test_eof19; +case 19: + if ( (*p) == 10 ) + goto tr35; + goto st18; +tr172: +#line 1 "NONE" + {te = p+1;} + goto st99; +st99: + if ( ++p == pe ) + goto _test_eof99; +case 99: +#line 3049 "rlscan.cpp" + switch( (*p) ) { + case 42: goto st20; + case 47: goto st22; + } + goto tr182; +tr38: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st20; +st20: + if ( ++p == pe ) + goto _test_eof20; +case 20: +#line 3067 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr38; + case 42: goto st21; + } + goto st20; +st21: + if ( ++p == pe ) + goto _test_eof21; +case 21: + switch( (*p) ) { + case 10: goto tr38; + case 42: goto st21; + case 47: goto tr40; + } + goto st20; +st22: + if ( ++p == pe ) + goto _test_eof22; +case 22: + if ( (*p) == 10 ) + goto tr42; + goto st22; +tr173: +#line 1 "NONE" + {te = p+1;} + goto st100; +st100: + if ( ++p == pe ) + goto _test_eof100; +case 100: +#line 3098 "rlscan.cpp" + if ( (*p) == 120 ) + goto st23; + if ( 48 <= (*p) && (*p) <= 57 ) + goto st101; + goto tr183; +st101: + if ( ++p == pe ) + goto _test_eof101; +case 101: + if ( 48 <= (*p) && (*p) <= 57 ) + goto st101; + goto tr183; +st23: + if ( ++p == pe ) + goto _test_eof23; +case 23: + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st102; + } else if ( (*p) > 70 ) { + if ( 97 <= (*p) && (*p) <= 102 ) + goto st102; + } else + goto st102; + goto tr43; +st102: + if ( ++p == pe ) + goto _test_eof102; +case 102: + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st102; + } else if ( (*p) > 70 ) { + if ( 97 <= (*p) && (*p) <= 102 ) + goto st102; + } else + goto st102; + goto tr185; +st103: + if ( ++p == pe ) + goto _test_eof103; +case 103: + if ( (*p) == 58 ) + goto tr186; + goto tr182; +tr177: +#line 1 "NONE" + {te = p+1;} +#line 813 "rlscan.rl" + {act = 39;} + goto st104; +tr201: +#line 1 "NONE" + {te = p+1;} +#line 808 "rlscan.rl" + {act = 38;} + goto st104; +tr206: +#line 1 "NONE" + {te = p+1;} +#line 800 "rlscan.rl" + {act = 36;} + goto st104; +tr208: +#line 1 "NONE" + {te = p+1;} +#line 779 "rlscan.rl" + {act = 29;} + goto st104; +tr213: +#line 1 "NONE" + {te = p+1;} +#line 781 "rlscan.rl" + {act = 31;} + goto st104; +tr215: +#line 1 "NONE" + {te = p+1;} +#line 791 "rlscan.rl" + {act = 33;} + goto st104; +tr218: +#line 1 "NONE" + {te = p+1;} +#line 792 "rlscan.rl" + {act = 34;} + goto st104; +tr221: +#line 1 "NONE" + {te = p+1;} +#line 787 "rlscan.rl" + {act = 32;} + goto st104; +tr224: +#line 1 "NONE" + {te = p+1;} +#line 796 "rlscan.rl" + {act = 35;} + goto st104; +tr225: +#line 1 "NONE" + {te = p+1;} +#line 777 "rlscan.rl" + {act = 27;} + goto st104; +tr227: +#line 1 "NONE" + {te = p+1;} +#line 804 "rlscan.rl" + {act = 37;} + goto st104; +tr231: +#line 1 "NONE" + {te = p+1;} +#line 780 "rlscan.rl" + {act = 30;} + goto st104; +st104: + if ( ++p == pe ) + goto _test_eof104; +case 104: +#line 3220 "rlscan.cpp" + if ( (*p) == 95 ) + goto tr177; + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr187; +st105: + if ( ++p == pe ) + goto _test_eof105; +case 105: + switch( (*p) ) { + case 95: goto tr177; + case 98: goto st106; + case 99: goto st110; + case 101: goto st115; + case 103: goto st121; + case 104: goto st124; + case 110: goto st127; + case 112: goto st130; + case 114: goto st131; + case 116: goto st133; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st106: + if ( ++p == pe ) + goto _test_eof106; +case 106: + switch( (*p) ) { + case 95: goto tr177; + case 114: goto st107; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st107: + if ( ++p == pe ) + goto _test_eof107; +case 107: + switch( (*p) ) { + case 95: goto tr177; + case 101: goto st108; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st108: + if ( ++p == pe ) + goto _test_eof108; +case 108: + switch( (*p) ) { + case 95: goto tr177; + case 97: goto st109; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st109: + if ( ++p == pe ) + goto _test_eof109; +case 109: + switch( (*p) ) { + case 95: goto tr177; + case 107: goto tr201; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st110: + if ( ++p == pe ) + goto _test_eof110; +case 110: + switch( (*p) ) { + case 95: goto tr177; + case 97: goto st111; + case 117: goto st113; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr202; +st111: + if ( ++p == pe ) + goto _test_eof111; +case 111: + switch( (*p) ) { + case 95: goto tr177; + case 108: goto st112; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st112: + if ( ++p == pe ) + goto _test_eof112; +case 112: + switch( (*p) ) { + case 95: goto tr177; + case 108: goto tr206; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st113: + if ( ++p == pe ) + goto _test_eof113; +case 113: + switch( (*p) ) { + case 95: goto tr177; + case 114: goto st114; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st114: + if ( ++p == pe ) + goto _test_eof114; +case 114: + switch( (*p) ) { + case 95: goto tr177; + case 115: goto tr208; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st115: + if ( ++p == pe ) + goto _test_eof115; +case 115: + switch( (*p) ) { + case 95: goto tr177; + case 110: goto st116; + case 120: goto st119; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st116: + if ( ++p == pe ) + goto _test_eof116; +case 116: + switch( (*p) ) { + case 95: goto tr177; + case 116: goto st117; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st117: + if ( ++p == pe ) + goto _test_eof117; +case 117: + switch( (*p) ) { + case 95: goto tr177; + case 114: goto st118; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st118: + if ( ++p == pe ) + goto _test_eof118; +case 118: + switch( (*p) ) { + case 95: goto tr177; + case 121: goto tr213; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st119: + if ( ++p == pe ) + goto _test_eof119; +case 119: + switch( (*p) ) { + case 95: goto tr177; + case 101: goto st120; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st120: + if ( ++p == pe ) + goto _test_eof120; +case 120: + switch( (*p) ) { + case 95: goto tr177; + case 99: goto tr215; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st121: + if ( ++p == pe ) + goto _test_eof121; +case 121: + switch( (*p) ) { + case 95: goto tr177; + case 111: goto st122; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st122: + if ( ++p == pe ) + goto _test_eof122; +case 122: + switch( (*p) ) { + case 95: goto tr177; + case 116: goto st123; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st123: + if ( ++p == pe ) + goto _test_eof123; +case 123: + switch( (*p) ) { + case 95: goto tr177; + case 111: goto tr218; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st124: + if ( ++p == pe ) + goto _test_eof124; +case 124: + switch( (*p) ) { + case 95: goto tr177; + case 111: goto st125; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st125: + if ( ++p == pe ) + goto _test_eof125; +case 125: + switch( (*p) ) { + case 95: goto tr177; + case 108: goto st126; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st126: + if ( ++p == pe ) + goto _test_eof126; +case 126: + switch( (*p) ) { + case 95: goto tr177; + case 100: goto tr221; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st127: + if ( ++p == pe ) + goto _test_eof127; +case 127: + switch( (*p) ) { + case 95: goto tr177; + case 101: goto st128; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st128: + if ( ++p == pe ) + goto _test_eof128; +case 128: + switch( (*p) ) { + case 95: goto tr177; + case 120: goto st129; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st129: + if ( ++p == pe ) + goto _test_eof129; +case 129: + switch( (*p) ) { + case 95: goto tr177; + case 116: goto tr224; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st130: + if ( ++p == pe ) + goto _test_eof130; +case 130: + switch( (*p) ) { + case 95: goto tr177; + case 99: goto tr225; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st131: + if ( ++p == pe ) + goto _test_eof131; +case 131: + switch( (*p) ) { + case 95: goto tr177; + case 101: goto st132; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st132: + if ( ++p == pe ) + goto _test_eof132; +case 132: + switch( (*p) ) { + case 95: goto tr177; + case 116: goto tr227; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st133: + if ( ++p == pe ) + goto _test_eof133; +case 133: + switch( (*p) ) { + case 95: goto tr177; + case 97: goto st134; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st134: + if ( ++p == pe ) + goto _test_eof134; +case 134: + switch( (*p) ) { + case 95: goto tr177; + case 114: goto st135; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st135: + if ( ++p == pe ) + goto _test_eof135; +case 135: + switch( (*p) ) { + case 95: goto tr177; + case 103: goto st136; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +st136: + if ( ++p == pe ) + goto _test_eof136; +case 136: + switch( (*p) ) { + case 95: goto tr177; + case 115: goto tr231; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr177; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr177; + } else + goto tr177; + goto tr188; +tr232: +#line 900 "rlscan.rl" + {te = p+1;{ token( RE_Char, ts, te ); }} + goto st137; +tr233: +#line 895 "rlscan.rl" {te = p+1;{ scan_error() << "unterminated OR literal" << endl; }} - goto st137; -tr234: -#line 890 "rlscan.rl" - {te = p+1;{ token( RE_Dash, 0, 0 ); }} - goto st137; -tr236: -#line 893 "rlscan.rl" - {te = p+1;{ token( RE_SqClose ); {cs = stack[--top];goto _again;} }} - goto st137; -tr237: -#line 900 "rlscan.rl" + goto st137; +tr234: +#line 890 "rlscan.rl" + {te = p+1;{ token( RE_Dash, 0, 0 ); }} + goto st137; +tr236: +#line 893 "rlscan.rl" + {te = p+1;{ token( RE_SqClose ); {cs = stack[--top];goto _again;} }} + goto st137; +tr237: +#line 900 "rlscan.rl" {te = p;p--;{ token( RE_Char, ts, te ); }} - goto st137; -tr238: -#line 887 "rlscan.rl" - {te = p+1;{ token( RE_Char, ts+1, te ); }} - goto st137; -tr239: -#line 886 "rlscan.rl" - {te = p+1;{ updateCol(); }} - goto st137; -tr240: -#line 878 "rlscan.rl" + goto st137; +tr238: +#line 887 "rlscan.rl" + {te = p+1;{ token( RE_Char, ts+1, te ); }} + goto st137; +tr239: +#line 886 "rlscan.rl" + {te = p+1;{ updateCol(); }} + goto st137; +tr240: +#line 878 "rlscan.rl" {te = p+1;{ token( RE_Char, '\0' ); }} - goto st137; -tr241: -#line 879 "rlscan.rl" + goto st137; +tr241: +#line 879 "rlscan.rl" {te = p+1;{ token( RE_Char, '\a' ); }} - goto st137; -tr242: -#line 880 "rlscan.rl" + goto st137; +tr242: +#line 880 "rlscan.rl" {te = p+1;{ token( RE_Char, '\b' ); }} - goto st137; -tr243: -#line 884 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\f' ); }} - goto st137; -tr244: -#line 882 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\n' ); }} - goto st137; -tr245: -#line 885 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\r' ); }} - goto st137; -tr246: -#line 881 "rlscan.rl" + goto st137; +tr243: +#line 884 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\f' ); }} + goto st137; +tr244: +#line 882 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\n' ); }} + goto st137; +tr245: +#line 885 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\r' ); }} + goto st137; +tr246: +#line 881 "rlscan.rl" {te = p+1;{ token( RE_Char, '\t' ); }} - goto st137; -tr247: -#line 883 "rlscan.rl" + goto st137; +tr247: +#line 883 "rlscan.rl" {te = p+1;{ token( RE_Char, '\v' ); }} - goto st137; -st137: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof137; -case 137: -#line 1 "NONE" - {ts = p;} -#line 3856 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr233; - case 45: goto tr234; - case 92: goto st138; - case 93: goto tr236; - } - goto tr232; -st138: - if ( ++p == pe ) - goto _test_eof138; -case 138: - switch( (*p) ) { - case 10: goto tr239; - case 48: goto tr240; - case 97: goto tr241; - case 98: goto tr242; - case 102: goto tr243; - case 110: goto tr244; - case 114: goto tr245; - case 116: goto tr246; - case 118: goto tr247; - } - goto tr238; -tr248: -#line 935 "rlscan.rl" - {te = p+1;{ token( RE_Char, ts, te ); }} - goto st139; -tr249: -#line 930 "rlscan.rl" + goto st137; +st137: +#line 1 "NONE" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof137; +case 137: +#line 1 "NONE" + {ts = p;} +#line 3856 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr233; + case 45: goto tr234; + case 92: goto st138; + case 93: goto tr236; + } + goto tr232; +st138: + if ( ++p == pe ) + goto _test_eof138; +case 138: + switch( (*p) ) { + case 10: goto tr239; + case 48: goto tr240; + case 97: goto tr241; + case 98: goto tr242; + case 102: goto tr243; + case 110: goto tr244; + case 114: goto tr245; + case 116: goto tr246; + case 118: goto tr247; + } + goto tr238; +tr248: +#line 935 "rlscan.rl" + {te = p+1;{ token( RE_Char, ts, te ); }} + goto st139; +tr249: +#line 930 "rlscan.rl" {te = p+1;{ scan_error() << "unterminated regular expression" << endl; }} - goto st139; -tr250: -#line 925 "rlscan.rl" - {te = p+1;{ token( RE_Star ); }} - goto st139; -tr251: -#line 924 "rlscan.rl" - {te = p+1;{ token( RE_Dot ); }} - goto st139; -tr255: -#line 918 "rlscan.rl" + goto st139; +tr250: +#line 925 "rlscan.rl" + {te = p+1;{ token( RE_Star ); }} + goto st139; +tr251: +#line 924 "rlscan.rl" + {te = p+1;{ token( RE_Dot ); }} + goto st139; +tr255: +#line 918 "rlscan.rl" {te = p;p--;{ token( RE_Slash, ts, te ); - {goto st146;} + {goto st146;} }} - goto st139; -tr256: -#line 918 "rlscan.rl" - {te = p+1;{ - token( RE_Slash, ts, te ); - {goto st146;} - }} - goto st139; -tr257: -#line 927 "rlscan.rl" - {te = p;p--;{ token( RE_SqOpen ); {stack[top++] = 139; goto st137;} }} - goto st139; -tr258: -#line 928 "rlscan.rl" - {te = p+1;{ token( RE_SqOpenNeg ); {stack[top++] = 139; goto st137;} }} - goto st139; -tr259: -#line 935 "rlscan.rl" + goto st139; +tr256: +#line 918 "rlscan.rl" + {te = p+1;{ + token( RE_Slash, ts, te ); + {goto st146;} + }} + goto st139; +tr257: +#line 927 "rlscan.rl" + {te = p;p--;{ token( RE_SqOpen ); {stack[top++] = 139; goto st137;} }} + goto st139; +tr258: +#line 928 "rlscan.rl" + {te = p+1;{ token( RE_SqOpenNeg ); {stack[top++] = 139; goto st137;} }} + goto st139; +tr259: +#line 935 "rlscan.rl" {te = p;p--;{ token( RE_Char, ts, te ); }} - goto st139; -tr260: -#line 915 "rlscan.rl" - {te = p+1;{ token( RE_Char, ts+1, te ); }} - goto st139; -tr261: -#line 914 "rlscan.rl" - {te = p+1;{ updateCol(); }} - goto st139; -tr262: -#line 906 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\0' ); }} - goto st139; -tr263: -#line 907 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\a' ); }} - goto st139; -tr264: -#line 908 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\b' ); }} - goto st139; -tr265: -#line 912 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\f' ); }} - goto st139; -tr266: -#line 910 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\n' ); }} - goto st139; -tr267: -#line 913 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\r' ); }} - goto st139; -tr268: -#line 909 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\t' ); }} - goto st139; -tr269: -#line 911 "rlscan.rl" - {te = p+1;{ token( RE_Char, '\v' ); }} - goto st139; -st139: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof139; -case 139: -#line 1 "NONE" - {ts = p;} -#line 3972 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr249; - case 42: goto tr250; - case 46: goto tr251; - case 47: goto st140; - case 91: goto st141; - case 92: goto st142; - } - goto tr248; -st140: - if ( ++p == pe ) - goto _test_eof140; -case 140: - if ( (*p) == 105 ) - goto tr256; - goto tr255; -st141: - if ( ++p == pe ) - goto _test_eof141; -case 141: - if ( (*p) == 94 ) - goto tr258; - goto tr257; -st142: - if ( ++p == pe ) - goto _test_eof142; -case 142: - switch( (*p) ) { - case 10: goto tr261; - case 48: goto tr262; - case 97: goto tr263; - case 98: goto tr264; - case 102: goto tr265; - case 110: goto tr266; - case 114: goto tr267; - case 116: goto tr268; - case 118: goto tr269; - } - goto tr260; -tr270: -#line 944 "rlscan.rl" + goto st139; +tr260: +#line 915 "rlscan.rl" + {te = p+1;{ token( RE_Char, ts+1, te ); }} + goto st139; +tr261: +#line 914 "rlscan.rl" + {te = p+1;{ updateCol(); }} + goto st139; +tr262: +#line 906 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\0' ); }} + goto st139; +tr263: +#line 907 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\a' ); }} + goto st139; +tr264: +#line 908 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\b' ); }} + goto st139; +tr265: +#line 912 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\f' ); }} + goto st139; +tr266: +#line 910 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\n' ); }} + goto st139; +tr267: +#line 913 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\r' ); }} + goto st139; +tr268: +#line 909 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\t' ); }} + goto st139; +tr269: +#line 911 "rlscan.rl" + {te = p+1;{ token( RE_Char, '\v' ); }} + goto st139; +st139: +#line 1 "NONE" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof139; +case 139: +#line 1 "NONE" + {ts = p;} +#line 3972 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr249; + case 42: goto tr250; + case 46: goto tr251; + case 47: goto st140; + case 91: goto st141; + case 92: goto st142; + } + goto tr248; +st140: + if ( ++p == pe ) + goto _test_eof140; +case 140: + if ( (*p) == 105 ) + goto tr256; + goto tr255; +st141: + if ( ++p == pe ) + goto _test_eof141; +case 141: + if ( (*p) == 94 ) + goto tr258; + goto tr257; +st142: + if ( ++p == pe ) + goto _test_eof142; +case 142: + switch( (*p) ) { + case 10: goto tr261; + case 48: goto tr262; + case 97: goto tr263; + case 98: goto tr264; + case 102: goto tr265; + case 110: goto tr266; + case 114: goto tr267; + case 116: goto tr268; + case 118: goto tr269; + } + goto tr260; +tr270: +#line 944 "rlscan.rl" {te = p+1;{ scan_error() << "unterminated write statement" << endl; }} - goto st143; -tr273: -#line 942 "rlscan.rl" - {te = p+1;{ token( ';' ); {goto st146;} }} - goto st143; -tr275: -#line 941 "rlscan.rl" - {te = p;p--;{ updateCol(); }} - goto st143; -tr276: -#line 940 "rlscan.rl" + goto st143; +tr273: +#line 942 "rlscan.rl" + {te = p+1;{ token( ';' ); {goto st146;} }} + goto st143; +tr275: +#line 941 "rlscan.rl" + {te = p;p--;{ updateCol(); }} + goto st143; +tr276: +#line 940 "rlscan.rl" {te = p;p--;{ token( TK_Word, ts, te ); }} - goto st143; -st143: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof143; -case 143: -#line 1 "NONE" - {ts = p;} -#line 4038 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr270; - case 32: goto st144; - case 59: goto tr273; - case 95: goto st145; - } - if ( (*p) < 65 ) { - if ( 9 <= (*p) && (*p) <= 10 ) - goto st144; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto st145; - } else - goto st145; - goto st0; -st0: -cs = 0; - goto _out; -st144: - if ( ++p == pe ) - goto _test_eof144; -case 144: - if ( (*p) == 32 ) - goto st144; - if ( 9 <= (*p) && (*p) <= 10 ) - goto st144; - goto tr275; -st145: - if ( ++p == pe ) - goto _test_eof145; -case 145: - if ( (*p) == 95 ) - goto st145; - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st145; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto st145; - } else - goto st145; - goto tr276; -tr45: -#line 1121 "rlscan.rl" - {{p = ((te))-1;}{ token( *ts ); }} - goto st146; -tr51: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } -#line 1018 "rlscan.rl" - {te = p+1;{ updateCol(); }} - goto st146; -tr55: -#line 1005 "rlscan.rl" - {{p = ((te))-1;}{ token( TK_UInt, ts, te ); }} - goto st146; -tr57: -#line 1086 "rlscan.rl" + goto st143; +st143: +#line 1 "NONE" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof143; +case 143: +#line 1 "NONE" + {ts = p;} +#line 4038 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr270; + case 32: goto st144; + case 59: goto tr273; + case 95: goto st145; + } + if ( (*p) < 65 ) { + if ( 9 <= (*p) && (*p) <= 10 ) + goto st144; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto st145; + } else + goto st145; + goto st0; +st0: +cs = 0; + goto _out; +st144: + if ( ++p == pe ) + goto _test_eof144; +case 144: + if ( (*p) == 32 ) + goto st144; + if ( 9 <= (*p) && (*p) <= 10 ) + goto st144; + goto tr275; +st145: + if ( ++p == pe ) + goto _test_eof145; +case 145: + if ( (*p) == 95 ) + goto st145; + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st145; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto st145; + } else + goto st145; + goto tr276; +tr45: +#line 1121 "rlscan.rl" + {{p = ((te))-1;}{ token( *ts ); }} + goto st146; +tr51: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } +#line 1018 "rlscan.rl" + {te = p+1;{ updateCol(); }} + goto st146; +tr55: +#line 1005 "rlscan.rl" + {{p = ((te))-1;}{ token( TK_UInt, ts, te ); }} + goto st146; +tr57: +#line 1086 "rlscan.rl" {te = p+1;{ updateCol(); endSection(); {cs = stack[--top];goto _again;} }} - goto st146; -tr277: -#line 1121 "rlscan.rl" - {te = p+1;{ token( *ts ); }} - goto st146; -tr278: -#line 1117 "rlscan.rl" - {te = p+1;{ - scan_error() << "unterminated ragel section" << endl; - }} - goto st146; -tr280: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } -#line 1095 "rlscan.rl" - {te = p+1;{ - updateCol(); - if ( singleLineSpec ) { - endSection(); - {cs = stack[--top];goto _again;} - } - }} - goto st146; -tr289: -#line 1015 "rlscan.rl" - {te = p+1;{ token( RE_Slash ); {goto st139;} }} - goto st146; -tr311: -#line 1103 "rlscan.rl" + goto st146; +tr277: +#line 1121 "rlscan.rl" + {te = p+1;{ token( *ts ); }} + goto st146; +tr278: +#line 1117 "rlscan.rl" + {te = p+1;{ + scan_error() << "unterminated ragel section" << endl; + }} + goto st146; +tr280: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } +#line 1095 "rlscan.rl" + {te = p+1;{ + updateCol(); + if ( singleLineSpec ) { + endSection(); + {cs = stack[--top];goto _again;} + } + }} + goto st146; +tr289: +#line 1015 "rlscan.rl" + {te = p+1;{ token( RE_Slash ); {goto st139;} }} + goto st146; +tr311: +#line 1103 "rlscan.rl" {te = p+1;{ if ( lastToken == KW_Export || lastToken == KW_Entry ) token( '{' ); @@ -4145,213 +4145,213 @@ tr311: curly_count = 1; inlineBlockType = CurlyDelimited; if ( hostLang->lang == HostLang::Ruby ) - {stack[top++] = 146; goto st52;} + {stack[top++] = 146; goto st52;} else - {stack[top++] = 146; goto st95;} + {stack[top++] = 146; goto st95;} } }} - goto st146; -tr314: -#line 1092 "rlscan.rl" - {te = p;p--;{ updateCol(); }} - goto st146; -tr315: -#line 1121 "rlscan.rl" - {te = p;p--;{ token( *ts ); }} - goto st146; -tr316: -#line 1010 "rlscan.rl" - {te = p;p--;{ token( TK_Literal, ts, te ); }} - goto st146; -tr317: -#line 1010 "rlscan.rl" - {te = p+1;{ token( TK_Literal, ts, te ); }} - goto st146; -tr318: -#line 1048 "rlscan.rl" - {te = p+1;{ token( TK_AllGblError ); }} - goto st146; -tr319: -#line 1032 "rlscan.rl" - {te = p+1;{ token( TK_AllFromState ); }} - goto st146; -tr320: -#line 1040 "rlscan.rl" - {te = p+1;{ token( TK_AllEOF ); }} - goto st146; -tr321: -#line 1067 "rlscan.rl" - {te = p+1;{ token( TK_AllCond ); }} - goto st146; -tr322: -#line 1056 "rlscan.rl" - {te = p+1;{ token( TK_AllLocalError ); }} - goto st146; -tr323: -#line 1024 "rlscan.rl" - {te = p+1;{ token( TK_AllToState ); }} - goto st146; -tr324: -#line 1049 "rlscan.rl" - {te = p+1;{ token( TK_FinalGblError ); }} - goto st146; -tr325: -#line 1033 "rlscan.rl" - {te = p+1;{ token( TK_FinalFromState ); }} - goto st146; -tr326: -#line 1041 "rlscan.rl" - {te = p+1;{ token( TK_FinalEOF ); }} - goto st146; -tr327: -#line 1068 "rlscan.rl" - {te = p+1;{ token( TK_LeavingCond ); }} - goto st146; -tr328: -#line 1057 "rlscan.rl" - {te = p+1;{ token( TK_FinalLocalError ); }} - goto st146; -tr329: -#line 1025 "rlscan.rl" - {te = p+1;{ token( TK_FinalToState ); }} - goto st146; -tr330: -#line 1071 "rlscan.rl" - {te = p+1;{ token( TK_StarStar ); }} - goto st146; -tr331: -#line 1072 "rlscan.rl" - {te = p+1;{ token( TK_DashDash ); }} - goto st146; -tr332: -#line 1073 "rlscan.rl" - {te = p+1;{ token( TK_Arrow ); }} - goto st146; -tr333: -#line 1070 "rlscan.rl" - {te = p+1;{ token( TK_DotDot ); }} - goto st146; -tr334: -#line 1005 "rlscan.rl" + goto st146; +tr314: +#line 1092 "rlscan.rl" + {te = p;p--;{ updateCol(); }} + goto st146; +tr315: +#line 1121 "rlscan.rl" + {te = p;p--;{ token( *ts ); }} + goto st146; +tr316: +#line 1010 "rlscan.rl" + {te = p;p--;{ token( TK_Literal, ts, te ); }} + goto st146; +tr317: +#line 1010 "rlscan.rl" + {te = p+1;{ token( TK_Literal, ts, te ); }} + goto st146; +tr318: +#line 1048 "rlscan.rl" + {te = p+1;{ token( TK_AllGblError ); }} + goto st146; +tr319: +#line 1032 "rlscan.rl" + {te = p+1;{ token( TK_AllFromState ); }} + goto st146; +tr320: +#line 1040 "rlscan.rl" + {te = p+1;{ token( TK_AllEOF ); }} + goto st146; +tr321: +#line 1067 "rlscan.rl" + {te = p+1;{ token( TK_AllCond ); }} + goto st146; +tr322: +#line 1056 "rlscan.rl" + {te = p+1;{ token( TK_AllLocalError ); }} + goto st146; +tr323: +#line 1024 "rlscan.rl" + {te = p+1;{ token( TK_AllToState ); }} + goto st146; +tr324: +#line 1049 "rlscan.rl" + {te = p+1;{ token( TK_FinalGblError ); }} + goto st146; +tr325: +#line 1033 "rlscan.rl" + {te = p+1;{ token( TK_FinalFromState ); }} + goto st146; +tr326: +#line 1041 "rlscan.rl" + {te = p+1;{ token( TK_FinalEOF ); }} + goto st146; +tr327: +#line 1068 "rlscan.rl" + {te = p+1;{ token( TK_LeavingCond ); }} + goto st146; +tr328: +#line 1057 "rlscan.rl" + {te = p+1;{ token( TK_FinalLocalError ); }} + goto st146; +tr329: +#line 1025 "rlscan.rl" + {te = p+1;{ token( TK_FinalToState ); }} + goto st146; +tr330: +#line 1071 "rlscan.rl" + {te = p+1;{ token( TK_StarStar ); }} + goto st146; +tr331: +#line 1072 "rlscan.rl" + {te = p+1;{ token( TK_DashDash ); }} + goto st146; +tr332: +#line 1073 "rlscan.rl" + {te = p+1;{ token( TK_Arrow ); }} + goto st146; +tr333: +#line 1070 "rlscan.rl" + {te = p+1;{ token( TK_DotDot ); }} + goto st146; +tr334: +#line 1005 "rlscan.rl" {te = p;p--;{ token( TK_UInt, ts, te ); }} - goto st146; -tr336: -#line 1006 "rlscan.rl" + goto st146; +tr336: +#line 1006 "rlscan.rl" {te = p;p--;{ token( TK_Hex, ts, te ); }} - goto st146; -tr337: -#line 1084 "rlscan.rl" - {te = p+1;{ token( TK_NameSep, ts, te ); }} - goto st146; -tr338: -#line 1020 "rlscan.rl" - {te = p+1;{ token( TK_ColonEquals ); }} - goto st146; -tr340: -#line 1076 "rlscan.rl" - {te = p;p--;{ token( TK_ColonGt ); }} - goto st146; -tr341: -#line 1077 "rlscan.rl" - {te = p+1;{ token( TK_ColonGtGt ); }} - goto st146; -tr342: -#line 1050 "rlscan.rl" - {te = p+1;{ token( TK_NotStartGblError ); }} - goto st146; -tr343: -#line 1034 "rlscan.rl" - {te = p+1;{ token( TK_NotStartFromState ); }} - goto st146; -tr344: -#line 1042 "rlscan.rl" - {te = p+1;{ token( TK_NotStartEOF ); }} - goto st146; -tr345: -#line 1078 "rlscan.rl" - {te = p+1;{ token( TK_LtColon ); }} - goto st146; -tr347: -#line 1058 "rlscan.rl" - {te = p+1;{ token( TK_NotStartLocalError ); }} - goto st146; -tr348: -#line 1026 "rlscan.rl" - {te = p+1;{ token( TK_NotStartToState ); }} - goto st146; -tr349: -#line 1063 "rlscan.rl" + goto st146; +tr337: +#line 1084 "rlscan.rl" + {te = p+1;{ token( TK_NameSep, ts, te ); }} + goto st146; +tr338: +#line 1020 "rlscan.rl" + {te = p+1;{ token( TK_ColonEquals ); }} + goto st146; +tr340: +#line 1076 "rlscan.rl" + {te = p;p--;{ token( TK_ColonGt ); }} + goto st146; +tr341: +#line 1077 "rlscan.rl" + {te = p+1;{ token( TK_ColonGtGt ); }} + goto st146; +tr342: +#line 1050 "rlscan.rl" + {te = p+1;{ token( TK_NotStartGblError ); }} + goto st146; +tr343: +#line 1034 "rlscan.rl" + {te = p+1;{ token( TK_NotStartFromState ); }} + goto st146; +tr344: +#line 1042 "rlscan.rl" + {te = p+1;{ token( TK_NotStartEOF ); }} + goto st146; +tr345: +#line 1078 "rlscan.rl" + {te = p+1;{ token( TK_LtColon ); }} + goto st146; +tr347: +#line 1058 "rlscan.rl" + {te = p+1;{ token( TK_NotStartLocalError ); }} + goto st146; +tr348: +#line 1026 "rlscan.rl" + {te = p+1;{ token( TK_NotStartToState ); }} + goto st146; +tr349: +#line 1063 "rlscan.rl" {te = p;p--;{ token( TK_Middle ); }} - goto st146; -tr350: -#line 1052 "rlscan.rl" - {te = p+1;{ token( TK_MiddleGblError ); }} - goto st146; -tr351: -#line 1036 "rlscan.rl" - {te = p+1;{ token( TK_MiddleFromState ); }} - goto st146; -tr352: -#line 1044 "rlscan.rl" - {te = p+1;{ token( TK_MiddleEOF ); }} - goto st146; -tr353: -#line 1060 "rlscan.rl" - {te = p+1;{ token( TK_MiddleLocalError ); }} - goto st146; -tr354: -#line 1028 "rlscan.rl" - {te = p+1;{ token( TK_MiddleToState ); }} - goto st146; -tr355: -#line 1074 "rlscan.rl" - {te = p+1;{ token( TK_DoubleArrow ); }} - goto st146; -tr356: -#line 1047 "rlscan.rl" - {te = p+1;{ token( TK_StartGblError ); }} - goto st146; -tr357: -#line 1031 "rlscan.rl" - {te = p+1;{ token( TK_StartFromState ); }} - goto st146; -tr358: -#line 1039 "rlscan.rl" - {te = p+1;{ token( TK_StartEOF ); }} - goto st146; -tr359: -#line 1066 "rlscan.rl" - {te = p+1;{ token( TK_StartCond ); }} - goto st146; -tr360: -#line 1055 "rlscan.rl" - {te = p+1;{ token( TK_StartLocalError ); }} - goto st146; -tr361: -#line 1023 "rlscan.rl" - {te = p+1;{ token( TK_StartToState ); }} - goto st146; -tr362: -#line 1051 "rlscan.rl" - {te = p+1;{ token( TK_NotFinalGblError ); }} - goto st146; -tr363: -#line 1035 "rlscan.rl" - {te = p+1;{ token( TK_NotFinalFromState ); }} - goto st146; -tr364: -#line 1043 "rlscan.rl" - {te = p+1;{ token( TK_NotFinalEOF ); }} - goto st146; -tr365: -#line 1059 "rlscan.rl" - {te = p+1;{ token( TK_NotFinalLocalError ); }} - goto st146; -tr366: -#line 1027 "rlscan.rl" - {te = p+1;{ token( TK_NotFinalToState ); }} - goto st146; -tr367: + goto st146; +tr350: +#line 1052 "rlscan.rl" + {te = p+1;{ token( TK_MiddleGblError ); }} + goto st146; +tr351: +#line 1036 "rlscan.rl" + {te = p+1;{ token( TK_MiddleFromState ); }} + goto st146; +tr352: +#line 1044 "rlscan.rl" + {te = p+1;{ token( TK_MiddleEOF ); }} + goto st146; +tr353: +#line 1060 "rlscan.rl" + {te = p+1;{ token( TK_MiddleLocalError ); }} + goto st146; +tr354: +#line 1028 "rlscan.rl" + {te = p+1;{ token( TK_MiddleToState ); }} + goto st146; +tr355: +#line 1074 "rlscan.rl" + {te = p+1;{ token( TK_DoubleArrow ); }} + goto st146; +tr356: +#line 1047 "rlscan.rl" + {te = p+1;{ token( TK_StartGblError ); }} + goto st146; +tr357: +#line 1031 "rlscan.rl" + {te = p+1;{ token( TK_StartFromState ); }} + goto st146; +tr358: +#line 1039 "rlscan.rl" + {te = p+1;{ token( TK_StartEOF ); }} + goto st146; +tr359: +#line 1066 "rlscan.rl" + {te = p+1;{ token( TK_StartCond ); }} + goto st146; +tr360: +#line 1055 "rlscan.rl" + {te = p+1;{ token( TK_StartLocalError ); }} + goto st146; +tr361: +#line 1023 "rlscan.rl" + {te = p+1;{ token( TK_StartToState ); }} + goto st146; +tr362: +#line 1051 "rlscan.rl" + {te = p+1;{ token( TK_NotFinalGblError ); }} + goto st146; +tr363: +#line 1035 "rlscan.rl" + {te = p+1;{ token( TK_NotFinalFromState ); }} + goto st146; +tr364: +#line 1043 "rlscan.rl" + {te = p+1;{ token( TK_NotFinalEOF ); }} + goto st146; +tr365: +#line 1059 "rlscan.rl" + {te = p+1;{ token( TK_NotFinalLocalError ); }} + goto st146; +tr366: +#line 1027 "rlscan.rl" + {te = p+1;{ token( TK_NotFinalToState ); }} + goto st146; +tr367: #line 1 "NONE" { switch( act ) { case 88: @@ -4366,7 +4366,7 @@ tr367: case 91: {{p = ((te))-1;} token( KW_Write ); - {goto st143;} + {goto st143;} } break; case 92: @@ -4386,9 +4386,9 @@ tr367: token( KW_GetKey ); inlineBlockType = SemiTerminated; if ( hostLang->lang == HostLang::Ruby ) - {stack[top++] = 146; goto st52;} + {stack[top++] = 146; goto st52;} else - {stack[top++] = 146; goto st95;} + {stack[top++] = 146; goto st95;} } break; case 97: @@ -4396,9 +4396,9 @@ tr367: token( KW_Access ); inlineBlockType = SemiTerminated; if ( hostLang->lang == HostLang::Ruby ) - {stack[top++] = 146; goto st52;} + {stack[top++] = 146; goto st52;} else - {stack[top++] = 146; goto st95;} + {stack[top++] = 146; goto st95;} } break; case 98: @@ -4406,9 +4406,9 @@ tr367: token( KW_Variable ); inlineBlockType = SemiTerminated; if ( hostLang->lang == HostLang::Ruby ) - {stack[top++] = 146; goto st52;} + {stack[top++] = 146; goto st52;} else - {stack[top++] = 146; goto st95;} + {stack[top++] = 146; goto st95;} } break; case 99: @@ -4443,2762 +4443,2762 @@ tr367: break; } } - goto st146; -tr368: -#line 1012 "rlscan.rl" - {te = p;p--;{ token( RE_SqOpen ); {stack[top++] = 146; goto st137;} }} - goto st146; -tr369: -#line 1013 "rlscan.rl" - {te = p+1;{ token( RE_SqOpenNeg ); {stack[top++] = 146; goto st137;} }} - goto st146; -tr370: -#line 1002 "rlscan.rl" - {te = p;p--;{ token( TK_Word, ts, te ); }} - goto st146; -tr461: -#line 1081 "rlscan.rl" - {te = p+1;{ token( TK_BarStar ); }} - goto st146; -st146: -#line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof146; -case 146: -#line 1 "NONE" - {ts = p;} -#line 4470 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr278; - case 9: goto st147; - case 10: goto tr280; - case 13: goto st147; - case 32: goto st147; - case 34: goto tr281; - case 35: goto tr282; - case 36: goto st151; - case 37: goto st152; - case 39: goto tr285; - case 42: goto st154; - case 45: goto st155; - case 46: goto st156; - case 47: goto tr289; - case 48: goto tr290; - case 58: goto st160; - case 60: goto st162; - case 61: goto st164; - case 62: goto st165; - case 64: goto st166; - case 91: goto st168; - case 95: goto tr297; - case 97: goto st169; - case 101: goto st183; - case 102: goto st190; - case 103: goto st193; - case 105: goto st198; - case 108: goto st211; - case 109: goto st214; - case 111: goto st220; - case 112: goto st226; - case 116: goto st237; - case 118: goto st238; - case 119: goto st245; - case 123: goto tr311; - case 124: goto st251; - case 125: goto tr313; - } - if ( (*p) < 65 ) { - if ( 49 <= (*p) && (*p) <= 57 ) - goto st158; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr277; -st147: - if ( ++p == pe ) - goto _test_eof147; -case 147: - switch( (*p) ) { - case 9: goto st147; - case 13: goto st147; - case 32: goto st147; - } - goto tr314; -tr281: + goto st146; +tr368: +#line 1012 "rlscan.rl" + {te = p;p--;{ token( RE_SqOpen ); {stack[top++] = 146; goto st137;} }} + goto st146; +tr369: +#line 1013 "rlscan.rl" + {te = p+1;{ token( RE_SqOpenNeg ); {stack[top++] = 146; goto st137;} }} + goto st146; +tr370: +#line 1002 "rlscan.rl" + {te = p;p--;{ token( TK_Word, ts, te ); }} + goto st146; +tr461: +#line 1081 "rlscan.rl" + {te = p+1;{ token( TK_BarStar ); }} + goto st146; +st146: #line 1 "NONE" - {te = p+1;} - goto st148; -st148: - if ( ++p == pe ) - goto _test_eof148; -case 148: -#line 4537 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr47; - case 34: goto st149; - case 92: goto st25; - } - goto st24; -tr47: -#line 641 "rlscan.rl" + {ts = 0;} + if ( ++p == pe ) + goto _test_eof146; +case 146: +#line 1 "NONE" + {ts = p;} +#line 4470 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr278; + case 9: goto st147; + case 10: goto tr280; + case 13: goto st147; + case 32: goto st147; + case 34: goto tr281; + case 35: goto tr282; + case 36: goto st151; + case 37: goto st152; + case 39: goto tr285; + case 42: goto st154; + case 45: goto st155; + case 46: goto st156; + case 47: goto tr289; + case 48: goto tr290; + case 58: goto st160; + case 60: goto st162; + case 61: goto st164; + case 62: goto st165; + case 64: goto st166; + case 91: goto st168; + case 95: goto tr297; + case 97: goto st169; + case 101: goto st183; + case 102: goto st190; + case 103: goto st193; + case 105: goto st198; + case 108: goto st211; + case 109: goto st214; + case 111: goto st220; + case 112: goto st226; + case 116: goto st237; + case 118: goto st238; + case 119: goto st245; + case 123: goto tr311; + case 124: goto st251; + case 125: goto tr313; + } + if ( (*p) < 65 ) { + if ( 49 <= (*p) && (*p) <= 57 ) + goto st158; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr277; +st147: + if ( ++p == pe ) + goto _test_eof147; +case 147: + switch( (*p) ) { + case 9: goto st147; + case 13: goto st147; + case 32: goto st147; + } + goto tr314; +tr281: +#line 1 "NONE" + {te = p+1;} + goto st148; +st148: + if ( ++p == pe ) + goto _test_eof148; +case 148: +#line 4537 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr47; + case 34: goto st149; + case 92: goto st25; + } + goto st24; +tr47: +#line 641 "rlscan.rl" { lastnl = p; column = 0; line++; } - goto st24; -st24: - if ( ++p == pe ) - goto _test_eof24; -case 24: -#line 4556 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr47; - case 34: goto st149; - case 92: goto st25; - } - goto st24; -st149: - if ( ++p == pe ) - goto _test_eof149; -case 149: - if ( (*p) == 105 ) - goto tr317; - goto tr316; -st25: - if ( ++p == pe ) - goto _test_eof25; -case 25: - if ( (*p) == 10 ) - goto tr47; - goto st24; -tr282: -#line 1 "NONE" - {te = p+1;} - goto st150; -st150: - if ( ++p == pe ) - goto _test_eof150; -case 150: -#line 4585 "rlscan.cpp" - if ( (*p) == 10 ) - goto tr51; - goto st26; -st26: - if ( ++p == pe ) - goto _test_eof26; -case 26: - if ( (*p) == 10 ) - goto tr51; - goto st26; -st151: - if ( ++p == pe ) - goto _test_eof151; -case 151: - switch( (*p) ) { - case 33: goto tr318; - case 42: goto tr319; - case 47: goto tr320; - case 63: goto tr321; - case 94: goto tr322; - case 126: goto tr323; - } - goto tr315; -st152: - if ( ++p == pe ) - goto _test_eof152; -case 152: - switch( (*p) ) { - case 33: goto tr324; - case 42: goto tr325; - case 47: goto tr326; - case 63: goto tr327; - case 94: goto tr328; - case 126: goto tr329; - } - goto tr315; -tr285: -#line 1 "NONE" - {te = p+1;} - goto st153; -st153: - if ( ++p == pe ) - goto _test_eof153; -case 153: -#line 4630 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr53; - case 39: goto st149; - case 92: goto st28; - } - goto st27; -tr53: -#line 641 "rlscan.rl" + goto st24; +st24: + if ( ++p == pe ) + goto _test_eof24; +case 24: +#line 4556 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr47; + case 34: goto st149; + case 92: goto st25; + } + goto st24; +st149: + if ( ++p == pe ) + goto _test_eof149; +case 149: + if ( (*p) == 105 ) + goto tr317; + goto tr316; +st25: + if ( ++p == pe ) + goto _test_eof25; +case 25: + if ( (*p) == 10 ) + goto tr47; + goto st24; +tr282: +#line 1 "NONE" + {te = p+1;} + goto st150; +st150: + if ( ++p == pe ) + goto _test_eof150; +case 150: +#line 4585 "rlscan.cpp" + if ( (*p) == 10 ) + goto tr51; + goto st26; +st26: + if ( ++p == pe ) + goto _test_eof26; +case 26: + if ( (*p) == 10 ) + goto tr51; + goto st26; +st151: + if ( ++p == pe ) + goto _test_eof151; +case 151: + switch( (*p) ) { + case 33: goto tr318; + case 42: goto tr319; + case 47: goto tr320; + case 63: goto tr321; + case 94: goto tr322; + case 126: goto tr323; + } + goto tr315; +st152: + if ( ++p == pe ) + goto _test_eof152; +case 152: + switch( (*p) ) { + case 33: goto tr324; + case 42: goto tr325; + case 47: goto tr326; + case 63: goto tr327; + case 94: goto tr328; + case 126: goto tr329; + } + goto tr315; +tr285: +#line 1 "NONE" + {te = p+1;} + goto st153; +st153: + if ( ++p == pe ) + goto _test_eof153; +case 153: +#line 4630 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr53; + case 39: goto st149; + case 92: goto st28; + } + goto st27; +tr53: +#line 641 "rlscan.rl" { lastnl = p; column = 0; line++; } - goto st27; -st27: - if ( ++p == pe ) - goto _test_eof27; -case 27: -#line 4649 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr53; - case 39: goto st149; - case 92: goto st28; - } - goto st27; -st28: - if ( ++p == pe ) - goto _test_eof28; -case 28: - if ( (*p) == 10 ) - goto tr53; - goto st27; -st154: - if ( ++p == pe ) - goto _test_eof154; -case 154: - if ( (*p) == 42 ) - goto tr330; - goto tr315; -st155: - if ( ++p == pe ) - goto _test_eof155; -case 155: - switch( (*p) ) { - case 45: goto tr331; - case 62: goto tr332; - } - goto tr315; -st156: - if ( ++p == pe ) - goto _test_eof156; -case 156: - if ( (*p) == 46 ) - goto tr333; - goto tr315; -tr290: + goto st27; +st27: + if ( ++p == pe ) + goto _test_eof27; +case 27: +#line 4649 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr53; + case 39: goto st149; + case 92: goto st28; + } + goto st27; +st28: + if ( ++p == pe ) + goto _test_eof28; +case 28: + if ( (*p) == 10 ) + goto tr53; + goto st27; +st154: + if ( ++p == pe ) + goto _test_eof154; +case 154: + if ( (*p) == 42 ) + goto tr330; + goto tr315; +st155: + if ( ++p == pe ) + goto _test_eof155; +case 155: + switch( (*p) ) { + case 45: goto tr331; + case 62: goto tr332; + } + goto tr315; +st156: + if ( ++p == pe ) + goto _test_eof156; +case 156: + if ( (*p) == 46 ) + goto tr333; + goto tr315; +tr290: #line 1 "NONE" {te = p+1;} - goto st157; -st157: - if ( ++p == pe ) - goto _test_eof157; -case 157: -#line 4694 "rlscan.cpp" - if ( (*p) == 120 ) - goto st29; - if ( 48 <= (*p) && (*p) <= 57 ) - goto st158; - goto tr334; -st158: - if ( ++p == pe ) - goto _test_eof158; -case 158: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st158; - goto tr334; -st29: - if ( ++p == pe ) - goto _test_eof29; -case 29: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st159; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto st159; - } else - goto st159; - goto tr55; -st159: - if ( ++p == pe ) - goto _test_eof159; -case 159: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st159; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto st159; - } else - goto st159; - goto tr336; -st160: - if ( ++p == pe ) - goto _test_eof160; -case 160: - switch( (*p) ) { - case 58: goto tr337; - case 61: goto tr338; - case 62: goto st161; - } - goto tr315; -st161: - if ( ++p == pe ) - goto _test_eof161; -case 161: - if ( (*p) == 62 ) - goto tr341; - goto tr340; -st162: - if ( ++p == pe ) - goto _test_eof162; -case 162: - switch( (*p) ) { - case 33: goto tr342; - case 42: goto tr343; - case 47: goto tr344; - case 58: goto tr345; - case 62: goto st163; - case 94: goto tr347; - case 126: goto tr348; - } - goto tr315; -st163: - if ( ++p == pe ) - goto _test_eof163; -case 163: - switch( (*p) ) { - case 33: goto tr350; - case 42: goto tr351; - case 47: goto tr352; - case 94: goto tr353; - case 126: goto tr354; - } - goto tr349; -st164: - if ( ++p == pe ) - goto _test_eof164; -case 164: - if ( (*p) == 62 ) - goto tr355; - goto tr315; -st165: - if ( ++p == pe ) - goto _test_eof165; -case 165: - switch( (*p) ) { - case 33: goto tr356; - case 42: goto tr357; - case 47: goto tr358; - case 63: goto tr359; - case 94: goto tr360; - case 126: goto tr361; - } - goto tr315; -st166: - if ( ++p == pe ) - goto _test_eof166; -case 166: - switch( (*p) ) { - case 33: goto tr362; - case 42: goto tr363; - case 47: goto tr364; - case 94: goto tr365; - case 126: goto tr366; - } - goto tr315; -tr297: + goto st157; +st157: + if ( ++p == pe ) + goto _test_eof157; +case 157: +#line 4694 "rlscan.cpp" + if ( (*p) == 120 ) + goto st29; + if ( 48 <= (*p) && (*p) <= 57 ) + goto st158; + goto tr334; +st158: + if ( ++p == pe ) + goto _test_eof158; +case 158: + if ( 48 <= (*p) && (*p) <= 57 ) + goto st158; + goto tr334; +st29: + if ( ++p == pe ) + goto _test_eof29; +case 29: + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st159; + } else if ( (*p) > 70 ) { + if ( 97 <= (*p) && (*p) <= 102 ) + goto st159; + } else + goto st159; + goto tr55; +st159: + if ( ++p == pe ) + goto _test_eof159; +case 159: + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st159; + } else if ( (*p) > 70 ) { + if ( 97 <= (*p) && (*p) <= 102 ) + goto st159; + } else + goto st159; + goto tr336; +st160: + if ( ++p == pe ) + goto _test_eof160; +case 160: + switch( (*p) ) { + case 58: goto tr337; + case 61: goto tr338; + case 62: goto st161; + } + goto tr315; +st161: + if ( ++p == pe ) + goto _test_eof161; +case 161: + if ( (*p) == 62 ) + goto tr341; + goto tr340; +st162: + if ( ++p == pe ) + goto _test_eof162; +case 162: + switch( (*p) ) { + case 33: goto tr342; + case 42: goto tr343; + case 47: goto tr344; + case 58: goto tr345; + case 62: goto st163; + case 94: goto tr347; + case 126: goto tr348; + } + goto tr315; +st163: + if ( ++p == pe ) + goto _test_eof163; +case 163: + switch( (*p) ) { + case 33: goto tr350; + case 42: goto tr351; + case 47: goto tr352; + case 94: goto tr353; + case 126: goto tr354; + } + goto tr349; +st164: + if ( ++p == pe ) + goto _test_eof164; +case 164: + if ( (*p) == 62 ) + goto tr355; + goto tr315; +st165: + if ( ++p == pe ) + goto _test_eof165; +case 165: + switch( (*p) ) { + case 33: goto tr356; + case 42: goto tr357; + case 47: goto tr358; + case 63: goto tr359; + case 94: goto tr360; + case 126: goto tr361; + } + goto tr315; +st166: + if ( ++p == pe ) + goto _test_eof166; +case 166: + switch( (*p) ) { + case 33: goto tr362; + case 42: goto tr363; + case 47: goto tr364; + case 94: goto tr365; + case 126: goto tr366; + } + goto tr315; +tr297: #line 1 "NONE" {te = p+1;} -#line 1002 "rlscan.rl" - {act = 108;} - goto st167; -tr377: +#line 1002 "rlscan.rl" + {act = 108;} + goto st167; +tr377: #line 1 "NONE" {te = p+1;} -#line 975 "rlscan.rl" - {act = 97;} - goto st167; -tr380: +#line 975 "rlscan.rl" + {act = 97;} + goto st167; +tr380: #line 1 "NONE" {te = p+1;} -#line 959 "rlscan.rl" - {act = 92;} - goto st167; -tr386: +#line 959 "rlscan.rl" + {act = 92;} + goto st167; +tr386: #line 1 "NONE" {te = p+1;} -#line 960 "rlscan.rl" - {act = 93;} - goto st167; -tr390: +#line 960 "rlscan.rl" + {act = 93;} + goto st167; +tr390: #line 1 "NONE" {te = p+1;} -#line 994 "rlscan.rl" - {act = 102;} - goto st167; -tr391: +#line 994 "rlscan.rl" + {act = 102;} + goto st167; +tr391: #line 1 "NONE" {te = p+1;} -#line 995 "rlscan.rl" - {act = 103;} - goto st167; -tr395: +#line 995 "rlscan.rl" + {act = 103;} + goto st167; +tr395: #line 1 "NONE" {te = p+1;} -#line 999 "rlscan.rl" - {act = 107;} - goto st167; -tr398: +#line 999 "rlscan.rl" + {act = 107;} + goto st167; +tr398: #line 1 "NONE" {te = p+1;} -#line 998 "rlscan.rl" - {act = 106;} - goto st167; -tr403: +#line 998 "rlscan.rl" + {act = 106;} + goto st167; +tr403: #line 1 "NONE" {te = p+1;} -#line 967 "rlscan.rl" - {act = 96;} - goto st167; -tr409: +#line 967 "rlscan.rl" + {act = 96;} + goto st167; +tr409: #line 1 "NONE" {te = p+1;} -#line 954 "rlscan.rl" - {act = 90;} - goto st167; -tr415: +#line 954 "rlscan.rl" + {act = 90;} + goto st167; +tr415: #line 1 "NONE" {te = p+1;} -#line 953 "rlscan.rl" - {act = 89;} - goto st167; -tr418: +#line 953 "rlscan.rl" + {act = 89;} + goto st167; +tr418: #line 1 "NONE" {te = p+1;} -#line 992 "rlscan.rl" - {act = 100;} - goto st167; -tr421: +#line 992 "rlscan.rl" + {act = 100;} + goto st167; +tr421: #line 1 "NONE" {te = p+1;} -#line 996 "rlscan.rl" - {act = 104;} - goto st167; -tr427: +#line 996 "rlscan.rl" + {act = 104;} + goto st167; +tr427: #line 1 "NONE" {te = p+1;} -#line 952 "rlscan.rl" +#line 952 "rlscan.rl" {act = 88;} - goto st167; -tr433: + goto st167; +tr433: #line 1 "NONE" {te = p+1;} -#line 993 "rlscan.rl" - {act = 101;} - goto st167; -tr440: +#line 993 "rlscan.rl" + {act = 101;} + goto st167; +tr440: #line 1 "NONE" {te = p+1;} -#line 962 "rlscan.rl" - {act = 95;} - goto st167; -tr445: +#line 962 "rlscan.rl" + {act = 95;} + goto st167; +tr445: #line 1 "NONE" {te = p+1;} -#line 961 "rlscan.rl" +#line 961 "rlscan.rl" {act = 94;} - goto st167; -tr446: + goto st167; +tr446: #line 1 "NONE" {te = p+1;} -#line 997 "rlscan.rl" - {act = 105;} - goto st167; -tr453: +#line 997 "rlscan.rl" + {act = 105;} + goto st167; +tr453: #line 1 "NONE" {te = p+1;} -#line 983 "rlscan.rl" +#line 983 "rlscan.rl" {act = 98;} - goto st167; -tr457: + goto st167; +tr457: #line 1 "NONE" {te = p+1;} -#line 991 "rlscan.rl" +#line 991 "rlscan.rl" {act = 99;} - goto st167; -tr460: + goto st167; +tr460: #line 1 "NONE" {te = p+1;} -#line 955 "rlscan.rl" - {act = 91;} - goto st167; -st167: - if ( ++p == pe ) - goto _test_eof167; -case 167: -#line 4938 "rlscan.cpp" - if ( (*p) == 95 ) - goto tr297; - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr367; -st168: - if ( ++p == pe ) - goto _test_eof168; -case 168: - if ( (*p) == 94 ) - goto tr369; - goto tr368; -st169: - if ( ++p == pe ) - goto _test_eof169; -case 169: - switch( (*p) ) { - case 95: goto tr297; - case 99: goto st170; - case 108: goto st177; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st170: - if ( ++p == pe ) - goto _test_eof170; -case 170: - switch( (*p) ) { - case 95: goto tr297; - case 99: goto st171; - case 116: goto st174; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st171: - if ( ++p == pe ) - goto _test_eof171; -case 171: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st172; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st172: - if ( ++p == pe ) - goto _test_eof172; -case 172: - switch( (*p) ) { - case 95: goto tr297; - case 115: goto st173; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st173: - if ( ++p == pe ) - goto _test_eof173; -case 173: - switch( (*p) ) { - case 95: goto tr297; - case 115: goto tr377; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st174: - if ( ++p == pe ) - goto _test_eof174; -case 174: - switch( (*p) ) { - case 95: goto tr297; - case 105: goto st175; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st175: - if ( ++p == pe ) - goto _test_eof175; -case 175: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st176; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st176: - if ( ++p == pe ) - goto _test_eof176; -case 176: - switch( (*p) ) { - case 95: goto tr297; - case 110: goto tr380; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st177: - if ( ++p == pe ) - goto _test_eof177; -case 177: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto st178; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st178: - if ( ++p == pe ) - goto _test_eof178; -case 178: - switch( (*p) ) { - case 95: goto tr297; - case 104: goto st179; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st179: - if ( ++p == pe ) - goto _test_eof179; -case 179: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto st180; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st180: - if ( ++p == pe ) - goto _test_eof180; -case 180: - switch( (*p) ) { - case 95: goto tr297; - case 121: goto st181; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st181: - if ( ++p == pe ) - goto _test_eof181; -case 181: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto st182; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st182: - if ( ++p == pe ) - goto _test_eof182; -case 182: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto tr386; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st183: - if ( ++p == pe ) - goto _test_eof183; -case 183: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st184; - case 114: goto st185; - case 120: goto st186; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st184: - if ( ++p == pe ) - goto _test_eof184; -case 184: - switch( (*p) ) { - case 95: goto tr297; - case 102: goto tr390; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st185: - if ( ++p == pe ) - goto _test_eof185; -case 185: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto tr391; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st186: - if ( ++p == pe ) - goto _test_eof186; -case 186: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto st187; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st187: - if ( ++p == pe ) - goto _test_eof187; -case 187: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st188; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st188: - if ( ++p == pe ) - goto _test_eof188; -case 188: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto st189; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st189: - if ( ++p == pe ) - goto _test_eof189; -case 189: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto tr395; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st190: - if ( ++p == pe ) - goto _test_eof190; -case 190: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto st191; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st191: - if ( ++p == pe ) - goto _test_eof191; -case 191: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st192; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st192: - if ( ++p == pe ) - goto _test_eof192; -case 192: - switch( (*p) ) { - case 95: goto tr297; - case 109: goto tr398; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st193: - if ( ++p == pe ) - goto _test_eof193; -case 193: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st194; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st194: - if ( ++p == pe ) - goto _test_eof194; -case 194: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto st195; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st195: - if ( ++p == pe ) - goto _test_eof195; -case 195: - switch( (*p) ) { - case 95: goto tr297; - case 107: goto st196; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st196: - if ( ++p == pe ) - goto _test_eof196; -case 196: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st197; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st197: - if ( ++p == pe ) - goto _test_eof197; -case 197: - switch( (*p) ) { - case 95: goto tr297; - case 121: goto tr403; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st198: - if ( ++p == pe ) - goto _test_eof198; -case 198: - switch( (*p) ) { - case 95: goto tr297; - case 109: goto st199; - case 110: goto st203; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st199: - if ( ++p == pe ) - goto _test_eof199; -case 199: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto st200; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st200: - if ( ++p == pe ) - goto _test_eof200; -case 200: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st201; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st201: - if ( ++p == pe ) - goto _test_eof201; -case 201: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto st202; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st202: - if ( ++p == pe ) - goto _test_eof202; -case 202: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto tr409; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st203: - if ( ++p == pe ) - goto _test_eof203; -case 203: - switch( (*p) ) { - case 95: goto tr297; - case 99: goto st204; - case 119: goto st208; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st204: - if ( ++p == pe ) - goto _test_eof204; -case 204: - switch( (*p) ) { - case 95: goto tr297; - case 108: goto st205; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st205: - if ( ++p == pe ) - goto _test_eof205; -case 205: - switch( (*p) ) { - case 95: goto tr297; - case 117: goto st206; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st206: - if ( ++p == pe ) - goto _test_eof206; -case 206: - switch( (*p) ) { - case 95: goto tr297; - case 100: goto st207; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st207: - if ( ++p == pe ) - goto _test_eof207; -case 207: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto tr415; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st208: - if ( ++p == pe ) - goto _test_eof208; -case 208: - switch( (*p) ) { - case 95: goto tr297; - case 104: goto st209; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st209: - if ( ++p == pe ) - goto _test_eof209; -case 209: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st210; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st210: - if ( ++p == pe ) - goto _test_eof210; -case 210: - switch( (*p) ) { - case 95: goto tr297; - case 110: goto tr418; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st211: - if ( ++p == pe ) - goto _test_eof211; -case 211: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st212; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st212: - if ( ++p == pe ) - goto _test_eof212; -case 212: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto st213; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st213: - if ( ++p == pe ) - goto _test_eof213; -case 213: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto tr421; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st214: - if ( ++p == pe ) - goto _test_eof214; -case 214: - switch( (*p) ) { - case 95: goto tr297; - case 97: goto st215; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st215: - if ( ++p == pe ) - goto _test_eof215; -case 215: - switch( (*p) ) { - case 95: goto tr297; - case 99: goto st216; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st216: - if ( ++p == pe ) - goto _test_eof216; -case 216: - switch( (*p) ) { - case 95: goto tr297; - case 104: goto st217; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st217: - if ( ++p == pe ) - goto _test_eof217; -case 217: - switch( (*p) ) { - case 95: goto tr297; - case 105: goto st218; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st218: - if ( ++p == pe ) - goto _test_eof218; -case 218: - switch( (*p) ) { - case 95: goto tr297; - case 110: goto st219; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st219: - if ( ++p == pe ) - goto _test_eof219; -case 219: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto tr427; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st220: - if ( ++p == pe ) - goto _test_eof220; -case 220: - switch( (*p) ) { - case 95: goto tr297; - case 117: goto st221; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st221: - if ( ++p == pe ) - goto _test_eof221; -case 221: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto st222; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st222: - if ( ++p == pe ) - goto _test_eof222; -case 222: - switch( (*p) ) { - case 95: goto tr297; - case 119: goto st223; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st223: - if ( ++p == pe ) - goto _test_eof223; -case 223: - switch( (*p) ) { - case 95: goto tr297; - case 104: goto st224; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st224: - if ( ++p == pe ) - goto _test_eof224; -case 224: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st225; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st225: - if ( ++p == pe ) - goto _test_eof225; -case 225: - switch( (*p) ) { - case 95: goto tr297; - case 110: goto tr433; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st226: - if ( ++p == pe ) - goto _test_eof226; -case 226: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st227; - case 114: goto st232; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st227: - if ( ++p == pe ) - goto _test_eof227; -case 227: - switch( (*p) ) { - case 95: goto tr297; - case 115: goto st228; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st228: - if ( ++p == pe ) - goto _test_eof228; -case 228: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto st229; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st229: - if ( ++p == pe ) - goto _test_eof229; -case 229: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto st230; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st230: - if ( ++p == pe ) - goto _test_eof230; -case 230: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto st231; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st231: - if ( ++p == pe ) - goto _test_eof231; -case 231: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto tr440; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st232: - if ( ++p == pe ) - goto _test_eof232; -case 232: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st233; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st233: - if ( ++p == pe ) - goto _test_eof233; -case 233: - switch( (*p) ) { - case 95: goto tr297; - case 112: goto st234; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st234: - if ( ++p == pe ) - goto _test_eof234; -case 234: - switch( (*p) ) { - case 95: goto tr297; - case 117: goto st235; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st235: - if ( ++p == pe ) - goto _test_eof235; -case 235: - switch( (*p) ) { - case 95: goto tr297; - case 115: goto st236; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st236: - if ( ++p == pe ) - goto _test_eof236; -case 236: - switch( (*p) ) { - case 95: goto tr297; - case 104: goto tr445; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st237: - if ( ++p == pe ) - goto _test_eof237; -case 237: - switch( (*p) ) { - case 95: goto tr297; - case 111: goto tr446; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st238: - if ( ++p == pe ) - goto _test_eof238; -case 238: - switch( (*p) ) { - case 95: goto tr297; - case 97: goto st239; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st239: - if ( ++p == pe ) - goto _test_eof239; -case 239: - switch( (*p) ) { - case 95: goto tr297; - case 114: goto st240; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st240: - if ( ++p == pe ) - goto _test_eof240; -case 240: - switch( (*p) ) { - case 95: goto tr297; - case 105: goto st241; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st241: - if ( ++p == pe ) - goto _test_eof241; -case 241: - switch( (*p) ) { - case 95: goto tr297; - case 97: goto st242; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 98 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st242: - if ( ++p == pe ) - goto _test_eof242; -case 242: - switch( (*p) ) { - case 95: goto tr297; - case 98: goto st243; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st243: - if ( ++p == pe ) - goto _test_eof243; -case 243: - switch( (*p) ) { - case 95: goto tr297; - case 108: goto st244; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st244: - if ( ++p == pe ) - goto _test_eof244; -case 244: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto tr453; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st245: - if ( ++p == pe ) - goto _test_eof245; -case 245: - switch( (*p) ) { - case 95: goto tr297; - case 104: goto st246; - case 114: goto st248; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st246: - if ( ++p == pe ) - goto _test_eof246; -case 246: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto st247; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st247: - if ( ++p == pe ) - goto _test_eof247; -case 247: - switch( (*p) ) { - case 95: goto tr297; - case 110: goto tr457; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st248: - if ( ++p == pe ) - goto _test_eof248; -case 248: - switch( (*p) ) { - case 95: goto tr297; - case 105: goto st249; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st249: - if ( ++p == pe ) - goto _test_eof249; -case 249: - switch( (*p) ) { - case 95: goto tr297; - case 116: goto st250; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st250: - if ( ++p == pe ) - goto _test_eof250; -case 250: - switch( (*p) ) { - case 95: goto tr297; - case 101: goto tr460; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr297; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto tr297; - } else - goto tr297; - goto tr370; -st251: - if ( ++p == pe ) - goto _test_eof251; -case 251: - if ( (*p) == 42 ) - goto tr461; - goto tr315; -tr313: +#line 955 "rlscan.rl" + {act = 91;} + goto st167; +st167: + if ( ++p == pe ) + goto _test_eof167; +case 167: +#line 4938 "rlscan.cpp" + if ( (*p) == 95 ) + goto tr297; + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr367; +st168: + if ( ++p == pe ) + goto _test_eof168; +case 168: + if ( (*p) == 94 ) + goto tr369; + goto tr368; +st169: + if ( ++p == pe ) + goto _test_eof169; +case 169: + switch( (*p) ) { + case 95: goto tr297; + case 99: goto st170; + case 108: goto st177; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st170: + if ( ++p == pe ) + goto _test_eof170; +case 170: + switch( (*p) ) { + case 95: goto tr297; + case 99: goto st171; + case 116: goto st174; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st171: + if ( ++p == pe ) + goto _test_eof171; +case 171: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st172; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st172: + if ( ++p == pe ) + goto _test_eof172; +case 172: + switch( (*p) ) { + case 95: goto tr297; + case 115: goto st173; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st173: + if ( ++p == pe ) + goto _test_eof173; +case 173: + switch( (*p) ) { + case 95: goto tr297; + case 115: goto tr377; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st174: + if ( ++p == pe ) + goto _test_eof174; +case 174: + switch( (*p) ) { + case 95: goto tr297; + case 105: goto st175; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st175: + if ( ++p == pe ) + goto _test_eof175; +case 175: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st176; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st176: + if ( ++p == pe ) + goto _test_eof176; +case 176: + switch( (*p) ) { + case 95: goto tr297; + case 110: goto tr380; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st177: + if ( ++p == pe ) + goto _test_eof177; +case 177: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto st178; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st178: + if ( ++p == pe ) + goto _test_eof178; +case 178: + switch( (*p) ) { + case 95: goto tr297; + case 104: goto st179; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st179: + if ( ++p == pe ) + goto _test_eof179; +case 179: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto st180; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st180: + if ( ++p == pe ) + goto _test_eof180; +case 180: + switch( (*p) ) { + case 95: goto tr297; + case 121: goto st181; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st181: + if ( ++p == pe ) + goto _test_eof181; +case 181: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto st182; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st182: + if ( ++p == pe ) + goto _test_eof182; +case 182: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto tr386; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st183: + if ( ++p == pe ) + goto _test_eof183; +case 183: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st184; + case 114: goto st185; + case 120: goto st186; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st184: + if ( ++p == pe ) + goto _test_eof184; +case 184: + switch( (*p) ) { + case 95: goto tr297; + case 102: goto tr390; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st185: + if ( ++p == pe ) + goto _test_eof185; +case 185: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto tr391; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st186: + if ( ++p == pe ) + goto _test_eof186; +case 186: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto st187; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st187: + if ( ++p == pe ) + goto _test_eof187; +case 187: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st188; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st188: + if ( ++p == pe ) + goto _test_eof188; +case 188: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto st189; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st189: + if ( ++p == pe ) + goto _test_eof189; +case 189: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto tr395; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st190: + if ( ++p == pe ) + goto _test_eof190; +case 190: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto st191; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st191: + if ( ++p == pe ) + goto _test_eof191; +case 191: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st192; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st192: + if ( ++p == pe ) + goto _test_eof192; +case 192: + switch( (*p) ) { + case 95: goto tr297; + case 109: goto tr398; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st193: + if ( ++p == pe ) + goto _test_eof193; +case 193: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st194; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st194: + if ( ++p == pe ) + goto _test_eof194; +case 194: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto st195; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st195: + if ( ++p == pe ) + goto _test_eof195; +case 195: + switch( (*p) ) { + case 95: goto tr297; + case 107: goto st196; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st196: + if ( ++p == pe ) + goto _test_eof196; +case 196: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st197; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st197: + if ( ++p == pe ) + goto _test_eof197; +case 197: + switch( (*p) ) { + case 95: goto tr297; + case 121: goto tr403; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st198: + if ( ++p == pe ) + goto _test_eof198; +case 198: + switch( (*p) ) { + case 95: goto tr297; + case 109: goto st199; + case 110: goto st203; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st199: + if ( ++p == pe ) + goto _test_eof199; +case 199: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto st200; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st200: + if ( ++p == pe ) + goto _test_eof200; +case 200: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st201; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st201: + if ( ++p == pe ) + goto _test_eof201; +case 201: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto st202; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st202: + if ( ++p == pe ) + goto _test_eof202; +case 202: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto tr409; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st203: + if ( ++p == pe ) + goto _test_eof203; +case 203: + switch( (*p) ) { + case 95: goto tr297; + case 99: goto st204; + case 119: goto st208; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st204: + if ( ++p == pe ) + goto _test_eof204; +case 204: + switch( (*p) ) { + case 95: goto tr297; + case 108: goto st205; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st205: + if ( ++p == pe ) + goto _test_eof205; +case 205: + switch( (*p) ) { + case 95: goto tr297; + case 117: goto st206; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st206: + if ( ++p == pe ) + goto _test_eof206; +case 206: + switch( (*p) ) { + case 95: goto tr297; + case 100: goto st207; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st207: + if ( ++p == pe ) + goto _test_eof207; +case 207: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto tr415; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st208: + if ( ++p == pe ) + goto _test_eof208; +case 208: + switch( (*p) ) { + case 95: goto tr297; + case 104: goto st209; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st209: + if ( ++p == pe ) + goto _test_eof209; +case 209: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st210; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st210: + if ( ++p == pe ) + goto _test_eof210; +case 210: + switch( (*p) ) { + case 95: goto tr297; + case 110: goto tr418; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st211: + if ( ++p == pe ) + goto _test_eof211; +case 211: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st212; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st212: + if ( ++p == pe ) + goto _test_eof212; +case 212: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto st213; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st213: + if ( ++p == pe ) + goto _test_eof213; +case 213: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto tr421; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st214: + if ( ++p == pe ) + goto _test_eof214; +case 214: + switch( (*p) ) { + case 95: goto tr297; + case 97: goto st215; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st215: + if ( ++p == pe ) + goto _test_eof215; +case 215: + switch( (*p) ) { + case 95: goto tr297; + case 99: goto st216; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st216: + if ( ++p == pe ) + goto _test_eof216; +case 216: + switch( (*p) ) { + case 95: goto tr297; + case 104: goto st217; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st217: + if ( ++p == pe ) + goto _test_eof217; +case 217: + switch( (*p) ) { + case 95: goto tr297; + case 105: goto st218; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st218: + if ( ++p == pe ) + goto _test_eof218; +case 218: + switch( (*p) ) { + case 95: goto tr297; + case 110: goto st219; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st219: + if ( ++p == pe ) + goto _test_eof219; +case 219: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto tr427; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st220: + if ( ++p == pe ) + goto _test_eof220; +case 220: + switch( (*p) ) { + case 95: goto tr297; + case 117: goto st221; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st221: + if ( ++p == pe ) + goto _test_eof221; +case 221: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto st222; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st222: + if ( ++p == pe ) + goto _test_eof222; +case 222: + switch( (*p) ) { + case 95: goto tr297; + case 119: goto st223; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st223: + if ( ++p == pe ) + goto _test_eof223; +case 223: + switch( (*p) ) { + case 95: goto tr297; + case 104: goto st224; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st224: + if ( ++p == pe ) + goto _test_eof224; +case 224: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st225; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st225: + if ( ++p == pe ) + goto _test_eof225; +case 225: + switch( (*p) ) { + case 95: goto tr297; + case 110: goto tr433; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st226: + if ( ++p == pe ) + goto _test_eof226; +case 226: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st227; + case 114: goto st232; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st227: + if ( ++p == pe ) + goto _test_eof227; +case 227: + switch( (*p) ) { + case 95: goto tr297; + case 115: goto st228; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st228: + if ( ++p == pe ) + goto _test_eof228; +case 228: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto st229; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st229: + if ( ++p == pe ) + goto _test_eof229; +case 229: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto st230; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st230: + if ( ++p == pe ) + goto _test_eof230; +case 230: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto st231; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st231: + if ( ++p == pe ) + goto _test_eof231; +case 231: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto tr440; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st232: + if ( ++p == pe ) + goto _test_eof232; +case 232: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st233; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st233: + if ( ++p == pe ) + goto _test_eof233; +case 233: + switch( (*p) ) { + case 95: goto tr297; + case 112: goto st234; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st234: + if ( ++p == pe ) + goto _test_eof234; +case 234: + switch( (*p) ) { + case 95: goto tr297; + case 117: goto st235; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st235: + if ( ++p == pe ) + goto _test_eof235; +case 235: + switch( (*p) ) { + case 95: goto tr297; + case 115: goto st236; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st236: + if ( ++p == pe ) + goto _test_eof236; +case 236: + switch( (*p) ) { + case 95: goto tr297; + case 104: goto tr445; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st237: + if ( ++p == pe ) + goto _test_eof237; +case 237: + switch( (*p) ) { + case 95: goto tr297; + case 111: goto tr446; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st238: + if ( ++p == pe ) + goto _test_eof238; +case 238: + switch( (*p) ) { + case 95: goto tr297; + case 97: goto st239; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st239: + if ( ++p == pe ) + goto _test_eof239; +case 239: + switch( (*p) ) { + case 95: goto tr297; + case 114: goto st240; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st240: + if ( ++p == pe ) + goto _test_eof240; +case 240: + switch( (*p) ) { + case 95: goto tr297; + case 105: goto st241; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st241: + if ( ++p == pe ) + goto _test_eof241; +case 241: + switch( (*p) ) { + case 95: goto tr297; + case 97: goto st242; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 98 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st242: + if ( ++p == pe ) + goto _test_eof242; +case 242: + switch( (*p) ) { + case 95: goto tr297; + case 98: goto st243; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st243: + if ( ++p == pe ) + goto _test_eof243; +case 243: + switch( (*p) ) { + case 95: goto tr297; + case 108: goto st244; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st244: + if ( ++p == pe ) + goto _test_eof244; +case 244: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto tr453; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st245: + if ( ++p == pe ) + goto _test_eof245; +case 245: + switch( (*p) ) { + case 95: goto tr297; + case 104: goto st246; + case 114: goto st248; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st246: + if ( ++p == pe ) + goto _test_eof246; +case 246: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto st247; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st247: + if ( ++p == pe ) + goto _test_eof247; +case 247: + switch( (*p) ) { + case 95: goto tr297; + case 110: goto tr457; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st248: + if ( ++p == pe ) + goto _test_eof248; +case 248: + switch( (*p) ) { + case 95: goto tr297; + case 105: goto st249; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st249: + if ( ++p == pe ) + goto _test_eof249; +case 249: + switch( (*p) ) { + case 95: goto tr297; + case 116: goto st250; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st250: + if ( ++p == pe ) + goto _test_eof250; +case 250: + switch( (*p) ) { + case 95: goto tr297; + case 101: goto tr460; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr297; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto tr297; + } else + goto tr297; + goto tr370; +st251: + if ( ++p == pe ) + goto _test_eof251; +case 251: + if ( (*p) == 42 ) + goto tr461; + goto tr315; +tr313: #line 1 "NONE" {te = p+1;} - goto st252; -st252: - if ( ++p == pe ) - goto _test_eof252; -case 252: -#line 6374 "rlscan.cpp" - if ( (*p) == 37 ) - goto st30; - goto tr315; -st30: - if ( ++p == pe ) - goto _test_eof30; -case 30: - if ( (*p) == 37 ) - goto tr57; - goto tr45; -tr58: -#line 1146 "rlscan.rl" - {{p = ((te))-1;}{ pass( *ts, 0, 0 ); }} - goto st253; -tr61: -#line 1130 "rlscan.rl" - {te = p+1;{ pass( IMP_Literal, ts, te ); }} - goto st253; -tr64: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } -#line 1128 "rlscan.rl" - {te = p+1;{ pass(); }} - goto st253; -tr463: -#line 1146 "rlscan.rl" - {te = p+1;{ pass( *ts, 0, 0 ); }} - goto st253; -tr464: -#line 1145 "rlscan.rl" + goto st252; +st252: + if ( ++p == pe ) + goto _test_eof252; +case 252: +#line 6374 "rlscan.cpp" + if ( (*p) == 37 ) + goto st30; + goto tr315; +st30: + if ( ++p == pe ) + goto _test_eof30; +case 30: + if ( (*p) == 37 ) + goto tr57; + goto tr45; +tr58: +#line 1146 "rlscan.rl" + {{p = ((te))-1;}{ pass( *ts, 0, 0 ); }} + goto st253; +tr61: +#line 1130 "rlscan.rl" + {te = p+1;{ pass( IMP_Literal, ts, te ); }} + goto st253; +tr64: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } +#line 1128 "rlscan.rl" + {te = p+1;{ pass(); }} + goto st253; +tr463: +#line 1146 "rlscan.rl" + {te = p+1;{ pass( *ts, 0, 0 ); }} + goto st253; +tr464: +#line 1145 "rlscan.rl" {te = p+1;} - goto st253; -tr474: -#line 1144 "rlscan.rl" - {te = p;p--;{ pass(); }} - goto st253; -tr475: -#line 1146 "rlscan.rl" - {te = p;p--;{ pass( *ts, 0, 0 ); }} - goto st253; -tr477: -#line 1138 "rlscan.rl" - {te = p;p--;{ - updateCol(); - singleLineSpec = true; - startSection(); - {stack[top++] = 253; goto st146;} - }} - goto st253; -tr478: -#line 1132 "rlscan.rl" - {te = p+1;{ - updateCol(); - singleLineSpec = false; - startSection(); - {stack[top++] = 253; goto st146;} - }} - goto st253; -tr479: -#line 1127 "rlscan.rl" - {te = p;p--;{ pass( IMP_UInt, ts, te ); }} - goto st253; -tr480: -#line 1126 "rlscan.rl" - {te = p;p--;{ pass( IMP_Word, ts, te ); }} - goto st253; -st253: + goto st253; +tr474: +#line 1144 "rlscan.rl" + {te = p;p--;{ pass(); }} + goto st253; +tr475: +#line 1146 "rlscan.rl" + {te = p;p--;{ pass( *ts, 0, 0 ); }} + goto st253; +tr477: +#line 1138 "rlscan.rl" + {te = p;p--;{ + updateCol(); + singleLineSpec = true; + startSection(); + {stack[top++] = 253; goto st146;} + }} + goto st253; +tr478: +#line 1132 "rlscan.rl" + {te = p+1;{ + updateCol(); + singleLineSpec = false; + startSection(); + {stack[top++] = 253; goto st146;} + }} + goto st253; +tr479: +#line 1127 "rlscan.rl" + {te = p;p--;{ pass( IMP_UInt, ts, te ); }} + goto st253; +tr480: +#line 1126 "rlscan.rl" + {te = p;p--;{ pass( IMP_Word, ts, te ); }} + goto st253; +st253: #line 1 "NONE" - {ts = 0;} - if ( ++p == pe ) - goto _test_eof253; -case 253: + {ts = 0;} + if ( ++p == pe ) + goto _test_eof253; +case 253: #line 1 "NONE" - {ts = p;} -#line 6453 "rlscan.cpp" - switch( (*p) ) { - case 0: goto tr464; - case 9: goto st254; - case 10: goto tr466; - case 32: goto st254; - case 34: goto tr467; - case 35: goto tr468; - case 37: goto st257; - case 39: goto tr470; - case 47: goto tr471; - case 95: goto st262; - } - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st261; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto st262; - } else - goto st262; - goto tr463; -tr466: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st254; -st254: - if ( ++p == pe ) - goto _test_eof254; -case 254: -#line 6487 "rlscan.cpp" - switch( (*p) ) { - case 9: goto st254; - case 10: goto tr466; - case 32: goto st254; - } - goto tr474; -tr467: + {ts = p;} +#line 6453 "rlscan.cpp" + switch( (*p) ) { + case 0: goto tr464; + case 9: goto st254; + case 10: goto tr466; + case 32: goto st254; + case 34: goto tr467; + case 35: goto tr468; + case 37: goto st257; + case 39: goto tr470; + case 47: goto tr471; + case 95: goto st262; + } + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st261; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto st262; + } else + goto st262; + goto tr463; +tr466: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st254; +st254: + if ( ++p == pe ) + goto _test_eof254; +case 254: +#line 6487 "rlscan.cpp" + switch( (*p) ) { + case 9: goto st254; + case 10: goto tr466; + case 32: goto st254; + } + goto tr474; +tr467: #line 1 "NONE" {te = p+1;} - goto st255; -st255: - if ( ++p == pe ) - goto _test_eof255; -case 255: -#line 6502 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr60; - case 34: goto tr61; - case 92: goto st32; - } - goto st31; -tr60: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st31; -st31: - if ( ++p == pe ) - goto _test_eof31; -case 31: -#line 6521 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr60; - case 34: goto tr61; - case 92: goto st32; - } - goto st31; -st32: - if ( ++p == pe ) - goto _test_eof32; -case 32: - if ( (*p) == 10 ) - goto tr60; - goto st31; -tr468: + goto st255; +st255: + if ( ++p == pe ) + goto _test_eof255; +case 255: +#line 6502 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr60; + case 34: goto tr61; + case 92: goto st32; + } + goto st31; +tr60: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st31; +st31: + if ( ++p == pe ) + goto _test_eof31; +case 31: +#line 6521 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr60; + case 34: goto tr61; + case 92: goto st32; + } + goto st31; +st32: + if ( ++p == pe ) + goto _test_eof32; +case 32: + if ( (*p) == 10 ) + goto tr60; + goto st31; +tr468: #line 1 "NONE" {te = p+1;} - goto st256; -st256: - if ( ++p == pe ) - goto _test_eof256; -case 256: -#line 6543 "rlscan.cpp" - if ( (*p) == 10 ) - goto tr64; - goto st33; -st33: - if ( ++p == pe ) - goto _test_eof33; -case 33: - if ( (*p) == 10 ) - goto tr64; - goto st33; -st257: - if ( ++p == pe ) - goto _test_eof257; -case 257: - if ( (*p) == 37 ) - goto st258; - goto tr475; -st258: - if ( ++p == pe ) - goto _test_eof258; -case 258: - if ( (*p) == 123 ) - goto tr478; - goto tr477; -tr470: + goto st256; +st256: + if ( ++p == pe ) + goto _test_eof256; +case 256: +#line 6543 "rlscan.cpp" + if ( (*p) == 10 ) + goto tr64; + goto st33; +st33: + if ( ++p == pe ) + goto _test_eof33; +case 33: + if ( (*p) == 10 ) + goto tr64; + goto st33; +st257: + if ( ++p == pe ) + goto _test_eof257; +case 257: + if ( (*p) == 37 ) + goto st258; + goto tr475; +st258: + if ( ++p == pe ) + goto _test_eof258; +case 258: + if ( (*p) == 123 ) + goto tr478; + goto tr477; +tr470: #line 1 "NONE" {te = p+1;} - goto st259; -st259: - if ( ++p == pe ) - goto _test_eof259; -case 259: -#line 6576 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr66; - case 39: goto tr61; - case 92: goto st35; - } - goto st34; -tr66: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st34; -st34: - if ( ++p == pe ) - goto _test_eof34; -case 34: -#line 6595 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr66; - case 39: goto tr61; - case 92: goto st35; - } - goto st34; -st35: - if ( ++p == pe ) - goto _test_eof35; -case 35: - if ( (*p) == 10 ) - goto tr66; - goto st34; -tr471: + goto st259; +st259: + if ( ++p == pe ) + goto _test_eof259; +case 259: +#line 6576 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr66; + case 39: goto tr61; + case 92: goto st35; + } + goto st34; +tr66: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st34; +st34: + if ( ++p == pe ) + goto _test_eof34; +case 34: +#line 6595 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr66; + case 39: goto tr61; + case 92: goto st35; + } + goto st34; +st35: + if ( ++p == pe ) + goto _test_eof35; +case 35: + if ( (*p) == 10 ) + goto tr66; + goto st34; +tr471: #line 1 "NONE" {te = p+1;} - goto st260; -st260: - if ( ++p == pe ) - goto _test_eof260; -case 260: -#line 6617 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr69; - case 47: goto tr61; - case 92: goto st37; - } - goto st36; -tr69: -#line 641 "rlscan.rl" - { - lastnl = p; - column = 0; - line++; - } - goto st36; -st36: - if ( ++p == pe ) - goto _test_eof36; -case 36: -#line 6636 "rlscan.cpp" - switch( (*p) ) { - case 10: goto tr69; - case 47: goto tr61; - case 92: goto st37; - } - goto st36; -st37: - if ( ++p == pe ) - goto _test_eof37; -case 37: - if ( (*p) == 10 ) - goto tr69; - goto st36; -st261: - if ( ++p == pe ) - goto _test_eof261; -case 261: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st261; - goto tr479; -st262: - if ( ++p == pe ) - goto _test_eof262; -case 262: - if ( (*p) == 95 ) - goto st262; - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st262; - } else if ( (*p) > 90 ) { - if ( 97 <= (*p) && (*p) <= 122 ) - goto st262; - } else - goto st262; - goto tr480; - } - _test_eof38: cs = 38; goto _test_eof; - _test_eof39: cs = 39; goto _test_eof; - _test_eof40: cs = 40; goto _test_eof; - _test_eof1: cs = 1; goto _test_eof; - _test_eof2: cs = 2; goto _test_eof; - _test_eof41: cs = 41; goto _test_eof; - _test_eof42: cs = 42; goto _test_eof; - _test_eof43: cs = 43; goto _test_eof; - _test_eof3: cs = 3; goto _test_eof; - _test_eof4: cs = 4; goto _test_eof; - _test_eof44: cs = 44; goto _test_eof; - _test_eof5: cs = 5; goto _test_eof; - _test_eof6: cs = 6; goto _test_eof; - _test_eof7: cs = 7; goto _test_eof; - _test_eof45: cs = 45; goto _test_eof; - _test_eof46: cs = 46; goto _test_eof; - _test_eof47: cs = 47; goto _test_eof; - _test_eof48: cs = 48; goto _test_eof; - _test_eof49: cs = 49; goto _test_eof; - _test_eof50: cs = 50; goto _test_eof; - _test_eof51: cs = 51; goto _test_eof; - _test_eof52: cs = 52; goto _test_eof; - _test_eof53: cs = 53; goto _test_eof; - _test_eof54: cs = 54; goto _test_eof; - _test_eof8: cs = 8; goto _test_eof; - _test_eof9: cs = 9; goto _test_eof; - _test_eof55: cs = 55; goto _test_eof; - _test_eof10: cs = 10; goto _test_eof; - _test_eof56: cs = 56; goto _test_eof; - _test_eof11: cs = 11; goto _test_eof; - _test_eof12: cs = 12; goto _test_eof; - _test_eof57: cs = 57; goto _test_eof; - _test_eof13: cs = 13; goto _test_eof; - _test_eof14: cs = 14; goto _test_eof; - _test_eof58: cs = 58; goto _test_eof; - _test_eof59: cs = 59; goto _test_eof; - _test_eof15: cs = 15; goto _test_eof; - _test_eof60: cs = 60; goto _test_eof; - _test_eof61: cs = 61; goto _test_eof; - _test_eof62: cs = 62; goto _test_eof; - _test_eof63: cs = 63; goto _test_eof; - _test_eof64: cs = 64; goto _test_eof; - _test_eof65: cs = 65; goto _test_eof; - _test_eof66: cs = 66; goto _test_eof; - _test_eof67: cs = 67; goto _test_eof; - _test_eof68: cs = 68; goto _test_eof; - _test_eof69: cs = 69; goto _test_eof; - _test_eof70: cs = 70; goto _test_eof; - _test_eof71: cs = 71; goto _test_eof; - _test_eof72: cs = 72; goto _test_eof; - _test_eof73: cs = 73; goto _test_eof; - _test_eof74: cs = 74; goto _test_eof; - _test_eof75: cs = 75; goto _test_eof; - _test_eof76: cs = 76; goto _test_eof; - _test_eof77: cs = 77; goto _test_eof; - _test_eof78: cs = 78; goto _test_eof; - _test_eof79: cs = 79; goto _test_eof; - _test_eof80: cs = 80; goto _test_eof; - _test_eof81: cs = 81; goto _test_eof; - _test_eof82: cs = 82; goto _test_eof; - _test_eof83: cs = 83; goto _test_eof; - _test_eof84: cs = 84; goto _test_eof; - _test_eof85: cs = 85; goto _test_eof; - _test_eof86: cs = 86; goto _test_eof; - _test_eof87: cs = 87; goto _test_eof; - _test_eof88: cs = 88; goto _test_eof; - _test_eof89: cs = 89; goto _test_eof; - _test_eof90: cs = 90; goto _test_eof; - _test_eof91: cs = 91; goto _test_eof; - _test_eof92: cs = 92; goto _test_eof; - _test_eof93: cs = 93; goto _test_eof; - _test_eof94: cs = 94; goto _test_eof; - _test_eof95: cs = 95; goto _test_eof; - _test_eof96: cs = 96; goto _test_eof; - _test_eof97: cs = 97; goto _test_eof; - _test_eof16: cs = 16; goto _test_eof; - _test_eof17: cs = 17; goto _test_eof; - _test_eof98: cs = 98; goto _test_eof; - _test_eof18: cs = 18; goto _test_eof; - _test_eof19: cs = 19; goto _test_eof; - _test_eof99: cs = 99; goto _test_eof; - _test_eof20: cs = 20; goto _test_eof; - _test_eof21: cs = 21; goto _test_eof; - _test_eof22: cs = 22; goto _test_eof; - _test_eof100: cs = 100; goto _test_eof; - _test_eof101: cs = 101; goto _test_eof; - _test_eof23: cs = 23; goto _test_eof; - _test_eof102: cs = 102; goto _test_eof; - _test_eof103: cs = 103; goto _test_eof; - _test_eof104: cs = 104; goto _test_eof; - _test_eof105: cs = 105; goto _test_eof; - _test_eof106: cs = 106; goto _test_eof; - _test_eof107: cs = 107; goto _test_eof; - _test_eof108: cs = 108; goto _test_eof; - _test_eof109: cs = 109; goto _test_eof; - _test_eof110: cs = 110; goto _test_eof; - _test_eof111: cs = 111; goto _test_eof; - _test_eof112: cs = 112; goto _test_eof; - _test_eof113: cs = 113; goto _test_eof; - _test_eof114: cs = 114; goto _test_eof; - _test_eof115: cs = 115; goto _test_eof; - _test_eof116: cs = 116; goto _test_eof; - _test_eof117: cs = 117; goto _test_eof; - _test_eof118: cs = 118; goto _test_eof; - _test_eof119: cs = 119; goto _test_eof; - _test_eof120: cs = 120; goto _test_eof; - _test_eof121: cs = 121; goto _test_eof; - _test_eof122: cs = 122; goto _test_eof; - _test_eof123: cs = 123; goto _test_eof; - _test_eof124: cs = 124; goto _test_eof; - _test_eof125: cs = 125; goto _test_eof; - _test_eof126: cs = 126; goto _test_eof; - _test_eof127: cs = 127; goto _test_eof; - _test_eof128: cs = 128; goto _test_eof; - _test_eof129: cs = 129; goto _test_eof; - _test_eof130: cs = 130; goto _test_eof; - _test_eof131: cs = 131; goto _test_eof; - _test_eof132: cs = 132; goto _test_eof; - _test_eof133: cs = 133; goto _test_eof; - _test_eof134: cs = 134; goto _test_eof; - _test_eof135: cs = 135; goto _test_eof; - _test_eof136: cs = 136; goto _test_eof; - _test_eof137: cs = 137; goto _test_eof; - _test_eof138: cs = 138; goto _test_eof; - _test_eof139: cs = 139; goto _test_eof; - _test_eof140: cs = 140; goto _test_eof; - _test_eof141: cs = 141; goto _test_eof; - _test_eof142: cs = 142; goto _test_eof; - _test_eof143: cs = 143; goto _test_eof; - _test_eof144: cs = 144; goto _test_eof; - _test_eof145: cs = 145; goto _test_eof; - _test_eof146: cs = 146; goto _test_eof; - _test_eof147: cs = 147; goto _test_eof; - _test_eof148: cs = 148; goto _test_eof; - _test_eof24: cs = 24; goto _test_eof; - _test_eof149: cs = 149; goto _test_eof; - _test_eof25: cs = 25; goto _test_eof; - _test_eof150: cs = 150; goto _test_eof; - _test_eof26: cs = 26; goto _test_eof; - _test_eof151: cs = 151; goto _test_eof; - _test_eof152: cs = 152; goto _test_eof; - _test_eof153: cs = 153; goto _test_eof; - _test_eof27: cs = 27; goto _test_eof; - _test_eof28: cs = 28; goto _test_eof; - _test_eof154: cs = 154; goto _test_eof; - _test_eof155: cs = 155; goto _test_eof; - _test_eof156: cs = 156; goto _test_eof; - _test_eof157: cs = 157; goto _test_eof; - _test_eof158: cs = 158; goto _test_eof; - _test_eof29: cs = 29; goto _test_eof; - _test_eof159: cs = 159; goto _test_eof; - _test_eof160: cs = 160; goto _test_eof; - _test_eof161: cs = 161; goto _test_eof; - _test_eof162: cs = 162; goto _test_eof; - _test_eof163: cs = 163; goto _test_eof; - _test_eof164: cs = 164; goto _test_eof; - _test_eof165: cs = 165; goto _test_eof; - _test_eof166: cs = 166; goto _test_eof; - _test_eof167: cs = 167; goto _test_eof; - _test_eof168: cs = 168; goto _test_eof; - _test_eof169: cs = 169; goto _test_eof; - _test_eof170: cs = 170; goto _test_eof; - _test_eof171: cs = 171; goto _test_eof; - _test_eof172: cs = 172; goto _test_eof; - _test_eof173: cs = 173; goto _test_eof; - _test_eof174: cs = 174; goto _test_eof; - _test_eof175: cs = 175; goto _test_eof; - _test_eof176: cs = 176; goto _test_eof; - _test_eof177: cs = 177; goto _test_eof; - _test_eof178: cs = 178; goto _test_eof; - _test_eof179: cs = 179; goto _test_eof; - _test_eof180: cs = 180; goto _test_eof; - _test_eof181: cs = 181; goto _test_eof; - _test_eof182: cs = 182; goto _test_eof; - _test_eof183: cs = 183; goto _test_eof; - _test_eof184: cs = 184; goto _test_eof; - _test_eof185: cs = 185; goto _test_eof; - _test_eof186: cs = 186; goto _test_eof; - _test_eof187: cs = 187; goto _test_eof; - _test_eof188: cs = 188; goto _test_eof; - _test_eof189: cs = 189; goto _test_eof; - _test_eof190: cs = 190; goto _test_eof; - _test_eof191: cs = 191; goto _test_eof; - _test_eof192: cs = 192; goto _test_eof; - _test_eof193: cs = 193; goto _test_eof; - _test_eof194: cs = 194; goto _test_eof; - _test_eof195: cs = 195; goto _test_eof; - _test_eof196: cs = 196; goto _test_eof; - _test_eof197: cs = 197; goto _test_eof; - _test_eof198: cs = 198; goto _test_eof; - _test_eof199: cs = 199; goto _test_eof; - _test_eof200: cs = 200; goto _test_eof; - _test_eof201: cs = 201; goto _test_eof; - _test_eof202: cs = 202; goto _test_eof; - _test_eof203: cs = 203; goto _test_eof; - _test_eof204: cs = 204; goto _test_eof; - _test_eof205: cs = 205; goto _test_eof; - _test_eof206: cs = 206; goto _test_eof; - _test_eof207: cs = 207; goto _test_eof; - _test_eof208: cs = 208; goto _test_eof; - _test_eof209: cs = 209; goto _test_eof; - _test_eof210: cs = 210; goto _test_eof; - _test_eof211: cs = 211; goto _test_eof; - _test_eof212: cs = 212; goto _test_eof; - _test_eof213: cs = 213; goto _test_eof; - _test_eof214: cs = 214; goto _test_eof; - _test_eof215: cs = 215; goto _test_eof; - _test_eof216: cs = 216; goto _test_eof; - _test_eof217: cs = 217; goto _test_eof; - _test_eof218: cs = 218; goto _test_eof; - _test_eof219: cs = 219; goto _test_eof; - _test_eof220: cs = 220; goto _test_eof; - _test_eof221: cs = 221; goto _test_eof; - _test_eof222: cs = 222; goto _test_eof; - _test_eof223: cs = 223; goto _test_eof; - _test_eof224: cs = 224; goto _test_eof; - _test_eof225: cs = 225; goto _test_eof; - _test_eof226: cs = 226; goto _test_eof; - _test_eof227: cs = 227; goto _test_eof; - _test_eof228: cs = 228; goto _test_eof; - _test_eof229: cs = 229; goto _test_eof; - _test_eof230: cs = 230; goto _test_eof; - _test_eof231: cs = 231; goto _test_eof; - _test_eof232: cs = 232; goto _test_eof; - _test_eof233: cs = 233; goto _test_eof; - _test_eof234: cs = 234; goto _test_eof; - _test_eof235: cs = 235; goto _test_eof; - _test_eof236: cs = 236; goto _test_eof; - _test_eof237: cs = 237; goto _test_eof; - _test_eof238: cs = 238; goto _test_eof; - _test_eof239: cs = 239; goto _test_eof; - _test_eof240: cs = 240; goto _test_eof; - _test_eof241: cs = 241; goto _test_eof; - _test_eof242: cs = 242; goto _test_eof; - _test_eof243: cs = 243; goto _test_eof; - _test_eof244: cs = 244; goto _test_eof; - _test_eof245: cs = 245; goto _test_eof; - _test_eof246: cs = 246; goto _test_eof; - _test_eof247: cs = 247; goto _test_eof; - _test_eof248: cs = 248; goto _test_eof; - _test_eof249: cs = 249; goto _test_eof; - _test_eof250: cs = 250; goto _test_eof; - _test_eof251: cs = 251; goto _test_eof; - _test_eof252: cs = 252; goto _test_eof; - _test_eof30: cs = 30; goto _test_eof; - _test_eof253: cs = 253; goto _test_eof; - _test_eof254: cs = 254; goto _test_eof; - _test_eof255: cs = 255; goto _test_eof; - _test_eof31: cs = 31; goto _test_eof; - _test_eof32: cs = 32; goto _test_eof; - _test_eof256: cs = 256; goto _test_eof; - _test_eof33: cs = 33; goto _test_eof; - _test_eof257: cs = 257; goto _test_eof; - _test_eof258: cs = 258; goto _test_eof; - _test_eof259: cs = 259; goto _test_eof; - _test_eof34: cs = 34; goto _test_eof; - _test_eof35: cs = 35; goto _test_eof; - _test_eof260: cs = 260; goto _test_eof; - _test_eof36: cs = 36; goto _test_eof; - _test_eof37: cs = 37; goto _test_eof; - _test_eof261: cs = 261; goto _test_eof; - _test_eof262: cs = 262; goto _test_eof; + goto st260; +st260: + if ( ++p == pe ) + goto _test_eof260; +case 260: +#line 6617 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr69; + case 47: goto tr61; + case 92: goto st37; + } + goto st36; +tr69: +#line 641 "rlscan.rl" + { + lastnl = p; + column = 0; + line++; + } + goto st36; +st36: + if ( ++p == pe ) + goto _test_eof36; +case 36: +#line 6636 "rlscan.cpp" + switch( (*p) ) { + case 10: goto tr69; + case 47: goto tr61; + case 92: goto st37; + } + goto st36; +st37: + if ( ++p == pe ) + goto _test_eof37; +case 37: + if ( (*p) == 10 ) + goto tr69; + goto st36; +st261: + if ( ++p == pe ) + goto _test_eof261; +case 261: + if ( 48 <= (*p) && (*p) <= 57 ) + goto st261; + goto tr479; +st262: + if ( ++p == pe ) + goto _test_eof262; +case 262: + if ( (*p) == 95 ) + goto st262; + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st262; + } else if ( (*p) > 90 ) { + if ( 97 <= (*p) && (*p) <= 122 ) + goto st262; + } else + goto st262; + goto tr480; + } + _test_eof38: cs = 38; goto _test_eof; + _test_eof39: cs = 39; goto _test_eof; + _test_eof40: cs = 40; goto _test_eof; + _test_eof1: cs = 1; goto _test_eof; + _test_eof2: cs = 2; goto _test_eof; + _test_eof41: cs = 41; goto _test_eof; + _test_eof42: cs = 42; goto _test_eof; + _test_eof43: cs = 43; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof44: cs = 44; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + _test_eof45: cs = 45; goto _test_eof; + _test_eof46: cs = 46; goto _test_eof; + _test_eof47: cs = 47; goto _test_eof; + _test_eof48: cs = 48; goto _test_eof; + _test_eof49: cs = 49; goto _test_eof; + _test_eof50: cs = 50; goto _test_eof; + _test_eof51: cs = 51; goto _test_eof; + _test_eof52: cs = 52; goto _test_eof; + _test_eof53: cs = 53; goto _test_eof; + _test_eof54: cs = 54; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; + _test_eof55: cs = 55; goto _test_eof; + _test_eof10: cs = 10; goto _test_eof; + _test_eof56: cs = 56; goto _test_eof; + _test_eof11: cs = 11; goto _test_eof; + _test_eof12: cs = 12; goto _test_eof; + _test_eof57: cs = 57; goto _test_eof; + _test_eof13: cs = 13; goto _test_eof; + _test_eof14: cs = 14; goto _test_eof; + _test_eof58: cs = 58; goto _test_eof; + _test_eof59: cs = 59; goto _test_eof; + _test_eof15: cs = 15; goto _test_eof; + _test_eof60: cs = 60; goto _test_eof; + _test_eof61: cs = 61; goto _test_eof; + _test_eof62: cs = 62; goto _test_eof; + _test_eof63: cs = 63; goto _test_eof; + _test_eof64: cs = 64; goto _test_eof; + _test_eof65: cs = 65; goto _test_eof; + _test_eof66: cs = 66; goto _test_eof; + _test_eof67: cs = 67; goto _test_eof; + _test_eof68: cs = 68; goto _test_eof; + _test_eof69: cs = 69; goto _test_eof; + _test_eof70: cs = 70; goto _test_eof; + _test_eof71: cs = 71; goto _test_eof; + _test_eof72: cs = 72; goto _test_eof; + _test_eof73: cs = 73; goto _test_eof; + _test_eof74: cs = 74; goto _test_eof; + _test_eof75: cs = 75; goto _test_eof; + _test_eof76: cs = 76; goto _test_eof; + _test_eof77: cs = 77; goto _test_eof; + _test_eof78: cs = 78; goto _test_eof; + _test_eof79: cs = 79; goto _test_eof; + _test_eof80: cs = 80; goto _test_eof; + _test_eof81: cs = 81; goto _test_eof; + _test_eof82: cs = 82; goto _test_eof; + _test_eof83: cs = 83; goto _test_eof; + _test_eof84: cs = 84; goto _test_eof; + _test_eof85: cs = 85; goto _test_eof; + _test_eof86: cs = 86; goto _test_eof; + _test_eof87: cs = 87; goto _test_eof; + _test_eof88: cs = 88; goto _test_eof; + _test_eof89: cs = 89; goto _test_eof; + _test_eof90: cs = 90; goto _test_eof; + _test_eof91: cs = 91; goto _test_eof; + _test_eof92: cs = 92; goto _test_eof; + _test_eof93: cs = 93; goto _test_eof; + _test_eof94: cs = 94; goto _test_eof; + _test_eof95: cs = 95; goto _test_eof; + _test_eof96: cs = 96; goto _test_eof; + _test_eof97: cs = 97; goto _test_eof; + _test_eof16: cs = 16; goto _test_eof; + _test_eof17: cs = 17; goto _test_eof; + _test_eof98: cs = 98; goto _test_eof; + _test_eof18: cs = 18; goto _test_eof; + _test_eof19: cs = 19; goto _test_eof; + _test_eof99: cs = 99; goto _test_eof; + _test_eof20: cs = 20; goto _test_eof; + _test_eof21: cs = 21; goto _test_eof; + _test_eof22: cs = 22; goto _test_eof; + _test_eof100: cs = 100; goto _test_eof; + _test_eof101: cs = 101; goto _test_eof; + _test_eof23: cs = 23; goto _test_eof; + _test_eof102: cs = 102; goto _test_eof; + _test_eof103: cs = 103; goto _test_eof; + _test_eof104: cs = 104; goto _test_eof; + _test_eof105: cs = 105; goto _test_eof; + _test_eof106: cs = 106; goto _test_eof; + _test_eof107: cs = 107; goto _test_eof; + _test_eof108: cs = 108; goto _test_eof; + _test_eof109: cs = 109; goto _test_eof; + _test_eof110: cs = 110; goto _test_eof; + _test_eof111: cs = 111; goto _test_eof; + _test_eof112: cs = 112; goto _test_eof; + _test_eof113: cs = 113; goto _test_eof; + _test_eof114: cs = 114; goto _test_eof; + _test_eof115: cs = 115; goto _test_eof; + _test_eof116: cs = 116; goto _test_eof; + _test_eof117: cs = 117; goto _test_eof; + _test_eof118: cs = 118; goto _test_eof; + _test_eof119: cs = 119; goto _test_eof; + _test_eof120: cs = 120; goto _test_eof; + _test_eof121: cs = 121; goto _test_eof; + _test_eof122: cs = 122; goto _test_eof; + _test_eof123: cs = 123; goto _test_eof; + _test_eof124: cs = 124; goto _test_eof; + _test_eof125: cs = 125; goto _test_eof; + _test_eof126: cs = 126; goto _test_eof; + _test_eof127: cs = 127; goto _test_eof; + _test_eof128: cs = 128; goto _test_eof; + _test_eof129: cs = 129; goto _test_eof; + _test_eof130: cs = 130; goto _test_eof; + _test_eof131: cs = 131; goto _test_eof; + _test_eof132: cs = 132; goto _test_eof; + _test_eof133: cs = 133; goto _test_eof; + _test_eof134: cs = 134; goto _test_eof; + _test_eof135: cs = 135; goto _test_eof; + _test_eof136: cs = 136; goto _test_eof; + _test_eof137: cs = 137; goto _test_eof; + _test_eof138: cs = 138; goto _test_eof; + _test_eof139: cs = 139; goto _test_eof; + _test_eof140: cs = 140; goto _test_eof; + _test_eof141: cs = 141; goto _test_eof; + _test_eof142: cs = 142; goto _test_eof; + _test_eof143: cs = 143; goto _test_eof; + _test_eof144: cs = 144; goto _test_eof; + _test_eof145: cs = 145; goto _test_eof; + _test_eof146: cs = 146; goto _test_eof; + _test_eof147: cs = 147; goto _test_eof; + _test_eof148: cs = 148; goto _test_eof; + _test_eof24: cs = 24; goto _test_eof; + _test_eof149: cs = 149; goto _test_eof; + _test_eof25: cs = 25; goto _test_eof; + _test_eof150: cs = 150; goto _test_eof; + _test_eof26: cs = 26; goto _test_eof; + _test_eof151: cs = 151; goto _test_eof; + _test_eof152: cs = 152; goto _test_eof; + _test_eof153: cs = 153; goto _test_eof; + _test_eof27: cs = 27; goto _test_eof; + _test_eof28: cs = 28; goto _test_eof; + _test_eof154: cs = 154; goto _test_eof; + _test_eof155: cs = 155; goto _test_eof; + _test_eof156: cs = 156; goto _test_eof; + _test_eof157: cs = 157; goto _test_eof; + _test_eof158: cs = 158; goto _test_eof; + _test_eof29: cs = 29; goto _test_eof; + _test_eof159: cs = 159; goto _test_eof; + _test_eof160: cs = 160; goto _test_eof; + _test_eof161: cs = 161; goto _test_eof; + _test_eof162: cs = 162; goto _test_eof; + _test_eof163: cs = 163; goto _test_eof; + _test_eof164: cs = 164; goto _test_eof; + _test_eof165: cs = 165; goto _test_eof; + _test_eof166: cs = 166; goto _test_eof; + _test_eof167: cs = 167; goto _test_eof; + _test_eof168: cs = 168; goto _test_eof; + _test_eof169: cs = 169; goto _test_eof; + _test_eof170: cs = 170; goto _test_eof; + _test_eof171: cs = 171; goto _test_eof; + _test_eof172: cs = 172; goto _test_eof; + _test_eof173: cs = 173; goto _test_eof; + _test_eof174: cs = 174; goto _test_eof; + _test_eof175: cs = 175; goto _test_eof; + _test_eof176: cs = 176; goto _test_eof; + _test_eof177: cs = 177; goto _test_eof; + _test_eof178: cs = 178; goto _test_eof; + _test_eof179: cs = 179; goto _test_eof; + _test_eof180: cs = 180; goto _test_eof; + _test_eof181: cs = 181; goto _test_eof; + _test_eof182: cs = 182; goto _test_eof; + _test_eof183: cs = 183; goto _test_eof; + _test_eof184: cs = 184; goto _test_eof; + _test_eof185: cs = 185; goto _test_eof; + _test_eof186: cs = 186; goto _test_eof; + _test_eof187: cs = 187; goto _test_eof; + _test_eof188: cs = 188; goto _test_eof; + _test_eof189: cs = 189; goto _test_eof; + _test_eof190: cs = 190; goto _test_eof; + _test_eof191: cs = 191; goto _test_eof; + _test_eof192: cs = 192; goto _test_eof; + _test_eof193: cs = 193; goto _test_eof; + _test_eof194: cs = 194; goto _test_eof; + _test_eof195: cs = 195; goto _test_eof; + _test_eof196: cs = 196; goto _test_eof; + _test_eof197: cs = 197; goto _test_eof; + _test_eof198: cs = 198; goto _test_eof; + _test_eof199: cs = 199; goto _test_eof; + _test_eof200: cs = 200; goto _test_eof; + _test_eof201: cs = 201; goto _test_eof; + _test_eof202: cs = 202; goto _test_eof; + _test_eof203: cs = 203; goto _test_eof; + _test_eof204: cs = 204; goto _test_eof; + _test_eof205: cs = 205; goto _test_eof; + _test_eof206: cs = 206; goto _test_eof; + _test_eof207: cs = 207; goto _test_eof; + _test_eof208: cs = 208; goto _test_eof; + _test_eof209: cs = 209; goto _test_eof; + _test_eof210: cs = 210; goto _test_eof; + _test_eof211: cs = 211; goto _test_eof; + _test_eof212: cs = 212; goto _test_eof; + _test_eof213: cs = 213; goto _test_eof; + _test_eof214: cs = 214; goto _test_eof; + _test_eof215: cs = 215; goto _test_eof; + _test_eof216: cs = 216; goto _test_eof; + _test_eof217: cs = 217; goto _test_eof; + _test_eof218: cs = 218; goto _test_eof; + _test_eof219: cs = 219; goto _test_eof; + _test_eof220: cs = 220; goto _test_eof; + _test_eof221: cs = 221; goto _test_eof; + _test_eof222: cs = 222; goto _test_eof; + _test_eof223: cs = 223; goto _test_eof; + _test_eof224: cs = 224; goto _test_eof; + _test_eof225: cs = 225; goto _test_eof; + _test_eof226: cs = 226; goto _test_eof; + _test_eof227: cs = 227; goto _test_eof; + _test_eof228: cs = 228; goto _test_eof; + _test_eof229: cs = 229; goto _test_eof; + _test_eof230: cs = 230; goto _test_eof; + _test_eof231: cs = 231; goto _test_eof; + _test_eof232: cs = 232; goto _test_eof; + _test_eof233: cs = 233; goto _test_eof; + _test_eof234: cs = 234; goto _test_eof; + _test_eof235: cs = 235; goto _test_eof; + _test_eof236: cs = 236; goto _test_eof; + _test_eof237: cs = 237; goto _test_eof; + _test_eof238: cs = 238; goto _test_eof; + _test_eof239: cs = 239; goto _test_eof; + _test_eof240: cs = 240; goto _test_eof; + _test_eof241: cs = 241; goto _test_eof; + _test_eof242: cs = 242; goto _test_eof; + _test_eof243: cs = 243; goto _test_eof; + _test_eof244: cs = 244; goto _test_eof; + _test_eof245: cs = 245; goto _test_eof; + _test_eof246: cs = 246; goto _test_eof; + _test_eof247: cs = 247; goto _test_eof; + _test_eof248: cs = 248; goto _test_eof; + _test_eof249: cs = 249; goto _test_eof; + _test_eof250: cs = 250; goto _test_eof; + _test_eof251: cs = 251; goto _test_eof; + _test_eof252: cs = 252; goto _test_eof; + _test_eof30: cs = 30; goto _test_eof; + _test_eof253: cs = 253; goto _test_eof; + _test_eof254: cs = 254; goto _test_eof; + _test_eof255: cs = 255; goto _test_eof; + _test_eof31: cs = 31; goto _test_eof; + _test_eof32: cs = 32; goto _test_eof; + _test_eof256: cs = 256; goto _test_eof; + _test_eof33: cs = 33; goto _test_eof; + _test_eof257: cs = 257; goto _test_eof; + _test_eof258: cs = 258; goto _test_eof; + _test_eof259: cs = 259; goto _test_eof; + _test_eof34: cs = 34; goto _test_eof; + _test_eof35: cs = 35; goto _test_eof; + _test_eof260: cs = 260; goto _test_eof; + _test_eof36: cs = 36; goto _test_eof; + _test_eof37: cs = 37; goto _test_eof; + _test_eof261: cs = 261; goto _test_eof; + _test_eof262: cs = 262; goto _test_eof; _test_eof: {} if ( p == eof ) { - switch ( cs ) { - case 39: goto tr82; - case 40: goto tr83; - case 1: goto tr0; - case 2: goto tr0; - case 41: goto tr83; - case 42: goto tr85; - case 43: goto tr83; - case 3: goto tr0; - case 4: goto tr0; - case 44: goto tr83; - case 5: goto tr0; - case 6: goto tr0; - case 7: goto tr0; - case 45: goto tr87; - case 46: goto tr88; - case 47: goto tr89; - case 48: goto tr89; - case 49: goto tr89; - case 50: goto tr89; - case 51: goto tr89; - case 53: goto tr113; - case 54: goto tr114; - case 8: goto tr14; - case 9: goto tr14; - case 55: goto tr114; - case 10: goto tr14; - case 56: goto tr114; - case 11: goto tr14; - case 12: goto tr14; - case 57: goto tr114; - case 13: goto tr14; - case 14: goto tr14; - case 58: goto tr115; - case 59: goto tr115; - case 15: goto tr27; - case 60: goto tr117; - case 61: goto tr114; - case 62: goto tr119; - case 63: goto tr120; - case 64: goto tr120; - case 65: goto tr120; - case 66: goto tr120; - case 67: goto tr120; - case 68: goto tr134; - case 69: goto tr120; - case 70: goto tr120; - case 71: goto tr120; - case 72: goto tr120; - case 73: goto tr120; - case 74: goto tr120; - case 75: goto tr120; - case 76: goto tr120; - case 77: goto tr120; - case 78: goto tr120; - case 79: goto tr120; - case 80: goto tr120; - case 81: goto tr120; - case 82: goto tr120; - case 83: goto tr120; - case 84: goto tr120; - case 85: goto tr120; - case 86: goto tr120; - case 87: goto tr120; - case 88: goto tr120; - case 89: goto tr120; - case 90: goto tr120; - case 91: goto tr120; - case 92: goto tr120; - case 93: goto tr120; - case 94: goto tr120; - case 96: goto tr181; - case 97: goto tr182; - case 16: goto tr29; - case 17: goto tr29; - case 98: goto tr182; - case 18: goto tr29; - case 19: goto tr29; - case 99: goto tr182; - case 20: goto tr29; - case 21: goto tr29; - case 22: goto tr29; - case 100: goto tr183; - case 101: goto tr183; - case 23: goto tr43; - case 102: goto tr185; - case 103: goto tr182; - case 104: goto tr187; - case 105: goto tr188; - case 106: goto tr188; - case 107: goto tr188; - case 108: goto tr188; - case 109: goto tr188; - case 110: goto tr202; - case 111: goto tr188; - case 112: goto tr188; - case 113: goto tr188; - case 114: goto tr188; - case 115: goto tr188; - case 116: goto tr188; - case 117: goto tr188; - case 118: goto tr188; - case 119: goto tr188; - case 120: goto tr188; - case 121: goto tr188; - case 122: goto tr188; - case 123: goto tr188; - case 124: goto tr188; - case 125: goto tr188; - case 126: goto tr188; - case 127: goto tr188; - case 128: goto tr188; - case 129: goto tr188; - case 130: goto tr188; - case 131: goto tr188; - case 132: goto tr188; - case 133: goto tr188; - case 134: goto tr188; - case 135: goto tr188; - case 136: goto tr188; - case 138: goto tr237; - case 140: goto tr255; - case 141: goto tr257; - case 142: goto tr259; - case 144: goto tr275; - case 145: goto tr276; - case 147: goto tr314; - case 148: goto tr315; - case 24: goto tr45; - case 149: goto tr316; - case 25: goto tr45; - case 150: goto tr315; - case 26: goto tr45; - case 151: goto tr315; - case 152: goto tr315; - case 153: goto tr315; - case 27: goto tr45; - case 28: goto tr45; - case 154: goto tr315; - case 155: goto tr315; - case 156: goto tr315; - case 157: goto tr334; - case 158: goto tr334; - case 29: goto tr55; - case 159: goto tr336; - case 160: goto tr315; - case 161: goto tr340; - case 162: goto tr315; - case 163: goto tr349; - case 164: goto tr315; - case 165: goto tr315; - case 166: goto tr315; - case 167: goto tr367; - case 168: goto tr368; - case 169: goto tr370; - case 170: goto tr370; - case 171: goto tr370; - case 172: goto tr370; - case 173: goto tr370; - case 174: goto tr370; - case 175: goto tr370; - case 176: goto tr370; - case 177: goto tr370; - case 178: goto tr370; - case 179: goto tr370; - case 180: goto tr370; - case 181: goto tr370; - case 182: goto tr370; - case 183: goto tr370; - case 184: goto tr370; - case 185: goto tr370; - case 186: goto tr370; - case 187: goto tr370; - case 188: goto tr370; - case 189: goto tr370; - case 190: goto tr370; - case 191: goto tr370; - case 192: goto tr370; - case 193: goto tr370; - case 194: goto tr370; - case 195: goto tr370; - case 196: goto tr370; - case 197: goto tr370; - case 198: goto tr370; - case 199: goto tr370; - case 200: goto tr370; - case 201: goto tr370; - case 202: goto tr370; - case 203: goto tr370; - case 204: goto tr370; - case 205: goto tr370; - case 206: goto tr370; - case 207: goto tr370; - case 208: goto tr370; - case 209: goto tr370; - case 210: goto tr370; - case 211: goto tr370; - case 212: goto tr370; - case 213: goto tr370; - case 214: goto tr370; - case 215: goto tr370; - case 216: goto tr370; - case 217: goto tr370; - case 218: goto tr370; - case 219: goto tr370; - case 220: goto tr370; - case 221: goto tr370; - case 222: goto tr370; - case 223: goto tr370; - case 224: goto tr370; - case 225: goto tr370; - case 226: goto tr370; - case 227: goto tr370; - case 228: goto tr370; - case 229: goto tr370; - case 230: goto tr370; - case 231: goto tr370; - case 232: goto tr370; - case 233: goto tr370; - case 234: goto tr370; - case 235: goto tr370; - case 236: goto tr370; - case 237: goto tr370; - case 238: goto tr370; - case 239: goto tr370; - case 240: goto tr370; - case 241: goto tr370; - case 242: goto tr370; - case 243: goto tr370; - case 244: goto tr370; - case 245: goto tr370; - case 246: goto tr370; - case 247: goto tr370; - case 248: goto tr370; - case 249: goto tr370; - case 250: goto tr370; - case 251: goto tr315; - case 252: goto tr315; - case 30: goto tr45; - case 254: goto tr474; - case 255: goto tr475; - case 31: goto tr58; - case 32: goto tr58; - case 256: goto tr475; - case 33: goto tr58; - case 257: goto tr475; - case 258: goto tr477; - case 259: goto tr475; - case 34: goto tr58; - case 35: goto tr58; - case 260: goto tr475; - case 36: goto tr58; - case 37: goto tr58; - case 261: goto tr479; - case 262: goto tr480; + switch ( cs ) { + case 39: goto tr82; + case 40: goto tr83; + case 1: goto tr0; + case 2: goto tr0; + case 41: goto tr83; + case 42: goto tr85; + case 43: goto tr83; + case 3: goto tr0; + case 4: goto tr0; + case 44: goto tr83; + case 5: goto tr0; + case 6: goto tr0; + case 7: goto tr0; + case 45: goto tr87; + case 46: goto tr88; + case 47: goto tr89; + case 48: goto tr89; + case 49: goto tr89; + case 50: goto tr89; + case 51: goto tr89; + case 53: goto tr113; + case 54: goto tr114; + case 8: goto tr14; + case 9: goto tr14; + case 55: goto tr114; + case 10: goto tr14; + case 56: goto tr114; + case 11: goto tr14; + case 12: goto tr14; + case 57: goto tr114; + case 13: goto tr14; + case 14: goto tr14; + case 58: goto tr115; + case 59: goto tr115; + case 15: goto tr27; + case 60: goto tr117; + case 61: goto tr114; + case 62: goto tr119; + case 63: goto tr120; + case 64: goto tr120; + case 65: goto tr120; + case 66: goto tr120; + case 67: goto tr120; + case 68: goto tr134; + case 69: goto tr120; + case 70: goto tr120; + case 71: goto tr120; + case 72: goto tr120; + case 73: goto tr120; + case 74: goto tr120; + case 75: goto tr120; + case 76: goto tr120; + case 77: goto tr120; + case 78: goto tr120; + case 79: goto tr120; + case 80: goto tr120; + case 81: goto tr120; + case 82: goto tr120; + case 83: goto tr120; + case 84: goto tr120; + case 85: goto tr120; + case 86: goto tr120; + case 87: goto tr120; + case 88: goto tr120; + case 89: goto tr120; + case 90: goto tr120; + case 91: goto tr120; + case 92: goto tr120; + case 93: goto tr120; + case 94: goto tr120; + case 96: goto tr181; + case 97: goto tr182; + case 16: goto tr29; + case 17: goto tr29; + case 98: goto tr182; + case 18: goto tr29; + case 19: goto tr29; + case 99: goto tr182; + case 20: goto tr29; + case 21: goto tr29; + case 22: goto tr29; + case 100: goto tr183; + case 101: goto tr183; + case 23: goto tr43; + case 102: goto tr185; + case 103: goto tr182; + case 104: goto tr187; + case 105: goto tr188; + case 106: goto tr188; + case 107: goto tr188; + case 108: goto tr188; + case 109: goto tr188; + case 110: goto tr202; + case 111: goto tr188; + case 112: goto tr188; + case 113: goto tr188; + case 114: goto tr188; + case 115: goto tr188; + case 116: goto tr188; + case 117: goto tr188; + case 118: goto tr188; + case 119: goto tr188; + case 120: goto tr188; + case 121: goto tr188; + case 122: goto tr188; + case 123: goto tr188; + case 124: goto tr188; + case 125: goto tr188; + case 126: goto tr188; + case 127: goto tr188; + case 128: goto tr188; + case 129: goto tr188; + case 130: goto tr188; + case 131: goto tr188; + case 132: goto tr188; + case 133: goto tr188; + case 134: goto tr188; + case 135: goto tr188; + case 136: goto tr188; + case 138: goto tr237; + case 140: goto tr255; + case 141: goto tr257; + case 142: goto tr259; + case 144: goto tr275; + case 145: goto tr276; + case 147: goto tr314; + case 148: goto tr315; + case 24: goto tr45; + case 149: goto tr316; + case 25: goto tr45; + case 150: goto tr315; + case 26: goto tr45; + case 151: goto tr315; + case 152: goto tr315; + case 153: goto tr315; + case 27: goto tr45; + case 28: goto tr45; + case 154: goto tr315; + case 155: goto tr315; + case 156: goto tr315; + case 157: goto tr334; + case 158: goto tr334; + case 29: goto tr55; + case 159: goto tr336; + case 160: goto tr315; + case 161: goto tr340; + case 162: goto tr315; + case 163: goto tr349; + case 164: goto tr315; + case 165: goto tr315; + case 166: goto tr315; + case 167: goto tr367; + case 168: goto tr368; + case 169: goto tr370; + case 170: goto tr370; + case 171: goto tr370; + case 172: goto tr370; + case 173: goto tr370; + case 174: goto tr370; + case 175: goto tr370; + case 176: goto tr370; + case 177: goto tr370; + case 178: goto tr370; + case 179: goto tr370; + case 180: goto tr370; + case 181: goto tr370; + case 182: goto tr370; + case 183: goto tr370; + case 184: goto tr370; + case 185: goto tr370; + case 186: goto tr370; + case 187: goto tr370; + case 188: goto tr370; + case 189: goto tr370; + case 190: goto tr370; + case 191: goto tr370; + case 192: goto tr370; + case 193: goto tr370; + case 194: goto tr370; + case 195: goto tr370; + case 196: goto tr370; + case 197: goto tr370; + case 198: goto tr370; + case 199: goto tr370; + case 200: goto tr370; + case 201: goto tr370; + case 202: goto tr370; + case 203: goto tr370; + case 204: goto tr370; + case 205: goto tr370; + case 206: goto tr370; + case 207: goto tr370; + case 208: goto tr370; + case 209: goto tr370; + case 210: goto tr370; + case 211: goto tr370; + case 212: goto tr370; + case 213: goto tr370; + case 214: goto tr370; + case 215: goto tr370; + case 216: goto tr370; + case 217: goto tr370; + case 218: goto tr370; + case 219: goto tr370; + case 220: goto tr370; + case 221: goto tr370; + case 222: goto tr370; + case 223: goto tr370; + case 224: goto tr370; + case 225: goto tr370; + case 226: goto tr370; + case 227: goto tr370; + case 228: goto tr370; + case 229: goto tr370; + case 230: goto tr370; + case 231: goto tr370; + case 232: goto tr370; + case 233: goto tr370; + case 234: goto tr370; + case 235: goto tr370; + case 236: goto tr370; + case 237: goto tr370; + case 238: goto tr370; + case 239: goto tr370; + case 240: goto tr370; + case 241: goto tr370; + case 242: goto tr370; + case 243: goto tr370; + case 244: goto tr370; + case 245: goto tr370; + case 246: goto tr370; + case 247: goto tr370; + case 248: goto tr370; + case 249: goto tr370; + case 250: goto tr370; + case 251: goto tr315; + case 252: goto tr315; + case 30: goto tr45; + case 254: goto tr474; + case 255: goto tr475; + case 31: goto tr58; + case 32: goto tr58; + case 256: goto tr475; + case 33: goto tr58; + case 257: goto tr475; + case 258: goto tr477; + case 259: goto tr475; + case 34: goto tr58; + case 35: goto tr58; + case 260: goto tr475; + case 36: goto tr58; + case 37: goto tr58; + case 261: goto tr479; + case 262: goto tr480; } } _out: {} } -#line 1241 "rlscan.rl" +#line 1241 "rlscan.rl" /* Check if we failed. */ if ( cs == rlscan_error ) { diff --git a/contrib/tools/ragel6/rlscan.rl b/contrib/tools/ragel6/rlscan.rl index c3217f1542..d8c0c2b5d2 100644 --- a/contrib/tools/ragel6/rlscan.rl +++ b/contrib/tools/ragel6/rlscan.rl @@ -1,6 +1,6 @@ /* * Copyright 2006-2007 Adrian Thurston <thurston@complang.org> - * Copyright 2011 Josef Goettgens + * Copyright 2011 Josef Goettgens */ /* This file is part of Ragel. @@ -548,18 +548,18 @@ bool isAbsolutePath( const char *path ) #endif } -inline char* resolvePath(const char* rel, const char* abs) { - const size_t l1 = strlen(rel); - const size_t l2 = strlen(abs); - char* ret = new char[l1 + l2 + 1]; - - const char* p = strrchr(abs, '/') + 1; - const size_t l3 = p - abs; - - memcpy(ret, abs, l3); - strcpy(ret + l3, rel); - - return ret; +inline char* resolvePath(const char* rel, const char* abs) { + const size_t l1 = strlen(rel); + const size_t l2 = strlen(abs); + char* ret = new char[l1 + l2 + 1]; + + const char* p = strrchr(abs, '/') + 1; + const size_t l3 = p - abs; + + memcpy(ret, abs, l3); + strcpy(ret + l3, rel); + + return ret; } char **Scanner::makeIncludePathChecks( const char *thisFileName, @@ -585,7 +585,7 @@ char **Scanner::makeIncludePathChecks( const char *thisFileName, if ( lastSlash == 0 ) checks[nextCheck++] = data; else { - checks[nextCheck++] = resolvePath(data, thisFileName); + checks[nextCheck++] = resolvePath(data, thisFileName); } /* Search from the include paths given on the command line. */ @@ -616,16 +616,16 @@ ifstream *Scanner::tryOpenInclude( char **pathChecks, long &found ) found = check - pathChecks; return inFile; } - - /* - * 03/26/2011 jg: - * Don't rely on sloppy runtime behaviour: reset the state of the stream explicitly. - * If inFile->open() fails, which happens when include dirs are tested, the fail bit - * is set by the runtime library. Currently the VS runtime library opens new files, - * but when it comes to reading it refuses to work. - */ - inFile->clear(); - + + /* + * 03/26/2011 jg: + * Don't rely on sloppy runtime behaviour: reset the state of the stream explicitly. + * If inFile->open() fails, which happens when include dirs are tested, the fail bit + * is set by the runtime library. Currently the VS runtime library opens new files, + * but when it comes to reading it refuses to work. + */ + inFile->clear(); + check += 1; } diff --git a/contrib/tools/ragel6/rubycodegen.cpp b/contrib/tools/ragel6/rubycodegen.cpp index ee68238934..f35c33de3d 100644 --- a/contrib/tools/ragel6/rubycodegen.cpp +++ b/contrib/tools/ragel6/rubycodegen.cpp @@ -58,7 +58,7 @@ using std::endl; extern CodeStyle codeStyle; extern int numSplitPartitions; -extern bool noLineDirectives; +extern bool noLineDirectives; /* * Callbacks invoked by the XML data parser. @@ -67,9 +67,9 @@ extern bool noLineDirectives; void rubyLineDirective( ostream &out, const char *fileName, int line ) { - if ( noLineDirectives ) - return; - + if ( noLineDirectives ) + return; + /* Write a comment containing line info. */ out << "# line " << line << " \""; for ( const char *pc = fileName; *pc != 0; pc++ ) { @@ -311,9 +311,9 @@ string RubyCodeGen::GET_KEY() ret << ")"; } else { - /* Expression for retrieving the key, use dereference and read ordinal, - * for compatibility with Ruby 1.9. */ - ret << DATA() << "[" << P() << "].ord"; + /* Expression for retrieving the key, use dereference and read ordinal, + * for compatibility with Ruby 1.9. */ + ret << DATA() << "[" << P() << "].ord"; } return ret.str(); } @@ -430,7 +430,7 @@ void RubyCodeGen::STATE_IDS() out << "\n"; - if ( !noEntry && entryPointNames.length() > 0 ) { + if ( !noEntry && entryPointNames.length() > 0 ) { for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) { STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << " = " << entryPointIds[en.pos()] << ";\n"; diff --git a/contrib/tools/ragel6/rubyflat.cpp b/contrib/tools/ragel6/rubyflat.cpp index 827084d2c2..20eb209583 100644 --- a/contrib/tools/ragel6/rubyflat.cpp +++ b/contrib/tools/ragel6/rubyflat.cpp @@ -279,17 +279,17 @@ void RubyFlatCodeGen::LOCATE_TRANS() " _keys = " << vCS() << " << 1\n" " _inds = " << IO() << "[" << vCS() << "]\n" " _slen = " << SP() << "[" << vCS() << "]\n" - " _wide = " << GET_WIDE_KEY() << "\n" + " _wide = " << GET_WIDE_KEY() << "\n" " _trans = if ( _slen > 0 && \n" - " " << K() << "[_keys] <= _wide && \n" - " " << "_wide <= " << K() << "[_keys + 1] \n" + " " << K() << "[_keys] <= _wide && \n" + " " << "_wide <= " << K() << "[_keys + 1] \n" " ) then\n" - " " << I() << "[ _inds + _wide - " << K() << "[_keys] ] \n" + " " << I() << "[ _inds + _wide - " << K() << "[_keys] ] \n" " else \n" " " << I() << "[ _inds + _slen ]\n" " end\n" ""; - + } std::ostream &RubyFlatCodeGen::COND_INDEX_OFFSET() @@ -309,17 +309,17 @@ std::ostream &RubyFlatCodeGen::COND_INDEX_OFFSET() void RubyFlatCodeGen::COND_TRANSLATE() { - out << + out << " _widec = " << GET_KEY() << "\n" " _keys = " << vCS() << " << 1\n" " _conds = " << CO() << "[" << vCS() << "]\n" " _slen = " << CSP() << "[" << vCS() << "]\n" - " _wide = " << GET_WIDE_KEY() << "\n" - " _cond = if ( _slen > 0 && \n" - " " << CK() << "[_keys] <= _wide &&\n" - " " << "_wide <= " << CK() << "[_keys + 1]\n" + " _wide = " << GET_WIDE_KEY() << "\n" + " _cond = if ( _slen > 0 && \n" + " " << CK() << "[_keys] <= _wide &&\n" + " " << "_wide <= " << CK() << "[_keys + 1]\n" " ) then \n" - " " << C() << "[ _conds + _wide - " << CK() << "[_keys]" << " ]\n" + " " << C() << "[ _conds + _wide - " << CK() << "[_keys]" << " ]\n" " else\n" " 0\n" " end\n"; diff --git a/contrib/tools/ragel6/version.h b/contrib/tools/ragel6/version.h index 3b1233c966..4e676e89dc 100644 --- a/contrib/tools/ragel6/version.h +++ b/contrib/tools/ragel6/version.h @@ -1,2 +1,2 @@ -#define VERSION "6.10" -#define PUBDATE "March 2017" +#define VERSION "6.10" +#define PUBDATE "March 2017" diff --git a/contrib/tools/ragel6/xmlcodegen.cpp b/contrib/tools/ragel6/xmlcodegen.cpp index e4b14bc82b..0f9d0a6787 100644 --- a/contrib/tools/ragel6/xmlcodegen.cpp +++ b/contrib/tools/ragel6/xmlcodegen.cpp @@ -1403,12 +1403,12 @@ void InputData::writeLanguage( std::ostream &out ) switch ( hostLang->lang ) { case HostLang::C: out << "C"; break; case HostLang::D: out << "D"; break; - case HostLang::D2: out << "D2"; break; - case HostLang::Go: out << "Go"; break; + case HostLang::D2: out << "D2"; break; + case HostLang::Go: out << "Go"; break; case HostLang::Java: out << "Java"; break; case HostLang::Ruby: out << "Ruby"; break; case HostLang::CSharp: out << "C#"; break; - case HostLang::OCaml: out << "OCaml"; break; + case HostLang::OCaml: out << "OCaml"; break; } out << "\""; } diff --git a/contrib/tools/ragel6/ya.make b/contrib/tools/ragel6/ya.make index 2c97f636ae..321608bb66 100644 --- a/contrib/tools/ragel6/ya.make +++ b/contrib/tools/ragel6/ya.make @@ -1,6 +1,6 @@ -# Generated by devtools/yamaker from nixpkgs 980c4c3c2f664ccc5002f7fd6e08059cf1f00e75. - -OWNER(pg g:cpp-contrib) +# Generated by devtools/yamaker from nixpkgs 980c4c3c2f664ccc5002f7fd6e08059cf1f00e75. + +OWNER(pg g:cpp-contrib) IF (USE_PREBUILT_TOOLS) INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/ragel6/ya.make.prebuilt) |