pax_global_header00006660000000000000000000000064137167174550014532gustar00rootroot0000000000000052 comment=06e1a6cbe1979db94c49e34bc47c0dbe304883db ADMS-release-2.3.7/000077500000000000000000000000001371671745500137055ustar00rootroot00000000000000ADMS-release-2.3.7/.appveyor.yml000066400000000000000000000026431371671745500163600ustar00rootroot00000000000000environment: matrix: - MSYSTEM : MINGW64 MBITS: 64 MARCH: x86_64 - MSYSTEM : MINGW32 MBITS: 32 MARCH: i686 platform: - x64 install: # Take a look at the environment - set "PATH=C:\msys64\usr\bin;C:\msys64\mingw%MBITS%\bin;%PATH%" - bash -lc "" - bash -lc "pacman --version" # Switch from SF to msys2.org (default, much faster) - bash -lc "pacman --noconfirm --sync pacman-mirrors" - bash -lc "pacman --noconfirm -S autoconf automake bison flex perl perl-XML-LibXML" build_script: ## Notes # * The "exec 0 Contributors ------------s o Modelization Groups Colin McAndrew James Victory o MICA Group Steven D Hamm o MDAS Group Savithri S Kuntal Joardar ADMS-release-2.3.7/CMakeLists.txt000066400000000000000000000053411371671745500164500ustar00rootroot00000000000000# This file is part of adms - http://sourceforge.net/projects/mot-adms. # # adms is a code generator for the Verilog-AMS language. # # Copyright (C) 2014-2015 Guilherme Brondani Torri # 2014 Luther T. Cat # # 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 . # skip CMake 3.0 project version management for the moment if(POLICY CMP0048) cmake_policy(SET CMP0048 OLD) endif() #================================== PROJECT(ADMS C) cmake_minimum_required(VERSION 2.8) # TODO: store version in a sensible place # e.g. qucs: file(STRINGS "${qucs-project_SOURCE_DIR}/VERSION" QUCS_VERSION) SET(PACKAGE_NAME "adms") SET(PACKAGE_VERSION "2.3.7") SET(PACKAGE_BUGREPORT "qucs-bugs@lists.sourceforge.net") # Default to static libs ( shared needs work, BUG with MinGW). OPTION ( BUILD_STATIC_LIBS "Build static libraries." ON ) IF ( MINGW ) IF ( BUILD_STATIC_LIBS ) ADD_DEFINITIONS(-Dstaticlink) ENDIF() ENDIF() INCLUDE( CheckIncludeFile ) check_include_file( sys/stat.h HAVE_SYS_STAT_H ) check_include_file( locale.h HAVE_LOCALE_H) check_include_file( float.h HAVE_FLOAT_H) check_include_file( unistd.h HAVE_UNISTD_H) check_include_file( stdlib.h HAVE_STDLIB_H) check_include_file( string.h HAVE_STRING_H) INCLUDE( CheckFunctionExists ) CHECK_FUNCTION_EXISTS (putenv HAVE_PUTENV) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) # Perl is used to recreate sources # * mkelements.pl # * mktext.pl # * mkgrammar.pl # Checking for perl modules requires FindPerlModules.cmake # Check all required modules at once SET(CMAKE_MODULE_PATH "${ADMS_SOURCE_DIR}/cmake/modules") include(FindPerlModules) find_package(PerlModules COMPONENTS XML::LibXML) if(NOT PERLMODULES_FOUND) message(FATAL_ERROR "Not all required perl modules were found on your system") endif(NOT PERLMODULES_FOUND) find_package(BISON 2.5) # handle api.prefix, unused for the moment IF (${BISON_VERSION} VERSION_LESS "2.6") SET (BISON_APIPREFIX "-p") ELSE (${BISON_VERSION} VERSION_LESS "2.6") SET (BISON_APIPREFIX "-Dapi.prefix=") ENDIF (${BISON_VERSION} VERSION_LESS "2.6") find_package(FLEX) ADD_SUBDIRECTORY(admsXml) ADMS-release-2.3.7/COPYING000066400000000000000000001045131371671745500147440ustar00rootroot00000000000000 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 . ADMS-release-2.3.7/ChangeLog000066400000000000000000000102261371671745500154600ustar00rootroot00000000000000adms-2.3.6: * Fix parser for parameter lists in subdevice instantiation. * Remove duplicated constants on provided headers. * Fix crash on x64 when printing the message about standard headers. adms-2.3.5: * Change license to GPLv3. * Add new simplified constants.vams and discplines.vams. Tested to work with models currently in use by Qucs, Ngspice, Xyce and Gnucap. Whenever these headers are used, adms informs the user about the availability of the standard headers at: http://accellera.org/downloads/standards/v-ams * Remove non-GPL constants.vams and disciplines.vams headers. These files are copyright of Accellera. With the LRM v2.4.0 updated versions of these files are freely accessible. However modification is not allowed. Hence, these files are not GPL and should not be included in adms. * Autotools, add back support for static and shared libraries build. * Build shared libraries by default. Tested on Linux, Mac OSX, and MSYS2. See the configure --disable-shared flag to change that. * CMake continues to builds static libraries only. * Fix out-of-tree build for Autotools and CMake. * Check scaling factors against LRM v2.4.0 * Add missing K scaling (uppercase kilo) * standard scale_factor T|G|M|K|k|m|u|n|p|f|a * Add testset (va and xml files) to test the scaling factors * Handle non-standard scaling factors with warning E|P|D|h|d|c|A Patch by Geoffrey Coram * Relax Bison requirement, tested with (2.5, 3.0.2) * Perl GD module is no longer required at build time. The GD module is becoming hard to install, and it is only used to create a few images used on the html documentation. If images need to be changed, run the mkimage.pl script and update the repository. adms-2.3.4: * able to parse BSIM6, BSIMCMG (107.0.0) * merge patches from WRspice * preprocessorLex.l: * remove print to screen of `disciplines.vams` * Change string recognition to allow embedded \" as literal quote * Capture quoted string containing line continuation character `\` * avoid spurious fatal error from an included file which last line contains onlywhite space. * preprocessorYacc.y: * fix BSIM6 parse problem, string macro arg broken by line continuation caused 'unexpected end-of-line' error. * verilogLex.l: * Change string recognition to allow embedded \" as literal quote * admsXml.c: * update website address on info message * turn error on verbose message for mismatched assignments (WRspice) adms-2.3.3: * adms.implitic.xml * add all standard functions and transcendental functions (LRM v2.3.1) * add `$limit` function, used in Xyce * fixed CMake build system: * enabled config.h reader configuration, checks for HAVE_ defines used on the generated source code. * added module to search for Perl modules (maintainer mode) * it runs the Perl scripts to generate source code * preprocessorLex.l: set Flex ptional output name to `preprocessorLex.c` * verilogaLex.l: set Flex optional output name to `verilogaLex.c` * install admsCheck: this is a test program for admsXml * admsXml, admsCheck: link libraries statically * Set static linking on Linux, OSX, Windows * Drop DLL support on MINGW (Win32), static linked adms-2.3.2: * further cleanup, no new language features * bump bison dependency, bison-2.6+ (tested with 2.7.1 and 3.0.2) * update admsXml help * use Git hash as revision number * show OS and Compiler version * fix `make dist` to create tarball * introduce support for CMake build scripts * update Readme and build instructions adms-2.3.1: * very little change from adms-2.3.0 * small improvements to build system and tidied up source download package. adms-2.3.0: svn release 1190 * Last released version used by Qucs and QucsStudio teams. * The original svn repository this was created from is now closed to the public. --- 2010-08-01 Holger Vogt * autogen.sh: update for CYGWIN and LINUX * compile-mingw.sh: added to allow compilation of admsXml.exe on MINGW * configure.ac: check for GD perl module removed * /images/makefile.am: image generation removed (are already there). * mkelements.pl: add preprocessor flag 'staticlink' to use with MINGW compilation ADMS-release-2.3.7/INSTALL000066400000000000000000000366051371671745500147500ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. ADMS-release-2.3.7/Makefile.am000066400000000000000000000011611371671745500157400ustar00rootroot00000000000000ACLOCAL_AMFLAGS = -I m4 extra = \ bootstrap.sh \ create_files.sh \ CMakeLists.txt \ README.md \ README-NGSPICE EXTRA_DIST= \ adms.css \ adms.xml \ admsstyle.xsl \ admst.dtd \ admst.xml \ admstpath.xml \ admstpathstyle.xsl \ admststyle.xsl \ metaadms.dtd \ metaadms.xsd \ metaadmst.dtd \ metaadmst.xsd \ metaadmstpath.dtd \ metaadmstpath.xsd \ $(extra) \ config.h \ config.h.cmake \ cmake/modules/FindPerlModules.cmake SUBDIRS=scripts admsXml CLEANFILES=*\~ .*.swp ADMS-release-2.3.7/NEWS000066400000000000000000000112521371671745500144050ustar00rootroot00000000000000##################################################################### # ChangeLog # ##################################################################### 10-10-2000: Increment version 1.0.2 1.0.1 has been used to compile r3-1.0.0 01-06-2001: Increment version 1.0.3 Made a lot of simplifications Remove class admsSemantic Add module admsNS Test-suite golden with previous SUCCEED 18-07-2001: Increment version 1.0.4 Made a lot of simplifications Test-suite golden with previous SUCCEED 25-07-2001: Increment version 1.0.5 mica/loadAC calls loadTRAN instead loadDC Test-suite golden with previous FAILED (mica) 30-07-2001: Increment version 1.0.6 useless classes removed Test-suite golden with previous SUCCEED 10-08-2001: Increment version 1.0.7 Made a lot of simplifications Test-suite golden with previous SUCCEED 13-08-2001: Increment version 1.0.8 Alias are not printed out by simulators Test-suite golden with previous FAILED (mica/spectre) 07-11-2002: Increment version: now 1.0.24 mica models created with this version (SP, MOSCAP3, R3, VBICSELFT) 07-11-2002: Increment version: now 1.0.25 mica models: 1.0.24 and 1.0.25 generate same c code for: HBT-1 MOSCAP3-9 R3-13 SMOS-16 SP-16 VBICSELFT-23 MOS1_lilly_qi-0 handles arrays of variables: module PDSOI_lilly_qi-0 20-11-2002: Increment version: now 1.1.0 start implementing admsXml mica models: 1.1.0 and 1.0.25 generate same c code 01-12-2002: Increment version: now 1.1.1 improve admsXml mica models: 1.1.1 and 1.0.25 generate same c code except for adms*/data/*interface_h.in (fix to _d_pow) 08-01-2003: Increment version: now 1.1.2 mica models: 1.1.2 and 1.1.1 generate same c code except MICAinterface.h (fixes to _limexp) except *defs.h and *noise.c (started implementation of noise analysis) 19-03-2003: Increment version: now 1.1.3 19-03-2003: Increment version: now 1.1.4 mica models: 1.1.4 and 1.1.2 generate same c code except file reverse.c (one comment added) module VBICSELFT: VBICSELFTdefs.h VBICSELFTevaluate.include VBICSELFTload.include VBICSELFTreserve.c module MOS1: it is a `A' device 19-03-2003: Increment version: now 1.1.5 mica models: 1.1.5 and 1.1.4 generate same c code except xml scripts for spectre 90% tested TODO: 1- "flag parameters" should be processed like real/int/string operators 2- remove "ask=" field 3- remove GLOBAL flag 4- add NOISE 5- add xpath=/adms to xml scripts 08-04-2003: Increment version: now 1.1.6 mica models: 1.1.6 and 1.1.5 generate same c code except WarningL R3-16 does not compile with this version. mica5HBT-1/HBTtopo.c mica6HBT-1/HBTtopo.c mica5MOSCAP3-14/MOSCAP3topo.c mica6MOSCAP3-14/MOSCAP3topo.c mica5VBICSELFT-24/VBICSELFTtopo.c mica6VBICSELFT-24/VBICSELFTtopo.c Same contents, however order of lines differ Keep changes and move to next version 11-04-2003: Increment version: now 1.1.7 mica models: 1.1.7 and 1.1.6 generate same c code for mica Did lot of clean-up in the code 15-04-2003: Increment version: now 1.1.8 mica models: 1.1.8 and 1.1.7 generate same c code for mica Did lot of clean-up 16-04-2003: Increment version: now 1.1.9 mica models: 1.1.9 and 1.1.8 generate same c code for mica. This version does not compile on Windows 17-04-2003: Increment version: now 1.1.10 mica models: 1.1.10 and 1.1.8 generate same c code for mica/spectre/ads Fixes to make adms compiled on Windows No check done on HPUX/SUN 18-04-2003: Increment version: now 1.1.11 fix bug in admsCheck that prevented use of gprof mica models: 1.1.11 and 1.1.8 generate same c code for mica/spectre/ads 18-05-2003: Increment version: now 1.1.12 fix bug in admsCheck that prevented use of gprof spectre: handles parameter range checking ads: improve syntax of code created mica: same c code as 1.1.8 03-05-2005: removed admsNS directory release adms-2.0.1 ===== gap ==== 21-11-2016: 2.3.6 **-08-2020: 2.3.7. minor release. reproducible build, typo fixes, include path, instructions ADMS-release-2.3.7/README-NGSPICE000066400000000000000000000021501371671745500156510ustar00rootroot00000000000000admsXml.exe 2010-08-04 Holger Vogt binary for MS Windows (32 bit, o.k. for 64 bit), created with MINGW gcc.exe (tdm-1) 4.5.0 Tested with ngspice under MINGW. Copy to MSYS /bin directory for immediate use with ngspice. How admsXml.exe was created: adms sources downloaded from svn server with $ svn co https://mot-adms.svn.sourceforge.net/svnroot/mot-adms/trunk/adms adms-svn on 2010-08-01 Changes made to sources * autogen.sh: update for CYGWIN and LINUX * compile-mingw.sh: added to allow compilation of admsXml.exe on MINGW * configure.ac: check for GD perl module removed * /images/makefile.am: image generation removed (are already there). * mkelements.pl; add preprocessor flag 'staticlink' to use with MINGW compilation * ChangeLog added Adapted sources are available at http://ngspice.sourceforge.net/admshowto.html Expand zip file to directory 'myadms' In CYGWIN window run cd myadms/adms-svn-ngspice-dist ./autogen_cyg.sh make install In MSYS window run cd myadms/adms-svn-ngspice-dist ./compile-mingw.sh admsXml.exe will be available in MSYS /bin diretory, ready for use with ngspice. ADMS-release-2.3.7/README.md000066400000000000000000000142641371671745500151730ustar00rootroot00000000000000 [![Build Status](https://travis-ci.org/Qucs/ADMS.svg?branch=master)](https://travis-ci.org/Qucs/ADMS) [![Build status](https://ci.appveyor.com/api/projects/status/r6k7oh37fuwujt32/branch/master?svg=true)](https://ci.appveyor.com/project/qucs/adms/branch/master) # ADMS - An automatic device model synthesizer ADMS is a code generator that converts electrical compact device models specified in high-level description language into ready-to-compile C code for the API of spice simulators. Based on transformations specified in XML language, ADMS transforms Verilog-AMS code into other target languages. This version is forked from the code previously available at: The original SVN repo is no longer available. This version is based on ADMS 2.3.0, the last version released by the original author in 2012. Currently only a subset of the Verilog-AMS language is supported. - Homepage (unmaintained): - Source code: ## Platforms ADMS is known to work on these platforms. - GNU/Linux - Darwin/OS X - FreeBSD - Windows ## Dependencies - C compiler (gcc, clang) - Autotools (autoconf, automake,...) or CMake - GNU Flex - GNU Bison (tested with 2.5+) - GNU Libtool - Perl with XML::LibXml - GD modules to manually update documentation images Installing dependencies on Linux Debian/Ubuntu: ``` sudo apt-get install build-essential sudo apt-get install automake libtool gperf flex bison sudo apt-get install libxml2 libxml2-dev sudo apt-get install libxml-libxml-perl sudo apt-get install libgd-perl ``` ### Maintainers Install and Packaging from Git This section is relevant in case ADMS is compiled from the Git repository. #### Compilation Using Autotools Use the default commands to compile, generate files and install. sh bootstrap.sh ./configure make install Autotools it currently used for creating release packages, the `adms-x.x.x.tar.gz` source code archive. sh bootstrap.sh ./configure make clean make dist #### Compilation Using CMake mkdir cmake; cd cmake cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/install/location/ make install Packaging is not yet supported with CMake. At the moment, only static libraries can be build with CMake. ### Users Install from Tarball This section is relevant in case ADMS is compiled from a source code archive (`adms-x.x.x.tar.gz`). #### Compilation Using Autotools tar xvfz adms-x.x.x.tar.gz cd adms-x.x.x ./configure --prefix=[/install/location/] make install #### Compilation Using CMake tar xvfz adms-x.x.x.tar.gz cd adms-x.x.x mkdir build; cd build cmake .. -DCMAKE_INSTALL_PREFIX=[/install/location/] make install #### Building an RPM Go through all the aclocal/automake/configure process to ensure you have all the dependencies installed. Chances are you will need to install these packages: gcc-c++ flex bison libtool libtool-ltdl-devel Then rename the ADSM directory to ADSM-2.3.0 and tar it to make ~/rpmbuild/SOURCES/ADMS-2.3.0.tar.gz Then copy the spec file into your rpmbuild/SPECS directory Then build with rpmbuild -ba SPECS/adms.spec ## Credits See AUTHORS file. ## License ADMS is under GPLv3. See COPYING file. --- Original author's build instructions: (for posterity) ``` 0- Prerequisites 0- gnu make is required (do not use other native make) 1- Description ADMS is a code generator that converts electrical compact device models specified in high-level description language into ready-to-compile c code for the API of spice simulators. 2- Installation - Unix or Linux 0- run: ./configure - see file INSTALLATION for more options 1- run: gmake 2- run: gmake install If the installation fails try: 0- run: autoheader 1- run: aclocal 2- run: automake 3- run: autoconf 4- run: ./configure - see file INSTALLATION for more options 5- run: gmake 6- run: gmake install In two shots: autoheader && aclocal && automake && autoconf && ./configure gmake && gmake install 3- Installation - Windows with cygwin environment 0- run: ./configure - see file INSTALLATION for more options 1- run: gmake 2- run: gmake install If the installation fails try: 0- run: autoheader 1- run: aclocal 2- run: automake 3- run: autoconf 4- run: ./configure - see file INSTALLATION for more options 5- run: gmake 6- run: gmake install In two shots: autoheader && aclocal && automake && autoconf && ./configure gmake && gmake install 4- Installation windows (no cygwin environment) 0- run: cl -DYY_NO_UNISTD_H -DPACKAGE_VERSION=\"msvc-229\" -DHAVE_CONFIG_H -DinsideElement -DinsidePreprocessor -DinsideVeriloga -I. -IadmsXml \ admsXml/adms.c admsXml/preprocessorLex.c admsXml/preprocessorMain.c admsXml/preprocessorYacc.c admsXml/verilogaLex.c admsXml/verilogaYacc.c \ admsXml/admsXml.c admsXml/admstpathYacc.c -o admsXml.exe If the installation fails send a message to r29173@users.sourceforge.net (note that there is NO strong support for windows compilers.) 5- Directory Structure adms - metaadms.dtd DTD of file adms.xml - adms.xml This file defines the data structure used by adms to save parsed hdl code. - auxconf set-up files created by automake -a -c - scripts: perl scripts - admsXml source code 5- For developers (using the cygwin environment) Here is how I create the compilation environment after checking out adms from the CVS repository: 0- run: autoheader (create autom4te.cache/config-h.in from configure.in) 1- run: mkdir auxconf (create directory auxconf) 2- run: aclocal (create aclocal.m4 from configure.in) 3- run: libtoolize --force --ltdl -c (create libltdl and config.guess, config.sub, ltmain.sh in auxconf) 4- run: automake -a -c (create missing, mkinstalldirs, install-sh in auxconf and all Makefile.in) 5- run: autoconf (create configure) 6- run: ./configure In three shots: rm -rf auxconf && autoheader && mkdir auxconf && aclocal && libtoolize --force --ltdl -c touch ChangeLog && automake -a -c && autoconf ./configure ``` ADMS-release-2.3.7/TODO000066400000000000000000000070441371671745500144020ustar00rootroot00000000000000## ## RCS Info ## $Id: TODO 682 2007-06-28 09:49:24Z r29173 $ ## ## Log ## $Log$ ## Revision 1.3 2004/08/03 12:33:54 r29173 ## import adms-1.21.0 from local CVS ## ## Revision 1.1.1.1 2004/05/21 12:20:01 r29173 ## recreated cvs data structure (crashed after revision 1.13.0!) ## ## Revision 1.3 2003/06/20 08:26:11 r29173 ## added RCS info into files ## ## Revision 1.3 2003/06/19 12:52:15 r29173 ## fixed dependency problem ## ## Revision 1.2 2003/05/21 14:20:55 r29173 ## add rcs info ## ## Bug: `define f(x) mytoto(V(I)): Cette phrase conduit le parser a echouer car mytoto n'est ni ANALOG, BUILTIN ou SYSTEM. La grammaire doit etre plus flexible et ne pas decider au niveau du lexer la semantique de mytoto. CoreDump: - parameter x=1u; 1u not supported - parameter x=1 exclude 0; exclude not supported Improvement: - dummy = $message: should be $message(...); - for(x;y;z): x should be saved as expression, not assignment -fixme: if(ln(x)<1.0) begin...end --> add suffix to tempory variables created for ln -fixme: c=$derivate(dynamic_code) --> declaration of c is static instead of derivate/dynamic -fixme:admsMica:add c code: if nb of terminals in netlist < default -> create new terminals ========================================================================================= Display: prendre comme base le soft "gmas" par example OPEN -- SAVE -- SAVE-AS -- ADMS -- COMPILE -- ABORT -- QUIT -- DEVICE(S) OPEN* SAVE* SAVE_AS* ADMS* MICA* ABORT* QUIT* list of devices VERILOGA SPICE ETC ----------------------------------------- | | | | | | | | | | | | | TEXT | | | | | | | | | ----------------------------------------- STAR `*': show default menu if click on parent menu, action linked to this menu is activated OPEN: OPEN*: open new window with list of current .ams files SAVE: SAVE*: save current text in same file or new file SAVE-AS: SAVE*-AS: prompt for file name save as current text given file name ADMS: ADMS*: check current file versus ADMS-grammar create internal parse-tree data create internal class object data FILE CREATED: .log USE : ALL MENU : message at bottom (OK or #warnings #errors) PARSE: parse current file wrt ADMS-grammar create internal parse-tree data .log file is created FILE CREATED: .log USE : DEBUG SEMANTIC: check current file wrt ADMS-grammar FILE CREATED: .log USE : DEBUG COMPILE: MICA*: MICA is default compiled language, create c-code for MICA DPI FILE CREATED: .log and all mica files USE : ALL MENU : message at bottom (OK or #warnings #errors) DEVICE(S): device list*: gives a list of devices for which compilation succeed (gives target language for which compilation succeed) ----------------------------------------------------------------------- ADMS-release-2.3.7/adms.css000066400000000000000000000064531371671745500153530ustar00rootroot00000000000000/* * RCS Info * $Id: adms.css 990 2008-04-29 15:08:06Z r29173 $ * * Log * $Log$ * Revision 1.13 2006/05/29 07:53:51 r29173 * improved display of stylesheet * * Revision 1.12 2005/11/30 13:57:21 r29173 * improved css definition of button * * Revision 1.11 2005/11/22 09:29:47 r29173 * added element comment * * Revision 1.10 2005/11/18 10:04:37 r29173 * added span.comment * * Revision 1.9 2005/04/14 13:31:19 r29173 * improved documentation * * Revision 1.8 2005/04/14 10:14:54 r29173 * improved documentation * * Revision 1.7 2005/03/31 18:11:58 r29173 * migration to adms-2.x.x:converted to adms2 syntax * * Revision 1.6 2005/03/17 11:46:04 r29173 * migration to adms-2.x.x:cosmetics * * Revision 1.5 2005/03/17 08:26:28 r29173 * migration to adms-2.x.x:move all href from absolute to relative values * * Revision 1.4 2005/03/16 17:37:47 r29173 * migration to adms-2.x.x:cosmetics * * Revision 1.3 2005/03/16 17:31:24 r29173 * migration to adms-2.x.x:small cosmetic * * Revision 1.2 2005/03/16 16:28:25 r29173 * migration to adms-2.x.x:start xpath coding; add documentation * * Revision 1.1 2005/03/14 17:34:20 r29173 * migration to adms-2.x.x:start xpath coding; add documentation * */ button { border-color: gray; border-width: 1pt; font-size:8pt; color:maroon; } button.semanticHidden { display:none; } button.semanticVisible { display:inline; border-color: gray; border-width: 1pt; font-size:8pt; color:maroon; } body { font-size:10pt; background-color:whitesmoke; } h1.title { text-align:center; color:maroon; font-size:12pt; } h1 { color:maroon; font-size:12pt; } h2 { color:maroon; font-size:10pt; margin-left:10px; } span.comment { color:maroon; font-size:10pt; margin-left:0px; } /* logos */ span.freescale { color:red; font-size:10pt; margin-left:15px; } span.sourceforge { color:red; font-size:10pt; margin-left:15px; } /* freegrammar grammar */ ul.freegrammar_productionset { list-style-type:disc; } ul.freegrammar_productionset_production { list-style-type:square; } li.freegrammar_productionset { color:black; } li.productionset_production { color:red; } span.production_constant { font-weight:bold; color:black; } span.production_regexp { font-weight:bold; color:magenta; } span.production_productionset { font-weight:bold; color:blue; } span.admst_transform { color:maroon; font-size:10pt; } span.admst_attribute { color:maroon; font-size:10pt; } body { font-size:10pt; } hr { color:navy; } p { font-size:10pt; margin-left:15px; } table { font-size:10pt; } td.rowspan { vertical-align:top; } td.notapplicable { color:gray; font-size:10pt; } pre { text-align:left; color:blue; font-size:8pt; margin-left:20px; } span.admst_obsolete { color:blue; } span.info { color:gray; font-style:italic; margin-left:5px; } span.shell_code, pre.admst_code, span.admst_transform { border-style:groove; border-width:thin; background-color:white; text-align:left; color:black; font-size:8pt; margin-left:20px; } a:link { color:maroon; text-decoration:none; } a:visited { color:maroon; text-decoration:none; } a:hover { color:black; } a:active { color:blue; } .trigger { cursor:pointer; display:block; } .branch { display:none; margin-left:16px; } ADMS-release-2.3.7/adms.xml000066400000000000000000002136321371671745500153620ustar00rootroot00000000000000 dummy variables: should be removed in the future basic adms elements elements used to save natures and disciplines inside the internal adms data tree elements used to save a module inside the internal adms data tree internal usage - parsing of xml scripts text: parse path: parse path: traverse transform: parse veriloga: parse ADMS-release-2.3.7/admsXml/000077500000000000000000000000001371671745500153125ustar00rootroot00000000000000ADMS-release-2.3.7/admsXml/CMakeLists.txt000066400000000000000000000140501371671745500200520ustar00rootroot00000000000000# This file is part of adms - http://sourceforge.net/projects/mot-adms. # # adms is a code generator for the Verilog-AMS language. # # Copyright (C) 2014-2015 Guilherme Brondani Torri # 2014 Luther T. Cat # # 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 . INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ) # for config.h INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ) # for admsPreprocessor.h, amdsVeriloga.h INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) # for generated source code # Run the Perl scrips to generate source code # Run mkelements.pl # Read in `adms.xml` and generete portions of adms and admst # Generate outputs: # adms.h # adms.c # admstpathYacc.y # admstpathYacc.h # admstpath.dtd MESSAGE(STATUS "Running mkelements.pl code generator") EXECUTE_PROCESS( COMMAND perl ${CMAKE_SOURCE_DIR}/admsXml/mkelements.pl ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE element_result ) IF(element_result EQUAL 0) MESSAGE(STATUS "mkelement.pl completed successfully") ELSE(element_result EQUAL 0) MESSAGE(FATAL_ERROR "mkelement.pl failed. Exit code: ${element_result}") ENDIF(element_result EQUAL 0) # Run mkctext.pl # Wrap source files as C code # Generate outputs: # constants.vams.c # disciplines.vams.c # adms.implicit.xml.c # dummy.va.c # dummy.xml.c SET(CTEXT constants.vams disciplines.vams adms.implicit.xml dummy.va dummy.xml ) FOREACH( inc ${CTEXT} ) MESSAGE(STATUS "Running mkctext.pl code generator on ${inc}") EXECUTE_PROCESS( COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/mkctext.pl ${CMAKE_CURRENT_SOURCE_DIR}/${inc} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE text_result ) IF(text_result EQUAL 0) MESSAGE(STATUS "mkctext.pl completed successfully") ELSE(text_result EQUAL 0) MESSAGE(FATAL_ERROR "mkctext.pl failed. Exit code: ${text_result}") ENDIF(text_result EQUAL 0) ENDFOREACH() # Run mkgrammar.pl # Process verilogaYacc.y.in and generate the parser # Generate output: # verilogaYacc.y # MESSAGE(STATUS "Running mkgrammar.pl code generator") EXECUTE_PROCESS( COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/mkgrammar.pl ${CMAKE_CURRENT_SOURCE_DIR}/verilogaYacc.y.in WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE grammar_result ) IF(grammar_result EQUAL 0) MESSAGE(STATUS "mkgrammar.pl completed successfully") ELSE(grammar_result EQUAL 0) MESSAGE(FATAL_ERROR "mkgrammar.pl failed. Exit code: ${grammar_result}") ENDIF(grammar_result EQUAL 0) # Issue with flex: # BISON_TARGET, FLEX_TARGET and ADD_FLEX_BISON_DEPENDENCY # Does not seem to overide the '%option outfile' or the location with -o option. # Solution: use custom command and set the working directory. # # -= admsElement =- # ADD_LIBRARY(admsElement ${CMAKE_CURRENT_BINARY_DIR}/adms.c) SET_TARGET_PROPERTIES(admsElement PROPERTIES COMPILE_DEFINITIONS insideElement) # # -= admsPreprocessor =- # SET(BisonOutput ${CMAKE_CURRENT_BINARY_DIR}/preprocessorYacc.h ${CMAKE_CURRENT_BINARY_DIR}/preprocessorYacc.c ) ADD_CUSTOM_COMMAND( OUTPUT ${BisonOutput} COMMAND ${BISON_EXECUTABLE} ARGS -by -opreprocessorYacc.c ${CMAKE_CURRENT_SOURCE_DIR}/preprocessorYacc.y WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) SET(FlexOutput ${CMAKE_CURRENT_BINARY_DIR}/preprocessorLex.h ${CMAKE_CURRENT_BINARY_DIR}/preprocessorLex.c ) ADD_CUSTOM_COMMAND( OUTPUT ${FlexOutput} COMMAND ${FLEX_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/preprocessorLex.l WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) ADD_LIBRARY(admsPreprocessor preprocessorMain.c ${BisonOutput} ${FlexOutput} ) SET_TARGET_PROPERTIES(admsPreprocessor PROPERTIES COMPILE_DEFINITIONS insidePreprocessor) # # -= admsVeriloga =- # SET(BisonOutput ${CMAKE_CURRENT_BINARY_DIR}/verilogaYacc.h ${CMAKE_CURRENT_BINARY_DIR}/verilogaYacc.c ) ADD_CUSTOM_COMMAND( OUTPUT ${BisonOutput} COMMAND ${BISON_EXECUTABLE} ARGS -by -overilogaYacc.c ${CMAKE_CURRENT_BINARY_DIR}/verilogaYacc.y WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) SET(FlexOutput ${CMAKE_CURRENT_BINARY_DIR}/verilogaLex.h ${CMAKE_CURRENT_BINARY_DIR}/verilogaLex.c ) ADD_CUSTOM_COMMAND( OUTPUT ${FlexOutput} COMMAND ${FLEX_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/verilogaLex.l WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) ADD_LIBRARY(admsVeriloga ${BisonOutput} ${FlexOutput} ) SET_TARGET_PROPERTIES(admsVeriloga PROPERTIES COMPILE_DEFINITIONS insideVeriloga) # # -= admsAdmstpath =- # SET(BisonOutput ${CMAKE_CURRENT_BINARY_DIR}/admstpathYacc.c ) ADD_CUSTOM_COMMAND( OUTPUT ${BisonOutput} COMMAND ${BISON_EXECUTABLE} ARGS -by -oadmstpathYacc.c ${CMAKE_CURRENT_BINARY_DIR}/admstpathYacc.y WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) # admstpathYacc.h is generated by mkelement.pl ADD_LIBRARY(admsAdmstpath ${BisonOutput} ${CMAKE_CURRENT_BINARY_DIR}/admstpathYacc.h ) SET_TARGET_PROPERTIES(admsAdmstpath PROPERTIES COMPILE_DEFINITIONS insideadmstpathYacc) # # -= admsXml =- # ADD_EXECUTABLE(admsXml admsXml.c) TARGET_LINK_LIBRARIES(admsXml admsElement admsVeriloga admsAdmstpath admsPreprocessor -lm) # # -= admsCheck =- # ADD_EXECUTABLE(admsCheck admsCheck.c) TARGET_LINK_LIBRARIES(admsCheck admsElement) # # Handle installation # INSTALL(TARGETS admsXml DESTINATION bin) INSTALL(FILES admsXml.1 DESTINATION share/man/man1) INSTALL(TARGETS admsCheck DESTINATION bin) INSTALL(FILES admsCheck.1 DESTINATION share/man/man1) INSTALL(FILES constants.vams disciplines.vams DESTINATION include/adms) ADMS-release-2.3.7/admsXml/Makefile.am000066400000000000000000000053271371671745500173550ustar00rootroot00000000000000incfile=constants.vams disciplines.vams adms.implicit.xml dummy.va dummy.xml incfilec=$(incfile:=.c) generated_FILES=adms.h adms.c verilogaYacc.y admstpathYacc.y admstpathYacc.h $(incfilec) \ verilogaLex.c verilogaYacc.c verilogaYacc.h admstpathYacc.c \ preprocessorLex.c preprocessorYacc.c preprocessorYacc.h SUFFIXES=.vams .vams.c .va .va.c .xml .xml.c .y.in # use mkctext.pl to create C files containing the contents of each input file # in a C character array. The output is used by make check only $(incfilec):%.c:% ${srcdir}/mkctext.pl $(PERL) ${srcdir}/mkctext.pl $< $(top_srcdir) admstpathYacc.y admstpathYacc.h adms.h adms.c: ${top_srcdir}/adms.xml ${top_srcdir}/admstpath.xml ${srcdir}/mkelements.pl $(PERL) ${srcdir}/mkelements.pl $(top_srcdir) verilogaYacc.y: ${srcdir}/verilogaYacc.y.in ${srcdir}/mkgrammar.pl $(PERL) ${srcdir}/mkgrammar.pl ${srcdir}/verilogaYacc.y.in dist_man_MANS = admsXml.1 admsCheck.1 lib_LTLIBRARIES=libadmsElement.la libadmsPreprocessor.la libadmsVeriloga.la libadmsAdmstpath.la libadmsElement_la_SOURCES=adms.c libadmsElement_la_CPPFLAGS=-DinsideElement libadmsElement_la_LDFLAGS=-no-undefined preprocessorYacc.h: preprocessorYacc.c libadmsPreprocessor_la_SOURCES=preprocessorLex.l preprocessorMain.c preprocessorYacc.h preprocessorYacc.y libadmsPreprocessor_la_CPPFLAGS=-DinsidePreprocessor libadmsPreprocessor_la_LDFLAGS=-no-undefined libadmsPreprocessor_la_LIBADD=libadmsElement.la verilogaYacc.h: verilogaYacc.c libadmsVeriloga_la_SOURCES=verilogaYacc.y verilogaLex.l verilogaYacc.h libadmsVeriloga_la_CPPFLAGS=-DinsideVeriloga libadmsVeriloga_la_LDFLAGS=-no-undefined libadmsVeriloga_la_LIBADD=libadmsElement.la admstpathYacc.y: admstpathYacc.h libadmsAdmstpath_la_SOURCES= admstpathYacc.y admstpathYacc.h libadmsAdmstpath_la_CPPFLAGS=-DinsideadmstpathYacc libadmsAdmstpath_la_LDFLAGS=-no-undefined libadmsAdmstpath_la_LIBADD=libadmsElement.la #depends on adms.implicit.xml bin_PROGRAMS=admsXml admsCheck admsXml_SOURCES=admsXml.c admsXml_LDADD=-lm libadmsElement.la libadmsVeriloga.la libadmsPreprocessor.la libadmsAdmstpath.la admsXml_CPPFLAGS=${AM_CPPFLAGS} -DADMS_INCLUDEDIR=\"${pkgincludedir}\" admsXml.c: adms.implicit.xml.c # Rules to create the admsCheck test program admsCheck.c=$(incfilec) admsCheck_SOURCES=admsCheck.c admsCheck_LDADD=libadmsElement.la BUILT_SOURCES=verilogaYacc.c preprocessorYacc.c adms.h adms.c $(incfilec) EXTRA_DIST=mkctext.pl mkelements.pl mkgrammar.pl adms.h adms.c \ preprocessorYacc.h admsPreprocessor.h verilogaYacc.h admsVeriloga.h \ $(incfile) $(incfilec) verilogaYacc.y.in admstpath.dtd \ CMakeLists.txt ../config.h basicLibrary.xml CLEANFILES=.*.swp *\~ core $(generated_FILES) pkginclude_HEADERS = constants.vams disciplines.vams ADMS-release-2.3.7/admsXml/adms.implicit.xml000066400000000000000000001253441371671745500206020ustar00rootroot00000000000000 ADMS-release-2.3.7/admsXml/admsCheck.1000066400000000000000000000023361371671745500172620ustar00rootroot00000000000000.TH admsCheck "1" "September 2008" "Debian/GNU Linux" "User Commands" .SH NAME admsCheck \- Test Program for admsXml .SH SYNOPSIS .B admsCheck .SH DESCRIPTION admsCheck creates two files: dummy.va dummy.xml. These two files illustrate how program admsXml works. dummy.va is an example of Verilog-AMS file. dummy.xml is a control file used by admsXml to convert file dummy.va into file dummy.net. More specifically running 'admsXml -e dummy.xml dummy.va' creates file dummy.net. The contents of file dummy.net is entirely controlled by the instructions provided in file dummy.xml. .SH FILES dummy.va: dummy Verilog-AMS file created by admsCheck. dummy.xml: dummy xml file created by admsCheck. dummy.net: file created by admsXml. .SH OPTIONS There is no options for this program. .SH AVAILABILITY The latest version of admsCheck can always be obtained from \fBmot-adms.sourceforge.net\fR .SH "REPORTING BUGS" Known bugs are documented within the BUGS file. Report bugs to . .SH COPYRIGHT .PP This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH AUTHORS Written by Laurent Lemaitre . ADMS-release-2.3.7/admsXml/admsCheck.c000066400000000000000000000113511371671745500173410ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2013 Richard Crozier 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 . */ /* * RCS Info * $Id: admsCheck.c 1110 2008-10-14 13:40:29Z r29173 $ * * Log * $Log$ * Revision 1.17 2006/09/13 16:13:20 r29173 * started migration to www.antlr.org tools * * Revision 1.16 2006/08/04 17:15:32 r29173 * rearranged code partionning into files * * Revision 1.15 2006/06/16 12:24:25 r29173 * ton of changes: memory clean-up * * Revision 1.14 2006/06/09 16:49:34 r29173 * improved malloc management * * Revision 1.13 2006/01/26 13:39:25 r29173 * fixed core dump when running admsCheck * * Revision 1.12 2005/06/21 08:02:28 r29173 * renamed adms_set_admsmain to adms_valueto_admsmain * * Revision 1.11 2005/05/09 14:38:29 r29173 * cleaned-up source directory structure * * Revision 1.10 2005/05/03 09:35:14 r29173 * cleaned-up header file dependencies * * Revision 1.9 2005/05/03 07:58:19 r29173 * moved admsNS into admsFile * * Revision 1.8 2005/04/01 07:25:44 r29173 * renamed prefix .xsl to .xml * * Revision 1.7 2005/01/11 09:58:01 r29173 * tons of changes - simplify accessor names (valueof, valueto) * * Revision 1.6 2004/11/19 12:29:56 r29173 * renamed _C into CAT * saved argc, argv into admsmain element * added adms:setenv transform * * Revision 1.5 2004/11/11 13:45:03 r29173 * replaced g_message by adms_message_info * * Revision 1.4 2004/11/01 09:37:36 r29173 * changed messaging macros (avoid useless computation of arguments) * improved the coding of transforms in xmlProgram.c * * Revision 1.3 2004/08/03 12:33:54 r29173 * import adms-1.21.0 from local CVS * * Revision 1.2 2004/08/03 10:05:46 r29173 * removed superelement from admsgui * fixed some warnings issued during compilation * * Revision 1.1.1.1 2004/05/21 12:20:01 r29173 * recreated cvs data structure (crashed after revision 1.13.0!) * * Revision 1.10 2004/03/11 16:25:14 r29173 * started implementing code builder in yacc parser * * Revision 1.9 2004/03/08 13:58:05 r29173 * all code lower-cased * * Revision 1.8 2004/03/08 08:24:19 r29173 * started implementing code builder in yacc parser * * Revision 1.7 2004/01/13 11:25:51 r29173 * added adms_message_usage * * Revision 1.6 2004/01/09 16:23:45 r29173 * cleaned-up use of #include * * Revision 1.5 2004/01/08 10:28:49 r29173 * moved code to always.[ch] * * Revision 1.4 2004/01/05 11:07:51 r29173 * change the way admsCheck.xml is downloaded * * Revision 1.3 2003/10/22 15:11:36 r29173 * changed the way script "text2Ccode.pl" handles file name. * * Revision 1.2 2003/05/21 14:18:00 r29173 * add rcs info * */ /* admsCheck Small program to perform a test run of adms using dummy.va and dummy.xml Used by 'make check' in the adms build system */ #include "adms.h" /*constants*/ #include "dummy.xml.c" #include "dummy.va.c" char*mydata[]={ "dummy.va","dummy_va", "dummy.xml","dummy_xml", NULL }; int main(const int argc, const char **argv) { char**mydataptr; rootnew(adms_admsmain_new("admsmain")); adms_admsmain_valueto_filename(root(),adms_kclone("stdin")); adms_message_info(("Create files:\n")); for( mydataptr=mydata; *mydataptr; mydataptr++,mydataptr++) { char*savefilename=*mydataptr; char*symbolname=*(mydataptr+1); char* myfilename=strdup(savefilename); FILE* ofh=fopen(myfilename,"w"); adms_message_info((" ... %s\n",myfilename)); free(myfilename); if(!strcmp(symbolname,"dummy_va")) fprintf(ofh,"%s",dummy_va); else if(!strcmp(symbolname,"dummy_xml")) fprintf(ofh,"%s",dummy_xml); fclose(ofh); } adms_message_info(("How to use the example\n")); adms_message_info((" admsXml dummy.va -e dummy.xml\n")); adms_message_info((" This command parses file dummy.va\n")); adms_message_info((" and interprets control file dummy.xml\n")); adms_message_info((" File dummy.net is created.\n")); adms_message_info((" (file .dummy.va.adms is created in background.)\n")); return 0; } ADMS-release-2.3.7/admsXml/admsPreprocessor.h000066400000000000000000000204461371671745500210240ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2015 Guilherme Brondani Torri 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 . */ /* * RCS Info * $Id: admsPreprocessor.h 985 2008-04-23 18:04:08Z r29173 $ * * Log * $Log$ * Revision 1.6 2005/11/08 14:07:59 r29173 * fixed bug (skipp_text becomes a list) * * Revision 1.5 2005/05/03 07:58:21 r29173 * moved admsNS into admsFile * * Revision 1.4 2004/11/19 12:29:56 r29173 * renamed _C into CAT * saved argc, argv into admsmain element * added adms:setenv transform * * Revision 1.3 2004/08/03 12:33:55 r29173 * import adms-1.21.0 from local CVS * * Revision 1.2 2004/05/26 13:02:48 r29173 * added default values to all enumerations * * Revision 1.1.1.1 2004/05/21 12:20:01 r29173 * recreated cvs data structure (crashed after revision 1.13.0!) * * Revision 1.11 2004/03/08 13:58:06 r29173 * all code lower-cased * * Revision 1.10 2004/02/06 09:06:03 r29173 * started implementing code builder in yacc parser * * Revision 1.9 2004/01/16 10:31:26 r29173 * added YYDEBUG=1 * * Revision 1.8 2004/01/09 16:23:47 r29173 * cleaned-up use of #include * * Revision 1.7 2004/01/06 14:13:13 r29173 * fixed definition of win32_interface * * Revision 1.6 2004/01/06 12:35:28 r29173 * fixed the use of globals: input file and output file * * Revision 1.5 2004/01/05 11:38:48 r29173 * removed unused code * * Revision 1.4 2003/12/11 16:10:11 r29173 * changed usage of win32_interface * * Revision 1.3 2003/12/11 16:01:53 r29173 * changed prefix [epst]_adms_ to [epst]_ * * Revision 1.2 2003/05/21 14:18:01 r29173 * add rcs info * */ #ifndef _preprocessor_main_included #define _preprocessor_main_included #include "adms.h" #undef win32_interface #if defined(WIN32) # if defined(insidePreprocessor) # define win32_interface __declspec(dllexport) # else # define win32_interface __declspec(dllimport) # endif #else # define win32_interface extern #endif // preprocessor flag for static link (MinGW) #ifdef staticlink # undef win32_interface # define win32_interface extern #endif #define last_char(s) s+(strlen(s)-1) #define INT2ADMS(a) ((p_adms)(long)(a)) win32_interface void adms_preprocessor_get_define_from_argv(const int argc,const char** argv); win32_interface int adms_preprocessor_getint_yydebug (void); win32_interface void adms_preprocessor_setint_yydebug (const int val); win32_interface int adms_preprocessor_registration_printf (const char *filename); typedef struct s_preprocessor t_preprocessor; typedef t_preprocessor* p_preprocessor; struct s_preprocessor { p_adms buffer; char * filename; FILE * fid; int cur_line_position; int cur_char_position; char * cur_message; p_slist cur_continuator_position; }; typedef struct s_preprocessor_pragma_define_text t_preprocessor_pragma_define_text; typedef t_preprocessor_pragma_define_text* p_preprocessor_pragma_define_text; struct s_preprocessor_pragma_define_text { char * name; int isArg; }; typedef struct s_preprocessor_pragma_define t_preprocessor_pragma_define; typedef t_preprocessor_pragma_define* p_preprocessor_pragma_define; struct s_preprocessor_pragma_define { char * name; int hasArg; int isDefined; p_slist arg; p_slist text; }; typedef struct s_preprocessor_substitutor t_preprocessor_substitutor; typedef t_preprocessor_substitutor* p_preprocessor_substitutor; typedef struct s_preprocessor_text t_preprocessor_text; typedef t_preprocessor_text* p_preprocessor_text; struct s_preprocessor_substitutor { p_preprocessor_pragma_define _pragma; p_slist _newarg; p_slist _newtext; p_preprocessor_text _cr_text; p_slist _cr_newarg; }; struct s_preprocessor_text { int _isarg; char * _str; }; typedef struct s_preprocessor_main t_preprocessor_main; typedef t_preprocessor_main* p_preprocessor_main; struct s_preprocessor_main { p_preprocessor cr_scanner; char * cr_filename; p_slist Scanner; p_slist Text; p_slist Defined; p_slist includePath; p_slist skipp_text; int error; }; win32_interface p_preprocessor_main pproot (void); win32_interface void adms_preprocessor_valueto_main (p_preprocessor_main mypreprocessor_main); win32_interface void preprocessorerror (const char *s); win32_interface int preprocessorlex (); win32_interface int preprocessorparse (); typedef struct s_continuator t_continuator; typedef t_continuator* p_continuator; struct s_continuator { int line_position; int char_position; }; win32_interface int adms_preprocessor_get_char_position (p_preprocessor cr_preprocessor); win32_interface int adms_preprocessor_get_line_position (p_preprocessor cr_preprocessor, int char_pos); win32_interface int adms_preprocessor_add_message ( char *message); win32_interface p_preprocessor_pragma_define adms_preprocessor_define_add (char * name); win32_interface int adms_preprocessor_define_add_default (char * name); win32_interface int adms_preprocessor_define_add_default_with_text (char * name, char * value); win32_interface p_preprocessor_pragma_define adms_preprocessor_undefine_add (char * name); win32_interface p_preprocessor_pragma_define adms_preprocessor_define_add_with_text (char * name, p_slist text); win32_interface p_preprocessor_pragma_define adms_preprocessor_define_add_with_arg (char * name, p_slist arg); win32_interface p_preprocessor_pragma_define adms_preprocessor_define_add_with_arg_and_text (char * name, p_slist arg, p_slist text); win32_interface p_preprocessor_pragma_define adms_preprocessor_pragma_define_exists (char * name); win32_interface int adms_preprocessor_identifier_is_def (char * name); win32_interface int adms_preprocessor_identifier_is_ndef (char * name); win32_interface p_preprocessor_pragma_define adms_preprocessor_identifer_set_undef (char * name); win32_interface int adms_preprocessor_pragma_define_is_def (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_is_ndef (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_arg (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_noarg (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_nullarg (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_text (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_notext (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_noarg_and_notext (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_noarg_and_text (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_nullarg_and_notext (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_nullarg_and_text (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_arg_and_notext (p_preprocessor_pragma_define pragma); win32_interface int adms_preprocessor_pragma_define_has_arg_and_text (p_preprocessor_pragma_define pragma); win32_interface p_preprocessor_text adms_preprocessor_new_text_as_string(char *name); win32_interface p_slist adms_preprocessor_new_text_as_substitutor (p_preprocessor_pragma_define define, p_slist newarg); win32_interface void adms_preprocessor_setfile_input (FILE *ifile); win32_interface FILE *adms_preprocessor_getfile_input (void); win32_interface void adms_preprocessor_setfile_output (FILE *ifile); win32_interface FILE *adms_preprocessor_getfile_output (void); #endif /* _preprocessor_main_included */ ADMS-release-2.3.7/admsXml/admsVeriloga.h000066400000000000000000000062311371671745500201020ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2015 Guilherme Brondani Torri 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 . */ /* * RCS Info * $Id: admsVeriloga.h 941 2008-03-27 17:38:57Z r29173 $ * * Log * $Log$ * Revision 1.6 2006/07/27 13:51:26 r29173 * moved code from xmlParser to admsImplicitTransforms * removed /simulator/function * * Revision 1.5 2006/01/13 10:07:04 r29173 * cleaned-up code style * * Revision 1.4 2005/05/09 14:38:31 r29173 * cleaned-up source directory structure * * Revision 1.3 2005/05/03 09:35:15 r29173 * cleaned-up header file dependencies * * Revision 1.2 2004/08/23 09:24:31 r29173 * removed unused function (adms_treedata_fatal) * * Revision 1.1 2004/08/03 12:33:55 r29173 * import adms-1.21.0 from local CVS * * Revision 1.3 2004/08/03 09:23:11 r29173 * renamed superelement into element * * Revision 1.2 2004/06/30 16:40:58 r29173 * renamed all admsObject files to object * * Revision 1.1.1.1 2004/05/21 12:20:01 r29173 * recreated cvs data structure (crashed after revision 1.13.0!) * * Revision 1.8 2004/04/19 21:03:22 r29173 * removed subdir admsTree * * Revision 1.7 2004/03/08 13:58:06 r29173 * all code lower-cased * * Revision 1.6 2004/01/16 10:30:00 r29173 * added accessors to yyin, yyout * * Revision 1.5 2004/01/06 14:13:13 r29173 * fixed definition of win32_interface * * Revision 1.4 2004/01/06 12:35:40 r29173 * fixed the use of globals: input file and output file * * Revision 1.3 2003/12/11 16:10:11 r29173 * changed usage of win32_interface * * Revision 1.2 2003/05/21 14:18:02 r29173 * add rcs info * */ #ifndef _admsveriloga_h #define _admsveriloga_h #include "adms.h" #undef win32_interface #if defined(WIN32) # if defined(insideVeriloga) # define win32_interface __declspec(dllexport) # else # define win32_interface __declspec(dllimport) # endif #else # define win32_interface extern #endif // preprocessor flag for static link (MinGW) #ifdef staticlink # undef win32_interface # define win32_interface extern #endif win32_interface void adms_veriloga_setint_yydebug (const int val); win32_interface void adms_veriloga_setfile_input (FILE *ifile); win32_interface void verilogaerror (const char *s); win32_interface int verilogalex (); win32_interface int verilogaparse (); typedef enum { ctx_any, ctx_moduletop } e_verilogactx; e_verilogactx verilogactx (); #endif /* _admsveriloga_h */ ADMS-release-2.3.7/admsXml/admsXml.1000066400000000000000000000036561371671745500170130ustar00rootroot00000000000000.TH admsXml "1" "September 2008" "Debian/GNU Linux" "User Commands" .SH NAME admsXml \- An automatic device model synthesizer. .SH SYNOPSIS .B admsXml source [\fIOPTIONS\fR] \fB\-e\fR script1 [\-e script2 ...] .SH DESCRIPTION admsXml is a code generator that converts electrical compact device models specified in high-level description language into ready-to-compile c code for the API of spice simulators. .SH FILES .TP \fR source verilog\-ams source code .TP \fR script1, ... admst scripts (xml format) .SH OPTIONS .TP \fB\-D\fR NAME predefine NAME as a macro, with definition `1' .TP \fB\-D\fR NAME=DEFINITION predefine NAME as a macro, with definition DEFINITION .TP \fB\-I\fR DIR Add directory DIR to search path for header files .TP \fB\-x\fR ignore file .adms.implicit.xml .TP \fB\-xv\fR do not check version number of scripts .TP \fB\-i\fR, \fB\-\-info\fR miscellaneous info (release, web site, mailing list) .TP \fB\-v\fR, \fB\-\-version\fR version number .TP \fB\-h\fR, \fB\-\-help\fR short help .SH ENVIRONMENT VARIABLES .TP \- adms_info="yes"|"no" print info [default=yes] .TP \- adms_usage="yes"|"no" print usage [default=yes] .TP \- adms_verbose="yes"|"no" print messages [default=no] .TP \- adms_debug="yes"|"no" print more messages [default=no] .TP \- adms_dbg_vla="yes"|"no" debug messages during vla parsing [default=no] .TP \- adms_dbg_xml="yes"|"no" debug messages during xml parsing [default=no] .TP \- adms_dbg_pre="yes"|"no" debug messages during vla preprocessing [default=no] .SH AVAILABILITY The latest version of admsXml can always be obtained from \fBmot-adms.sourceforge.net\fR .SH "REPORTING BUGS" Known bugs are documented within the BUGS file. Report bugs to . .SH COPYRIGHT .PP This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH AUTHORS Written by Laurent Lemaitre . ADMS-release-2.3.7/admsXml/admsXml.c000066400000000000000000003072771371671745500171030ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2014 Francesco Lannutti 2013-2014 Guilherme Brondani Torri 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 . */ /* [nepasimprimer] * RCS Info * $Id: admsXml.c 1184 2010-06-23 21:33:17Z r29173 $ * * Log * $Log$ * Revision 1.12 2006/09/08 16:03:46 r29173 * set transform attributes as admsttext * * Revision 1.11 2006/08/30 02:57:12 r29173 * added %() support * * Revision 1.10 2006/08/18 17:10:50 r29173 * did lot of simplifications * added element quark (character array) * * Revision 1.9 2006/08/10 11:31:47 r29173 * did lot of simplifications * * Revision 1.8 2006/08/04 17:15:31 r29173 * rearranged code partionning into files * * Revision 1.7 2006/08/02 16:45:52 r29173 * rearranged code partionning into files * * Revision 1.6 2005/04/25 12:29:33 r29173 * fixed few memory leak issues (introduced adms.._free) * * Revision 1.5 2004/11/19 12:29:56 r29173 * renamed _C into CAT * saved argc, argv into admsmain element * added adms:setenv transform * * Revision 1.4 2004/08/19 16:46:44 r29173 * cleaned-up i/o file handling * * Revision 1.3 2004/08/03 12:33:55 r29173 * import adms-1.21.0 from local CVS * * Revision 1.2 2004/05/26 13:02:47 r29173 * added default values to all enumerations * * Revision 1.1.1.1 2004/05/21 12:20:01 r29173 * recreated cvs data structure (crashed after revision 1.13.0!) * * Revision 1.67 2004/05/17 11:50:28 r29173 * simplified handling of variable attributes * * Revision 1.66 2004/05/13 07:34:50 r29173 * continue removing GNode* structure * * Revision 1.65 2004/05/05 10:19:30 r29173 * started removing GNode* structure * * Revision 1.64 2004/05/04 08:07:10 r29173 * added code for @final * removed libltdl * * Revision 1.63 2004/04/19 16:24:31 r29173 * moved code of xparser to xmlParser * * Revision 1.62 2004/04/19 15:41:37 r29173 * moved code of treeValidate to xmlParser * * Revision 1.61 2004/04/19 14:52:19 r29173 * cleaned-up code * added handling of \t in xml files * * Revision 1.60 2004/03/30 09:06:34 r29173 * added adms_message * added statistics * started noise implementation * * Revision 1.59 2004/03/25 20:14:49 r29173 * splitted variable->scope into small pieces * * Revision 1.58 2004/03/19 12:45:35 r29173 * started implementing code builder in yacc parser * * Revision 1.57 2004/03/19 10:24:58 r29173 * started implementing code builder in yacc parser * * Revision 1.56 2004/03/08 13:58:07 r29173 * all code lower-cased * * Revision 1.55 2004/03/08 08:24:20 r29173 * started implementing code builder in yacc parser * * Revision 1.54 2004/03/04 11:01:28 r29173 * started implementing code builder in yacc parser * * Revision 1.53 2004/03/02 13:42:00 r29173 * started implementing code builder in yacc parser * * Revision 1.52 2004/03/02 10:48:27 r29173 * start implementing support to new vla syntax * * Revision 1.51 2004/02/25 11:34:23 r29173 * start implementing support to new vla syntax * * Revision 1.50 2004/02/21 16:13:54 r29173 * start implementing support to new vla syntax * * Revision 1.49 2004/02/20 22:22:18 r29173 * start implementing support to new vla syntax * * Revision 1.48 2004/02/20 19:40:08 r29173 * start implementing support to new vla syntax * * Revision 1.47 2004/02/20 19:05:53 r29173 * start implementing support to new vla syntax * * Revision 1.46 2004/02/20 14:56:37 r29173 * start implementing support to new vla syntax * * Revision 1.45 2004/02/20 13:45:30 r29173 * start implementing support to new vla syntax * * Revision 1.44 2004/02/19 17:02:38 r29173 * started implementing code builder in yacc parser * * Revision 1.43 2004/02/19 01:25:11 r29173 * started implementing code builder in yacc parser * * Revision 1.42 2004/02/18 23:30:46 r29173 * started implementing code builder in yacc parser * * Revision 1.41 2004/02/18 00:43:01 r29173 * started implementing code builder in yacc parser * * Revision 1.40 2004/02/15 13:07:43 r29173 * started implementing code builder in yacc parser * * Revision 1.39 2004/02/14 22:46:49 r29173 * started implementing code builder in yacc parser * * Revision 1.38 2004/02/14 20:15:42 r29173 * started implementing code builder in yacc parser * * Revision 1.37 2004/02/13 14:28:39 r29173 * started implementing code builder in yacc parser * * Revision 1.36 2004/02/11 15:19:31 r29173 * release 1.5.1 * * Revision 1.35 2004/02/11 14:20:11 r29173 * started implementing code builder in yacc parser * * Revision 1.34 2004/02/10 16:44:30 r29173 * started implementing code builder in yacc parser * * Revision 1.33 2004/02/10 10:48:24 r29173 * started implementing code builder in yacc parser * * Revision 1.32 2004/02/06 16:27:19 r29173 * started implementing code builder in yacc parser * * Revision 1.31 2004/02/06 14:52:08 r29173 * started implementing code builder in yacc parser * * Revision 1.30 2004/02/05 21:37:03 r29173 * started implementing code builder in yacc parser * * Revision 1.29 2004/02/05 14:02:30 r29173 * started implementing code builder in yacc parser * * Revision 1.28 2004/02/04 20:49:12 r29173 * started implementing code builder in yacc parser * * Revision 1.27 2004/02/04 20:34:24 r29173 * started implementing code builder in yacc parser * * Revision 1.26 2004/02/03 12:48:29 r29173 * started implementing code builder in yacc parser * * Revision 1.25 2004/01/29 15:49:08 r29173 * renamed accessors of xmlnodes * * Revision 1.24 2004/01/28 16:15:06 r29173 * started implementing code builder in yacc parser * * Revision 1.23 2004/01/28 10:37:29 r29173 * started implementing code builder in yacc parser * * Revision 1.22 2004/01/27 17:20:15 r29173 * started implementing code builder in yacc parser * * Revision 1.21 2004/01/27 13:46:14 r29173 * started implementing code builder in yacc parser * * Revision 1.20 2004/01/22 12:10:40 r29173 * started implementing code builder in yacc parser * * Revision 1.19 2004/01/21 14:35:45 r29173 * started implementing code builder in yacc parser * * Revision 1.18 2004/01/16 11:18:29 r29173 * removed use of adms_xml_load_scope * * Revision 1.17 2004/01/16 10:24:02 r29173 * added admsPreprocessor code * added admsSimulator code * * Revision 1.16 2004/01/13 11:25:52 r29173 * added adms_message_usage * * Revision 1.15 2004/01/09 16:23:48 r29173 * cleaned-up use of #include * * Revision 1.14 2004/01/08 10:28:49 r29173 * moved code to always.[ch] * * Revision 1.13 2004/01/07 15:19:15 r29173 * added command line arguments -h and -v * * Revision 1.12 2004/01/06 12:35:01 r29173 * fixed the use of globals: input file and output file * * Revision 1.11 2004/01/05 11:40:14 r29173 * added message when no arg specified at command line * * Revision 1.10 2003/12/15 21:47:14 r29173 * started to create adms_object_new automatically * * Revision 1.9 2003/12/15 20:54:30 r29173 * started to create adms_object_new automatically * * Revision 1.8 2003/12/12 14:33:27 r29173 * changed construct (a!=NULL) into (a) or (a)?1:0 * * Revision 1.7 2003/12/11 16:01:54 r29173 * changed prefix [epst]_adms_ to [epst]_ * * Revision 1.6 2003/12/05 13:47:14 r29173 * used only one routine to create xml nodes * * Revision 1.5 2003/11/08 22:25:52 r29173 * re-organized code (removed file simulatorLoad.c) * * Revision 1.4 2003/11/08 17:46:10 r29173 * re-organized handling of xparsers * * Revision 1.3 2003/10/31 16:43:06 r29173 * clean-up the way xparser works * * Revision 1.2 2003/05/21 14:18:02 r29173 * add rcs info * */ /*[nepasimprimer]*/ #include "admstpathYacc.h" typedef void (*p_valueto) (p_adms myadms1,p_adms myadms2); typedef void (*p_valuetobasicenumeration) (p_adms myadms,admse myinteger); typedef void (*p_valuetobasicinteger) (p_adms myadms,int myinteger); typedef void (*p_valuetobasicreal) (p_adms myadms,double myreal); typedef void (*p_valuetobasicstring) (p_adms myadms,char *mystring); /* examples: /a/b => \0,a,b and a/b/ => a,b,\0*/ static p_slist adms_split_new (const char* myname) { p_slist mypath=NULL; const char* sj=myname; const char* si=myname; while(*sj!='\0') { if((*sj=='/')||(*sj=='\\')) { if(si==sj) adms_slist_push(&mypath,NULL); else adms_slist_push(&mypath,(p_adms)adms_m2nclone(si,sj)); si=sj+1; } sj++; } adms_slist_push(&mypath,(p_adms)adms_m2nclone(si,sj)); return adms_slist_reverse(mypath); } static void free_strlist (p_slist myli0) { p_slist myli; for(myli=myli0;myli;myli=myli->next) free(myli->data); adms_slist_free(myli0); } static char* dirname (const char* myname) { p_slist myli0=adms_split_new(myname); char* mydirname=NULL; p_slist myli=myli0; int first=1; #if defined(ADMS_OS_MS) if((myli->data==NULL)&&myli->next&&(!strcmp((char*)(myli->next->data),"cygdrive"))) { myli=myli->next->next; if(myli) { adms_k2strconcat(&mydirname,(char*)(myli->data)); adms_k2strconcat(&mydirname,":/"); myli=myli->next; } else adms_k2strconcat(&mydirname,ADMS_PATH_SEPARATOR); } #endif for(;myli;myli=myli->next,first=0) { if(myli->data==NULL) adms_k2strconcat(&mydirname,ADMS_PATH_SEPARATOR); else if(myli->next==NULL) { if(!strcmp((char*)(myli->data),".")||!strcmp((char*)(myli->data),"..")) { if(!first) adms_k2strconcat(&mydirname,ADMS_PATH_SEPARATOR); adms_k2strconcat(&mydirname,(char*)(myli->data)); } } else { adms_k2strconcat(&mydirname,(char*)(myli->data)); if(myli->next->next) adms_k2strconcat(&mydirname,ADMS_PATH_SEPARATOR); } } free_strlist(myli0); if(mydirname) return mydirname; else return adms_kclone("."); } static char* basename (const char* myname) { p_slist myli0=adms_split_new(myname); char* mybasename=NULL; p_slist myli=adms_slist_last(myli0); if(!(!strcmp((char*)(myli->data),".")||!strcmp((char*)(myli->data),".."))) adms_k2strconcat(&mybasename,(char*)(myli->data)); free_strlist(myli0); return mybasename; } static char* filename (const char* myname) { char* myfilename=NULL; char* mybasename=basename(myname); adms_strconcat(&myfilename,dirname(myname)); if(mybasename) { adms_k2strconcat(&myfilename,ADMS_PATH_SEPARATOR); adms_strconcat(&myfilename,mybasename); } return myfilename; } /*',,' becomes '' '' ''*/ /*'' becomes ''*/ /*'a\' 'b\' 'c' becomes 'a,b,c' - note: 'a\\' becomes 'a\' - strlen(delimiter) should be 1 */ static p_slist adms_strsplit (const char* string,const char* delimiter,int max_tokens) { p_slist myl=NULL; p_slist myslash=NULL; p_slist myli0=NULL; p_slist myli; const char* myrem=string; char* occurence=strstr(myrem,delimiter); int dlen=strlen(delimiter); int stringlen=strlen(myrem); while(--max_tokens && occurence) { int len=(int)(occurence-myrem); char* str=adms_knclone(myrem,len); adms_slist_push(&myli0,(p_adms)str); myrem+=len+dlen; if(!*myrem) adms_slist_push(&myli0,(p_adms)adms_kclone("")); occurence=strstr(myrem,delimiter); } if(*myrem) adms_slist_push(&myli0,(p_adms)adms_knclone(myrem,stringlen-(int)(myrem-string))); if(stringlen==0) adms_slist_push(&myli0,(p_adms)adms_kclone("")); adms_slist_inreverse(&myli0); for(myli=myli0;myli;myli=myli->next) { char*s=(char*)(myli->data); int mylength=strlen(s); if(myli->next&&mylength&&(*(s+mylength-1)=='\\')) { *(s+mylength-1)=*delimiter; if(!myslash) myslash=myli; } else { if(myslash) { p_slist mylj; char* myconcat=NULL; for(mylj=myslash;mylj!=myli->next;mylj=mylj->next) adms_strconcat(&myconcat,(char*)(mylj->data)); adms_slist_push(&myl,(p_adms)myconcat); myslash=NULL; } else adms_slist_push(&myl,myli->data); } } adms_slist_free(myli0); return adms_slist_reverse(myl); } static void adms_push_admst (p_admst myadmst,p_transform mytransform) { adms_slist_push(&root()->_valueof,(p_adms)myadmst); adms_slist_push(&root()->_valueof,(p_adms)mytransform); if(myadmst && myadmst->_refd) myadmst->_refd++; } /*[nepasimprimer]*/ static void awrite (p_transform mytransform,p_admst mylhs,p_admst myrhsori) { p_admst myrhs=aread(myrhsori); if(mylhs->_pseudo==admse__croix) { ((p_attribute)mylhs->_item.p)->_value=(p_adms)myrhs; if(myrhs) if(myrhs->_refd) myrhs->_refd++; } else if(!mylhs->_valueto) { adms_message_fatal_continue(("assignment not supported - lhs=%s rhs=%s\n",ns_etostr(mylhs->_pseudo),ns_etostr(myrhs->_pseudo))) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } else if(!myrhs) { ((p_valueto)mylhs->_valueto)(mylhs->_previous->_item.p,NULL); } else if(mylhs->_pseudo==admse_basicenumeration) { char* myvalues=aprintf(mytransform,myrhs); admse mye=ns_strtoe(myvalues); ((p_valuetobasicenumeration)mylhs->_valueto)(mylhs->_previous->_item.p,mye); free(myvalues); } else if(mylhs->_pseudo==admse_basicinteger) { char* myvalues=aprintf(mytransform,myrhs); int myi=adms_strtol(mytransform,myvalues); ((p_valuetobasicinteger)mylhs->_valueto)(mylhs->_previous->_item.p,myi); free(myvalues); } else if(mylhs->_pseudo==admse_basicreal) { char* myvalues=aprintf(mytransform,myrhs); double myr=adms_strtod(mytransform,myvalues); ((p_valuetobasicreal)mylhs->_valueto)(mylhs->_previous->_item.p,myr); free(myvalues); } else if(mylhs->_pseudo==admse_basicstring) { char* myvalues=aprintf(mytransform,myrhs); ((p_valuetobasicstring)mylhs->_valueto)(mylhs->_previous->_item.p,myvalues); } else if(mylhs->_pseudo==myrhs->_pseudo) ((p_valueto)mylhs->_valueto)(mylhs->_previous->_item.p,myrhs->_item.p); else if(mylhs->_pseudo==admse_empty) { if((myrhs->_pseudo==admse_basicenumeration) ||(myrhs->_pseudo==admse_basicinteger) ||(myrhs->_pseudo==admse_basicreal) ||(myrhs->_pseudo==admse_basicstring)) { adms_message_fatal_continue(("assigment not supported - lhs=empty rhs=%s\n",ns_etostr(myrhs->_pseudo))) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } else ((p_valueto)mylhs->_valueto)(mylhs->_previous->_item.p,myrhs->_item.p); } else if(mylhs->_pseudo!=admse_empty && myrhs->_pseudo!=admse_empty && mylhs->_pseudo!=myrhs->_pseudo) { /* SRW -- Changed this to a verbose message. This gets triggered when we replace a one-line conditional with a block, which must happen if we add a line such as for contribution splitting. Since the operation is done below anyway, it shouldn't be considered as an error. adms_message_error_continue(("mismatch in assigment - lhs=%s rhs=%s\n",ns_etostr(mylhs->_pseudo),ns_etostr(myrhs->_pseudo))) adms_message_error(("see %s\n",adms_transform_uid(mytransform))) */ adms_message_verbose(("mismatch in assigment - lhs=%s rhs=%s\n",ns_etostr(mylhs->_pseudo),ns_etostr(myrhs->_pseudo))) adms_message_verbose(("see %s\n",adms_transform_uid(mytransform))) ((p_valueto)mylhs->_valueto)(mylhs->_previous->_item.p,myrhs->_item.p); } else { ((p_valueto)mylhs->_valueto)(mylhs->_previous->_item.p,myrhs->_item.p); } } static void postx (p_transform mytransform) { p_slist myli; postxx(mytransform); for(myli=mytransform->_templates;myli;myli=myli->next) postx((p_transform)myli->data); for(myli=mytransform->_children;myli;myli=myli->next) postx((p_transform)myli->data); } /*[nepasimprimer]*/ static p_slist getlist_from_argv (const int argc,const char* *argv,const char* opt,char* argtype) { p_slist mylist=NULL; int i; for(i=1;i2)&&(value[0]=='-')) {} else if((strlen(value)==2)&&(value[0]=='-')) i++; else myargvalue=adms_kclone(argv[i]); } if(!strcmp(opt,value)) { if(i2)&&!strncmp(opt,value,2)) myargvalue=adms_knclone(value+2,strlen(value)-2); if(myargvalue) { char* myunixpath=filename(myargvalue); free(myargvalue); if(!strcmp(argtype,"file")) { if(!adms_file_isregular(myunixpath)) adms_message_fatal(("option %s: cannot read file '%s'\n",opt,myunixpath)) } else if(!strcmp(argtype,"directory")) { if(!adms_file_isdirectory(myunixpath)) adms_message_fatal(("option %s: cannot read directory '%s'\n",opt,myunixpath)) } adms_slist_push(&mylist,(p_adms)myunixpath); adms_message_verbose(("shift: %s %s\n",opt,myunixpath)) } } } return adms_slist_reverse(mylist); } #include "admsPreprocessor.h" #include "admsVeriloga.h" /*[nepasimprimer]*/ static void parseva (const int argc,const char** argv,char* myverilogamsfile) { p_slist myli; char* mytmpverilogamsfile=NULL; adms_k2strconcat(&mytmpverilogamsfile,"."); adms_strconcat(&mytmpverilogamsfile,basename(myverilogamsfile)); adms_k2strconcat(&mytmpverilogamsfile,".adms"); root()->_filename=basename(myverilogamsfile); root()->_fullfilename=adms_kclone(myverilogamsfile); root()->_curfilename=adms_kclone(myverilogamsfile); adms_message_info(("%sXml-%s (%s) %s %s\n",PACKAGE_NAME,PACKAGE_VERSION,GIT,__DATE__,__TIME__)) /* preprocess input file */ { p_preprocessor mypreprocessor=(p_preprocessor)malloc(sizeof(t_preprocessor)); FILE* myverilogamsfilefh=adms_file_open_read(myverilogamsfile); FILE* ofh=fopen(mytmpverilogamsfile,"wb"); if(!ofh) adms_message_fatal(("%s: failed to open file [write mode]\n",mytmpverilogamsfile)) adms_preprocessor_setfile_input(myverilogamsfilefh); mypreprocessor->cur_line_position=1; mypreprocessor->cur_char_position=1; mypreprocessor->cur_message=NULL; mypreprocessor->fid=myverilogamsfilefh; mypreprocessor->filename=adms_kclone(myverilogamsfile); mypreprocessor->buffer=NULL; mypreprocessor->cur_continuator_position=NULL; adms_preprocessor_valueto_main((p_preprocessor_main)malloc(sizeof(t_preprocessor_main))); pproot()->Defined=NULL; pproot()->Scanner=NULL; pproot()->Text=NULL; pproot()->cr_filename=adms_kclone(myverilogamsfile); pproot()->cr_scanner=mypreprocessor; pproot()->error=0; adms_slist_push(&pproot()->skipp_text,(p_adms)(long)(0)); pproot()->includePath=getlist_from_argv(argc,argv,"-I","directory"); adms_slist_push(&pproot()->includePath,(p_adms)"."); #ifdef ADMS_INCLUDEDIR adms_slist_push(&pproot()->includePath,(p_adms)ADMS_INCLUDEDIR); #endif adms_preprocessor_get_define_from_argv(argc,argv); adms_preprocessor_define_add_default("insideADMS"); adms_message_verbose(("create temporary file %s\n",mytmpverilogamsfile)) (int) preprocessorparse(); /* save preprocessed Verilog-AMS file */ fputs("# 1 \"",ofh); fputs(pproot()->cr_scanner->filename,ofh); fputs("\"\n",ofh); adms_slist_inreverse(&pproot()->Text); for(myli=pproot()->Text;myli;myli=myli->next) fputs(((p_preprocessor_text)(myli->data))->_str,ofh); fclose(ofh); /* free preprocessor */ free(mypreprocessor->filename); free(pproot()->cr_scanner); fclose(myverilogamsfilefh); } /* parses temporary file */ { FILE* ifh=adms_file_open_read(mytmpverilogamsfile); if(root()->_dbg_vla==admse_yes) adms_veriloga_setint_yydebug(1); adms_veriloga_setfile_input(ifh); if(verilogaparse(root())) adms_message_fatal(("parse Verilog-AMS preprocessed file '%s' failed\n",mytmpverilogamsfile)) else adms_message_verbose(("No error found during parsing\n")) fclose(ifh); } for(myli=root()->_module;myli;myli=myli->next) ((p_module)myli->data)->_evaluation=adms_evaluation_new(); free(mytmpverilogamsfile); free(myverilogamsfile); } /*[nepasimprimer]*/ static void Xattribute (p_transform mytransform,p_admst dot,p_admst dotdot) { } static void Xnotadmst (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist myli; p_slist Attribute=mytransform->_attribute; fputs("<",OUT()); fputs(mytransform->_name,OUT()); while(Attribute) { p_attribute myattribute=(p_attribute)Attribute->data; char* value=tsprintf(dot,(p_text)myattribute->_value); fputs(" ",OUT()); fputs(myattribute->_name,OUT()); fputs("=\"",OUT()); fputs(value,OUT()); free(value); fputs("\"",OUT()); Attribute=Attribute->next; } for(myli=mytransform->_children;myli;myli=myli->next) { p_transform mychild=(p_transform)myli->data; if(mychild->_callback==(void*)Xattribute) { char* name=tsprintf(dot,mychild->_textname); fputs(" ",OUT()); fputs(name,OUT()); free(name); fputs("=\"",OUT()); xtraverse(mychild->_children,dot,dotdot); fputs("\"",OUT()); } } fputs(">\n",OUT()); xtraverse(mytransform->_children,dot,dotdot); fputs("_name,OUT()); fputs(">\n",OUT()); } /*[nepasimprimer]*/ static int myskipversion=0; static void Xadmst (p_transform mytransform,p_admst dot,p_admst dotdot) { if(!myskipversion&&mytransform->_textversion) { char* installed=PACKAGE_VERSION; p_slist Installed=adms_strsplit(installed,".",3); int installed_major=strtol((char*)(Installed->data),(char* *)NULL,10); int installed_minor=strtol((char*)(Installed->next->data),(char* *)NULL,10); char* requested=tsprintf(dot,mytransform->_textversion); p_slist Requested=adms_strsplit(requested,".",3); int xmlrequested_major; int xmlrequested_minor; if(!(Requested&&Requested->next&&Requested->next->next)) adms_message_fatal(("%s: invalid version number\n",adms_transform_uid(mytransform))) errno=0; xmlrequested_major=strtol((char*)(Requested->data),(char* *)NULL,10); xmlrequested_minor=strtol((char*)(Requested->next->data),(char* *)NULL,10); if(errno) { adms_message_fatal_continue(("'%s' invalid number - expecting for instance %s\n",requested,installed)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } if((xmlrequested_major>installed_major)||(xmlrequested_major==installed_major && xmlrequested_minor>installed_minor)) { adms_message_fatal_continue(("adms version too old (requested by xml control file: %s installed adms version: %s)\n",requested,installed)) adms_message_fatal_continue(("please install more recent version of adms\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } if((xmlrequested_major_children,dot,dotdot); } /*[nepasimprimer]*/ static void Xforeach (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist myli; p_ptraverse pselect=bar(dot,mytransform->_pathselect); for(myli=pselect->_admst;myli;myli=myli->next) xtraverse(mytransform->_children,(p_admst)myli->data,dot); free_ptraverse(pselect); } static void Xjoin (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist myli; char* separator=(mytransform->_textseparator)?tsprintf(dot,mytransform->_textseparator):NULL; p_ptraverse pselect=bar(dot,mytransform->_pathselect); for(myli=pselect->_admst;myli;myli=myli->next) { xtraverse(mytransform->_children,(p_admst)myli->data,dot); if(myli->next&&separator) fputs(separator,OUT()); } free(separator); free_ptraverse(pselect); } static void Xbreak (p_transform mytransform,p_admst dot,p_admst dotdot) { break_found=1; } static void Xvalueof (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); if(pselect->_admst) { p_slist myli=pselect->_admst; for(;myli;myli=myli->next) { p_admst myadmst=(p_admst)myli->data; adms_push_admst(myadmst,mytransform); } } else adms_push_admst(NULL,mytransform); free_ptraverse(pselect); } /*[nepasimprimer]*/ /*bug: if-inside behaves like if-not-inside when 'select' is not a $var*/ static int Find (p_slist l,p_kadms data) { while(l) { if(l->data==data) return 1; l=l->next; } return 0; } static int Xifinsidep_isempty (p_transform mytransform,p_admst dot,p_admst dotdot) { p_admst mystackinto=adms_pull_admst(mytransform); if(mystackinto) { if(mystackinto->_pseudo==admse_basiclist) { adms_message_fatal_continue(("'into' is a dollar variable - this is not supported\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } else if(mystackinto->_pseudo==admse__ladms) { p_slist into=(p_slist)mystackinto->_item.p; p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist lselect; for(lselect=pselect->_admst;lselect;lselect=lselect->next) { p_admst myadmst=(p_admst)lselect->data; if(myadmst->_pseudo==admse_basiclist) { adms_message_fatal_continue(("'select' is a dollar variable - this is not supported\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } else if(myadmst->_pseudo==admse__ladms) { p_slist mylii; for(mylii=(p_slist)myadmst->_item.p;mylii;mylii=mylii->next) if(!Find(into,mylii->data)) { free_ptraverse(pselect); deref(mystackinto); return 0; } } else if(Find(into,myadmst->_item.p)) { free_ptraverse(pselect); deref(mystackinto); return 0; } } free_ptraverse(pselect); } deref(mystackinto); } return 1; } /*[nepasimprimer]*/ static void Xifinsidep (p_transform mytransform,p_admst dot,p_admst dotdot) { if(!Xifinsidep_isempty(mytransform,dot,dotdot)) xtraverse(mytransform->_children,dot,dotdot); } static void Xifnotinsidep (p_transform mytransform,p_admst dot,p_admst dotdot) { if(Xifinsidep_isempty(mytransform,dot,dotdot)) xtraverse(mytransform->_children,dot,dotdot); } /*[nepasimprimer]*/ static int Xifinsidepath_isempty (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse plist=bar(dot,mytransform->_pathlist); p_slist linto; for(linto=plist->_admst;linto;linto=linto->next) { p_admst ainto=(p_admst)linto->data; if(ainto->_pseudo==admse_basiclist) { adms_message_fatal_continue(("'into' is a dollar variable - this is not supported\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } else if(ainto->_pseudo==admse__ladms) { p_slist into=(p_slist)ainto->_item.p; if(into) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist lselect; for(lselect=pselect->_admst;lselect;lselect=lselect->next) { p_admst aselect=(p_admst)lselect->data; if(aselect->_pseudo==admse_basiclist) { adms_message_fatal_continue(("'select' is a dollar variable - this is not supported\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } else if(aselect->_pseudo==admse__ladms) { p_slist myli=(p_slist)aselect->_item.p; for(;myli;myli=myli->next) if(!Find(into,((p_admst)myli->data)->_item.p)) { free_ptraverse(pselect); free_ptraverse(plist); return 0; } } else if(Find(into,aselect->_item.p)) { free_ptraverse(pselect); free_ptraverse(plist); return 0; } } free_ptraverse(pselect); } } } free_ptraverse(plist); return 1; } static void Xifinsidepath (p_transform mytransform,p_admst dot,p_admst dotdot) { if(!Xifinsidepath_isempty(mytransform,dot,dotdot)) xtraverse(mytransform->_children,dot,dotdot); } static void Xifnotinsidepath (p_transform mytransform,p_admst dot,p_admst dotdot) { if(Xifinsidepath_isempty(mytransform,dot,dotdot)) xtraverse(mytransform->_children,dot,dotdot); } /*[nepasimprimer]*/ static void Xchoose (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist myli; for(myli=mytransform->_children;myli;myli=myli->next) { p_transform mychild=(p_transform)myli->data; if(!strcmp(mychild->_name,"admst:when")) { p_ptraverse ptest=bar(dot,mychild->_pathtest); if(ptest->_admst&&((p_admst)ptest->_admst->data)->_item.p) { xtraverse(mychild->_children,dot,dotdot); free_ptraverse(ptest); return; } free_ptraverse(ptest); } else if(!strcmp(mychild->_name,"admst:otherwise")) { xtraverse(mychild->_children,dot,dotdot); return; } else adms_message_fatal(("%s: %s admst transform unexpected",adms_transform_uid(mytransform),adms_transform_uid(mychild))) } } /*[nepasimprimer]*/ static void Xif (p_transform mytransform,p_admst dot,p_admst dotdot) { xtraverse(mytransform->_children,dot,dotdot); } /*[nepasimprimer]*/ static void Xreturn (p_transform mytransform,p_admst dot,p_admst dotdot) { char* myname=tsprintf(dot,mytransform->_textname); char* mystring=tsprintf(dot,mytransform->_textstring); p_admst d=adms_admst_newpa(dot,dot,(p_adms)adms_return_new(myname,mystring)); d->_hasnewbasicstring=2; free(myname); free(mystring); if(root()->_itransform) { d->_refd++; adms_slist_push(&((p_itransform)root()->_itransform->data)->_return,(p_adms)d); return; } adms_message_fatal_continue(("admst:return only allowed inside admst:template\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } /*[nepasimprimer]*/ static void Xapplytemplates (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myl0; for(myl0=pselect->_admst;myl0;myl0=myl0->next) { p_slist myl1; char* match=tsprintf((p_admst)myl0->data,mytransform->_textmatch); p_itransform myitransform; p_transform mytemplate=lookfortemplates(mytransform,match); if(!mytemplate) { adms_message_fatal_continue(("Template not found:\n")) adms_message_fatal_continue((" \n",match)) adms_message_fatal((" see: %s\n",adms_transform_uid(mytransform))) } free(match); myitransform=adms_itransform_new(mytemplate); myitransform->_originalcall=root()->_itransform?((p_itransform)root()->_itransform->data)->_originalcall:mytransform; adms_slist_push(&root()->_itransform,(p_adms)myitransform); if(((p_admst)myl0->data)->_item.p) { p_slist l; xtraverse(mytemplate->_children,(p_admst)myl0->data,dot); for(l=myitransform->_variable;l;l=l->next) { p_slist li; for(li=((p_admstvariable)l->data)->_value;li;li=li->next) deref((p_admst)li->data); adms_admstvariable_free((p_admstvariable)l->data); } } adms_slist_pull(&root()->_itransform); adms_slist_push(&root()->_itransforminsideapplytemplate,(p_adms)myitransform); xtraverse(mytransform->_children,(p_admst)myl0->data,dot); break_found=0; for(myl1=myitransform->_return;myl1;myl1=myl1->next) { p_admst myadmst=(p_admst)myl1->data; myadmst->_refd--; if(myadmst->_refd==1) { adms_return_free((p_return)myadmst->_item.p); adms_admst_free(myadmst); } } adms_itransform_free(myitransform); adms_slist_pull(&root()->_itransforminsideapplytemplate); } free_ptraverse(pselect); } /*[nepasimprimer]*/ static p_admstvariable getdollar (p_transform mytransform,p_admst dot) { char* tname=tsprintf(dot,mytransform->_textname); p_admstvariable mydollar=lookup_dollar(tname); if(!mydollar) { mydollar=adms_admstvariable_new(tname); if(root()->_itransform) { p_itransform myitransform=(p_itransform)root()->_itransform->data; adms_slist_push(&myitransform->_variable,(p_adms)mydollar); } else adms_slist_push(&root()->_variable,(p_adms)mydollar); } free(tname); return mydollar; } static void derefprevious (p_slist v) { p_slist l; for(l=v;l;l=l->next) { ((p_admst)l->data)->_refd--; deref((p_admst)l->data); } adms_slist_free(v); } static p_admstvariable getdollarnulled (p_transform mytransform,p_admst dot) { p_admstvariable mydollar=getdollar(mytransform,dot); derefprevious(mydollar->_value); mydollar->_value=NULL; return mydollar; } static void Xvariablenull (p_transform mytransform,p_admst dot,p_admst dotdot) { (void)getdollarnulled(mytransform,dot); } static void Xvariablep (p_transform mytransform,p_admst dot,p_admst dotdot) { adms_slist_push(&getdollarnulled(mytransform,dot)->_value,(p_adms)adms_pull_admst(mytransform)); } static void Xvariableconstant (p_transform mytransform,p_admst dot,p_admst dotdot) { adms_slist_push(&getdollarnulled(mytransform,dot)->_value,mytransform->_textstring->_token->data); } static void Xvariablestring (p_transform mytransform,p_admst dot,p_admst dotdot) { p_admstvariable mydollar=getdollar(mytransform,dot); p_slist mypreviousvalue=mydollar->_value; p_admst myadmst=adms_admst_newns(dot,dot,tsprintf(dot,mytransform->_textstring)); mydollar->_value=NULL; adms_slist_push(&mydollar->_value,(p_adms)myadmst); if(myadmst->_refd) myadmst->_refd++; derefprevious(mypreviousvalue); } static void Xvariable (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist l; p_slist ll; p_admstvariable mydollar=getdollar(mytransform,dot); p_slist mypreviousvalue=mydollar->_value; p_ptraverse ppath=bar(dot,mytransform->_pathpath); mydollar->_value=ppath->_admst; for(l=mydollar->_value;l;l=l->next) { if(((p_admst)l->data)->_refd) ((p_admst)l->data)->_refd++; if(((p_admst)l->data)->_hasnewbasicstring!=2) ((p_admst)l->data)->_refd++; } for(l=ppath->_alladmst;l;l=l->next) for(ll=(p_slist)l->data;ll;ll=ll->next) deref((p_admst)ll->data); for(l=ppath->_aliasadmst;l;l=l->next) deref((p_admst)l->data); for(l=ppath->_admst;l;l=l->next) deref((p_admst)l->data); adms_slist_free(ppath->_alladmst); adms_slist_free(ppath->_aliasadmst); free(ppath); derefprevious(mypreviousvalue); } /*[nepasimprimer]*/ static void Xvaluetop (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) awrite(mytransform,(p_admst)myli->data,adms_pull_admst(mytransform)); free_ptraverse(pselect); } static void Xvaluetopath (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_ptraverse ptstring=bar(dot,(p_path)mytransform->_textstring->_token->data); p_slist myli=pselect->_admst; p_slist mylii=ptstring->_admst; for(;myli&&mylii;myli=myli->next,mylii=mylii->next?mylii->next:mylii) awrite(mytransform,(p_admst)myli->data,(p_admst)mylii->data); free_ptraverse(ptstring); free_ptraverse(pselect); } static void Xvaluetonull (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli=pselect->_admst; for(;myli;myli=myli->next) { p_admst myadmst=(p_admst)myli->data; if(myadmst->_pseudo==admse_basiclist) ((p_admstvariable)myadmst->_item.p)->_value=NULL; else if(myadmst->_pseudo==admse__ladms || myadmst->_pseudo==admse__ladmst) awrite(mytransform,(p_admst)myli->data,NULL); else if(myadmst->_pseudo==admse__croix) { p_attribute myattribute=(p_attribute)myadmst->_item.p; myattribute->_value=NULL; } } free_ptraverse(pselect); } static void Xvaluetoconstant (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; p_admst myconstant=(p_admst)mytransform->_textstring->_token->data; for(myli=pselect->_admst;myli;myli=myli->next) awrite(mytransform,(p_admst)myli->data,myconstant); free_ptraverse(pselect); } static void Xvaluetostring (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist l; char* tvalue=tsprintf(dot,mytransform->_textstring); p_admst myadmst=adms_admst_newns(dot,dot,tvalue); for(l=pselect->_admst;l;l=l->next) awrite(mytransform,(p_admst)l->data,myadmst); deref(myadmst); free_ptraverse(pselect); } static void Xvalueto (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_ptraverse ppath=bar(dot,mytransform->_pathpath); p_slist myli; p_slist mylii=ppath->_admst; if(mylii) for(myli=pselect->_admst;myli;myli=myli->next,mylii=mylii->next?mylii->next:mylii) awrite(mytransform,(p_admst)myli->data,(p_admst)mylii->data); else for(myli=pselect->_admst;myli;myli=myli->next) awrite(mytransform,(p_admst)myli->data,NULL); free_ptraverse(ppath); free_ptraverse(pselect); } /*[nepasimprimer]*/ static void Xtext (p_transform mytransform,p_admst dot,p_admst dotdot) { if(mytransform->_textformat==NULL) return; if(mytransform->_pathselect) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) tprintf((p_admst)myli->data,mytransform->_textformat); free_ptraverse(pselect); } else tprintf(dot,mytransform->_textformat); } /*[nepasimprimer]*/ static void Xmessage (p_transform mytransform,p_admst dot,p_admst dotdot) { if(mytransform->_pathselect) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) { char* text=tsprintf((p_admst)myli->data,mytransform->_textformat); adms_message_info(("%s",text)) free(text); } free_ptraverse(pselect); } else { char* text=tsprintf(dot,mytransform->_textformat); adms_message_info(("%s",text)) free(text); } } static void Xwarning (p_transform mytransform,p_admst dot,p_admst dotdot) { if(mytransform->_pathselect) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) { char* text=tsprintf((p_admst)myli->data,mytransform->_textformat); adms_message_warning(("%s",text)) free(text); } free_ptraverse(pselect); } else { char* text=tsprintf(dot,mytransform->_textformat); adms_message_warning(("%s",text)) free(text); } } static void Xerror (p_transform mytransform,p_admst dot,p_admst dotdot) { if(mytransform->_pathselect) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) { char* text=tsprintf((p_admst)myli->data,mytransform->_textformat); adms_message_error(("%s",text)) free(text); } free_ptraverse(pselect); } else { char* text=tsprintf(dot,mytransform->_textformat); adms_message_error(("%s",text)) free(text); } } static void Xfatal (p_transform mytransform,p_admst dot,p_admst dotdot) { if(mytransform->_pathselect) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) { char* text=tsprintf((p_admst)myli->data,mytransform->_textformat); adms_message_fatal_continue(("%s",text)) free(text); } adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) free_ptraverse(pselect); } else { char* text=tsprintf(dot,mytransform->_textformat); adms_message_fatal_continue(("%s",text)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) free(text); } } /*[nepasimprimer]*/ static void Xnewarguments (p_transform mytransform,p_admst dot,p_admst dotdot) { p_admst myadmst; int size=adms_slist_length(mytransform->_textarguments); p_slist* Arguments=(p_slist*)calloc(size,sizeof(p_admst)); char* tdatatype=tsprintf(dot,mytransform->_textdatatype); p_new new=!strcmp(tdatatype,"quark")?adms_admsxml_new(mytransform,"basicstring"):adms_admsxml_new(mytransform,tdatatype); int i=0; p_slist myli; free(tdatatype); for(myli=mytransform->_textarguments;myli;myli=myli->next) { p_text myargname=(p_text)myli->data; if(myargname->_admse==admse__path) { p_ptraverse myptraverse=bar(dot,(p_path)myargname->_token->data); Arguments[i]=myptraverse->_admst; adms_slist_free(myptraverse->_alladmst); free(myptraverse); } else if(myargname->_admse==admse__p) { Arguments[i]=NULL; adms_slist_push(&Arguments[i],(p_adms)adms_pull_admst(mytransform)); } else { p_admst mynewadmst=adms_admst_newns(dot,dot,tsprintf(dot,myargname)); Arguments[i]=NULL; adms_slist_push(&Arguments[i],(p_adms)mynewadmst); } i++; } myadmst=new(mytransform,dot,Arguments,size); xtraverse(mytransform->_children,myadmst,dot); deref(myadmst); free(Arguments); } static void Xnew (p_transform mytransform,p_admst dot,p_admst dotdot) { p_admst myadmst; int size=mytransform->_pathinputs?adms_slist_length(mytransform->_pathinputs):1; p_slist* inputs=(p_slist*)calloc(size,sizeof(p_admst)); p_ptraverse* ptraverseinputs=(p_ptraverse*)calloc(size,sizeof(p_ptraverse)); char* tdatatype=tsprintf(dot,mytransform->_textdatatype); p_new new=!strcmp(tdatatype,"quark")?adms_admsxml_new(mytransform,"basicstring"):adms_admsxml_new(mytransform,tdatatype); int i=0; p_slist myli; free(tdatatype); for(myli=mytransform->_pathinputs;myli;myli=myli->next) { p_ptraverse myptraverse=bar(dot,(p_path)myli->data); inputs[i]=myptraverse->_admst; ptraverseinputs[i]=myptraverse; i++; } myadmst=new(mytransform,dot,inputs,size); xtraverse(mytransform->_children,myadmst,dot); deref(myadmst); for(i=0;i_pathinto); p_ptraverse pselect=bar(dot,mytransform->_pathselect); for(myli=pinto->_admst;myli;myli=myli->next) { p_admst myadmsti=(p_admst)myli->data; if(myadmsti->_pseudo==admse_basiclist) { p_slist mylistinto=((p_admstvariable)myadmsti->_item.p)->_value; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); adms_slist_push(&mylistinto,(p_adms)myadmstii); if(myadmstii->_refd) myadmstii->_refd++; } ((p_admstvariable)myadmsti->_item.p)->_value=mylistinto; } else if(myadmsti->_pseudo==admse__ladmst) { p_slist mylistinto=(p_slist)myadmsti->_item.p; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); adms_slist_push(&mylistinto,(p_adms)myadmstii); if(myadmstii->_refd) myadmstii->_refd++; } ((p_valueto)myadmsti->_valueto)(myadmsti->_previous->_item.p,(p_adms)mylistinto); } else if(myadmsti->_pseudo==admse__ladms) { p_slist mylistinto=(p_slist)myadmsti->_item.p; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); if(myadmstii->_pseudo==admse_basicstring) adms_slist_push(&mylistinto,(p_adms)adms_kclone(myadmstii->_item.s)); else adms_slist_push(&mylistinto,myadmstii->_item.p); } ((p_valueto)myadmsti->_valueto)(myadmsti->_previous->_item.p,(p_adms)mylistinto); } } free_ptraverse(pselect); free_ptraverse(pinto); } static void Xpushonduplicate (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist myli; p_slist mylii; p_ptraverse pinto=bar(dot,mytransform->_pathinto); p_ptraverse pselect=bar(dot,mytransform->_pathselect); for(myli=pinto->_admst;myli;myli=myli->next) { p_admst myadmsti=(p_admst)myli->data; if(myadmsti->_pseudo==admse_basiclist) { p_slist mylistinto=((p_admstvariable)myadmsti->_item.p)->_value; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); admse mytype0=myadmstii->_pseudo; int found=0; p_adms myadms0=myadmstii->_item.p; p_cmp mycmp=adms_admsxml_cmp(myadmstii); p_slist myliii; for(myliii=mylistinto;myliii&&!found;myliii=myliii->next) { p_admst myadmst1=(p_admst)myliii->data; p_adms myadms1=myadmst1->_item.p; admse mytype1=myadmst1->_pseudo; found=(mytype0==mytype1)&&(!mycmp(myadms0,myadms1)); } if(!found) { adms_slist_push(&mylistinto,(p_adms)myadmstii); if(myadmstii->_refd) myadmstii->_refd++; } } ((p_admstvariable)myadmsti->_item.p)->_value=mylistinto; } else if(myadmsti->_pseudo==admse__ladmst) { p_slist mylistinto=(p_slist)myadmsti->_item.p; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); admse mytype0=myadmstii->_pseudo; int found=0; p_adms myadms0=myadmstii->_item.p; p_cmp mycmp=adms_admsxml_cmp(myadmstii); p_slist myliii; for(myliii=mylistinto;myliii&&!found;myliii=myliii->next) { p_admst myadmst1=(p_admst)myliii->data; p_adms myadms1=myadmst1->_item.p; admse mytype1=myadmst1->_pseudo; found=(mytype0==mytype1)&&(!mycmp(myadms0,myadms1)); } if(!found) { adms_slist_push(&mylistinto,(p_adms)myadmstii); if(myadmstii->_refd) myadmstii->_refd++; } } ((p_valueto)myadmsti->_valueto)(myadmsti->_previous->_item.p,(p_adms)mylistinto); } else if(myadmsti->_pseudo==admse__ladms) { p_slist mylistinto=(p_slist)myadmsti->_item.p; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); admse mytype0=myadmstii->_pseudo; int found=0; p_adms myadms0=myadmstii->_item.p; p_cmp mycmp=adms_admsxml_cmp(myadmstii); p_slist myliii; for(myliii=mylistinto;myliii&&!found;myliii=myliii->next) { p_adms myadms1=myliii->data; admse mytype1=myadms1?myadms1->_datatypename:admse_empty; found=(mytype0==mytype1)&&(!mycmp(myadms0,myadms1)); } if(!found) { if(myadmstii->_pseudo==admse_basicstring) adms_slist_push(&mylistinto,(p_adms)adms_kclone(myadmstii->_item.s)); else adms_slist_push(&mylistinto,myadmstii->_item.p); } } ((p_valueto)myadmsti->_valueto)(myadmsti->_previous->_item.p,(p_adms)mylistinto); } } free_ptraverse(pselect); free_ptraverse(pinto); } static int oncompare (p_ptraverse poncompareinto0, p_ptraverse poncompareinto1) { p_slist myl0=poncompareinto0->_admst; p_slist myl1=poncompareinto1->_admst; int allthesame=1; if(adms_slist_length(myl0)!=adms_slist_length(myl1)) allthesame=0; else { for(;myl0&&allthesame;myl0=myl0->next,myl1=myl1->next) { p_admst myadmstcmp0=(p_admst)myl0->data; p_admst myadmstcmp1=(p_admst)myl1->data; allthesame=(myadmstcmp0->_item.p==myadmstcmp1->_item.p); } } free_ptraverse(poncompareinto1); return allthesame; } static int oncompare1 (p_ptraverse poncompareinto0, p_admst ai) { int found=0; p_slist lii=(p_slist)ai->_item.p; for(;lii&&!found;lii=lii->next) { p_admst d=adms_admst_newpa(ai,ai,lii->data); p_ptraverse poncompareinto1=bar(d,poncompareinto0->_transform->_pathoncompare); found=oncompare(poncompareinto0,poncompareinto1); adms_admst_free(d); } return found; } static void Xpushoncompare (p_transform mytransform,p_admst dot,p_admst dotdot) { p_slist myli; p_slist mylii; p_ptraverse pinto=bar(dot,mytransform->_pathinto); p_ptraverse pselect=bar(dot,mytransform->_pathselect); for(myli=pinto->_admst;myli;myli=myli->next) { p_admst myadmsti=(p_admst)myli->data; if(myadmsti->_pseudo==admse_basiclist) { p_slist mylistinto=((p_admstvariable)myadmsti->_item.p)->_value; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); p_ptraverse poncompareinto0=bar(myadmstii,mytransform->_pathoncompare); int found=0; p_slist myliii; for(myliii=mylistinto;myliii&&!found;myliii=myliii->next) found=oncompare(poncompareinto0,bar((p_admst)myliii->data,mytransform->_pathoncompare)); if(!found) { adms_slist_push(&mylistinto,(p_adms)myadmstii); if(myadmstii->_refd) myadmstii->_refd++; } free_ptraverse(poncompareinto0); } ((p_admstvariable)myadmsti->_item.p)->_value=mylistinto; } else if(myadmsti->_pseudo==admse__ladmst) { p_slist mylistinto=(p_slist)myadmsti->_item.p; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); p_ptraverse poncompareinto0=bar(myadmstii,mytransform->_pathoncompare); int found=0; p_slist myliii; for(myliii=mylistinto;myliii&&!found;myliii=myliii->next) found=oncompare(poncompareinto0,bar((p_admst)myliii->data,mytransform->_pathoncompare)); if(!found) { adms_slist_push(&mylistinto,(p_adms)myadmstii); if(myadmstii->_refd) myadmstii->_refd++; } free_ptraverse(poncompareinto0); } ((p_valueto)myadmsti->_valueto)(myadmsti->_previous->_item.p,(p_adms)mylistinto); } else if(myadmsti->_pseudo==admse__ladms) { p_slist mylistinto=(p_slist)myadmsti->_item.p; for(mylii=pselect->_admst;mylii;mylii=mylii->next) { p_admst myadmstii=aread((p_admst)mylii->data); p_ptraverse poncompareinto0=bar(myadmstii,mytransform->_pathoncompare); int found=0; found=oncompare1(poncompareinto0,myadmsti); if(!found) { if(myadmstii->_pseudo==admse_basicstring) adms_slist_push(&mylistinto,(p_adms)adms_kclone(myadmstii->_item.s)); else adms_slist_push(&mylistinto,myadmstii->_item.p); } free_ptraverse(poncompareinto0); } ((p_valueto)myadmsti->_valueto)(myadmsti->_previous->_item.p,(p_adms)mylistinto); } } free_ptraverse(pselect); free_ptraverse(pinto); } /*[nepasimprimer]*/ static void Xreset (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli=pselect->_admst; for(;myli;myli=myli->next) { p_admst myadmst=(p_admst)myli->data; if(myadmst->_pseudo==admse_basiclist) ((p_admstvariable)myadmst->_item.p)->_value=NULL; else if(myadmst->_pseudo==admse__ladms || myadmst->_pseudo==admse__ladmst) awrite(mytransform,(p_admst)myli->data,NULL); } free_ptraverse(pselect); } /*[nepasimprimer]*/ static void Xreverse (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli=pselect->_admst; for(;myli;myli=myli->next) { p_admst myadmst=(p_admst)myli->data; if(myadmst->_pseudo==admse_basiclist) adms_slist_inreverse(&((p_admstvariable)myadmst->_item.p)->_value); else if(myadmst->_pseudo==admse__ladms || myadmst->_pseudo==admse__ladmst) { p_slist mylist=(p_slist)myadmst->_item.p; adms_slist_inreverse(&mylist); ((p_valueto)myadmst->_valueto)(myadmst->_previous->_item.p,(p_adms)mylist); } } free_ptraverse(pselect); } /*[nepasimprimer]*/ static void Xread (p_transform mytransform,p_admst dot,p_admst dotdot) { char* myfilename=tsprintf(dot,mytransform->_textfile); parseva(1,NULL,myfilename); } /*[nepasimprimer]*/ static void Xopen (p_transform mytransform,p_admst dot,p_admst dotdot) { char* myfilename=tsprintf(dot,mytransform->_textfile); FILE*ofh; if(!(ofh=fopen(myfilename,"wb"))) adms_message_fatal(("%s: failed to open file [write mode]\n",myfilename)) if(ofh) adms_slist_push(&globalfileoutputlist,(p_adms)ofh); else adms_message_fatal(("%s: cannot open file.\n",adms_transform_uid(mytransform))) xtraverse(mytransform->_children,dot,dotdot); fclose(OUT()); adms_slist_pull(&globalfileoutputlist); free(myfilename); } /*[nepasimprimer]*/ static void Xsetenv (p_transform mytransform,p_admst dot,p_admst dotdot) { char* myname=tsprintf(dot,mytransform->_textname); char* mystring=tsprintf(dot,mytransform->_textstring); if(!adms_setenv(myname,mystring)) { adms_message_fatal(("cannot set shell variable: '%s=%s'\n",myname,mystring)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } free(myname); free(mystring); } /*[nepasimprimer]*/ static void Xcount (p_transform mytransform,p_admst dot,p_admst dotdot) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); adms_push_admst(adms_admst_newbi(dot,dot,adms_slist_length(pselect->_admst)),mytransform); free_ptraverse(pselect); } /*[nepasimprimer]*/ static void Xgetenv (p_transform mytransform,p_admst dot,p_admst dotdot) { char* myname=tsprintf(dot,mytransform->_textname); const char* myenv=getenv(myname); if(myenv==NULL) { adms_message_fatal_continue(("missing shell variable '%s'\n",myname)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } adms_push_admst(adms_admst_newns(dot,dot,adms_kclone(myenv)),mytransform); free(myname); } /*[nepasimprimer]*/ static void Xcopy (p_transform mytransform,p_admst dot,p_admst dotdot) { FILE*fromfh; FILE*tofh; char buf[1024]; char* tfrom=tsprintf(dot,mytransform->_textfrom); char* tto=tsprintf(dot,mytransform->_textto); char* myfromfile=filename(tfrom); char* myfrombasename=basename(myfromfile); char* myfromdirname=dirname(myfromfile); char* mytopath=filename(tto); char* mytofilename=NULL; char* mytodirname=NULL; free(tfrom); free(tto); if(!adms_file_isregular(myfromfile)) adms_message_fatal(("%s: from=`%s' file not found\n",adms_transform_uid(mytransform),myfromfile)) if(adms_file_isdirectory(mytopath)) { adms_k2strconcat(&mytodirname,mytopath); adms_k2strconcat(&mytofilename,mytopath); adms_k2strconcat(&mytofilename,ADMS_PATH_SEPARATOR); adms_k2strconcat(&mytofilename,myfrombasename); } else { mytodirname=dirname(mytopath); if(adms_file_isdirectory(mytodirname)) adms_k2strconcat(&mytofilename,mytopath); else adms_message_fatal(("%s: to=`%s' invalid directory\n",adms_transform_uid(mytransform),mytodirname)) } if(!strcmp(myfromdirname,mytodirname)) adms_message_fatal(("%s: file '%s' copied to itself!\n",adms_transform_uid(mytransform),myfromfile)) fromfh=fopen(myfromfile,"rb"); tofh=fopen(mytofilename,"wb"); if(!fromfh) adms_message_fatal(("%s: from=`%s' cannot open file [read mode]\n",adms_transform_uid(mytransform),myfromfile)) if(!tofh) adms_message_fatal(("%s: to=`%s' cannot open file [write mode]\n",adms_transform_uid(mytransform),mytopath)) while(!feof(fromfh)) { size_t newbytes=fread(buf,sizeof(char),sizeof(buf),fromfh); if(ferror(fromfh)) adms_message_fatal(("%s: from=`%s' cannot read file contents\n",adms_transform_uid(mytransform),myfromfile)) fwrite(buf,sizeof(char),newbytes,tofh); } fclose(tofh); fclose(fromfh); adms_message_verbose(("%s: copy file '%s' to '%s'\n",adms_transform_uid(mytransform),myfromfile,mytofilename)) free(myfromfile); free(myfromdirname); free(myfrombasename); free(mytopath); free(mytodirname); free(mytofilename); } /*[nepasimprimer]*/ struct sa {char *e1; char *nom; char *e2; /*=*/ char *e3; char *valeur; struct sa *X;}; struct sb {char *nom; char* e; struct sa *a0; struct sa *a;}; static void texttoxml (const char*s) { adms_message_admstdbg_impl("%s",s); } static char* xmltotxt (char*s) { char*s0=s; char*s1=s; while(*s) { if(!strncmp(s,"\r\n",2)) *s1='\n',s+=2; else if(!strncmp(s,""",6)) *s1='\"',s+=6; else if(!strncmp(s,"&",5)) *s1='&',s+=5; else if(!strncmp(s,"<",4)) *s1='<',s+=4; else if(!strncmp(s,">",4)) *s1='>',s+=4; else if(!strncmp(s,"'",6)) *s1='\'',s+=6; else *s1=*s,s++; s1++; } *s1='\0'; s0=realloc(s0,(s1-s0+1)*sizeof(char)); return s0; } static int xmlstrncpy (char*d,const char*o,int n) { int l=0; char*d0=d; while(*o&&n) { if(!strncmp(o,"\r\n",2)) l++,*d='\n',o+=2,n-=2; else if(!strncmp(o,"\n",1)) l++,*d='\n',o+=1,n-=1; else *d=*o,o++,n--; d++; } *d='\0'; d0=realloc(d0,(d-d0+1)*sizeof(char)); return l; } static char* xmlmemcpy (char*d,const char*o,int n,int *nl) { char*d0=d; while(*o&&n) { if(!strncmp(o,"\r\n",2)) *nl=*nl+1,*d=*o,d++,o++,n--; else if(!strncmp(o,"\n",1)) *nl=*nl+1; *d=*o,d++,o++,n--; } *d='\0'; return d0; } static int xmlisspace (const char c,int* L) { if(c=='\n') {*L+=1;return 1;} else return isspace(c); } /*[nepasimprimer]*/ #define FRfr_XMLFATAL0 "ben alors! ne commence pas par un nom\n" #define FRfr_XMLFATAL1 "ben alors! et le nom d'attribut devant le signe =.\n" #define FRfr_XMLFATAL2 "ben alors! le charactere = ?\n" #define FRfr_XMLFATAL3 "ben alors! le charactere \" ?\n" #define FRfr_XMLFATAL4 "ben alors! la valeur n'est pas terminee par le charactere \" ?\n" #define ANcn_XMLFATAL0 "%s:%i: tag doesn't start with a name\n",monfichier,*L #define ANcn_XMLFATAL1 "%s:%i: attribute name expected before character =\n",monfichier,*L #define ANcn_XMLFATAL2 "%s:%i: inside tag character \'=\' expected\n",monfichier,*L #define ANcn_XMLFATAL3 "%s:%i: inside tag character \'\"\' expected\n",monfichier,*L #define ANcn_XMLFATAL4 "%s:%i: unterminated attribute value - character \" expected\n",monfichier,*L #define XMLFATAL0 ANcn_XMLFATAL0 #define XMLFATAL1 ANcn_XMLFATAL1 #define XMLFATAL2 ANcn_XMLFATAL2 #define XMLFATAL3 ANcn_XMLFATAL3 #define XMLFATAL4 ANcn_XMLFATAL4 struct sb* balisenouveau(const char **cp,int* L,const char *monfichier) { struct sb* balisep=malloc(sizeof(struct sb)); struct sb balise; const char*c=*cp; const char*c0=c; balise.nom=NULL; balise.e=NULL; balise.a0=NULL; balise.a=NULL; for(;*c&&!isspace(*c)&&strncmp(c,">",1)&&strncmp(c,"/>",2);c++); if(c-c0) balise.nom=malloc(sizeof(char)*(c-c0+1)), balise.e=NULL, balise.a0=NULL, memcpy(balise.nom,c0,c-c0),balise.nom[c-c0]='\0'; else adms_message_fatal((XMLFATAL0)) while(*c) { char*e1; c0=c;for(;*c&&xmlisspace(*c,L);c++); if(!strncmp(c,">",1)||!strncmp(c,"/>",2)||!*c) { balise.e=malloc(sizeof(char)*(c-c0+1)), strncpy(balise.e,c0,c-c0), balise.e[c-c0]='\0'; break; } e1=malloc(sizeof(char)*(c-c0+1)); strncpy(e1,c0,c-c0); e1[c-c0]='\0'; c0=c;for(;*c&&!isspace(*c)&&(*c!='=');c++); if(c==c0) adms_message_fatal((XMLFATAL1)) if(balise.a0) balise.a=balise.a->X=malloc(sizeof(struct sa)), balise.a->X=NULL; else balise.a=balise.a0=malloc(sizeof(struct sa)), balise.a->X=NULL; balise.a->nom=malloc(sizeof(char)*(c-c0+1)); balise.a->e1=e1; memcpy(balise.a->nom,c0,c-c0),balise.a->nom[c-c0]='\0'; c0=c;for(;*c&&xmlisspace(*c,L);c++); balise.a->e2=malloc(sizeof(char)*(c-c0+1)), strncpy(balise.a->e2,c0,c-c0), balise.a->e2[c-c0]='\0'; if(*c!='=') adms_message_fatal((XMLFATAL2)) c++; c0=c;for(;*c&&xmlisspace(*c,L);c++); balise.a->e3=malloc(sizeof(char)*(c-c0+1)), strncpy(balise.a->e3,c0,c-c0), balise.a->e3[c-c0]='\0'; if(*c!='"') adms_message_fatal((XMLFATAL3)) c++; c0=c;for(;*c&&(*c!='\"');c++); if(*c!='\"') adms_message_fatal((XMLFATAL4)) balise.a->valeur=malloc(sizeof(char)*(c-c0+1)); balise.a->valeur=xmlmemcpy(balise.a->valeur,c0,c-c0,L); c++; } *balisep=balise; *cp=c; return balisep; } typedef struct sx* px; struct sx { int l; int c; const char* f; char *contenu; struct sb* bp; px r; px x; px X; px y; px Y0; px Y; void (*adms) (const px xp); void (*dbg) (const px xp); }; px noeud_courant=NULL; static void racinedbg (const px xp) { px Y; for(Y=xp->Y0;Y;Y=Y->X) (Y->dbg)(Y); } static void instructiondbg (const px xp) { adms_message_admstdbg_impl(" f,xp->l); texttoxml(xp->contenu); adms_message_admstdbg_impl("?>"); } static void declarationdbg (const px xp) { adms_message_admstdbg_impl(" f,xp->l); texttoxml(xp->contenu); adms_message_admstdbg_impl("?>"); } static void typededocumentdbg (const px xp) { adms_message_admstdbg_impl(" f,xp->l); texttoxml(xp->contenu); adms_message_admstdbg_impl("?>"); } static void commentairedbg (const px xp) { adms_message_admstdbg_impl(" "); } static void debutbalisedbg (const px xp) { if(!strcmp(xp->bp->nom,"admst")) adms_message_admstdbg_impl(" ",xp->f,xp->l); else { adms_message_admstdbg_impl(" <%s",xp->f,xp->l,xp->bp->nom); for(xp->bp->a=xp->bp->a0;xp->bp->a;xp->bp->a=xp->bp->a->X) adms_message_admstdbg_impl("%s",xp->bp->a->e1), adms_message_admstdbg_impl("%s",xp->bp->a->nom), adms_message_admstdbg_impl("%s",xp->bp->a->e2), adms_message_admstdbg_impl("="), adms_message_admstdbg_impl("%s",xp->bp->a->e3), adms_message_admstdbg_impl("\""), texttoxml(xp->bp->a->valeur), adms_message_admstdbg_impl("\""); adms_message_admstdbg_impl("%s",xp->bp->e); adms_message_admstdbg_impl(">"); } for(xp->Y=xp->Y0;xp->Y;xp->Y=xp->Y->X) (xp->Y->dbg)(xp->Y); } static void balisefeuilledbg (const px xp) { adms_message_admstdbg_impl(" <%s",xp->f,xp->l,xp->bp->nom); for(xp->bp->a=xp->bp->a0;xp->bp->a;xp->bp->a=xp->bp->a->X) adms_message_admstdbg_impl("%s",xp->bp->a->e1), adms_message_admstdbg_impl("%s",xp->bp->a->nom), adms_message_admstdbg_impl("%s",xp->bp->a->e2), adms_message_admstdbg_impl("="), adms_message_admstdbg_impl("%s",xp->bp->a->e3), adms_message_admstdbg_impl("\""), texttoxml(xp->bp->a->valeur), adms_message_admstdbg_impl("\""); adms_message_admstdbg_impl("%s",xp->bp->e); adms_message_admstdbg_impl("/>"); } static void findebalisedbg (const px xp) { if(!strcmp(xp->bp->nom,"admst")) adms_message_admstdbg_impl(" ",xp->f,xp->l); else { adms_message_admstdbg_impl(" f,xp->l); adms_message_admstdbg_impl("%s",xp->bp->nom); adms_message_admstdbg_impl("%s",xp->bp->e); adms_message_admstdbg_impl(">"); } } static void textedbg (const px xp) { texttoxml(xp->contenu); } static void xmlhook_start (const px xp); static void xmlhook_end (const px xp); static void xmlhook_text (const px xp); static void racineadms (const px xp) { px Y; for(Y=xp->Y0;Y;Y=Y->X) (Y->adms)(Y); } static void instructionadms (const px xp) {} static void declarationadms (const px xp) {} static void typededocumentadms (const px xp) {} static void commentaireadms (const px xp) {} static void debutbaliseadms (const px xp) { xmlhook_start(xp); for(xp->Y=xp->Y0;xp->Y;xp->Y=xp->Y->X) (xp->Y->adms)(xp->Y); } static void balisefeuilleadms (const px xp) { xmlhook_start(xp); xmlhook_end(xp); } static void findebaliseadms (const px xp) { xmlhook_end(xp); } static void texteadms (const px xp) { xmlhook_text(xp); } struct sx racine={0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,racineadms,racinedbg}; #define noeuds n(instruction) n(declaration) n(typededocument) n(commentaire) n(debutbalise) n(balisefeuille) n(findebalise) n(texte) #undef n #define n(I) static px I##new (char* contenu,struct sb* bp,const char*monfichier,const px y,const int l,const int c) \ {\ px xp=malloc(sizeof(struct sx)); \ xp->l=l; \ xp->c=c; \ xp->f=monfichier; \ xp->y=y; \ xp->Y0=NULL; \ xp->Y=NULL; \ xp->x=NULL; \ xp->X=NULL; \ xp->contenu=contenu; \ xp->bp=bp; \ xp->dbg= I## dbg; \ xp->adms= I## adms; \ if(y->Y0==NULL) y->Y=y->Y0=xp; \ else {y->Y=y->Y->X=xp;} \ return xp; \ } noeuds #undef n /*[nepasimprimer]*/ static void arbre (const char *s,const char*monfichier) { int L=1; noeud_courant=&racine; for(;*s;s++) { if(0) {} else if(!strncmp(s,"",23)) { const char*s0=s; int l; char*contenu; s+=23; l=s-s0; contenu=malloc(sizeof(char)*(l+1)); declarationnew(contenu,NULL,monfichier,noeud_courant,L,s-s0); L+=xmlstrncpy(contenu,s0,l); } else if(!strncmp(s,"s0+0)&&!strncmp(s-1,"?>",2));s++); if(*s) { int l=s-s0-1; char*contenu=malloc(sizeof(char)*(l+1)); declarationnew(contenu,NULL,monfichier,noeud_courant,L,s-s0); L+=xmlstrncpy(contenu,s0,l); } else adms_message_fatal(("%s:%i: xml declaration unterminated '%.20s'\n",monfichier,L,s0)) } else if(!strncmp(s,"s0+0)&&!strncmp(s-1,"?>",2));s++); if(*s) { int l=s-s0-1; char*contenu=malloc(sizeof(char)*(l+1)); instructionnew(contenu,NULL,monfichier,noeud_courant,L,s-s0); L+=xmlstrncpy(contenu,s0,l); } else adms_message_fatal(("%s:%i: xml instruction declaration unterminated '%.20s'\n",monfichier,L,s0)) } else if(!strncmp(s,"",3));s++); if(*s) { int l=s-s0-2; char*contenu=malloc(sizeof(char)*(l+1)); commentairenew(contenu,NULL,monfichier,noeud_courant,L,s-s0); L+=xmlstrncpy(contenu,s0,l); } else adms_message_fatal(("%s:%i: xml comment declaration unterminated '%.20s'\n",monfichier,L,s0)) } else if(!strncmp(s,"';s++); if(*s) { int l=s-s0-0; char*contenu=malloc(sizeof(char)*(l+1)); typededocumentnew(contenu,NULL,monfichier,noeud_courant,L,s-s0); L+=xmlstrncpy(contenu,s0,l); } else adms_message_fatal(("%s:%i: xml doctype declaration unterminated '%.20s'\n",monfichier,L,s0)) } else if(!strncmp(s,"';s++); if(s-s0) balisep->nom=malloc(sizeof(char)*(s-s0+1)), balisep->e=NULL, balisep->a0=NULL, memcpy(balisep->nom,s0,s-s0),balisep->nom[s-s0]='\0'; else adms_message_fatal(("%s:%i: end tag unterminated '%.20s'\n",monfichier,L0,s0)) s0=s;for(;*s&&xmlisspace(*s,&L);s++); balisep->e=malloc(sizeof(char)*(s-s0+1)), strncpy(balisep->e,s0,s-s0), balisep->e[s-s0]='\0'; if(*s&&*s=='>') { findebalisenew(NULL,balisep,monfichier,noeud_courant,L0,s-s0); if(!noeud_courant->bp) adms_message_fatal(("%s:%i: end tag '%s' floating\n",monfichier,L0,balisep->nom)) if(strcmp(noeud_courant->bp->nom,balisep->nom)) { adms_message_fatal_continue(("%s:%i: end tag mismatch '%s'\n",monfichier,L0,balisep->nom)) adms_message_fatal(("%s:%i: current open tag '%s'\n",monfichier,noeud_courant->l,noeud_courant->bp->nom)) } noeud_courant=(noeud_courant&&(noeud_courant!=&racine))?noeud_courant->y:NULL; } else adms_message_fatal(("%s:%i: end tag unterminated '%.20s'\n",monfichier,L0,s0)) } else if(*s=='<') { int L0=L; const char*s0=++s; struct sb* bp=balisenouveau(&s,&L,monfichier); if(!strncmp(s,"/>",2)) s++, balisefeuillenew(NULL,bp,monfichier,noeud_courant,L0,s-s0); else if(!strncmp(s,">",1)) noeud_courant=debutbalisenew(NULL,bp,monfichier,noeud_courant,L0,s-s0); else adms_message_fatal(("%s:%i: tag badly formed '%.20s'\n",monfichier,L0,s0)) } else { const char*s0; for(s0=s;*s&&*s!='<';s++); if(s>s0) { char*contenu=malloc(sizeof(char)*(s-s0+1)); textenew(contenu,NULL,monfichier,noeud_courant,L,s-s0); noeud_courant->Y->contenu=xmlmemcpy(contenu,s0,s-s0,&L); s--; } } } } /*[nepasimprimer]*/ #undef T #define T(p) !strcmp(mytransform->_name,#p) static void setcallback (p_transform mytransform) { if(T(admst:if-inside)) { if(mytransform->_textlist->_admse==admse__p) mytransform->_callback=(void*)Xifinsidep,mytransform->_id="Xifinsidep"; else if(mytransform->_textlist->_admse==admse__path) mytransform->_callback=(void*)Xifinsidepath,mytransform->_id="Xifinsidepath"; else { adms_message_fatal_continue(("'list' should be exactly '%%p' or '%%(...)'\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } } else if(T(admst:if-not-inside)) { if(mytransform->_textlist->_admse==admse__p) mytransform->_callback=(void*)Xifnotinsidep,mytransform->_id="Xifnotinsidep"; else if(mytransform->_textlist->_admse==admse__path) mytransform->_callback=(void*)Xifnotinsidepath,mytransform->_id="Xifnotinsidepath"; else { adms_message_fatal_continue(("'list' should be exactly '%%p' or '%%(...)'\n")) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } } else if(T(admst:variable)) { if(mytransform->_textselect) { if(mytransform->_textselect->_admse==admse__p) mytransform->_callback=(void*)Xvariablep, mytransform->_id="Xvariablep"; else if(mytransform->_textselect->_admse==admse__path) mytransform->_callback=(void*)Xvariable, mytransform->_id="Xvariable", mytransform->_pathpath=(p_path)mytransform->_textselect->_token->data; else if((adms_slist_length(mytransform->_textselect->_token)==1)&&(mytransform->_textselect->_token->data->_datatypename==admse_admst)) mytransform->_callback=(void*)Xvariableconstant, mytransform->_id="Xvariableconstant", mytransform->_textstring=mytransform->_textselect; else mytransform->_callback=(void*)Xvariablestring, mytransform->_id="Xvariablestring", mytransform->_textstring=mytransform->_textselect; } else if(mytransform->_textstring) { if((adms_slist_length(mytransform->_textstring->_token)==1)&&(mytransform->_textstring->_token->data->_datatypename==admse_admst)) mytransform->_callback=(void*)Xvariableconstant, mytransform->_id="Xvariableconstant"; else mytransform->_callback=(void*)Xvariablestring, mytransform->_id="Xvariablestring"; } else if(mytransform->_pathpath) mytransform->_callback=(void*)Xvariable, mytransform->_id="Xvariable"; else mytransform->_callback=(void*)Xvariablenull, mytransform->_id="Xvariablenull"; } else if(T(admst:value-to)) { if(mytransform->_textstring) { if(mytransform->_textstring->_admse==admse__p) mytransform->_callback=(void*)Xvaluetop, mytransform->_id="Xvaluetop"; else if(mytransform->_textstring->_admse==admse__path) mytransform->_callback=(void*)Xvaluetopath, mytransform->_id="Xvaluetopath"; else if((adms_slist_length(mytransform->_textstring->_token)==1)&&(mytransform->_textstring->_token->data->_datatypename==admse_admst)) mytransform->_callback=(void*)Xvaluetoconstant, mytransform->_id="Xvaluetoconstant"; else mytransform->_callback=(void*)Xvaluetostring, mytransform->_id="Xvaluetostring"; } else if(mytransform->_pathpath) mytransform->_callback=(void*)Xvalueto, mytransform->_id="Xvalueto"; else mytransform->_callback=(void*)Xvaluetonull, mytransform->_id="Xvaluetonull"; } else if(T(admst:text)) mytransform->_callback=(void*)Xtext,mytransform->_id="Xtext"; else if(T(admst:new)&&((mytransform->_textarguments))) mytransform->_callback=(void*)Xnewarguments,mytransform->_id="Xnewarguments"; else if(T(admst:new)&&((mytransform->_pathinputs))) mytransform->_callback=(void*)Xnew,mytransform->_id="Xnew"; else if(T(admst)) mytransform->_callback=(void*)Xadmst,mytransform->_id="Xadmst"; else if(T(admst:for-each)) mytransform->_callback=(void*)Xforeach,mytransform->_id="Xforeach"; else if(T(admst:join)) mytransform->_callback=(void*)Xjoin,mytransform->_id="Xjoin"; else if(T(admst:break)) mytransform->_callback=(void*)Xbreak,mytransform->_id="Xbreak"; else if(T(admst:value-of)) mytransform->_callback=(void*)Xvalueof,mytransform->_id="Xvalueof"; else if(T(admst:choice)||T(admst:choose)) mytransform->_callback=(void*)Xchoose,mytransform->_id="Xchoose"; else if(T(admst:when)) {mytransform->_id="Xnull_when";} else if(T(admst:otherwise)) {mytransform->_id="Xnull_otherwise";} else if(T(admst:if)) mytransform->_callback=(void*)Xif,mytransform->_id="Xif"; else if(T(admst:templates)||T(admst:template)) {mytransform->_id="Xnull_template";} else if(T(admst:apply-template)||T(admst:apply-templates)) mytransform->_callback=(void*)Xapplytemplates,mytransform->_id="Xapplytemplates"; else if(T(admst:return)) mytransform->_callback=(void*)Xreturn,mytransform->_id="Xreturn"; else if(T(admst:attribute)) mytransform->_callback=(void*)Xattribute,mytransform->_id="Xattribute"; else if(T(admst:push)) { if(mytransform->_pathoncompare) mytransform->_callback=(void*)Xpushoncompare,mytransform->_id="Xpushoncompare"; else if(mytransform->_textonduplicate&&!strcmp(tsprintf(NULL,mytransform->_textonduplicate),"ignore")) mytransform->_callback=(void*)Xpushonduplicate,mytransform->_id="Xpushonduplicate"; else mytransform->_callback=(void*)Xpush,mytransform->_id="Xpush"; } else if(T(admst:reset)) mytransform->_callback=(void*)Xreset,mytransform->_id="Xreset"; else if(T(admst:count)) mytransform->_callback=(void*)Xcount,mytransform->_id="Xcount"; else if(T(admst:reverse)) mytransform->_callback=(void*)Xreverse,mytransform->_id="Xreverse"; else if(T(admst:read)) mytransform->_callback=(void*)Xread,mytransform->_id="Xread"; else if(T(admst:open)) mytransform->_callback=(void*)Xopen,mytransform->_id="Xopen"; else if(T(admst:setenv)) mytransform->_callback=(void*)Xsetenv,mytransform->_id="Xsetenv"; else if(T(admst:getenv)) mytransform->_callback=(void*)Xgetenv,mytransform->_id="Xgetenv"; else if(T(admst:copy)) mytransform->_callback=(void*)Xcopy,mytransform->_id="Xcopy"; else if(T(admst:assert)) mytransform->_callback=(void*)Xassert,mytransform->_id="Xassert"; else if(T(admst:message)) mytransform->_callback=(void*)Xmessage,mytransform->_id="Xmessage"; else if(T(admst:warning)) mytransform->_callback=(void*)Xwarning,mytransform->_id="Xwarning"; else if(T(admst:error)) mytransform->_callback=(void*)Xerror,mytransform->_id="Xerror"; else if(T(admst:fatal)) mytransform->_callback=(void*)Xfatal,mytransform->_id="Xfatal"; else adms_message_fatal(("%s: unknown transform\n",adms_transform_uid(mytransform))) } static void setkeeplist (p_transform mytransform) { if((mytransform->_callback==(void*)Xvalueof) || (mytransform->_callback==(void*)Xifinsidep) || (mytransform->_callback==(void*)Xifnotinsidep) || (mytransform->_callback==(void*)Xvaluetonull) || (mytransform->_callback==(void*)Xreset) || (mytransform->_callback==(void*)Xreverse)) mytransform->_pathselect->_keeplist=1; else if((mytransform->_callback==(void*)Xpush)||(mytransform->_callback==(void*)Xpushoncompare)||(mytransform->_callback==(void*)Xpushonduplicate)) mytransform->_pathinto->_keeplist=1; else if((mytransform->_callback==(void*)Xifinsidepath) || (mytransform->_callback==(void*)Xifnotinsidepath)) mytransform->_pathlist->_keeplist=1; } static void xmlhook_start (const px xp) { int l=xp->l; const char* admstfile=xp->f; char* mybasename=basename(admstfile); p_slist Transform=root()->_transform; p_transform mytransform; struct sb* bp=xp->bp; const char* xname=bp->nom; if(!strcmp(xname,"admst")) mytransform=adms_transform_new(admstfile,mybasename,l,xname,NULL); else { p_transform parent=(p_transform)Transform->data; mytransform=adms_transform_new(admstfile,mybasename,l,xname,parent); if(T(admst:templates)||T(admst:template)) adms_slist_push(&parent->_templates,(p_adms)mytransform); else adms_slist_push(&parent->_children,(p_adms)mytransform); } free(mybasename); adms_slist_push(&root()->_transform,(p_adms)mytransform); if(is_admst(xname)) { for(bp->a=bp->a0;bp->a;bp->a=bp->a->X) { const char* aname=bp->a->nom; const char* avalue=xmltotxt(bp->a->valeur); if(((strlen(aname)==5)&&!strncmp(aname,"xmlns",5))||((strlen(aname)>5)&&!strncmp(aname,"xmlns:",6))) {} else if(!strcmp(aname,"arguments")) { p_slist myli=adms_strsplit(avalue,",",1000); p_slist myli0=myli; for(;myli;myli=myli->next) adms_slist_push(&mytransform->_textarguments,(p_adms)tparse(mytransform,aname,(char*)(myli->data))); adms_slist_inreverse(&mytransform->_textarguments); free_strlist(myli0); } else if(!strcmp(aname,"inputs")) { p_slist myli=adms_strsplit(avalue,",",1000); p_slist myli0=myli; for(;myli;myli=myli->next) adms_slist_push(&mytransform->_pathinputs,(p_adms)pparse(mytransform,aname,(char*)(myli->data))); adms_slist_inreverse(&mytransform->_pathinputs); free_strlist(myli0); } else if(!strcmp(aname,"oncompare")) mytransform->_pathoncompare=pparse(mytransform,aname,avalue); else if(!strcmp(aname,"test")) mytransform->_pathtest=pparse(mytransform,aname,avalue); else if(!strcmp(aname,"path")) mytransform->_pathpath=pparse(mytransform,aname,avalue); else if(!strcmp(aname,"into")) mytransform->_pathinto=pparse(mytransform,aname,avalue); else if(!strcmp(aname,"select")) { if(!strcmp(xname,"admst:variable")) mytransform->_textselect=tparse(mytransform,aname,avalue); else mytransform->_pathselect=pparse(mytransform,aname,avalue); } else if(!strcmp(aname,"string")||!strcmp(aname,"value")) mytransform->_textstring=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"match")) mytransform->_textmatch=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"required")) mytransform->_textrequired=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"separator")) mytransform->_textseparator=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"from")) mytransform->_textfrom=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"to")) mytransform->_textto=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"list")) { mytransform->_textlist=tparse(mytransform,aname,avalue); mytransform->_pathlist=(p_path)mytransform->_textlist->_token->data; } else if(!strcmp(aname,"name")) mytransform->_textname=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"format")) mytransform->_textformat=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"onduplicate")) mytransform->_textonduplicate=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"file")) mytransform->_textfile=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"version")) mytransform->_textversion=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"datatype")) mytransform->_textdatatype=tparse(mytransform,aname,avalue); else if(!strcmp(aname,"mode")) adms_message_obsolete(("%s:%i: attribute %s=\"%s\" is ignored\n",admstfile,l,aname,avalue)) else adms_message_fatal(("%s:%i: unknown attribute %s=\"%s\"\n",admstfile,l,aname,avalue)) } setcallback(mytransform); return; } else mytransform->_callback=(void*)Xnotadmst,mytransform->_id="Xnotadmst"; for(bp->a=bp->a0;bp->a;bp->a=bp->a->X) { const char* aname=bp->a->nom; const char* avalue=bp->a->valeur; p_attribute myattribute=adms_attribute_new(aname); myattribute->_value=(p_adms)tparse(mytransform,aname,avalue); adms_slist_push(&mytransform->_attribute,(p_adms)myattribute); } adms_slist_inreverse(&mytransform->_attribute); } static void xmlhook_end (const px xp) { p_slist Transform=root()->_transform; p_transform mytransform=Transform?(p_transform)Transform->data:NULL; sanityxx (mytransform); if(is_admst(mytransform->_name)) setkeeplist(mytransform); if(!T(admst)) adms_slist_pull(&root()->_transform); adms_slist_inreverse(&mytransform->_children); } /*[nepasimprimer]*/ static void dbx (p_transform mytransform) { p_slist myli; adms_message_admstdbg_impl("<%s file=\"%s\">\n",mytransform->_id,adms_transform_uid(mytransform)); dbxx(mytransform); for(myli=mytransform->_templates;myli;myli=myli->next) dbx((p_transform)myli->data); for(myli=mytransform->_children;myli;myli=myli->next) dbx((p_transform)myli->data); adms_message_admstdbg_impl("\n",mytransform->_id); } /*SNT becomes T static const char* text_excluding_leadingspaces (const char* text) { const char* cPtr=text; while(*cPtr&&isspace(*cPtr)) cPtr++; if(*cPtr&&(*cPtr=='\n' || *cPtr=='\r')) cPtr++; return cPtr; } */ /*[TNS]NS becomes [TNS]N */ static char* text_excluding_trailingspaces (const char* text) { const char* cPtr=text; const char* nl=NULL; int t=0; int space=0; while(*cPtr) { if(!isspace(*cPtr)) {t=1; space=0;} if(t&&(*cPtr=='\n' || *cPtr=='\r')) {nl=cPtr; space=0;} if(nl&&(*cPtr=='\n' || *cPtr=='\r')) space=1; cPtr++; } if(t&&space) return adms_knclone(text,nl-text); else if(t) return adms_kclone(text); else return NULL; } static void xmlhook_text (const px xp) { const char* text=xmltotxt(xp->contenu); char* newtext=text_excluding_trailingspaces(text); if(root()->_transform&&newtext) { p_transform parent=(p_transform)root()->_transform->data; char* mybasename=basename(xp->f); p_transform mytransform=adms_transform_new(xp->f,mybasename,parent->_l,"admst:text",parent); free(mybasename); mytransform->_textformat=tparse(mytransform,"text()",newtext); mytransform->_callback=(void*)Xtext,mytransform->_id="Xtext"; adms_slist_push(&parent->_children,(p_adms)mytransform); } free(newtext); } /*[nepasimprimer]*/ #if defined(STANDALONE) static void creearbrex(const char*xcode,const char*myadmstfile) #else static void creearbrex(const char*myadmstfile) #endif { #if defined(STANDALONE) char* xfile=adms_kclone(myadmstfile); char* xdata=adms_kclone(xcode); #else /*read xfile*/ char* xfile=filename(myadmstfile); FILE*xxfh=fopen(xfile,"rb"); char buf[1024]; char *xdata=NULL; size_t readbytes=0; if(!xxfh) adms_message_fatal(("%s: failed to open file [read mode]\n",xfile)) if(!adms_file_isregular(xfile)) adms_message_fatal(("%s: cannot read file - perhaps binary file\n",xfile)) while(!feof(xxfh)) { size_t newreadbytes=fread(buf,sizeof(char),sizeof(buf),xxfh); if(ferror(xxfh)) adms_message_fatal(("%s: failed to read file\n",xfile)) if(!(xdata=(char*)realloc(xdata,readbytes+newreadbytes))) adms_message_fatal(("%s: not enough memory available to read the file\n",xfile)) memcpy(xdata+readbytes,buf,newreadbytes); readbytes+=newreadbytes; } fclose(xxfh); xdata=(char*)realloc(xdata,readbytes+1); *(xdata+readbytes)='\0'; #endif racine.Y0=NULL; racine.Y=NULL; arbre(xdata,myadmstfile); free(xdata); free(xfile); } #if defined(STANDALONE) int admsmain (const char*xcode,const char*xflag,const char*vafile) { int argc=3; const char**argv=malloc(sizeof(char*)*argc); #else static void xbackup (const char* xfile,FILE*xfh) { FILE*xxfh=fopen(xfile,"rb"); char buf[1024]; char *firstbyte=NULL; size_t readbytes=0; if(!xxfh) adms_message_fatal(("%s: failed to open file [read mode]\n",xfile)) if(!adms_file_isregular(xfile)) adms_message_fatal(("%s: cannot read file - perhaps binary file\n",xfile)) while(!feof(xxfh)) { size_t newreadbytes=fread(buf,sizeof(char),sizeof(buf),xxfh); if(ferror(xxfh)) adms_message_fatal(("%s: failed to read file\n",xfile)) if(!(firstbyte=(char*)realloc(firstbyte,readbytes+newreadbytes))) adms_message_fatal(("%s: not enough memory available to read the file\n",xfile)) memcpy(firstbyte+readbytes,buf,newreadbytes); readbytes+=newreadbytes; } fclose(xxfh); firstbyte=(char*)realloc(firstbyte,readbytes+1); *(firstbyte+readbytes)='\0'; fwrite(firstbyte,sizeof(char),readbytes,xfh); fflush(xfh); free(firstbyte); } int main (const int argc,const char**argv) { #endif char* myadmsimplicitxmlfile; char* mygetenv=getenv("adms_implicit_transforms"); int myskipxmli=0; time_t mytime=time(NULL); p_slist myxargs; p_slist myli; FILE*xfh; char* xheader=NULL; const char* xinterface=".interface.xml"; #if defined(STANDALONE) argv[0]=adms_kclone("admsXml"); argv[1]=adms_kclone(xflag); argv[2]=adms_kclone(vafile); #endif /*NAN*/ adms_NAN=adms_dzero/adms_dzero; /*admsmain*/ rootnew(adms_admsmain_new("admsmain")); if(getenv("adms_info") && !strcmp(getenv("adms_info"), "no")) root()->_info=admse_no; if(getenv("adms_usage") && !strcmp(getenv("adms_usage"), "no")) root()->_usage=admse_no; if(getenv("adms_obsolete")&& !strcmp(getenv("adms_obsolete"),"no")) root()->_obsolete=admse_no; if(getenv("adms_hint") && !strcmp(getenv("adms_hint"), "yes")) root()->_hint=admse_yes; if(getenv("adms_verbose") && !strcmp(getenv("adms_verbose"), "yes")) root()->_verbose=admse_yes; if(getenv("adms_debug") && !strcmp(getenv("adms_debug"), "yes")) root()->_debug=admse_yes; if(getenv("adms_dbg_vla") && !strcmp(getenv("adms_dbg_vla"), "yes")) root()->_dbg_vla=admse_yes; if(getenv("adms_dbg_xml") && !strcmp(getenv("adms_dbg_xml"), "yes")) root()->_dbg_xml=admse_yes; /*argc,argv*/ { int i; root()->_argc=argc; root()->_argv=NULL; for(i=0;i_argv,(p_adms)adms_kclone(argv[i])); } } /*[nepasimprimer]*/ /*main.simulator*/ { char* sfullname=NULL; adms_k2strconcat(&sfullname,PACKAGE_NAME); adms_k2strconcat(&sfullname,"Xml-"); if(getenv("adms_check")) adms_k2strconcat(&sfullname,"0.0.0 (shell variable 'adms_check' is set!)"); else adms_k2strconcat(&sfullname,PACKAGE_VERSION); root()->_simulator=adms_simulator_new(sfullname); root()->_simulator->_fullname=adms_kclone(sfullname); } /*[nepasimprimer]*/ /*main.simulator.developer*/ if(getenv("adms_check")) root()->_simulator->_developer=adms_kclone("0.0.0 (shell variable 'adms_check' is set)"); else { char* sdeveloper=NULL; adms_k2strconcat(&sdeveloper,PACKAGE_NAME); adms_k2strconcat(&sdeveloper,"Xml"); adms_k2strconcat(&sdeveloper,"-"); adms_k2strconcat(&sdeveloper,PACKAGE_VERSION); adms_k2strconcat(&sdeveloper," ("); adms_k2strconcat(&sdeveloper,__DATE__); adms_k2strconcat(&sdeveloper,"-"); adms_k2strconcat(&sdeveloper,__TIME__); adms_k2strconcat(&sdeveloper,")"); root()->_simulator->_developer=sdeveloper; } /*[nepasimprimer]*/ /*main.simulator.currentdate*/ if(getenv("adms_check")) root()->_simulator->_currentdate=adms_kclone("0.0.0 (shell variable 'adms_check' is set)\n"); else { char mybuffer[100]; struct tm* mylocaltime=localtime(&mytime); strftime (mybuffer,100,"%a, %d %b %Y %H:%M:%S",mylocaltime); root()->_simulator->_currentdate=adms_kclone(mybuffer); } /*[nepasimprimer]*/ /*shell*/ if(getenv("adms_dbg_pre")) adms_preprocessor_setint_yydebug(1); else adms_preprocessor_setint_yydebug(0); /*[nepasimprimer]*/ if( (argc==1) || ((argc==2)&&!strcmp(argv[1],"-h")) || ((argc==2)&&!strcmp(argv[1],"--help")) || ((argc==3)&&!strcmp(argv[1],"--")&&!strcmp(argv[2],"help")) ) { adms_message_usage(("%sXml-%s (%s) ",PACKAGE_NAME,PACKAGE_VERSION,GIT)) adms_message_usage_continue(("%s %s (os=%s compiler=%s)\n",__DATE__,__TIME__,ADMS_OS,ADMS_COMPILER)) adms_message_usage(("%sXml source [options] -e script1 [-e script2 ...]\n",PACKAGE_NAME)) adms_message_usage(("files:\n")) adms_message_usage((" source: verilog-ams source code\n")) adms_message_usage((" script1, ...: admst scripts (xml format)\n")) adms_message_usage(("options:\n")) adms_message_usage((" -D NAME: predefine NAME as a macro, with definition `1'\n")) adms_message_usage((" -D NAME=DEFINITION: predefine NAME as a macro, with definition DEFINITION\n")) adms_message_usage((" -I DIR: Add directory DIR to search path for header files\n")) adms_message_usage((" -x : ignore file .adms.implicit.xml\n")) adms_message_usage((" -xv: do not check version number of scripts\n")) adms_message_usage(("shell variables:\n")) adms_message_usage(("- adms_info=\"yes\"|\"no\": print info [default=yes]\n")) adms_message_usage(("- adms_usage=\"yes\"|\"no\": print usage [default=yes]\n")) adms_message_usage(("- adms_verbose=\"yes\"|\"no\": print messages [default=no]\n")) adms_message_usage(("- adms_debug=\"yes\"|\"no\": print more messages [default=no]\n")) adms_message_usage(("- adms_dbg_vla=\"yes\"|\"no\": debug messages during vla parsing [default=no]\n")) adms_message_usage(("- adms_dbg_xml=\"yes\"|\"no\": debug messages during xml parsing [default=no]\n")) adms_message_usage(("- adms_dbg_pre=\"yes\"|\"no\": debug messages during vla preprocessing [default=no]\n")) adms_message_usage(("-i or --info: miscellaneous info (release, web site, mailing list)\n")) adms_message_usage(("-v or --version: version number\n")) adms_message_usage(("-h or --help: short help\n")) } else if( ((argc==2)&&!strcmp(argv[1],"-v")) || ((argc==2)&&!strcmp(argv[1],"--version")) || ((argc==3)&&!strcmp(argv[1],"--")&&!strcmp (argv[2],"version")) ) { adms_message_usage(("\n",PACKAGE_NAME,PACKAGE_VERSION,__DATE__,__TIME__)) return 0; } else if( ((argc==2)&&!strcmp(argv[1],"-i")) || ((argc==2)&&!strcmp(argv[1],"--info")) || ((argc==3)&&!strcmp(argv[1],"--")&&!strcmp(argv[2],"info")) ) { adms_message_usage(("\n")) adms_message_usage((" \n",GIT,__DATE__,__TIME__)) adms_message_usage(("\n")) return 0; } /*create implicit admst script*/ { if(mygetenv) { myadmsimplicitxmlfile=filename(mygetenv); adms_message_info(("loading implicit xml script %s\n",mygetenv)) adms_message_info(("(shell variable 'adms_implicit_transforms' has been set)\n")) } else { #include "adms.implicit.xml.c" FILE*ofh; myadmsimplicitxmlfile=adms_kclone(".adms.implicit.xml"); if(!(ofh=fopen(myadmsimplicitxmlfile,"wb"))) adms_message_fatal(("%s: failed to open file [write mode]\n",myadmsimplicitxmlfile)) fputs(adms_implicit_xml,ofh); fclose(ofh); } } if( (argc==1) || ((argc==2)&&!strcmp(argv[1],"-h")) || ((argc==2)&&!strcmp(argv[1],"--help")) || ((argc==3)&&!strcmp(argv[1],"--")&&!strcmp(argv[2],"help")) ) return 0; /*[nepasimprimer]*/ /*parse verilogams list*/ { p_slist l=getlist_from_argv(argc,argv,"-f","file"); for(myli=l;myli;myli=myli->next) parseva(argc,argv,(char*)(myli->data)); adms_slist_free(l); } /*add implicit admst script*/ myxargs=getlist_from_argv(argc,argv,"-e","file"); #if defined(STANDALONE) adms_slist_push(&myxargs,(p_adms)adms_kclone("stdin")); #endif adms_slist_push(&myxargs,(p_adms)myadmsimplicitxmlfile); /*[nepasimprimer]*/ /*traverse scripts*/ if(!(xfh=fopen(xinterface,"wb"))) adms_message_fatal(("%s: failed to open file [write mode]\n",xinterface)) adms_k2strconcat(&xheader,"\n\n"); fwrite(xheader,sizeof(char),strlen(xheader)*sizeof(char),xfh); #if defined(STANDALONE) fwrite(xcode,sizeof(char),strlen(xcode)*sizeof(char),xfh); #endif fflush(xfh); free(xheader); #if defined(STANDALONE) #else for(myli=myxargs;myli;myli=myli->next) if(!myskipxmli || myli!=myxargs) { const char* myadmstfile=(char*)(myli->data); char* xfile=filename(myadmstfile); char* xlocalheader=NULL; adms_k2strconcat(&xlocalheader,"\n"); adms_k2strconcat(&xlocalheader,"\n"); fwrite(xlocalheader,sizeof(char),strlen(xlocalheader)*sizeof(char),xfh); fflush(xfh); free(xlocalheader); xbackup(xfile,xfh); free(xfile); } #endif fclose(xfh); /*db*/ if(root()->_dbg_xml==admse_yes) { p_slist l; char*mydbgfile1=".admst1.xml"; char*mydbgfile2=".admst2.xml"; const char*admstdtduri="http://mot-adms.svn.sourceforge.net/viewvc/mot-adms/trunk/adms/admst.dtd"; #if defined(STANDALONE) creearbrex(xcode,".interface.xml"); #else creearbrex(".interface.xml"); #endif if(!(stdadmstdbgimpl=fopen(mydbgfile1,"wb"))) adms_message_fatal(("%s: failed to open file [write mode]\n",mydbgfile1)) adms_message_admstdbg_impl("\n"); adms_message_admstdbg_impl("\n",admstdtduri); adms_message_admstdbg_impl("\n",mydbgfile1); adms_message_admstdbg_impl("\n",admstdtduri); racine.dbg(&racine); adms_message_admstdbg_impl("\n"); fclose(stdadmstdbg); stdadmstdbgimpl=NULL; if(!(stdadmstdbgimpl=fopen(mydbgfile2,"wb"))) adms_message_fatal(("%s: failed to open file [write mode]\n",mydbgfile2)) adms_message_admstdbg_impl("\n"); for(l=root()->_transform;l;l=l->next) dbx((p_transform)l->data); adms_message_admstdbg_impl("\n"); fclose(stdadmstdbg); stdadmstdbgimpl=NULL; adms_message_info(("%s, %s: debug files created (note: shell variable 'adms_dbg_xml' is set)\n",mydbgfile1,mydbgfile2)) } /*[nepasimprimer]*/ for(myli=myxargs;myli;myli=myli->next) if(!myskipxmli || myli!=myxargs) { p_slist l; #if defined(STANDALONE) creearbrex(xcode,(char*)myli->data); #else creearbrex((char*)myli->data); #endif adms_message_verbose(("-e file: %s\n",(char*)myli->data)) racine.adms(&racine); if(root()->_dbg_xml==admse_yes) { char*mydbgfile=NULL; char* mybasename=basename((char*)myli->data); adms_k2strconcat(&mydbgfile,"."); adms_k2strconcat(&mydbgfile,mybasename); if(!(stdadmstdbgimpl=fopen(mydbgfile,"wb"))) adms_message_fatal(("%s: failed to open file [write mode]\n",mydbgfile)) racine.dbg(&racine); free(mydbgfile); free(mybasename); } adms_message_verbose(("traverse: %s\n",(char*)myli->data)) adms_slist_inreverse(&root()->_transform); /*postx*/ for(l=root()->_transform;l;l=l->next) postx((p_transform)l->data); /*traverse*/ for(l=root()->_transform;l;l=l->next) adms_slist_push(&root()->_invtransform,l->data); for(l=root()->_transform;l;l=l->next) { p_transform mytransform=(p_transform)l->data; p_admst myadmst=adms_admst_newpa(NULL,NULL,(p_adms)root()); Xadmst(mytransform,myadmst,NULL); deref(myadmst); } if(root()->_valueof) { p_transform mytransform=(p_transform)root()->_valueof->data; adms_message_fatal_continue(("stack '%%s' is not empty! (%i element(s) left)\n",adms_slist_length(root()->_valueof)/2)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } adms_slist_free(root()->_transform); root()->_transform=NULL; free(myli->data); } adms_slist_free(root()->_invtransform); adms_message_verbose(("%s: file created (all -e files in one file)\n",xinterface)) for(myli=root()->_variable;myli;myli=myli->next) { p_admstvariable dollar=(p_admstvariable)myli->data; p_slist l; for(l=dollar->_value;l;l=l->next) { ((p_admst)l->data)->_refd--; deref((p_admst)l->data); } adms_admstvariable_free(dollar); } adms_slist_free(myxargs); /*[nepasimprimer]*/ adms_message_info(("elapsed time: %g (second)\n",difftime(time(NULL),mytime))) adms_message_info(("admst iterations: %i (%i freed)\n",adms_global_nbadmstnew(),adms_global_nbadmstdestroy())) return 0; } #if defined (STANDALONE) && defined (APATHMAIN) int main (int argc,char **argv) { return apath_main (argc,argv); } #endif ADMS-release-2.3.7/admsXml/basicLibrary.xml000066400000000000000000002264451371671745500204570ustar00rootroot00000000000000 #define _cos(val,arg) val = cos(arg); #define _d_cos(val,dval,arg) val = cos(arg); dval = (-sin(arg)); #define _sin(val,arg) val = sin(arg); #define _d_sin(val,dval,arg) val = sin(arg); dval = (cos(arg)); #define _tan(val,arg) val = tan(arg); #define _d_tan(val,dval,arg) val = tan(arg); dval = (1.0/cos(arg)/cos(arg)); #define _hypot(xy,x,y) xy = sqrt((x)*(x)+(y)*(y)); #define _dx_hypot(dx,xy,x,y) dx = (x)/(xy); #define _dy_hypot(dy,xy,x,y) dy = (y)/(xy); #define _max(xy,x,y) xy = ((x)>(y))?(x):(y); #define _dx_max(dx,xy,x,y) dx = ((x)>(y))?1.0:0.0; #define _dy_max(dy,xy,x,y) dy = ((x)>(y))?0.0:1.0; #define _min(xy,x,y) xy = ((x)<(y))?(x):(y); #define _dx_min(dx,xy,x,y) dx = ((x)<(y))?1.0:0.0; #define _dy_min(dy,xy,x,y) dy = ((x)<(y))?0.0:1.0; #define _cosh(val,arg) val = cosh(arg); #define _d_cosh(val,dval,arg) val = cosh(arg); dval = (sinh(arg)); #define _sinh(val,arg) val = sinh(arg); #define _d_sinh(val,dval,arg) val = sinh(arg); dval = (cosh(arg)); #define _tanh(val,arg) val = tanh(arg); #define _d_tanh(val,dval,arg) val = tanh(arg); dval = (1.0/cosh(arg)/cosh(arg)); #define _acos(val,arg) val = acos(arg); #define _d_acos(val,dval,arg) val = acos(arg); dval = (-1.0/sqrt(1-arg*arg)); #define _asin(val,arg) val = asin(arg); #define _d_asin(val,dval,arg) val = asin(arg); dval = (+1.0/sqrt(1-arg*arg)); #define _atan(val,arg) val = atan(arg); #define _d_atan(val,dval,arg) val = atan(arg); dval = (+1.0/(1+arg*arg)); #define _logE(val,arg) val = log(arg); #define _d_logE(val,dval,arg) val = log(arg); dval = (1.0/arg); #define _log10(val,arg) val = log10(arg); #define _d_log10(val,dval,arg) val = log10(arg); dval = (1.0/arg/log(10)); #define _exp(val,arg) val = exp(arg); #define _d_exp(val,dval,arg) val = exp(arg); dval = val; #define _sqrt(val,arg) val = sqrt(arg); #define _d_sqrt(val,dval,arg) val = sqrt(arg); dval = (1.0/val/2.0); #define _pow(xy,x,y) xy = pow(x,y); #define _dx_pow(dx,xy,x,y) dx = (x==0.0)?0.0:((y/x)*xy); #define _dy_pow(dy,xy,x,y) dy = (x==0.0)?0.0:((log(x)/exp(0.0))*xy); #define _limexp(val,arg) _exp(val,arg) #define _d_limexp(val,dval,arg) _d_exp(val,dval,arg) #define _fabs(val,arg) val = fabs(arg); #define _d_fabs(val,dval,arg) val = fabs(arg); dval = (((val)>=0)?(+1.0):(-1.0)); #define _abs(val) ((val)<(0) ? (-(val)):(val)) #if defined(_DYNAMIC)\n int %s;\n double %s=0.0/0.0;\n char* %s;\n #endif /*_DYNAMIC*/\n %s ADMS-release-2.3.7/admsXml/constants.vams000066400000000000000000000034311371671745500202170ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2016 Guilherme Brondani Torri 2016 Felix Salfelder 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 . */ `ifdef CONSTANTS_VAMS `else `define CONSTANTS_VAMS 1 /* Mathematical constants */ `define M_PI 3.14159265358979323846 `define M_SQRT2 1.41421356237309504880 /* Physical constants */ // P_EPS0 -> electric constant, vacuum permittivity (F m^−1) `define P_EPS0 8.854187817e-12 // P_K -> Bolzman constant (J K^-1) `define P_K 1.3806503e-23 // P_Q -> elementary electron charge (C) `define P_Q 1.6021766208e-19 // P_CELCIUS0 -> zero Celsius in Kelvin `define P_CELSIUS0 273.15 // from the wiki. bastien said that these are listed in the standard `define M_E 2.71828182845904523536 `define M_LOG2E 1.44269504088896340737 `define M_LOG10E .43429448190325182765 `define M_LN2 .69314718055994530941 `define M_LN10 2.30258509299404568401 `define P_C 299792458 // m / s `define P_H 6.62607004081e-34 //planck constant. in \text{ J⋅s} `define P_U0 1.2566370614e-6 // v. perm. H / m or T·m / A or Wb / (A·m) or V·s / (A·m) `endif // CONSTANTS_VAMS ADMS-release-2.3.7/admsXml/disciplines.vams000066400000000000000000000034171371671745500205150ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2016 Guilherme Brondani Torri 2016 Felix Salfelder 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 . */ `ifdef DISCIPLINES_VAMS `else `define DISCIPLINES_VAMS 1 // Electrical current nature current access = I; units = "A"; abstol = 0.001234; endnature // Electrical potential nature voltage access = V; units = "V"; abstol = 0.0004321; endnature // Power nature power access = Pwr; units = "W"; abstol = 0.00101010; endnature // Magnetic flux nature flux access = Phi; units = "We"; endnature // how hot it is. nature temperature access = Temp; units = "K"; abstol = 3.14; endnature // required for heat energy exchange. discipline thermal potential temperature; flow power; enddiscipline // Electrical discipline discipline electrical potential voltage; flow current; enddiscipline discipline magnetic potential voltage; // FIXME flow current; // FIXME enddiscipline discipline rotational_omega potential voltage; // FIXME flow current; // FIXME enddiscipline `endif // DISCIPLINES_VAMS ADMS-release-2.3.7/admsXml/dummy.va000066400000000000000000000010751371671745500170000ustar00rootroot00000000000000// DUMMY EXAMPLE // // example and test verilog file for use with adms // `include"discipline.h" module dummy(p,q); inout p,q; // external nodes (* desc="+ node"*) electrical p; (* desc="- node"*) electrical q; // Branch definitions branch (q ,q) pq; // branch from p to q // Parameter definitions (* desc="resistance value" unit="Ohm" *) parameter real R = 1.0; // Variable definitions (* desc="clamped conductance value" unit="1/Ohm" *) real g; analog begin begin g = (R>0.1) ? 1.0/R : 10.0; I(p,q) <+ g*V(p,q); end end endmodule ADMS-release-2.3.7/admsXml/dummy.xml000066400000000000000000000072171371671745500171760ustar00rootroot00000000000000 %(value)%(scalingunit) -%(datatypename)-not-done-yet-- ADMS-release-2.3.7/admsXml/mkctext.pl000066400000000000000000000056061371671745500173350ustar00rootroot00000000000000#!/bin/perl -w # # This file is part of adms - http://sourceforge.net/projects/mot-adms. # # adms is a code generator for the Verilog-AMS language. # # Copyright (C) 2002-2012 Laurent Lemaitre # 2013-2014 Guilherme Brondani Torri # 2013-12-10 Richard Crozier # # 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 . # # # mktext.pl # # perl helper script for adms build system # # takes two argments, a file name and a path intended to # be the top level source directory path for adms. # # It creates a small C file, which copies the input file into a C # character array. The name of the C file is generated from the # input file name e.g. # # > echo "Some text" > infile.txt # # > mktext.pl infile.txt /my/top/level/source/directory # svn version: Unversioned directory # created: infile.txt.c # # > cat infile.txt.c # /* File automatically created by mkctext.pl*/ # # const char * infile_txt = "" # "Some text\n" # ; # # if the directory containing the file is under subversion # version control, the text SVN_VERSION in the file is replaced # with the version number reported by svnversion # my $filename=shift; my $top_srcdir=shift; $top_srcdir=".." if not defined $top_srcdir; #git # cygpath is a Cygwin utility to convert Unix and Windows format paths my$cygpath_top_srcdir=$top_srcdir; if($cygpath_top_srcdir=`cygpath -ad $top_srcdir 2>/dev/null`) { chomp $cygpath_top_srcdir; $cygpath_top_srcdir="\"$cygpath_top_srcdir\""; } my$GIT; $GIT=`git log --pretty=format:'%h' -n 1u` or $GIT="unknown"; #print "git version: $GIT\n"; sub text2ccode { my$fileFullName = shift; $fileFullName =~ m/\/?([^\/]+)$/; my$fileName = $1; my$OutputCfile = "$fileName.c"; my$cName = $fileName; $cName =~ s/\./_/g; open IF, "<${fileFullName}"; open OCF, ">${OutputCfile}"; printf(OCF "/* File automatically created by " . __FILE__ . "*/\n"); printf(OCF "\n"); printf(OCF "const char * %s = \"\"\n",${cName}); while() { my $line=$_; $line=~s/\r?$//; $line=~s/\n$//; $line=~s/\\/\\\\/g; $line=~s/"/\\"/g; $line=~s/\@GIT_VERSION=[^@]*\@/\@GIT_VERSION=$GIT\@/g; printf(OCF "\"%s\\n\"\n", $line); } printf(OCF ";\n"); close IF; close OCF; print "created: ${OutputCfile}\n"; } &text2ccode($filename); ADMS-release-2.3.7/admsXml/mkelements.pl000066400000000000000000004751231371671745500200270ustar00rootroot00000000000000#!perl -W # # This file is part of adms - http://sourceforge.net/projects/mot-adms. # # adms is a code generator for the Verilog-AMS language. # # Copyright (C) 2002-2012 Laurent Lemaitre # 2013-2015 Guilherme Brondani Torri # 2015 Felix Salfelder # 2014-12-06 Francesco Lannutti # 2013 Bastien ROUCARIÈS # 2012-2013 Ryan Fox # # 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 . use warnings; use XML::LibXML; my $top_srcdir=shift @ARGV; $top_srcdir=".." if not defined $top_srcdir; sub checkargument { my$arg1=shift; if(not defined $arg1) { my($package1,$filename1,$line1,$subroutine1,$hasargs1,$wantarray1,$evaltext1,$is_require1,$hints1,$bitmask1)=caller(1); die "$subroutine1:$line1: failed"; } } my$admsxml=XML::LibXML->new->parse_file("$top_srcdir/adms.xml")->getDocumentElement; map{eval("sub x$_ {\&checkargument(\@_); shift->getAttribute(\"$_\");}");} qw(name path datatypefamily datatypename default info element attribute format); my$admstpathxml=XML::LibXML->new->parse_file("$top_srcdir/admstpath.xml")->getDocumentElement; map{eval("sub x$_ {\&checkargument(\@_); shift->getAttribute(\"$_\");}");} qw(id label value ret linkto eparent regexp); my$admstxml=XML::LibXML->new->parse_file("$top_srcdir/admst.xml")->getDocumentElement; map{eval("sub x$_ {\&checkargument(\@_); shift->getAttribute(\"$_\");}");} qw(haschild type); my$BUILDER="\n/* ------- code automatically created by $0 -------------- */\n\n"; # build accessors for attribute sub eparent { my$element=shift; return $element->parentNode if($element->parentNode->nodeName eq "element"); } sub xsize { my$node=shift; return "list" if($node->nodeName eq "list"); return "scalar"; } sub uid {my$e=shift;return if not $e;return $e->findnodes("uid/scalar|uid/list");} sub attr {my$e=shift;return if not $e;return $e->findnodes("(uid/scalar)|(uid/list)|scalar|list");} #svn my$cygpath_top_srcdir=$top_srcdir; if($cygpath_top_srcdir=`cygpath -ad $top_srcdir 2>/dev/null`) { chomp $cygpath_top_srcdir; $cygpath_top_srcdir="\"$cygpath_top_srcdir\""; } my$GIT; $GIT=`git log --pretty=format:'%h' -n 1` or $GIT="unknown"; print "git version: $GIT\n"; #parse adms.xml my $EA; my $EH; foreach($admsxml->findnodes("//element")) { my$e=$_; push @$EA,$_; $EH->{&xname($_)}=$_; } #c-type sub ctype { my$xdatatypename=&xdatatypename($_); if(0) {} elsif($xdatatypename eq "basicenumeration") {return "admse"} elsif($xdatatypename eq "basicinteger") {return "int"} elsif($xdatatypename eq "basicreal") {return "double"} elsif($xdatatypename eq "basicstring") {return "const char*"} elsif($xdatatypename eq "basickstring") {return "const char*"} elsif($xdatatypename eq "basicfunction") {return "void*"} elsif($xdatatypename eq "basiclist") {return "p_slist"} else{return "p_$xdatatypename"} } sub ccontainer { my$attribute=shift; return (&xsize($attribute) eq "list")?"p_slist":ctype($attribute); } sub hdece { return &uid($_)?(join",",map{&ccontainer($_)." my".&xname($_)}&uid($_)):"void"; } sub hdec { return &uid($EH->{xdatatypename($_)})?(join",",map{&ctype($_)." my".&xname($_)}&uid($EH->{xdatatypename($_)})):"void"; } my$adms_h; $adms_h.=$BUILDER; $adms_h.="#ifndef adms_h\n"; $adms_h.="#define adms_h\n"; $adms_h.="\n"; $adms_h.="#define GIT \"$GIT\" /* git release version */\n"; $adms_h.=q@ /*headers -- depend on compiler, OS, ...*/ # if defined(_MSC_VER) # define PACKAGE_NAME "adms" # if ! defined(PACKAGE_VERSION) # pragma message(__FILE__ ": warning: #warning undefined macro 'PACKAGE_VERSION' - defaulted to 'unknown'") # define PACKAGE_VERSION "unknown" # endif # define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION # define PACKAGE_TARNAME PACKAGE_NAME # define PACKAGE_BUGREPORT "r29173\@users.sourceforge.net" # include # define isnan _isnan # define ADMS_PATH_SEPARATOR "\\\\" # define ADMS_F_OK 0 # ifndef inline # define inline # endif # define HAVE_FLOAT_H 1 # define HAVE_STDLIB_H 1 # define HAVE_PUTENV 1 # define HAVE_LOCALE 1 # define HAVE_STRING_H 1 # define HAVE_SYS_STAT_H 1 # include # else # include # define ADMS_PATH_SEPARATOR "/" # include # define ADMS_F_OK F_OK # endif # include # if defined(HAVE_SYS_STAT_H) # include # endif # if defined(HAVE_LOCALE_H) # include # endif # if defined(HAVE_FLOAT_H) # include # endif # if defined(HAVE_UNISTD_H) # include # endif # if defined(HAVE_STDLIB_H) # include # endif # if defined(HAVE_STRING_H) # include # endif # include # include # include # include # include # include # include /* in case not Posix */ # if defined(_S_IFDIR) # define ADMS_S_IFDIR _S_IFDIR # else # define ADMS_S_IFDIR S_IFDIR # endif /* check OS */ # if defined(__CYGWIN__) # define ADMS_OS_MS # define ADMS_OS_MSCYGWIN # define ADMS_OS "MSCYGWIN" # elif defined(__MSDOS__) # define ADMS_OS_MS # define ADMS_OS_MSDOS # define ADMS_OS "MSDOS" # elif defined(_WIN64) # define ADMS_OS_MS # define ADMS_OS_MSWIN64 # define ADMS_OS "MSWIN64" # elif defined(_WIN32) # define ADMS_OS_MS # define ADMS_OS_MSWIN32 # define ADMS_OS "MSWIN32" # elif defined(__APPLE__) # define ADMS_OS_DARWIN # define ADMS_OS "DARWIN" # elif defined(__linux) # define ADMS_OS_LINUX # define ADMS_OS "LINUX" # else # define ADMS_OS_UNKNOWN # define ADMS_OS "UNKNOWN" # endif /* check compiler */ # if defined(__MINGW32__) # ifndef WIN32 # define WIN32 # endif # define ADMS_COMPILER_MINGW32 # define ADMS_COMPILER "MINGW32" # elif defined(__CYGWIN__) # ifndef WIN32 # define WIN32 # endif # define ADMS_COMPILER_GCC # define ADMS_COMPILER "GCC" # elif defined(_MSC_VER) # ifndef WIN32 # define WIN32 # endif # define ADMS_COMPILER_MSVC # define ADMS_COMPILER "MSVC" # elif defined(__APPLE__) # if defined(__clang__) # define ADMS_COMPILER_CLANG # define ADMS_COMPILER "CLANG" # elif defined(__GNUC__) # define ADMS_COMPILER_GCC # define ADMS_COMPILER "GCC" # endif # elif defined(__linux) # if defined(__GNUC__) # define ADMS_COMPILER_GCC # define ADMS_COMPILER "GCC" # endif # else # define ADMS_COMPILER_CC # define ADMS_COMPILER "CC" # endif @; #c macros $adms_h.="#define E\\\n"; map{$adms_h.=" EE(".xname($_).")\\\n";} @$EA; $adms_h.="/*fin*/\n\n"; $adms_h.="#define A\\\n"; map{my$e=xname($_);map{$adms_h.=" AA(".xname($_).")\\\n";} &attr($_);} @$EA; $adms_h.="/*fin*/\n\n"; my%ALIAS; foreach(@$EA) { my$e=&xname($_); foreach($_->findnodes("alias")) { push @{$ALIAS{&xname($_)}},[$e,&xelement($_)]; } } my%ALIASBIS; foreach(@$EA) { my$e=&xname($_); foreach($_->findnodes("aliasbis")) { push @{$ALIASBIS{&xname($_)}},[$e,&xpath($_)]; } } #va elements my@VA; map{push @VA,xname($_) if vla(xname($_));} @$EA; #math elements my@MATHELEMENTS; foreach($admsxml->findnodes("//element[\@name='math']//element")) { push @MATHELEMENTS,[xname($_),"math"]; } #elements + attributes $adms_h.="#define EA\\\n"; map{my$e=xname($_);map{$adms_h.=" EEA(".$e.",".xname($_).")\\\n";} &attr($_);} @$EA; $adms_h.="/*fin*/\n\n"; $adms_h.="#define TK\\\n"; #add tokens for pparse #look for //[@name=pparse]/scalar/attribute[@name=tkid] my@token; #element map{push @token,xname($_);} @$EA; #attribute map{map{push @token,xname($_);} $_->findnodes("uid/scalar|uid/list|scalar|list");} @$EA; #enum map{map{push @token,xname($_);} $_->findnodes("uid/scalar/evalue|scalar/evalue");} @$EA; push @token,qw(past_name datatypefamily absolute basicenumeration basicinteger basicreal basicstring basiclist empty); my@tokenname; my%seentokenname; map{$adms_h.=" TTK($_)\\\n" if not defined $seentokenname{$_};$seentokenname{$_}=1;} @token; $adms_h.="/*fin*/\n\n"; #lexer my$tk; map{$tk.=" tktk_".xid($_).",\n";} $admstpathxml->findnodes("//constant"); map{map{$tk.=" tktk_".$_.",\n";}split " ", xid($_);} $admstpathxml->findnodes("//regexp"); $adms_h.=qq@ #undef TTK #define TTK(tk) admse_##tk, typedef enum { admse__zero=0, admse__any, admse__constant, admse__p, /*%p*/ admse__s, /*%s*/ admse__path, admse__arguments, admse__croix, admse__croixcroix, admse__ladms, admse__ladmst, TK admse__ } admse; @; $adms_h.="#undef win32_interface\n"; $adms_h.="#if defined(WIN32)\n"; $adms_h.="# if defined(insideElement)\n"; $adms_h.="# define win32_interface __declspec(dllexport)\n"; $adms_h.="# else\n"; $adms_h.="# define win32_interface __declspec(dllimport)\n"; $adms_h.="# endif\n"; $adms_h.="#else\n"; $adms_h.="# define win32_interface extern\n"; $adms_h.="#endif\n"; $adms_h.="\n"; $adms_h.="// preprocessor flag for static link (MinGW)\n"; $adms_h.="#ifdef staticlink\n"; $adms_h.="# undef win32_interface\n"; $adms_h.="# define win32_interface extern\n"; $adms_h.="#endif\n"; $adms_h.="\n"; foreach(@$EA) { my$ename=xname($_); $adms_h.="typedef struct s_$ename t_$ename;\n"; $adms_h.="typedef t_$ename* p_$ename;\n"; $adms_h.="typedef const p_$ename p_k$ename;\n"; } #miscH $adms_h.="\n/*miscH*/\n"; $adms_h.="typedef struct s_slist t_slist;\n"; $adms_h.="typedef t_slist* p_slist;\n"; $adms_h.="win32_interface FILE *stdadmstdbgimpl;\n"; $adms_h.="win32_interface FILE *stdadmstdbgimpl;\n"; $adms_h.="#define stdadmstdbg (stdadmstdbgimpl?stdadmstdbgimpl:stderr)\n"; $adms_h.="win32_interface int admsmain(const char*xcode,const char*xflag,const char*vacode);\n"; $adms_h.="win32_interface int adms_global_nbadmstnew(void);\n"; $adms_h.="win32_interface int adms_global_nbadmstdestroy(void);\n"; $adms_h.="win32_interface void adms_global_increment_nbadmstnew(void);\n"; $adms_h.="win32_interface void adms_global_increment_nbadmstdestroy(void);\n"; $adms_h.="/*-- admst/new prototypes --*/\n"; foreach (qw[bd be bi br bs ns ks pa pn pc pd la ln pp]) { my$cast=$_ eq"bd"?"const admse": $_ eq"be"?"const admse": $_ eq"bi"?"const int": $_ eq"br"?"const double": $_ eq"bs"?"char*": $_ eq"ns"?"char*": $_ eq"ks"?"char*": $_ eq"pd"?"p_admstvariable": $_ eq"pn"?"p_admst": $_ eq"pc"?"p_attribute": $_ eq"la"?"p_slist": $_ eq"ln"?"p_slist": $_ eq"pp"?"admse": "const p_adms"; my$inputs0=$_ eq"ks"?"$cast item": "p_admst myprevious,p_admst mypreviouspath,$cast item"; $adms_h.="win32_interface p_admst adms_admst_new$_ ($inputs0);\n"; } $adms_h.="\n/*-- Miscellaneous routines --*/\n"; $adms_h.=q@ win32_interface const double adms_dzero; win32_interface double adms_NAN; win32_interface p_admst aread (p_admst myadmst); win32_interface void deref(p_admst mystack); union admsu { int i; double r; char* s; p_adms p; }; win32_interface const int minusone; win32_interface int adms_strtol (p_ktransform mytransform,const char* mynumber); win32_interface double adms_strtod (p_ktransform mytransform,const char* myreal); win32_interface void bp(void); win32_interface char*adms_integertostring(int value); win32_interface char*adms_doubletostring(double value); win32_interface int adms_setenv(const char* myname,const char* myvalue); win32_interface int adms_file_isregular(const char* myfilename); win32_interface int adms_file_isdirectory(const char* myfilename); win32_interface p_slist adms_slist_new (p_adms d); win32_interface p_slist adms_slist_copy (p_slist l); win32_interface void adms_slist_concat (p_slist* l1,p_slist l2); win32_interface p_slist adms_slist_find (p_slist l,p_kadms data); win32_interface void adms_slist_free (p_slist l); win32_interface int adms_slist_index (p_slist l, p_kadms data); win32_interface p_slist adms_slist_last (p_slist l); win32_interface unsigned int adms_slist_length (p_slist l); win32_interface p_slist adms_slist_nth (p_slist l,unsigned int n); win32_interface p_adms adms_slist_nth_data (p_slist l,unsigned int n); win32_interface void adms_slist_print(const char* message,p_slist l); win32_interface p_adms adms_slist_pull(p_slist* l); win32_interface void adms_slist_push(p_slist* l,p_adms data); win32_interface p_slist adms_slist_reverse (p_slist l); win32_interface void adms_slist_inreverse (p_slist* l); struct s_slist { p_adms data; p_slist next; }; @; $adms_h.=q[ win32_interface p_admsmain root(void); win32_interface void rootnew(p_admsmain myglobaladmsmain); typedef p_admst (t_new) (p_ktransform mytransform,p_admst dot,p_slist arguments[],const int size); typedef p_admst (*p_new) (p_ktransform mytransform,p_admst dot,p_slist arguments[],const int size); #define _t_new(function) p_admst (function) (p_ktransform mytransform,p_admst dot,p_slist arguments[],const int size) typedef int (t_cmp) (p_adms myadms, p_adms myadmsref); typedef int (*p_cmp) (p_adms myadms, p_adms myadmsref); #define _t_cmp(function) int (function) (p_adms myadms, p_adms myadmsref) /*-- Messaging --*/ typedef void (t_message) (const char*format, ...); typedef void (*p_message) (const char*format, ...); #define _t_message(function) void (function) (const char*format, ...) win32_interface void adms_toupper(char*m); win32_interface void adms_tolower(char*m); win32_interface char*adms_kclone(const char* m); win32_interface char*adms_knclone(const char* m,const int l); win32_interface char*adms_m2nclone(const char* m,const char* n); win32_interface void adms_strconcat(char **s1,char *s2); win32_interface void adms_k2strconcat(char **s1,const char* s2); win32_interface FILE *adms_file_open_read (const char* fileName); ]; my@message=( ["info","stdout",0], ["usage","stdout",0], ["verbose","stdout",0], ["debug","stdout",0], ["dbg_vla","stdout",0], ["dbg_xml","stdout",0], ["dbg_mem","stdout",0], ["hint","stderr",0], ["warning","stderr",0], ["obsolete","stderr",0], ["error","stderr",2], ["fatal","stderr",1], ["admstdbg","stdadmstdbg",-1] ); foreach my$mess(@message) { my$name=$mess->[0]; $adms_h.="win32_interface t_message adms_message_${name}_impl;\n"; $adms_h.="win32_interface t_message adms_message_${name}_continue_impl;\n"; $adms_h.="#define adms_message_$name(VAARGS)\\\n"; $adms_h.="{\\\n"; $adms_h.=" if((root())\\\n"; $adms_h.=" &&(root()->_$name==admse_yes))\\\n"; $adms_h.=" adms_message_${name}_impl VAARGS;\\\n"; $adms_h.="}\n"; $adms_h.="#define adms_message_${name}_continue(VAARGS)\\\n"; $adms_h.="{\\\n"; $adms_h.=" if((root())\\\n"; $adms_h.=" &&(root()->_$name==admse_yes))\\\n"; $adms_h.=" adms_message_${name}_continue_impl VAARGS;\\\n"; $adms_h.="}\n"; } $adms_h.="\n"; $adms_h.="win32_interface char* aprintf (p_ktransform mytransform,p_kadmst myadmst);\n"; sub vla {my$e=shift; return !(($e eq "return")||($e eq "adms")||($e eq "yaccval")||($e eq "admst")||($e eq "transform") ||($e eq "itransform")||($e eq "admstvariable")||($e eq "pparse")||($e eq "ptraverse")||($e eq "text")||($e eq "path"));} foreach(@$EA) { my$element=$_; my$ename=$element->getAttribute("name"); $adms_h.="\n/* ------- $ename -------------- */\n"; my$parent=&eparent($element); $adms_h.="#define adms_$ename(member) ((p_$ename)(member))\n"; #mkstruct $adms_h.="struct s_$ename {\n"; if($parent) { my$parentName=$parent->getAttribute ("name"); $adms_h.=" t_$parentName _$parentName;\n"; } foreach(&attr($element)) { my$xname=&xname($_); if(($ename eq "admst")&&($xname eq "item")) { $adms_h.=" union admsu _item;\n"; } elsif(($xname eq "datatypename")||($xname eq "pseudo")) { $adms_h.=" admse _${xname};\n"; } else { my$ctype=ccontainer($_); $ctype=~s/const // if(&xdatatypename($_) eq "basicstring"); $adms_h.=" $ctype _$xname;\n"; $adms_h.=" int _${xname}_isdefault : 2;\n" if vla($ename); } } $adms_h.="};\n"; #uid $adms_h.="win32_interface char*adms_${ename}_uid (p_$ename my$ename);\n"; if($ename ne "adms") { $adms_h.="win32_interface p_$ename adms_${ename}_new (".&hdece($_).");\n"; $adms_h.="win32_interface void adms_${ename}_free(p_$ename my$ename);\n"; } foreach(&attr($element)) { #valueto my$xname=&xname($_); my$xdatatypename=&xdatatypename($_); $adms_h.="win32_interface void adms_${ename}_valueto_$xname (p_$ename my$ename,".ccontainer($_)." _${xname});\n"; next if xsize($_) eq "scalar"; #prepend if(($ename eq "module")&&($xname =~ "branch|node|probe|source")) { $adms_h.="win32_interface ".ctype($_)." adms_${ename}_list_${xname}_prepend_by_id_once_or_ignore (p_$ename mymy${ename},".&hdec($_).");\n"; } if( (($ename =~ "admsmain")&&($xname =~ "module|nature")) || (($ename =~ "module")&&($xname =~ "branchalias|instance|node|nodealias|range")) ) { $adms_h.="win32_interface ".ctype($_)." adms_${ename}_list_${xname}_prepend_by_id_once_or_abort (p_$ename mymy${ename},".&hdec($_).");\n"; } if( (($ename =~ "admsmain")&&($xname =~ "discipline")) || (($ename =~ "analogfunction|block|module")&&($xname =~ "variable")) || (($ename =~ "instance")&&($xname =~ "parameterset|terminal")) || (($ename =~ "module")&&($xname =~ "analogfunction")) || (($ename =~ "variable")&&($xname =~ "alias")) ) { $adms_h.="win32_interface void adms_${ename}_list_${xname}_prepend_once_or_abort (p_$ename mymy${ename},".ctype($_)." my${xname});\n"; } next if $xdatatypename eq "adms"; my@cmp; foreach(&uid($EH->{$xdatatypename})) { my$cur="ref$xdatatypename->_".&xname($_); my$ref="my".&xname($_); if(xdatatypename($_) eq "basicstring") { push @cmp,"!strcmp($cur,$ref)"; } elsif(&xdatatypename($_) eq "lexval") { push @cmp,"!strcmp($cur->_string,$ref->_string)"; } elsif(&xdatatypename($_) eq "quark") { push @cmp,"!strcmp($cur->_value,$ref->_value)"; } else { push @cmp,"($cur==$ref)"; } } #lookup if( (($ename =~ "admsmain")&&($xname =~ "discipline")) || (($ename =~ "admsmain")&&($xname =~ "module")) || (($ename =~ "admsmain")&&($xname =~ "nature")) || (($ename =~ "analogfunction")&&($xname =~ "variable")) || (($ename =~ "module")&&($xname =~ "branchalias")) || (($ename =~ "module")&&($xname =~ "node")) || (($ename =~ "module")&&($xname =~ "variable")) ) { $adms_h.="win32_interface ".ctype($_)." adms_${ename}_list_${xname}_lookup_by_id (p_$ename mymy$ename,".&hdec($_).");\n"; } } } $adms_h.=" win32_interface admse ns_strtoe (const char* tk); win32_interface char* ns_etostr (admse e); win32_interface p_new adms_admsxml_new (p_ktransform mytransform,const char* ename); win32_interface p_cmp adms_admsxml_cmp (p_kadmst myadmst); #endif /* adms_h */\n"; open FILE,">adms.h"; print FILE $adms_h; close FILE; print "adms.h: created\n"; sub pnew { my$leaf=shift; my$leafpath=shift; my$element=shift; my$parent=shift; my$pname=$parent->getAttribute("name"); my$pelement=$EH->{$pname}; my$supersuperElement=&eparent($pelement); my$code; if($supersuperElement) { $code.=&pnew($leaf,"${leafpath}_$pname.",$pelement,$supersuperElement); } foreach(&attr($pelement)) { my$xname=&xname($_); my$xdatatypename=&xdatatypename($_); my$xdefault=&xdefault($_); next if not $xdefault; if($xdefault=~/^@/) { $xdefault=~s/@//; $code=" ${leafpath}_$pname._$xname=admse_".$leaf->getAttribute($xdefault).";\n"; } elsif($xdatatypename eq "basicreal") { $code.=" ${leafpath}_$pname._$xname=$xdefault;\n"; } elsif($xdatatypename eq "basicenumeration") { $code.=" ${leafpath}_$pname._$xname=admse_$xdefault;\n"; } else {die;} } return $code; } sub mkfree () { my$element=$_; my$ename=$element->getAttribute("name"); my$code; $code.="void adms_${ename}_free (p_$ename my$ename)\n"; $code.="{\n"; $code.=" if(!my$ename)\n"; $code.=" return;\n"; my$parent; foreach(&attr($element)) { if(xsize($_) eq "list" && $ename ne "admst") { $code.=" adms_slist_free(my$ename->_".&xname($_).");\n"; } elsif(xdatatypename($_) eq "basicstring") { $code.=" free(my$ename->_".xname($_).");\n"; } } $code.=" adms_global_increment_nbadmstdestroy();\n" if $ename eq "admst"; $code.=" free(my$ename);\n"; $code.="}\n"; return $code; } sub mkuid () { my$element=$_; my$ename=$element->getAttribute("name"); my$code; my$format=$element->findnodes("uid")->get_node(0)->getAttribute ("format"); $code.="char*adms_${ename}_uid (p_$ename mynew$ename)\n"; $code.="{\n"; $code.=" char*myuid=NULL;\n"; my@Attr=&attr($element); $code.=" adms_k2strconcat(&myuid,\"\");\n" if not $format; while($format=~s/^([^\$]*)\$(\d)//) { $code.=" adms_k2strconcat(&myuid,\"$1\");\n" if $1; my$attr=$Attr[$2-1]; die "$ename: $format" if not defined $attr; my$xname=&xname($attr); my$xfamily=&xdatatypefamily($attr); my$xdatatypename=&xdatatypename($attr); my$xsize=&xsize($attr); my$xformat=&xformat($attr); if($xsize eq "list") { my$subformat=$xformat; $code.=" {\n"; $code.=" p_slist list=mynew$ename->_$xname;\n"; $code.=" while(list)\n"; $code.=" {\n"; $code.=" adms_strconcat(&myuid,adms_admsxml_uid(list->data));\n"; $code.=" if(list->next) adms_k2strconcat(&myuid,\"$subformat\");\n"; $code.=" list=list->next;\n"; $code.=" }\n"; $code.=" }\n"; } elsif(defined($xformat)) { $code.=" if(mynew$ename->_$xname)\n"; $code.=" {\n"; while($xformat=~s/([^\$]*)\$(\d+)//) { my$v=&xname($Attr[$2-1]); $code.=" adms_k2strconcat(&myuid,\"$1\");\n"; $code.=" adms_strconcat(&myuid,adms_admsxml_uid(mynew$ename->_$v));\n"; } $code.=" adms_k2strconcat(&myuid,\"$xformat\");\n" if $xformat; $code.=" }\n"; } elsif($xdatatypename eq "basicenumeration") { foreach(@{$attr->findnodes("evalue")}) { my$enode=$_; $code.=" if(mynew$ename->_$xname==admse_".&xname($enode).")\n"; $code.=" {\n"; my$enuminfo=&xinfo($enode); while($enuminfo=~s/([^\$]*)\$(\d+)//) { my$v=&xname($Attr[$2-1]); $code.=" adms_k2strconcat(&myuid,\"$1\");\n"; $code.=" adms_strconcat(&myuid,adms_admsxml_uid(mynew$ename->_$v));\n"; } $code.=" adms_k2strconcat(&myuid,\"$enuminfo\");\n" if $enuminfo; $code.=" }\n"; } } elsif(($xdatatypename eq "basicinteger")&&($xname eq "pseudo")) { $code.=" adms_strconcat(&myuid,ns_etostr(mynew$ename->_$xname));\n"; } elsif($xdatatypename eq "basicinteger") { $code.=" adms_strconcat(&myuid,adms_integertostring(mynew$ename->_$xname));\n"; } elsif($xdatatypename eq "basicreal") { $code.=" adms_strconcat(&myuid,adms_doubletostring(mynew$ename->_$xname));\n"; } elsif($xdatatypename eq "basicstring") { $code.=" adms_k2strconcat(&myuid,mynew$ename->_$xname);\n"; } elsif($xdatatypename eq "adms") { $code.=" adms_strconcat(&myuid,adms_admsxml_uid(mynew$ename->_$xname));\n"; } elsif($xfamily eq "reference") { $code.=" adms_strconcat(&myuid,adms_${xdatatypename}_uid(mynew$ename->_$xname));\n"; } } $code.=" adms_k2strconcat(&myuid,\"$format\");\n" if $format; $code.=" return myuid;\n"; $code.="}\n"; return $code; } my$adms_c; $adms_c.=$BUILDER; $adms_c.="#include \"adms.h\"\n"; $adms_c.="const double adms_dzero=0.0;\n"; $adms_c.="double adms_NAN;\n"; #enumeration to string $adms_c.="FILE *stdadmstdbgimpl=NULL;\n"; $adms_c.="#undef TTK\n"; $adms_c.="#define TTK(tk) if(e==admse_##tk) return #tk;\n"; $adms_c.="char* ns_etostr (admse e)\n"; $adms_c.="{\n"; $adms_c.=" TK\n"; $adms_c.=" if(e==admse__zero) return \"_zero\";\n"; $adms_c.=" if(e==admse__any) return \"_any\";\n"; $adms_c.=" if(e==admse__constant) return \"_constant\";\n"; $adms_c.=" if(e==admse__p) return \"_p\";\n"; $adms_c.=" if(e==admse__s) return \"_s\";\n"; $adms_c.=" if(e==admse__path) return \"_path\";\n"; $adms_c.=" if(e==admse__arguments) return \"_arguments\";\n"; $adms_c.=" if(e==admse__croix) return \"_croix\";\n"; $adms_c.=" if(e==admse__croixcroix) return \"_croixcroix\";\n"; $adms_c.=" if(e==admse__ladms) return \"_ladms\";\n"; $adms_c.=" if(e==admse__ladmst) return \"_ladmst\";\n"; $adms_c.=" return NULL;\n"; $adms_c.="}\n"; #string to enumeration $adms_c.="#undef TTK\n"; $adms_c.="#define TTK(tk) if(!strcmp(mytk,#tk)) return admse_##tk;\n"; $adms_c.="admse ns_strtoe (const char* mytk)\n"; $adms_c.="{\n"; $adms_c.=" TK\n"; $adms_c.=" return admse__any;\n"; $adms_c.="}\n"; $adms_c.="static char* adms_admsxml_uid (p_kadms myitem)\n"; $adms_c.="{\n"; $adms_c.=" if(!myitem)\n"; $adms_c.=" return adms_kclone(\"\");\n"; foreach(@$EA) { my$ename=xname($_); next if $ename eq "adms"; $adms_c.=" if(myitem->_datatypename==admse_$ename)\n"; $adms_c.=" return adms_${ename}_uid((p_$ename)myitem);\n"; } $adms_c.=" adms_message_fatal_continue((\"%s:%i: internal error - should not be reached\\n\",__FILE__,__LINE__))\n"; $adms_c.=" adms_message_fatal((\"%s:%i: please report to r29173\@users.sourceforge.net\\n\",__FILE__,__LINE__))\n"; $adms_c.=" return NULL;\n"; $adms_c.="}\n"; $adms_c.="char* aprintf (p_ktransform mytransform,p_kadmst myadmst)\n"; $adms_c.="{\n"; $adms_c.=" if(myadmst->_pseudo==admse__ladms)\n"; $adms_c.=" {\n"; $adms_c.=" adms_message_fatal_continue((\"list not supported\\n\"))\n"; $adms_c.=" adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform)))\n"; $adms_c.=" }\n"; $adms_c.=" if(myadmst->_pseudo==admse_empty)\n"; $adms_c.=" return adms_kclone(\"\");\n"; $adms_c.=" if(myadmst->_pseudo==admse_datatypename)\n"; $adms_c.=" return adms_kclone(ns_etostr((admse)myadmst->_item.i));\n"; $adms_c.=" if(myadmst->_pseudo==admse_basicenumeration)\n"; $adms_c.=" return adms_kclone(ns_etostr((admse)myadmst->_item.i));\n"; $adms_c.=" if(myadmst->_pseudo==admse_basicinteger)\n"; $adms_c.=" return adms_integertostring(myadmst->_item.i);\n"; $adms_c.=" if(myadmst->_pseudo==admse_basicreal)\n"; $adms_c.=" return adms_doubletostring(myadmst->_item.r);\n"; $adms_c.=" if(myadmst->_pseudo==admse_basicstring)\n"; $adms_c.=" return adms_kclone((char*)myadmst->_item.s);\n"; $adms_c.=" if(myadmst->_pseudo==admse__croix)\n"; $adms_c.=" {\n"; $adms_c.=" if(((p_attribute)myadmst->_item.p)->_value)\n"; $adms_c.=" return aprintf(mytransform,(p_admst)((p_attribute)myadmst->_item.p)->_value);\n"; $adms_c.=" else\n"; $adms_c.=" return adms_kclone(\"\");\n"; $adms_c.=" }\n"; foreach(@$EA) { my$ename=xname($_); next if $ename eq "adms"; $adms_c.=" if(myadmst->_pseudo==admse_$ename)\n"; $adms_c.=" return adms_${ename}_uid((p_$ename)myadmst->_item.p);\n"; } $adms_c.=" adms_message_fatal_continue((\"%s:%i: internal error - should not be reached\\n\",__FILE__,__LINE__))\n"; $adms_c.=" adms_message_fatal_continue((\"%s:%i: please report to r29173\@users.sourceforge.net\\n\",__FILE__,__LINE__))\n"; $adms_c.=" adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform)))\n"; $adms_c.=" return NULL;\n"; $adms_c.="}\n"; $adms_c.=q@ const int minusone=-1; void deref (p_admst myadmst) { myadmst->_refd--; if(myadmst->_refd) return; if(myadmst->_original) { if(myadmst->_hasnewbasicstring==1) { myadmst->_original->_refd--; if(myadmst->_original->_refd==0) { free(myadmst->_original->_item.s); adms_admst_free(myadmst->_original); } } else if(myadmst->_hasnewbasicstring==2) { myadmst->_original->_refd--; if(myadmst->_original->_refd==0) { adms_return_free((p_return)myadmst->_original->_item.p); adms_admst_free(myadmst->_original); } else adms_message_fatal(("internal error")) } } if(myadmst->_hasnewbasicstring==1) free(myadmst->_item.s); else if(myadmst->_hasnewbasicstring==2) adms_return_free((p_return)myadmst->_item.p); adms_admst_free(myadmst); } #define p_basicstring char* #define adms_basicstring_uid(e) ((char*)e) static p_admst adms_basicenumeration_xnew (p_ktransform mytransform,p_admst dot,p_slist myinputs[],const int size) { if(size!=1) { adms_message_fatal_continue(("admst:new(basicenumeration) bad number of inputs (found %i, expected 1)\n",size)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else if(adms_slist_length(myinputs[0])!=1) { adms_message_fatal_continue(("admst:new(basicenumeration) bad number of element in inputs[0] (found %i, expected 1)\n",adms_slist_length(myinputs[0]))) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else { char*s=aprintf(mytransform,(p_admst)(myinputs[0]->data)); /*xnew*/p_admst myadmst=adms_admst_newbi(dot,dot,adms_strtol(mytransform,s)); free(s); deref((p_admst)myinputs[0]->data); adms_slist_free(myinputs[0]); return myadmst; } } static p_admst adms_basicinteger_xnew (p_ktransform mytransform,p_admst dot,p_slist myinputs[],const int size) { if(size!=1) { adms_message_fatal_continue(("admst:new(basicinteger) bad number of inputs (found %i, expected 1)\n",size)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else if(adms_slist_length(myinputs[0])!=1) { adms_message_fatal_continue(("admst:new(basicinteger) bad number of element in inputs[0] (found %i, expected 1)\n",adms_slist_length(myinputs[0]))) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else { char*s=aprintf(mytransform,(p_admst)(myinputs[0]->data)); /*xnew*/p_admst myadmst=adms_admst_newbi(dot,dot,adms_strtol(mytransform,s)); free(s); deref((p_admst)myinputs[0]->data); adms_slist_free(myinputs[0]); return myadmst; } } static p_admst adms_basicreal_xnew (p_ktransform mytransform,p_admst dot,p_slist myinputs[],const int size) { if(size!=1) { adms_message_fatal_continue(("admst:new(basicreal) bad number of inputs (found %i, expected 1)\n",size)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else if(adms_slist_length(myinputs[0])!=1) { adms_message_fatal_continue(("admst:new(basicreal) bad number of element in inputs[0] (found %i, expected 1)\n",adms_slist_length(myinputs[0]))) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else { char*s=aprintf(mytransform,(p_admst)(myinputs[0]->data)); /*xnew*/p_admst myadmst=adms_admst_newbr(dot,dot,adms_strtod(mytransform,s)); free(s); deref((p_admst)myinputs[0]->data); adms_slist_free(myinputs[0]); return myadmst; } } static p_admst adms_basicstring_xnew (p_ktransform mytransform,p_admst dot,p_slist myinputs[],const int size) { if(size!=1) { adms_message_fatal_continue(("admst:new(basicstring) bad number of inputs (found %i, expected 1)\n",size)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else if(adms_slist_length(myinputs[0])!=1) { adms_message_fatal_continue(("admst:new(basicstring) bad number of element in inputs[0] (found %i, expected 1)\n",adms_slist_length(myinputs[0]))) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) return NULL; } else { char*s=aprintf(mytransform,(p_admst)(myinputs[0]->data)); /*xnew*/p_admst myadmst=adms_admst_newbs(dot,dot,s); deref((p_admst)myinputs[0]->data); adms_slist_free(myinputs[0]); return myadmst; } } static int adms_basicenumeration_cmp (const char* mybasicenumeration,const char* refbasicenumeration) { return (mybasicenumeration!=refbasicenumeration); } static int adms_basicinteger_cmp (const char* mybasicinteger,const char* refbasicinteger) { return (mybasicinteger!=refbasicinteger); } static int adms_basicreal_cmp (const char* mybasicreal,const char* refbasicreal) { return ((mybasicreal-refbasicreal)<0)||((mybasicreal-refbasicreal)>0); } static int adms_basicstring_cmp (const char* mybasicstring,const char* refbasicstring) { return (strcmp(mybasicstring,refbasicstring)); } @; foreach(@$EA) { my$ename=xname($_); next if not vla($ename); #cmp $adms_c.="static int adms_${ename}_cmp (p_$ename my$ename,p_$ename ref$ename)\n"; $adms_c.="{\n"; $adms_c.=" return\n"; $adms_c.=" (\n"; my$isfirst=" "; foreach(&uid($_)) { my$xname=&xname($_); my$xdatatypename=&xdatatypename($_); if($xdatatypename eq "basicstring") { $adms_c.="${isfirst}strcmp(my$ename->_".&xname($_).",ref$ename->_".&xname($_).")"; $isfirst="\n ||\n "; } elsif($xdatatypename eq "basicstring") { $adms_c.="${isfirst}strcmp(my$ename->_".&xname($_)."->_string,ref$ename->_".&xname($_)."->_string)"; $isfirst="\n ||\n "; } elsif($xdatatypename eq "quark") { $adms_c.="${isfirst}strcmp(my$ename->_".&xname($_)."->_value,ref$ename->_".&xname($_)."->_value)"; $isfirst="\n ||\n "; } elsif($xdatatypename eq "lexval") { $adms_c.="${isfirst}strcmp(my$ename->_".&xname($_)."->_string,ref$ename->_".&xname($_)."->_string)"; $isfirst="\n ||\n "; } else { $adms_c.="$isfirst(my$ename->_".&xname($_)." != ref$ename->_".&xname($_).")"; $isfirst="\n ||\n "; } } $adms_c.=$isfirst."1" if not &uid($_); $adms_c.="\n );\n"; $adms_c.="}\n"; } foreach(@$EA) { my$ename=xname($_); $adms_c.="\n/* ------- $ename -------------- */\n"; $adms_c.=&mkfree($_); foreach(&attr($_)) { #valueto my$xname=&xname($_); my$xdatatypename=&xdatatypename($_); $adms_c.="\nvoid adms_${ename}_valueto_$xname (p_$ename my$ename,".ccontainer($_)." _${xname})\n{\n"; #fixme: other basic? if(($xdatatypename eq "basicstring")&&(xsize($_) eq "scalar")) { $adms_c.=" my$ename->_$xname=adms_kclone(_$xname);\n"; } elsif(($ename eq "admst")&&($xname eq "item")) { $adms_c.=" /*fixme: my$ename->_$xname=_$xname;*/\n"; } else { $adms_c.=" my$ename->_$xname=_$xname;\n"; } $adms_c.=" my$ename->_${xname}_isdefault=0;\n" if vla($ename); $adms_c.="}\n"; next if xsize($_) eq "scalar"; #prepend my$cdec=join",",map{"my".&xname($_)}&uid($EH->{xdatatypename($_)}); if(($ename eq "module")&&($xname =~ "branch|node|probe|source")) { $adms_c.=ctype($_)." adms_${ename}_list_${xname}_prepend_by_id_once_or_ignore (p_$ename mymy${ename},".&hdec($_).")\n"; $adms_c.="{\n"; $adms_c.=" p_slist list=mymy$ename->_$xname;\n"; $adms_c.=" ".ctype($_)." ref${xname}=adms_${xdatatypename}_new($cdec);\n"; $adms_c.=" while(list)\n"; $adms_c.=" {\n"; $adms_c.=" if(!adms_${xdatatypename}_cmp((p_$xdatatypename)list->data,ref${xname}))\n"; $adms_c.=" {\n"; $adms_c.=" adms_${xdatatypename}_free (ref$xname);\n"; $adms_c.=" return (p_$xdatatypename)list->data;\n"; $adms_c.=" }\n"; $adms_c.=" list=list->next;\n"; $adms_c.=" }\n"; $adms_c.=" adms_slist_push(&mymy$ename->_$xname,(p_adms)ref$xname);\n"; $adms_c.=" return ref$xname;\n"; $adms_c.="}\n"; } if( (($ename =~ "admsmain")&&($xname =~ "module|nature")) || (($ename =~ "module")&&($xname =~ "branchalias|instance|node|nodealias|range")) ) { $adms_c.=ctype($_)." adms_${ename}_list_${xname}_prepend_by_id_once_or_abort (p_$ename mymy${ename},".&hdec($_).")\n"; $adms_c.="{\n"; $adms_c.=" p_slist list=mymy${ename}->_${xname};\n"; $adms_c.=" ".ctype($_)." ref${xname}=adms_${xdatatypename}_new($cdec);\n"; $adms_c.=" while(list)\n"; $adms_c.=" {\n"; $adms_c.=" if(!adms_${xdatatypename}_cmp((p_$xdatatypename)list->data,ref${xname}))\n"; $adms_c.=" {\n"; $adms_c.=" adms_message_fatal((\"${ename}=[%s] ${xname}=[%s] already defined\\n\",\n"; $adms_c.=" adms_${ename}_uid(mymy${ename}),adms_${xdatatypename}_uid(ref${xname})))\n"; $adms_c.=" adms_${xdatatypename}_free (ref${xname});\n"; $adms_c.=" }\n"; $adms_c.=" list=list->next;\n"; $adms_c.=" }\n"; $adms_c.=" adms_slist_push(&mymy${ename}->_${xname},(p_adms)ref$xname);\n"; $adms_c.=" return ref${xname};\n"; $adms_c.="}\n"; } if( (($ename =~ "admsmain")&&($xname =~ "discipline")) || (($ename =~ "analogfunction|block|module")&&($xname =~ "variable")) || (($ename =~ "instance")&&($xname =~ "parameterset|terminal")) || (($ename =~ "module")&&($xname =~ "analogfunction")) || (($ename =~ "variable")&&($xname =~ "alias")) ) { $adms_c.="void adms_${ename}_list_${xname}_prepend_once_or_abort (p_$ename mymy${ename},".ctype($_)." my${xname})\n"; $adms_c.="{\n"; $adms_c.=" p_slist list=mymy${ename}->_${xname};\n"; $adms_c.=" while(list)\n"; $adms_c.=" {\n"; $adms_c.=" if(!adms_${xdatatypename}_cmp((p_$xdatatypename)list->data,my${xname}))\n"; $adms_c.=" {\n"; $adms_c.=" adms_message_fatal((\"${ename}=[%s] ${xname}=[%s] already defined\\n\",\n"; $adms_c.=" adms_${ename}_uid(mymy${ename}),adms_${xdatatypename}_uid(my${xname})))\n"; $adms_c.=" return;\n"; $adms_c.=" }\n"; $adms_c.=" list=list->next;\n"; $adms_c.=" }\n"; $adms_c.=" adms_slist_push(&mymy${ename}->_${xname},(p_adms)my$xname);\n"; $adms_c.="}\n"; } #lookup # BUG. linear search has linear runtime. # use proper containers!!1 if( (($ename =~ "admsmain")&&($xname =~ "discipline")) || (($ename =~ "admsmain")&&($xname =~ "module")) || (($ename =~ "admsmain")&&($xname =~ "nature")) || (($ename =~ "analogfunction")&&($xname =~ "variable")) || (($ename =~ "module")&&($xname =~ "branchalias")) || (($ename =~ "module")&&($xname =~ "node")) || (($ename =~ "module")&&($xname =~ "variable")) ) { $adms_c.=ctype($_)." adms_${ename}_list_${xname}_lookup_by_id (p_$ename mymy$ename,".&hdec($_).")\n"; $adms_c.="{\n"; $adms_c.=" p_slist list=mymy$ename->_$xname;\n"; $adms_c.=" while(list) {\n"; $adms_c.=" p_$xdatatypename ref$xdatatypename=(p_$xdatatypename)list->data;\n"; $adms_c.=" if("; my@cmp; foreach(&uid($EH->{$xdatatypename})) { my$cur="ref$xdatatypename->_".&xname($_); my$ref="my".&xname($_); if(xdatatypename($_) eq "basicstring") {push @cmp,"!strcmp($cur,$ref)";} elsif(&xdatatypename($_) eq "lexval") {push @cmp,"!strcmp($cur->_string,$ref->_string)";} elsif(&xdatatypename($_) eq "quark") {push @cmp,"!strcmp($cur->_value,$ref->_value)";} elsif(&xdatatypename($_) eq "lexval") {push @cmp,"!strcmp($cur->_string,$ref->_string)";} else {push @cmp,"($cur==$ref)";} } $adms_c.=join "&&\n ",@cmp; $adms_c.=")\n"; $adms_c.=" return ref$xdatatypename;\n"; $adms_c.=" list=list->next;\n"; $adms_c.=" }\n"; $adms_c.=" return NULL;\n"; $adms_c.="}\n"; } } next if $ename eq "adms"; #new $adms_c.="p_$ename adms_${ename}_new (".&hdece($_).")\n"; $adms_c.="{\n"; $adms_c.=" p_$ename mynew$ename=(p_$ename) calloc(1,(size_t)sizeof(t_$ename));\n"; $adms_c.=" adms_global_increment_nb${ename}new();\n" if($ename eq "admst"); my$parent=&eparent($_); if($parent) { $adms_c.=&pnew($_,"mynew$ename->",$_,$parent); } foreach(&attr($_)) { my$xname=&xname($_); my$xdatatypename=&xdatatypename($_); my$xdefault=&xdefault($_); if($_->parentNode->nodeName eq "uid") { if($xdatatypename eq "basicstring") {$adms_c.=" mynew$ename->_$xname=adms_kclone(my$xname);\n";} else {$adms_c.=" mynew$ename->_$xname=my$xname;\n";} $adms_c.=" mynew$ename->_${xname}_isdefault=1;\n" if vla($ename); } elsif(defined $xdefault) { if($xdatatypename eq "basicenumeration") {$adms_c.=" mynew$ename->_$xname=admse_$xdefault;\n";} elsif($xdatatypename eq "basicinteger") {$adms_c.=" mynew$ename->_$xname=$xdefault;\n"} elsif($xdatatypename eq "basicreal") {$adms_c.=" mynew$ename->_$xname=$xdefault;\n"} elsif($xdatatypename eq "basicstring") {$adms_c.=" mynew$ename->_$xname=adms_kclone(\"$xdefault\");\n";} elsif($xdatatypename eq "quark") {$adms_c.=" mynew$ename->_$xname=adms_quark_new(\"$xdefault\");\n";} elsif($xdefault eq "") {$adms_c.=" mynew$ename->_$xname=NULL;\n";} $adms_c.=" mynew$ename->_${xname}_isdefault=1;\n" if vla($ename); } else { $adms_c.=" mynew$ename->_${xname}_isdefault=-1;\n" if vla($ename); } } $adms_c.=" return mynew$ename;\n"; $adms_c.="}\n"; $adms_c.=&mkuid($_); next if not vla($ename); #xnew my@inputs; my$i=0; my$check; my$free; my$nbinputs=scalar(@{uid($_)}); $adms_c.="static p_admst adms_${ename}_xnew (p_ktransform mytransform,p_admst dot,p_slist myinputs[],const int size)\n{\n"; #fixme: special prototype for variable if(${ename} eq "variable") { $adms_c.=" if(size==3)\n"; $adms_c.=" return adms_variableprototype_xnew (mytransform,dot,myinputs,size);\n"; $adms_c.=" else"; } $adms_c.=" if(size!=$nbinputs)\n"; $adms_c.=" {\n"; $adms_c.=" adms_message_fatal_continue((\"admst:new($ename) bad number of inputs (found %i, expected $nbinputs)\\n\",size))\n"; $adms_c.=" adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform)))\n"; $adms_c.=" return NULL;\n"; $adms_c.=" }\n"; $adms_c.=" else\n"; $adms_c.=" {\n"; foreach(&uid($_)) { my$xname=&xname($_); my$xdatatypename=&xdatatypename($_); if(0) {} elsif($xdatatypename eq "basicinteger") { $adms_c.=" char* my${xname}s=aprintf(mytransform,(p_admst)myinputs[$i]->data);\n"; $adms_c.=" ".ctype($_)." my$xname=adms_strtol(mytransform,my${xname}s);\n"; $free.=" free(my${xname}s);\n"; } elsif($xdatatypename eq "basicreal") { $adms_c.=" char* my${xname}s=aprintf(mytransform,(p_admst)myinputs[$i]->data);\n"; $adms_c.=" ".ctype($_)." my$xname=adms_strtod(mytransform,my${xname}s);\n"; $free.=" free(my${xname}s);\n"; } elsif($xdatatypename eq "basicstring") { $adms_c.=" char* my${xname}=aprintf(mytransform,(p_admst)myinputs[$i]->data);\n"; $free.=" free(my${xname});\n"; } elsif($xdatatypename eq "basicenumeration") { $adms_c.=" char* my${xname}s=aprintf(mytransform,(p_admst)myinputs[$i]->data);\n"; $adms_c.=" admse my${xname}e=ns_strtoe(my${xname}s);\n"; $adms_c.=" ".ctype($_)." my$xname=my${xname}e;\n"; $check.=" if(!my${xname}e)\n"; $check.=" {\n"; $check.=" adms_message_fatal_continue((\"cannot convert '%s' to a valid value\\n\",my${xname}s))\n"; $check.=" adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform)))\n"; $check.=" }\n"; $free.=" free(my${xname}s);\n"; } elsif(xsize($_) eq "list") { $adms_c.=" ".ccontainer($_)." my$xname=myinputs[$i];\n"; } elsif($xdatatypename eq "lexval") { $adms_c.=" char* my${xname}s=aprintf(mytransform,(p_admst)myinputs[$i]->data);\n"; $adms_c.=" ".ctype($_)." my$xname=adms_lexval_new(my${xname}s,adms_transform_uid(mytransform),0,0);\n"; $free.=" free(my${xname}s);\n"; } else { $adms_c.=" ".ccontainer($_)." my$xname=(p_$xdatatypename)((p_admst)myinputs[$i]->data)->_item.p;\n"; } push @inputs,"my$xname"; $i++; } $adms_c.=" /*xnew*/p_admst myadmst=adms_admst_newpa(dot,dot,(p_adms)adms_${ename}_new(".(join",",@inputs)."));\n"; $adms_c.=$check if $check; $adms_c.=$free if $free; $adms_c.=" return myadmst;\n"; $adms_c.=" }\n"; $adms_c.="}\n"; } my$VA; foreach(@VA) {$VA.=" else if(!strcmp(ename,\"$_\")) return (p_new) adms_".$_."_xnew;\n";} $adms_c.=qq[ p_new adms_admsxml_new (p_ktransform mytransform,const char* ename) { if(0) {} $VA else if(!strcmp(ename,"basicenumeration")) return (p_new) adms_basicenumeration_xnew; else if(!strcmp(ename,"basicinteger")) return (p_new) adms_basicinteger_xnew; else if(!strcmp(ename,"basicreal")) return (p_new) adms_basicreal_xnew; else if(!strcmp(ename,"basicstring")) return (p_new) adms_basicstring_xnew; adms_message_fatal_continue(("adms element '%s' cannot be created using admst:new\\n",ename)) adms_message_fatal(("see %s\\n",adms_transform_uid(mytransform))) return NULL; }\n]; $VA=""; foreach(@VA) {$VA.=" if(myadmstread->_pseudo==admse_$_) return (p_cmp)adms_".$_."_cmp;\n";} $adms_c.=qq[ p_cmp adms_admsxml_cmp (p_kadmst myadmst) { p_admst myadmstread=aread(myadmst); if(myadmstread->_pseudo==admse_basicenumeration) return (p_cmp)adms_basicenumeration_cmp; if(myadmstread->_pseudo==admse_basicinteger) return (p_cmp)adms_basicinteger_cmp; if(myadmstread->_pseudo==admse_basicreal) return (p_cmp)adms_basicreal_cmp; if(myadmstread->_pseudo==admse_basicstring) return (p_cmp)adms_basicstring_cmp; $VA adms_message_fatal_continue(("%s:%i: internal error - should not be reached\\n",__FILE__,__LINE__)) adms_message_fatal(("%s:%i: please report to r29173\@users.sourceforge.net\\n",__FILE__,__LINE__)) return NULL; }\n]; #miscC $adms_c.="/*-- admst/new prototypes --*/\n"; foreach (qw[bd be bi br bs ks ns pa pn pc pd la ln pp]) { my$field=$_ eq"bd"?"i": $_ eq"be"?"i": $_ eq"bi"?"i": $_ eq"br"?"r": $_ eq"bs"?"s": $_ eq"ns"?"s": $_ eq"ks"?"s": "p"; my$cast=$_ eq"bd"?"const admse": $_ eq"be"?"const admse": $_ eq"bi"?"const int": $_ eq"br"?"const double": $_ eq"bs"?"char*": $_ eq"ns"?"char*": $_ eq"ks"?"char*": $_ eq"pd"?"p_admstvariable": $_ eq"pn"?"p_admst": $_ eq"pc"?"p_attribute": $_ eq"la"?"p_slist": $_ eq"ln"?"p_slist": $_ eq"pp"?"admse": "const p_adms"; my$item=$_ eq"pn"?"item->_item.p": $_ eq"pd"?"(p_adms)item": $_ eq"pc"?"(p_adms)item": $_ eq"la"?"(p_adms)item": $_ eq"ln"?"(p_adms)item": $_ eq"pp"?"myprevious->_item.p": "item"; my$pseudocode=$_ eq"bd"?"admse_datatypename": $_ eq"be"?"admse_basicenumeration": $_ eq"bi"?"admse_basicinteger": $_ eq"br"?"admse_basicreal": $_ eq"bs"?"admse_basicstring": $_ eq"ns"?"admse_basicstring": $_ eq"ks"?"admse_basicstring": $_ eq"pa"?"item?item->_datatypename:admse_empty": $_ eq"pn"?"item->_pseudo": $_ eq"pc"?"admse__croix": $_ eq"pd"?"admse_basiclist": $_ eq"la"?"admse__ladms": $_ eq"ln"?"admse__ladmst": $_ eq"pp"?"item": "mypseudo"; my$extra=$_ eq"ns"?"myadmst->_hasnewbasicstring=1;\n ": $_ eq"ks"?"myadmst->_refd=0;\n ": ""; my$inputs0=$_ eq"ks"?"$cast item": "p_admst myprevious,p_admst mypreviouspath,$cast item"; my$inputs1=$_ eq"ks"?"NULL,NULL,$pseudocode": "myprevious,mypreviouspath,$pseudocode"; $adms_c.="p_admst adms_admst_new$_ ($inputs0) { p_admst myadmst=adms_admst_new($inputs1); ".(($_ ne"pn")?"myadmst->_item.$field=$item;":"if(item->_hasnewbasicstring==1) { myadmst->_item.s=item->_item.s; myadmst->_original=item; item->_refd++; } else myadmst->_item.p=item->_item.p;").(($_ ne"bs")?"":"\n if(myprevious->_hasnewbasicstring==2) { myadmst->_original=myprevious; myprevious->_refd++; }")." ${extra}return myadmst; }\n"; } $adms_c.=q[ /*-- Miscellaneous routines --*/ p_admst aread (p_admst myadmst) { p_admst myadmstread=(myadmst&&myadmst->_pseudo==admse__croix)?(p_admst)((p_attribute)myadmst->_item.p)->_value:myadmst; return myadmstread; } int adms_strtol (p_ktransform mytransform,const char* mynumber) { int nb; char* tail; errno=0; nb=strtol(mynumber,&tail,10); if(*tail||errno) { adms_message_fatal_continue(("%s: cannot convert value to valid integer value\n",mynumber)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } return nb; } double adms_strtod (p_ktransform mytransform,const char* myreal) { double nb; char* tail; errno=0; nb=strtod(myreal,&tail); if(*tail||errno) return adms_NAN; if(*tail||errno) { adms_message_fatal_continue(("%s: cannot convert value to valid real value\n",myreal)) adms_message_fatal(("see %s\n",adms_transform_uid(mytransform))) } return nb; } void bp (void) {} char*adms_integertostring (int value) { char*string=malloc(sizeof(char)*50); sprintf(string,"%i",value); return string; } char*adms_doubletostring (double value) { if(isnan(value)) { char*string=malloc(sizeof(char)*4); sprintf(string,"nan"); return string; } else { char*string=malloc(sizeof(char)*50); sprintf(string,"%e",value); return string; } } int adms_file_isregular (const char* myfilename) { return((access(myfilename,ADMS_F_OK)==0)); } int adms_file_isdirectory (const char* myfilename) { struct stat s; return((stat(myfilename,&s)==0)&&(s.st_mode&ADMS_S_IFDIR)); } int adms_setenv (const char* myname,const char* myvalue) { int myres; #if defined(HAVE_PUTENV) char*myassign=NULL; adms_k2strconcat(&myassign,myname); adms_k2strconcat(&myassign,"="); adms_k2strconcat(&myassign,myvalue); myres=putenv(myassign); free(myassign); #else myres=setenv(myname,myvalue,1); #endif return (myres==0); } p_slist adms_slist_last (p_slist l) { if(l) { while(l->next) l=l->next; } return l; } p_slist adms_slist_new (p_adms d) { p_slist newl=NULL; adms_slist_push(&newl,d); return newl; } p_slist adms_slist_copy (p_slist l) { p_slist copiedl=NULL; while(l) { adms_slist_push(&copiedl,l->data); l=l->next; } return adms_slist_reverse(copiedl); } void adms_slist_push (p_slist* l,p_adms data) { p_slist n=malloc(sizeof(t_slist)); n->next=*l; n->data=data; *l=n; } p_adms adms_slist_pull (p_slist* l) { if(*l) { p_slist n=*l; p_adms data=n->data; *l=(*l)->next; free(n); return data; } return NULL; } void adms_slist_concat (p_slist* l1,p_slist l2) { if(l2) { if(*l1) adms_slist_last(*l1)->next=l2; else *l1=l2; } } unsigned int adms_slist_length (p_slist l) { unsigned int length=0; while(l) { length++; l=l->next; } return length; } p_slist adms_slist_nth (p_slist l,unsigned int n) { while (n-->0 && l) l=l->next; return l; } p_adms adms_slist_nth_data (p_slist l,unsigned int n) { while (n-->0 && l) l=l->next; return l ? l->data : ((p_adms)0); } p_slist adms_slist_find (p_slist l,p_kadms data) { while(l) { if(l->data==data) break; l=l->next; } return l; } int adms_slist_index (p_slist l, p_kadms data) { int i=0; while(l) { if(l->data==data) return i; i++; l=l->next; } return -1; } p_slist adms_slist_reverse (p_slist l) { p_slist p=NULL; while(l) { p_slist n=l->next; l->next=p; p=l; l=n; } return p; } void adms_slist_inreverse (p_slist* l) { *l=adms_slist_reverse(*l); } void adms_slist_free (p_slist l) { while(l) { p_slist freed=l; l=l->next; free(freed); } } int globalnbadmstnew=0, globalnbadmstdestroy=0; int adms_global_nbadmstnew (void) {return globalnbadmstnew;} int adms_global_nbadmstdestroy (void) {return globalnbadmstdestroy;} void adms_global_increment_nbadmstnew (void) {globalnbadmstnew++;} void adms_global_increment_nbadmstdestroy (void) {globalnbadmstdestroy++;} p_admsmain globaladmsmain; p_admsmain root (void) {return globaladmsmain;} void rootnew (p_admsmain myglobaladmsmain) {globaladmsmain=myglobaladmsmain;} /*-- Messaging --*/ void adms_toupper (char*m) { for(;*m;m++) *m=toupper(*m); } void adms_tolower (char*m) { for(;*m;m++) *m=tolower(*m); } char*adms_kclone (const char* m) { if(m) { int l=strlen(m); char*mycpy=(char*)malloc((l+1)*sizeof(char)); memcpy(mycpy,m,l); mycpy[l]='\0'; return mycpy; } else return NULL; } char*adms_knclone (const char* m,const int l) { char*mycpy=(char*)malloc((l+1)*sizeof(char)); memcpy(mycpy,m,l); mycpy[l]='\0'; return mycpy; } /*clone array (m,n(: "abcdefghijkl\0" returns as "cdef\0"*/ /* m n */ /* same as adms_knclone(m,n-m) */ char*adms_m2nclone (const char* m,const char* n) { int l=(char*)n-(char*)m; char*mycpy=(char*)malloc((l+1)*sizeof(char)); memcpy(mycpy,m,l); mycpy[l]='\0'; return mycpy; } /*s1: realloced s2: constant ret: s1=s1s2*/ void adms_k2strconcat (char **s1,const char* s2) { if(!s2) return; if(*s1) { int l1=strlen(*s1); int l2=strlen(s2); *s1=(char*)realloc(*s1,(l1+l2+1)*sizeof(char)); memcpy(*s1+l1,s2,l2+1); } else *s1=strdup(s2); } /*s1: realloced s2: freed ret: s1=s1s2*/ void adms_strconcat (char **s1,char *s2) { adms_k2strconcat(s1,s2); free(s2); } FILE* adms_file_open_read (const char* myfilename) { FILE* fh=fopen(myfilename,"r"); if(!fh) adms_message_fatal(("%s: failed to open file [read mode]\n",myfilename)) return fh; } ]; foreach my$mess(@message) { my$name=$mess->[0]; my$ofh=$mess->[1]; my$isfatal=($mess->[2]==1); my$iserror=($mess->[2]==2); my$prefix=sprintf("\"[%-7s]",$name); $prefix=~s/ /\./g; $prefix.=" \""; $adms_c.="_t_message (adms_message_${name}_impl)\n"; $adms_c.="{\n"; $adms_c.=" va_list ap;\n"; $adms_c.=" int insideformat=0;\n"; $adms_c.=" int i;\n"; $adms_c.=" char* s;\n"; $adms_c.=" char c;\n"; $adms_c.=" double d;\n"; $adms_c.=" void* p;\n"; $adms_c.=" fputs($prefix,$ofh);\n" if($mess->[2]>=0); $adms_c.=" va_start(ap, format);\n"; $adms_c.=" for(;*format;format++)\n"; $adms_c.=" {\n"; $adms_c.=" if(insideformat)\n"; $adms_c.=" {\n"; $adms_c.=" insideformat=0;\n"; $adms_c.=" switch(*format) \n"; $adms_c.=" {\n"; $adms_c.=" case 's':\n"; $adms_c.=" s=va_arg (ap,char*);\n"; $adms_c.=" if(s) fputs(s,$ofh); else fputs(\"NULL\",$ofh);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'e':\n"; $adms_c.=" d=va_arg (ap,double);\n"; $adms_c.=" fprintf($ofh,\"%e\",d);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'c':\n"; $adms_c.=" c=va_arg (ap,int);\n"; $adms_c.=" fprintf($ofh,\"%c\",c);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'g':\n"; $adms_c.=" d=va_arg (ap,double);\n"; $adms_c.=" fprintf($ofh,\"%g\",d);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'f':\n"; $adms_c.=" d=va_arg (ap,double);\n"; $adms_c.=" fprintf($ofh,\"%f\",d);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'i':\n"; $adms_c.=" i=va_arg (ap,int);\n"; $adms_c.=" fprintf($ofh,\"%i\",i);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'p':\n"; $adms_c.=" p=va_arg (ap,void*);\n"; $adms_c.=" fprintf($ofh,\"%p\",p);\n"; $adms_c.=" break;\n"; $adms_c.=" default:\n"; $adms_c.=" fputc(*format,$ofh);\n"; $adms_c.=" }\n"; $adms_c.=" }\n"; $adms_c.=" else\n"; $adms_c.=" {\n"; $adms_c.=" switch(*format) \n"; $adms_c.=" {\n"; $adms_c.=" case '%':\n"; $adms_c.=" insideformat=1;\n"; $adms_c.=" break;\n"; $adms_c.=" default:\n"; $adms_c.=" fputc(*format,$ofh);\n"; $adms_c.=" }\n"; $adms_c.=" }\n"; $adms_c.=" }\n"; $adms_c.=" va_end (ap);\n"; $adms_c.=" fflush($ofh);\n"; $adms_c.=" bp();\n" if($iserror); $adms_c.=" bp(),exit(1);\n" if($isfatal); $adms_c.="}\n"; $adms_c.="_t_message (adms_message_${name}_continue_impl)\n"; $adms_c.="{\n"; $adms_c.=" va_list ap;\n"; $adms_c.=" int insideformat=0;\n"; $adms_c.=" int i;\n"; $adms_c.=" char* s;\n"; $adms_c.=" char c;\n"; $adms_c.=" double d;\n"; $adms_c.=" void* p;\n"; $adms_c.=" fputs($prefix,$ofh);\n" if($isfatal || $iserror); $adms_c.=" va_start(ap, format);\n"; $adms_c.=" for(;*format;format++)\n"; $adms_c.=" {\n"; $adms_c.=" if(insideformat)\n"; $adms_c.=" {\n"; $adms_c.=" insideformat=0;\n"; $adms_c.=" switch(*format) \n"; $adms_c.=" {\n"; $adms_c.=" case 's':\n"; $adms_c.=" s=va_arg (ap,char*);\n"; $adms_c.=" if(s) fputs(s,$ofh); else fputs(\"NULL\",$ofh);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'c':\n"; $adms_c.=" c=va_arg (ap,int);\n"; $adms_c.=" fputc(c,$ofh);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'e':\n"; $adms_c.=" d=va_arg (ap,double);\n"; $adms_c.=" fprintf($ofh,\"%e\",d);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'g':\n"; $adms_c.=" d=va_arg (ap,double);\n"; $adms_c.=" fprintf($ofh,\"%g\",d);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'f':\n"; $adms_c.=" d=va_arg (ap,double);\n"; $adms_c.=" fprintf($ofh,\"%f\",d);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'i':\n"; $adms_c.=" i=va_arg (ap,int);\n"; $adms_c.=" fprintf($ofh,\"%i\",i);\n"; $adms_c.=" break;\n"; $adms_c.=" case 'p':\n"; $adms_c.=" p=va_arg (ap,void*);\n"; $adms_c.=" fprintf($ofh,\"%p\",p);\n"; $adms_c.=" break;\n"; $adms_c.=" default:\n"; $adms_c.=" fputc(*format,$ofh);\n"; $adms_c.=" }\n"; $adms_c.=" }\n"; $adms_c.=" else\n"; $adms_c.=" {\n"; $adms_c.=" switch(*format) \n"; $adms_c.=" {\n"; $adms_c.=" case '%':\n"; $adms_c.=" insideformat=1;\n"; $adms_c.=" break;\n"; $adms_c.=" default:\n"; $adms_c.=" fputc(*format,$ofh);\n"; $adms_c.=" }\n"; $adms_c.=" }\n"; $adms_c.=" }\n"; $adms_c.=" va_end (ap);\n"; $adms_c.=" fflush($ofh);\n"; $adms_c.="}\n"; } open FILE,">adms.c"; print FILE $adms_c; close FILE; print "adms.c: created\n"; #apath language map{my$e=$_;my$ename=&xname($e); map{push @{$A{xname($_)}},[$e,$_] if (&xname($_) ne "datatypename");} &attr($_) if vla($ename)||$ename eq "return"||$ename eq "math"||$ename eq "subexpression";} @$EA; my@Location03; foreach(@$EA) { my$ename=&xname($_); next if not $ename eq "adms"||$ename eq "math"||$ename eq "subexpression"; push @Location03," IFIDENT($ename)\n"; foreach($_->findnodes(".//element")) { next if not vla(xname($_)); push @Location03," MKscalar(".xname($_).",sub)\n"; } push @Location03," ENDIFIDENT\n"; } foreach(sort keys(%A)) { my($aname,$ee)=($_,$A{$_}); push @Location03," IFIDENT($aname)\n"; foreach(@$ee) { my($e,$a)=@$_; if(xsize($a) eq "list") { push @Location03," MKlist(".xname($e).",".xdatatypename($a).")\n"; } else { push @Location03," MKscalar(".xname($e).",".xdatatypename($a).")\n"; } } push @Location03," ENDIFIDENT\n"; } #dtd sub LN { my($type,$rhs)=(shift,shift); return "p_admst d=adms_admst_new$type(ai,ai,$rhs);".&ALLLASTPOS("d"); } sub LLNN { my($type,$rhs)=(shift,shift); return "p_admst d=adms_admst_new$type(dot,dot,$rhs);".&ALLLASTPOS("d"); } open admstpath_dtd,">admstpath.dtd"; my$dtd=q[ --> ]; print admstpath_dtd $dtd; close admstpath_dtd; print "admstpath.dtd: created\n"; open admstpathYacc_h,">admstpathYacc.h"; print admstpathYacc_h "$BUILDER #include \"adms.h\" #undef win32_interface #if defined(WIN32) # if defined(insideadmstpathYacc) # define win32_interface __declspec(dllexport) # else # define win32_interface __declspec(dllimport) # endif #else # define win32_interface extern #endif // preprocessor flag for static link (MinGW) #ifdef staticlink # undef win32_interface # define win32_interface extern #endif win32_interface p_slist globalfileoutputlist; win32_interface int break_found; win32_interface FILE *OUT(void); win32_interface int is_admst (const char* name); win32_interface int apath_main (int argc,char **argv); win32_interface void dbxx (p_transform mytransform); win32_interface void postxx (p_transform mytransform); win32_interface void sanityxx (p_transform mytransform); win32_interface p_transform lookfortemplates(p_transform mytransform,const char*match); win32_interface p_path pparse (p_transform mytransform,const char* aname,const char* avalue); win32_interface p_text tparse (p_ktransform mytransform,const char* aname,const char* avalue); win32_interface p_admst adms_pull_admst (p_transform mytransform); win32_interface p_admstvariable lookup_dollar (const char* myid); win32_interface void tprintf (p_kadmst myadmst, p_ktext mytext); win32_interface char* tsprintf (p_kadmst myadmst, p_ktext mytext); win32_interface void free_ptraverse (p_ptraverse p); win32_interface p_ptraverse bar (p_admst dot,p_path mypath0); win32_interface void Xassert (p_transform mytransform,p_admst dot,p_admst dotdot); win32_interface void xtraverse (p_slist mytransforms,p_admst dot,p_admst dotdot); "; close admstpathYacc_h; print "admstpathYacc.h: created\n"; open admstpathYacc_y,">admstpathYacc.y"; print admstpathYacc_y "$BUILDER %name-prefix \"admstpath\" %lex-param {p_pparse mypparse} %parse-param {p_pparse mypparse} \%{ #include \"admstpathYacc.h\" "; sub REQUIRECHILD { return " if(!mytransform->_children) adms_message_fatal((\"transform requires children - see %s\\n\",adms_transform_uid(mytransform)))\n"; } sub EXCLUDECHILD { return " if(mytransform->_children) adms_message_fatal((\"transform does not support children - see %s\\n\",adms_transform_uid(mytransform)))\n"; } sub EXCLUDE { my($type,$item)=@_; return " if(mytransform->_$type$item) adms_message_fatal((\"transform does not support attribute '$item' - see %s\\n\",adms_transform_uid(mytransform)))\n"; } sub REQUIRE { my($type,$item)=@_; return " if(!mytransform->_$type$item) adms_message_fatal((\"transform requires attribute '$item' - see %s\\n\",adms_transform_uid(mytransform)))\n"; } sub OBSOLETE { my($obsolete,$new)=@_; return " if(!strcmp(mytransform->_name,\"$obsolete\")) adms_message_obsolete((\"%s: please use '$new' instead\\n\",adms_transform_uid(mytransform)))\n"; } print admstpathYacc_y ' static int admstpathlex (p_pparse mypparse); static void dbpath (p_path mypath); static void dbtext (p_text mytext); static void postpath (p_path mypath); static void posttext (p_text mytext) { p_slist li; for(li=mytext->_token;li;li=li->next) { p_adms mytoken=li->data; if(mytoken->_datatypename==admse_path) { ((p_path)mytoken)->_aname=adms_kclone("//"); adms_k2strconcat(&((p_path)mytoken)->_aname,mytext->_aname); postpath((p_path)mytoken); } else if(mytoken->_datatypename==admse_text) { ((p_text)mytoken)->_aname=adms_kclone("//"); adms_k2strconcat(&((p_text)mytoken)->_aname,mytext->_aname); posttext((p_text)mytoken); } } } void dbxx (const p_transform mytransform) { if(!is_admst(mytransform->_name)) { p_slist l=mytransform->_attribute; for(;l;l=l->next) dbtext((p_text)((p_attribute)l->data)->_value); } '; foreach($admstxml->findnodes("//transform")) { my$tname=xname($_); foreach($_->findnodes(".//attribute|.//attribute-implied|.//attribute-warning")) { my$type=xtype($_); my$aname=$type.xname($_); print admstpathYacc_y " if(!strcmp(mytransform->_name,\"$tname\")&&mytransform->_$aname) db$type(mytransform->_$aname);\n"; } foreach($_->findnodes(".//attribute-list")) { my$type=xtype($_); my$aname=$type.xname($_); print admstpathYacc_y " if(!strcmp(mytransform->_name,\"$tname\")&&mytransform->_$aname)\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " p_slist l=mytransform->_$aname;\n"; print admstpathYacc_y " for(;l;l=l->next)\n"; print admstpathYacc_y " db$type((p_$type)l->data);\n"; print admstpathYacc_y " }\n"; } } print admstpathYacc_y "}\n"; print admstpathYacc_y "void postxx (p_transform mytransform)\n"; print admstpathYacc_y "{\n"; print admstpathYacc_y " if(!is_admst(mytransform->_name)) { p_slist l=mytransform->_attribute; for(;l;l=l->next) posttext((p_text)((p_attribute)l->data)->_value); } "; foreach($admstxml->findnodes("//transform")) { my$tname=xname($_); foreach($_->findnodes(".//attribute|.//attribute-implied|.//attribute-warning")) { my$type=xtype($_); my$aname=$type.xname($_); print admstpathYacc_y " if(!strcmp(mytransform->_name,\"$tname\")&&mytransform->_$aname) post$type(mytransform->_$aname);\n"; } foreach($_->findnodes(".//attribute-list")) { my$type=xtype($_); my$aname=$type.xname($_); print admstpathYacc_y " if(!strcmp(mytransform->_name,\"$tname\")&&mytransform->_$aname)\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " p_slist l=mytransform->_$aname;\n"; print admstpathYacc_y " for(;l;l=l->next)\n"; print admstpathYacc_y " post$type((p_$type)l->data);\n"; print admstpathYacc_y " }\n"; } } print admstpathYacc_y "}\n"; print admstpathYacc_y 'void sanityxx (p_transform mytransform)'."\n"; print admstpathYacc_y '{'."\n"; print admstpathYacc_y ' if(!is_admst(mytransform->_name)) { }'."\n"; foreach($admstxml->findnodes("//transform")) { my$transform=$_; my@ids; foreach($transform->findnodes("obsolete")) { push @ids,"!strcmp(mytransform->_name,\"".xname($_)."\")"; } push @ids,"!strcmp(mytransform->_name,\"".xname($transform)."\")"; print admstpathYacc_y " else if(".(join "||",@ids).")\n {\n"; print admstpathYacc_y &REQUIRECHILD if(defined xhaschild($transform) && (xhaschild($transform) eq "yes")); print admstpathYacc_y &EXCLUDECHILD if(defined xhaschild($transform) && (xhaschild($transform) eq "no")); foreach($transform->findnodes("obsolete|exclude|attribute")) { if($_->nodeName eq "attribute") { print admstpathYacc_y &REQUIRE(xtype($_),xname($_)); } elsif($_->nodeName eq "exclude") { print admstpathYacc_y &EXCLUDE(xtype($_),xname($_)); } elsif($_->nodeName eq "obsolete") { print admstpathYacc_y &OBSOLETE(xname($_),xname($transform)); } } print admstpathYacc_y " }\n"; } print admstpathYacc_y ' else adms_message_fatal(("%s: unknown transform\n",adms_transform_uid(mytransform)))'."\n"; print admstpathYacc_y '}'."\n"; sub ALIASADMST {my$d=shift;return " adms_slist_push(&p->_aliasadmst,(p_adms)$d); ";} sub arrachage {my$ai=shift;return "if($ai->_preva) $ai->_preva->_nexta=$ai->_nexta,$ai->_preva=NULL; if($ai->_nexta) $ai->_nexta->_preva=$ai->_preva,$ai->_nexta=NULL;";} sub insertion {my$ai=shift;return "if(p->_a1==NULL) p->_a1=p->_an=$ai; else p->_an->_nexta=$ai,$ai->_preva=p->_an,p->_an=$ai;";} sub fixme {my$ai=shift;return &arrachage($ai).&insertion($ai);} sub ALLLASTPOS {my$ai=shift;return &fixme($ai)."$ai->_position=++p->_position;";} foreach (@Location03) { if(/MK\w+\((\w+),(\w+)\)/) {$e=$1;$d=$2;} if(/IFIDENT\((\w+)\)/) { $a=$1; print admstpathYacc_y "static void location030$a\(p_ptraverse p,p_path mypath,p_admst dot)\n"; print admstpathYacc_y "{\n"; print admstpathYacc_y " p_admst ai=aread(dot);\n"; print admstpathYacc_y " admse e;\n"; print admstpathYacc_y " if(ai)\n"; print admstpathYacc_y " e=ai->_pseudo;\n"; print admstpathYacc_y " else\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " p_admst d=adms_admst_newpa(ai,ai,NULL);".&ALLLASTPOS("d")." return;\n"; print admstpathYacc_y " }\n"; print admstpathYacc_y " if(0) {}\n"; if($a eq "dependency") { foreach(@MATHELEMENTS) { my($ealias,$e)=@{$_}; print admstpathYacc_y " else if(e==admse_$ealias)\n"; print admstpathYacc_y " e=admse_$e;\n"; } } foreach(@{$ALIAS{$a}}) { my($ealias,$e)=@{$_}; print admstpathYacc_y " else if(e==admse_$ealias)\n"; print admstpathYacc_y " e=admse_$e;\n"; } print admstpathYacc_y " if(0) {}\n"; foreach(@{$ALIASBIS{$a}}) { my($elt,$palias)=@{$_}; my@ealias=split "/",$palias; print admstpathYacc_y " else if(e==admse_$elt)\n"; print admstpathYacc_y " {\n"; my$idx=0; my$xdatatypename; foreach(@ealias) { my$path=$_; my$islast=scalar(@ealias)==$idx+1; my$prevpath=$xdatatypename?$xdatatypename:$elt; my$prevai=$xdatatypename?"d".($idx-1):"ai"; my$attr=$EH->{$prevpath}->findnodes("((uid/scalar)|(uid/list)|scalar|list)[\@name='$path']")->[0]; $xdatatypename=&xdatatypename($attr); if(xsize($attr) eq "list") { print admstpathYacc_y " /*AAAA0*/ p_slist l$idx=((p_$prevpath)$prevai->_item.p)->_$path;\n"; print admstpathYacc_y " for(;l$idx;l$idx=l$idx->next)\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " p_admst d$idx=adms_admst_newpa($prevai,ai,l$idx->data);".&ALLLASTPOS("d$idx")."\n"; print admstpathYacc_y " }\n"; } else { print admstpathYacc_y " /*BBBB0*/ "; if($xdatatypename eq "basicenumeration") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbe($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } elsif($xdatatypename eq "basicinteger") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbi($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } elsif($xdatatypename eq "basicreal") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbr($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } elsif($xdatatypename eq "basicstring") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbs($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } else { print admstpathYacc_y "p_admst d$idx=adms_admst_newpa($prevai,ai,(p_adms)((p_$prevpath)$prevai->_item.p)->_$path);"; } print admstpathYacc_y &ALIASADMST("d$idx") if not $islast; print admstpathYacc_y &ALLLASTPOS("d$idx") if $islast; print admstpathYacc_y "d$idx->_valueto=(void*)adms_${prevpath}_valueto_$path;\n"; } $idx++; } print admstpathYacc_y " }\n"; } } elsif(/MKlist/) { if($e eq "list" && $a eq "item") {$code="p_admst d=adms_admst_newpn(dot,dot,(p_admst)lii->data);";} elsif($d eq "basicstring") {$code="p_admst d=adms_admst_newbs(ai,ai,(char*)lii->data);";} else {$code="p_admst d=adms_admst_newpa(ai,ai,lii->data);";} print admstpathYacc_y " else if(e==admse_$e) { p_slist lii=((p_$e)ai->_item.p)->_$a; for(;lii;lii=lii->next) { $code".&ALLLASTPOS("d")." } } "; } elsif(/MKscalar/) { print admstpathYacc_y " else if(e==admse_$e)\n {\n"; if(/MKscalar\(attribute,adms\)/) { print admstpathYacc_y " p_admst d=adms_admst_newpc(ai,ai,(p_attribute)ai->_item.p);"; } elsif($d eq "sub") { print admstpathYacc_y " p_admst d=adms_admst_newpp(ai,ai,admse_$a); d->_valueto=(void*)NULL;"; } elsif($d eq "basicenumeration") { print admstpathYacc_y " p_admst d=adms_admst_newbe(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } elsif($d eq "basicinteger") { print admstpathYacc_y " p_admst d=adms_admst_newbi(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } elsif($d eq "basicreal") { print admstpathYacc_y " p_admst d=adms_admst_newbr(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } elsif($d eq "basicstring") { print admstpathYacc_y " p_admst d=adms_admst_newbs(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } else { print admstpathYacc_y " p_admst d=adms_admst_newpa(ai,ai,(p_adms)((p_$e)(ai->_item.p))->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } print admstpathYacc_y &ALLLASTPOS("d")."\n }\n"; } if(/ENDIFIDENT/) { print admstpathYacc_y " else\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " ".&LN("pn","ai")."\n"; print admstpathYacc_y " adms_message_error((\"%s: '$a' bad attribute\\n\",adms_transform_uid(p->_transform)))\n"; print admstpathYacc_y " }\n"; print admstpathYacc_y "}\n"; } } print admstpathYacc_y "\n"; foreach (@Location03) { if(/MK\w+\((\w+),(\w+)\)/) {$e=$1;$d=$2;} if(/IFIDENT\((\w+)\)/) { $a=$1; print admstpathYacc_y "static void location031$a\(p_ptraverse p,p_path mypath,p_admst dot)\n"; print admstpathYacc_y "{\n"; print admstpathYacc_y " p_admst ai=aread(dot);\n"; print admstpathYacc_y " admse e;\n"; print admstpathYacc_y " if(ai)\n"; print admstpathYacc_y " e=ai->_pseudo;\n"; print admstpathYacc_y " else\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " p_admst d=adms_admst_newpa(ai,ai,NULL);".&ALLLASTPOS("d")." return;\n"; print admstpathYacc_y " }\n"; print admstpathYacc_y " if(0) {}\n"; if($a eq "dependency") { foreach(@MATHELEMENTS) { my($ealias,$e)=@{$_}; print admstpathYacc_y " else if(e==admse_$ealias)\n"; print admstpathYacc_y " e=admse_$e;\n"; } } foreach(@{$ALIAS{$a}}) { my($ealias,$e)=@{$_}; print admstpathYacc_y " else if(e==admse_$ealias)\n"; print admstpathYacc_y " e=admse_$e;\n"; } print admstpathYacc_y " if(0) {}\n"; foreach(@{$ALIASBIS{$a}}) { my($elt,$palias)=@{$_}; my@ealias=split "/",$palias; print admstpathYacc_y " else if(e==admse_$elt)\n"; print admstpathYacc_y " {\n"; my$idx=0; my$xdatatypename; foreach(@ealias) { my$path=$_; my$islast=scalar(@ealias)==$idx+1; my$prevpath=$xdatatypename?$xdatatypename:$elt; my$prevai=$xdatatypename?"d".($idx-1):"ai"; my$attr=$EH->{$prevpath}->findnodes("((uid/scalar)|(uid/list)|scalar|list)[\@name='$path']")->[0]; $xdatatypename=&xdatatypename($attr); my$field; my$cast; if($xdatatypename eq "basicenumeration") {$field="i";$cast="";} elsif($xdatatypename eq "basicinteger") {$field="i";$cast="";} elsif($xdatatypename eq "basicreal") {$field="r";$cast="";} elsif($xdatatypename eq "basicstring") {$field="s";$cast="";} else {$field="p";$cast="(p_adms)";} if(xsize($attr) eq "list") { die if not $islast; print admstpathYacc_y " /*AAAA1*/ p_admst d$idx=adms_admst_newla($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } else { print admstpathYacc_y " /*BBBB1*/ "; if($xdatatypename eq "basicenumeration") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbe($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } elsif($xdatatypename eq "basicinteger") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbi($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } elsif($xdatatypename eq "basicreal") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbr($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } elsif($xdatatypename eq "basicstring") { print admstpathYacc_y "p_admst d$idx=adms_admst_newbs($prevai,ai,((p_$prevpath)$prevai->_item.p)->_$path);"; } else { print admstpathYacc_y "p_admst d$idx=adms_admst_newpa($prevai,ai,(p_adms)((p_$prevpath)$prevai->_item.p)->_$path);"; } } print admstpathYacc_y &ALIASADMST("d$idx") if not $islast; print admstpathYacc_y &ALLLASTPOS("d$idx") if $islast; print admstpathYacc_y "d$idx->_valueto=(void*)adms_${prevpath}_valueto_$path;\n"; $idx++; } print admstpathYacc_y " }\n"; } } if(/MKlist/) { if($e eq "list" && $a eq "item") { print admstpathYacc_y " else if(e==admse_$e)\n {\n p_admst d=adms_admst_newln(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;".&ALLLASTPOS("d")."\n }\n"; } else { print admstpathYacc_y " else if(e==admse_$e)\n {\n p_admst d=adms_admst_newla(ai,ai,(p_slist)(((p_$e)ai->_item.p)->_$a)); d->_valueto=(void*)adms_${e}_valueto_$a;".&ALLLASTPOS("d")."\n }\n"; } } elsif(/MKscalar/) { print admstpathYacc_y " else if(e==admse_$e)\n {\n "; if(/MKscalar\(attribute,adms\)/) { print admstpathYacc_y "p_admst d=adms_admst_newpc(ai,ai,(p_attribute)ai->_item.p);"; } elsif($d eq "sub") { print admstpathYacc_y "p_admst d=adms_admst_newpp(ai,ai,admse_$a); d->_valueto=(void*)NULL;"; } elsif($d eq "basicenumeration") { print admstpathYacc_y "p_admst d=adms_admst_newbe(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } elsif($d eq "basicinteger") { print admstpathYacc_y "p_admst d=adms_admst_newbi(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } elsif($d eq "basicreal") { print admstpathYacc_y "p_admst d=adms_admst_newbr(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } elsif($d eq "basicstring") { print admstpathYacc_y "p_admst d=adms_admst_newbs(ai,ai,((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } else { print admstpathYacc_y "p_admst d=adms_admst_newpa(ai,ai,(p_adms)((p_$e)ai->_item.p)->_$a); d->_valueto=(void*)adms_${e}_valueto_$a;"; } print admstpathYacc_y &ALLLASTPOS("d")."\n }\n"; } if(/ENDIFIDENT/) { print admstpathYacc_y " else\n"; print admstpathYacc_y " {\n"; print admstpathYacc_y " ".&LN("pn","ai")."\n"; print admstpathYacc_y " adms_message_error((\"%s: '$a' bad attribute\\n\",adms_transform_uid(p->_transform)))\n"; print admstpathYacc_y " }\n"; print admstpathYacc_y "}\n"; } } print admstpathYacc_y "\n"; my@Locationalias03; foreach(@$EA) { foreach($_->findnodes("alias")) { push @Locationalias03, &xname($_); } push @Locationalias03,xname(&eparent($_)) if &eparent($_); next if (not vla(xname($_))) && xname($_) ne "adms"; foreach(&attr($_)) { push @Locationalias03, &xname($_); } } sub uniq { my@array=@_; my%seen; my@new; map{push @new, $_ if not $seen{$_};$seen{$_}=1;} @array; return @new; } @Locationalias03=&uniq(@Locationalias03); print admstpathYacc_y " static void groupage (void) {} static void location04 (void) {} static void location05 (void) {} "; print admstpathYacc_y " p_slist globalfileoutputlist=NULL; int break_found=0; FILE *OUT (void) { return globalfileoutputlist?(FILE*)globalfileoutputlist->data:stdout; } p_transform lookfortemplates(p_transform mytransform,const char*match) { p_slist li; p_transform parent=root()->_itransform?((p_itransform)root()->_itransform->data)->_originalcall:mytransform; while(parent) { p_slist l; for(l=parent->_templates;l;l=l->next) if(!strcmp(((p_admst)((p_transform)l->data)->_textmatch->_token->data)->_item.s,match)) return (p_transform)l->data; parent=parent->_parent; } for(li=root()->_invtransform;li;li=li->next) { p_slist l; parent=(p_transform)li->data; for(l=parent->_templates;l;l=l->next) if(!strcmp(((p_admst)((p_transform)l->data)->_textmatch->_token->data)->_item.s,match)) return (p_transform)l->data; } parent=mytransform; while(parent) { p_slist l; for(l=parent->_templates;l;l=l->next) if(!strcmp(((p_admst)((p_transform)l->data)->_textmatch->_token->data)->_item.s,match)) return (p_transform)l->data; parent=parent->_parent; } return NULL; } static void location02 (p_ptraverse p,p_path mypath,p_admst dot) { p_itransform myitransform=adms_itransform_new(mypath->_template); p_ptraverse p0=bar(dot,(p_path)mypath->_u->data); p_slist myl0=p0->_admst; myitransform->_originalcall=mypath->_transform; adms_slist_push(&root()->_itransform,(p_adms)myitransform); for(;myl0;myl0=myl0->next) { if(myl0->data&&((p_admst)myl0->data)->_item.p) { p_slist l; xtraverse(myitransform->_template->_children,(p_admst)myl0->data,dot); for(l=myitransform->_variable;l;l=l->next) { p_slist li; for(li=((p_admstvariable)l->data)->_value;li;li=li->next) deref((p_admst)li->data); adms_admstvariable_free((p_admstvariable)l->data); } } } adms_slist_pull(&root()->_itransform); free_ptraverse(p0); for(myl0=myitransform->_return;myl0;myl0=myl0->next) { ".&ALLLASTPOS("((p_admst)myl0->data)")." } adms_itransform_free(myitransform); } void Xassert (p_transform mytransform,p_admst dot,p_admst dotdot) { if(!mytransform->_textformat) { adms_message_fatal_continue((\"assert failed\\n\")) adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform))) } else if(mytransform->_pathselect) { p_ptraverse pselect=bar(dot,mytransform->_pathselect); p_slist myli; for(myli=pselect->_admst;myli;myli=myli->next) { char* text=tsprintf((p_admst)myli->data,mytransform->_textformat); adms_message_fatal_continue((\"%s\",text)) free(text); } adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform))) free_ptraverse(pselect); } else { char* text=tsprintf(dot,mytransform->_textformat); adms_message_fatal_continue((\"%s\",text)) adms_message_fatal((\"see %s\\n\",adms_transform_uid(mytransform))) free(text); } } typedef void (*p_transform_evaluate) (p_transform mytransform,p_admst dot); void xtraverse (p_slist mytransforms,p_admst dot,p_admst dotdot) { p_slist l; for(l=mytransforms;l;l=l->next) { int mypassed=1; p_transform mytransform=(p_transform)l->data; if(mytransform->_pathtest) { p_ptraverse myptraverse=bar(dot,mytransform->_pathtest); if(mytransform->_callback==(void*)Xassert) mypassed=!myptraverse->_admst; else { p_admst myadmst0; mypassed=(myptraverse->_admst&&(myadmst0=aread((p_admst)myptraverse->_admst->data))&&(myadmst0->_pseudo!=admse_empty)); } free_ptraverse(myptraverse); } if(mypassed) ((p_transform_evaluate)mytransform->_callback)(mytransform,dot); if(break_found==1) break; } } static void root00 (p_ptraverse p,p_path mypath,p_admst dot) { p_admst d=adms_admst_newpa(dot,dot,(p_adms)root());".&ALLLASTPOS("d")." } void location03 (void) {} /*[nepasimprimer]*/ static void adms_fatal_on_obsolete_syntax(p_transform mytransform,p_admst myadmst) { if(myadmst&& ((myadmst->_pseudo==admse_datatypename) ||(myadmst->_pseudo==admse_empty) ||(myadmst->_pseudo==admse_basicenumeration) ||(myadmst->_pseudo==admse_basicinteger) ||(myadmst->_pseudo==admse_basicreal) ||(myadmst->_pseudo==admse_basicstring))) return; if(myadmst&&(myadmst->_pseudo==admse_expression)) { adms_message_warning_continue((\"[removed feature] admst:value-of 'expression'\\n\")) adms_message_warning_continue((\"[removed feature] Please use admst:apply-templates\\n\")) adms_message_warning_continue((\"[removed feature] see: %s\\n\",adms_transform_uid(mytransform))) adms_message_warning((\"[removed feature] For help contact me at r29173\@users.sourceforge.net\\n\")) } else if(myadmst->_pseudo==admse__arguments) { adms_message_warning_continue((\"[removed feature] admst:value-of 'arguments'\\n\")) adms_message_warning_continue((\"[removed feature] Please use admst:apply-templates\\n\")) adms_message_warning_continue((\"[removed feature] see: %s\\n\",adms_transform_uid(mytransform))) adms_message_warning((\"[removed feature] For help contact me at r29173\@users.sourceforge.net\\n\")) } } p_admst adms_pull_admst (p_transform mytransform) { if(root()->_valueof) { adms_slist_pull(&root()->_valueof); /*pull transform*/ return (p_admst)adms_slist_pull(&root()->_valueof); } adms_message_fatal_continue((\"stack '%%s' has no more element!\\n\")) adms_message_fatal((\"see %s\",adms_transform_uid(mytransform))) return NULL; } p_admstvariable lookup_dollar (const char* myid) { p_itransform myitransform=root()->_itransform?(p_itransform)root()->_itransform->data:NULL; p_slist list; if(myitransform) { list=myitransform->_variable; while(list) { if(!strcmp(((p_admstvariable)list->data)->_name,myid)) return (p_admstvariable)list->data; list=list->next; } } list=root()->_variable; while(list) { if(!strcmp(((p_admstvariable)list->data)->_name,myid)) return (p_admstvariable)list->data; list=list->next; } return NULL; } char* tsprintf (p_kadmst myadmst, p_ktext mytext) { char* myvalue=myadmst?adms_kclone(\"\"):((p_admst)mytext->_token->data)->_item.s; p_slist myl; for(myl=((myadmst&&mytext)?mytext->_token:NULL);myl;myl=myl->next) { p_adms token=myl->data; if(token->_datatypename==admse_text) { if(((p_text)token)->_admse==admse__s) { p_admst mystack=adms_pull_admst(mytext->_transform); if(mystack) { char* mynewvalue=aprintf(mytext->_transform,mystack); if(mynewvalue) { adms_fatal_on_obsolete_syntax(mytext->_transform,mystack); adms_k2strconcat(&myvalue,mynewvalue); free(mynewvalue); } deref(mystack); } } else { char* dollarname=tsprintf(myadmst,(p_text)token); p_admstvariable dollar=lookup_dollar(dollarname); if(dollar) { p_slist myl2=dollar->_value; for(;myl2;myl2=myl2->next) { char* val=aprintf(mytext->_transform,(p_admst)myl2->data); if(val) { adms_k2strconcat(&myvalue,val); free(val); } } } else { adms_message_obsolete_continue((\"variable \$(%s) is undefined\\n\",dollarname)) adms_message_obsolete((\"Check if you really wanted to access an variable. If not replace '\$' by '\$'\\n\")) adms_message_obsolete((\"see %s\\n\",adms_transform_uid(mytext->_transform))) adms_k2strconcat(&myvalue,\"\$\"); adms_k2strconcat(&myvalue,dollarname); } free(dollarname); } } else if(token->_datatypename==admse_admst) adms_k2strconcat(&myvalue,((p_admst)token)->_item.s); else if(token->_datatypename==admse_path) { p_ptraverse myptraverse=bar(myadmst,(p_path)token); p_slist myl; for(myl=myptraverse->_admst;myl;myl=myl->next) { char* mynewvalue=aprintf(((p_path)token)->_transform,(p_admst)myl->data); if(mynewvalue) adms_k2strconcat(&myvalue,mynewvalue); free(mynewvalue); } free_ptraverse(myptraverse); } } return myvalue; } void tprintf (p_kadmst myadmst, p_ktext mytext) { p_slist myl; for(myl=mytext->_token;myl;myl=myl->next) { p_adms token=myl->data; if(token->_datatypename==admse_text) { if(((p_text)token)->_admse==admse__s) { p_admst mystack=adms_pull_admst(mytext->_transform); if(mystack) { char* mynewvalue=aprintf(mytext->_transform,mystack); if(mynewvalue) { adms_fatal_on_obsolete_syntax(mytext->_transform,mystack); fputs(mynewvalue,OUT()); free(mynewvalue); } deref(mystack); } } else { char* dollarname=tsprintf(myadmst,(p_text)token); p_admstvariable dollar=lookup_dollar(dollarname); if(dollar) { p_slist myl2=dollar->_value; for(;myl2;myl2=myl2->next) { char* val=aprintf(mytext->_transform,(p_admst)myl2->data); if(val) { fputs(val,OUT()); free(val); } } } else { adms_message_obsolete_continue((\"variable \$(%s) is undefined\\n\",dollarname)) adms_message_obsolete((\"Check if you really wanted to access an variable. If not replace '\$' by '\$'\\n\")) adms_message_obsolete((\"see %s\\n\",adms_transform_uid(mytext->_transform))) fputs(\"\$\",OUT()); fputs(dollarname,OUT()); } free(dollarname); } } else if(token->_datatypename==admse_admst) fputs(((p_admst)token)->_item.s,OUT()); else if(token->_datatypename==admse_path) { p_ptraverse myptraverse=bar(myadmst,(p_path)token); p_slist myl; for(myl=myptraverse->_admst;myl;myl=myl->next) { char* mynewvalue=aprintf(((p_path)token)->_transform,(p_admst)myl->data); if(mynewvalue) fputs(mynewvalue,OUT()); free(mynewvalue); } free_ptraverse(myptraverse); } } } static void location26 (p_ptraverse p,p_path mypath,p_admst dot) { tprintf(dot,mypath->_text); } static int retdatatypename(p_admst myadmst) { if( (myadmst->_pseudo==admse_empty) || (myadmst->_pseudo==admse_basicenumeration) || (myadmst->_pseudo==admse_basicinteger) || (myadmst->_pseudo==admse_basicreal) || (myadmst->_pseudo==admse_basicstring) || (myadmst->_pseudo==admse__ladms) || (myadmst->_pseudo==admse__ladmst) || (myadmst->_pseudo==admse_datatypename) ) return myadmst->_pseudo; else if(myadmst->_pseudo==admse__croix) return ((p_attribute)myadmst->_item.p)->_value?((p_admst)((p_attribute)myadmst->_item.p)->_value)->_pseudo:admse_empty; else return myadmst->_item.p->_datatypename; } static p_attribute retcroixcroix (p_admst myadmst,p_path mypath) { char*myname=tsprintf(myadmst,mypath->_text); p_attribute myattribute=adms_attribute_new(myname); free(myname); return myattribute; } static p_attribute retcroix (p_admst myadmst,p_path mypath) { p_attribute myattribute=NULL; char*myname=tsprintf(myadmst,mypath->_text); p_slist list; p_adms item=myadmst->_item.p; if( (myadmst->_pseudo==admse_basicenumeration) || (myadmst->_pseudo==admse_basicinteger) || (myadmst->_pseudo==admse_basicreal) || (myadmst->_pseudo==admse_basicstring) || (myadmst->_pseudo==admse_datatypename) ) { adms_message_fatal_continue((\"operator '#' applied to element '%s' - not supported!\\n\",ns_etostr(myadmst->_pseudo))) adms_message_fatal((\"see %s\\n\",adms_transform_uid(mypath->_transform))) } list=item?item->_attribute:NULL; for(;list&&!myattribute;list=list->next) if(!strcmp(((p_attribute)list->data)->_name,myname)) myattribute=(p_attribute)list->data; if(!myattribute) { myattribute=adms_attribute_new(myname); adms_slist_push(&item->_attribute,(p_adms)myattribute); } free(myname); return myattribute; } static p_slist retcroixstar (p_admst myadmst) { return myadmst->_item.p?myadmst->_item.p->_attribute:NULL; } static int adms_slist_compare (p_admst myadmst0,p_admst myadmst1) { admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_empty)&&(mytype1==admse_empty)) return 0; else if(mytype0==admse_empty) return -1; else if(mytype1==admse_empty) return +1; else if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) return (myadmst0->_item.i-myadmst1->_item.i); else { char* uid1=aprintf(NULL,myadmst0); char* uid2=aprintf(NULL,myadmst1); int res=strcmp(uid1,uid2); free(uid1); free(uid2); return res; } } static p_slist adms_slist_sort_merge (p_slist myl0, p_slist myl1) { t_slist list; p_slist myli=&list; while(myl0&&myl1) { if(adms_slist_compare((p_admst)myl0->data,(p_admst)myl1->data)<0) { myli=myli->next=myl0; myl0=myl0->next; } else { myli=myli->next=myl1; myl1=myl1->next; } } myli->next=myl0?myl0:myl1; return list.next; } static p_slist adms_slist_sort (p_slist list) { p_slist myl0, myl1; if(!list) return NULL; if(!list->next) return list; myl0=list; myl1=list->next; while((myl1=myl1->next)!=NULL) { if((myl1=myl1->next)==NULL) break; myl0=myl0->next; } myl1=myl0->next; myl0->next=NULL; return adms_slist_sort_merge(adms_slist_sort(list),adms_slist_sort(myl1)); } "; sub L0 { my($desc,$id,$ddata)=(shift,shift,shift); return "/*$desc*/ static void location$id (p_ptraverse p,p_path mypath,p_admst dot) { $ddata }\n"; } #print admstpathYacc_y &L0("returned",15,")); print admstpathYacc_y "/*returned*/\nstatic void location15 (p_ptraverse p,p_path mypath,p_admst dot) { p_slist l; p_admst d=NULL; char* myname=tsprintf(dot,mypath->_text); p_itransform myitransform; if(!root()->_itransforminsideapplytemplate) { adms_message_fatal_continue((\"return('%s') allowed only inside admst:apply-templates\\n\",myname)) adms_message_fatal((\"see %s\\n\",adms_transform_uid(mypath->_transform))) } myitransform=(p_itransform)root()->_itransforminsideapplytemplate->data; for(l=myitransform->_return;l&&!d;l=l->next) if(!strcmp(((p_return)((p_admst)l->data)->_item.p)->_name,myname)) d=(p_admst)l->data; if(d==NULL) { adms_message_fatal_continue((\"returned('%s'): undefined returned value\\n\",myname)) adms_message_fatal((\"see %s\\n\",adms_transform_uid(mypath->_transform))) } free(myname); if(d->_refd) d->_refd++;".&ALLLASTPOS("d")." } "; print admstpathYacc_y "/*\"\%p\"*/\nstatic void location200 (p_ptraverse p,p_path mypath,p_admst dot) { p_admst d=adms_pull_admst(mypath->_transform);".&ALLLASTPOS("d")." } "; print admstpathYacc_y "/*'k'*/\nstatic void location09k (p_ptraverse p,p_path mypath,p_admst dot) { ((p_admst)mypath->_text->_token->data)->_previouspath=dot; ".&ALLLASTPOS("((p_admst)mypath->_text->_token->data)")." } "; print admstpathYacc_y "/*int*/\nstatic void location10 (p_ptraverse p,p_path mypath,p_admst dot) { ((p_admst)mypath->_text->_token->data)->_previouspath=dot; ".&ALLLASTPOS("((p_admst)mypath->_text->_token->data)")." } "; sub L1 { my($desc,$id,$type,$rhs)=@_; return "/*$desc*/ static void location$id (p_ptraverse p,p_path mypath,p_admst dot) { p_admst d=adms_admst_new$type(dot,dot,$rhs);".&ALLLASTPOS("d")." }\n"; } print admstpathYacc_y " static p_admstvariable retaroba (p_admst myadmst,p_path mypath) { char* myid=tsprintf(myadmst,mypath->_text); p_admstvariable mydollar; p_slist list; p_adms item=myadmst->_item.p; list=item->_variable; while(list) { if(!strcmp(((p_admstvariable)list->data)->_name,myid)) { free(myid); return (p_admstvariable)list->data; } list=list->next; } mydollar=adms_admstvariable_new(myid); adms_slist_push(&item->_variable,(p_adms)mydollar); free(myid); return mydollar; } static p_admstvariable retdollar (p_admst myadmst,p_path mypath) { char* id=tsprintf(aread(myadmst),mypath->_text); p_admstvariable dollar=lookup_dollar(id); if(!dollar) adms_message_fatal((\"variable \$(%s) is undefined! see %s\\n\",id,adms_transform_uid(mypath->_transform))) free(id); return dollar; } static int retcount (p_admst myadmst,p_path mypath) { p_ptraverse p0=bar(myadmst,(p_path)mypath->_u->data); int count=p0->_admst?((p_admst)p0->_admst->data)->_count:0; free_ptraverse(p0); return count; }\n"; print admstpathYacc_y &L1("datatypename","03datatypename","bd","retdatatypename(dot)"); print admstpathYacc_y &L1("ident","03dummy","bi","0"); print admstpathYacc_y &L1("real","07","br","adms_strtod(mypath->_transform,tsprintf(NULL,mypath->_text))"); print admstpathYacc_y &L1("position",18,"bi","(dot)->_position"); print admstpathYacc_y &L1("count",27,"bi","retcount(dot,mypath)"); print admstpathYacc_y &L1("''","09","ns","tsprintf(dot,mypath->_text)"); print admstpathYacc_y &L1("##",12,"pa","(p_adms)retcroixcroix(dot,mypath)"); print admstpathYacc_y &L1("#",13,"pc","retcroix(dot,mypath)"); print admstpathYacc_y &L1("admst",14,"pa","(p_adms)dot"); print admstpathYacc_y &L1("\$var","041","pd","retdollar(dot,mypath)"); print admstpathYacc_y &L1("\@var","051","pd","retaroba(dot,mypath)"); print admstpathYacc_y "/*index*/ static int retindex (p_slist mylii,p_ptraverse p0) { p_admst myadmst1=(p_admst)mylii->data; p_adms myadms1=myadmst1->_item.p; admse mytype1=myadmst1->_pseudo; p_cmp mycmp=adms_admsxml_cmp(myadmst1); p_slist myl0; int myindex=-1; int found=0; for(myl0=p0->_admst;myl0&&!found;myl0=myl0->next) { p_admst myadmst0=(p_admst)myl0->data; p_adms myadms0=myadmst0->_item.p; admse mytype0=myadmst0->_pseudo; found=(mytype0==mytype1)&&(!mycmp(myadms0,myadms1)); myindex++; } if(found) return myindex; else return minusone; } static void location19 (p_ptraverse p,p_path mypath,p_admst dot) { p_ptraverse p0=bar(dot,(p_path)mypath->_u->data); p_ptraverse p1=bar(dot,(p_path)mypath->_u->next->data); p_slist l1=p1->_admst; for(;l1;l1=l1->next) { p_admst d=adms_admst_newbi(dot,dot,retindex(l1,p0));".&ALLLASTPOS("d")." } free_ptraverse(p0); free_ptraverse(p1); }\n"; sub L2 { my($desc,$id,$type,$rhs)=@_; return "/*$desc*/ static void location$id (p_ptraverse p,p_path mypath,p_admst dot) { p_ptraverse p0=bar(dot,(p_path)mypath->_u->data); p_slist l0=p0->_admst; for(;l0;l0=l0->next) { p_admst d=adms_admst_new$type(dot,dot,$rhs);".&ALLLASTPOS("d")." } free_ptraverse(p0); }\n"; } print admstpathYacc_y " static char* retaprintf (p_path mypath,p_slist myl0) { return aprintf(mypath->_transform,(p_admst)myl0->data); } static char* retpointer (p_slist myl0) { char* mystring=malloc(sizeof(char)*50); sprintf(mystring,\"%p\",((p_admst)myl0->data)->_item.p); return mystring; } static char* retuc (p_path mypath,p_slist myl0) { char* mystring=aprintf(mypath->_transform,(p_admst)myl0->data); adms_toupper(mystring); return mystring; } static char* retlc (p_path mypath,p_slist myl0) { char* mystring=aprintf(mypath->_transform,(p_admst)myl0->data); adms_tolower(mystring); return mystring; }\n"; print admstpathYacc_y &L2("uid",20,"ns","retaprintf(mypath,l0)"); print admstpathYacc_y &L2("id ",21,"ns","retpointer(l0)"); print admstpathYacc_y &L2("uc",24,"ns","retuc(mypath,l0)"); print admstpathYacc_y &L2("lc",25,"ns","retlc(mypath,l0)"); sub L3 { my($desc,$id,$func,$type,$rhs)=@_; return "/*$desc*/ static void location$id (p_ptraverse p,p_path mypath,p_admst dot) { p_ptraverse p0=bar(dot,(p_path)mypath->_u->data); p_slist lii=$func(p0->_admst); p0->_admst=lii; for(;lii;lii=lii->next) { p_admst d=adms_admst_new$type(dot,dot,$rhs);".&ALLLASTPOS("d")." } free_ptraverse(p0); }\n"; } print admstpathYacc_y &L3("sort",22,"adms_slist_sort","pn","(p_admst)lii->data"); print admstpathYacc_y &L3("reverse",23,"adms_slist_reverse","pn","(p_admst)lii->data"); sub L4 { my($desc,$id,$dii,$type,$rhs)=@_; return "/*$desc*/ static void location$id (p_ptraverse p,p_path mypath,p_admst dot) { p_slist lii=$dii; for(;lii;lii=lii->next) { p_admst d=adms_admst_new$type(dot,dot,$rhs);".&ALLLASTPOS("d")." } }\n"; } print admstpathYacc_y &L4("#*",130,"retcroixstar(dot)?retcroixstar(dot):NULL","pc","(p_attribute)lii->data"); print admstpathYacc_y &L4("\$var","040","retdollar(dot,mypath)->_value","pn","(p_admst)lii->data"); print admstpathYacc_y &L4("\@var","050","retaroba(dot,mypath)->_value","pn","(p_admst)lii->data"); print admstpathYacc_y " static void attributecallback (p_path mypath0,p_slist npaths,p_slist npath) { p_path mypath=(p_path)npath->data; mypath->_keeplist=(mypath0->_keeplist&&(npath->next==NULL)&&(mypath->_c==NULL))||mypath->_keeplist; if(mypath->_callback==(void*)location04) { mypath->_callback=(mypath->_keeplist)?(void*)location041:(void*)location040; mypath->_callbackname=(mypath->_keeplist)?\"location041\":\"location040\"; } else if(mypath->_callback==(void*)location05) { mypath->_callback=(mypath->_keeplist)?(void*)location051:(void*)location050; mypath->_callbackname=(mypath->_keeplist)?\"location051\":\"location050\"; } else if(mypath->_callback==(void*)location03) { if(0) {}\n"; foreach (@Locationalias03) { print admstpathYacc_y " else if(mypath->_text->_admse==admse_$_)\n"; print admstpathYacc_y " {\n"; if($_ eq "datatypename") { print admstpathYacc_y " mypath->_callback=(void*)location03datatypename;\n"; print admstpathYacc_y " mypath->_callbackname=\"location03datatypename.$_\";\n"; } else { print admstpathYacc_y " mypath->_callback=(mypath->_keeplist)?(void*)location031$_:(void*)location030$_;\n"; print admstpathYacc_y " mypath->_callbackname=(mypath->_keeplist)?\"location031$_\":\"location030$_\";\n"; } print admstpathYacc_y " }\n"; } print admstpathYacc_y ' else { adms_message_fatal_continue(("element or attribute \'%s\' does not exist\\n",mypath->_text->_value)) adms_message_fatal(("see %s\\n",adms_transform_uid(mypath->_transform))) } } } static void postpath (p_path mypath) { p_slist l; if(mypath->_callback==(void*)location02) { const char* match=((p_admst)mypath->_text->_token->data)->_item.s; if(!(mypath->_template=lookfortemplates(mypath->_transform,match))) { adms_message_fatal_continue(("Template not found: %s\\n",match)) adms_message_fatal((" see: %s\\n",adms_transform_uid(mypath->_transform))) } } for(l=mypath->_bar;l;l=l->next) { p_slist paths=(p_slist)l->data; for(;paths;paths=paths->next) { postpath((p_path)paths->data); attributecallback(mypath,l,paths); } } for(l=mypath->_arg;l;l=l->next) { p_slist paths=(p_slist)l->data; for(;paths;paths=paths->next) { postpath((p_path)paths->data); attributecallback(mypath,l,paths); } } for(l=mypath->_u;l;l=l->next) postpath((p_path)l->data); for(l=mypath->_b;l;l=l->next) postpath((p_path)l->data); for(l=mypath->_c;l;l=l->next) postpath((p_path)l->data); if(mypath->_text) posttext(mypath->_text); } '; print admstpathYacc_y " static void location00 (p_ptraverse p,p_path mypath,p_admst dot) { p_admst d=adms_admst_newpn(dot->_previous,dot->_previouspath,dot); d->_position=dot->_position; d->_count=dot->_count; ".&fixme("d")."; } static void location01 (p_ptraverse p,p_path mypath,p_admst dot) { p_admst d=adms_admst_newpn(dot->_previouspath->_previous,dot->_previouspath->_previouspath,dot->_previouspath); d->_position=dot->_previouspath->_position; d->_count=dot->_previouspath->_count; ".&fixme("d")."; } typedef p_slist (*_p_cblocation) (p_ptraverse p,p_path mypath,p_admst dot); typedef int (*_p_cbcondition) (const p_path mypath,p_admst myadmst); "; print admstpathYacc_y " void free_ptraverse (p_ptraverse p) { p_slist l; p_slist ll; for(l=p->_alladmst;l;l=l->next) for(ll=(p_slist)l->data;ll;ll=ll->next) deref((p_admst)ll->data); for(l=p->_aliasadmst;l;l=l->next) deref((p_admst)l->data); for(l=p->_admst;l;l=l->next) deref((p_admst)l->data); adms_slist_free(p->_alladmst); adms_slist_free(p->_aliasadmst); adms_slist_free(p->_admst); free(p); } static p_slist slash (p_ptraverse p,p_slist paths,p_admst dot) { p_slist output=NULL; int premier=1; adms_slist_push(&output,(p_adms)dot); for(;paths;paths=paths->next) { p_slist l; p_path mypath=(p_path)paths->data; p_slist output1=NULL; int dernier=(paths->next==NULL); if(mypath->_callback==(void*)groupage) { int count=0; for(l=output;l;l=l->next) if((((p_admst)l->data)->_selected==admse_yes)&&((p_admst)l->data)->_pseudo!=admse_empty) { p_ptraverse p0=bar((p_admst)l->data,mypath); adms_slist_concat(&output1,p0->_admst); adms_slist_free(p0->_alladmst); free(p0); } for(l=output1;l;l=l->next) ((p_admst)l->data)->_position=++count; p->_position=count; } else { p_admst ai; p->_position=0; p->_a1=p->_an=NULL; for(l=output;l;l=l->next) if((((p_admst)l->data)->_selected==admse_yes)&&((p_admst)l->data)->_pseudo!=admse_empty) ((_p_cblocation)mypath->_callback)(p,mypath,(p_admst)l->data); for(ai=p->_an;ai;ai=ai->_preva) adms_slist_push(&output1,(p_adms)ai); } if(premier) adms_slist_free(output),premier=0; if(!dernier) adms_slist_push(&p->_alladmst,(p_adms)output1); if((mypath->_callback!=(void*)location00)&&(mypath->_callback!=(void*)location01)) for(l=output1;l;l=l->next) ((p_admst)l->data)->_count=p->_position; if(mypath->_c) { int count=0; for(l=output1;l;l=l->next) if(((_p_cbcondition)((p_path)mypath->_c->data)->_callback)((p_path)mypath->_c->data,(p_admst)l->data)) { count++; if((mypath->_callback!=(void*)location00)&&(mypath->_callback!=(void*)location01)) ((p_admst)l->data)->_position=count; } else ((p_admst)l->data)->_selected=admse_no; if((mypath->_callback!=(void*)location00)&&(mypath->_callback!=(void*)location01)) for(l=output1;l;l=l->next) ((p_admst)l->data)->_count=count; if(dernier) { p_slist l=output1; p_slist n; p_slist lastnode=NULL; output1=NULL; for(;l;l=n) if(((p_admst)l->data)->_selected==admse_yes) { if(lastnode) lastnode->next=l,lastnode=l; else output1=lastnode=l; n=l->next; } else n=l->next,deref((p_admst)l->data),free(l); if(lastnode) lastnode->next=NULL; } } output=output1; } return output; } p_ptraverse bar (p_admst dot,p_path mypath) { p_ptraverse p=adms_ptraverse_new(mypath->_transform); p_slist bars; p_slist output=NULL; for(bars=mypath->_bar;bars;bars=bars->next) adms_slist_concat(&output,slash(p,(p_slist)bars->data,dot)); p->_admst=output; return p; } static void addptraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_slist paths1=(p_slist)mypath->_arg->next->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); p_ptraverse p1=adms_ptraverse_new(mypath->_transform); p_slist o1=slash(p1,paths1,dot); for(;o0&&o1;o0=o0->next,o1=o1->next) { p_admst myadmst0=(p_admst)o0->data; p_admst myadmst1=(p_admst)o1->data; admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) { ".&LLNN("bi","myadmst0->_item.i+myadmst1->_item.i")." } else if((mytype0==admse_basicreal)&&(mytype1==admse_basicreal)) { ".&LLNN("br","myadmst0->_item.r+myadmst1->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)+strtod(aprintf(mypath->_transform,myadmst1),NULL)")." } } for(o0=o1?o1:o0;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { ".&LLNN("bi","myadmst0->_item.i")." } else if(mytype0==admse_basicreal) { ".&LLNN("br","myadmst0->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)")." } } } static void addmtraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_slist paths1=(p_slist)mypath->_arg->next->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); p_ptraverse p1=adms_ptraverse_new(mypath->_transform); p_slist o1=slash(p1,paths1,dot); for(;o0&&o1;o0=o0->next,o1=o1->next) { p_admst myadmst0=(p_admst)o0->data; p_admst myadmst1=(p_admst)o1->data; admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) { ".&LLNN("bi","myadmst0->_item.i-myadmst1->_item.i")." } else if((mytype0==admse_basicreal)&&(mytype1==admse_basicreal)) { ".&LLNN("br","myadmst0->_item.r-myadmst1->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)-strtod(aprintf(mypath->_transform,myadmst1),NULL)")." } } for(;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { ".&LLNN("bi","myadmst0->_item.i")." } else if(mytype0==admse_basicreal) { ".&LLNN("br","myadmst0->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)")." } } for(;o1;o1=o1->next) { p_admst myadmst1=(p_admst)o1->data; admse mytype1=myadmst1->_pseudo; if(mytype1==admse_basicinteger) { ".&LLNN("bi","-myadmst1->_item.i")." } else if(mytype1==admse_basicreal) { ".&LLNN("br","-myadmst1->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","-1*strtod(aprintf(mypath->_transform,myadmst1),NULL)")." } } } static void multtimetraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_slist paths1=(p_slist)mypath->_arg->next->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); p_ptraverse p1=adms_ptraverse_new(mypath->_transform); p_slist o1=slash(p1,paths1,dot); for(;o0&&o1;o0=o0->next,o1=o1->next) { p_admst myadmst0=(p_admst)o0->data; p_admst myadmst1=(p_admst)o1->data; admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) { ".&LLNN("bi","myadmst0->_item.i*myadmst1->_item.i")." } else if((mytype0==admse_basicreal)&&(mytype1==admse_basicreal)) { ".&LLNN("br","myadmst0->_item.r*myadmst1->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)*strtod(aprintf(mypath->_transform,myadmst1),NULL)")." } } for(o0=o1?o1:o0;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { ".&LLNN("bi","myadmst0->_item.i")." } else if(mytype0==admse_basicreal) { ".&LLNN("br","myadmst0->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)")." } } } static void multdivtraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_slist paths1=(p_slist)mypath->_arg->next->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); p_ptraverse p1=adms_ptraverse_new(mypath->_transform); p_slist o1=slash(p1,paths1,dot); for(;o0&&o1;o0=o0->next,o1=o1->next) { p_admst myadmst0=(p_admst)o0->data; p_admst myadmst1=(p_admst)o1->data; admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) { ".&LLNN("br","(double)myadmst0->_item.i/(double)myadmst1->_item.i")." } else if((mytype0==admse_basicreal)&&(mytype1==admse_basicreal)) { ".&LLNN("br","myadmst0->_item.r/myadmst1->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","(strtod(aprintf(mypath->_transform,myadmst0),NULL)/strtod(aprintf(mypath->_transform,myadmst1),NULL))")." } } for(;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { ".&LLNN("br","(double)myadmst0->_item.i/1.0")." } else if(mytype0==admse_basicreal) { ".&LLNN("br","myadmst0->_item.r/1.0")." } else { // Convert the string representation to a number ".&LLNN("br","strtod(aprintf(mypath->_transform,myadmst0),NULL)/1.0")." } } for(;o1;o1=o1->next) { p_admst myadmst1=(p_admst)o1->data; admse mytype1=myadmst1->_pseudo; if(mytype1==admse_basicinteger) { ".&LLNN("br","1.0/(double)myadmst1->_item.i")." } else if(mytype1==admse_basicreal) { ".&LLNN("br","1.0/myadmst1->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","1.0/strtod(aprintf(mypath->_transform,myadmst1),NULL)")." } } } static void unaryptraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); for(;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { ".&LLNN("bi","+myadmst0->_item.i")." } else if(mytype0==admse_basicreal) { ".&LLNN("br","+myadmst0->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","+strtod(aprintf(mypath->_transform,myadmst0),NULL)")." } } } static void unarymtraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); for(;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { ".&LLNN("bi","-myadmst0->_item.i")." } else if(mytype0==admse_basicreal) { ".&LLNN("br","-myadmst0->_item.r")." } else { // Convert the string representation to a number ".&LLNN("br","-strtod(aprintf(mypath->_transform,myadmst0),NULL)")." } } } static void incrptraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); for(;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basiclist) { p_slist dollarlist=((p_admstvariable)myadmst0->_item.p)->_value; for(;dollarlist;dollarlist=dollarlist->next) { p_admst myadmst1=(p_admst)dollarlist->data; admse mytype1=myadmst1->_pseudo; if(mytype1==admse_basicinteger) { ".&LLNN("bi","myadmst1->_item.i")." myadmst1->_item.i+=1; } else if(mytype1==admse_basicreal) { ".&LLNN("br","myadmst1->_item.r")." myadmst1->_item.r+=1.0; } else adms_message_fatal((\"%s: '++' operator - case not implemented - sorry!\\n\",adms_transform_uid(mypath->_transform))) } } } } static void incrmtraverse (p_ptraverse p,p_path mypath,p_admst dot) { p_slist paths0=(p_slist)mypath->_arg->data; p_ptraverse p0=adms_ptraverse_new(mypath->_transform); p_slist o0=slash(p0,paths0,dot); for(;o0;o0=o0->next) { p_admst myadmst0=(p_admst)o0->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basiclist) { p_slist dollarlist=((p_admstvariable)myadmst0->_item.p)->_value; for(;dollarlist;dollarlist=dollarlist->next) { p_admst myadmst1=(p_admst)dollarlist->data; admse mytype1=myadmst1->_pseudo; if(mytype1==admse_basicinteger) { ".&LLNN("bi","myadmst1->_item.i")." myadmst1->_item.i-=1; } else if(mytype1==admse_basicreal) { ".&LLNN("br","myadmst1->_item.r")." myadmst1->_item.r-=1.0; } else adms_message_fatal((\"%s: '--' operator - case not implemented - sorry!\\n\",adms_transform_uid(mypath->_transform))) } } } } static int expression01 (const p_path mypath,p_admst dot) { p_ptraverse p0=bar(dot,(p_path)mypath->_u->data); int pos=dot->_position; p_slist l; for(l=p0->_admst;l;l=l->next) { p_admst myadmst0=(p_admst)l->data; admse mytype0=myadmst0->_pseudo; if(mytype0==admse_basicinteger) { if(pos==myadmst0->_item.i) { free_ptraverse(p0); return 1; } } else adms_message_fatal((\"%s: 'integer' expected!\\n\",adms_transform_uid(mypath->_transform))) } free_ptraverse(p0); return 0; } #define admstpatherror(mypparse,msgid) admstpatherrorimpl(mypparse,msgid) #define ISPATH ((int)(long)globalctxt->data==0) #define ISTEXT ((int)(long)globalctxt->data==1) #define ISTIC ((int)(long)globalctxt->data==2) #define SETPATH adms_slist_push(&globalctxt,(p_adms)0); #define SETTEXT adms_slist_push(&globalctxt,(p_adms)1); #define SETTIC adms_slist_push(&globalctxt,(p_adms)2); #define PARENMATCH (parenidx&&paren==(int)(long)parenidx->data) #define INSIDEPATH (globalctxt&&(globalctxt->next)&&(((int)(long)globalctxt->next->data)==0)) static p_slist globalctxt=NULL; static int goto_atext=0; static int paren=0; static p_slist parenidx=NULL; static int globalignorequote=0; static p_path BASICSTRING (const p_pparse mypparse,char *mytvalue) { p_path ret=adms_path_new(mypparse->_transform,adms_text_new(mypparse->_transform,mytvalue)); adms_slist_push(&(ret->_text->_token),(p_adms)adms_admst_newks(mytvalue)); ret->_text->_admse=ns_strtoe(((p_admst)ret->_text->_token->data)->_item.s); ret->_aname=adms_kclone(mytvalue); return ret; } static p_path BASICINTEGER (const p_pparse mypparse,char *mytvalue) { p_path ret=adms_path_new(mypparse->_transform,adms_text_new(mypparse->_transform,mytvalue)); adms_slist_push(&(ret->_text->_token),(p_adms)adms_admst_newbi(NULL,NULL,adms_strtol(mypparse->_transform,mytvalue))); ((p_admst)ret->_text->_token->data)->_refd=0; ret->_text->_admse=admse__any; ret->_aname=adms_kclone(mytvalue); return ret; } int is_admst (const char* name) { return (((strlen(name)==5)&&!strncmp(name,\"admst\",5))||((strlen(name)>5)&&!strncmp(name,\"admst:\",6))); } void dbtext (p_text mytext) { p_slist li; if(mytext->_aname) adms_message_admstdbg_impl(\"\",mytext->_aname,mytext->_value,ns_etostr(mytext->_admse)); else adms_message_admstdbg_impl(\"\",mytext->_value,ns_etostr(mytext->_admse)); for(li=mytext->_token;li;li=li->next) { p_adms mytoken=li->data; if(mytoken->_datatypename==admse_text && ((p_text)mytoken)->_admse==admse__s) adms_message_admstdbg_impl(\"\\n\",ns_etostr(((p_text)mytoken)->_admse)); else if(mytoken->_datatypename==admse_text) dbtext((p_text)mytoken); else if(mytoken->_datatypename==admse_admst) { adms_message_admstdbg_impl(\"\",ns_etostr(((p_admst)mytoken)->_pseudo)); adms_message_admstdbg_impl(\"\%s\",aprintf(mytext->_transform,(p_admst)mytoken)); adms_message_admstdbg_impl(\"\\n\"); } else if(mytoken->_datatypename==admse_path) { adms_message_admstdbg_impl(\"\"); dbpath((p_path)mytoken); adms_message_admstdbg_impl(\"\"); } } if(mytext->_aname) adms_message_admstdbg_impl(\"\\n\",mytext->_aname); else adms_message_admstdbg_impl(\"\\n\"); } void dbpath (p_path mypath) { if(mypath->_text||mypath->_bar||mypath->_arg||mypath->_u||mypath->_b||mypath->_c) { adms_message_admstdbg_impl(\"<\%s keeplist=\\\"%i\\\">\",mypath->_callbackname,mypath->_keeplist); if(mypath->_bar) { p_slist bar; for(bar=mypath->_bar;bar;bar=bar->next) { p_slist l=(p_slist)bar->data; adms_message_admstdbg_impl(\"\"); for(;l;l=l->next) dbpath((p_path)l->data); adms_message_admstdbg_impl(\"\"); } } if(mypath->_arg) { p_slist arg; for(arg=mypath->_arg;arg;arg=arg->next) { p_slist l=(p_slist)arg->data; adms_message_admstdbg_impl(\"\"); for(;l;l=l->next) dbpath((p_path)l->data); adms_message_admstdbg_impl(\"\"); } } if(mypath->_u) { p_slist l; adms_message_admstdbg_impl(\"\"); for(l=mypath->_u;l;l=l->next) dbpath((p_path)l->data); adms_message_admstdbg_impl(\"\"); } if(mypath->_b) { p_slist l; adms_message_admstdbg_impl(\"\"); for(l=mypath->_b;l;l=l->next) dbpath((p_path)l->data); adms_message_admstdbg_impl(\"\"); } if(mypath->_c) { p_slist l; adms_message_admstdbg_impl(\"\"); for(l=mypath->_c;l;l=l->next) dbpath((p_path)l->data); adms_message_admstdbg_impl(\"\"); } if(mypath->_text) dbtext(mypath->_text); adms_message_admstdbg_impl(\"\",mypath->_callbackname); } else adms_message_admstdbg_impl(\"<\%s/>\",mypath->_callbackname); } static int binaryand (const p_path mypath,p_admst myadmst) { if(((_p_cbcondition)((p_path)mypath->_b->data)->_callback)((p_path)mypath->_b->data,myadmst)) return ((_p_cbcondition)((p_path)mypath->_b->next->data)->_callback)((p_path)mypath->_b->next->data,myadmst); return 0; } static int binaryor (const p_path mypath,p_admst myadmst) { if(!((_p_cbcondition)((p_path)mypath->_b->data)->_callback)((p_path)mypath->_b->data,myadmst)) return ((_p_cbcondition)((p_path)mypath->_b->next->data)->_callback)((p_path)mypath->_b->next->data,myadmst); return 1; } static int atomicnilled (const p_path mypath,p_admst myadmst) { p_admst myadmst0; p_ptraverse p0=bar(myadmst,(p_path)mypath->_u->data); int passed=(p0->_admst==NULL)||(p0->_admst->data==NULL)||((myadmst0=aread((p_admst)p0->_admst->data))==NULL)||(myadmst0->_item.p==NULL); free_ptraverse(p0); return passed; } static int atomicexists (const p_path mypath,p_admst myadmst) { return !atomicnilled(mypath,myadmst); }"; print admstpathYacc_y " static int atomicisdefault (const p_path mypath,p_admst myadmst) { "; foreach(@$EA) { my$e=&xname($_); foreach($_->findnodes("alias")) { my$alias=&xname($_); my$newe=&xelement($_); my$a=&xattribute($_); print admstpathYacc_y " if(myadmst->_pseudo==admse_$e && mypath->_text->_admse==admse_$alias) return ((p_$newe)(myadmst->_item.p))->_${a}_isdefault;\n"; } } #va elements + attributes foreach(@$EA) { my$e=xname($_); next if not vla($e); foreach(&attr($_)) { my$a=xname($_); print admstpathYacc_y " if(myadmst->_pseudo==admse_$e && mypath->_text->_admse==admse_$a) return ((p_$e)(myadmst->_item.p))->_${a}_isdefault;\n"; } } print admstpathYacc_y " return 0; } static int atomicgroupage (const p_path mypath,p_admst myadmst) { return ((_p_cbcondition)((p_path)mypath->_u->data)->_callback)(((p_path)mypath->_u->data),myadmst); } static int unary00 (const p_path mypath,p_admst myadmst) { return !((_p_cbcondition)((p_path)mypath->_u->data)->_callback)(((p_path)mypath->_u->data),myadmst); } static int atomictrue (const p_path mypath,p_admst myadmst) { return 1; } static int atomicfalse (const p_path mypath,p_admst myadmst) { return 0; } static int atomiceq (const p_path mypath,p_admst myadmst) { p_ptraverse p0; p_ptraverse p1; p_slist myl0; p_slist myl1; int passed=1; p_path root0=(p_path)mypath->_u->data; p_path root1=(p_path)mypath->_u->next->data; p_slist n000=(p_slist)root0->_bar->data; p_slist n01=root0->_bar->next; p_slist n001=n000->next; p_path l000=(p_path)n000->data; p_slist n100=(p_slist)root1->_bar->data; p_slist n11=root1->_bar->next; p_slist n101=n100->next; p_path l100=(p_path)n100->data; int isdatatypename0=(l000->_callback==(void*)location03datatypename)&&(n001==NULL)&&(n01==NULL); int isquotedstring1=((l100->_callback==(void*)location09)||(l100->_callback==(void*)location09k))&&(n11==NULL)&&(n101==NULL)&&(n11==NULL); if(isdatatypename0 && isquotedstring1) { p_admst myadmst0=aread(myadmst); if(myadmst0) return (retdatatypename(myadmst0)==l100->_text->_admse); else return (admse_empty==l100->_text->_admse); } p0=bar(myadmst,(p_path)mypath->_u->data); p1=bar(myadmst,(p_path)mypath->_u->next->data); myl0=p0->_admst; myl1=p1->_admst; if(adms_slist_length(myl0)!=adms_slist_length(myl1)) passed=0; for(;myl0&&passed;myl0=myl0->next,myl1=myl1->next) { p_admst myadmst0=aread((p_admst)myl0->data); p_admst myadmst1=aread((p_admst)myl1->data); if(!myadmst0) passed=0; else { admse admse0=myadmst0->_pseudo; admse admse1=myadmst1->_pseudo; if(admse0==admse_empty) {} else if(admse0==admse_datatypename) { char* mystring=aprintf(mypath->_transform,myadmst1); passed=(myadmst0->_item.i==ns_strtoe(mystring)); free(mystring); } else if((admse0==admse_basicinteger)&&(admse1==admse_basicstring)) { char *s=adms_integertostring(myadmst0->_item.i); passed=!strcmp(s,myadmst1->_item.s); free(s); } else if((admse0==admse_basicstring)&&(admse1==admse_basicinteger)) { char *s=adms_integertostring(myadmst1->_item.i); passed=!strcmp(myadmst0->_item.s,s); free(s); } else if((admse0==admse_basicenumeration)&&(admse1==admse_basicstring)) passed=!strcmp(ns_etostr(myadmst0->_item.i),myadmst1->_item.s); else if((admse0==admse_basicstring)&&(admse1==admse_basicenumeration)) passed=!strcmp(myadmst0->_item.s,ns_etostr(myadmst1->_item.i)); else if((admse0==admse_basicenumeration)&&(admse1==admse_basicinteger)) passed=(myadmst0->_item.i==myadmst1->_item.i); else if((admse0==admse_basicinteger)&&(admse1==admse_basicenumeration)) passed=(myadmst0->_item.i==myadmst1->_item.i); else if(admse0!=admse1) passed=0; else if(admse0==admse_basicenumeration) passed=(myadmst0->_item.i==myadmst1->_item.i); else if(admse0==admse_basicinteger) passed=(myadmst0->_item.i==myadmst1->_item.i); else if(admse0==admse_basicreal) passed=(myadmst0->_item.r>=myadmst1->_item.r-1.0e-307)&&(myadmst0->_item.r<=myadmst1->_item.r+1.0e-307); else if(admse0==admse_basicstring) passed=!strcmp(myadmst0->_item.s,myadmst1->_item.s); else passed=(myadmst0->_item.p==myadmst1->_item.p); } } free_ptraverse(p0); free_ptraverse(p1); return passed; } static int atomicne (const p_path mypath,p_admst myadmst) { return !atomiceq(mypath,myadmst); } static int atomiclt (const p_path mypath,p_admst myadmst) { p_ptraverse p0=bar(myadmst,(p_path)mypath->_u->data); p_ptraverse p1=bar(myadmst,(p_path)mypath->_u->next->data); p_slist myl0=p0->_admst; p_slist myl1=p1->_admst; int passed=1; if(adms_slist_length(myl0)!=adms_slist_length(myl1)) passed=0; else { for(;myl0&&passed;myl0=myl0->next,myl1=myl1->next) { p_admst myadmst0=(p_admst)myl0->data; p_admst myadmst1=(p_admst)myl1->data; admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) { int myinteger0=myadmst0->_item.i; int myinteger1=myadmst1->_item.i; passed=(myinteger0_item.r; double myreal1=myadmst1->_item.r; passed=(myreal0_transform,myadmst0),NULL); double myreal1=strtod(aprintf(mypath->_transform,myadmst1),NULL); passed=(myreal0_u->data); p_ptraverse p1=bar(myadmst,(p_path)mypath->_u->next->data); p_slist myl0=p0->_admst; p_slist myl1=p1->_admst; int passed=1; if(adms_slist_length(myl0)!=adms_slist_length(myl1)) passed=0; else { for(;myl0&&passed;myl0=myl0->next,myl1=myl1->next) { p_admst myadmst0=(p_admst)myl0->data; p_admst myadmst1=(p_admst)myl1->data; admse mytype0=myadmst0->_pseudo; admse mytype1=myadmst1->_pseudo; if((mytype0==admse_basicinteger)&&(mytype1==admse_basicinteger)) { int myinteger0=myadmst0->_item.i; int myinteger1=myadmst1->_item.i; passed=(myinteger0>myinteger1); } else if((mytype0==admse_basicreal)&&(mytype1==admse_basicreal)) { double myreal0=myadmst0->_item.r; double myreal1=myadmst1->_item.r; passed=(myreal0>myreal1); } else { // Convert the string representation to a number double myreal0=strtod(aprintf(mypath->_transform,myadmst0),NULL); double myreal1=strtod(aprintf(mypath->_transform,myadmst1),NULL); passed=(myreal0>myreal1); } } } free_ptraverse(p0); free_ptraverse(p1); return passed; } #if defined(STANDALONE) #define adms_transform_uid(txt) \"unknown\" #endif static void admstpatherrorimpl (const p_pparse mypparse,char const *s) { adms_message_fatal_continue((\"\%s - invalid path \\\"\%s\\\"\\n\",s,mypparse->_value)) adms_message_fatal((\"see \%s\\n\",adms_transform_uid(mypparse->_transform))) } "; #lexer print admstpathYacc_y " %} %token tktk_cr %token tktk_lf %token tktk_tab %token tktk_percent %token tktk_percents %token tktk_ticptr %token tktk_anytext %token tktk_goto_atext %token tktk_cquote "; map{map{print admstpathYacc_y "\%token "."tktk_".$_."\n";} split " ", xid($_);} $admstpathxml->findnodes("//constant|//regexp"); map{print admstpathYacc_y "\%type <_".xret($_)."> ".xid($_)."\n" if defined xret($_);} $admstpathxml->findnodes("//productionset"); print admstpathYacc_y " %union { p_slist _slist; p_path _path; p_text _text; } %% "; foreach($admstpathxml->findnodes("//productionset")) { my$set=$_; print admstpathYacc_y xid($set)."\n"; my$isfirst=1; foreach($set->findnodes("production")) { my$production=$_; my$rootcounter=0; my$semantic=$isfirst?" :":" |"; my$xid=xid($production); my$id=$xid<10?"0$xid":"$xid"; my$label=xlabel($production)?xlabel($production):xid($set).$id; $isfirst=0; foreach($production->findnodes("item")) { my$itemproduction=$admstpathxml->findnodes("//productionset[\@id='".xlinkto($_)."']")->[0]; $semantic.=" ".($itemproduction?xid($itemproduction):"tktk_".xlinkto($_)); $rootcounter++ if xlinkto($_) eq "pathroot"; } $semantic.="\n"; $semantic.=" {/*".xid($_).(xlabel($_)?" ".xlabel($_):"")."*/\n"; my$T=" "; if(xid($set) eq "root") { if($xid == 0) { } elsif($xid == 1) { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"");'."\n"; $semantic.=$T.'mytext->_token=adms_slist_reverse($2);'."\n"; $semantic.=$T.'((p_pparse)mypparse)->_text=mytext;'."\n"; } } elsif(xid($set) eq "pathroot_l") { if($xid == 0) { $semantic.=$T.'((p_pparse)mypparse)->_path=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'((p_pparse)mypparse)->_path=$3;'."\n"; } } elsif(xid($set) eq "pathroot") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'adms_slist_inreverse(&$1);'."\n"; $semantic.=$T.'$$->_bar=$1;'."\n"; $semantic.=$T.'$$->_callback=NULL;'."\n"; $semantic.=$T.'$$->_callbackname="path";'."\n"; } elsif(xid($set) eq "pathbar") { if($xid == 0) { $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)$1);'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=$1;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)$3);'."\n"; } } elsif(xid($set) eq "pathadd") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'p_path addp=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'addp->_callback=(void*)addptraverse;'."\n"; $semantic.=$T.'addp->_callbackname="addptraverse";'."\n"; $semantic.=$T.'adms_slist_push(&addp->_arg,(p_adms)$3);'."\n"; $semantic.=$T.'adms_slist_push(&addp->_arg,(p_adms)$1);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)addp);'."\n"; } elsif($xid == 2) { $semantic.=$T.'p_path addm=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'addm->_callback=(void*)addmtraverse;'."\n"; $semantic.=$T.'addm->_callbackname="addmtraverse";'."\n"; $semantic.=$T.'adms_slist_push(&addm->_arg,(p_adms)$3);'."\n"; $semantic.=$T.'adms_slist_push(&addm->_arg,(p_adms)$1);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)addm);'."\n"; } } elsif(xid($set) eq "pathmult") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'p_path multp=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'multp->_callback=(void*)multtimetraverse;'."\n"; $semantic.=$T.'multp->_callbackname="multtimetraverse";'."\n"; $semantic.=$T.'adms_slist_push(&multp->_arg,(p_adms)$3);'."\n"; $semantic.=$T.'adms_slist_push(&multp->_arg,(p_adms)$1);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)multp);'."\n"; } elsif($xid == 2) { $semantic.=$T.'p_path multm=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'multm->_callback=(void*)multdivtraverse;'."\n"; $semantic.=$T.'multm->_callbackname="multdivtraverse";'."\n"; $semantic.=$T.'adms_slist_push(&multm->_arg,(p_adms)$3);'."\n"; $semantic.=$T.'adms_slist_push(&multm->_arg,(p_adms)$1);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)multm);'."\n"; } } elsif(xid($set) eq "pathunary") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'p_path unaryp=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'unaryp->_callback=(void*)unaryptraverse;'."\n"; $semantic.=$T.'unaryp->_callbackname="unaryptraverse";'."\n"; $semantic.=$T.'adms_slist_push(&unaryp->_arg,(p_adms)$2);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)unaryp);'."\n"; } elsif($xid == 2) { $semantic.=$T.'p_path unarym=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'unarym->_callback=(void*)unarymtraverse;'."\n"; $semantic.=$T.'unarym->_callbackname="unarymtraverse";'."\n"; $semantic.=$T.'adms_slist_push(&unarym->_arg,(p_adms)$2);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)unarym);'."\n"; } } elsif(xid($set) eq "pathincr") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'p_path incrp=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'p_path path0=(p_path)adms_slist_last($1)->data;'."\n"; $semantic.=$T.'path0->_keeplist=1;'."\n"; $semantic.=$T.'incrp->_callback=(void*)incrptraverse;'."\n"; $semantic.=$T.'incrp->_callbackname="incrptraverse";'."\n"; $semantic.=$T.'adms_slist_push(&incrp->_arg,(p_adms)$1);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)incrp);'."\n"; } elsif($xid == 2) { $semantic.=$T.'p_path incrm=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'p_path path0=(p_path)adms_slist_last($1)->data;'."\n"; $semantic.=$T.'path0->_keeplist=1;'."\n"; $semantic.=$T.'incrm->_callback=(void*)incrmtraverse;'."\n"; $semantic.=$T.'incrm->_callbackname="incrmtraverse";'."\n"; $semantic.=$T.'adms_slist_push(&incrm->_arg,(p_adms)$1);'."\n"; $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)incrm);'."\n"; } } elsif(xid($set) eq "pathsep0") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; $semantic.=$T.'adms_slist_inreverse(&$$);'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=$1;'."\n"; $semantic.=$T.'adms_slist_inreverse(&$$);'."\n"; } elsif($xid == 2) { $semantic.=$T.'p_path pathroot=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'pathroot->_callback=(void*)root00;'."\n"; $semantic.=$T.'pathroot->_callbackname="root00";'."\n"; $semantic.=$T.'$$=$2;'."\n"; $semantic.=$T.'adms_slist_inreverse(&$$);'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)pathroot);'."\n"; } elsif($xid == 3) { $semantic.=$T.'p_path pathroot=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'pathroot->_callback=(void*)root00;'."\n"; $semantic.=$T.'pathroot->_callbackname="root00";'."\n"; $semantic.=$T.'$$=$2;'."\n"; $semantic.=$T.'adms_slist_inreverse(&$$);'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)pathroot);'."\n"; } } elsif(xid($set) eq "pathsep") { if($xid == 0) { $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)$1);'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=$1;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)$3);'."\n"; } } elsif(xid($set) eq "locationcondition") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; $semantic.=$T.'if($2) adms_slist_push(&$$->_c,(p_adms)$2);'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)location00;'."\n"; $semantic.=$T.'$$->_callbackname="location00";'."\n"; $semantic.=$T.'if($1) adms_slist_push(&$$->_c,(p_adms)$1);'."\n"; } elsif($xid == 2) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 3) { $semantic.=$T.'$$=$2;'."\n"; $semantic.=$T.'$$->_callbackname="groupage";'."\n"; $semantic.=$T.'$$->_callback=(void*)groupage;'."\n"; } } elsif(xid($set) eq "location") { if(0) {} elsif($label eq "intp") { $semantic.=$T.'$$=BASICINTEGER((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($label eq "realp") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($label eq "ident") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; $semantic.=$T.'if(($$->_text->_admse==admse_past_name)||($$->_text->_admse==admse_datatypefamily))'."\n"; $semantic.=$T.'{'."\n"; $semantic.=$T.' $$->_callback=(void*)location03dummy;'."\n"; $semantic.=$T.' $$->_callbackname="location03dummy";'."\n"; $semantic.=$T.'}'."\n"; $semantic.=$T.'else'."\n"; $semantic.=$T.'{'."\n"; $semantic.=$T.' $$->_callback=(void*)location03;'."\n"; $semantic.=$T.' $$->_callbackname="location03";'."\n"; $semantic.=$T.'}'."\n"; } elsif($label eq "q") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_text=$1;'."\n"; $semantic.=$T.'if((adms_slist_length($$->_text->_token)==1)&&($$->_text->_token->data->_datatypename==admse_admst))'."\n"; $semantic.=$T.'{'."\n"; $semantic.=$T.' $$->_callback=(void*)location09k;'."\n"; $semantic.=$T.' $$->_callbackname="location09k.'.$label.'";'."\n"; $semantic.=$T.'}'."\n"; $semantic.=$T.'else'."\n"; $semantic.=$T.'{'."\n"; $semantic.=$T.' $$->_callback=(void*)location09;'."\n"; $semantic.=$T.' $$->_callbackname="location09.'.$label.'";'."\n"; $semantic.=$T.'}'."\n"; } elsif($label eq "ident.index") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,"index");'."\n"; } elsif($label eq "ticptr") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"\'%p\'");'."\n"; $semantic.=$T.'adms_slist_push(&(mytext->_token),(p_adms)adms_admst_newks(adms_kclone("%p")));'."\n"; $semantic.=$T.'mytext->_admse=admse__p;'."\n"; $semantic.=$T.'$$->_text=mytext;'."\n"; } elsif($label eq "dollar") { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"$");'."\n"; $semantic.=$T.'mytext->_token=adms_slist_reverse($2);'."\n"; $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,mytext);'."\n"; } elsif($label eq "aroba") { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"@");'."\n"; $semantic.=$T.'mytext->_token=adms_slist_reverse($2);'."\n"; $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,mytext);'."\n"; } elsif($label eq "croix") { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"#");'."\n"; $semantic.=$T.'mytext->_token=adms_slist_reverse($2);'."\n"; $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,mytext);'."\n"; } elsif($label eq "croixcroix") { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"##");'."\n"; $semantic.=$T.'mytext->_token=adms_slist_reverse($2);'."\n"; $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,mytext);'."\n"; } elsif($label eq "kdollar") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($label eq "karoba") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($label eq "kcroix") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($label eq "kcroixcroix") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($label eq "function.admst") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; } elsif($label eq "function.ident") { $semantic.=$T.'$$=$1;'."\n"; } elsif($label eq "function.returned") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_text=$3;'."\n"; } elsif($label eq "function.text") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_text=$3;'."\n"; } else { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; } if($rootcounter==2) { $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$5);'."\n"; } if($rootcounter) { $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$3);'."\n"; } if(($label ne "q")&&($label ne "ident")) { $semantic.=$T.'$$->_callback=(void*)'.xid($set).$id.';'."\n"; $semantic.=$T.'$$->_callbackname="'.xid($set).$id.'.'.$label.'";'."\n"; } } elsif(xid($set) eq "identifier") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif(xid($set) eq "quotedstring") { if($xid == 0) { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"qtext");'."\n"; $semantic.=$T.'mytext->_token=adms_slist_reverse($2);'."\n"; $semantic.=$T.'if(adms_slist_length(mytext->_token)==1)'."\n"; $semantic.=$T.'{'."\n"; $semantic.=$T.' if(mytext->_token->data->_datatypename==admse_path)'."\n"; $semantic.=$T.' mytext->_admse=admse__path;'."\n"; $semantic.=$T.' else if(mytext->_token->data->_datatypename==admse_admst)'."\n"; $semantic.=$T.' mytext->_admse=ns_strtoe(((p_admst)mytext->_token->data)->_item.s);'."\n"; $semantic.=$T.'}'."\n"; $semantic.=$T.'$$=mytext;'."\n"; } elsif($xid == 1) { $semantic.=$T.'p_text mytext=adms_text_new(((p_pparse)mypparse)->_transform,"");'."\n"; $semantic.=$T.'adms_slist_push(&(mytext->_token),(p_adms)adms_admst_newks(adms_kclone("")));'."\n"; $semantic.=$T.'$$=mytext;'."\n"; } } elsif(xid($set) eq "atext") { if($xid == 0) { $semantic.=$T.'$$=NULL;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)$1);'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=$1;'."\n"; $semantic.=$T.'adms_slist_push(&$$,(p_adms)$2);'."\n"; } } elsif(xid($set) eq "atextitem") { if($xid == 0) { $semantic.=$T.'$$=(p_path)adms_admst_newks(adms_kclone("\n"));'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=(p_path)adms_admst_newks(adms_kclone("\r"));'."\n"; } elsif($xid == 2) { $semantic.=$T.'$$=(p_path)adms_admst_newks(adms_kclone("\t"));'."\n"; } elsif($xid == 3) { $semantic.=$T.'$$=(p_path)adms_admst_newks(adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; } elsif($xid == 4) { $semantic.=$T.'$$=(p_path)adms_text_new(((p_pparse)mypparse)->_transform,"%s");'."\n"; $semantic.=$T.'((p_text)$$)->_admse=admse__s;'."\n"; } elsif($xid == 5) { $semantic.=$T.'$$=(p_path)adms_text_new(((p_pparse)mypparse)->_transform,"$");'."\n"; $semantic.=$T.'((p_text)$$)->_token=adms_slist_reverse($2);'."\n"; } elsif($xid == 6) { $semantic.=$T.'char* mytvalue=adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen);'."\n"; $semantic.=$T.'$$=(p_path)adms_text_new(((p_pparse)mypparse)->_transform,"$");'."\n"; $semantic.=$T.'adms_slist_push(&(((p_text)$$)->_token),(p_adms)adms_admst_newks(mytvalue));'."\n"; } elsif($xid == 7) { $semantic.=$T.'$$=$2;'."\n"; } } elsif(xid($set) eq "condition") { $semantic.=$T.'$$=$2;'."\n"; } elsif(xid($set) eq "expression") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)expression01;'."\n"; $semantic.=$T.'$$->_callbackname="expression01";'."\n"; $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$1);'."\n"; } } elsif(xid($set) eq "binaryor") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)binaryor;'."\n"; $semantic.=$T.'$$->_callbackname="binaryor";'."\n"; $semantic.=$T.'adms_slist_push(&$$->_b,(p_adms)$3);'."\n"; $semantic.=$T.'adms_slist_push(&$$->_b,(p_adms)$1);'."\n"; } } elsif(xid($set) eq "binaryand") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)binaryand;'."\n"; $semantic.=$T.'$$->_callbackname="binaryand";'."\n"; $semantic.=$T.'adms_slist_push(&$$->_b,(p_adms)$3);'."\n"; $semantic.=$T.'adms_slist_push(&$$->_b,(p_adms)$1);'."\n"; } } elsif(xid($set) eq "unary") { if($xid == 0) { $semantic.=$T.'$$=$1;'."\n"; } elsif($xid == 1) { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)unary00;'."\n"; $semantic.=$T.'$$->_callbackname="unary00";'."\n"; $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$2);'."\n"; } } elsif(xid($set) eq "atomic") { if($label eq "isdefault") { $semantic.=$T.'$$=BASICSTRING((p_pparse)mypparse,adms_knclone(((p_pparse)mypparse)->_tkstart,((p_pparse)mypparse)->_tklen));'."\n"; $semantic.=$T.'$$->_callback=(void*)atomicisdefault;'."\n"; $semantic.=$T.'$$->_callbackname="atomicisdefault";'."\n"; } elsif($label eq "groupage") { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)atomicgroupage;'."\n"; $semantic.=$T.'$$->_callbackname="atomicgroupage";'."\n"; $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$2);'."\n"; } else { $semantic.=$T.'$$=adms_path_new(((p_pparse)mypparse)->_transform,NULL);'."\n"; $semantic.=$T.'$$->_callback=(void*)atomic'.$label.';'."\n"; $semantic.=$T.'$$->_callbackname="atomic'.$label.'";'."\n"; } if($rootcounter) { $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$3);'."\n"; } if($rootcounter==2) { $semantic.=$T.'adms_slist_push(&$$->_u,(p_adms)$1);'."\n"; } } print admstpathYacc_y $semantic; print admstpathYacc_y " }\n"; } print admstpathYacc_y ";\n"; } print admstpathYacc_y " %% static const char* tparsecb (p_pparse mypparse) { const char* t=mypparse->_position; mypparse->_tkstart=t; if(0) {} else if(*t=='\\\''&&INSIDEPATH) { adms_slist_pull(&globalctxt); t+=1, mypparse->_tkid= (admse) tktk_cquote; } else if(*t=='\%') { if(*(t+1)=='\\0') t+=1, mypparse->_tkid= (admse) tktk_anytext; else if(*(t+1)=='s') t+=2, mypparse->_tkid= (admse) tktk_percents; else if(*(t+1)=='\%') { mypparse->_tkstart=t+1; t+=2, mypparse->_tkid= (admse) tktk_anytext; } else if(*(t+1)=='(') { paren++; adms_slist_push(&parenidx,(p_adms)(long)paren); SETPATH mypparse->_tkstart=t+2; t+=2, mypparse->_tkid= (admse) tktk_percent; } else t+=2, mypparse->_tkid= (admse) tktk_anytext; } else if(*t=='\\\\') { if(*(t+1)=='\\0') t+=1, mypparse->_tkid= (admse) tktk_anytext; if(*(t+1)=='n') t+=2, mypparse->_tkid= (admse) tktk_cr; else if(*(t+1)=='r') t+=2, mypparse->_tkid= (admse) tktk_cr; else if(*(t+1)=='t') t+=2, mypparse->_tkid= (admse) tktk_tab; else { mypparse->_tkstart=t+1; t+=2, mypparse->_tkid= (admse) tktk_anytext; } } else if(*t=='\$') { if(*(t+1)=='\\0') t+=1, mypparse->_tkid= (admse) tktk_anytext; if(*(t+1)=='(') { paren++; adms_slist_push(&parenidx,(p_adms)(long)paren); SETTEXT mypparse->_tkstart=t+2; t+=2, mypparse->_tkid= (admse) tktk_dollarvariable; } else { mypparse->_tkstart=t+1; t++; while(*t&&(isalnum(*t)||*t=='_')) t++; mypparse->_tkid= (admse) tktk_kdollarvariable; } } else if(ISTEXT&&(*t==')')) { if(PARENMATCH) { t+=1, mypparse->_tkid= (admse) tktk_closeE, adms_slist_pull(&parenidx); adms_slist_pull(&globalctxt); } else t+=1, mypparse->_tkid= (admse) tktk_anytext; paren--; } else { if(INSIDEPATH) { if(ISTEXT) while(*t&&(*t!=')')&&(*t!='\\0')&&(*t!='\%')&&(*t!='\\\\')&&(*t!='\$')&&(*t!='\\'')) { if(*t=='(') paren++; t++; } else if(ISTIC) while(*t&&(*t!='\\0')&&(*t!='\%')&&(*t!='\\\\')&&(*t!='\$')&&(*t!='\\'')) { t++; } else adms_message_fatal((\"%s:'%s' unexpected error in apath parser - please report to r29173\@users.sourceforge.net\\n\",adms_transform_uid(mypparse->_transform),mypparse->_value)) } else { if(ISTEXT) while(*t&&(*t!=')')&&(*t!='\\0')&&(*t!='\%')&&(*t!='\\\\')&&(*t!='\$')) { if(*t=='(') paren++; t++; } else if(ISTIC) while(*t&&(*t!='\\0')&&(*t!='\%')&&(*t!='\\\\')&&(*t!='\$')) { t++; } else adms_message_fatal((\"%s:'%s' unexpected error in apath parser - please report to r29173\@users.sourceforge.net\\n\",adms_transform_uid(mypparse->_transform),mypparse->_value)) } mypparse->_tkid= (admse) tktk_anytext; } mypparse->_tklen=(int)(long)(t-mypparse->_tkstart); return t; } static int admstpathlex (p_pparse mypparse) { const char* t=mypparse->_position; const char* tstart; if(*t=='\\0') return 0; if(goto_atext) { goto_atext=0; return tktk_goto_atext; } "; map {print admstpathYacc_y " while(".xvalue($_).") t++;\n";} $admstpathxml->findnodes("//ignore"); print admstpathYacc_y " tstart=t; if(!strncmp(t,\"\\\'%p\\'\",4)&&!isalpha(*(t+4))) t+=4, mypparse->_tkid= (admse) tktk_ticptr; else if(!ISPATH) t=tparsecb(mypparse); "; foreach($admstpathxml->findnodes("//constant|//regexp")) { if($_->nodeName eq "regexp") { print admstpathYacc_y $_->textContent; } elsif(xvalue($_)=~/\w$/) { my$len=length(xvalue($_)); print admstpathYacc_y " else if(!strncmp(t,\"".xvalue($_)."\",$len)&&!isalpha(*(t+$len)))\n"; print admstpathYacc_y " t+=$len, mypparse->_tkid= (admse) tktk_".xid($_).";\n"; } else { my$len=length(xvalue($_)); print admstpathYacc_y " else if(!strncmp(t,\"".xvalue($_)."\",$len))\n"; print admstpathYacc_y " t+=$len, mypparse->_tkid= (admse) tktk_".xid($_).";\n"; } } print admstpathYacc_y " else { if(*t=='\\0') return 0; adms_message_fatal((\"%s: invalid path - unexpected character: %s\\n\", adms_transform_uid(mypparse->_transform), mypparse->_value)) } mypparse->_position=t; return mypparse->_tkid; } p_path pparse (p_transform mytransform,const char* aname,const char* avalue) { p_path mypath; p_pparse mypparse=adms_pparse_new(mytransform,aname,avalue); goto_atext=0; SETPATH globalignorequote=0; if(*avalue) { mypparse->_position=avalue; admstpathparse (mypparse); mypath=mypparse->_path; mypath->_aname=adms_kclone(aname); mypath->_avalue=avalue?adms_kclone(avalue):adms_kclone(\"\"); } else { mypath=NULL; adms_message_fatal_continue((\"invalid path \\\"\%s\\\"\\n\",mypparse->_value)) adms_message_fatal((\"see \%s\\n\",adms_transform_uid(mypparse->_transform))) } adms_slist_pull(&globalctxt); adms_pparse_free(mypparse); return mypath; } p_text tparse (p_ktransform mytransform, const char* aname, const char* avalue) { p_text mytext; if(!avalue) mytext=adms_text_new(mytransform,avalue); else if(*avalue=='\\0') { p_text mytext=adms_text_new(mytransform,avalue); adms_slist_push(&(mytext->_token),(p_adms)adms_admst_newks(adms_kclone(\"\"))); return mytext; } else { p_pparse mypparse=adms_pparse_new(mytransform,aname,avalue); SETTIC goto_atext=1; globalignorequote=1; mypparse->_position=avalue; admstpathparse (mypparse); mytext=mypparse->_text; adms_pparse_free(mypparse); mytext->_value=adms_kclone(avalue); adms_slist_pull(&globalctxt); } mytext->_admse=ns_strtoe(avalue); if((adms_slist_length(mytext->_token)==1)&&(mytext->_token->data->_datatypename==admse_path)) mytext->_admse=admse__path; else if(!strcmp(avalue,\"\%p\")) mytext->_admse=admse__p; mytext->_aname=adms_kclone(aname); return mytext; } int apath_main (int argc,char **argv) { int argci; int doatext=0; char*avalue=(argc==1)?\"a/b/c|c|c|c\":argv[1]; for(argci=1;argci\",\"\",0,\"*\",NULL),\"input:text\",avalue)); else { char*aname=\"stdin\"; p_pparse mypparse=adms_pparse_new(adms_transform_new(\"\",\"\",0,\"*\",NULL),aname,avalue); mypparse->_position=avalue; SETPATH globalignorequote=0; admstpathparse (mypparse); printf(\"

\",avalue); mypparse->_path->_aname=adms_kclone(aname); postpath(mypparse->_path); dbpath(mypparse->_path); printf(\"

\\n\"); } return 0; } "; close admstpathYacc_y; print "admstpathYacc.y: created\n"; ADMS-release-2.3.7/admsXml/mkgrammar.pl000066400000000000000000000072111371671745500176260ustar00rootroot00000000000000#!perl -w # # This file is part of adms - http://sourceforge.net/projects/mot-adms. # # adms is a code generator for the Verilog-AMS language. # # Copyright (C) 2002-2012 Laurent Lemaitre # 2014 Guilherme Brondani Torri # # 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 . my%Token; my$atTop=1; my$atBotton=0; my@Bottom; my@allbisonrule; open OFH, ">verilogaYacc.y"; print OFH "/* File automatically created by " . __FILE__ . " */\n"; print OFH "\n"; while(<>) { $atTop=0 if m/R_admsParse/; print OFH if $atTop; $atBotton=1 if m/^%%$/; push @Bottom,$_ if $atBotton; if(/^R_/) { chop; my$bisonrule; $bisonrule->{name}=$_; push @allbisonrule,$bisonrule; $_=<>; while(s/^\s+\|\s*//) { my$bisonalternative; NEWALTERNATIVE: { my%fragment; $fragment{precedence}=$1 if s/\s+(\%.*)$//; s/^\s+//; foreach my$tk(split /\s+/,$_) { push @{$fragment{child}},$tk; $Token{$tk}=1 if ($tk=~/tk_/); } $_=<>; while(s/^(\s+)_/$1 /) { $fragment{code}.=$_; $_=<>; } push @{$bisonalternative->{child}},\%fragment; if(not(m/^\s+;$/ || m/^\s+\|\s*/)) { goto NEWALTERNATIVE; } } push @{$bisonrule->{alternative}},$bisonalternative; } die "bisonrule should terminate with ';' - see $_" if(not m/^\s+;$/); } } map {print OFH "\%token <_lexval> $_\n";} sort keys %Token; print OFH "\n"; map {print OFH "\%type <_yaccval> $_->{name}\n";} @allbisonrule; print OFH "\n"; print OFH "%%\n"; foreach my$mybisonrule(@allbisonrule) { print OFH "$mybisonrule->{name}\n"; my$firstalternative=$mybisonrule->{alternative}->[0]; my$alterindex=0; foreach my$myalter(@{$mybisonrule->{alternative}}) { my$fragmentindex=0; my$tokenstart=0; foreach my$fragment(@{$myalter->{child}}) { my$child=$fragment->{child}; my$code=$fragment->{code}; print OFH " "x8; if($alterindex==0 && $fragmentindex==0) { print OFH ": "; } elsif($fragmentindex==0) { print OFH "| "; } else { print OFH " "; } print OFH join " ", @$child if $child; print OFH "\n"; print OFH " "x10 . "{\n"; if($code) { my$tkindex=$tokenstart+1; foreach my$tk(@$child) { if(defined($Token{$tk}) && ($code =~ m/mylexval$tkindex/)) { print OFH " "x12 . "char* mylexval$tkindex=((p_lexval)\$$tkindex)->_string;\n"; } $tkindex++; } print OFH $code; } my$tkindex=$tokenstart+1; foreach my$tk(@$child) { $tkindex++; } print OFH " "x10 . "}"; print OFH " " . $fragment->{precedence} if (defined $fragment->{precedence}); print OFH "\n"; $fragmentindex++; $tokenstart+=scalar(@$child)+1; } $alterindex++; } print OFH " "x8 . ";\n"; } print OFH @Bottom; close OFH; print "created: verilogaYacc.y\n"; ADMS-release-2.3.7/admsXml/preprocessorLex.l000066400000000000000000000573651371671745500207060ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2016 Felix Salfelder 2014-2016 Guilherme Brondani Torri 2013 Bastien ROUCARIÈS 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 . */ %option outfile="preprocessorLex.c" %option prefix="preprocessor" %{ #define YY_NO_INPUT #include "adms.h" #include "admsPreprocessor.h" #include "preprocessorYacc.h" #ifndef INITIAL # define INITIAL 0 #endif #include "constants.vams.c" #include "disciplines.vams.c" #define yyflex_unput \ {\ int i;\ char *yycopy=strdup(yytext);\ for ( i = yyleng - 1; i >= 0; --i )\ unput(yycopy[i]);\ free(yycopy);\ } #define DONT_SKIPP (pproot()->skipp_text->data==INT2ADMS(0)) void adms_preprocessor_setfile_input (FILE *ifile) { yyin = ifile; } FILE *adms_preprocessor_getfile_input (void) { return yyin; } void adms_preprocessor_setfile_output (FILE *ifile) { yyout = ifile; } FILE *adms_preprocessor_getfile_output (void) { return yyout; } #define tkreturn(token) {pproot()->cr_scanner->cur_char_position+=yyleng; return token;} static char* adms_preprocessor_lex_remove_leading_quote (char* name) { char* unquoted_name; char* start; char* finish; start = name+1; finish = name + strlen(name); unquoted_name = adms_knclone (start, finish - start ); return (unquoted_name); } static char* adms_preprocessor_lex_get_path (char* macro, const char begin, const char end) { char* path; char* start=macro; char* finish; while( *start && (*start != begin) ) start++; finish=++start; while( *finish && (*finish != end) ) finish++; path=adms_knclone (start, finish - start ); return path; } void preprocessorerror (const char *message) { p_preprocessor cr_preprocessor=pproot()->cr_scanner; adms_message_fatal (("[%s:%i]:%s: %s\n", cr_preprocessor->filename, adms_preprocessor_get_line_position(cr_preprocessor,cr_preprocessor->cur_char_position-yyleng), message, cr_preprocessor->cur_message?cr_preprocessor->cur_message:"(unknown)" )) } static void adms_file_fprintf ( char *filename, const char *filedata) { FILE *ofh = fopen (filename,"w"); if (fprintf ( ofh, "%s", filedata)==EOF) adms_message_fatal(("%s: cannot write file\n", filename)) fclose (ofh); } static FILE* adms_file_open_read_with_path (const char* myfilename, p_slist mypath) { p_slist l; for(l=mypath;l;l=l->next) { FILE* myfh=NULL; char* mypathname=strdup((char*)(l->data)); adms_k2strconcat(&mypathname,ADMS_PATH_SEPARATOR); adms_k2strconcat(&mypathname,myfilename); if((myfh=fopen(mypathname,"r"))) return myfh; } return NULL; } static void adms_preprocessor_lex_include_file (char* fileName) { FILE*myfh; p_preprocessor scanner; char*message=NULL; adms_k2strconcat(&message,pproot()->cr_scanner->filename); adms_k2strconcat(&message,":"); adms_strconcat(&message,adms_integertostring(adms_preprocessor_get_line_position (pproot()->cr_scanner, 0))); if(pproot()->cr_filename) free(pproot()->cr_filename); pproot()->cr_filename=strdup(fileName); if(!(myfh=adms_file_open_read_with_path(fileName,(p_slist)(pproot()->includePath)))) { if(!strcmp(fileName,"discipline.h")||!strcmp(fileName,"disciplines.h")||!strcmp(fileName,"discipline.vams")||!strcmp(fileName,"disciplines.vams")) { adms_message_warning(("[%s]: simplified vams header file created\n",message)) adms_message_warning((" (not found in -I path) ... '%s'\n",fileName)) adms_message_info(("standard '%s' header is available at\n",fileName)) adms_message_info((" 'http://accellera.org/downloads/standards/v-ams'\n")) //printf("%s",disciplines_vams); adms_file_fprintf(fileName,disciplines_vams); myfh=adms_file_open_read(fileName); } else if(!strcmp(fileName,"constant.h")||!strcmp(fileName,"constants.h")||!strcmp(fileName,"constant.vams")||!strcmp(fileName,"constants.vams")) { adms_message_warning(("[%s]: simplified vams header file created (not found in -I path) ... '%s'\n",message,fileName)) adms_message_info(("standard '%s' header is available at 'http://accellera.org/downloads/standards/v-ams'\n",fileName)) adms_file_fprintf(fileName,constants_vams); myfh=adms_file_open_read(fileName); } else adms_message_fatal(("[%s]: failed to open file ... '%s'\n",message,fileName)) } scanner=(p_preprocessor)malloc(sizeof(t_preprocessor)); adms_message_verbose(("include file '%s'\n",fileName)) scanner->buffer=NULL; scanner->fid=NULL; scanner->cur_continuator_position=NULL; pproot()->cr_scanner->buffer = (p_adms)YY_CURRENT_BUFFER; adms_slist_push(&pproot()->Scanner,(void*)pproot()->cr_scanner ); yyin = myfh; scanner->fid = yyin; scanner->cur_line_position = 1; scanner->cur_char_position = 1; scanner->filename=strdup(pproot()->cr_filename); scanner->buffer = (void*) yy_create_buffer(yyin,YY_BUF_SIZE ); pproot()->cr_scanner = scanner; yy_switch_to_buffer((YY_BUFFER_STATE)scanner->buffer ); preprocessorlval.mystr = NULL; adms_k2strconcat(&preprocessorlval.mystr,"# 1 \""); adms_k2strconcat(&preprocessorlval.mystr,pproot()->cr_scanner->filename); adms_k2strconcat(&preprocessorlval.mystr,"\"\n"); BEGIN( INITIAL ); free(message); } static char *adms_preprocessor_lex_skipp_text () { char *c; int nbline=0; c = yytext; while (*c) { if(*c=='\n') { pproot()->cr_scanner->cur_char_position = 1; pproot()->cr_scanner->cur_line_position++; nbline++; } else pproot()->cr_scanner->cur_char_position++; c++; } if(nbline) { char*str=(char*)malloc(sizeof(char)*(nbline+1)); memset(str,'\n',nbline); str[nbline] = '\0'; return str; } else return strdup(""); } %} whitespace [ \t\v\f]* Whitespace [ \t\v\f]+ newline \r?\n ident $?[A-Za-z_][A-Za-z0-9_]* notident [^`a-zA-Z_\r\n]+ notpragma [^#`a-zA-Z_\r\n]+ xpath \"[^\"]*\" ipath \<[^>]+\> continuator \\\r?\n anystring \"([^\"]|\\\")*\" b10_uint [1-9][0-9]* comment \/\*[^\*]*\*+([^\*\/][^\*]*\*+)*\/ comment_oneline \/\/[^\r\n]* /* port branch access I() --> I(a,a) */ iprb I\(\<[A-Za-z_][A-Za-z0-9_]*\>\) %x PRAGMA_PATH %x PRAGMA_COMMENT %x PRAGMA_NAME %x PRAGMA_ERROR %x PRAGMA_DEFINE_START %x PRAGMA_DEFINE_IGNORE %x PRAGMA_DEFINE_NOARG %x PRAGMA_DEFINE_WITHARG %x PRAGMA_DEFINE_TEXT_START %x PRAGMA_DEFINE_TEXT %x PRAGMA_DEFINE_WITHARG_COMMA %x PRAGMA_DEFINE_WITHARG_ARGS %x PRAGMA_SUBSTITUTOR_START %x PRAGMA_SUBSTITUTOR_ARG %x PRAGMA_SUBSTITUTOR_PAIR %x PRAGMA_SUBSTITUTOR_ARGITEM %x PRAGMA_SUBSTITUTOR_ARGCOMMA %x PRAGMA_SUBSTITUTOR_ARGEND %% {anystring} { preprocessorlval.mystr = strdup( yytext ); tkreturn(TK_STRING) } {continuator} { p_continuator continuator; continuator=(p_continuator)malloc(sizeof(t_continuator)); continuator->char_position = yyleng-1; continuator->line_position = pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_line_position += 1; pproot()->cr_scanner->cur_char_position = 1; adms_slist_push(&(pproot()->cr_scanner->cur_continuator_position),(p_adms)continuator); tkreturn(TK_NOPRAGMA_CONTINUATOR) } /* ignored sequences */ ^#{Whitespace}{b10_uint}{whitespace}{anystring}{Whitespace}{newline} { } \r\n { preprocessorlval.mystr=strdup(yytext); return(TK_EOL); } \n { preprocessorlval.mystr=strdup(yytext); return(TK_EOL); } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; preprocessorlval.mystr=strdup(yytext); return(TK_SPACE ); } {comment} { preprocessorlval.mystr=adms_preprocessor_lex_skipp_text (); return(TK_COMMENT); } {comment_oneline} { preprocessorlval.mystr=adms_preprocessor_lex_skipp_text (); return(TK_COMMENT); } /* port branch access I() --> I(a,a) */ {iprb} { { const char *t1 = strchr(yytext, '<'); const char *t2 = strchr(yytext, '>'); int len = 2*(t2-t1) + 5; char *tn = (char*)malloc(len); const char *tt; preprocessorlval.mystr = tn; *tn++ = 'I'; *tn++ = '('; for (tt = t1+1; tt < t2; tt++) *tn++ = *tt; *tn++ = ','; for (tt = t1+1; tt < t2; tt++) *tn++ = *tt; *tn++ = ')'; *tn = 0; } tkreturn(TK_IDENT) } /* pragma */ ^{whitespace}[`]define { pproot()->cr_scanner->cur_char_position+=yyleng; if ( DONT_SKIPP ) { BEGIN( PRAGMA_DEFINE_START ); tkreturn(TK_DEFINE) } else BEGIN( PRAGMA_DEFINE_IGNORE ); } .* { pproot()->cr_scanner->cur_char_position+=yyleng; BEGIN( INITIAL ); } {newline} { pproot()->cr_scanner->cur_message=strdup("- `define: unexpected end-of-line"); yyflex_unput BEGIN( INITIAL ); } ^{whitespace}[`]undef { if ( DONT_SKIPP ) { BEGIN( PRAGMA_NAME ); tkreturn(TK_UNDEF) } else BEGIN( PRAGMA_DEFINE_IGNORE ); } ^{whitespace}[`]ifdef { preprocessorlval.mystr=strdup("");; BEGIN( PRAGMA_NAME ); tkreturn(TK_IFDEF) } ^{whitespace}[`]ifndef { preprocessorlval.mystr=strdup("");; BEGIN( PRAGMA_NAME ); tkreturn(TK_IFNDEF) } ^{whitespace}[`]else { char* string=NULL; adms_k2strconcat(&string,"# "); adms_strconcat(&string,adms_integertostring(pproot()->cr_scanner->cur_line_position+1)); adms_k2strconcat(&string," \""); adms_k2strconcat(&string,pproot()->cr_scanner->filename); adms_k2strconcat(&string,"\""); preprocessorlval.mystr=string; BEGIN( PRAGMA_COMMENT ); tkreturn(TK_ELSE) } ^{whitespace}[`]endif { char* string=NULL; adms_k2strconcat(&string,"# "); adms_strconcat(&string,adms_integertostring(pproot()->cr_scanner->cur_line_position+1)); adms_k2strconcat(&string," \""); adms_k2strconcat(&string,pproot()->cr_scanner->filename); adms_k2strconcat(&string,"\""); preprocessorlval.mystr=string; BEGIN( PRAGMA_COMMENT ); tkreturn(TK_ENDIF) } ^{whitespace}[`]include { if(DONT_SKIPP) BEGIN(PRAGMA_PATH); else BEGIN(PRAGMA_DEFINE_IGNORE); } {ident}/{newline} { BEGIN( PRAGMA_DEFINE_NOARG ); preprocessorlval.mystr=strdup(yytext ); tkreturn(TK_PRAGMA_NAME) } {ident}/{Whitespace} { BEGIN( PRAGMA_DEFINE_NOARG ); preprocessorlval.mystr=strdup(yytext ); tkreturn(TK_PRAGMA_NAME) } {ident}/\( { BEGIN( PRAGMA_DEFINE_WITHARG ); preprocessorlval.mystr=strdup(yytext ); tkreturn(TK_PRAGMA_NAME) } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; } {newline} { pproot()->cr_scanner->cur_message=strdup("- pragma name: unexpected end-of-line"); yyflex_unput BEGIN( PRAGMA_ERROR ); } . { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - identifier was expected"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_ERROR ); } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; } {newline} { pproot()->cr_scanner->cur_message=strdup("- `define: unexpected end-of-line)"); yyflex_unput BEGIN( INITIAL ); tkreturn(TK_DEFINE_END) } {continuator} { p_continuator continuator; continuator=(p_continuator)malloc(sizeof(t_continuator)); continuator->char_position = yyleng-1; continuator->line_position = pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_line_position += 1; pproot()->cr_scanner->cur_char_position = 1; adms_slist_push(&(pproot()->cr_scanner->cur_continuator_position),(p_adms)continuator); tkreturn(TK_CONTINUATOR) } . { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - whitespace was expected"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_DEFINE_TEXT_START ); } \({whitespace}\) { pproot()->cr_scanner->cur_char_position+=yyleng; BEGIN( PRAGMA_DEFINE_TEXT_START ); tkreturn(TK_ARG_NULL) } \([^)]+{newline} { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - `define has no closing paren"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_ERROR ); } \({whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; BEGIN( PRAGMA_DEFINE_WITHARG_ARGS ); } {ident} { BEGIN( PRAGMA_DEFINE_WITHARG_COMMA ); preprocessorlval.mystr=strdup(yytext ); tkreturn(TK_ARG) } . { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - `define has unexpected syntax"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_ERROR ); } , { pproot()->cr_scanner->cur_char_position+=yyleng; } \) { pproot()->cr_scanner->cur_char_position+=yyleng; BEGIN( PRAGMA_DEFINE_TEXT_START ); } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; } . { yyflex_unput BEGIN( PRAGMA_DEFINE_WITHARG_ARGS ); } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; BEGIN( PRAGMA_DEFINE_TEXT ); } {continuator} { p_continuator continuator; continuator=(p_continuator)malloc(sizeof(t_continuator)); continuator->char_position = yyleng-1; continuator->line_position = pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_line_position += 1; pproot()->cr_scanner->cur_char_position = 1; adms_slist_push(&(pproot()->cr_scanner->cur_continuator_position),(p_adms)continuator); tkreturn(TK_CONTINUATOR) } {newline} { yyflex_unput BEGIN( INITIAL ); tkreturn(TK_DEFINE_END) } . { yyflex_unput BEGIN( PRAGMA_DEFINE_TEXT ); } {Whitespace}/{newline} { pproot()->cr_scanner->cur_char_position+=yyleng; } `{ident}/[ ]*\( { preprocessorlval.mystr=strdup(adms_preprocessor_lex_remove_leading_quote( yytext )); if(DONT_SKIPP) { p_preprocessor_pragma_define Define; if ((Define = adms_preprocessor_pragma_define_exists (preprocessorlval.mystr))) { if(adms_preprocessor_pragma_define_has_noarg(Define)) tkreturn(TK_SUBSTITUTOR_NOARG) else if(adms_preprocessor_pragma_define_has_nullarg(Define)) tkreturn(TK_SUBSTITUTOR_NULLARG) else tkreturn(TK_SUBSTITUTOR_WITHARG) } else { preprocessorlval.mystr = strdup(yytext); pproot()->cr_scanner->cur_message=strdup(yytext); tkreturn(TK_ERROR_PRAGMA_NOT_FOUND) } } else tkreturn(TK_IDENT) } `{ident} { preprocessorlval.mystr=strdup(adms_preprocessor_lex_remove_leading_quote( yytext )); if(DONT_SKIPP) { p_preprocessor_pragma_define Define; if((Define=adms_preprocessor_pragma_define_exists (preprocessorlval.mystr))) { if(adms_preprocessor_pragma_define_has_noarg(Define)) tkreturn(TK_SUBSTITUTOR_NOARG) else if(adms_preprocessor_pragma_define_has_nullarg(Define)) tkreturn(TK_SUBSTITUTOR_NULLARG_ALONE) else tkreturn(TK_SUBSTITUTOR_WITHARG_ALONE) } else { preprocessorlval.mystr=strdup(yytext); pproot()->cr_scanner->cur_message=strdup(yytext); tkreturn(TK_ERROR_PRAGMA_NOT_FOUND) } } else tkreturn(TK_IDENT) } {ident} { preprocessorlval.mystr = strdup(yytext); tkreturn(TK_IDENT) } \( { preprocessorlval.mystr = strdup(yytext); tkreturn('(') } \) { preprocessorlval.mystr = strdup(yytext); tkreturn(')') } \, { preprocessorlval.mystr = strdup(yytext); tkreturn(',') } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; preprocessorlval.mystr=strdup(yytext); return(TK_SPACE ); } {comment_oneline} { preprocessorlval.mystr=adms_preprocessor_lex_skipp_text (); return(TK_COMMENT); } {comment} { preprocessorlval.mystr=adms_preprocessor_lex_skipp_text (); return(TK_COMMENT); } {anystring} { /* SRW - fix bsim6 parse error, comma in quoted string macro arg caused * string to be tokenized, so argument list was hosed. This prevents * a single '"' from being a viable non-ident. */ pproot()->cr_scanner->cur_char_position+=yyleng; preprocessorlval.mystr=strdup(yytext); return(TK_SPACE ); } . { preprocessorlval.mystr = strdup(yytext); tkreturn(TK_NOT_IDENT) } {continuator} { p_continuator continuator; continuator=(p_continuator)malloc(sizeof(t_continuator)); continuator->char_position = yyleng-1; continuator->line_position = pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_line_position += 1; pproot()->cr_scanner->cur_char_position = 1; adms_slist_push(&(pproot()->cr_scanner->cur_continuator_position),(p_adms)continuator); tkreturn(TK_CONTINUATOR) } {newline} { yyflex_unput BEGIN( INITIAL ); tkreturn(TK_DEFINE_END) } {ident} { BEGIN( PRAGMA_COMMENT ); preprocessorlval.mystr=strdup(yytext ); tkreturn(TK_PRAGMA_NAME) } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; } {newline} { pproot()->cr_scanner->cur_message=strdup("- unexpected end-of-line"); yyflex_unput BEGIN( PRAGMA_ERROR ); } . { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - pragma name was expected"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_ERROR ); } {continuator} { p_continuator continuator; continuator=(p_continuator)malloc(sizeof(t_continuator)); continuator->char_position = yyleng-1; continuator->line_position = pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_line_position += 1; pproot()->cr_scanner->cur_char_position = 1; adms_slist_push(&(pproot()->cr_scanner->cur_continuator_position),(p_adms)continuator); tkreturn(TK_CONTINUATOR) } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; } {xpath} { char* fileName; BEGIN( INITIAL ); fileName = adms_preprocessor_lex_get_path(yytext,'"','"'); adms_preprocessor_lex_include_file(fileName); tkreturn(TK_INCLUDE) } {ipath} { char* fileName; BEGIN( INITIAL ); fileName = adms_preprocessor_lex_get_path(yytext,'<','>'); adms_message_info(("%s: implicit path handled as explicit path!",fileName)) adms_preprocessor_lex_include_file(fileName); tkreturn(TK_INCLUDE) } . { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - bad path"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_ERROR ); } {Whitespace} { pproot()->cr_scanner->cur_char_position+=yyleng; } {comment_oneline} { preprocessorlval.mystr=adms_preprocessor_lex_skipp_text (); return(TK_COMMENT); } {comment} { preprocessorlval.mystr=adms_preprocessor_lex_skipp_text (); return(TK_COMMENT); } {continuator} { p_continuator continuator; continuator=(p_continuator)malloc(sizeof(t_continuator)); continuator->char_position = yyleng-1; continuator->line_position = pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_line_position += 1; pproot()->cr_scanner->cur_char_position = 1; adms_slist_push(&(pproot()->cr_scanner->cur_continuator_position),(p_adms)continuator); tkreturn(TK_CONTINUATOR) } {newline} { yyflex_unput BEGIN( INITIAL ); } . { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - unknown error"); pproot()->cr_scanner->cur_message=string; yyflex_unput BEGIN( PRAGMA_ERROR ); } .*{newline} { char* string=NULL; adms_k2strconcat(&string,"at character "); adms_k2strconcat(&string,yytext); adms_k2strconcat(&string," - unknown error"); pproot()->cr_scanner->cur_message=string; tkreturn(TK_ERROR_PRAGMA_DEFINITION) } `{ident}/[ ]*\( { p_preprocessor_pragma_define Define; preprocessorlval.mystr = strdup(adms_preprocessor_lex_remove_leading_quote( yytext)); if(DONT_SKIPP) { if ((Define = adms_preprocessor_pragma_define_exists (preprocessorlval.mystr))) { if(adms_preprocessor_pragma_define_has_noarg(Define)) tkreturn(TK_SUBSTITUTOR_NOARG) else if(adms_preprocessor_pragma_define_has_nullarg(Define)) tkreturn(TK_SUBSTITUTOR_NULLARG) else tkreturn(TK_SUBSTITUTOR_WITHARG) } else { preprocessorlval.mystr = strdup(yytext); pproot()->cr_scanner->cur_message=strdup(yytext); tkreturn(TK_ERROR_PRAGMA_NOT_FOUND) } } else tkreturn(TK_IDENT) } `{ident} { preprocessorlval.mystr = strdup(adms_preprocessor_lex_remove_leading_quote( yytext )); { p_preprocessor_pragma_define Define; if(DONT_SKIPP) { if((Define=adms_preprocessor_pragma_define_exists (preprocessorlval.mystr))) { if(adms_preprocessor_pragma_define_has_noarg(Define)) tkreturn(TK_SUBSTITUTOR_NOARG) else if(adms_preprocessor_pragma_define_has_nullarg(Define)) tkreturn(TK_SUBSTITUTOR_NULLARG_ALONE) else tkreturn(TK_SUBSTITUTOR_WITHARG_ALONE) } else { preprocessorlval.mystr = strdup(yytext); pproot()->cr_scanner->cur_message=strdup(yytext); tkreturn(TK_ERROR_PRAGMA_NOT_FOUND) } } else tkreturn(TK_IDENT) } } {ident} { preprocessorlval.mystr = strdup(yytext); tkreturn(TK_IDENT) } \( { preprocessorlval.mystr = strdup(yytext); return '('; } \) { preprocessorlval.mystr = strdup(yytext); return ')'; } \, { preprocessorlval.mystr = strdup(yytext); return ','; } . { preprocessorlval.mystr = strdup(yytext); return TK_NOT_IDENT; } <> { char* string=NULL; if( pproot()->Scanner != NULL ) { yy_delete_buffer((YY_BUFFER_STATE)(pproot()->cr_scanner->buffer)); free(pproot()->cr_scanner ); pproot()->cr_scanner = (p_preprocessor) adms_slist_pull(&pproot()->Scanner ); yyin = pproot()->cr_scanner->fid; yy_switch_to_buffer((YY_BUFFER_STATE)pproot()->cr_scanner->buffer ); } else yyterminate (); /* SRW -- added newline below to avoid lex error due to last line of * included file being whitespace only. */ adms_k2strconcat(&string,"\n# "); adms_strconcat(&string,adms_integertostring(pproot()->cr_scanner->cur_line_position+1)); adms_k2strconcat(&string," \""); adms_k2strconcat(&string,pproot()->cr_scanner->filename); adms_k2strconcat(&string,"\""); preprocessorlval.mystr=string; tkreturn(TK_EOF) } %% int yywrap (void) {return 1;} ADMS-release-2.3.7/admsXml/preprocessorMain.c000066400000000000000000000366321371671745500210230ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 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 . */ /* * RCS Info * $Id: preprocessorMain.c 1154 2008-11-04 10:25:43Z r29173 $ * * Log * $Log$ * Revision 1.12 2005/06/17 16:44:25 r29173 * debug memory allocation with valgrind * * Revision 1.11 2005/06/16 07:12:45 r29173 * debug memory allocation with valgrind * * Revision 1.10 2005/05/09 14:38:30 r29173 * cleaned-up source directory structure * * Revision 1.9 2005/05/03 09:35:15 r29173 * cleaned-up header file dependencies * * Revision 1.8 2005/05/03 07:58:21 r29173 * moved admsNS into admsFile * * Revision 1.7 2004/11/19 12:29:56 r29173 * renamed _C into CAT * saved argc, argv into admsmain element * added adms:setenv transform * * Revision 1.6 2004/11/01 09:37:37 r29173 * changed messaging macros (avoid useless computation of arguments) * improved the coding of transforms in xmlProgram.c * * Revision 1.5 2004/10/20 15:33:52 r29173 * tons of changes * 1- introduced element whileloop (marat) * 2- reshaped the handling of the messaging system * 3- fixed bug in admsCheck/Makefile.am * 4- started implementation of implicit adms transforms * * Revision 1.4 2004/08/19 16:45:47 r29173 * cleaned-up i/o file handling * * Revision 1.3 2004/08/03 12:33:55 r29173 * import adms-1.21.0 from local CVS * * Revision 1.3 2004/07/09 14:39:11 r29173 * removed data structure ns * * Revision 1.2 2004/05/26 13:02:48 r29173 * added default values to all enumerations * * Revision 1.1.1.1 2004/05/21 12:20:01 r29173 * recreated cvs data structure (crashed after revision 1.13.0!) * * Revision 1.14 2004/03/08 13:58:06 r29173 * all code lower-cased * * Revision 1.13 2004/02/13 14:28:39 r29173 * started implementing code builder in yacc parser * * Revision 1.12 2004/02/06 09:06:03 r29173 * started implementing code builder in yacc parser * * Revision 1.11 2004/01/21 14:35:47 r29173 * started implementing code builder in yacc parser * * Revision 1.10 2004/01/09 16:23:47 r29173 * cleaned-up use of #include * * Revision 1.9 2004/01/08 10:28:50 r29173 * moved code to always.[ch] * * Revision 1.8 2004/01/06 12:35:29 r29173 * fixed the use of globals: input file and output file * * Revision 1.7 2003/12/12 15:08:35 r29173 * changed construct (a==NULL) to (!a) * * Revision 1.6 2003/12/12 14:43:38 r29173 * changed construct (a==NULL) to (!a) * * Revision 1.5 2003/12/12 14:33:26 r29173 * changed construct (a!=NULL) into (a) or (a)?1:0 * * Revision 1.4 2003/12/11 20:14:07 r29173 * cleaned-up after compilation with CFLAG+=-Wall * * Revision 1.3 2003/12/11 16:01:53 r29173 * changed prefix [epst]_adms_ to [epst]_ * * Revision 1.2 2003/05/21 14:18:01 r29173 * add rcs info * */ #include "admsPreprocessor.h" #define strdup_before_ptr(s,sptr,offset) adms_knclone(s+offset,sptr-s-offset) #define strdup_after_ptr(s,sptr,offset) adms_knclone(sptr+offset,strlen(s)-(sptr-s)-offset) extern int adms_preprocessor_leng; static p_preprocessor_main adms_preprocessor_main; void adms_preprocessor_valueto_main (p_preprocessor_main myadms_preprocessor_main) { adms_preprocessor_main=myadms_preprocessor_main; } p_preprocessor_main pproot () { return adms_preprocessor_main; } void adms_preprocessor_get_define_from_argv (const int argc,const char** argv) { int i; for (i=1; i2) && ((value[0])=='-') && ((value[1])=='D') ) { char *equal = NULL; char *arg = strdup_after_ptr (value,value+2,0); char *argPtr = arg; while (*argPtr && (!equal)) { if (*argPtr=='=') equal= argPtr; argPtr++; } if (*arg == '=') adms_message_verbose(("at command line argument, bad syntax ... '%s'\n",value)) else if (equal == last_char (arg)) defineName = strdup_before_ptr (arg,equal,0); else if (!equal) defineName = strdup(arg); else { defineName = strdup_before_ptr (arg,equal,0); defineValue = strdup_after_ptr (arg,equal,1); } if (defineName) { if (defineValue) adms_preprocessor_define_add_default_with_text (defineName, defineValue); else adms_preprocessor_define_add_default (defineName); } free(arg); } if (defineName) adms_message_verbose(("set pragma ... '%s'\n",defineName)) free(value); } } int adms_preprocessor_add_message ( char *message) { adms_message_info((message)) return 0; } p_preprocessor_text adms_preprocessor_new_text_as_string(char *name) { p_preprocessor_text text=(p_preprocessor_text)malloc(sizeof(t_preprocessor_text)); text->_str = name; text->_isarg = 0; return text; } static int adms_preprocessor_pragma_substitute_text (p_preprocessor_substitutor substitutor) { if (adms_preprocessor_pragma_define_is_def (substitutor->_pragma)) { p_preprocessor_text space = adms_preprocessor_new_text_as_string(" "); p_slist l; for(l=substitutor->_pragma->text;l;l=l->next) { p_preprocessor_text text=(p_preprocessor_text)(l->data); p_slist arg=adms_slist_copy(substitutor->_pragma->arg); adms_slist_inreverse(&arg); substitutor->_cr_text=text; substitutor->_cr_newarg=adms_slist_copy(substitutor->_newarg); adms_slist_inreverse(&substitutor->_cr_newarg); if (text->_isarg==1) { p_slist ll; for(ll=arg;ll;ll=ll->next) { char* arg=(char*)ll->data; if(!strcmp(substitutor->_cr_text->_str,arg)) { if(substitutor->_cr_newarg) { p_slist newarg=adms_slist_copy((p_slist)(substitutor->_cr_newarg->data)); adms_slist_inreverse(&newarg); adms_slist_concat(&newarg,substitutor->_newtext); substitutor->_newtext=newarg; } else adms_slist_push(&(substitutor->_newtext),(p_adms)substitutor->_cr_text); } substitutor->_cr_newarg = substitutor->_cr_newarg->next; } } else { p_preprocessor_text newtext = adms_preprocessor_new_text_as_string(text->_str); newtext->_isarg = -1; adms_slist_push(&(substitutor->_newtext),(p_adms)newtext); } adms_slist_free(arg); adms_slist_free(substitutor->_cr_newarg); } adms_slist_push(&(substitutor->_newtext),(p_adms)space); } else { p_preprocessor_text name = adms_preprocessor_new_text_as_string(substitutor->_pragma->name); adms_slist_push(&(substitutor->_newtext),(p_adms)name); } return 0; } p_slist adms_preprocessor_new_text_as_substitutor (p_preprocessor_pragma_define define, p_slist newarg) { p_preprocessor_substitutor substitutor=(p_preprocessor_substitutor)malloc(sizeof(t_preprocessor_substitutor)); substitutor->_newtext=NULL; substitutor->_cr_text=NULL; substitutor->_cr_newarg=NULL; substitutor->_pragma = define; substitutor->_newarg = newarg; adms_preprocessor_pragma_substitute_text(substitutor); adms_slist_inreverse(&substitutor->_newtext); return substitutor->_newtext; } int adms_preprocessor_pragma_define_has_arg (p_preprocessor_pragma_define pragma) { return (pragma->hasArg==1); } int adms_preprocessor_pragma_define_is_def (p_preprocessor_pragma_define pragma) { return (pragma->isDefined==1); } int adms_preprocessor_identifier_is_def (char * name) { int test; p_preprocessor_pragma_define pragma; if( (pragma = adms_preprocessor_pragma_define_exists (name)) && adms_preprocessor_pragma_define_is_def(pragma) ) test = ( pragma->isDefined == 1 ); else test = 0; return test; } p_preprocessor_pragma_define adms_preprocessor_identifer_set_undef (char * name) { p_preprocessor_pragma_define pragma = adms_preprocessor_pragma_define_exists (name); if(!pragma) pragma = adms_preprocessor_define_add (name); pragma->isDefined = 0; return pragma; } int adms_preprocessor_identifier_is_ndef (char * name) { return (!adms_preprocessor_identifier_is_def (name) ); } int adms_preprocessor_pragma_define_is_ndef (p_preprocessor_pragma_define pragma) { return (!adms_preprocessor_pragma_define_is_def(pragma)); } int adms_preprocessor_pragma_define_has_noarg (p_preprocessor_pragma_define pragma) { return (!adms_preprocessor_pragma_define_has_arg(pragma)); } int adms_preprocessor_pragma_define_has_nullarg (p_preprocessor_pragma_define pragma) { return adms_preprocessor_pragma_define_has_arg(pragma) && (adms_slist_length( pragma->arg )==0); } int adms_preprocessor_pragma_define_has_text (p_preprocessor_pragma_define pragma) { return ((pragma->text)?1:0); } int adms_preprocessor_pragma_define_has_notext (p_preprocessor_pragma_define pragma) { return (!adms_preprocessor_pragma_define_has_text(pragma)); } int adms_preprocessor_pragma_define_has_noarg_and_notext (p_preprocessor_pragma_define pragma) { int test; test = adms_preprocessor_pragma_define_has_noarg(pragma) && adms_preprocessor_pragma_define_has_notext(pragma) ; return test; } int adms_preprocessor_pragma_define_has_noarg_and_text (p_preprocessor_pragma_define pragma) { int test; test = adms_preprocessor_pragma_define_has_noarg(pragma) && adms_preprocessor_pragma_define_has_text(pragma) ; return test; } int adms_preprocessor_pragma_define_has_nullarg_and_notext (p_preprocessor_pragma_define pragma) { int test; test = adms_preprocessor_pragma_define_has_nullarg(pragma) && adms_preprocessor_pragma_define_has_notext(pragma) ; return test; } int adms_preprocessor_pragma_define_has_nullarg_and_text (p_preprocessor_pragma_define pragma) { int test; test = adms_preprocessor_pragma_define_has_nullarg(pragma) && adms_preprocessor_pragma_define_has_text(pragma) ; return test; } int adms_preprocessor_pragma_define_has_arg_and_notext (p_preprocessor_pragma_define pragma) { int test; test = adms_preprocessor_pragma_define_has_arg(pragma) && adms_preprocessor_pragma_define_has_notext(pragma) ; return test; } int adms_preprocessor_pragma_define_has_arg_and_text (p_preprocessor_pragma_define pragma) { int test; test = adms_preprocessor_pragma_define_has_arg(pragma) && adms_preprocessor_pragma_define_has_text(pragma) ; return test; } static int adms_preprocessor_identifier_is_pragma_cb (p_preprocessor_pragma_define pragma, char * identifier) { return (!!strcmp(pragma->name,identifier)); } typedef int (*Binary) (const void* d1,const void* d2); static p_slist adms_slist_find_custom (p_slist l,const void* data,Binary func) { while(l) { if(!func(l->data,data)) return l; l=l->next; } return ((void *)0); } p_preprocessor_pragma_define adms_preprocessor_pragma_define_exists (char * name) { p_slist Data; p_preprocessor_pragma_define pragma; if((Data=adms_slist_find_custom ( pproot()->Defined,name,(Binary)adms_preprocessor_identifier_is_pragma_cb))) pragma=(p_preprocessor_pragma_define) Data->data; else pragma=NULL; return pragma; } p_preprocessor_pragma_define adms_preprocessor_define_add (char * name) { p_preprocessor_pragma_define pragma; if ((pragma = adms_preprocessor_pragma_define_exists(name))) { if( pragma->isDefined == 1 ) adms_message_warning(("pragma redefined ... '%s'\n",name)) pragma->hasArg = 0; pragma->arg = NULL; pragma->text = NULL; } else { pragma=(p_preprocessor_pragma_define)malloc(sizeof(t_preprocessor_pragma_define)); pragma->hasArg = 0; pragma->arg=NULL; pragma->text=NULL; pragma->name = name; adms_slist_push(&(pproot()->Defined),(p_adms)pragma); } pragma->isDefined = 1; return pragma; } int adms_preprocessor_define_add_default (char * name) { p_preprocessor_pragma_define pragma; pragma = adms_preprocessor_define_add (name); adms_message_verbose(("define macro ... '%s'\n",name)) assert(adms_preprocessor_pragma_define_has_noarg_and_notext(pragma)); return 0; } int adms_preprocessor_define_add_default_with_text (char * name, char * value) { p_slist Text; p_preprocessor_text text; p_preprocessor_pragma_define pragma; text = adms_preprocessor_new_text_as_string(value); Text = adms_slist_new((p_adms)text); pragma = adms_preprocessor_define_add_with_text (name, Text); adms_message_verbose(("define macro with value ... '%s=%s'\n",name, value)) assert(adms_preprocessor_pragma_define_has_noarg_and_text(pragma)); return 0; } p_preprocessor_pragma_define adms_preprocessor_undefine_add (char * name) { p_preprocessor_pragma_define pragma; pragma = adms_preprocessor_pragma_define_exists(name); if(!pragma) { pragma=(p_preprocessor_pragma_define)malloc(sizeof(t_preprocessor_pragma_define)); pragma->arg=NULL; pragma->text=NULL; pragma->name = name; adms_slist_push(&(pproot()->Defined),(p_adms)pragma); } pragma->isDefined = 0; return pragma; } p_preprocessor_pragma_define adms_preprocessor_define_add_with_arg (char * name, p_slist arg) { p_preprocessor_pragma_define pragma; pragma = adms_preprocessor_define_add (name ); pragma->hasArg = 1; pragma->arg = arg; pragma->text = NULL; return pragma; } p_preprocessor_pragma_define adms_preprocessor_define_add_with_text (char * name, p_slist text) { p_preprocessor_pragma_define pragma; pragma = adms_preprocessor_define_add (name ); pragma->hasArg = 0; pragma->arg = NULL; pragma->text = text; return pragma; } p_preprocessor_pragma_define adms_preprocessor_define_add_with_arg_and_text (char * name, p_slist arg, p_slist text) { p_preprocessor_pragma_define pragma; p_slist l; pragma = adms_preprocessor_define_add_with_arg (name, arg ); pragma->text = text; for(l=pragma->text;l;l=l->next) { p_preprocessor_text text=(p_preprocessor_text)(l->data); p_slist ll; for(ll=pragma->arg;ll;ll=ll->next) { if((text->_isarg != -1) && !strcmp(text->_str,(char*)(ll->data))) text->_isarg = 1; } } return pragma; } static p_continuator adms_preprocessor_get_line_position_cb (p_slist l,int mycharpos) { while(l) { p_continuator mycontinuator=(p_continuator)(l->data); if(mycharpos<=mycontinuator->char_position) return mycontinuator; l=l->next; } return NULL; } int adms_preprocessor_get_line_position (p_preprocessor cr_preprocessor, int char_pos) { int line_pos=cr_preprocessor->cur_line_position; p_continuator mycontinuator; p_slist Reversed=adms_slist_reverse(cr_preprocessor->cur_continuator_position); if((mycontinuator=adms_preprocessor_get_line_position_cb(Reversed,char_pos))) line_pos=mycontinuator->line_position; cr_preprocessor->cur_continuator_position = adms_slist_reverse(Reversed ); return line_pos; } ADMS-release-2.3.7/admsXml/preprocessorYacc.y000066400000000000000000000541251371671745500210410ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2014 Francesco Lannutti 2014 Guilherme Brondani Torri 2013 Ryan Fox 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 . */ %name-prefix "preprocessor" %defines %{ #include "admsPreprocessor.h" #define YYDEBUG 1 #define KS(s) adms_k2strconcat(&message,s); #define KI(i) adms_k2strconcat(&message,adms_integertostring(i)); #define K0 KS("[") KS(pproot()->cr_scanner->filename) KS(":") \ KI(adms_preprocessor_get_line_position(pproot()->cr_scanner,0)) KS("]: ") #define DONT_SKIPP (pproot()->skipp_text->data==INT2ADMS(0)) p_slist continuatorList=NULL; p_slist condistrue=NULL; %} %union{ p_slist slist; char* mystr; } %token TK_PRAGMA_NAME %token TK_IDENT %token TK_STRING %token TK_NOT_IDENT %token TK_ARG %token TK_ARG_NULL %token TK_SUBSTITUTOR_NOARG %token TK_SUBSTITUTOR_NULLARG %token TK_SUBSTITUTOR_NULLARG_ALONE %token TK_SUBSTITUTOR_WITHARG %token TK_SUBSTITUTOR_WITHARG_ALONE %token TK_CONTINUATOR %token TK_NOPRAGMA_CONTINUATOR %token TK_EOL %token TK_EOF %token TK_COMMENT %token TK_INCLUDE %token TK_SPACE %token TK_ERROR_PRAGMA_DEFINITION %token TK_ERROR_PRAGMA_NOT_FOUND %token TK_ERROR_UNEXPECTED_CHAR %token TK_ERROR_FILE_OPEN %token TK_DEFINE %token TK_DEFINE_END %token TK_UNDEF %token TK_IFDEF %token TK_IFNDEF %token TK_ELSE %token TK_ENDIF %type R_description %type R_list_of_conditional %type R_conditional %type R_alternative %type R_define_alternative %type R_define_list_of_arg %type R_pragma %type R_define_text %type R_define_notpragma %type R_notpragma %type R_arg_null %type R_substitutor %type R_substitutor_list_of_arg %type R_list_of_arg %type R_list_of_arg_with_comma %type R_arg %type R_other %type R_include %type R_if %type R_ifn %type R_else %type R_endif %type R_substitutor_nullarg %type R_substitutor_witharg %type R_ifdef %type R_ifndef %type R_undef %type R_define %start R_description %% R_description : R_list_of_conditional { pproot()->Text=$1; } ; R_list_of_conditional : R_conditional { $$=$1; } | R_list_of_conditional R_conditional { $$=$2; adms_slist_concat(&($$),$1); } ; R_conditional : R_if R_ifdef R_list_of_conditional R_else R_list_of_conditional R_endif { if(condistrue->data==INT2ADMS(1)) { $$=$6; adms_slist_concat(&($$),$3); } else if(condistrue->data==INT2ADMS(0)) { $$=$5; adms_slist_concat(&($$),$4); } adms_slist_pull(&pproot()->skipp_text); adms_slist_pull(&condistrue); } | R_if R_ifdef R_list_of_conditional R_endif { if(condistrue->data==INT2ADMS(1)) { $$=$3; adms_slist_concat(&($$),$1); } else if(condistrue->data==INT2ADMS(0)) $$=$4; adms_slist_pull(&pproot()->skipp_text); adms_slist_pull(&condistrue); } | R_ifn R_ifndef R_list_of_conditional R_else R_list_of_conditional R_endif { if(condistrue->data==INT2ADMS(1)) { $$=$6; adms_slist_concat(&($$),$3); } else if(condistrue->data==INT2ADMS(0)) { $$=$5; adms_slist_concat(&($$),$4); } adms_slist_pull(&pproot()->skipp_text); adms_slist_pull(&condistrue); } | R_ifn R_ifndef R_list_of_conditional R_endif { if(condistrue->data==INT2ADMS(1)) { $$=$3; adms_slist_concat(&($$),$1); } else if(condistrue->data==INT2ADMS(0)) $$=$4; adms_slist_pull(&pproot()->skipp_text); adms_slist_pull(&condistrue); } | R_alternative { $$=$1; } ; R_if : TK_IFDEF { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } ; R_ifn : TK_IFNDEF { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } ; R_ifdef : TK_PRAGMA_NAME { $$=$1; if(!DONT_SKIPP) { adms_slist_push(&pproot()->skipp_text,INT2ADMS(1)); adms_slist_push(&condistrue,INT2ADMS(-1)); } else if(adms_preprocessor_identifier_is_def($1)) { adms_slist_push(&condistrue,INT2ADMS(1)); adms_slist_push(&pproot()->skipp_text,INT2ADMS(0)); } else { adms_slist_push(&condistrue,INT2ADMS(0)); adms_slist_push(&pproot()->skipp_text,INT2ADMS(1)); } } ; R_ifndef : TK_PRAGMA_NAME { $$=$1; if(!DONT_SKIPP) { adms_slist_push(&pproot()->skipp_text,INT2ADMS(1)); adms_slist_push(&condistrue,INT2ADMS(-1)); } else if(adms_preprocessor_identifier_is_ndef($1)) { adms_slist_push(&condistrue,INT2ADMS(1)); adms_slist_push(&pproot()->skipp_text,INT2ADMS(0)); } else { adms_slist_push(&condistrue,INT2ADMS(0)); adms_slist_push(&pproot()->skipp_text,INT2ADMS(1)); } } ; R_else : TK_ELSE { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); if(condistrue->data==INT2ADMS(0)) pproot()->skipp_text->data=INT2ADMS(0); else if(condistrue->data==INT2ADMS(1)) pproot()->skipp_text->data=INT2ADMS(1); else pproot()->skipp_text->data=INT2ADMS(1); } ; R_endif : TK_ENDIF { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } ; R_include : TK_INCLUDE { p_preprocessor_text newtext; newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } ; R_undef : TK_UNDEF TK_PRAGMA_NAME { $$=$2; } ; R_alternative : R_pragma { $$=$1; } | R_notpragma { $$=$1; } ; R_pragma : R_include { $$=$1; } | R_define_alternative { $$=$1; } | R_undef { $$=NULL; if(DONT_SKIPP) adms_preprocessor_identifer_set_undef($1); } | TK_ERROR_UNEXPECTED_CHAR { $$=NULL; } | TK_ERROR_FILE_OPEN { char*message=NULL; $$=NULL; K0 KS(pproot()->cr_scanner->cur_message) KS("\n") adms_preprocessor_add_message(message); free(pproot()->cr_scanner->cur_message); pproot()->cr_scanner->cur_message=NULL; } | TK_ERROR_PRAGMA_DEFINITION { char*message=NULL; $$=NULL; K0 KS("macro ") KS(pproot()->cr_scanner->cur_message) KS(" badly formed\n") adms_preprocessor_add_message(message); pproot()->error += 1; free(pproot()->cr_scanner->cur_message); pproot()->cr_scanner->cur_message=NULL; } ; R_notpragma : R_substitutor { $$=$1; } | TK_NOPRAGMA_CONTINUATOR { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("\n"); adms_slist_push(&continuatorList,(p_adms)newtext); $$=NULL; } | TK_EOL { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("\n"); $$=adms_slist_new((p_adms)newtext); adms_slist_concat(&($$),continuatorList); continuatorList=NULL; ++pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_char_position=1; pproot()->cr_scanner->cur_continuator_position=NULL; } | R_other { $$=$1; } | TK_ERROR_PRAGMA_NOT_FOUND { char*message=NULL; $$=NULL; K0 KS("macro ") KS(pproot()->cr_scanner->cur_message) KS(" is undefined\n") adms_preprocessor_add_message(message); pproot()->error += 1; free(pproot()->cr_scanner->cur_message); pproot()->cr_scanner->cur_message=NULL; } ; R_define_notpragma : R_substitutor { $$=$1; } | TK_CONTINUATOR { p_preprocessor_text newtext1=adms_preprocessor_new_text_as_string("\n"); p_preprocessor_text newtext2=adms_preprocessor_new_text_as_string(""); adms_slist_push(&continuatorList,(p_adms)newtext1); $$=adms_slist_new((p_adms)newtext2); } | TK_EOL { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); adms_slist_concat(&($$),continuatorList); continuatorList=NULL; ++pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_char_position=1; pproot()->cr_scanner->cur_continuator_position=NULL; } | R_other { $$=$1; } | TK_ERROR_PRAGMA_NOT_FOUND { char*message=NULL; $$=NULL; K0 KS("macro ") KS(pproot()->cr_scanner->cur_message) KS(" is undefined\n") adms_preprocessor_add_message(message); pproot()->error += 1; free(pproot()->cr_scanner->cur_message); pproot()->cr_scanner->cur_message=NULL; } ; R_substitutor : TK_SUBSTITUTOR_NOARG { p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); $$=adms_preprocessor_new_text_as_substitutor(Define,NULL); } | TK_SUBSTITUTOR_NULLARG_ALONE { p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); $$=adms_preprocessor_new_text_as_substitutor(Define,NULL); } | R_substitutor_nullarg R_arg_null { p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); $$=adms_preprocessor_new_text_as_substitutor(Define,NULL); } | R_substitutor_nullarg '(' R_substitutor_list_of_arg ')' { char*message=NULL; p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); $$=adms_preprocessor_new_text_as_substitutor(Define, $3); K0 KS("arguments given to macro `") KS( Define->name) KS("\n") adms_preprocessor_add_message(message); pproot()->error += 1; } | TK_SUBSTITUTOR_WITHARG_ALONE { char*message=NULL; p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); $$=adms_preprocessor_new_text_as_substitutor(Define,NULL); K0 KS("macro `") KS(Define->name) KS(" has no argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n") adms_preprocessor_add_message(message); pproot()->error += 1; adms_slist_push(&($$),(p_adms)$1); } | R_substitutor_witharg R_arg_null { char*message=NULL; p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); $$=adms_preprocessor_new_text_as_substitutor(Define,NULL); K0 KS("macro `") KS(Define->name) KS(" has no argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n") adms_preprocessor_add_message(message); pproot()->error += 1; } | R_substitutor_witharg '(' R_substitutor_list_of_arg ')' { p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1); { if(adms_slist_length($3) == adms_slist_length(Define->arg)) { } else if(adms_slist_length($3) > adms_slist_length(Define->arg)) { if(adms_slist_length($3) == 1) { char*message=NULL; K0 KS("macro `") KS(Define->name) KS(" has one argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n") adms_preprocessor_add_message(message); } else { char*message=NULL; K0 KS("macro `") KS(Define->name) KS(" has too many (") KI(adms_slist_length($3)) KS(") arguments\n") adms_preprocessor_add_message(message); } pproot()->error += 1; } else { if(adms_slist_length($3) == 1) { char*message=NULL; K0 KS("macro `") KS(Define->name) KS(" has one argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n") adms_preprocessor_add_message(message); } else { char*message=NULL; K0 KS("macro `") KS(Define->name) KS(" has too few (") KI(adms_slist_length($3)) KS(") arguments\n") adms_preprocessor_add_message(message); } pproot()->error += 1; } } $$=adms_preprocessor_new_text_as_substitutor(Define, $3); } ; R_substitutor_nullarg : TK_SUBSTITUTOR_NULLARG TK_SPACE { $$=$1; } | TK_SUBSTITUTOR_NULLARG { $$=$1; } ; R_substitutor_witharg : TK_SUBSTITUTOR_WITHARG TK_SPACE { $$=$1; } | TK_SUBSTITUTOR_WITHARG { $$=$1; } ; R_arg_null : '(' ')' { } ; R_substitutor_list_of_arg : R_list_of_arg { $$=adms_slist_new((p_adms)$1); } | R_substitutor_list_of_arg ',' R_list_of_arg { adms_slist_push(&($1),(p_adms)$3); $$=$1; } ; R_list_of_arg : R_arg { $$=$1; } | R_list_of_arg R_arg { $$=$2; adms_slist_concat(&($$),$1); } ; R_list_of_arg_with_comma : R_list_of_arg { $$=$1; } | R_list_of_arg_with_comma ',' R_list_of_arg { p_preprocessor_text comma=adms_preprocessor_new_text_as_string(","); adms_slist_push(&($1),(p_adms)comma); $$=$3; adms_slist_concat(&($$),$1); } ; R_arg : TK_SPACE { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_CONTINUATOR { /* SRW - fix bsim6.va parse problem, string macro arg broken by * continuator caused 'unexpected end of line' error. */ $$=0; } | TK_COMMENT { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_EOL { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("\n"); ++pproot()->cr_scanner->cur_line_position; pproot()->cr_scanner->cur_char_position=1; pproot()->cr_scanner->cur_continuator_position=NULL; $$=adms_slist_new((p_adms)newtext); } | '(' R_list_of_arg_with_comma ')' { p_preprocessor_text lparen=adms_preprocessor_new_text_as_string("("); p_preprocessor_text rparen=adms_preprocessor_new_text_as_string(")"); $$=$2; adms_slist_concat(&($$),adms_slist_new((p_adms)lparen)); adms_slist_push(&($$),(p_adms)rparen); } | '(' ')' { p_preprocessor_text lparen=adms_preprocessor_new_text_as_string("("); p_preprocessor_text rparen=adms_preprocessor_new_text_as_string(")"); $$=adms_slist_new((p_adms)lparen); adms_slist_push(&($$),(p_adms)rparen); } | TK_IDENT { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_STRING { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_NOT_IDENT { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | R_substitutor { $$=$1; } ; R_other : '(' { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("("); $$=adms_slist_new((p_adms)newtext); } | ')' { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string(")"); $$=adms_slist_new((p_adms)newtext); } | ',' { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string(","); $$=adms_slist_new((p_adms)newtext); } | TK_IDENT { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_NOT_IDENT { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_STRING { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_SPACE { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_COMMENT { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } | TK_EOF { p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1); $$=adms_slist_new((p_adms)newtext); } ; R_define_alternative : R_define TK_DEFINE_END { p_preprocessor_pragma_define Define; if(DONT_SKIPP) Define=adms_preprocessor_define_add($1); $$=NULL; } | R_define R_define_text TK_DEFINE_END { p_preprocessor_pragma_define Define; if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_text($1, $2); $$=NULL; } | R_define TK_ARG_NULL TK_DEFINE_END { p_preprocessor_pragma_define Define; if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg($1, NULL); $$=NULL; } | R_define TK_ARG_NULL R_define_text TK_DEFINE_END { p_preprocessor_pragma_define Define; if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg_and_text($1, NULL, $3); $$=NULL; } | R_define R_define_list_of_arg TK_DEFINE_END { p_preprocessor_pragma_define Define; if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg($1, $2); $$=NULL; } | R_define R_define_list_of_arg R_define_text TK_DEFINE_END { p_preprocessor_pragma_define Define; if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg_and_text($1, $2, $3); $$=NULL; } ; R_define : TK_DEFINE TK_PRAGMA_NAME { $$=$2; } ; R_define_list_of_arg : TK_ARG { $$=adms_slist_new((p_adms)$1); } | R_define_list_of_arg TK_ARG { adms_slist_push(&($1),(p_adms)$2); $$=$1; } ; R_define_text : R_define_notpragma { $$=$1; } | R_define_text R_define_notpragma { $$=$2; adms_slist_concat(&($$),$1); } ; %% int adms_preprocessor_getint_yydebug(void) { return yydebug; } void adms_preprocessor_setint_yydebug(const int val) { yydebug=val; } ADMS-release-2.3.7/admsXml/verilogaLex.l000066400000000000000000000222071371671745500177530ustar00rootroot00000000000000/* This file is part of adms - http://sourceforge.net/projects/mot-adms. adms is a code generator for the Verilog-AMS language. Copyright (C) 2002-2012 Laurent Lemaitre 2014-08-12 Guilherme Brondani Torri 2013-07-24 Bastien ROUCARIÈS 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 . */ %option outfile="verilogaLex.c" %option prefix="veriloga" %{ #include "admsVeriloga.h" #include "verilogaYacc.h" static int adms_strtointeger (const char *mystr) { int val; errno=0; val=(int)strtol(mystr,NULL,10); if(errno) adms_message_fatal(("%s: strtoint conversion failed\n",mystr)) return val; } void adms_veriloga_setfile_input (FILE *ifile) { yyin=ifile; } void verilogaerror (const char *s) { adms_message_fatal(("%s: during lexical analysis %s at line %i -- see '%s'\n",root()->_curfilename,s,root()->_curline,verilogatext)) } void POS_UPDATE(const int myyyleng,const char*myyytext) { int c=root()->_fpos; adms_message_dbg_vla(("%s:%i:%i-%i read token '%s'\n",root()->_curfilename, root()->_curline,c+1,c+myyyleng,myyytext)) adms_admsmain_valueto_fpos(root(),c+myyyleng); } void TKRETURN(const char*myyytext, const int myyyleng) { verilogalval._lexval=adms_lexval_new(myyytext,root()->_curfilename,root()->_curline,root()->_fpos+1); POS_UPDATE(myyyleng,myyytext); } void TKSTRIPPEDRETURN(const char*myyytext, const int myyyleng) { char*mystrippedstring; int mynewlen=strlen(myyytext)-2; assert(mynewlen>=0); mystrippedstring=(char*)malloc(mynewlen+1); if(mystrippedstring) { strncpy(mystrippedstring,myyytext+1,mynewlen); mystrippedstring[mynewlen]='\0'; } POS_UPDATE(myyyleng,myyytext); verilogalval._lexval=adms_lexval_new( mystrippedstring, root()->_curfilename, root()->_curline, root()->_fpos ); free(mystrippedstring); } #ifdef YYDEBUG extern int yydebug; #endif %} whitespace0 [ \t\v\f]* whitespace [ \t\v\f]+ newline \r?\n wn [ \t\v\f\r?\n] wn0 [ \t\v\f\r?\n]* wn1 [ \t\v\f\r?\n]+ ident [A-Za-z_][A-Za-z0-9_]* attribute [A-Za-z_][A-Za-z0-9_:.]* attributevalue {wn0}={wn0}{anystring} anystring \"([^\"]|\\\")*\" b8_int 0[0-9]* b10_uint [1-9][0-9]* b16_int 0[xX][0-9A-Fa-f]+ float [0-9]*\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+\.?([eE][+-]?[0-9]+)? char \'[^\']*[\'\n] %x insideAttribute %x insideAttributeBegin %x insideAttributeEqual %x insideAttributeValue %x insideAttributeEnd %x insidePragma %option nounput %% {newline} { adms_admsmain_valueto_curline(root(),root()->_curline+1); adms_admsmain_valueto_fpos(root(),0); } ^#{whitespace} {BEGIN(insidePragma);} {whitespace} {POS_UPDATE(yyleng,yytext);} { {anystring} { char*mystrippedstring; int mynewlen=strlen(yytext)-2; assert(mynewlen>=0); mystrippedstring=(char*)malloc(mynewlen+1); if(mystrippedstring) { strncpy(mystrippedstring,yytext+1,mynewlen); mystrippedstring[mynewlen]='\0'; } adms_admsmain_valueto_curfilename(root(),mystrippedstring); free(mystrippedstring); } {b10_uint} { adms_admsmain_valueto_curline(root(),adms_strtointeger(yytext)); adms_admsmain_valueto_fpos(root(),0); } {newline} { BEGIN(INITIAL); adms_admsmain_valueto_fpos(root(),0); } {whitespace} {POS_UPDATE(yyleng,yytext);} . { adms_message_fatal(("[%s:%i]: inside pragma declaration unexpected character at [%s]\n",root()->_curfilename,root()->_curline,yytext)) } } {anystring} {TKSTRIPPEDRETURN(yytext,yyleng); return tk_anystring;} "(*"{wn0} {BEGIN(insideAttribute); {TKRETURN(yytext,yyleng); return tk_beginattribute;}} { "*)" {BEGIN(INITIAL);TKRETURN(yytext,yyleng);return tk_endattribute;} {attribute}{attributevalue} {BEGIN(insideAttributeBegin);yyless(0);} . { char myyytext[1000]; register int i=0; myyytext[i]=yytext[0]; for(;;) { while((myyytext[i]!='*')&&(myyytext[i]!=EOF)) { myyytext[++i]=input(); } if(myyytext[i]=='*') { while((myyytext[++i]=input())=='*') ; if(myyytext[i]==')') { BEGIN(INITIAL); i-=2; while(myyytext[i]==' ') i--; myyytext[i+1]='\0'; POS_UPDATE(yyleng,yytext); verilogalval._lexval=adms_lexval_new( myyytext, root()->_curfilename, root()->_curline, root()->_fpos ); return tk_anytext; } } if(myyytext[i]==EOF) { adms_message_fatal(("[%s:%i]: inside Verilog-ams EOF found in attribute declaration [%s]\n",root()->_curfilename,root()->_curline,yytext)) } } } } { {attribute} {BEGIN(insideAttributeEqual);TKRETURN(yytext,yyleng);return tk_ident;} . { adms_message_fatal(("[%s:%i]: inside Verilog-ams attribute declaration unexpected character at [%s]\n",root()->_curfilename,root()->_curline,yytext)) } } { {wn0}={wn0} {BEGIN(insideAttributeValue);return '=';} . { adms_message_fatal(("[%s:%i]: inside Verilog-ams attribute declaration unexpected character at [%s]\n",root()->_curfilename,root()->_curline,yytext)) } } { {anystring} {TKSTRIPPEDRETURN(yytext,yyleng);BEGIN(insideAttributeEnd);return tk_anystring;} . { adms_message_fatal(("[%s:%i]: inside Verilog-ams attribute declaration unexpected character at [%s]\n",root()->_curfilename,root()->_curline,yytext)) } } { {wn0}"*)" {BEGIN(INITIAL);TKRETURN(yytext,yyleng);return tk_endattribute;} {wn1} {BEGIN(insideAttributeBegin);POS_UPDATE(yyleng,yytext);} {wn0},{wn0} {BEGIN(insideAttributeBegin);POS_UPDATE(yyleng,yytext);} {attribute}{attributevalue} {BEGIN(insideAttributeBegin);yyless(0);} . { adms_message_fatal(("[%s:%i]: inside Verilog-ams attribute declaration unexpected character at [%s]\n",root()->_curfilename,root()->_curline,yytext)) } } parameter {TKRETURN(yytext,yyleng); return tk_parameter;} aliasparameter {TKRETURN(yytext,yyleng); return tk_aliasparameter;} aliasparam {TKRETURN(yytext,yyleng); return tk_aliasparam;} module {TKRETURN(yytext,yyleng); return tk_module;} endmodule {TKRETURN(yytext,yyleng); return tk_endmodule;} function {TKRETURN(yytext,yyleng); return tk_function;} endfunction {TKRETURN(yytext,yyleng); return tk_endfunction;} discipline {TKRETURN(yytext,yyleng); return tk_discipline;} potential {TKRETURN(yytext,yyleng); return tk_potential;} flow {TKRETURN(yytext,yyleng); return tk_flow;} domain {TKRETURN(yytext,yyleng); return tk_domain;} ground {TKRETURN(yytext,yyleng); return tk_ground;} enddiscipline {TKRETURN(yytext,yyleng); return tk_enddiscipline;} nature {TKRETURN(yytext,yyleng); return tk_nature;} endnature {TKRETURN(yytext,yyleng); return tk_endnature;} input {TKRETURN(yytext,yyleng); return tk_input;} output {TKRETURN(yytext,yyleng); return tk_output;} inout {TKRETURN(yytext,yyleng); return tk_inout;} branch {TKRETURN(yytext,yyleng); return tk_branch;} analog {TKRETURN(yytext,yyleng); return tk_analog;} begin {TKRETURN(yytext,yyleng); return tk_begin;} end {TKRETURN(yytext,yyleng); return tk_end;} if {TKRETURN(yytext,yyleng); return tk_if;} while {TKRETURN(yytext,yyleng); return tk_while;} case {TKRETURN(yytext,yyleng); return tk_case;} endcase {TKRETURN(yytext,yyleng); return tk_endcase;} default {TKRETURN(yytext,yyleng); return tk_default;} for {TKRETURN(yytext,yyleng); return tk_for;} else {TKRETURN(yytext,yyleng); return tk_else;} integer {TKRETURN(yytext,yyleng); return tk_integer;} real {TKRETURN(yytext,yyleng); return tk_real;} string {TKRETURN(yytext,yyleng); return tk_string;} from {TKRETURN(yytext,yyleng); return tk_from;} exclude {TKRETURN(yytext,yyleng); return tk_exclude;} inf {TKRETURN(yytext,yyleng); return tk_inf;} INF {TKRETURN(yytext,yyleng); return tk_inf;} {ident} { TKRETURN(yytext,yyleng); switch (verilogactx()){ case ctx_moduletop: if (adms_admsmain_list_discipline_lookup_by_id(root(),yytext)) { return tk_disc_id; } default: return tk_ident; } } \>\> {TKRETURN(yytext,yyleng); return tk_op_shr;} \<\< {TKRETURN(yytext,yyleng); return tk_op_shl;} \&\& {TKRETURN(yytext,yyleng); return tk_and;} \|\| {TKRETURN(yytext,yyleng); return tk_or;} \^\~ {TKRETURN(yytext,yyleng); return tk_bitwise_equr;} \${ident} {TKRETURN(yytext,yyleng); return tk_dollar_ident;} {char} {TKSTRIPPEDRETURN(yytext,yyleng); return tk_char;} {b8_int} {TKRETURN(yytext,yyleng); return tk_integer;} {b10_uint} {TKRETURN(yytext,yyleng); return tk_integer;} {b16_int} {TKRETURN(yytext,yyleng); return tk_integer;} {float} {TKRETURN(yytext,yyleng); return tk_number;} . {POS_UPDATE(yyleng,yytext);return yytext[0];} %% int yywrap (void) {return 1;} // vim:sw=2:ts=8:noet: ADMS-release-2.3.7/admsXml/verilogaYacc.y.in000066400000000000000000002134071371671745500205300ustar00rootroot00000000000000%name-prefix "veriloga" %defines %{ #define YYDEBUG 1 #include "admsVeriloga.h" static e_verilogactx ctx; e_verilogactx verilogactx (){return ctx;} void set_context(e_verilogactx x){ctx=x;} #define NEWVARIABLE(l) p_variableprototype myvariableprototype=adms_variableprototype_new(gModule,l,(p_adms)gBlockList->data); inline static void Y (p_yaccval myyaccval,p_adms myusrdata) {myyaccval->_usrdata=myusrdata;} inline static p_adms YY(p_yaccval myyaccval) {return myyaccval->_usrdata;} static char* gNatureAccess=NULL; static p_number gNatureAbsTol=NULL; static char* gNatureUnits=NULL; static char* gNatureidt=NULL; static char* gNatureddt=NULL; static char* gDisc=NULL; static p_discipline gDiscipline=NULL; static p_module gModule=NULL; static p_analogfunction gAnalogfunction=NULL; static p_module gInstanceModule=NULL; static p_node gGND=NULL; static p_source gSource=NULL; static p_lexval gLexval=NULL; static p_contribution gContribution=NULL; static admse gVariableType=admse_real; static admse gNodeDirection; int uid=0; static p_slist gVariableDeclarationList=NULL; static p_slist gInstanceVariableList=NULL; static p_slist gTerminalList=NULL; static p_slist gBranchAliasList=NULL; static p_slist gRangeList=NULL; static p_slist gNodeList=NULL; static p_slist gAttributeList=NULL; static p_slist gGlobalAttributeList=NULL; static p_slist gBlockList=NULL; static p_slist gBlockVariableList=NULL; static p_branchalias gBranchAlias=NULL; static void adms_veriloga_message_fatal_continue(const p_lexval mytoken) { adms_message_fatal_continue(("[%s:%i:%i]: at '%s':\n",mytoken->_f,mytoken->_l,mytoken->_c,mytoken->_string)) } static void adms_veriloga_message_fatal (const char* message,const p_lexval mytoken) { adms_veriloga_message_fatal_continue(mytoken); adms_message_fatal((message)) } /* inline static p_variableprototype variableprototype_recursive_lookup_by_id (p_adms myadms,p_lexval mylexval) { if(myadms==(p_adms)gModule) return adms_module_list_variable_lookup_by_id(gModule,gModule,mylexval,(p_adms)gModule); else if(myadms==(p_adms)gAnalogfunction) return adms_analogfunction_list_variable_lookup_by_id(gAnalogfunction,gModule,mylexval,(p_adms)gAnalogfunction); else { p_slist l; for(l=((p_block)myadms)->_variable;l;l=l->next) if(!strcmp(((p_variableprototype)l->data)->_lexval->_string,mylexval->_string)) return (p_variableprototype)l->data; return variableprototype_recursive_lookup_by_id((p_adms)((p_block)myadms)->_block,mylexval); } } */ inline static p_variable variable_recursive_lookup_by_id (p_adms myadms,p_lexval mylexval) { if(myadms==(p_adms)gModule) { p_variable myvariable=NULL; p_variableprototype myvariableprototype; if((myvariableprototype=adms_module_list_variable_lookup_by_id(gModule,gModule,mylexval,(p_adms)gModule))) { myvariable=adms_variable_new(myvariableprototype); adms_slist_push(&myvariableprototype->_instance,(p_adms)myvariable); } return myvariable; } else if(myadms==(p_adms)gAnalogfunction) { p_variable myvariable=NULL; p_variableprototype myvariableprototype; if((myvariableprototype=adms_analogfunction_list_variable_lookup_by_id(gAnalogfunction,gModule,mylexval,(p_adms)gAnalogfunction))) { myvariable=adms_variable_new(myvariableprototype); adms_slist_push(&myvariableprototype->_instance,(p_adms)myvariable); } return myvariable; } else { p_slist l; for(l=((p_block)myadms)->_variable;l;l=l->next) if(!strcmp(((p_variableprototype)l->data)->_lexval->_string,mylexval->_string)) { p_variableprototype myvariableprototype=(p_variableprototype)l->data; p_variable myvariable=adms_variable_new(myvariableprototype); adms_slist_push(&myvariableprototype->_instance,(p_adms)myvariable); return myvariable; } return variable_recursive_lookup_by_id((p_adms)((p_block)myadms)->_block,mylexval); } } static p_nature lookup_nature(const char *myname) { p_slist l; for(l=root()->_nature;l;l=l->next) if(!strcmp(((p_nature)l->data)->_name,myname)) return (p_nature)l->data; return NULL; } %} %left PREC_IF_THEN %left tk_else %union { p_lexval _lexval; p_yaccval _yaccval; } R_admsParse | R_l.admsParse ; R_l.admsParse | R_s.admsParse | R_l.admsParse R_s.admsParse ; R_s.admsParse | R_d.module | R_discipline_member | R_nature_member ; R_discipline_member | tk_discipline R_discipline_name R_l.discipline_assignment tk_enddiscipline _ adms_admsmain_list_discipline_prepend_once_or_abort(root(),gDiscipline); _ gDiscipline=NULL; ; R_discipline_name | tk_ident _ gDiscipline=adms_discipline_new(mylexval1); ; R_l.discipline_assignment | R_s.discipline_assignment | R_l.discipline_assignment R_s.discipline_assignment ; R_s.discipline_assignment | tk_potential R_discipline.naturename ';' _ gDiscipline->_potential=(p_nature)YY($2); | tk_flow R_discipline.naturename ';' _ gDiscipline->_flow=(p_nature)YY($2); | tk_domain tk_ident ';' _ if(!strcmp(mylexval2,"discrete")) _ gDiscipline->_domain=admse_discrete; _ else if(!strcmp(mylexval2,"continuous")) _ gDiscipline->_domain=admse_continuous; _ else _ adms_veriloga_message_fatal("domain: bad value given - should be either 'discrete' or 'continuous'\n",$2); ; R_discipline.naturename | tk_ident _ p_nature mynature=lookup_nature(mylexval1); _ if(!mynature) _ adms_veriloga_message_fatal("can't find nature definition\n",$1); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mynature); ; R_nature_member | tk_nature tk_ident R_l.nature_assignment tk_endnature _ p_nature mynature=NULL; _ if(gNatureAccess) _ mynature=adms_admsmain_list_nature_prepend_by_id_once_or_abort(root(),gNatureAccess); _ else _ adms_veriloga_message_fatal("attribute 'access' in nature definition not found\n",$2); _ adms_nature_valueto_name(mynature,mylexval2); _ if(gNatureidt) _ adms_nature_valueto_idt_name(mynature,gNatureidt); _ if(gNatureddt) _ adms_nature_valueto_ddt_name(mynature,gNatureddt); _ if(gNatureUnits) _ mynature->_units=gNatureUnits; _ if(gNatureAbsTol) _ mynature->_abstol=gNatureAbsTol; _ gNatureAccess=NULL; _ gNatureAbsTol=NULL; _ gNatureUnits=NULL; _ gNatureidt=NULL; _ gNatureddt=NULL; ; R_l.nature_assignment | R_s.nature_assignment | R_l.nature_assignment R_s.nature_assignment ; R_s.nature_assignment | tk_ident '=' tk_number ';' _ if(!strcmp($1->_string,"abstol")) _ { _ if(gNatureAbsTol) _ adms_veriloga_message_fatal("nature attribute defined more than once\n",$1); _ gNatureAbsTol=adms_number_new($3); _ } _ else _ adms_veriloga_message_fatal("unknown nature attribute\n",$1); | tk_ident '=' tk_number tk_ident ';' _ admse myunit=admse_1; _ if(!strcmp($1->_string,"abstol")) _ { _ if(gNatureAbsTol) _ adms_veriloga_message_fatal("nature attribute defined more than once\n",$1); _ gNatureAbsTol=adms_number_new($3); _ } _ else _ adms_veriloga_message_fatal("unknown nature attribute\n",$1); _ if(0) {} _ else if(!strcmp(mylexval4,"E")) myunit=admse_E; _ else if(!strcmp(mylexval4,"P")) myunit=admse_P; _ else if(!strcmp(mylexval4,"T")) myunit=admse_T; _ else if(!strcmp(mylexval4,"G")) myunit=admse_G; _ else if(!strcmp(mylexval4,"M")) myunit=admse_M; _ else if(!strcmp(mylexval4,"K")) myunit=admse_K; _ else if(!strcmp(mylexval4,"k")) myunit=admse_k; _ else if(!strcmp(mylexval4,"h")) myunit=admse_h; _ else if(!strcmp(mylexval4,"D")) myunit=admse_D; _ else if(!strcmp(mylexval4,"d")) myunit=admse_d; _ else if(!strcmp(mylexval4,"c")) myunit=admse_c; _ else if(!strcmp(mylexval4,"m")) myunit=admse_m; _ else if(!strcmp(mylexval4,"u")) myunit=admse_u; _ else if(!strcmp(mylexval4,"n")) myunit=admse_n; _ else if(!strcmp(mylexval4,"A")) myunit=admse_A; _ else if(!strcmp(mylexval4,"p")) myunit=admse_p; _ else if(!strcmp(mylexval4,"f")) myunit=admse_f; _ else if(!strcmp(mylexval4,"a")) myunit=admse_a; _ else _ adms_veriloga_message_fatal("can not convert symbol to valid unit\n",$4); _ gNatureAbsTol->_scalingunit=myunit; | tk_ident '=' tk_anystring ';' _ if(!strcmp($1->_string,"units")) _ { _ if(gNatureUnits) _ adms_veriloga_message_fatal("nature attribute defined more than once\n",$1); _ gNatureUnits=adms_kclone(mylexval3); _ } _ else _ adms_veriloga_message_fatal("unknown nature attribute\n",$1); | tk_ident '=' tk_ident ';' _ if(!strcmp($1->_string,"access")) _ { _ if(gNatureAccess) _ adms_veriloga_message_fatal("nature attribute defined more than once\n",$1); _ gNatureAccess=adms_kclone(mylexval3); _ } _ else if(!strcmp($1->_string,"idt_nature")) _ { _ if(gNatureidt) _ adms_veriloga_message_fatal("idt_nature attribute defined more than once\n",$1); _ gNatureidt=adms_kclone(mylexval3); _ } _ else if(!strcmp($1->_string,"ddt_nature")) _ { _ if(gNatureddt) _ adms_veriloga_message_fatal("ddt_nature attribute defined more than once\n",$1); _ gNatureddt=adms_kclone(mylexval3); _ } _ else _ adms_veriloga_message_fatal("unknown nature attribute\n",$1); ; R_d.attribute.0 | | R_d.attribute ; R_d.attribute | tk_beginattribute R_l.attribute tk_endattribute | tk_beginattribute tk_anytext _ p_attribute myattribute=adms_attribute_new("ibm"); _ p_admst myconstant=adms_admst_newks(adms_kclone(mylexval2)); _ myattribute->_value=(p_adms)myconstant; _ adms_slist_push(&gAttributeList,(p_adms)myattribute); | tk_beginattribute tk_endattribute ; R_l.attribute | R_s.attribute | R_l.attribute R_s.attribute ; R_s.attribute | tk_ident '=' tk_anystring _ p_attribute myattribute=adms_attribute_new(mylexval1); _ p_admst myconstant=adms_admst_newks(adms_kclone(mylexval3)); _ myattribute->_value=(p_adms)myconstant; _ adms_slist_push(&gAttributeList,(p_adms)myattribute); ; R_d.module | R_d.attribute.0 tk_module tk_ident _ p_slist l; _ p_nodealias mynodealias; _ gModule=adms_admsmain_list_module_prepend_by_id_once_or_abort(root(),mylexval3); _ adms_slist_push(&gBlockList,(p_adms)gModule); _ mynodealias=adms_module_list_nodealias_prepend_by_id_once_or_abort(gModule,gModule,"0"); _ gGND=adms_module_list_node_prepend_by_id_once_or_abort(gModule,gModule,"GND"); _ mynodealias->_node=gGND; _ gGND->_location=admse_ground; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&gModule->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; R_d.terminal _ set_context(ctx_moduletop); R_modulebody tk_endmodule _ adms_slist_pull(&gBlockList); _ adms_slist_inreverse(&gModule->_assignment); ; R_modulebody | | R_l.declaration | R_netlist | R_l.declaration R_netlist ; R_netlist | R_analog | R_l.instance | R_l.instance R_analog | R_analog R_l.instance | R_l.instance R_analog R_l.instance ; R_l.instance | R_s.instance | R_l.instance R_s.instance ; R_d.terminal | '(' R_l.terminal.0 ')' R_d.attribute.0 ';' _ p_slist l; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&gModule->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; ; R_l.terminal.0 | | R_l.terminal ; R_l.terminal | R_s.terminal | R_l.terminal ',' R_s.terminal ; R_s.terminal | tk_ident _ p_nodealias mynodealias=adms_module_list_nodealias_prepend_by_id_once_or_abort(gModule,gModule,mylexval1); _ p_node mynode=adms_module_list_node_prepend_by_id_once_or_abort(gModule,gModule,mylexval1); _ mynodealias->_node=mynode; _ mynode->_location=admse_external; ; R_l.declaration | R_s.declaration.withattribute | R_l.declaration R_s.declaration.withattribute ; R_s.declaration.withattribute | R_s.declaration _ set_context(ctx_moduletop); | R_d.attribute.global R_s.declaration _ adms_slist_free(gGlobalAttributeList); gGlobalAttributeList=NULL; _ set_context(ctx_moduletop); ; R_d.attribute.global | R_d.attribute _ gGlobalAttributeList=gAttributeList; _ gAttributeList=NULL; ; R_s.declaration | R_d.node | R_d.branch | tk_parameter _ set_context(ctx_any); R_variable.type R_l.parameter R_d.variable.end | tk_parameter _ set_context(ctx_any); R_l.parameter R_d.variable.end | R_variable.type _ set_context(ctx_any); R_l.variable R_d.variable.end | R_d.aliasparameter | R_d.analogfunction | ';' ; R_d.node | R_node.type _ set_context(ctx_any); R_l.terminalnode ';' _ p_slist l; _ for(l=gTerminalList;l;l=l->next) _ ((p_node)l->data)->_direction=gNodeDirection; _ adms_slist_free(gTerminalList); gTerminalList=NULL; | tk_ground _ set_context(ctx_any); R_l.node ';' _ p_slist l; _ for(l=gNodeList;l;l=l->next) _ ((p_node)l->data)->_location=admse_ground; _ adms_slist_free(gNodeList); gNodeList=NULL; | tk_disc_id _ set_context(ctx_any); _ gDisc=mylexval1; R_l.node ';' _ char* mydisciplinename=gDisc; _ p_discipline mydiscipline=adms_admsmain_list_discipline_lookup_by_id(root(),mydisciplinename); _ p_slist l; _ for(l=gNodeList;l;l=l->next) _ ((p_node)l->data)->_discipline=mydiscipline; _ adms_slist_free(gNodeList); gNodeList=NULL; ; R_node.type | tk_input _ gNodeDirection=admse_input; | tk_output _ gNodeDirection=admse_output; | tk_inout _ gNodeDirection=admse_inout; ; R_l.terminalnode | R_s.terminalnode | R_l.terminalnode ',' R_s.terminalnode ; R_l.node | R_s.node | R_l.node ',' R_s.node ; R_s.terminalnode | tk_ident R_d.attribute.0 _ p_slist l; _ p_node mynode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval1); _ if(!mynode) _ adms_veriloga_message_fatal("terminal not found\n",$1); _ if(mynode->_location!=admse_external) _ adms_veriloga_message_fatal("node not a terminal\n",$1); _ adms_slist_push(&gTerminalList,(p_adms)mynode); _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&mynode->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&mynode->_attribute,l->data); ; R_s.node | tk_ident R_d.attribute.0 _ p_slist l; _ p_node mynode=adms_module_list_node_prepend_by_id_once_or_ignore(gModule,gModule,mylexval1); _ adms_slist_push(&gNodeList,(p_adms)mynode); _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&mynode->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&mynode->_attribute,l->data); ; R_d.branch | tk_branch R_s.branch ';' ; R_l.branchalias | R_s.branchalias | R_l.branchalias ',' R_s.branchalias ; R_s.branchalias | tk_ident _ adms_slist_push(&gBranchAliasList,(p_adms)mylexval1); ; R_s.branch | '(' tk_ident ',' tk_ident ')' R_l.branchalias _ p_slist l; _ p_branch mybranch; _ p_node pnode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval2); _ p_node nnode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval4); _ mybranch=adms_module_list_branch_prepend_by_id_once_or_ignore(gModule,gModule,pnode,nnode); _ if(!pnode) _ adms_veriloga_message_fatal("node never declared\n",$2); _ if(!nnode) _ adms_veriloga_message_fatal("node never declared\n",$4); _ for(l=gBranchAliasList;l;l=l->next) _ { _ char*aliasname=(char*)l->data; _ p_branchalias mybranchalias; _ mybranchalias=adms_module_list_branchalias_prepend_by_id_once_or_abort(gModule,gModule,aliasname); _ if(mybranchalias) mybranchalias->_branch=mybranch; _ } _ adms_slist_free(gBranchAliasList); _ gBranchAliasList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&mybranch->_attribute,l->data); | '(' tk_ident ')' R_l.branchalias _ p_slist l; _ p_branch mybranch; _ p_node pnode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval2); _ if(!pnode) _ adms_veriloga_message_fatal("node never declared\n",$2); _ mybranch=adms_module_list_branch_prepend_by_id_once_or_ignore(gModule,gModule,pnode,gGND); _ for(l=gBranchAliasList;l;l=l->next) _ { _ char*aliasname=(char*)l->data; _ p_branchalias mybranchalias; _ mybranchalias=adms_module_list_branchalias_prepend_by_id_once_or_abort(gModule,gModule,aliasname); _ if(mybranchalias) mybranchalias->_branch=mybranch; _ } _ adms_slist_free(gBranchAliasList); _ gBranchAliasList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&mybranch->_attribute,l->data); ; R_d.analogfunction | R_d.analogfunction.proto R_l.analogfunction.declaration R_analogcode.block tk_endfunction _ adms_slist_pull(&gBlockList); _ gAnalogfunction->_tree=YY($3); _ gAnalogfunction=NULL; ; R_d.analogfunction.proto | tk_analog tk_function R_d.analogfunction.name ';' _ NEWVARIABLE(gAnalogfunction->_lexval) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_output=admse_yes; | tk_analog tk_function tk_integer R_d.analogfunction.name ';' _ NEWVARIABLE(gAnalogfunction->_lexval) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_output=admse_yes; _ myvariableprototype->_type=admse_integer; _ gAnalogfunction->_type=admse_integer; | tk_analog tk_function tk_real R_d.analogfunction.name ';' _ NEWVARIABLE(gAnalogfunction->_lexval) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_output=admse_yes; ; R_d.analogfunction.name | tk_ident _ p_slist l; _ gAnalogfunction=adms_analogfunction_new(gModule,$1); _ adms_slist_push(&gBlockList,(p_adms)gAnalogfunction); _ adms_module_list_analogfunction_prepend_once_or_abort(gModule,gAnalogfunction); _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&gAnalogfunction->_attribute,l->data); ; R_l.analogfunction.declaration | R_s.analogfunction.declaration | R_l.analogfunction.declaration R_s.analogfunction.declaration ; R_s.analogfunction.declaration | tk_input R_l.analogfunction.input.variable ';' | tk_output R_l.analogfunction.output.variable ';' | tk_inout R_l.analogfunction.inout.variable ';' | tk_integer R_l.analogfunction.integer.variable ';' | tk_real R_l.analogfunction.real.variable ';' ; R_l.analogfunction.input.variable | tk_ident _ NEWVARIABLE($1) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_input=admse_yes; _ myvariableprototype->_parametertype=admse_analogfunction; | R_l.analogfunction.input.variable ',' tk_ident _ NEWVARIABLE($3) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_input=admse_yes; _ myvariableprototype->_parametertype=admse_analogfunction; ; R_l.analogfunction.output.variable | tk_ident _ NEWVARIABLE($1) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_output=admse_yes; _ myvariableprototype->_parametertype=admse_analogfunction; | R_l.analogfunction.output.variable ',' tk_ident _ NEWVARIABLE($3) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_output=admse_yes; _ myvariableprototype->_parametertype=admse_analogfunction; ; R_l.analogfunction.inout.variable | tk_ident _ NEWVARIABLE($1) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_input=admse_yes; _ myvariableprototype->_output=admse_yes; _ myvariableprototype->_parametertype=admse_analogfunction; | R_l.analogfunction.inout.variable ',' tk_ident _ NEWVARIABLE($3) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_input=admse_yes; _ myvariableprototype->_output=admse_yes; _ myvariableprototype->_parametertype=admse_analogfunction; ; R_l.analogfunction.integer.variable | tk_ident _ p_variableprototype myvariableprototype=adms_analogfunction_list_variable_lookup_by_id(gAnalogfunction,gModule,$1,(p_adms)gAnalogfunction); _ if(myvariableprototype) _ myvariableprototype->_type=admse_integer; _ else _ { _ NEWVARIABLE($1) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_type=admse_integer; _ } | R_l.analogfunction.integer.variable ',' tk_ident _ p_variableprototype myvariableprototype=adms_analogfunction_list_variable_lookup_by_id(gAnalogfunction,gModule,$3,(p_adms)gAnalogfunction); _ if(myvariableprototype) _ myvariableprototype->_type=admse_integer; _ else _ { _ NEWVARIABLE($3) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_type=admse_integer; _ } ; R_l.analogfunction.real.variable | tk_ident _ p_variableprototype myvariableprototype=adms_analogfunction_list_variable_lookup_by_id(gAnalogfunction,gModule,$1,(p_adms)gAnalogfunction); _ if(myvariableprototype) _ myvariableprototype->_type=admse_real; _ else _ { _ NEWVARIABLE($1) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_type=admse_real; _ } | R_l.analogfunction.real.variable ',' tk_ident _ p_variableprototype myvariableprototype=adms_analogfunction_list_variable_lookup_by_id(gAnalogfunction,gModule,$3,(p_adms)gAnalogfunction); _ if(myvariableprototype) _ myvariableprototype->_type=admse_real; _ else _ { _ NEWVARIABLE($3) _ adms_analogfunction_list_variable_prepend_once_or_abort(gAnalogfunction,myvariableprototype); _ myvariableprototype->_type=admse_real; _ } ; R_variable.type.set | tk_integer _ gVariableType=admse_integer; | tk_real _ gVariableType=admse_real; | tk_string _ gVariableType=admse_string; ; R_variable.type | R_variable.type.set _ set_context(ctx_any); R_d.attribute.0 _ adms_slist_concat(&gGlobalAttributeList,gAttributeList); _ gAttributeList=NULL; ; R_d.variable.end | ';' _ p_slist l; _ for(l=gVariableDeclarationList;l;l=l->next) _ ((p_variableprototype)l->data)->_type=gVariableType; _ adms_slist_free(gVariableDeclarationList); gVariableDeclarationList=NULL; ; R_l.parameter | R_s.parameter | R_l.parameter ',' R_s.parameter ; R_l.variable | R_s.variable | R_l.variable ',' R_s.variable ; R_d.aliasparameter | R_d.aliasparameter.token tk_ident '=' tk_ident R_d.attribute.0 ';' _ p_slist l; _ p_variableprototype myvariableprototype=adms_module_list_variable_lookup_by_id(gModule,gModule,$4,(p_adms)gModule); _ if(!myvariableprototype) _ adms_veriloga_message_fatal("variable never declared\n",$4); _ adms_variableprototype_list_alias_prepend_once_or_abort(myvariableprototype,adms_kclone(mylexval2)); _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&myvariableprototype->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&myvariableprototype->_attribute,l->data); ; R_d.aliasparameter.token | tk_aliasparameter | tk_aliasparam ; R_s.parameter | R_s.parameter.name R_d.attribute.0 _ p_slist l; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&((p_variableprototype)gVariableDeclarationList->data)->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&((p_variableprototype)gVariableDeclarationList->data)->_attribute,l->data); ; R_s.variable | R_s.variable.name R_d.attribute.0 _ p_slist l; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&((p_variableprototype)gVariableDeclarationList->data)->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ for(l=gGlobalAttributeList;l;l=l->next) _ adms_slist_push(&((p_variableprototype)gVariableDeclarationList->data)->_attribute,l->data); ; R_s.parameter.name | R_s.variable.name '=' R_s.expression R_s.parameter.range _ ((p_variableprototype)gVariableDeclarationList->data)->_input=admse_yes; _ ((p_variableprototype)gVariableDeclarationList->data)->_default=((p_expression)YY($3)); _ ((p_variableprototype)gVariableDeclarationList->data)->_range=adms_slist_reverse(gRangeList); _ gRangeList=NULL; | R_s.variable.name '=' '{' R_l.expression '}' R_s.parameter.range _ p_slist myArgs=(p_slist)YY($4); _ adms_slist_inreverse(&myArgs); _ ((p_variableprototype)gVariableDeclarationList->data)->_input=admse_yes; _ ((p_variableprototype)gVariableDeclarationList->data)->_default=((p_expression)myArgs->data); _ ((p_variableprototype)gVariableDeclarationList->data)->_arraydefault=myArgs; _ ((p_variableprototype)gVariableDeclarationList->data)->_range=adms_slist_reverse(gRangeList); _ gRangeList=NULL; ; R_s.variable.name | tk_ident _ NEWVARIABLE($1) _ if(adms_module_list_node_lookup_by_id(gModule,gModule,mylexval1)) _ adms_veriloga_message_fatal("variable already defined as node\n",$1); _ adms_module_list_variable_prepend_once_or_abort(gModule,myvariableprototype); _ adms_slist_push(&gVariableDeclarationList,(p_adms)myvariableprototype); | tk_ident '[' tk_number ':' tk_number ']' _ NEWVARIABLE($1) _ if(adms_module_list_node_lookup_by_id(gModule,gModule,mylexval1)) _ adms_veriloga_message_fatal("variable already defined as node\n",$1); _ adms_module_list_variable_prepend_once_or_abort(gModule,myvariableprototype); _ adms_slist_push(&gVariableDeclarationList,(p_adms)myvariableprototype); _ myvariableprototype->_sizetype=admse_array; _ myvariableprototype->_minsize=adms_number_new($3); _ myvariableprototype->_maxsize=adms_number_new($5); ; R_s.parameter.range | | R_l.interval ; R_l.interval | R_s.interval | R_l.interval R_s.interval ; R_s.interval | tk_from R_d.interval _ if(((p_range)YY($2))->_infboundtype==admse_range_bound_value) _ ((p_range)YY($2))->_type=admse_include_value; _ else _ ((p_range)YY($2))->_type=admse_include; _ adms_slist_push(&gRangeList,YY($2)); | tk_exclude R_d.interval _ if(((p_range)YY($2))->_infboundtype==admse_range_bound_value) _ ((p_range)YY($2))->_type=admse_exclude_value; _ else _ ((p_range)YY($2))->_type=admse_exclude; _ adms_slist_push(&gRangeList,YY($2)); ; R_d.interval | '(' R_interval.inf ':' R_interval.sup ')' _ p_range myrange=adms_module_list_range_prepend_by_id_once_or_abort(gModule,gModule,(p_expression)YY($2),(p_expression)YY($4)); _ $$=adms_yaccval_new("unknown source file"); _ myrange->_infboundtype=admse_range_bound_exclude; _ myrange->_supboundtype=admse_range_bound_exclude; _ Y($$,(p_adms)myrange); | '(' R_interval.inf ':' R_interval.sup ']' _ p_range myrange=adms_module_list_range_prepend_by_id_once_or_abort(gModule,gModule,(p_expression)YY($2),(p_expression)YY($4)); _ $$=adms_yaccval_new("unknown source file"); _ myrange->_infboundtype=admse_range_bound_exclude; _ myrange->_supboundtype=admse_range_bound_include; _ Y($$,(p_adms)myrange); | '[' R_interval.inf ':' R_interval.sup ')' _ p_range myrange=adms_module_list_range_prepend_by_id_once_or_abort(gModule,gModule,(p_expression)YY($2),(p_expression)YY($4)); _ $$=adms_yaccval_new("unknown source file"); _ myrange->_infboundtype=admse_range_bound_include; _ myrange->_supboundtype=admse_range_bound_exclude; _ Y($$,(p_adms)myrange); | '[' R_interval.inf ':' R_interval.sup ']' _ p_range myrange=adms_module_list_range_prepend_by_id_once_or_abort(gModule,gModule,(p_expression)YY($2),(p_expression)YY($4)); _ $$=adms_yaccval_new("unknown source file"); _ myrange->_infboundtype=admse_range_bound_include; _ myrange->_supboundtype=admse_range_bound_include; _ Y($$,(p_adms)myrange); | R_s.expression _ p_range myrange=adms_module_list_range_prepend_by_id_once_or_abort(gModule,gModule,(p_expression)YY($1),(p_expression)YY($1)); _ $$=adms_yaccval_new("unknown source file"); _ myrange->_infboundtype=admse_range_bound_value; _ myrange->_supboundtype=admse_range_bound_value; _ Y($$,(p_adms)myrange); ; R_interval.inf | R_s.expression _ $$=$1; | '-' tk_inf _ p_number mynumber=adms_number_new($2); _ p_expression myexpression=adms_expression_new(gModule,(p_adms)mynumber); _ mynumber->_lexval->_string=adms_kclone("-inf"); _ adms_slist_push(&gModule->_expression,(p_adms)myexpression); _ $$=adms_yaccval_new("unknown source file"); _ myexpression->_infinity=admse_minus; _ myexpression->_hasspecialnumber=adms_kclone("YES"); _ Y($$,(p_adms)myexpression); ; R_interval.sup | R_s.expression _ $$=$1; | tk_inf _ p_number mynumber=adms_number_new($1); _ p_expression myexpression=adms_expression_new(gModule,(p_adms)mynumber); _ mynumber->_lexval->_string=adms_kclone("+inf"); _ adms_slist_push(&gModule->_expression,(p_adms)myexpression); _ $$=adms_yaccval_new("unknown source file"); _ myexpression->_infinity=admse_plus; _ myexpression->_hasspecialnumber=adms_kclone("YES"); _ Y($$,(p_adms)myexpression); | '+' tk_inf _ p_number mynumber=adms_number_new($2); _ p_expression myexpression=adms_expression_new(gModule,(p_adms)mynumber); _ mynumber->_lexval->_string=adms_kclone("+inf"); _ adms_slist_push(&gModule->_expression,(p_adms)myexpression); _ $$=adms_yaccval_new("unknown source file"); _ myexpression->_infinity=admse_plus; _ myexpression->_hasspecialnumber=adms_kclone("YES"); _ Y($$,(p_adms)myexpression); ; R_analog | tk_analog _ set_context(ctx_any); // from here, don't recognize node declarations. _ // they are not permitted anyway. R_analogcode _ gModule->_analog=adms_analog_new(YY($R_analogcode)); ; R_analogcode | R_analogcode.atomic _ $$=$1; | R_analogcode.block _ $$=$1; ; R_l.expression | R_s.expression _ p_slist myArgs=NULL; _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_push(&myArgs,YY($1)); _ Y($$,(p_adms)myArgs); | R_l.expression ',' R_s.expression _ p_slist myArgs=(p_slist)YY($1); _ $$=$1; _ adms_slist_push(&myArgs,YY($3)); _ Y($$,(p_adms)myArgs); ; R_analogcode.atomic | R_d.attribute.0 R_d.blockvariable _ p_slist l; _ p_slist lv; _ for(l=gAttributeList;l;l=l->next) _ for(lv=((p_blockvariable)YY($2))->_variable;lv;lv=lv->next) _ adms_slist_push(&((p_variableprototype)lv->data)->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ $$=$2; | R_d.contribution _ $$=$1; | R_s.assignment ';' _ $$=$1; | R_d.conditional _ $$=$1; | R_d.while _ $$=$1; | R_d.case _ $$=$1; | R_d.for _ $$=$1; | tk_dollar_ident '(' R_l.expression ')' ';' _ p_function myfunction=adms_function_new($1,uid++); _ p_slist myArgs=(p_slist)YY($3); _ p_callfunction mycallfunction=adms_callfunction_new(gModule,myfunction); _ adms_slist_push(&gModule->_callfunction,(p_adms)mycallfunction); _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_inreverse(&myArgs); _ myfunction->_arguments=myArgs; _ Y($$,(p_adms)mycallfunction); | tk_dollar_ident '(' ')' ';' _ p_function myfunction=adms_function_new($1,uid++); _ p_callfunction mycallfunction=adms_callfunction_new(gModule,myfunction); _ adms_slist_push(&gModule->_callfunction,(p_adms)mycallfunction); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mycallfunction); | tk_dollar_ident ';' _ p_function myfunction=adms_function_new($1,uid++); _ p_callfunction mycallfunction=adms_callfunction_new(gModule,myfunction); _ adms_slist_push(&gModule->_callfunction,(p_adms)mycallfunction); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mycallfunction); | ';' _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)adms_nilled_new(gModule)); ; R_analogcode.block | R_d.block _ $$=$1; | R_analogcode.block.atevent R_d.block _ $$=$2; _ adms_lexval_free(((p_block)YY($$))->_lexval); _ ((p_block)YY($$))->_lexval=(p_lexval)YY($1); ; R_analogcode.block.atevent | '@' '(' tk_ident '(' R_l.analysis ')' ')' _ adms_veriloga_message_fatal("@ control not supported\n",$3); | '@' tk_ident _ char* mypartitionning=adms_kclone(mylexval2); _ if(strcmp(mypartitionning,"initial_model") _ && strcmp(mypartitionning,"initial_instance") _ && strcmp(mypartitionning,"noise") _ && strcmp(mypartitionning,"initial_step") _ && strcmp(mypartitionning,"final_step")) _ adms_veriloga_message_fatal(" @() control not supported\n",$2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)$2); | '@' '(' tk_ident ')' _ char* mypartitionning=adms_kclone(mylexval3); _ if(strcmp(mypartitionning,"initial_model") _ && strcmp(mypartitionning,"initial_instance") _ && strcmp(mypartitionning,"noise") _ && strcmp(mypartitionning,"initial_step") _ && strcmp(mypartitionning,"final_step")) _ adms_veriloga_message_fatal(" @() control not supported\n",$3); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)$3); ; R_l.analysis | R_s.analysis | R_l.analysis ',' R_s.analysis ; R_s.analysis | tk_anystring ; R_d.block | R_d.block.begin tk_end _ $$=adms_yaccval_new("unknown source file"); _ Y($$,gBlockList->data); _ adms_slist_pull(&gBlockList); | R_d.block.begin ':' tk_ident tk_end _ $$=adms_yaccval_new("unknown source file"); _ Y($$,gBlockList->data); _ adms_slist_pull(&gBlockList); _ ((p_block)YY($$))->_lexval->_string=$3->_string; | R_d.block.begin R_l.blockitem tk_end _ $$=adms_yaccval_new("unknown source file"); _ Y($$,gBlockList->data); _ adms_slist_pull(&gBlockList); | R_d.block.begin ':' tk_ident R_l.blockitem tk_end _ $$=adms_yaccval_new("unknown source file"); _ Y($$,gBlockList->data); _ adms_slist_pull(&gBlockList); _ ((p_block)YY($$))->_lexval->_string=$3->_string; ; R_d.block.begin | R_d.attribute.0 tk_begin _ p_slist l; _ p_block myblock=adms_block_new(gModule,$2,gBlockList?((p_block)gBlockList->data):NULL,NULL); _ $$=adms_yaccval_new("unknown source file"); _ myblock->_lexval->_string=adms_kclone(""); _ adms_slist_push(&gBlockList,(p_adms)myblock); _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&myblock->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ adms_slist_push(&gModule->_block,gBlockList->data); ; R_l.blockitem | R_analogcode _ adms_slist_push(&((p_block)gBlockList->data)->_item,YY($1)); | R_l.blockitem R_analogcode _ adms_slist_push(&((p_block)gBlockList->data)->_item,YY($2)); ; R_d.blockvariable | tk_integer R_l.blockvariable ';' _ p_slist l; _ p_blockvariable myblockvariable=adms_blockvariable_new(((p_block)gBlockList->data)); _ adms_slist_push(&gModule->_blockvariable,(p_adms)myblockvariable); _ for(l=gBlockVariableList;l;l=l->next) _ ((p_variableprototype)l->data)->_type=admse_integer; _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_inreverse(&gBlockVariableList); _ myblockvariable->_variable=gBlockVariableList; _ gBlockVariableList=NULL; _ Y($$,(p_adms)myblockvariable); | tk_real R_l.blockvariable ';' _ p_slist l; _ p_blockvariable myblockvariable=adms_blockvariable_new(((p_block)gBlockList->data)); _ adms_slist_push(&gModule->_blockvariable,(p_adms)myblockvariable); _ for(l=gBlockVariableList;l;l=l->next) _ ((p_variableprototype)l->data)->_type=admse_real; _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_inreverse(&gBlockVariableList); _ myblockvariable->_variable=gBlockVariableList; _ gBlockVariableList=NULL; _ Y($$,(p_adms)myblockvariable); | tk_string R_l.blockvariable ';' _ p_slist l; _ p_blockvariable myblockvariable=adms_blockvariable_new(((p_block)gBlockList->data)); _ adms_slist_push(&gModule->_blockvariable,(p_adms)myblockvariable); _ for(l=gBlockVariableList;l;l=l->next) _ ((p_variableprototype)l->data)->_type=admse_string; _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_inreverse(&gBlockVariableList); _ myblockvariable->_variable=gBlockVariableList; _ gBlockVariableList=NULL; _ Y($$,(p_adms)myblockvariable); ; R_l.blockvariable | R_s.blockvariable | R_l.blockvariable ',' R_s.blockvariable ; R_s.blockvariable | tk_ident _ NEWVARIABLE($1) _ adms_block_list_variable_prepend_once_or_abort(((p_block)gBlockList->data),myvariableprototype); _ adms_slist_push(&gBlockVariableList,(p_adms)myvariableprototype); | tk_ident '[' tk_number ':' tk_number ']' _ NEWVARIABLE($1) _ adms_block_list_variable_prepend_once_or_abort(((p_block)gBlockList->data),myvariableprototype); _ adms_slist_push(&gVariableDeclarationList,(p_adms)myvariableprototype); _ myvariableprototype->_sizetype=admse_array; _ myvariableprototype->_minsize=adms_number_new($3); _ myvariableprototype->_maxsize=adms_number_new($5); ; R_d.contribution | R_contribution R_d.attribute.0 ';' _ p_slist l; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&gContribution->_attribute,l->data); _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ gContribution=NULL; ; R_contribution | R_source '<' '+' R_s.expression _ p_source mysource=(p_source)YY($1); _ $$=adms_yaccval_new("unknown source file"); _ gContribution=adms_contribution_new(gModule,mysource,(p_expression)YY($4),gLexval); _ adms_slist_push(&gModule->_contribution,(p_adms)gContribution); _ Y($$,(p_adms)gContribution); _ gContribution->_branchalias=gBranchAlias; _ gBranchAlias=NULL; ; R_source | tk_ident '(' tk_ident ',' tk_ident ')' _ p_node Pnode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval3); _ p_node Nnode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval5); _ char* natureID=mylexval1; _ p_nature mynature=adms_admsmain_list_nature_lookup_by_id(root(),natureID); _ p_branch mybranch=adms_module_list_branch_prepend_by_id_once_or_ignore(gModule,gModule,Pnode,Nnode); _ $$=adms_yaccval_new("unknown source file"); _ if(!mynature) _ adms_message_fatal(("[source:error] there is no nature with access %s, missing discipline.h file?\n",natureID)) _ gSource=adms_module_list_source_prepend_by_id_once_or_ignore(gModule,gModule,mybranch,mynature); _ gLexval=$1; _ Y($$,(p_adms)gSource); | tk_ident '(' tk_ident ')' _ char* natureID=mylexval1; _ p_nature mynature=adms_admsmain_list_nature_lookup_by_id(root(),natureID); _ p_branchalias branchalias=adms_module_list_branchalias_lookup_by_id(gModule,gModule,mylexval3); _ p_node pnode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval3); _ p_branch mybranch=NULL; _ $$=adms_yaccval_new("unknown source file"); _ if(!mynature) _ adms_message_fatal(("[source:error] there is no nature with access %s, please, include discipline.h file\n",natureID)) _ if(pnode) _ mybranch=adms_module_list_branch_prepend_by_id_once_or_ignore(gModule,gModule,pnode,gGND); _ else if(branchalias) _ mybranch=branchalias->_branch; _ else _ adms_veriloga_message_fatal("undefined branch or node\n",$1); _ gSource=adms_module_list_source_prepend_by_id_once_or_ignore(gModule,gModule,mybranch,mynature); _ gLexval=$1; _ gBranchAlias=branchalias; _ Y($$,(p_adms)gSource); ; R_d.while | tk_while '(' R_s.expression ')' R_analogcode _ p_whileloop mywhileloop=adms_whileloop_new(gModule,(p_expression)YY($3),YY($5)); _ adms_slist_push(&gModule->_whileloop,(p_adms)mywhileloop); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mywhileloop); ; R_d.for | tk_for '(' R_s.assignment ';' R_s.expression ';' R_s.assignment ')' R_analogcode _ p_forloop myforloop=adms_forloop_new(gModule,(p_assignment)YY($3),(p_expression)YY($5),(p_assignment)YY($7),YY($9)); _ adms_slist_push(&gModule->_forloop,(p_adms)myforloop); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myforloop); ; R_d.case | tk_case '(' R_s.expression ')' R_l.case.item tk_endcase _ p_case mycase=adms_case_new(gModule,(p_expression)YY($3)); _ adms_slist_push(&gModule->_case,(p_adms)mycase); _ $$=adms_yaccval_new("unknown source file"); _ mycase->_caseitem=adms_slist_reverse((p_slist)YY($5)); _ Y($$,(p_adms)mycase); ; R_l.case.item | R_s.case.item _ p_slist myArgs=NULL; _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_push(&myArgs,YY($1)); _ Y($$,(p_adms)myArgs); | R_l.case.item R_s.case.item _ p_slist myArgs=(p_slist)YY($1); _ $$=$1; _ adms_slist_push(&myArgs,YY($2)); _ Y($$,(p_adms)myArgs); ; R_s.case.item | R_l.enode ':' R_analogcode _ p_slist myArgs=(p_slist)YY($1); _ p_caseitem mycaseitem=adms_caseitem_new(YY($3)); _ $$=adms_yaccval_new("unknown source file"); _ mycaseitem->_condition=adms_slist_reverse(myArgs); _ Y($$,(p_adms)mycaseitem); | tk_default ':' R_analogcode _ p_caseitem mycaseitem=adms_caseitem_new(YY($3)); _ $$=adms_yaccval_new("unknown source file"); _ mycaseitem->_defaultcase=admse_yes; _ Y($$,(p_adms)mycaseitem); | tk_default R_analogcode _ p_caseitem mycaseitem=adms_caseitem_new(YY($2)); _ $$=adms_yaccval_new("unknown source file"); _ mycaseitem->_defaultcase=admse_yes; _ Y($$,(p_adms)mycaseitem); ; R_s.paramlist.0 | | '#' '(' R_l.instance.parameter ')' ; R_s.instance | R_instance.module.name R_s.paramlist.0 tk_ident '(' R_l.node ')' ';' _ p_instance myinstance; _ p_slist l1; _ p_slist l2; _ myinstance=adms_module_list_instance_prepend_by_id_once_or_abort(gModule,gModule,gInstanceModule,mylexval3); _ adms_slist_inreverse(&gInstanceModule->_node); _ l2=gInstanceModule->_node; _ l2=l2->next; /*GND ignored*/ _ for(l1=adms_slist_reverse(gNodeList);l1;l1=l1->next) _ { _ adms_instance_list_terminal_prepend_once_or_abort(myinstance,adms_instancenode_new(((p_node)l1->data),(p_node)l2->data)); _ l2=l2->next; _ } _ for(l1=gInstanceVariableList;l1;l1=l1->next) _ adms_instance_list_parameterset_prepend_once_or_abort(myinstance,(p_instanceparameter)l1->data); _ adms_slist_inreverse(&gInstanceModule->_node); _ adms_slist_free(gNodeList);gNodeList=NULL; _ adms_slist_free(gInstanceVariableList);gInstanceVariableList=NULL; ; R_instance.module.name | tk_ident _ set_context(ctx_any); // from here, don't recognize node declarations. _ // they are not permitted anyway. _ gInstanceModule=adms_admsmain_list_module_lookup_by_id(root(),mylexval1); _ if(!gInstanceModule) _ adms_message_fatal(("module '%s' not found\n",mylexval1)); ; R_l.instance.parameter | R_s.instance.parameter | R_l.instance.parameter ',' R_s.instance.parameter ; R_s.instance.parameter | '.' tk_ident '(' R_s.expression ')' _ p_variableprototype myvariableprototype=adms_module_list_variable_lookup_by_id(gInstanceModule,gInstanceModule,$2,(p_adms)gInstanceModule); _ if(myvariableprototype) _ { _ p_instanceparameter myinstanceparameter; _ myinstanceparameter=adms_instanceparameter_new(myvariableprototype); _ adms_slist_push(&gInstanceVariableList,(p_adms)myinstanceparameter); _ myinstanceparameter->_value=((p_expression)YY($4)); _ } _ else _ { _ adms_veriloga_message_fatal_continue($2); _ adms_message_fatal(("[%s.%s.%s]: undefined variable (instance declaration)", _ adms_module_uid(gModule),adms_module_uid(gInstanceModule),mylexval2)) _ } ; R_s.assignment | tk_ident '=' R_s.expression _ p_assignment myassignment; _ p_variable myvariable=variable_recursive_lookup_by_id(gBlockList->data,$1); _ p_variableprototype myvariableprototype; _ if(!myvariable) _ adms_veriloga_message_fatal("undefined variable\n",$1); _ myvariableprototype=myvariable->_prototype; _ myassignment=adms_assignment_new(gModule,(p_adms)myvariable,(p_expression)YY($3),$1); _ adms_slist_push(&gModule->_assignment,(p_adms)myassignment); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myassignment); _ myvariableprototype->_vcount++; _ myvariableprototype->_vlast=myassignment; | R_d.attribute tk_ident '=' R_s.expression _ p_assignment myassignment; _ p_variable myvariable=variable_recursive_lookup_by_id(gBlockList->data,$2); _ p_variableprototype myvariableprototype; _ if(!myvariable) _ adms_veriloga_message_fatal("undefined variable\n",$2); _ myvariableprototype=myvariable->_prototype; _ myassignment=adms_assignment_new(gModule,(p_adms)myvariable,(p_expression)YY($4),$2); _ adms_slist_push(&gModule->_assignment,(p_adms)myassignment); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myassignment); _ { _ p_slist l; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&myassignment->_attribute,l->data); _ } _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ myvariableprototype->_vcount++; _ myvariableprototype->_vlast=myassignment; | tk_ident '[' R_expression ']' '=' R_s.expression _ p_assignment myassignment; _ p_array myarray; _ p_variable myvariable=variable_recursive_lookup_by_id(gBlockList->data,$1); _ p_variableprototype myvariableprototype; _ if(!myvariable) _ adms_veriloga_message_fatal("undefined variable\n",$1); _ myvariableprototype=myvariable->_prototype; _ myarray=adms_array_new(myvariable,YY($3)); _ myassignment=adms_assignment_new(gModule,(p_adms)myarray,(p_expression)YY($6),$1); _ adms_slist_push(&gModule->_assignment,(p_adms)myassignment); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myassignment); _ myvariableprototype->_vcount++; _ myvariableprototype->_vlast=myassignment; | R_d.attribute tk_ident '[' R_expression ']' '=' R_s.expression _ p_assignment myassignment; _ p_array myarray; _ p_variable myvariable=variable_recursive_lookup_by_id(gBlockList->data,$2); _ p_variableprototype myvariableprototype; _ if(!myvariable) _ adms_veriloga_message_fatal("undefined variable\n",$2); _ myvariableprototype=myvariable->_prototype; _ myarray=adms_array_new(myvariable,YY($4)); _ myassignment=adms_assignment_new(gModule,(p_adms)myarray,(p_expression)YY($7),$2); _ adms_slist_push(&gModule->_assignment,(p_adms)myassignment); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myassignment); _ { _ p_slist l; _ for(l=gAttributeList;l;l=l->next) _ adms_slist_push(&myassignment->_attribute,l->data); _ } _ adms_slist_free(gAttributeList); gAttributeList=NULL; _ myvariableprototype->_vcount++; _ myvariableprototype->_vlast=myassignment; ; R_d.conditional | tk_if '(' R_s.expression ')' R_analogcode %prec PREC_IF_THEN _ p_expression myexpression=(p_expression)YY($3); _ p_adms mythen=YY($5); _ p_conditional myconditional=adms_conditional_new(gModule,myexpression,mythen,NULL); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myconditional); | tk_if '(' R_s.expression ')' R_analogcode tk_else R_analogcode _ p_expression myexpression=(p_expression)YY($3); _ p_adms mythen=YY($5); _ p_adms myelse=YY($7); _ p_conditional myconditional=adms_conditional_new(gModule,myexpression,mythen,myelse); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myconditional); ; R_s.expression | R_expression _ p_expression myexpression=adms_expression_new(gModule,YY($1)); _ adms_slist_push(&gModule->_expression,(p_adms)myexpression); _ $$=$1; _ Y($$,(p_adms)myexpression); ; R_l.enode | R_s.function_expression _ p_slist myArgs=NULL; _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_push(&myArgs,YY($1)); _ Y($$,(p_adms)myArgs); | R_l.enode ',' R_s.function_expression _ p_slist myArgs=(p_slist)YY($1); _ $$=$1; _ adms_slist_push(&myArgs,YY($3)); _ Y($$,(p_adms)myArgs); ; R_s.function_expression | R_expression _ $$=$1; ; R_expression | R_e.conditional _ $$=$1; ; R_e.conditional | R_e.bitwise_equ _ $$=$1; | R_e.bitwise_equ '?' R_e.bitwise_equ ':' R_e.bitwise_equ _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_adms m3=YY($5); _ p_mapply_ternary myop=adms_mapply_ternary_new(admse_conditional,m1,m2,m3); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.bitwise_equ | R_e.bitwise_xor _ $$=$1; | R_e.bitwise_equ tk_bitwise_equr R_e.bitwise_xor _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_bw_equr,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.bitwise_equ '~' '^' R_e.bitwise_xor _ p_adms m1=YY($1); _ p_adms m2=YY($4); _ p_mapply_binary myop=adms_mapply_binary_new(admse_bw_equl,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.bitwise_xor | R_e.bitwise_or _ $$=$1; | R_e.bitwise_xor '^' R_e.bitwise_or _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_bw_xor,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.bitwise_or | R_e.bitwise_and _ $$=$1; | R_e.bitwise_or '|' R_e.bitwise_and _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_bw_or,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.bitwise_and | R_e.logical_or _ $$=$1; | R_e.bitwise_and '&' R_e.logical_or _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_bw_and,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.logical_or | R_e.logical_and _ $$=$1; | R_e.logical_or tk_or R_e.logical_and _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_or,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.logical_and | R_e.comp_equ _ $$=$1; | R_e.logical_and tk_and R_e.comp_equ _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_and,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.comp_equ | R_e.comp _ $$=$1; | R_e.comp_equ '=' '=' R_e.comp _ p_adms m1=YY($1); _ p_adms m2=YY($4); _ p_mapply_binary myop=adms_mapply_binary_new(admse_equ,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.comp_equ '!' '=' R_e.comp _ p_adms m1=YY($1); _ p_adms m2=YY($4); _ p_mapply_binary myop=adms_mapply_binary_new(admse_notequ,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.comp | R_e.bitwise_shift _ $$=$1; | R_e.comp '<' R_e.bitwise_shift _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_lt,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.comp '<' '=' R_e.bitwise_shift _ p_adms m1=YY($1); _ p_adms m2=YY($4); _ p_mapply_binary myop=adms_mapply_binary_new(admse_lt_equ,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.comp '>' R_e.bitwise_shift _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_gt,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.comp '>' '=' R_e.bitwise_shift _ p_adms m1=YY($1); _ p_adms m2=YY($4); _ p_mapply_binary myop=adms_mapply_binary_new(admse_gt_equ,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.bitwise_shift | R_e.arithm_add _ $$=$1; | R_e.bitwise_shift tk_op_shr R_e.arithm_add _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_shiftr,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.bitwise_shift tk_op_shl R_e.arithm_add _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_shiftl,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.arithm_add | R_e.arithm_mult _ $$=$1; | R_e.arithm_add '+' R_e.arithm_mult _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_addp,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.arithm_add '-' R_e.arithm_mult _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_addm,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.arithm_mult | R_e.unary _ $$=$1; | R_e.arithm_mult '*' R_e.unary _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_multtime,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.arithm_mult '/' R_e.unary _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_multdiv,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); | R_e.arithm_mult '%' R_e.unary _ p_adms m1=YY($1); _ p_adms m2=YY($3); _ p_mapply_binary myop=adms_mapply_binary_new(admse_multmod,m1,m2); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myop); ; R_e.unary | R_e.atomic _ $$=$1; | '+' R_e.atomic _ p_adms m=YY($2); _ p_mapply_unary mymathapply=adms_mapply_unary_new(admse_plus,m); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mymathapply); | '-' R_e.atomic _ p_adms m=YY($2); _ p_mapply_unary mymathapply=adms_mapply_unary_new(admse_minus,m); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mymathapply); | '!' R_e.atomic _ p_adms m=YY($2); _ p_mapply_unary mymathapply=adms_mapply_unary_new(admse_not,m); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mymathapply); | '~' R_e.atomic _ p_adms m=YY($2); _ p_mapply_unary mymathapply=adms_mapply_unary_new(admse_bw_not,m); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)mymathapply); ; R_e.atomic | tk_integer _ p_number mynumber=adms_number_new($1); _ $$=adms_yaccval_new("unknown source file"); _ mynumber->_cast=admse_i; _ Y($$,(p_adms)mynumber); | tk_integer tk_ident _ p_number mynumber=adms_number_new($1); _ int myunit=admse_1; _ $$=adms_yaccval_new("unknown source file"); _ if(0) {} _ else if(!strcmp(mylexval2,"E")) myunit=admse_E; _ else if(!strcmp(mylexval2,"P")) myunit=admse_P; _ else if(!strcmp(mylexval2,"T")) myunit=admse_T; _ else if(!strcmp(mylexval2,"G")) myunit=admse_G; _ else if(!strcmp(mylexval2,"M")) myunit=admse_M; _ else if(!strcmp(mylexval2,"K")) myunit=admse_K; _ else if(!strcmp(mylexval2,"k")) myunit=admse_k; _ else if(!strcmp(mylexval2,"h")) myunit=admse_h; _ else if(!strcmp(mylexval2,"D")) myunit=admse_D; _ else if(!strcmp(mylexval2,"d")) myunit=admse_d; _ else if(!strcmp(mylexval2,"c")) myunit=admse_c; _ else if(!strcmp(mylexval2,"m")) myunit=admse_m; _ else if(!strcmp(mylexval2,"u")) myunit=admse_u; _ else if(!strcmp(mylexval2,"n")) myunit=admse_n; _ else if(!strcmp(mylexval2,"A")) myunit=admse_A; _ else if(!strcmp(mylexval2,"p")) myunit=admse_p; _ else if(!strcmp(mylexval2,"f")) myunit=admse_f; _ else if(!strcmp(mylexval2,"a")) myunit=admse_a; _ else _ adms_veriloga_message_fatal(" can not convert symbol to valid unit\n",$2); _ mynumber->_scalingunit=myunit; _ mynumber->_cast=admse_i; _ Y($$,(p_adms)mynumber); | tk_number _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)adms_number_new($1)); | tk_number tk_ident _ p_number mynumber=adms_number_new($1); _ int myunit=admse_1; _ $$=adms_yaccval_new("unknown source file"); _ if(0) {} _ else if(!strcmp(mylexval2,"E")) myunit=admse_E; _ else if(!strcmp(mylexval2,"P")) myunit=admse_P; _ else if(!strcmp(mylexval2,"T")) myunit=admse_T; _ else if(!strcmp(mylexval2,"G")) myunit=admse_G; _ else if(!strcmp(mylexval2,"M")) myunit=admse_M; _ else if(!strcmp(mylexval2,"K")) myunit=admse_K; _ else if(!strcmp(mylexval2,"k")) myunit=admse_k; _ else if(!strcmp(mylexval2,"h")) myunit=admse_h; _ else if(!strcmp(mylexval2,"D")) myunit=admse_D; _ else if(!strcmp(mylexval2,"d")) myunit=admse_d; _ else if(!strcmp(mylexval2,"c")) myunit=admse_c; _ else if(!strcmp(mylexval2,"m")) myunit=admse_m; _ else if(!strcmp(mylexval2,"u")) myunit=admse_u; _ else if(!strcmp(mylexval2,"n")) myunit=admse_n; _ else if(!strcmp(mylexval2,"A")) myunit=admse_A; _ else if(!strcmp(mylexval2,"p")) myunit=admse_p; _ else if(!strcmp(mylexval2,"f")) myunit=admse_f; _ else if(!strcmp(mylexval2,"a")) myunit=admse_a; _ else _ adms_veriloga_message_fatal(" can not convert symbol to valid unit\n",$2); _ mynumber->_scalingunit=myunit; _ Y($$,(p_adms)mynumber); | tk_char _ adms_veriloga_message_fatal("%s: character are not handled\n",$1); | tk_anystring _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)adms_string_new(mylexval1)); | tk_ident _ $$=adms_yaccval_new("unknown source file"); _ p_variable myvariable=variable_recursive_lookup_by_id(gBlockList->data,$1); _ if(myvariable) _ Y($$,(p_adms)myvariable); _ else if (!gAnalogfunction) _ { _ p_branchalias mybranchalias=adms_module_list_branchalias_lookup_by_id(gModule,gModule,mylexval1); _ p_node mynode=adms_module_list_node_lookup_by_id(gModule,gModule,mylexval1); _ if(mynode) Y($$,(p_adms)mynode); _ if(mybranchalias) _ Y($$,(p_adms)mybranchalias->_branch); _ } _ if(!YY($$)) _ adms_veriloga_message_fatal("identifier never declared\n",$1); | tk_dollar_ident _ p_function myfunction=adms_function_new($1,uid++); _ $$=adms_yaccval_new("unknown source file"); _ Y($$,(p_adms)myfunction); | tk_ident '[' R_expression ']' _ $$=adms_yaccval_new("unknown source file"); _ p_variable myvariable=variable_recursive_lookup_by_id(gBlockList->data,$1); _ if(!myvariable) _ adms_veriloga_message_fatal("undefined array variable\n",$1); _ Y($$,(p_adms)adms_array_new(myvariable,YY($3))); | tk_dollar_ident '(' R_l.enode ')' _ p_function myfunction=adms_function_new($1,uid++); _ p_slist myArgs=(p_slist)YY($3); _ $$=adms_yaccval_new("unknown source file"); _ adms_slist_inreverse(&myArgs); _ myfunction->_arguments=myArgs; _ Y($$,(p_adms)myfunction); | tk_ident '(' R_l.enode ')' _ char* myfunctionname=mylexval1; _ p_slist myArgs=(p_slist)YY($3); _ int narg=adms_slist_length(myArgs); _ p_probe myprobe=NULL; _ p_nature mynature=adms_admsmain_list_nature_lookup_by_id(root(),myfunctionname); _ $$=adms_yaccval_new("unknown source file"); _ if(mynature && narg==1) _ { _ p_adms mychild0=(p_adms)adms_slist_nth_data(myArgs,0); _ if(mychild0->_datatypename==admse_node) _ { _ p_branch mybranch=adms_module_list_branch_prepend_by_id_once_or_ignore(gModule,gModule,(p_node)mychild0,gGND); _ myprobe=adms_module_list_probe_prepend_by_id_once_or_ignore(gModule,gModule,mybranch,mynature); _ } _ else if(mychild0->_datatypename==admse_branch) _ { _ myprobe=adms_module_list_probe_prepend_by_id_once_or_ignore(gModule,gModule,(p_branch)mychild0,mynature); _ } _ else _ adms_veriloga_message_fatal("bad argument (expecting node or branch)\n",$1); _ } _ else if(mynature && narg==2) _ { _ p_adms mychild0=(p_adms)adms_slist_nth_data(myArgs,0); _ p_adms mychild1=(p_adms)adms_slist_nth_data(myArgs,1); _ p_branch mybranch; _ if(mychild0->_datatypename!=admse_node) _ adms_veriloga_message_fatal("second argument of probe is not a node\n",$1); _ if(mychild1->_datatypename!=admse_node) _ adms_veriloga_message_fatal("first argument of probe is not a node\n",$1); _ mybranch=adms_module_list_branch_prepend_by_id_once_or_ignore(gModule,gModule,(p_node)mychild1,((p_node)mychild0)); _ myprobe=adms_module_list_probe_prepend_by_id_once_or_ignore(gModule,gModule,mybranch,mynature); _ } _ if(myprobe) _ Y($$,(p_adms)myprobe); _ else _ { _ p_slist l; _ p_function myfunction=adms_function_new($1,uid++); _ for(l=gModule->_analogfunction;l&&(myfunction->_definition==NULL);l=l->next) _ { _ p_analogfunction myanalogfunction=(p_analogfunction)l->data; _ if(!strcmp($1->_string,myanalogfunction->_lexval->_string)) _ myfunction->_definition=myanalogfunction; _ } _ myfunction->_arguments=adms_slist_reverse(myArgs); _ Y($$,(p_adms)myfunction); _ } | '(' R_expression ')' _ $$=$2; ; %% void adms_veriloga_setint_yydebug(const int val) { yydebug=val; } ADMS-release-2.3.7/admsstyle.xsl000066400000000000000000000215021371671745500164420ustar00rootroot00000000000000 adms.xsl: The adms Data Tree - Reference Document

This section gives a tree view of the different internal data structure created by adms after parsing an input file.

Symbols used:

  • : adms element
  • property (constructor)
  • : property (scalar)
  • property (list)

Clicking on a node will expand it.


This page has been automatically created by applying the xsl transform admsstyle.xsl to the xml data file adms.xml.
The rendering of the page is specified by the css stylesheet adms.css. You can get the full contents of data file adms.xml by viewing the source of the document from your web browser. Please address any comments to r29173.

root switchNodeCollaping(''); (uid="")
display:block
images/adms-uid.png images/adms-.png switchNodeCollaping(''); ()
expandNode(''); #root () ()
(uid="")
(alias) / same as // ADMS-release-2.3.7/admst.dtd000066400000000000000000000151101371671745500155100ustar00rootroot00000000000000 ADMS-release-2.3.7/admst.xml000066400000000000000000000246371371671745500155530ustar00rootroot00000000000000 ADMS-release-2.3.7/admstpath.xml000066400000000000000000000465641371671745500164330ustar00rootroot00000000000000 space - ignored during parsing _tkid= (admse) tktk_openE; paren++; } ]]> _tkid= (admse) tktk_closeE, adms_slist_pull(&parenidx); adms_slist_pull(&globalctxt); } else t+=1, mypparse->_tkid= (admse) tktk_closeE; paren--; } ]]> _tkid= (admse) tktk_dollarvariable; } ]]> _tkstart=tstart+1; mypparse->_tklen=(int)(long)(t-(tstart+1)); mypparse->_tkid= (admse) tktk_kdollarvariable; } ]]> _tkid= (admse) tktk_arobavariable; } ]]> _tkstart=tstart+1; mypparse->_tklen=(int)(long)(t-(tstart+1)); mypparse->_tkid= (admse) tktk_karobavariable; } ]]> _tkid= (admse) tktk_croixcroixvariable; } ]]> _tkstart=tstart+1; mypparse->_tklen=(int)(long)(t-(tstart+1)); mypparse->_tkid= (admse) tktk_croixstar; } ]]> _tkstart=tstart+1; mypparse->_tklen=(int)(long)(t-(tstart+1)); mypparse->_tkid= (admse) tktk_kcroixcroixvariable; } ]]> _tkid= (admse) tktk_croixvariable; } ]]> _tkstart=tstart+1; mypparse->_tklen=(int)(long)(t-(tstart+1)); mypparse->_tkid= (admse) tktk_kcroixvariable; } ]]> _tkid= (admse) tktk_oquote; } ]]> Boolean not-equal Boolean gt Boolean lt used to select all children Arithmetic increment Arithmetic decrement Arithmetic addition Arithmetic divide comma bar Arithmetic substraction selector of previous admst transform selector of current admst transform separator between two admstpath items Boolean equal open admstpath condition close admstpath condition function: return admst element Boolean and function: return count of argument function: return 1 if argument is exists false() function function: generates unique id of argument function: return position if second argument inside first argument function: return 1 if argument has default value function: returns argument converted to upper-case string function: return 1 if argument is nilled inverse Boolean value of admstpath condition Boolean or function: return position of argument function: return value from admst:apply-templates function: reverse order function: sort in dictionary order function: prints first argument using format specified in second argument true() function function: return uid of element function: returns argument converted to upper-case string _tkid= (admse) tktk_ident; mypparse->_tkstart=tstart; mypparse->_tklen=(int)(long)(t-tstart); } ]]> else if(isdigit(*t)) { while(isdigit(*t)) t++; if(*t=='.') { t++; while(isdigit(*t)) t++; mypparse->_tkid= (admse) tktk_real; mypparse->_tkstart=tstart; mypparse->_tklen=(int)(long)(t-tstart); } else { mypparse->_tkid= (admse) tktk_integer; mypparse->_tkstart=tstart; mypparse->_tklen=(int)(long)(t-tstart); } } ADMS-release-2.3.7/admstpathstyle.xsl000066400000000000000000000252461371671745500175140ustar00rootroot00000000000000 admstpath.xml: The admst Path Syntax - Reference Document

Introduction

This section gives the details of the yacc grammar used to build the admst path parser. The admst path is very similar to the xml xpath language. In future releases of adms we plan to substitute the admst path by the xml xpath language. Lot of development is on going on importing the xpath technology to adms.

Example

Some examples of valid admst paths

admst path: examples

admst path description
select all modules
select nodes the position of which is external - in other words select terminals
select terminal the name of which is 'gate'

admst path: Grammar Definition

The admst path grammar description is very simple. This is due to the limitations of the method applied to build the parser into adms (predicative parser). But it is good enough for most of the current applications that use adms.

      
      
    
      
        
      
      
    
    • .
    • Ø

admst path: lexical terminals

admst path: lexical terminals

terminal regexp description
showSemanticCCode('') color:blue;
showSemanticCCode('') color:blue;

This page has been automatically created by applying the xsl transform admstpathstyle.xsl to the xml data file admstpath.xml.
The rendering of the page is specified by the css stylesheet adms.css. You can get the full contents of data file admstpath.xml by viewing the source of the document from your web browser. Please address any comments to r29173.

ADMS-release-2.3.7/admststyle.xsl000066400000000000000000000255161371671745500166370ustar00rootroot00000000000000 admst.xsl: The admst Language - Reference Document

Reference Manual of admst-2 Language

A Freescale.com !n!t!at!ve Supported by www.sourceforge.net

Introduction

This document is the reference document of the admst language. admst is a subset of the xml language. Its DTD can be found at admst.dtd. admst is used by adms to transform verilog-ams source code into any kind of outputs (html documents, C code for spice simulators.) The primary application of admst is to create C code generators that generate from verilog-ams language ready-to-compile C code for some simulator-specific API. However its use can be extended to other applications like the automatic generation of html documentation. Most of the syntax used by admst has been borrowed from the xsl language.
The command below shows how adms interprets admst scripts (myadmst.xml is an admst script and myverilogams.va is a verilog-ams file):

admsXml myverilogams.va -e myadmst.xml

admsXml interprets the admst intructions found in file myadmst.xml and apply the instructions to the contents of the verilog-ams file myverilogams.va. It will produce some output files according to the admst transforms specified into myadmst.xml.

Example of admst script

  
  2. 
  3. 
  4.  
  5.  
  6. ]]>
  
  • Line 1. is required. It is not used by admsXml but it helps xml tools to identify the contents of the admst file.
  • Line 2. is required. It defines a link to the DTD of the admst language. The admst DTD is similar to a yacc grammar. It specifies the syntax of the admst language. It is not used by adms. If program xmllint is installed on your system then the following command can check the validity of script myadmst.xml against DTD admst.dtd:

    xmllint admst.xml -noout -postvalid -noblanks

  • Line 3. and Line 6. are required. They delimit the declaration of the admst transforms.
  • Line 4. illustrates the use of admst transform admst:getenv. admst:getenv has one attribute called name. Transform admst:getenv will look for the value of shell environement variable HOME and pushes its value to a internal stack created by admsXml.
  • Line 5. illustrates the use of admst transform admst:text. admst:text has one attribute called format. Transform admst:text will print the text specified into attribute format. Each occurence of %s will be replaced by the top value of the internal stack created by admsXml.

List of admst Transforms

The list below provides a brief description of all possible admst transforms. Each admst transform has a set of attributes that modify or refine its behavior. An attribute is made of a name and a value: attrName="attrValue". The container of value attrValue can either be a scalar or a list. The data type of value attrValue can either be a basic type (integer, real, string, enumeration) or a reference to an adms element (module, node, branch, ...). adms uses attribute properties (datatypefamily, datatypename, size) to check dynamically the validity of attrValue. A star ("*") means that attrValue can be any adms element or can be of any type.

Examples:

  • attribute version of admst transform admst can only be a scalar string.
  • attribute select of admst transform admst:for-each can only be a list of any adms elements.

admst transforms

name attributes
name type size required
#howtouse: obsolete - see obsolete - ignored list scalar warn yes no

This page has been automatically created by applying the xsl transform admststyle.xsl to the xml data file admst.xml.
The rendering of the page is specified by the css stylesheet adms.css. You can get the full contents of data file admst.xml by viewing the source of the document from your web browser. Please address any comments to r29173.

ADMS-release-2.3.7/auxconf/000077500000000000000000000000001371671745500153505ustar00rootroot00000000000000ADMS-release-2.3.7/auxconf/ylwrap000077500000000000000000000153121371671745500166160ustar00rootroot00000000000000#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2013-01-12.17; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . get_dirname () { case $1 in */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';; # Otherwise, we want the empty string (not "."). esac } # guard FILE # ---------- # The CPP macro used to guard inclusion of FILE. guard () { printf '%s\n' "$1" \ | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \ -e 's/__*/_/g' } # quote_for_sed [STRING] # ---------------------- # Return STRING (or stdin) quoted to be used as a sed pattern. quote_for_sed () { case $# in 0) cat;; 1) printf '%s\n' "$1";; esac \ | sed -e 's|[][\\.*]|\\&|g' } case "$1" in '') echo "$0: No files given. Try '$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input=$1 shift # We'll later need for a correct munging of "#line" directives. input_sub_rx=`get_dirname "$input" | quote_for_sed` case $input in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input=`pwd`/$input ;; esac input_rx=`get_dirname "$input" | quote_for_sed` # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot=false if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot=true fi # The parser itself, the first file, is the destination of the .y.c # rule in the Makefile. parser=$1 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for # instance, we rename #include "y.tab.h" into #include "parse.h" # during the conversion from y.tab.c to parse.c. sed_fix_filenames= # Also rename header guards, as Bison 2.7 for instance uses its header # guard in its implementation file. sed_fix_header_guards= while test $# -ne 0; do if test x"$1" = x"--"; then shift break fi from=$1 # Handle y_tab.c and y_tab.h output by DOS if $y_tab_nodot; then case $from in "y.tab.c") from=y_tab.c;; "y.tab.h") from=y_tab.h;; esac fi shift to=$1 shift sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;" sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;" done # The program to run. prog=$1 shift # Make any relative path in $prog absolute. case $prog in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog=`pwd`/$prog ;; esac dirname=ylwrap$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then for from in * do to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend '../'. case $to in [\\/]* | ?:[\\/]*) target=$to;; *) target=../$to;; esac # Do not overwrite unchanged header files to avoid useless # recompilations. Always update the parser itself: it is the # destination of the .y.c rule in the Makefile. Divert the # output of all other files to a temporary file so we can # compare them to existing versions. if test $from != $parser; then realtarget=$target target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'` fi # Munge "#line" or "#" directives. Don't let the resulting # debug information point at an absolute srcdir. Use the real # output file name, not yy.lex.c for instance. Adjust the # include guards too. sed -e "/^#/!b" \ -e "s|$input_rx|$input_sub_rx|" \ -e "$sed_fix_filenames" \ -e "$sed_fix_header_guards" \ "$from" >"$target" || ret=$? # Check whether files must be updated. if test "$from" != "$parser"; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$to is unchanged" rm -f "$target" else echo "updating $to" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the parser. This is a # blatant hack to let us support using "yacc -d". If -d is not # specified, don't fail when the header file is "missing". if test "$from" = "$parser"; then ret=1 fi fi done fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: ADMS-release-2.3.7/bootstrap.sh000077500000000000000000000007051371671745500162630ustar00rootroot00000000000000# !/bin/sh here=`pwd` cd `dirname $0` echo "Bootstrapping the ADMS sources..." echo "Libtoolizing... " case `uname` in *Darwin*) LIBTOOLIZE=glibtoolize ;; *) LIBTOOLIZE=libtoolize ;; esac $LIBTOOLIZE --copy --force echo "Creating aclocal.m4... " aclocal -I m4 echo "Creating headers... " autoheader echo "Creating Makefiles... " automake -Wall --copy --add-missing --foreign echo "Creating configure... " autoconf echo "Done!" exit 0 ADMS-release-2.3.7/cmake/000077500000000000000000000000001371671745500147655ustar00rootroot00000000000000ADMS-release-2.3.7/cmake/modules/000077500000000000000000000000001371671745500164355ustar00rootroot00000000000000ADMS-release-2.3.7/cmake/modules/FindPerlModules.cmake000066400000000000000000000043221371671745500224740ustar00rootroot00000000000000# - try to find perl modules, passed as COMPONENTS # # Non-cache variable you might use in your CMakeLists.txt: # PERLMODULES_FOUND # # Requires these CMake modules: # FindPackageHandleStandardArgs (known included with CMake >=2.6.2) # # Original Author: # 2012 Ryan Pavlik # http://academic.cleardefinition.com # Iowa State University HCI Graduate Program/VRAC # # Copyright Iowa State University 2012. # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) if(NOT PERL_FOUND) find_package(Perl QUIET) endif() set(_deps_check) if(PERL_FOUND) foreach(module ${PerlModules_FIND_COMPONENTS}) string(REPLACE "::" "/" modfilename "${module}.pm") string(REPLACE "::" "_" modvarname "PERLMODULES_${module}_MODULE") string(TOUPPER "${modvarname}" modvarname) list(APPEND _deps_check ${modvarname}) if(NOT ${modvarname}) if(NOT PerlModules_FIND_QUIETLY) message(STATUS "Checking for perl module ${module}") endif() execute_process(COMMAND "${PERL_EXECUTABLE}" "-e" "use ${module}; print \$INC{\"${modfilename}\"}" RESULT_VARIABLE result_code OUTPUT_VARIABLE filename ERROR_VARIABLE error_info OUTPUT_STRIP_TRAILING_WHITESPACE) if(result_code EQUAL 0) if(NOT PerlModules_FIND_QUIETLY) message(STATUS "Checking for perl module ${module} - found at ${filename}") endif() set(${modvarname} "${filename}" CACHE FILEPATH "Location found for module ${module}" FORCE) mark_as_advanced(${modvarname}) else() if(NOT PerlModules_FIND_QUIETLY) message(STATUS "Checking for perl module ${module} - failed") endif() set(${modvarname} "NOTFOUND" CACHE FILEPATH "No location found for module ${module}" FORCE) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Perl module ${module} exists failed with the following error output:\n" "${error_info}\n\n") endif() endif() endforeach() endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PerlModules DEFAULT_MSG PERL_FOUND ${_deps_check}) ADMS-release-2.3.7/config.h.cmake000066400000000000000000000006471371671745500164110ustar00rootroot00000000000000/* config.h. Generated from config.h.cmake by cmake configure. */ #cmakedefine HAVE_SYS_STAT_H 1 #cmakedefine HAVE_LOCALE_H 1 #cmakedefine HAVE_FLOAT_H 1 #cmakedefine HAVE_UNISTD_H 1 #cmakedefine HAVE_STDLIB_H 1 #cmakedefine HAVE_STRING_H 1 #cmakedefine HAVE_PUTENV 1 #cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" #cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" ADMS-release-2.3.7/configure.ac000066400000000000000000000066261371671745500162050ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) AC_INIT([adms],[2.3.7],[qucs-devel@lists.sourceforge.net]) AC_CONFIG_HEADER([config.h]) # specific configuration. AC_CONFIG_AUX_DIR([auxconf]) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. AC_PROG_CXX AC_PROG_AWK AC_PROG_YACC AC_PROG_CC AC_PROG_CPP AC_PROG_LEX AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) LT_INIT # Automake Initialisation. AM_INIT_AUTOMAKE([foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_CHECK_PROG(GIT,git,yes) AC_MSG_CHECKING([for git repo]) AX_PROG_FLEX([],[AC_MSG_WARN(Program flex not found (found $LEX)) AC_MSG_ERROR(Please install gnu flex from http://www.gnu.org/software/flex/)]) AX_PROG_BISON([],[AC_MSG_WARN(Program bison not found (found $YACC)) AC_MSG_ERROR(Please install gnu bison from http://www.gnu.org/software/bison/)]) AC_ARG_VAR([BISON], [Path to Bison parser generator]) AC_ARG_VAR([FLEX], [Path to Flex lexical analyser generator]) AC_PATH_PROG([BISON], [bison]) AC_PATH_PROG([FLEX], [flex]) bison_req=2.5 AX_PROG_BISON_VERSION([${bison_req}], [], [ AC_MSG_ERROR([need $BISON >= $bison_req, found $bison_version]) ]) #advice use of gcc AX_COMPILER_VENDOR if test "x$ax_cv_c_compiler_vendor" != "xgnu"; then AC_MSG_WARN(Seems that the selected C-compiler is not gnu gcc C-compiler) AC_MSG_WARN(We advice you to use gcc as C-compiler) AC_MSG_WARN(You can install it from http://www.gnu.org/software/gcc/) fi AX_CFLAGS_WARN_ALL # Checks for libraries. # FIXME: Replace `main' with a function in `-lm': AC_CHECK_LIB([m], [pow]) # Checks for header files. AC_FUNC_ALLOCA AC_HEADER_STDC AC_CHECK_HEADERS([float.h inttypes.h libintl.h locale.h malloc.h stddef.h stdlib.h string.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_INT16_T AC_TYPE_INT32_T AC_TYPE_INT8_T AC_TYPE_SIZE_T AC_STRUCT_TM AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT8_T # Checks for library functions. #https://github.com/Qucs/ADMS/issues/3 #AC_FUNC_MALLOC #AC_FUNC_REALLOC AC_FUNC_STAT AC_FUNC_STRFTIME AC_FUNC_STRTOD AC_CHECK_FUNCS([floor memset putenv setenv strdup strstr strtol]) # Libtool initialisation. AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL AC_SUBST([LIBTOOL_DEPS]) dnl Perl, XML::LibXML module required AC_PATH_PROG(PERL, perl, :) if test "$PERL" = ":"; then AC_MSG_ERROR([The $PACKAGE package requires an installed perl.]) fi; AX_PERL_MODULE_VERSION([XML::LibXML 2],[],[ AC_MSG_RESULT(failed) AC_MSG_ERROR([Perl package XML::LibXML may be downloaded from http://search.cpan.org/dist/libXML])]) # Define preprocessor flag for static build (MinGW). AS_IF([test "x$enable_shared" = "xno"], [ case $host in *mingw*) AC_DEFINE([staticlink], [1], [Define 'staticlink' for MinGW]) ;; esac ]) AC_CONFIG_FILES([Makefile admsXml/Makefile scripts/Makefile]) AC_OUTPUT dnl Print results. AC_MSG_RESULT([]) AC_MSG_RESULT([ $PACKAGE version $VERSION configured successfully.]) AC_MSG_RESULT([ Configure Information: Host : $host C Compiler : $CC DEFS : $DEFS CFLAGS : $CFLAGS Linker : $LD LIBS : $LIBS Prefix : $prefix Perl : $PERL Flex : $FLEX Bison : $BISON Build shared library : $enable_shared ]) ADMS-release-2.3.7/contrib/000077500000000000000000000000001371671745500153455ustar00rootroot00000000000000ADMS-release-2.3.7/contrib/adms.spec000066400000000000000000000010551371671745500171460ustar00rootroot00000000000000Name: ADMS Version: 2.3.0 Release: 1%{?dist} Summary: code generator that converts electrical compact device models.. transforms Verilog-AMS code into other target languages License: GPL URL: https://github.com/Qucs/ADMS Source0: ADMS-2.3.0.tar.gz #BuildRequires: #Requires: %description %prep %setup -q %build %configure make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT %make_install %files %doc %{_bindir}/* /usr/include/adms/* /usr/lib64/* /usr/share/man/man1/* %changelog ADMS-release-2.3.7/create_files.sh000066400000000000000000000003301371671745500166620ustar00rootroot00000000000000cd admsXml /usr/bin/perl ./mkelements.pl .. for i in constants.vams disciplines.vams adms.implicit.xml dummy.va dummy.xml; do /usr/bin/perl ./mkctext.pl $i .. done /usr/bin/perl ./mkgrammar.pl ./verilogaYacc.y.in ADMS-release-2.3.7/images/000077500000000000000000000000001371671745500151525ustar00rootroot00000000000000ADMS-release-2.3.7/images/Makefile.am000066400000000000000000000007001371671745500172030ustar00rootroot00000000000000generated_FILES= \ adms-alias.png \ adms-element.png \ adms-enumeration.png \ adms-list.png \ adms-scalar.png \ adms-uid.png EXTRA_DIST=mkimages.pl $(generated_FILES) # Perl GD module is required to update the figures. # The script used to be run by make, but it become hard to # get GD installed and it does not really seem necessary. # Images are now added to the repository. CLEANFILES=.*.swp *\~ ADMS-release-2.3.7/images/adms-alias.png000066400000000000000000000002441371671745500176730ustar00rootroot00000000000000‰PNG  IHDR ’_PLTEõõõÿúÍÿÿxš;tRNS@æØf pHYsÄÄ•+.IDAT™c`&­ÄÀÀ¥”À@ȲAÄò *A@ €ó r†½÷õ¯ÌIEND®B`‚ADMS-release-2.3.7/images/adms-element.png000066400000000000000000000002471371671745500202360ustar00rootroot00000000000000‰PNG  IHDR ’_PLTEõõõÿúÍÿÿxš;tRNS@æØf pHYsÄÄ•+1IDAT™c`0Ì@ÊD”`ÄfR&cf# Td„à妲rkT³IEND®B`‚ADMS-release-2.3.7/images/adms-enumeration.png000066400000000000000000000002201371671745500211220ustar00rootroot00000000000000‰PNG  IHDR ’_PLTEõõõÿúÍÿÿxš;tRNS@æØf pHYsÄÄ•+IDAT™c`À °`fˆ˜266FâA(6¶–whv|IEND®B`‚ADMS-release-2.3.7/images/adms-list.png000066400000000000000000000002421371671745500175530ustar00rootroot00000000000000‰PNG  IHDR ’_PLTEõõõÿúÍÿÿxš;tRNS@æØf pHYsÄÄ•+,IDAT™c`0L@J D˜”àÂf³•˜@ŠÀŠ¡<ˆEß¿ÿ'I“IEND®B`‚ADMS-release-2.3.7/images/adms-scalar.png000066400000000000000000000002421371671745500200450ustar00rootroot00000000000000‰PNG  IHDR ’_PLTEõõõÿúÍÿÿxš;tRNS@æØf pHYsÄÄ•+,IDAT™c`0Ì@ÊD˜àÂf³˜AŠ ÀŠ¡<ˆh¥ž…ö8aIEND®B`‚ADMS-release-2.3.7/images/adms-uid.png000066400000000000000000000002441371671745500173630ustar00rootroot00000000000000‰PNG  IHDR ’_PLTEõõõÿúÍÿÿxš;tRNS@æØf pHYsÄÄ•+.IDAT™c`fmÌÀÀ ¥ŒÁ@ȲAÄò *A@ €ó rÉòòfAåÁIEND®B`‚ADMS-release-2.3.7/images/mkimages.pl000066400000000000000000000050741371671745500173120ustar00rootroot00000000000000#!/usr/local/bin/perl -w # # This file is part of adms - http://sourceforge.net/projects/mot-adms. # # adms is a code generator for the Verilog-AMS language. # # Copyright (C) 2002-2012 Laurent Lemaitre # # 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 . ## RCS Info ## $Id: mkimages.pl 891 2008-03-07 16:18:12Z r29173 $ ## ## Log ## $Log$ ## Revision 1.3 2006/09/04 08:51:05 r29173 ## tons of simplifications ## ## Revision 1.2 2005/05/27 16:30:38 r29173 ## moving code from xmlParserNew.c to xml - added subexpression ## ## Revision 1.1 2005/05/25 09:11:54 r29173 ## add png image builder ## use GD; my$size=10; my$hframe=1.2*$size; #x-axis my$vframe=$size; sub build_png { my%arg; while(@_) {my($k,$v)=(shift,shift);$arg{$k}=$v;} my$png=$arg{"PNG"}; my$command=$arg{"COMMAND"}; my$im=new GD::Image($hframe,$vframe); my$whitesmoke=$im->colorAllocate(245, 245, 245); my$black=$im->colorAllocate(0, 0, 0), my$red=$im->colorAllocate(255, 0, 0); my$blue=$im->colorAllocate(0,0,255); my$yellow=$im->colorAllocate(255,250,205); $im->transparent($whitesmoke); $im->interlaced(1); eval($command); open PNG,">$png.png"; binmode PNG; print PNG $im->png; close PNG; print "image created ... $png.png\n"; } &build_png( PNG=>'adms-enumeration', COMMAND=>'$im->line($size/2,0,$size/2,$size,$red); $im->line(0,$size/2,$size/2,$size/2,$red);' ); &build_png( PNG=>'adms-list', COMMAND=>'$im->ellipse($size/2,$size/2,0.8*$size,0.8*$size,$blue);' ); &build_png( PNG=>'adms-alias', COMMAND=>'$im->filledEllipse($size/2,$size/2,0.8*$size,0.8*$size,$blue);' ); &build_png( PNG=>'adms-scalar', COMMAND=>'$im->ellipse($size/2,$size/2,0.8*$size,0.8*$size,$red);' ); &build_png( PNG=>'adms-uid', COMMAND=>'$im->filledEllipse($size/2,$size/2,0.8*$size,0.8*$size,$red);' ); &build_png( PNG=>'adms-element', COMMAND=>'$im->ellipse($size/2,$size/2,0.8*$size,0.8*$size,$red); $im->rectangle(0.1*$size,0.1*$size,0.9*$size,0.9*$size,$blue);' ); ADMS-release-2.3.7/m4/000077500000000000000000000000001371671745500142255ustar00rootroot00000000000000ADMS-release-2.3.7/m4/ax_append_flag.m4000066400000000000000000000053041371671745500174210ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_append_flag.html # =========================================================================== # # SYNOPSIS # # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) # # DESCRIPTION # # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space # added in between. # # If FLAGS-VARIABLE is not specified, the current language's flags (e.g. # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly # FLAG. # # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2011 Maarten Bosmans # # 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 . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 2 AC_DEFUN([AX_APPEND_FLAG], [AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl AS_VAR_SET_IF(FLAGS, [case " AS_VAR_GET(FLAGS) " in *" $1 "*) AC_RUN_LOG([: FLAGS already contains $1]) ;; *) AC_RUN_LOG([: FLAGS="$FLAGS $1"]) AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) ;; esac], [AS_VAR_SET(FLAGS,["$1"])]) AS_VAR_POPDEF([FLAGS])dnl ])dnl AX_APPEND_FLAG ADMS-release-2.3.7/m4/ax_cflags_warn_all.m4000066400000000000000000000116711371671745500203030ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html # =========================================================================== # # SYNOPSIS # # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # # DESCRIPTION # # Try to find a compiler option that enables most reasonable warnings. # # For the GNU compiler it will be -Wall (and -ansi -pedantic) The result # is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. # # Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, # HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and # Intel compilers. For a given compiler, the Fortran flags are much more # experimental than their C equivalents. # # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS # - $2 add-value-if-not-found : nothing # - $3 action-if-found : add value to shellvariable # - $4 action-if-not-found : nothing # # NOTE: These macros depend on AX_APPEND_FLAG. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2010 Rhys Ulerich # # 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 . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 14 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], VAR,[VAR="no, unknown" ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-warn all % -warn all" dnl Intel "-pedantic % -Wall" dnl GCC "-xstrconst % -v" dnl Solaris C "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX "-ansi -ansiE % -fullwarn" dnl IRIX "+ESlit % +w1" dnl HP-UX C "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) "-h conform % -h msglevel 2" dnl Cray C (Unicos) # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" ]) AS_VAR_POPDEF([FLAGS])dnl AC_REQUIRE([AX_APPEND_FLAG]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; esac AS_VAR_POPDEF([VAR])dnl ])dnl AX_FLAGS_WARN_ALL dnl implementation tactics: dnl the for-argument contains a list of options. The first part of dnl these does only exist to detect the compiler - usually it is dnl a global option to enable -ansi or -extrawarnings. All other dnl compilers will fail about it. That was needed since a lot of dnl compilers will give false positives for some option-syntax dnl like -Woption or -Xoption as they think of it is a pass-through dnl to later compile stages or something. The "%" is used as a dnl delimiter. A non-option comment can be given after "%%" marks dnl which will be shown but not added to the respective C/CXXFLAGS. AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([C]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([C]) ]) AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([C++]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([C++]) ]) AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([Fortran]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([Fortran]) ]) ADMS-release-2.3.7/m4/ax_compare_version.m4000066400000000000000000000146521371671745500203620ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_compare_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # # DESCRIPTION # # This macro compares two version strings. Due to the various number of # minor-version numbers that can exist, and the fact that string # comparisons are not compatible with numeric comparisons, this is not # necessarily trivial to do in a autoconf script. This macro makes doing # these comparisons easy. # # The six basic comparisons are available, as well as checking equality # limited to a certain number of minor-version levels. # # The operator OP determines what type of comparison to do, and can be one # of: # # eq - equal (test A == B) # ne - not equal (test A != B) # le - less than or equal (test A <= B) # ge - greater than or equal (test A >= B) # lt - less than (test A < B) # gt - greater than (test A > B) # # Additionally, the eq and ne operator can have a number after it to limit # the test to that number of minor versions. # # eq0 - equal up to the length of the shorter version # ne0 - not equal up to the length of the shorter version # eqN - equal up to N sub-version levels # neN - not equal up to N sub-version levels # # When the condition is true, shell commands ACTION-IF-TRUE are run, # otherwise shell commands ACTION-IF-FALSE are run. The environment # variable 'ax_compare_version' is always set to either 'true' or 'false' # as well. # # Examples: # # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) # # would both be true. # # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) # # would both be false. # # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) # # would be true because it is only comparing two minor versions. # # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) # # would be true because it is only comparing the lesser number of minor # versions of the two values. # # Note: The characters that separate the version numbers do not matter. An # empty string is the same as version 0. OP is evaluated by autoconf, not # configure, so must be a string, not a variable. # # The author would like to acknowledge Guido Draheim whose advice about # the m4_case and m4_ifvaln functions make this macro only include the # portions necessary to perform the specific comparison specified by the # OP argument in the final configure script. # # LICENSE # # Copyright (c) 2008 Tim Toolan # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 dnl ######################################################################### AC_DEFUN([AX_COMPARE_VERSION], [ AC_REQUIRE([AC_PROG_AWK]) # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. AS_VAR_PUSHDEF([A],[ax_compare_version_A]) A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` AS_VAR_PUSHDEF([B],[ax_compare_version_B]) B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary dnl # then the first line is used to determine if the condition is true. dnl # The sed right after the echo is to remove any indented white space. m4_case(m4_tolower($2), [lt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [gt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [le],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` ], [ge],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` ],[ dnl Split the operator from the subversion count if present. m4_bmatch(m4_substr($2,2), [0],[ # A count of zero means use the length of the shorter version. # Determine the number of characters in A and B. ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` # Set A to no more than B's length and B to no more than A's length. A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` ], [[0-9]+],[ # A count greater than zero means use only that many subversions A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` ], [.+],[ AC_WARNING( [illegal OP numeric parameter: $2]) ],[]) # Pad zeros at end of numbers to make same length. ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" B="$B`echo $A | sed 's/./0/g'`" A="$ax_compare_version_tmp_A" # Check for equality or inequality as necessary. m4_case(m4_tolower(m4_substr($2,0,2)), [eq],[ test "x$A" = "x$B" && ax_compare_version=true ], [ne],[ test "x$A" != "x$B" && ax_compare_version=true ],[ AC_WARNING([illegal OP parameter: $2]) ]) ]) AS_VAR_POPDEF([A])dnl AS_VAR_POPDEF([B])dnl dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. if test "$ax_compare_version" = "true" ; then m4_ifvaln([$4],[$4],[:])dnl m4_ifvaln([$5],[else $5])dnl fi ]) dnl AX_COMPARE_VERSION ADMS-release-2.3.7/m4/ax_compiler_vendor.m4000066400000000000000000000066161371671745500203570ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html # =========================================================================== # # SYNOPSIS # # AX_COMPILER_VENDOR # # DESCRIPTION # # Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, # hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, # watcom, etc. The vendor is returned in the cache variable # $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2008 Matteo Frigo # # 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 . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 11 AC_DEFUN([AX_COMPILER_VENDOR], [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [# note: don't check for gcc first since some other compilers define __GNUC__ vendors="intel: __ICC,__ECC,__INTEL_COMPILER ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale: __PATHCC__,__PATHSCALE__ clang: __clang__ gnu: __GNUC__ sun: __SUNPRO_C,__SUNPRO_CC hp: __HP_cc,__HP_aCC dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland: __BORLANDC__,__TURBOC__ comeau: __COMO__ cray: _CRAYC kai: __KCC lcc: __LCC__ sgi: __sgi,sgi microsoft: _MSC_VER metrowerks: __MWERKS__ watcom: __WATCOMC__ portland: __PGI unknown: UNKNOWN" for ventest in $vendors; do case $ventest in *:) vendor=$ventest; continue ;; *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; esac AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ #if !($vencpp) thisisanerror; #endif ])], [break]) done ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` ]) ]) ADMS-release-2.3.7/m4/ax_perl_module_version.m4000066400000000000000000000046301371671745500212360ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_perl_module_version.html # =========================================================================== # # SYNOPSIS # # AX_PERL_MODULE_VERSION([MODULE VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # # DESCRIPTION # # Checks to see if the list of 'Module Version' are avaiable in the # system. If all the modules in the list are avaiable ACTION-IF-TRUE is # executed. Case one module is not avaiable ACTION-IF-FALSE is executed # and the macro execution is aborted. NOTE: Perl is needed. # # Example: # # AX_PERL_MODULE_VERSION(CGI::Test 0.104 CGI::Ajax 0.694, , # AC_MSG_ERROR(Need some Perl modules)) # # LICENSE # # Copyright (c) 2009 Marco Gomes # Copyright (c) 2009 Ruben Fonseca # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 5 AU_ALIAS([AC_PERL_MODULE_VERSION], [AX_PERL_MODULE_VERSION]) AC_DEFUN([AX_PERL_MODULE_VERSION],[dnl ac_perl_list_modules="$1" # Make sure we have perl if test -z "$PERL"; then AC_CHECK_PROG(PERL,perl,perl) fi # Check the number of arguments args_num=`echo $ac_perl_list_modules | wc -w` let "ckeck_args = $args_num % 2" if test "$check_args" = "1" ; then AC_MSG_ERROR(syntax error) else eval fi if test "x$PERL" != x; then ac_failed=0 while test ${#ac_perl_list_modules} -gt 2 ; do module_name=`echo $ac_perl_list_modules | cut -d " " -f 1` module_version=`echo $ac_perl_list_modules | cut -d " " -f 2` ac_perl_list_modules=`echo $ac_perl_list_modules | cut -d " " -f 3-` AC_MSG_CHECKING(for perl module $module_name version $module_version) $PERL "-M$module_name" -e exit > /dev/null 2>&1 if test $? -ne 0; then AC_MSG_RESULT(no); ac_failed=1 ac_perl_list_modules="" else version=`$PERL "-M$module_name" -e 'print $'"$module_name::VERSION" 2>&1` $PERL -e 'exit(shift cmp shift)' "$version" "$module_version" if test $? -eq 0 -o $? -eq 1 ; then AC_MSG_RESULT(ok); else AC_MSG_RESULT(no) ac_failed=1 ac_perl_list_modules="" fi fi; done if test "$ac_failed" = 0; then : $2 else : $3 fi else AC_MSG_ERROR(could not find perl) fi])dnl ADMS-release-2.3.7/m4/ax_prog_bison.m4000066400000000000000000000052721371671745500173260ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_prog_bison.html # =========================================================================== # # SYNOPSIS # # AX_PROG_BISON(ACTION-IF-TRUE,ACTION-IF-FALSE) # # DESCRIPTION # # Check whether bison is the parser generator. Run ACTION-IF-TRUE if # successful, ACTION-IF-FALSE otherwise # # LICENSE # # Copyright (c) 2009 Francesco Salvestrini # Copyright (c) 2010 Diego Elio Petteno` # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 9 AC_DEFUN([AX_PROG_BISON], [ AC_REQUIRE([AC_PROG_YACC]) AC_REQUIRE([AC_PROG_EGREP]) AC_CACHE_CHECK([if bison is the parser generator],[ax_cv_prog_bison],[ AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '], [ax_cv_prog_bison=yes], [ax_cv_prog_bison=no]) ]) AS_IF([test "$ax_cv_prog_bison" = "yes"], [ dnl replace the yacc-compatible compiler with the real bison, as dnl otherwise autoconf limits us to the POSIX yacc. dnl We also change the generated filename to the old one, so that dnl automake's ylwrap can deal with it. YACC="${YACC% -y} -o y.tab.c" ] m4_ifnblank([$1], [[$1]]), m4_ifnblank([$2], [[$2]]) ) ]) ADMS-release-2.3.7/m4/ax_prog_bison_version.m4000066400000000000000000000040321371671745500210640ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_prog_bison_version.html # =========================================================================== # # SYNOPSIS # # AX_PROG_BISON_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE]) # # DESCRIPTION # # Makes sure that bison version is greater or equal to the version # indicated. If true the shell commands in ACTION-IF-TRUE are executed. If # not the shell commands in commands in ACTION-IF-TRUE are executed. If # not the shell commands in ACTION-IF-FALSE are run. Note if $BISON is not # set (for example by running AC_CHECK_PROG or AC_PATH_PROG) the macro # will fail. # # Example: # # AC_PATH_PROG([BISON],[bison]) # AX_PROG_BISON_VERSION([3.0.2],[ ... ],[ ... ]) # # This will check to make sure that the bison you have is at least version # 3.0.2 or greater. # # NOTE: This macro uses the $BISON variable to perform the check. # # LICENSE # # Copyright (c) 2015 Jonathan Rajotte-Julien # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 2 AC_DEFUN([AX_PROG_BISON_VERSION],[ AC_REQUIRE([AC_PROG_SED]) AC_REQUIRE([AC_PROG_GREP]) AS_IF([test -n "$BISON"],[ ax_bison_version="$1" AC_MSG_CHECKING([for bison version]) changequote(<<,>>) bison_version=`$BISON --version 2>&1 \ | $SED -n -e '/bison (GNU Bison)/b inspect b : inspect s/.* (\{0,1\}\([0-9]*\.[0-9]*\.[0-9]*\))\{0,1\}.*/\1/;p'` changequote([,]) AC_MSG_RESULT($bison_version) AC_SUBST([BISON_VERSION],[$bison_version]) AX_COMPARE_VERSION([$bison_version],[ge],[$ax_bison_version],[ : $2 ],[ : $3 ]) ],[ AC_MSG_WARN([could not find bison]) $3 ]) ]) ADMS-release-2.3.7/m4/ax_prog_flex.m4000066400000000000000000000046231371671745500171510ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_prog_flex.html # =========================================================================== # # SYNOPSIS # # AX_PROG_FLEX(ACTION-IF-TRUE,ACTION-IF-FALSE) # # DESCRIPTION # # Check whether flex is the scanner generator. Run ACTION-IF-TRUE if # successful, ACTION-IF-FALSE otherwise # # LICENSE # # Copyright (c) 2009 Francesco Salvestrini # Copyright (c) 2010 Diego Elio Petteno` # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 10 AC_DEFUN([AX_PROG_FLEX], [ AC_REQUIRE([AM_PROG_LEX]) AC_REQUIRE([AC_PROG_EGREP]) AC_CACHE_CHECK([if flex is the lexer generator],[ax_cv_prog_flex],[ AS_IF([$LEX --version 2>/dev/null | $EGREP -q '^\'], [ax_cv_prog_flex=yes], [ax_cv_prog_flex=no]) ]) AS_IF([test "$ax_cv_prog_flex" = "yes"], m4_ifnblank([$1], [[$1]]), m4_ifnblank([$2], [[$2]]) ) ]) ADMS-release-2.3.7/metaadms.dtd000066400000000000000000000055361371671745500162060ustar00rootroot00000000000000 ADMS-release-2.3.7/metaadms.xsd000066400000000000000000000115571371671745500162310ustar00rootroot00000000000000 ADMS-release-2.3.7/metaadmst.dtd000066400000000000000000000052321371671745500163630ustar00rootroot00000000000000 ADMS-release-2.3.7/metaadmst.xsd000066400000000000000000000070531371671745500164110ustar00rootroot00000000000000 ADMS-release-2.3.7/metaadmstpath.dtd000066400000000000000000000057071371671745500172470ustar00rootroot00000000000000 ADMS-release-2.3.7/metaadmstpath.xsd000066400000000000000000000102221371671745500172560ustar00rootroot00000000000000 ADMS-release-2.3.7/scripts/000077500000000000000000000000001371671745500153745ustar00rootroot00000000000000ADMS-release-2.3.7/scripts/Makefile.am000066400000000000000000000007011371671745500174260ustar00rootroot00000000000000EXTRA_DIST= \ admstvariables.xml \ analogfunction.va \ analogfunction.xml \ arobavariable.xml \ attributes.xml \ blockvariables.xml \ croixvariable.xml \ dependency.xml \ getargv.xml \ getenv.xml \ getinstance.xml \ gettransform.xml \ sort.xml \ strutils.xml \ vlatommlMODULE.htm.xml \ vlatovla.xml ADMS-release-2.3.7/scripts/admstvariables.xml000066400000000000000000000054631371671745500211270ustar00rootroot00000000000000 ADMS-release-2.3.7/scripts/analogfunction.va000066400000000000000000000026361371671745500207420ustar00rootroot00000000000000`include "discipline.h" module myanalogfunction (p,q); electrical p,q; real a,b; analog function real myfunction; input x; real x; begin if(x<0.2) myfunction = abs(x); else if(x<0.6) myfunction = cos(2*x); else myfunction = sin(2*x); end endfunction analog function real norm; input x, y, index; real x, y; integer index; begin case(index) 0: norm = max(abs(x),abs(y)); 1: norm = abs(x)+abs(y); 2: norm = sqrt(pow(x,2)+pow(y,2)); default: $strobe("Warning: norm does not exist"); endcase end endfunction `define VEXLIM 200.0 analog function real expLin; input x; real x; real expl; begin if (x < `VEXLIM) expLin = exp(x); else begin expl = exp(`VEXLIM); expLin = expl * (1.0 + (x - `VEXLIM)); end end endfunction analog function real linLog; input x; real x; real vlim; begin vlim=10.0; if (x < vlim) linLog = x; else linLog = vlim + ln(1.0 + (x - vlim)); end endfunction analog begin case (a) 1,2: begin a=1; b=0; end 3,4: begin a=2; b=0; end 5,6: begin a=3; b=0; end default : begin a=1234; b=5678; end endcase end endmodule ADMS-release-2.3.7/scripts/analogfunction.xml000066400000000000000000001411621371671745500211320ustar00rootroot00000000000000 inline double _cos(double arg) { return cos(arg); } inline double _d0_cos(double arg) { return (-sin(arg)); } inline double _sin(double arg) { return sin(arg); } inline double _d0_sin(double arg) { return (cos(arg)); } inline double _tan(double arg) { return tan(arg); } inline double _d0_tan(double arg) { return (1.0/cos(arg)/cos(arg)); } inline double _cosh(double arg) { return cosh(arg); } inline double _d0_cosh(double arg) { return (sinh(arg)); } inline double _sinh(double arg) { return sinh(arg); } inline double _d0_sinh(double arg) { return (cosh(arg)); } inline double _tanh(double arg) { return tanh(arg); } inline double _d0_tanh(double arg) { return (1.0/cosh(arg)/cosh(arg)); } inline double _acos(double arg) { return acos(arg); } inline double _d0_acos(double arg) { return (-1.0/sqrt(1-arg*arg)); } inline double _asin(double arg) { return asin(arg); } inline double _d0_asin(double arg) { return (+1.0/sqrt(1-arg*arg)); } inline double _atan(double arg) { return atan(arg); } inline double _d0_atan(double arg) { return (+1.0/(1+arg*arg)); } inline double _logE(double arg) { return log(arg); } inline double _d0_logE(double arg) { return (1.0/arg); } inline double _log10(double arg) { return log10(arg); } inline double _d0_log10(double arg) { return (1.0/arg/log(10)); } inline double _exp(double arg) { return exp(arg); } inline double _d0_exp(double arg) { return exp(arg); } /* fixme */ inline double _sqrt(double arg) { return sqrt(arg); } inline double _d0_sqrt(double arg) { return (1.0/sqrt(arg)/2.0); } /* fixme */ inline double _abs(double arg) { return fabs(arg); } inline double _d0_abs(double arg) { return (((arg)>=0)?(+1.0):(-1.0)); } inline double _hypot(double x,double y) { return sqrt((x)*(x)+(y)*(y)); } inline double _d0_hypot(double x,double y) { return (x)/sqrt((x)*(x)+(y)*(y)); } /* fixme */ inline double _d1_hypot(double x,double y) { return (y)/sqrt((x)*(x)+(y)*(y)); } /* fixme */ inline double _max(double x,double y) { return ((x)>(y))?(x):(y); } inline double _d0_max(double x,double y) { return ((x)>(y))?1.0:0.0; } inline double _d1_max(double x,double y) { return ((x)>(y))?0.0:1.0; } inline double _min(double x,double y) { return ((x)<(y))?(x):(y); } inline double _d0_min(double x,double y) { return ((x)<(y))?1.0:0.0; } inline double _d1_min(double x,double y) { return ((x)<(y))?0.0:1.0; } inline double _pow(double x,double y) { return pow(x,y); } inline double _d0_pow(double x,double y) { return (x==0.0)?0.0:((y/x)*pow(x,y)); } /* fixme */ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0.0))*pow(x,y)); } /* fixme */ #define _limexp(arg) _exp(val,arg) #define _d_limexp(arg) _d_exp(val,dval,arg) inline double $(module)_vt (double Tdev) { return 1.3806503e-23*Tdev/1.602176462e-19; } inline double $(module)_d_vt (double Tdev, double d_Tdev) { double vt_Tdev=1.3806503e-23/1.602176462e-19; return vt_Tdev*d_Tdev; } $(module)_$function ( ); $(module)_d_$(function) ( , ); $(module)_$function ( ) { return $function; } double $(module)_d_$(function) ( , ) { ; return ; } #ifdef STAND_ALONE int main(void) { double my$function, myd_$function, ; my$function=$(module)_$function( ); myd_$function=$(module)_d_$function( , ); printf("my$function=%%e\\n",my$function); printf("myd_$function=%%e\\n",myd_$function); printf("(1.0,1.0) norm0=%%e dnorm0=%%e [expected: 1.0]\\n", $(module)_norm(1.0,1.0,0.0), $(module)_d_norm(1.0,1.0,0.0,1.0,1.0,1.0)); printf("(1.0,1.0) norm1=%%e dnorm1=%%e [expected: 2.0]\\n", $(module)_norm(1.0,1.0,1.0), $(module)_d_norm(1.0,1.0,1.0,1.0,1.0,1.0)); printf("(1.0,1.0) norm2=%%e dnorm2=%%e [expected: sqrt(2.0)=%%e]\\n",$(module)_norm(1.0,1.0,2.0), $(module)_d_norm(1.0,1.0,2.0,1.0,1.0,1.0),sqrt(2)); double x,xnb=500.0,xmin=0.0,xmax=10.0,xstep=(xmax-xmin)/xnb; FILE*y=fopen("y.data","w"); FILE*dy=fopen("dy.data","w"); for(x=xmin;x<=xmax;x+=xstep) { fprintf(y,"%%.2f %%.2f\\n",x,$(module)_$myfunction(x)); fprintf(dy,"%%.2f %%.2f\\n",x,$(module)_d_$myfunction(x,1.0)); } fclose(y); fclose(dy); return 0; } #endif /* STAND_ALONE */ /* * analogfunction.h - analog function header * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * */ #ifdef __cplusplus extern "C" { #endif /*__cplusplus*/ #ifndef __$(module)_ANALOGFUNCTION_H__ #define __$(module)_ANALOGFUNCTION_H__ #endif /* __$(module)_ANALOGFUNCTION_H__ */ #ifdef __cplusplus } #endif /*__cplusplus*/ /* * analogfunction.cpp - analog function implementations * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * */ #include <stdio.h> #include "analogfunction.h" #include <math.h> #ifdef __cplusplus extern "C" { #endif /*__cplusplus*/ #ifdef __cplusplus } #endif /*__cplusplus*/ ADMS-release-2.3.7/scripts/arobavariable.xml000066400000000000000000000047621371671745500207210ustar00rootroot00000000000000 `include "discipline.h" module $(module1)(p,n); inout p, n; electrical p, n; parameter real A=1.0; parameter real B=1.0; real a,b; analog begin begin : A real a,b; a=1; b=1; end begin : B a=1; b=1; end end endmodule ADMS-release-2.3.7/scripts/attributes.xml000066400000000000000000000077041371671745500203140ustar00rootroot00000000000000 `include "disciplines.h" (* info_before="module info before" *) module mymodule (p,n) (* info_after="module info after" *) ; (*globalterminal="my terminals"*) inout p, n; electrical p(*localterm="my p term"*), n(*localterm="my n term"*); (*globalbranch="my branches"*)branch (p,n) pn; (*globalwidth="width applies to all parameters"*) parameter real w1=1u (*localwidth="local attribute of width1"*), w2=1u (*localwidth="local attribute of width2"*); (*globallength="length applies to all parameters"*) parameter real l1=1u (*locallength="local attribute of length1"*), l2=1u (*locallength="local attribute of length2"*); (*global="my conductances"*) real g1 (*local="this is g1"*),g2 (*local="this is g2"*),g3 (*local="this is g3"*),g4 (*local="this is g4"*); analog begin g1=w1/l1; g2=w2/l2; I(p,n)<+g1*V(p,n) (*contrib_attr1="hello1" contrib_attr2="hello2"*); I(p,n)<+g2*V(p,n) (*contrib1="hello1bis" contrib2="hello2bis" contrib3="hello3" contrib4="hello4"*); end endmodule ADMS-release-2.3.7/scripts/blockvariables.xml000066400000000000000000000062651371671745500211120ustar00rootroot00000000000000 %(branch/pnode/name),%(branch/nnode/name) `include "disciplines.h" module myblockvariable (p,n); inout p, n; electrical p, n; parameter real w=1u; parameter real l=1u; parameter integer level=0; real a1; analog begin : main begin : A real a1, a2, a3; real b1, b2, b3; a1=V(p,n); //A.a1 end a1=1; //myblockvariable.a1 begin : B real a1, a2, a3, a4; real b1, b2, b3; b1=1; //B.b1 begin : C real a1, a2, a3; real b1, b2, b3; a2=V(p,n); //C.a2 end a2=V(p,n); //B.a2 end a1=w/l; //myblockvariable.a1 I(p,n) <+ a1*V(p,n); end endmodule ADMS-release-2.3.7/scripts/croixvariable.xml000066400000000000000000000050031371671745500207460ustar00rootroot00000000000000 `include "discipline.h" module $(module1)(p,n); inout p, n; electrical p, n; parameter real A=1.0; parameter real B=1.0; real a,b; analog begin begin : Loc real a,b; (*eq="Eq.1"*) a=1; (*eq="Eq.2"*) b=1; end begin : Glob (*eq="Eq.1"*) a=1; (*eq="Eq.2"*) b=1; end end endmodule ADMS-release-2.3.7/scripts/dependency.xml000066400000000000000000000351751371671745500202470ustar00rootroot00000000000000 +: 0 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 -: 0 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 *: 0 1 2 3 1 1 2 3 2 2 3 3 3 3 3 3 /: 0 1 3 3 1 1 3 3 2 2 3 3 3 3 3 3 ?: arg1=c: 0 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 ?: arg1=np: 1 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 ?: arg1=l : 1 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 ?: arg1=nl: 1 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 sqrt: 0.0 1.0 3.1 3.1 pow: 0.0 1.0 3.1 3.1 1.0 1.0 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 ddx: 0.0 1.0 3.1 3.1 branch: p:GND=yes source: V(p:GND)=yes source: I(p:GND)=yes probe: I(p:GND)=yes probe: V(p:GND)=yes c: parametertype=model input=no np: parametertype=model input=no l: parametertype=model input=no nl: parametertype=model input=no P: parametertype=instance input=yes C01: parametertype=model input=no C02: parametertype=model input=no C03: parametertype=model input=no C04: parametertype=model input=no C05: parametertype=model input=no C06: parametertype=model input=no C07: parametertype=model input=no C08: parametertype=model input=no C09: parametertype=model input=no C10: parametertype=model input=no C11: parametertype=model input=no C12: parametertype=model input=no C13: parametertype=model input=no C14: parametertype=model input=no C15: parametertype=model input=no C16: parametertype=model input=no A: parametertype=model input=no B: parametertype=model input=no AA: parametertype=model input=no awl: parametertype=model input=no bwl: parametertype=model input=no afl: parametertype=model input=no bfl: parametertype=model input=no c: input=local OPdependent=no np: input=local OPdependent=yes l: input=local OPdependent=yes nl: input=local OPdependent=yes P: input=global_instance OPdependent=no C01: input=local OPdependent=no C02: input=local OPdependent=yes C03: input=local OPdependent=yes C04: input=local OPdependent=yes C05: input=local OPdependent=yes C06: input=local OPdependent=yes C07: input=local OPdependent=yes C08: input=local OPdependent=yes C09: input=local OPdependent=yes C10: input=local OPdependent=yes C11: input=local OPdependent=yes C12: input=local OPdependent=yes C13: input=local OPdependent=yes C14: input=local OPdependent=yes C15: input=local OPdependent=yes C16: input=local OPdependent=yes A: input=local OPdependent=yes B: input=local OPdependent=yes AA: input=global_instance OPdependent=no awl: input=local OPdependent=yes bwl: input=local OPdependent=yes afl: input=local OPdependent=yes bfl: input=local OPdependent=yes P from [(0):(1)] P exclude [(-inf):(+inf)] I(p:GND)<+(I(p:GND)); wn=no lhswn=no I(p:GND)<+(V(p:GND)); wn=no lhswn=no V(p:GND)<+(I(p:GND)); wn=no lhswn=yes V(p:GND)<+(white_noise(V(p:GND))); wn=yes lhswn=yes V(p:GND)<+(flicker_noise(V(p:GND),1.0)); wn=no lhswn=yes I(p:GND)<+(I(p:GND)); lhsfn=no fn=no I(p:GND)<+(V(p:GND)); lhsfn=no fn=no V(p:GND)<+(I(p:GND)); lhsfn=yes fn=no V(p:GND)<+(white_noise(V(p:GND))); lhsfn=yes fn=no V(p:GND)<+(flicker_noise(V(p:GND),1.0)); lhsfn=yes fn=yes conditional: 000001002003010011012013020021022023030031032033111111112113111111112113121121122123131131132133211211212213211211212213221221222223231231232233311311312313311311312313321321322323331331332333 C0 0_0_0 1_1_1 1_1_1 1_1_1 1_1_1 1_1_1 1_1_1 1_1_1 2_2_2 2_2_2 2_2_2 2_2_2 3_3_3 3_3_3 3_3_3 3_3_3 C1 0 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 -------- 1 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 -------- 1 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 -------- 1 1 2 3 1 1 2 3 2 2 2 3 3 3 3 3 -------- LOOPS block.fl: linear block.FL: linear block.wl: nonlinear block.WL: nonlinear block.main: nonlinear c: constant np: noprobe l: linear nl: nonlinear P: constant C01: constant C02: noprobe C03: noprobe C04: noprobe C05: noprobe C06: noprobe C07: noprobe C08: noprobe C09: linear C10: linear C11: linear C12: linear C13: nonlinear C14: nonlinear C15: nonlinear C16: nonlinear A: nonlinear B: nonlinear AA: constant awl: noprobe bwl: nonlinear afl: noprobe bfl: linear `include "disciplines.vams" module $m (p); electrical p; real c,np,l,nl; (*type="instance"*) parameter real P=1 from [0:1] exclude [-inf:+inf]; real C01,C02,C03,C04,C05,C06,C07,C08,C09; real C10,C11,C12,C13,C14,C15,C16; real A; real B; real AA (*ask="yes"*); real awl,bwl; real afl,bfl; analog begin : main c=1; if(V(p)) np=1; l=V(p); nl=log(V(p)); (*dbg:name="+"*) A=c +c ; A=c +np; A=c +l ; (*dbg:nl*) A=c +nl; A=np+c ; A=np+np; A=np+l ; (*dbg:nl*) A=np+nl; A=l +c ; A=l +np; A=l +l ; (*dbg:nl*) A=l +nl; A=nl+c ; A=nl+np; A=nl+l ; (*dbg:nl*) A=nl+nl; (*dbg:name="-"*) A=c -c ; A=c -np; A=c -l ; (*dbg:nl*) A=c -nl; A=np-c ; A=np-np; A=np-l ; (*dbg:nl*) A=np-nl; A=l -c ; A=l -np; A=l -l ; (*dbg:nl*) A=l -nl; A=nl-c ; A=nl-np; A=nl-l ; (*dbg:nl*) A=nl-nl; (*dbg:name="*"*) A=c *c ; A=c *np; A=c *l ; (*dbg:nl*) A=c *nl; A=np*c ; A=np*np; A=np*l ; (*dbg:nl*) A=np*nl; A=l *c ; A=l *np; A=l *l ; (*dbg:nl*) A=l *nl; A=nl*c ; A=nl*np; A=nl*l ; (*dbg:nl*) A=nl*nl; (*dbg:name="/"*) A=c /c ; A=c /np; A=c /l ; (*dbg:nl*) A=c /nl; A=np/c ; A=np/np; A=np/l ; (*dbg:nl*) A=np/nl; A=l /c ; A=l /np; A=l /l ; (*dbg:nl*) A=l /nl; A=nl/c ; A=nl/np; A=nl/l ; (*dbg:nl*) A=nl/nl; (*dbg:name="?: arg1=c"*) A=c ?c :c ; A=c ?c :np; A=c ?c :l ; (*dbg:nl*) A=c ?c :nl; A=c ?np:c ; A=c ?np:np; A=c ?np:l ; (*dbg:nl*) A=c ?np:nl; A=c ?l :c ; A=c ?l :np; A=c ?l :l ; (*dbg:nl*) A=c ?l :nl; A=c ?nl:c ; A=c ?nl:np; A=c ?nl:l ; (*dbg:nl*) A=c ?nl:nl; (*dbg:name="?: arg1=np"*) A=np?c :c ; A=np?c :np; A=np?c :l ; (*dbg:nl*) A=np?c :nl; A=np?np:c ; A=np?np:np; A=np?np:l ; (*dbg:nl*) A=np?np:nl; A=np?l :c ; A=np?l :np; A=np?l :l ; (*dbg:nl*) A=np?l :nl; A=np?nl:c ; A=np?nl:np; A=np?nl:l ; (*dbg:nl*) A=np?nl:nl; (*dbg:name="?: arg1=l "*) A=l ?c :c ; A=l ?c :np; A=l ?c :l ; (*dbg:nl*) A=l ?c :nl; A=l ?np:c ; A=l ?np:np; A=l ?np:l ; (*dbg:nl*) A=l ?np:nl; A=l ?l :c ; A=l ?l :np; A=l ?l :l ; (*dbg:nl*) A=l ?l :nl; A=l ?nl:c ; A=l ?nl:np; A=l ?nl:l ; (*dbg:nl*) A=l ?nl:nl; (*dbg:name="?: arg1=nl"*) A=nl?c :c ; A=nl?c :np; A=nl?c :l ; (*dbg:nl*) A=nl?c :nl; A=nl?np:c ; A=nl?np:np; A=nl?np:l ; (*dbg:nl*) A=nl?np:nl; A=nl?l :c ; A=nl?l :np; A=nl?l :l ; (*dbg:nl*) A=nl?l :nl; A=nl?nl:c ; A=nl?nl:np; A=nl?nl:l ; (*dbg:nl*) A=nl?nl:nl; (*dbg:name="sqrt"*) A=sqrt(c) ; A=sqrt(np); A=sqrt(l ); (*dbg:nl*) A=sqrt(nl); (*dbg:name="pow"*) A=pow(c ,c) ; A=pow(c ,np); A=pow(c ,l ); (*dbg:nl*) A=pow(c ,nl); A=pow(np,c) ; A=pow(np,np); A=pow(np,l ); (*dbg:nl*) A=pow(np,nl); A=pow(l ,c) ; A=pow(l ,np); A=pow(l ,l ); (*dbg:nl*) A=pow(l ,nl); A=pow(nl,c) ; A=pow(nl,np); A=pow(nl,l ); (*dbg:nl*) A=pow(nl,nl); (*dbg:name="ddx"*) A=ddx(c) ; A=ddx(np,V(p)); A=ddx(l ,V(p)); (*dbg:nl*) A=ddx(nl,V(p)); I(p)<+I(p); I(p)<+V(p); V(p)<+I(p); V(p)<+white_noise(V(p)); V(p)<+flicker_noise(V(p),1.0); if(c ) (*dbg:c0="" *) C01=c ; if(np) (*dbg:c0="" *) C02=c ; if(l ) (*dbg:c0="" *) C03=c ; if(nl) (*dbg:c0="\n"*) C04=c ; if(c ) (*dbg:c0="" *) C05=np; if(np) (*dbg:c0="" *) C06=np; if(l ) (*dbg:c0="" *) C07=np; if(nl) (*dbg:c0="\n"*) C08=np; if(c ) (*dbg:c0="" *) C09=l ; if(np) (*dbg:c0="" *) C10=l ; if(l ) (*dbg:c0="" *) C11=l ; if(nl) (*dbg:c0="\n"*) C12=l ; if(c ) (*dbg:c0="" *) C13=nl; if(np) (*dbg:c0="" *) C14=nl; if(l ) (*dbg:c0="" *) C15=nl; if(nl) (*dbg:c0="\n"*) C16=nl; if(c ) (*dbg:c1="" *) B=c ; else B=c; if(c ) (*dbg:c1="" *) B=c ; else B=np; if(c ) (*dbg:c1="" *) B=c ; else B=l ; if(c ) (*dbg:c1="\n" *) B=c ; else B=nl; if(c ) (*dbg:c1="" *) B=np; else B=c ; if(c ) (*dbg:c1="" *) B=np; else B=np; if(c ) (*dbg:c1="" *) B=np; else B=l ; if(c ) (*dbg:c1="\n" *) B=np; else B=nl; if(c ) (*dbg:c1="" *) B=l ; else B=c ; if(c ) (*dbg:c1="" *) B=l ; else B=np; if(c ) (*dbg:c1="" *) B=l ; else B=l; if(c ) (*dbg:c1="\n" *) B=l ; else B=nl; if(c ) (*dbg:c1="" *) B=nl; else B=c ; if(c ) (*dbg:c1="" *) B=nl; else B=np; if(c ) (*dbg:c1="" *) B=nl; else B=l ; if(c ) (*dbg:c1="\n--------\n"*) B=nl; else B=nl; if(np) (*dbg:c1="" *) B=c ; else B=c; if(np) (*dbg:c1="" *) B=c ; else B=np; if(np) (*dbg:c1="" *) B=c ; else B=l ; if(np) (*dbg:c1="\n" *) B=c ; else B=nl; if(np) (*dbg:c1="" *) B=np; else B=c ; if(np) (*dbg:c1="" *) B=np; else B=np; if(np) (*dbg:c1="" *) B=np; else B=l ; if(np) (*dbg:c1="\n" *) B=np; else B=nl; if(np) (*dbg:c1="" *) B=l ; else B=c ; if(np) (*dbg:c1="" *) B=l ; else B=np; if(np) (*dbg:c1="" *) B=l ; else B=l; if(np) (*dbg:c1="\n" *) B=l ; else B=nl; if(np) (*dbg:c1="" *) B=nl; else B=c ; if(np) (*dbg:c1="" *) B=nl; else B=np; if(np) (*dbg:c1="" *) B=nl; else B=l ; if(np) (*dbg:c1="\n--------\n"*) B=nl; else B=nl; if(l ) (*dbg:c1="" *) B=c ; else B=c; if(l ) (*dbg:c1="" *) B=c ; else B=np; if(l ) (*dbg:c1="" *) B=c ; else B=l ; if(l ) (*dbg:c1="\n" *) B=c ; else B=nl; if(l ) (*dbg:c1="" *) B=np; else B=c ; if(l ) (*dbg:c1="" *) B=np; else B=np; if(l ) (*dbg:c1="" *) B=np; else B=l ; if(l ) (*dbg:c1="\n" *) B=np; else B=nl; if(l ) (*dbg:c1="" *) B=l ; else B=c ; if(l ) (*dbg:c1="" *) B=l ; else B=np; if(l ) (*dbg:c1="" *) B=l ; else B=l; if(l ) (*dbg:c1="\n" *) B=l ; else B=nl; if(l ) (*dbg:c1="" *) B=nl; else B=c ; if(l ) (*dbg:c1="" *) B=nl; else B=np; if(l ) (*dbg:c1="" *) B=nl; else B=l ; if(l ) (*dbg:c1="\n--------\n"*) B=nl; else B=nl; if(nl) (*dbg:c1="" *) B=c ; else B=c; if(nl) (*dbg:c1="" *) B=c ; else B=np; if(nl) (*dbg:c1="" *) B=c ; else B=l ; if(nl) (*dbg:c1="\n" *) B=c ; else B=nl; if(nl) (*dbg:c1="" *) B=np; else B=c ; if(nl) (*dbg:c1="" *) B=np; else B=np; if(nl) (*dbg:c1="" *) B=np; else B=l ; if(nl) (*dbg:c1="\n" *) B=np; else B=nl; if(nl) (*dbg:c1="" *) B=l ; else B=c ; if(nl) (*dbg:c1="" *) B=l ; else B=np; if(nl) (*dbg:c1="" *) B=l ; else B=l; if(nl) (*dbg:c1="\n" *) B=l ; else B=nl; if(nl) (*dbg:c1="" *) B=nl; else B=c ; if(nl) (*dbg:c1="" *) B=nl; else B=np; if(nl) (*dbg:c1="" *) B=nl; else B=l ; if(nl) (*dbg:c1="\n--------\n"*) B=nl; else B=nl; begin : WL while(bwl==0) begin : wl awl=1; bwl=V(p)*V(p); end end begin : FL for(afl=1;afl<bfl;bfl=1) begin : fl afl=1; bfl=V(p); end end end endmodule 0 1 2 3 0 1 ADMS-release-2.3.7/scripts/getargv.xml000066400000000000000000000024601371671745500175570ustar00rootroot00000000000000 ADMS-release-2.3.7/scripts/getenv.xml000066400000000000000000000024441371671745500174120ustar00rootroot00000000000000 ADMS-release-2.3.7/scripts/getinstance.xml000066400000000000000000000061741371671745500204320ustar00rootroot00000000000000 `include "discipline.h" module c(ct1,ct2); inout ct1, ct2; electrical ct1, ct2; parameter real cP1 = 10; parameter real cP2 = 10; analog begin I(ct1,ct2)<+V(ct1,ct2)/(cP1+cP2); end endmodule module b(bt1,bt2); inout bt1, bt2; electrical bt1, bt2; parameter real bP1 = 10; parameter real bP2 = 10; analog begin I(bt1,bt2)<+V(bt1,bt2)/bP1; end c #(.cP1(bP2),.cP2(bP1)) C1(bt1,bt2); endmodule module a(at1, at2); parameter real aP=1.0; inout at1, at2; electrical at1, at2; electrical topin; analog begin I(at1,at2)<+V(at1,at2)/aP; end b #(.bP1(aP),.bP2(1/aP)) B1(at1,at2); b #(.bP2(aP)) B2(at2,at1); endmodule ADMS-release-2.3.7/scripts/gettransform.xml000066400000000000000000000026361371671745500206400ustar00rootroot00000000000000 %(.) ADMS-release-2.3.7/scripts/sort.xml000066400000000000000000000201041371671745500171020ustar00rootroot00000000000000 `include "discipline.h" module $(module1)(p,n); inout p, n; electrical p, n; parameter real B=1.0; parameter real A=1.0; real b,a; analog a=1; endmodule 01 ** foreach(variable) text................................@returns (B,A,b,a) 02 ** foreach.sort(variable) text...........................@returns (A,B,a,b) 03 ** \$p1=variable text(\$p1)................................@returns (B,A,b,a) 04 ** \$p1=sort(variable) text(\$p1)..........................@returns (A,B,a,b) 05 ** text(variable)........................................@returns (B,A,b,a) 06 ** text(sort(variable))..................................@returns (A,B,a,b) 07 ** foreach(reverse(variable))............................@returns (a,b,A,B) 08 ** \$p1=variable text(reverse(\$p1)).......................@returns (a,b,A,B) 09 ** \$p1=reverse(variable) text(\$p1).......................@returns (a,b,A,B) 10 ** reset(\$p1) push(\$p1,variable[input='no']) text(\$p1)...@returns (a,b) 11 ** \$p2=reverse(sort(\$p1)) text(\$p2)......................@returns (b,a) 12 ** push(\$p1,variable) text(\$p1)..........................@returns (a,b,A,B,a,b) 13 ** text(sort(reverse(\$p1)))..............................@returns (A,B,a,a,b,b) 14 ** reset(\$p3) push(\$p3,\$p2) push(\$p3,\$p1) text(\$p1)......@returns (b,a,B,A,b,a,a,b) 01 ** foreach(variable) text................................@returns (B,A,b,a) B,A,b,a, 1.0 2.1 3.2 4.3 02 ** foreach.sort(variable) text...........................@returns (A,B,a,b) A,B,a,b, 1.1 2.0 3.3 4.2 03 ** \$p1=variable text(\$p1)................................@returns (B,A,b,a) B,A,b,a, 1.0 2.1 3.2 4.3 04 ** \$p1=sort(variable) text(\$p1)..........................@returns (A,B,a,b) A,B,a,b, 1.0 2.1 3.2 4.3 05 ** text(variable)........................................@returns (B,A,b,a) B,A,b,a, 1.0 2.1 3.2 4.3 06 ** text(sort(variable))..................................@returns (A,B,a,b) A,B,a,b, 1.1 2.0 3.3 4.2 07 ** foreach(reverse(variable))............................@returns (a,b,A,B) a,b,A,B, 1.3 2.2 3.1 4.0 08 ** \$p1=variable text(reverse(\$p1)).......................@returns (a,b,A,B) a,b,A,B, 1.3 2.2 3.1 4.0 09 ** \$p1=reverse(variable) text(\$p1).......................@returns (a,b,A,B) a,b,A,B, 1.0 2.1 3.2 4.3 10 ** reset(\$p1) push(\$p1,variable[input='no']) text(\$p1)...@returns (a,b) a,b, 1.0 2.1 11 ** \$p2=reverse(sort(\$p1)) text(\$p2)......................@returns (b,a) b,a, 1.0 2.1 12 ** push(\$p1,variable) text(\$p1)..........................@returns (a,b,A,B,a,b) a,b,A,B,a,b, 1.0 2.1 3.2 4.3 5.0 6.1 13 ** text(sort(reverse(\$p1)))..............................@returns (A,B,a,a,b,b) A,B,a,a,b,b, 1.2 2.3 3.0 4.0 5.1 6.1 14 ** reset(\$p3) push(\$p3,\$p2) push(\$p3,\$p1) text(\$p1)......@returns (b,a,B,A,b,a,a,b) b,a,B,A,b,a,a,b, 1.1 2.0 3.3 4.2 5.1 6.0 7.0 8.1 ADMS-release-2.3.7/scripts/strutils.xml000066400000000000000000000062031371671745500200100ustar00rootroot00000000000000 upper-case: 1.0: B upper-case: 2.1: A upper-case: 3.0: B upper-case: 4.1: A upper-case: 5.4: COMMENTCAVA upper-case: 6.5: CAVATRESBIEN lower-case: 1.0: b lower-case: 2.1: a lower-case: 3.0: b lower-case: 4.1: a lower-case: 5.4: commentcava lower-case: 6.5: cavatresbien original: 1 B: 0: B original: 2 A: 1: A original: 3 b: 2: b original: 4 a: 3: a original: 5 CommentCaVa: 4: CommentCaVa original: 6 CaVatresBien: 5: CaVatresBien ---- basicstringbasicstringbasicstringbasicstringbasicstringbasicstring cavatresbiencommentcavaabab ---- basicstringbasicstringbasicstringbasicstringbasicstringbasicstring CAVATRESBIENCOMMENTCAVAABAB oooo basicstringbasicstringbasicstringbasicstring CAVATRESBIENCOMMENTCAVAAB oooo basicstringbasicstringbasicstringbasicstring CAVATRESBIENCOMMENTCAVAAB `include "discipline.h" module strutils(p,n); inout p, n; electrical p, n; parameter real B=1.0; parameter real A=1.0; real b,a; real CommentCaVa,CaVatresBien; analog a=1; endmodule ADMS-release-2.3.7/scripts/vlatommlMODULE.htm.xml000066400000000000000000001156601371671745500214570ustar00rootroot00000000000000 [ <!ENTITY ac "&#x0290F;" ><!--most positive --> <!ENTITY acE "&#x029DB;" ><!--most positive, two lines below --> <!ENTITY amalg "&#x02A3F;" ><!--/amalg B: amalgamation or coproduct --> <!ENTITY barvee "&#x022BD;" ><!--bar, vee --> <!ENTITY barwed "&#x022BC;" ><!--/barwedge B: logical and, bar above --> <!ENTITY Barwed "&#x02306;" ><!--/doublebarwedge B: log and, dbl bar above --> <!ENTITY bsolb "&#x029C5;" ><!--reverse solidus in square --> <!ENTITY Cap "&#x022D2;" ><!--/Cap /doublecap B: dbl intersection --> <!ENTITY capand "&#x02A44;" ><!--intersection, and --> <!ENTITY capbrcup "&#x02A49;" ><!--intersection, bar, union --> <!ENTITY capcap "&#x02A4B;" ><!--intersection, intersection, joined --> <!ENTITY capcup "&#x02A47;" ><!--intersection above union --> <!ENTITY capdot "&#x02A40;" ><!--intersection, with dot --> <!ENTITY caps "&#x02229;&#x0FE00;" ><!--intersection, serifs --> <!ENTITY ccaps "&#x02A4D;" ><!--closed intersection, serifs --> <!ENTITY ccups "&#x02A4C;" ><!--closed union, serifs --> <!ENTITY ccupssm "&#x02A50;" ><!--closed union, serifs, smash product --> <!ENTITY coprod "&#x02210;" ><!--/coprod L: coproduct operator --> <!ENTITY Cup "&#x022D3;" ><!--/Cup /doublecup B: dbl union --> <!ENTITY cupbrcap "&#x02A48;" ><!--union, bar, intersection --> <!ENTITY cupcap "&#x02A46;" ><!--union above intersection --> <!ENTITY cupcup "&#x02A4A;" ><!--union, union, joined --> <!ENTITY cupdot "&#x0228D;" ><!--union, with dot --> <!ENTITY cupor "&#x02A45;" ><!--union, or --> <!ENTITY cups "&#x0222A;&#x0FE00;" ><!--union, serifs --> <!ENTITY cuvee "&#x022CE;" ><!--/curlyvee B: curly logical or --> <!ENTITY cuwed "&#x022CF;" ><!--/curlywedge B: curly logical and --> <!ENTITY dagger "&#x02020;" ><!--/dagger B: dagger relation --> <!ENTITY Dagger "&#x02021;" ><!--/ddagger B: double dagger relation --> <!ENTITY diam "&#x022C4;" ><!--/diamond B: open diamond --> <!ENTITY divonx "&#x022C7;" ><!--/divideontimes B: division on times --> <!ENTITY eplus "&#x02A71;" ><!--equal, plus --> <!ENTITY hercon "&#x022B9;" ><!--hermitian conjugate matrix --> <!ENTITY intcal "&#x022BA;" ><!--/intercal B: intercal --> <!ENTITY iprod "&#x02A3C;" ><!--/intprod --> <!ENTITY loplus "&#x02A2D;" ><!--plus sign in left half circle --> <!ENTITY lotimes "&#x02A34;" ><!--multiply sign in left half circle --> <!ENTITY lthree "&#x022CB;" ><!--/leftthreetimes B: --> <!ENTITY ltimes "&#x022C9;" ><!--/ltimes B: times sign, left closed --> <!ENTITY midast "&#x0002A;" ><!--/ast B: asterisk --> <!ENTITY minusb "&#x0229F;" ><!--/boxminus B: minus sign in box --> <!ENTITY minusd "&#x02238;" ><!--/dotminus B: minus sign, dot above --> <!ENTITY minusdu "&#x02A2A;" ><!--minus sign, dot below --> <!ENTITY ncap "&#x02A43;" ><!--bar, intersection --> <!ENTITY ncup "&#x02A42;" ><!--bar, union --> <!ENTITY oast "&#x0229B;" ><!--/circledast B: asterisk in circle --> <!ENTITY ocir "&#x0229A;" ><!--/circledcirc B: small circle in circle --> <!ENTITY odash "&#x0229D;" ><!--/circleddash B: hyphen in circle --> <!ENTITY odiv "&#x02A38;" ><!--divide in circle --> <!ENTITY odot "&#x02299;" ><!--/odot B: middle dot in circle --> <!ENTITY odsold "&#x029BC;" ><!--dot, solidus, dot in circle --> <!ENTITY ofcir "&#x029BF;" ><!--filled circle in circle --> <!ENTITY ogt "&#x029C1;" ><!--greater-than in circle --> <!ENTITY ohbar "&#x029B5;" ><!--circle with horizontal bar --> <!ENTITY olcir "&#x029BE;" ><!--large circle in circle --> <!ENTITY olt "&#x029C0;" ><!--less-than in circle --> <!ENTITY omid "&#x029B6;" ><!--vertical bar in circle --> <!ENTITY ominus "&#x02296;" ><!--/ominus B: minus sign in circle --> <!ENTITY opar "&#x029B7;" ><!--parallel in circle --> <!ENTITY operp "&#x029B9;" ><!--perpendicular in circle --> <!ENTITY oplus "&#x02295;" ><!--/oplus B: plus sign in circle --> <!ENTITY osol "&#x02298;" ><!--/oslash B: solidus in circle --> <!ENTITY otimes "&#x02297;" ><!--/otimes B: multiply sign in circle --> <!ENTITY Otimes "&#x02A37;" ><!--multiply sign in double circle --> <!ENTITY otimesas "&#x02A36;" ><!--multiply sign in circle, circumflex accent --> <!ENTITY ovbar "&#x0233D;" ><!--circle with vertical bar --> <!ENTITY plusacir "&#x02A23;" ><!--plus, circumflex accent above --> <!ENTITY plusb "&#x0229E;" ><!--/boxplus B: plus sign in box --> <!ENTITY pluscir "&#x02A22;" ><!--plus, small circle above --> <!ENTITY plusdo "&#x02214;" ><!--/dotplus B: plus sign, dot above --> <!ENTITY plusdu "&#x02A25;" ><!--plus sign, dot below --> <!ENTITY pluse "&#x02A72;" ><!--plus, equals --> <!ENTITY plussim "&#x02A26;" ><!--plus, similar below --> <!ENTITY plustwo "&#x02A27;" ><!--plus, two; Nim-addition --> <!ENTITY prod "&#x0220F;" ><!--/prod L: product operator --> <!ENTITY race "&#x029DA;" ><!--reverse most positive, line below --> <!ENTITY roplus "&#x02A2E;" ><!--plus sign in right half circle --> <!ENTITY rotimes "&#x02A35;" ><!--multiply sign in right half circle --> <!ENTITY rthree "&#x022CC;" ><!--/rightthreetimes B: --> <!ENTITY rtimes "&#x022CA;" ><!--/rtimes B: times sign, right closed --> <!ENTITY sdot "&#x022C5;" ><!--/cdot B: small middle dot --> <!ENTITY sdotb "&#x022A1;" ><!--/dotsquare /boxdot B: small dot in box --> <!ENTITY setmn "&#x02216;" ><!--/setminus B: reverse solidus --> <!ENTITY simplus "&#x02A24;" ><!--plus, similar above --> <!ENTITY smashp "&#x02A33;" ><!--smash product --> <!ENTITY solb "&#x029C4;" ><!--solidus in square --> <!ENTITY sqcap "&#x02293;" ><!--/sqcap B: square intersection --> <!ENTITY sqcaps "&#x02293;&#x0FE00;" ><!--square intersection, serifs --> <!ENTITY sqcup "&#x02294;" ><!--/sqcup B: square union --> <!ENTITY sqcups "&#x02294;&#x0FE00;" ><!--square union, serifs --> <!ENTITY ssetmn "&#x02216;&#x0FE00;" ><!--/smallsetminus B: sm reverse solidus --> <!ENTITY sstarf "&#x022C6;" ><!--/star B: small star, filled --> <!ENTITY subdot "&#x02ABD;" ><!--subset, with dot --> <!ENTITY sum "&#x02211;" ><!--/sum L: summation operator --> <!ENTITY supdot "&#x02ABE;" ><!--superset, with dot --> <!ENTITY timesb "&#x022A0;" ><!--/boxtimes B: multiply sign in box --> <!ENTITY timesbar "&#x02A31;" ><!--multiply sign, bar below --> <!ENTITY timesd "&#x02A30;" ><!--times, dot --> <!ENTITY tridot "&#x025EC;" ><!--dot in triangle --> <!ENTITY triminus "&#x02A3A;" ><!--minus in triangle --> <!ENTITY triplus "&#x02A39;" ><!--plus in triangle --> <!ENTITY trisb "&#x029CD;" ><!--triangle, serifs at bottom --> <!ENTITY tritime "&#x02A3B;" ><!--multiply in triangle --> <!ENTITY uplus "&#x0228E;" ><!--/uplus B: plus sign in union --> <!ENTITY veebar "&#x022BB;" ><!--/veebar B: logical or, bar below --> <!ENTITY wedbar "&#x02A5F;" ><!--wedge, bar below --> <!ENTITY wreath "&#x02240;" ><!--/wr B: wreath product --> <!ENTITY xcap "&#x022C2;" ><!--/bigcap L: intersection operator --> <!ENTITY xcirc "&#x025EF;" ><!--/bigcirc B: large circle --> <!ENTITY xcup "&#x022C3;" ><!--/bigcup L: union operator --> <!ENTITY xdtri "&#x025BD;" ><!--/bigtriangledown B: big dn tri, open --> <!ENTITY xodot "&#x02299;" ><!--/bigodot L: circle dot operator --> <!ENTITY xoplus "&#x02295;" ><!--/bigoplus L: circle plus operator --> <!ENTITY xotime "&#x02297;" ><!--/bigotimes L: circle times operator --> <!ENTITY xsqcup "&#x02294;" ><!--/bigsqcup L: square union operator --> <!ENTITY xuplus "&#x0228E;" ><!--/biguplus L: --> <!ENTITY xutri "&#x025B3;" ><!--/bigtriangleup B: big up tri, open --> <!ENTITY xvee "&#x022C1;" ><!--/bigvee L: logical and operator --> <!ENTITY xwedge "&#x022C0;" ><!--/bigwedge L: logical or operator --> ] <admst:text format="Module %(name) (%(/simulator/currentdate))\n"/>

Module %(name) (%(/simulator/currentdate))

Note:\n This file has been created automatically from a Verilog-AMS input file using adms and xml translater vlatomml.xml.\n The main purpose of the translater is to help debugging adms and\n simplifying the process of documenting compact devices.\n The rendering of the output\n can greatly be improved. Any comments/helps highly appreciated.[r29173]
Usefull links:
  • \n vlatomml.xml: script used to convert verilog-ams code into xhtml+mathml format using\n adms
  • MathPlayer: displays mathml equations in browser (IE5/IE6 only)
  • W3C-MathML: good starting point to learn mathml

Input Variables

Input Variables: instance=%(count(variable[input='yes' and parametertype='instance'])) (bold) and model=%(count(variable[input='yes' and parametertype='model']))
name description default
%(name) %(value) - (%(value))
%(name) %(value) - (%(value))

Output Variables

Output Variables: instance=%(count(variable[input='no' and output='yes' and parametertype='instance'])) (bold) and model=%(count(variable[input='no' and output='yes' and parametertype='model'])) (red-underlined: temperature dependent)
name description dependencies
%(name) %(name) %(value) - %(name)
%(name) %(name) %(value) - %(name)

Nature/Discipline Definition

Nature
name access abstol units
%(name) %(access) %(abstol) %(units)
Discipline
name potential flow
%(name) %(potential/name) %(flow/name)

Model Equations

Notations used:
  • green: input parameter
  • bar over: variable never used
  • bar under: temperature dependent variable
  • red: voltage dependent variable
+ - ! ~ | &amp; + - &sdot; &amp;&amp; == &gt; &gt;= &lt; &lt;= != || ? : color='green' color='red' _ - color='green' color='red' _ - %(value) no desc %(name) "%(value)" %(value) %(value)&sdot;1.0e+18 %(value)P %(value)T %(value)G %(value)M %(value)k %(value)&sdot;1.0e+2 %(value)&sdot;1.0e+1 %(value)&sdot;1.0e-1 %(value)&sdot;1.0e-2 %(value)m %(value)&micro; %(value)n %(value)&angst; %(value)p %(value)f %(value)&sdot;1.0e-18 %(nature/access) %(branch/pnode/name) %(branch/pnode/name) Initial Model Initial Instance ------------ end of Initial Model ------------ end of Initial Instance if else ; = ; &lt;+ ; ADMS-release-2.3.7/scripts/vlatovla.xml000066400000000000000000000351241371671745500177530ustar00rootroot00000000000000 nature %(name) access=%(access); units="%(units)"; abstol=%(abstol); endnature discipline %(name) potential %(potential/name); flow %(flow/name); enddiscipline module %(name) (%(name)) (**); inout %(name); electrical %(name) (**) ;\n parameter %(type) %(name) = (* %(name)="%(value)" *);\n %(name) "%(value)" %(value) (%(value)*1.0e+18) (%(value)*1.0e+15) (%(value)*1.0e+12) (%(value)*1.0e+9) (%(value)*1.0e+6) (%(value)*1.0e+3) (%(value)*1.0e+2) (%(value)*1.0e+1) (%(value)*1.0e-1) (%(value)*1.0e-2) (%(value)*1.0e-3) (%(value)*1.0e-6) (%(value)*1.0e-9) (%(value)*1.0e-10) (%(value)*1.0e-12) (%(value)*1.0e-15) (%(value)*1.0e-18) ; ADMS-release-2.3.7/testcases/000077500000000000000000000000001371671745500157035ustar00rootroot00000000000000ADMS-release-2.3.7/testcases/0000_scale_factor.va000066400000000000000000000023621371671745500213220ustar00rootroot00000000000000 // scale_factor ::= T|G|M|K|k|m|u|n|p|f|a // non-standard E P D h d c A module scaling(); parameter integer itera = 1T; parameter integer igiga = 1G; parameter integer imega = 1M; parameter integer iKilo = 1K; parameter integer ikilo = 1k; parameter integer imili = 1m; parameter integer imicro = 1u; parameter integer inano = 1n; parameter integer ipico = 1p; parameter integer ifemto = 1f; parameter integer iatto = 1a; parameter integer iexa = 1E; parameter integer ipeta = 1P; parameter integer ihecto = 1h; parameter integer ideca = 1D; parameter integer ideci = 1d; parameter integer icenti = 1c; parameter integer iamgstron = 1A; parameter real tera = 1.0T; parameter real giga = 1.0G; parameter real mega = 1.0M; parameter real Kilo = 1.0K; parameter real kilo = 1.0k; parameter real mili = 1.0m; parameter real micro = 1.0u; parameter real nano = 1.0n; parameter real pico = 1.0p; parameter real femto = 1.0f; parameter real atto = 1.0a; parameter real exa = 1.0E; parameter real peta = 1.0P; parameter real hecto = 1.0h; parameter real deca = 1.0D; parameter real deci = 1.0d; parameter real centi = 1.0c; parameter real amgstron = 1.0A; endmodule ADMS-release-2.3.7/testcases/0000_scale_factor.xml000066400000000000000000000073471371671745500215240ustar00rootroot00000000000000 %s $(cast) %se12 $(cast) %se+9 $(cast) %se+6 $(cast) %se+3 $(cast) %se+3 $(cast) %se-3 $(cast) %se-6 $(cast) %se-9 $(cast) %se-12 $(cast) %se-15 $(cast) %se-18 $(cast) %se+18 $(cast) %se+15 $(cast) %se+2 $(cast) %se+1 $(cast) %se-1 $(cast) %se-2 $(cast) %se-10 ADMS-release-2.3.7/testcases/0001_operator.va000066400000000000000000000010311371671745500205210ustar00rootroot00000000000000// these devices do not make any sense. // intended for testing the function stash within globalexpression `include "discipline.h" module sometest(p,n); inout p,n; electrical p,n; parameter real c=1e-6 from [0:inf); analog begin begin I(p,n) <+ c*ddt(V(n,p)*9); I(p,n) <+ exp(ddt(V(p,n))); end end endmodule module anothertest(p,n); inout p,n; electrical p,n; parameter real c=1e-6 from [0:inf); analog begin begin real foo; foo = c*idt(exp(V(p,n))); I(p,n) <+ pow(ddt(foo*V(p,n)),2); end end endmodule ADMS-release-2.3.7/testcases/0001_operator.xml000066400000000000000000000163651371671745500207330ustar00rootroot00000000000000 ADMS-release-2.3.7/testcases/0002_transition.va000066400000000000000000000002711371671745500210660ustar00rootroot00000000000000 module trans(); real out1, expr1, td, rt, ft, ttol; real out2, expr2; analog begin out1 = transition(expr1, td, rt, ft, ttol); out2 = transition(expr2 - 1.5, td); end endmodule ADMS-release-2.3.7/testcases/0002_transition.xml000066400000000000000000000057071371671745500212710ustar00rootroot00000000000000 ADMS-release-2.3.7/testcases/0003_subdev.va000066400000000000000000000011511371671745500201630ustar00rootroot00000000000000// testing subdevice instanciation `include "discipline.h" module net(p, n); inout p, n; electrical p, n; // BUG: cannot instanciate subdevices without params. parameter real dummy=1 from [0:inf); analog begin begin V(p, n) <+ 0; end end endmodule module RESISTOR(p, n); inout p, n; electrical p, n; parameter real r=1 from [0:inf); analog begin begin I(p, n) <+ V(p, n) / r; end end endmodule module schematic(pp, nn); inout pp, nn; electrical pp, nn; electrical p_int, n_int; net #(.dummy(0)) n1(p, p_int); net #(.dummy(0)) n2(n, n_int); RESISTOR #(.r(1)) r1(pp, nn); endmodule ADMS-release-2.3.7/testcases/testNgspice.sh000066400000000000000000000035421371671745500205330ustar00rootroot00000000000000#!/bin/bash ### # This script runs admsXml with files present in the Ngspice project. # # - Run this script from the directory ~/git/ADMS/testcases ### # # Request admsXml as argument # if [ -z "$1" ] then echo " Missing path to admsXml executable." echo " Example: $ sh testNgspice.sh /usr/local/admsXml" exit 1 else ADMSXML=$1 echo " Running admsXml for Ngspice" echo " Using: $ADMSXML" fi # # Clone Ngspice sources. # if [ ! -d "ngspice" ] then git clone --depth=1 --branch=master http://git.code.sf.net/p/ngspice/ngspice ngspice fi # # # List of XML scripts (order matters) # arrayXML=(ngspiceVersion.xml ngspiceMODULEitf.h.xml ngspiceMODULEinit.c.xml ngspiceMODULEinit.h.xml ngspiceMODULEext.h.xml ngspiceMODULEdefs.h.xml ngspiceMODULEask.c.xml ngspiceMODULEmask.c.xml ngspiceMODULEpar.c.xml ngspiceMODULEmpar.c.xml ngspiceMODULEload.c.xml ngspiceMODULEacld.c.xml ngspiceMODULEpzld.c.xml ngspiceMODULEtemp.c.xml ngspiceMODULEtrunc.c.xml ngspiceMODULEsetup.c.xml ngspiceMODULEdel.c.xml ngspiceMODULEmdel.c.xml ngspiceMODULEdest.c.xml ngspiceMODULEnoise.c.xml ngspiceMODULEguesstopology.c.xml ngspiceMODULE.hxx.xml ngspiceMODULE.c.xml) # # Turn list of scripts in a command: "-e script1 [-e script2]" # XML="" for script in "${arrayXML[@]}" do XML=$XML" -e ../../admst/$script" done # # Process each Verilog-A file. # cd ngspice topDir=`pwd` arrayVA=($(find . -name '*.va')) for VA in "${arrayVA[@]}" do dir=`dirname $VA` file=`basename $VA` # jump in cd $dir cmd="$ADMSXML $XML $file" echo "---" echo "$cmd" # Run $cmd # Stop on error if [[ $? -ne 0 ]] ; then exit 1 fi # jump out cd $topDir done ADMS-release-2.3.7/testcases/testQucs.sh000066400000000000000000000022051371671745500200510ustar00rootroot00000000000000#!/bin/bash ### # This script runs admsXml with files present in the Qucs project. # # - Run this script from the directory ~/git/ADMS/testcases ### # # Request admsXml as argument # if [ -z "$1" ] then echo " Missing path to admsXml executable." echo " Example: $ sh testQucs.sh /usr/local/admsXml" exit 1 else ADMSXML=$1 echo " Running admsXml for Qucs" echo " Using: $ADMSXML" fi # # Clone Qucs sources. # if [ ! -d "qucs" ] then git clone --depth=1 --branch=master https://github.com/Qucs/qucs.git qucs fi cd qucs/qucs-core/src/components/verilog # # List of XML scripts (order matters) # arrayXML=(analogfunction.xml qucsVersion.xml qucsMODULEdefs.xml qucsMODULEguiJSONsymbol.xml qucsMODULEcore.xml qucsMODULEgui.xml) # # Turn list of scripts in a command: "-e script1 [-e script2]" # XML="" for script in "${arrayXML[@]}" do XML=$XML" -e $script" done # # Process each Verilog-A file. # arrayVA=($(ls *.va)) for VA in "${arrayVA[@]}" do cmd="$ADMSXML $XML $VA" echo "---" echo "$cmd" # Run $cmd # Stop on error if [[ $? -ne 0 ]] ; then exit 1 fi done ADMS-release-2.3.7/testcases/testXyce.sh000066400000000000000000000032301371671745500200450ustar00rootroot00000000000000#!/bin/bash ### # This script runs admsXml with files present in the Xyce project. # # - Run this script from the directory ~/git/ADMS/testcases/ ### # # Request admsXml as argument # if [ -z "$1" ] then echo " Missing path to admsXml executable." echo " Example: $ sh testXyce.sh /usr/local/admsXml" exit 1 else ADMSXML=$1 echo " Running admsXml for Xyce" echo " Using: $ADMSXML" fi # # Get Xyce sources. # if [ ! -d "Xyce-6.2" ] then echo "" echo "Please download and extract the Xyce sources" echo "from https://xyce.sandia.gov/index.html" exit fi testDir=`pwd` # # Boostrap Verilog-A files customized to Xyce. # cd Xyce-6.2/ sh utils/generate_ADMS.sh # # List of XML scripts (order matters) # arrayXML=(xyceBasicTemplates.xml xyceVersion.xml xyceHeaderFile.xml xyceImplementationFile.xml) # # Turn list of scripts in a command: "-e script1 [-e script2]" # XML="" for script in "${arrayXML[@]}" do XML=$XML" -e $testDir/Xyce-6.2/utils/ADMS/$script" done # # Process each Verilog-A file. # cd $testDir cd Xyce-6.2 topDir=`pwd` arrayVA=($(find . -name *.va)) for VA in "${arrayVA[@]}" do echo "---" dir=`dirname $VA` file=`basename $VA` # skip # - bsimcmg* :included in another file. Complain of missint `attr # - fbhhbt :fails with missing absdelay if [ "$file" == "bsimcmg_main.va" ] || [ "$file" == "bsimcmg_nqsmod3.va" ] || [ "$file" == "fbhhbt-2.1.va" ] then echo "Skip $file" continue fi # jump in cd $dir echo `pwd` cmd="$ADMSXML $XML $file" echo "$cmd" # Run $cmd # Stop on error if [[ $? -ne 0 ]] ; then exit 1 fi # jump out cd $topDir done