coala-1.0.1_src/COPYING000644 001750 001750 00000104374 11477164507 015243 0ustar00tovok7tovok7000000 000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . coala-1.0.1_src/bin/coala000755 001750 001750 00000032153 11477164507 015760 0ustar00tovok7tovok7000000 000000 #!/usr/bin/python ######################################################################### # Copyright 2010 Torsten Grote # # 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 3 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, see . ########################################################################## from __future__ import with_statement import sys import os import re import subprocess import tempfile from optparse import OptionParser, OptionGroup if sys.version.rsplit()[0] < '2.5': print 'You need at least python 2.5 to run coala' sys.exit(1) # defined that early to extract coala version from binary def checkProgram(prog): try: (result, error) = subprocess.Popen([prog, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() except OSError, err: print err return False if result != '': return result.splitlines()[0] else: return False version = checkProgram("coala.bin") if not version: print "There is a problem with the coala binary file. Is it in your $PATH, is it executable, is it compiled for your architecture?" sys.exit(1) # Parse Command Line Options description = version+" Copyright (C) 2007-2010 Torsten Grote This program comes with ABSOLUTELY NO WARRANTY. It is free software, and you are welcome to redistribute it under certain conditions." usage = "%prog [options] file [number]" parser = OptionParser(usage=usage, description=description, add_help_option=False, version="%prog " + version, conflict_handler="resolve") parser.add_option("-l", "--language", dest="language", choices=["c","b","al","m","c_taid"], help="the action language (c, c_taid, b, al or m) to be used as input (default: %default)", action="store", metavar="LANG") parser.add_option("-s", "--static-file", dest="static_files", help="file containing static information such as variable types.", action="append", metavar="FILE") parser.add_option("-c", "--const", dest="const", help="replaces constant t with value v", metavar="t=v") parser.add_option("-d", "--debug", dest="debug", help="show debugging output", action="store_true") parser.add_option("", "--version", help="show program's version number and exit", action="version") parser.add_option("-h", "--help", help="show this help message and exit", action="help") encoding_group = OptionGroup(parser, "Encoding Options") encoding_group.add_option("-i", "--incremental", dest="incremental", choices=["yes","no","backwards"], help="use incremental encoding. INC can be yes, no or backwards. Default: %default", action="store", metavar="INC") encoding_group.add_option("-e", "--meta-encoding", dest="meta_encoding", help="use meta-encoding", action="store_true") encoding_group.add_option("-n", "--negation", dest="negation", help="simulate classical negation instead of using the built-in one", action="store_true") parser.add_option_group(encoding_group) solver_group = OptionGroup(parser, "Solver Options") solver_group.add_option("", "--max-sol", dest="max_sol", help="Compute [number] solutions. Default: %default", type="int", action="store", metavar="NUM") solver_group.add_option("", "--imax", dest="imax", help="Perform at most NUM incremental steps. Default: %default", type="int", action="store", metavar="NUM") solver_group.add_option("-t", "--text", dest="text", help="show only coala output and don't look for solutions", action="store_true") solver_group.add_option("-g", "--ground", dest="ground", help="show only grounded coala output and don't look for solutions", action="store_true") parser.add_option_group(solver_group) output_group = OptionGroup(parser, "Output Options") output_group.add_option("-o", "--output", dest="output", help="change the way the solutions are presented, long, compact or raw. Default: %default", action="store", choices=['long','compact', 'raw'], metavar="OUTPUT") output_group.add_option("-f", "--show-fluents", dest="show_fluents", help="show not only actions, but also fluents in solution", action="store_true") #output_group.add_option("", "--hide", dest="hide", help="Hide this action or fluent name from output", action="append", metavar="NAME") parser.add_option_group(output_group) parser.set_defaults( language = "c", incremental = "yes", meta_encoding = False, show_fluents = False, negation = False, output = "compact", text = False, ground = False, max_sol = 1, imax = 99, debug = False ) (opt, args) = parser.parse_args() if opt.meta_encoding: ACTION = re.compile("^occ\((.*?),?(\d+)\)$") FLUENT = re.compile("^hol\((.*?),?(\d+)\)$") elif opt.language == 'b': ACTION = re.compile("^occ\((.*?),?(\d+)\)$") FLUENT = re.compile("^holds\((.*?),?(\d+)\)$") else: ACTION = re.compile("^-?action_([a-zA-Z0-9_]*\(.*?),? *(\d+) *\)\.?$") FLUENT = re.compile("^-?fluent_([a-zA-Z0-9_]*\(.*?),? *(\d+) *\)\.?$") PARSER = [ re.compile("^Answer:\ (\d+)$"), re.compile("^(-?[a-z_][a-zA-Z0-9_]*(\(.+\))?\ *)+$"), re.compile("^SATISFIABLE$"), re.compile("^UNSATISFIABLE$"), re.compile("^Error: (?P.+)$"), ] def main(): checkOptions() lp = callCoala("coala.bin") if opt.text: print lp else: output = callClingo(lp) if opt.ground or opt.output == 'raw': print output else: answer_sets = getAnswerSets(output) printAnswerSets(answer_sets) return 0 def checkOptions(): # get last positional argument and check if its a number try: int(args[len(args)-1]) opt.max_sol = args.pop(len(args)-1) except IndexError: print "coala needs at least one file as argument. Run `coala --help` for more information." print parser.print_usage() sys.exit(0) except ValueError: opt.max_sol = '1' if(opt.language == "c_taid" and (opt.incremental == "yes" or opt.incremental == "backwards" or opt.meta_encoding)): raise RuntimeError("Action Language c_taid does not support these options.") if((opt.language == "b" or opt.language == "al") and opt.meta_encoding): raise RuntimeWarning("Action Language "+opt.language+" does only support one encoding.") if(opt.text and opt.ground): raise RuntimeError("The options -g and -t can not be used together.") def callCoala(coala_binary): coala_options = getCoalaOptions() if(opt.debug): print "Calling Coala with:" print " " + subprocess.list2cmdline([coala_binary] + coala_options) (result, error) = subprocess.Popen([coala_binary] + coala_options, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if error != "": print error return result def getCoalaOptions(): result = ['-l'] result.append(opt.language) if(opt.meta_encoding): result.append('-e') elif(opt.incremental == "yes" or opt.incremental == "backward"): result.append('-n') if(opt.incremental == "yes"): result.append('-i') elif(opt.incremental == "backward"): result.append('-ir') elif(opt.negation): result.append('-n') opt.negation = True if(opt.debug): result.extend(['-d','99']) elif(opt.show_fluents): result.extend(['-d','1']) for file in args: if os.path.exists(file): result.append(file) else: raise RuntimeError("Input file %s does not exist." % file) return result def callClingo(lp): iclingo_options = ['--imax='+str(opt.imax), opt.max_sol] iclingo = checkProgram("iclingo") if(not iclingo and opt.incremental != "no"): raise RuntimeError("Could not find iclingo binary which is needed to process the incremental encoding.") elif(not iclingo): iclingo = checkProgram("clingo") if(not clingo): raise RuntimeError("Could not find an iclingo or clingo binary. At least one of them is needed to compute solutions.") else: iclingo = "clingo" else: iclingo = "iclingo" if(opt.incremental == "no"): iclingo_options.append('--clingo') if(opt.const): iclingo_options.extend(['-c', opt.const]) if(opt.ground): iclingo_options.append('-t') if(opt.const): iclingo_options.append('--ifixed=' + opt.const.rsplit('=',1)[1]) # create tmp file for input tmp = tempfile.NamedTemporaryFile() tmp.write(lp) if opt.static_files: for file in opt.static_files: if(os.path.exists(file)): if(opt.incremental != "no"): tmp.write("#base.\n") with open(file, 'r') as f: for line in f: tmp.write(line) else: raise RuntimeError("Static file '%s' could not be found." % file) tmp.seek(0) if opt.debug: print "Calling iClingo with:" print " " + subprocess.list2cmdline([iclingo] + iclingo_options) iclingo_options.append('--istats') (result, error) = subprocess.Popen([iclingo] + iclingo_options, stdin=tmp, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if error != "": print error return result def getAnswerSets(output): answer_sets = [] for line in output.splitlines(): matched = False for i in range(len(PARSER)): match = PARSER[i].match(line) if match != None: matched = True if i == 0 and opt.debug: print "Found %s. Answer Set." % match.group(1) elif i == 1: answer_sets.append(line.split()) elif i == 2: return answer_sets elif i == 3: raise RuntimeError("The problem doesn't have any solutions. Try to comment out some constraints or queries. " + "In case of an LTL query, this message means that no counter examples have been found.") elif i == 4: raise RuntimeError(line) if not matched: if opt.debug: print line #raise SyntaxError("Unkown clasp output read: %s" % line) return answer_sets def printAnswerSets(answer_sets): i = 1 for answer_set in answer_sets: if opt.output == "long": print "\nAnswer: %d" % i print '-' * 78 else: print "Answer: %d" % i printAnswerSet(answer_set) i += 1 if i-1 >= int(opt.max_sol) and opt.max_sol != '0': print "There might be more solutions. Find out by adding the maximal [number] of" print "solutions as a parameter. Use 0 for all." def printAnswerSet(answer_set): """prints the answer set""" times = [] actions = {} fluents = {} # stores all actions and fluents in two dictionaries for predicate in answer_set: for (parser, plan) in [(ACTION, actions), (FLUENT, fluents)]: match = parser.match(predicate) if match != None: t = int(match.group(2)) if t in plan: plan[t].append(predicate) else: plan[t] = [predicate] if not t in times: times.append(t) times.sort() if opt.output == "compact": # append fluents to actions and sort both for time in times: if not time in actions: actions[time] = [] else: actions[time].sort() if time in fluents: fluents[time].sort() actions[time].extend(fluents[time]) # prints predicates in rows row_len = getPredicateLength(actions, fluents) for time in actions: printRow(actions, row_len, time) else: # append actions to fluents and sort both for time in times: if not time in fluents: fluents[time] = [] else: fluents[time].sort() if time in actions: actions[time].sort() fluents[time].extend(actions[time]) # print one predicate per row for predicate in fluents[time]: printPredicate(time, predicate) print '-' * 78 def getPredicateLength(actions, fluents): row_len = {} for plan in [actions, fluents]: for time in plan: plan[time].sort() row = 0 for predicate in plan[time]: predicate = formatPredicate(predicate)[0] if row in row_len: if len(predicate) > row_len[row]: row_len[row] = len(predicate) else: row_len[row] = len(predicate) row += 1 return row_len def formatPredicate(predicate): pred = '' match = ACTION.match(predicate) if match == None: match = FLUENT.match(predicate) if match == None: pred = predicate else: pred = match.group(1) pred_type = "fluent" else: pred = match.group(1) pred_type = "action" if not opt.language == 'b' and not opt.meta_encoding: # remove opening bracket if time was only argument new_pred = pred.rstrip('(') # close bracket if needed if new_pred == pred: new_pred += ')' pred = new_pred if opt.output == "compact": if pred_type == "action": pred = "A " + pred elif pred_type == "fluent": pred = "F " + pred elif opt.output == "long": pred = pred.replace(',', ', ') return (pred, pred_type) def printRow(plan, row_len, time): time_str = str(time).rjust(len(str(len(plan)))) print " %s. " % time_str, row = 0 for predicate in plan[time]: print formatPredicate(predicate)[0].ljust(row_len[row]+1), row += 1 print "" def printPredicate(time, predicate): (pred, pred_type) = formatPredicate(predicate) print str(time).rjust(3) + " ", if pred_type == "action": print "A", elif pred_type == "fluent": print "F", else: print " ", print " " + pred if __name__ == '__main__': if opt.debug: sys.exit(main()) else: try: sys.exit(main()) except Warning, warn: sys.stderr.write('WARNING: %s\n' % str(warn)) except Exception, err: sys.stderr.write('ERROR: %s\n' % str(err)) sys.exit(1) coala-1.0.1_src/src/lib/options.h000644 001750 001750 00000004060 11477164507 017400 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/options.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef OPTIONS_H #define OPTIONS_H #include #include using namespace std; namespace Coala { class CompilerOptions { public: CompilerOptions(); virtual ~CompilerOptions(); bool checkOptions(); void setLanguage(string); string getLanguage(); void setInputStream(istream&); istream* getInputStream(); void setOutputStream(ostream&); ostream* getOutputStream(); void setFakeClassicalNegation(bool); bool getFakeClassicalNegation(); void setDebug(int); int getDebug(); void setDirectEncoding(bool); bool getDirectEncoding(); void setIncremental(bool); bool getIncremental(); void setReverseIncremental(bool); bool getReverseIncremental(); void setWhereCheck(bool); bool getWhereCheck(); private: string language_; istream* inputStream_; ostream* outputStream_; bool fakeClassicalNegation_; int debug_; bool directEncoding_; bool incremental_; bool reverseIncremental_; bool whereCheck_; }; }; #endif // OPTIONS_H coala-1.0.1_src/src/lib/main.cpp000644 001750 001750 00000006610 11477164507 017167 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/main.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "main.h" #include "c/Compiler.h" #include "b/Compiler.h" #include "c_taid/compiler.h" namespace Coala { Compiler::Compiler() { options_ = new CompilerOptions(); } Compiler::~Compiler() { delete options_; //delete compiler_; // segfault with from options } int Compiler::compile() { if(!options_->checkOptions()) { throw std::runtime_error("Invalid combination of options set."); } if(options_->getLanguage() == "c" || options_->getLanguage() == "m") { compiler_ = new C::Compiler(options_); } else if(options_->getLanguage() == "b") { compiler_ = new B::Compiler(options_); } else if(options_->getLanguage() == "c_taid") { compiler_ = new C_taid::Compiler(options_); } else { throw std::runtime_error("Unknown input language to compile."); } if(options_->getDebug() > 99) { cout << "% Options\n"; cout << "% \n"; cout << "% Language: " << options_->getLanguage() << "\n"; cout << "% Debug Level: " << options_->getDebug() << "\n"; cout << "% Simulated Classical Negation: " << (options_->getFakeClassicalNegation() ? "true" : "false") << "\n"; cout << "% Direct Encoding: " << (options_->getDirectEncoding() ? "true" : "false") << "\n"; cout << "% Incremental: " << (options_->getIncremental() ? "true" : "false") << "\n"; cout << "% Reverse Incremental: " << (options_->getReverseIncremental() ? "true" : "false") << "\n"; cout << "% Where Check: " << (options_->getWhereCheck() ? "true" : "false") << "\n"; } return compiler_->compile(); } void Compiler::setLanguage(string language) { options_->setLanguage(language); } void Compiler::setInputStream(istream& inputStream) { options_->setInputStream(inputStream); } void Compiler::setOutputStream(ostream& outputStream) { options_->setOutputStream(outputStream); } void Compiler::setFakeClassicalNegation(bool fakeClassicalNegation) { options_->setFakeClassicalNegation(fakeClassicalNegation); } void Compiler::setDebug(int debug) { options_->setDebug(debug); } void Compiler::setDirectEncoding(bool directEncoding) { options_->setDirectEncoding(directEncoding); } void Compiler::setIncremental(bool incremental) { options_->setIncremental(incremental); } void Compiler::setReverseIncremental(bool reverseIncremental) { options_->setReverseIncremental(reverseIncremental); } void Compiler::setWhereCheck(bool whereCheck) { options_->setWhereCheck(whereCheck); } }; coala-1.0.1_src/src/lib/c_taid/scanner.cpp000644 001750 001750 00000142533 11477164507 021124 0ustar00tovok7tovok7000000 000000 #line 2 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.cpp" #line 4 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.cpp" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* The c++ scanner is a mess. The FlexLexer.h header file relies on the * following macro. This is required in order to pass the c++-multiple-scanners * test in the regression suite. We get reports that it breaks inheritance. * We will address this in a future release of flex, or omit the C++ scanner * altogether. */ #define yyFlexLexer ctaidFlexLexer /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* begin standard C++ headers. */ #include #include #include #include #include /* end standard C++ headers. */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. * Ditto for the __ia64__ case accordingly. */ #define YY_BUF_SIZE 32768 #else #define YY_BUF_SIZE 16384 #endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif extern int yyleng; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ int yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { std::istream* yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] void *ctaidalloc (yy_size_t ); void *ctaidrealloc (void *,yy_size_t ); void ctaidfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; #define yytext_ptr yytext #define YY_INTERACTIVE #include int yyFlexLexer::yywrap() { return 1; } /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 23 #define YY_END_OF_BUFFER 24 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[122] = { 0, 0, 0, 24, 22, 1, 1, 22, 19, 22, 20, 18, 22, 16, 1, 0, 21, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 5, 0, 0, 3, 0, 0, 0, 0, 0, 4, 13, 0, 0, 0, 15, 0, 9, 0, 0, 7, 0, 12, 0, 0, 0, 10, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 5, 6, 7, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 9, 1, 10, 1, 1, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 1, 1, 1, 1, 12, 1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 11, 11, 22, 11, 23, 24, 25, 11, 26, 27, 28, 29, 11, 30, 31, 32, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[33] = { 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } ; static yyconst flex_int16_t yy_base[126] = { 0, 0, 12, 140, 141, 23, 25, 136, 141, 0, 141, 130, 16, 0, 33, 134, 141, 0, 128, 23, 122, 117, 102, 110, 24, 107, 115, 24, 103, 0, 100, 105, 116, 96, 106, 98, 93, 111, 100, 104, 103, 104, 99, 94, 93, 89, 141, 85, 98, 88, 92, 141, 87, 83, 77, 82, 88, 84, 78, 71, 83, 70, 85, 74, 82, 72, 68, 83, 71, 72, 67, 62, 61, 65, 65, 57, 63, 68, 55, 141, 66, 63, 69, 68, 67, 48, 52, 64, 45, 43, 59, 42, 43, 141, 141, 141, 58, 57, 141, 39, 39, 51, 53, 35, 141, 141, 51, 34, 31, 141, 48, 141, 40, 46, 141, 26, 141, 33, 11, 20, 141, 141, 51, 53, 21, 9 } ; static yyconst flex_int16_t yy_def[126] = { 0, 122, 122, 121, 121, 121, 121, 123, 121, 124, 121, 121, 121, 125, 121, 123, 121, 124, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 125, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 0, 121, 121, 121, 121 } ; static yyconst flex_int16_t yy_nxt[174] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 29, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 17, 4, 14, 14, 14, 14, 19, 120, 20, 21, 22, 23, 14, 14, 24, 30, 25, 26, 27, 37, 119, 28, 31, 41, 38, 118, 117, 42, 32, 13, 13, 15, 15, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 40, 39, 36, 35, 34, 33, 18, 16, 18, 16, 121, 3, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121 } ; static yyconst flex_int16_t yy_chk[174] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 125, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 124, 2, 5, 5, 6, 6, 12, 119, 12, 12, 12, 12, 14, 14, 12, 19, 12, 12, 12, 24, 118, 12, 19, 27, 24, 117, 115, 27, 19, 122, 122, 123, 123, 113, 112, 110, 108, 107, 106, 103, 102, 101, 100, 99, 97, 96, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 28, 26, 25, 23, 22, 21, 20, 18, 15, 11, 7, 3, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[24] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #line 1 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" /**************************************************************************** * lib/c_taid/scanner.l - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #line 21 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" #include "parser.h" #include bool second_part = false; bool asked_query = false; void printPartError(const string, const int); void printQueryError(const string, const int); #line 542 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.cpp" #define INITIAL 0 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ #define YY_READ_BUF_SIZE 16384 #else #define YY_READ_BUF_SIZE 8192 #endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO #define ECHO LexerOutput( yytext, yyleng ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ \ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) LexerError( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 #define YY_DECL int yyFlexLexer::yylex() #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 53 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" #line 649 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.cpp" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = & std::cin; if ( ! yyout ) yyout = & std::cout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 122 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 141 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) yylineno++; ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: /* rule 1 can match eol */ YY_RULE_SETUP #line 54 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" // ignore white space. YY_BREAK case 2: YY_RULE_SETUP #line 55 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { if(second_part) printPartError(yytext, lineno()); else return CtaidParser::ACT; } YY_BREAK case 3: YY_RULE_SETUP #line 56 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::FLU; } YY_BREAK case 4: YY_RULE_SETUP #line 57 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::DEF; } YY_BREAK case 5: YY_RULE_SETUP #line 58 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::CAUS; } YY_BREAK case 6: YY_RULE_SETUP #line 59 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::IF; } YY_BREAK case 7: YY_RULE_SETUP #line 60 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { if(second_part) printPartError(yytext, lineno()); else return CtaidParser::TRIG; } YY_BREAK case 8: YY_RULE_SETUP #line 61 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { if(second_part) printPartError(yytext, lineno()); else return CtaidParser::ALLOW; } YY_BREAK case 9: YY_RULE_SETUP #line 62 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::INHIB; } YY_BREAK case 10: YY_RULE_SETUP #line 63 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::NCONC; } YY_BREAK case 11: YY_RULE_SETUP #line 64 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::AT; } YY_BREAK case 12: YY_RULE_SETUP #line 65 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { second_part = true; return CtaidParser::OC_AT; } YY_BREAK case 13: YY_RULE_SETUP #line 66 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { if(asked_query) printQueryError(yytext, lineno()); else { asked_query = true; return CtaidParser::EXP; } } YY_BREAK case 14: YY_RULE_SETUP #line 72 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { if(asked_query) printQueryError(yytext, lineno()); else { asked_query = true; return CtaidParser::PLAN; } } YY_BREAK case 15: YY_RULE_SETUP #line 78 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { if(asked_query) printQueryError(yytext, lineno()); else { asked_query = true; return CtaidParser::PRED; } } YY_BREAK case 16: YY_RULE_SETUP #line 84 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::IDENTIFIER; } YY_BREAK case 17: YY_RULE_SETUP #line 85 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::NEG_IDENTI; } YY_BREAK case 18: YY_RULE_SETUP #line 86 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::NUMBER; } YY_BREAK case 19: YY_RULE_SETUP #line 87 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::COMMA; } YY_BREAK case 20: YY_RULE_SETUP #line 88 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { return CtaidParser::DOT; } YY_BREAK case 21: /* rule 21 can match eol */ YY_RULE_SETUP #line 89 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { /* comment */ } YY_BREAK case YY_STATE_EOF(INITIAL): #line 90 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { yyterminate(); } YY_BREAK case 22: YY_RULE_SETUP #line 91 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" { cerr << "\n\nError: Unknown keyword '"+string(yytext)+"' found at line "<yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) { yyin = arg_yyin; yyout = arg_yyout; yy_c_buf_p = 0; yy_init = 0; yy_start = 0; yy_flex_debug = 0; yylineno = 1; // this will only get updated if %option yylineno yy_did_buffer_switch_on_eof = 0; yy_looking_for_trail_begin = 0; yy_more_flag = 0; yy_more_len = 0; yy_more_offset = yy_prev_more_offset = 0; yy_start_stack_ptr = yy_start_stack_depth = 0; yy_start_stack = NULL; yy_buffer_stack = 0; yy_buffer_stack_top = 0; yy_buffer_stack_max = 0; yy_state_buf = 0; } /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::~yyFlexLexer() { delete [] yy_state_buf; ctaidfree(yy_start_stack ); yy_delete_buffer( YY_CURRENT_BUFFER ); ctaidfree(yy_buffer_stack ); } /* The contents of this function are C++ specific, so the () macro is not used. */ void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) { if ( new_in ) { yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); } if ( new_out ) yyout = new_out; } #ifdef YY_INTERACTIVE int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) #else int yyFlexLexer::LexerInput( char* buf, int max_size ) #endif { if ( yyin->eof() || yyin->fail() ) return 0; #ifdef YY_INTERACTIVE yyin->get( buf[0] ); if ( yyin->eof() ) return 0; if ( yyin->bad() ) return -1; return 1; #else (void) yyin->read( buf, max_size ); if ( yyin->bad() ) return -1; else return yyin->gcount(); #endif } void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout->write( buf, size ); } /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ int yyFlexLexer::yy_get_next_buffer() { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ ctaidrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ctaidrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ yy_state_type yyFlexLexer::yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 122 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) { register int yy_is_jam; register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 122 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 121); return yy_is_jam ? 0 : yy_current_state; } void yyFlexLexer::yyunput( int c, register char* yy_bp) { register char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = (yy_n_chars) + 2; register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; if ( c == '\n' ){ --yylineno; } (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } int yyFlexLexer::yyinput() { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); if ( c == '\n' ) yylineno++; ; return c; } /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyFlexLexer::yyrestart( std::istream* input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_init_buffer( YY_CURRENT_BUFFER, input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } void yyFlexLexer::yy_load_buffer_state() { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) ctaidalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) ctaidalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) ctaidfree((void *) b->yy_ch_buf ); ctaidfree((void *) b ); } extern "C" int isatty (int ); /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) { int oerrno = errno; yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yyFlexLexer::yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ void yyFlexLexer::yyensure_buffer_stack(void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)ctaidalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)ctaidrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } void yyFlexLexer::yy_push_state( int new_state ) { if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) { yy_size_t new_size; (yy_start_stack_depth) += YY_START_STACK_INCR; new_size = (yy_start_stack_depth) * sizeof( int ); if ( ! (yy_start_stack) ) (yy_start_stack) = (int *) ctaidalloc(new_size ); else (yy_start_stack) = (int *) ctaidrealloc((void *) (yy_start_stack),new_size ); if ( ! (yy_start_stack) ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; BEGIN(new_state); } void yyFlexLexer::yy_pop_state() { if ( --(yy_start_stack_ptr) < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); } int yyFlexLexer::yy_top_state() { return (yy_start_stack)[(yy_start_stack_ptr) - 1]; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif void yyFlexLexer::LexerError( yyconst char msg[] ) { std::cerr << msg << std::endl; exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *ctaidalloc (yy_size_t size ) { return (void *) malloc( size ); } void *ctaidrealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void ctaidfree (void * ptr ) { free( (char *) ptr ); /* see ctaidrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 94 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/scanner.l" void printPartError(const string etext, const int line) { cerr << "\n\nError: Keyword '"+etext+"' may only appear in description part, but found at line "<getDebug(); neg=options->getFakeClassicalNegation()?"neg_":"-";} %define MEMBERS void postProcessing(); bool cout_neg(bool); int debug; string neg; virtual ~CtaidParser(){}\ private:\ typedef set > StringSet;\ StringSet all_fluents;\ StringSet default_fluents;\ StringSet inertial_fluents;\ StringSet all_actions;\ StringSet triggered_actions;\ StringSet allowed_actions;\ StringSet exogenous_actions; // TODO // - adapt debug value // - get the end time right // - action rules for prediction only for non-triggered ones // - check whether fluents and actions are defined %header{ #include #include #include #include #include #include #include "../options.h" using namespace std; //using namespace C_taid; %} %{ typedef list > ListPair; int latest_obs = 0; %} %union { int number; const string *istring; list > *ilist; } %token IDENTIFIER %token NEG_IDENTI %token NUMBER %token ACT // action %token FLU // fluent %token DEF // default %token CAUS // causes %token IF // if %token TRIG // triggers %token ALLOW // allows %token INHIB // inhibits %token NCONC // noconcurrency %token AT // at %token OC_AT // occurs_at %token EXP // explain %token PLAN // plan %token PRED // predict %token COMMA // , %token DOT // . %type fluent_list %start program %% program: /* empty */ | program rule DOT; rule: desc_rule | obs_rule | query_rule; desc_rule: fact | static_rule | dyn_rule | trig_rule | allow_rule | inhib_rule | nconc_rule; obs_rule: flu_obs | act_obs; query_rule: exp_rule | plan_rule | pred_rule; fact: act_fact | flu_fact | def_fact; // (action a_1,...,a_n) act_fact: ACT fluent_list { // not really a fluent_list, but I still use it for actions for(ListPair::iterator n = $2->begin(); n != $2->end(); ++n) { if(neg == "neg_") { cout << ":- action_"+n->first+"(T), neg_action_"+n->first+"(T), time(T).\n"; // hides every neg_action if(debug < 2) cout << "#hide neg_action_"+n->first+"(T).\n"; } all_actions.insert(n->first); } delete $2; } // (fluent f_1,...,f_n) flu_fact: FLU fluent_list { for(ListPair::iterator n = $2->begin(); n != $2->end(); ++n) { all_fluents.insert(n->first); } delete $2; } // (default f_1,...,f_n) def_fact: DEF fluent_list { for(ListPair::iterator n = $2->begin(); n != $2->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T) :- not "; cout_neg(!n->second); cout << "fluent_"+n->first+"(T), time(T).\n"; if(neg == "neg_") { // relationship between fluent and its negation cout << ":- fluent_"+n->first+"(T), neg_fluent_"+n->first+"(T), time(T).\n"; // hides neg_fluent for every default fluent if(debug < 2) { cout << "#hide neg_fluent_"+n->first+"(T).\n"; } } if(debug < 1) cout << "#hide fluent_"+n->first+"(T).\n"; default_fluents.insert(n->first); } delete $2; } // (a causes f_1,...,f_n if g_1,...,g_m) dyn_rule: IDENTIFIER CAUS fluent_list IF fluent_list { for(ListPair::iterator n = $3->begin(); n != $3->end(); ++n) { // f_1,...,f_n cout_neg(n->second); cout << "fluent_"+n->first+"(T+1) :- action_"+*$1+"(T), "; for(ListPair::iterator m = $5->begin(); m != $5->end(); ++m) { // g_1,...,g_m cout_neg(m->second); cout << "fluent_"+m->first+"(T), "; } cout << "time(T; T+1).\n"; } delete $1; delete $3; delete $5; } // (a causes f_1,...,f_n) | IDENTIFIER CAUS fluent_list { for(ListPair::iterator n = $3->begin(); n != $3->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T+1) :- action_"+*$1+"(T), time(T; T+1).\n"; } delete $1; delete $3; } // (f_1,...,f_n if g_1,...,g_m) static_rule: fluent_list IF fluent_list { for(ListPair::iterator n = $1->begin(); n != $1->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T) :- "; for(ListPair::iterator m = $3->begin(); m != $3->end(); ++m) { cout_neg(m->second); cout << "fluent_"+m->first+"(T), "; } cout << "time(T).\n"; } delete $1; delete $3; } // (f_1,...,f_n triggers a) trig_rule: fluent_list TRIG IDENTIFIER { cout << "trig_action_"+*$3+"(T) :- "; for(ListPair::iterator n = $1->begin(); n != $1->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T), "; } cout << "time(T).\n"; // trigger only when not inhibited cout << "action_"+*$3+"(T) :- trig_action_"+*$3+"(T), not "+neg+"action_"+*$3+"(T), time(T).\n"; // hides every trig_action if(debug < 2) cout << "#hide trig_action_"+*$3+"(T).\n"; triggered_actions.insert(*$3); delete $1; delete $3; } // (f_1,...,f_n allows a) allow_rule: fluent_list ALLOW IDENTIFIER { cout << "allow_action_"+*$3+"(T) :- "; for(ListPair::iterator n = $1->begin(); n != $1->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T), "; } cout << "time(T).\n"; // hides allow_action for every allowed action if(debug < 2) cout << "#hide allow_action_"+*$3+"(T).\n"; allowed_actions.insert(*$3); delete $1; delete $3; } // (f_1,...,f_n inhibits a) inhib_rule: fluent_list INHIB IDENTIFIER { cout << neg+"action_"+*$3+"(T) :- "; for(ListPair::iterator n = $1->begin(); n != $1->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T), "; } cout << "time(T).\n"; delete $1; delete $3; } // (noconcurrency a_1,...,a_n) nconc_rule: NCONC fluent_list { // not really a fluent_list, but I still use it for actions cout << ":- 2 {"; for(ListPair::iterator n = $2->begin(); n != $2->end(); ++n) { if(n != $2->begin()) cout << ", "; cout << "action_"+n->first+"(T)"; } cout << "}, time(T).\n"; delete $2; } // f at t_i flu_obs: fluent_list AT NUMBER { for(ListPair::iterator n = $1->begin(); n != $1->end(); ++n) { if($3 == 0) { cout_neg(n->second); cout << "fluent_"+n->first+"(0).\n"; } else { cout << ":- not "; cout_neg(n->second); cout << "fluent_"+n->first+"("<<$3<<"), time("<<$3<<").\n"; } } // remember a later observation time latest_obs = ($3 > latest_obs) ? $3 : latest_obs ; delete $1; } // a occurs_at t_i act_obs: fluent_list OC_AT NUMBER { for(ListPair::iterator n = $1->begin(); n != $1->end(); ++n) { // for non-exogenous actions (not triggered or allowed) if(triggered_actions.find(n->first) != triggered_actions.end() || allowed_actions.find(n->first) != allowed_actions.end()) { cout << ":- "; cout_neg(!n->second); cout << "action_"+n->first+"("<<$3<<"), time("<<$3<<").\n"; } // for exogenous actions else { cout_neg(n->second); cout << "action_"+n->first+"("<<$3<<").\n"; } } // remember a later observation time latest_obs = ($3 > latest_obs) ? $3 : latest_obs ; delete $1; } // explain n exp_rule: EXP { // rules for generating all possible initial states for(StringSet::iterator n = all_fluents.begin(); n != all_fluents.end(); ++n) { cout << "fluent_"+*n+"(0) :- not "+neg+"fluent_"+*n+"(0).\n"; cout << neg+"fluent_"+*n+"(0) :- not fluent_"+*n+"(0).\n"; } // all exogenous and allowed actions in one set: all - triggered StringSet exoallow_actions; set_difference(all_actions.begin(), all_actions.end(), triggered_actions.begin(), triggered_actions.end(), insert_iterator(exoallow_actions, exoallow_actions.begin()) ); for(StringSet::iterator n = exoallow_actions.begin(); n != exoallow_actions.end(); ++n) { cout << "action_"+*n+"(T) :- allow_action_"+*n+"(T), not "+neg+"action_"+*n+"(T), time(T), T(exoallow_actions, exoallow_actions.begin()) ); for(StringSet::iterator n = exoallow_actions.begin(); n != exoallow_actions.end(); ++n) { cout << "action_"+*n+"(T) :- allow_action_"+*n+"(T), not "+neg+"action_"+*n+"(T), not achieved(T), time(T).\n"; cout << neg+"action_"+*n+"(T) :- not action_"+*n+"(T), time(T).\n"; } cout << ":- not achieved.\n"; cout << "achieved :- achieved(0).\n"; cout << "achieved :- achieved(T+1), not achieved(T), time(T;T+1).\n"; cout << "achieved(T) :- "; for(ListPair::iterator n = $2->begin(); n != $2->end(); ++n) { if(n != $2->begin()) cout << ", "; cout_neg(n->second); cout << "fluent_"+n->first+"(T)"; } cout << ", T=n.\n"; cout << "achieved(T) :- achieved(T+1), "; for(ListPair::iterator n = $2->begin(); n != $2->end(); ++n) { if(n != $2->begin()) cout << ", "; cout_neg(n->second); cout << "fluent_"+n->first+"(T)"; } cout << ", time(T;T+1).\n"; // hides the achieve predicates if(debug < 2) cout << "#hide achieved.\n"; if(debug < 2) cout << "#hide achieved(T).\n"; delete $2; } // predict f_1,...,f_n pred_rule: PRED fluent_list { // rules for generating all possible initial states for(StringSet::iterator n = all_fluents.begin(); n != all_fluents.end(); ++n) { cout << "fluent_"+*n+"(0) :- not "+neg+"fluent_"+*n+"(0).\n"; cout << neg+"fluent_"+*n+"(0) :- not fluent_"+*n+"(0).\n"; } // justify the observations by including for every action: for(StringSet::iterator n = all_actions.begin(); n != all_actions.end(); ++n) { cout << "action_"+*n+"(T) :- allow_action_"+*n+"(T), not "+neg+"action_"+*n+"(T), time(T), Tbegin(); n != $2->end(); ++n) { if(n != $2->begin()) cout << ", "; cout_neg(n->second); cout << "fluent_"+n->first+"(T)"; } cout << ", time(T), T>="<push_back(pair(*$1, true)); delete $1; } | NEG_IDENTI { $$ = new ListPair(); $$->push_back(pair(*$1, false)); delete $1; } | fluent_list COMMA IDENTIFIER { $1->push_back(pair(*$3, true)); $$ = $1; delete $3; } | fluent_list COMMA NEG_IDENTI { $1->push_back(pair(*$3, false)); $$ = $1; delete $3; } %% void CtaidParser::postProcessing() { // trig_allow_actions = triggered_actions + allowed_actions StringSet trig_allow_actions; set_union(triggered_actions.begin(), triggered_actions.end(), allowed_actions.begin(), allowed_actions.end(), insert_iterator(trig_allow_actions, trig_allow_actions.begin()) ); // exogenous_actions = all_actions - trig_allow_actions set_difference(all_actions.begin(), all_actions.end(), trig_allow_actions.begin(), trig_allow_actions.end(), insert_iterator(exogenous_actions, exogenous_actions.begin()) ); // add rules for EXOGENOUS actions (not triggered or allowed) cout << "\n% exogenous actions\n"; for(StringSet::iterator n = exogenous_actions.begin(); n != exogenous_actions.end(); ++n) { cout << "allow_action_"+*n+"(T) :- time(T).\n"; // hides allow_action for every exogenous action if(debug < 2) cout << "#hide allow_action_"+*n+"(T).\n"; } // inertial_fluents = all_fluents - default_fluents set_difference(all_fluents.begin(), all_fluents.end(), default_fluents.begin(), default_fluents.end(), insert_iterator(inertial_fluents, inertial_fluents.begin()) ); // add rules for INERTIAL fluents (not default) cout << "\n% inertial fluents\n"; for(StringSet::iterator n = inertial_fluents.begin(); n != inertial_fluents.end(); ++n) { cout << "fluent_"+*n+"(T+1) :- fluent_"+*n+"(T), not "+neg+"fluent_"+*n+"(T+1), time(T;T+1).\n"; cout << neg+"fluent_"+*n+"(T+1) :- "+neg+"fluent_"+*n+"(T), not fluent_"+*n+"(T+1), time(T;T+1).\n"; if(neg == "neg_") { // relationship between fluent and its negation cout << ":- fluent_"+*n+"(T), neg_fluent_"+*n+"(T), time(T).\n"; // hides neg_fluent for every inertial fluent if(debug < 2) { cout << "#hide neg_fluent_"+*n+"(T).\n"; } } if(debug < 1) cout << "#hide fluent_"+*n+"(T).\n"; } // add time cout << "\n% time facts\n"; cout << "time(0..n).\n"; if(debug < 2) cout << "#hide time(N).\n"; } bool CtaidParser::cout_neg(bool not_neg) { if(not_neg) return true; else { cout << neg; return false; } } coala-1.0.1_src/src/lib/c_taid/parser.h000644 001750 001750 00000021232 11477164507 020424 0ustar00tovok7tovok7000000 000000 #ifndef YY_CtaidParser_h_included #define YY_CtaidParser_h_included #define YY_USE_CLASS #line 1 "/usr/share/bison++/bison.h" /* before anything */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #line 8 "/usr/share/bison++/bison.h" #define YY_CtaidParser_LSP_NEEDED #define YY_CtaidParser_ERROR_BODY = 0 #define YY_CtaidParser_LEX_BODY = 0 #define YY_CtaidParser_CONSTRUCTOR_PARAM Coala::CompilerOptions* options #define YY_CtaidParser_CONSTRUCTOR_CODE {debug=options->getDebug(); neg=options->getFakeClassicalNegation()?"neg_":"-";} #define YY_CtaidParser_MEMBERS void postProcessing(); bool cout_neg(bool); int debug; string neg; virtual ~CtaidParser(){}\ private:\ typedef set > StringSet;\ StringSet all_fluents;\ StringSet default_fluents;\ StringSet inertial_fluents;\ StringSet all_actions;\ StringSet triggered_actions;\ StringSet allowed_actions;\ StringSet exogenous_actions; #line 44 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" #include #include #include #include #include #include #include "../options.h" using namespace std; //using namespace C_taid; #line 64 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" typedef union { int number; const string *istring; list > *ilist; } yy_CtaidParser_stype; #define YY_CtaidParser_STYPE yy_CtaidParser_stype #line 21 "/usr/share/bison++/bison.h" /* %{ and %header{ and %union, during decl */ #ifndef YY_CtaidParser_COMPATIBILITY #ifndef YY_USE_CLASS #define YY_CtaidParser_COMPATIBILITY 1 #else #define YY_CtaidParser_COMPATIBILITY 0 #endif #endif #if YY_CtaidParser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YYLTYPE #ifndef YY_CtaidParser_LTYPE #define YY_CtaidParser_LTYPE YYLTYPE /* WARNING obsolete !!! user defined YYLTYPE not reported into generated header */ /* use %define LTYPE */ #endif #endif /*#ifdef YYSTYPE*/ #ifndef YY_CtaidParser_STYPE #define YY_CtaidParser_STYPE YYSTYPE /* WARNING obsolete !!! user defined YYSTYPE not reported into generated header */ /* use %define STYPE */ #endif /*#endif*/ #ifdef YYDEBUG #ifndef YY_CtaidParser_DEBUG #define YY_CtaidParser_DEBUG YYDEBUG /* WARNING obsolete !!! user defined YYDEBUG not reported into generated header */ /* use %define DEBUG */ #endif #endif /* use goto to be compatible */ #ifndef YY_CtaidParser_USE_GOTO #define YY_CtaidParser_USE_GOTO 1 #endif #endif /* use no goto to be clean in C++ */ #ifndef YY_CtaidParser_USE_GOTO #define YY_CtaidParser_USE_GOTO 0 #endif #ifndef YY_CtaidParser_PURE #line 65 "/usr/share/bison++/bison.h" #line 65 "/usr/share/bison++/bison.h" /* YY_CtaidParser_PURE */ #endif #line 68 "/usr/share/bison++/bison.h" #line 68 "/usr/share/bison++/bison.h" /* prefix */ #ifndef YY_CtaidParser_DEBUG #line 71 "/usr/share/bison++/bison.h" #line 71 "/usr/share/bison++/bison.h" /* YY_CtaidParser_DEBUG */ #endif #ifndef YY_CtaidParser_LSP_NEEDED #line 75 "/usr/share/bison++/bison.h" #line 75 "/usr/share/bison++/bison.h" /* YY_CtaidParser_LSP_NEEDED*/ #endif /* DEFAULT LTYPE*/ #ifdef YY_CtaidParser_LSP_NEEDED #ifndef YY_CtaidParser_LTYPE #ifndef BISON_YYLTYPE_ISDECLARED #define BISON_YYLTYPE_ISDECLARED typedef struct yyltype { int timestamp; int first_line; int first_column; int last_line; int last_column; char *text; } yyltype; #endif #define YY_CtaidParser_LTYPE yyltype #endif #endif /* DEFAULT STYPE*/ #ifndef YY_CtaidParser_STYPE #define YY_CtaidParser_STYPE int #endif /* DEFAULT MISCELANEOUS */ #ifndef YY_CtaidParser_PARSE #define YY_CtaidParser_PARSE yyparse #endif #ifndef YY_CtaidParser_LEX #define YY_CtaidParser_LEX yylex #endif #ifndef YY_CtaidParser_LVAL #define YY_CtaidParser_LVAL yylval #endif #ifndef YY_CtaidParser_LLOC #define YY_CtaidParser_LLOC yylloc #endif #ifndef YY_CtaidParser_CHAR #define YY_CtaidParser_CHAR yychar #endif #ifndef YY_CtaidParser_NERRS #define YY_CtaidParser_NERRS yynerrs #endif #ifndef YY_CtaidParser_DEBUG_FLAG #define YY_CtaidParser_DEBUG_FLAG yydebug #endif #ifndef YY_CtaidParser_ERROR #define YY_CtaidParser_ERROR yyerror #endif #ifndef YY_CtaidParser_PARSE_PARAM #ifndef __STDC__ #ifndef __cplusplus #ifndef YY_USE_CLASS #define YY_CtaidParser_PARSE_PARAM #ifndef YY_CtaidParser_PARSE_PARAM_DEF #define YY_CtaidParser_PARSE_PARAM_DEF #endif #endif #endif #endif #ifndef YY_CtaidParser_PARSE_PARAM #define YY_CtaidParser_PARSE_PARAM void #endif #endif /* TOKEN C */ #ifndef YY_USE_CLASS #ifndef YY_CtaidParser_PURE #ifndef yylval extern YY_CtaidParser_STYPE YY_CtaidParser_LVAL; #else #if yylval != YY_CtaidParser_LVAL extern YY_CtaidParser_STYPE YY_CtaidParser_LVAL; #else #warning "Namespace conflict, disabling some functionality (bison++ only)" #endif #endif #endif #line 169 "/usr/share/bison++/bison.h" #define IDENTIFIER 258 #define NEG_IDENTI 259 #define NUMBER 260 #define ACT 261 #define FLU 262 #define DEF 263 #define CAUS 264 #define IF 265 #define TRIG 266 #define ALLOW 267 #define INHIB 268 #define NCONC 269 #define AT 270 #define OC_AT 271 #define EXP 272 #define PLAN 273 #define PRED 274 #define COMMA 275 #define DOT 276 #line 169 "/usr/share/bison++/bison.h" /* #defines token */ /* after #define tokens, before const tokens S5*/ #else #ifndef YY_CtaidParser_CLASS #define YY_CtaidParser_CLASS CtaidParser #endif #ifndef YY_CtaidParser_INHERIT #define YY_CtaidParser_INHERIT #endif #ifndef YY_CtaidParser_MEMBERS #define YY_CtaidParser_MEMBERS #endif #ifndef YY_CtaidParser_LEX_BODY #define YY_CtaidParser_LEX_BODY #endif #ifndef YY_CtaidParser_ERROR_BODY #define YY_CtaidParser_ERROR_BODY #endif #ifndef YY_CtaidParser_CONSTRUCTOR_PARAM #define YY_CtaidParser_CONSTRUCTOR_PARAM #endif /* choose between enum and const */ #ifndef YY_CtaidParser_USE_CONST_TOKEN #define YY_CtaidParser_USE_CONST_TOKEN 0 /* yes enum is more compatible with flex, */ /* so by default we use it */ #endif #if YY_CtaidParser_USE_CONST_TOKEN != 0 #ifndef YY_CtaidParser_ENUM_TOKEN #define YY_CtaidParser_ENUM_TOKEN yy_CtaidParser_enum_token #endif #endif class YY_CtaidParser_CLASS YY_CtaidParser_INHERIT { public: #if YY_CtaidParser_USE_CONST_TOKEN != 0 /* static const int token ... */ #line 212 "/usr/share/bison++/bison.h" static const int IDENTIFIER; static const int NEG_IDENTI; static const int NUMBER; static const int ACT; static const int FLU; static const int DEF; static const int CAUS; static const int IF; static const int TRIG; static const int ALLOW; static const int INHIB; static const int NCONC; static const int AT; static const int OC_AT; static const int EXP; static const int PLAN; static const int PRED; static const int COMMA; static const int DOT; #line 212 "/usr/share/bison++/bison.h" /* decl const */ #else enum YY_CtaidParser_ENUM_TOKEN { YY_CtaidParser_NULL_TOKEN=0 #line 215 "/usr/share/bison++/bison.h" ,IDENTIFIER=258 ,NEG_IDENTI=259 ,NUMBER=260 ,ACT=261 ,FLU=262 ,DEF=263 ,CAUS=264 ,IF=265 ,TRIG=266 ,ALLOW=267 ,INHIB=268 ,NCONC=269 ,AT=270 ,OC_AT=271 ,EXP=272 ,PLAN=273 ,PRED=274 ,COMMA=275 ,DOT=276 #line 215 "/usr/share/bison++/bison.h" /* enum token */ }; /* end of enum declaration */ #endif public: int YY_CtaidParser_PARSE(YY_CtaidParser_PARSE_PARAM); virtual void YY_CtaidParser_ERROR(char *msg) YY_CtaidParser_ERROR_BODY; #ifdef YY_CtaidParser_PURE #ifdef YY_CtaidParser_LSP_NEEDED virtual int YY_CtaidParser_LEX(YY_CtaidParser_STYPE *YY_CtaidParser_LVAL,YY_CtaidParser_LTYPE *YY_CtaidParser_LLOC) YY_CtaidParser_LEX_BODY; #else virtual int YY_CtaidParser_LEX(YY_CtaidParser_STYPE *YY_CtaidParser_LVAL) YY_CtaidParser_LEX_BODY; #endif #else virtual int YY_CtaidParser_LEX() YY_CtaidParser_LEX_BODY; YY_CtaidParser_STYPE YY_CtaidParser_LVAL; #ifdef YY_CtaidParser_LSP_NEEDED YY_CtaidParser_LTYPE YY_CtaidParser_LLOC; #endif int YY_CtaidParser_NERRS; int YY_CtaidParser_CHAR; #endif #if YY_CtaidParser_DEBUG != 0 public: int YY_CtaidParser_DEBUG_FLAG; /* nonzero means print parse trace */ #endif public: YY_CtaidParser_CLASS(YY_CtaidParser_CONSTRUCTOR_PARAM); public: YY_CtaidParser_MEMBERS }; /* other declare folow */ #endif #if YY_CtaidParser_COMPATIBILITY != 0 /* backward compatibility */ /* Removed due to bison problems /#ifndef YYSTYPE / #define YYSTYPE YY_CtaidParser_STYPE /#endif*/ #ifndef YYLTYPE #define YYLTYPE YY_CtaidParser_LTYPE #endif #ifndef YYDEBUG #ifdef YY_CtaidParser_DEBUG #define YYDEBUG YY_CtaidParser_DEBUG #endif #endif #endif /* END */ #line 267 "/usr/share/bison++/bison.h" #endif coala-1.0.1_src/src/lib/c_taid/parser.cpp000644 001750 001750 00000147026 11477164507 020771 0ustar00tovok7tovok7000000 000000 #define YY_CtaidParser_h_included #define YY_USE_CLASS /* A Bison++ parser, made from /home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y */ /* with Bison++ version bison++ Version 1.21.9-1, adapted from GNU bison by coetmeur@icdc.fr Maintained by Magnus Ekdahl */ #define YY_USE_CLASS #line 1 "/usr/share/bison++/bison.cc" /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, when this file is copied by Bison++ into a Bison++ output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison, and has been in Bison++ since 1.21.9. */ /* HEADER SECTION */ #if defined( _MSDOS ) || defined(MSDOS) || defined(__MSDOS__) #define __MSDOS_AND_ALIKE #endif #if defined(_WINDOWS) && defined(_MSC_VER) #define __HAVE_NO_ALLOCA #define __MSDOS_AND_ALIKE #endif #ifndef alloca #if defined( __GNUC__) #define alloca __builtin_alloca #elif (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) #include #elif defined (__MSDOS_AND_ALIKE) #include #ifndef __TURBOC__ /* MS C runtime lib */ #define alloca _alloca #endif #elif defined(_AIX) /* pragma must be put before any C/C++ instruction !! */ #pragma alloca #include #elif defined(__hpux) #ifdef __cplusplus extern "C" { void *alloca (unsigned int); }; #else /* not __cplusplus */ void *alloca (); #endif /* not __cplusplus */ #endif /* not _AIX not MSDOS, or __TURBOC__ or _AIX, not sparc. */ #endif /* alloca not defined. */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #ifndef YY_USE_CLASS /*#warning "For C++ its recomended to use bison++, otherwise classes won't be generated"*/ #endif #else #ifndef __STDC__ #define const #endif #ifdef YY_USE_CLASS #error "This is a C++ header generated by bison++, please use a C++ compiler!" #endif #endif #include #define YYBISON 1 #line 88 "/usr/share/bison++/bison.cc" #define YY_CtaidParser_LSP_NEEDED #define YY_CtaidParser_ERROR_BODY = 0 #define YY_CtaidParser_LEX_BODY = 0 #define YY_CtaidParser_CONSTRUCTOR_PARAM Coala::CompilerOptions* options #define YY_CtaidParser_CONSTRUCTOR_CODE {debug=options->getDebug(); neg=options->getFakeClassicalNegation()?"neg_":"-";} #define YY_CtaidParser_MEMBERS void postProcessing(); bool cout_neg(bool); int debug; string neg; virtual ~CtaidParser(){}\ private:\ typedef set > StringSet;\ StringSet all_fluents;\ StringSet default_fluents;\ StringSet inertial_fluents;\ StringSet all_actions;\ StringSet triggered_actions;\ StringSet allowed_actions;\ StringSet exogenous_actions; #line 44 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" #include #include #include #include #include #include #include "../options.h" using namespace std; //using namespace C_taid; #line 58 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" typedef list > ListPair; int latest_obs = 0; #line 64 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" typedef union { int number; const string *istring; list > *ilist; } yy_CtaidParser_stype; #define YY_CtaidParser_STYPE yy_CtaidParser_stype #line 88 "/usr/share/bison++/bison.cc" /* %{ and %header{ and %union, during decl */ #define YY_CtaidParser_BISON 1 #ifndef YY_CtaidParser_COMPATIBILITY #ifndef YY_USE_CLASS #define YY_CtaidParser_COMPATIBILITY 1 #else #define YY_CtaidParser_COMPATIBILITY 0 #endif #endif #if YY_CtaidParser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YYLTYPE #ifndef YY_CtaidParser_LTYPE #define YY_CtaidParser_LTYPE YYLTYPE #endif #endif /* Testing alternative bison solution /#ifdef YYSTYPE*/ #ifndef YY_CtaidParser_STYPE #define YY_CtaidParser_STYPE YYSTYPE #endif /*#endif*/ #ifdef YYDEBUG #ifndef YY_CtaidParser_DEBUG #define YY_CtaidParser_DEBUG YYDEBUG #endif #endif /* use goto to be compatible */ #ifndef YY_CtaidParser_USE_GOTO #define YY_CtaidParser_USE_GOTO 1 #endif #endif /* use no goto to be clean in C++ */ #ifndef YY_CtaidParser_USE_GOTO #define YY_CtaidParser_USE_GOTO 0 #endif #ifndef YY_CtaidParser_PURE #line 130 "/usr/share/bison++/bison.cc" #line 130 "/usr/share/bison++/bison.cc" /* YY_CtaidParser_PURE */ #endif /* section apres lecture def, avant lecture grammaire S2 */ #line 134 "/usr/share/bison++/bison.cc" #line 134 "/usr/share/bison++/bison.cc" /* prefix */ #ifndef YY_CtaidParser_DEBUG #line 136 "/usr/share/bison++/bison.cc" #line 136 "/usr/share/bison++/bison.cc" /* YY_CtaidParser_DEBUG */ #endif #ifndef YY_CtaidParser_LSP_NEEDED #line 141 "/usr/share/bison++/bison.cc" #line 141 "/usr/share/bison++/bison.cc" /* YY_CtaidParser_LSP_NEEDED*/ #endif /* DEFAULT LTYPE*/ #ifdef YY_CtaidParser_LSP_NEEDED #ifndef YY_CtaidParser_LTYPE #ifndef BISON_YYLTYPE_ISDECLARED #define BISON_YYLTYPE_ISDECLARED typedef struct yyltype { int timestamp; int first_line; int first_column; int last_line; int last_column; char *text; } yyltype; #endif #define YY_CtaidParser_LTYPE yyltype #endif #endif /* DEFAULT STYPE*/ /* We used to use `unsigned long' as YY_CtaidParser_STYPE on MSDOS, but it seems better to be consistent. Most programs should declare their own type anyway. */ #ifndef YY_CtaidParser_STYPE #define YY_CtaidParser_STYPE int #endif /* DEFAULT MISCELANEOUS */ #ifndef YY_CtaidParser_PARSE #define YY_CtaidParser_PARSE yyparse #endif #ifndef YY_CtaidParser_LEX #define YY_CtaidParser_LEX yylex #endif #ifndef YY_CtaidParser_LVAL #define YY_CtaidParser_LVAL yylval #endif #ifndef YY_CtaidParser_LLOC #define YY_CtaidParser_LLOC yylloc #endif #ifndef YY_CtaidParser_CHAR #define YY_CtaidParser_CHAR yychar #endif #ifndef YY_CtaidParser_NERRS #define YY_CtaidParser_NERRS yynerrs #endif #ifndef YY_CtaidParser_DEBUG_FLAG #define YY_CtaidParser_DEBUG_FLAG yydebug #endif #ifndef YY_CtaidParser_ERROR #define YY_CtaidParser_ERROR yyerror #endif #ifndef YY_CtaidParser_PARSE_PARAM #ifndef YY_USE_CLASS #ifdef YYPARSE_PARAM #define YY_CtaidParser_PARSE_PARAM void* YYPARSE_PARAM #else #ifndef __STDC__ #ifndef __cplusplus #define YY_CtaidParser_PARSE_PARAM #endif #endif #endif #endif #ifndef YY_CtaidParser_PARSE_PARAM #define YY_CtaidParser_PARSE_PARAM void #endif #endif #if YY_CtaidParser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YY_CtaidParser_LTYPE #ifndef YYLTYPE #define YYLTYPE YY_CtaidParser_LTYPE #else /* WARNING obsolete !!! user defined YYLTYPE not reported into generated header */ #endif #endif /* Removed due to bison compabilityproblems /#ifndef YYSTYPE /#define YYSTYPE YY_CtaidParser_STYPE /#else*/ /* WARNING obsolete !!! user defined YYSTYPE not reported into generated header */ /*#endif*/ #ifdef YY_CtaidParser_PURE # ifndef YYPURE # define YYPURE YY_CtaidParser_PURE # endif #endif #ifdef YY_CtaidParser_DEBUG # ifndef YYDEBUG # define YYDEBUG YY_CtaidParser_DEBUG # endif #endif #ifndef YY_CtaidParser_ERROR_VERBOSE #ifdef YYERROR_VERBOSE #define YY_CtaidParser_ERROR_VERBOSE YYERROR_VERBOSE #endif #endif #ifndef YY_CtaidParser_LSP_NEEDED # ifdef YYLSP_NEEDED # define YY_CtaidParser_LSP_NEEDED YYLSP_NEEDED # endif #endif #endif #ifndef YY_USE_CLASS /* TOKEN C */ #line 263 "/usr/share/bison++/bison.cc" #define IDENTIFIER 258 #define NEG_IDENTI 259 #define NUMBER 260 #define ACT 261 #define FLU 262 #define DEF 263 #define CAUS 264 #define IF 265 #define TRIG 266 #define ALLOW 267 #define INHIB 268 #define NCONC 269 #define AT 270 #define OC_AT 271 #define EXP 272 #define PLAN 273 #define PRED 274 #define COMMA 275 #define DOT 276 #line 263 "/usr/share/bison++/bison.cc" /* #defines tokens */ #else /* CLASS */ #ifndef YY_CtaidParser_CLASS #define YY_CtaidParser_CLASS CtaidParser #endif #ifndef YY_CtaidParser_INHERIT #define YY_CtaidParser_INHERIT #endif #ifndef YY_CtaidParser_MEMBERS #define YY_CtaidParser_MEMBERS #endif #ifndef YY_CtaidParser_LEX_BODY #define YY_CtaidParser_LEX_BODY #endif #ifndef YY_CtaidParser_ERROR_BODY #define YY_CtaidParser_ERROR_BODY #endif #ifndef YY_CtaidParser_CONSTRUCTOR_PARAM #define YY_CtaidParser_CONSTRUCTOR_PARAM #endif #ifndef YY_CtaidParser_CONSTRUCTOR_CODE #define YY_CtaidParser_CONSTRUCTOR_CODE #endif #ifndef YY_CtaidParser_CONSTRUCTOR_INIT #define YY_CtaidParser_CONSTRUCTOR_INIT #endif /* choose between enum and const */ #ifndef YY_CtaidParser_USE_CONST_TOKEN #define YY_CtaidParser_USE_CONST_TOKEN 0 /* yes enum is more compatible with flex, */ /* so by default we use it */ #endif #if YY_CtaidParser_USE_CONST_TOKEN != 0 #ifndef YY_CtaidParser_ENUM_TOKEN #define YY_CtaidParser_ENUM_TOKEN yy_CtaidParser_enum_token #endif #endif class YY_CtaidParser_CLASS YY_CtaidParser_INHERIT { public: #if YY_CtaidParser_USE_CONST_TOKEN != 0 /* static const int token ... */ #line 307 "/usr/share/bison++/bison.cc" static const int IDENTIFIER; static const int NEG_IDENTI; static const int NUMBER; static const int ACT; static const int FLU; static const int DEF; static const int CAUS; static const int IF; static const int TRIG; static const int ALLOW; static const int INHIB; static const int NCONC; static const int AT; static const int OC_AT; static const int EXP; static const int PLAN; static const int PRED; static const int COMMA; static const int DOT; #line 307 "/usr/share/bison++/bison.cc" /* decl const */ #else enum YY_CtaidParser_ENUM_TOKEN { YY_CtaidParser_NULL_TOKEN=0 #line 310 "/usr/share/bison++/bison.cc" ,IDENTIFIER=258 ,NEG_IDENTI=259 ,NUMBER=260 ,ACT=261 ,FLU=262 ,DEF=263 ,CAUS=264 ,IF=265 ,TRIG=266 ,ALLOW=267 ,INHIB=268 ,NCONC=269 ,AT=270 ,OC_AT=271 ,EXP=272 ,PLAN=273 ,PRED=274 ,COMMA=275 ,DOT=276 #line 310 "/usr/share/bison++/bison.cc" /* enum token */ }; /* end of enum declaration */ #endif public: int YY_CtaidParser_PARSE (YY_CtaidParser_PARSE_PARAM); virtual void YY_CtaidParser_ERROR(char *msg) YY_CtaidParser_ERROR_BODY; #ifdef YY_CtaidParser_PURE #ifdef YY_CtaidParser_LSP_NEEDED virtual int YY_CtaidParser_LEX (YY_CtaidParser_STYPE *YY_CtaidParser_LVAL,YY_CtaidParser_LTYPE *YY_CtaidParser_LLOC) YY_CtaidParser_LEX_BODY; #else virtual int YY_CtaidParser_LEX (YY_CtaidParser_STYPE *YY_CtaidParser_LVAL) YY_CtaidParser_LEX_BODY; #endif #else virtual int YY_CtaidParser_LEX() YY_CtaidParser_LEX_BODY; YY_CtaidParser_STYPE YY_CtaidParser_LVAL; #ifdef YY_CtaidParser_LSP_NEEDED YY_CtaidParser_LTYPE YY_CtaidParser_LLOC; #endif int YY_CtaidParser_NERRS; int YY_CtaidParser_CHAR; #endif #if YY_CtaidParser_DEBUG != 0 int YY_CtaidParser_DEBUG_FLAG; /* nonzero means print parse trace */ #endif public: YY_CtaidParser_CLASS(YY_CtaidParser_CONSTRUCTOR_PARAM); public: YY_CtaidParser_MEMBERS }; /* other declare folow */ #if YY_CtaidParser_USE_CONST_TOKEN != 0 #line 341 "/usr/share/bison++/bison.cc" const int YY_CtaidParser_CLASS::IDENTIFIER=258; const int YY_CtaidParser_CLASS::NEG_IDENTI=259; const int YY_CtaidParser_CLASS::NUMBER=260; const int YY_CtaidParser_CLASS::ACT=261; const int YY_CtaidParser_CLASS::FLU=262; const int YY_CtaidParser_CLASS::DEF=263; const int YY_CtaidParser_CLASS::CAUS=264; const int YY_CtaidParser_CLASS::IF=265; const int YY_CtaidParser_CLASS::TRIG=266; const int YY_CtaidParser_CLASS::ALLOW=267; const int YY_CtaidParser_CLASS::INHIB=268; const int YY_CtaidParser_CLASS::NCONC=269; const int YY_CtaidParser_CLASS::AT=270; const int YY_CtaidParser_CLASS::OC_AT=271; const int YY_CtaidParser_CLASS::EXP=272; const int YY_CtaidParser_CLASS::PLAN=273; const int YY_CtaidParser_CLASS::PRED=274; const int YY_CtaidParser_CLASS::COMMA=275; const int YY_CtaidParser_CLASS::DOT=276; #line 341 "/usr/share/bison++/bison.cc" /* const YY_CtaidParser_CLASS::token */ #endif /*apres const */ YY_CtaidParser_CLASS::YY_CtaidParser_CLASS(YY_CtaidParser_CONSTRUCTOR_PARAM) YY_CtaidParser_CONSTRUCTOR_INIT { #if YY_CtaidParser_DEBUG != 0 YY_CtaidParser_DEBUG_FLAG=0; #endif YY_CtaidParser_CONSTRUCTOR_CODE; }; #endif #line 352 "/usr/share/bison++/bison.cc" #define YYFINAL 59 #define YYFLAG -32768 #define YYNTBASE 22 #define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 43) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }; #if YY_CtaidParser_DEBUG != 0 static const short yyprhs[] = { 0, 0, 1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 44, 47, 50, 56, 60, 64, 68, 72, 76, 79, 83, 87, 89, 92, 95, 97, 99, 103 }; static const short yyrhs[] = { -1, 22, 23, 21, 0, 24, 0, 25, 0, 26, 0, 27, 0, 32, 0, 31, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 28, 0, 29, 0, 30, 0, 6, 42, 0, 7, 42, 0, 8, 42, 0, 3, 9, 42, 10, 42, 0, 3, 9, 42, 0, 42, 10, 42, 0, 42, 11, 3, 0, 42, 12, 3, 0, 42, 13, 3, 0, 14, 42, 0, 42, 15, 5, 0, 42, 16, 5, 0, 17, 0, 18, 42, 0, 19, 42, 0, 3, 0, 4, 0, 42, 20, 3, 0, 42, 20, 4, 0 }; #endif #if (YY_CtaidParser_DEBUG != 0) || defined(YY_CtaidParser_ERROR_VERBOSE) static const short yyrline[] = { 0, 96, 96, 98, 98, 98, 100, 100, 100, 100, 100, 100, 100, 102, 102, 104, 104, 104, 106, 106, 106, 109, 124, 132, 157, 175, 185, 201, 223, 242, 256, 269, 289, 311, 330, 374, 403, 408, 413, 418 }; static const char * const yytname[] = { "$","error","$illegal.","IDENTIFIER", "NEG_IDENTI","NUMBER","ACT","FLU","DEF","CAUS","IF","TRIG","ALLOW","INHIB","NCONC", "AT","OC_AT","EXP","PLAN","PRED","COMMA","DOT","program","rule","desc_rule", "obs_rule","query_rule","fact","act_fact","flu_fact","def_fact","dyn_rule","static_rule", "trig_rule","allow_rule","inhib_rule","nconc_rule","flu_obs","act_obs","exp_rule", "plan_rule","pred_rule","fluent_list","" }; #endif static const short yyr1[] = { 0, 22, 22, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 29, 30, 31, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 42, 42, 42 }; static const short yyr2[] = { 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 5, 3, 3, 3, 3, 3, 2, 3, 3, 1, 2, 2, 1, 1, 3, 3 }; static const short yydefact[] = { 1, 0, 36, 37, 0, 0, 0, 0, 33, 0, 0, 0, 3, 4, 5, 6, 18, 19, 20, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 36, 21, 22, 23, 30, 34, 35, 2, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 31, 32, 38, 39, 0, 24, 0, 0 }; static const short yydefgoto[] = { 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 }; static const short yypact[] = {-32768, 4, 8,-32768, 10, 10, 10, 10,-32768, 10, 10, 3,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 18, 10,-32768, 0, 0, 0, 0, 0, 0,-32768, 10, 22, 23, 29, 30, 32, 12, -1, 0,-32768,-32768, -32768,-32768,-32768,-32768,-32768, 10, 0, 39,-32768 }; static const short yypgoto[] = {-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4 }; #define YYLAST 52 static const short yytable[] = { 33, 34, 35, 36, 58, 37, 38, 2, 3, 56, 4, 5, 6, 32, 3, 54, 55, 31, 7, 46, 46, 8, 9, 10, 39, 49, 50, 47, 40, 41, 42, 43, 51, 44, 45, 52, 48, 53, 46, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57 }; static const short yycheck[] = { 4, 5, 6, 7, 0, 9, 10, 3, 4, 10, 6, 7, 8, 3, 4, 3, 4, 9, 14, 20, 20, 17, 18, 19, 21, 3, 3, 31, 10, 11, 12, 13, 3, 15, 16, 5, 40, 5, 20, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56 }; #line 352 "/usr/share/bison++/bison.cc" /* fattrs + tables */ /* parser code folow */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* Note: dollar marks section change the next is replaced by the list of actions, each action as one case of the switch. */ #if YY_CtaidParser_USE_GOTO != 0 /* SUPRESSION OF GOTO : on some C++ compiler (sun c++) the goto is strictly forbidden if any constructor/destructor is used in the whole function (very stupid isn't it ?) so goto are to be replaced with a 'while/switch/case construct' here are the macro to keep some apparent compatibility */ #define YYGOTO(lb) {yy_gotostate=lb;continue;} #define YYBEGINGOTO enum yy_labels yy_gotostate=yygotostart; \ for(;;) switch(yy_gotostate) { case yygotostart: { #define YYLABEL(lb) } case lb: { #define YYENDGOTO } } #define YYBEGINDECLARELABEL enum yy_labels {yygotostart #define YYDECLARELABEL(lb) ,lb #define YYENDDECLARELABEL }; #else /* macro to keep goto */ #define YYGOTO(lb) goto lb #define YYBEGINGOTO #define YYLABEL(lb) lb: #define YYENDGOTO #define YYBEGINDECLARELABEL #define YYDECLARELABEL(lb) #define YYENDDECLARELABEL #endif /* LABEL DECLARATION */ YYBEGINDECLARELABEL YYDECLARELABEL(yynewstate) YYDECLARELABEL(yybackup) /* YYDECLARELABEL(yyresume) */ YYDECLARELABEL(yydefault) YYDECLARELABEL(yyreduce) YYDECLARELABEL(yyerrlab) /* here on detecting error */ YYDECLARELABEL(yyerrlab1) /* here on error raised explicitly by an action */ YYDECLARELABEL(yyerrdefault) /* current state does not do anything special for the error token. */ YYDECLARELABEL(yyerrpop) /* pop the current state because it cannot handle the error token */ YYDECLARELABEL(yyerrhandle) YYENDDECLARELABEL /* ALLOCA SIMULATION */ /* __HAVE_NO_ALLOCA */ #ifdef __HAVE_NO_ALLOCA int __alloca_free_ptr(char *ptr,char *ref) {if(ptr!=ref) free(ptr); return 0;} #define __ALLOCA_alloca(size) malloc(size) #define __ALLOCA_free(ptr,ref) __alloca_free_ptr((char *)ptr,(char *)ref) #ifdef YY_CtaidParser_LSP_NEEDED #define __ALLOCA_return(num) \ do { return( __ALLOCA_free(yyss,yyssa)+\ __ALLOCA_free(yyvs,yyvsa)+\ __ALLOCA_free(yyls,yylsa)+\ (num)); } while(0) #else #define __ALLOCA_return(num) \ do { return( __ALLOCA_free(yyss,yyssa)+\ __ALLOCA_free(yyvs,yyvsa)+\ (num)); } while(0) #endif #else #define __ALLOCA_return(num) do { return(num); } while(0) #define __ALLOCA_alloca(size) alloca(size) #define __ALLOCA_free(ptr,ref) #endif /* ENDALLOCA SIMULATION */ #define yyerrok (yyerrstatus = 0) #define yyclearin (YY_CtaidParser_CHAR = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT __ALLOCA_return(0) #define YYABORT __ALLOCA_return(1) #define YYERROR YYGOTO(yyerrlab1) /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL YYGOTO(yyerrlab) #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (YY_CtaidParser_CHAR == YYEMPTY && yylen == 1) \ { YY_CtaidParser_CHAR = (token), YY_CtaidParser_LVAL = (value); \ yychar1 = YYTRANSLATE (YY_CtaidParser_CHAR); \ YYPOPSTACK; \ YYGOTO(yybackup); \ } \ else \ { YY_CtaidParser_ERROR ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YY_CtaidParser_PURE /* UNPURE */ #define YYLEX YY_CtaidParser_LEX() #ifndef YY_USE_CLASS /* If nonreentrant, and not class , generate the variables here */ int YY_CtaidParser_CHAR; /* the lookahead symbol */ YY_CtaidParser_STYPE YY_CtaidParser_LVAL; /* the semantic value of the */ /* lookahead symbol */ int YY_CtaidParser_NERRS; /* number of parse errors so far */ #ifdef YY_CtaidParser_LSP_NEEDED YY_CtaidParser_LTYPE YY_CtaidParser_LLOC; /* location data for the lookahead */ /* symbol */ #endif #endif #else /* PURE */ #ifdef YY_CtaidParser_LSP_NEEDED #define YYLEX YY_CtaidParser_LEX(&YY_CtaidParser_LVAL, &YY_CtaidParser_LLOC) #else #define YYLEX YY_CtaidParser_LEX(&YY_CtaidParser_LVAL) #endif #endif #ifndef YY_USE_CLASS #if YY_CtaidParser_DEBUG != 0 int YY_CtaidParser_DEBUG_FLAG; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ #ifdef __cplusplus static void __yy_bcopy (char *from, char *to, int count) #else #ifdef __STDC__ static void __yy_bcopy (char *from, char *to, int count) #else static void __yy_bcopy (from, to, count) char *from; char *to; int count; #endif #endif { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #endif int #ifdef YY_USE_CLASS YY_CtaidParser_CLASS:: #endif YY_CtaidParser_PARSE(YY_CtaidParser_PARSE_PARAM) #ifndef __STDC__ #ifndef __cplusplus #ifndef YY_USE_CLASS /* parameter definition without protypes */ YY_CtaidParser_PARSE_PARAM_DEF #endif #endif #endif { register int yystate; register int yyn; register short *yyssp; register YY_CtaidParser_STYPE *yyvsp; int yyerrstatus; /* number of tokens to shift before error messages enabled */ int yychar1=0; /* lookahead token as an internal (translated) token number */ short yyssa[YYINITDEPTH]; /* the state stack */ YY_CtaidParser_STYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ short *yyss = yyssa; /* refer to the stacks thru separate pointers */ YY_CtaidParser_STYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YY_CtaidParser_LSP_NEEDED YY_CtaidParser_LTYPE yylsa[YYINITDEPTH]; /* the location stack */ YY_CtaidParser_LTYPE *yyls = yylsa; YY_CtaidParser_LTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif int yystacksize = YYINITDEPTH; #ifdef YY_CtaidParser_PURE int YY_CtaidParser_CHAR; YY_CtaidParser_STYPE YY_CtaidParser_LVAL; int YY_CtaidParser_NERRS; #ifdef YY_CtaidParser_LSP_NEEDED YY_CtaidParser_LTYPE YY_CtaidParser_LLOC; #endif #endif YY_CtaidParser_STYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ int yylen; /* start loop, in which YYGOTO may be used. */ YYBEGINGOTO #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; YY_CtaidParser_NERRS = 0; YY_CtaidParser_CHAR = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YY_CtaidParser_LSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ YYLABEL(yynewstate) *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YY_CtaidParser_STYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YY_CtaidParser_LSP_NEEDED YY_CtaidParser_LTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YY_CtaidParser_LSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YY_CtaidParser_LSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { YY_CtaidParser_ERROR("parser stack overflow"); __ALLOCA_return(2); } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; yyss = (short *) __ALLOCA_alloca (yystacksize * sizeof (*yyssp)); __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); __ALLOCA_free(yyss1,yyssa); yyvs = (YY_CtaidParser_STYPE *) __ALLOCA_alloca (yystacksize * sizeof (*yyvsp)); __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); __ALLOCA_free(yyvs1,yyvsa); #ifdef YY_CtaidParser_LSP_NEEDED yyls = (YY_CtaidParser_LTYPE *) __ALLOCA_alloca (yystacksize * sizeof (*yylsp)); __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); __ALLOCA_free(yyls1,yylsa); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YY_CtaidParser_LSP_NEEDED yylsp = yyls + size - 1; #endif #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Entering state %d\n", yystate); #endif YYGOTO(yybackup); YYLABEL(yybackup) /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* YYLABEL(yyresume) */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) YYGOTO(yydefault); /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (YY_CtaidParser_CHAR == YYEMPTY) { #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Reading a token: "); #endif YY_CtaidParser_CHAR = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (YY_CtaidParser_CHAR <= 0) /* This means end of input. */ { yychar1 = 0; YY_CtaidParser_CHAR = YYEOF; /* Don't call YYLEX any more */ #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(YY_CtaidParser_CHAR); #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) { fprintf (stderr, "Next token is %d (%s", YY_CtaidParser_CHAR, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, YY_CtaidParser_CHAR, YY_CtaidParser_LVAL); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) YYGOTO(yydefault); yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrlab); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrlab); if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Shifting token %d (%s), ", YY_CtaidParser_CHAR, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (YY_CtaidParser_CHAR != YYEOF) YY_CtaidParser_CHAR = YYEMPTY; *++yyvsp = YY_CtaidParser_LVAL; #ifdef YY_CtaidParser_LSP_NEEDED *++yylsp = YY_CtaidParser_LLOC; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; YYGOTO(yynewstate); /* Do the default action for the current state. */ YYLABEL(yydefault) yyn = yydefact[yystate]; if (yyn == 0) YYGOTO(yyerrlab); /* Do a reduction. yyn is the number of a rule to reduce with. */ YYLABEL(yyreduce) yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif #line 839 "/usr/share/bison++/bison.cc" switch (yyn) { case 21: #line 109 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { // not really a fluent_list, but I still use it for actions for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { if(neg == "neg_") { cout << ":- action_"+n->first+"(T), neg_action_"+n->first+"(T), time(T).\n"; // hides every neg_action if(debug < 2) cout << "#hide neg_action_"+n->first+"(T).\n"; } all_actions.insert(n->first); } delete yyvsp[0].ilist; ; break;} case 22: #line 124 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { all_fluents.insert(n->first); } delete yyvsp[0].ilist; ; break;} case 23: #line 132 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T) :- not "; cout_neg(!n->second); cout << "fluent_"+n->first+"(T), time(T).\n"; if(neg == "neg_") { // relationship between fluent and its negation cout << ":- fluent_"+n->first+"(T), neg_fluent_"+n->first+"(T), time(T).\n"; // hides neg_fluent for every default fluent if(debug < 2) { cout << "#hide neg_fluent_"+n->first+"(T).\n"; } } if(debug < 1) cout << "#hide fluent_"+n->first+"(T).\n"; default_fluents.insert(n->first); } delete yyvsp[0].ilist; ; break;} case 24: #line 157 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { // f_1,...,f_n cout_neg(n->second); cout << "fluent_"+n->first+"(T+1) :- action_"+*yyvsp[-4].istring+"(T), "; for(ListPair::iterator m = yyvsp[0].ilist->begin(); m != yyvsp[0].ilist->end(); ++m) { // g_1,...,g_m cout_neg(m->second); cout << "fluent_"+m->first+"(T), "; } cout << "time(T; T+1).\n"; } delete yyvsp[-4].istring; delete yyvsp[-2].ilist; delete yyvsp[0].ilist; ; break;} case 25: #line 175 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T+1) :- action_"+*yyvsp[-2].istring+"(T), time(T; T+1).\n"; } delete yyvsp[-2].istring; delete yyvsp[0].ilist; ; break;} case 26: #line 185 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T) :- "; for(ListPair::iterator m = yyvsp[0].ilist->begin(); m != yyvsp[0].ilist->end(); ++m) { cout_neg(m->second); cout << "fluent_"+m->first+"(T), "; } cout << "time(T).\n"; } delete yyvsp[-2].ilist; delete yyvsp[0].ilist; ; break;} case 27: #line 201 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { cout << "trig_action_"+*yyvsp[0].istring+"(T) :- "; for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T), "; } cout << "time(T).\n"; // trigger only when not inhibited cout << "action_"+*yyvsp[0].istring+"(T) :- trig_action_"+*yyvsp[0].istring+"(T), not "+neg+"action_"+*yyvsp[0].istring+"(T), time(T).\n"; // hides every trig_action if(debug < 2) cout << "#hide trig_action_"+*yyvsp[0].istring+"(T).\n"; triggered_actions.insert(*yyvsp[0].istring); delete yyvsp[-2].ilist; delete yyvsp[0].istring; ; break;} case 28: #line 223 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { cout << "allow_action_"+*yyvsp[0].istring+"(T) :- "; for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T), "; } cout << "time(T).\n"; // hides allow_action for every allowed action if(debug < 2) cout << "#hide allow_action_"+*yyvsp[0].istring+"(T).\n"; allowed_actions.insert(*yyvsp[0].istring); delete yyvsp[-2].ilist; delete yyvsp[0].istring; ; break;} case 29: #line 242 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { cout << neg+"action_"+*yyvsp[0].istring+"(T) :- "; for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { cout_neg(n->second); cout << "fluent_"+n->first+"(T), "; } cout << "time(T).\n"; delete yyvsp[-2].ilist; delete yyvsp[0].istring; ; break;} case 30: #line 256 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { // not really a fluent_list, but I still use it for actions cout << ":- 2 {"; for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { if(n != yyvsp[0].ilist->begin()) cout << ", "; cout << "action_"+n->first+"(T)"; } cout << "}, time(T).\n"; delete yyvsp[0].ilist; ; break;} case 31: #line 269 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { if(yyvsp[0].number == 0) { cout_neg(n->second); cout << "fluent_"+n->first+"(0).\n"; } else { cout << ":- not "; cout_neg(n->second); cout << "fluent_"+n->first+"("< latest_obs) ? yyvsp[0].number : latest_obs ; delete yyvsp[-2].ilist; ; break;} case 32: #line 289 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { for(ListPair::iterator n = yyvsp[-2].ilist->begin(); n != yyvsp[-2].ilist->end(); ++n) { // for non-exogenous actions (not triggered or allowed) if(triggered_actions.find(n->first) != triggered_actions.end() || allowed_actions.find(n->first) != allowed_actions.end()) { cout << ":- "; cout_neg(!n->second); cout << "action_"+n->first+"("<second); cout << "action_"+n->first+"("< latest_obs) ? yyvsp[0].number : latest_obs ; delete yyvsp[-2].ilist; ; break;} case 33: #line 311 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { // rules for generating all possible initial states for(StringSet::iterator n = all_fluents.begin(); n != all_fluents.end(); ++n) { cout << "fluent_"+*n+"(0) :- not "+neg+"fluent_"+*n+"(0).\n"; cout << neg+"fluent_"+*n+"(0) :- not fluent_"+*n+"(0).\n"; } // all exogenous and allowed actions in one set: all - triggered StringSet exoallow_actions; set_difference(all_actions.begin(), all_actions.end(), triggered_actions.begin(), triggered_actions.end(), insert_iterator(exoallow_actions, exoallow_actions.begin()) ); for(StringSet::iterator n = exoallow_actions.begin(); n != exoallow_actions.end(); ++n) { cout << "action_"+*n+"(T) :- allow_action_"+*n+"(T), not "+neg+"action_"+*n+"(T), time(T), T(exoallow_actions, exoallow_actions.begin()) ); for(StringSet::iterator n = exoallow_actions.begin(); n != exoallow_actions.end(); ++n) { cout << "action_"+*n+"(T) :- allow_action_"+*n+"(T), not "+neg+"action_"+*n+"(T), not achieved(T), time(T).\n"; cout << neg+"action_"+*n+"(T) :- not action_"+*n+"(T), time(T).\n"; } cout << ":- not achieved.\n"; cout << "achieved :- achieved(0).\n"; cout << "achieved :- achieved(T+1), not achieved(T), time(T;T+1).\n"; cout << "achieved(T) :- "; for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { if(n != yyvsp[0].ilist->begin()) cout << ", "; cout_neg(n->second); cout << "fluent_"+n->first+"(T)"; } cout << ", T=n.\n"; cout << "achieved(T) :- achieved(T+1), "; for(ListPair::iterator n = yyvsp[0].ilist->begin(); n != yyvsp[0].ilist->end(); ++n) { if(n != yyvsp[0].ilist->begin()) cout << ", "; cout_neg(n->second); cout << "fluent_"+n->first+"(T)"; } cout << ", time(T;T+1).\n"; // hides the achieve predicates if(debug < 2) cout << "#hide achieved.\n"; if(debug < 2) cout << "#hide achieved(T).\n"; delete yyvsp[0].ilist; ; break;} case 35: #line 374 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { // rules for generating all possible initial states for(StringSet::iterator n = all_fluents.begin(); n != all_fluents.end(); ++n) { cout << "fluent_"+*n+"(0) :- not "+neg+"fluent_"+*n+"(0).\n"; cout << neg+"fluent_"+*n+"(0) :- not fluent_"+*n+"(0).\n"; } // justify the observations by including for every action: for(StringSet::iterator n = all_actions.begin(); n != all_actions.end(); ++n) { cout << "action_"+*n+"(T) :- allow_action_"+*n+"(T), not "+neg+"action_"+*n+"(T), time(T), Tbegin(); n != yyvsp[0].ilist->end(); ++n) { if(n != yyvsp[0].ilist->begin()) cout << ", "; cout_neg(n->second); cout << "fluent_"+n->first+"(T)"; } cout << ", time(T), T>="<push_back(pair(*yyvsp[0].istring, true)); delete yyvsp[0].istring; ; break;} case 37: #line 408 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { yyval.ilist = new ListPair(); yyval.ilist->push_back(pair(*yyvsp[0].istring, false)); delete yyvsp[0].istring; ; break;} case 38: #line 413 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { yyvsp[-2].ilist->push_back(pair(*yyvsp[0].istring, true)); yyval.ilist = yyvsp[-2].ilist; delete yyvsp[0].istring; ; break;} case 39: #line 418 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" { yyvsp[-2].ilist->push_back(pair(*yyvsp[0].istring, false)); yyval.ilist = yyvsp[-2].ilist; delete yyvsp[0].istring; ; break;} } #line 839 "/usr/share/bison++/bison.cc" /* the action file gets copied in in place of this dollarsign */ yyvsp -= yylen; yyssp -= yylen; #ifdef YY_CtaidParser_LSP_NEEDED yylsp -= yylen; #endif #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YY_CtaidParser_LSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = YY_CtaidParser_LLOC.first_line; yylsp->first_column = YY_CtaidParser_LLOC.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; YYGOTO(yynewstate); YYLABEL(yyerrlab) /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++YY_CtaidParser_NERRS; #ifdef YY_CtaidParser_ERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; msg = (char *) malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); if (count < 5) { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; } } YY_CtaidParser_ERROR(msg); free(msg); } else YY_CtaidParser_ERROR ("parse error; also virtual memory exceeded"); } else #endif /* YY_CtaidParser_ERROR_VERBOSE */ YY_CtaidParser_ERROR("parse error"); } YYGOTO(yyerrlab1); YYLABEL(yyerrlab1) /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (YY_CtaidParser_CHAR == YYEOF) YYABORT; #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Discarding token %d (%s).\n", YY_CtaidParser_CHAR, yytname[yychar1]); #endif YY_CtaidParser_CHAR = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ YYGOTO(yyerrhandle); YYLABEL(yyerrdefault) /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) YYGOTO(yydefault); #endif YYLABEL(yyerrpop) /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YY_CtaidParser_LSP_NEEDED yylsp--; #endif #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif YYLABEL(yyerrhandle) yyn = yypact[yystate]; if (yyn == YYFLAG) YYGOTO(yyerrdefault); yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) YYGOTO(yyerrdefault); yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrpop); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrpop); if (yyn == YYFINAL) YYACCEPT; #if YY_CtaidParser_DEBUG != 0 if (YY_CtaidParser_DEBUG_FLAG) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = YY_CtaidParser_LVAL; #ifdef YY_CtaidParser_LSP_NEEDED *++yylsp = YY_CtaidParser_LLOC; #endif yystate = yyn; YYGOTO(yynewstate); /* end loop, in which YYGOTO may be used. */ YYENDGOTO } /* END */ #line 1038 "/usr/share/bison++/bison.cc" #line 424 "/home/tovok7/svn/potassco/coala/src/lib/c_taid/parser.y" void CtaidParser::postProcessing() { // trig_allow_actions = triggered_actions + allowed_actions StringSet trig_allow_actions; set_union(triggered_actions.begin(), triggered_actions.end(), allowed_actions.begin(), allowed_actions.end(), insert_iterator(trig_allow_actions, trig_allow_actions.begin()) ); // exogenous_actions = all_actions - trig_allow_actions set_difference(all_actions.begin(), all_actions.end(), trig_allow_actions.begin(), trig_allow_actions.end(), insert_iterator(exogenous_actions, exogenous_actions.begin()) ); // add rules for EXOGENOUS actions (not triggered or allowed) cout << "\n% exogenous actions\n"; for(StringSet::iterator n = exogenous_actions.begin(); n != exogenous_actions.end(); ++n) { cout << "allow_action_"+*n+"(T) :- time(T).\n"; // hides allow_action for every exogenous action if(debug < 2) cout << "#hide allow_action_"+*n+"(T).\n"; } // inertial_fluents = all_fluents - default_fluents set_difference(all_fluents.begin(), all_fluents.end(), default_fluents.begin(), default_fluents.end(), insert_iterator(inertial_fluents, inertial_fluents.begin()) ); // add rules for INERTIAL fluents (not default) cout << "\n% inertial fluents\n"; for(StringSet::iterator n = inertial_fluents.begin(); n != inertial_fluents.end(); ++n) { cout << "fluent_"+*n+"(T+1) :- fluent_"+*n+"(T), not "+neg+"fluent_"+*n+"(T+1), time(T;T+1).\n"; cout << neg+"fluent_"+*n+"(T+1) :- "+neg+"fluent_"+*n+"(T), not fluent_"+*n+"(T+1), time(T;T+1).\n"; if(neg == "neg_") { // relationship between fluent and its negation cout << ":- fluent_"+*n+"(T), neg_fluent_"+*n+"(T), time(T).\n"; // hides neg_fluent for every inertial fluent if(debug < 2) { cout << "#hide neg_fluent_"+*n+"(T).\n"; } } if(debug < 1) cout << "#hide fluent_"+*n+"(T).\n"; } // add time cout << "\n% time facts\n"; cout << "time(0..n).\n"; if(debug < 2) cout << "#hide time(N).\n"; } bool CtaidParser::cout_neg(bool not_neg) { if(not_neg) return true; else { cout << neg; return false; } } coala-1.0.1_src/src/lib/c_taid/compiler.h000644 001750 001750 00000002765 11477164507 020754 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c_taid/compiler.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #undef yyFlexLexer #define yyFlexLexer ctaidFlexLexer #include #include #include "../main.h" #include "../options.h" #include "parser.h" namespace C_taid { class Compiler : public Coala::AbstractCompiler, public CtaidParser { private: ctaidFlexLexer lexer; public: Compiler(Coala::CompilerOptions*); virtual ~Compiler(); int compile(); int yylex(); void yyerror(char*); void change_input(std::istream*); }; }; coala-1.0.1_src/src/lib/c_taid/scanner.l000644 001750 001750 00000006604 11477164507 020573 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c_taid/scanner.l - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ %{ #include "parser.h" #include bool second_part = false; bool asked_query = false; void printPartError(const string, const int); void printQueryError(const string, const int); %} %option yylineno nounput noyywrap c++ prefix="ctaid" IDENTIFIER [a-zA-Z][a-zA-Z0-9_]* NEG_IDENTI \-[a-zA-Z0-9_]+ NUMBER [0-9]+ COMMENT \%.*\n ACT FLU DEF CAUS IF TRIG ALLOW INHIB NCONC AT OCAT EXP PLAN PRED %% [\t\n ]+ // ignore white space. {ACT} { if(second_part) printPartError(yytext, lineno()); else return CtaidParser::ACT; } {FLU} { return CtaidParser::FLU; } {DEF} { return CtaidParser::DEF; } {CAUS} { return CtaidParser::CAUS; } {IF} { return CtaidParser::IF; } {TRIG} { if(second_part) printPartError(yytext, lineno()); else return CtaidParser::TRIG; } {ALLOW} { if(second_part) printPartError(yytext, lineno()); else return CtaidParser::ALLOW; } {INHIB} { return CtaidParser::INHIB; } {NCONC} { return CtaidParser::NCONC; } {AT} { return CtaidParser::AT; } {OCAT} { second_part = true; return CtaidParser::OC_AT; } {EXP} { if(asked_query) printQueryError(yytext, lineno()); else { asked_query = true; return CtaidParser::EXP; } } {PLAN} { if(asked_query) printQueryError(yytext, lineno()); else { asked_query = true; return CtaidParser::PLAN; } } {PRED} { if(asked_query) printQueryError(yytext, lineno()); else { asked_query = true; return CtaidParser::PRED; } } {IDENTIFIER} { return CtaidParser::IDENTIFIER; } {NEG_IDENTI} { return CtaidParser::NEG_IDENTI; } {NUMBER} { return CtaidParser::NUMBER; } "," { return CtaidParser::COMMA; } "." { return CtaidParser::DOT; } {COMMENT} { /* comment */ } <> { yyterminate(); } . { cerr << "\n\nError: Unknown keyword '"+string(yytext)+"' found at line "<getInputStream()); } Compiler::~Compiler() { } int Compiler::compile() { return yyparse(); } int Compiler::yylex() { int token = lexer.yylex(); if(token == IDENTIFIER) yylval.istring = new string(lexer.YYText()); else { if(token == NEG_IDENTI) { // remove leading negation sign '-' from fluent string *tmp_str = new string(lexer.YYText()); tmp_str->erase(0,1); yylval.istring = tmp_str; } else { if(token == NUMBER) yylval.number = atoi(lexer.YYText()); } } yylloc.first_line = lexer.lineno(); yylloc.last_line = lexer.lineno(); yylloc.text = (char *)lexer.YYText(); return token; } void Compiler::yyerror(char *m) { if(strcmp(yylloc.text, "\n") == 0) yylloc.text = (char*)"[newline]"; cerr << "\n\ncoala: Error: Syntax error in line "< namespace C { class FluentDefinition : virtual public Statement { public: FluentDefinition(int line, Formula* fluent_list, Types* types=NULL); virtual ~FluentDefinition ( ); void print(Printer*, bool); protected: void printFakeNeg(Printer* p); Formula* F_; }; }; // end of package namespace #endif // FLUENTDEFINITION_H coala-1.0.1_src/src/lib/c/RQuery.cpp000644 001750 001750 00000002433 11477164507 017713 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/RQuery.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "RQuery.h" using namespace C; RQuery::RQuery(int line, Formula* F, Formula* A, string* time, Types* types) : Query(line, types) { F_ = F; A_ = A; time_ = *time; } RQuery::~RQuery ( ) { } void RQuery::print(Printer* p) { } coala-1.0.1_src/src/lib/c/Types.h000644 001750 001750 00000003447 11477164507 017243 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Types.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef TYPES_H #define TYPES_H #include #include #include #include #include "Type.h" #include "Constraint.h" namespace C { class Types { public: Types(); Types(Type*); Types(Constraint*); virtual ~Types ( ); set* getVariables(); void addType(Type*); void addType(Constraint*); string getAsString(Printer*, set*, int); void print(Printer* p, set* vars, int line); bool printTypes(Printer*, set*, vector*); void printConstraints(Printer*, set*, vector*, bool); void check(set* vars, int line); private: vector types_; vector constraints_; }; }; // end of package namespace #endif // TYPES_H coala-1.0.1_src/src/lib/c/Type.cpp000644 001750 001750 00000003031 11477164507 017400 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Type.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Type.h" using namespace C; Type::Type(string* name, Arguments* args, bool sign) : Identifier(name, args) { sign_ = sign; } Type::~Type() { } void Type::setMin(int number) { args_->setMin(number); } void Type::setMax(int number) { args_->setMax(number); } int Type::getMin() { return args_->getMin(); } int Type::getMax() { return args_->getMax(); } bool Type::isTrue() { return sign_; } string Type::print(Printer* p) { return getName() + "(" + args_->print(p) + ")"; } coala-1.0.1_src/src/lib/c/Formula.h000644 001750 001750 00000003736 11477164507 017545 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Formula.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef FORMULA_H #define FORMULA_H #include "Types.h" #include #include #include #include namespace C { class FluentAction; class Formula { public: Formula(); Formula(char, Formula*); Formula(char, vector*); virtual ~Formula(); void addPart(Formula*); char getType(); Formula* getFirstFormula(); vector::iterator begin(); vector::iterator end(); void insert(vector::iterator, vector::iterator, vector::iterator); Formula* invert(); FluentAction* getFluentAction(); bool isTrue(); bool isFalse(); void print(Printer*, set*, string T=""); void printAlsoActions(Printer*, set*, string T=""); void printCompositeFluents(Printer*, Types*); void printCompositeFluentActions(Printer*, Types*); protected: char type_; private: vector* I_; }; }; // end of package namespace #endif // FORMULA_H coala-1.0.1_src/src/lib/c/Types.cpp000644 001750 001750 00000015124 11477164507 017571 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Types.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Types.h" using namespace C; Types::Types() { types_ = vector(); constraints_ = vector(); } Types::Types(Type* identifier) { types_ = vector(1, identifier); constraints_ = vector(); } Types::Types(Constraint* constraint) { types_ = vector(); constraints_ = vector(1, constraint); } Types::~Types ( ) { } set* Types::getVariables() { set* vars = new set(); if(!types_.empty()) { for(vector::iterator n = types_.begin(); n!= types_.end(); ++n) { // only return variables that don't need additional type information if((*n)->isTrue()) { set* tmp_vars = (*n)->getVariables(); if(!tmp_vars->empty()) { vars->insert(tmp_vars->begin(), tmp_vars->end()); } } } // end for } if(!constraints_.empty()) { for(vector::iterator n = constraints_.begin(); n!= constraints_.end(); ++n) { // only return variables that don't need additional type information if((*n)->getType() == "==") { set* tmp_vars = (*n)->getVariables(); if(!tmp_vars->empty()) { vars->insert(tmp_vars->begin(), tmp_vars->end()); } delete tmp_vars; } } // end for constraint loop } return vars; } void Types::addType(Type* identifier) { types_.push_back(identifier); } void Types::addType(Constraint* constraint) { constraints_.push_back(constraint); } string Types::getAsString(Printer* p, set* variables, int line) { std::stringstream tmp_stream; Printer* tmp_p = new Printer( &tmp_stream, p->debug, p->fake_neg, p->inc, p->rev, p->no_w_chk, p->no_direct_enc, p->lang); print(tmp_p, variables, line); delete tmp_p; return tmp_stream.str(); } void Types::print(Printer* p, set* variables, int line) { // take variables from constraints into account for(vector::iterator constraint = constraints_.begin(); constraint != constraints_.end(); ++constraint) { set* constraint_vars = (*constraint)->getVariables(); variables->insert(constraint_vars->begin(), constraint_vars->end()); delete constraint_vars; } if(!p->no_w_chk) { if(variables) check(variables, line); else { set* vars = new set(); check(vars, line); delete vars; } } bool printed = printTypes(p, variables, &types_); printConstraints(p, variables, &constraints_, printed); } bool Types::printTypes(Printer* p, set* variables, vector* vec) { bool printed = false; if(!vec->empty()) { for(vector::iterator n = vec->begin(); n != vec->end(); ++n) { //set* type_vars = (*n)->getVariables(); //set result; //insert_iterator< set > res_ins(result, result.begin()); //set_intersection(type_vars->begin(), type_vars->end(), variables->begin(), variables->end(), res_ins); // only add types that have variables that are actually used and drop the rest //if(!result.empty()) { string type = (*n)->print(p); string restricted = ""; int min = (*n)->getMin(); int max = (*n)->getMax(); // type grounding has been restricted if(min != -1 || max != -1) { restricted = "restricted_"; string min_str; string max_str; stringstream ss; ss << min; ss >> min_str; ss.clear(); ss << max; ss >> max_str; if(min != -1) p->addExtra(min_str + " "); p->addExtra("{ " + restricted + type + " : " + type + " }"); if(max != -1) p->addExtra(" " + max_str); p->addExtra(".\n"); } if(printed) p->add(", "); if(!(*n)->isTrue()) p->add("not "); p->add(restricted + type); printed = true; //} } // end for } return printed; } void Types::printConstraints(Printer* p, set* variables, vector* vec, bool printed) { if(!vec->empty()) { for(vector::iterator n = vec->begin(); n != vec->end(); ++n) { //set* type_vars = (*n)->getVariables(); //set result; //insert_iterator< set > res_ins(result, result.begin()); //set_intersection(type_vars->begin(), type_vars->end(), variables->begin(), variables->end(), res_ins); // only add types that have variables that are actually used and drop the rest //if(!result.empty()) { if(printed) p->add(", "); p->add((*n)->print(p)); printed = true; //} //delete type_vars; } } } void Types::check(set* vars, int line) { set* type_vars = getVariables(); if(*vars != *type_vars) { string error; stringstream ss; ss << line; ss >> error; if(!type_vars->empty()) { set::iterator type = type_vars->begin(); for(set::iterator var = vars->begin(); var != vars->end(); ++var) { Variable* v = *var; Variable* t = *type; bool out = false; if(v != t) { for(; type != type_vars->end();) { if(v == *type) { out = true; break; } else if(++type == type_vars->end()) { throw std::runtime_error("Variable "+v->getText()+" not defined in line "+error+".\n"); } } } if(out) break; if(++type == type_vars->end()) { string var_name; if(var == vars->end()) { var_name = v->getText(); } else { var_name = (*++var)->getText(); } throw std::runtime_error("Variable "+var_name+" not defined in line "+error+".\n"); } } // end for } else { throw std::runtime_error("No Variables defined at line "+error+". Hint: Types with 'not' are not defining.\n"); } } delete type_vars; } coala-1.0.1_src/src/lib/c/Identifier.h000644 001750 001750 00000003121 11477164507 020206 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Identifier.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef IDENTIFIER_H #define IDENTIFIER_H #include #include #include "Variable.h" #include "Arguments.h" #include namespace C { class Identifier { public: // Identifier(); Identifier(string* name, Arguments* args); Identifier(string* name); virtual ~Identifier(); //virtual string print(Printer*, string T=""); string getName(); /** * @return vector */ set* getVariables(); protected: Arguments* args_; string name_; }; }; // end of package namespace #endif // IDENTIFIER_H coala-1.0.1_src/src/lib/c/Scanner.cpp000644 001750 001750 00000156670 11477164507 020072 0ustar00tovok7tovok7000000 000000 #line 2 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.cpp" #line 4 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.cpp" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* The c++ scanner is a mess. The FlexLexer.h header file relies on the * following macro. This is required in order to pass the c++-multiple-scanners * test in the regression suite. We get reports that it breaks inheritance. * We will address this in a future release of flex, or omit the C++ scanner * altogether. */ #define yyFlexLexer cFlexLexer /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* begin standard C++ headers. */ #include #include #include #include #include /* end standard C++ headers. */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. * Ditto for the __ia64__ case accordingly. */ #define YY_BUF_SIZE 32768 #else #define YY_BUF_SIZE 16384 #endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif extern int yyleng; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ int yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { std::istream* yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] void *calloc (yy_size_t ); void *crealloc (void *,yy_size_t ); void cfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; #define yytext_ptr yytext #define YY_INTERACTIVE #include int yyFlexLexer::yywrap() { return 1; } /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 60 #define YY_END_OF_BUFFER 61 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[190] = { 0, 0, 0, 0, 0, 61, 59, 1, 1, 54, 59, 51, 39, 40, 49, 47, 34, 48, 38, 50, 32, 36, 35, 43, 59, 44, 52, 33, 33, 53, 30, 30, 30, 55, 4, 5, 7, 6, 3, 1, 42, 0, 58, 56, 31, 37, 32, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 46, 33, 33, 30, 30, 30, 31, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 29, 8, 0, 0, 0, 28, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 13, 0, 0, 0, 0, 15, 0, 0, 26, 0, 0, 0, 0, 0, 22, 9, 19, 11, 18, 0, 10, 0, 0, 0, 0, 0, 0, 25, 16, 0, 0, 0, 0, 0, 0, 24, 17, 0, 0, 0, 0, 20, 0, 0, 23, 0, 0, 27, 0, 0, 21, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 1, 6, 7, 1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 18, 19, 20, 21, 22, 1, 23, 23, 23, 23, 23, 24, 25, 23, 23, 23, 23, 26, 23, 23, 23, 23, 23, 27, 23, 28, 29, 23, 23, 30, 23, 23, 1, 1, 1, 31, 32, 1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 39, 39, 42, 43, 44, 45, 39, 39, 46, 47, 48, 49, 39, 50, 51, 52, 39, 1, 53, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[54] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1 } ; static yyconst flex_int16_t yy_base[195] = { 0, 0, 0, 30, 37, 231, 232, 66, 69, 210, 226, 232, 232, 232, 232, 232, 232, 207, 213, 232, 210, 232, 232, 61, 205, 204, 232, 0, 195, 232, 0, 177, 176, 232, 0, 0, 0, 0, 0, 73, 232, 217, 232, 232, 0, 232, 203, 197, 232, 44, 184, 179, 23, 170, 40, 181, 43, 178, 166, 171, 232, 232, 0, 184, 0, 173, 160, 0, 232, 159, 158, 155, 183, 154, 164, 159, 151, 157, 177, 160, 144, 160, 150, 158, 143, 154, 173, 0, 0, 148, 151, 154, 232, 139, 152, 137, 146, 146, 232, 135, 176, 142, 141, 128, 139, 129, 232, 129, 127, 120, 134, 121, 132, 124, 120, 118, 130, 117, 112, 116, 140, 123, 115, 137, 110, 51, 114, 134, 106, 79, 112, 119, 104, 113, 102, 232, 127, 126, 232, 125, 124, 123, 95, 232, 121, 108, 232, 107, 90, 105, 102, 86, 232, 232, 232, 232, 232, 115, 232, 87, 92, 86, 86, 82, 97, 232, 232, 108, 107, 90, 84, 74, 71, 232, 232, 89, 66, 70, 74, 232, 41, 57, 232, 68, 43, 232, 26, 37, 232, 232, 111, 113, 116, 119, 122 } ; static yyconst flex_int16_t yy_def[195] = { 0, 189, 1, 1, 1, 189, 189, 189, 189, 189, 190, 189, 189, 189, 189, 189, 189, 191, 189, 189, 189, 189, 189, 189, 189, 189, 189, 192, 192, 189, 193, 193, 193, 189, 192, 192, 192, 192, 192, 189, 189, 190, 189, 189, 194, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 192, 192, 193, 193, 193, 194, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 192, 193, 193, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 0, 189, 189, 189, 189, 189 } ; static yyconst flex_int16_t yy_nxt[286] = { 0, 6, 7, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 27, 28, 27, 27, 27, 27, 29, 6, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 32, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 35, 75, 36, 188, 37, 38, 34, 35, 187, 36, 76, 37, 38, 39, 39, 39, 39, 39, 39, 47, 39, 39, 39, 78, 69, 81, 48, 70, 145, 79, 186, 71, 140, 82, 185, 164, 184, 72, 183, 49, 182, 50, 51, 141, 52, 146, 53, 54, 181, 55, 56, 57, 165, 180, 58, 179, 59, 41, 41, 41, 41, 44, 44, 62, 178, 62, 64, 177, 64, 67, 176, 67, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 144, 143, 142, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 80, 77, 74, 73, 68, 46, 42, 66, 65, 63, 61, 60, 46, 45, 43, 42, 40, 189, 5, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189 } ; static yyconst flex_int16_t yy_chk[286] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 52, 3, 187, 3, 3, 4, 4, 186, 4, 52, 4, 4, 7, 7, 7, 8, 8, 8, 23, 39, 39, 39, 54, 49, 56, 23, 49, 129, 54, 184, 49, 125, 56, 183, 151, 181, 49, 180, 23, 178, 23, 23, 125, 23, 129, 23, 23, 177, 23, 23, 23, 151, 176, 23, 175, 23, 190, 190, 190, 190, 191, 191, 192, 172, 192, 193, 171, 193, 194, 170, 194, 169, 168, 167, 164, 163, 162, 161, 160, 159, 157, 150, 149, 148, 147, 145, 144, 142, 141, 140, 139, 137, 136, 134, 133, 132, 131, 130, 128, 127, 126, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 105, 104, 103, 102, 101, 100, 99, 97, 96, 95, 94, 93, 91, 90, 89, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 66, 65, 63, 59, 58, 57, 55, 53, 51, 50, 47, 46, 41, 32, 31, 28, 25, 24, 20, 18, 17, 10, 9, 5, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[61] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #line 1 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" /**************************************************************************** * lib/c/Scanner.l - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #line 21 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" #include #include "Parser.h" #line 586 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.cpp" #define INITIAL 0 #define ltl 1 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ #define YY_READ_BUF_SIZE 16384 #else #define YY_READ_BUF_SIZE 8192 #endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO #define ECHO LexerOutput( yytext, yyleng ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ \ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) LexerError( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 #define YY_DECL int yyFlexLexer::yylex() #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 57 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" #line 694 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.cpp" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = & std::cin; if ( ! yyout ) yyout = & std::cout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 190 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 232 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) yylineno++; ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: /* rule 1 can match eol */ YY_RULE_SETUP #line 58 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" // ignore white space. YY_BREAK case 2: YY_RULE_SETUP #line 59 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { BEGIN(ltl); return Parser::LTL; } YY_BREAK case 3: YY_RULE_SETUP #line 60 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::X; } YY_BREAK case 4: YY_RULE_SETUP #line 61 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::F; } YY_BREAK case 5: YY_RULE_SETUP #line 62 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::G; } YY_BREAK case 6: YY_RULE_SETUP #line 63 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::U; } YY_BREAK case 7: YY_RULE_SETUP #line 64 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::R; } YY_BREAK case 8: YY_RULE_SETUP #line 65 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::NOT; } YY_BREAK case 9: YY_RULE_SETUP #line 66 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::ACT; } YY_BREAK case 10: YY_RULE_SETUP #line 67 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::FLU; } YY_BREAK case 11: YY_RULE_SETUP #line 68 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::CAUS; } YY_BREAK case 12: YY_RULE_SETUP #line 69 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::IF; } YY_BREAK case 13: YY_RULE_SETUP #line 70 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::AFTER; } YY_BREAK case 14: YY_RULE_SETUP #line 71 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::TRUE; } YY_BREAK case 15: YY_RULE_SETUP #line 72 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::FALSE; } YY_BREAK case 16: YY_RULE_SETUP #line 73 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::DEF; } YY_BREAK case 17: YY_RULE_SETUP #line 74 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::INERT; } YY_BREAK case 18: YY_RULE_SETUP #line 75 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::CAUSES; } YY_BREAK case 19: YY_RULE_SETUP #line 76 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::ALWAYS; } YY_BREAK case 20: YY_RULE_SETUP #line 77 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::MAY; } YY_BREAK case 21: YY_RULE_SETUP #line 78 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::NONEXE; } YY_BREAK case 22: YY_RULE_SETUP #line 79 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::WHERE; } YY_BREAK case 23: YY_RULE_SETUP #line 80 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::OC_AT; } YY_BREAK case 24: YY_RULE_SETUP #line 81 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::HO_AT; } YY_BREAK case 25: YY_RULE_SETUP #line 82 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::OCCURS; } YY_BREAK case 26: YY_RULE_SETUP #line 83 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::HOLDS; } YY_BREAK case 27: YY_RULE_SETUP #line 84 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::NECES; } YY_BREAK case 28: YY_RULE_SETUP #line 85 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::AT; } YY_BREAK case 29: YY_RULE_SETUP #line 86 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::MOD; } YY_BREAK case 30: YY_RULE_SETUP #line 87 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::IDENTIFIER; } YY_BREAK case 31: YY_RULE_SETUP #line 88 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::NEG_IDENTI; } YY_BREAK case 32: YY_RULE_SETUP #line 89 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::NUMBER; } YY_BREAK case 33: YY_RULE_SETUP #line 90 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::VARIABLE; } YY_BREAK case 34: YY_RULE_SETUP #line 91 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::COMMA; } YY_BREAK case 35: YY_RULE_SETUP #line 92 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::SEMIC; } YY_BREAK case 36: YY_RULE_SETUP #line 93 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::COLON; } YY_BREAK case 37: YY_RULE_SETUP #line 94 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::DDOT; } YY_BREAK case 38: YY_RULE_SETUP #line 95 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { BEGIN(0); return Parser::DOT; } YY_BREAK case 39: YY_RULE_SETUP #line 96 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::LBRAC; } YY_BREAK case 40: YY_RULE_SETUP #line 97 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::RBRAC; } YY_BREAK case 41: YY_RULE_SETUP #line 98 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::EQ; } YY_BREAK case 42: YY_RULE_SETUP #line 99 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::NEQ; } YY_BREAK case 43: YY_RULE_SETUP #line 100 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::LT; } YY_BREAK case 44: YY_RULE_SETUP #line 101 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::GT; } YY_BREAK case 45: YY_RULE_SETUP #line 102 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::LE; } YY_BREAK case 46: YY_RULE_SETUP #line 103 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::GE; } YY_BREAK case 47: YY_RULE_SETUP #line 104 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::PLUS; } YY_BREAK case 48: YY_RULE_SETUP #line 105 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::MINUS; } YY_BREAK case 49: YY_RULE_SETUP #line 106 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::TIMES; } YY_BREAK case 50: YY_RULE_SETUP #line 107 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::DIV; } YY_BREAK case 51: YY_RULE_SETUP #line 108 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::AND; } YY_BREAK case 52: YY_RULE_SETUP #line 109 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::OR; } YY_BREAK case 53: YY_RULE_SETUP #line 110 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::XOR; } YY_BREAK case 54: YY_RULE_SETUP #line 111 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::LTLNOT; } YY_BREAK case 55: YY_RULE_SETUP #line 112 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::LTLOR; } YY_BREAK case 56: YY_RULE_SETUP #line 113 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::IMPL; } YY_BREAK case 57: YY_RULE_SETUP #line 114 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { return Parser::EQUIV; } YY_BREAK case 58: /* rule 58 can match eol */ YY_RULE_SETUP #line 115 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { /* comment */ } YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(ltl): #line 116 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { yyterminate(); } YY_BREAK case 59: YY_RULE_SETUP #line 117 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" { cerr << "\n\nError: Unknown keyword '"+string(yytext)+"' found at line "<yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) { yyin = arg_yyin; yyout = arg_yyout; yy_c_buf_p = 0; yy_init = 0; yy_start = 0; yy_flex_debug = 0; yylineno = 1; // this will only get updated if %option yylineno yy_did_buffer_switch_on_eof = 0; yy_looking_for_trail_begin = 0; yy_more_flag = 0; yy_more_len = 0; yy_more_offset = yy_prev_more_offset = 0; yy_start_stack_ptr = yy_start_stack_depth = 0; yy_start_stack = NULL; yy_buffer_stack = 0; yy_buffer_stack_top = 0; yy_buffer_stack_max = 0; yy_state_buf = 0; } /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::~yyFlexLexer() { delete [] yy_state_buf; cfree(yy_start_stack ); yy_delete_buffer( YY_CURRENT_BUFFER ); cfree(yy_buffer_stack ); } /* The contents of this function are C++ specific, so the () macro is not used. */ void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) { if ( new_in ) { yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); } if ( new_out ) yyout = new_out; } #ifdef YY_INTERACTIVE int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) #else int yyFlexLexer::LexerInput( char* buf, int max_size ) #endif { if ( yyin->eof() || yyin->fail() ) return 0; #ifdef YY_INTERACTIVE yyin->get( buf[0] ); if ( yyin->eof() ) return 0; if ( yyin->bad() ) return -1; return 1; #else (void) yyin->read( buf, max_size ); if ( yyin->bad() ) return -1; else return yyin->gcount(); #endif } void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout->write( buf, size ); } /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ int yyFlexLexer::yy_get_next_buffer() { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ crealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) crealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ yy_state_type yyFlexLexer::yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 190 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) { register int yy_is_jam; register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 190 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 189); return yy_is_jam ? 0 : yy_current_state; } void yyFlexLexer::yyunput( int c, register char* yy_bp) { register char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = (yy_n_chars) + 2; register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; if ( c == '\n' ){ --yylineno; } (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } int yyFlexLexer::yyinput() { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); if ( c == '\n' ) yylineno++; ; return c; } /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyFlexLexer::yyrestart( std::istream* input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_init_buffer( YY_CURRENT_BUFFER, input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } void yyFlexLexer::yy_load_buffer_state() { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) calloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) calloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) cfree((void *) b->yy_ch_buf ); cfree((void *) b ); } extern "C" int isatty (int ); /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) { int oerrno = errno; yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yyFlexLexer::yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ void yyFlexLexer::yyensure_buffer_stack(void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)calloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)crealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } void yyFlexLexer::yy_push_state( int new_state ) { if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) { yy_size_t new_size; (yy_start_stack_depth) += YY_START_STACK_INCR; new_size = (yy_start_stack_depth) * sizeof( int ); if ( ! (yy_start_stack) ) (yy_start_stack) = (int *) calloc(new_size ); else (yy_start_stack) = (int *) crealloc((void *) (yy_start_stack),new_size ); if ( ! (yy_start_stack) ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; BEGIN(new_state); } void yyFlexLexer::yy_pop_state() { if ( --(yy_start_stack_ptr) < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); } int yyFlexLexer::yy_top_state() { return (yy_start_stack)[(yy_start_stack_ptr) - 1]; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif void yyFlexLexer::LexerError( yyconst char msg[] ) { std::cerr << msg << std::endl; exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *calloc (yy_size_t size ) { return (void *) malloc( size ); } void *crealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void cfree (void * ptr ) { free( (char *) ptr ); /* see crealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 120 "/home/tovok7/svn/potassco/coala/src/lib/c/Scanner.l" coala-1.0.1_src/src/lib/c/Formula.cpp000644 001750 001750 00000020627 11477164507 020076 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Formula.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Formula.h" #include "FluentAction.h" using namespace C; Formula::Formula() { I_ = new vector(); type_ = '?'; } Formula::Formula(char type, Formula* identifier) { type_ = type; I_ = new vector(1, identifier); } Formula::Formula(char type, vector* vec) { type_ = type; if(vec == NULL) I_ = new vector(); else I_ = vec; } Formula::~Formula () { delete I_; } void Formula::addPart(Formula* identifier) { I_->push_back(identifier); } char Formula::getType() { return type_; } Formula* Formula::getFirstFormula() { return I_->at(0); } vector::iterator Formula::begin() { return I_->begin(); } vector::iterator Formula::end() { return I_->end(); } void Formula::insert(vector::iterator loc, vector::iterator begin, vector::iterator end) { I_->insert(loc, begin, end); } Formula* Formula::invert() { if(getType() == 'c') { for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { *n = (*n)->invert(); } return this; } else if(getType() == '_') { return new Formula('n', new vector(1, this)); } else if(getType() == 'n') { return (Formula*) I_->at(0); } else { return this; } } bool Formula::isTrue() { if(I_->size() == 1 && I_->at(0)->getType() == '_' && ((FluentAction*)I_->at(0))->getName() == "0") return true; else return false; } bool Formula::isFalse() { if(getType() == 'n' && I_->size() == 1 && I_->at(0)->getType() == '_' && ((FluentAction*)I_->at(0))->getName() == "0") return true; else return false; } FluentAction* Formula::getFluentAction() { if(getType() == '_') return (FluentAction*) this; else if(getType() == 'n' && I_->size() == 1 && I_->at(0)->getType() == '_') return (FluentAction*) I_->at(0); else throw std::runtime_error("getFluentAction() was called in wrong context. Please notify the author!"); } // TODO check if this can be generalized for every Type of Formula (FluentAction as well) void Formula::print(Printer* p, set* vars, string T) { assert(p->no_direct_enc); if(I_->empty()) { p->add("\"true\""); } else if(I_->size() == 1) { FluentAction* f; bool neg; if(I_->at(0)->getType() == 'n') { f = (FluentAction*) I_->at(0)->getFirstFormula(); neg = true; } else { f = (FluentAction*) I_->at(0); neg = false; } if(neg) p->add("neg(" + f->print(p, T) + ")"); else p->add(f->print(p, T)); // get the vars set* tmp_vars = f->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } else { p->add("and("); for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { FluentAction* f; bool neg; if((*n)->getType() == 'n') { f = (FluentAction*) (*n)->getFirstFormula(); neg = true; } else { f = (FluentAction*) *n; neg = false; } if(neg) p->add("neg(" + f->print(p, T) + ")"); else p->add(f->print(p, T)); if(n != I_->end()-1) p->add(", "); // get the vars set* tmp_vars = f->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); } p->add(")"); } } void Formula::printAlsoActions(Printer* p, set* vars, string T) { string F = ""; string A = ""; int f = 0; int a = 0; FluentAction* i; bool neg; for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { // check for negation if((*n)->getType() == 'n') { i = (FluentAction*) (*n)->getFirstFormula(); neg = true; } else { i = (FluentAction*) *n; neg = false; } if(i->getClass() == "Fluent") { if(f > 0) F += ", "; if(neg) { if(p->no_direct_enc) F += "neg("; else F += p->neg; F += i->print(p, T); if(p->no_direct_enc) F += ")"; } else F += i->print(p, T); f++; } else { if(a > 0) A += ", "; if(neg) { if(p->no_direct_enc) A += "neg("; else A += p->neg; A += i->print(p, T); if(p->no_direct_enc) A += ")"; } else A += i->print(p, T); a++; } // get the vars set* tmp_vars = i->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); } if(p->no_direct_enc) { if(f == 0) F = "\"true\""; else if(f > 1) F = "and("+F+")"; if(a == 0) A = "\"true\""; else if(a > 1) A = "and("+A+")"; p->add(F + ", " + A); } else { p->add(F); if(f != 0 && a != 0) p->add(", "); p->add(A); } } void Formula::printCompositeFluents(Printer* p, Types* types) { if(I_->size() > 1) { set vars; // print cfluent p->add("cfluent("); print(p, &vars); p->add(")"); if(vars.empty()) p->add(".\n"); else { p->add(" :- "); types->print(p, &vars, 0); p->add(".\n"); } // print fpart for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { FluentAction* f; bool neg; if((*n)->getType() == 'n') { f = (FluentAction*) (*n)->getFirstFormula(); neg = true; } else { f = (FluentAction*) *n; neg = false; } p->add("fpart("); print(p, &vars); p->add(", "); if(neg) p->add("neg(" + f->print(p, "") + ")"); else p->add(f->print(p, "")); p->add(")"); if(vars.empty()) p->add(".\n"); else { p->add(" :- "); types->print(p, &vars, 0); p->add(".\n"); } } } // end if size>1 } void Formula::printCompositeFluentActions(Printer* p, Types* types) { string F = ""; vector Fs = vector(); set F_vars; string A = ""; vector As = vector(); set A_vars; int f = 0; int a = 0; for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { FluentAction* i; bool neg; if((*n)->getType() == 'n') { i = (FluentAction*) (*n)->getFirstFormula(); neg = true; } else { i = (FluentAction*) *n; neg = false; } if(i->getClass() == "Fluent") { if(f > 0) F += ", "; f++; if(neg) { F += "neg(" + i->print(p, "") + ")"; Fs.push_back("neg(" + i->print(p, "") + ")"); } else { F += i->print(p, ""); Fs.push_back(i->print(p, "")); } set* tmp_vars = i->getVariables(); if(!tmp_vars->empty()) F_vars.insert(tmp_vars->begin(), tmp_vars->end()); } else { if(a > 0) A += ", "; a++; if(neg) { A += "neg(" + i->print(p, "") + ")"; As.push_back("neg(" + i->print(p, "") + ")"); } else { A += i->print(p, ""); As.push_back(i->print(p, "")); } set* tmp_vars = i->getVariables(); if(!tmp_vars->empty()) A_vars.insert(tmp_vars->begin(), tmp_vars->end()); } } if(f > 1) { p->add("cfluent(and("+F+"))"); if(F_vars.empty()) p->add(".\n"); else { p->add(" :- "); types->print(p, &F_vars, 0); p->add(".\n"); } for(vector::iterator n = Fs.begin(); n != Fs.end(); ++n) { p->add("fpart(and("+F+"), "+*n+")"); if(F_vars.empty()) p->add(".\n"); else { p->add(" :- "); types->print(p, &F_vars, 0); p->add(".\n"); } } } if(a > 1) { p->add("caction(and("+A+"))"); if(A_vars.empty()) p->add(".\n"); else { p->add(" :- "); types->print(p, &A_vars, 0); p->add(".\n"); } for(vector::iterator n = As.begin(); n != As.end(); ++n) { p->add("apart(and("+A+"), "+*n+")"); if(A_vars.empty()) p->add(".\n"); else { p->add(" :- "); types->print(p, &A_vars, 0); p->add(".\n"); } } } } coala-1.0.1_src/src/lib/c/Program.cpp000644 001750 001750 00000022660 11477164507 020077 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Program.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Program.h" #include "Parser.h" using namespace C; Program::Program(Coala::CompilerOptions* options) { options_ = options; ltl_node_num_ = 1; ltlquery_ = NULL; // true/false fluent fluents_.insert( make_pair("0", new FluentAction(new string("0"))) ); } Program::~Program() { for(map::iterator n = fluents_.begin(); n != fluents_.end(); ++n) { delete n->second; } } void Program::setLine(int* line) { line_ = line; } Variable* Program::addVariable(string* name) { map::iterator iter = variables_.find(*name); if(iter != variables_.end()) { return variables_[*name]; } else { Variable* var = new Variable(name); variables_.insert(make_pair(*name, var)); return var; } } Formula* Program::addFormula(char type, Formula* identifier) { // TODO check for duplicates return new Formula(type, identifier); } Formula* Program::addFormula(char type, vector* vec) { // TODO check for duplicates return new Formula(type, vec); } bool Program::addAction(FluentAction* action) { pair::iterator,bool> result = actions_.insert( make_pair(action->getName(), action) ); return result.second; } void Program::addActionDef(Formula* action_list, Types* types) { FluentAction* a; for(vector::iterator action = action_list->begin(); action != action_list->end(); action++) { a = (FluentAction*) *action; a->setClass("Action"); if(!addAction(a)) cerr << "Warning: action " << a->getName() << " defined multiple times at line " << *line_ << ".\n"; } action_definitions_.push_back(new ActionDefinition(*line_, action_list, types)); } bool Program::addFluent(FluentAction* fluent) { pair::iterator,bool> result = fluents_.insert( make_pair(fluent->getName(), (FluentAction*)fluent) ); return result.second; } void Program::addFluentDef(Formula* fluent_list, Types* types) { FluentAction* f; for(vector::iterator fluent = fluent_list->begin(); fluent != fluent_list->end(); fluent++) { if((*fluent)->getType() == 'n') { cerr << "Warning: fluent '" << f->getName() << "' can not be defined negatively at line " << *line_ << ".\n"; f = (*fluent)->getFluentAction(); *fluent = f; } else f = (FluentAction*) *fluent; f->setClass("Fluent"); if(!addFluent(f)) cerr << "Warning: fluent '" << f->getName() << "' defined multiple times at line " << *line_ << ".\n"; } fluent_definitions_.push_back(new FluentDefinition(*line_, fluent_list, types)); } void Program::addStaticRule(Formula* F, Formula* G, Types* types) { if(options_->getLanguage() == "c") { transformFormula(F, "Fluent"); transformFormula(G, "Fluent"); } else if(options_->getLanguage() == "m") { transformFormula(F, "Action"); transformFormula(G, "Action"); } static_rules_.push_back(new StaticRule(*line_, F, G, types)); } void Program::addDynamicRule(Formula* F, Formula* G, Formula* H, Types* types) { transformFormula(F, "Fluent"); transformFormula(G, "Fluent"); transformFormula(H, "Action"); dynamic_rules_.push_back(new DynamicRule(*line_, F, G, H, types)); } // f_1,...,f_n g_1,...,g_m = f f_1, g_1,...,g_m void Program::addDefaultRule(Formula* F, Formula* G, Types* types) { for(vector::iterator n = F->begin(); n != F->end(); ++n) { Formula* F_new = addFormula(F->getType(), *n); vector* G_new = new vector(1, *n); if(G) G_new->insert(G_new->end(), G->begin(), G->end()); addStaticRule(F_new, addFormula('c', G_new), types); } delete F; delete G; } // f_1, ..., f_n = f f f void Program::addInertialRule(Formula* F, Types* types) { for(vector::iterator n = F->begin(); n != F->end(); ++n) { Formula* F_new = addFormula(F->getType(), *n); addDynamicRule(F_new, F_new, F_new, types); } delete F; } // a1,...,a_o f_1, ..., f_n g_1, ..., g_m = f g, a void Program::addCausesRule(Formula* A, Formula* F, Formula* G, Types* types) { Formula* G_new; if(G) { G->insert(G->begin(), A->begin(), A->end()); G_new = G; } else { G_new = A; } addDynamicRule(F, NULL, G_new, types); // Don't delete G here since it is G_new as well } // f_1, ..., f_n = -f_1, ..., -f_n void Program::addAlwaysRule(Formula* G, Types* types) { Formula* F = addFormula('c', addFormula('n', new FluentAction(new string("0")))); G->invert(); addStaticRule(F, G, types); } // a_1,...,a_n f_1,...,f_m g_1,...,g_l = f_1,...,f_m f_1,...,f_m g_1,...,g_l,a_1,...,a_n void Program::addMayCauseRule(Formula* A, Formula* F, Formula* G, Types* types) { if(G) G->insert(G->begin(), A->begin(), A->end()); else G = A; addDynamicRule(F, F, G, types); } // a_1,..., a_n f_1,..., f_m = a_1,...,a_n,f_1,...,f_m void Program::addNonexecutableRule(Formula* A, Formula* G, Types* types) { Formula* F = addFormula('c', new Formula('n', new FluentAction(new string("0")))); if(G) G->insert(G->begin(), A->begin(), A->end()); else G = A; addDynamicRule(F, NULL, G, types); } void Program::addQQuery(string type, Formula* A, string time, Types* types) { transformFormula(A, "Action"); qqueries_.push_back(new QQuery(*line_, type, A, &time, types)); } void Program::addRQuery(Formula* F, Formula* A, string time, Types* types) { transformFormula(F, "Fluent"); transformFormula(A, "Action"); rqueries_.push_back(new RQuery(*line_, F, A, &time, types)); } LTLNode* Program::getLTLNode(int type, LTLNode* left, LTLNode* right, Formula* content) { if(content) { if(content->getType() != '_') throw std::runtime_error("Invalid operator in front of atomic LTL formula."); transformFormula(addFormula('c', content), "unknown"); return new LTLNode(type, (FluentAction*)content, ltl_node_num_++); } else return new LTLNode(type, left, right, ltl_node_num_++); } void Program::addLTLQuery(LTLNode* node) { if(ltlquery_) ltlquery_->setNode(getLTLNode(Parser::LTLOR, ltlquery_->getNode(), node, NULL)); else ltlquery_ = new LTLQuery(node, *line_); } void Program::print(Printer* p) { // prints all Variables of the Program // for(map::iterator n = variables_.begin(); n != variables_.end(); ++n) { // cout << n->first << "\n"; // } p->add("\n%\n% Fluents\n%\n"); for(vector::iterator n = fluent_definitions_.begin(); n != fluent_definitions_.end(); ++n) { (*n)->print(p, ltlquery_); delete *n; } p->setSection('c'); p->add("\n%\n% Actions\n%\n"); for(vector::iterator n = action_definitions_.begin(); n != action_definitions_.end(); ++n) { (*n)->print(p); } p->setSection('c'); p->add("\n%\n% Static Rules\n%\n"); for(vector::iterator n = static_rules_.begin(); n != static_rules_.end(); ++n) { (*n)->print(p); } p->add("\n%\n% Dynamic Rules\n%\n"); for(vector::iterator n = dynamic_rules_.begin(); n != dynamic_rules_.end(); ++n) { (*n)->print(p); } p->setSection('v'); p->add("\n%\n% Queries\n%\n"); for(vector::iterator n = qqueries_.begin(); n != qqueries_.end(); ++n) { (*n)->print(p); } for(vector::iterator n = rqueries_.begin(); n != rqueries_.end(); ++n) { (*n)->print(p); } if(ltlquery_) { ltlquery_->print(p, &fluents_); p->add("\n"); } p->print(); } void Program::transformFormula(Formula* formula, string type) { if(formula) { string error; stringstream ss; ss << *line_; ss >> error; for(vector::iterator n = formula->begin(); n != formula->end(); ++n) { FluentAction* i = (*n)->getFluentAction(); map::iterator fluent_it = fluents_.find(i->getName()); if(fluent_it != fluents_.end()) { i->setClass("Fluent"); // TODO merge fluents if value and arguments are equal // *n = fluent_it->second; } else if(type == "Fluent") { throw std::runtime_error(i->getName() + " was not defined as a fluent prior to line " + error + ".\n"); } else { map::iterator action_it = actions_.find(i->getName()); if(action_it != actions_.end()) { i->setClass("Action"); // TODO merge actions if value and arguments are equal // *n = action_it->second; } else { throw std::runtime_error(i->getName() + " was not defined as action or fluent prior to line " + error + ".\n"); } } } // end for } // end if != NULL } coala-1.0.1_src/src/lib/c/Pool.cpp000644 001750 001750 00000002763 11477164507 017403 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Pool.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Pool.h" using namespace C; Pool::Pool(Variable* var1, Variable* var2) { vars_ = vector(1, var1); vars_.push_back(var2); text_ = var1->getText()+";"+var2->getText(); } Pool::~Pool ( ) { } set* Pool::getVariables() { set* vars = new set(); vars->insert(vars_.begin(), vars_.end()); return vars; } void Pool::addVariable(Variable* var) { vars_.push_back(var); text_ += ";"+var->getText(); } coala-1.0.1_src/src/lib/c/Constraint.h000644 001750 001750 00000003760 11477164507 020261 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Constraint.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef CONSTRAINT_H #define CONSTRAINT_H #include #include #include "Variable.h" #include "Constant.h" namespace C { class Constraint { public: Constraint(Variable* left_var, Variable* right_var, string* text, string* type=NULL); Constraint(Variable* var, string* text, string* type=NULL); Constraint(string* text, string* type=NULL); virtual ~Constraint ( ); string print(Printer* p); /** * @return vector */ set* getVariables ( ); string getText(); string getType(); void merge(Constraint* constraint, string* type=NULL); void merge(string* text, Variable*, string* type=NULL); void merge(string* text, string* type=NULL); void mergeLeft(string* text, Variable* var, string* type=NULL); void mergeLeft(string* text, string* type=NULL); private: void init(string*, string*); vector vars_; string text_; string type_; }; }; // end of package namespace #endif // CONSTRAINT_H coala-1.0.1_src/src/lib/c/Parser.y000644 001750 001750 00000036073 11477164507 017415 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Parser.y - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ %name Parser %define LSP_NEEDED %define ERROR_BODY = 0 %define LEX_BODY = 0 %define MEMBERS void preProcessing(Coala::CompilerOptions*); void postProcessing(Printer*); virtual ~Parser(){}\ private: std::string to_string(int integer); %header{ #include #include #include #include #include #include "../options.h" #include "Program.h" #include "Printer.h" using namespace std; using namespace C; %} %{ Program* program; %} %union { int number; string* str; Formula* form; Type* typ; Types* types; Arguments* args; Constraint* constr; Pool* var_pool; Interval* interval; LTLNode* ltl_node; } %token IDENTIFIER %token NEG_IDENTI %token VARIABLE %token NUMBER %token ACT // %token FLU // %token CAUS // %token IF // %token AFTER // %token TRUE // %token FALSE // %token DEF // %token INERT // %token CAUSES // %token ALWAYS // %token MAY // %token NONEXE // %token WHERE // %token OC_AT // %token HO_AT // %token OCCURS // %token HOLDS // %token NECES // %token AT // %token NOT // not %token COMMA // , %token SEMIC // ; %token COLON // : %token DOT // . %token DDOT // .. %token LBRAC // ( %token RBRAC // ) %token EQ // == %token NEQ // != %token LT // < %token GT // > %token LE // <= %token GE // >= %token PLUS // + %token MINUS // - %token TIMES // * %token DIV // / %token MOD // mod %token AND // & %token OR // ? %token XOR // ^ %token LTL // LTL: %token LTLNOT // ! %token LTLOR // | %token IMPL // -> %token EQUIV // <-> %token X // X %token F // F %token G // G %token U // U %token R // R // LTL Operator Precedence %left EQUIV IMPL LTLOR AND %left U R %nonassoc G F X %nonassoc LTLNOT %type
formula %type types_list %type type %type term_list %type identifier %type constraint %type pool %type interval %type operation %type operator %type eqoperator %type ltl_expr %start program %% /***************************************************************************************************************************/ program: /* empty */ | program rule DOT; rule: fact | law | shortcut | query; fact: act_fact | flu_fact; law: static_rule | dyn_rule; shortcut: def_rule | inert_rule | caus_rule | always_rule | may_rule | nonexe_rule; query: oc_query | ho_query | hypo_query | ltl_query; // a_1,...,a_n bla. act_fact: ACT formula { program->addActionDef($2); } | ACT formula WHERE types_list { program->addActionDef($2, $4); } // f_1,...,f_n bla. flu_fact: FLU formula { program->addFluentDef($2); } | FLU formula WHERE types_list { program->addFluentDef($2, $4); } // f_1,...,f_n g_1,...,g_m bla. static_rule: CAUS formula { program->addStaticRule($2, NULL); } | CAUS formula WHERE types_list { program->addStaticRule($2, NULL, $4); } | CAUS formula IF formula { program->addStaticRule($2, $4); } | CAUS formula IF formula WHERE types_list { program->addStaticRule($2, $4, $6); } // f_1,...,f_n g_1,...,g_m h_1,...,h_l bla. dyn_rule: CAUS formula AFTER formula { program->addDynamicRule($2, NULL, $4); } | CAUS formula AFTER formula WHERE types_list { program->addDynamicRule($2, NULL, $4, $6); } | CAUS formula IF formula AFTER formula { program->addDynamicRule($2, $4, $6); } | CAUS formula IF formula AFTER formula WHERE types_list { program->addDynamicRule($2, $4, $6, $8); } // f_1,...,f_n g_1,...,g_m bla. = f_1 f_1, g_1,...,g_m bla. def_rule: DEF formula { program->addDefaultRule($2, NULL); } | DEF formula WHERE types_list { program->addDefaultRule($2, NULL, $4); } | DEF formula IF formula { program->addDefaultRule($2, $4); } | DEF formula IF formula WHERE types_list { program->addDefaultRule($2, $4, $6); } // f_1, ..., f_n bla. = f f f bla. inert_rule: INERT formula { program->addInertialRule($2); } | INERT formula WHERE types_list { program->addInertialRule($2, $4); } // a1,...,a_o f_1, ..., f_n g_1, ..., g_m bla. = f g, a bla. caus_rule: formula CAUSES formula { program->addCausesRule($1, $3, NULL); } | formula CAUSES formula WHERE types_list { program->addCausesRule($1, $3, NULL, $5); } | formula CAUSES formula IF formula { program->addCausesRule($1, $3, $5); } | formula CAUSES formula IF formula WHERE types_list { program->addCausesRule($1, $3, $5, $7); } // f_1, ..., f_n bla. = -f_1, ..., -f_n bla. always_rule: | ALWAYS formula { program->addAlwaysRule($2); } | ALWAYS formula WHERE types_list { program->addAlwaysRule($2, $4); } // a_1,...,a_n f_1,...,f_m g_1,...,g_l bla. = f_1 f_1 g_1,...,g_l,a_1,...,a_n bla. may_rule: formula MAY formula { program->addMayCauseRule($1, $3, NULL); } | formula MAY formula WHERE types_list { program->addMayCauseRule($1, $3, NULL, $5); } | formula MAY formula IF formula { program->addMayCauseRule($1, $3, $5); } | formula MAY formula IF formula WHERE types_list { program->addMayCauseRule($1, $3, $5, $7); } // a_1,..., a_n f_1,..., f_m bla. = a_1,...,a_n,f_1,...,f_m bla. nonexe_rule: NONEXE formula { program->addNonexecutableRule($2, NULL); } | NONEXE formula WHERE types_list { program->addNonexecutableRule($2, NULL, $4); } | NONEXE formula IF formula { program->addNonexecutableRule($2, $4); } | NONEXE formula IF formula WHERE types_list { program->addNonexecutableRule($2, $4, $6); } // a_1,...,a_n t_i bla. oc_query: formula OC_AT NUMBER { program->addQQuery("occurs", $1, to_string($3)); } | formula OC_AT IDENTIFIER { program->addQQuery("occurs", $1, *$3); } | formula OC_AT NUMBER WHERE types_list { program->addQQuery("occurs", $1, to_string($3), $5); } | formula OC_AT IDENTIFIER WHERE types_list { program->addQQuery("occurs", $1, *$3, $5); } // f_1,...,f_n t_i bla. ho_query: formula HO_AT NUMBER { program->addQQuery("holds", $1, to_string($3)); } | formula HO_AT IDENTIFIER { program->addQQuery("holds", $1, *$3); } | formula HO_AT NUMBER WHERE types_list { program->addQQuery("holds", $1, to_string($3), $5); } | formula HO_AT IDENTIFIER WHERE types_list { program->addQQuery("holds", $1, *$3, $5); } // necessarily f_1,...,f_n after A1,...,Ak at ti bla. hypo_query: NECES formula AFTER formula AT NUMBER { program->addRQuery($2, $4, to_string($6)); } | NECES formula AFTER formula AT NUMBER WHERE types_list { program->addRQuery($2, $4, to_string($6), $8); } // f_1,...,f_n formula: identifier { $$ = program->addFormula('c', $1); } | TRUE { $$ = program->addFormula('c', new FluentAction(new string("0"))); } | FALSE { $$ = program->addFormula('c', new Formula('n', new FluentAction(new string("0")))); } | formula COMMA identifier { $1->addPart($3); $$ = $1; } identifier: IDENTIFIER { $$ = new FluentAction($1); } | IDENTIFIER LBRAC term_list RBRAC { $$ = new FluentAction($1, $3); } | NEG_IDENTI { $$ = new Formula('n', new FluentAction($1)); } | NEG_IDENTI LBRAC term_list RBRAC { $$ = new Formula('n', new FluentAction($1, $3)); } // X, a, 3, X;Y, 1..Z term_list: VARIABLE { $$ = new Arguments(program->addVariable($1)); } | IDENTIFIER { $$ = new Arguments(new Constant($1)); } | NUMBER { $$ = new Arguments(new Constant($1)); } | pool { $$ = new Arguments($1); } | interval { $$ = new Arguments($1); } | IDENTIFIER LBRAC term_list RBRAC { $$ = new Arguments(new Function($1, $3->getArgs())); } | term_list COMMA VARIABLE { $1->addVariable(program->addVariable($3)); $$ = $1; } | term_list COMMA IDENTIFIER { $1->addConstant(new Constant($3)); $$ = $1; } | term_list COMMA NUMBER { $1->addConstant(new Constant($3)); $$ = $1; } | term_list COMMA pool { $1->addPool($3); $$ = $1; } | term_list COMMA interval { $1->addInterval($3); $$ = $1; } | term_list COMMA IDENTIFIER LBRAC term_list RBRAC { $1->addFunction(new Function($3, $5->getArgs())); $$ = $1; } // X;Y pool: VARIABLE SEMIC VARIABLE { $$ = new Pool(program->addVariable($1), program->addVariable($3)); } | pool SEMIC VARIABLE { $1->addVariable(program->addVariable($3)); $$ = $1; } // 1..X interval: NUMBER DDOT NUMBER { $$ = new Interval(new Constant($1), new Constant($3)); } | NUMBER DDOT VARIABLE { $$ = new Interval(new Constant($1), program->addVariable($3)); } | VARIABLE DDOT NUMBER { $$ = new Interval(program->addVariable($1), new Constant($3)); } | VARIABLE DDOT VARIABLE { $$ = new Interval(program->addVariable($1), program->addVariable($3)); } // type_1(X),...,type_n(Y), X!=Y types_list: constraint { $$ = new Types($1); } | type { $$ = new Types($1); } | NUMBER COLON type { $3->setMin($1); $$ = new Types($3); } | type COLON NUMBER { $1->setMax($3); $$ = new Types($1); } | NUMBER COLON type COLON NUMBER { $3->setMin($1); $3->setMax($5); $$ = new Types($3); } | types_list COMMA constraint { $1->addType($3); } | types_list COMMA type { $1->addType($3); } | types_list COMMA NUMBER COLON type { $5->setMin($3); $1->addType($5); } | types_list COMMA type COLON NUMBER { $3->setMax($5); $1->addType($3); } | types_list COMMA NUMBER COLON type COLON NUMBER { $5->setMin($3); $5->setMax($7); $1->addType($5); } // type_xyz(X,Y,Z) type: IDENTIFIER LBRAC term_list RBRAC { $$ = new Type($1, $3, true); } | NOT IDENTIFIER LBRAC term_list RBRAC { $$ = new Type($2, $4, false); } // X!=Y etc. constraint: operation eqoperator operation { $1->merge($3, $2); $$ = $1; } | NUMBER eqoperator operation { $3->mergeLeft(new string(to_string($1)+*$2), $2); $$ = $3; } | operation eqoperator NUMBER { $1->merge(new string(*$2+to_string($3)), $2); $$ = $1; } | IDENTIFIER eqoperator operation { $3->mergeLeft(new string(*$1+*$2), $2); $$ = $3; } | operation eqoperator IDENTIFIER { $1->merge(new string(*$2+*$3), $2); $$ = $1; } | VARIABLE eqoperator operation { $3->mergeLeft(new string(*$1+*$2), program->addVariable($1), $2); $$ = $3; } | operation eqoperator VARIABLE { $1->merge(new string(*$2+*$3), program->addVariable($3), $2); $$ = $1; } | VARIABLE eqoperator VARIABLE { $$ = new Constraint(program->addVariable($1), program->addVariable($3), new string(*$1+*$2+*$3), $2); } | NUMBER eqoperator VARIABLE { $$ = new Constraint(program->addVariable($3), new string(to_string($1)+*$2+*$3), $2); } | VARIABLE eqoperator NUMBER { $$ = new Constraint(program->addVariable($1), new string(*$1+*$2+to_string($3)), $2); } | IDENTIFIER eqoperator VARIABLE { $$ = new Constraint(program->addVariable($3), new string(*$1+*$2+*$3), $2); } | VARIABLE eqoperator IDENTIFIER { $$ = new Constraint(program->addVariable($1), new string(*$1+*$2+*$3), $2); } | NUMBER eqoperator IDENTIFIER { $$ = new Constraint(new string(to_string($1)+*$2+*$3), $2); } | IDENTIFIER eqoperator NUMBER { $$ = new Constraint(new string(*$1+*$2+to_string($3)), $2); } // X+1+Y operation: NUMBER operator VARIABLE { $$ = new Constraint(program->addVariable($3), new string(to_string($1)+*$2+*$3)); } | VARIABLE operator NUMBER { $$ = new Constraint(program->addVariable($1), new string(*$1+*$2+to_string($3))); } | VARIABLE operator VARIABLE { $$ = new Constraint(program->addVariable($1), program->addVariable($3), new string(*$1+*$2+*$3)); } | operation operator NUMBER { $1->merge(new string(*$2+to_string($3))); $$ = $1; } | operation operator VARIABLE { $1->merge(new string(*$2+*$3), program->addVariable($3)); $$ = $1; } eqoperator: EQ { $$ = new string("=="); } | NEQ { $$ = new string("!="); } | LT { $$ = new string("<"); } | GT { $$ = new string(">"); } | LE { $$ = new string("<="); } | GE { $$ = new string(">="); } operator: PLUS { $$ = new string("+"); } | MINUS { $$ = new string("-"); } | TIMES { $$ = new string("*"); } | DIV { $$ = new string("/"); } | MOD { $$ = new string(" mod "); } | AND { $$ = new string("&"); } | OR { $$ = new string("?"); } | XOR { $$ = new string("^"); } ltl_query: LTL ltl_expr { program->addLTLQuery($2); } ltl_expr: identifier { $$ = program->getLTLNode(IDENTIFIER, NULL, NULL, $1); } | LBRAC ltl_expr RBRAC { $$ = $2; } | LTLNOT ltl_expr { $$ = program->getLTLNode(LTLNOT, NULL, $2); } | ltl_expr AND ltl_expr { $$ = program->getLTLNode(AND, $1, $3); } | ltl_expr LTLOR ltl_expr { $$ = program->getLTLNode(LTLOR, $1, $3); } | ltl_expr IMPL ltl_expr { $$ = program->getLTLNode(IMPL, $1, $3); } | ltl_expr EQUIV ltl_expr { $$ = program->getLTLNode(EQUIV, $1, $3); } | X ltl_expr { $$ = program->getLTLNode(X, NULL, $2); } | G ltl_expr { $$ = program->getLTLNode(G, NULL, $2); } | F ltl_expr { $$ = program->getLTLNode(F, NULL, $2); } | ltl_expr U ltl_expr { $$ = program->getLTLNode(U, $1, $3); } | ltl_expr R ltl_expr { $$ = program->getLTLNode(R, $1, $3); } %% /***************************************************************************************************************************/ void Parser::preProcessing(Coala::CompilerOptions* options) { program = new Program(options); program->setLine(&yylloc.first_line); } void Parser::postProcessing(Printer* p) { program->print(p); delete program; } std::string Parser::to_string(int integer) { std::stringstream ss; std::string str; ss << integer; ss >> str; return str; } coala-1.0.1_src/src/lib/c/Interval.h000644 001750 001750 00000003043 11477164507 017713 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Interval.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef INTERVAL_H #define INTERVAL_H #include "Term.h" #include "Variable.h" #include "Constant.h" #include namespace C { class Interval : virtual public Term { public: Interval(Constant* num1, Constant* num2); Interval(Constant* num, Variable* var); Interval(Variable* var, Constant* num); Interval(Variable* var1, Variable* var2); virtual ~Interval ( ); set* getVariables(); private: Term* from_; Term* to_; }; }; // end of package namespace #endif // INTERVAL_H coala-1.0.1_src/src/lib/c/StaticRule.cpp000644 001750 001750 00000007031 11477164507 020542 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/StaticRule.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "StaticRule.h" using namespace C; StaticRule::StaticRule(int line, Formula* F, Formula* G, Types* types) : Statement(line, types) { F_ = F; G_ = G; } StaticRule::~StaticRule ( ) { } void StaticRule::print(Printer* p) { if(p->no_direct_enc) { printNonDirect(p); } else { printDirect(p); } } void StaticRule::printDirect(Printer* p) { string T; set* vars = new set(); // print the static rule twice: for T=0 and T>0 for(int i = 1; i <= 2; ++i) { if(i == 1) { p->setSection('b'); T = "0"; } else { p->setSection('c'); T = p->T; } FluentAction* f; FluentAction* g; string neg_f = p->neg; string neg_g = p->neg; // f1_fluent(T-1) :- not -g1_fluent(T-1). for(vector::iterator fluent_f = F_->begin(); fluent_f != F_->end(); ++fluent_f) { if(!(*fluent_f)->isFalse()) { // check for negation if((*fluent_f)->getType() == 'n') { f = (FluentAction*) (*fluent_f)->getFirstFormula(); neg_f = p->neg; } else { f = (FluentAction*) *fluent_f; neg_f = ""; } vars = f->getVariables(); p->add(neg_f + f->print(p, T)); } // print G part if(G_ && !G_->isTrue()) { p->add(" :- "); for(vector::iterator fluent_g = G_->begin(); fluent_g != G_->end(); ++fluent_g) { // check for negation if((*fluent_g)->getType() == 'n') { g = (FluentAction*) (*fluent_g)->getFirstFormula(); neg_g = ""; } else { g = (FluentAction*) *fluent_g; neg_g = p->neg; } p->add("not " + neg_g + g->print(p, T)); if(fluent_g != G_->end()-1) p->add(", "); // get the vars set* tmp_vars = g->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } } if(!vars->empty()) { if(G_ && !G_->isTrue()) { p->add(", "); } else { p->add(" :- "); } types_.print(p, vars, line_); } p->add(".\n"); } } // end main for delete vars; } void StaticRule::printNonDirect(Printer* p) { p->setSection('b'); set* vars = new set(); p->add("caused("); F_->print(p, vars); p->add(","); if(G_) G_->print(p, vars); else p->add("\"true\""); p->add(",\"true\",\"true\")"); if(vars->empty()) p->add(".\n"); else { p->add(" :- "); types_.print(p, vars, line_); p->add(".\n"); } F_->printCompositeFluents(p, &types_); if(G_) G_->printCompositeFluents(p, &types_); delete vars; } coala-1.0.1_src/src/lib/c/Constant.h000644 001750 001750 00000002575 11477164507 017731 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Constant.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef CONSTANT_H #define CONSTANT_H #include "Term.h" #include #include namespace C { class Constant : virtual public Term { public: Constant ( ); Constant(string* text); Constant(int number); virtual ~Constant ( ); set* getVariables(); }; }; // end of package namespace #endif // CONSTANT_H coala-1.0.1_src/src/lib/c/ActionDefinition.h000644 001750 001750 00000002734 11477164507 021363 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/ActionDefinition.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef ACTIONDEFINITION_H #define ACTIONDEFINITION_H #include "Statement.h" #include "Formula.h" #include "Types.h" #include namespace C { class ActionDefinition : public Statement { public: ActionDefinition(int line, Formula* action_list, Types* types=NULL); virtual ~ActionDefinition ( ); void print(Printer* p); private: Formula* A_; }; }; // end of package namespace #endif // ACTIONDEFINITION_H coala-1.0.1_src/src/lib/c/Statement.cpp000644 001750 001750 00000004457 11477164507 020440 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Statement.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Statement.h" using namespace C; Statement::Statement(int line, Types* types) { if(types) { types_ = *types; //delete types; } else types_ = Types(); line_ = line; } Statement::~Statement() { } void Statement::print ( ) { } template void Statement::printIdentifiers(Printer* p, T* I, set* vars) { if(I->empty()) { p->add("\"true\""); } else if(I->size() == 1) { p->add(I->at(0)->print(p, p->T)); // get the vars set* tmp_vars = I->at(0)->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); } else { p->add("and("); for(typename T::iterator n = I->begin(); n != I->end(); ++n) { p->add((*n)->print(p, p->T)); if(n != I->end()-1) p->add(","); // get the vars set* tmp_vars = (*n)->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); } p->add(")"); } } template void Statement::printIdentifiers< vector >(Printer* p, vector* I, set* vars); string Statement::createTempArgs(int num) { string result = ""; for(int i = 1; i <= num; i++) { stringstream i_str; i_str << i; result += "X" + i_str.str() + ","; } return result + "T"; } coala-1.0.1_src/src/lib/c/Statement.h000644 001750 001750 00000003031 11477164507 020070 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Statement.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef STATEMENT_H #define STATEMENT_H #include #include "Types.h" #include "Identifier.h" #include "FluentAction.h" #include "Constraint.h" namespace C { class Statement { public: Statement(int line=0, Types* types=NULL); virtual ~Statement ( ); void print ( ); protected: template void printIdentifiers(Printer* p, T* I, set* vars); string createTempArgs(int); Types types_; int line_; }; }; // end of package namespace #endif // STATEMENT_H coala-1.0.1_src/src/lib/c/Term.h000644 001750 001750 00000003722 11477164507 017042 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Term.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef TERM_H #define TERM_H #include #include #include #include "Printer.h" using namespace std; namespace C { class Variable; class Term { public: Term ( ); virtual ~Term ( ); string print(Printer* p = NULL); /** * @return vector */ virtual set* getVariables(); protected: string text_; enum TermKind { CONSTANT, VARIABLE, FUNCTION, POOL, INTERVAL }; TermKind term_kind_; public: /** * Set the value of text * @param new_var the new value of text */ void setText ( string new_var ); /** * Get the value of text * @return the value of text */ string getText ( ); /** * Set the value of term_kind * @param new_var the new value of term_kind */ void setTerm_kind ( TermKind new_var ); /** * Get the value of term_kind * @return the value of term_kind */ TermKind getKind ( ); }; }; // end of package namespace #endif // TERM_H coala-1.0.1_src/src/lib/c/ActionDefinition.cpp000644 001750 001750 00000005706 11477164507 021720 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/ActionDefinition.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "ActionDefinition.h" using namespace C; ActionDefinition::ActionDefinition(int line, Formula* action_list, Types* types) : Statement(line, types) { A_ = action_list; } ActionDefinition::~ActionDefinition () { delete A_; } void ActionDefinition::print(Printer* p) { for(vector::iterator n = A_->begin(); n != A_->end(); ++n) { FluentAction* a = (FluentAction*) *n; string action = a->print(p, p->T+"-1"); set* vars = a->getVariables(); if(p->no_direct_enc) { p->setSection('b'); p->add("action(" + action + ")"); if(!vars->empty()) { p->add(" :- "); types_.print(p, vars, line_); } p->add(".\n"); } else { p->setSection('c'); if(p->lang != "m") { // action_a(T-1) :- not -action_a(T-1) p->add(action + " :- not " + p->neg+action); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); // -action(T-1) :- not action_a(T-1). p->add(p->neg+action + " :- not " + action); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); } p->setSection('b'); p->add("#show action_" + a->getName() + "(" + createTempArgs(vars->size()) + ").\n"); // :- f1_action(T-1), neg_f1_action(T-1). if(p->fake_neg) { p->setSection('c'); p->add(":- " + action + ", " + p->neg + action); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); if(p->debug > 1) { p->setSection('b'); p->add("#show " + p->neg + "action_" + a->getName() + "(" + createTempArgs(vars->size()) + ").\n"); } } p->setSection('c'); // completeness condition p->add(":- not " + action + ", not " + p->neg + action); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); } // end direct encoding delete vars; } } coala-1.0.1_src/src/lib/c/Printer.h000644 001750 001750 00000003526 11477164507 017560 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Printer.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef printer_h #define printer_h #include #include #include #include using namespace std; namespace C { class Printer { public: Printer(ostream *output_stream, int, bool, bool, bool, bool, bool, string); virtual ~Printer(); void add(string text); void addExtra(string text); void setSection(char); void print(); void printLTLAuxilliaries(); void printIncLTLAuxilliaries(); int debug; bool fake_neg; bool inc; bool rev; bool no_w_chk; bool no_direct_enc; string lang; string neg; string T; protected: virtual void printEncoding(); void printBackwardsEncoding(); char section_; ostream* o; stringstream b; stringstream c; stringstream v; stringstream extra; bool printed_ltl_aux_; }; }; // end of package namespace #endif // PRINTER_H coala-1.0.1_src/src/lib/c/Compiler.h000644 001750 001750 00000003202 11477164507 017676 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Compiler.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef COMPILER_H #define COMPILER_H #undef yyFlexLexer #define yyFlexLexer cFlexLexer #include #include "../main.h" #include "../options.h" #include "Parser.h" #include "Program.h" namespace C { class Compiler : public Coala::AbstractCompiler, public Parser { private: cFlexLexer lexer; Printer* printer_; Coala::CompilerOptions* options_; protected: ostream* output_stream_; public: Compiler(Coala::CompilerOptions*); virtual ~Compiler(); int compile(); int yylex(); void yyerror(char*); void change_input(std::istream*); }; }; #endif // COMPILER_H coala-1.0.1_src/src/lib/c/Variable.h000644 001750 001750 00000002555 11477164507 017663 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Variable.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef VARIABLE_H #define VARIABLE_H #include #include "Term.h" namespace C { class Variable : virtual public Term { public: Variable ( ); Variable(string* name); virtual ~Variable ( ); set* getVariables(); private: string name_; }; }; // end of package namespace #endif // VARIABLE_H coala-1.0.1_src/src/lib/c/Function.cpp000644 001750 001750 00000003353 11477164507 020253 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Function.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Function.h" using namespace C; Function::Function(string* name, vector* terms) { name_ = *name; terms_ = *terms; text_ = *name+"("; for(vector::iterator n = terms_.begin(); n != terms_.end(); ++n) { text_ += (*n)->getText(); if(n != terms_.end()-1) text_ += ","; } text_ += ")"; } Function::~Function ( ) { } set* Function::getVariables() { set* vars = new set(); if(!terms_.empty()) { for(vector::iterator n = terms_.begin(); n!= terms_.end(); ++n) { set* tmp_vars = (*n)->getVariables(); if(!tmp_vars->empty()) { vars->insert(tmp_vars->begin(), tmp_vars->end()); } } } return vars; } coala-1.0.1_src/src/lib/c/Arguments.h000644 001750 001750 00000003676 11477164507 020110 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Arguments.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef ARGUMENTS_H #define ARGUMENTS_H #include #include #include "Variable.h" #include "Constant.h" #include "Pool.h" #include "Interval.h" #include "Function.h" #include "Printer.h" namespace C { class Arguments { public: Arguments(Variable* variable); Arguments(Constant* constant); Arguments(Pool* pool); Arguments(Interval* interval); Arguments(Function* function); virtual ~Arguments ( ); string print(Printer* p = NULL); /** * @return vector */ set* getVariables(); void addVariable(Variable* var); void addConstant(Constant* con); void addPool(Pool* pool); void addInterval(Interval* interval); void addFunction(Function* function); void setMin(int); void setMax(int); int getMin(); int getMax(); vector* getArgs(); private: vector args_; int min_; int max_; }; }; // end of package namespace #endif // ARGUMENTS_H coala-1.0.1_src/src/lib/c/Pool.h000644 001750 001750 00000002630 11477164507 017041 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Pool.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef POOL_H #define POOL_H #include "Term.h" #include "Variable.h" #include namespace C { class Pool : virtual public Term { public: Pool(Variable* var1, Variable* var2); virtual ~Pool ( ); set* getVariables(); void addVariable(Variable* var); private: vector vars_; }; }; // end of package namespace #endif // POOL_H coala-1.0.1_src/src/lib/c/Interval.cpp000644 001750 001750 00000003520 11477164507 020246 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Interval.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Interval.h" using namespace C; Interval::Interval(Constant* num1, Constant* num2) { from_ = num1; to_ = num2; text_ = from_->getText()+".."+to_->getText(); } Interval::Interval(Constant* num, Variable* var) { from_ = num; to_ = var; text_ = from_->getText()+".."+to_->getText(); } Interval::Interval(Variable* var, Constant* num) { from_ = var; to_ = num; text_ = from_->getText()+".."+to_->getText(); } Interval::Interval(Variable* var1, Variable* var2) { from_ = var1; to_ = var2; text_ = from_->getText()+".."+to_->getText(); } Interval::~Interval ( ) { } set* Interval::getVariables() { set* vars = new set(); //from_->getVariables(); // if(!to_->getVariables().empty()) // vars.push_back(to_->getVariables().at(0)); return vars; } coala-1.0.1_src/src/lib/c/Type.h000644 001750 001750 00000002745 11477164507 017060 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Type.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef TYPE_H #define TYPE_H #include #include #include "Identifier.h" #include "Arguments.h" #include namespace C { class Type : public Identifier { public: Type(string* name, Arguments* args, bool sign); virtual ~Type(); void setMin(int); void setMax(int); int getMin(); int getMax(); bool isTrue(); string print(Printer*); private: bool sign_; }; }; // end of package namespace #endif // TYPE_H coala-1.0.1_src/src/lib/c/QQuery.cpp000644 001750 001750 00000004645 11477164507 017721 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/QQuery.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "QQuery.h" using namespace C; QQuery::QQuery(int line, string type, Formula* I, string* time, Types* types) : Statement(line, types), Query(line, types) { type_ = type; I_ = I; time_ = *time; } QQuery::~QQuery ( ) { } void QQuery::print(Printer* p) { if(p->rev) { if(time_ == "0") time_ = "-t"; else if(time_ == "t") time_ = "0"; else { time_ = "-" + time_; cerr << "Warning: Setting time of query in line " << line_ << " to " << time_ << ".\n"; cerr << " This will most likely cause problems with the reverse incremental encoding.\n"; } } if(time_ == "0") p->setSection('b'); else p->setSection('v'); FluentAction* i; string neg = p->neg; // :- not f1, ..., not f_n for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { if((*n)->getType() == 'n') { i = (FluentAction*) (*n)->getFirstFormula(); neg = p->neg; } else { i = (FluentAction*) *n; neg = ""; } p->add(":- not "); if(p->no_direct_enc) { p->add(type_+"("); if(neg == "") { p->add(i->print(p, time_)); p->add(", " + time_ + ")"); } else { p->add("neg(" + i->print(p, time_)); p->add("), "+time_+")"); } } else { p->add(neg + i->print(p, time_)); } set* vars = i->getVariables(); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); delete vars; } } coala-1.0.1_src/src/lib/c/Query.h000644 001750 001750 00000003300 11477164507 017230 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/ - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef QUERY_H #define QUERY_H #include "Statement.h" #include namespace C { /******************************* Abstract Class **************************** Query does not have any pure virtual methods, but its author defined it as an abstract class, so you should not use it directly. Inherit from it instead and create only objects from the derived classes *****************************************************************************/ class Query : virtual public Statement { public: Query(int line=0, Types* types=NULL); virtual ~Query ( ); void print(Printer* p); protected: string time_; }; }; // end of package namespace #endif // QUERY_H coala-1.0.1_src/src/lib/c/Scanner.l000644 001750 001750 00000007234 11477164507 017532 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Scanner.l - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ %{ #include #include "Parser.h" %} %option yylineno nounput noyywrap c++ prefix="c" %s ltl MOD mod IDENTIFIER [a-z][a-zA-Z0-9_]* NEG_IDENTI \-[a-z][a-zA-Z0-9_]* NUMBER [0-9]+ VARIABLE [A-Z][a-zA-Z0-9_]* COMMENT \%.*\n NOT not ACT FLU CAUS IF AFTER TRUE FALSE DEF INERT CAUSES ALWAYS MAY NONEXE WHERE OC_AT HO_AT HOLDS OCCURS NECES AT %% [\t\n ]+ // ignore white space. "LTL:" { BEGIN(ltl); return Parser::LTL; } "X" { return Parser::X; } "F" { return Parser::F; } "G" { return Parser::G; } "U" { return Parser::U; } "R" { return Parser::R; } {NOT} { return Parser::NOT; } {ACT} { return Parser::ACT; } {FLU} { return Parser::FLU; } {CAUS} { return Parser::CAUS; } {IF} { return Parser::IF; } {AFTER} { return Parser::AFTER; } {TRUE} { return Parser::TRUE; } {FALSE} { return Parser::FALSE; } {DEF} { return Parser::DEF; } {INERT} { return Parser::INERT; } {CAUSES} { return Parser::CAUSES; } {ALWAYS} { return Parser::ALWAYS; } {MAY} { return Parser::MAY; } {NONEXE} { return Parser::NONEXE; } {WHERE} { return Parser::WHERE; } {OC_AT} { return Parser::OC_AT; } {HO_AT} { return Parser::HO_AT; } {OCCURS} { return Parser::OCCURS; } {HOLDS} { return Parser::HOLDS; } {NECES} { return Parser::NECES; } {AT} { return Parser::AT; } {MOD} { return Parser::MOD; } {IDENTIFIER} { return Parser::IDENTIFIER; } {NEG_IDENTI} { return Parser::NEG_IDENTI; } {NUMBER} { return Parser::NUMBER; } {VARIABLE} { return Parser::VARIABLE; } "," { return Parser::COMMA; } ";" { return Parser::SEMIC; } ":" { return Parser::COLON; } ".." { return Parser::DDOT; } "." { BEGIN(0); return Parser::DOT; } "(" { return Parser::LBRAC; } ")" { return Parser::RBRAC; } "==" { return Parser::EQ; } "!=" { return Parser::NEQ; } "<" { return Parser::LT; } ">" { return Parser::GT; } "<=" { return Parser::LE; } ">=" { return Parser::GE; } "+" { return Parser::PLUS; } "-" { return Parser::MINUS; } "*" { return Parser::TIMES; } "/" { return Parser::DIV; } "&" { return Parser::AND; } "?" { return Parser::OR; } "^" { return Parser::XOR; } "!" { return Parser::LTLNOT; } "|" { return Parser::LTLOR; } "->" { return Parser::IMPL; } "<->" { return Parser::EQUIV; } {COMMENT} { /* comment */ } <> { yyterminate(); } . { cerr << "\n\nError: Unknown keyword '"+string(yytext)+"' found at line "<* fluents) { if(p->rev) throw std::runtime_error("LTL Queries are not yet supported with reverse incremental option."); if(p->inc) p->printIncLTLAuxilliaries(); else p->printLTLAuxilliaries(); // special check for correctness of loop guess in case of direct encoding if(!p->no_direct_enc) printLoopGuessCheck(p, fluents); // negate node to find counter examples node_ = node_->negate(false); if(p->inc) { p->setSection('c'); node_->printIncPropagator(p); p->add("ltl_counter_example(t) :- "); } else { p->add("ltl_counter_example :- "); } node_->print(p, true, false); } void LTLQuery::printLoopGuessCheck(Printer* p, map* fluents) { // % check that loop guess was correct p->setSection('v'); for(map::iterator f = fluents->begin(); f != fluents->end(); ++f) { if(f->first == "0") continue; p->add(":- loop_start(T-1), "); p->add(f->second->print(p, "T-1") + ", "); if(p->inc) p->add("time(T), "); p->add(p->neg + f->second->print(p, "t") + ".\n"); p->add(":- loop_start(T-1), "); p->add(f->second->print(p, "t") + ", "); if(p->inc) p->add("time(T), "); p->add(p->neg + f->second->print(p, "T-1") + ".\n"); } } /* class LTLNode starts here */ LTLNode::LTLNode(int type, LTLNode* left, LTLNode* right, int num) { type_ = type; left_ = left; right_ = right; content_ = NULL; num_ = num; } LTLNode::LTLNode(int type, FluentAction* content, int num) { type_ = type; left_ = NULL; right_ = NULL; content_ = content; num_ = num; } LTLNode::~LTLNode() { } int LTLNode::getType() { return type_; } string LTLNode::getClass() { string result = ""; if(type_ == Parser::IDENTIFIER) { result = content_->getClass(); } else if(type_ == Parser::LTLNOT) { result = right_->getClass(); } return result; } LTLNode* LTLNode::getRightNode() { return right_; } bool LTLNode::printContent(Printer* p, string T, bool sign=true) { // works and used also for non-content nodes because of empty class bool is_ltl_function = false; if(type_ == Parser::IDENTIFIER) { if(p->no_direct_enc) { if(getClass() == "Action") p->add("occurs("); else if(getClass() == "Fluent") p->add("holds("); if(!sign) { p->add("neg(" + content_->print(p, T) + ")"); return false; } else p->add(content_->print(p, T)); } else p->add(content_->print(p, T)); } else if(type_ == Parser::LTLNOT) { if(p->no_direct_enc && getClass() != "") { right_->printContent(p, T, false); } else if(getClass() != "") { p->add(p->neg); right_->printContent(p, T); } else { p->add("not "); is_ltl_function = right_->printContent(p, T); // end function here because content was printed // else the predicate would be ended twice at the end return is_ltl_function; } } else { is_ltl_function = true; // construct name of auxilliary function string name = ""; stringstream ss; ss << num_; ss >> name; name = "ltl_f_" + name; // special negation for LTL predicate if(!sign) p->add("not "); if(p->no_direct_enc) { if(p->inc) p->add("holds(" + name + ", t"); else p->add("holds(" + name); } else { if(p->inc) p->add(name + "(t, " + T + ")"); else p->add(name + "(" + T + ")"); } } // end predicate for non-direct encoding if(p->no_direct_enc) p->add(", " + T + ")"); return is_ltl_function; } void LTLNode::printLTLCondition(Printer* p, string T) { string name = ""; stringstream ss; ss << num_; ss >> name; name = "ltl_f_" + name; if(p->no_direct_enc) p->add("holds(ltl_c("+name+"), "+T+")"); else p->add("ltl_c("+name+", "+T+")"); } void LTLNode::print(Printer* p, bool top_node, bool time_node) { switch(type_) { case Parser::IDENTIFIER: printContent(p, "0"); p->add(".\n"); break; case Parser::LTLNOT: if(printContent(p, "0", false)) { p->add(".\n"); right_->check_and_print(p, time_node); } else p->add(".\n"); break; case Parser::AND: printAND(p, top_node, time_node); break; case Parser::LTLOR: printOR(p, top_node, time_node); break; case Parser::IMPL: p->add("->"); throw std::runtime_error("LTL Queries are not yet supported with implication."); break; case Parser::EQUIV: p->add("="); throw std::runtime_error("LTL Queries are not yet supported with equations."); break; case Parser::X: printX(p, top_node, time_node); break; case Parser::F: printF(p, top_node, time_node); break; case Parser::G: printG(p, top_node, time_node); break; case Parser::U: printU(p, top_node, time_node); break; case Parser::R: printR(p, top_node, time_node); break; default: cerr << "\ntype: " << type_; throw std::runtime_error("Unknown LTL Query element."); break; } } void LTLNode::check_and_print(Printer* p, bool time_node) { if(type_ != Parser::IDENTIFIER && type_ != Parser::LTLNOT) { print(p, false, time_node); } } // TODO simplify LTL formula void LTLNode::printAND(Printer* p, bool top_node, bool time_node) { string T = "0"; // loop to print it two times, one for T=0 and one for general T for(int i=0; i<=1; ++i) { if(i == 1) { if(!top_node && time_node) { if(p->inc) T = "t"; else T = "T"; } else break; } if(!top_node) { printContent(p, T); p->add(" :- "); } left_->printContent(p, T); p->add(", "); right_->printContent(p, T); p->add(".\n"); } left_->check_and_print(p, time_node); right_->check_and_print(p, time_node); } void LTLNode::printOR(Printer* p, bool top_node, bool time_node) { string T = "0"; if(top_node) { printContent(p, T); p->add(".\n"); } // loop to print it two times, one for T=0 and one for general T for(int i=0; i<=1; ++i) { if(i == 1) { if(!top_node && time_node) { if(p->inc) T = "t"; else T = "T"; } else break; } printContent(p, T); p->add(" :- "); left_->printContent(p, T); p->add(".\n"); printContent(p, T); p->add(" :- "); right_->printContent(p, T); p->add(".\n"); } left_->check_and_print(p, time_node); right_->check_and_print(p, time_node); } void LTLNode::printX(Printer* p, bool top_node, bool time_node) { string T = "0"; if(top_node) { printContent(p, T); p->add(".\n"); } // loop to print it two times, one for T=0 and one for general T for(int i=0; i<=1; ++i) { if(i == 1) { if(!top_node && time_node) { if(p->inc) T = "t"; else T = "T"; printContent(p, "t"); p->add(" :- after_loop_start("+T+"), "); right_->printContent(p, T); p->add(".\n"); } else break; } if(T != "0" && p->inc) { printContent(p, "T-1"); p->add(" :- "); right_->printContent(p, "T"); p->add(", time(T)"); p->add(".\n"); } else { printContent(p, T); p->add(" :- "); right_->printContent(p, T+"+1"); p->add(".\n"); } } right_->check_and_print(p, true); } void LTLNode::printF(Printer* p, bool top_node, bool time_node) { string T = "0"; if(top_node) { printContent(p, T); p->add(".\n"); } for(int i=0; i<=1; ++i) { if(i == 1) { if(p->inc) { T = "t"; printContent(p, T); p->add(" :- after_loop_start("+T+"-1), "); printContent(p, T+"-1"); p->add(".\n"); } else { T = "T"; printContent(p, "t+1"); p->add(" :- after_loop_start("+T+"), "); printContent(p, T); p->add(".\n"); } } printContent(p, T); p->add(" :- "); right_->printContent(p, T); p->add(".\n"); if(T != "0" && p->inc) { printContent(p, "T-1"); p->add(" :- "); printContent(p, "T"); p->add(", time(T)"); p->add(".\n"); } else { printContent(p, T); p->add(" :- "); printContent(p, T+"+1"); p->add(".\n"); } } right_->check_and_print(p, true); } void LTLNode::printG(Printer* p, bool top_node, bool time_node) { string T = "0"; if(top_node) { printContent(p, T); p->add(".\n"); } for(int i=0; i<=1; ++i) { if(i == 1) { if(p->inc) T = "t"; else T = "T"; printLTLCondition(p, T); p->add(" :- in_loop("+T+"), not "); right_->printContent(p, T); p->add(".\n"); } if(T != "0" && p->inc) { printContent(p, "T-1"); p->add(" :- "); right_->printContent(p, "T-1"); p->add(", "); printContent(p, "T"); p->add(", time(T).\n"); } else { printContent(p, T); p->add(" :- "); right_->printContent(p, T); p->add(", "); printContent(p, T+"+1"); p->add(".\n"); } if(p->inc) { printContent(p, "t"); p->add(" :- loop_exists(t-1), not "); } else { printContent(p, "t+1"); p->add(" :- loop_exists, not "); } printLTLCondition(p, T); p->add(".\n"); // TODO check t+1 and "+T+" } right_->check_and_print(p, true); } void LTLNode::printU(Printer* p, bool top_node, bool time_node) { string T = "0"; if(top_node) { printContent(p, T); p->add(".\n"); } for(int i=0; i<=1; ++i) { if(i == 1) { if(p->inc) { T = "t"; printContent(p, T); p->add(" :- after_loop_start("+T+"-1), "); printContent(p, T+"-1"); p->add(".\n"); } else { T = "T"; printContent(p, "t+1"); p->add(" :- after_loop_start("+T+"), "); printContent(p, T); p->add(".\n"); } } printContent(p, T); p->add(" :- "); right_->printContent(p , T); p->add(".\n"); if(T != "0" && p->inc) { printContent(p, "T-1"); p->add(" :- "); left_->printContent(p, "T-1"); p->add(", "); printContent(p, "T"); p->add(", time(T).\n"); } else { printContent(p, T); p->add(" :- "); left_->printContent(p, T); p->add(", "); printContent(p, T+"+1"); p->add(".\n"); } } left_->check_and_print(p, true); right_->check_and_print(p, true); } void LTLNode::printR(Printer* p, bool top_node, bool time_node) { string T = "0"; if(top_node) { printContent(p, T); p->add(".\n"); } for(int i=0; i<=1; ++i) { if(i == 1) { if(p->inc) { T = "t"; printContent(p, T); p->add(" :- after_loop_start("+T+"-1), "); printContent(p, T+"-1"); p->add(".\n"); } else { T = "T"; printContent(p, "t+1"); p->add(" :- after_loop_start("+T+"), "); printContent(p, T); p->add(".\n"); } printLTLCondition(p, T); p->add(" :- in_loop("+T+"), not "); right_->printContent(p, T); // TODO check this holds line p->add(".\n"); } printContent(p, T); p->add(" :- "); right_->printContent(p, T); p->add(", "); left_->printContent(p, T); p->add(".\n"); if(T != "0" && p->inc) { printContent(p, "T-1"); p->add(" :- "); right_->printContent(p, "T-1"); p->add(", "); printContent(p, "T"); p->add(", time(T).\n"); } else { printContent(p, T); p->add(" :- "); right_->printContent(p, T); p->add(", "); printContent(p, T+"+1"); p->add(".\n"); } if(p->inc) { printContent(p, "t"); p->add(" :- loop_exists(t-1), not "); printLTLCondition(p, T); p->add(".\n"); // TODO check t+1 and T } else { printContent(p, "t+1"); p->add(" :- loop_exists, not "); printLTLCondition(p, T); p->add(".\n"); // TODO check t+1 and T } } left_->check_and_print(p, true); right_->check_and_print(p, true); } void LTLNode::print_debug(Printer* p) { switch(type_) { case Parser::LTLNOT: p->add(" !"); break; case Parser::AND: p->add(" &"); break; case Parser::LTLOR: p->add(" |"); break; case Parser::IMPL: p->add(" ->"); break; case Parser::EQUIV: p->add(" <->"); break; case Parser::X: p->add(" X"); break; case Parser::F: p->add(" F"); break; case Parser::G: p->add(" G"); break; case Parser::U: p->add(" U"); break; case Parser::R: p->add(" R"); break; case Parser::IDENTIFIER: p->add(" "); break; default: p->add(" ?"); cout << type_ << "?"; break; } cout << "[" << num_ << "]"; if(type_ != Parser::IDENTIFIER) p->add("("); if(left_ && right_) { left_->print_debug(p); p->add(","); right_->print_debug(p); } else if(right_) { right_->print_debug(p); } else if(content_) { p->add(content_->print(p)); } else { p->add("ERROR LTL DEBUG PRINT"); } if(type_ != Parser::IDENTIFIER) p->add(") "); cout.flush(); } LTLNode* LTLNode::negate(bool negation=false) { // if negation of parent node was just removed, do nothing if(negation) return this; switch(type_) { case Parser::LTLNOT: // if three negations in a row, delete first two and negate third one if(right_->getType() == Parser::LTLNOT && right_->getRightNode()->getType() == Parser::LTLNOT) { delete right_; delete this; return right_->getRightNode()->negate(); } else { delete this; return right_->negate(true); } case Parser::AND: type_ = Parser::LTLOR; left_ = left_->negate(); right_ = right_->negate(); return this; case Parser::LTLOR: type_ = Parser::AND; left_ = left_->negate(); right_ = right_->negate(); return this; case Parser::IMPL: // TODO return this; case Parser::EQUIV: // TODO return this; case Parser::X: right_ = right_->negate(); return this; case Parser::F: type_ = Parser::G; right_ = right_->negate(); return this; case Parser::G: type_ = Parser::F; right_ = right_->negate(); return this; case Parser::U: type_ = Parser::R; left_ = left_->negate(); right_ = right_->negate(); return this; case Parser::R: type_ = Parser::U; left_ = left_->negate(); right_ = right_->negate(); return this; case Parser::IDENTIFIER: // assumes negation nodes can all have 0 as num_ return new LTLNode(Parser::LTLNOT, NULL, this, 0); default: throw std::runtime_error("Unknown LTL symbol in negation."); return this; } } void LTLNode::printIncPropagator(Printer* p) { if(type_ == Parser::LTLNOT) { right_->printIncPropagator(p); } else if(type_ == Parser::X || type_ == Parser::F || type_ == Parser::G) { printIncPropagatorForThisNode(p); right_->printIncPropagator(p); } else if(type_ == Parser::AND || type_ == Parser::LTLOR || type_ == Parser::U || type_ == Parser::R) { printIncPropagatorForThisNode(p); left_->printIncPropagator(p); right_->printIncPropagator(p); } } void LTLNode::printIncPropagatorForThisNode(Printer* p) { printContent(p, "T"); p->add(" :- "); // construct name of auxilliary function string name = ""; stringstream ss; ss << num_; ss >> name; name = "ltl_f_" + name; if(p->no_direct_enc) p->add("holds(" + name + ", t-1, T)"); else p->add(name + "(t-1, T)"); p->add(", time(T).\n"); } coala-1.0.1_src/src/lib/c/QQuery.h000644 001750 001750 00000002646 11477164507 017365 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/QQuery.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef QQUERY_H #define QQUERY_H #include "Query.h" #include "Formula.h" #include namespace C { class QQuery : virtual public Query { public: QQuery(int line, string type, Formula* I, string* time, Types* types); virtual ~QQuery ( ); virtual void print(Printer* p); protected: Formula* I_; string type_; }; }; // end of package namespace #endif // QQUERY_H coala-1.0.1_src/src/lib/c/Function.h000644 001750 001750 00000002612 11477164507 017715 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Function.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef FUNCTION_H #define FUNCTION_H #include "Term.h" #include namespace C { class Function : virtual public Term { public: Function(string* name, vector* terms); virtual ~Function ( ); set* getVariables(); private: vector terms_; string name_; }; }; // end of package namespace #endif // FUNCTION_H coala-1.0.1_src/src/lib/c/LTLQuery.h000644 001750 001750 00000004574 11477164507 017622 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/LTLQuery.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef LTLQUERY_H #define LTLQUERY_H #include #include #include "Query.h" #include "FluentAction.h" namespace C { class LTLNode; class LTLQuery : virtual public Query { public: LTLQuery(LTLNode*, int line, Types* types=NULL); virtual ~LTLQuery(); LTLNode* getNode(); void setNode(LTLNode*); void print(Printer*, map*); void printLoopGuessCheck(Printer*, map*); private: LTLNode* node_; }; class LTLNode { public: LTLNode(int, LTLNode*, LTLNode*, int); LTLNode(int, FluentAction*, int); virtual ~LTLNode(); int getType(); string getClass(); LTLNode* getRightNode(); void printLTLCondition(Printer*, string); void print(Printer*, bool, bool); bool printContent(Printer*, string, bool); void check_and_print(Printer*, bool); void printAND(Printer*, bool, bool); void printOR(Printer*, bool, bool); void printX(Printer*, bool, bool); void printF(Printer*, bool, bool); void printG(Printer*, bool, bool); void printU(Printer*, bool, bool); void printR(Printer*, bool, bool); void print_debug(Printer*); LTLNode* negate(bool); void printIncPropagator(Printer*); void printIncPropagatorForThisNode(Printer*); private: int type_; LTLNode* left_; LTLNode* right_; int num_; FluentAction* content_; }; }; // end of package namespace #endif // LTLQUERY_H coala-1.0.1_src/src/lib/c/Term.cpp000644 001750 001750 00000003275 11477164507 017400 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Term.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Term.h" using namespace C; Term::Term ( ) { } Term::~Term ( ) { } string Term::print(Printer* p) { return text_; } /** * Set the value of text * @param new_var the new value of text */ void Term::setText ( string new_var ) { text_ = new_var; } /** * Get the value of text * @return the value of text */ string Term::getText ( ) { return text_; } /** * Set the value of term_kind * @param new_var the new value of term_kind */ void Term::setTerm_kind ( TermKind new_var ) { term_kind_ = new_var; } //TermKind Term::getKind() { // return term_kind_; //} set* Term::getVariables ( ) { return new set(); } coala-1.0.1_src/src/lib/c/Variable.cpp000644 001750 001750 00000002574 11477164507 020217 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Variable.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Variable.h" using namespace C; // Constructors/Destructors // //Variable::Variable ( ) { //} Variable::Variable(string* name) { name_ = *name; text_ = *name; } Variable::~Variable ( ) { } set* Variable::getVariables() { set* vars = new set(); vars->insert(this); return vars; } coala-1.0.1_src/src/lib/c/Arguments.cpp000644 001750 001750 00000005540 11477164507 020433 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Arguments.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Arguments.h" using namespace C; Arguments::Arguments(Variable* variable) { args_ = vector(1, variable); min_ = -1; max_ = -1; } Arguments::Arguments(Constant* constant) { args_ = vector(1, constant); min_ = -1; max_ = -1; } Arguments::Arguments(Pool* pool) { args_ = vector(1, pool); min_ = -1; max_ = -1; } Arguments::Arguments(Interval* interval) { args_ = vector(1, interval); min_ = -1; max_ = -1; } Arguments::Arguments(Function* function) { args_ = vector(1, function); min_ = -1; max_ = -1; } Arguments::~Arguments() { } string Arguments::print(Printer* p) { string result = ""; for(vector::iterator n = args_.begin(); n != args_.end(); ++n) { result += (*n)->print(); if(n != args_.end()-1) result += ","; } return result; } void Arguments::addVariable(Variable* var) { args_.push_back(var); } void Arguments::addConstant(Constant* con) { args_.push_back(con); } void Arguments::addPool(Pool* pool) { args_.push_back(pool); } void Arguments::addInterval(Interval* interval) { args_.push_back(interval); } void Arguments::addFunction(Function* function) { args_.push_back(function); } void Arguments::setMin(int min) { min_ = min; } void Arguments::setMax(int max) { max_ = max; } int Arguments::getMin() { return min_; } int Arguments::getMax() { return max_; } vector* Arguments::getArgs() { return &args_; } /** * @return vector */ set* Arguments::getVariables() { set* vars = new set(); if(!args_.empty()) { for(vector::iterator n = args_.begin(); n!= args_.end(); ++n) { set* tmp_vars = (*n)->getVariables(); if(!tmp_vars->empty()) { vars->insert(tmp_vars->begin(), tmp_vars->end()); } delete tmp_vars; } } return vars; } coala-1.0.1_src/src/lib/c/Program.h000644 001750 001750 00000006323 11477164507 017542 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Program.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef program_h #define program_h #include #include #include #include "../options.h" #include "Variable.h" #include "Formula.h" #include "StaticRule.h" #include "DynamicRule.h" #include "ActionDefinition.h" #include "FluentDefinition.h" #include "Query.h" #include "QQuery.h" #include "RQuery.h" #include "LTLQuery.h" #include "Printer.h" namespace C { class Program { public: Program(Coala::CompilerOptions*); virtual ~Program(); void setLine(int* line); virtual void print(Printer* p); Variable* addVariable(string*); Formula* addFormula(char, Formula*); Formula* addFormula(char, vector*); bool addAction(FluentAction* action); void addActionDef(Formula* action_list, Types* types=0); bool addFluent(FluentAction* fluent); void addFluentDef(Formula* fluent_list, Types* types=0); virtual void addStaticRule(Formula* F, Formula* G, Types* types=NULL); virtual void addDynamicRule(Formula* F, Formula* G, Formula* H, Types* types=NULL); void addDefaultRule(Formula* F, Formula* G, Types* types=NULL); void addInertialRule(Formula* F, Types* types=NULL); void addCausesRule(Formula* A, Formula* F, Formula* G, Types* types=NULL); void addAlwaysRule(Formula* G, Types* types=NULL); void addMayCauseRule(Formula* A, Formula* F, Formula* G, Types* types=NULL); virtual void addNonexecutableRule(Formula* A, Formula* G, Types* types=NULL); void addQQuery(string type, Formula* A, string time, Types* types=NULL); void addRQuery(Formula* F, Formula* A, string time, Types* types=NULL); LTLNode* getLTLNode(int, LTLNode*, LTLNode*, Formula* content=NULL); void addLTLQuery(LTLNode*); protected: void transformFormula(Formula* I, string type); int* line_; Coala::CompilerOptions* options_; int ltl_node_num_; Printer* p_; map actions_; map fluents_; map variables_; vector qqueries_; vector rqueries_; LTLQuery* ltlquery_; vector static_rules_; vector dynamic_rules_; vector action_definitions_; vector fluent_definitions_; }; }; // end of package namespace #endif // PROGRAM_H coala-1.0.1_src/src/lib/c/Query.cpp000644 001750 001750 00000002311 11477164507 017564 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/ - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Query.h" using namespace C; Query::Query (int line, Types* types) : Statement(line, types) { } Query::~Query ( ) { } //void Query::print(Printer* p) { //} coala-1.0.1_src/src/lib/c/FluentAction.cpp000644 001750 001750 00000004323 11477164507 021057 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Fluent.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "FluentAction.h" #include "Formula.h" using namespace C; FluentAction::FluentAction(string* name, Arguments* args) : Identifier(name, args) { type_ = '_'; } FluentAction::FluentAction(string* name) : Identifier(name) { type_ = '_'; } FluentAction::~FluentAction ( ) { } string FluentAction::getNameWithArgs() { string result = getName(); if(args_ != NULL) result += "(" + args_->print() + ")"; return result; } void FluentAction::setClass(string cl) { class_ = cl; } string FluentAction::getClass() { return class_; } string FluentAction::print(Printer* p, string T) { string result = ""; if(p->no_direct_enc) { if(name_ != "0") { result += name_; if(args_) result += "(" + args_->print(p) + ")"; } else result += "\"true\""; } // true and false just gets ignored in direct encoding else if(name_ != "0") { if(class_ == "Fluent") { result += "fluent_"; } else if(class_ == "Action") { result += "action_"; } result += name_; result += "("; if(args_) { result += args_->print(p); result += "," + T; } else result += T; result += ")"; } return result; } string FluentAction::print(Printer* p) { return print(p, "0"); } coala-1.0.1_src/src/lib/c/DynamicRule.cpp000644 001750 001750 00000007172 11477164507 020705 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/DynamicRule.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "DynamicRule.h" using namespace C; DynamicRule::DynamicRule(int line, Formula* F, Formula* G, Formula* H, Types* types) : Statement(line, types), StaticRule(line, F, G, types) { H_ = H; } DynamicRule::~DynamicRule () { delete H_; } void DynamicRule::printDirect(Printer* p) { p->setSection('c'); FluentAction* f; FluentAction* g; string neg_f = p->neg; string neg_g = p->neg; // f1_fluent(T) :- not -g1_fluent(T), a_action(T-1). for(vector::iterator fluent_f = F_->begin(); fluent_f != F_->end(); ++fluent_f) { set* vars = new set(); if(!(*fluent_f)->isFalse()) { // check for negation if((*fluent_f)->getType() == 'n') { f = (FluentAction*) (*fluent_f)->getFirstFormula(); neg_f = p->neg; } else { f = (FluentAction*) *fluent_f; neg_f = ""; } p->add(neg_f + f->print(p, p->T) + " :- "); delete vars; vars = f->getVariables(); } else { p->add(":- "); } // print G part if(G_ && !G_->isTrue()) { for(vector::iterator fluent_g = G_->begin(); fluent_g != G_->end(); ++fluent_g) { // check for negation if((*fluent_g)->getType() == 'n') { g = (FluentAction*) (*fluent_g)->getFirstFormula(); neg_g = ""; } else { g = (FluentAction*) *fluent_g; neg_g = p->neg; } p->add("not " + neg_g + g->print(p, p->T) + ", "); // get the vars set* tmp_vars = g->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } } // print H part H_->printAlsoActions(p, vars, p->T + "-1"); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); delete vars; } } void DynamicRule::printNonDirect(Printer* p) { p->setSection('b'); for(vector::iterator n = F_->begin(); n != F_->end(); ++n) { FluentAction* f; bool neg; if((*n)->getType() == 'n') { f = (FluentAction*) (*n)->getFirstFormula(); neg = true; } else { f = (FluentAction*) *n; neg = false; } p->add("caused("); if(neg) p->add("neg(" + f->print(p) + ")"); else p->add(f->print(p)); set* vars = f->getVariables(); p->add(", "); if(G_) G_->print(p, vars); else p->add("\"true\""); p->add(", "); H_->printAlsoActions(p, vars); p->add(")"); if(vars->empty()) p->add(".\n"); else { p->add(" :- "); types_.print(p, vars, line_); p->add(".\n"); } delete vars; } //F_->printCompositeFluents(p, &types_); if(G_) G_->printCompositeFluents(p, &types_); H_->printCompositeFluentActions(p, &types_); } coala-1.0.1_src/src/lib/c/Constant.cpp000644 001750 001750 00000002630 11477164507 020254 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Constant.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Constant.h" using namespace C; //Constant::Constant ( ) { //} Constant::Constant(string* text) { text_ = *text; term_kind_ = CONSTANT; } Constant::Constant(int number) { stringstream ss; ss << number; ss >> text_; term_kind_ = CONSTANT; } Constant::~Constant ( ) { } set* Constant::getVariables() { return new set(); } coala-1.0.1_src/src/lib/c/Constraint.cpp000644 001750 001750 00000005537 11477164507 020620 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Constraint.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Constraint.h" using namespace C; Constraint::Constraint(Variable* left_var, Variable* right_var, string* text, string* type) { init(text, type); vars_.push_back(left_var); vars_.push_back(right_var); } Constraint::Constraint(Variable* var, string* text, string* type) { init(text, type); vars_.push_back(var); } Constraint::Constraint(string* text, string* type) { init(text, type); } void Constraint::init(string* text, string* type) { vars_ = vector(); text_ = *text; delete text; if(type) { type_ = *type; delete type; } } Constraint::~Constraint () { for(vector::iterator n = vars_.begin(); n != vars_.end(); ++n) { delete *n; } } /** * @return vector */ set* Constraint::getVariables ( ) { set* vars = new set(); for(vector::iterator n = vars_.begin(); n != vars_.end(); ++n) { Variable* var = *n; vars->insert(var); } return vars; } string Constraint::getText() { return text_; } string Constraint::getType() { return type_; } void Constraint::merge(Constraint* constraint, string* type) { text_ += constraint->getText(); vars_.insert(vars_.begin(), constraint->getVariables()->begin(), constraint->getVariables()->end()); if(type) type_ = *type; } void Constraint::merge(string* text, Variable* var, string* type) { text_ += *text; vars_.push_back(var); if(type) type_ = *type; } void Constraint::merge(string* text, string* type) { text_ += *text; if(type) type_ = *type; } void Constraint::mergeLeft(string* text, Variable* var, string* type) { text_ = *text + text_; vars_.push_back(var); if(type) type_ = *type; } void Constraint::mergeLeft(string* text, string* type) { text_ = *text + text_; if(type) type_ = *type; } string Constraint::print(Printer* p) { return text_; } coala-1.0.1_src/src/lib/c/DynamicRule.h000644 001750 001750 00000002710 11477164507 020343 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/DynamicRule.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef DYNAMICRULE_H #define DYNAMICRULE_H #include "StaticRule.h" #include namespace C { class DynamicRule : public StaticRule { public: DynamicRule(int line, Formula* F, Formula* G, Formula* H, Types* types=NULL); virtual ~DynamicRule ( ); void printDirect(Printer* p); void printNonDirect(Printer* p); protected: Formula* H_; }; }; // end of package namespace #endif // DYNAMICRULE_H coala-1.0.1_src/src/lib/c/CMakeLists.txt000644 001750 001750 00000000405 11477164507 020515 0ustar00tovok7tovok7000000 000000 IF(USE_FLEX_BISON) FLEX_FILE(Scanner.l) BISON_FILE(Parser.y) ENDIF(USE_FLEX_BISON) FILE(GLOB COALA_C_LIB_SRC *.cpp) ADD_LIBRARY(coala-c-lib STATIC ${COALA_C_LIB_SRC} Parser.cpp Scanner.cpp) SET_TARGET_PROPERTIES(coala-c-lib PROPERTIES OUTPUT_NAME coala-c) coala-1.0.1_src/src/lib/c/RQuery.h000644 001750 001750 00000002640 11477164507 017360 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/RQuery.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef RQUERY_H #define RQUERY_H #include "Query.h" #include #include "Formula.h" namespace C { class RQuery : virtual public Query { public: RQuery(int line, Formula* F, Formula* A, string* time, Types* types=NULL); virtual ~RQuery ( ); void print(Printer* p); private: Formula* A_; Formula* F_; }; }; // end of package namespace #endif // RQUERY_H coala-1.0.1_src/src/lib/c/Parser.h000644 001750 001750 00000023105 11477164507 017364 0ustar00tovok7tovok7000000 000000 #ifndef YY_Parser_h_included #define YY_Parser_h_included #define YY_USE_CLASS #line 1 "/usr/share/bison++/bison.h" /* before anything */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #line 8 "/usr/share/bison++/bison.h" #define YY_Parser_LSP_NEEDED #define YY_Parser_ERROR_BODY = 0 #define YY_Parser_LEX_BODY = 0 #define YY_Parser_MEMBERS void preProcessing(Coala::CompilerOptions*); void postProcessing(Printer*); virtual ~Parser(){}\ private: std::string to_string(int integer); #line 27 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" #include #include #include #include #include #include "../options.h" #include "Program.h" #include "Printer.h" using namespace std; using namespace C; #line 46 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" typedef union { int number; string* str; Formula* form; Type* typ; Types* types; Arguments* args; Constraint* constr; Pool* var_pool; Interval* interval; LTLNode* ltl_node; } yy_Parser_stype; #define YY_Parser_STYPE yy_Parser_stype #line 21 "/usr/share/bison++/bison.h" /* %{ and %header{ and %union, during decl */ #ifndef YY_Parser_COMPATIBILITY #ifndef YY_USE_CLASS #define YY_Parser_COMPATIBILITY 1 #else #define YY_Parser_COMPATIBILITY 0 #endif #endif #if YY_Parser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YYLTYPE #ifndef YY_Parser_LTYPE #define YY_Parser_LTYPE YYLTYPE /* WARNING obsolete !!! user defined YYLTYPE not reported into generated header */ /* use %define LTYPE */ #endif #endif /*#ifdef YYSTYPE*/ #ifndef YY_Parser_STYPE #define YY_Parser_STYPE YYSTYPE /* WARNING obsolete !!! user defined YYSTYPE not reported into generated header */ /* use %define STYPE */ #endif /*#endif*/ #ifdef YYDEBUG #ifndef YY_Parser_DEBUG #define YY_Parser_DEBUG YYDEBUG /* WARNING obsolete !!! user defined YYDEBUG not reported into generated header */ /* use %define DEBUG */ #endif #endif /* use goto to be compatible */ #ifndef YY_Parser_USE_GOTO #define YY_Parser_USE_GOTO 1 #endif #endif /* use no goto to be clean in C++ */ #ifndef YY_Parser_USE_GOTO #define YY_Parser_USE_GOTO 0 #endif #ifndef YY_Parser_PURE #line 65 "/usr/share/bison++/bison.h" #line 65 "/usr/share/bison++/bison.h" /* YY_Parser_PURE */ #endif #line 68 "/usr/share/bison++/bison.h" #line 68 "/usr/share/bison++/bison.h" /* prefix */ #ifndef YY_Parser_DEBUG #line 71 "/usr/share/bison++/bison.h" #line 71 "/usr/share/bison++/bison.h" /* YY_Parser_DEBUG */ #endif #ifndef YY_Parser_LSP_NEEDED #line 75 "/usr/share/bison++/bison.h" #line 75 "/usr/share/bison++/bison.h" /* YY_Parser_LSP_NEEDED*/ #endif /* DEFAULT LTYPE*/ #ifdef YY_Parser_LSP_NEEDED #ifndef YY_Parser_LTYPE #ifndef BISON_YYLTYPE_ISDECLARED #define BISON_YYLTYPE_ISDECLARED typedef struct yyltype { int timestamp; int first_line; int first_column; int last_line; int last_column; char *text; } yyltype; #endif #define YY_Parser_LTYPE yyltype #endif #endif /* DEFAULT STYPE*/ #ifndef YY_Parser_STYPE #define YY_Parser_STYPE int #endif /* DEFAULT MISCELANEOUS */ #ifndef YY_Parser_PARSE #define YY_Parser_PARSE yyparse #endif #ifndef YY_Parser_LEX #define YY_Parser_LEX yylex #endif #ifndef YY_Parser_LVAL #define YY_Parser_LVAL yylval #endif #ifndef YY_Parser_LLOC #define YY_Parser_LLOC yylloc #endif #ifndef YY_Parser_CHAR #define YY_Parser_CHAR yychar #endif #ifndef YY_Parser_NERRS #define YY_Parser_NERRS yynerrs #endif #ifndef YY_Parser_DEBUG_FLAG #define YY_Parser_DEBUG_FLAG yydebug #endif #ifndef YY_Parser_ERROR #define YY_Parser_ERROR yyerror #endif #ifndef YY_Parser_PARSE_PARAM #ifndef __STDC__ #ifndef __cplusplus #ifndef YY_USE_CLASS #define YY_Parser_PARSE_PARAM #ifndef YY_Parser_PARSE_PARAM_DEF #define YY_Parser_PARSE_PARAM_DEF #endif #endif #endif #endif #ifndef YY_Parser_PARSE_PARAM #define YY_Parser_PARSE_PARAM void #endif #endif /* TOKEN C */ #ifndef YY_USE_CLASS #ifndef YY_Parser_PURE #ifndef yylval extern YY_Parser_STYPE YY_Parser_LVAL; #else #if yylval != YY_Parser_LVAL extern YY_Parser_STYPE YY_Parser_LVAL; #else #warning "Namespace conflict, disabling some functionality (bison++ only)" #endif #endif #endif #line 169 "/usr/share/bison++/bison.h" #define IDENTIFIER 258 #define NEG_IDENTI 259 #define VARIABLE 260 #define NUMBER 261 #define ACT 262 #define FLU 263 #define CAUS 264 #define IF 265 #define AFTER 266 #define TRUE 267 #define FALSE 268 #define DEF 269 #define INERT 270 #define CAUSES 271 #define ALWAYS 272 #define MAY 273 #define NONEXE 274 #define WHERE 275 #define OC_AT 276 #define HO_AT 277 #define OCCURS 278 #define HOLDS 279 #define NECES 280 #define AT 281 #define NOT 282 #define COMMA 283 #define SEMIC 284 #define COLON 285 #define DOT 286 #define DDOT 287 #define LBRAC 288 #define RBRAC 289 #define EQ 290 #define NEQ 291 #define LT 292 #define GT 293 #define LE 294 #define GE 295 #define PLUS 296 #define MINUS 297 #define TIMES 298 #define DIV 299 #define MOD 300 #define AND 301 #define OR 302 #define XOR 303 #define LTL 304 #define LTLNOT 305 #define LTLOR 306 #define IMPL 307 #define EQUIV 308 #define X 309 #define F 310 #define G 311 #define U 312 #define R 313 #line 169 "/usr/share/bison++/bison.h" /* #defines token */ /* after #define tokens, before const tokens S5*/ #else #ifndef YY_Parser_CLASS #define YY_Parser_CLASS Parser #endif #ifndef YY_Parser_INHERIT #define YY_Parser_INHERIT #endif #ifndef YY_Parser_MEMBERS #define YY_Parser_MEMBERS #endif #ifndef YY_Parser_LEX_BODY #define YY_Parser_LEX_BODY #endif #ifndef YY_Parser_ERROR_BODY #define YY_Parser_ERROR_BODY #endif #ifndef YY_Parser_CONSTRUCTOR_PARAM #define YY_Parser_CONSTRUCTOR_PARAM #endif /* choose between enum and const */ #ifndef YY_Parser_USE_CONST_TOKEN #define YY_Parser_USE_CONST_TOKEN 0 /* yes enum is more compatible with flex, */ /* so by default we use it */ #endif #if YY_Parser_USE_CONST_TOKEN != 0 #ifndef YY_Parser_ENUM_TOKEN #define YY_Parser_ENUM_TOKEN yy_Parser_enum_token #endif #endif class YY_Parser_CLASS YY_Parser_INHERIT { public: #if YY_Parser_USE_CONST_TOKEN != 0 /* static const int token ... */ #line 212 "/usr/share/bison++/bison.h" static const int IDENTIFIER; static const int NEG_IDENTI; static const int VARIABLE; static const int NUMBER; static const int ACT; static const int FLU; static const int CAUS; static const int IF; static const int AFTER; static const int TRUE; static const int FALSE; static const int DEF; static const int INERT; static const int CAUSES; static const int ALWAYS; static const int MAY; static const int NONEXE; static const int WHERE; static const int OC_AT; static const int HO_AT; static const int OCCURS; static const int HOLDS; static const int NECES; static const int AT; static const int NOT; static const int COMMA; static const int SEMIC; static const int COLON; static const int DOT; static const int DDOT; static const int LBRAC; static const int RBRAC; static const int EQ; static const int NEQ; static const int LT; static const int GT; static const int LE; static const int GE; static const int PLUS; static const int MINUS; static const int TIMES; static const int DIV; static const int MOD; static const int AND; static const int OR; static const int XOR; static const int LTL; static const int LTLNOT; static const int LTLOR; static const int IMPL; static const int EQUIV; static const int X; static const int F; static const int G; static const int U; static const int R; #line 212 "/usr/share/bison++/bison.h" /* decl const */ #else enum YY_Parser_ENUM_TOKEN { YY_Parser_NULL_TOKEN=0 #line 215 "/usr/share/bison++/bison.h" ,IDENTIFIER=258 ,NEG_IDENTI=259 ,VARIABLE=260 ,NUMBER=261 ,ACT=262 ,FLU=263 ,CAUS=264 ,IF=265 ,AFTER=266 ,TRUE=267 ,FALSE=268 ,DEF=269 ,INERT=270 ,CAUSES=271 ,ALWAYS=272 ,MAY=273 ,NONEXE=274 ,WHERE=275 ,OC_AT=276 ,HO_AT=277 ,OCCURS=278 ,HOLDS=279 ,NECES=280 ,AT=281 ,NOT=282 ,COMMA=283 ,SEMIC=284 ,COLON=285 ,DOT=286 ,DDOT=287 ,LBRAC=288 ,RBRAC=289 ,EQ=290 ,NEQ=291 ,LT=292 ,GT=293 ,LE=294 ,GE=295 ,PLUS=296 ,MINUS=297 ,TIMES=298 ,DIV=299 ,MOD=300 ,AND=301 ,OR=302 ,XOR=303 ,LTL=304 ,LTLNOT=305 ,LTLOR=306 ,IMPL=307 ,EQUIV=308 ,X=309 ,F=310 ,G=311 ,U=312 ,R=313 #line 215 "/usr/share/bison++/bison.h" /* enum token */ }; /* end of enum declaration */ #endif public: int YY_Parser_PARSE(YY_Parser_PARSE_PARAM); virtual void YY_Parser_ERROR(char *msg) YY_Parser_ERROR_BODY; #ifdef YY_Parser_PURE #ifdef YY_Parser_LSP_NEEDED virtual int YY_Parser_LEX(YY_Parser_STYPE *YY_Parser_LVAL,YY_Parser_LTYPE *YY_Parser_LLOC) YY_Parser_LEX_BODY; #else virtual int YY_Parser_LEX(YY_Parser_STYPE *YY_Parser_LVAL) YY_Parser_LEX_BODY; #endif #else virtual int YY_Parser_LEX() YY_Parser_LEX_BODY; YY_Parser_STYPE YY_Parser_LVAL; #ifdef YY_Parser_LSP_NEEDED YY_Parser_LTYPE YY_Parser_LLOC; #endif int YY_Parser_NERRS; int YY_Parser_CHAR; #endif #if YY_Parser_DEBUG != 0 public: int YY_Parser_DEBUG_FLAG; /* nonzero means print parse trace */ #endif public: YY_Parser_CLASS(YY_Parser_CONSTRUCTOR_PARAM); public: YY_Parser_MEMBERS }; /* other declare folow */ #endif #if YY_Parser_COMPATIBILITY != 0 /* backward compatibility */ /* Removed due to bison problems /#ifndef YYSTYPE / #define YYSTYPE YY_Parser_STYPE /#endif*/ #ifndef YYLTYPE #define YYLTYPE YY_Parser_LTYPE #endif #ifndef YYDEBUG #ifdef YY_Parser_DEBUG #define YYDEBUG YY_Parser_DEBUG #endif #endif #endif /* END */ #line 267 "/usr/share/bison++/bison.h" #endif coala-1.0.1_src/src/lib/c/Identifier.cpp000644 001750 001750 00000003055 11477164507 020547 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Identifier.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Identifier.h" using namespace C; //Identifier::Identifier() {} Identifier::Identifier(string* name) { name_ = *name; delete name; args_ = NULL; } Identifier::Identifier(string* name, Arguments* args) { name_ = *name; args_ = args; } Identifier::~Identifier() { delete args_; } string Identifier::getName() { return name_; } /** * @return vector */ set* Identifier::getVariables ( ) { if(args_) return args_->getVariables(); else return new set(); } coala-1.0.1_src/src/lib/c/FluentAction.h000644 001750 001750 00000003130 11477164507 020517 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Fluent.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef FLUENTACTION_H #define FLUENTACTION_H #include "Formula.h" #include "Identifier.h" #include "Printer.h" #include namespace C { class Formula; class FluentAction : public Identifier, public Formula { public: FluentAction(string* name, Arguments* args); FluentAction(string* name); virtual ~FluentAction(); string print(Printer* p, string T); string print(Printer* p); string getNameWithArgs(); void setClass(string); string getClass(); private: string class_; }; }; // end of package namespace #endif // FLUENTACTION_H coala-1.0.1_src/src/lib/c/Parser.cpp000644 001750 001750 00000224436 11477164507 017731 0ustar00tovok7tovok7000000 000000 #define YY_Parser_h_included #define YY_USE_CLASS /* A Bison++ parser, made from /home/tovok7/svn/potassco/coala/src/lib/c/Parser.y */ /* with Bison++ version bison++ Version 1.21.9-1, adapted from GNU bison by coetmeur@icdc.fr Maintained by Magnus Ekdahl */ #define YY_USE_CLASS #line 1 "/usr/share/bison++/bison.cc" /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, when this file is copied by Bison++ into a Bison++ output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison, and has been in Bison++ since 1.21.9. */ /* HEADER SECTION */ #if defined( _MSDOS ) || defined(MSDOS) || defined(__MSDOS__) #define __MSDOS_AND_ALIKE #endif #if defined(_WINDOWS) && defined(_MSC_VER) #define __HAVE_NO_ALLOCA #define __MSDOS_AND_ALIKE #endif #ifndef alloca #if defined( __GNUC__) #define alloca __builtin_alloca #elif (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) #include #elif defined (__MSDOS_AND_ALIKE) #include #ifndef __TURBOC__ /* MS C runtime lib */ #define alloca _alloca #endif #elif defined(_AIX) /* pragma must be put before any C/C++ instruction !! */ #pragma alloca #include #elif defined(__hpux) #ifdef __cplusplus extern "C" { void *alloca (unsigned int); }; #else /* not __cplusplus */ void *alloca (); #endif /* not __cplusplus */ #endif /* not _AIX not MSDOS, or __TURBOC__ or _AIX, not sparc. */ #endif /* alloca not defined. */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #ifndef YY_USE_CLASS /*#warning "For C++ its recomended to use bison++, otherwise classes won't be generated"*/ #endif #else #ifndef __STDC__ #define const #endif #ifdef YY_USE_CLASS #error "This is a C++ header generated by bison++, please use a C++ compiler!" #endif #endif #include #define YYBISON 1 #line 88 "/usr/share/bison++/bison.cc" #define YY_Parser_LSP_NEEDED #define YY_Parser_ERROR_BODY = 0 #define YY_Parser_LEX_BODY = 0 #define YY_Parser_MEMBERS void preProcessing(Coala::CompilerOptions*); void postProcessing(Printer*); virtual ~Parser(){}\ private: std::string to_string(int integer); #line 27 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" #include #include #include #include #include #include "../options.h" #include "Program.h" #include "Printer.h" using namespace std; using namespace C; #line 42 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" Program* program; #line 46 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" typedef union { int number; string* str; Formula* form; Type* typ; Types* types; Arguments* args; Constraint* constr; Pool* var_pool; Interval* interval; LTLNode* ltl_node; } yy_Parser_stype; #define YY_Parser_STYPE yy_Parser_stype #line 88 "/usr/share/bison++/bison.cc" /* %{ and %header{ and %union, during decl */ #define YY_Parser_BISON 1 #ifndef YY_Parser_COMPATIBILITY #ifndef YY_USE_CLASS #define YY_Parser_COMPATIBILITY 1 #else #define YY_Parser_COMPATIBILITY 0 #endif #endif #if YY_Parser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YYLTYPE #ifndef YY_Parser_LTYPE #define YY_Parser_LTYPE YYLTYPE #endif #endif /* Testing alternative bison solution /#ifdef YYSTYPE*/ #ifndef YY_Parser_STYPE #define YY_Parser_STYPE YYSTYPE #endif /*#endif*/ #ifdef YYDEBUG #ifndef YY_Parser_DEBUG #define YY_Parser_DEBUG YYDEBUG #endif #endif /* use goto to be compatible */ #ifndef YY_Parser_USE_GOTO #define YY_Parser_USE_GOTO 1 #endif #endif /* use no goto to be clean in C++ */ #ifndef YY_Parser_USE_GOTO #define YY_Parser_USE_GOTO 0 #endif #ifndef YY_Parser_PURE #line 130 "/usr/share/bison++/bison.cc" #line 130 "/usr/share/bison++/bison.cc" /* YY_Parser_PURE */ #endif /* section apres lecture def, avant lecture grammaire S2 */ #line 134 "/usr/share/bison++/bison.cc" #line 134 "/usr/share/bison++/bison.cc" /* prefix */ #ifndef YY_Parser_DEBUG #line 136 "/usr/share/bison++/bison.cc" #line 136 "/usr/share/bison++/bison.cc" /* YY_Parser_DEBUG */ #endif #ifndef YY_Parser_LSP_NEEDED #line 141 "/usr/share/bison++/bison.cc" #line 141 "/usr/share/bison++/bison.cc" /* YY_Parser_LSP_NEEDED*/ #endif /* DEFAULT LTYPE*/ #ifdef YY_Parser_LSP_NEEDED #ifndef YY_Parser_LTYPE #ifndef BISON_YYLTYPE_ISDECLARED #define BISON_YYLTYPE_ISDECLARED typedef struct yyltype { int timestamp; int first_line; int first_column; int last_line; int last_column; char *text; } yyltype; #endif #define YY_Parser_LTYPE yyltype #endif #endif /* DEFAULT STYPE*/ /* We used to use `unsigned long' as YY_Parser_STYPE on MSDOS, but it seems better to be consistent. Most programs should declare their own type anyway. */ #ifndef YY_Parser_STYPE #define YY_Parser_STYPE int #endif /* DEFAULT MISCELANEOUS */ #ifndef YY_Parser_PARSE #define YY_Parser_PARSE yyparse #endif #ifndef YY_Parser_LEX #define YY_Parser_LEX yylex #endif #ifndef YY_Parser_LVAL #define YY_Parser_LVAL yylval #endif #ifndef YY_Parser_LLOC #define YY_Parser_LLOC yylloc #endif #ifndef YY_Parser_CHAR #define YY_Parser_CHAR yychar #endif #ifndef YY_Parser_NERRS #define YY_Parser_NERRS yynerrs #endif #ifndef YY_Parser_DEBUG_FLAG #define YY_Parser_DEBUG_FLAG yydebug #endif #ifndef YY_Parser_ERROR #define YY_Parser_ERROR yyerror #endif #ifndef YY_Parser_PARSE_PARAM #ifndef YY_USE_CLASS #ifdef YYPARSE_PARAM #define YY_Parser_PARSE_PARAM void* YYPARSE_PARAM #else #ifndef __STDC__ #ifndef __cplusplus #define YY_Parser_PARSE_PARAM #endif #endif #endif #endif #ifndef YY_Parser_PARSE_PARAM #define YY_Parser_PARSE_PARAM void #endif #endif #if YY_Parser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YY_Parser_LTYPE #ifndef YYLTYPE #define YYLTYPE YY_Parser_LTYPE #else /* WARNING obsolete !!! user defined YYLTYPE not reported into generated header */ #endif #endif /* Removed due to bison compabilityproblems /#ifndef YYSTYPE /#define YYSTYPE YY_Parser_STYPE /#else*/ /* WARNING obsolete !!! user defined YYSTYPE not reported into generated header */ /*#endif*/ #ifdef YY_Parser_PURE # ifndef YYPURE # define YYPURE YY_Parser_PURE # endif #endif #ifdef YY_Parser_DEBUG # ifndef YYDEBUG # define YYDEBUG YY_Parser_DEBUG # endif #endif #ifndef YY_Parser_ERROR_VERBOSE #ifdef YYERROR_VERBOSE #define YY_Parser_ERROR_VERBOSE YYERROR_VERBOSE #endif #endif #ifndef YY_Parser_LSP_NEEDED # ifdef YYLSP_NEEDED # define YY_Parser_LSP_NEEDED YYLSP_NEEDED # endif #endif #endif #ifndef YY_USE_CLASS /* TOKEN C */ #line 263 "/usr/share/bison++/bison.cc" #define IDENTIFIER 258 #define NEG_IDENTI 259 #define VARIABLE 260 #define NUMBER 261 #define ACT 262 #define FLU 263 #define CAUS 264 #define IF 265 #define AFTER 266 #define TRUE 267 #define FALSE 268 #define DEF 269 #define INERT 270 #define CAUSES 271 #define ALWAYS 272 #define MAY 273 #define NONEXE 274 #define WHERE 275 #define OC_AT 276 #define HO_AT 277 #define OCCURS 278 #define HOLDS 279 #define NECES 280 #define AT 281 #define NOT 282 #define COMMA 283 #define SEMIC 284 #define COLON 285 #define DOT 286 #define DDOT 287 #define LBRAC 288 #define RBRAC 289 #define EQ 290 #define NEQ 291 #define LT 292 #define GT 293 #define LE 294 #define GE 295 #define PLUS 296 #define MINUS 297 #define TIMES 298 #define DIV 299 #define MOD 300 #define AND 301 #define OR 302 #define XOR 303 #define LTL 304 #define LTLNOT 305 #define LTLOR 306 #define IMPL 307 #define EQUIV 308 #define X 309 #define F 310 #define G 311 #define U 312 #define R 313 #line 263 "/usr/share/bison++/bison.cc" /* #defines tokens */ #else /* CLASS */ #ifndef YY_Parser_CLASS #define YY_Parser_CLASS Parser #endif #ifndef YY_Parser_INHERIT #define YY_Parser_INHERIT #endif #ifndef YY_Parser_MEMBERS #define YY_Parser_MEMBERS #endif #ifndef YY_Parser_LEX_BODY #define YY_Parser_LEX_BODY #endif #ifndef YY_Parser_ERROR_BODY #define YY_Parser_ERROR_BODY #endif #ifndef YY_Parser_CONSTRUCTOR_PARAM #define YY_Parser_CONSTRUCTOR_PARAM #endif #ifndef YY_Parser_CONSTRUCTOR_CODE #define YY_Parser_CONSTRUCTOR_CODE #endif #ifndef YY_Parser_CONSTRUCTOR_INIT #define YY_Parser_CONSTRUCTOR_INIT #endif /* choose between enum and const */ #ifndef YY_Parser_USE_CONST_TOKEN #define YY_Parser_USE_CONST_TOKEN 0 /* yes enum is more compatible with flex, */ /* so by default we use it */ #endif #if YY_Parser_USE_CONST_TOKEN != 0 #ifndef YY_Parser_ENUM_TOKEN #define YY_Parser_ENUM_TOKEN yy_Parser_enum_token #endif #endif class YY_Parser_CLASS YY_Parser_INHERIT { public: #if YY_Parser_USE_CONST_TOKEN != 0 /* static const int token ... */ #line 307 "/usr/share/bison++/bison.cc" static const int IDENTIFIER; static const int NEG_IDENTI; static const int VARIABLE; static const int NUMBER; static const int ACT; static const int FLU; static const int CAUS; static const int IF; static const int AFTER; static const int TRUE; static const int FALSE; static const int DEF; static const int INERT; static const int CAUSES; static const int ALWAYS; static const int MAY; static const int NONEXE; static const int WHERE; static const int OC_AT; static const int HO_AT; static const int OCCURS; static const int HOLDS; static const int NECES; static const int AT; static const int NOT; static const int COMMA; static const int SEMIC; static const int COLON; static const int DOT; static const int DDOT; static const int LBRAC; static const int RBRAC; static const int EQ; static const int NEQ; static const int LT; static const int GT; static const int LE; static const int GE; static const int PLUS; static const int MINUS; static const int TIMES; static const int DIV; static const int MOD; static const int AND; static const int OR; static const int XOR; static const int LTL; static const int LTLNOT; static const int LTLOR; static const int IMPL; static const int EQUIV; static const int X; static const int F; static const int G; static const int U; static const int R; #line 307 "/usr/share/bison++/bison.cc" /* decl const */ #else enum YY_Parser_ENUM_TOKEN { YY_Parser_NULL_TOKEN=0 #line 310 "/usr/share/bison++/bison.cc" ,IDENTIFIER=258 ,NEG_IDENTI=259 ,VARIABLE=260 ,NUMBER=261 ,ACT=262 ,FLU=263 ,CAUS=264 ,IF=265 ,AFTER=266 ,TRUE=267 ,FALSE=268 ,DEF=269 ,INERT=270 ,CAUSES=271 ,ALWAYS=272 ,MAY=273 ,NONEXE=274 ,WHERE=275 ,OC_AT=276 ,HO_AT=277 ,OCCURS=278 ,HOLDS=279 ,NECES=280 ,AT=281 ,NOT=282 ,COMMA=283 ,SEMIC=284 ,COLON=285 ,DOT=286 ,DDOT=287 ,LBRAC=288 ,RBRAC=289 ,EQ=290 ,NEQ=291 ,LT=292 ,GT=293 ,LE=294 ,GE=295 ,PLUS=296 ,MINUS=297 ,TIMES=298 ,DIV=299 ,MOD=300 ,AND=301 ,OR=302 ,XOR=303 ,LTL=304 ,LTLNOT=305 ,LTLOR=306 ,IMPL=307 ,EQUIV=308 ,X=309 ,F=310 ,G=311 ,U=312 ,R=313 #line 310 "/usr/share/bison++/bison.cc" /* enum token */ }; /* end of enum declaration */ #endif public: int YY_Parser_PARSE (YY_Parser_PARSE_PARAM); virtual void YY_Parser_ERROR(char *msg) YY_Parser_ERROR_BODY; #ifdef YY_Parser_PURE #ifdef YY_Parser_LSP_NEEDED virtual int YY_Parser_LEX (YY_Parser_STYPE *YY_Parser_LVAL,YY_Parser_LTYPE *YY_Parser_LLOC) YY_Parser_LEX_BODY; #else virtual int YY_Parser_LEX (YY_Parser_STYPE *YY_Parser_LVAL) YY_Parser_LEX_BODY; #endif #else virtual int YY_Parser_LEX() YY_Parser_LEX_BODY; YY_Parser_STYPE YY_Parser_LVAL; #ifdef YY_Parser_LSP_NEEDED YY_Parser_LTYPE YY_Parser_LLOC; #endif int YY_Parser_NERRS; int YY_Parser_CHAR; #endif #if YY_Parser_DEBUG != 0 int YY_Parser_DEBUG_FLAG; /* nonzero means print parse trace */ #endif public: YY_Parser_CLASS(YY_Parser_CONSTRUCTOR_PARAM); public: YY_Parser_MEMBERS }; /* other declare folow */ #if YY_Parser_USE_CONST_TOKEN != 0 #line 341 "/usr/share/bison++/bison.cc" const int YY_Parser_CLASS::IDENTIFIER=258; const int YY_Parser_CLASS::NEG_IDENTI=259; const int YY_Parser_CLASS::VARIABLE=260; const int YY_Parser_CLASS::NUMBER=261; const int YY_Parser_CLASS::ACT=262; const int YY_Parser_CLASS::FLU=263; const int YY_Parser_CLASS::CAUS=264; const int YY_Parser_CLASS::IF=265; const int YY_Parser_CLASS::AFTER=266; const int YY_Parser_CLASS::TRUE=267; const int YY_Parser_CLASS::FALSE=268; const int YY_Parser_CLASS::DEF=269; const int YY_Parser_CLASS::INERT=270; const int YY_Parser_CLASS::CAUSES=271; const int YY_Parser_CLASS::ALWAYS=272; const int YY_Parser_CLASS::MAY=273; const int YY_Parser_CLASS::NONEXE=274; const int YY_Parser_CLASS::WHERE=275; const int YY_Parser_CLASS::OC_AT=276; const int YY_Parser_CLASS::HO_AT=277; const int YY_Parser_CLASS::OCCURS=278; const int YY_Parser_CLASS::HOLDS=279; const int YY_Parser_CLASS::NECES=280; const int YY_Parser_CLASS::AT=281; const int YY_Parser_CLASS::NOT=282; const int YY_Parser_CLASS::COMMA=283; const int YY_Parser_CLASS::SEMIC=284; const int YY_Parser_CLASS::COLON=285; const int YY_Parser_CLASS::DOT=286; const int YY_Parser_CLASS::DDOT=287; const int YY_Parser_CLASS::LBRAC=288; const int YY_Parser_CLASS::RBRAC=289; const int YY_Parser_CLASS::EQ=290; const int YY_Parser_CLASS::NEQ=291; const int YY_Parser_CLASS::LT=292; const int YY_Parser_CLASS::GT=293; const int YY_Parser_CLASS::LE=294; const int YY_Parser_CLASS::GE=295; const int YY_Parser_CLASS::PLUS=296; const int YY_Parser_CLASS::MINUS=297; const int YY_Parser_CLASS::TIMES=298; const int YY_Parser_CLASS::DIV=299; const int YY_Parser_CLASS::MOD=300; const int YY_Parser_CLASS::AND=301; const int YY_Parser_CLASS::OR=302; const int YY_Parser_CLASS::XOR=303; const int YY_Parser_CLASS::LTL=304; const int YY_Parser_CLASS::LTLNOT=305; const int YY_Parser_CLASS::LTLOR=306; const int YY_Parser_CLASS::IMPL=307; const int YY_Parser_CLASS::EQUIV=308; const int YY_Parser_CLASS::X=309; const int YY_Parser_CLASS::F=310; const int YY_Parser_CLASS::G=311; const int YY_Parser_CLASS::U=312; const int YY_Parser_CLASS::R=313; #line 341 "/usr/share/bison++/bison.cc" /* const YY_Parser_CLASS::token */ #endif /*apres const */ YY_Parser_CLASS::YY_Parser_CLASS(YY_Parser_CONSTRUCTOR_PARAM) YY_Parser_CONSTRUCTOR_INIT { #if YY_Parser_DEBUG != 0 YY_Parser_DEBUG_FLAG=0; #endif YY_Parser_CONSTRUCTOR_CODE; }; #endif #line 352 "/usr/share/bison++/bison.cc" #define YYFINAL 248 #define YYFLAG -32768 #define YYNTBASE 59 #define YYTRANSLATE(x) ((unsigned)(x) <= 313 ? yytranslate[x] : 91) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58 }; #if YY_Parser_DEBUG != 0 static const short yyprhs[] = { 0, 0, 1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 44, 49, 52, 57, 60, 65, 70, 77, 82, 89, 96, 105, 108, 113, 118, 125, 128, 133, 137, 143, 149, 157, 158, 161, 166, 170, 176, 182, 190, 193, 198, 203, 210, 214, 218, 224, 230, 234, 238, 244, 250, 257, 266, 268, 270, 272, 276, 278, 283, 285, 290, 292, 294, 296, 298, 300, 305, 309, 313, 317, 321, 325, 332, 336, 340, 344, 348, 352, 356, 358, 360, 364, 368, 374, 378, 382, 388, 394, 402, 407, 413, 417, 421, 425, 429, 433, 437, 441, 445, 449, 453, 457, 461, 465, 469, 473, 477, 481, 485, 489, 491, 493, 495, 497, 499, 501, 503, 505, 507, 509, 511, 513, 515, 517, 520, 522, 526, 529, 533, 537, 541, 545, 548, 551, 554, 558 }; static const short yyrhs[] = { -1, 59, 60, 31, 0, 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 89, 0, 7, 78, 0, 7, 78, 20, 83, 0, 8, 78, 0, 8, 78, 20, 83, 0, 9, 78, 0, 9, 78, 20, 83, 0, 9, 78, 10, 78, 0, 9, 78, 10, 78, 20, 83, 0, 9, 78, 11, 78, 0, 9, 78, 11, 78, 20, 83, 0, 9, 78, 10, 78, 11, 78, 0, 9, 78, 10, 78, 11, 78, 20, 83, 0, 14, 78, 0, 14, 78, 20, 83, 0, 14, 78, 10, 78, 0, 14, 78, 10, 78, 20, 83, 0, 15, 78, 0, 15, 78, 20, 83, 0, 78, 16, 78, 0, 78, 16, 78, 20, 83, 0, 78, 16, 78, 10, 78, 0, 78, 16, 78, 10, 78, 20, 83, 0, 0, 17, 78, 0, 17, 78, 20, 83, 0, 78, 18, 78, 0, 78, 18, 78, 20, 83, 0, 78, 18, 78, 10, 78, 0, 78, 18, 78, 10, 78, 20, 83, 0, 19, 78, 0, 19, 78, 20, 83, 0, 19, 78, 10, 78, 0, 19, 78, 10, 78, 20, 83, 0, 78, 21, 6, 0, 78, 21, 3, 0, 78, 21, 6, 20, 83, 0, 78, 21, 3, 20, 83, 0, 78, 22, 6, 0, 78, 22, 3, 0, 78, 22, 6, 20, 83, 0, 78, 22, 3, 20, 83, 0, 25, 78, 11, 78, 26, 6, 0, 25, 78, 11, 78, 26, 6, 20, 83, 0, 79, 0, 12, 0, 13, 0, 78, 28, 79, 0, 3, 0, 3, 33, 80, 34, 0, 4, 0, 4, 33, 80, 34, 0, 5, 0, 3, 0, 6, 0, 81, 0, 82, 0, 3, 33, 80, 34, 0, 80, 28, 5, 0, 80, 28, 3, 0, 80, 28, 6, 0, 80, 28, 81, 0, 80, 28, 82, 0, 80, 28, 3, 33, 80, 34, 0, 5, 29, 5, 0, 81, 29, 5, 0, 6, 32, 6, 0, 6, 32, 5, 0, 5, 32, 6, 0, 5, 32, 5, 0, 85, 0, 84, 0, 6, 30, 84, 0, 84, 30, 6, 0, 6, 30, 84, 30, 6, 0, 83, 28, 85, 0, 83, 28, 84, 0, 83, 28, 6, 30, 84, 0, 83, 28, 84, 30, 6, 0, 83, 28, 6, 30, 84, 30, 6, 0, 3, 33, 80, 34, 0, 27, 3, 33, 80, 34, 0, 86, 87, 86, 0, 6, 87, 86, 0, 86, 87, 6, 0, 3, 87, 86, 0, 86, 87, 3, 0, 5, 87, 86, 0, 86, 87, 5, 0, 5, 87, 5, 0, 6, 87, 5, 0, 5, 87, 6, 0, 3, 87, 5, 0, 5, 87, 3, 0, 6, 87, 3, 0, 3, 87, 6, 0, 6, 88, 5, 0, 5, 88, 6, 0, 5, 88, 5, 0, 86, 88, 6, 0, 86, 88, 5, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, 49, 90, 0, 79, 0, 33, 90, 34, 0, 50, 90, 0, 90, 46, 90, 0, 90, 51, 90, 0, 90, 52, 90, 0, 90, 53, 90, 0, 54, 90, 0, 56, 90, 0, 55, 90, 0, 90, 57, 90, 0, 90, 58, 90, 0 }; #endif #if (YY_Parser_DEBUG != 0) || defined(YY_Parser_ERROR_VERBOSE) static const short yyrline[] = { 0, 140, 140, 142, 142, 142, 142, 144, 144, 146, 146, 148, 148, 148, 148, 148, 148, 150, 150, 150, 150, 153, 155, 158, 160, 163, 165, 166, 167, 170, 172, 173, 174, 177, 179, 180, 181, 184, 186, 189, 191, 192, 193, 196, 197, 198, 201, 203, 204, 205, 208, 210, 211, 212, 215, 217, 218, 219, 222, 224, 225, 226, 229, 231, 234, 236, 237, 238, 240, 242, 243, 244, 247, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 262, 264, 267, 269, 270, 271, 274, 276, 277, 278, 279, 280, 281, 282, 283, 284, 287, 289, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 309, 311, 312, 313, 314, 316, 318, 319, 320, 321, 322, 324, 326, 327, 328, 329, 330, 331, 332, 334, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348 }; static const char * const yytname[] = { "$","error","$illegal.","IDENTIFIER", "NEG_IDENTI","VARIABLE","NUMBER","ACT","FLU","CAUS","IF","AFTER","TRUE","FALSE", "DEF","INERT","CAUSES","ALWAYS","MAY","NONEXE","WHERE","OC_AT","HO_AT","OCCURS", "HOLDS","NECES","AT","NOT","COMMA","SEMIC","COLON","DOT","DDOT","LBRAC","RBRAC", "EQ","NEQ","LT","GT","LE","GE","PLUS","MINUS","TIMES","DIV","MOD","AND","OR", "XOR","LTL","LTLNOT","LTLOR","IMPL","EQUIV","X","F","G","U","R","program","rule", "fact","law","shortcut","query","act_fact","flu_fact","static_rule","dyn_rule", "def_rule","inert_rule","caus_rule","always_rule","may_rule","nonexe_rule","oc_query", "ho_query","hypo_query","formula","identifier","term_list","pool","interval", "types_list","type","constraint","operation","eqoperator","operator","ltl_query", "ltl_expr","" }; #endif static const short yyr1[] = { 0, 59, 59, 60, 60, 60, 60, 61, 61, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 65, 65, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 69, 69, 69, 69, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73, 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, 75, 76, 76, 76, 76, 77, 77, 78, 78, 78, 78, 79, 79, 79, 79, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 82, 82, 82, 82, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, 88, 88, 88, 88, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 }; static const short yyr2[] = { 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 4, 2, 4, 4, 6, 4, 6, 6, 8, 2, 4, 4, 6, 2, 4, 3, 5, 5, 7, 0, 2, 4, 3, 5, 5, 7, 2, 4, 4, 6, 3, 3, 5, 5, 3, 3, 5, 5, 6, 8, 1, 1, 1, 3, 1, 4, 1, 4, 1, 1, 1, 1, 1, 4, 3, 3, 3, 3, 3, 6, 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 5, 3, 3, 5, 5, 7, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 2, 3, 3, 3, 3, 2, 2, 2, 3, 3 }; static const short yydefact[] = { 1, 43, 68, 70, 0, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 64, 20, 0, 0, 21, 23, 25, 33, 37, 44, 50, 0, 0, 0, 0, 0, 0, 136, 135, 2, 0, 0, 0, 0, 0, 73, 72, 74, 0, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 143, 145, 144, 0, 0, 0, 0, 0, 0, 39, 46, 55, 54, 59, 58, 67, 0, 0, 0, 0, 0, 69, 0, 71, 0, 0, 0, 0, 22, 91, 90, 0, 24, 27, 29, 26, 35, 34, 38, 45, 52, 51, 0, 137, 139, 140, 141, 142, 146, 147, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 89, 88, 87, 86, 79, 78, 80, 81, 82, 85, 0, 121, 122, 123, 124, 125, 126, 0, 127, 128, 129, 130, 131, 132, 133, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 40, 48, 47, 57, 56, 61, 60, 77, 0, 0, 112, 115, 105, 113, 109, 111, 107, 118, 117, 0, 92, 114, 110, 0, 103, 116, 0, 0, 96, 95, 93, 106, 108, 104, 102, 120, 119, 31, 28, 30, 36, 53, 62, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 42, 49, 83, 94, 101, 97, 98, 32, 63, 0, 99, 0, 0 }; static const short yydefgoto[] = { 1, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 62, 63, 64, 108, 109, 110, 111, 169, 170, 35, 52 }; static const short yypact[] = {-32768, 136, -22, 33, 155, 155, 155,-32768,-32768, 155, 155, 155, 155, 155, 39, 44,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768, 168,-32768,-32768, 128, 128, -6, 35, 29, 81, 40, 70, 82, 7, 39, 39, 39, 39, 39, -32768, 130,-32768, 155, 155, 18, 295, 204, 37, 9, -3, -8, 74,-32768, 25, 27, 27, 155, 155, 27, 155, 27, 27, 27, 155, 27, 155, 54,-32768,-32768, -32768,-32768, 39, 39, 39, 39, 39, 39, 104, 132, 88, 98, 110, 127,-32768, 128, 149, 255, 282, 189, -32768, 188,-32768, 243, 208, 175, 153, 181, 196,-32768, 208, 181, 41, 76, 181, 151, 181, 181, 181, 178, 181, 71,-32768, 205, 205, 205, 205,-32768,-32768, 155, 27, 155, 27, 27, 27, 27, 27, 163,-32768,-32768, -32768,-32768,-32768, 231, 9, -3, 74,-32768,-32768, 128, -32768,-32768,-32768,-32768,-32768,-32768, 297,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768, 222, 299, 1, 290, 272, 261, 31, 283, 294, 301, 155, 27, 27, 27, 27, 302, 237, 181, 238, 181, 181, 181, 181, 181,-32768, 128, 256, 227, 227, 227,-32768, 227, 227, 227,-32768, -32768, 276, 280,-32768, 227, 227, 227,-32768, 128, 194, 281,-32768,-32768,-32768, 227, 227, 227,-32768,-32768, 239, 181, 181, 181, 181, 292, 27, 27, 257,-32768, 307, 258, 1, 308, 27, 27, 181, 181,-32768,-32768,-32768, 285,-32768, 181, 181, 310,-32768, 317,-32768 }; static const short yypgoto[] = {-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4, -2, -34, 218, 219, -57, -145, 148, -28, 69, -80,-32768, 116 }; #define YYLAST 320 static const short yytable[] = { 38, 39, 40, 65, 202, 41, 42, 43, 44, 45, 112, 36, 51, 115, 66, 117, 118, 119, 77, 121, 100, 91, 58, 203, 92, 167, 101, 211, 107, 99, 104, 175, 105, 106, 104, 58, 105, 210, 97, 68, 69, 98, 2, 3, 51, 51, 51, 51, 51, 70, 89, 90, 176, 100, 107, 67, 95, 58, 107, 103, 73, 177, 138, 58, 113, 114, 37, 116, 58, 58, 96, 120, 46, 122, 183, 53, 185, 186, 187, 188, 189, 51, 51, 51, 51, 51, 51, 241, 123, 47, 74, 71, 75, 48, 49, 50, 178, 181, 58, 58, 83, 72, 76, 102, 58, 84, 85, 86, 134, 58, 58, 87, 88, 167, 130, 175, 192, 167, 135, 175, 221, 222, 223, 224, 131, 167, 182, 175, 184, 195, 136, 59, 58, 60, 61, 167, 247, 175, 199, 2, 3, 207, 132, 4, 5, 6, 217, 137, 7, 8, 9, 10, 133, 11, 139, 12, 171, 228, 2, 3, 58, 13, 78, 79, 80, 81, 82, 7, 8, 236, 237, 179, 220, 157, 166, 231, 83, 243, 244, 58, 174, 84, 85, 86, 54, 14, 55, 87, 88, 56, 57, 100, 144, 149, 145, 146, 58, 190, 180, 124, 125, 126, 127, 128, 129, 168, 58, 2, 3, 172, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 232, 196, 173, 197, 198, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 226, 227, 234, 140, 141, 87, 88, 191, 58, 58, 58, 158, 159, 160, 161, 162, 163, 164, 165, 150, 208, 151, 152, 153, 154, 155, 156, 100, 100, 100, 142, 143, 213, 229, 238, 240, 204, 209, 205, 206, 214, 93, 215, 216, 94, 193, 194, 200, 201, 218, 219, 225, 150, 230, 233, 235, 239, 242, 245, 246, 248, 147, 148, 212 }; static const short yycheck[] = { 4, 5, 6, 37, 3, 9, 10, 11, 12, 13, 67, 33, 14, 70, 20, 72, 73, 74, 11, 76, 28, 3, 28, 168, 6, 105, 34, 172, 27, 32, 3, 111, 5, 6, 3, 28, 5, 6, 29, 10, 11, 32, 3, 4, 46, 47, 48, 49, 50, 20, 54, 55, 11, 28, 27, 20, 58, 28, 27, 34, 20, 20, 96, 28, 68, 69, 33, 71, 28, 28, 33, 75, 33, 77, 131, 31, 133, 134, 135, 136, 137, 83, 84, 85, 86, 87, 88, 232, 34, 50, 20, 10, 10, 54, 55, 56, 20, 26, 28, 28, 46, 20, 20, 29, 28, 51, 52, 53, 20, 28, 28, 57, 58, 193, 10, 195, 150, 197, 20, 199, 177, 178, 179, 180, 20, 205, 130, 207, 132, 157, 20, 3, 28, 5, 6, 215, 0, 217, 166, 3, 4, 169, 10, 7, 8, 9, 174, 20, 12, 13, 14, 15, 20, 17, 5, 19, 3, 191, 3, 4, 28, 25, 46, 47, 48, 49, 50, 12, 13, 226, 227, 20, 176, 104, 105, 209, 46, 234, 235, 28, 111, 51, 52, 53, 16, 49, 18, 57, 58, 21, 22, 28, 3, 5, 5, 6, 28, 34, 20, 83, 84, 85, 86, 87, 88, 30, 28, 3, 4, 28, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 30, 3, 30, 5, 6, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 20, 20, 20, 5, 6, 57, 58, 33, 28, 28, 28, 41, 42, 43, 44, 45, 46, 47, 48, 33, 5, 35, 36, 37, 38, 39, 40, 28, 28, 28, 5, 6, 6, 34, 34, 34, 3, 33, 5, 6, 3, 3, 5, 6, 6, 5, 6, 5, 6, 5, 6, 6, 33, 30, 30, 20, 6, 6, 30, 6, 0, 100, 100, 172 }; #line 352 "/usr/share/bison++/bison.cc" /* fattrs + tables */ /* parser code folow */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* Note: dollar marks section change the next is replaced by the list of actions, each action as one case of the switch. */ #if YY_Parser_USE_GOTO != 0 /* SUPRESSION OF GOTO : on some C++ compiler (sun c++) the goto is strictly forbidden if any constructor/destructor is used in the whole function (very stupid isn't it ?) so goto are to be replaced with a 'while/switch/case construct' here are the macro to keep some apparent compatibility */ #define YYGOTO(lb) {yy_gotostate=lb;continue;} #define YYBEGINGOTO enum yy_labels yy_gotostate=yygotostart; \ for(;;) switch(yy_gotostate) { case yygotostart: { #define YYLABEL(lb) } case lb: { #define YYENDGOTO } } #define YYBEGINDECLARELABEL enum yy_labels {yygotostart #define YYDECLARELABEL(lb) ,lb #define YYENDDECLARELABEL }; #else /* macro to keep goto */ #define YYGOTO(lb) goto lb #define YYBEGINGOTO #define YYLABEL(lb) lb: #define YYENDGOTO #define YYBEGINDECLARELABEL #define YYDECLARELABEL(lb) #define YYENDDECLARELABEL #endif /* LABEL DECLARATION */ YYBEGINDECLARELABEL YYDECLARELABEL(yynewstate) YYDECLARELABEL(yybackup) /* YYDECLARELABEL(yyresume) */ YYDECLARELABEL(yydefault) YYDECLARELABEL(yyreduce) YYDECLARELABEL(yyerrlab) /* here on detecting error */ YYDECLARELABEL(yyerrlab1) /* here on error raised explicitly by an action */ YYDECLARELABEL(yyerrdefault) /* current state does not do anything special for the error token. */ YYDECLARELABEL(yyerrpop) /* pop the current state because it cannot handle the error token */ YYDECLARELABEL(yyerrhandle) YYENDDECLARELABEL /* ALLOCA SIMULATION */ /* __HAVE_NO_ALLOCA */ #ifdef __HAVE_NO_ALLOCA int __alloca_free_ptr(char *ptr,char *ref) {if(ptr!=ref) free(ptr); return 0;} #define __ALLOCA_alloca(size) malloc(size) #define __ALLOCA_free(ptr,ref) __alloca_free_ptr((char *)ptr,(char *)ref) #ifdef YY_Parser_LSP_NEEDED #define __ALLOCA_return(num) \ do { return( __ALLOCA_free(yyss,yyssa)+\ __ALLOCA_free(yyvs,yyvsa)+\ __ALLOCA_free(yyls,yylsa)+\ (num)); } while(0) #else #define __ALLOCA_return(num) \ do { return( __ALLOCA_free(yyss,yyssa)+\ __ALLOCA_free(yyvs,yyvsa)+\ (num)); } while(0) #endif #else #define __ALLOCA_return(num) do { return(num); } while(0) #define __ALLOCA_alloca(size) alloca(size) #define __ALLOCA_free(ptr,ref) #endif /* ENDALLOCA SIMULATION */ #define yyerrok (yyerrstatus = 0) #define yyclearin (YY_Parser_CHAR = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT __ALLOCA_return(0) #define YYABORT __ALLOCA_return(1) #define YYERROR YYGOTO(yyerrlab1) /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL YYGOTO(yyerrlab) #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (YY_Parser_CHAR == YYEMPTY && yylen == 1) \ { YY_Parser_CHAR = (token), YY_Parser_LVAL = (value); \ yychar1 = YYTRANSLATE (YY_Parser_CHAR); \ YYPOPSTACK; \ YYGOTO(yybackup); \ } \ else \ { YY_Parser_ERROR ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YY_Parser_PURE /* UNPURE */ #define YYLEX YY_Parser_LEX() #ifndef YY_USE_CLASS /* If nonreentrant, and not class , generate the variables here */ int YY_Parser_CHAR; /* the lookahead symbol */ YY_Parser_STYPE YY_Parser_LVAL; /* the semantic value of the */ /* lookahead symbol */ int YY_Parser_NERRS; /* number of parse errors so far */ #ifdef YY_Parser_LSP_NEEDED YY_Parser_LTYPE YY_Parser_LLOC; /* location data for the lookahead */ /* symbol */ #endif #endif #else /* PURE */ #ifdef YY_Parser_LSP_NEEDED #define YYLEX YY_Parser_LEX(&YY_Parser_LVAL, &YY_Parser_LLOC) #else #define YYLEX YY_Parser_LEX(&YY_Parser_LVAL) #endif #endif #ifndef YY_USE_CLASS #if YY_Parser_DEBUG != 0 int YY_Parser_DEBUG_FLAG; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ #ifdef __cplusplus static void __yy_bcopy (char *from, char *to, int count) #else #ifdef __STDC__ static void __yy_bcopy (char *from, char *to, int count) #else static void __yy_bcopy (from, to, count) char *from; char *to; int count; #endif #endif { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #endif int #ifdef YY_USE_CLASS YY_Parser_CLASS:: #endif YY_Parser_PARSE(YY_Parser_PARSE_PARAM) #ifndef __STDC__ #ifndef __cplusplus #ifndef YY_USE_CLASS /* parameter definition without protypes */ YY_Parser_PARSE_PARAM_DEF #endif #endif #endif { register int yystate; register int yyn; register short *yyssp; register YY_Parser_STYPE *yyvsp; int yyerrstatus; /* number of tokens to shift before error messages enabled */ int yychar1=0; /* lookahead token as an internal (translated) token number */ short yyssa[YYINITDEPTH]; /* the state stack */ YY_Parser_STYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ short *yyss = yyssa; /* refer to the stacks thru separate pointers */ YY_Parser_STYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YY_Parser_LSP_NEEDED YY_Parser_LTYPE yylsa[YYINITDEPTH]; /* the location stack */ YY_Parser_LTYPE *yyls = yylsa; YY_Parser_LTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif int yystacksize = YYINITDEPTH; #ifdef YY_Parser_PURE int YY_Parser_CHAR; YY_Parser_STYPE YY_Parser_LVAL; int YY_Parser_NERRS; #ifdef YY_Parser_LSP_NEEDED YY_Parser_LTYPE YY_Parser_LLOC; #endif #endif YY_Parser_STYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ int yylen; /* start loop, in which YYGOTO may be used. */ YYBEGINGOTO #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; YY_Parser_NERRS = 0; YY_Parser_CHAR = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YY_Parser_LSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ YYLABEL(yynewstate) *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YY_Parser_STYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YY_Parser_LSP_NEEDED YY_Parser_LTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YY_Parser_LSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YY_Parser_LSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { YY_Parser_ERROR("parser stack overflow"); __ALLOCA_return(2); } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; yyss = (short *) __ALLOCA_alloca (yystacksize * sizeof (*yyssp)); __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); __ALLOCA_free(yyss1,yyssa); yyvs = (YY_Parser_STYPE *) __ALLOCA_alloca (yystacksize * sizeof (*yyvsp)); __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); __ALLOCA_free(yyvs1,yyvsa); #ifdef YY_Parser_LSP_NEEDED yyls = (YY_Parser_LTYPE *) __ALLOCA_alloca (yystacksize * sizeof (*yylsp)); __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); __ALLOCA_free(yyls1,yylsa); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YY_Parser_LSP_NEEDED yylsp = yyls + size - 1; #endif #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Entering state %d\n", yystate); #endif YYGOTO(yybackup); YYLABEL(yybackup) /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* YYLABEL(yyresume) */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) YYGOTO(yydefault); /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (YY_Parser_CHAR == YYEMPTY) { #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Reading a token: "); #endif YY_Parser_CHAR = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (YY_Parser_CHAR <= 0) /* This means end of input. */ { yychar1 = 0; YY_Parser_CHAR = YYEOF; /* Don't call YYLEX any more */ #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(YY_Parser_CHAR); #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) { fprintf (stderr, "Next token is %d (%s", YY_Parser_CHAR, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, YY_Parser_CHAR, YY_Parser_LVAL); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) YYGOTO(yydefault); yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrlab); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrlab); if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Shifting token %d (%s), ", YY_Parser_CHAR, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (YY_Parser_CHAR != YYEOF) YY_Parser_CHAR = YYEMPTY; *++yyvsp = YY_Parser_LVAL; #ifdef YY_Parser_LSP_NEEDED *++yylsp = YY_Parser_LLOC; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; YYGOTO(yynewstate); /* Do the default action for the current state. */ YYLABEL(yydefault) yyn = yydefact[yystate]; if (yyn == 0) YYGOTO(yyerrlab); /* Do a reduction. yyn is the number of a rule to reduce with. */ YYLABEL(yyreduce) yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif #line 839 "/usr/share/bison++/bison.cc" switch (yyn) { case 21: #line 154 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addActionDef(yyvsp[0].form); ; break;} case 22: #line 155 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addActionDef(yyvsp[-2].form, yyvsp[0].types); ; break;} case 23: #line 159 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addFluentDef(yyvsp[0].form); ; break;} case 24: #line 160 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addFluentDef(yyvsp[-2].form, yyvsp[0].types); ; break;} case 25: #line 164 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addStaticRule(yyvsp[0].form, NULL); ; break;} case 26: #line 165 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addStaticRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 27: #line 166 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addStaticRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 28: #line 167 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addStaticRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 29: #line 171 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDynamicRule(yyvsp[-2].form, NULL, yyvsp[0].form); ; break;} case 30: #line 172 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDynamicRule(yyvsp[-4].form, NULL, yyvsp[-2].form, yyvsp[0].types); ; break;} case 31: #line 173 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDynamicRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].form); ; break;} case 32: #line 174 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDynamicRule(yyvsp[-6].form, yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 33: #line 178 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDefaultRule(yyvsp[0].form, NULL); ; break;} case 34: #line 179 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDefaultRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 35: #line 180 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDefaultRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 36: #line 181 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addDefaultRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 37: #line 185 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addInertialRule(yyvsp[0].form); ; break;} case 38: #line 186 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addInertialRule(yyvsp[-2].form, yyvsp[0].types); ; break;} case 39: #line 190 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addCausesRule(yyvsp[-2].form, yyvsp[0].form, NULL); ; break;} case 40: #line 191 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addCausesRule(yyvsp[-4].form, yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 41: #line 192 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addCausesRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].form); ; break;} case 42: #line 193 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addCausesRule(yyvsp[-6].form, yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 44: #line 197 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addAlwaysRule(yyvsp[0].form); ; break;} case 45: #line 198 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addAlwaysRule(yyvsp[-2].form, yyvsp[0].types); ; break;} case 46: #line 202 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addMayCauseRule(yyvsp[-2].form, yyvsp[0].form, NULL); ; break;} case 47: #line 203 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addMayCauseRule(yyvsp[-4].form, yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 48: #line 204 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addMayCauseRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].form); ; break;} case 49: #line 205 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addMayCauseRule(yyvsp[-6].form, yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 50: #line 209 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addNonexecutableRule(yyvsp[0].form, NULL); ; break;} case 51: #line 210 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addNonexecutableRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 52: #line 211 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addNonexecutableRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 53: #line 212 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addNonexecutableRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 54: #line 216 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("occurs", yyvsp[-2].form, to_string(yyvsp[0].number)); ; break;} case 55: #line 217 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("occurs", yyvsp[-2].form, *yyvsp[0].str); ; break;} case 56: #line 218 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("occurs", yyvsp[-4].form, to_string(yyvsp[-2].number), yyvsp[0].types); ; break;} case 57: #line 219 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("occurs", yyvsp[-4].form, *yyvsp[-2].str, yyvsp[0].types); ; break;} case 58: #line 223 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("holds", yyvsp[-2].form, to_string(yyvsp[0].number)); ; break;} case 59: #line 224 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("holds", yyvsp[-2].form, *yyvsp[0].str); ; break;} case 60: #line 225 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("holds", yyvsp[-4].form, to_string(yyvsp[-2].number), yyvsp[0].types); ; break;} case 61: #line 226 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addQQuery("holds", yyvsp[-4].form, *yyvsp[-2].str, yyvsp[0].types); ; break;} case 62: #line 230 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addRQuery(yyvsp[-4].form, yyvsp[-2].form, to_string(yyvsp[0].number)); ; break;} case 63: #line 231 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addRQuery(yyvsp[-6].form, yyvsp[-4].form, to_string(yyvsp[-2].number), yyvsp[0].types); ; break;} case 64: #line 235 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = program->addFormula('c', yyvsp[0].form); ; break;} case 65: #line 236 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = program->addFormula('c', new FluentAction(new string("0"))); ; break;} case 66: #line 237 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = program->addFormula('c', new Formula('n', new FluentAction(new string("0")))); ; break;} case 67: #line 238 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].form->addPart(yyvsp[0].form); yyval.form = yyvsp[-2].form; ; break;} case 68: #line 241 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = new FluentAction(yyvsp[0].str); ; break;} case 69: #line 242 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = new FluentAction(yyvsp[-3].str, yyvsp[-1].args); ; break;} case 70: #line 243 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = new Formula('n', new FluentAction(yyvsp[0].str)); ; break;} case 71: #line 244 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.form = new Formula('n', new FluentAction(yyvsp[-3].str, yyvsp[-1].args)); ; break;} case 72: #line 248 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.args = new Arguments(program->addVariable(yyvsp[0].str)); ; break;} case 73: #line 249 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.args = new Arguments(new Constant(yyvsp[0].str)); ; break;} case 74: #line 250 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.args = new Arguments(new Constant(yyvsp[0].number)); ; break;} case 75: #line 251 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.args = new Arguments(yyvsp[0].var_pool); ; break;} case 76: #line 252 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.args = new Arguments(yyvsp[0].interval); ; break;} case 77: #line 253 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.args = new Arguments(new Function(yyvsp[-3].str, yyvsp[-1].args->getArgs())); ; break;} case 78: #line 254 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].args->addVariable(program->addVariable(yyvsp[0].str)); yyval.args = yyvsp[-2].args; ; break;} case 79: #line 255 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].args->addConstant(new Constant(yyvsp[0].str)); yyval.args = yyvsp[-2].args; ; break;} case 80: #line 256 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].args->addConstant(new Constant(yyvsp[0].number)); yyval.args = yyvsp[-2].args; ; break;} case 81: #line 257 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].args->addPool(yyvsp[0].var_pool); yyval.args = yyvsp[-2].args; ; break;} case 82: #line 258 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].args->addInterval(yyvsp[0].interval); yyval.args = yyvsp[-2].args; ; break;} case 83: #line 259 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-5].args->addFunction(new Function(yyvsp[-3].str, yyvsp[-1].args->getArgs())); yyval.args = yyvsp[-5].args; ; break;} case 84: #line 263 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.var_pool = new Pool(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str)); ; break;} case 85: #line 264 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].var_pool->addVariable(program->addVariable(yyvsp[0].str)); yyval.var_pool = yyvsp[-2].var_pool; ; break;} case 86: #line 268 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.interval = new Interval(new Constant(yyvsp[-2].number), new Constant(yyvsp[0].number)); ; break;} case 87: #line 269 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.interval = new Interval(new Constant(yyvsp[-2].number), program->addVariable(yyvsp[0].str)); ; break;} case 88: #line 270 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.interval = new Interval(program->addVariable(yyvsp[-2].str), new Constant(yyvsp[0].number)); ; break;} case 89: #line 271 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.interval = new Interval(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str)); ; break;} case 90: #line 275 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.types = new Types(yyvsp[0].constr); ; break;} case 91: #line 276 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.types = new Types(yyvsp[0].typ); ; break;} case 92: #line 277 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[0].typ->setMin(yyvsp[-2].number); yyval.types = new Types(yyvsp[0].typ); ; break;} case 93: #line 278 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].typ->setMax(yyvsp[0].number); yyval.types = new Types(yyvsp[-2].typ); ; break;} case 94: #line 279 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].typ->setMin(yyvsp[-4].number); yyvsp[-2].typ->setMax(yyvsp[0].number); yyval.types = new Types(yyvsp[-2].typ); ; break;} case 95: #line 280 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].types->addType(yyvsp[0].constr); ; break;} case 96: #line 281 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].types->addType(yyvsp[0].typ); ; break;} case 97: #line 282 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[0].typ->setMin(yyvsp[-2].number); yyvsp[-4].types->addType(yyvsp[0].typ); ; break;} case 98: #line 283 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].typ->setMax(yyvsp[0].number); yyvsp[-4].types->addType(yyvsp[-2].typ); ; break;} case 99: #line 284 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].typ->setMin(yyvsp[-4].number); yyvsp[-2].typ->setMax(yyvsp[0].number); yyvsp[-6].types->addType(yyvsp[-2].typ); ; break;} case 100: #line 288 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.typ = new Type(yyvsp[-3].str, yyvsp[-1].args, true); ; break;} case 101: #line 289 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.typ = new Type(yyvsp[-3].str, yyvsp[-1].args, false); ; break;} case 102: #line 293 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].constr->merge(yyvsp[0].constr, yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 103: #line 294 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[0].constr->mergeLeft(new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str), yyvsp[-1].str); yyval.constr = yyvsp[0].constr; ; break;} case 104: #line 295 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+to_string(yyvsp[0].number)), yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 105: #line 296 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[0].constr->mergeLeft(new string(*yyvsp[-2].str+*yyvsp[-1].str), yyvsp[-1].str); yyval.constr = yyvsp[0].constr; ; break;} case 106: #line 297 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 107: #line 298 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[0].constr->mergeLeft(new string(*yyvsp[-2].str+*yyvsp[-1].str), program->addVariable(yyvsp[-2].str), yyvsp[-1].str); yyval.constr = yyvsp[0].constr; ; break;} case 108: #line 299 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+*yyvsp[0].str), program->addVariable(yyvsp[0].str), yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 109: #line 300 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 110: #line 301 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[0].str), new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 111: #line 302 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+to_string(yyvsp[0].number)), yyvsp[-1].str); ; break;} case 112: #line 303 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[0].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 113: #line 304 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 114: #line 305 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 115: #line 306 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(new string(*yyvsp[-2].str+*yyvsp[-1].str+to_string(yyvsp[0].number)), yyvsp[-1].str); ; break;} case 116: #line 310 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[0].str), new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str+*yyvsp[0].str)); ; break;} case 117: #line 311 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+to_string(yyvsp[0].number))); ; break;} case 118: #line 312 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str)); ; break;} case 119: #line 313 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+to_string(yyvsp[0].number))); yyval.constr = yyvsp[-2].constr; ; break;} case 120: #line 314 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+*yyvsp[0].str), program->addVariable(yyvsp[0].str)); yyval.constr = yyvsp[-2].constr; ; break;} case 121: #line 317 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("=="); ; break;} case 122: #line 318 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("!="); ; break;} case 123: #line 319 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("<"); ; break;} case 124: #line 320 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string(">"); ; break;} case 125: #line 321 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("<="); ; break;} case 126: #line 322 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string(">="); ; break;} case 127: #line 325 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("+"); ; break;} case 128: #line 326 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("-"); ; break;} case 129: #line 327 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("*"); ; break;} case 130: #line 328 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("/"); ; break;} case 131: #line 329 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string(" mod "); ; break;} case 132: #line 330 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("&"); ; break;} case 133: #line 331 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("?"); ; break;} case 134: #line 332 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.str = new string("^"); ; break;} case 135: #line 334 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { program->addLTLQuery(yyvsp[0].ltl_node); ; break;} case 136: #line 337 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(IDENTIFIER, NULL, NULL, yyvsp[0].form); ; break;} case 137: #line 338 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = yyvsp[-1].ltl_node; ; break;} case 138: #line 339 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(LTLNOT, NULL, yyvsp[0].ltl_node); ; break;} case 139: #line 340 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(AND, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 140: #line 341 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(LTLOR, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 141: #line 342 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(IMPL, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 142: #line 343 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(EQUIV, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 143: #line 344 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(X, NULL, yyvsp[0].ltl_node); ; break;} case 144: #line 345 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(G, NULL, yyvsp[0].ltl_node); ; break;} case 145: #line 346 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(F, NULL, yyvsp[0].ltl_node); ; break;} case 146: #line 347 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(U, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 147: #line 348 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" { yyval.ltl_node = program->getLTLNode(R, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} } #line 839 "/usr/share/bison++/bison.cc" /* the action file gets copied in in place of this dollarsign */ yyvsp -= yylen; yyssp -= yylen; #ifdef YY_Parser_LSP_NEEDED yylsp -= yylen; #endif #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YY_Parser_LSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = YY_Parser_LLOC.first_line; yylsp->first_column = YY_Parser_LLOC.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; YYGOTO(yynewstate); YYLABEL(yyerrlab) /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++YY_Parser_NERRS; #ifdef YY_Parser_ERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; msg = (char *) malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); if (count < 5) { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; } } YY_Parser_ERROR(msg); free(msg); } else YY_Parser_ERROR ("parse error; also virtual memory exceeded"); } else #endif /* YY_Parser_ERROR_VERBOSE */ YY_Parser_ERROR("parse error"); } YYGOTO(yyerrlab1); YYLABEL(yyerrlab1) /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (YY_Parser_CHAR == YYEOF) YYABORT; #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Discarding token %d (%s).\n", YY_Parser_CHAR, yytname[yychar1]); #endif YY_Parser_CHAR = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ YYGOTO(yyerrhandle); YYLABEL(yyerrdefault) /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) YYGOTO(yydefault); #endif YYLABEL(yyerrpop) /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YY_Parser_LSP_NEEDED yylsp--; #endif #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif YYLABEL(yyerrhandle) yyn = yypact[yystate]; if (yyn == YYFLAG) YYGOTO(yyerrdefault); yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) YYGOTO(yyerrdefault); yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrpop); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrpop); if (yyn == YYFINAL) YYACCEPT; #if YY_Parser_DEBUG != 0 if (YY_Parser_DEBUG_FLAG) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = YY_Parser_LVAL; #ifdef YY_Parser_LSP_NEEDED *++yylsp = YY_Parser_LLOC; #endif yystate = yyn; YYGOTO(yynewstate); /* end loop, in which YYGOTO may be used. */ YYENDGOTO } /* END */ #line 1038 "/usr/share/bison++/bison.cc" #line 351 "/home/tovok7/svn/potassco/coala/src/lib/c/Parser.y" /***************************************************************************************************************************/ void Parser::preProcessing(Coala::CompilerOptions* options) { program = new Program(options); program->setLine(&yylloc.first_line); } void Parser::postProcessing(Printer* p) { program->print(p); delete program; } std::string Parser::to_string(int integer) { std::stringstream ss; std::string str; ss << integer; ss >> str; return str; } coala-1.0.1_src/src/lib/c/Compiler.cpp000644 001750 001750 00000004750 11477164507 020242 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Compiler.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Compiler.h" namespace C { Compiler::Compiler(Coala::CompilerOptions* options) { options_ = options; change_input(options_->getInputStream()); printer_ = new Printer(options_->getOutputStream(), options_->getDebug(), options_->getFakeClassicalNegation(), options_->getIncremental(), options_->getReverseIncremental(), !options_->getWhereCheck(), !options_->getDirectEncoding(), options_->getLanguage()); } Compiler::~Compiler() { } int Compiler::compile() { preProcessing(options_); int result = yyparse(); postProcessing(printer_); return result; } int Compiler::yylex() { int token = lexer.yylex(); if(token == IDENTIFIER) yylval.str = new string(lexer.YYText()); else if(token == NEG_IDENTI) { // remove leading negation sign '-' from fluent string *tmp_str = new string(lexer.YYText()); tmp_str->erase(0,1); yylval.str = tmp_str; } else if(token == VARIABLE) { yylval.str = new string(lexer.YYText()); } else if(token == NUMBER) yylval.number = atoi(lexer.YYText()); yylloc.first_line = lexer.lineno(); yylloc.last_line = lexer.lineno(); yylloc.text = (char *)lexer.YYText(); return token; } void Compiler::yyerror(char *m) { // if(yylloc.text == "\n") yylloc.text = (char*)"[newline]"; cerr << "\n\nError: Syntax error in line "<T+"-1) :- "; for(vector::iterator n = F_->begin(); n != F_->end(); ++n) { FluentAction* f = (FluentAction*) *n; p->setSection('b'); string fluent = f->print(p, "0"); set* vars = f->getVariables(); if(p->no_direct_enc) { p->add("fluent(" + fluent + ")"); if(!vars->empty()) { p->add(" :- "); types_.print(p, vars, line_); } p->add(".\n"); } else { // fluent_f(0) :- not -fluent_f(0) p->add(fluent + " :- not " + p->neg + fluent); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); // -fluent_f(0) :- not fluent_f(0). p->add(p->neg + fluent + " :- not " + fluent); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); if(p->debug > 0) { p->add("#show fluent_" + f->getName() + "(" + createTempArgs(vars->size()) + ").\n"); } // :- f1_fluent(T-1), neg_f1_fluent(T-1). if(p->fake_neg) { string T; // print constraint twice: for T=0 and T>0 for(int i = 1; i <= 2; ++i) { if(i == 1) { p->setSection('b'); T = "0"; } else { p->setSection('c'); T = p->T; } p->add(":- " + f->print(p, T) + ", " + p->neg + f->print(p, T)); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); } if(p->debug > 1) { p->setSection('b'); p->add("#show " + p->neg + "fluent_" + f->getName() + "(" + createTempArgs(vars->size()) + ").\n"); } } p->setSection('c'); // completeness condition p->add(":- not " + f->print(p, p->T) + ", not " + p->neg + f->print(p, p->T)); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); // print LTL idle condition if(ltl) { // % idle if no fluents changed p->add("idle("+ f->getNameWithArgs() +","+p->T+"-1) :- "); p->add(f->print(p, p->T+"-1") + ", "); p->add(f->print(p, p->T)); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); p->add("idle("+ f->getNameWithArgs() +","+p->T+"-1) :- "); p->add(p->neg + f->print(p, p->T+"-1") + ", "); p->add(p->neg + f->print(p, p->T)); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); if(idle != "idle("+p->T+"-1) :- ") idle += ", "; idle += "idle(" + f->getNameWithArgs() + ","+p->T+"-1)"; if(!vars->empty()) { idle += " : " + types_.getAsString(p, vars, line_); } } } // end else: direct encoding delete vars; } if(!p->no_direct_enc && ltl) p->add(idle + ".\n"); } coala-1.0.1_src/src/lib/c/Printer.cpp000644 001750 001750 00000024122 11477164507 020106 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/Printer.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Printer.h" using namespace C; Printer::Printer(std::ostream* output_stream, int debug_level, bool fake_negation, bool incremental, bool reverse, bool no_where_check, bool no_dir_enc, string language) { o = output_stream; debug = debug_level; no_direct_enc = no_dir_enc; fake_neg = fake_negation; inc = incremental; rev = reverse; no_w_chk = no_where_check; lang = language; neg = fake_neg ? "neg_" : "-"; T = inc ? "t" : "T"; section_ = 'b'; printed_ltl_aux_ = false; if(!inc) { *o << "#domain time(T).\n"; *o << "time(1..t).\n"; } } Printer::~Printer() { } void Printer::setSection(char section) { if(inc) section_ = section; } void Printer::print() { if(no_direct_enc) { if(rev) printBackwardsEncoding(); else printEncoding(); } else { // hide everything except actions and fluents if(debug < 3) *o << "#hide.\n"; } if(inc) { *o << "\n#base.\n" << b.str() << extra.str(); *o << "\n#cumulative t.\n" << c.str(); *o << "\n#volatile t.\n" << v.str(); *o << "\n#base.\n"; } else if(no_direct_enc || printed_ltl_aux_) { *o << b.str(); *o << c.str(); *o << v.str(); } *o << extra.str(); } void Printer::add(std::string text) { if(inc) { if(section_ == 'b') b << text; else if(section_ == 'c') c << text; else if(section_ == 'v') v << text; } else { *o << text; // TODO remove flush // o->flush(); } } void Printer::addExtra(std::string text) { extra << text; } void Printer::printEncoding() { b << "\n%\n% Encoding of Action Language C\n%\n"; // #base. // % Artificial fluent "true" holds in initial state b << "holds(\"true\",0).\n"; // % Guess initial state b << "1 { holds(F,0), holds(neg(F),0) } 1 :- fluent(F).\n"; // % Propagate composite fluents b << "holds(G,0) :- cfluent(G), holds(F,0) : fpart(G,F).\n"; b << "holds(neg(G),0) :- fpart(G,F), not holds(F,0).\n"; // % Check static laws in the initial state b << ":- caused(F,G,\"true\",\"true\"), holds(G,0), not holds(F,0).\n"; // % Get nicer output c << "hol(F,0) :- fluent(F), holds(F,0).\n"; // #cumulative t. // % Artificial fluent "true" holds in every state c << "holds(\"true\","+T+").\n"; // % Artificial action "true" is executed in every step c << "occurs(\"true\","+T+"-1).\n"; if(lang != "m") { // % Guess atomic actions to apply c << "1 { occurs(A,"+T+"-1), occurs(neg(A),"+T+"-1) } 1 :- action(A).\n"; } // % Propagate composite fluents c << "holds(G,"+T+") :- cfluent(G), holds(F,"+T+") : fpart(G,F).\n"; c << "holds(neg(G),"+T+") :- fpart(G,F), not holds(F,"+T+").\n"; // % Propagate composite actions c << "occurs(A,"+T+"-1) :- caction(A), occurs(B,"+T+"-1) : apart(A,B).\n"; c << "occurs(neg(A),"+T+"-1) :- caction(A), apart(A,B), not occurs(B,"+T+"-1).\n"; // % Apply the causal rule that fire c << "holds(F,"+T+") :- caused(F,G,P,A), occurs(A,"+T+"-1), holds(P,"+T+"-1), not { holds(G,"+T+") } 0.\n"; // % Check static laws in every state c << ":- caused(F,G,\"true\",\"true\"), holds(G,"+T+"), not holds(F,"+T+").\n"; // % Successor state must be total and consistent c << ":- holds(F,"+T+"), holds(neg(F),"+T+").\n"; c << ":- fluent(F), not holds(F,"+T+"), not holds(neg(F),"+T+").\n"; // % Get nicer output c << "occ(A,"+T+"-1) :- action(A), occurs(A,"+T+"-1).\n"; c << "hol(F,"+T+ ") :- fluent(F), holds(F,"+T +").\n"; // hide everything except actions and fluents if(debug < 3) b << "#hide.\n"; b << "#show occ(X1,T).\n"; if(debug > 0) b << "#show hol(X1,T).\n"; } void Printer::printBackwardsEncoding() { b << "\n%\n% Backwards Encoding of Action Language C\n%\n"; // #base. // % Artificial fluent "true" holds in goal state b << "holds(\"true\",0).\n"; // % Guess goal state b << "1 { holds(F,0), holds(neg(F),0) } 1 :- fluent(F).\n"; // % Propagate composite fluents b << "holds(G,0) :- cfluent(G), holds(F,0) : fpart(G,F).\n"; b << "holds(neg(G),0) :- fpart(G,F), not holds(F,0).\n"; // % shortcut for laws b << "static(F,G) :- caused(F,G,\"true\",\"true\").\n"; b << "dynamic(F,G,P,A) :- caused(F,G,P,A), not static(F,G).\n"; // % Check static laws b << ":- static(F,G), holds(G,0), not holds(F,0).\n"; // #cumulative t. // % Artificial action "true" is applied in every step c << "occurs(\"true\",-"+T+").\n"; if(lang != "m") { // % Guess atomic actions to apply c << "1 { occurs(A,-"+T+"), occurs(neg(A),-"+T+") } 1 :- action(A).\n"; } // % Propagate composite actions c << "occurs(A,-"+T+") :- caction(A), occurs(B,-"+T+") : apart(A,B).\n"; c << "occurs(neg(A),-"+T+") :- caction(A), apart(A,B), not occurs(B,-"+T+").\n"; // % Guess predecessor state c << "1 { holds(F,-"+T+"), holds(neg(F),-"+T+") } 1 :- fluent(F).\n"; // % Artificial fluent "true" holds in the predecessor state c << "holds(\"true\",-"+T+").\n"; // % Propagate composite fluents c << "holds(G,-"+T+") :- cfluent(G), holds(F,-"+T+") : fpart(G,F).\n"; c << "holds(neg(G),-"+T+") :- fpart(G,F), not holds(F,-"+T+").\n"; // % Check static laws c << ":- static(F,G), holds(G,-"+T+"), not holds(F,-"+T+").\n"; // % Determine dynamic laws that fire c << "fire(F,G,P,A,-"+T+") :- dynamic(F,G,P,A), occurs(A,-"+T+"), holds(P,-"+T+"), holds(G,-"+T+"+1).\n"; // % Effects of causal laws that fire must be consistent with successor state c << ":- fire(F,G,P,A,-"+T+"), not holds(F,-"+T+"+1).\n"; // % For every successor state literal, at least one causal rule must fire c << ":- fluent(F), holds( F ,-"+T+"+1), { fire( F ,G,P,A,-"+T+") : dynamic( F ,G,P,A), holds(H,-"+T+"+1) : static( F ,H) } 0.\n"; c << ":- fluent(F), holds(neg(F),-"+T+"+1), { fire(neg(F),G,P,A,-"+T+") : dynamic(neg(F),G,P,A), holds(H,-"+T+"+1) : static(neg(F),H) } 0.\n"; // % Get nicer output c << "occ(A,-"+T+") :- action(A), occurs(A,-"+T+").\n"; // hide everything except actions and fluents if(debug < 3) b << "#hide.\n"; b << "#show occ(X1,T).\n"; if(debug > 0) b << "#show holds(X1,T).\n"; } void Printer::printLTLAuxilliaries() { if(printed_ltl_aux_) return; // % el = loop_start // % le = loop_exists // % nl = after_loop_start // % il = in_loop // % guess which state is equivalent to the last c << "0 { loop_start(T-1) : time(T) } 1.\n"; if(debug > 2) c << "#show loop_start/1.\n"; // % a loop exists if there's a start c << "loop_exists :- loop_start(T-1).\n"; if(debug > 0) c << "#show loop_exists.\n"; // % predicate for first state after loop start c << "after_loop_start(T) :- loop_start(T-1).\n"; if(debug > 2) c << "#show after_loop_start/1.\n"; // % states which are in the loop c << "in_loop(T) :- loop_start(T-1).\n"; c << "in_loop(T) :- in_loop(T-1).\n"; if(debug > 2) c << "#show in_loop/1.\n"; // % idling only at the beginning v << ":- idle(T), not idle(T-1).\n"; // % disallow loop by idling v << ":- loop_exists, idle(t-1).\n"; // % compute only counter examples v << ":- not ltl_counter_example.\n"; v << "#show ltl_counter_example.\n"; if(no_direct_enc) { // % define idling in a lparse compatible way c << "idle(F,T-1) :- holds(F,T-1), holds(F,T), fluent(F).\n"; c << "idle(F,T-1) :- holds(neg(F),T-1), holds(neg(F),T), fluent(F).\n"; c << "idle(T-1) :- idle(F,T-1) : fluent(F).\n"; // % check that loop guess was correct v << ":- loop_start(T-1), holds(F,T-1), holds(neg(F),t).\n"; v << ":- loop_start(T-1), holds(F,t), holds(neg(F),T-1).\n"; } printed_ltl_aux_ = true; } void Printer::printIncLTLAuxilliaries() { if(printed_ltl_aux_) return; // % el = loop_start // % le = loop_exists // % nl = after_loop_start // % il = in_loop c << "time(t).\n"; // % guess which state is equivalent to the last // % incremental version of 0 { loop_start(T-1) : time(T) } 1. c << "0 { loop_start(t-1) } 1 :- not in_loop(t-1).\n"; if(debug > 2) c << "#show loop_start/1.\n"; // % states which are in the loop c << "in_loop(t) :- loop_start(t-1).\n"; c << "in_loop(t) :- in_loop(t-1).\n"; if(debug > 2) c << "#show in_loop/1.\n"; // % a loop exists if there's a start c << "loop_exists(t-1) :- loop_start(t-1).\n"; c << "loop_exists(t-1) :- loop_exists(t-2).\n"; if(debug > 0) c << "#show loop_exists/1.\n"; // % predicate for first state after loop start c << "after_loop_start(t) :- loop_start(t-1).\n"; if(debug > 2) c << "#show after_loop_start/1.\n"; // % once there is a counter example there will be always one c << "ltl_counter_example(t) :- ltl_counter_example(t-1).\n"; // % compute only counter examples v << ":- not ltl_counter_example(t).\n"; v << "#show ltl_counter_example/1.\n"; // % idling only at the beginning v << ":- idle(t), not idle(t-1).\n"; // % disallow loop by idling v << ":- loop_exists(t), idle(t-1).\n"; if(no_direct_enc) { // % idling if no fluents changed c << "idle(F,t-1) :- holds(F,t-1), holds(F,t), fluent(F).\n"; c << "idle(F,t-1) :- holds(neg(F),t-1), holds(neg(F),t), fluent(F).\n"; c << "idle(t-1) :- idle(F,t-1) : fluent(F).\n"; // % check that loop guess was correct v << ":- loop_start(T-1), holds(F,T-1), holds(neg(F),t), time(T).\n"; v << ":- loop_start(T-1), holds(F,t), holds(neg(F),T-1), time(T).\n"; } printed_ltl_aux_ = true; } coala-1.0.1_src/src/lib/c/StaticRule.h000644 001750 001750 00000003054 11477164507 020210 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/c/StaticRule.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef STATICRULE_H #define STATICRULE_H #include "Statement.h" #include "Formula.h" #include "Printer.h" #include #include namespace C { class StaticRule : virtual public Statement { public: StaticRule(int line, Formula* F, Formula* G, Types* types=NULL); virtual ~StaticRule ( ); void print(Printer* p); virtual void printDirect(Printer* p); virtual void printNonDirect(Printer* p); protected: Formula* F_; Formula* G_; }; }; // end of package namespace #endif // STATICRULE_H coala-1.0.1_src/src/lib/b/FluentDefinition.h000644 001750 001750 00000002773 11477164507 021405 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/FluentDefinition.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef BFLUENTDEFINITION_H #define BFLUENTDEFINITION_H #include "../c/FluentDefinition.h" #include namespace B { using namespace C; class FluentDefinition : public C::FluentDefinition { public: FluentDefinition(int line, Formula* fluent_list, bool defined=false, Types* types=NULL); virtual ~FluentDefinition ( ); void print(Printer*, bool); private: bool defined_; }; }; // end of package namespace #endif // BFLUENTDEFINITION_H coala-1.0.1_src/src/lib/b/Scanner.cpp000644 001750 001750 00000154645 11477164507 020071 0ustar00tovok7tovok7000000 000000 #line 2 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.cpp" #line 4 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.cpp" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* The c++ scanner is a mess. The FlexLexer.h header file relies on the * following macro. This is required in order to pass the c++-multiple-scanners * test in the regression suite. We get reports that it breaks inheritance. * We will address this in a future release of flex, or omit the C++ scanner * altogether. */ #define yyFlexLexer bFlexLexer /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* begin standard C++ headers. */ #include #include #include #include #include /* end standard C++ headers. */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. * Ditto for the __ia64__ case accordingly. */ #define YY_BUF_SIZE 32768 #else #define YY_BUF_SIZE 16384 #endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif extern int yyleng; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ int yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { std::istream* yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] void *balloc (yy_size_t ); void *brealloc (void *,yy_size_t ); void bfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; #define yytext_ptr yytext #define YY_INTERACTIVE #include int yyFlexLexer::yywrap() { return 1; } /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 55 #define YY_END_OF_BUFFER 56 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[174] = { 0, 0, 0, 0, 0, 56, 54, 1, 1, 49, 54, 46, 34, 35, 44, 42, 29, 43, 33, 45, 27, 31, 30, 38, 54, 39, 47, 28, 28, 48, 25, 25, 25, 50, 4, 5, 7, 6, 3, 1, 37, 0, 53, 51, 26, 32, 27, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 41, 28, 28, 25, 25, 25, 26, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 24, 8, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 21, 9, 12, 13, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 17, 18, 0, 15, 16, 0, 0, 0, 11, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 1, 6, 7, 1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 18, 19, 20, 21, 22, 1, 23, 23, 23, 23, 23, 24, 25, 23, 23, 23, 23, 26, 23, 23, 23, 23, 23, 27, 23, 28, 29, 23, 23, 30, 23, 23, 1, 1, 1, 31, 32, 1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 42, 48, 49, 50, 51, 42, 52, 53, 54, 42, 1, 55, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[56] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1 } ; static yyconst flex_int16_t yy_base[179] = { 0, 0, 0, 32, 39, 217, 218, 68, 71, 196, 212, 218, 218, 218, 218, 218, 218, 193, 199, 218, 196, 218, 218, 63, 191, 190, 218, 0, 181, 218, 0, 162, 161, 218, 0, 0, 0, 0, 0, 75, 218, 203, 218, 218, 0, 218, 189, 183, 218, 168, 169, 164, 147, 47, 153, 152, 43, 162, 148, 155, 218, 218, 0, 168, 0, 157, 142, 0, 218, 141, 139, 151, 151, 144, 135, 152, 141, 162, 135, 140, 145, 128, 141, 160, 0, 0, 135, 126, 133, 138, 123, 134, 127, 133, 218, 122, 117, 115, 128, 116, 218, 117, 125, 116, 109, 122, 113, 136, 107, 106, 113, 105, 131, 114, 105, 46, 112, 98, 126, 96, 218, 141, 95, 110, 93, 218, 120, 119, 118, 117, 101, 103, 218, 114, 101, 92, 89, 127, 218, 218, 218, 218, 125, 92, 218, 73, 80, 69, 78, 72, 65, 86, 63, 51, 47, 51, 56, 218, 55, 70, 68, 35, 64, 63, 218, 218, 30, 218, 218, 20, 10, 37, 218, 218, 115, 117, 120, 123, 126 } ; static yyconst flex_int16_t yy_def[179] = { 0, 173, 1, 1, 1, 173, 173, 173, 173, 173, 174, 173, 173, 173, 173, 173, 173, 175, 173, 173, 173, 173, 173, 173, 173, 173, 173, 176, 176, 173, 177, 177, 177, 173, 176, 176, 176, 176, 176, 173, 173, 174, 173, 173, 178, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 176, 176, 177, 177, 177, 178, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 176, 177, 177, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 0, 173, 173, 173, 173, 173 } ; static yyconst flex_int16_t yy_nxt[274] = { 0, 6, 7, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 27, 28, 27, 27, 27, 27, 29, 6, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 35, 172, 36, 171, 37, 38, 34, 35, 170, 36, 169, 37, 38, 39, 39, 39, 39, 39, 39, 47, 39, 39, 39, 73, 77, 128, 48, 168, 167, 166, 78, 79, 165, 74, 164, 163, 162, 161, 129, 49, 160, 50, 51, 52, 53, 54, 55, 56, 159, 158, 157, 156, 57, 155, 154, 153, 58, 152, 59, 41, 41, 41, 41, 44, 44, 62, 151, 62, 64, 150, 64, 67, 149, 67, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 76, 75, 72, 71, 70, 69, 68, 46, 42, 66, 65, 63, 61, 60, 46, 45, 43, 42, 40, 173, 5, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173 } ; static yyconst flex_int16_t yy_chk[274] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 171, 3, 170, 3, 3, 4, 4, 169, 4, 166, 4, 4, 7, 7, 7, 8, 8, 8, 23, 39, 39, 39, 53, 56, 115, 23, 163, 162, 161, 56, 56, 160, 53, 159, 158, 156, 155, 115, 23, 154, 23, 23, 23, 23, 23, 23, 23, 153, 152, 151, 150, 23, 149, 148, 147, 23, 146, 23, 174, 174, 174, 174, 175, 175, 176, 145, 176, 177, 143, 177, 178, 142, 178, 137, 136, 135, 134, 133, 131, 130, 129, 128, 127, 126, 124, 123, 122, 121, 119, 118, 117, 116, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 99, 98, 97, 96, 95, 93, 92, 91, 90, 89, 88, 87, 86, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 66, 65, 63, 59, 58, 57, 55, 54, 52, 51, 50, 49, 47, 46, 41, 32, 31, 28, 25, 24, 20, 18, 17, 10, 9, 5, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[56] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #line 1 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" /**************************************************************************** * lib/b/Scanner.l - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #line 21 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" #include #include "Parser.h" #line 576 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.cpp" #define INITIAL 0 #define ltl 1 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ #define YY_READ_BUF_SIZE 16384 #else #define YY_READ_BUF_SIZE 8192 #endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO #define ECHO LexerOutput( yytext, yyleng ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ \ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) LexerError( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 #define YY_DECL int yyFlexLexer::yylex() #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 52 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" #line 684 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.cpp" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = & std::cin; if ( ! yyout ) yyout = & std::cout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 174 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 218 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) yylineno++; ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: /* rule 1 can match eol */ YY_RULE_SETUP #line 53 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" // ignore white space. YY_BREAK case 2: YY_RULE_SETUP #line 54 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { BEGIN(ltl); return BParser::LTL; } YY_BREAK case 3: YY_RULE_SETUP #line 55 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::X; } YY_BREAK case 4: YY_RULE_SETUP #line 56 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::F; } YY_BREAK case 5: YY_RULE_SETUP #line 57 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::G; } YY_BREAK case 6: YY_RULE_SETUP #line 58 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::U; } YY_BREAK case 7: YY_RULE_SETUP #line 59 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::R; } YY_BREAK case 8: YY_RULE_SETUP #line 60 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::NOT; } YY_BREAK case 9: YY_RULE_SETUP #line 61 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::ACT; } YY_BREAK case 10: YY_RULE_SETUP #line 62 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::FLU; } YY_BREAK case 11: YY_RULE_SETUP #line 63 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::DFLU; } YY_BREAK case 12: YY_RULE_SETUP #line 64 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::CAUS; } YY_BREAK case 13: YY_RULE_SETUP #line 65 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::CAUSES; } YY_BREAK case 14: YY_RULE_SETUP #line 66 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::IF; } YY_BREAK case 15: YY_RULE_SETUP #line 67 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::EXE; } YY_BREAK case 16: YY_RULE_SETUP #line 68 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::NONEXE; } YY_BREAK case 17: YY_RULE_SETUP #line 69 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::INIT; } YY_BREAK case 18: YY_RULE_SETUP #line 70 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::OC_AT; } YY_BREAK case 19: YY_RULE_SETUP #line 71 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::HO_AT; } YY_BREAK case 20: YY_RULE_SETUP #line 72 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::GOAL; } YY_BREAK case 21: YY_RULE_SETUP #line 73 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::WHERE; } YY_BREAK case 22: YY_RULE_SETUP #line 74 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::TRUE; } YY_BREAK case 23: YY_RULE_SETUP #line 75 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::FALSE; } YY_BREAK case 24: YY_RULE_SETUP #line 76 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::MOD; } YY_BREAK case 25: YY_RULE_SETUP #line 77 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::IDENTIFIER; } YY_BREAK case 26: YY_RULE_SETUP #line 78 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::NEG_IDENTI; } YY_BREAK case 27: YY_RULE_SETUP #line 79 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::NUMBER; } YY_BREAK case 28: YY_RULE_SETUP #line 80 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::VARIABLE; } YY_BREAK case 29: YY_RULE_SETUP #line 81 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::COMMA; } YY_BREAK case 30: YY_RULE_SETUP #line 82 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::SEMIC; } YY_BREAK case 31: YY_RULE_SETUP #line 83 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::COLON; } YY_BREAK case 32: YY_RULE_SETUP #line 84 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::DDOT; } YY_BREAK case 33: YY_RULE_SETUP #line 85 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { BEGIN(0); return BParser::DOT; } YY_BREAK case 34: YY_RULE_SETUP #line 86 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::LBRAC; } YY_BREAK case 35: YY_RULE_SETUP #line 87 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::RBRAC; } YY_BREAK case 36: YY_RULE_SETUP #line 88 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::EQ; } YY_BREAK case 37: YY_RULE_SETUP #line 89 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::NEQ; } YY_BREAK case 38: YY_RULE_SETUP #line 90 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::LT; } YY_BREAK case 39: YY_RULE_SETUP #line 91 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::GT; } YY_BREAK case 40: YY_RULE_SETUP #line 92 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::LE; } YY_BREAK case 41: YY_RULE_SETUP #line 93 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::GE; } YY_BREAK case 42: YY_RULE_SETUP #line 94 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::PLUS; } YY_BREAK case 43: YY_RULE_SETUP #line 95 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::MINUS; } YY_BREAK case 44: YY_RULE_SETUP #line 96 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::TIMES; } YY_BREAK case 45: YY_RULE_SETUP #line 97 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::DIV; } YY_BREAK case 46: YY_RULE_SETUP #line 98 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::AND; } YY_BREAK case 47: YY_RULE_SETUP #line 99 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::OR; } YY_BREAK case 48: YY_RULE_SETUP #line 100 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::XOR; } YY_BREAK case 49: YY_RULE_SETUP #line 101 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::LTLNOT; } YY_BREAK case 50: YY_RULE_SETUP #line 102 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::LTLOR; } YY_BREAK case 51: YY_RULE_SETUP #line 103 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::IMPL; } YY_BREAK case 52: YY_RULE_SETUP #line 104 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { return BParser::EQUIV; } YY_BREAK case 53: /* rule 53 can match eol */ YY_RULE_SETUP #line 105 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { /* comment */ } YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(ltl): #line 106 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { yyterminate(); } YY_BREAK case 54: YY_RULE_SETUP #line 107 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" { cerr << "\n\nError: Unknown keyword '"+string(yytext)+"' found at line "<yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) { yyin = arg_yyin; yyout = arg_yyout; yy_c_buf_p = 0; yy_init = 0; yy_start = 0; yy_flex_debug = 0; yylineno = 1; // this will only get updated if %option yylineno yy_did_buffer_switch_on_eof = 0; yy_looking_for_trail_begin = 0; yy_more_flag = 0; yy_more_len = 0; yy_more_offset = yy_prev_more_offset = 0; yy_start_stack_ptr = yy_start_stack_depth = 0; yy_start_stack = NULL; yy_buffer_stack = 0; yy_buffer_stack_top = 0; yy_buffer_stack_max = 0; yy_state_buf = 0; } /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::~yyFlexLexer() { delete [] yy_state_buf; bfree(yy_start_stack ); yy_delete_buffer( YY_CURRENT_BUFFER ); bfree(yy_buffer_stack ); } /* The contents of this function are C++ specific, so the () macro is not used. */ void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) { if ( new_in ) { yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); } if ( new_out ) yyout = new_out; } #ifdef YY_INTERACTIVE int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) #else int yyFlexLexer::LexerInput( char* buf, int max_size ) #endif { if ( yyin->eof() || yyin->fail() ) return 0; #ifdef YY_INTERACTIVE yyin->get( buf[0] ); if ( yyin->eof() ) return 0; if ( yyin->bad() ) return -1; return 1; #else (void) yyin->read( buf, max_size ); if ( yyin->bad() ) return -1; else return yyin->gcount(); #endif } void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout->write( buf, size ); } /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ int yyFlexLexer::yy_get_next_buffer() { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ brealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) brealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ yy_state_type yyFlexLexer::yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 174 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) { register int yy_is_jam; register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 174 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 173); return yy_is_jam ? 0 : yy_current_state; } void yyFlexLexer::yyunput( int c, register char* yy_bp) { register char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = (yy_n_chars) + 2; register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; if ( c == '\n' ){ --yylineno; } (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } int yyFlexLexer::yyinput() { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); if ( c == '\n' ) yylineno++; ; return c; } /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyFlexLexer::yyrestart( std::istream* input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_init_buffer( YY_CURRENT_BUFFER, input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } void yyFlexLexer::yy_load_buffer_state() { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) balloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) balloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) bfree((void *) b->yy_ch_buf ); bfree((void *) b ); } extern "C" int isatty (int ); /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) { int oerrno = errno; yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yyFlexLexer::yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ void yyFlexLexer::yyensure_buffer_stack(void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)balloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)brealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } void yyFlexLexer::yy_push_state( int new_state ) { if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) { yy_size_t new_size; (yy_start_stack_depth) += YY_START_STACK_INCR; new_size = (yy_start_stack_depth) * sizeof( int ); if ( ! (yy_start_stack) ) (yy_start_stack) = (int *) balloc(new_size ); else (yy_start_stack) = (int *) brealloc((void *) (yy_start_stack),new_size ); if ( ! (yy_start_stack) ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; BEGIN(new_state); } void yyFlexLexer::yy_pop_state() { if ( --(yy_start_stack_ptr) < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); } int yyFlexLexer::yy_top_state() { return (yy_start_stack)[(yy_start_stack_ptr) - 1]; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif void yyFlexLexer::LexerError( yyconst char msg[] ) { std::cerr << msg << std::endl; exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *balloc (yy_size_t size ) { return (void *) malloc( size ); } void *brealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void bfree (void * ptr ) { free( (char *) ptr ); /* see brealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 110 "/home/tovok7/svn/potassco/coala/src/lib/b/Scanner.l" coala-1.0.1_src/src/lib/b/Program.cpp000644 001750 001750 00000010256 11477164507 020074 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Program.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Program.h" #include "Parser.h" using namespace B; B::Program::Program(Coala::CompilerOptions* options) : C::Program(options) { } B::Program::~Program() { } void B::Program::addFluentDef(Formula* fluent_list, bool defined, Types* types) { FluentAction* f; for(vector::iterator fluent = fluent_list->begin(); fluent != fluent_list->end(); fluent++) { if((*fluent)->getType() == 'n') { cerr << "Warning: fluent '" << f->getName() << "' can not be defined negatively at line " << *line_ << ".\n"; f = (*fluent)->getFluentAction(); *fluent = f; } else f = (FluentAction*) *fluent; f->setClass("Fluent"); if(!addFluent(f)) cerr << "Warning: fluent '" << f->getName() << "' defined multiple times at line " << *line_ << ".\n"; } fluent_definitions_.push_back(new B::FluentDefinition(*line_, fluent_list, defined, types)); } void B::Program::addStaticRule(C::Formula* F, C::Formula* G, C::Types* types) { transformFormula(F, "Fluent"); transformFormula(G, "Fluent"); static_rules_.push_back(new B::StaticRule(*line_, F, G, types)); } void B::Program::addDynamicRule(Formula* A, Formula* F, Formula* G, Types* types) { transformFormula(A, "Action"); transformFormula(F, "Fluent"); transformFormula(G, "Fluent"); dynamic_rules_.push_back(new B::DynamicRule(*line_, F, G, A, types)); } void B::Program::addNonexecutableRule(Formula* A, Formula* G, Types* types) { Formula* F = addFormula('c', new Formula('n', new FluentAction(new string("0")))); addDynamicRule(A, F, G, types); } void B::Program::addExecutableRule(Formula* A, Formula* F, Types* types) { executable_rules_.push_back(new ExecutableRule(*line_, A, F, types)); } void B::Program::addInitiallyRule(Formula* F, Types* types) { addQQuery("holds", F, "0", types); } void B::Program::addQQuery(string type, Formula* A, string time, Types* types) { transformFormula(A, "Action"); qqueries_.push_back(new B::QQuery(*line_, type, A, &time, types)); } void B::Program::print(Printer* p) { //p->add("\n%\n% Fluents\n%\n"); for(vector::iterator n = fluent_definitions_.begin(); n != fluent_definitions_.end(); ++n) { (*n)->print(p, ltlquery_); delete *n; } p->setSection('c'); p->add("\n%\n% Actions\n%\n"); for(vector::iterator n = action_definitions_.begin(); n != action_definitions_.end(); ++n) { (*n)->print(p); } p->setSection('c'); p->add("\n%\n% Static Rules\n%\n"); for(vector::iterator n = static_rules_.begin(); n != static_rules_.end(); ++n) { (*n)->print(p); } p->add("\n%\n% Dynamic Rules\n%\n"); for(vector::iterator n = dynamic_rules_.begin(); n != dynamic_rules_.end(); ++n) { (*n)->print(p); } p->add("\n%\n% Executable Rules\n%\n"); for(vector::iterator n = executable_rules_.begin(); n != executable_rules_.end(); ++n) { (*n)->print(p); } p->setSection('v'); p->add("\n%\n% Initially Rules\n%\n"); for(vector::iterator n = qqueries_.begin(); n != qqueries_.end(); ++n) { (*n)->print(p); } p->add("\n%\n% LTL Queries\n%\n"); if(ltlquery_) { ltlquery_->print(p, &fluents_); p->add("\n"); } p->print(); } coala-1.0.1_src/src/lib/b/Parser.y000644 001750 001750 00000034160 11477164507 017407 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Parser.y - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ %name BParser %define LSP_NEEDED %define ERROR_BODY = 0 %define LEX_BODY = 0 %define MEMBERS void preProcessing(Coala::CompilerOptions*); void postProcessing(Printer*); virtual ~BParser(){}\ private: std::string to_string(int integer);\ public: B::Program* program; %header{ #include #include #include #include #include #include "../options.h" #include "Program.h" using namespace std; using namespace C; %} %union { int number; string* str; Formula* form; Type* typ; Types* types; Arguments* args; Constraint* constr; Pool* var_pool; Interval* interval; LTLNode* ltl_node; } %token IDENTIFIER %token NEG_IDENTI %token VARIABLE %token NUMBER %token NOT // not %token ACT // %token FLU // %token DFLU // %token CAUS // %token CAUSES // %token IF // %token EXE // %token NONEXE // %token INIT // %token OC_AT // %token HO_AT // %token GOAL // %token WHERE // %token TRUE // %token FALSE // %token DEF // %token INERT // %token COMMA // , %token SEMIC // ; %token COLON // : %token DOT // . %token DDOT // .. %token LBRAC // ( %token RBRAC // ) %token EQ // == %token NEQ // != %token LT // < %token GT // > %token LE // <= %token GE // >= %token PLUS // + %token MINUS // - %token TIMES // * %token DIV // / %token MOD // mod %token AND // & %token OR // ? %token XOR // ^ %token LTL // LTL: %token LTLNOT // ! %token LTLOR // | %token IMPL // -> %token EQUIV // <-> %token X // X %token F // F %token G // G %token U // U %token R // R // LTL Operator Precedence %left EQUIV IMPL LTLOR AND %left U R %nonassoc G F X %nonassoc LTLNOT %type formula %type types_list %type type %type term_list %type identifier %type constraint %type pool %type interval %type operation %type operator %type eqoperator %type ltl_expr %start program %% /***************************************************************************************************************************/ program: /* empty */ | program rule DOT; rule: fact | law | query; fact: act_fact | flu_fact | dflu_fact; law: static_rule | static_caused_rule | dyn_rule | exe_rule | nonexe_rule; query: init_rule | oc_query | ho_query | goal_query | ltl_query; // a_1,...,a_n bla. act_fact: ACT formula { program->addActionDef($2); } | ACT formula WHERE types_list { program->addActionDef($2, $4); } // f_1,...,f_n bla. flu_fact: FLU formula { program->addFluentDef($2); } | FLU formula WHERE types_list { program->addFluentDef($2, false, $4); } // f_1,...,f_n bla. dflu_fact: DFLU formula { program->addFluentDef($2, true); } | DFLU formula WHERE types_list { program->addFluentDef($2, true, $4); } // f_1,...,f_n g_1,...,g_m bla. static_rule: formula { program->addStaticRule($1, NULL); } | formula WHERE types_list { program->addStaticRule($1, NULL, $3); } | formula IF formula { program->addStaticRule($1, $3); } | formula IF formula WHERE types_list { program->addStaticRule($1, $3, $5); } // f_1,...,f_n g_1,...,g_m bla. static_caused_rule: CAUS formula { program->addStaticRule($2, NULL); } | CAUS formula WHERE types_list { program->addStaticRule($2, NULL, $4); } | CAUS formula IF formula { program->addStaticRule($2, $4); } | CAUS formula IF formula WHERE types_list { program->addStaticRule($2, $4, $6); } // a f_1,...,f_n g_1,...,g_m bla. dyn_rule: formula CAUSES formula { program->addDynamicRule($1, $3); } | formula CAUSES formula WHERE types_list { program->addDynamicRule($1, $3, NULL, $5); } | formula CAUSES formula IF formula { program->addDynamicRule($1, $3, $5); } | formula CAUSES formula IF formula WHERE types_list { program->addDynamicRule($1, $3, $5, $7); } // a_1,...,a_n g_1,...,g_m bla. exe_rule: EXE formula { program->addExecutableRule($2, NULL); } | EXE formula WHERE types_list { program->addExecutableRule($2, NULL, $4); } | EXE formula IF formula { program->addExecutableRule($2, $4); } | EXE formula IF formula WHERE types_list { program->addExecutableRule($2, $4, $6); } // a_1,..., a_n f_1,..., f_m bla. = a_1,...,a_n,f_1,...,f_m bla. nonexe_rule: NONEXE formula { program->addNonexecutableRule($2, NULL); } | NONEXE formula WHERE types_list { program->addNonexecutableRule($2, NULL, $4); } | NONEXE formula IF formula { program->addNonexecutableRule($2, $4); } | NONEXE formula IF formula WHERE types_list { program->addNonexecutableRule($2, $4, $6); } // f_1,..., f_n bla. = f_1,...,f_n 0 bla. init_rule: INIT formula { program->addInitiallyRule($2); } | INIT formula WHERE types_list { program->addInitiallyRule($2, $4); } // a_1,...,a_n t_i bla. oc_query: formula OC_AT NUMBER { program->addQQuery("occ", $1, to_string($3)); } | formula OC_AT IDENTIFIER { program->addQQuery("occ", $1, *$3); } | formula OC_AT NUMBER WHERE types_list { program->addQQuery("occ", $1, to_string($3), $5); } | formula OC_AT IDENTIFIER WHERE types_list { program->addQQuery("occ", $1, *$3, $5); } // f_1,...,f_n t_i bla. ho_query: formula HO_AT NUMBER { program->addQQuery("holds", $1, to_string($3)); } | formula HO_AT IDENTIFIER { program->addQQuery("holds", $1, *$3); } | formula HO_AT NUMBER WHERE types_list { program->addQQuery("holds", $1, to_string($3), $5); } | formula HO_AT IDENTIFIER WHERE types_list { program->addQQuery("holds", $1, *$3, $5); } // f_1,...,f_n bla. goal_query: GOAL formula { program->addQQuery("holds", $2, "t"); } | GOAL formula WHERE types_list { program->addQQuery("holds", $2, "t", $4); } // f_1,...,f_n formula: identifier { $$ = program->addFormula('c', $1); } | TRUE { $$ = program->addFormula('c', new FluentAction(new string("0"))); } | FALSE { $$ = program->addFormula('c', new Formula('n', new FluentAction(new string("0")))); } | formula COMMA identifier { $1->addPart($3); $$ = $1; } identifier: IDENTIFIER { $$ = new FluentAction($1); } | IDENTIFIER LBRAC term_list RBRAC { $$ = new FluentAction($1, $3); } | NEG_IDENTI { $$ = new Formula('n', new FluentAction($1)); } | NEG_IDENTI LBRAC term_list RBRAC { $$ = new Formula('n', new FluentAction($1, $3)); } // X, a, 3, X;Y, 1..Z term_list: VARIABLE { $$ = new Arguments(program->addVariable($1)); } | IDENTIFIER { $$ = new Arguments(new Constant($1)); } | NUMBER { $$ = new Arguments(new Constant($1)); } | pool { $$ = new Arguments($1); } | interval { $$ = new Arguments($1); } | IDENTIFIER LBRAC term_list RBRAC { $$ = new Arguments(new Function($1, $3->getArgs())); } | term_list COMMA VARIABLE { $1->addVariable(program->addVariable($3)); $$ = $1; } | term_list COMMA IDENTIFIER { $1->addConstant(new Constant($3)); $$ = $1; } | term_list COMMA NUMBER { $1->addConstant(new Constant($3)); $$ = $1; } | term_list COMMA pool { $1->addPool($3); $$ = $1; } | term_list COMMA interval { $1->addInterval($3); $$ = $1; } | term_list COMMA IDENTIFIER LBRAC term_list RBRAC { $1->addFunction(new Function($3, $5->getArgs())); $$ = $1; } // X;Y pool: VARIABLE SEMIC VARIABLE { $$ = new Pool(program->addVariable($1), program->addVariable($3)); } | pool SEMIC VARIABLE { $1->addVariable(program->addVariable($3)); $$ = $1; } // 1..X interval: NUMBER DDOT NUMBER { $$ = new Interval(new Constant($1), new Constant($3)); } | NUMBER DDOT VARIABLE { $$ = new Interval(new Constant($1), program->addVariable($3)); } | VARIABLE DDOT NUMBER { $$ = new Interval(program->addVariable($1), new Constant($3)); } | VARIABLE DDOT VARIABLE { $$ = new Interval(program->addVariable($1), program->addVariable($3)); } // type_1(X),...,type_n(Y), X!=Y types_list: constraint { $$ = new Types($1); } | type { $$ = new Types($1); } | NUMBER COLON type { $3->setMin($1); $$ = new Types($3); } | type COLON NUMBER { $1->setMax($3); $$ = new Types($1); } | NUMBER COLON type COLON NUMBER { $3->setMin($1); $3->setMax($5); $$ = new Types($3); } | types_list COMMA constraint { $1->addType($3); } | types_list COMMA type { $1->addType($3); } | types_list COMMA NUMBER COLON type { $5->setMin($3); $1->addType($5); } | types_list COMMA type COLON NUMBER { $3->setMax($5); $1->addType($3); } | types_list COMMA NUMBER COLON type COLON NUMBER { $5->setMin($3); $5->setMax($7); $1->addType($5); } // type_xyz(X,Y,Z) type: IDENTIFIER LBRAC term_list RBRAC { $$ = new Type($1, $3, true); } | NOT IDENTIFIER LBRAC term_list RBRAC { $$ = new Type($2, $4, false); } // X!=Y etc. constraint: operation eqoperator operation { $1->merge($3, $2); $$ = $1; } | NUMBER eqoperator operation { $3->mergeLeft(new string(to_string($1)+*$2), $2); $$ = $3; } | operation eqoperator NUMBER { $1->merge(new string(*$2+to_string($3)), $2); $$ = $1; } | IDENTIFIER eqoperator operation { $3->mergeLeft(new string(*$1+*$2), $2); $$ = $3; } | operation eqoperator IDENTIFIER { $1->merge(new string(*$2+*$3), $2); $$ = $1; } | VARIABLE eqoperator operation { $3->mergeLeft(new string(*$1+*$2), program->addVariable($1), $2); $$ = $3; } | operation eqoperator VARIABLE { $1->merge(new string(*$2+*$3), program->addVariable($3), $2); $$ = $1; } | VARIABLE eqoperator VARIABLE { $$ = new Constraint(program->addVariable($1), program->addVariable($3), new string(*$1+*$2+*$3), $2); } | NUMBER eqoperator VARIABLE { $$ = new Constraint(program->addVariable($3), new string(to_string($1)+*$2+*$3), $2); } | VARIABLE eqoperator NUMBER { $$ = new Constraint(program->addVariable($1), new string(*$1+*$2+to_string($3)), $2); } | IDENTIFIER eqoperator VARIABLE { $$ = new Constraint(program->addVariable($3), new string(*$1+*$2+*$3), $2); } | VARIABLE eqoperator IDENTIFIER { $$ = new Constraint(program->addVariable($1), new string(*$1+*$2+*$3), $2); } | NUMBER eqoperator IDENTIFIER { $$ = new Constraint(new string(to_string($1)+*$2+*$3), $2); } | IDENTIFIER eqoperator NUMBER { $$ = new Constraint(new string(*$1+*$2+to_string($3)), $2); } // X+1+Y operation: NUMBER operator VARIABLE { $$ = new Constraint(program->addVariable($3), new string(to_string($1)+*$2+*$3)); } | VARIABLE operator NUMBER { $$ = new Constraint(program->addVariable($1), new string(*$1+*$2+to_string($3))); } | VARIABLE operator VARIABLE { $$ = new Constraint(program->addVariable($1), program->addVariable($3), new string(*$1+*$2+*$3)); } | operation operator NUMBER { $1->merge(new string(*$2+to_string($3))); $$ = $1; } | operation operator VARIABLE { $1->merge(new string(*$2+*$3), program->addVariable($3)); $$ = $1; } eqoperator: EQ { $$ = new string("=="); } | NEQ { $$ = new string("!="); } | LT { $$ = new string("<"); } | GT { $$ = new string(">"); } | LE { $$ = new string("<="); } | GE { $$ = new string(">="); } operator: PLUS { $$ = new string("+"); } | MINUS { $$ = new string("-"); } | TIMES { $$ = new string("*"); } | DIV { $$ = new string("/"); } | MOD { $$ = new string(" mod "); } | AND { $$ = new string("&"); } | OR { $$ = new string("?"); } | XOR { $$ = new string("^"); } ltl_query: LTL ltl_expr { program->addLTLQuery($2); } ltl_expr: identifier { $$ = program->getLTLNode(IDENTIFIER, NULL, NULL, $1); } | LBRAC ltl_expr RBRAC { $$ = $2; } | LTLNOT ltl_expr { $$ = program->getLTLNode(LTLNOT, NULL, $2); } | ltl_expr AND ltl_expr { $$ = program->getLTLNode(AND, $1, $3); } | ltl_expr LTLOR ltl_expr { $$ = program->getLTLNode(LTLOR, $1, $3); } | ltl_expr IMPL ltl_expr { $$ = program->getLTLNode(IMPL, $1, $3); } | ltl_expr EQUIV ltl_expr { $$ = program->getLTLNode(EQUIV, $1, $3); } | X ltl_expr { $$ = program->getLTLNode(X, NULL, $2); } | G ltl_expr { $$ = program->getLTLNode(G, NULL, $2); } | F ltl_expr { $$ = program->getLTLNode(F, NULL, $2); } | ltl_expr U ltl_expr { $$ = program->getLTLNode(U, $1, $3); } | ltl_expr R ltl_expr { $$ = program->getLTLNode(R, $1, $3); } %% /***************************************************************************************************************************/ void BParser::preProcessing(Coala::CompilerOptions* options) { program = new B::Program(options); program->setLine(&yylloc.first_line); } void BParser::postProcessing(Printer* p) { program->print(p); // delete program; } std::string BParser::to_string(int integer) { std::stringstream ss; std::string str; ss << integer; ss >> str; return str; } coala-1.0.1_src/src/lib/b/StaticRule.cpp000644 001750 001750 00000006065 11477164507 020547 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/StaticRule.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "StaticRule.h" using namespace B; B::StaticRule::StaticRule(int line, Formula* F, Formula* G, Types* types) : Statement(line, types), C::StaticRule(line, F, G, types) { } B::StaticRule::~StaticRule ( ) { } void B::StaticRule::printDirect(Printer* p) { cerr << "% WARNING: No direct encoding for static rules yet\n"; } void B::StaticRule::printNonDirect(Printer* p) { string T; set* vars = new set(); // print the static rule twice: for T=0 and T>0 for(int i = 1; i <= 2; ++i) { if(i == 1) { p->setSection('b'); T = "0"; } else { p->setSection('c'); T = p->T; } FluentAction* f; string neg_f; FluentAction* g; string neg_g; // holds(f, T) :- holds(g, T). for(vector::iterator fluent_f = F_->begin(); fluent_f != F_->end(); ++fluent_f) { if(!(*fluent_f)->isFalse()) { // check for negation if((*fluent_f)->getType() == 'n') { f = (FluentAction*) (*fluent_f)->getFirstFormula(); neg_f = p->neg; } else { f = (FluentAction*) *fluent_f; neg_f = ""; } vars = f->getVariables(); p->add("holds(" + neg_f + f->print(p) + ", " + T + ") :- "); } else { p->add(":- "); } if(G_ && !G_->isTrue()) { for(vector::iterator fluent_g = G_->begin(); fluent_g != G_->end(); ++fluent_g) { // check for negation if((*fluent_g)->getType() == 'n') { g = (FluentAction*) (*fluent_g)->getFirstFormula(); neg_g = p->neg; } else { g = (FluentAction*) *fluent_g; neg_g = ""; } p->add("holds(" + neg_g + g->print(p) + ", " + T + ")"); if(fluent_g != G_->end()-1) p->add(", "); // get the vars set* tmp_vars = g->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } } if(!vars->empty()) { if(G_ && !G_->isTrue()) p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); // delete vars; } } // end of for loop for printing twice } coala-1.0.1_src/src/lib/b/Printer.h000644 001750 001750 00000003617 11477164507 017560 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Printer.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef bprinter_h #define bprinter_h #include "../c/Printer.h" #include #include #include #include using namespace std; namespace B { class Printer : public C::Printer { public: Printer(ostream *output_stream, int, bool, bool, bool, bool, bool, string); virtual ~Printer(); private: void printEncoding(); /* void add(string text); void addExtra(string text); void setSection(char); void print(); void printLTLAuxilliaries(); void printIncLTLAuxilliaries(); int debug; bool fake_neg; bool inc; bool rev; bool no_w_chk; bool no_direct_enc; string lang; string neg; string T; private: void printBackwardsEncoding(); char section_; ostream* o; stringstream b; stringstream c; stringstream v; stringstream extra; bool printed_ltl_aux_; */ }; }; // end of package namespace #endif // BPRINTER_H coala-1.0.1_src/src/lib/b/Compiler.h000644 001750 001750 00000003211 11477164507 017675 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Compiler.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef BCOMPILER_H #define BCOMPILER_H #undef yyFlexLexer #define yyFlexLexer bFlexLexer #include #include "../main.h" #include "../options.h" #include "Parser.h" #include "Printer.h" namespace B { class Compiler : public Coala::AbstractCompiler, public BParser { private: bFlexLexer lexer; Printer* printer_; Coala::CompilerOptions* options_; protected: ostream* output_stream_; public: Compiler(Coala::CompilerOptions*); virtual ~Compiler(); int compile(); int yylex(); void yyerror(char*); void change_input(std::istream*); }; }; #endif // BCOMPILER_H coala-1.0.1_src/src/lib/b/QQuery.cpp000644 001750 001750 00000004060 11477164507 017707 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/QQuery.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "QQuery.h" using namespace B; B::QQuery::QQuery(int line, string type, Formula* I, string* time, Types* types) : Statement(line, types), C::QQuery(line, type, I, time, types) { } B::QQuery::~QQuery ( ) { } void B::QQuery::print(Printer* p) { if(time_ == "0") p->setSection('b'); else p->setSection('v'); FluentAction* i; string neg; if(time_ != "0") { p->add(":- not goal(t).\n"); p->add("goal(t) :- "); } // :- not f1, ..., not f_n for(vector::iterator n = I_->begin(); n != I_->end(); ++n) { if((*n)->getType() == 'n') { i = (FluentAction*) (*n)->getFirstFormula(); neg = p->neg; } else { i = (FluentAction*) *n; neg = ""; } p->add(type_ + "(" + neg + i->print(p, time_) + ", " + time_ + ")"); if(time_ != "0" && n != I_->end()-1) p->add(", "); set* vars = i->getVariables(); if(!vars->empty()) { p->add(" :- "); types_.print(p, vars, line_); } if(time_ == "0") p->add(".\n"); delete vars; } if(time_ != "0") p->add(".\n"); } coala-1.0.1_src/src/lib/b/ExecutableRule.h000644 001750 001750 00000002754 11477164507 021047 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/ExecutableRule.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef EXECUTABLERULE_H #define EXECUTABLERULE_H #include "../c/Statement.h" #include #include namespace B { using namespace C; class ExecutableRule : virtual public C::Statement { public: ExecutableRule(int line, Formula* A, Formula* F, Types* types=NULL); virtual ~ExecutableRule ( ); void print(Printer* p); protected: Formula* A_; Formula* F_; }; }; // end of package namespace #endif // EXECUTABLERULE_H coala-1.0.1_src/src/lib/b/Scanner.l000644 001750 001750 00000006730 11477164507 017531 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Scanner.l - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ %{ #include #include "Parser.h" %} %option yylineno nounput noyywrap c++ prefix="b" %s ltl MOD mod IDENTIFIER [a-z][a-zA-Z0-9_]* NEG_IDENTI \-[a-z][a-zA-Z0-9_]* NUMBER [0-9]+ VARIABLE [A-Z][a-zA-Z0-9_]* COMMENT \%.*\n NOT not ACT FLU DFLU CAUS CAUSES IF EXE NONEXE INIT OC_AT HO_AT GOAL WHERE TRUE FALSE %% [\t\n ]+ // ignore white space. "LTL:" { BEGIN(ltl); return BParser::LTL; } "X" { return BParser::X; } "F" { return BParser::F; } "G" { return BParser::G; } "U" { return BParser::U; } "R" { return BParser::R; } {NOT} { return BParser::NOT; } {ACT} { return BParser::ACT; } {FLU} { return BParser::FLU; } {DFLU} { return BParser::DFLU; } {CAUS} { return BParser::CAUS; } {CAUSES} { return BParser::CAUSES; } {IF} { return BParser::IF; } {EXE} { return BParser::EXE; } {NONEXE} { return BParser::NONEXE; } {INIT} { return BParser::INIT; } {OC_AT} { return BParser::OC_AT; } {HO_AT} { return BParser::HO_AT; } {GOAL} { return BParser::GOAL; } {WHERE} { return BParser::WHERE; } {TRUE} { return BParser::TRUE; } {FALSE} { return BParser::FALSE; } {MOD} { return BParser::MOD; } {IDENTIFIER} { return BParser::IDENTIFIER; } {NEG_IDENTI} { return BParser::NEG_IDENTI; } {NUMBER} { return BParser::NUMBER; } {VARIABLE} { return BParser::VARIABLE; } "," { return BParser::COMMA; } ";" { return BParser::SEMIC; } ":" { return BParser::COLON; } ".." { return BParser::DDOT; } "." { BEGIN(0); return BParser::DOT; } "(" { return BParser::LBRAC; } ")" { return BParser::RBRAC; } "==" { return BParser::EQ; } "!=" { return BParser::NEQ; } "<" { return BParser::LT; } ">" { return BParser::GT; } "<=" { return BParser::LE; } ">=" { return BParser::GE; } "+" { return BParser::PLUS; } "-" { return BParser::MINUS; } "*" { return BParser::TIMES; } "/" { return BParser::DIV; } "&" { return BParser::AND; } "?" { return BParser::OR; } "^" { return BParser::XOR; } "!" { return BParser::LTLNOT; } "|" { return BParser::LTLOR; } "->" { return BParser::IMPL; } "<->" { return BParser::EQUIV; } {COMMENT} { /* comment */ } <> { yyterminate(); } . { cerr << "\n\nError: Unknown keyword '"+string(yytext)+"' found at line "< namespace B { using namespace C; class QQuery : public C::QQuery { public: QQuery(int line, string type, Formula* I, string* time, Types* types); virtual ~QQuery ( ); void print(Printer* p); }; }; // end of package namespace #endif // BQQUERY_H coala-1.0.1_src/src/lib/b/Program.h000644 001750 001750 00000006707 11477164507 017547 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Program.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef bprogram_h #define bprogram_h #include #include #include #include "../options.h" #include "../c/Program.h" #include "../c/Formula.h" #include "FluentDefinition.h" #include "StaticRule.h" #include "DynamicRule.h" #include "ExecutableRule.h" #include "QQuery.h" /* #include "ActionDefinition.h" #include "Query.h" #include "RQuery.h" #include "LTLQuery.h" #include "Printer.h" */ namespace B { using namespace C; class Program : public C::Program { public: Program(Coala::CompilerOptions*); virtual ~Program(); void print(Printer* p); /* void setLine(int* line); virtual Variable* addVariable(string*); virtual Formula* addFormula(char, Formula*); virtual Formula* addFormula(char, vector*); bool addAction(FluentAction* action); void addActionDef(Formula* action_list, Types* types=0); bool addFluent(FluentAction* fluent); */ void addFluentDef(Formula* fluent_list, bool defined=false, Types* types=NULL); void addStaticRule(Formula* F, Formula* G, Types* types=NULL); void addDynamicRule(Formula* A, Formula* F, Formula* G=NULL, Types* types=NULL); void addExecutableRule(Formula* A, Formula* F, Types* types=NULL); void addNonexecutableRule(Formula* A, Formula* G, Types* types=NULL); void addInitiallyRule(Formula* F, Types* types=NULL); void addQQuery(string type, Formula* A, string time, Types* types=NULL); /* void addInertialRule(Formula* F, Types* types=NULL); void addCausesRule(Formula* A, Formula* F, Formula* G, Types* types=NULL); void addAlwaysRule(Formula* G, Types* types=NULL); void addMayCauseRule(Formula* A, Formula* F, Formula* G, Types* types=NULL); void addRQuery(Formula* F, Formula* A, string time, Types* types=NULL); LTLNode* getLTLNode(int, LTLNode*, LTLNode*, Formula* content=NULL); void addLTLQuery(LTLNode*); */ protected: vector static_rules_; vector dynamic_rules_; vector executable_rules_; vector fluent_definitions_; vector qqueries_; /* void transformFormula(Formula* I, string type); int* line_; Coala::CompilerOptions* options_; int ltl_node_num_; Printer* p_; map actions_; map fluents_; map variables_; vector rqueries_; LTLQuery* ltlquery_; vector action_definitions_; */ }; }; // end of package namespace #endif // BPROGRAM_H coala-1.0.1_src/src/lib/b/DynamicRule.cpp000644 001750 001750 00000007066 11477164507 020706 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/DynamicRule.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "DynamicRule.h" using namespace B; B::DynamicRule::DynamicRule(int line, Formula* F, Formula* G, Formula* H, Types* types) : Statement(line, types), C::DynamicRule(line, F, G, H, types) { } B::DynamicRule::~DynamicRule () { delete H_; } void B::DynamicRule::print(Printer* p) { printNonDirect(p); } void B::DynamicRule::printNonDirect(Printer* p) { p->setSection('c'); FluentAction* f; FluentAction* a; FluentAction* g; string neg_f = p->neg; string neg_a = p->neg; string neg_g = p->neg; // holds(f, T) :- occ(a, T-1), possible(a, T-1), holds(g, T-1). for(vector::iterator fluent_f = F_->begin(); fluent_f != F_->end(); ++fluent_f) { set* vars; if(!(*fluent_f)->isFalse()) { // check for negation if((*fluent_f)->getType() == 'n') { f = (FluentAction*) (*fluent_f)->getFirstFormula(); neg_f = p->neg; } else { f = (FluentAction*) *fluent_f; neg_f = ""; } p->add("holds(" + neg_f + f->print(p) + ", " + p->T + ") :- "); vars = f->getVariables(); } else { vars = new set(); p->add(":- "); } // print A part for(vector::iterator action_a = H_->begin(); action_a != H_->end(); ++action_a) { // check for negation if((*action_a)->getType() == 'n') { a = (FluentAction*) (*action_a)->getFirstFormula(); neg_a = p->neg; } else { a = (FluentAction*) *action_a; neg_a = ""; } p->add("occ(" + neg_a + a->print(p) + ", " + p->T + "-1), "); p->add("possible(" + neg_a + a->print(p) + ", " + p->T + "-1)"); if(action_a != H_->end()-1) p->add(", "); // get the vars set* tmp_vars = a->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } // print G part if(G_ && !G_->isTrue()) { p->add(", "); for(vector::iterator fluent_g = G_->begin(); fluent_g != G_->end(); ++fluent_g) { // check for negation if((*fluent_g)->getType() == 'n') { g = (FluentAction*) (*fluent_g)->getFirstFormula(); neg_g = p->neg; } else { g = (FluentAction*) *fluent_g; neg_g = ""; } p->add("holds(" + neg_g + g->print(p) + ", " + p->T + "-1)"); if(fluent_g != G_->end()-1) p->add(", "); // get the vars set* tmp_vars = g->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } } if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); delete vars; } } coala-1.0.1_src/src/lib/b/ExecutableRule.cpp000644 001750 001750 00000005710 11477164507 021375 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/ExecutableRule.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "ExecutableRule.h" using namespace B; ExecutableRule::ExecutableRule(int line, Formula* A, Formula* F, Types* types) : C::Statement(line, types) { A_ = A; F_ = F; } ExecutableRule::~ExecutableRule ( ) { } void ExecutableRule::print(Printer* p) { set* vars = new set(); string T; // print the static rule twice: for T=0 and T>0 for(int i = 1; i <= 2; ++i) { if(i == 1) { p->setSection('b'); T = "0"; } else { p->setSection('c'); T = p->T; } FluentAction* a; FluentAction* f; string neg_a; string neg_f; // possible(a, T) :- holds(f, T). for(vector::iterator action_a = A_->begin(); action_a != A_->end(); ++action_a) { if(!(*action_a)->isFalse()) { // check for negation if((*action_a)->getType() == 'n') { a = (FluentAction*) (*action_a)->getFirstFormula(); neg_a = p->neg; } else { a = (FluentAction*) *action_a; neg_a = ""; } vars = a->getVariables(); p->add("possible(" + neg_a + a->print(p) + ", " + T + ")"); } // print F part if(F_ && !F_->isTrue()) { p->add(" :- "); for(vector::iterator fluent_f = F_->begin(); fluent_f != F_->end(); ++fluent_f) { // check for negation if((*fluent_f)->getType() == 'n') { f = (FluentAction*) (*fluent_f)->getFirstFormula(); neg_f = p->neg; } else { f = (FluentAction*) *fluent_f; neg_f = ""; } p->add("holds(" + neg_f + f->print(p) + ", " + T + ")"); if(fluent_f != F_->end()-1) p->add(", "); // get the vars set* tmp_vars = f->getVariables(); if(!tmp_vars->empty()) vars->insert(tmp_vars->begin(), tmp_vars->end()); delete tmp_vars; } } if(!vars->empty()) { if(F_ && !F_->isTrue()) p->add(", "); else p->add(" :- "); types_.print(p, vars, line_); } p->add(".\n"); } } // end main for delete vars; } coala-1.0.1_src/src/lib/b/DynamicRule.h000644 001750 001750 00000002712 11477164507 020344 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/DynamicRule.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef BDYNAMICRULE_H #define BDYNAMICRULE_H #include "../c/DynamicRule.h" #include namespace B { using namespace C; class DynamicRule : public C::DynamicRule { public: DynamicRule(int line, Formula* F, Formula* G, Formula* H, Types* types=NULL); virtual ~DynamicRule ( ); void print(Printer*); void printNonDirect(Printer* p); }; }; // end of package namespace #endif // BDYNAMICRULE_H coala-1.0.1_src/src/lib/b/CMakeLists.txt000644 001750 001750 00000000405 11477164507 020514 0ustar00tovok7tovok7000000 000000 IF(USE_FLEX_BISON) FLEX_FILE(Scanner.l) BISON_FILE(Parser.y) ENDIF(USE_FLEX_BISON) FILE(GLOB COALA_B_LIB_SRC *.cpp) ADD_LIBRARY(coala-b-lib STATIC ${COALA_B_LIB_SRC} Parser.cpp Scanner.cpp) SET_TARGET_PROPERTIES(coala-b-lib PROPERTIES OUTPUT_NAME coala-b) coala-1.0.1_src/src/lib/b/Parser.h000644 001750 001750 00000023041 11477164507 017362 0ustar00tovok7tovok7000000 000000 #ifndef YY_BParser_h_included #define YY_BParser_h_included #define YY_USE_CLASS #line 1 "/usr/share/bison++/bison.h" /* before anything */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #line 8 "/usr/share/bison++/bison.h" #define YY_BParser_LSP_NEEDED #define YY_BParser_ERROR_BODY = 0 #define YY_BParser_LEX_BODY = 0 #define YY_BParser_MEMBERS void preProcessing(Coala::CompilerOptions*); void postProcessing(Printer*); virtual ~BParser(){}\ private: std::string to_string(int integer);\ public: B::Program* program; #line 28 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" #include #include #include #include #include #include "../options.h" #include "Program.h" using namespace std; using namespace C; #line 42 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" typedef union { int number; string* str; Formula* form; Type* typ; Types* types; Arguments* args; Constraint* constr; Pool* var_pool; Interval* interval; LTLNode* ltl_node; } yy_BParser_stype; #define YY_BParser_STYPE yy_BParser_stype #line 21 "/usr/share/bison++/bison.h" /* %{ and %header{ and %union, during decl */ #ifndef YY_BParser_COMPATIBILITY #ifndef YY_USE_CLASS #define YY_BParser_COMPATIBILITY 1 #else #define YY_BParser_COMPATIBILITY 0 #endif #endif #if YY_BParser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YYLTYPE #ifndef YY_BParser_LTYPE #define YY_BParser_LTYPE YYLTYPE /* WARNING obsolete !!! user defined YYLTYPE not reported into generated header */ /* use %define LTYPE */ #endif #endif /*#ifdef YYSTYPE*/ #ifndef YY_BParser_STYPE #define YY_BParser_STYPE YYSTYPE /* WARNING obsolete !!! user defined YYSTYPE not reported into generated header */ /* use %define STYPE */ #endif /*#endif*/ #ifdef YYDEBUG #ifndef YY_BParser_DEBUG #define YY_BParser_DEBUG YYDEBUG /* WARNING obsolete !!! user defined YYDEBUG not reported into generated header */ /* use %define DEBUG */ #endif #endif /* use goto to be compatible */ #ifndef YY_BParser_USE_GOTO #define YY_BParser_USE_GOTO 1 #endif #endif /* use no goto to be clean in C++ */ #ifndef YY_BParser_USE_GOTO #define YY_BParser_USE_GOTO 0 #endif #ifndef YY_BParser_PURE #line 65 "/usr/share/bison++/bison.h" #line 65 "/usr/share/bison++/bison.h" /* YY_BParser_PURE */ #endif #line 68 "/usr/share/bison++/bison.h" #line 68 "/usr/share/bison++/bison.h" /* prefix */ #ifndef YY_BParser_DEBUG #line 71 "/usr/share/bison++/bison.h" #line 71 "/usr/share/bison++/bison.h" /* YY_BParser_DEBUG */ #endif #ifndef YY_BParser_LSP_NEEDED #line 75 "/usr/share/bison++/bison.h" #line 75 "/usr/share/bison++/bison.h" /* YY_BParser_LSP_NEEDED*/ #endif /* DEFAULT LTYPE*/ #ifdef YY_BParser_LSP_NEEDED #ifndef YY_BParser_LTYPE #ifndef BISON_YYLTYPE_ISDECLARED #define BISON_YYLTYPE_ISDECLARED typedef struct yyltype { int timestamp; int first_line; int first_column; int last_line; int last_column; char *text; } yyltype; #endif #define YY_BParser_LTYPE yyltype #endif #endif /* DEFAULT STYPE*/ #ifndef YY_BParser_STYPE #define YY_BParser_STYPE int #endif /* DEFAULT MISCELANEOUS */ #ifndef YY_BParser_PARSE #define YY_BParser_PARSE yyparse #endif #ifndef YY_BParser_LEX #define YY_BParser_LEX yylex #endif #ifndef YY_BParser_LVAL #define YY_BParser_LVAL yylval #endif #ifndef YY_BParser_LLOC #define YY_BParser_LLOC yylloc #endif #ifndef YY_BParser_CHAR #define YY_BParser_CHAR yychar #endif #ifndef YY_BParser_NERRS #define YY_BParser_NERRS yynerrs #endif #ifndef YY_BParser_DEBUG_FLAG #define YY_BParser_DEBUG_FLAG yydebug #endif #ifndef YY_BParser_ERROR #define YY_BParser_ERROR yyerror #endif #ifndef YY_BParser_PARSE_PARAM #ifndef __STDC__ #ifndef __cplusplus #ifndef YY_USE_CLASS #define YY_BParser_PARSE_PARAM #ifndef YY_BParser_PARSE_PARAM_DEF #define YY_BParser_PARSE_PARAM_DEF #endif #endif #endif #endif #ifndef YY_BParser_PARSE_PARAM #define YY_BParser_PARSE_PARAM void #endif #endif /* TOKEN C */ #ifndef YY_USE_CLASS #ifndef YY_BParser_PURE #ifndef yylval extern YY_BParser_STYPE YY_BParser_LVAL; #else #if yylval != YY_BParser_LVAL extern YY_BParser_STYPE YY_BParser_LVAL; #else #warning "Namespace conflict, disabling some functionality (bison++ only)" #endif #endif #endif #line 169 "/usr/share/bison++/bison.h" #define IDENTIFIER 258 #define NEG_IDENTI 259 #define VARIABLE 260 #define NUMBER 261 #define NOT 262 #define ACT 263 #define FLU 264 #define DFLU 265 #define CAUS 266 #define CAUSES 267 #define IF 268 #define EXE 269 #define NONEXE 270 #define INIT 271 #define OC_AT 272 #define HO_AT 273 #define GOAL 274 #define WHERE 275 #define TRUE 276 #define FALSE 277 #define DEF 278 #define INERT 279 #define COMMA 280 #define SEMIC 281 #define COLON 282 #define DOT 283 #define DDOT 284 #define LBRAC 285 #define RBRAC 286 #define EQ 287 #define NEQ 288 #define LT 289 #define GT 290 #define LE 291 #define GE 292 #define PLUS 293 #define MINUS 294 #define TIMES 295 #define DIV 296 #define MOD 297 #define AND 298 #define OR 299 #define XOR 300 #define LTL 301 #define LTLNOT 302 #define LTLOR 303 #define IMPL 304 #define EQUIV 305 #define X 306 #define F 307 #define G 308 #define U 309 #define R 310 #line 169 "/usr/share/bison++/bison.h" /* #defines token */ /* after #define tokens, before const tokens S5*/ #else #ifndef YY_BParser_CLASS #define YY_BParser_CLASS BParser #endif #ifndef YY_BParser_INHERIT #define YY_BParser_INHERIT #endif #ifndef YY_BParser_MEMBERS #define YY_BParser_MEMBERS #endif #ifndef YY_BParser_LEX_BODY #define YY_BParser_LEX_BODY #endif #ifndef YY_BParser_ERROR_BODY #define YY_BParser_ERROR_BODY #endif #ifndef YY_BParser_CONSTRUCTOR_PARAM #define YY_BParser_CONSTRUCTOR_PARAM #endif /* choose between enum and const */ #ifndef YY_BParser_USE_CONST_TOKEN #define YY_BParser_USE_CONST_TOKEN 0 /* yes enum is more compatible with flex, */ /* so by default we use it */ #endif #if YY_BParser_USE_CONST_TOKEN != 0 #ifndef YY_BParser_ENUM_TOKEN #define YY_BParser_ENUM_TOKEN yy_BParser_enum_token #endif #endif class YY_BParser_CLASS YY_BParser_INHERIT { public: #if YY_BParser_USE_CONST_TOKEN != 0 /* static const int token ... */ #line 212 "/usr/share/bison++/bison.h" static const int IDENTIFIER; static const int NEG_IDENTI; static const int VARIABLE; static const int NUMBER; static const int NOT; static const int ACT; static const int FLU; static const int DFLU; static const int CAUS; static const int CAUSES; static const int IF; static const int EXE; static const int NONEXE; static const int INIT; static const int OC_AT; static const int HO_AT; static const int GOAL; static const int WHERE; static const int TRUE; static const int FALSE; static const int DEF; static const int INERT; static const int COMMA; static const int SEMIC; static const int COLON; static const int DOT; static const int DDOT; static const int LBRAC; static const int RBRAC; static const int EQ; static const int NEQ; static const int LT; static const int GT; static const int LE; static const int GE; static const int PLUS; static const int MINUS; static const int TIMES; static const int DIV; static const int MOD; static const int AND; static const int OR; static const int XOR; static const int LTL; static const int LTLNOT; static const int LTLOR; static const int IMPL; static const int EQUIV; static const int X; static const int F; static const int G; static const int U; static const int R; #line 212 "/usr/share/bison++/bison.h" /* decl const */ #else enum YY_BParser_ENUM_TOKEN { YY_BParser_NULL_TOKEN=0 #line 215 "/usr/share/bison++/bison.h" ,IDENTIFIER=258 ,NEG_IDENTI=259 ,VARIABLE=260 ,NUMBER=261 ,NOT=262 ,ACT=263 ,FLU=264 ,DFLU=265 ,CAUS=266 ,CAUSES=267 ,IF=268 ,EXE=269 ,NONEXE=270 ,INIT=271 ,OC_AT=272 ,HO_AT=273 ,GOAL=274 ,WHERE=275 ,TRUE=276 ,FALSE=277 ,DEF=278 ,INERT=279 ,COMMA=280 ,SEMIC=281 ,COLON=282 ,DOT=283 ,DDOT=284 ,LBRAC=285 ,RBRAC=286 ,EQ=287 ,NEQ=288 ,LT=289 ,GT=290 ,LE=291 ,GE=292 ,PLUS=293 ,MINUS=294 ,TIMES=295 ,DIV=296 ,MOD=297 ,AND=298 ,OR=299 ,XOR=300 ,LTL=301 ,LTLNOT=302 ,LTLOR=303 ,IMPL=304 ,EQUIV=305 ,X=306 ,F=307 ,G=308 ,U=309 ,R=310 #line 215 "/usr/share/bison++/bison.h" /* enum token */ }; /* end of enum declaration */ #endif public: int YY_BParser_PARSE(YY_BParser_PARSE_PARAM); virtual void YY_BParser_ERROR(char *msg) YY_BParser_ERROR_BODY; #ifdef YY_BParser_PURE #ifdef YY_BParser_LSP_NEEDED virtual int YY_BParser_LEX(YY_BParser_STYPE *YY_BParser_LVAL,YY_BParser_LTYPE *YY_BParser_LLOC) YY_BParser_LEX_BODY; #else virtual int YY_BParser_LEX(YY_BParser_STYPE *YY_BParser_LVAL) YY_BParser_LEX_BODY; #endif #else virtual int YY_BParser_LEX() YY_BParser_LEX_BODY; YY_BParser_STYPE YY_BParser_LVAL; #ifdef YY_BParser_LSP_NEEDED YY_BParser_LTYPE YY_BParser_LLOC; #endif int YY_BParser_NERRS; int YY_BParser_CHAR; #endif #if YY_BParser_DEBUG != 0 public: int YY_BParser_DEBUG_FLAG; /* nonzero means print parse trace */ #endif public: YY_BParser_CLASS(YY_BParser_CONSTRUCTOR_PARAM); public: YY_BParser_MEMBERS }; /* other declare folow */ #endif #if YY_BParser_COMPATIBILITY != 0 /* backward compatibility */ /* Removed due to bison problems /#ifndef YYSTYPE / #define YYSTYPE YY_BParser_STYPE /#endif*/ #ifndef YYLTYPE #define YYLTYPE YY_BParser_LTYPE #endif #ifndef YYDEBUG #ifdef YY_BParser_DEBUG #define YYDEBUG YY_BParser_DEBUG #endif #endif #endif /* END */ #line 267 "/usr/share/bison++/bison.h" #endif coala-1.0.1_src/src/lib/b/Parser.cpp000644 001750 001750 00000220607 11477164507 017724 0ustar00tovok7tovok7000000 000000 #define YY_BParser_h_included #define YY_USE_CLASS /* A Bison++ parser, made from /home/tovok7/svn/potassco/coala/src/lib/b/Parser.y */ /* with Bison++ version bison++ Version 1.21.9-1, adapted from GNU bison by coetmeur@icdc.fr Maintained by Magnus Ekdahl */ #define YY_USE_CLASS #line 1 "/usr/share/bison++/bison.cc" /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, when this file is copied by Bison++ into a Bison++ output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison, and has been in Bison++ since 1.21.9. */ /* HEADER SECTION */ #if defined( _MSDOS ) || defined(MSDOS) || defined(__MSDOS__) #define __MSDOS_AND_ALIKE #endif #if defined(_WINDOWS) && defined(_MSC_VER) #define __HAVE_NO_ALLOCA #define __MSDOS_AND_ALIKE #endif #ifndef alloca #if defined( __GNUC__) #define alloca __builtin_alloca #elif (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) #include #elif defined (__MSDOS_AND_ALIKE) #include #ifndef __TURBOC__ /* MS C runtime lib */ #define alloca _alloca #endif #elif defined(_AIX) /* pragma must be put before any C/C++ instruction !! */ #pragma alloca #include #elif defined(__hpux) #ifdef __cplusplus extern "C" { void *alloca (unsigned int); }; #else /* not __cplusplus */ void *alloca (); #endif /* not __cplusplus */ #endif /* not _AIX not MSDOS, or __TURBOC__ or _AIX, not sparc. */ #endif /* alloca not defined. */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #ifndef YY_USE_CLASS /*#warning "For C++ its recomended to use bison++, otherwise classes won't be generated"*/ #endif #else #ifndef __STDC__ #define const #endif #ifdef YY_USE_CLASS #error "This is a C++ header generated by bison++, please use a C++ compiler!" #endif #endif #include #define YYBISON 1 #line 88 "/usr/share/bison++/bison.cc" #define YY_BParser_LSP_NEEDED #define YY_BParser_ERROR_BODY = 0 #define YY_BParser_LEX_BODY = 0 #define YY_BParser_MEMBERS void preProcessing(Coala::CompilerOptions*); void postProcessing(Printer*); virtual ~BParser(){}\ private: std::string to_string(int integer);\ public: B::Program* program; #line 28 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" #include #include #include #include #include #include "../options.h" #include "Program.h" using namespace std; using namespace C; #line 42 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" typedef union { int number; string* str; Formula* form; Type* typ; Types* types; Arguments* args; Constraint* constr; Pool* var_pool; Interval* interval; LTLNode* ltl_node; } yy_BParser_stype; #define YY_BParser_STYPE yy_BParser_stype #line 88 "/usr/share/bison++/bison.cc" /* %{ and %header{ and %union, during decl */ #define YY_BParser_BISON 1 #ifndef YY_BParser_COMPATIBILITY #ifndef YY_USE_CLASS #define YY_BParser_COMPATIBILITY 1 #else #define YY_BParser_COMPATIBILITY 0 #endif #endif #if YY_BParser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YYLTYPE #ifndef YY_BParser_LTYPE #define YY_BParser_LTYPE YYLTYPE #endif #endif /* Testing alternative bison solution /#ifdef YYSTYPE*/ #ifndef YY_BParser_STYPE #define YY_BParser_STYPE YYSTYPE #endif /*#endif*/ #ifdef YYDEBUG #ifndef YY_BParser_DEBUG #define YY_BParser_DEBUG YYDEBUG #endif #endif /* use goto to be compatible */ #ifndef YY_BParser_USE_GOTO #define YY_BParser_USE_GOTO 1 #endif #endif /* use no goto to be clean in C++ */ #ifndef YY_BParser_USE_GOTO #define YY_BParser_USE_GOTO 0 #endif #ifndef YY_BParser_PURE #line 130 "/usr/share/bison++/bison.cc" #line 130 "/usr/share/bison++/bison.cc" /* YY_BParser_PURE */ #endif /* section apres lecture def, avant lecture grammaire S2 */ #line 134 "/usr/share/bison++/bison.cc" #line 134 "/usr/share/bison++/bison.cc" /* prefix */ #ifndef YY_BParser_DEBUG #line 136 "/usr/share/bison++/bison.cc" #line 136 "/usr/share/bison++/bison.cc" /* YY_BParser_DEBUG */ #endif #ifndef YY_BParser_LSP_NEEDED #line 141 "/usr/share/bison++/bison.cc" #line 141 "/usr/share/bison++/bison.cc" /* YY_BParser_LSP_NEEDED*/ #endif /* DEFAULT LTYPE*/ #ifdef YY_BParser_LSP_NEEDED #ifndef YY_BParser_LTYPE #ifndef BISON_YYLTYPE_ISDECLARED #define BISON_YYLTYPE_ISDECLARED typedef struct yyltype { int timestamp; int first_line; int first_column; int last_line; int last_column; char *text; } yyltype; #endif #define YY_BParser_LTYPE yyltype #endif #endif /* DEFAULT STYPE*/ /* We used to use `unsigned long' as YY_BParser_STYPE on MSDOS, but it seems better to be consistent. Most programs should declare their own type anyway. */ #ifndef YY_BParser_STYPE #define YY_BParser_STYPE int #endif /* DEFAULT MISCELANEOUS */ #ifndef YY_BParser_PARSE #define YY_BParser_PARSE yyparse #endif #ifndef YY_BParser_LEX #define YY_BParser_LEX yylex #endif #ifndef YY_BParser_LVAL #define YY_BParser_LVAL yylval #endif #ifndef YY_BParser_LLOC #define YY_BParser_LLOC yylloc #endif #ifndef YY_BParser_CHAR #define YY_BParser_CHAR yychar #endif #ifndef YY_BParser_NERRS #define YY_BParser_NERRS yynerrs #endif #ifndef YY_BParser_DEBUG_FLAG #define YY_BParser_DEBUG_FLAG yydebug #endif #ifndef YY_BParser_ERROR #define YY_BParser_ERROR yyerror #endif #ifndef YY_BParser_PARSE_PARAM #ifndef YY_USE_CLASS #ifdef YYPARSE_PARAM #define YY_BParser_PARSE_PARAM void* YYPARSE_PARAM #else #ifndef __STDC__ #ifndef __cplusplus #define YY_BParser_PARSE_PARAM #endif #endif #endif #endif #ifndef YY_BParser_PARSE_PARAM #define YY_BParser_PARSE_PARAM void #endif #endif #if YY_BParser_COMPATIBILITY != 0 /* backward compatibility */ #ifdef YY_BParser_LTYPE #ifndef YYLTYPE #define YYLTYPE YY_BParser_LTYPE #else /* WARNING obsolete !!! user defined YYLTYPE not reported into generated header */ #endif #endif /* Removed due to bison compabilityproblems /#ifndef YYSTYPE /#define YYSTYPE YY_BParser_STYPE /#else*/ /* WARNING obsolete !!! user defined YYSTYPE not reported into generated header */ /*#endif*/ #ifdef YY_BParser_PURE # ifndef YYPURE # define YYPURE YY_BParser_PURE # endif #endif #ifdef YY_BParser_DEBUG # ifndef YYDEBUG # define YYDEBUG YY_BParser_DEBUG # endif #endif #ifndef YY_BParser_ERROR_VERBOSE #ifdef YYERROR_VERBOSE #define YY_BParser_ERROR_VERBOSE YYERROR_VERBOSE #endif #endif #ifndef YY_BParser_LSP_NEEDED # ifdef YYLSP_NEEDED # define YY_BParser_LSP_NEEDED YYLSP_NEEDED # endif #endif #endif #ifndef YY_USE_CLASS /* TOKEN C */ #line 263 "/usr/share/bison++/bison.cc" #define IDENTIFIER 258 #define NEG_IDENTI 259 #define VARIABLE 260 #define NUMBER 261 #define NOT 262 #define ACT 263 #define FLU 264 #define DFLU 265 #define CAUS 266 #define CAUSES 267 #define IF 268 #define EXE 269 #define NONEXE 270 #define INIT 271 #define OC_AT 272 #define HO_AT 273 #define GOAL 274 #define WHERE 275 #define TRUE 276 #define FALSE 277 #define DEF 278 #define INERT 279 #define COMMA 280 #define SEMIC 281 #define COLON 282 #define DOT 283 #define DDOT 284 #define LBRAC 285 #define RBRAC 286 #define EQ 287 #define NEQ 288 #define LT 289 #define GT 290 #define LE 291 #define GE 292 #define PLUS 293 #define MINUS 294 #define TIMES 295 #define DIV 296 #define MOD 297 #define AND 298 #define OR 299 #define XOR 300 #define LTL 301 #define LTLNOT 302 #define LTLOR 303 #define IMPL 304 #define EQUIV 305 #define X 306 #define F 307 #define G 308 #define U 309 #define R 310 #line 263 "/usr/share/bison++/bison.cc" /* #defines tokens */ #else /* CLASS */ #ifndef YY_BParser_CLASS #define YY_BParser_CLASS BParser #endif #ifndef YY_BParser_INHERIT #define YY_BParser_INHERIT #endif #ifndef YY_BParser_MEMBERS #define YY_BParser_MEMBERS #endif #ifndef YY_BParser_LEX_BODY #define YY_BParser_LEX_BODY #endif #ifndef YY_BParser_ERROR_BODY #define YY_BParser_ERROR_BODY #endif #ifndef YY_BParser_CONSTRUCTOR_PARAM #define YY_BParser_CONSTRUCTOR_PARAM #endif #ifndef YY_BParser_CONSTRUCTOR_CODE #define YY_BParser_CONSTRUCTOR_CODE #endif #ifndef YY_BParser_CONSTRUCTOR_INIT #define YY_BParser_CONSTRUCTOR_INIT #endif /* choose between enum and const */ #ifndef YY_BParser_USE_CONST_TOKEN #define YY_BParser_USE_CONST_TOKEN 0 /* yes enum is more compatible with flex, */ /* so by default we use it */ #endif #if YY_BParser_USE_CONST_TOKEN != 0 #ifndef YY_BParser_ENUM_TOKEN #define YY_BParser_ENUM_TOKEN yy_BParser_enum_token #endif #endif class YY_BParser_CLASS YY_BParser_INHERIT { public: #if YY_BParser_USE_CONST_TOKEN != 0 /* static const int token ... */ #line 307 "/usr/share/bison++/bison.cc" static const int IDENTIFIER; static const int NEG_IDENTI; static const int VARIABLE; static const int NUMBER; static const int NOT; static const int ACT; static const int FLU; static const int DFLU; static const int CAUS; static const int CAUSES; static const int IF; static const int EXE; static const int NONEXE; static const int INIT; static const int OC_AT; static const int HO_AT; static const int GOAL; static const int WHERE; static const int TRUE; static const int FALSE; static const int DEF; static const int INERT; static const int COMMA; static const int SEMIC; static const int COLON; static const int DOT; static const int DDOT; static const int LBRAC; static const int RBRAC; static const int EQ; static const int NEQ; static const int LT; static const int GT; static const int LE; static const int GE; static const int PLUS; static const int MINUS; static const int TIMES; static const int DIV; static const int MOD; static const int AND; static const int OR; static const int XOR; static const int LTL; static const int LTLNOT; static const int LTLOR; static const int IMPL; static const int EQUIV; static const int X; static const int F; static const int G; static const int U; static const int R; #line 307 "/usr/share/bison++/bison.cc" /* decl const */ #else enum YY_BParser_ENUM_TOKEN { YY_BParser_NULL_TOKEN=0 #line 310 "/usr/share/bison++/bison.cc" ,IDENTIFIER=258 ,NEG_IDENTI=259 ,VARIABLE=260 ,NUMBER=261 ,NOT=262 ,ACT=263 ,FLU=264 ,DFLU=265 ,CAUS=266 ,CAUSES=267 ,IF=268 ,EXE=269 ,NONEXE=270 ,INIT=271 ,OC_AT=272 ,HO_AT=273 ,GOAL=274 ,WHERE=275 ,TRUE=276 ,FALSE=277 ,DEF=278 ,INERT=279 ,COMMA=280 ,SEMIC=281 ,COLON=282 ,DOT=283 ,DDOT=284 ,LBRAC=285 ,RBRAC=286 ,EQ=287 ,NEQ=288 ,LT=289 ,GT=290 ,LE=291 ,GE=292 ,PLUS=293 ,MINUS=294 ,TIMES=295 ,DIV=296 ,MOD=297 ,AND=298 ,OR=299 ,XOR=300 ,LTL=301 ,LTLNOT=302 ,LTLOR=303 ,IMPL=304 ,EQUIV=305 ,X=306 ,F=307 ,G=308 ,U=309 ,R=310 #line 310 "/usr/share/bison++/bison.cc" /* enum token */ }; /* end of enum declaration */ #endif public: int YY_BParser_PARSE (YY_BParser_PARSE_PARAM); virtual void YY_BParser_ERROR(char *msg) YY_BParser_ERROR_BODY; #ifdef YY_BParser_PURE #ifdef YY_BParser_LSP_NEEDED virtual int YY_BParser_LEX (YY_BParser_STYPE *YY_BParser_LVAL,YY_BParser_LTYPE *YY_BParser_LLOC) YY_BParser_LEX_BODY; #else virtual int YY_BParser_LEX (YY_BParser_STYPE *YY_BParser_LVAL) YY_BParser_LEX_BODY; #endif #else virtual int YY_BParser_LEX() YY_BParser_LEX_BODY; YY_BParser_STYPE YY_BParser_LVAL; #ifdef YY_BParser_LSP_NEEDED YY_BParser_LTYPE YY_BParser_LLOC; #endif int YY_BParser_NERRS; int YY_BParser_CHAR; #endif #if YY_BParser_DEBUG != 0 int YY_BParser_DEBUG_FLAG; /* nonzero means print parse trace */ #endif public: YY_BParser_CLASS(YY_BParser_CONSTRUCTOR_PARAM); public: YY_BParser_MEMBERS }; /* other declare folow */ #if YY_BParser_USE_CONST_TOKEN != 0 #line 341 "/usr/share/bison++/bison.cc" const int YY_BParser_CLASS::IDENTIFIER=258; const int YY_BParser_CLASS::NEG_IDENTI=259; const int YY_BParser_CLASS::VARIABLE=260; const int YY_BParser_CLASS::NUMBER=261; const int YY_BParser_CLASS::NOT=262; const int YY_BParser_CLASS::ACT=263; const int YY_BParser_CLASS::FLU=264; const int YY_BParser_CLASS::DFLU=265; const int YY_BParser_CLASS::CAUS=266; const int YY_BParser_CLASS::CAUSES=267; const int YY_BParser_CLASS::IF=268; const int YY_BParser_CLASS::EXE=269; const int YY_BParser_CLASS::NONEXE=270; const int YY_BParser_CLASS::INIT=271; const int YY_BParser_CLASS::OC_AT=272; const int YY_BParser_CLASS::HO_AT=273; const int YY_BParser_CLASS::GOAL=274; const int YY_BParser_CLASS::WHERE=275; const int YY_BParser_CLASS::TRUE=276; const int YY_BParser_CLASS::FALSE=277; const int YY_BParser_CLASS::DEF=278; const int YY_BParser_CLASS::INERT=279; const int YY_BParser_CLASS::COMMA=280; const int YY_BParser_CLASS::SEMIC=281; const int YY_BParser_CLASS::COLON=282; const int YY_BParser_CLASS::DOT=283; const int YY_BParser_CLASS::DDOT=284; const int YY_BParser_CLASS::LBRAC=285; const int YY_BParser_CLASS::RBRAC=286; const int YY_BParser_CLASS::EQ=287; const int YY_BParser_CLASS::NEQ=288; const int YY_BParser_CLASS::LT=289; const int YY_BParser_CLASS::GT=290; const int YY_BParser_CLASS::LE=291; const int YY_BParser_CLASS::GE=292; const int YY_BParser_CLASS::PLUS=293; const int YY_BParser_CLASS::MINUS=294; const int YY_BParser_CLASS::TIMES=295; const int YY_BParser_CLASS::DIV=296; const int YY_BParser_CLASS::MOD=297; const int YY_BParser_CLASS::AND=298; const int YY_BParser_CLASS::OR=299; const int YY_BParser_CLASS::XOR=300; const int YY_BParser_CLASS::LTL=301; const int YY_BParser_CLASS::LTLNOT=302; const int YY_BParser_CLASS::LTLOR=303; const int YY_BParser_CLASS::IMPL=304; const int YY_BParser_CLASS::EQUIV=305; const int YY_BParser_CLASS::X=306; const int YY_BParser_CLASS::F=307; const int YY_BParser_CLASS::G=308; const int YY_BParser_CLASS::U=309; const int YY_BParser_CLASS::R=310; #line 341 "/usr/share/bison++/bison.cc" /* const YY_BParser_CLASS::token */ #endif /*apres const */ YY_BParser_CLASS::YY_BParser_CLASS(YY_BParser_CONSTRUCTOR_PARAM) YY_BParser_CONSTRUCTOR_INIT { #if YY_BParser_DEBUG != 0 YY_BParser_DEBUG_FLAG=0; #endif YY_BParser_CONSTRUCTOR_CODE; }; #endif #line 352 "/usr/share/bison++/bison.cc" #define YYFINAL 232 #define YYFLAG -32768 #define YYNTBASE 56 #define YYTRANSLATE(x) ((unsigned)(x) <= 310 ? yytranslate[x] : 86) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 }; #if YY_BParser_DEBUG != 0 static const short yyprhs[] = { 0, 0, 1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 45, 48, 53, 56, 61, 63, 67, 71, 77, 80, 85, 90, 97, 101, 107, 113, 121, 124, 129, 134, 141, 144, 149, 154, 161, 164, 169, 173, 177, 183, 189, 193, 197, 203, 209, 212, 217, 219, 221, 223, 227, 229, 234, 236, 241, 243, 245, 247, 249, 251, 256, 260, 264, 268, 272, 276, 283, 287, 291, 295, 299, 303, 307, 309, 311, 315, 319, 325, 329, 333, 339, 345, 353, 358, 364, 368, 372, 376, 380, 384, 388, 392, 396, 400, 404, 408, 412, 416, 420, 424, 428, 432, 436, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 471, 473, 477, 480, 484, 488, 492, 496, 499, 502, 505, 509 }; static const short yyrhs[] = { -1, 56, 57, 28, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 84, 0, 8, 73, 0, 8, 73, 20, 78, 0, 9, 73, 0, 9, 73, 20, 78, 0, 10, 73, 0, 10, 73, 20, 78, 0, 73, 0, 73, 20, 78, 0, 73, 13, 73, 0, 73, 13, 73, 20, 78, 0, 11, 73, 0, 11, 73, 20, 78, 0, 11, 73, 13, 73, 0, 11, 73, 13, 73, 20, 78, 0, 73, 12, 73, 0, 73, 12, 73, 20, 78, 0, 73, 12, 73, 13, 73, 0, 73, 12, 73, 13, 73, 20, 78, 0, 14, 73, 0, 14, 73, 20, 78, 0, 14, 73, 13, 73, 0, 14, 73, 13, 73, 20, 78, 0, 15, 73, 0, 15, 73, 20, 78, 0, 15, 73, 13, 73, 0, 15, 73, 13, 73, 20, 78, 0, 16, 73, 0, 16, 73, 20, 78, 0, 73, 17, 6, 0, 73, 17, 3, 0, 73, 17, 6, 20, 78, 0, 73, 17, 3, 20, 78, 0, 73, 18, 6, 0, 73, 18, 3, 0, 73, 18, 6, 20, 78, 0, 73, 18, 3, 20, 78, 0, 19, 73, 0, 19, 73, 20, 78, 0, 74, 0, 21, 0, 22, 0, 73, 25, 74, 0, 3, 0, 3, 30, 75, 31, 0, 4, 0, 4, 30, 75, 31, 0, 5, 0, 3, 0, 6, 0, 76, 0, 77, 0, 3, 30, 75, 31, 0, 75, 25, 5, 0, 75, 25, 3, 0, 75, 25, 6, 0, 75, 25, 76, 0, 75, 25, 77, 0, 75, 25, 3, 30, 75, 31, 0, 5, 26, 5, 0, 76, 26, 5, 0, 6, 29, 6, 0, 6, 29, 5, 0, 5, 29, 6, 0, 5, 29, 5, 0, 80, 0, 79, 0, 6, 27, 79, 0, 79, 27, 6, 0, 6, 27, 79, 27, 6, 0, 78, 25, 80, 0, 78, 25, 79, 0, 78, 25, 6, 27, 79, 0, 78, 25, 79, 27, 6, 0, 78, 25, 6, 27, 79, 27, 6, 0, 3, 30, 75, 31, 0, 7, 3, 30, 75, 31, 0, 81, 82, 81, 0, 6, 82, 81, 0, 81, 82, 6, 0, 3, 82, 81, 0, 81, 82, 3, 0, 5, 82, 81, 0, 81, 82, 5, 0, 5, 82, 5, 0, 6, 82, 5, 0, 5, 82, 6, 0, 3, 82, 5, 0, 5, 82, 3, 0, 6, 82, 3, 0, 3, 82, 6, 0, 6, 83, 5, 0, 5, 83, 6, 0, 5, 83, 5, 0, 81, 83, 6, 0, 81, 83, 5, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 85, 0, 74, 0, 30, 85, 31, 0, 47, 85, 0, 85, 43, 85, 0, 85, 48, 85, 0, 85, 49, 85, 0, 85, 50, 85, 0, 51, 85, 0, 53, 85, 0, 52, 85, 0, 85, 54, 85, 0, 85, 55, 85, 0 }; #endif #if (YY_BParser_DEBUG != 0) || defined(YY_BParser_ERROR_VERBOSE) static const short yyrline[] = { 0, 133, 133, 135, 135, 135, 137, 137, 137, 139, 139, 139, 139, 139, 141, 141, 141, 141, 141, 144, 146, 149, 151, 154, 156, 159, 161, 162, 163, 166, 168, 169, 170, 173, 175, 176, 177, 180, 182, 183, 184, 187, 189, 190, 191, 194, 196, 199, 201, 202, 203, 206, 208, 209, 210, 213, 215, 218, 220, 221, 222, 224, 226, 227, 228, 231, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 246, 248, 251, 253, 254, 255, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 271, 273, 276, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 293, 295, 296, 297, 298, 300, 302, 303, 304, 305, 306, 308, 310, 311, 312, 313, 314, 315, 316, 318, 320, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332 }; static const char * const yytname[] = { "$","error","$illegal.","IDENTIFIER", "NEG_IDENTI","VARIABLE","NUMBER","NOT","ACT","FLU","DFLU","CAUS","CAUSES","IF", "EXE","NONEXE","INIT","OC_AT","HO_AT","GOAL","WHERE","TRUE","FALSE","DEF","INERT", "COMMA","SEMIC","COLON","DOT","DDOT","LBRAC","RBRAC","EQ","NEQ","LT","GT","LE", "GE","PLUS","MINUS","TIMES","DIV","MOD","AND","OR","XOR","LTL","LTLNOT","LTLOR", "IMPL","EQUIV","X","F","G","U","R","program","rule","fact","law","query","act_fact", "flu_fact","dflu_fact","static_rule","static_caused_rule","dyn_rule","exe_rule", "nonexe_rule","init_rule","oc_query","ho_query","goal_query","formula","identifier", "term_list","pool","interval","types_list","type","constraint","operation","eqoperator", "operator","ltl_query","ltl_expr","" }; #endif static const short yyr1[] = { 0, 56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 69, 69, 70, 70, 70, 70, 71, 71, 71, 71, 72, 72, 73, 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 79, 79, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81, 82, 82, 82, 82, 82, 82, 83, 83, 83, 83, 83, 83, 83, 83, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85 }; static const short yyr2[] = { 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 4, 2, 4, 1, 3, 3, 5, 2, 4, 4, 6, 3, 5, 5, 7, 2, 4, 4, 6, 2, 4, 4, 6, 2, 4, 3, 3, 5, 5, 3, 3, 5, 5, 2, 4, 1, 1, 1, 3, 1, 4, 1, 4, 1, 1, 1, 1, 1, 4, 3, 3, 3, 3, 3, 6, 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 5, 3, 3, 5, 5, 7, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 2, 3, 3, 3, 3, 2, 2, 2, 3, 3 }; static const short yydefact[] = { 1, 0, 61, 63, 0, 0, 0, 0, 0, 0, 0, 0, 58, 59, 0, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 25, 57, 18, 0, 0, 19, 21, 23, 29, 37, 41, 45, 55, 0, 0, 0, 0, 0, 129, 128, 2, 0, 0, 0, 0, 0, 0, 66, 65, 67, 0, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 136, 138, 137, 0, 0, 0, 0, 0, 0, 33, 27, 48, 47, 52, 51, 0, 0, 0, 0, 26, 84, 83, 0, 60, 0, 0, 0, 0, 0, 62, 0, 64, 20, 22, 24, 31, 30, 39, 38, 43, 42, 46, 56, 130, 132, 133, 134, 135, 139, 140, 0, 0, 0, 0, 0, 0, 0, 0, 114, 115, 116, 117, 118, 119, 0, 120, 121, 122, 123, 124, 125, 126, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 82, 81, 80, 79, 72, 71, 73, 74, 75, 78, 0, 0, 0, 35, 34, 28, 50, 49, 54, 53, 0, 105, 108, 98, 106, 102, 104, 100, 111, 110, 0, 85, 107, 103, 0, 96, 109, 0, 0, 89, 88, 86, 99, 101, 97, 95, 113, 112, 70, 0, 32, 40, 44, 0, 93, 0, 0, 0, 0, 0, 36, 87, 94, 90, 91, 76, 0, 92, 0, 0 }; static const short yydefgoto[] = { 1, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 61, 62, 63, 97, 98, 99, 100, 154, 155, 33, 50 }; static const short yypact[] = {-32768, 132, -6, 24, 22, 22, 22, 22, 22, 22, 22, 22,-32768,-32768, -2, 33,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 91,-32768,-32768, 158, 158, 55, 109, 125, 71, 81, 108, 222, 223, -2, -2, -2, -2, -2,-32768, -16, -32768, 22, 22, 276, 280, 256, 74, 36, 258, 61, 6, 66,-32768, 27, 256, 256, 256, 22, 256, 22, 256, 22, 256, 256, 256, -8,-32768,-32768,-32768,-32768, -2, -2, -2, -2, -2, -2, 124, 224, 82, 90, 100, 118, 202, 186, 147, 149, 137, 174,-32768, 186, -32768, 158, 228, 113, 170, 197,-32768, 236,-32768, 137, 137, 137, 225, 137, 231, 137, 232, 137, 137, 137, -32768, 76, 76, 76, 76,-32768,-32768, 22, 256, 256, 256, 256, 256, 256, 158,-32768,-32768,-32768,-32768,-32768, -32768, 249,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 267, 283, 262, 271, 255, 241, 261, 269, 275, 285, 28,-32768,-32768,-32768,-32768,-32768, 263, 258, 61, 66, -32768,-32768, 256, 256, 256, 233, 137, 137, 137, 137, 137, 137, 31, 128, 128, 128,-32768, 128, 128, 128, -32768,-32768, 264, 265,-32768, 128, 128, 128,-32768, 158, 172, 268,-32768,-32768,-32768, 128, 128, 128,-32768,-32768, -32768, 158, 137, 137, 137, 256,-32768, 279, 51, 262, 290, 215, 137,-32768,-32768, 270,-32768,-32768, 292,-32768, 299,-32768 }; static const short yypgoto[] = {-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768, 11, 41, -35, 194, 195, -61, -146, 145, -94, -64, -91,-32768, 112 }; #define YYLAST 302 static const short yytable[] = { 64, 2, 3, 152, 110, 111, 112, 194, 114, 160, 116, 202, 118, 119, 120, 36, 37, 38, 39, 40, 41, 42, 43, 121, 34, 2, 3, 81, 44, 142, 151, 106, 82, 83, 84, 81, 159, 107, 85, 86, 82, 83, 84, 12, 13, 45, 85, 86, 186, 46, 47, 48, 106, 106, 35, 49, 106, 190, 109, 211, 198, 51, 217, 87, 88, 208, 102, 161, 177, 178, 179, 180, 181, 182, 226, 65, 106, 2, 3, 113, 57, 115, 225, 117, 68, 49, 49, 49, 49, 49, 105, 69, 108, 152, 70, 160, 57, 152, 101, 160, 183, 71, 131, 52, 53, 152, 57, 160, 54, 55, 132, 56, 213, 214, 215, 152, 57, 160, 163, 164, 133, 72, 49, 49, 49, 49, 49, 49, 73, 66, 85, 86, 231, 57, 57, 2, 3, 128, 134, 176, 4, 5, 6, 7, 129, 67, 8, 9, 10, 57, 57, 11, 156, 12, 13, 223, 76, 77, 78, 79, 80, 58, 157, 59, 60, 219, 143, 144, 145, 146, 147, 148, 149, 150, 153, 165, 166, 222, 14, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 122, 123, 124, 125, 126, 127, 220, 167, 158, 168, 169, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 135, 162, 136, 137, 138, 139, 140, 141, 106, 172, 74, 75, 130, 173, 228, 57, 57, 57, 57, 174, 175, 216, 184, 185, 57, 57, 57, 93, 199, 94, 95, 96, 93, 193, 94, 201, 96, 96, 187, 200, 188, 189, 195, 204, 196, 197, 205, 89, 206, 207, 90, 91, 103, 224, 92, 104, 191, 192, 209, 210, 218, 212, 135, 221, 227, 229, 230, 232, 170, 171, 203 }; static const short yycheck[] = { 35, 3, 4, 94, 65, 66, 67, 153, 69, 100, 71, 157, 73, 74, 75, 4, 5, 6, 7, 8, 9, 10, 11, 31, 30, 3, 4, 43, 30, 93, 94, 25, 48, 49, 50, 43, 100, 31, 54, 55, 48, 49, 50, 21, 22, 47, 54, 55, 142, 51, 52, 53, 25, 25, 30, 14, 25, 151, 31, 31, 154, 28, 31, 52, 53, 159, 30, 102, 129, 130, 131, 132, 133, 134, 220, 20, 25, 3, 4, 68, 25, 70, 31, 72, 13, 44, 45, 46, 47, 48, 29, 20, 26, 184, 13, 186, 25, 188, 57, 190, 135, 20, 20, 12, 13, 196, 25, 198, 17, 18, 20, 20, 173, 174, 175, 206, 25, 208, 5, 6, 20, 13, 81, 82, 83, 84, 85, 86, 20, 20, 54, 55, 0, 25, 25, 3, 4, 13, 20, 128, 8, 9, 10, 11, 20, 20, 14, 15, 16, 25, 25, 19, 3, 21, 22, 216, 44, 45, 46, 47, 48, 3, 25, 5, 6, 200, 38, 39, 40, 41, 42, 43, 44, 45, 27, 5, 6, 212, 46, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 81, 82, 83, 84, 85, 86, 27, 3, 27, 5, 6, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 30, 5, 32, 33, 34, 35, 36, 37, 25, 5, 20, 20, 20, 20, 31, 25, 25, 25, 25, 20, 20, 20, 5, 6, 25, 25, 25, 3, 5, 5, 6, 7, 3, 3, 5, 6, 7, 7, 3, 30, 5, 6, 3, 6, 5, 6, 3, 3, 5, 6, 6, 3, 26, 6, 6, 29, 5, 6, 5, 6, 27, 30, 30, 27, 6, 27, 6, 0, 106, 106, 157 }; #line 352 "/usr/share/bison++/bison.cc" /* fattrs + tables */ /* parser code folow */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* Note: dollar marks section change the next is replaced by the list of actions, each action as one case of the switch. */ #if YY_BParser_USE_GOTO != 0 /* SUPRESSION OF GOTO : on some C++ compiler (sun c++) the goto is strictly forbidden if any constructor/destructor is used in the whole function (very stupid isn't it ?) so goto are to be replaced with a 'while/switch/case construct' here are the macro to keep some apparent compatibility */ #define YYGOTO(lb) {yy_gotostate=lb;continue;} #define YYBEGINGOTO enum yy_labels yy_gotostate=yygotostart; \ for(;;) switch(yy_gotostate) { case yygotostart: { #define YYLABEL(lb) } case lb: { #define YYENDGOTO } } #define YYBEGINDECLARELABEL enum yy_labels {yygotostart #define YYDECLARELABEL(lb) ,lb #define YYENDDECLARELABEL }; #else /* macro to keep goto */ #define YYGOTO(lb) goto lb #define YYBEGINGOTO #define YYLABEL(lb) lb: #define YYENDGOTO #define YYBEGINDECLARELABEL #define YYDECLARELABEL(lb) #define YYENDDECLARELABEL #endif /* LABEL DECLARATION */ YYBEGINDECLARELABEL YYDECLARELABEL(yynewstate) YYDECLARELABEL(yybackup) /* YYDECLARELABEL(yyresume) */ YYDECLARELABEL(yydefault) YYDECLARELABEL(yyreduce) YYDECLARELABEL(yyerrlab) /* here on detecting error */ YYDECLARELABEL(yyerrlab1) /* here on error raised explicitly by an action */ YYDECLARELABEL(yyerrdefault) /* current state does not do anything special for the error token. */ YYDECLARELABEL(yyerrpop) /* pop the current state because it cannot handle the error token */ YYDECLARELABEL(yyerrhandle) YYENDDECLARELABEL /* ALLOCA SIMULATION */ /* __HAVE_NO_ALLOCA */ #ifdef __HAVE_NO_ALLOCA int __alloca_free_ptr(char *ptr,char *ref) {if(ptr!=ref) free(ptr); return 0;} #define __ALLOCA_alloca(size) malloc(size) #define __ALLOCA_free(ptr,ref) __alloca_free_ptr((char *)ptr,(char *)ref) #ifdef YY_BParser_LSP_NEEDED #define __ALLOCA_return(num) \ do { return( __ALLOCA_free(yyss,yyssa)+\ __ALLOCA_free(yyvs,yyvsa)+\ __ALLOCA_free(yyls,yylsa)+\ (num)); } while(0) #else #define __ALLOCA_return(num) \ do { return( __ALLOCA_free(yyss,yyssa)+\ __ALLOCA_free(yyvs,yyvsa)+\ (num)); } while(0) #endif #else #define __ALLOCA_return(num) do { return(num); } while(0) #define __ALLOCA_alloca(size) alloca(size) #define __ALLOCA_free(ptr,ref) #endif /* ENDALLOCA SIMULATION */ #define yyerrok (yyerrstatus = 0) #define yyclearin (YY_BParser_CHAR = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT __ALLOCA_return(0) #define YYABORT __ALLOCA_return(1) #define YYERROR YYGOTO(yyerrlab1) /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL YYGOTO(yyerrlab) #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (YY_BParser_CHAR == YYEMPTY && yylen == 1) \ { YY_BParser_CHAR = (token), YY_BParser_LVAL = (value); \ yychar1 = YYTRANSLATE (YY_BParser_CHAR); \ YYPOPSTACK; \ YYGOTO(yybackup); \ } \ else \ { YY_BParser_ERROR ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YY_BParser_PURE /* UNPURE */ #define YYLEX YY_BParser_LEX() #ifndef YY_USE_CLASS /* If nonreentrant, and not class , generate the variables here */ int YY_BParser_CHAR; /* the lookahead symbol */ YY_BParser_STYPE YY_BParser_LVAL; /* the semantic value of the */ /* lookahead symbol */ int YY_BParser_NERRS; /* number of parse errors so far */ #ifdef YY_BParser_LSP_NEEDED YY_BParser_LTYPE YY_BParser_LLOC; /* location data for the lookahead */ /* symbol */ #endif #endif #else /* PURE */ #ifdef YY_BParser_LSP_NEEDED #define YYLEX YY_BParser_LEX(&YY_BParser_LVAL, &YY_BParser_LLOC) #else #define YYLEX YY_BParser_LEX(&YY_BParser_LVAL) #endif #endif #ifndef YY_USE_CLASS #if YY_BParser_DEBUG != 0 int YY_BParser_DEBUG_FLAG; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ #ifdef __cplusplus static void __yy_bcopy (char *from, char *to, int count) #else #ifdef __STDC__ static void __yy_bcopy (char *from, char *to, int count) #else static void __yy_bcopy (from, to, count) char *from; char *to; int count; #endif #endif { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #endif int #ifdef YY_USE_CLASS YY_BParser_CLASS:: #endif YY_BParser_PARSE(YY_BParser_PARSE_PARAM) #ifndef __STDC__ #ifndef __cplusplus #ifndef YY_USE_CLASS /* parameter definition without protypes */ YY_BParser_PARSE_PARAM_DEF #endif #endif #endif { register int yystate; register int yyn; register short *yyssp; register YY_BParser_STYPE *yyvsp; int yyerrstatus; /* number of tokens to shift before error messages enabled */ int yychar1=0; /* lookahead token as an internal (translated) token number */ short yyssa[YYINITDEPTH]; /* the state stack */ YY_BParser_STYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ short *yyss = yyssa; /* refer to the stacks thru separate pointers */ YY_BParser_STYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YY_BParser_LSP_NEEDED YY_BParser_LTYPE yylsa[YYINITDEPTH]; /* the location stack */ YY_BParser_LTYPE *yyls = yylsa; YY_BParser_LTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif int yystacksize = YYINITDEPTH; #ifdef YY_BParser_PURE int YY_BParser_CHAR; YY_BParser_STYPE YY_BParser_LVAL; int YY_BParser_NERRS; #ifdef YY_BParser_LSP_NEEDED YY_BParser_LTYPE YY_BParser_LLOC; #endif #endif YY_BParser_STYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ int yylen; /* start loop, in which YYGOTO may be used. */ YYBEGINGOTO #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; YY_BParser_NERRS = 0; YY_BParser_CHAR = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YY_BParser_LSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ YYLABEL(yynewstate) *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YY_BParser_STYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YY_BParser_LSP_NEEDED YY_BParser_LTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YY_BParser_LSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YY_BParser_LSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { YY_BParser_ERROR("parser stack overflow"); __ALLOCA_return(2); } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; yyss = (short *) __ALLOCA_alloca (yystacksize * sizeof (*yyssp)); __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); __ALLOCA_free(yyss1,yyssa); yyvs = (YY_BParser_STYPE *) __ALLOCA_alloca (yystacksize * sizeof (*yyvsp)); __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); __ALLOCA_free(yyvs1,yyvsa); #ifdef YY_BParser_LSP_NEEDED yyls = (YY_BParser_LTYPE *) __ALLOCA_alloca (yystacksize * sizeof (*yylsp)); __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); __ALLOCA_free(yyls1,yylsa); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YY_BParser_LSP_NEEDED yylsp = yyls + size - 1; #endif #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Entering state %d\n", yystate); #endif YYGOTO(yybackup); YYLABEL(yybackup) /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* YYLABEL(yyresume) */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) YYGOTO(yydefault); /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (YY_BParser_CHAR == YYEMPTY) { #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Reading a token: "); #endif YY_BParser_CHAR = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (YY_BParser_CHAR <= 0) /* This means end of input. */ { yychar1 = 0; YY_BParser_CHAR = YYEOF; /* Don't call YYLEX any more */ #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(YY_BParser_CHAR); #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) { fprintf (stderr, "Next token is %d (%s", YY_BParser_CHAR, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, YY_BParser_CHAR, YY_BParser_LVAL); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) YYGOTO(yydefault); yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrlab); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrlab); if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Shifting token %d (%s), ", YY_BParser_CHAR, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (YY_BParser_CHAR != YYEOF) YY_BParser_CHAR = YYEMPTY; *++yyvsp = YY_BParser_LVAL; #ifdef YY_BParser_LSP_NEEDED *++yylsp = YY_BParser_LLOC; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; YYGOTO(yynewstate); /* Do the default action for the current state. */ YYLABEL(yydefault) yyn = yydefact[yystate]; if (yyn == 0) YYGOTO(yyerrlab); /* Do a reduction. yyn is the number of a rule to reduce with. */ YYLABEL(yyreduce) yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif #line 839 "/usr/share/bison++/bison.cc" switch (yyn) { case 19: #line 145 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addActionDef(yyvsp[0].form); ; break;} case 20: #line 146 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addActionDef(yyvsp[-2].form, yyvsp[0].types); ; break;} case 21: #line 150 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addFluentDef(yyvsp[0].form); ; break;} case 22: #line 151 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addFluentDef(yyvsp[-2].form, false, yyvsp[0].types); ; break;} case 23: #line 155 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addFluentDef(yyvsp[0].form, true); ; break;} case 24: #line 156 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addFluentDef(yyvsp[-2].form, true, yyvsp[0].types); ; break;} case 25: #line 160 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[0].form, NULL); ; break;} case 26: #line 161 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 27: #line 162 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 28: #line 163 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 29: #line 167 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[0].form, NULL); ; break;} case 30: #line 168 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 31: #line 169 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 32: #line 170 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addStaticRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 33: #line 174 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addDynamicRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 34: #line 175 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addDynamicRule(yyvsp[-4].form, yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 35: #line 176 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addDynamicRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].form); ; break;} case 36: #line 177 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addDynamicRule(yyvsp[-6].form, yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 37: #line 181 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addExecutableRule(yyvsp[0].form, NULL); ; break;} case 38: #line 182 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addExecutableRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 39: #line 183 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addExecutableRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 40: #line 184 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addExecutableRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 41: #line 188 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addNonexecutableRule(yyvsp[0].form, NULL); ; break;} case 42: #line 189 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addNonexecutableRule(yyvsp[-2].form, NULL, yyvsp[0].types); ; break;} case 43: #line 190 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addNonexecutableRule(yyvsp[-2].form, yyvsp[0].form); ; break;} case 44: #line 191 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addNonexecutableRule(yyvsp[-4].form, yyvsp[-2].form, yyvsp[0].types); ; break;} case 45: #line 195 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addInitiallyRule(yyvsp[0].form); ; break;} case 46: #line 196 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addInitiallyRule(yyvsp[-2].form, yyvsp[0].types); ; break;} case 47: #line 200 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("occ", yyvsp[-2].form, to_string(yyvsp[0].number)); ; break;} case 48: #line 201 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("occ", yyvsp[-2].form, *yyvsp[0].str); ; break;} case 49: #line 202 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("occ", yyvsp[-4].form, to_string(yyvsp[-2].number), yyvsp[0].types); ; break;} case 50: #line 203 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("occ", yyvsp[-4].form, *yyvsp[-2].str, yyvsp[0].types); ; break;} case 51: #line 207 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("holds", yyvsp[-2].form, to_string(yyvsp[0].number)); ; break;} case 52: #line 208 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("holds", yyvsp[-2].form, *yyvsp[0].str); ; break;} case 53: #line 209 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("holds", yyvsp[-4].form, to_string(yyvsp[-2].number), yyvsp[0].types); ; break;} case 54: #line 210 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("holds", yyvsp[-4].form, *yyvsp[-2].str, yyvsp[0].types); ; break;} case 55: #line 214 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("holds", yyvsp[0].form, "t"); ; break;} case 56: #line 215 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addQQuery("holds", yyvsp[-2].form, "t", yyvsp[0].types); ; break;} case 57: #line 219 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = program->addFormula('c', yyvsp[0].form); ; break;} case 58: #line 220 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = program->addFormula('c', new FluentAction(new string("0"))); ; break;} case 59: #line 221 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = program->addFormula('c', new Formula('n', new FluentAction(new string("0")))); ; break;} case 60: #line 222 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].form->addPart(yyvsp[0].form); yyval.form = yyvsp[-2].form; ; break;} case 61: #line 225 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = new FluentAction(yyvsp[0].str); ; break;} case 62: #line 226 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = new FluentAction(yyvsp[-3].str, yyvsp[-1].args); ; break;} case 63: #line 227 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = new Formula('n', new FluentAction(yyvsp[0].str)); ; break;} case 64: #line 228 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.form = new Formula('n', new FluentAction(yyvsp[-3].str, yyvsp[-1].args)); ; break;} case 65: #line 232 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.args = new Arguments(program->addVariable(yyvsp[0].str)); ; break;} case 66: #line 233 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.args = new Arguments(new Constant(yyvsp[0].str)); ; break;} case 67: #line 234 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.args = new Arguments(new Constant(yyvsp[0].number)); ; break;} case 68: #line 235 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.args = new Arguments(yyvsp[0].var_pool); ; break;} case 69: #line 236 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.args = new Arguments(yyvsp[0].interval); ; break;} case 70: #line 237 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.args = new Arguments(new Function(yyvsp[-3].str, yyvsp[-1].args->getArgs())); ; break;} case 71: #line 238 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].args->addVariable(program->addVariable(yyvsp[0].str)); yyval.args = yyvsp[-2].args; ; break;} case 72: #line 239 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].args->addConstant(new Constant(yyvsp[0].str)); yyval.args = yyvsp[-2].args; ; break;} case 73: #line 240 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].args->addConstant(new Constant(yyvsp[0].number)); yyval.args = yyvsp[-2].args; ; break;} case 74: #line 241 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].args->addPool(yyvsp[0].var_pool); yyval.args = yyvsp[-2].args; ; break;} case 75: #line 242 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].args->addInterval(yyvsp[0].interval); yyval.args = yyvsp[-2].args; ; break;} case 76: #line 243 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-5].args->addFunction(new Function(yyvsp[-3].str, yyvsp[-1].args->getArgs())); yyval.args = yyvsp[-5].args; ; break;} case 77: #line 247 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.var_pool = new Pool(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str)); ; break;} case 78: #line 248 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].var_pool->addVariable(program->addVariable(yyvsp[0].str)); yyval.var_pool = yyvsp[-2].var_pool; ; break;} case 79: #line 252 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.interval = new Interval(new Constant(yyvsp[-2].number), new Constant(yyvsp[0].number)); ; break;} case 80: #line 253 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.interval = new Interval(new Constant(yyvsp[-2].number), program->addVariable(yyvsp[0].str)); ; break;} case 81: #line 254 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.interval = new Interval(program->addVariable(yyvsp[-2].str), new Constant(yyvsp[0].number)); ; break;} case 82: #line 255 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.interval = new Interval(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str)); ; break;} case 83: #line 259 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.types = new Types(yyvsp[0].constr); ; break;} case 84: #line 260 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.types = new Types(yyvsp[0].typ); ; break;} case 85: #line 261 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[0].typ->setMin(yyvsp[-2].number); yyval.types = new Types(yyvsp[0].typ); ; break;} case 86: #line 262 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].typ->setMax(yyvsp[0].number); yyval.types = new Types(yyvsp[-2].typ); ; break;} case 87: #line 263 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].typ->setMin(yyvsp[-4].number); yyvsp[-2].typ->setMax(yyvsp[0].number); yyval.types = new Types(yyvsp[-2].typ); ; break;} case 88: #line 264 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].types->addType(yyvsp[0].constr); ; break;} case 89: #line 265 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].types->addType(yyvsp[0].typ); ; break;} case 90: #line 266 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[0].typ->setMin(yyvsp[-2].number); yyvsp[-4].types->addType(yyvsp[0].typ); ; break;} case 91: #line 267 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].typ->setMax(yyvsp[0].number); yyvsp[-4].types->addType(yyvsp[-2].typ); ; break;} case 92: #line 268 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].typ->setMin(yyvsp[-4].number); yyvsp[-2].typ->setMax(yyvsp[0].number); yyvsp[-6].types->addType(yyvsp[-2].typ); ; break;} case 93: #line 272 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.typ = new Type(yyvsp[-3].str, yyvsp[-1].args, true); ; break;} case 94: #line 273 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.typ = new Type(yyvsp[-3].str, yyvsp[-1].args, false); ; break;} case 95: #line 277 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].constr->merge(yyvsp[0].constr, yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 96: #line 278 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[0].constr->mergeLeft(new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str), yyvsp[-1].str); yyval.constr = yyvsp[0].constr; ; break;} case 97: #line 279 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+to_string(yyvsp[0].number)), yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 98: #line 280 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[0].constr->mergeLeft(new string(*yyvsp[-2].str+*yyvsp[-1].str), yyvsp[-1].str); yyval.constr = yyvsp[0].constr; ; break;} case 99: #line 281 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 100: #line 282 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[0].constr->mergeLeft(new string(*yyvsp[-2].str+*yyvsp[-1].str), program->addVariable(yyvsp[-2].str), yyvsp[-1].str); yyval.constr = yyvsp[0].constr; ; break;} case 101: #line 283 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+*yyvsp[0].str), program->addVariable(yyvsp[0].str), yyvsp[-1].str); yyval.constr = yyvsp[-2].constr; ; break;} case 102: #line 284 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 103: #line 285 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[0].str), new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 104: #line 286 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+to_string(yyvsp[0].number)), yyvsp[-1].str); ; break;} case 105: #line 287 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[0].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 106: #line 288 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 107: #line 289 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str+*yyvsp[0].str), yyvsp[-1].str); ; break;} case 108: #line 290 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(new string(*yyvsp[-2].str+*yyvsp[-1].str+to_string(yyvsp[0].number)), yyvsp[-1].str); ; break;} case 109: #line 294 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[0].str), new string(to_string(yyvsp[-2].number)+*yyvsp[-1].str+*yyvsp[0].str)); ; break;} case 110: #line 295 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+to_string(yyvsp[0].number))); ; break;} case 111: #line 296 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.constr = new Constraint(program->addVariable(yyvsp[-2].str), program->addVariable(yyvsp[0].str), new string(*yyvsp[-2].str+*yyvsp[-1].str+*yyvsp[0].str)); ; break;} case 112: #line 297 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+to_string(yyvsp[0].number))); yyval.constr = yyvsp[-2].constr; ; break;} case 113: #line 298 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyvsp[-2].constr->merge(new string(*yyvsp[-1].str+*yyvsp[0].str), program->addVariable(yyvsp[0].str)); yyval.constr = yyvsp[-2].constr; ; break;} case 114: #line 301 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("=="); ; break;} case 115: #line 302 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("!="); ; break;} case 116: #line 303 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("<"); ; break;} case 117: #line 304 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string(">"); ; break;} case 118: #line 305 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("<="); ; break;} case 119: #line 306 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string(">="); ; break;} case 120: #line 309 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("+"); ; break;} case 121: #line 310 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("-"); ; break;} case 122: #line 311 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("*"); ; break;} case 123: #line 312 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("/"); ; break;} case 124: #line 313 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string(" mod "); ; break;} case 125: #line 314 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("&"); ; break;} case 126: #line 315 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("?"); ; break;} case 127: #line 316 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.str = new string("^"); ; break;} case 128: #line 318 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { program->addLTLQuery(yyvsp[0].ltl_node); ; break;} case 129: #line 321 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(IDENTIFIER, NULL, NULL, yyvsp[0].form); ; break;} case 130: #line 322 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = yyvsp[-1].ltl_node; ; break;} case 131: #line 323 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(LTLNOT, NULL, yyvsp[0].ltl_node); ; break;} case 132: #line 324 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(AND, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 133: #line 325 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(LTLOR, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 134: #line 326 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(IMPL, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 135: #line 327 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(EQUIV, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 136: #line 328 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(X, NULL, yyvsp[0].ltl_node); ; break;} case 137: #line 329 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(G, NULL, yyvsp[0].ltl_node); ; break;} case 138: #line 330 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(F, NULL, yyvsp[0].ltl_node); ; break;} case 139: #line 331 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(U, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} case 140: #line 332 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" { yyval.ltl_node = program->getLTLNode(R, yyvsp[-2].ltl_node, yyvsp[0].ltl_node); ; break;} } #line 839 "/usr/share/bison++/bison.cc" /* the action file gets copied in in place of this dollarsign */ yyvsp -= yylen; yyssp -= yylen; #ifdef YY_BParser_LSP_NEEDED yylsp -= yylen; #endif #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YY_BParser_LSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = YY_BParser_LLOC.first_line; yylsp->first_column = YY_BParser_LLOC.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; YYGOTO(yynewstate); YYLABEL(yyerrlab) /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++YY_BParser_NERRS; #ifdef YY_BParser_ERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; msg = (char *) malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); if (count < 5) { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; } } YY_BParser_ERROR(msg); free(msg); } else YY_BParser_ERROR ("parse error; also virtual memory exceeded"); } else #endif /* YY_BParser_ERROR_VERBOSE */ YY_BParser_ERROR("parse error"); } YYGOTO(yyerrlab1); YYLABEL(yyerrlab1) /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (YY_BParser_CHAR == YYEOF) YYABORT; #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Discarding token %d (%s).\n", YY_BParser_CHAR, yytname[yychar1]); #endif YY_BParser_CHAR = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ YYGOTO(yyerrhandle); YYLABEL(yyerrdefault) /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) YYGOTO(yydefault); #endif YYLABEL(yyerrpop) /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YY_BParser_LSP_NEEDED yylsp--; #endif #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif YYLABEL(yyerrhandle) yyn = yypact[yystate]; if (yyn == YYFLAG) YYGOTO(yyerrdefault); yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) YYGOTO(yyerrdefault); yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrpop); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrpop); if (yyn == YYFINAL) YYACCEPT; #if YY_BParser_DEBUG != 0 if (YY_BParser_DEBUG_FLAG) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = YY_BParser_LVAL; #ifdef YY_BParser_LSP_NEEDED *++yylsp = YY_BParser_LLOC; #endif yystate = yyn; YYGOTO(yynewstate); /* end loop, in which YYGOTO may be used. */ YYENDGOTO } /* END */ #line 1038 "/usr/share/bison++/bison.cc" #line 335 "/home/tovok7/svn/potassco/coala/src/lib/b/Parser.y" /***************************************************************************************************************************/ void BParser::preProcessing(Coala::CompilerOptions* options) { program = new B::Program(options); program->setLine(&yylloc.first_line); } void BParser::postProcessing(Printer* p) { program->print(p); // delete program; } std::string BParser::to_string(int integer) { std::stringstream ss; std::string str; ss << integer; ss >> str; return str; } coala-1.0.1_src/src/lib/b/Compiler.cpp000644 001750 001750 00000005046 11477164507 020240 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Compiler.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Compiler.h" namespace B { Compiler::Compiler(Coala::CompilerOptions* options) { options_ = options; change_input(options_->getInputStream()); printer_ = new Printer(options_->getOutputStream(), options_->getDebug(), true, // always fake classical negation options_->getIncremental(), options_->getReverseIncremental(), !options_->getWhereCheck(), true, // we just have one encoding options_->getLanguage()); } Compiler::~Compiler() { } int Compiler::compile() { preProcessing(options_); int result = yyparse(); postProcessing(printer_); return result; } int Compiler::yylex() { int token = lexer.yylex(); if(token == IDENTIFIER) yylval.str = new string(lexer.YYText()); else if(token == NEG_IDENTI) { // remove leading negation sign '-' from fluent string *tmp_str = new string(lexer.YYText()); tmp_str->erase(0,1); yylval.str = tmp_str; } else if(token == VARIABLE) { yylval.str = new string(lexer.YYText()); } else if(token == NUMBER) yylval.number = atoi(lexer.YYText()); yylloc.first_line = lexer.lineno(); yylloc.last_line = lexer.lineno(); yylloc.text = (char *)lexer.YYText(); return token; } void Compiler::yyerror(char *m) { // if(yylloc.text == "\n") yylloc.text = (char*)"[newline]"; cerr << "\n\nError: Syntax error in line "<add("% fluent definition\n"); C::FluentDefinition::print(p, ltl); p->setSection('c'); for(vector::iterator n = F_->begin(); n != F_->end(); ++n) { FluentAction* f = (FluentAction*) *n; string fluent = f->print(p); set* vars = f->getVariables(); if(not defined_) { p->add("% inertial rules\n"); p->add("holds(" + fluent + ", " + p->T + ") :- "); p->add("holds(" + fluent + ", " + p->T + "-1), "); p->add("not holds(" + p->neg + fluent + ", " + p->T + ")"); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); p->add("holds(" + p->neg + fluent + ", " + p->T + ") :- "); p->add("holds(" + p->neg + fluent + ", " + p->T + "-1), "); p->add("not holds(" + fluent + ", " + p->T + ")"); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); } // print the constraint twice: for T=0 and T>0 for(int i = 1; i <= 2; ++i) { string T; if(i == 1) { p->setSection('b'); T = "0"; } else { p->setSection('c'); T = p->T; } if(defined_) { p->add("\n% Closed world assumptions for defined fluent\n"); p->add("holds(" + p->neg + fluent + ", " + T + ") :- "); p->add("not holds(" + fluent + ", " + T + ")"); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); } p->add("\n% exclusivity constraint\n"); p->add(":- holds(" + fluent + ", " + T + "), "); p->add("holds(" + p->neg + fluent + ", " + T + ")"); if(!vars->empty()) { p->add(", "); types_.print(p, vars, line_); } p->add(".\n"); } } } coala-1.0.1_src/src/lib/b/Printer.cpp000644 001750 001750 00000004315 11477164507 020107 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/Printer.cpp - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "Printer.h" using namespace B; B::Printer::Printer(std::ostream* output_stream, int debug_level, bool fake_negation, bool incremental, bool reverse, bool no_where_check, bool no_dir_enc, string language) : C::Printer(output_stream, debug_level, fake_negation, incremental, reverse, no_where_check, no_dir_enc, language) { } B::Printer::~Printer() { } void B::Printer::printEncoding() { b << "\n%\n% Domain independent rules\n%\n"; // #base. // % Guess initial state // b << "1 { holds(F,0), holds(neg(F),0) } 1 :- fluent(F).\n"; // #cumulative t. // % generation of action occurences // c << "occ(A, "+T+"-1) :- action(A), possible(A, "+T+"-1), not nocc(A, "+T+"-1).\n"; // c << "nocc(A, "+T+"-1) :- action(A), action(B), occ(B, "+T+"-1), A!=B.\n"; c << "0 { occ(A, "+T+"-1) : action(A) } 1.\n"; c << ":- occ(A, "+T+"-1), not possible(A, "+T+"-1), action(A).\n"; c << ":- not occ(A, "+T+"-1), possible(A, "+T+"-1), action(A), not occ(B, "+T+"-1) : action(B).\n"; // hide everything except actions and fluents if(debug < 3) b << "#hide.\n"; b << "#show occ(X1,T).\n"; if(debug > 0) b << "#show holds(X1,T).\n"; } coala-1.0.1_src/src/lib/b/StaticRule.h000644 001750 001750 00000002750 11477164507 020211 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/b/StaticRule.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef BSTATICRULE_H #define BSTATICRULE_H #include "../c/StaticRule.h" #include "../c/Statement.h" #include #include namespace B { using namespace C; class StaticRule : public C::StaticRule { public: StaticRule(int line, Formula* F, Formula* G, Types* types=NULL); virtual ~StaticRule ( ); void printDirect(Printer* p); void printNonDirect(Printer* p); }; }; // end of package namespace #endif // BSTATICRULE_H coala-1.0.1_src/src/lib/options.cpp000644 001750 001750 00000006235 11477164507 017741 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/options.cpp - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #include "options.h" namespace Coala { CompilerOptions::CompilerOptions() { language_ = "c"; fakeClassicalNegation_ = false; debug_ = 0; directEncoding_ = false; incremental_ = false; reverseIncremental_ = false; whereCheck_ = true; } CompilerOptions::~CompilerOptions() { } bool CompilerOptions::checkOptions() { if(language_ == "c_taid") { if(!directEncoding_ || incremental_ || reverseIncremental_) return false; else return true; } else if(language_ == "c" || language_ == "m") { if(!directEncoding_ && language_ == "m") return false; else if(directEncoding_ && reverseIncremental_) return false; else return true; } else return true; } void CompilerOptions::setLanguage(string language) { language_ = language; } string CompilerOptions::getLanguage() { return language_; } void CompilerOptions::setInputStream(istream& inputStream) { inputStream_ = &inputStream; } istream* CompilerOptions::getInputStream() { return inputStream_; } void CompilerOptions::setOutputStream(ostream& outputStream) { outputStream_ = &outputStream; } ostream* CompilerOptions::getOutputStream() { return outputStream_; } void CompilerOptions::setFakeClassicalNegation(bool fakeClassicalNegation) { fakeClassicalNegation_ = fakeClassicalNegation; } bool CompilerOptions::getFakeClassicalNegation() { return fakeClassicalNegation_; } void CompilerOptions::setDebug(int debug) { debug_ = debug; } int CompilerOptions::getDebug() { return debug_; } void CompilerOptions::setDirectEncoding(bool directEncoding) { directEncoding_ = directEncoding; } bool CompilerOptions::getDirectEncoding() { return directEncoding_; } void CompilerOptions::setIncremental(bool incremental) { incremental_ = incremental; } bool CompilerOptions::getIncremental() { return incremental_; } void CompilerOptions::setReverseIncremental(bool reverseIncremental) { reverseIncremental_ = reverseIncremental; } bool CompilerOptions::getReverseIncremental() { return reverseIncremental_; } void CompilerOptions::setWhereCheck(bool whereCheck) { whereCheck_ = whereCheck; } bool CompilerOptions::getWhereCheck() { return whereCheck_; } }; coala-1.0.1_src/src/lib/CMakeLists.txt000644 001750 001750 00000000700 11477164507 020271 0ustar00tovok7tovok7000000 000000 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules") IF(USE_FLEX_BISON) SET(BISON_GENERATE_DEFINES TRUE) INCLUDE(UseFlex) INCLUDE(UseBison++) ENDIF(USE_FLEX_BISON) ADD_LIBRARY(coala-lib STATIC main.cpp options.cpp) TARGET_LINK_LIBRARIES(coala-lib coala-c-lib coala-b-lib coala-c_taid-lib) SET_TARGET_PROPERTIES(coala-lib PROPERTIES OUTPUT_NAME coala) ADD_SUBDIRECTORY(c) ADD_SUBDIRECTORY(b) ADD_SUBDIRECTORY(c_taid) coala-1.0.1_src/src/lib/main.h000644 001750 001750 00000003334 11477164507 016634 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * lib/main.h - This file is part of coala * * * * Copyright (C) 2009 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef MAIN_H #define MAIN_H #include #include #include "options.h" using namespace std; namespace Coala { class AbstractCompiler { public: virtual int compile() = 0; }; class Compiler : public AbstractCompiler { public: Compiler(); virtual ~Compiler(); int compile(); void setLanguage(string); void setInputStream(istream&); void setOutputStream(ostream&); void setFakeClassicalNegation(bool); void setDebug(int); void setDirectEncoding(bool); void setIncremental(bool); void setReverseIncremental(bool); void setWhereCheck(bool); private: AbstractCompiler* compiler_; CompilerOptions* options_; }; }; #endif // MAIN_H coala-1.0.1_src/src/app/options.h000644 001750 001750 00000004073 11477164507 017416 0ustar00tovok7tovok7000000 000000 /**************************************************************************** * app/options.h - This file is part of coala * * * * Copyright (C) 2009-2010 Torsten Grote * * * * 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 3 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, see http://www.gnu.org/licenses * ****************************************************************************/ #ifndef COALA_OPTIONS_H_INCLUDED #define COALA_OPTIONS_H_INCLUDED #include #include "program_opts/program_options.h" const char* const VERSION = "1.0.1"; namespace Coala { class Options { public: Options(); virtual ~Options(); void setDefaults(); bool parse(int argc, char** argv, std::ostream& os); const std::string& getError() const { return error_; } const std::string getWarning() const { return warning_; } std::string language; bool fake_class_neg; int debug; bool no_direct_enc; bool incremental; bool reverse; bool no_where_check; bool version; bool help; std::vector input; // list of files private: void initOptions(ProgramOptions::OptionGroup& allOpts, ProgramOptions::OptionGroup& hidden); void checkCommonOptions(const ProgramOptions::OptionValues&); void printHelp(const ProgramOptions::OptionGroup& opts, std::ostream& os) const; void printVersion(const ProgramOptions::OptionGroup& opts, std::ostream& os) const; std::string error_; std::string warning_; }; } #endif coala-1.0.1_src/src/app/program_opts/detail/smartpointer.h000644 001750 001750 00000015362 11477164507 024433 0ustar00tovok7tovok7000000 000000 // scaled down version of Jean Gressmann's smartpointer.h /* Copyright (c) October 2004 Jean Gressmann (jsg@rz.uni-potsdam.de) * * This 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 file 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 file; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef PROGRAM_OPTIONS_DETAIL_SMARTPOINTER_H #define PROGRAM_OPTIONS_DETAIL_SMARTPOINTER_H #if defined(_MSC_VER) # define for if(0);else for # pragma warning(disable:4521) # pragma warning(disable:4786) # pragma warning(disable:4522) # pragma warning(disable:4355) # pragma warning(disable:4291) #endif #include #include namespace ProgramOptions { // Thanks to Benjamin Kaufmann (kaufmann@cs.uni-potsdam.de) // who provided for compile time assertions for void pointers template struct StaticAssert; template <> struct StaticAssert {}; template struct is_void {enum {result = 0};}; template <> struct is_void {enum {result = 1};}; // These freeResource() functions are required to handle their // specific Null indifferently, say delete 0 is // to do nothing. template struct PointerTraits_ { StaticAssert::result> Error_Smart_Pointer_Does_Not_Support_Void_Ptr; typedef T ValueType; typedef T& ReferenceType; typedef const T& ConstReferenceType; typedef T* PointerType; typedef const T* ConstPointerType; static const PointerType Null; static void freeResource(PointerType p) { enum { no_incomplete_types_please = sizeof(*p) }; delete p; } }; template const typename PointerTraits_::PointerType PointerTraits_::Null = 0; // reference counting based on a shared counter template class ReferenceCountedOwner_ { public: typedef typename Traits::PointerType PT; typedef typename Traits::ConstPointerType CPT; static CPT null() { return Traits::Null; } private: class RefCount_ { PT managed_; size_t count_; RefCount_(); RefCount_(const RefCount_&); RefCount_& operator=(const RefCount_&); public: explicit RefCount_(PT p) : managed_(p) , count_(1) {} inline void inc() { ++count_; } inline size_t count() const { return count_; } inline bool unique() const { return count_ == 1; } void dec() { --count_; if(!count_) { PT deleteme = managed_; delete this; Traits::freeResource(deleteme); } } void weakDec() { --count_; if(!count_) { delete this; } } inline PT get() { return managed_; } inline CPT get() const { return managed_; } }; RefCount_* refCount_; void decIfValidRefCount() { if(refCount_) { RefCount_* temp = 0; std::swap(temp, refCount_); temp->dec(); } } inline void incIfValidRefCount() // nothrow guarantee { if(refCount_) refCount_->inc(); } inline static RefCount_* createRefCount(PT p) { return p == Traits::Null ? 0 : new RefCount_(p); } public: ~ReferenceCountedOwner_() { decIfValidRefCount(); } explicit ReferenceCountedOwner_() : refCount_(0) {} ReferenceCountedOwner_(PT p) : refCount_(createRefCount(p)) {} ReferenceCountedOwner_(const ReferenceCountedOwner_& o) : refCount_(o.refCount_) { incIfValidRefCount(); } inline ReferenceCountedOwner_& operator=(const ReferenceCountedOwner_& o) { ReferenceCountedOwner_(o).swap(*this); return *this; } inline ReferenceCountedOwner_& operator=(PT p) { ReferenceCountedOwner_(p).swap(*this); return *this; } inline bool unique() const { return refCount_ ? refCount_->unique() : true; } // nothrow guarantee inline size_t count() const { return refCount_ ? refCount_->count() : 1; } // nothrow guarantee inline PT get() { return refCount_ ? refCount_->get() : Traits::Null; } inline CPT get() const { return refCount_ ? refCount_->get() : Traits::Null; } inline void swap(ReferenceCountedOwner_& o) // nothrow guarantee { std::swap(refCount_, o.refCount_); } inline void reset() { ReferenceCountedOwner_().swap(*this); } inline void release() { if(refCount_) refCount_->weakDec(); refCount_ = 0; } }; template < class T, class Traits = PointerTraits_, class RefCountPolicy = ReferenceCountedOwner_ > class SmartPointer : public RefCountPolicy { public: typedef typename Traits::PointerType PT; typedef typename Traits::ConstPointerType CPT; typedef typename Traits::ReferenceType RT; typedef typename Traits::ConstReferenceType CRT; explicit SmartPointer() {} explicit SmartPointer(PT p) : RefCountPolicy(p) {} SmartPointer(const SmartPointer& o) : RefCountPolicy(o) {} SmartPointer(SmartPointer& o) : RefCountPolicy(o) {} inline SmartPointer& operator=(SmartPointer& o) { RefCountPolicy::operator=(o); return *this; } inline SmartPointer& operator=(const SmartPointer& o) { RefCountPolicy::operator=(o); return *this; } inline SmartPointer& operator=(PT p) { RefCountPolicy::operator=(p); return *this; } inline bool operator==(const SmartPointer& o) const { return this->get() == o.get(); } inline bool operator!=(const SmartPointer& o) const { return this->get() != o.get(); } inline operator bool() const { return this->get() != Traits::Null; } inline PT operator->() { return this->get(); } inline CPT operator->() const { return this->get(); } inline RT operator*() { return *this->get(); } inline CRT operator*() const { return *this->get(); } }; template > class SharedPtr : public SmartPointer > { typedef SmartPointer > Base; typedef typename Base::PT PT; public: explicit SharedPtr() : Base() {} SharedPtr(PT p) : Base(p) {} SharedPtr(const SharedPtr& o) : Base(o) {} inline SharedPtr& operator=(PT p) { Base::operator=(p); return *this; } inline SharedPtr& operator=(const SharedPtr& o) { Base::operator=(o); return *this; } }; } #endif coala-1.0.1_src/src/app/program_opts/errors.h000644 001750 001750 00000005777 11477164507 021767 0ustar00tovok7tovok7000000 000000 // // Copyright (c) Benjamin Kaufmann 2004 // // This 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 file 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 file; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // NOTE: ProgramOptions is inspired by Boost.Program_options // see: www.boost.org/libs/program_options // #ifndef PROGRAM_OPTIONS_ERRORS_H_INCLUDED #define PROGRAM_OPTIONS_ERRORS_H_INCLUDED #include namespace ProgramOptions { //! thrown when a value has an unexpected type class BadValue : public std::logic_error { public: BadValue(const std::string& msg) : std::logic_error(msg) {} ~BadValue() throw () {} std::string getOptionName() const { return optionName_; } private: std::string optionName_; }; //! thrown when an option has an illegal name class BadOptionName : public std::logic_error { public: BadOptionName(const std::string& name) : std::logic_error(std::string("bad option name: ").append(name)) {} ~BadOptionName() throw () {} }; //! thrown when more than one option in a group has the same name class DuplicateOption : public std::logic_error { public: DuplicateOption(const std::string& name, const std::string& grp) : std::logic_error(grp + " - " + "Duplicate Option: '" + name + "'") , name_(name) , grpDesc_(grp) {} const std::string& getOptionName() const {return name_;} const std::string& getGroupName() const {return grpDesc_;} ~DuplicateOption() throw() {} private: const std::string name_; const std::string grpDesc_; }; //! thrown when an unknown option is requested class UnknownOption : public std::logic_error { public: UnknownOption(const std::string& name) : std::logic_error(std::string("unknown option: ").append(name)) {} ~UnknownOption() throw() {} }; //! thrown when there's ambiguity amoung several possible options. class AmbiguousOption : public std::logic_error { public: AmbiguousOption(const std::string& optname) : std::logic_error(std::string("ambiguous option: ").append(optname)) {} ~AmbiguousOption() throw () {} }; //! thrown when there are several occurrences of an option in one source class MultipleOccurences : public std::logic_error { public: MultipleOccurences(const std::string& opt) : std::logic_error(std::string("multiple occurences: ").append(opt)) {} ~MultipleOccurences() throw () {} }; } #endif coala-1.0.1_src/src/app/program_opts/value_base.h000644 001750 001750 00000004322 11477164507 022542 0ustar00tovok7tovok7000000 000000 // // Copyright (c) Benjamin Kaufmann 2004 // // This 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 file 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 file; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // NOTE: ProgramOptions is inspired by Boost.Program_options // see: www.boost.org/libs/program_options // #ifndef PROGRAM_OPTIONS_VALUE_BASE_H_INCLUDED #define PROGRAM_OPTIONS_VALUE_BASE_H_INCLUDED #ifdef _MSC_VER #pragma warning (disable : 4786) #pragma warning (disable : 4503) #endif #include namespace ProgramOptions { //! base class for values of options class ValueBase { protected: ValueBase(); public: virtual ~ValueBase() = 0; //! returns true if the object already stores a value virtual bool hasValue() const = 0; //! returns true if the value of the option is implicit /*! * this property is only meaningful for command line options. * An implicit option is a flag, i.e an option that does not * expect an explicit value. * Example: --help or --version */ virtual bool isImplicit() const = 0; //! returns true if the value of this option can be composed from multiple source virtual bool isComposing() const = 0; //! returns true if the value currently holds its default value virtual bool isDefaulted() const = 0; //! sets the value's default value as value. /*! * \return true if the default value was set */ virtual bool applyDefault() = 0; //! Parses the given string and stores the result in this value. /*! * \return * - true if the given string contains a valid value * - false otherwise */ virtual bool parse(const std::string&) = 0; }; } #endif coala-1.0.1_src/src/app/program_opts/program_options.cpp000644 001750 001750 00000045076 11477164507 024224 0ustar00tovok7tovok7000000 000000 // // Copyright (c) Benjamin Kaufmann 2004 // // This 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 file 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 file; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // NOTE: ProgramOptions is inspired by Boost.Program_options // see: www.boost.org/libs/program_options // #ifdef _MSC_VER #pragma warning (disable : 4786) #pragma warning (disable : 4503) #endif #include "program_options.h" #include "errors.h" #include #include #include #include #include using namespace std; namespace ProgramOptions { namespace { void defaultFormat(std::ostream& os, const ProgramOptions::Option& o) { stringstream temp; temp << " "; if (!o.shortName().empty()) { temp << "-" << o.shortName() << ", "; } temp << "--" << o.longName(); if (!o.getValue()->isImplicit()) temp << '=' << o.argDescription(); os << temp.str(); if (!o.description().empty()) { if (temp.str().size() < size_t(27)) { for(size_t pad = 27 - temp.str().size(); pad > 0; --pad) { os.put(' '); } } os << "" << o.description(); } } } /////////////////////////////////////////////////////////////////////////////// // class ValueBase /////////////////////////////////////////////////////////////////////////////// ValueBase::ValueBase() {} ValueBase::~ValueBase() {} /////////////////////////////////////////////////////////////////////////////// // class Option /////////////////////////////////////////////////////////////////////////////// Option::Option(const string& longName, const string& shortName, const string& desc, const std::string& argDesc, ValueBase* v) : longName_(longName) , shortName_(shortName) , description_(desc) , argDesc_(argDesc) , value_(v) { assert(v); assert(!longName.empty()); } Option::~Option() {} /////////////////////////////////////////////////////////////////////////////// // class OptionGroup /////////////////////////////////////////////////////////////////////////////// OptionGroup::OptionGroup(const std::string& description) : size_(0) { options_.push_back(GroupOptions()); options_[0].first = description; } OptionGroup::~OptionGroup() {} OptionGroupInitHelper OptionGroup::addOptions() { return OptionGroupInitHelper(this); } OptionGroup& OptionGroup::addOptions(const OptionGroup& other) { if (this != &other) { for (std::size_t i = 0; i != other.options_.size(); ++i) { Options::size_type ng = options_.size(); options_.push_back(GroupOptions()); options_[ng].first = other.options_[i].first; for (std::size_t j = 0; j != other.options_[i].second.size(); ++j) { insertOption(other.options_[i].second[j], ng); } } } return *this; } // THROW: DuplicateOption if an option with the same short or long name // already exists. void OptionGroup::addOption(auto_ptr