# HG changeset patch
# User Edouard Tisserant
# Date 1301930375 -7200
# Node ID 579db02bebd91a196f0f60d6a41c6cb3d2d37af0
# Parent 4f281513277f2c9a66b072edad9c40bfbff0bc72# Parent 86ef2244aef1e0350de5145d43d13c7af6502d4f
Merge
diff -r 86ef2244aef1 -r 579db02bebd9 COPYING
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/COPYING Mon Apr 04 17:19:35 2011 +0200
@@ -0,0 +1,674 @@
+ 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
+.
diff -r 86ef2244aef1 -r 579db02bebd9 Makefile
--- a/Makefile Fri Apr 01 17:26:29 2011 +0200
+++ b/Makefile Mon Apr 04 17:19:35 2011 +0200
@@ -24,7 +24,7 @@
-rm -f iec2iec iec2c *.o absyntax/*.o
echo > Makefile.depend
# make something everywhere (ie, in all Makefiles that have that target)
- find . -depth -mindepth 2 -maxdepth 2 -name Makefile -printf %h\\n | xargs -i make -C{} $@
+ find . -depth -mindepth 2 -maxdepth 2 -name Makefile | sed 's/Makefile//g' | xargs -I {} make -C{} clean
CXXFLAGS += -I.
diff -r 86ef2244aef1 -r 579db02bebd9 Makefile.Darwin
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.Darwin Mon Apr 04 17:19:35 2011 +0200
@@ -0,0 +1,17 @@
+#CXX = i686-mingw32-c++
+CXX = g++
+
+#get warnings, debugging information and optimization
+CFLAGS = -Wall -Wpointer-arith -Wwrite-strings
+# CFLAGS += -Werror
+CFLAGS += -ggdb
+#CFLAGS += -O3 -funroll-loops
+# Note: if the optimizer crashes, we'll leave out the -O3 for those files
+
+#get warnings, debugging information and optimization
+#CXXFLAGS = -Wall -pedantic -Wpointer-arith -Wwrite-strings
+#CXXFLAGS += -ggdb
+#CXXFLAGS += -O3 -funroll-loops
+CXXFLAGS = $(CFLAGS)
+
+IECLIBDIR=lib
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax/absyntax.cc
--- a/absyntax/absyntax.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax/absyntax.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,27 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax/absyntax.def
--- a/absyntax/absyntax.def Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax/absyntax.def Mon Apr 04 17:19:35 2011 +0200
@@ -1,27 +1,34 @@
/*
- * (c) 2003-2007 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
*
*/
+
/*
* Definition of the Abstract Syntax data structure components
*/
@@ -46,7 +53,7 @@
/*****************************************************************/
/*****************************************************************/
/* */
-/* Symbols defined in: */
+/* safe Symbols are defined in: */
/* PLCopen - Technical Committee 5 */
/* Safety Software Technical Specification, */
/* Part 1: Concepts and Function Blocks, */
@@ -60,10 +67,6 @@
-SYM_REF0(safebool_type_name_c)
-
-
-
/*****************************************************************/
@@ -93,11 +96,14 @@
SYM_REF0(eno_param_c)
*/
-/***************************/
-/* 2.1.6 - Pragmas */
-/***************************/
+/********************/
+/* 2.1.6 - Pragmas */
+/********************/
+SYM_REF0(disable_code_generation_pragma_c)
+SYM_REF0(enable_code_generation_pragma_c)
SYM_TOKEN(pragma_c)
+
/***************************/
/* B 0 - Programming Model */
/***************************/
@@ -129,14 +135,59 @@
/* Note:
* We do not have signed_integer_c and signed_real_c classes.
* These are stored in the parse tree as a integer_c or real_c
- * preceded by a unary minus operator.
+ * preceded by a unary minus operator if they are inside an expression,
+ * or a neg_integer_c and neg_real_c when used outside an ST expression.
*/
/* Not required:
SYM_TOKEN(signed_integer_c)
SYM_TOKEN(signed_real_c)
*/
-SYM_REF1(neg_literal_c, exp)
+/* NOTE: literal __values__ are stored directly in classes such as:
+ * - real_c
+ * - integer_c
+ * - binary_integer_c
+ * - etc...
+ *
+ * However, for both the real_c and the integer_c, if they are preceded
+ * by a '-' negation sign, they are further encapsulated inside
+ * a neg_literal_c (i.e. the neg_literal_c will point to the
+ * real_c or integer_c with the value being negated.
+ * neg_literal_c -> integer_literal_c
+ * OR
+ * neg_literal_c -> real_literal_c
+ *
+ * In the semantic verification and code generation stages of the compiler,
+ * the integer_c is treated as a basic (undefined) data type, since an integer
+ * constant may be used as a BYTE, BOOLEAN, REAL, etc..., depending on the
+ * context in which it is used.
+ * However, an integer_c that is preceded by a '-' may not be used
+ * as an ANY_BIT data type (BYTE, BOOLEAN, WORD, ...).
+ * We must therefore be able to determine, holding a simple pointer
+ * to an integer_c, if that integer_c value is preceded by a '-'.
+ * However, since the neg_literal_c points to the integer_c, and not
+ * vice-versa, we can't determine that.
+ * There are 3 simple ways of working around this:
+ * - change the order of the pointers:
+ * have the integer_c and real_c point to the neg_literal_c
+ * - maintain the order of the pointers, and
+ * add redundant info to the integer_c and real_c
+ * - replace the neg_literal_c with two distinc classes
+ * (neg_integer_c and neg_real_c), one for each
+ * lietral type. This means that we can now treat
+ * each of these classes as an unknown data type
+ * just as we do with the integer_c and real_c.
+ *
+ * The second option is simply ugly.
+ * and the first has a serious drawback: when generating code it is
+ * easier to encapsulate the real or integer values inside prefix
+ * and postfix symbols (e.g. NEG() - with postfix ')' )
+ * if we keep the pointer order as is.
+ *
+ * For the above reasoning, we use the third option.
+ */
+SYM_REF1(neg_real_c, exp)
+SYM_REF1(neg_integer_c, exp)
/* Not required:
SYM_REF2(numeric_literal_c, type, value)
@@ -144,6 +195,8 @@
SYM_REF2(integer_literal_c, type, value)
SYM_REF2(real_literal_c, type, value)
SYM_REF2(bit_string_literal_c, type, value)
+/* A typed or untyped boolean literal... */
+/* type may be NULL */
SYM_REF2(boolean_literal_c, type, value)
/* helper class for boolean_literal_c */
@@ -168,7 +221,7 @@
/* B 1.2.3.1 - Duration */
/************************/
SYM_REF0(neg_time_c)
-SYM_REF2(duration_c, neg, interval)
+SYM_REF3(duration_c, type_name, neg, interval)
SYM_TOKEN(fixed_point_c)
SYM_REF2(days_c, days, hours)
SYM_REF2(hours_c, hours, minutes)
@@ -180,11 +233,11 @@
/************************************/
/* B 1.2.3.2 - Time of day and Date */
/************************************/
-SYM_REF1(time_of_day_c, daytime)
+SYM_REF2(time_of_day_c, type_name, daytime)
SYM_REF3(daytime_c, day_hour, day_minute, day_second)
-SYM_REF1(date_c, date_literal)
+SYM_REF2(date_c, type_name, date_literal)
SYM_REF3(date_literal_c, year, month, day)
-SYM_REF2(date_and_time_c, date_literal, daytime)
+SYM_REF3(date_and_time_c, type_name, date_literal, daytime)
/**********************/
@@ -215,10 +268,31 @@
SYM_REF0(string_type_name_c)
SYM_REF0(wstring_type_name_c)
-/*
-SYM_REF0(constant_int_type_name_c)
-SYM_REF0(constant_real_type_name_c)
-*/
+ /*****************************************************************/
+ /* Keywords defined in "Safety Software Technical Specification" */
+ /*****************************************************************/
+
+SYM_REF0(safetime_type_name_c)
+SYM_REF0(safebool_type_name_c)
+SYM_REF0(safesint_type_name_c)
+SYM_REF0(safeint_type_name_c)
+SYM_REF0(safedint_type_name_c)
+SYM_REF0(safelint_type_name_c)
+SYM_REF0(safeusint_type_name_c)
+SYM_REF0(safeuint_type_name_c)
+SYM_REF0(safeudint_type_name_c)
+SYM_REF0(safeulint_type_name_c)
+SYM_REF0(safereal_type_name_c)
+SYM_REF0(safelreal_type_name_c)
+SYM_REF0(safedate_type_name_c)
+SYM_REF0(safetod_type_name_c)
+SYM_REF0(safedt_type_name_c)
+SYM_REF0(safebyte_type_name_c)
+SYM_REF0(safeword_type_name_c)
+SYM_REF0(safedword_type_name_c)
+SYM_REF0(safelword_type_name_c)
+SYM_REF0(safestring_type_name_c)
+SYM_REF0(safewstring_type_name_c)
/********************************/
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax/absyntax.hh
--- a/absyntax/absyntax.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax/absyntax.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,27 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax/visitor.cc
--- a/absyntax/visitor.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax/visitor.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,27 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax/visitor.hh
--- a/absyntax/visitor.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax/visitor.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,27 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/absyntax_utils.cc
--- a/absyntax_utils/absyntax_utils.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/absyntax_utils.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/absyntax_utils.hh
--- a/absyntax_utils/absyntax_utils.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/absyntax_utils.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/add_en_eno_param_decl.cc
--- a/absyntax_utils/add_en_eno_param_decl.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/add_en_eno_param_decl.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/add_en_eno_param_decl.hh
--- a/absyntax_utils/add_en_eno_param_decl.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/add_en_eno_param_decl.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/decompose_var_instance_name.cc
--- a/absyntax_utils/decompose_var_instance_name.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/decompose_var_instance_name.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/decompose_var_instance_name.hh
--- a/absyntax_utils/decompose_var_instance_name.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/decompose_var_instance_name.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_call_iterator.cc
--- a/absyntax_utils/function_call_iterator.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_call_iterator.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_call_iterator.hh
--- a/absyntax_utils/function_call_iterator.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_call_iterator.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_call_param_iterator.cc
--- a/absyntax_utils/function_call_param_iterator.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_call_param_iterator.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_call_param_iterator.hh
--- a/absyntax_utils/function_call_param_iterator.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_call_param_iterator.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_param_iterator.cc
--- a/absyntax_utils/function_param_iterator.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_param_iterator.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_param_iterator.hh
--- a/absyntax_utils/function_param_iterator.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_param_iterator.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/function_type_decl.h
--- a/absyntax_utils/function_type_decl.h Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/function_type_decl.h Mon Apr 04 17:19:35 2011 +0200
@@ -1,19 +1,27 @@
/*
- * (c) 2008 Edouard TISSERANT
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2008 Edouard TISSERANT
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
+
/*
* An IEC 61131-3 IL and ST compiler.
*
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/get_function_type.cc
--- a/absyntax_utils/get_function_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/get_function_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,19 +1,27 @@
/*
- * (c) 2008 Edouard TISSERANT
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2008 Edouard TISSERANT
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
+
/*
* An IEC 61131-3 IL and ST compiler.
*
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/get_function_type.h
--- a/absyntax_utils/get_function_type.h Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/get_function_type.h Mon Apr 04 17:19:35 2011 +0200
@@ -1,19 +1,27 @@
/*
- * (c) 2008 Edouard TISSERANT
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2008 Edouard TISSERANT
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
+
/*
* An IEC 61131-3 IL and ST compiler.
*
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/get_function_type_decl.c
--- a/absyntax_utils/get_function_type_decl.c Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/get_function_type_decl.c Mon Apr 04 17:19:35 2011 +0200
@@ -1,19 +1,27 @@
/*
- * (c) 2008 Edouard TISSERANT
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2008 Edouard TISSERANT
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
+
/*
* An IEC 61131-3 IL and ST compiler.
*
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/get_sizeof_datatype.cc
--- a/absyntax_utils/get_sizeof_datatype.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/get_sizeof_datatype.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -147,14 +154,19 @@
* If 'x' were a SINT, then the '30' would have to be a SINT too!
*/
-/* NOTE: all integer and real literal tokens will always be positive (i.e. no leading '-')
+/* NOTE: all integer_c and real_c tokens will always be positive (i.e. no leading '-')
* due to the way the source code is parsed by iec.flex.
*/
void *get_sizeof_datatype_c::visit(real_c *symbol) {
return _encode_int(32);
}
-/* NOTE: all integer and real literal tokens will always be positive (i.e. no leading '-')
+void *get_sizeof_datatype_c::visit(neg_real_c *symbol) {
+ return symbol->exp->accept(*this);
+}
+
+
+/* NOTE: all integer_c and real_c literal tokens will always be positive (i.e. no leading '-')
* due to the way the source code is parsed by iec.flex.
*/
void *get_sizeof_datatype_c::visit(integer_c *symbol) {
@@ -224,8 +236,13 @@
}
-/* NOTE: all integer and real literal tokens will always be positive (i.e. no leading '-')
- * due to the way the source code is parsed by iec.flex.
+void *get_sizeof_datatype_c::visit(neg_integer_c *symbol) {
+ return symbol->exp->accept(*this);
+}
+
+
+/* NOTE: all binary_integer_c tokens will always be positive (i.e. no leading '-')
+ * due to the syntax definition of IEC 61131-3.
*/
void *get_sizeof_datatype_c::visit(binary_integer_c *symbol) {
const char *sval = symbol->value;
@@ -255,8 +272,8 @@
}
-/* NOTE: all integer and real literal tokens will always be positive (i.e. no leading '-')
- * due to the way the source code is parsed by iec.flex.
+/* NOTE: all octal_integer_c tokens will always be positive (i.e. no leading '-')
+ * due to the syntax definition of IEC 61131-3.
*/
void *get_sizeof_datatype_c::visit(octal_integer_c *symbol) {
const char *sval = symbol->value;
@@ -287,8 +304,8 @@
}
-/* NOTE: all integer and real literal tokens will always be positive (i.e. no leading '-')
- * due to the way the source code is parsed by iec.flex.
+/* NOTE: all hex_integer_c tokens will always be positive (i.e. no leading '-')
+ * due to the syntax definition of IEC 61131-3.
*/
void *get_sizeof_datatype_c::visit(hex_integer_c *symbol) {
const char *sval = symbol->value;
@@ -327,27 +344,27 @@
/***********************************/
/* B 1.3.1 - Elementary Data Types */
/***********************************/
-// void *get_sizeof_datatype_c::visit(time_type_name_c *symbol) {return _encode_int(0); }
-void *get_sizeof_datatype_c::visit(bool_type_name_c *symbol) {return _encode_int(1); }
-void *get_sizeof_datatype_c::visit(sint_type_name_c *symbol) {return _encode_int(8); }
-void *get_sizeof_datatype_c::visit(int_type_name_c *symbol) {return _encode_int(16);}
-void *get_sizeof_datatype_c::visit(dint_type_name_c *symbol) {return _encode_int(32);}
-void *get_sizeof_datatype_c::visit(lint_type_name_c *symbol) {return _encode_int(64);}
-void *get_sizeof_datatype_c::visit(usint_type_name_c *symbol) {return _encode_int(8); }
-void *get_sizeof_datatype_c::visit(uint_type_name_c *symbol) {return _encode_int(16);}
-void *get_sizeof_datatype_c::visit(udint_type_name_c *symbol) {return _encode_int(32);}
-void *get_sizeof_datatype_c::visit(ulint_type_name_c *symbol) {return _encode_int(64);}
-void *get_sizeof_datatype_c::visit(real_type_name_c *symbol) {return _encode_int(32);}
-void *get_sizeof_datatype_c::visit(lreal_type_name_c *symbol) {return _encode_int(64);}
-// void *get_sizeof_datatype_c::visit(date_type_name_c *symbol) {return _encode_int(0); }
-// void *get_sizeof_datatype_c::visit(tod_type_name_c *symbol) {return _encode_int(0); }
-// void *get_sizeof_datatype_c::visit(dt_type_name_c *symbol) {return _encode_int(0); }
-void *get_sizeof_datatype_c::visit(byte_type_name_c *symbol) {return _encode_int(8); }
-void *get_sizeof_datatype_c::visit(word_type_name_c *symbol) {return _encode_int(16);}
-void *get_sizeof_datatype_c::visit(dword_type_name_c *symbol) {return _encode_int(32);}
-void *get_sizeof_datatype_c::visit(lword_type_name_c *symbol) {return _encode_int(64);}
-// void *get_sizeof_datatype_c::visit(string_type_name_c *symbol) {return _encode_int(0); }
-// void *get_sizeof_datatype_c::visit(wstring_type_name_c *symbol) {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(time_type_name_c *symbol) {return _encode_int(0); }
+void *get_sizeof_datatype_c::visit(bool_type_name_c *symbol) {return _encode_int(1); }
+void *get_sizeof_datatype_c::visit(sint_type_name_c *symbol) {return _encode_int(8); }
+void *get_sizeof_datatype_c::visit(int_type_name_c *symbol) {return _encode_int(16);}
+void *get_sizeof_datatype_c::visit(dint_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(lint_type_name_c *symbol) {return _encode_int(64);}
+void *get_sizeof_datatype_c::visit(usint_type_name_c *symbol) {return _encode_int(8); }
+void *get_sizeof_datatype_c::visit(uint_type_name_c *symbol) {return _encode_int(16);}
+void *get_sizeof_datatype_c::visit(udint_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(ulint_type_name_c *symbol) {return _encode_int(64);}
+void *get_sizeof_datatype_c::visit(real_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(lreal_type_name_c *symbol) {return _encode_int(64);}
+// void *get_sizeof_datatype_c::visit(date_type_name_c *symbol) {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(tod_type_name_c *symbol) {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(dt_type_name_c *symbol) {return _encode_int(0); }
+void *get_sizeof_datatype_c::visit(byte_type_name_c *symbol) {return _encode_int(8); }
+void *get_sizeof_datatype_c::visit(word_type_name_c *symbol) {return _encode_int(16);}
+void *get_sizeof_datatype_c::visit(dword_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(lword_type_name_c *symbol) {return _encode_int(64);}
+// void *get_sizeof_datatype_c::visit(string_type_name_c *symbol) {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(wstring_type_name_c *symbol) {return _encode_int(0); }
/******************************************************/
/* Extensions to the base standard as defined in */
/* "Safety Software Technical Specification, */
@@ -355,7 +372,28 @@
/* Version 1.0 – Official Release" */
/* by PLCopen - Technical Committee 5 - 2006-01-31 */
/******************************************************/
-void *get_sizeof_datatype_c::visit(safebool_type_name_c *symbol) {return _encode_int(1);}
+// void *get_sizeof_datatype_c::visit(safetime_type_name_c *symbol); {return _encode_int(0); }
+void *get_sizeof_datatype_c::visit(safebool_type_name_c *symbol) {return _encode_int(1); }
+void *get_sizeof_datatype_c::visit(safesint_type_name_c *symbol) {return _encode_int(8); }
+void *get_sizeof_datatype_c::visit(safeint_type_name_c *symbol) {return _encode_int(16);}
+void *get_sizeof_datatype_c::visit(safedint_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(safelint_type_name_c *symbol) {return _encode_int(64);}
+void *get_sizeof_datatype_c::visit(safeusint_type_name_c *symbol) {return _encode_int(8); }
+void *get_sizeof_datatype_c::visit(safeuint_type_name_c *symbol) {return _encode_int(16);}
+void *get_sizeof_datatype_c::visit(safeudint_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(safeulint_type_name_c *symbol) {return _encode_int(64);}
+void *get_sizeof_datatype_c::visit(safereal_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(safelreal_type_name_c *symbol) {return _encode_int(64);}
+// void *get_sizeof_datatype_c::visit(safedate_type_name_c *symbol); {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(safetod_type_name_c *symbol); {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(safedt_type_name_c *symbol); {return _encode_int(0); }
+void *get_sizeof_datatype_c::visit(safebyte_type_name_c *symbol) {return _encode_int(8); }
+void *get_sizeof_datatype_c::visit(safeword_type_name_c *symbol) {return _encode_int(16);}
+void *get_sizeof_datatype_c::visit(safedword_type_name_c *symbol) {return _encode_int(32);}
+void *get_sizeof_datatype_c::visit(safelword_type_name_c *symbol) {return _encode_int(64);}
+// void *get_sizeof_datatype_c::visit(safestring_type_name_c *symbol); {return _encode_int(0); }
+// void *get_sizeof_datatype_c::visit(safewstring_type_name_c *symbol); {return _encode_int(0); }
+
/********************************/
/* B 1.3.3 - Derived data types */
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/get_sizeof_datatype.hh
--- a/absyntax_utils/get_sizeof_datatype.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/get_sizeof_datatype.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -91,7 +98,9 @@
* If 'x' were a SINT, then the '30' would have to be a SINT too!
*/
void *visit(real_c *symbol);
+ void *visit(neg_real_c *symbol);
void *visit(integer_c *symbol);
+ void *visit(neg_integer_c *symbol);
void *visit(binary_integer_c *symbol);
void *visit(octal_integer_c *symbol);
void *visit(hex_integer_c *symbol);
@@ -128,7 +137,27 @@
/* Version 1.0 – Official Release" */
/* by PLCopen - Technical Committee 5 - 2006-01-31 */
/******************************************************/
+// void *visit(safetime_type_name_c *symbol);
void *visit(safebool_type_name_c *symbol);
+ void *visit(safesint_type_name_c *symbol);
+ void *visit(safeint_type_name_c *symbol);
+ void *visit(safedint_type_name_c *symbol);
+ void *visit(safelint_type_name_c *symbol);
+ void *visit(safeusint_type_name_c *symbol);
+ void *visit(safeuint_type_name_c *symbol);
+ void *visit(safeudint_type_name_c *symbol);
+ void *visit(safeulint_type_name_c *symbol);
+ void *visit(safereal_type_name_c *symbol);
+ void *visit(safelreal_type_name_c *symbol);
+// void *visit(safedate_type_name_c *symbol);
+// void *visit(safetod_type_name_c *symbol);
+// void *visit(safedt_type_name_c *symbol) ;
+ void *visit(safebyte_type_name_c *symbol);
+ void *visit(safeword_type_name_c *symbol);
+ void *visit(safedword_type_name_c *symbol);
+ void *visit(safelword_type_name_c *symbol);
+// void *visit(safestring_type_name_c *symbol);
+// void *visit(safewstring_type_name_c *symbol);
/********************************/
/* B 1.3.3 - Derived data types */
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_base_type.cc
--- a/absyntax_utils/search_base_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_base_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -85,10 +92,14 @@
* If 'x' were a SINT, then the '30' would have to be a SINT too!
*/
void *search_base_type_c::visit(real_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(neg_real_c *symbol) {return (void *)symbol;}
void *search_base_type_c::visit(integer_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(neg_integer_c *symbol) {return (void *)symbol;}
void *search_base_type_c::visit(binary_integer_c *symbol) {return (void *)symbol;}
void *search_base_type_c::visit(octal_integer_c *symbol) {return (void *)symbol;}
void *search_base_type_c::visit(hex_integer_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(boolean_true_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(boolean_false_c *symbol) {return (void *)symbol;}
/***********************************/
@@ -115,10 +126,8 @@
void *search_base_type_c::visit(lword_type_name_c *symbol) {return (void *)symbol;}
void *search_base_type_c::visit(string_type_name_c *symbol) {return (void *)symbol;}
void *search_base_type_c::visit(wstring_type_name_c *symbol) {return (void *)symbol;}
-/*
-void *search_base_type_c::visit(constant_int_type_name_c *symbol) {return (void *)symbol;}
-void *search_base_type_c::visit(constant_real_type_name_c *symbol) {return (void *)symbol;}
-*/
+
+
/******************************************************/
/* Extensions to the base standard as defined in */
/* "Safety Software Technical Specification, */
@@ -126,7 +135,28 @@
/* Version 1.0 – Official Release" */
/* by PLCopen - Technical Committee 5 - 2006-01-31 */
/******************************************************/
-void *search_base_type_c::visit(safebool_type_name_c *symbol) {return (void *)symbol;}
+
+void *search_base_type_c::visit(safetime_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safebool_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safesint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safeint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safedint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safelint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safeusint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safeuint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safeudint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safeulint_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safereal_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safelreal_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safedate_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safetod_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safedt_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safebyte_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safeword_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safedword_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safelword_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safestring_type_name_c *symbol) {return (void *)symbol;}
+void *search_base_type_c::visit(safewstring_type_name_c *symbol) {return (void *)symbol;}
/********************************/
/* B 1.3.3 - Derived data types */
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_base_type.hh
--- a/absyntax_utils/search_base_type.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_base_type.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -71,10 +78,14 @@
* If 'x' were a SINT, then the '30' would have to be a SINT too!
*/
void *visit(real_c *symbol);
+ void *visit(neg_real_c *symbol);
void *visit(integer_c *symbol);
+ void *visit(neg_integer_c *symbol);
void *visit(binary_integer_c *symbol);
void *visit(octal_integer_c *symbol);
void *visit(hex_integer_c *symbol);
+ void *visit(boolean_true_c *symbol);
+ void *visit(boolean_false_c *symbol);
/***********************************/
@@ -102,11 +113,6 @@
void *visit(string_type_name_c *symbol);
void *visit(wstring_type_name_c *symbol);
-/*
- void *visit(constant_int_type_name_c *symbol);
- void *visit(constant_real_type_name_c *symbol);
-*/
-
/******************************************************/
/* Extensions to the base standard as defined in */
/* "Safety Software Technical Specification, */
@@ -114,7 +120,27 @@
/* Version 1.0 – Official Release" */
/* by PLCopen - Technical Committee 5 - 2006-01-31 */
/******************************************************/
+ void *visit(safetime_type_name_c *symbol);
void *visit(safebool_type_name_c *symbol);
+ void *visit(safesint_type_name_c *symbol);
+ void *visit(safeint_type_name_c *symbol);
+ void *visit(safedint_type_name_c *symbol);
+ void *visit(safelint_type_name_c *symbol);
+ void *visit(safeusint_type_name_c *symbol);
+ void *visit(safeuint_type_name_c *symbol);
+ void *visit(safeudint_type_name_c *symbol);
+ void *visit(safeulint_type_name_c *symbol);
+ void *visit(safereal_type_name_c *symbol);
+ void *visit(safelreal_type_name_c *symbol);
+ void *visit(safedate_type_name_c *symbol);
+ void *visit(safetod_type_name_c *symbol);
+ void *visit(safedt_type_name_c *symbol) ;
+ void *visit(safebyte_type_name_c *symbol);
+ void *visit(safeword_type_name_c *symbol);
+ void *visit(safedword_type_name_c *symbol);
+ void *visit(safelword_type_name_c *symbol);
+ void *visit(safestring_type_name_c *symbol);
+ void *visit(safewstring_type_name_c *symbol);
/********************************/
/* B 1.3.3 - Derived data types */
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_constant_type.cc
--- a/absyntax_utils/search_constant_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_constant_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -59,7 +66,9 @@
* If 'x' were a SINT, then the '30' would have to be a SINT too!
*/
void *search_constant_type_c::visit(real_c *symbol) {return (void *)symbol;}
+void *search_constant_type_c::visit(neg_real_c *symbol) {return (void *)symbol;}
void *search_constant_type_c::visit(integer_c *symbol) {return (void *)symbol;}
+void *search_constant_type_c::visit(neg_integer_c *symbol) {return (void *)symbol;}
void *search_constant_type_c::visit(binary_integer_c *symbol) {return (void *)symbol;}
void *search_constant_type_c::visit(octal_integer_c *symbol) {return (void *)symbol;}
void *search_constant_type_c::visit(hex_integer_c *symbol) {return (void *)symbol;}
@@ -90,7 +99,7 @@
/* B 1.2.3.1 - Duration */
/************************/
void *search_constant_type_c::visit(neg_time_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */
-void *search_constant_type_c::visit(duration_c *symbol) {return (void *)&time_type_name;}
+void *search_constant_type_c::visit(duration_c *symbol) {return (void *)(symbol->type_name);}
void *search_constant_type_c::visit(fixed_point_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */
void *search_constant_type_c::visit(days_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */
void *search_constant_type_c::visit(hours_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */
@@ -101,11 +110,12 @@
/************************************/
/* B 1.2.3.2 - Time of day and Date */
/************************************/
-void *search_constant_type_c::visit(time_of_day_c *symbol) {return (void *)&tod_type_name;}
+void *search_constant_type_c::visit(time_of_day_c *symbol) {return (void *)(symbol->type_name);}
void *search_constant_type_c::visit(daytime_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */
-void *search_constant_type_c::visit(date_c *symbol) {return (void *)&date_type_name;}
+void *search_constant_type_c::visit(date_c *symbol) {return (void *)(symbol->type_name);}
void *search_constant_type_c::visit(date_literal_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */
-void *search_constant_type_c::visit(date_and_time_c *symbol) {return (void *)&dt_type_name;}
+void *search_constant_type_c::visit(date_and_time_c *symbol) {return (void *)(symbol->type_name);}
+
real_type_name_c search_constant_type_c::real_type_name;
sint_type_name_c search_constant_type_c::sint_type_name;
@@ -129,10 +139,16 @@
time_type_name_c search_constant_type_c::time_type_name;
int_type_name_c search_constant_type_c::int_type_name;
-/*
-constant_real_type_name_c search_constant_type_c::constant_real_type_name;
-constant_int_type_name_c search_constant_type_c::constant_int_type_name;
-*/
+// safebool_type_name_c search_constant_type_c::safebool_type_name;
+ /* The following is required because the expression (TOD_var - TOD_var) will result in a data type
+ * (in this case, TIME) that is neither of the expression elements...
+ */
+safetime_type_name_c search_constant_type_c::safetime_type_name;
+safetod_type_name_c search_constant_type_c::safetod_type_name;
+safedt_type_name_c search_constant_type_c::safedt_type_name;
+
+
+
/* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */
/* It should then move to search_expression_type_c */
integer_c search_constant_type_c::integer("1");
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_constant_type.hh
--- a/absyntax_utils/search_constant_type.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_constant_type.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -67,10 +74,6 @@
static time_type_name_c time_type_name;
static int_type_name_c int_type_name;
-/*
- static constant_real_type_name_c constant_real_type_name;
- static constant_int_type_name_c constant_int_type_name;
-*/
/* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */
static integer_c integer;
@@ -81,7 +84,15 @@
/* Version 1.0 – Official Release" */
/* by PLCopen - Technical Committee 5 - 2006-01-31 */
/******************************************************/
- static safebool_type_name_c safebool_type_name;
+
+// static safebool_type_name_c safebool_type_name;
+ /* The following is required because the expression (TOD_var - TOD_var) will result in a data type
+ * (in this case, TIME) that is neither of the expression elements...
+ */
+ static safetime_type_name_c safetime_type_name;
+ static safetod_type_name_c safetod_type_name;
+ static safedt_type_name_c safedt_type_name;
+
public:
@@ -97,7 +108,9 @@
/* B 1.2.1 - Numeric Literals */
/******************************/
void *visit(real_c *symbol);
+ void *visit(neg_real_c *symbol);
void *visit(integer_c *symbol);
+ void *visit(neg_integer_c *symbol);
void *visit(binary_integer_c *symbol);
void *visit(octal_integer_c *symbol);
void *visit(hex_integer_c *symbol);
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_expression_type.cc
--- a/absyntax_utils/search_expression_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_expression_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -49,24 +56,34 @@
bool search_expression_type_c::is_bool_type(symbol_c *type_symbol) {
bool_type_name_c tt;
if (type_symbol == NULL) {return true;}
- return (typeid(*type_symbol) == typeid(bool_type_name_c));
+ if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(boolean_true_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(boolean_false_c)) {return true;}
+ return false;
}
/* A helper function... */
bool search_expression_type_c::is_time_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safetod_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedt_type_name_c)) {return true;}
return false;
}
/* A helper function... */
bool search_expression_type_c::is_string_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;}
return false;
}
@@ -74,6 +91,7 @@
bool search_expression_type_c::is_literal_integer_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
if (typeid(*type_symbol) == typeid(integer_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(neg_integer_c)) {return true;}
if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;}
if (typeid(*type_symbol) == typeid(octal_integer_c)) {return true;}
if (typeid(*type_symbol) == typeid(hex_integer_c)) {return true;}
@@ -83,29 +101,40 @@
/* A helper function... */
bool search_expression_type_c::is_integer_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safesint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safelint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeusint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeuint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeudint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeulint_type_name_c)) {return true;}
return is_literal_integer_type(type_symbol);
}
/* A helper function... */
bool search_expression_type_c::is_literal_real_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(real_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(real_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(neg_real_c)) {return true;}
return false;
}
/* A helper function... */
bool search_expression_type_c::is_real_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safereal_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;}
return is_literal_real_type(type_symbol);
}
@@ -116,28 +145,34 @@
bool search_expression_type_c::is_nbinary_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safebyte_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safelword_type_name_c)) {return true;}
return is_literal_integer_type(type_symbol);
}
bool search_expression_type_c::is_binary_type(symbol_c *type_symbol) {
if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
- return is_nbinary_type(type_symbol);
+// if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
+// if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;}
+ return (is_nbinary_type(type_symbol) || is_bool_type(type_symbol));
}
bool search_expression_type_c::is_same_type(symbol_c *first_type, symbol_c *second_type) {
if (first_type == NULL || second_type == NULL) {return true;}
if (typeid(*first_type) == typeid(*second_type)) {return true;}
- if (is_integer_type(first_type) && is_literal_integer_type(second_type)) {return true;}
- if (is_literal_integer_type(first_type) && is_integer_type(second_type)) {return true;}
- if (is_binary_type(first_type) && is_literal_integer_type(second_type)) {return true;}
- if (is_literal_integer_type(first_type) && is_binary_type(second_type)) {return true;}
- if (is_real_type(first_type) && is_literal_real_type(second_type)) {return true;}
- if (is_literal_real_type(first_type) && is_real_type(second_type)) {return true;}
+ if (is_bool_type(first_type) && is_bool_type(second_type)) {return true;}
+ if (is_integer_type(first_type) && is_literal_integer_type(second_type)) {return true;}
+ if (is_literal_integer_type(first_type) && is_integer_type(second_type)) {return true;}
+ if (is_binary_type(first_type) && is_literal_integer_type(second_type)) {return true;}
+ if (is_literal_integer_type(first_type) && is_binary_type(second_type)) {return true;}
+ if (is_real_type(first_type) && is_literal_real_type(second_type)) {return true;}
+ if (is_literal_real_type(first_type) && is_real_type(second_type)) {return true;}
return false;
}
@@ -146,12 +181,12 @@
if (first_type == NULL) {return second_type;}
if (second_type == NULL) {return first_type;}
if (typeid(*first_type) == typeid(*second_type)) {return first_type;}
- if (is_integer_type(first_type) && is_literal_integer_type(second_type)) {return first_type;}
- if (is_literal_integer_type(first_type) && is_integer_type(second_type)) {return second_type;}
- if (is_binary_type(first_type) && is_literal_integer_type(second_type)) {return first_type;}
- if (is_literal_integer_type(first_type) && is_binary_type(second_type)) {return second_type;}
- if (is_real_type(first_type) && is_literal_real_type(second_type)) {return first_type;}
- if (is_literal_real_type(first_type) && is_real_type(second_type)) {return second_type;}
+ if (is_integer_type(first_type) && is_literal_integer_type(second_type)) {return first_type;}
+ if (is_literal_integer_type(first_type) && is_integer_type(second_type)) {return second_type;}
+ if (is_binary_type(first_type) && is_literal_integer_type(second_type)) {return first_type;}
+ if (is_literal_integer_type(first_type) && is_binary_type(second_type)) {return second_type;}
+ if (is_real_type(first_type) && is_literal_real_type(second_type)) {return first_type;}
+ if (is_literal_real_type(first_type) && is_real_type(second_type)) {return second_type;}
return NULL;
}
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_expression_type.hh
--- a/absyntax_utils/search_expression_type.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_expression_type.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_fb_instance_decl.cc
--- a/absyntax_utils/search_fb_instance_decl.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_fb_instance_decl.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_fb_instance_decl.hh
--- a/absyntax_utils/search_fb_instance_decl.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_fb_instance_decl.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_fb_typedecl.cc
--- a/absyntax_utils/search_fb_typedecl.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_fb_typedecl.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_fb_typedecl.hh
--- a/absyntax_utils/search_fb_typedecl.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_fb_typedecl.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_il_operand_type.cc
--- a/absyntax_utils/search_il_operand_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_il_operand_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_il_operand_type.hh
--- a/absyntax_utils/search_il_operand_type.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_il_operand_type.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_type_code.c
--- a/absyntax_utils/search_type_code.c Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_type_code.c Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2008 Edouard TISSERANT
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2008 Edouard TISSERANT
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_var_instance_decl.cc
--- a/absyntax_utils/search_var_instance_decl.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_var_instance_decl.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_var_instance_decl.hh
--- a/absyntax_utils/search_var_instance_decl.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_var_instance_decl.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_varfb_instance_type.cc
--- a/absyntax_utils/search_varfb_instance_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_varfb_instance_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/search_varfb_instance_type.hh
--- a/absyntax_utils/search_varfb_instance_type.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/search_varfb_instance_type.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/spec_init_separator.cc
--- a/absyntax_utils/spec_init_separator.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/spec_init_separator.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/spec_init_separator.hh
--- a/absyntax_utils/spec_init_separator.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/spec_init_separator.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/type_initial_value.cc
--- a/absyntax_utils/type_initial_value.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/type_initial_value.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -76,10 +83,10 @@
date_literal_0 = new date_literal_c(integer_1, integer_1, integer_1);
date_literal_0 = new date_literal_c(new integer_c("1970"), integer_1, integer_1);
daytime_literal_0 = new daytime_c(integer_0, integer_0, real_0);
- time_0 = new duration_c(NULL, new seconds_c(integer_0, NULL)); // T#0S
- date_0 = new date_c(date_literal_0); // D#0001-01-01
- tod_0 = new time_of_day_c(daytime_literal_0); // TOD#00:00:00
- dt_0 = new date_and_time_c(date_literal_0, daytime_literal_0); // DT#0001-01-01-00:00:00
+ time_0 = new duration_c(new time_type_name_c(), NULL, new seconds_c(integer_0, NULL)); // T#0S
+ date_0 = new date_c(new date_type_name_c(), date_literal_0); // D#0001-01-01
+ tod_0 = new time_of_day_c(new tod_type_name_c(), daytime_literal_0); // TOD#00:00:00
+ dt_0 = new date_and_time_c(new dt_type_name_c(), date_literal_0, daytime_literal_0); // DT#0001-01-01-00:00:00
string_0 = new single_byte_character_string_c("''");
wstring_0 = new double_byte_character_string_c("\"\"");
@@ -128,27 +135,49 @@
/***********************************/
/* B 1.3.1 - Elementary Data Types */
/***********************************/
-void *type_initial_value_c::visit(time_type_name_c *symbol) {return (void *)time_0;}
-void *type_initial_value_c::visit(bool_type_name_c *symbol) {return (void *)bool_0;}
-void *type_initial_value_c::visit(sint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(int_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(dint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(lint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(usint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(uint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(udint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(ulint_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(real_type_name_c *symbol) {return (void *)real_0;}
-void *type_initial_value_c::visit(lreal_type_name_c *symbol) {return (void *)real_0;}
-void *type_initial_value_c::visit(date_type_name_c *symbol) {return (void *)date_0;}
-void *type_initial_value_c::visit(tod_type_name_c *symbol) {return (void *)tod_0;}
-void *type_initial_value_c::visit(dt_type_name_c *symbol) {return (void *)dt_0;}
-void *type_initial_value_c::visit(byte_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(word_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(dword_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(lword_type_name_c *symbol) {return (void *)integer_0;}
-void *type_initial_value_c::visit(string_type_name_c *symbol) {return (void *)string_0;}
-void *type_initial_value_c::visit(wstring_type_name_c *symbol) {return (void *)wstring_0;}
+void *type_initial_value_c::visit(time_type_name_c *symbol) {return (void *)time_0;}
+void *type_initial_value_c::visit(bool_type_name_c *symbol) {return (void *)bool_0;}
+void *type_initial_value_c::visit(sint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(int_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(dint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(lint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(usint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(uint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(udint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(ulint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(real_type_name_c *symbol) {return (void *)real_0;}
+void *type_initial_value_c::visit(lreal_type_name_c *symbol) {return (void *)real_0;}
+void *type_initial_value_c::visit(date_type_name_c *symbol) {return (void *)date_0;}
+void *type_initial_value_c::visit(tod_type_name_c *symbol) {return (void *)tod_0;}
+void *type_initial_value_c::visit(dt_type_name_c *symbol) {return (void *)dt_0;}
+void *type_initial_value_c::visit(byte_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(word_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(dword_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(lword_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(string_type_name_c *symbol) {return (void *)string_0;}
+void *type_initial_value_c::visit(wstring_type_name_c *symbol) {return (void *)wstring_0;}
+
+void *type_initial_value_c::visit(safetime_type_name_c *symbol) {return (void *)time_0;}
+void *type_initial_value_c::visit(safebool_type_name_c *symbol) {return (void *)bool_0;}
+void *type_initial_value_c::visit(safesint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safeint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safedint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safelint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safeusint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safeuint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safeudint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safeulint_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safereal_type_name_c *symbol) {return (void *)real_0;}
+void *type_initial_value_c::visit(safelreal_type_name_c *symbol) {return (void *)real_0;}
+void *type_initial_value_c::visit(safedate_type_name_c *symbol) {return (void *)date_0;}
+void *type_initial_value_c::visit(safetod_type_name_c *symbol) {return (void *)tod_0;}
+void *type_initial_value_c::visit(safedt_type_name_c *symbol) {return (void *)dt_0;}
+void *type_initial_value_c::visit(safebyte_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safeword_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safedword_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safelword_type_name_c *symbol) {return (void *)integer_0;}
+void *type_initial_value_c::visit(safestring_type_name_c *symbol) {return (void *)string_0;}
+void *type_initial_value_c::visit(safewstring_type_name_c *symbol) {return (void *)wstring_0;}
/********************************/
/* B 1.3.3 - Derived data types */
diff -r 86ef2244aef1 -r 579db02bebd9 absyntax_utils/type_initial_value.hh
--- a/absyntax_utils/type_initial_value.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/absyntax_utils/type_initial_value.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -107,6 +114,28 @@
void *visit(string_type_name_c *symbol);
void *visit(wstring_type_name_c *symbol);
+ void *visit(safetime_type_name_c *symbol);
+ void *visit(safebool_type_name_c *symbol);
+ void *visit(safesint_type_name_c *symbol);
+ void *visit(safeint_type_name_c *symbol);
+ void *visit(safedint_type_name_c *symbol);
+ void *visit(safelint_type_name_c *symbol);
+ void *visit(safeusint_type_name_c *symbol);
+ void *visit(safeuint_type_name_c *symbol);
+ void *visit(safeudint_type_name_c *symbol);
+ void *visit(safeulint_type_name_c *symbol);
+ void *visit(safereal_type_name_c *symbol);
+ void *visit(safelreal_type_name_c *symbol);
+ void *visit(safedate_type_name_c *symbol);
+ void *visit(safetod_type_name_c *symbol);
+ void *visit(safedt_type_name_c *symbol);
+ void *visit(safebyte_type_name_c *symbol);
+ void *visit(safeword_type_name_c *symbol);
+ void *visit(safedword_type_name_c *symbol);
+ void *visit(safelword_type_name_c *symbol);
+ void *visit(safestring_type_name_c *symbol);
+ void *visit(safewstring_type_name_c *symbol);
+
/********************************/
/* B 1.3.3 - Derived data types */
/********************************/
diff -r 86ef2244aef1 -r 579db02bebd9 lib/counter.txt
--- a/lib/counter.txt Fri Apr 01 17:26:29 2011 +0200
+++ b/lib/counter.txt Mon Apr 04 17:19:35 2011 +0200
@@ -28,6 +28,10 @@
Q : BOOL;
CV : INT;
END_VAR
+
+ VAR RRR : REAL; END_VAR
+ RRR := 9.9;
+
IF R THEN CV := 0 ;
ELSIF CU AND (CV < PV)
THEN CV := CV+1;
diff -r 86ef2244aef1 -r 579db02bebd9 lib/create_standard_function_header.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/create_standard_function_header.sh Mon Apr 04 17:19:35 2011 +0200
@@ -0,0 +1,527 @@
+#!/bin/sh
+
+#/*
+# * matiec - a compiler for the programming languages defined in IEC 61131-3
+# * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+# *
+# * 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 .
+# *
+# *
+# * This code is made available on the understanding that it will not be
+# * used in safety-critical situations without a full and competent review.
+# */
+#
+#/*
+# * An IEC 61131-3 compiler.
+# *
+# * Based on the
+# * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
+# *
+# */
+#
+#
+# A shell script to create the library header file containing the
+# standard functions defined in IEC 61131-3
+#
+
+
+create()
+{
+echo
+echo
+echo FUNCTION $1 : $3
+echo " "VAR_INPUT IN: $2";" END_VAR
+echo " "VAR_OUTPUT OUT: $3";" END_VAR
+echo " "LD TRUE
+echo END_FUNCTION
+}
+
+
+
+
+echo
+echo {disable code generation}
+echo
+echo
+
+create REAL_TO_SINT REAL SINT
+create REAL_TO_LINT REAL LINT
+create REAL_TO_DINT REAL DINT
+create REAL_TO_DATE REAL DATE
+create REAL_TO_DWORD REAL DWORD
+create REAL_TO_DT REAL DT
+create REAL_TO_TOD REAL TOD
+create REAL_TO_UDINT REAL UDINT
+create REAL_TO_WORD REAL WORD
+create REAL_TO_STRING REAL STRING
+create REAL_TO_LWORD REAL LWORD
+create REAL_TO_UINT REAL UINT
+create REAL_TO_LREAL REAL LREAL
+create REAL_TO_BYTE REAL BYTE
+create REAL_TO_USINT REAL USINT
+create REAL_TO_ULINT REAL ULINT
+create REAL_TO_BOOL REAL BOOL
+create REAL_TO_TIME REAL TIME
+create REAL_TO_INT REAL INT
+create SINT_TO_REAL SINT REAL
+create SINT_TO_LINT SINT LINT
+create SINT_TO_DINT SINT DINT
+create SINT_TO_DATE SINT DATE
+create SINT_TO_DWORD SINT DWORD
+create SINT_TO_DT SINT DT
+create SINT_TO_TOD SINT TOD
+create SINT_TO_UDINT SINT UDINT
+create SINT_TO_WORD SINT WORD
+create SINT_TO_STRING SINT STRING
+create SINT_TO_LWORD SINT LWORD
+create SINT_TO_UINT SINT UINT
+create SINT_TO_LREAL SINT LREAL
+create SINT_TO_BYTE SINT BYTE
+create SINT_TO_USINT SINT USINT
+create SINT_TO_ULINT SINT ULINT
+create SINT_TO_BOOL SINT BOOL
+create SINT_TO_TIME SINT TIME
+create SINT_TO_INT SINT INT
+create LINT_TO_REAL LINT REAL
+create LINT_TO_SINT LINT SINT
+create LINT_TO_DINT LINT DINT
+create LINT_TO_DATE LINT DATE
+create LINT_TO_DWORD LINT DWORD
+create LINT_TO_DT LINT DT
+create LINT_TO_TOD LINT TOD
+create LINT_TO_UDINT LINT UDINT
+create LINT_TO_WORD LINT WORD
+create LINT_TO_STRING LINT STRING
+create LINT_TO_LWORD LINT LWORD
+create LINT_TO_UINT LINT UINT
+create LINT_TO_LREAL LINT LREAL
+create LINT_TO_BYTE LINT BYTE
+create LINT_TO_USINT LINT USINT
+create LINT_TO_ULINT LINT ULINT
+create LINT_TO_BOOL LINT BOOL
+create LINT_TO_TIME LINT TIME
+create LINT_TO_INT LINT INT
+create DINT_TO_REAL DINT REAL
+create DINT_TO_SINT DINT SINT
+create DINT_TO_LINT DINT LINT
+create DINT_TO_DATE DINT DATE
+create DINT_TO_DWORD DINT DWORD
+create DINT_TO_DT DINT DT
+create DINT_TO_TOD DINT TOD
+create DINT_TO_UDINT DINT UDINT
+create DINT_TO_WORD DINT WORD
+create DINT_TO_STRING DINT STRING
+create DINT_TO_LWORD DINT LWORD
+create DINT_TO_UINT DINT UINT
+create DINT_TO_LREAL DINT LREAL
+create DINT_TO_BYTE DINT BYTE
+create DINT_TO_USINT DINT USINT
+create DINT_TO_ULINT DINT ULINT
+create DINT_TO_BOOL DINT BOOL
+create DINT_TO_TIME DINT TIME
+create DINT_TO_INT DINT INT
+create DATE_TO_REAL DATE REAL
+create DATE_TO_SINT DATE SINT
+create DATE_TO_LINT DATE LINT
+create DATE_TO_DINT DATE DINT
+create DATE_TO_DWORD DATE DWORD
+create DATE_TO_UDINT DATE UDINT
+create DATE_TO_WORD DATE WORD
+create DATE_TO_STRING DATE STRING
+create DATE_TO_LWORD DATE LWORD
+create DATE_TO_UINT DATE UINT
+create DATE_TO_LREAL DATE LREAL
+create DATE_TO_BYTE DATE BYTE
+create DATE_TO_USINT DATE USINT
+create DATE_TO_ULINT DATE ULINT
+create DATE_TO_INT DATE INT
+create DWORD_TO_REAL DWORD REAL
+create DWORD_TO_SINT DWORD SINT
+create DWORD_TO_LINT DWORD LINT
+create DWORD_TO_DINT DWORD DINT
+create DWORD_TO_DATE DWORD DATE
+create DWORD_TO_DT DWORD DT
+create DWORD_TO_TOD DWORD TOD
+create DWORD_TO_UDINT DWORD UDINT
+create DWORD_TO_WORD DWORD WORD
+create DWORD_TO_STRING DWORD STRING
+create DWORD_TO_LWORD DWORD LWORD
+create DWORD_TO_UINT DWORD UINT
+create DWORD_TO_LREAL DWORD LREAL
+create DWORD_TO_BYTE DWORD BYTE
+create DWORD_TO_USINT DWORD USINT
+create DWORD_TO_ULINT DWORD ULINT
+create DWORD_TO_BOOL DWORD BOOL
+create DWORD_TO_TIME DWORD TIME
+create DWORD_TO_INT DWORD INT
+create DT_TO_REAL DT REAL
+create DT_TO_SINT DT SINT
+create DT_TO_LINT DT LINT
+create DT_TO_DINT DT DINT
+create DT_TO_DWORD DT DWORD
+create DT_TO_UDINT DT UDINT
+create DT_TO_WORD DT WORD
+create DT_TO_STRING DT STRING
+create DT_TO_LWORD DT LWORD
+create DT_TO_UINT DT UINT
+create DT_TO_LREAL DT LREAL
+create DT_TO_BYTE DT BYTE
+create DT_TO_USINT DT USINT
+create DT_TO_ULINT DT ULINT
+create DT_TO_INT DT INT
+create TOD_TO_REAL TOD REAL
+create TOD_TO_SINT TOD SINT
+create TOD_TO_LINT TOD LINT
+create TOD_TO_DINT TOD DINT
+create TOD_TO_DWORD TOD DWORD
+create TOD_TO_UDINT TOD UDINT
+create TOD_TO_WORD TOD WORD
+create TOD_TO_STRING TOD STRING
+create TOD_TO_LWORD TOD LWORD
+create TOD_TO_UINT TOD UINT
+create TOD_TO_LREAL TOD LREAL
+create TOD_TO_BYTE TOD BYTE
+create TOD_TO_USINT TOD USINT
+create TOD_TO_ULINT TOD ULINT
+create TOD_TO_INT TOD INT
+create UDINT_TO_REAL UDINT REAL
+create UDINT_TO_SINT UDINT SINT
+create UDINT_TO_LINT UDINT LINT
+create UDINT_TO_DINT UDINT DINT
+create UDINT_TO_DATE UDINT DATE
+create UDINT_TO_DWORD UDINT DWORD
+create UDINT_TO_DT UDINT DT
+create UDINT_TO_TOD UDINT TOD
+create UDINT_TO_WORD UDINT WORD
+create UDINT_TO_STRING UDINT STRING
+create UDINT_TO_LWORD UDINT LWORD
+create UDINT_TO_UINT UDINT UINT
+create UDINT_TO_LREAL UDINT LREAL
+create UDINT_TO_BYTE UDINT BYTE
+create UDINT_TO_USINT UDINT USINT
+create UDINT_TO_ULINT UDINT ULINT
+create UDINT_TO_BOOL UDINT BOOL
+create UDINT_TO_TIME UDINT TIME
+create UDINT_TO_INT UDINT INT
+create WORD_TO_REAL WORD REAL
+create WORD_TO_SINT WORD SINT
+create WORD_TO_LINT WORD LINT
+create WORD_TO_DINT WORD DINT
+create WORD_TO_DATE WORD DATE
+create WORD_TO_DWORD WORD DWORD
+create WORD_TO_DT WORD DT
+create WORD_TO_TOD WORD TOD
+create WORD_TO_UDINT WORD UDINT
+create WORD_TO_STRING WORD STRING
+create WORD_TO_LWORD WORD LWORD
+create WORD_TO_UINT WORD UINT
+create WORD_TO_LREAL WORD LREAL
+create WORD_TO_BYTE WORD BYTE
+create WORD_TO_USINT WORD USINT
+create WORD_TO_ULINT WORD ULINT
+create WORD_TO_BOOL WORD BOOL
+create WORD_TO_TIME WORD TIME
+create WORD_TO_INT WORD INT
+create STRING_TO_REAL STRING REAL
+create STRING_TO_SINT STRING SINT
+create STRING_TO_LINT STRING LINT
+create STRING_TO_DINT STRING DINT
+create STRING_TO_DATE STRING DATE
+create STRING_TO_DWORD STRING DWORD
+create STRING_TO_DT STRING DT
+create STRING_TO_TOD STRING TOD
+create STRING_TO_UDINT STRING UDINT
+create STRING_TO_WORD STRING WORD
+create STRING_TO_LWORD STRING LWORD
+create STRING_TO_UINT STRING UINT
+create STRING_TO_LREAL STRING LREAL
+create STRING_TO_BYTE STRING BYTE
+create STRING_TO_USINT STRING USINT
+create STRING_TO_ULINT STRING ULINT
+create STRING_TO_BOOL STRING BOOL
+create STRING_TO_TIME STRING TIME
+create STRING_TO_INT STRING INT
+create LWORD_TO_REAL LWORD REAL
+create LWORD_TO_SINT LWORD SINT
+create LWORD_TO_LINT LWORD LINT
+create LWORD_TO_DINT LWORD DINT
+create LWORD_TO_DATE LWORD DATE
+create LWORD_TO_DWORD LWORD DWORD
+create LWORD_TO_DT LWORD DT
+create LWORD_TO_TOD LWORD TOD
+create LWORD_TO_UDINT LWORD UDINT
+create LWORD_TO_WORD LWORD WORD
+create LWORD_TO_STRING LWORD STRING
+create LWORD_TO_UINT LWORD UINT
+create LWORD_TO_LREAL LWORD LREAL
+create LWORD_TO_BYTE LWORD BYTE
+create LWORD_TO_USINT LWORD USINT
+create LWORD_TO_ULINT LWORD ULINT
+create LWORD_TO_BOOL LWORD BOOL
+create LWORD_TO_TIME LWORD TIME
+create LWORD_TO_INT LWORD INT
+create UINT_TO_REAL UINT REAL
+create UINT_TO_SINT UINT SINT
+create UINT_TO_LINT UINT LINT
+create UINT_TO_DINT UINT DINT
+create UINT_TO_DATE UINT DATE
+create UINT_TO_DWORD UINT DWORD
+create UINT_TO_DT UINT DT
+create UINT_TO_TOD UINT TOD
+create UINT_TO_UDINT UINT UDINT
+create UINT_TO_WORD UINT WORD
+create UINT_TO_STRING UINT STRING
+create UINT_TO_LWORD UINT LWORD
+create UINT_TO_LREAL UINT LREAL
+create UINT_TO_BYTE UINT BYTE
+create UINT_TO_USINT UINT USINT
+create UINT_TO_ULINT UINT ULINT
+create UINT_TO_BOOL UINT BOOL
+create UINT_TO_TIME UINT TIME
+create UINT_TO_INT UINT INT
+create LREAL_TO_REAL LREAL REAL
+create LREAL_TO_SINT LREAL SINT
+create LREAL_TO_LINT LREAL LINT
+create LREAL_TO_DINT LREAL DINT
+create LREAL_TO_DATE LREAL DATE
+create LREAL_TO_DWORD LREAL DWORD
+create LREAL_TO_DT LREAL DT
+create LREAL_TO_TOD LREAL TOD
+create LREAL_TO_UDINT LREAL UDINT
+create LREAL_TO_WORD LREAL WORD
+create LREAL_TO_STRING LREAL STRING
+create LREAL_TO_LWORD LREAL LWORD
+create LREAL_TO_UINT LREAL UINT
+create LREAL_TO_BYTE LREAL BYTE
+create LREAL_TO_USINT LREAL USINT
+create LREAL_TO_ULINT LREAL ULINT
+create LREAL_TO_BOOL LREAL BOOL
+create LREAL_TO_TIME LREAL TIME
+create LREAL_TO_INT LREAL INT
+create BYTE_TO_REAL BYTE REAL
+create BYTE_TO_SINT BYTE SINT
+create BYTE_TO_LINT BYTE LINT
+create BYTE_TO_DINT BYTE DINT
+create BYTE_TO_DATE BYTE DATE
+create BYTE_TO_DWORD BYTE DWORD
+create BYTE_TO_DT BYTE DT
+create BYTE_TO_TOD BYTE TOD
+create BYTE_TO_UDINT BYTE UDINT
+create BYTE_TO_WORD BYTE WORD
+create BYTE_TO_STRING BYTE STRING
+create BYTE_TO_LWORD BYTE LWORD
+create BYTE_TO_UINT BYTE UINT
+create BYTE_TO_LREAL BYTE LREAL
+create BYTE_TO_USINT BYTE USINT
+create BYTE_TO_ULINT BYTE ULINT
+create BYTE_TO_BOOL BYTE BOOL
+create BYTE_TO_TIME BYTE TIME
+create BYTE_TO_INT BYTE INT
+create USINT_TO_REAL USINT REAL
+create USINT_TO_SINT USINT SINT
+create USINT_TO_LINT USINT LINT
+create USINT_TO_DINT USINT DINT
+create USINT_TO_DATE USINT DATE
+create USINT_TO_DWORD USINT DWORD
+create USINT_TO_DT USINT DT
+create USINT_TO_TOD USINT TOD
+create USINT_TO_UDINT USINT UDINT
+create USINT_TO_WORD USINT WORD
+create USINT_TO_STRING USINT STRING
+create USINT_TO_LWORD USINT LWORD
+create USINT_TO_UINT USINT UINT
+create USINT_TO_LREAL USINT LREAL
+create USINT_TO_BYTE USINT BYTE
+create USINT_TO_ULINT USINT ULINT
+create USINT_TO_BOOL USINT BOOL
+create USINT_TO_TIME USINT TIME
+create USINT_TO_INT USINT INT
+create ULINT_TO_REAL ULINT REAL
+create ULINT_TO_SINT ULINT SINT
+create ULINT_TO_LINT ULINT LINT
+create ULINT_TO_DINT ULINT DINT
+create ULINT_TO_DATE ULINT DATE
+create ULINT_TO_DWORD ULINT DWORD
+create ULINT_TO_DT ULINT DT
+create ULINT_TO_TOD ULINT TOD
+create ULINT_TO_UDINT ULINT UDINT
+create ULINT_TO_WORD ULINT WORD
+create ULINT_TO_STRING ULINT STRING
+create ULINT_TO_LWORD ULINT LWORD
+create ULINT_TO_UINT ULINT UINT
+create ULINT_TO_LREAL ULINT LREAL
+create ULINT_TO_BYTE ULINT BYTE
+create ULINT_TO_USINT ULINT USINT
+create ULINT_TO_BOOL ULINT BOOL
+create ULINT_TO_TIME ULINT TIME
+create ULINT_TO_INT ULINT INT
+create BOOL_TO_REAL BOOL REAL
+create BOOL_TO_SINT BOOL SINT
+create BOOL_TO_LINT BOOL LINT
+create BOOL_TO_DINT BOOL DINT
+create BOOL_TO_DATE BOOL DATE
+create BOOL_TO_DWORD BOOL DWORD
+create BOOL_TO_DT BOOL DT
+create BOOL_TO_TOD BOOL TOD
+create BOOL_TO_UDINT BOOL UDINT
+create BOOL_TO_WORD BOOL WORD
+create BOOL_TO_STRING BOOL STRING
+create BOOL_TO_LWORD BOOL LWORD
+create BOOL_TO_UINT BOOL UINT
+create BOOL_TO_LREAL BOOL LREAL
+create BOOL_TO_BYTE BOOL BYTE
+create BOOL_TO_USINT BOOL USINT
+create BOOL_TO_ULINT BOOL ULINT
+create BOOL_TO_TIME BOOL TIME
+create BOOL_TO_INT BOOL INT
+create TIME_TO_REAL TIME REAL
+create TIME_TO_SINT TIME SINT
+create TIME_TO_LINT TIME LINT
+create TIME_TO_DINT TIME DINT
+create TIME_TO_DWORD TIME DWORD
+create TIME_TO_UDINT TIME UDINT
+create TIME_TO_WORD TIME WORD
+create TIME_TO_STRING TIME STRING
+create TIME_TO_LWORD TIME LWORD
+create TIME_TO_UINT TIME UINT
+create TIME_TO_LREAL TIME LREAL
+create TIME_TO_BYTE TIME BYTE
+create TIME_TO_USINT TIME USINT
+create TIME_TO_ULINT TIME ULINT
+create TIME_TO_INT TIME INT
+create INT_TO_REAL INT REAL
+create INT_TO_SINT INT SINT
+create INT_TO_LINT INT LINT
+create INT_TO_DINT INT DINT
+create INT_TO_DATE INT DATE
+create INT_TO_DWORD INT DWORD
+create INT_TO_DT INT DT
+create INT_TO_TOD INT TOD
+create INT_TO_UDINT INT UDINT
+create INT_TO_WORD INT WORD
+create INT_TO_STRING INT STRING
+create INT_TO_LWORD INT LWORD
+create INT_TO_UINT INT UINT
+create INT_TO_LREAL INT LREAL
+create INT_TO_BYTE INT BYTE
+create INT_TO_USINT INT USINT
+create INT_TO_ULINT INT ULINT
+create INT_TO_BOOL INT BOOL
+create INT_TO_TIME INT TIME
+
+create DATE_AND_TIME_TO_TIME_OF_DAY DATE_AND_TIME TIME_OF_DAY
+create DATE_AND_TIME_TO_DATE DATE_AND_TIME DATE
+
+echo
+echo
+echo "(* *BCD_TO_** and **_TO_BCD* are not yet supported *)"
+echo "(* We comment them out for now... *)"
+echo "(*"
+create UDINT_TO_BCD_BYTE UDINT BYTE
+create UDINT_TO_BCD_WORD UDINT WORD
+create UDINT_TO_BCD_DWORD UDINT DWORD
+create UDINT_TO_BCD_LWORD UDINT LWORD
+create UINT_TO_BCD_BYTE UINT BYTE
+create UINT_TO_BCD_WORD UINT WORD
+create UINT_TO_BCD_DWORD UINT DWORD
+create UINT_TO_BCD_LWORD UINT LWORD
+create USINT_TO_BCD_BYTE USINT BYTE
+create USINT_TO_BCD_WORD USINT WORD
+create USINT_TO_BCD_DWORD USINT DWORD
+create USINT_TO_BCD_LWORD USINT LWORD
+create ULINT_TO_BCD_BYTE ULINT BYTE
+create ULINT_TO_BCD_WORD ULINT WORD
+create ULINT_TO_BCD_DWORD ULINT DWORD
+create ULINT_TO_BCD_LWORD ULINT LWORD
+
+create BYTE_BCD_TO_UDINT BYTE UDINT
+create WORD_BCD_TO_UDINT WORD UDINT
+create DWORD_BCD_TO_UDINT DWORD UDINT
+create LWORD_BCD_TO_UDINT LWORD UDINT
+create BYTE_BCD_TO_UINT BYTE UINT
+create WORD_BCD_TO_UINT WORD UINT
+create DWORD_BCD_TO_UINT DWORD UINT
+create LWORD_BCD_TO_UINT LWORD UINT
+create BYTE_BCD_TO_USINT BYTE USINT
+create WORD_BCD_TO_USINT WORD USINT
+create DWORD_BCD_TO_USINT DWORD USINT
+create LWORD_BCD_TO_USINT LWORD USINT
+create BYTE_BCD_TO_ULINT BYTE ULINT
+create WORD_BCD_TO_ULINT WORD ULINT
+create DWORD_BCD_TO_ULINT DWORD ULINT
+create LWORD_BCD_TO_ULINT LWORD ULINT
+echo "*)"
+
+
+echo
+echo {enable code generation}
+
+exit 0
+
+ ABS
+ SQRT
+ LN
+ LOG
+ EXP
+ SIN
+ COS
+ TAN
+ ASIN
+ ACOS
+ ATAN
+ ADD
+ MUL
+ SUB
+ DIV
+ MOD
+ EXPT
+ MOVE
+ SHL
+ SHR
+ ROR
+ ROL
+ AND
+ OR
+ XOR
+ NOT
+ SEL
+ MAX
+ MIN
+ LIMIT
+ MUX
+ GT
+ GE
+ EQ
+ LT
+ LE
+ NE
+ LEN
+ LEFT
+ RIGHT
+ MID
+ CONCAT
+ INSERT
+ DELETE
+ REPLACE
+ FIND
+
+ TRUNC
+
+
+
+
+
+
+
+
diff -r 86ef2244aef1 -r 579db02bebd9 lib/iec_std_lib.h
--- a/lib/iec_std_lib.h Fri Apr 01 17:26:29 2011 +0200
+++ b/lib/iec_std_lib.h Mon Apr 04 17:19:35 2011 +0200
@@ -791,7 +791,7 @@
return res;
}
-/* workaround for va-atgs limitation on shorter that int params */
+/* workaround for va-args limitation on shorter than int params */
#define VA_ARGS_REAL LREAL
#define VA_ARGS_LREAL LREAL
#define VA_ARGS_SINT DINT
diff -r 86ef2244aef1 -r 579db02bebd9 lib/iec_types.h
--- a/lib/iec_types.h Fri Apr 01 17:26:29 2011 +0200
+++ b/lib/iec_types.h Mon Apr 04 17:19:35 2011 +0200
@@ -29,12 +29,10 @@
typedef float IEC_REAL;
typedef double IEC_LREAL;
-#pragma pack(push,1)
typedef struct {
long int tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
-}IEC_TIMESPEC;
-#pragma pack(pop)
+}__attribute__((packed)) IEC_TIMESPEC;
typedef IEC_TIMESPEC IEC_TIME;
typedef IEC_TIMESPEC IEC_DATE;
@@ -50,11 +48,9 @@
#endif
typedef STR_LEN_TYPE __strlen_t;
-#pragma pack(push,1)
typedef struct {
__strlen_t len;
uint8_t body[STR_MAX_LEN];
-} IEC_STRING;
-#pragma pack(pop)
+} __attribute__((packed)) IEC_STRING;
#endif /*IEC_TYPES_H*/
diff -r 86ef2244aef1 -r 579db02bebd9 lib/ieclib.txt
--- a/lib/ieclib.txt Fri Apr 01 17:26:29 2011 +0200
+++ b/lib/ieclib.txt Mon Apr 04 17:19:35 2011 +0200
@@ -1,32 +1,43 @@
(*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*)
(*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
*
*)
-(*
- * This is the library conatining the function blocks defined in the standard.
+(*******************************************************************************************************
+ * This is the library conatining the standard functions and function blocks defined in the standard. *
+ *******************************************************************************************************
*)
+(* The standard functions *)
+(*{#include "standard_functions.txt" }*)
+(* The standard function blocks *)
{#include "edge_detection.txt" }
{#include "bistable.txt" }
{#include "counter.txt" }
@@ -36,4 +47,6 @@
{#include "integral_st.txt" }
{#include "pid_st.txt" }
{#include "ramp_st.txt" }
+
+(* Some usefull non-standard function blocks *)
{#include "sema.txt" }
diff -r 86ef2244aef1 -r 579db02bebd9 lib/standard_functions.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/standard_functions.txt Mon Apr 04 17:19:35 2011 +0200
@@ -0,0 +1,2798 @@
+
+{disable code generation}
+
+
+
+
+FUNCTION REAL_TO_SINT : SINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_LINT : LINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_DINT : DINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_DATE : DATE
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_DWORD : DWORD
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_DT : DT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_TOD : TOD
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_UDINT : UDINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_WORD : WORD
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_STRING : STRING
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_LWORD : LWORD
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_UINT : UINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_LREAL : LREAL
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_BYTE : BYTE
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_USINT : USINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_ULINT : ULINT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_BOOL : BOOL
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_TIME : TIME
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION REAL_TO_INT : INT
+ VAR_INPUT IN: REAL; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_REAL : REAL
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_LINT : LINT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_DINT : DINT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_DATE : DATE
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_DWORD : DWORD
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_DT : DT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_TOD : TOD
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_UDINT : UDINT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_WORD : WORD
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_STRING : STRING
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_LWORD : LWORD
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_UINT : UINT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_LREAL : LREAL
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_BYTE : BYTE
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_USINT : USINT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_ULINT : ULINT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_BOOL : BOOL
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_TIME : TIME
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION SINT_TO_INT : INT
+ VAR_INPUT IN: SINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_REAL : REAL
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_SINT : SINT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_DINT : DINT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_DATE : DATE
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_DWORD : DWORD
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_DT : DT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_TOD : TOD
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_UDINT : UDINT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_WORD : WORD
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_STRING : STRING
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_LWORD : LWORD
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_UINT : UINT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_LREAL : LREAL
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_BYTE : BYTE
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_USINT : USINT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_ULINT : ULINT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_BOOL : BOOL
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_TIME : TIME
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LINT_TO_INT : INT
+ VAR_INPUT IN: LINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_REAL : REAL
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_SINT : SINT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_LINT : LINT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_DATE : DATE
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_DWORD : DWORD
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_DT : DT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_TOD : TOD
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_UDINT : UDINT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_WORD : WORD
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_STRING : STRING
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_LWORD : LWORD
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_UINT : UINT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_LREAL : LREAL
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_BYTE : BYTE
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_USINT : USINT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_ULINT : ULINT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_BOOL : BOOL
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_TIME : TIME
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DINT_TO_INT : INT
+ VAR_INPUT IN: DINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_REAL : REAL
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_SINT : SINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_LINT : LINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_DINT : DINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_DWORD : DWORD
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_UDINT : UDINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_WORD : WORD
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_STRING : STRING
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_LWORD : LWORD
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_UINT : UINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_LREAL : LREAL
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_BYTE : BYTE
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_USINT : USINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_ULINT : ULINT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_TO_INT : INT
+ VAR_INPUT IN: DATE; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_REAL : REAL
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_SINT : SINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_LINT : LINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_DINT : DINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_DATE : DATE
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_DT : DT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_TOD : TOD
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_UDINT : UDINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_WORD : WORD
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_STRING : STRING
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_LWORD : LWORD
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_UINT : UINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_LREAL : LREAL
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_BYTE : BYTE
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_USINT : USINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_ULINT : ULINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_BOOL : BOOL
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_TIME : TIME
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_TO_INT : INT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_REAL : REAL
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_SINT : SINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_LINT : LINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_DINT : DINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_DWORD : DWORD
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_UDINT : UDINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_WORD : WORD
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_STRING : STRING
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_LWORD : LWORD
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_UINT : UINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_LREAL : LREAL
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_BYTE : BYTE
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_USINT : USINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_ULINT : ULINT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DT_TO_INT : INT
+ VAR_INPUT IN: DT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_REAL : REAL
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_SINT : SINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_LINT : LINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_DINT : DINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_DWORD : DWORD
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_UDINT : UDINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_WORD : WORD
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_STRING : STRING
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_LWORD : LWORD
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_UINT : UINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_LREAL : LREAL
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_BYTE : BYTE
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_USINT : USINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_ULINT : ULINT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TOD_TO_INT : INT
+ VAR_INPUT IN: TOD; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_REAL : REAL
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_SINT : SINT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_LINT : LINT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_DINT : DINT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_DATE : DATE
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_DWORD : DWORD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_DT : DT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_TOD : TOD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_WORD : WORD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_STRING : STRING
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_LWORD : LWORD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_UINT : UINT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_LREAL : LREAL
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_BYTE : BYTE
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_USINT : USINT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_ULINT : ULINT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_BOOL : BOOL
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_TIME : TIME
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_INT : INT
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_REAL : REAL
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_SINT : SINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_LINT : LINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_DINT : DINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_DATE : DATE
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_DWORD : DWORD
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_DT : DT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_TOD : TOD
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_UDINT : UDINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_STRING : STRING
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_LWORD : LWORD
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_UINT : UINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_LREAL : LREAL
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_BYTE : BYTE
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_USINT : USINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_ULINT : ULINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_BOOL : BOOL
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_TIME : TIME
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_TO_INT : INT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_REAL : REAL
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_SINT : SINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_LINT : LINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_DINT : DINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_DATE : DATE
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_DWORD : DWORD
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_DT : DT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_TOD : TOD
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_UDINT : UDINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_WORD : WORD
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_LWORD : LWORD
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_UINT : UINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_LREAL : LREAL
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_BYTE : BYTE
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_USINT : USINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_ULINT : ULINT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_BOOL : BOOL
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_TIME : TIME
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION STRING_TO_INT : INT
+ VAR_INPUT IN: STRING; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_REAL : REAL
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_SINT : SINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_LINT : LINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_DINT : DINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_DATE : DATE
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_DWORD : DWORD
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_DT : DT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_TOD : TOD
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_UDINT : UDINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_WORD : WORD
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_STRING : STRING
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_UINT : UINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_LREAL : LREAL
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_BYTE : BYTE
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_USINT : USINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_ULINT : ULINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_BOOL : BOOL
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_TIME : TIME
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_TO_INT : INT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_REAL : REAL
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_SINT : SINT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_LINT : LINT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_DINT : DINT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_DATE : DATE
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_DWORD : DWORD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_DT : DT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_TOD : TOD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_UDINT : UDINT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_WORD : WORD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_STRING : STRING
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_LWORD : LWORD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_LREAL : LREAL
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_BYTE : BYTE
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_USINT : USINT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_ULINT : ULINT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_BOOL : BOOL
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_TIME : TIME
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_INT : INT
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_REAL : REAL
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_SINT : SINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_LINT : LINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_DINT : DINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_DATE : DATE
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_DWORD : DWORD
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_DT : DT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_TOD : TOD
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_UDINT : UDINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_WORD : WORD
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_STRING : STRING
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_LWORD : LWORD
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_UINT : UINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_BYTE : BYTE
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_USINT : USINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_ULINT : ULINT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_BOOL : BOOL
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_TIME : TIME
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LREAL_TO_INT : INT
+ VAR_INPUT IN: LREAL; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_REAL : REAL
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_SINT : SINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_LINT : LINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_DINT : DINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_DATE : DATE
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_DWORD : DWORD
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_DT : DT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_TOD : TOD
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_UDINT : UDINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_WORD : WORD
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_STRING : STRING
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_LWORD : LWORD
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_UINT : UINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_LREAL : LREAL
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_USINT : USINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_ULINT : ULINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_BOOL : BOOL
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_TIME : TIME
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_TO_INT : INT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_REAL : REAL
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_SINT : SINT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_LINT : LINT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_DINT : DINT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_DATE : DATE
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_DWORD : DWORD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_DT : DT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_TOD : TOD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_UDINT : UDINT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_WORD : WORD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_STRING : STRING
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_LWORD : LWORD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_UINT : UINT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_LREAL : LREAL
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_BYTE : BYTE
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_ULINT : ULINT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_BOOL : BOOL
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_TIME : TIME
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_INT : INT
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_REAL : REAL
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_SINT : SINT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_LINT : LINT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_DINT : DINT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_DATE : DATE
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_DWORD : DWORD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_DT : DT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_TOD : TOD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_UDINT : UDINT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_WORD : WORD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_STRING : STRING
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_LWORD : LWORD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_UINT : UINT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_LREAL : LREAL
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_BYTE : BYTE
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_USINT : USINT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_BOOL : BOOL
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_TIME : TIME
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_INT : INT
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_REAL : REAL
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_SINT : SINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_LINT : LINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_DINT : DINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_DATE : DATE
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_DWORD : DWORD
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_DT : DT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_TOD : TOD
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_UDINT : UDINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_WORD : WORD
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_STRING : STRING
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_LWORD : LWORD
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_UINT : UINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_LREAL : LREAL
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_BYTE : BYTE
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_USINT : USINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_ULINT : ULINT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_TIME : TIME
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BOOL_TO_INT : INT
+ VAR_INPUT IN: BOOL; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_REAL : REAL
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_SINT : SINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_LINT : LINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_DINT : DINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_DWORD : DWORD
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_UDINT : UDINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_WORD : WORD
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_STRING : STRING
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_LWORD : LWORD
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_UINT : UINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_LREAL : LREAL
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_BYTE : BYTE
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_USINT : USINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_ULINT : ULINT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION TIME_TO_INT : INT
+ VAR_INPUT IN: TIME; END_VAR
+ VAR_OUTPUT OUT: INT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_REAL : REAL
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: REAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_SINT : SINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: SINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_LINT : LINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: LINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_DINT : DINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: DINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_DATE : DATE
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_DWORD : DWORD
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_DT : DT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: DT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_TOD : TOD
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: TOD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_UDINT : UDINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_WORD : WORD
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_STRING : STRING
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: STRING; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_LWORD : LWORD
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_UINT : UINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_LREAL : LREAL
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: LREAL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_BYTE : BYTE
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_USINT : USINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_ULINT : ULINT
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_BOOL : BOOL
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: BOOL; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION INT_TO_TIME : TIME
+ VAR_INPUT IN: INT; END_VAR
+ VAR_OUTPUT OUT: TIME; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_AND_TIME_TO_TIME_OF_DAY : TIME_OF_DAY
+ VAR_INPUT IN: DATE_AND_TIME; END_VAR
+ VAR_OUTPUT OUT: TIME_OF_DAY; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DATE_AND_TIME_TO_DATE : DATE
+ VAR_INPUT IN: DATE_AND_TIME; END_VAR
+ VAR_OUTPUT OUT: DATE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+(* *BCD_TO_** and **_TO_BCD* are not yet supported *)
+(* We comment them out for now... *)
+(*
+
+
+FUNCTION UDINT_TO_BCD_BYTE : BYTE
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_BCD_WORD : WORD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_BCD_DWORD : DWORD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UDINT_TO_BCD_LWORD : LWORD
+ VAR_INPUT IN: UDINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_BCD_BYTE : BYTE
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_BCD_WORD : WORD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_BCD_DWORD : DWORD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION UINT_TO_BCD_LWORD : LWORD
+ VAR_INPUT IN: UINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_BCD_BYTE : BYTE
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_BCD_WORD : WORD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_BCD_DWORD : DWORD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION USINT_TO_BCD_LWORD : LWORD
+ VAR_INPUT IN: USINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_BCD_BYTE : BYTE
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: BYTE; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_BCD_WORD : WORD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: WORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_BCD_DWORD : DWORD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: DWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION ULINT_TO_BCD_LWORD : LWORD
+ VAR_INPUT IN: ULINT; END_VAR
+ VAR_OUTPUT OUT: LWORD; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_BCD_TO_UDINT : UDINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_BCD_TO_UDINT : UDINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_BCD_TO_UDINT : UDINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_BCD_TO_UDINT : UDINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: UDINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_BCD_TO_UINT : UINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_BCD_TO_UINT : UINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_BCD_TO_UINT : UINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_BCD_TO_UINT : UINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: UINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_BCD_TO_USINT : USINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_BCD_TO_USINT : USINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_BCD_TO_USINT : USINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_BCD_TO_USINT : USINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: USINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION BYTE_BCD_TO_ULINT : ULINT
+ VAR_INPUT IN: BYTE; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION WORD_BCD_TO_ULINT : ULINT
+ VAR_INPUT IN: WORD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION DWORD_BCD_TO_ULINT : ULINT
+ VAR_INPUT IN: DWORD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+
+
+FUNCTION LWORD_BCD_TO_ULINT : ULINT
+ VAR_INPUT IN: LWORD; END_VAR
+ VAR_OUTPUT OUT: ULINT; END_VAR
+ LD TRUE
+END_FUNCTION
+*)
+
+{enable code generation}
diff -r 86ef2244aef1 -r 579db02bebd9 main.cc
--- a/main.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/main.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,27 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -97,6 +103,10 @@
/* Version 1.0 – Official Release */
/******************************************************/
printf(" s : allow use of safe extensions\n");
+ printf("\n");
+ printf("%s - Copyright (C) 2003-2011 \n"
+ "This program comes with ABSOLUTELY NO WARRANTY!\n"
+ "This is free software licensed under GPL v3, and you are welcome to redistribute it under the conditions specified by this license.\n", cmd);
}
diff -r 86ef2244aef1 -r 579db02bebd9 readme
--- a/readme Fri Apr 01 17:26:29 2011 +0200
+++ b/readme Mon Apr 04 17:19:35 2011 +0200
@@ -1,14 +1,14 @@
- IEC 61131-3 IL and ST compiler
+ MATIEC - IEC 61131-3 compiler
The following compiler has been based on the
FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
- (c) 2003 Mario de Sousa
+ Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
@@ -27,7 +27,7 @@
The compiler works in 4(+1) stages:
Stage 1 - Lexical analyser - implemented with flex (iec.flex)
Stage 2 - Syntax parser - implemented with bison (iec.y)
- Stage 3 - Semantics analyser - not yet implemented
+ Stage 3 - Semantics analyser - currently in its early stages
Stage 4 - Code generator - implemented in C++
Stage 4+1 - Binary code generator - gcc, javac, etc...
@@ -56,22 +56,6 @@
NOTE 2
======
- I (Mario) have a feeling that the abstract syntax may be
-considerably simplified without any drawbacks to semantic checking
-and code generation. I have nevertheless opted to keep as much
-info as possible in the abstract syntax tree, in case it may become
-necessary further on.
- Once we start coding the next stages (semantic checking and code
-generation) I will get a better understanding of what is required
-of the abstract syntax tree. At that stage I will be better
-positioned to make a more informed decision on how best to structure
-the abstract syntax tree.
- For now, we play conservative and keep as much info as possible.
-
-
-
- NOTE 3
- ======
It would be nice to get this parser integrated into the gcc
group of compilers. We would then be able to compile our st/il
programs directly into executable binaries, for all the processor
@@ -145,10 +129,11 @@
We extend the IEC 61131-3 standard syntax to allow inclusion of
other files. The accepted syntax is:
- (*#include "" *)
-
-Note how this would be ignored by other standard complient compilers
-as a simple comment!
+ {#include "" }
+
+We use a pragma directive for this (allowed by the standard itself),
+ since it is an extension of the standard. In principle, this would
+be ignored by other standard complient compilers!
@@ -403,4 +388,4 @@
**************************************************************************
- (c) 2003 Mario de Sousa
+ Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/Makefile
--- a/stage1_2/Makefile Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/Makefile Mon Apr 04 17:19:35 2011 +0200
@@ -3,7 +3,7 @@
-default: all
+default: all
all: iec.flex.o iec.y.o stage1_2.o
@@ -15,6 +15,7 @@
-rm -f stage1_2.o
-rm -f iec.y.o
-rm -f iec.flex.o
+ -rm -f Makefile.depend
CFLAGS += -I. -I../* -I../../absyntax
@@ -22,7 +23,8 @@
iec.flex.c: iec.flex
flex -oiec.flex.c iec.flex
-stage1_2.cc: iec.y.hh
+stage1_2.cc: iec.y.hh
+stage1_2.o: stage1_2.cc
iec.flex.o: iec.y.hh iec.flex.c
$(CXX) -c iec.flex.c -D DEFAULT_LIBDIR='"$(IECLIBDIR)"' $(CFLAGS)
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/iec.flex
--- a/stage1_2/iec.flex Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/iec.flex Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -84,6 +91,9 @@
*/
%option noyy_top_state
+/* We will not be using unput() in our flex code... */
+%option nounput
+
/**************************************************/
/* External Variable and Function declarations... */
/**************************************************/
@@ -144,6 +154,14 @@
/* We will not be using unput() in our flex code... */
+/* NOTE: it seems that this #define is no longer needed, It has been
+ * replaced by %option nounput.
+ * Should we simply delete it?
+ * For now leave it in, in case someone is using an old version of flex.
+ * In any case, the most harm that can result in a warning message
+ * when compiling iec.flex.c:
+ * warning: ‘void yyunput(int, char*)’ defined but not used
+ */
#define YY_NO_UNPUT
/* Variable defined by the bison parser.
@@ -438,8 +456,28 @@
/* Prelimenary constructs... */
/*****************************/
-
-/* A pragma... */
+/* In order to allow the declaration of POU prototypes (Function, FB, Program, ...),
+ * especially the prototypes of Functions and FBs defined in the standard
+ * (i.e. standard functions and FBs), we extend the IEC 61131-3 standard syntax
+ * with two pragmas to indicate that the code is to be parsed (going through the
+ * lexical, syntactical, and semantic analysers), but no code is to be generated.
+ *
+ * The accepted syntax is:
+ * {no_code_generation begin}
+ * ... prototypes ...
+ * {no_code_generation end}
+ *
+ * When parsing these prototypes the abstract syntax tree will be populated as usual,
+ * allowing the semantic analyser to correctly analyse the semantics of calls to these
+ * functions/FBs. However, stage4 will simply ignore all IEC61131-3 code
+ * between the above two pragmas.
+ */
+
+disable_code_generation_pragma "{disable code generation}"
+enable_code_generation_pragma "{enable code generation}"
+
+
+/* Any other pragma... */
pragma "{"[^}]*"}"
@@ -726,6 +764,12 @@
/* We start off by searching for the pragmas we handle in the lexical parser. */
{file_include_pragma} unput_text(0); yy_push_state(include_beg);
+ /* Pragmas sent to syntax analyser (bison) */
+{disable_code_generation_pragma} return disable_code_generation_pragma_token;
+{enable_code_generation_pragma} return enable_code_generation_pragma_token;
+{disable_code_generation_pragma} return disable_code_generation_pragma_token;
+{enable_code_generation_pragma} return enable_code_generation_pragma_token;
+
/* Any other pragma we find, we just pass it up to the syntax parser... */
/* Note that the state is exclusive, so we have to include it here too. */
{pragma} {/* return the pragmma without the enclosing '{' and '}' */
@@ -964,6 +1008,7 @@
{il_whitespace_no_pragma} /* Eat any whitespace */
+
/*****************************************/
/* B.1.1 Letters, digits and identifiers */
/*****************************************/
@@ -1034,11 +1079,16 @@
/* B 1.2.1 - Numeric Literals */
/******************************/
TRUE return TRUE; /* Keyword */
-BOOL#1 return TRUE; /* Keyword (Data Type) + Delimiter */
-BOOL#TRUE return TRUE; /* Keyword (Data Type) + Delimiter + Keyword */
+BOOL#1 return boolean_true_literal_token;
+BOOL#TRUE return boolean_true_literal_token;
+SAFEBOOL#1 {if (get_opt_safe_extensions()) {return safeboolean_true_literal_token;} else{REJECT;}} /* Keyword (Data Type) */
+SAFEBOOL#TRUE {if (get_opt_safe_extensions()) {return safeboolean_true_literal_token;} else{REJECT;}} /* Keyword (Data Type) */
+
FALSE return FALSE; /* Keyword */
-BOOL#0 return FALSE; /* Keyword (Data Type) + Delimiter */
-BOOL#FALSE return FALSE; /* Keyword (Data Type) + Delimiter + Keyword */
+BOOL#0 return boolean_false_literal_token;
+BOOL#FALSE return boolean_false_literal_token;
+SAFEBOOL#0 {if (get_opt_safe_extensions()) {return safeboolean_false_literal_token;} else{REJECT;}} /* Keyword (Data Type) */
+SAFEBOOL#FALSE {if (get_opt_safe_extensions()) {return safeboolean_false_literal_token;} else{REJECT;}} /* Keyword (Data Type) */
/************************/
@@ -1064,11 +1114,82 @@
/***********************************/
/* B 1.3.1 - Elementary Data Types */
/***********************************/
+BOOL return BOOL; /* Keyword (Data Type) */
+
BYTE return BYTE; /* Keyword (Data Type) */
WORD return WORD; /* Keyword (Data Type) */
DWORD return DWORD; /* Keyword (Data Type) */
LWORD return LWORD; /* Keyword (Data Type) */
+SINT return SINT; /* Keyword (Data Type) */
+INT return INT; /* Keyword (Data Type) */
+DINT return DINT; /* Keyword (Data Type) */
+LINT return LINT; /* Keyword (Data Type) */
+
+USINT return USINT; /* Keyword (Data Type) */
+UINT return UINT; /* Keyword (Data Type) */
+UDINT return UDINT; /* Keyword (Data Type) */
+ULINT return ULINT; /* Keyword (Data Type) */
+
+REAL return REAL; /* Keyword (Data Type) */
+LREAL return LREAL; /* Keyword (Data Type) */
+
+WSTRING return WSTRING; /* Keyword (Data Type) */
+STRING return STRING; /* Keyword (Data Type) */
+
+TIME return TIME; /* Keyword (Data Type) */
+DATE return DATE; /* Keyword (Data Type) */
+DT return DT; /* Keyword (Data Type) */
+TOD return TOD; /* Keyword (Data Type) */
+DATE_AND_TIME return DATE_AND_TIME; /* Keyword (Data Type) */
+TIME_OF_DAY return TIME_OF_DAY; /* Keyword (Data Type) */
+
+ /*****************************************************************/
+ /* Keywords defined in "Safety Software Technical Specification" */
+ /*****************************************************************/
+ /*
+ * NOTE: The following keywords are define in
+ * "Safety Software Technical Specification,
+ * Part 1: Concepts and Function Blocks,
+ * Version 1.0 – Official Release"
+ * written by PLCopen - Technical Committee 5
+ *
+ * We only support these extensions and keywords
+ * if the apropriate command line option is given.
+ */
+SAFEBOOL {if (get_opt_safe_extensions()) {return SAFEBOOL;} else {REJECT;}}
+
+SAFEBYTE {if (get_opt_safe_extensions()) {return SAFEBYTE;} else {REJECT;}}
+SAFEWORD {if (get_opt_safe_extensions()) {return SAFEWORD;} else {REJECT;}}
+SAFEDWORD {if (get_opt_safe_extensions()) {return SAFEDWORD;} else{REJECT;}}
+SAFELWORD {if (get_opt_safe_extensions()) {return SAFELWORD;} else{REJECT;}}
+
+SAFEREAL {if (get_opt_safe_extensions()) {return SAFESINT;} else{REJECT;}}
+SAFELREAL {if (get_opt_safe_extensions()) {return SAFELREAL;} else{REJECT;}}
+
+SAFESINT {if (get_opt_safe_extensions()) {return SAFESINT;} else{REJECT;}}
+SAFEINT {if (get_opt_safe_extensions()) {return SAFEINT;} else{REJECT;}}
+SAFEDINT {if (get_opt_safe_extensions()) {return SAFEDINT;} else{REJECT;}}
+SAFELINT {if (get_opt_safe_extensions()) {return SAFELINT;} else{REJECT;}}
+
+SAFEUSINT {if (get_opt_safe_extensions()) {return SAFEUSINT;} else{REJECT;}}
+SAFEUINT {if (get_opt_safe_extensions()) {return SAFEUINT;} else{REJECT;}}
+SAFEUDINT {if (get_opt_safe_extensions()) {return SAFEUDINT;} else{REJECT;}}
+SAFEULINT {if (get_opt_safe_extensions()) {return SAFEULINT;} else{REJECT;}}
+
+ /* SAFESTRING and SAFEWSTRING are not yet supported, i.e. checked correctly, in the semantic analyser (stage 3) */
+ /* so it is best not to support them at all... */
+ /*
+SAFEWSTRING {if (get_opt_safe_extensions()) {return SAFEWSTRING;} else{REJECT;}}
+SAFESTRING {if (get_opt_safe_extensions()) {return SAFESTRING;} else{REJECT;}}
+ */
+
+SAFETIME {if (get_opt_safe_extensions()) {return SAFETIME;} else{REJECT;}}
+SAFEDATE {if (get_opt_safe_extensions()) {return SAFEDATE;} else{REJECT;}}
+SAFEDT {if (get_opt_safe_extensions()) {return SAFEDT;} else{REJECT;}}
+SAFETOD {if (get_opt_safe_extensions()) {return SAFETOD;} else{REJECT;}}
+SAFEDATE_AND_TIME {if (get_opt_safe_extensions()) {return SAFEDATE_AND_TIME;} else{REJECT;}}
+SAFETIME_OF_DAY {if (get_opt_safe_extensions()) {return SAFETIME_OF_DAY;} else{REJECT;}}
/********************************/
/* B 1.3.2 - Generic data types */
@@ -1105,30 +1226,6 @@
/*********************/
/* B 1.4 - Variables */
/*********************/
-REAL return REAL; /* Keyword (Data Type) */
-LREAL return LREAL; /* Keyword (Data Type) */
-
-SINT return SINT; /* Keyword (Data Type) */
-INT return INT; /* Keyword (Data Type) */
-DINT return DINT; /* Keyword (Data Type) */
-LINT return LINT; /* Keyword (Data Type) */
-
-USINT return USINT; /* Keyword (Data Type) */
-UINT return UINT; /* Keyword (Data Type) */
-UDINT return UDINT; /* Keyword (Data Type) */
-ULINT return ULINT; /* Keyword (Data Type) */
-
-
-WSTRING return WSTRING; /* Keyword (Data Type) */
-STRING return STRING; /* Keyword (Data Type) */
-BOOL return BOOL; /* Keyword (Data Type) */
-TIME return TIME; /* Keyword (Data Type) */
-DATE return DATE; /* Keyword (Data Type) */
-DT return DT; /* Keyword (Data Type) */
-TOD return TOD; /* Keyword (Data Type) */
-DATE_AND_TIME return DATE_AND_TIME; /* Keyword (Data Type) */
-TIME_OF_DAY return TIME_OF_DAY; /* Keyword (Data Type) */
-
/******************************************/
/* B 1.4.3 - Declaration & Initialisation */
@@ -1388,20 +1485,7 @@
EXIT return EXIT; /* Keyword */
- /*****************************************************************/
- /* Keywords defined in "Safety Software Technical Specification" */
- /*****************************************************************/
- /*
- * NOTE: The following keywords are define in
- * "Safety Software Technical Specification,
- * Part 1: Concepts and Function Blocks,
- * Version 1.0 – Official Release"
- * written by PLCopen - Technical Committee 5
- *
- * We only support these extensions and keywords
- * if the apropriate command line option is given.
- */
-SAFEBOOL {if (get_opt_safe_extensions()) {return SAFEBOOL;} else{REJECT;}} /* Keyword (Data Type) */
+
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/iec.y
--- a/stage1_2/iec.y Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/iec.y Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003-2007 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL, ST and SFC compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -283,11 +290,26 @@
/* B XXX - Things that are missing from the standard, but should have been there! */
/**********************************************************************************/
-
-/* The pragmas... */
+/* Pragmas that our compiler will accept.
+ * See the comment in iec.flex for why these pragmas exist.
+ */
+%token disable_code_generation_pragma_token
+%token enable_code_generation_pragma_token
+%type disable_code_generation_pragma
+%type enable_code_generation_pragma
+
+
+/* All other pragmas that we do not support... */
+/* In most stage 4, the text inside the pragmas will simply be copied to the output file.
+ * This allows us to insert C code (if using stage 4 generating C code)
+ * inside/interningled with the IEC 61131-3 code!
+ */
%token pragma_token
%type pragma
+/* The joining of all previous pragmas, i.e. any possible pragma */
+%type any_pragma
+
/* Where do these tokens belong?? They are missing from the standard! */
/* NOTE: There are other tokens related to these 'EN' ENO', that are also
@@ -326,9 +348,7 @@
/* B 1.2 - Constants */
/*********************/
%type constant
-/* a helper symbol for expression */
-%type non_negative_constant
-
+%type non_negative_constant
/******************************/
/* B 1.2.1 - Numeric Literals */
@@ -337,12 +357,8 @@
bit
*/
%type numeric_literal
-/* helper symbol for non_negative_constant */
-%type non_negative_numeric_literal
%type integer_literal
%type signed_integer
-/* a helper symbol for non_negative_constant */
-%type non_negative_signed_integer
%token integer_token
%type integer
%token binary_integer_token
@@ -354,15 +370,16 @@
%token real_token
%type real
%type signed_real
-/* helper symbol for non_negative_real_literal */
-%type non_negative_signed_real
%type real_literal
-/* helper symbol for non_negative_numeric_literal */
-%type non_negative_real_literal
// %type exponent
%type bit_string_literal
%type boolean_literal
+%token safeboolean_true_literal_token
+%token safeboolean_false_literal_token
+%token boolean_true_literal_token
+%token boolean_false_literal_token
+
%token FALSE
%token TRUE
@@ -419,7 +436,7 @@
%token fixed_point_ms_token
%token integer_ms_token
-%token TIME
+// %token TIME
%token T_SHARP
@@ -438,10 +455,10 @@
%type day
%type date_and_time
-%token TIME_OF_DAY
-%token DATE
+// %token TIME_OF_DAY
+// %token DATE
%token D_SHARP
-%token DATE_AND_TIME
+// %token DATE_AND_TIME
/**********************/
@@ -522,13 +539,49 @@
%token STRING
%token BOOL
-// %token TIME
-// %token DATE
-// %token DATE_AND_TIME
+%token TIME
+%token DATE
+%token DATE_AND_TIME
%token DT
-// %token TIME_OF_DAY
+%token TIME_OF_DAY
%token TOD
+/******************************************************/
+/* Symbols defined in */
+/* "Safety Software Technical Specification, */
+/* Part 1: Concepts and Function Blocks, */
+/* Version 1.0 – Official Release" */
+/* by PLCopen - Technical Committee 5 - 2006-01-31 */
+/******************************************************/
+
+%token SAFEBYTE
+%token SAFEWORD
+%token SAFEDWORD
+%token SAFELWORD
+
+%token SAFELREAL
+%token SAFEREAL
+
+%token SAFESINT
+%token SAFEINT
+%token SAFEDINT
+%token SAFELINT
+
+%token SAFEUSINT
+%token SAFEUINT
+%token SAFEUDINT
+%token SAFEULINT
+
+%token SAFEWSTRING
+%token SAFESTRING
+%token SAFEBOOL
+
+%token SAFETIME
+%token SAFEDATE
+%token SAFEDATE_AND_TIME
+%token SAFEDT
+%token SAFETIME_OF_DAY
+%token SAFETOD
/********************************/
/* B 1.3.2 - Generic data types */
@@ -1168,6 +1221,7 @@
%type unary_expression
// %type unary_operator
%type primary_expression
+%type non_negative_primary_expression
/* intermediate helper symbol for primary_expression */
%type function_invocation
@@ -1274,15 +1328,6 @@
%token EXIT
-/******************************************************/
-/* Symbols defined in */
-/* "Safety Software Technical Specification, */
-/* Part 1: Concepts and Function Blocks, */
-/* Version 1.0 – Official Release" */
-/* by PLCopen - Technical Committee 5 - 2006-01-31 */
-/******************************************************/
-%token SAFEBOOL
-
%%
@@ -1346,9 +1391,23 @@
/* the pragmas... */
+
+
+disable_code_generation_pragma:
+ disable_code_generation_pragma_token {$$ = new disable_code_generation_pragma_c(locloc(@$));}
+
+enable_code_generation_pragma:
+ enable_code_generation_pragma_token {$$ = new enable_code_generation_pragma_c(locloc(@$));}
+
pragma:
pragma_token {$$ = new pragma_c($1, locloc(@$));}
+any_pragma:
+ disable_code_generation_pragma
+| enable_code_generation_pragma
+| pragma
+;
+
/* EN/ENO */
/* Tese tokens are essentially used as variable names, so we handle them
@@ -1454,6 +1513,8 @@
}
| library library_element_declaration
{$$ = $1; $$->add_element($2);}
+| library any_pragma
+ {$$ = $1; $$->add_element($2);}
/* ERROR_CHECK_BEGIN */
| library error library_element_declaration
{$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;}
@@ -1597,10 +1658,23 @@
| bit_string_literal
| boolean_literal
/* NOTE: in order to remove reduce/reduce conflicts,
+ * [between -9.5 being parsed as
+ * (i) a signed real,
+ * (ii) or as a real preceded by the '-' operator
+ * ]
+ * we need to define a variant of the constant construct
+ * where any constant is never preceded by the '-' character.
+ * In order to do this, we have borugh the signed_real
+ * directly into the definition of the constant construct
+ * (so we can define another non_negative_constant
+ * construct that does not include it!)
+ */
+| signed_real
+/* NOTE: in order to remove reduce/reduce conflicts,
* unsigned_integer, signed_integer, binary_integer, octal_integer
* and hex_integer have been integrated directly into
* the constants construct, instead of belonging to
- * either the bit_string_literal or integer_literal
+ * both the bit_string_literal or integer_literal
* construct.
*/
/* NOTE: unsigned_integer, although used in some
@@ -1614,24 +1688,58 @@
| hex_integer
;
-/* a helper symbol for expression */
-/* A constant without any preceding '-', but may
- * include a preceding '+' !
+
+/* NOTE: in order to remove reduce/reduce conflicts,
+ * [between -9.5 being parsed as
+ * (i) a signed real,
+ * (ii) or as a real preceded by the '-' operator
+ * ]
+ * we need to define a variant of the constant construct
+ * where any constant is never preceded by the '-' character.
+ * In order to do this, we have borugh the signed_real
+ * directly into the definition of the constant construct
+ * (so we can define another non_negative_constant
+ * construct that does not include it!)
*/
non_negative_constant:
- non_negative_numeric_literal
+ numeric_literal
| character_string
| time_literal
| bit_string_literal
| boolean_literal
-| non_negative_signed_integer
+/* NOTE: in order to remove reduce/reduce conflicts,
+ * [between -9.5 being parsed as
+ * (i) a signed real,
+ * (ii) or as a real preceded by the '-' operator
+ * ]
+ * we need to define a variant of the constant construct
+ * where any constant is never preceded by the '-' character.
+ * In order to do this, we have borugh the signed_real
+ * directly into the definition of the constant construct
+ * (so we can define another non_negative_constant
+ * construct that does not include it!)
+ */
+/* | signed_real */
+| real /* an unsigned real */
+/* NOTE: in order to remove reduce/reduce conflicts,
+ * unsigned_integer, signed_integer, binary_integer, octal_integer
+ * and hex_integer have been integrated directly into
+ * the constants construct, instead of belonging to
+ * both the bit_string_literal or integer_literal
+ * construct.
+ */
+/* NOTE: unsigned_integer, although used in some
+ * rules, is not defined in the spec!
+ * We therefore replaced unsigned_integer as integer
+ */
+| integer /* i.e. an unsigned_integer */
+/* | signed_integer */
| binary_integer
| octal_integer
| hex_integer
;
-
/******************************/
/* B 1.2.1 - Numeric Literals */
/******************************/
@@ -1663,7 +1771,7 @@
* Flex handles real, while bison handles signed_real
* and real_literal.
*
- * - According to the spec, intger '.' integer
+ * - According to the spec, integer '.' integer
* may be reduced to either a real or a fixed_point.
* It is nevertheless possible to figure out from the
* context which of the two rules should be used in
@@ -1720,12 +1828,6 @@
| real_literal
;
-/* helper symbol for non_negative_constant */
-non_negative_numeric_literal:
- integer_literal
-| non_negative_real_literal
-;
-
integer_literal:
integer_type_name '#' signed_integer
@@ -1761,22 +1863,16 @@
signed_integer:
integer
| '+' integer {$$ = $2;}
-| '-' integer {$$ = new neg_literal_c($2, locloc(@$));}
-;
-
-/* a helper symbol for non_negative_constant */
-/* A integer without any preceding '-', but may
- * include a preceding '+' !
- */
-non_negative_signed_integer:
- integer
-| '+' integer {$$ = $2;}
+| '-' integer {$$ = new neg_integer_c($2, locloc(@$));}
;
real_literal:
- signed_real
-| real_type_name '#' signed_real
+/* NOTE: see note in the definition of constant for reason
+ * why signed_real is missing here!
+ */
+/* signed_real */
+ real_type_name '#' signed_real
{$$ = new real_literal_c($1, $3, locf(@1), locl(@3));}
/* ERROR_CHECK_BEGIN */
| real_type_name signed_real
@@ -1790,24 +1886,13 @@
/* ERROR_CHECK_END */
;
-/* helper symbol for non_negative_numeric_literal */
-non_negative_real_literal:
- non_negative_signed_real
-| real_type_name '#' signed_real
- {$$ = new real_literal_c($1, $3, locf(@1), locl(@3));}
-;
signed_real:
real
| '+' real {$$ = $2;}
-| '-' real {$$ = new neg_literal_c($2, locloc(@2));}
-;
-
-/* helper symbol for non_negative_real_literal */
-non_negative_signed_real:
- real
-| '+' real {$$ = $2;}
-;
+| '-' real {$$ = new neg_real_c($2, locloc(@2));}
+;
+
bit_string_literal:
@@ -1838,7 +1923,7 @@
| bit_string_type_name hex_integer
{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;}
| bit_string_type_name '#' error
- {$$ = NULL;
+ {$$ = NULL;
if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for bit string literal.");}
else {print_err_msg(locf(@3), locl(@3), "invalid value for bit string literal."); yyclearin;}
yyerrok;
@@ -1848,12 +1933,36 @@
boolean_literal:
- TRUE {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)),
- new boolean_true_c(locloc(@$)),
- locloc(@$));}
-| FALSE {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)),
+ boolean_true_literal_token
+ {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)),
+ new boolean_true_c(locloc(@$)),
+ locloc(@$));
+ }
+| boolean_false_literal_token
+ {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)),
new boolean_false_c(locloc(@$)),
- locloc(@$));}
+ locloc(@$));
+ }
+| safeboolean_true_literal_token
+ {$$ = new boolean_literal_c(new safebool_type_name_c(locloc(@$)),
+ new boolean_true_c(locloc(@$)),
+ locloc(@$));
+ }
+| safeboolean_false_literal_token
+ {$$ = new boolean_literal_c(new safebool_type_name_c(locloc(@$)),
+ new boolean_false_c(locloc(@$)),
+ locloc(@$));
+ }
+| FALSE
+ {$$ = new boolean_literal_c(NULL,
+ new boolean_false_c(locloc(@$)),
+ locloc(@$));
+ }
+| TRUE
+ {$$ = new boolean_literal_c(NULL,
+ new boolean_true_c(locloc(@$)),
+ locloc(@$));
+ }
/*
| BOOL '#' '1' {}
| BOOL '#' '0' {}
@@ -1935,13 +2044,17 @@
* when it comes across 'T#'
*/
TIME '#' interval
- {$$ = new duration_c(NULL, $3, locloc(@$));}
+ {$$ = new duration_c(new time_type_name_c(locloc(@1)), NULL, $3, locloc(@$));}
| TIME '#' '-' interval
- {$$ = new duration_c(new neg_time_c(locloc(@$)), $4, locloc(@$));}
+ {$$ = new duration_c(new time_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $4, locloc(@$));}
| T_SHARP interval
- {$$ = new duration_c(NULL, $2, locloc(@$));}
+ {$$ = new duration_c(new time_type_name_c(locloc(@1)), NULL, $2, locloc(@$));}
| T_SHARP '-' interval
- {$$ = new duration_c(new neg_time_c(locloc(@$)), $3, locloc(@$));}
+ {$$ = new duration_c(new time_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $3, locloc(@$));}
+| SAFETIME '#' interval
+ {$$ = new duration_c(new safetime_type_name_c(locloc(@1)), NULL, $3, locloc(@$));}
+| SAFETIME '#' '-' interval
+ {$$ = new duration_c(new safetime_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $4, locloc(@$));}
/* ERROR_CHECK_BEGIN */
| TIME interval
{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;}
@@ -2106,7 +2219,9 @@
/************************************/
time_of_day:
TIME_OF_DAY '#' daytime
- {$$ = new time_of_day_c($3, locloc(@$));}
+ {$$ = new time_of_day_c(new tod_type_name_c(locloc(@1)), $3, locloc(@$));}
+| SAFETIME_OF_DAY '#' daytime
+ {$$ = new time_of_day_c(new safetod_type_name_c(locloc(@1)), $3, locloc(@$));}
/* ERROR_CHECK_BEGIN */
| TIME_OF_DAY daytime
{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME_OF_DAY' and daytime in time of day."); yynerrs++;}
@@ -2153,9 +2268,11 @@
date:
DATE '#' date_literal
- {$$ = new date_c($3, locloc(@$));}
+ {$$ = new date_c(new date_type_name_c(locloc(@1)), $3, locloc(@$));}
| D_SHARP date_literal
- {$$ = new date_c($2, locloc(@$));}
+ {$$ = new date_c(new date_type_name_c(locloc(@1)), $2, locloc(@$));}
+| SAFEDATE '#' date_literal
+ {$$ = new date_c(new safedate_type_name_c(locloc(@1)), $3, locloc(@$));}
/* ERROR_CHECK_BEGIN */
| DATE date_literal
{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE' and date literal in date."); yynerrs++;}
@@ -2206,7 +2323,9 @@
date_and_time:
DATE_AND_TIME '#' date_literal '-' daytime
- {$$ = new date_and_time_c($3, $5, locloc(@$));}
+ {$$ = new date_and_time_c(new dt_type_name_c(locloc(@1)), $3, $5, locloc(@$));}
+| SAFEDATE_AND_TIME '#' date_literal '-' daytime
+ {$$ = new date_and_time_c(new safedt_type_name_c(locloc(@1)), $3, $5, locloc(@$));}
/* ERROR_CHECK_BEGIN */
| DATE_AND_TIME date_literal '-' daytime
{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE_AND_TIME' and date literal in date and time."); yynerrs++;}
@@ -2251,6 +2370,14 @@
/***********************************/
/* B 1.3.1 - Elementary Data Types */
/***********************************/
+ /******************************************************/
+ /* SAFExxxx Symbols defined in */
+ /* "Safety Software Technical Specification, */
+ /* Part 1: Concepts and Function Blocks, */
+ /* Version 1.0 – Official Release" */
+ /* by PLCopen - Technical Committee 5 - 2006-01-31 */
+ /******************************************************/
+
elementary_type_name:
numeric_type_name
| date_type_name
@@ -2262,13 +2389,7 @@
* and grouping type definition for reason why BOOL
* was added to this definition.
*/
- /******************************************************/
- /* Symbols defined in */
- /* "Safety Software Technical Specification, */
- /* Part 1: Concepts and Function Blocks, */
- /* Version 1.0 – Official Release" */
- /* by PLCopen - Technical Committee 5 - 2006-01-31 */
- /******************************************************/
+| SAFETIME {$$ = new safetime_type_name_c(locloc(@$));}
| SAFEBOOL {$$ = new safebool_type_name_c(locloc(@$));}
;
@@ -2283,38 +2404,57 @@
;
signed_integer_type_name:
- SINT {$$ = new sint_type_name_c(locloc(@$));}
-| INT {$$ = new int_type_name_c(locloc(@$));}
-| DINT {$$ = new dint_type_name_c(locloc(@$));}
-| LINT {$$ = new lint_type_name_c(locloc(@$));}
+ SINT {$$ = new sint_type_name_c(locloc(@$));}
+| INT {$$ = new int_type_name_c(locloc(@$));}
+| DINT {$$ = new dint_type_name_c(locloc(@$));}
+| LINT {$$ = new lint_type_name_c(locloc(@$));}
+| SAFESINT {$$ = new safesint_type_name_c(locloc(@$));}
+| SAFEINT {$$ = new safeint_type_name_c(locloc(@$));}
+| SAFEDINT {$$ = new safedint_type_name_c(locloc(@$));}
+| SAFELINT {$$ = new safelint_type_name_c(locloc(@$));}
;
unsigned_integer_type_name:
- USINT {$$ = new usint_type_name_c(locloc(@$));}
-| UINT {$$ = new uint_type_name_c(locloc(@$));}
-| UDINT {$$ = new udint_type_name_c(locloc(@$));}
-| ULINT {$$ = new ulint_type_name_c(locloc(@$));}
+ USINT {$$ = new usint_type_name_c(locloc(@$));}
+| UINT {$$ = new uint_type_name_c(locloc(@$));}
+| UDINT {$$ = new udint_type_name_c(locloc(@$));}
+| ULINT {$$ = new ulint_type_name_c(locloc(@$));}
+| SAFEUSINT {$$ = new safeusint_type_name_c(locloc(@$));}
+| SAFEUINT {$$ = new safeuint_type_name_c(locloc(@$));}
+| SAFEUDINT {$$ = new safeudint_type_name_c(locloc(@$));}
+| SAFEULINT {$$ = new safeulint_type_name_c(locloc(@$));}
;
real_type_name:
- REAL {$$ = new real_type_name_c(locloc(@$));}
-| LREAL {$$ = new lreal_type_name_c(locloc(@$));}
+ REAL {$$ = new real_type_name_c(locloc(@$));}
+| LREAL {$$ = new lreal_type_name_c(locloc(@$));}
+| SAFEREAL {$$ = new safereal_type_name_c(locloc(@$));}
+| SAFELREAL {$$ = new safelreal_type_name_c(locloc(@$));}
;
date_type_name:
- DATE {$$ = new date_type_name_c(locloc(@$));}
-| TIME_OF_DAY {$$ = new tod_type_name_c(locloc(@$));}
-| TOD {$$ = new tod_type_name_c(locloc(@$));}
-| DATE_AND_TIME {$$ = new dt_type_name_c(locloc(@$));}
-| DT {$$ = new dt_type_name_c(locloc(@$));}
+ DATE {$$ = new date_type_name_c(locloc(@$));}
+| TIME_OF_DAY {$$ = new tod_type_name_c(locloc(@$));}
+| TOD {$$ = new tod_type_name_c(locloc(@$));}
+| DATE_AND_TIME {$$ = new dt_type_name_c(locloc(@$));}
+| DT {$$ = new dt_type_name_c(locloc(@$));}
+| SAFEDATE {$$ = new safedate_type_name_c(locloc(@$));}
+| SAFETIME_OF_DAY {$$ = new safetod_type_name_c(locloc(@$));}
+| SAFETOD {$$ = new safetod_type_name_c(locloc(@$));}
+| SAFEDATE_AND_TIME {$$ = new safedt_type_name_c(locloc(@$));}
+| SAFEDT {$$ = new safedt_type_name_c(locloc(@$));}
;
bit_string_type_name:
- BYTE {$$ = new byte_type_name_c(locloc(@$));}
-| WORD {$$ = new word_type_name_c(locloc(@$));}
-| DWORD {$$ = new dword_type_name_c(locloc(@$));}
-| LWORD {$$ = new lword_type_name_c(locloc(@$));}
+ BYTE {$$ = new byte_type_name_c(locloc(@$));}
+| WORD {$$ = new word_type_name_c(locloc(@$));}
+| DWORD {$$ = new dword_type_name_c(locloc(@$));}
+| LWORD {$$ = new lword_type_name_c(locloc(@$));}
+| SAFEBYTE {$$ = new safebyte_type_name_c(locloc(@$));}
+| SAFEWORD {$$ = new safeword_type_name_c(locloc(@$));}
+| SAFEDWORD {$$ = new safedword_type_name_c(locloc(@$));}
+| SAFELWORD {$$ = new safelword_type_name_c(locloc(@$));}
/* NOTE: see note under the B 1.2.1 section of token
* and grouping type definition for reason why the BOOL
* was omitted from this definition.
@@ -2333,6 +2473,8 @@
elementary_string_type_name:
STRING {$$ = new string_type_name_c(locloc(@$));}
| WSTRING {$$ = new wstring_type_name_c(locloc(@$));}
+| SAFESTRING {$$ = new safestring_type_name_c(locloc(@$));}
+| SAFEWSTRING {$$ = new safewstring_type_name_c(locloc(@$));}
;
@@ -5969,11 +6111,11 @@
instruction_list:
il_instruction
{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
-| pragma eol_list
+| any_pragma eol_list
{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
| instruction_list il_instruction
{$$ = $1; $$->add_element($2);}
-| instruction_list pragma
+| instruction_list any_pragma
{$$ = $1; $$->add_element($2);}
;
@@ -6375,7 +6517,7 @@
il_param_instruction:
- il_param_assignment ',' eol_list
+ il_param_assignment ',' eol_list
| il_param_out_assignment ',' eol_list
/* ERROR_CHECK_BEGIN */
| il_param_assignment ',' error
@@ -6607,13 +6749,61 @@
/* any_identifier SENDTO */
sendto_identifier SENDTO
{$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));}
+/* The following is not required, as the sendto_identifier_token returned by flex will
+ * also include the 'ENO' identifier.
+ * The resulting abstract syntax tree is identical with or without this following rule,
+ * as both the eno_identifier and the sendto_identifier are stored as
+ * an identifier_c !!
+ */
+/*
| eno_identifier SENDTO
{$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));}
+*/
/*| NOT variable_name SENDTO */
| NOT sendto_identifier SENDTO
{$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));}
+/* The following is not required, as the sendto_identifier_token returned by flex will
+ * also include the 'ENO' identifier.
+ * The resulting abstract syntax tree is identical with or without this following rule,
+ * as both the eno_identifier and the sendto_identifier are stored as
+ * an identifier_c !!
+ *
+ * NOTE: Removing the following rule also removes a shift/reduce conflict from the parser.
+ * This conflict is not really an error/ambiguity in the syntax, but rather
+ * due to the fact that more than a single look-ahead token would be required
+ * to correctly parse the syntax, something that bison does not support.
+ *
+ * The shift/reduce conflict arises because bison does not know whether
+ * to parse the 'NOT ENO' in the following code
+ * LD 1
+ * funct_name (
+ * NOT ENO => bool_var,
+ * EN := TRUE
+ * )
+ * as either a il_param_assignment (wrong!) or an il_param_out_assignment.(correct).
+ * The '=>' delimiter (known as SEND_TO in this iec.y file) is a dead giveaway that
+ * it should be parsed as an il_param_out_assignment, but still, bison gets confused!
+ * Bison considers the possibility of reducing the 'NOT ENO' as an NOT_operator with
+ * the 'ENO' operand
+ * (NOT_operator -> il_simple_operator -> il_simple_operation -> il_simple_instruction ->
+ * -> simple_instr_list -> il_param_assignment)
+ * instead of reducing it to an il_param_out_operator.
+ * ( il_param_out_operator -> il_param_out_assignment)
+ *
+ * Note that the shift/reduce conflict only manifests itself in the il_formal_funct_call,
+ * where both the il_param_out_assignment and il_param_assignment are used!
+ *
+ * il_param_out_assignment --+--> il_param_instruction -> il_param_instruction_list --+
+ * | |
+ * il_param_assignment --+ |
+ * |
+ * il_formal_funct_call <- il_param_list <-+
+ *
+ */
+/*
| NOT eno_identifier SENDTO
{$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));}
+*/
/* ERROR_CHECK_BEGIN */
| error SENDTO
{$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid parameter defined in parameter out assignment."); yyerrok;}
@@ -6854,8 +7044,8 @@
unary_expression:
- primary_expression
-| '-' primary_expression
+ non_negative_primary_expression
+| '-' non_negative_primary_expression
{$$ = new neg_expression_c($2, locloc(@$));}
| NOT primary_expression
{$$ = new not_expression_c($2, locloc(@$));}
@@ -6890,8 +7080,9 @@
* expression<-unary_expression<-constant<-integer
* (i.e. the constant 9, preceded by a unary negation)
*
- * To remove the conlfict, we only allow constants without
+ * To remove the conflict, we only allow constants without
* a preceding '-' to be used in primary_expression
+ * (i.e. as a parameter to the unary negation operator)
*/
/* NOTE: We use enumerated_value_without_identifier instead of enumerated_value
* in order to remove a reduce/reduce conflict between reducing an
@@ -6903,8 +7094,7 @@
* for a variable and an enumerated value, then the variable shall be
* considered.
*/
-primary_expression:
-/* constant */
+non_negative_primary_expression:
non_negative_constant
//| enumerated_value_without_identifier
| enumerated_value
@@ -6919,6 +7109,22 @@
;
+primary_expression:
+ constant
+//| enumerated_value_without_identifier
+ enumerated_value
+| variable
+| '(' expression ')'
+ {$$ = $2;}
+| function_invocation
+/* ERROR_CHECK_BEGIN */
+| '(' expression error
+ {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of expression in ST expression."); yyerrok;}
+/* ERROR_CHECK_END */
+;
+
+
+
/* intermediate helper symbol for primary_expression */
/* NOTE: function_name includes the standard function name 'NOT' !
* This introduces a reduce/reduce conflict, as NOT(var)
@@ -6972,11 +7178,11 @@
statement_list:
statement ';'
{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
-| pragma
+| any_pragma
{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
| statement_list statement ';'
{$$ = $1; $$->add_element($2);}
-| statement_list pragma
+| statement_list any_pragma
{$$ = $1; $$->add_element($2);}
/* ERROR_CHECK_BEGIN */
| statement error
@@ -7138,14 +7344,30 @@
/*| any_identifier SENDTO variable */
| sendto_identifier SENDTO variable
{$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));}
+/* The following is not required, as the sendto_identifier_token returned by flex will
+ * also include the 'ENO' identifier.
+ * The resulting abstract syntax tree is identical with or without this following rule,
+ * as both the eno_identifier and the sendto_identifier are stored as
+ * an identifier_c !!
+ */
+/*
| eno_identifier SENDTO variable
{$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));}
+*/
/*| NOT variable_name SENDTO variable */
/*| NOT any_identifier SENDTO variable*/
| NOT sendto_identifier SENDTO variable
{$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));}
+/* The following is not required, as the sendto_identifier_token returned by flex will
+ * also include the 'ENO' identifier.
+ * The resulting abstract syntax tree is identical with or without this following rule,
+ * as both the eno_identifier and the sendto_identifier are stored as
+ * an identifier_c !!
+ */
+/*
| NOT eno_identifier SENDTO variable
{$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));}
+*/
/* ERROR_CHECK_BEGIN */
| any_identifier ASSIGN error
{$$ = NULL;
@@ -7165,12 +7387,14 @@
else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;}
yyerrok;
}
+/*
| eno_identifier SENDTO error
{$$ = NULL;
if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");}
else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;}
yyerrok;
}
+*/
| NOT SENDTO variable
{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter name defined in ST formal parameter out negated assignment."); yynerrs++;}
| NOT error SENDTO variable
@@ -7181,12 +7405,14 @@
else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;}
yyerrok;
}
+/*
| NOT eno_identifier SENDTO error
{$$ = NULL;
if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");}
else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;}
yyerrok;
}
+*/
/* ERROR_CHECK_END */
;
@@ -7779,6 +8005,11 @@
}
/* first parse the standard library file... */
+ /*
+ #if YYDEBUG
+ yydebug = 1;
+ #endif
+ */
yyin = lib_file;
allow_function_overloading = true;
full_token_loc = full_token_loc_;
@@ -7802,11 +8033,11 @@
library_element_symtable.end_value())
library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token);
-#if YYDEBUG
- yydebug = 1;
-#endif
/* now parse the input file... */
+ #if YYDEBUG
+ yydebug = 1;
+ #endif
yyin = in_file;
allow_function_overloading = false;
full_token_loc = full_token_loc_;
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/stage1_2.cc
--- a/stage1_2/stage1_2.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/stage1_2.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2007 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/stage1_2.hh
--- a/stage1_2/stage1_2.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/stage1_2.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/stage1_2_priv.hh
--- a/stage1_2/stage1_2_priv.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/stage1_2_priv.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2007 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 stage1_2/standard_function_names.c
--- a/stage1_2/standard_function_names.c Fri Apr 01 17:26:29 2011 +0200
+++ b/stage1_2/standard_function_names.c Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2008 Edouard TISSERANT
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2008 Edouard TISSERANT
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 stage3/stage3.cc
--- a/stage3/stage3.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage3/stage3.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,24 +1,31 @@
/*
- * (c) 20099 Catarina da Costa Boucinha
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
- * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2009-04-24)
+ * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
*
*/
@@ -29,6 +36,9 @@
(*tree_root).accept(visit_expression_type);
+ if (visit_expression_type.get_error_found())
+ return -1;
+
return 0;
}
diff -r 86ef2244aef1 -r 579db02bebd9 stage3/stage3.hh
--- a/stage3/stage3.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage3/stage3.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,24 +1,31 @@
/*
- * (c) 2009 Catarina da Costa Boucinha
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
- * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2009-04-24)
+ * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
*
*/
diff -r 86ef2244aef1 -r 579db02bebd9 stage3/visit_expression_type.cc
--- a/stage3/visit_expression_type.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage3/visit_expression_type.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2009 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -50,118 +57,236 @@
(symbol1))
#define STAGE3_ERROR(symbol1, symbol2, msg) { \
- /*printf("semantic error between (%d:%d) and (%d:%d): %s\n", \
+ fprintf(stderr, "semantic error between (%d:%d) and (%d:%d): %s\n", \
FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column, \
LAST_(symbol1,symbol2) ->last_line, LAST_(symbol1,symbol2) ->last_column, \
- msg);*/ \
+ msg); \
il_error = true; \
- }
-
-
-
+ error_found = true; \
+ }
+
+
+/* set to 1 to see debug info during execution */
+static int debug = 0;
void *visit_expression_type_c::visit(program_declaration_c *symbol) {
search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
symbol->var_declarations->accept(*this);
- //printf("checking semantics in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
+ if (debug) printf("checking semantics in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
il_parenthesis_level = 0;
il_error = false;
il_default_variable_type = NULL;
symbol->function_block_body->accept(*this);
il_default_variable_type = NULL;
delete search_varfb_instance_type;
+ search_varfb_instance_type = NULL;
return NULL;
}
void *visit_expression_type_c::visit(function_declaration_c *symbol) {
search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
symbol->var_declarations_list->accept(*this);
- //printf("checking semantics in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
+ if (debug) printf("checking semantics in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
il_parenthesis_level = 0;
il_error = false;
il_default_variable_type = NULL;
symbol->function_body->accept(*this);
il_default_variable_type = NULL;
delete search_varfb_instance_type;
+ search_varfb_instance_type = NULL;
return NULL;
}
void *visit_expression_type_c::visit(function_block_declaration_c *symbol) {
search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
symbol->var_declarations->accept(*this);
- //printf("checking semantics in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
+ if (debug) printf("checking semantics in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
il_parenthesis_level = 0;
il_error = false;
il_default_variable_type = NULL;
symbol->fblock_body->accept(*this);
il_default_variable_type = NULL;
delete search_varfb_instance_type;
- return NULL;
-}
-
-
-
-
-
-
-
-
-
-visit_expression_type_c::visit_expression_type_c(symbol_c *search_scope) {
+ search_varfb_instance_type = NULL;
+ return NULL;
+}
+
+
+
+
+
+
+
+
+
+visit_expression_type_c::visit_expression_type_c(symbol_c *ignore) {
+ error_found = false;
}
visit_expression_type_c::~visit_expression_type_c(void) {
}
+bool visit_expression_type_c::get_error_found(void) {
+ return error_found;
+}
+
+
+
+/* NOTE on data type handling and literals...
+ * ==========================================
+ *
+ * Literals that are explicitly type cast
+ * e.g.: BYTE#42
+ * INT#65
+ * TIME#45h23m
+ * etc...
+ * are NOT considered literals in the following code.
+ * Since they are type cast, and their data type is fixed and well known,
+ * they are treated as a variable of that data type (except when determining lvalues)
+ * In other words, when calling search_constant_type_c on these constants, it returns
+ * a xxxxx_type_name_c, and not one of the xxxx_literal_c !
+ *
+ * When the following code handles a literal, it is really a literal of unknown data type.
+ * e.g. 42, may be considered an int, a byte, a word, etc...
+ *
+ * NOTE: type_symbol == NULL is valid!
+ * This will occur, for example, when and undefined/undeclared symbolic_variable is used in the program.
+ * This will not be of any type, so we always return false.
+ */
/* A helper function... */
bool visit_expression_type_c::is_ANY_ELEMENTARY_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
+ if (type_symbol == NULL) {return false;}
return is_ANY_MAGNITUDE_type(type_symbol)
- || is_ANY_BIT_type(type_symbol)
- || is_ANY_STRING_type(type_symbol)
- || is_ANY_DATE_type(type_symbol);
+ || is_ANY_BIT_type (type_symbol)
+ || is_ANY_STRING_type (type_symbol)
+ || is_ANY_DATE_type (type_symbol);
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFEELEMENTARY_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ return is_ANY_SAFEMAGNITUDE_type(type_symbol)
+ || is_ANY_SAFEBIT_type (type_symbol)
+ || is_ANY_SAFESTRING_type (type_symbol)
+ || is_ANY_SAFEDATE_type (type_symbol);
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ /* NOTE: doing
+ * return is_ANY_SAFEELEMENTARY_type() || is_ANY_ELEMENTARY_type()
+ * is incorrect, as the literals would never be considered compatible...
+ */
+ return is_ANY_MAGNITUDE_compatible(type_symbol)
+ || is_ANY_BIT_compatible (type_symbol)
+ || is_ANY_STRING_compatible (type_symbol)
+ || is_ANY_DATE_compatible (type_symbol);
}
/* A helper function... */
bool visit_expression_type_c::is_ANY_MAGNITUDE_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;}
return is_ANY_NUM_type(type_symbol);
}
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFEMAGNITUDE_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;}
+ return is_ANY_SAFENUM_type(type_symbol);
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_MAGNITUDE_type (type_symbol)) {return true;}
+ if (is_ANY_SAFEMAGNITUDE_type(type_symbol)) {return true;}
+
+ return is_ANY_NUM_compatible(type_symbol);
+}
/* A helper function... */
bool visit_expression_type_c::is_ANY_NUM_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
- return is_ANY_REAL_type(type_symbol) || is_ANY_INT_type(type_symbol);
-}
-
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_REAL_type(type_symbol)) {return true;}
+ if (is_ANY_INT_type(type_symbol)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFENUM_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ return is_ANY_SAFEREAL_type(type_symbol)
+ || is_ANY_SAFEINT_type (type_symbol);
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_NUM_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_REAL_compatible(type_symbol)) {return true;}
+ if (is_ANY_INT_compatible(type_symbol)) {return true;}
+ return false;
+}
/* A helper function... */
bool visit_expression_type_c::is_ANY_DATE_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;}
return false;
}
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFEDATE_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safetod_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedt_type_name_c)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_DATE_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_DATE_type (type_symbol)) {return true;}
+ if (is_ANY_SAFEDATE_type(type_symbol)) {return true;}
+ return false;
+}
/* A helper function... */
bool visit_expression_type_c::is_ANY_STRING_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;}
+// TODO literal_string ???
return false;
}
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFESTRING_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_STRING_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_STRING_type (type_symbol)) {return true;}
+ if (is_ANY_SAFESTRING_type(type_symbol)) {return true;}
+ return false;
+}
/* A helper function... */
bool visit_expression_type_c::is_ANY_INT_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;}
@@ -170,49 +295,130 @@
if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;}
- if (is_literal_integer_type(type_symbol)) {return true;}
return false;
}
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFEINT_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safesint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safelint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeusint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeuint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeudint_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeulint_type_name_c)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_INT_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_INT_type (type_symbol)) {return true;}
+ if (is_ANY_SAFEINT_type(type_symbol)) {return true;}
+ if (is_literal_integer_type(type_symbol)) {return true;}
+ return false;
+}
/* A helper function... */
bool visit_expression_type_c::is_ANY_REAL_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;}
- if (is_literal_real_type(type_symbol)) {return true;}
return false;
}
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFEREAL_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safereal_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_REAL_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_REAL_type (type_symbol)) {return true;}
+ if (is_ANY_SAFEREAL_type(type_symbol)) {return true;}
+ if (is_literal_real_type(type_symbol)) {return true;}
+ return false;
+}
/* A helper function... */
bool visit_expression_type_c::is_ANY_BIT_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
- if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;}
- if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;}
- if (is_literal_integer_type(type_symbol)) {return true;}
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;}
return false;
}
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_SAFEBIT_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safebyte_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safeword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safedword_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(safelword_type_name_c)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_BIT_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_ANY_BIT_type (type_symbol)) {return true;}
+ if (is_ANY_SAFEBIT_type(type_symbol)) {return true;}
+ if (is_nonneg_literal_integer_type(type_symbol)) {return true;}
+ if (is_literal_bool_type(type_symbol)) {return true;}
+ return false;
+}
/* A helper function... */
bool visit_expression_type_c::is_BOOL_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {ERROR;}
- if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
- if (is_literal_bool_type(type_symbol)) {return true;}
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;}
return false;
}
+/* A helper function... */
+bool visit_expression_type_c::is_SAFEBOOL_type(symbol_c *type_symbol){
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;}
+ return false;
+}
+
+/* A helper function... */
+bool visit_expression_type_c::is_ANY_BOOL_compatible(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
+ if (is_BOOL_type (type_symbol)) {return true;}
+ if (is_SAFEBOOL_type(type_symbol)) {return true;}
+ if (is_literal_bool_type(type_symbol)) {return true;}
+ return false;
+}
+
+
+#define is_type(type_name_symbol, type_name_class) (typeid(*type_name_symbol) == typeid(type_name_class))
+
#define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol)
/* A helper function... */
bool visit_expression_type_c::is_literal_integer_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {return true;}
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(neg_integer_c)) {return true;}
+ return is_nonneg_literal_integer_type(type_symbol);
+}
+
+
+/* A helper function... */
+bool visit_expression_type_c::is_nonneg_literal_integer_type(symbol_c *type_symbol) {
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(integer_c)) {return true;}
if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;}
if (typeid(*type_symbol) == typeid(octal_integer_c)) {return true;}
@@ -223,8 +429,9 @@
/* A helper function... */
bool visit_expression_type_c::is_literal_real_type(symbol_c *type_symbol) {
- if (type_symbol == NULL) {return true;}
- if (typeid(*type_symbol) == typeid(real_c)) {return true;}
+ if (type_symbol == NULL) {return false;}
+ if (typeid(*type_symbol) == typeid(real_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(neg_real_c)) {return true;}
return false;
}
@@ -233,15 +440,14 @@
bool visit_expression_type_c::is_literal_bool_type(symbol_c *type_symbol) {
bool_type_name_c bool_t;
- if (type_symbol == NULL) {return true;}
+ if (type_symbol == NULL) {return false;}
if (typeid(*type_symbol) == typeid(boolean_true_c)) {return true;}
if (typeid(*type_symbol) == typeid(boolean_false_c)) {return true;}
- if (is_literal_integer_type(type_symbol))
+ if (is_nonneg_literal_integer_type(type_symbol))
if (sizeoftype(&bool_t) >= sizeoftype(type_symbol)) {return true;}
return false;
}
-
/* Determine the common data type between two data types.
* If no common data type found, return NULL.
*
@@ -253,8 +459,9 @@
*
* If two literals, then return the literal that requires more bits...
*/
+
symbol_c *visit_expression_type_c::common_type__(symbol_c *first_type, symbol_c *second_type) {
- if (first_type == NULL && second_type == NULL) {ERROR;}
+ if (first_type == NULL && second_type == NULL) {return NULL;}
if (first_type == NULL) {return second_type;}
if (second_type == NULL) {return first_type;}
@@ -267,30 +474,82 @@
if (is_literal_bool_type(first_type) && is_literal_bool_type(second_type))
{return first_type;}
- /* This check can only be made after the is_literal_XXXX checks */
+ /* The following check can only be made after the is_literal_XXXX checks */
/* When two literals of the same type, with identical typeid's are checked,
- * we must return the one that occupies more bits...
+ * we must return the one that occupies more bits... This is done above.
*/
if (typeid(*first_type) == typeid(*second_type)) {return first_type;}
- if (is_BOOL_type(first_type) && is_literal_bool_type(second_type)) {return first_type;}
- if (is_BOOL_type(second_type) && is_literal_bool_type(first_type)) {return second_type;}
-
- if (is_ANY_BIT_type(first_type) && is_literal_integer_type(second_type))
+ /* NOTE Although a BOOL is also an ANY_BIT, we must check it explicitly since some
+ * literal bool values are not literal integers...
+ */
+ if (is_BOOL_type(first_type) && is_literal_bool_type(second_type)) {return first_type;}
+ if (is_BOOL_type(second_type) && is_literal_bool_type(first_type)) {return second_type;}
+
+ if (is_SAFEBOOL_type(first_type) && is_literal_bool_type(second_type)) {return first_type;}
+ if (is_SAFEBOOL_type(second_type) && is_literal_bool_type(first_type)) {return second_type;}
+
+ if (is_SAFEBOOL_type(first_type) && is_BOOL_type(second_type)) {return second_type;}
+ if (is_SAFEBOOL_type(second_type) && is_BOOL_type(first_type)) {return first_type;}
+
+ if (is_ANY_BIT_type(first_type) && is_nonneg_literal_integer_type(second_type))
{return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);}
- if (is_ANY_BIT_type(second_type) && is_literal_integer_type(first_type))
+ if (is_ANY_BIT_type(second_type) && is_nonneg_literal_integer_type(first_type))
{return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);}
- if (is_ANY_INT_type(first_type) && is_literal_integer_type(second_type))
+ if (is_ANY_SAFEBIT_type(first_type) && is_nonneg_literal_integer_type(second_type))
{return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);}
- if (is_ANY_INT_type(second_type) && is_literal_integer_type(first_type))
+ if (is_ANY_SAFEBIT_type(second_type) && is_nonneg_literal_integer_type(first_type))
{return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);}
- if (is_ANY_REAL_type(first_type) && is_literal_real_type(second_type))
+ if (is_ANY_SAFEBIT_type(first_type) && is_ANY_BIT_type(second_type))
+ {return ((sizeoftype(first_type) == sizeoftype(second_type))? second_type:NULL);}
+ if (is_ANY_SAFEBIT_type(second_type) && is_ANY_BIT_type(first_type))
+ {return ((sizeoftype(first_type) == sizeoftype(second_type))? first_type :NULL);}
+
+ if (is_ANY_INT_type(first_type) && is_literal_integer_type(second_type))
{return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);}
- if (is_ANY_REAL_type(second_type) && is_literal_real_type(first_type))
+ if (is_ANY_INT_type(second_type) && is_literal_integer_type(first_type))
{return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);}
+ if (is_ANY_SAFEINT_type(first_type) && is_literal_integer_type(second_type))
+ {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);}
+ if (is_ANY_SAFEINT_type(second_type) && is_literal_integer_type(first_type))
+ {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);}
+
+ if (is_ANY_SAFEINT_type(first_type) && is_ANY_INT_type(second_type))
+ {return ((sizeoftype(first_type) == sizeoftype(second_type))? second_type:NULL);}
+ if (is_ANY_SAFEINT_type(second_type) && is_ANY_INT_type(first_type))
+ {return ((sizeoftype(first_type) == sizeoftype(second_type))? first_type :NULL);}
+
+ if (is_ANY_REAL_type(first_type) && is_literal_real_type(second_type))
+ {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);}
+ if (is_ANY_REAL_type(second_type) && is_literal_real_type(first_type))
+ {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);}
+
+ if (is_ANY_SAFEREAL_type(first_type) && is_literal_real_type(second_type))
+ {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);}
+ if (is_ANY_SAFEREAL_type(second_type) && is_literal_real_type(first_type))
+ {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);}
+
+ if (is_ANY_SAFEREAL_type(first_type) && is_ANY_REAL_type(second_type))
+ {return ((sizeoftype(first_type) == sizeoftype(second_type))? second_type:NULL);}
+ if (is_ANY_SAFEREAL_type(second_type) && is_ANY_REAL_type(first_type))
+ {return ((sizeoftype(first_type) == sizeoftype(second_type))? first_type :NULL);}
+
+ /* the Time and Date types... */
+ if (is_type(first_type, safetime_type_name_c) && is_type(second_type, time_type_name_c)) {return second_type;}
+ if (is_type(second_type, safetime_type_name_c) && is_type( first_type, time_type_name_c)) {return first_type;}
+
+ if (is_type(first_type, safedate_type_name_c) && is_type(second_type, date_type_name_c)) {return second_type;}
+ if (is_type(second_type, safedate_type_name_c) && is_type( first_type, date_type_name_c)) {return first_type;}
+
+ if (is_type(first_type, safedt_type_name_c) && is_type(second_type, dt_type_name_c)) {return second_type;}
+ if (is_type(second_type, safedt_type_name_c) && is_type( first_type, dt_type_name_c)) {return first_type;}
+
+ if (is_type(first_type, safetod_type_name_c) && is_type(second_type, tod_type_name_c)) {return second_type;}
+ if (is_type(second_type, safetod_type_name_c) && is_type( first_type, tod_type_name_c)) {return first_type;}
+
/* no common type */
return NULL;
}
@@ -300,27 +559,66 @@
* if no common data type is found.
*/
symbol_c *visit_expression_type_c::common_type(symbol_c *first_type, symbol_c *second_type) {
+/*
symbol_c *res = common_type__(first_type, second_type);
if (NULL == res) ERROR;
return res;
+*/
+ return common_type__(first_type, second_type);
+}
+
+
+/* Return TRUE if the second (value) data type may be assigned to a variable of the first (variable) data type
+ * such as:
+ * var_type value_type
+ * BOOL BYTE#7 -> returns false
+ * INT INT#7 -> returns true
+ * INT 7 -> returns true
+ * REAL 7.89 -> returns true
+ * REAL 7 -> returns true
+ * INT 7.89 -> returns false
+ * SAFEBOOL BOOL#1 -> returns false !!!
+ * etc...
+ *
+ * NOTE: It is assumed that the var_type is the data type of an lvalue
+ */
+bool visit_expression_type_c::is_valid_assignment(symbol_c *var_type, symbol_c *value_type) {
+ if (var_type == NULL) {/* STAGE3_ERROR(value_type, value_type, "Var_type == NULL"); */ return false;}
+ if (value_type == NULL) {/* STAGE3_ERROR(var_type, var_type, "Value_type == NULL"); */ return false;}
+
+ symbol_c *common_type = common_type__(var_type, value_type);
+ if (NULL == common_type)
+ return false;
+ return (typeid(*var_type) == typeid(*common_type));
}
/* Return TRUE if there is a common data type, otherwise return FALSE
+ * i.e., return TRUE if both data types may be used simultaneously in an expression
+ * such as:
+ * BOOL#0 AND BYTE#7 -> returns false
+ * 0 AND BYTE#7 -> returns true
+ * INT#10 AND INT#7 -> returns true
+ * INT#10 AND 7 -> returns true
+ * REAL#34.3 AND 7.89 -> returns true
+ * REAL#34.3 AND 7 -> returns true
+ * INT#10 AND 7.89 -> returns false
+ * SAFEBOOL#0 AND BOOL#1 -> returns true !!!
+ * etc...
*/
bool visit_expression_type_c::is_compatible_type(symbol_c *first_type, symbol_c *second_type) {
- if (first_type == NULL || second_type == NULL) {ERROR;}
+ if (first_type == NULL || second_type == NULL) {return false;}
return (NULL != common_type__(first_type, second_type));
}
-#define is_num_type is_ANY_NUM_type
-#define is_integer_type is_ANY_INT_type
-#define is_real_type is_ANY_REAL_type
-#define is_binary_type is_ANY_BIT_type
+#define is_num_type is_ANY_NUM_compatible
+#define is_integer_type is_ANY_INT_compatible
+#define is_real_type is_ANY_REAL_compatible
+#define is_binary_type is_ANY_BIT_compatible
/* actually the ROR, ROL, SHL, and SHR function also accept boolean type! */
-#define is_nbinary_type is_ANY_BIT_type
+#define is_nbinary_type is_ANY_BIT_compatible
#define compute_standard_function_default visit_expression_type_c::compute_standard_function_default
#define compute_standard_function_il visit_expression_type_c::compute_standard_function_il
#define search_expression_type_c visit_expression_type_c
@@ -350,20 +648,30 @@
/* A helper function... */
+/*
symbol_c *visit_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type,
is_data_type_t is_data_type) {
+*/
+symbol_c *visit_expression_type_c::compute_expression(symbol_c *left_type, symbol_c *right_type, is_data_type_t is_data_type,
+ symbol_c *left_expr, symbol_c *right_expr) {
bool error = false;
if (!(this->*is_data_type)(left_type)) {
- STAGE3_ERROR(left_type, left_type, "invalid data type of first operand.");
+ if (debug) printf("visit_expression_type_c::compute_expression(): invalid left_type\n");
+ if (left_expr != NULL)
+ STAGE3_ERROR(left_expr, left_expr, "Invalid data type of operand, or of data resulting from previous IL instructions.");
error = true;
}
if (!(this->*is_data_type)(right_type)) {
- STAGE3_ERROR(right_type, right_type, "invalid data type of second operand.");
+ if (debug) printf("visit_expression_type_c::compute_expression(): invalid right_type\n");
+ if (right_expr != NULL)
+ STAGE3_ERROR(right_expr, right_expr, "Invalid data type of operand.");
error = true;
}
if (!is_compatible_type(left_type, right_type)) {
- STAGE3_ERROR(left_type, right_type, "type mismatch between operands.");
+ if (debug) printf("visit_expression_type_c::compute_expression(): left_type & right_type are incompatible\n");
+ if ((left_expr != NULL) && (right_expr != NULL))
+ STAGE3_ERROR(left_expr, right_expr, "Type mismatch between operands.");
error = true;
}
@@ -374,26 +682,44 @@
}
+# if 0
/* A helper function... */
symbol_c *visit_expression_type_c::compute_numeric_expression(symbol_c *left_type, symbol_c *right_type,
is_data_type_t is_data_type) {
- if (!(this->*is_data_type)(left_type))
- STAGE3_ERROR(left_type, right_type, "Both parts of the equation must be the same type.");
- if (!(this->*is_data_type)(right_type))
- STAGE3_ERROR(left_type, right_type, "Both parts of the equation must be the same type.");
- if (!is_compatible_type(left_type, right_type))
- STAGE3_ERROR(left_type, right_type, "Both parts of the equation must be the same type.");
-
+ bool error = false;
+
+ if (!(this->*is_data_type)(left_type)) {
+ STAGE3_ERROR(left_type, right_type, "Invalid data type of left operand.");
+ error = true;
+ }
+ if (!(this->*is_data_type)(right_type)) {
+ STAGE3_ERROR(left_type, right_type, "Invalid data type of right operand.");
+ error = true;
+ }
+ if (!is_compatible_type(left_type, right_type)) {
+ STAGE3_ERROR(left_type, right_type, "Type mismatch between operands.");
+ error = true;
+ }
+
+/*
if (is_literal_integer_type(left_type) || is_literal_real_type(left_type)) {
return right_type;
} else {
return left_type;
}
+*/
+
+ if (error)
+ return NULL;
+ else
+ return common_type(left_type, right_type);
/* humour the compiler... */
- return NULL;
-}
-
+/*
+ return NULL;
+*/
+}
+#endif
@@ -425,7 +751,7 @@
*/
if(param_name != NULL) {
param_type = fp_iterator.param_type();
- if(!is_compatible_type(il_default_variable_type,param_type))
+ if(!is_valid_assignment(param_type, il_default_variable_type))
STAGE3_ERROR(f_call, f_call, "In function/FB call, first parameter has invalid data type.");
}
} // if (use_il_defvar)
@@ -449,7 +775,7 @@
/* Get the parameter type */
param_type = fp_iterator.param_type();
/* If the declared parameter and the parameter from the function call do no have the same type */
- if(!is_compatible_type(call_param_type,param_type)) STAGE3_ERROR(call_param_value, call_param_value, "Type mismatch in function/FB call parameter.");
+ if(!is_valid_assignment(param_type, call_param_type)) STAGE3_ERROR(call_param_value, call_param_value, "Type mismatch in function/FB call parameter.");
}
}
}
@@ -490,7 +816,7 @@
symbol_c *param_type;
identifier_c *param_name;
function_param_iterator_c fp_iterator(f_decl);
-
+
/* Find the corresponding parameter of the function being called */
param_name = fp_iterator.search(call_param_name);
if(param_name == NULL) {
@@ -499,8 +825,7 @@
/* Get the parameter type */
param_type = fp_iterator.param_type();
/* If the declared parameter and the parameter from the function call have the same type */
-// if(!is_compatible_type(call_param_type, param_type)) STAGE3_ERROR(call_param_name, call_param_value, "Type mismatch function/FB call parameter.");
- if(!is_compatible_type(call_param_type, param_type)) STAGE3_ERROR(call_param_name, call_param_name, "Type mismatch function/FB call parameter.");
+ if(!is_valid_assignment(param_type, call_param_type)) STAGE3_ERROR(call_param_name, call_param_name, "Type mismatch function/FB call parameter.");
}
}
@@ -549,7 +874,7 @@
/* Get the parameter type */
param_type = fp_iterator.param_type();
/* If the declared parameter and the parameter from the function call have the same type */
- if(!is_compatible_type(call_param_type, param_type)) STAGE3_ERROR(call_param_name, call_param_value, "Type mismatch function/FB call parameter.");
+ if(!is_valid_assignment(param_type, call_param_type)) STAGE3_ERROR(call_param_name, call_param_value, "Type mismatch function/FB call parameter.");
}
}
}
@@ -559,6 +884,10 @@
/* a helper function... */
symbol_c *visit_expression_type_c::base_type(symbol_c *symbol) {
+ /* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used
+ * in the code.
+ */
+ if (symbol == NULL) return NULL;
return (symbol_c *)symbol->accept(search_base_type);
}
@@ -566,10 +895,10 @@
/* a helper function... */
void *visit_expression_type_c::verify_null(symbol_c *symbol){
if(il_default_variable_type == NULL){
- STAGE3_ERROR(symbol, symbol, "Il default variable can't be NULL.");
+ STAGE3_ERROR(symbol, symbol, "Missing LD instruction (or equivalent) before this instruction.");
}
if(il_operand_type == NULL){
- STAGE3_ERROR(symbol, symbol, "function requires an operand.");
+ STAGE3_ERROR(symbol, symbol, "This instruction requires an operand.");
}
return NULL;
}
@@ -642,6 +971,7 @@
return NULL;
/* determine the data type of the operand */
+ il_operand = symbol->il_operand;
if (symbol->il_operand != NULL){
il_operand_type = base_type((symbol_c *)symbol->il_operand->accept(*this));
} else {
@@ -651,6 +981,7 @@
symbol->il_simple_operator->accept(*this);
il_operand_type = NULL;
+ il_operand = NULL;
return NULL;
}
@@ -739,16 +1070,18 @@
il_parenthesis_level--;
if (il_parenthesis_level < 0) ERROR;
+ il_operand = symbol->simple_instr_list;
il_operand_type = il_default_variable_type;
il_default_variable_type = il_default_variable_type_back;
/* Now check the if the data type semantics of operation are correct,
* but only if no previous error has been found...
*/
- if (il_error)
- return NULL;
- symbol->il_expr_operator->accept(*this);
-
+ if (!il_error)
+ symbol->il_expr_operator->accept(*this);
+
+ il_operand_type = NULL;
+ il_operand = NULL;
return NULL;
}
@@ -929,8 +1262,8 @@
void *visit_expression_type_c::visit(LDN_operator_c *symbol) {
if(il_operand_type == NULL)
STAGE3_ERROR(symbol, symbol, "LDN operator requires an operand.");
- if(!is_ANY_BIT_type(il_operand_type))
- STAGE3_ERROR(symbol, symbol, "invalid data type of LDN operand, should be of type ANY_BIT.");
+ if(!is_ANY_BIT_compatible(il_operand_type))
+ STAGE3_ERROR(symbol, il_operand, "invalid data type of LDN operand, should be of type ANY_BIT.");
il_default_variable_type = il_operand_type;
return NULL;
}
@@ -938,7 +1271,8 @@
// SYM_REF0(ST_operator_c)
void *visit_expression_type_c::visit(ST_operator_c *symbol) {
verify_null(symbol);
- if(!is_compatible_type(il_default_variable_type, il_operand_type))
+
+ if(!is_valid_assignment(il_operand_type, il_default_variable_type))
STAGE3_ERROR(symbol, symbol, "Type mismatch in ST operation.");
/* TODO: check whether il_operand_type is an LVALUE !! */
/* data type of il_default_variable_type is unchanged... */
@@ -949,13 +1283,13 @@
// SYM_REF0(STN_operator_c)
void *visit_expression_type_c::visit(STN_operator_c *symbol) {
verify_null(symbol);
- if(!is_compatible_type(il_default_variable_type, il_operand_type))
+ if(!is_valid_assignment(il_operand_type, il_default_variable_type))
STAGE3_ERROR(symbol, symbol, "Type mismatch in ST operation.");
/* TODO: check whether il_operand_type is an LVALUE !! */
- if(!is_ANY_BIT_type(il_default_variable_type))
+ if(!is_ANY_BIT_compatible(il_default_variable_type))
STAGE3_ERROR(symbol, symbol, "invalid data type of il_default_variable for STN operand, should be of type ANY_BIT.");
- if(!is_ANY_BIT_type(il_operand_type))
- STAGE3_ERROR(symbol, symbol, "invalid data type of STN operand, should be of type ANY_BIT.");
+ if(!is_ANY_BIT_compatible(il_operand_type))
+ STAGE3_ERROR(symbol, il_operand, "invalid data type of STN operand, should be of type ANY_BIT.");
/* data type of il_default_variable_type is unchanged... */
// il_default_variable_type = il_default_variable_type;
return NULL;
@@ -964,14 +1298,14 @@
//SYM_REF0(NOT_operator_c)
void *visit_expression_type_c::visit(NOT_operator_c *symbol) {
if(il_operand_type != NULL){
- STAGE3_ERROR(symbol, symbol, "NOT operator may not have an operand.");
+ STAGE3_ERROR(symbol, il_operand, "NOT operator may not have an operand.");
return NULL;
}
if(il_default_variable_type == NULL) {
STAGE3_ERROR(symbol, symbol, "Il default variable should not be NULL.");
return NULL;
}
- if(!is_ANY_BIT_type(il_default_variable_type)) {
+ if(!is_ANY_BIT_compatible(il_default_variable_type)) {
STAGE3_ERROR(symbol, symbol, "Il default variable should be of type ANY_BIT.");
return NULL;
}
@@ -984,7 +1318,7 @@
void *visit_expression_type_c::visit(S_operator_c *symbol) {
verify_null(symbol);
if (!is_BOOL_type(il_default_variable_type)) {STAGE3_ERROR(symbol, symbol, "IL default variable should be BOOL type.");}
- if (!is_BOOL_type(il_operand_type)) {STAGE3_ERROR(symbol, symbol, "operator S requires operand of type BOOL.");}
+ if (!is_BOOL_type(il_operand_type)) {STAGE3_ERROR(symbol, il_operand, "operator S requires operand of type BOOL.");}
/* TODO: check whether il_operand_type is an LVALUE !! */
/* data type of il_default_variable_type is unchanged... */
// il_default_variable_type = il_default_variable_type;
@@ -995,7 +1329,7 @@
void *visit_expression_type_c::visit(R_operator_c *symbol) {
verify_null(symbol);
if (!is_BOOL_type(il_default_variable_type)) {STAGE3_ERROR(symbol, symbol, "IL default variable should be BOOL type.");}
- if (!is_BOOL_type(il_operand_type)) {STAGE3_ERROR(symbol, symbol, "operator R requires operand of type BOOL.");}
+ if (!is_BOOL_type(il_operand_type)) {STAGE3_ERROR(symbol, il_operand, "operator R requires operand of type BOOL.");}
/* TODO: check whether il_operand_type is an LVALUE !! */
/* data type of il_default_variable_type is unchanged... */
// il_default_variable_type = il_default_variable_type;
@@ -1054,42 +1388,48 @@
//SYM_REF0(AND_operator_c)
void *visit_expression_type_c::visit(AND_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible,
+ symbol , il_operand);
return NULL;
}
//SYM_REF0(OR_operator_c)
void *visit_expression_type_c::visit(OR_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible,
+ symbol , il_operand);
return NULL;
}
//SYM_REF0(XOR_operator_c)
void *visit_expression_type_c::visit(XOR_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible,
+ symbol , il_operand);
return NULL;
}
// SYM_REF0(ANDN_operator_c)
void *visit_expression_type_c::visit(ANDN_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible,
+ symbol , il_operand);
return NULL;
}
// SYM_REF0(ORN_operator_c)
void *visit_expression_type_c::visit(ORN_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible,
+ symbol , il_operand);
return NULL;
}
// SYM_REF0(XORN_operator_c)
void *visit_expression_type_c::visit(XORN_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible,
+ symbol , il_operand);
return NULL;
}
@@ -1098,13 +1438,33 @@
verify_null(symbol);
symbol_c *left_type = il_default_variable_type;
symbol_c *right_type = il_operand_type;
- if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))
+
+/* The following is not required, it is already handled by compute_expression() ... */
+/*
+ if (is_type(left_type, time_type_name_c) && is_type(right_type, time_type_name_c))
il_default_variable_type = &time_type_name;
- else if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))
+*/
+
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c))
il_default_variable_type = &tod_type_name;
- else if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))
+ else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c))
+ il_default_variable_type = &tod_type_name;
+ else if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &tod_type_name;
+ else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &safetod_type_name;
+
+ else if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c))
il_default_variable_type = &dt_type_name;
- else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type);
+ else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c))
+ il_default_variable_type = &dt_type_name;
+ else if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &dt_type_name;
+ else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &safedt_type_name;
+
+ else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible,
+ symbol , il_operand);
return NULL;
}
@@ -1113,19 +1473,60 @@
verify_null(symbol);
symbol_c *left_type = il_default_variable_type;
symbol_c *right_type = il_operand_type;;
+
+/* The following is not required, it is already handled by compute_expression() ... */
+/*
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))
il_default_variable_type = &time_type_name;
- else if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c))
+*/
+
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c))
+ il_default_variable_type = &tod_type_name;
+ else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c))
+ il_default_variable_type = &tod_type_name;
+ else if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &tod_type_name;
+ else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &safetod_type_name;
+
+ else if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c))
+ il_default_variable_type = &dt_type_name;
+ else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c))
+ il_default_variable_type = &dt_type_name;
+ else if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &dt_type_name;
+ else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ il_default_variable_type = &safedt_type_name;
+
+ else if (is_type(left_type, date_type_name_c) && is_type(right_type, date_type_name_c))
il_default_variable_type = &time_type_name;
- else if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))
- il_default_variable_type = &tod_type_name;
- else if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c))
+ else if (is_type(left_type, safedate_type_name_c) && is_type(right_type, date_type_name_c))
il_default_variable_type = &time_type_name;
- else if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))
- il_default_variable_type = &dt_type_name;
- else if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c))
+ else if (is_type(left_type, date_type_name_c) && is_type(right_type, safedate_type_name_c))
il_default_variable_type = &time_type_name;
- else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type);
+ else if (is_type(left_type, safedate_type_name_c) && is_type(right_type, safedate_type_name_c))
+ il_default_variable_type = &safetime_type_name;
+
+ else if (is_type(left_type, tod_type_name_c) && is_type(right_type, tod_type_name_c))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, tod_type_name_c))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetod_type_name_c))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetod_type_name_c))
+ il_default_variable_type = &safetime_type_name;
+
+ else if (is_type(left_type, dt_type_name_c) && is_type(right_type, dt_type_name_c))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, dt_type_name_c))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, dt_type_name_c) && is_type(right_type, safedt_type_name_c))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safedt_type_name_c))
+ il_default_variable_type = &safetime_type_name;
+
+ else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible,
+ symbol , il_operand);
return NULL;
}
@@ -1134,9 +1535,21 @@
verify_null(symbol);
symbol_c *left_type = il_default_variable_type;
symbol_c *right_type = il_operand_type;
- if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type))
+
+ if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type))
il_default_variable_type = &time_type_name;
- else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_type);
+ else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type))
+ il_default_variable_type = &safetime_type_name;
+ /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines,
+ * this next line is really only to check for integers/reals of undefined type on 'right_type'...
+ */
+ else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type))
+ il_default_variable_type = &safetime_type_name;
+
+ else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_compatible,
+ symbol , il_operand);
return NULL;
}
@@ -1145,23 +1558,36 @@
verify_null(symbol);
symbol_c *left_type = il_default_variable_type;
symbol_c *right_type = il_operand_type;
- if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type))
+
+ if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type))
il_default_variable_type = &time_type_name;
- else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_type);
+ else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type))
+ il_default_variable_type = &time_type_name;
+ else if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type))
+ il_default_variable_type = &safetime_type_name;
+ /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines,
+ * this next line is really only to check for integers/reals of undefined type on 'right_type'...
+ */
+ else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type))
+ il_default_variable_type = &safetime_type_name;
+
+ else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_compatible,
+ symbol , il_operand);
return NULL;
}
// SYM_REF0(MOD_operator_c)
void *visit_expression_type_c::visit(MOD_operator_c *symbol) {
verify_null(symbol);
- il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_INT_type);
+ il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_INT_compatible);
return NULL;
}
// SYM_REF0(GT_operator_c)
void *visit_expression_type_c::visit(GT_operator_c *symbol) {
verify_null(symbol);
- compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible,
+ symbol , il_operand);
il_default_variable_type = &search_expression_type_c::bool_type_name;
return NULL;
}
@@ -1169,7 +1595,8 @@
//SYM_REF0(GE_operator_c)
void *visit_expression_type_c::visit(GE_operator_c *symbol) {
verify_null(symbol);
- compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible,
+ symbol , il_operand);
il_default_variable_type = &search_expression_type_c::bool_type_name;
return NULL;
}
@@ -1177,7 +1604,8 @@
//SYM_REF0(EQ_operator_c)
void *visit_expression_type_c::visit(EQ_operator_c *symbol) {
verify_null(symbol);
- compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible,
+ symbol , il_operand);
il_default_variable_type = &search_expression_type_c::bool_type_name;
return NULL;
}
@@ -1185,7 +1613,8 @@
//SYM_REF0(LT_operator_c)
void *visit_expression_type_c::visit(LT_operator_c *symbol) {
verify_null(symbol);
- compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible,
+ symbol , il_operand);
il_default_variable_type = &search_expression_type_c::bool_type_name;
return NULL;
}
@@ -1193,7 +1622,8 @@
//SYM_REF0(LE_operator_c)
void *visit_expression_type_c::visit(LE_operator_c *symbol) {
verify_null(symbol);
- compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible,
+ symbol , il_operand);
il_default_variable_type = &search_expression_type_c::bool_type_name;
return NULL;
}
@@ -1201,7 +1631,8 @@
//SYM_REF0(NE_operator_c)
void *visit_expression_type_c::visit(NE_operator_c *symbol) {
verify_null(symbol);
- compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible,
+ symbol , il_operand);
il_default_variable_type = &search_expression_type_c::bool_type_name;
return NULL;
}
@@ -1299,28 +1730,28 @@
void *visit_expression_type_c::visit(or_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- return compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_type);
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_compatible);
}
void *visit_expression_type_c::visit(xor_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- return compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_type);
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_compatible);
}
void *visit_expression_type_c::visit(and_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- return compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_type);
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_compatible);
}
void *visit_expression_type_c::visit(equ_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible);
return &search_expression_type_c::bool_type_name;
}
@@ -1328,7 +1759,7 @@
void *visit_expression_type_c::visit(notequ_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible);
return &search_expression_type_c::bool_type_name;
}
@@ -1336,7 +1767,7 @@
void *visit_expression_type_c::visit(lt_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible);
return &search_expression_type_c::bool_type_name;
}
@@ -1344,7 +1775,7 @@
void *visit_expression_type_c::visit(gt_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible);
return &search_expression_type_c::bool_type_name;
}
@@ -1352,7 +1783,7 @@
void *visit_expression_type_c::visit(le_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible);
return &search_expression_type_c::bool_type_name;
}
@@ -1360,7 +1791,7 @@
void *visit_expression_type_c::visit(ge_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type);
+ compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible);
return &search_expression_type_c::bool_type_name;
}
@@ -1368,55 +1799,147 @@
void *visit_expression_type_c::visit(add_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;}
- if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;}
- if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;}
- return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type);
+
+/* The following is already checked in compute_expression */
+/*
+ if (is_type(left_type, time_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&time_type_name;
+*/
+
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&tod_type_name;
+ if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&tod_type_name;
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&tod_type_name;
+ if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&safetod_type_name;
+
+ if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&dt_type_name;
+ if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&dt_type_name;
+ if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&dt_type_name;
+ if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&safedt_type_name;
+
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible);
}
void *visit_expression_type_c::visit(sub_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;}
- if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) {return (void *)&time_type_name;}
- if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;}
- if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) {return (void *)&time_type_name;}
- if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;}
- if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)) {return (void *)&time_type_name;}
- return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type);
+
+/* The following is already checked in compute_expression */
+/*
+ if (is_type(left_type, time_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&time_type_name;
+*/
+
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&tod_type_name;
+ if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&tod_type_name;
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&tod_type_name;
+ if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&safetod_type_name;
+
+ if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&dt_type_name;
+ if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c))
+ return (void *)&dt_type_name;
+ if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&dt_type_name;
+ if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c))
+ return (void *)&safedt_type_name;
+
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, tod_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safetod_type_name_c) && is_type(right_type, tod_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetod_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetod_type_name_c))
+ return (void *)&safetime_type_name;
+
+ if (is_type(left_type, date_type_name_c) && is_type(right_type, date_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safedate_type_name_c) && is_type(right_type, date_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, date_type_name_c) && is_type(right_type, safedate_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safedate_type_name_c) && is_type(right_type, safedate_type_name_c))
+ return (void *)&safetime_type_name;
+
+ if (is_type(left_type, dt_type_name_c) && is_type(right_type, dt_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safedt_type_name_c) && is_type(right_type, dt_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, dt_type_name_c) && is_type(right_type, safedt_type_name_c))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safedt_type_name_c))
+ return (void *)&safetime_type_name;
+
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible);
}
void *visit_expression_type_c::visit(mul_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type)) {return (void *)&time_type_name;}
- return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_type);
+
+ if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type))
+ return (void *)&safetime_type_name;
+ /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines,
+ * this next line is really only to check for integers/reals of undefined type on 'right_type'...
+ */
+ if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type))
+ return (void *)&safetime_type_name;
+
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_compatible);
}
void *visit_expression_type_c::visit(div_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type)){return (void *)&time_type_name;}
- return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_type);
+
+ if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type))
+ return (void *)&time_type_name;
+ if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type))
+ return (void *)&safetime_type_name;
+ /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines,
+ * this next line is really only to check for integers/reals of undefined type on 'right_type'...
+ */
+ if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type))
+ return (void *)&safetime_type_name;
+
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_compatible);
}
void *visit_expression_type_c::visit(mod_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_INT_type);
+ return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_INT_compatible);
}
void *visit_expression_type_c::visit(power_expression_c *symbol) {
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- if (!is_ANY_REAL_type(left_type))
+ if (!is_ANY_REAL_compatible(left_type))
STAGE3_ERROR(symbol->l_exp, symbol->l_exp, "first operand of ** operator has invalid data type, should be of type ANY_REAL.");
- if (!is_ANY_NUM_type(right_type))
+ if (!is_ANY_NUM_compatible(right_type))
STAGE3_ERROR(symbol->r_exp, symbol->r_exp, "second operand of ** operator has invalid data type, should be of type ANY_NUM.");
return (void *)left_type;
@@ -1425,7 +1948,7 @@
void *visit_expression_type_c::visit(neg_expression_c *symbol) {
symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this));
- if (!is_ANY_MAGNITUDE_type(exp_type))
+ if (!is_ANY_MAGNITUDE_compatible(exp_type))
STAGE3_ERROR(symbol, symbol, "operand of negate expression '-' has invalid data type, should be of type ANY_MAGNITUDE.");
return exp_type;
@@ -1434,7 +1957,7 @@
void *visit_expression_type_c::visit(not_expression_c *symbol) {
symbol_c *type = base_type((symbol_c *)symbol->exp->accept(*this));
- return compute_boolean_expression(type, type, &visit_expression_type_c::is_ANY_BIT_type);
+ return compute_expression(type, type, &visit_expression_type_c::is_ANY_BIT_compatible);
}
@@ -1475,7 +1998,7 @@
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
- if (!is_compatible_type(left_type, right_type)) {
+ if (!is_valid_assignment(left_type, right_type)) {
STAGE3_ERROR(symbol, symbol, "data type mismatch in assignment statement!\n");
}
return NULL;
@@ -1536,7 +2059,7 @@
// SYM_REF4(if_statement_c, expression, statement_list, elseif_statement_list, else_statement_list)
void *visit_expression_type_c::visit(if_statement_c *symbol) {
symbol_c *expr_type = base_type((symbol_c*)symbol->expression->accept(*this));
- if (!is_BOOL_type(expr_type)) STAGE3_ERROR(symbol,symbol,"IF conditional expression is not of boolean type.");
+ if (!is_BOOL_type(expr_type)) STAGE3_ERROR(symbol->expression,symbol->expression,"IF conditional expression is not of boolean type.");
if (NULL != symbol->statement_list)
symbol->statement_list->accept(*this);
if (NULL != symbol->elseif_statement_list)
@@ -1555,7 +2078,7 @@
// SYM_REF2(elseif_statement_c, expression, statement_list)
void *visit_expression_type_c::visit(elseif_statement_c *symbol) {
symbol_c *elseif_expr_type = base_type((symbol_c*)symbol->expression->accept(*this));
- if(!is_BOOL_type(elseif_expr_type)) STAGE3_ERROR(symbol,symbol,"ELSIF conditional expression is not of boolean type.");
+ if(!is_BOOL_type(elseif_expr_type)) STAGE3_ERROR(symbol->expression,symbol->expression,"ELSIF conditional expression is not of boolean type.");
if (NULL != symbol->statement_list)
symbol->statement_list->accept(*this);
return NULL;
@@ -1595,6 +2118,7 @@
} else {
element_type = base_type(element_type);
if (NULL != element_type){
+ /* The CASE value is only used for comparison (and not assingment), so we only check for compatibility! */
if (!is_compatible_type(case_expression_type, element_type))
STAGE3_ERROR(symbol->elements[i], symbol->elements[i], "Invalid data type of case list element.");
}
@@ -1616,22 +2140,25 @@
if (NULL == var_type) ERROR;
// ASSIGN
symbol_c *beg_expr_type = base_type((symbol_c*)symbol->beg_expression->accept(*this));
- if (NULL != beg_expr_type) {
- if(!is_compatible_type(var_type,beg_expr_type))
- STAGE3_ERROR(symbol, symbol, "Data type mismatch between control variable and initial value.");
+ if (NULL != beg_expr_type) {
+ /* The BEG value is assigned to the variable, so we check for assignment validity! */
+ if(!is_valid_assignment(var_type, beg_expr_type))
+ STAGE3_ERROR(symbol->beg_expression, symbol->beg_expression, "Data type mismatch between control variable and initial value.");
}
// TO
symbol_c *end_expr_type = base_type((symbol_c*)symbol->end_expression->accept(*this));
if (NULL != end_expr_type) {
- if(!is_compatible_type(var_type,end_expr_type))
- STAGE3_ERROR(symbol, symbol, "Data type mismatch between control variable and final value.");
+ /* The TO value is only used for comparison, so we only check for compatibility! */
+ if(!is_compatible_type(var_type, end_expr_type))
+ STAGE3_ERROR(symbol->end_expression, symbol->end_expression, "Data type mismatch between control variable and final value.");
}
// BY
if(symbol->by_expression != NULL) {
symbol_c *by_expr_type = base_type((symbol_c*)symbol->by_expression->accept(*this));
if (NULL != end_expr_type) {
- if(!is_compatible_type(var_type,by_expr_type))
- STAGE3_ERROR(symbol, symbol, "Data type mismatch between control variable and BY value.");
+ /* The BY value is used in an expression (add, sub, ...), so we only check for compatibility! */
+ if(!is_compatible_type(var_type, by_expr_type))
+ STAGE3_ERROR(symbol->by_expression, symbol->by_expression, "Data type mismatch between control variable and BY value.");
}
}
// DO
@@ -1647,7 +2174,7 @@
symbol_c *expr_type = base_type((symbol_c*)symbol->expression->accept(*this));
if (NULL != expr_type) {
if(!is_BOOL_type(expr_type))
- STAGE3_ERROR(symbol,symbol,"WHILE conditional expression is not of boolean type.");
+ STAGE3_ERROR(symbol->expression,symbol->expression,"WHILE conditional expression is not of boolean type.");
}
if (NULL != symbol->statement_list)
@@ -1664,7 +2191,7 @@
symbol_c *expr_type = base_type((symbol_c*)symbol->expression->accept(*this));
if (NULL != expr_type) {
if(!is_BOOL_type(expr_type))
- STAGE3_ERROR(symbol,symbol,"REPEAT conditional expression is not of boolean type.");
+ STAGE3_ERROR(symbol->expression,symbol->expression,"REPEAT conditional expression is not of boolean type.");
}
return NULL;
}
diff -r 86ef2244aef1 -r 579db02bebd9 stage3/visit_expression_type.hh
--- a/stage3/visit_expression_type.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage3/visit_expression_type.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2009-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -67,29 +74,67 @@
*/
int il_parenthesis_level;
bool il_error;
-
+ bool error_found;
+
+ /* the current data type of the data stored in the IL stack, i.e. the default variable */
symbol_c *il_default_variable_type;
+ /* the current IL operand being analysed - its symbol and its data type */
symbol_c *il_operand_type;
+ symbol_c *il_operand;
public:
- visit_expression_type_c(symbol_c *search_scope);
+ visit_expression_type_c(symbol_c *ignore);
virtual ~visit_expression_type_c(void);
+ bool get_error_found(void);
+
+ typedef struct {
+ symbol_c *value;
+ symbol_c *type;
+ } value_and_type_t;
+
/* A helper function... */
- bool is_ANY_ELEMENTARY_type(symbol_c *type_symbol);
- bool is_ANY_MAGNITUDE_type(symbol_c *type_symbol);
- bool is_ANY_DATE_type(symbol_c *type_symbol);
- bool is_ANY_STRING_type(symbol_c *type_symbol);
- bool is_ANY_INT_type(symbol_c *type_symbol);
- bool is_ANY_REAL_type(symbol_c *type_symbol);
- bool is_ANY_NUM_type(symbol_c *type_symbol);
- bool is_ANY_BIT_type(symbol_c *type_symbol);
- bool is_BOOL_type(symbol_c *type_symbol);
-
- bool is_literal_integer_type(symbol_c *type_symbol);
- bool is_literal_real_type(symbol_c *type_symbol);
- bool is_literal_bool_type(symbol_c *type_symbol);
+ bool is_ANY_ELEMENTARY_type (symbol_c *type_symbol);
+ bool is_ANY_SAFEELEMENTARY_type (symbol_c *type_symbol);
+ bool is_ANY_ELEMENTARY_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_MAGNITUDE_type (symbol_c *type_symbol);
+ bool is_ANY_SAFEMAGNITUDE_type (symbol_c *type_symbol);
+ bool is_ANY_MAGNITUDE_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_DATE_type (symbol_c *type_symbol);
+ bool is_ANY_SAFEDATE_type (symbol_c *type_symbol);
+ bool is_ANY_DATE_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_STRING_type (symbol_c *type_symbol);
+ bool is_ANY_SAFESTRING_type (symbol_c *type_symbol);
+ bool is_ANY_STRING_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_INT_type (symbol_c *type_symbol);
+ bool is_ANY_SAFEINT_type (symbol_c *type_symbol);
+ bool is_ANY_INT_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_REAL_type (symbol_c *type_symbol);
+ bool is_ANY_SAFEREAL_type (symbol_c *type_symbol);
+ bool is_ANY_REAL_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_NUM_type (symbol_c *type_symbol);
+ bool is_ANY_SAFENUM_type (symbol_c *type_symbol);
+ bool is_ANY_NUM_compatible (symbol_c *type_symbol);
+
+ bool is_ANY_BIT_type (symbol_c *type_symbol);
+ bool is_ANY_SAFEBIT_type (symbol_c *type_symbol);
+ bool is_ANY_BIT_compatible (symbol_c *type_symbol);
+
+ bool is_BOOL_type (symbol_c *type_symbol);
+ bool is_SAFEBOOL_type (symbol_c *type_symbol);
+ bool is_ANY_BOOL_compatible (symbol_c *type_symbol);
+
+ bool is_nonneg_literal_integer_type (symbol_c *type_symbol);
+ bool is_literal_integer_type (symbol_c *type_symbol);
+ bool is_literal_real_type (symbol_c *type_symbol);
+ bool is_literal_bool_type (symbol_c *type_symbol);
/* Determine the common data type between two data types.
* If no common data type found, return NULL.
@@ -108,7 +153,35 @@
* if no common data type is found.
*/
symbol_c *common_type(symbol_c *first_type, symbol_c *second_type);
- /* Return TRUE if there is a common data type, otherwise return FALSE */
+/* Return TRUE if the second (value) data type may be assigned to a variable of the first (variable) data type
+ * such as:
+ * var_type value_type
+ * BOOL BYTE#7 -> returns false
+ * INT INT#7 -> returns true
+ * INT 7 -> returns true
+ * REAL 7.89 -> returns true
+ * REAL 7 -> returns true
+ * INT 7.89 -> returns false
+ * SAFEBOOL BOOL#1 -> returns false !!!
+ * etc...
+ *
+ * NOTE: It is assumed that the var_type is the data type of an lvalue
+ */
+ bool is_valid_assignment(symbol_c *var_type, symbol_c *value_type);
+
+/* Return TRUE if there is a common data type, otherwise return FALSE
+ * i.e., return TRUE if both data types may be used simultaneously in an expression
+ * such as:
+ * BOOL#0 AND BYTE#7 -> returns false
+ * 0 AND BYTE#7 -> returns true
+ * INT#10 AND INT#7 -> returns true
+ * INT#10 AND 7 -> returns true
+ * REAL#34.3 AND 7.89 -> returns true
+ * REAL#34.3 AND 7 -> returns true
+ * INT#10 AND 7.89 -> returns false
+ * SAFEBOOL#0 AND BOOL#1 -> returns true !!!
+ * etc...
+ */
bool is_compatible_type(symbol_c *first_type, symbol_c *second_type);
void compute_input_operatores(symbol_c *symbol, const char *input_operator);
@@ -128,8 +201,12 @@
/* A helper function... */
typedef bool (visit_expression_type_c::*is_data_type_t)(symbol_c *type_symbol); /* a pointer to a function! */
- symbol_c *compute_boolean_expression(symbol_c *left_exp, symbol_c *right_exp, is_data_type_t is_data_type);
- symbol_c *compute_numeric_expression(symbol_c *left_exp, symbol_c *right_exp, is_data_type_t is_data_type);
+// symbol_c *compute_boolean_expression(symbol_c *left_exp, symbol_c *right_exp, is_data_type_t is_data_type);
+// symbol_c *compute_numeric_expression(symbol_c *left_exp, symbol_c *right_exp, is_data_type_t is_data_type);
+// symbol_c *compute_expression(symbol_c *left_exp, symbol_c *right_exp, is_data_type_t is_data_type);
+ symbol_c *compute_expression(symbol_c *left_type, symbol_c *right_type, is_data_type_t is_data_type,
+ symbol_c *left_expr=NULL, symbol_c *right_expr=NULL);
+
/* a helper function... */
symbol_c *base_type(symbol_c *symbol);
@@ -137,9 +214,6 @@
/* a helper function... */
void *verify_null(symbol_c *symbol);
-
-
-
/*********************/
/* B 1.4 - Variables */
/*********************/
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/Makefile
--- a/stage4/Makefile Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/Makefile Mon Apr 04 17:19:35 2011 +0200
@@ -10,7 +10,7 @@
clean:
rm -f *.o
- find . -depth -mindepth 2 -maxdepth 2 -name Makefile -printf %h\\n | xargs -i make -C{} $@
+ find . -depth -mindepth 2 -maxdepth 2 -name Makefile | sed 's/Makefile//g' | xargs -I {} make -C{} clean
CXXFLAGS += -I. -I../*
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/generate_c/generate_c.cc
--- a/stage4/generate_c/generate_c.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/generate_c/generate_c.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -364,10 +371,16 @@
public:
generate_c_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL);
+
+ /********************/
+ /* 2.1.6 - Pragmas */
+ /********************/
+ void *visit(enable_code_generation_pragma_c * symbol) {s4o_ptr->enable_output(); return NULL;}
+ void *visit(disable_code_generation_pragma_c * symbol) {s4o_ptr->disable_output(); return NULL;}
+
/*********************************************/
/* B.1.6 Sequential function chart elements */
/*********************************************/
-
/*| sequential_function_chart sfc_network*/
void *visit(sequential_function_chart_c * symbol);
@@ -438,14 +451,23 @@
class generate_c_pous_c: public generate_c_typedecl_c {
-
+ private:
+ stage4out_c *s4o_ptr;
+
public:
generate_c_pous_c(stage4out_c *s4o_ptr, stage4out_c *s4o_incl_ptr)
- : generate_c_typedecl_c(s4o_ptr, s4o_incl_ptr) {};
+ : generate_c_typedecl_c(s4o_ptr, s4o_incl_ptr) {
+ generate_c_pous_c::s4o_ptr = s4o_ptr;
+ };
virtual ~generate_c_pous_c(void) {}
public:
+/********************/
+/* 2.1.6 - Pragmas */
+/********************/
+void *visit(enable_code_generation_pragma_c * symbol) {s4o_ptr->enable_output(); return NULL;}
+void *visit(disable_code_generation_pragma_c * symbol) {s4o_ptr->disable_output(); return NULL;}
/*************************/
/* B.1 - Common elements */
@@ -981,10 +1003,15 @@
/***********************************************************************/
class generate_c_config_c: public generate_c_typedecl_c {
+ private:
+ stage4out_c *s4o_ptr;
public:
generate_c_config_c(stage4out_c *s4o_ptr)
- : generate_c_typedecl_c(s4o_ptr) {};
+ : generate_c_typedecl_c(s4o_ptr) {
+ generate_c_config_c::s4o_ptr = s4o_ptr;
+ };
+
virtual ~generate_c_config_c(void) {}
typedef enum {
@@ -996,12 +1023,18 @@
declaretype_t wanted_declaretype;
+
+public:
+/********************/
+/* 2.1.6 - Pragmas */
+/********************/
+void *visit(enable_code_generation_pragma_c * symbol) {s4o_ptr->enable_output(); return NULL;}
+void *visit(disable_code_generation_pragma_c * symbol) {s4o_ptr->disable_output(); return NULL;}
+
+
/********************************/
/* B 1.7 Configuration elements */
/********************************/
-
-
-public:
/*
CONFIGURATION configuration_name
optional_global_var_declarations
@@ -1022,8 +1055,7 @@
s4o.print("/* Editing this file is not recommended... */\n");
s4o.print("/*******************************************/\n\n");
s4o.print("#include \"iec_std_lib.h\"\n\n");
-
- s4o.print("#include \"accessor.h\"\n\n");
+ s4o.print("#include \"accessor.h\"\n\n");
/* (A) configuration declaration... */
/* (A.1) configuration name in comment */
@@ -1171,6 +1203,7 @@
symbol_c *current_resource_name;
symbol_c *current_task_name;
symbol_c *current_global_vars;
+ stage4out_c *s4o_ptr;
public:
generate_c_resources_c(stage4out_c *s4o_ptr, symbol_c *config_scope, symbol_c *resource_scope, unsigned long time)
@@ -1181,7 +1214,9 @@
current_resource_name = NULL;
current_task_name = NULL;
current_global_vars = NULL;
+ generate_c_resources_c::s4o_ptr = s4o_ptr;
};
+
virtual ~generate_c_resources_c(void) {
delete search_config_instance;
delete search_resource_instance;
@@ -1231,6 +1266,14 @@
return NULL;
}
+
+ /********************/
+ /* 2.1.6 - Pragmas */
+ /********************/
+ void *visit(enable_code_generation_pragma_c * symbol) {s4o_ptr->enable_output(); return NULL;}
+ void *visit(disable_code_generation_pragma_c * symbol) {s4o_ptr->disable_output(); return NULL;}
+
+
/******************************************/
/* B 1.4.3 - Declaration & Initialisation */
/******************************************/
@@ -1678,6 +1721,30 @@
~generate_c_c(void) {}
+
+
+/********************/
+/* 2.1.6 - Pragmas */
+/********************/
+ void *visit(enable_code_generation_pragma_c * symbol) {
+ s4o .enable_output();
+ pous_s4o .enable_output();
+ pous_incl_s4o .enable_output();
+ located_variables_s4o.enable_output();
+ variables_s4o .enable_output();
+ return NULL;
+ }
+
+ void *visit(disable_code_generation_pragma_c * symbol) {
+ s4o .disable_output();
+ pous_s4o .disable_output();
+ pous_incl_s4o .disable_output();
+ located_variables_s4o.disable_output();
+ variables_s4o .disable_output();
+ return NULL;
+ }
+
+
/***************************/
/* B 0 - Programming Model */
/***************************/
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/generate_c/generate_c.hh
--- a/stage4/generate_c/generate_c.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/generate_c/generate_c.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL, ST and SFC compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/generate_c/generate_c_base.cc
--- a/stage4/generate_c/generate_c_base.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/generate_c/generate_c_base.cc Mon Apr 04 17:19:35 2011 +0200
@@ -267,9 +267,12 @@
return NULL;
}
-/***************************/
-/* 2.1.6 - Pragmas */
-/***************************/
+/********************/
+/* 2.1.6 - Pragmas */
+/********************/
+ void *visit(enable_code_generation_pragma_c * symbol) {s4o.enable_output(); return NULL;}
+ void *visit(disable_code_generation_pragma_c * symbol) {s4o.disable_output(); return NULL;}
+
/* Do not use print_token() as it will change everything into uppercase */
void *visit(pragma_c *symbol) {return s4o.print(symbol->value);}
@@ -303,21 +306,34 @@
void *visit(octal_integer_c *symbol) {s4o.print("0"); return print_striped_token(symbol, 2);}
void *visit(hex_integer_c *symbol) {s4o.print("0x"); return print_striped_token(symbol, 3);}
+ void *visit(neg_real_c *symbol) {
+ s4o.print("-");
+ symbol->exp->accept(*this);
+ return NULL;
+ }
+
+ void *visit(neg_integer_c *symbol) {
+ s4o.print("-");
+ symbol->exp->accept(*this);
+ return NULL;
+ }
+
void *visit(integer_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
void *visit(real_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
void *visit(bit_string_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
- void *visit(boolean_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
+ void *visit(boolean_literal_c *symbol) {
+ if (NULL != symbol->type)
+ return print_literal(symbol->type, symbol->value);
+ else {
+ bool_type_name_c bool_type;
+ return print_literal(&bool_type, symbol->value);
+ }
+ }
/* helper class for boolean_literal_c */
void *visit(boolean_true_c *symbol) {s4o.print("TRUE"); return NULL;}
void *visit(boolean_false_c *symbol) {s4o.print("FALSE"); return NULL;}
- void *visit(neg_literal_c *symbol) {
- s4o.print("-");
- symbol->exp->accept(*this);
- return NULL;
- }
-
void *visit(neg_expression_c *symbol) {
s4o.print("-");
symbol->exp->accept(*this);
@@ -562,35 +578,49 @@
/***********************************/
/* B 1.3.1 - Elementary Data Types */
/***********************************/
- void *visit(time_type_name_c *symbol) {s4o.print("TIME"); return NULL;}
- void *visit(bool_type_name_c *symbol) {s4o.print("BOOL"); return NULL;}
- void *visit(sint_type_name_c *symbol) {s4o.print("SINT"); return NULL;}
- void *visit(int_type_name_c *symbol) {s4o.print("INT"); return NULL;}
- void *visit(dint_type_name_c *symbol) {s4o.print("DINT"); return NULL;}
- void *visit(lint_type_name_c *symbol) {s4o.print("LINT"); return NULL;}
- void *visit(usint_type_name_c *symbol) {s4o.print("USINT"); return NULL;}
- void *visit(uint_type_name_c *symbol) {s4o.print("UINT"); return NULL;}
- void *visit(udint_type_name_c *symbol) {s4o.print("UDINT"); return NULL;}
- void *visit(ulint_type_name_c *symbol) {s4o.print("ULINT"); return NULL;}
- void *visit(real_type_name_c *symbol) {s4o.print("REAL"); return NULL;}
- void *visit(lreal_type_name_c *symbol) {s4o.print("LREAL"); return NULL;}
- void *visit(date_type_name_c *symbol) {s4o.print("DATE"); return NULL;}
- void *visit(tod_type_name_c *symbol) {s4o.print("TOD"); return NULL;}
- void *visit(dt_type_name_c *symbol) {s4o.print("DT"); return NULL;}
- void *visit(byte_type_name_c *symbol) {s4o.print("BYTE"); return NULL;}
- void *visit(word_type_name_c *symbol) {s4o.print("WORD"); return NULL;}
- void *visit(lword_type_name_c *symbol) {s4o.print("LWORD"); return NULL;}
- void *visit(dword_type_name_c *symbol) {s4o.print("DWORD"); return NULL;}
- void *visit(string_type_name_c *symbol) {s4o.print("STRING"); return NULL;}
- void *visit(wstring_type_name_c *symbol) {s4o.print("WSTRING"); return NULL;}
- /******************************************************/
- /* Extensions to the base standard as defined in */
- /* "Safety Software Technical Specification, */
- /* Part 1: Concepts and Function Blocks, */
- /* Version 1.0 – Official Release" */
- /* by PLCopen - Technical Committee 5 - 2006-01-31 */
- /******************************************************/
- void *visit(safebool_type_name_c *symbol) {s4o.print("SAFEBOOL"); return NULL;}
+ void *visit(time_type_name_c *symbol) {s4o.print("TIME"); return NULL;}
+ void *visit(bool_type_name_c *symbol) {s4o.print("BOOL"); return NULL;}
+ void *visit(sint_type_name_c *symbol) {s4o.print("SINT"); return NULL;}
+ void *visit(int_type_name_c *symbol) {s4o.print("INT"); return NULL;}
+ void *visit(dint_type_name_c *symbol) {s4o.print("DINT"); return NULL;}
+ void *visit(lint_type_name_c *symbol) {s4o.print("LINT"); return NULL;}
+ void *visit(usint_type_name_c *symbol) {s4o.print("USINT"); return NULL;}
+ void *visit(uint_type_name_c *symbol) {s4o.print("UINT"); return NULL;}
+ void *visit(udint_type_name_c *symbol) {s4o.print("UDINT"); return NULL;}
+ void *visit(ulint_type_name_c *symbol) {s4o.print("ULINT"); return NULL;}
+ void *visit(real_type_name_c *symbol) {s4o.print("REAL"); return NULL;}
+ void *visit(lreal_type_name_c *symbol) {s4o.print("LREAL"); return NULL;}
+ void *visit(date_type_name_c *symbol) {s4o.print("DATE"); return NULL;}
+ void *visit(tod_type_name_c *symbol) {s4o.print("TOD"); return NULL;}
+ void *visit(dt_type_name_c *symbol) {s4o.print("DT"); return NULL;}
+ void *visit(byte_type_name_c *symbol) {s4o.print("BYTE"); return NULL;}
+ void *visit(word_type_name_c *symbol) {s4o.print("WORD"); return NULL;}
+ void *visit(lword_type_name_c *symbol) {s4o.print("LWORD"); return NULL;}
+ void *visit(dword_type_name_c *symbol) {s4o.print("DWORD"); return NULL;}
+ void *visit(string_type_name_c *symbol) {s4o.print("STRING"); return NULL;}
+ void *visit(wstring_type_name_c *symbol) {s4o.print("WSTRING"); return NULL;}
+
+ void *visit(safetime_type_name_c *symbol) {s4o.print("TIME"); return NULL;}
+ void *visit(safebool_type_name_c *symbol) {s4o.print("BOOL"); return NULL;}
+ void *visit(safesint_type_name_c *symbol) {s4o.print("SINT"); return NULL;}
+ void *visit(safeint_type_name_c *symbol) {s4o.print("INT"); return NULL;}
+ void *visit(safedint_type_name_c *symbol) {s4o.print("DINT"); return NULL;}
+ void *visit(safelint_type_name_c *symbol) {s4o.print("LINT"); return NULL;}
+ void *visit(safeusint_type_name_c *symbol) {s4o.print("USINT"); return NULL;}
+ void *visit(safeuint_type_name_c *symbol) {s4o.print("UINT"); return NULL;}
+ void *visit(safeudint_type_name_c *symbol) {s4o.print("UDINT"); return NULL;}
+ void *visit(safeulint_type_name_c *symbol) {s4o.print("ULINT"); return NULL;}
+ void *visit(safereal_type_name_c *symbol) {s4o.print("REAL"); return NULL;}
+ void *visit(safelreal_type_name_c *symbol) {s4o.print("LREAL"); return NULL;}
+ void *visit(safedate_type_name_c *symbol) {s4o.print("DATE"); return NULL;}
+ void *visit(safetod_type_name_c *symbol) {s4o.print("TOD"); return NULL;}
+ void *visit(safedt_type_name_c *symbol) {s4o.print("DT"); return NULL;}
+ void *visit(safebyte_type_name_c *symbol) {s4o.print("BYTE"); return NULL;}
+ void *visit(safeword_type_name_c *symbol) {s4o.print("WORD"); return NULL;}
+ void *visit(safelword_type_name_c *symbol) {s4o.print("LWORD"); return NULL;}
+ void *visit(safedword_type_name_c *symbol) {s4o.print("DWORD"); return NULL;}
+ void *visit(safestring_type_name_c *symbol) {s4o.print("STRING"); return NULL;}
+ void *visit(safewstring_type_name_c *symbol) {s4o.print("WSTRING"); return NULL;}
/********************************/
/* B.1.3.2 - Generic data types */
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_st.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/generate_c/generate_c_st.cc Mon Apr 04 17:19:35 2011 +0200
@@ -571,13 +571,13 @@
}
/* TODO: power expression... */
-void *visit(power_expression_c *symbol) {ERROR; return print_binary_expression(symbol->l_exp, symbol->r_exp, " ** ");}
+void *visit(power_expression_c *symbol) {
+ ERROR;
+ return print_binary_expression(symbol->l_exp, symbol->r_exp, " ** ");
+}
+
void *visit(neg_expression_c *symbol) {
- symbol_c *exp_type = search_expression_type->get_type(symbol->exp);
- if (search_expression_type->is_integer_type(exp_type) || search_expression_type->is_real_type(exp_type))
- return print_unary_expression(symbol->exp, " -");
- ERROR;
- return NULL;
+ return print_unary_expression(symbol->exp, " -");
}
void *visit(not_expression_c *symbol) {
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/generate_iec/generate_iec.cc
--- a/stage4/generate_iec/generate_iec.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/generate_iec/generate_iec.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -71,8 +78,10 @@
}
void *print_literal(symbol_c *type, symbol_c *value) {
- type->accept(*this);
- s4o.print("#");
+ if (NULL != type) {
+ type->accept(*this);
+ s4o.print("#");
+ }
value->accept(*this);
return NULL;
}
@@ -145,10 +154,12 @@
-/***************************/
-/* 2.1.6 Pragmas */
-/***************************/
-void *visit(pragma_c *symbol) {return print_token(symbol);}
+/******************/
+/* 2.1.6 Pragmas */
+/******************/
+void *visit(enable_code_generation_pragma_c*) {s4o.print("{enable code generation}"); return NULL;}
+void *visit(disable_code_generation_pragma_c*) {s4o.print("{disable code generation}"); return NULL;}
+void *visit(pragma_c *symbol) {return print_token(symbol);}
/***************************/
@@ -168,22 +179,22 @@
/******************************/
/* B 1.2.1 - Numeric Literals */
/******************************/
-void *visit(real_c *symbol) {return print_token(symbol);}
-void *visit(integer_c *symbol) {return print_token(symbol);}
-void *visit(binary_integer_c *symbol) {return print_token(symbol);}
-void *visit(octal_integer_c *symbol) {return print_token(symbol);}
-void *visit(hex_integer_c *symbol) {return print_token(symbol);}
-
-void *visit(integer_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
-void *visit(real_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
+void *visit(real_c *symbol) {return print_token(symbol);}
+void *visit(neg_real_c *symbol) {return print_unary_expression(symbol->exp, "-");}
+void *visit(integer_c *symbol) {return print_token(symbol);}
+void *visit(neg_integer_c *symbol) {return print_unary_expression(symbol->exp, "-");}
+void *visit(binary_integer_c *symbol) {return print_token(symbol);}
+void *visit(octal_integer_c *symbol) {return print_token(symbol);}
+void *visit(hex_integer_c *symbol) {return print_token(symbol);}
+
+void *visit(integer_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
+void *visit(real_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
void *visit(bit_string_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
-void *visit(boolean_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
-void *visit(neg_literal_c *symbol) {return print_unary_expression(symbol->exp, "-");}
-
+void *visit(boolean_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
/* helper class for boolean_literal_c */
-void *visit(boolean_true_c *symbol) {s4o.print(/*"TRUE"*/"1"); return NULL;}
-void *visit(boolean_false_c *symbol) {s4o.print(/*"FALSE"*/"0"); return NULL;}
+void *visit(boolean_true_c *symbol) {s4o.print(/*"TRUE"*/"1"); return NULL;}
+void *visit(boolean_false_c *symbol) {s4o.print(/*"FALSE"*/"0"); return NULL;}
/*******************************/
/* B.1.2.2 Character Strings */
@@ -297,39 +308,50 @@
/***********************************/
/* B 1.3.1 - Elementary Data Types */
/***********************************/
-void *visit(time_type_name_c *symbol) {s4o.print("TIME"); return NULL;}
-void *visit(bool_type_name_c *symbol) {s4o.print("BOOL"); return NULL;}
-/******************************************************/
-/* whether we are suporting safe extensions */
-/* as defined in PLCopen - Technical Committee 5 */
-/* Safety Software Technical Specification, */
-/* Part 1: Concepts and Function Blocks, */
-/* Version 1.0 – Official Release */
-/******************************************************/
-void *visit(safebool_type_name_c *symbol) {s4o.print("SAFEBOOL"); return NULL;}
-void *visit(sint_type_name_c *symbol) {s4o.print("SINT"); return NULL;}
-void *visit(int_type_name_c *symbol) {s4o.print("INT"); return NULL;}
-void *visit(dint_type_name_c *symbol) {s4o.print("DINT"); return NULL;}
-void *visit(lint_type_name_c *symbol) {s4o.print("LINT"); return NULL;}
-void *visit(usint_type_name_c *symbol) {s4o.print("USINT"); return NULL;}
-void *visit(uint_type_name_c *symbol) {s4o.print("UINT"); return NULL;}
-void *visit(udint_type_name_c *symbol) {s4o.print("UDINT"); return NULL;}
-void *visit(ulint_type_name_c *symbol) {s4o.print("ULINT"); return NULL;}
-void *visit(real_type_name_c *symbol) {s4o.print("REAL"); return NULL;}
-void *visit(lreal_type_name_c *symbol) {s4o.print("LREAL"); return NULL;}
-void *visit(date_type_name_c *symbol) {s4o.print("DATE"); return NULL;}
-void *visit(tod_type_name_c *symbol) {s4o.print("TOD"); return NULL;}
-void *visit(dt_type_name_c *symbol) {s4o.print("DT"); return NULL;}
-void *visit(byte_type_name_c *symbol) {s4o.print("BYTE"); return NULL;}
-void *visit(word_type_name_c *symbol) {s4o.print("WORD"); return NULL;}
-void *visit(lword_type_name_c *symbol) {s4o.print("LWORD"); return NULL;}
-void *visit(dword_type_name_c *symbol) {s4o.print("DWORD"); return NULL;}
-void *visit(string_type_name_c *symbol) {s4o.print("STRING"); return NULL;}
-void *visit(wstring_type_name_c *symbol) {s4o.print("WSTRING"); return NULL;}
-/*
-void *visit(constant_int_type_name_c *symbol) {return NULL;}
-void *visit(constant_real_type_name_c *symbol) {return NULL;}
-*/
+void *visit(time_type_name_c *symbol) {s4o.print("TIME"); return NULL;}
+void *visit(bool_type_name_c *symbol) {s4o.print("BOOL"); return NULL;}
+void *visit(sint_type_name_c *symbol) {s4o.print("SINT"); return NULL;}
+void *visit(int_type_name_c *symbol) {s4o.print("INT"); return NULL;}
+void *visit(dint_type_name_c *symbol) {s4o.print("DINT"); return NULL;}
+void *visit(lint_type_name_c *symbol) {s4o.print("LINT"); return NULL;}
+void *visit(usint_type_name_c *symbol) {s4o.print("USINT"); return NULL;}
+void *visit(uint_type_name_c *symbol) {s4o.print("UINT"); return NULL;}
+void *visit(udint_type_name_c *symbol) {s4o.print("UDINT"); return NULL;}
+void *visit(ulint_type_name_c *symbol) {s4o.print("ULINT"); return NULL;}
+void *visit(real_type_name_c *symbol) {s4o.print("REAL"); return NULL;}
+void *visit(lreal_type_name_c *symbol) {s4o.print("LREAL"); return NULL;}
+void *visit(date_type_name_c *symbol) {s4o.print("DATE"); return NULL;}
+void *visit(tod_type_name_c *symbol) {s4o.print("TOD"); return NULL;}
+void *visit(dt_type_name_c *symbol) {s4o.print("DT"); return NULL;}
+void *visit(byte_type_name_c *symbol) {s4o.print("BYTE"); return NULL;}
+void *visit(word_type_name_c *symbol) {s4o.print("WORD"); return NULL;}
+void *visit(lword_type_name_c *symbol) {s4o.print("LWORD"); return NULL;}
+void *visit(dword_type_name_c *symbol) {s4o.print("DWORD"); return NULL;}
+void *visit(string_type_name_c *symbol) {s4o.print("STRING"); return NULL;}
+void *visit(wstring_type_name_c *symbol) {s4o.print("WSTRING"); return NULL;}
+
+void *visit(safetime_type_name_c *symbol) {s4o.print("SAFETIME"); return NULL;}
+void *visit(safebool_type_name_c *symbol) {s4o.print("SAFEBOOL"); return NULL;}
+void *visit(safesint_type_name_c *symbol) {s4o.print("SAFESINT"); return NULL;}
+void *visit(safeint_type_name_c *symbol) {s4o.print("SAFEINT"); return NULL;}
+void *visit(safedint_type_name_c *symbol) {s4o.print("SAFEDINT"); return NULL;}
+void *visit(safelint_type_name_c *symbol) {s4o.print("SAFELINT"); return NULL;}
+void *visit(safeusint_type_name_c *symbol) {s4o.print("SAFEUSINT"); return NULL;}
+void *visit(safeuint_type_name_c *symbol) {s4o.print("SAFEUINT"); return NULL;}
+void *visit(safeudint_type_name_c *symbol) {s4o.print("SAFEUDINT"); return NULL;}
+void *visit(safeulint_type_name_c *symbol) {s4o.print("SAFEULINT"); return NULL;}
+void *visit(safereal_type_name_c *symbol) {s4o.print("SAFEREAL"); return NULL;}
+void *visit(safelreal_type_name_c *symbol) {s4o.print("SAFELREAL"); return NULL;}
+void *visit(safedate_type_name_c *symbol) {s4o.print("SAFEDATE"); return NULL;}
+void *visit(safetod_type_name_c *symbol) {s4o.print("SAFETOD"); return NULL;}
+void *visit(safedt_type_name_c *symbol) {s4o.print("SAFEDT"); return NULL;}
+void *visit(safebyte_type_name_c *symbol) {s4o.print("SAFEBYTE"); return NULL;}
+void *visit(safeword_type_name_c *symbol) {s4o.print("SAFEWORD"); return NULL;}
+void *visit(safelword_type_name_c *symbol) {s4o.print("SAFELWORD"); return NULL;}
+void *visit(safedword_type_name_c *symbol) {s4o.print("SAFEDWORD"); return NULL;}
+void *visit(safestring_type_name_c *symbol) {s4o.print("SAFESTRING"); return NULL;}
+void *visit(safewstring_type_name_c *symbol) {s4o.print("SAFEWSTRING"); return NULL;}
+
/********************************/
/* B 1.3.3 - Derived data types */
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/generate_iec/generate_iec.hh
--- a/stage4/generate_iec/generate_iec.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/generate_iec/generate_iec.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/stage4.cc
--- a/stage4/stage4.cc Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/stage4.cc Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
- *
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
+ *
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -74,6 +81,7 @@
m_file = file;
this->indent_level = indent_level;
this->indent_spaces = "";
+ allow_output = true;
}
stage4out_c::~stage4out_c(void) {
@@ -84,6 +92,13 @@
}
}
+void stage4out_c::enable_output(void) {
+ allow_output = true;
+}
+
+void stage4out_c::disable_output(void) {
+ allow_output = false;
+}
void stage4out_c::indent_right(void) {
indent_spaces+=indent_level;
@@ -98,32 +113,38 @@
void *stage4out_c::print(const char *str) {
+ if (!allow_output) return NULL;
*out << str;
return NULL;
}
void *stage4out_c::print_integer(int integer) {
+ if (!allow_output) return NULL;
*out << integer;
return NULL;
}
void *stage4out_c::print_long_integer(unsigned long l_integer) {
+ if (!allow_output) return NULL;
*out << l_integer << "UL";
return NULL;
}
void *stage4out_c::print_long_long_integer(unsigned long long ll_integer) {
+ if (!allow_output) return NULL;
*out << ll_integer << "ULL";
return NULL;
}
void *stage4out_c::printupper(const char *str) {
+ if (!allow_output) return NULL;
for (int i = 0; str[i] != '\0'; i++)
*out << (unsigned char)toupper(str[i]);
return NULL;
}
void *stage4out_c::printlocation(const char *str) {
+ if (!allow_output) return NULL;
*out << "__";
for (int i = 0; str[i] != '\0'; i++)
if(str[i] == '.')
@@ -134,6 +155,7 @@
}
void *stage4out_c::printlocation_comasep(const char *str) {
+ if (!allow_output) return NULL;
*out << (unsigned char)toupper(str[0]);
*out << ',';
*out << (unsigned char)toupper(str[1]);
@@ -148,12 +170,14 @@
void *stage4out_c::print(std::string str) {
+ if (!allow_output) return NULL;
*out << str;
return NULL;
}
void *stage4out_c::printupper(std::string str) {
+ if (!allow_output) return NULL;
/* The string standard class does not have a converter member function to upper case.
* We have to do it ourselves, a character at a time...
*/
@@ -170,6 +194,7 @@
void *stage4out_c::printlocation(std::string str) {
+ if (!allow_output) return NULL;
return printlocation(str.c_str());
}
diff -r 86ef2244aef1 -r 579db02bebd9 stage4/stage4.hh
--- a/stage4/stage4.hh Fri Apr 01 17:26:29 2011 +0200
+++ b/stage4/stage4.hh Mon Apr 04 17:19:35 2011 +0200
@@ -1,21 +1,28 @@
/*
- * (c) 2003 Mario de Sousa
+ * matiec - a compiler for the programming languages defined in IEC 61131-3
*
- * Offered to the public under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt)
*
- * 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.
+ * 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 .
+ *
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
/*
- * An IEC 61131-3 IL and ST compiler.
+ * An IEC 61131-3 compiler.
*
* Based on the
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
@@ -41,6 +48,9 @@
stage4out_c(const char *dir, const char *radix, const char *extension, std::string indent_level = " ");
~stage4out_c(void);
+ void enable_output(void);
+ void disable_output(void);
+
void indent_right(void);
void indent_left(void);
@@ -62,6 +72,13 @@
protected:
std::ostream *out;
std::fstream *m_file;
+
+ /* A flag to tell whether to really print to the file, or to ignore any request to print to the file */
+ /* This is used to implement the no_code_generation pragmas, that lets the user tell the compiler
+ * when to switch on and off the code generation, without stoping the lexical, syntatical, and
+ * semantic analysers from analysing the code.
+ */
+ bool allow_output;
};
diff -r 86ef2244aef1 -r 579db02bebd9 tests/syntax/identifier/identifier_as_variable1.test
--- a/tests/syntax/identifier/identifier_as_variable1.test Fri Apr 01 17:26:29 2011 +0200
+++ b/tests/syntax/identifier/identifier_as_variable1.test Mon Apr 04 17:19:35 2011 +0200
@@ -40,35 +40,35 @@
(* A helper FUNCTION BLOCK declaration *)
function_block foo_fb
var_input
- a_1, b_1: int;
- end_var
- var_output
- c_1, d_1: int;
- end_var
- c_1 := 10 + b_1;
+ a_1, b_1: real;
+ end_var
+ var_output
+ c_1, d_1: real;
+ end_var
+ c_1 := 10.0 + b_1;
end_function_block
(* A helper FUNCTION declaration *)
-function foo_f1 : int
- var_input
- a_1, b_1: int;
- end_var
- var_output
- c_1, d_1: int;
- end_var
- c_1 := 10 + b_1;
+function foo_f1 : real
+ var_input
+ a_1, b_1: real;
+ end_var
+ var_output
+ c_1, d_1: real;
+ end_var
+ c_1 := 10.0 + b_1;
end_function
(* Another helper FUNCTION declaration *)
-function foo_f2 : int
+function foo_f2 :real
var_input
a_1, b_1: foo_fb;
end_var
var_output
- c_1, d_1: int;
- end_var
- c_1 := 10;
+ c_1, d_1: real;
+ end_var
+ c_1 := 10.0;
end_function
@@ -77,11 +77,11 @@
(* Testing use of XXXX in several locations of variable declarations *)
(*********************************************************************)
-function bar01 : int
- var_input
- XXXX, a_1, b_1: int;
- end_var
- a_1 := 1;
+function bar01 : real
+ var_input
+ XXXX, a_1, b_1: real;
+ end_var
+ a_1 := 1.0;
end_function
function_block bar02
@@ -187,21 +187,30 @@
function_block bar90
var
+ e_1, f_1 : real;
+ XXXX : real;
+ fb : foo_fb;
+ end_var
+ e_1 := bar01 (XXXX := 10.0);
+ e_1 := bar01 (a_1 := XXXX);
+ e_1 := bar01 (XXXX := XXXX);
+ fb(XXXX, 20.0);
+ fb (10.0, XXXX, e_1, f_1);
+ fb (a_1 := XXXX, b_1:=XXXX, c_1=>XXXX, d_1=>f_1);
+ fb(a_1 := 10.0, b_1:=20.0, c_1=>e_1, d_1=>XXXX);
+ fb (c_1=>XXXX, a_1:=20.0, d_1=>f_1);
+ XXXX := fb.c_1;
+ fb.a_1 := XXXX + XXXX * 2.0 * (XXXX) / foo_f1(XXXX, 10.0, XXXX, e_1) / XXXX ** XXXX;
+ IF (XXXX >= 10.0) THEN XXXX := 10.0; END_IF;
+end_function_block
+
+
+function_block bar90a
+ var
e_1, f_1 : int;
XXXX : int;
- fb : foo_fb;
- end_var
- e_1 := bar01 (XXXX := 10);
- e_1 := bar01 (a_1 := XXXX);
- e_1 := bar01 (XXXX := XXXX);
- fb(XXXX, 20);
- fb (10, XXXX, e_1, f_1);
- fb (a_1 := XXXX, b_1:=XXXX, c_1=>XXXX, d_1=>f_1);
- fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>XXXX);
- fb (c_1=>XXXX, a_1:=20, d_1=>f_1);
- XXXX := fb.c_1;
- fb.a_1 := XXXX + XXXX * 2 * (XXXX) / foo_f1(XXXX, 10, XXXX, e_1) MOD XXXX MOD XXXX ** XXXX;
- IF (XXXX >= 10) THEN XXXX := 10; END_IF;
+ end_var
+ XXXX := XXXX MOD XXXX;
CASE (XXXX + 10) OF
10: XXXX := 10;
10..20:XXXX := 20;
@@ -234,19 +243,19 @@
function_block bar91
var
- e_1, f_1 : int;
+ e_1, f_1 : real;
XXXX : foo_fb;
end_var
- XXXX(e_1, 20);
- XXXX (10, e_1, e_1, f_1);
+ XXXX(e_1, 20.0);
+ XXXX (10.0, e_1, e_1, f_1);
XXXX (a_1 := e_1, b_1:=e_1 , c_1=>e_1, d_1=>f_1);
- XXXX(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>e_1);
- XXXX (c_1=>e_1, a_1:=20, d_1=>f_1);
+ XXXX(a_1 := 10.0, b_1:=20.0, c_1=>e_1, d_1=>e_1);
+ XXXX (c_1=>e_1, a_1:=20.0, d_1=>f_1);
e_1 := XXXX.c_1;
XXXX.a_1 := e_1;
e_1 := foo_f2(XXXX, XXXX, e_1, f_1);
e_1 := foo_f2 (XXXX, XXXX);
- e_1 := foo_f2 (c_1 => e_1, b_1 := XXXX, d_1 := 10, a_1 := XXXX);
+ e_1 := foo_f2 (c_1 => e_1, b_1 := XXXX, d_1 := 10.0, a_1 := XXXX);
e_1 := foo_f2 (b_1 := XXXX);
end_function_block
diff -r 86ef2244aef1 -r 579db02bebd9 tests/syntax/identifier/runtests
--- a/tests/syntax/identifier/runtests Fri Apr 01 17:26:29 2011 +0200
+++ b/tests/syntax/identifier/runtests Mon Apr 04 17:19:35 2011 +0200
@@ -9,6 +9,7 @@
do
sed s/XXXX/$id/g $ff > $ff"_"$id.iec
if `../../../iec2iec $ff"_"$id.iec -I ../../../lib > $ff"_"$id.out 2>$ff"_"$id.err`
+ #if `../../../iec2c $ff"_"$id.iec -I ../../../lib > $ff"_"$id.out 2>$ff"_"$id.err`
# TODO before deciding test is success [OK]
# - test whether xxx.out has size <> 0
# - test whether xxx.err has size == 0