[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-662-g95d6028
ontologiae
ontologiae at gmail.com
Mon Nov 22 10:30:58 UTC 2010
The following commit has been merged in the master branch:
commit 95d602829bb352916e75031e3032300bd58fa994
Author: ontologiae <ontologiae at gmail.com>
Date: Mon Nov 22 11:29:22 2010 +0100
add editor
diff --git a/editor/eclipse/COPYING b/editor/eclipse/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/editor/eclipse/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ 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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+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:
+
+ <program> Copyright (C) <year> <name of author>
+ 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
+<http://www.gnu.org/licenses/>.
+
+ 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
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/editor/eclipse/META-INF/MANIFEST.MF b/editor/eclipse/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..0d87043
--- /dev/null
+++ b/editor/eclipse/META-INF/MANIFEST.MF
@@ -0,0 +1,99 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.lisaac.ldt;singleton:=true
+Bundle-Version: 1.1.8
+Bundle-Activator: org.lisaac.ldt.LisaacPlugin
+Bundle-Vendor: %Bundle-Vendor.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.console,
+ org.eclipse.debug.ui,
+ org.eclipse.ltk.core.refactoring,
+ org.eclipse.search
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,
+ bin/
+Import-Package: org.eclipse.debug.core,
+ org.eclipse.debug.core.model,
+ org.eclipse.debug.ui,
+ org.eclipse.ltk.ui.refactoring,
+ org.eclipse.search.ui,
+ org.eclipse.ui.texteditor.templates,
+ org.eclipse.ui.views.contentoutline
+Export-Package: org.lisaac.ldt;
+ uses:="org.eclipse.core.runtime,
+ org.eclipse.jface.resource,
+ org.eclipse.ui.plugin,
+ org.eclipse.jface.text.templates.persistence,
+ org.osgi.framework,
+ org.eclipse.jface.text.templates",
+ org.lisaac.ldt.actions;
+ uses:="org.eclipse.jface.action,
+ org.eclipse.ui,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.widgets",
+ org.lisaac.ldt.builder;uses:="org.lisaac.ldt.model,org.eclipse.core.runtime,org.eclipse.core.resources",
+ org.lisaac.ldt.editors;
+ uses:="org.eclipse.jface.text,
+ org.eclipse.jface.text.hyperlink,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text.source,
+ org.eclipse.jface.text.rules,
+ org.eclipse.jface.text.contentassist,
+ org.lisaac.ldt.model,
+ org.eclipse.jface.preference,
+ org.eclipse.jface.text.presentation,
+ org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.graphics,
+ org.eclipse.jface.util,
+ org.eclipse.swt.widgets,
+ org.eclipse.ui.editors.text",
+ org.lisaac.ldt.launch;
+ uses:="org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.debug.core.model,
+ org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.graphics,
+ org.eclipse.swt.widgets",
+ org.lisaac.ldt.model;
+ uses:="org.lisaac.ldt.model.types,
+ org.lisaac.ldt.model.items,
+ org.lisaac.ldt.model.lip,
+ org.eclipse.core.resources,
+ org.lisaac.ldt.builder",
+ org.lisaac.ldt.model.items;uses:="org.lisaac.ldt.model,org.lisaac.ldt.model.types",
+ org.lisaac.ldt.model.lip,
+ org.lisaac.ldt.model.types,
+ org.lisaac.ldt.outline;uses:="org.lisaac.ldt.model.items,org.eclipse.jface.viewers,org.eclipse.swt.graphics",
+ org.lisaac.ldt.perspectives;uses:="org.eclipse.ui",
+ org.lisaac.ldt.preferences;
+ uses:="org.eclipse.ui.texteditor.templates,
+ org.eclipse.jface.preference,
+ org.eclipse.ui,
+ org.eclipse.core.runtime.preferences",
+ org.lisaac.ldt.properties;uses:="org.eclipse.core.resources,org.eclipse.ui.dialogs,org.eclipse.swt.widgets",
+ org.lisaac.ldt.templates;uses:="org.eclipse.jface.text,org.eclipse.swt.graphics,org.eclipse.jface.text.templates",
+ org.lisaac.ldt.views;
+ uses:="org.eclipse.jface.text,
+ org.eclipse.ui.texteditor,
+ org.eclipse.ui.console,
+ org.eclipse.ui.views.contentoutline,
+ org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.widgets",
+ org.lisaac.ldt.wizards;
+ uses:="org.eclipse.jface.wizard,
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.widgets"
+Bundle-Localization: plugin
+Bundle-Name: %Bundle-Name.0
diff --git a/editor/eclipse/README b/editor/eclipse/README
new file mode 100644
index 0000000..b752969
--- /dev/null
+++ b/editor/eclipse/README
@@ -0,0 +1,113 @@
+ -------------------------------------------------
+ Mode Eclipse for LISAAC language
+ ------------------------------------------------
+
+ LICENSE
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.;
+
+
+How to get started?
+===================
+
+ - Install lastest Lisaac Compiler 0.14.
+
+ * Plugin Installation :
+ -------------------
+
+ - Use the Eclipse Update Manager to install the Lisaac plugin. Add the http://isaacproject.u-strasbg.fr/eclipse/update/ site in the manager, select Lisaac feature and click 'Install'.
+ or
+ - Open the Eclisaac project as described below, export it into a .jar file, copy the jar into your 'eclipse/plugins' directory.
+
+ * Plugin Development and Bug Report :
+ ------------------------------------------------
+
+ - Install latest Eclipse SDK (3.5 Galileo) see http://www.eclipse.org/downloads.
+
+ - Copy the 'editor/eclipse' directory to your Eclipse workspace.
+ - Launch Eclipse, create a Project (File->New->Project, select General->Project).
+ - Enter project name: 'eclipse' and click on the finish button.
+ or
+ - Select your own workspace and create a project with 'eclipse' lisaac plugin location.
+ or
+ - Import the 'eclipse' project (File->Import then select 'Existing Projects into Workspace').
+
+ - First Run : open META-INF/MANIFEST.MF and click on the link 'Launch an Eclipse application'.
+ - Other Run : Green toolbar button Run or Run->Run As->EclipseApplication
+
+ - export the plugin project to a suitable .jar file. (optional)
+
+
+Quick Start into the Lisaac Mode.
+===================
+
+ * General overview:
+ -----------------------
+
+ The Lisaac plugin define features for the user:
+ - Open a Lisaac perspective.
+ - Create a new Lisaac Project.
+ - Create a new Prototype.
+ - Syntax highlighting, customizable in Lisaac preferences (in Window->preferences menu).
+ - Code completion with Ctrl+space key binding.
+ - Auto-indentation with F2 key binding.
+ - Code navigation with Ctrl+click and mouse hover.
+ - Outline view for prototypes. (Window->Show view->outline menu).
+ - [NEW] Slot & section folding at the left of editor.
+ - [NEW] Run the compiler & the program with the 'Run' menu.
+ - [NEW] Section Header refactor & rename prototype refactor ('Refactor' menu).
+
+
+
+Quick Start into Source Code.
+===================
+
+ * General overview:
+ -----------------------
+
+ - META-INF/MANIFEST.MF Main file for Plugin general settings - edit within eclipse only.
+ - plugin.xml Define Extensions Points that the plugin implements - edit within eclipse only.
+ - build.properties Define Plugin classpath for compilation - edit within eclipse only.
+
+ - .project & .classpath & .settings Eclipse files associated with the project - you may erase or replace them.
+
+ - src/ Java implementation.
+ - help/ Help files used inside lisaac plugin, html doc (Help->Help contents) and sheetcheats (Help->Cheat Sheets...)
+ - icons/ Icons used in lisaac plugin.
+ - bin/ Java binary files (removed in git repository) This is automatically placed in jar file while releasing.
+
+ * Java Packages overview
+ -------------------------------
+
+ - lisaac/ Main package, contain plugin activator, LisaacPlugin.java, this object follows plugin lifecycle.
+ - lisaac/actions Plugin menus actions, which implements IActionDelegate interface.
+ - lisaac/builder Incremental project builder - Handle calls to create & update Lisaac Models for each lisaac project.
+ - lisaac/editors Lisaac and Lip Editor. Handle syntax coloring, completion, hyperlinks...
+ - lisaac/launch Interface to call Lisaac Compiler and lisaac tools - Manage Lisaac Run Configuration (Run->Run configurations...)
+ - lisaac/model Manage and Parse Lisaac Models - Used by completion, colorer, hyperlinks, run...
+ - lisaac/model/items Parsing element of lisaac syntax tree.
+ - lisaac/model/lip Parsing element of lip syntax tree.
+ - lisaac/model/types Parsing types of lisaac syntax tree.
+ - lisaac/outline Elements displayed in Lisaac Outline view.
+ - lisaac/perspectives Define Lisaac Perspective.
+ - lisaac/preferences Add menus to Window->Preferences Menu in Lisaac section.
+ - lisaac/properties Add menus to right-click Properties Menu for lisaac resources.
+ - lisaac/templates Support for Editor Templates.
+ - lisaac/views Define Lisaac Views, Console, Outline view, ...
+ - lisaac/wizards Define Lisaac Wizards, New Lisaac Project, New Prototype, ...
+ - lisaac/refactor Define Lisaac refactorings.
+
+ --
+ Best regards,
+ Damien Bouvarel <Damien.Bouvarel at bvra.e.ujf-grenoble.fr>
+ The Lisaac team.
diff --git a/editor/eclipse/build.properties b/editor/eclipse/build.properties
new file mode 100644
index 0000000..329e511
--- /dev/null
+++ b/editor/eclipse/build.properties
@@ -0,0 +1,20 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ bin/,\
+ icons/,\
+ plugin.xml,\
+ plugin.properties,\
+ help/,\
+ build.properties
+bin.excludes = icons/Thumbs.db
+src.excludes = icons/Thumbs.db
+src.includes = META-INF/,\
+ README,\
+ build.properties,\
+ help/,\
+ icons/,\
+ plugin.properties,\
+ plugin.xml,\
+ src/
diff --git a/editor/eclipse/editor_eclipse_org.lisaac.ldt_1.1.8.jar b/editor/eclipse/editor_eclipse_org.lisaac.ldt_1.1.8.jar
new file mode 100644
index 0000000..6ecefd6
Binary files /dev/null and b/editor/eclipse/editor_eclipse_org.lisaac.ldt_1.1.8.jar differ
diff --git a/editor/eclipse/help/html/maintopic.html b/editor/eclipse/help/html/maintopic.html
new file mode 100644
index 0000000..a476078
--- /dev/null
+++ b/editor/eclipse/help/html/maintopic.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Main Topic</title>
+</head>
+
+<body>
+<h1>Main Topic</h1>
+Please enter your text here.
+</body>
+</html>
\ No newline at end of file
diff --git a/editor/eclipse/help/html/overview.html b/editor/eclipse/help/html/overview.html
new file mode 100644
index 0000000..a476078
--- /dev/null
+++ b/editor/eclipse/help/html/overview.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Main Topic</title>
+</head>
+
+<body>
+<h1>Main Topic</h1>
+Please enter your text here.
+</body>
+</html>
\ No newline at end of file
diff --git a/editor/eclipse/help/html/subtopic.html b/editor/eclipse/help/html/subtopic.html
new file mode 100644
index 0000000..8a61c50
--- /dev/null
+++ b/editor/eclipse/help/html/subtopic.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Sub Topic</title>
+</head>
+
+<body>
+<h1>Sub Topic</h1>
+Please enter your text here.
+</body>
+</html>
\ No newline at end of file
diff --git a/editor/eclipse/help/html/toc.html b/editor/eclipse/help/html/toc.html
new file mode 100644
index 0000000..326f0a9
--- /dev/null
+++ b/editor/eclipse/help/html/toc.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Table of Contents</title>
+</head>
+
+<body>
+<h1>Table of Contents</h1>
+Please enter your text here.
+</body>
+</html>
\ No newline at end of file
diff --git a/editor/eclipse/help/sheet1_HelloWorld.xml b/editor/eclipse/help/sheet1_HelloWorld.xml
new file mode 100644
index 0000000..3324a79
--- /dev/null
+++ b/editor/eclipse/help/sheet1_HelloWorld.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cheatsheet
+ title="Create a Hello World application">
+ <intro>
+ <description>
+ This cheat sheet shows you how to create a "Hello World" Lisaac application.
+
+ The application will print "Hello World" in the console when run.
+ Enter Lisaac World!
+ </description>
+ </intro>
+ <item
+ title="Open the Lisaac perspective">
+ <description>
+ If you're not already in a Lisaac perspective, in the main menu select <b>Window > Open Perspective > Lisaac</b>.
+
+ </description>
+ <command
+ required="false"
+ serialization="org.eclipse.ui.perspectives.showPerspective"/>
+ </item>
+ <item
+ title="Create a Lisaac Project">
+ <description>
+ We need a project to create an application. Click on the <b>New Lisaac Project</b> button, or click on the link below. Enter <b>HelloWorld</b> for the project name, then click <b>Finish</b>.
+
+ </description>
+ <command
+ required="false"
+ serialization="org.eclipse.ui.newWizard"/>
+ </item>
+
+ <item
+ skip="false"
+ title="Create your HelloWorld Prototype">
+ <description>
+ The next step is to create a new prototype.
+If the project wizard has not created a main prototype, click on the <b>New Prototype</b> button, select the checkbox to create the <b>main</b> slot.
+ </description>
+ <command
+ required="false"
+ serialization="org.eclipse.ui.newWizard"/>
+ </item>
+ <item
+ title="Add a print statement">
+ <description>
+ Now that you have your HelloWorld prototype, in the <b>main</b> slot, add the following statement:
+"Hello World!".print;
+then <b>save</b> your changes, the prototype will automatically compile.
+ </description>
+ </item>
+ <item
+ title="Run your Lisaac application">
+ <description>
+ To run your application, select <b>Run-> Run configurations</b> menu, select <b>Lisaac Application</b>.
+The <b>Console</b> view should appear at the bottom and display the "Hello, world!" output.
+
+Congratulations! You have successfully created a Lisaac Hello World application!
+ </description>
+ </item>
+
+</cheatsheet>
diff --git a/editor/eclipse/help/testToc.xml b/editor/eclipse/help/testToc.xml
new file mode 100644
index 0000000..ca7402e
--- /dev/null
+++ b/editor/eclipse/help/testToc.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?NLS TYPE="org.eclipse.help.toc"?>
+
+<toc label="Lisaac Development user Guide" topic="html/toc.html">
+ <link toc="toc.xml" />
+</toc>
diff --git a/editor/eclipse/help/toc.xml b/editor/eclipse/help/toc.xml
new file mode 100644
index 0000000..6ad67be
--- /dev/null
+++ b/editor/eclipse/help/toc.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?NLS TYPE="org.eclipse.help.toc"?>
+
+<toc label="Lisaac Table of Contents">
+ <topic label="Lisaac development overview" href="html/overview.html">
+ </topic>
+ <topic href="html/maintopic.html" label="Getting Started">
+ <topic label="Topic">
+ </topic>
+ </topic>
+ <topic href="html/maintopic.html" label="Reference">
+ <topic label="Topic">
+ </topic>
+ </topic>
+ <topic label="Tips and Tricks">
+ </topic>
+ <topic label="Legal">
+ </topic>
+</toc>
diff --git a/editor/eclipse/icons/alphab_sort_co.gif b/editor/eclipse/icons/alphab_sort_co.gif
new file mode 100644
index 0000000..6d77244
Binary files /dev/null and b/editor/eclipse/icons/alphab_sort_co.gif differ
diff --git a/editor/eclipse/icons/blank.gif b/editor/eclipse/icons/blank.gif
new file mode 100644
index 0000000..ede75be
Binary files /dev/null and b/editor/eclipse/icons/blank.gif differ
diff --git a/editor/eclipse/icons/error_co.gif b/editor/eclipse/icons/error_co.gif
new file mode 100644
index 0000000..8612eaf
Binary files /dev/null and b/editor/eclipse/icons/error_co.gif differ
diff --git a/editor/eclipse/icons/keyword.gif b/editor/eclipse/icons/keyword.gif
new file mode 100644
index 0000000..435d62e
Binary files /dev/null and b/editor/eclipse/icons/keyword.gif differ
diff --git a/editor/eclipse/icons/library.gif b/editor/eclipse/icons/library.gif
new file mode 100644
index 0000000..cb55e33
Binary files /dev/null and b/editor/eclipse/icons/library.gif differ
diff --git a/editor/eclipse/icons/private-nonshared.gif b/editor/eclipse/icons/private-nonshared.gif
new file mode 100644
index 0000000..39891e1
Binary files /dev/null and b/editor/eclipse/icons/private-nonshared.gif differ
diff --git a/editor/eclipse/icons/private-shared.gif b/editor/eclipse/icons/private-shared.gif
new file mode 100644
index 0000000..e4c1859
Binary files /dev/null and b/editor/eclipse/icons/private-shared.gif differ
diff --git a/editor/eclipse/icons/prototype.gif b/editor/eclipse/icons/prototype.gif
new file mode 100644
index 0000000..eb6e0b6
Binary files /dev/null and b/editor/eclipse/icons/prototype.gif differ
diff --git a/editor/eclipse/icons/public-nonshared.gif b/editor/eclipse/icons/public-nonshared.gif
new file mode 100644
index 0000000..828590b
Binary files /dev/null and b/editor/eclipse/icons/public-nonshared.gif differ
diff --git a/editor/eclipse/icons/public-shared.gif b/editor/eclipse/icons/public-shared.gif
new file mode 100644
index 0000000..698f668
Binary files /dev/null and b/editor/eclipse/icons/public-shared.gif differ
diff --git a/editor/eclipse/icons/sample.gif b/editor/eclipse/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
Binary files /dev/null and b/editor/eclipse/icons/sample.gif differ
diff --git a/editor/eclipse/icons/sections_co.gif b/editor/eclipse/icons/sections_co.gif
new file mode 100644
index 0000000..82bc04e
Binary files /dev/null and b/editor/eclipse/icons/sections_co.gif differ
diff --git a/editor/eclipse/icons/source-folder.gif b/editor/eclipse/icons/source-folder.gif
new file mode 100644
index 0000000..fca9c53
Binary files /dev/null and b/editor/eclipse/icons/source-folder.gif differ
diff --git a/editor/eclipse/icons/template.gif b/editor/eclipse/icons/template.gif
new file mode 100644
index 0000000..fdde5fb
Binary files /dev/null and b/editor/eclipse/icons/template.gif differ
diff --git a/editor/eclipse/icons/warning_co.gif b/editor/eclipse/icons/warning_co.gif
new file mode 100644
index 0000000..3af228c
Binary files /dev/null and b/editor/eclipse/icons/warning_co.gif differ
diff --git a/editor/eclipse/plugin.properties b/editor/eclipse/plugin.properties
new file mode 100644
index 0000000..164a6d3
--- /dev/null
+++ b/editor/eclipse/plugin.properties
@@ -0,0 +1,43 @@
+#Properties file for eclipse
+Bundle-Name.0 = Lisaac Plug-in
+editor.name.0 = Lisaac Editor
+editor.name.1 = Lip Editor
+perspective.name.0 = Lisaac
+page.name.0 = Lisaac
+page.name.1 = Templates
+page.name.2 = Syntax Coloring
+page.name.3 = Editor
+page.name.5 = Lisaac Compiler
+category.name.0 = Lisaac
+wizard.name.0 = Lisaac Project
+wizard.name.1 = Lisaac Prototype
+consoleFactory.label.0 = Lisaac Console
+launchConfigurationType.name.0 = Lisaac Application
+actionSet.description.0 = Lisaac Source Tools
+actionSet.label.0 = Source
+menu.label.0 = Source
+action.label.0 = Correct Indentation
+action.label.1 = Generate Constructor
+menu.label.1 = New Prototype
+action.label.2 = New Prototype
+action.tooltip.0 = Create new prototype
+action.label.3 = Toggle Comment
+command.name.0 = Indentation
+category.name.1 = Lisaac Command
+command.name.1 = Generate Constructor
+command.name.2 = New Prototype
+command.name.3 = Toggle comment
+shortcut.label.0 = Lisaac Application
+
+perspective.description.0 = Perspective for Lisaac Development
+template.description.0 = While loop
+template.description.1 = Until Loop
+template.description.2 = If statement
+template.description.3 = If Else statement
+template.description.4 = If false statement
+template.description.5 = For loop
+Bundle-Vendor.0 = Damien Bouvarel
+wizard.name.2 = Source folder
+action.label.4 = Rename Prototype...
+menu.label.2 = Refactor
+command.name.4 = Rename Prototype
\ No newline at end of file
diff --git a/editor/eclipse/plugin.xml b/editor/eclipse/plugin.xml
new file mode 100644
index 0000000..ec60bde
--- /dev/null
+++ b/editor/eclipse/plugin.xml
@@ -0,0 +1,521 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ id="lisaacProblem"
+ name="Lisaac Problem"
+ point="org.eclipse.core.resources.markers">
+ <persistent
+ value="true">
+ </persistent>
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <super
+ type="org.eclipse.core.resources.textmarker">
+ </super>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ name="%editor.name.0"
+ extensions="li"
+ icon="$nl$/icons/prototype.gif"
+ contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
+ class="org.lisaac.ldt.editors.LisaacEditor"
+ id="org.lisaac.ldt.editors.LisaacEditor">
+ </editor>
+ <editor
+ class="org.lisaac.ldt.editors.LipEditor"
+ contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
+ default="false"
+ extensions="lip"
+ icon="$nl$/icons/releng_gears.gif"
+ id="org.lisaac.ldt.editors.LipEditor"
+ name="%editor.name.1">
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.help.toc">
+ <toc
+ file="help/toc.xml">
+ </toc>
+ <toc
+ file="help/testToc.xml"
+ primary="true">
+ </toc>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ name="%perspective.name.0"
+ class="org.lisaac.ldt.perspectives.LisaacPerspective"
+ id="org.lisaac.ldt.perspectives.LisaacPerspective">
+ <description>
+ %perspective.description.0
+ </description>
+ </perspective>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ name="%page.name.0"
+ class="org.lisaac.ldt.preferences.LisaacPreferencePage"
+ id="org.lisaac.ldt.preferences.LisaacPreferencePage">
+ </page>
+ <page
+ category="org.lisaac.ldt.editorpreferences"
+ class="org.lisaac.ldt.preferences.LisaacTemplatePage"
+ id="org.lisaac.ldt.templatepreferences"
+ name="%page.name.1">
+ </page>
+ <page
+ category="org.lisaac.ldt.editorpreferences"
+ class="org.lisaac.ldt.preferences.LisaacColoringPage"
+ id="org.lisaac.ldt.editorcolorpreferences"
+ name="%page.name.2">
+ </page>
+ <page
+ category="org.lisaac.ldt.preferences.LisaacPreferencePage"
+ class="org.lisaac.ldt.preferences.LisaacEditorPage"
+ id="org.lisaac.ldt.editorpreferences"
+ name="%page.name.3">
+ <keywordReference
+ id="org.eclipse.ui.editors.general">
+ </keywordReference>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.lisaac.ldt.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.lisaac.ldt.properties.LisaacProjectPropertyPage"
+ id="org.lisaac.ldt.properties.projectPropertyPage"
+ name="%page.name.5"
+ objectClass="org.eclipse.core.resources.IProject">
+ </page>
+ </extension>
+ <extension
+ id="org.lisaac.ldt.newWizard"
+ name="Lisaac Project Wizard"
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="Lisaac"
+ name="%category.name.0">
+ </category>
+ <wizard
+ canFinishEarly="true"
+ category="Lisaac"
+ class="org.lisaac.ldt.wizards.NewProjectWizard"
+ finalPerspective="org.lisaac.ldt.perspectives.LisaacPerspective"
+ hasPages="true"
+ icon="$nl$/icons/sample.gif"
+ id="org.lisaac.ldt.wizard"
+ name="%wizard.name.0"
+ preferredPerspectives="org.lisaac.ldt.perspectives.LisaacPerspective"
+ project="true">
+ </wizard>
+ <wizard
+ canFinishEarly="false"
+ category="Lisaac"
+ class="org.lisaac.ldt.wizards.NewPrototypeWizard"
+ finalPerspective="org.lisaac.ldt.perspectives.LisaacPerspective"
+ hasPages="true"
+ icon="$nl$/icons/prototype.gif"
+ id="org.lisaac.ldt.prototype"
+ name="%wizard.name.1"
+ preferredPerspectives="org.lisaac.ldt.perspectives.LisaacPerspective"
+ project="false">
+ </wizard>
+ </extension>
+ <extension
+ id="builder"
+ name="Lisaac Builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ callOnEmptyDelta="false"
+ hasNature="true"
+ isConfigurable="false">
+ <run
+ class="org.lisaac.ldt.builder.LisaacBuilder">
+ </run>
+ </builder>
+ </extension>
+ <extension
+ id="lisaac"
+ name="Lisaac Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.lisaac.ldt.builder.LisaacNature">
+ </run>
+ </runtime>
+ <builder
+ id="org.lisaac.ldt.builder">
+ </builder>
+ </extension>
+ <extension
+ point="org.eclipse.ui.console.consoleFactories">
+ <consoleFactory
+ class="org.lisaac.ldt.views.ConsoleFactory"
+ label="%consoleFactory.label.0">
+ </consoleFactory>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.lisaac.ldt.launch.LaunchConfiguration"
+ id="org.lisaac.ldt.launchConfiguration"
+ modes="run,debug"
+ name="%launchConfigurationType.name.0"
+ public="true">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.lisaac.ldt.launch.LaunchConfigurationTabGroup"
+ id="org.lisaac.ldt.LaunchConfigurationTabGroup"
+ type="org.lisaac.ldt.launchConfiguration">
+ </launchConfigurationTabGroup>
+ </extension>
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ description="%actionSet.description.0"
+ id="org.lisaac.ldt.source"
+ label="%actionSet.label.0"
+ visible="true">
+ <menu
+ id="org.lisaac.ldt.sourcemenu"
+ label="%menu.label.0"
+ path="edit">
+ <groupMarker
+ name="toggle">
+ </groupMarker>
+ <separator
+ name="org.lisaac.ldt.separator1">
+ </separator>
+ <groupMarker
+ name="indent">
+ </groupMarker>
+ <separator
+ name="org.lisaac.ldt.separator2">
+ </separator>
+ <groupMarker
+ name="generate">
+ </groupMarker>
+ </menu>
+ <action
+ class="org.lisaac.ldt.actions.IndentAction"
+ definitionId="org.lisaac.ldt.cmd1"
+ id="org.lisaac.ldt.indentaction"
+ label="%action.label.0"
+ menubarPath="org.lisaac.ldt.sourcemenu/indent">
+ </action>
+ <action
+ class="org.lisaac.ldt.actions.GenerateConstructor"
+ definitionId="org.lisaac.ldt.cmd2"
+ id="org.lisaac.ldt.generateconstructor"
+ label="%action.label.1"
+ menubarPath="org.lisaac.ldt.sourcemenu/generate">
+ </action>
+ <menu
+ id="org.lisaac.ldt.toolbar"
+ label="%menu.label.1">
+ </menu>
+ <action
+ class="org.lisaac.ldt.actions.CreatePrototype"
+ definitionId="org.lisaac.ldt.cmd3"
+ icon="$nl$/icons/prototype.gif"
+ id="org.lisaac.ldt.toolbar_action1"
+ label="%action.label.2"
+ style="push"
+ toolbarPath="org.lisaac.ldt.toolbar"
+ tooltip="%action.tooltip.0">
+ </action>
+ <action
+ class="org.lisaac.ldt.actions.ToggleComment"
+ definitionId="org.lisaac.ldt.cmd4"
+ id="org.lisaac.ldt.comment1"
+ label="%action.label.3"
+ menubarPath="org.lisaac.ldt.sourcemenu/toggle">
+ </action>
+ <action
+ class="org.lisaac.ldt.actions.RenamePrototype"
+ definitionId="org.lisaac.ldt.cmd5"
+ enablesFor="1"
+ id="org.lisaac.ldt.action.refactor1"
+ label="%action.label.4"
+ menubarPath="org.lisaac.ldt.refactor.menu/renameproto"
+ style="push">
+ </action>
+ <menu
+ id="org.lisaac.ldt.refactor.menu"
+ label="%menu.label.2"
+ path="org.lisaac.ldt.sourcemenu">
+ </menu>
+ <action
+ class="org.lisaac.ldt.actions.ChangeHeader"
+ definitionId="org.lisaac.ldt.cmd6"
+ id="org.lisaac.ldt.action.refactor2"
+ label="Change Project Headers"
+ menubarPath="org.lisaac.ldt.refactor.menu/changeheader"
+ style="push">
+ </action>
+ </actionSet>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.lisaac.ldt.commands"
+ id="org.lisaac.ldt.cmd1"
+ name="%command.name.0">
+ </command>
+ <category
+ id="org.lisaac.ldt.commands"
+ name="%category.name.1">
+ </category>
+ <command
+ categoryId="org.lisaac.ldt.commands"
+ id="org.lisaac.ldt.cmd2"
+ name="%command.name.1">
+ </command>
+ <command
+ categoryId="org.lisaac.ldt.commands"
+ id="org.lisaac.ldt.cmd3"
+ name="%command.name.2">
+ </command>
+ <command
+ categoryId="org.lisaac.ldt.commands"
+ id="org.lisaac.ldt.cmd4"
+ name="%command.name.3">
+ </command>
+ <command
+ categoryId="org.lisaac.ldt.commands"
+ id="org.lisaac.ldt.cmd5"
+ name="%command.name.4">
+ </command>
+ <command
+ categoryId="org.lisaac.ldt.commands"
+ id="org.lisaac.ldt.cmd6"
+ name="Change Header">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.lisaac.ldt.cmd1"
+ contextId="org.eclipse.ui.textEditorScope"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="F2">
+ </key>
+ </extension>
+ <extension
+ point="org.eclipse.ui.cheatsheets.cheatSheetContent">
+ <category
+ id="org.lisaac.ldt.cheatsheet"
+ name="Lisaac Development">
+ </category>
+ <cheatsheet
+ category="org.lisaac.ldt.cheatsheet"
+ composite="false"
+ contentFile="help/sheet1_HelloWorld.xml"
+ id="org.lisaac.ldt.cheatsheet1"
+ name="Lisaac HelloWorld">
+ <description>
+ Create a "Hello World" Lisaac application from scratch.
+ </description>
+ </cheatsheet>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors.templates">
+ <contextType
+ class="org.lisaac.ldt.templates.LisaacContextType"
+ id="org.lisaac.ldt.contexttype"
+ name="Lisaac context type">
+ </contextType>
+ <template
+ autoinsert="true"
+ contextTypeId="org.lisaac.ldt.contexttype"
+ description="%template.description.0"
+ icon="$nl$/icons/template.gif"
+ id="org.lisaac.ldt.template_whiledo"
+ name="while_do">
+ <pattern>
+ while_do {
+ ${cursor}
+};
+ </pattern>
+ </template>
+ <template
+ autoinsert="true"
+ contextTypeId="org.lisaac.ldt.contexttype"
+ description="%template.description.1"
+ icon="$nl$/icons/template.gif"
+ id="org.lisaac.ldt.template_untildo"
+ name="until_do">
+ <pattern>
+ until_do {
+ ${cursor}
+};
+ </pattern>
+ </template>
+ <template
+ autoinsert="true"
+ contextTypeId="org.lisaac.ldt.contexttype"
+ description="%template.description.2"
+ icon="$nl$/icons/template.gif"
+ id="org.lisaac.ldt.template_if"
+ name="if">
+ <pattern>
+ if {
+ ${cursor}
+};
+ </pattern>
+ </template>
+ <template
+ autoinsert="true"
+ contextTypeId="org.lisaac.ldt.contexttype"
+ description="%template.description.3"
+ icon="$nl$/icons/template.gif"
+ id="org.lisaac.ldt.template_ifelse"
+ name="if__else">
+ <pattern>
+ if {
+ ${cursor}
+} else {
+};
+ </pattern>
+ </template>
+ <template
+ autoinsert="true"
+ contextTypeId="org.lisaac.ldt.contexttype"
+ description="%template.description.4"
+ icon="$nl$/icons/template.gif"
+ id="org.lisaac.ldt.template_iffalse"
+ name="if_false">
+ <pattern>
+ if_false {
+ ${cursor}
+};
+ </pattern>
+ </template>
+ <template
+ autoinsert="true"
+ contextTypeId="org.lisaac.ldt.contexttype"
+ description="%template.description.5"
+ icon="$nl$/icons/template.gif"
+ id="org.lisaac.ldt.template_for"
+ name="to__do">
+ <pattern>
+ to ${cursor} do { i:INTEGER;
+};
+ </pattern>
+ </template>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ class="org.lisaac.ldt.launch.LisaacApplicationShortcut"
+ icon="$nl$/icons/prototype.gif"
+ id="org.lisaac.ldt.launch.shortcut"
+ label="%shortcut.label.0"
+ modes="run,debug">
+ <perspective
+ id="org.lisaac.ldt.perspectives.LisaacPerspective">
+ </perspective>
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <or><test property="org.eclipse.debug.ui.matchesPattern" value="*.li"/></or>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ </shortcut>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors.annotationTypes">
+ <type
+ markerSeverity="2"
+ markerType="org.lisaac.ldt.lisaacProblem"
+ name="org.lisaac.ldt.annotationtype"
+ super="org.eclipse.ui.workbench.texteditor.error">
+ </type>
+ </extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ class="org.lisaac.ldt.editors.LisaacResourceDecorator"
+ id="org.lisaac.ldt.decorator"
+ label="%decorator.label.0"
+ lightweight="true"
+ location="BOTTOM_LEFT"
+ state="true">
+ <enablement>
+ <objectClass
+ name="org.eclipse.core.resources.IResource">
+ </objectClass>
+ </enablement>
+ </decorator>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors.markerAnnotationSpecification">
+ <specification
+ annotationType="org.lisaac.ldt.annotationtype"
+ colorPreferenceKey="errorIndicationColor"
+ colorPreferenceValue="255,0,128"
+ contributesToHeader="true"
+ highlightPreferenceKey="errorIndicationHighlighting"
+ highlightPreferenceValue="false"
+ includeOnPreferencePage="true"
+ isGoToNextNavigationTarget="true"
+ isGoToNextNavigationTargetKey="isErrorGoToNextNavigationTarget"
+ isGoToPreviousNavigationTarget="true"
+ isGoToPreviousNavigationTargetKey="isErrorGoToPreviousNavigationTarget"
+ label="Lisaac Problem"
+ overviewRulerPreferenceKey="errorIndicationInOverviewRuler"
+ overviewRulerPreferenceValue="true"
+ presentationLayer="6"
+ showInNextPrevDropdownToolbarAction="true"
+ showInNextPrevDropdownToolbarActionKey="showErrorInNextPrevDropdownToolbarAction"
+ symbolicIcon="error"
+ textPreferenceKey="errorIndication"
+ textPreferenceValue="true"
+ textStylePreferenceKey="errorTextStyle"
+ textStylePreferenceValue="PROBLEM_UNDERLINE"
+ verticalRulerPreferenceKey="errorIndicationInVerticalRuler"
+ verticalRulerPreferenceValue="true">
+ </specification>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <viewerContribution
+ id="org.lisaac.ldt.editoraction"
+ targetID="#TextEditorContext">
+ <action
+ class="org.lisaac.ldt.actions.RefreshEditor"
+ id="org.lisaac.ldt.editoraction1"
+ label="Refresh Editor">
+ </action>
+ </viewerContribution>
+ </extension>
+ <extension
+ point="org.eclipse.search.searchPages">
+ <page
+ class="eclisaac.SearchPage1"
+ id="eclisaac.page1"
+ label="label">
+ </page>
+ </extension>
+
+</plugin>
diff --git a/editor/eclipse/src/org/lisaac/ldt/LisaacMessages.java b/editor/eclipse/src/org/lisaac/ldt/LisaacMessages.java
new file mode 100644
index 0000000..928e1dc
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/LisaacMessages.java
@@ -0,0 +1,22 @@
+package org.lisaac.ldt;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class LisaacMessages {
+ private static final String BUNDLE_NAME = "org.lisaac.ldt.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private LisaacMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/LisaacPlugin.java b/editor/eclipse/src/org/lisaac/ldt/LisaacPlugin.java
new file mode 100644
index 0000000..7dfb3fa
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/LisaacPlugin.java
@@ -0,0 +1,159 @@
+package org.lisaac.ldt;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ISaveContext;
+import org.eclipse.core.resources.ISaveParticipant;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
+import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.lisaac.ldt.builder.LisaacChangeListener;
+import org.lisaac.ldt.builder.LisaacNature;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.templates.LisaacContextType;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class LisaacPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.lisaac.ldt"; //$NON-NLS-1$
+
+ // The shared instance
+ private static LisaacPlugin plugin;
+
+
+ /** The template store. */
+ private TemplateStore fStore;
+ /** The context type registry. */
+ private ContextTypeRegistry fRegistry;
+
+
+ private static final String TEMPLATES_KEY = "org.lisaac.ldt.templatepreferences"; //$NON-NLS-1$
+
+
+ public TemplateStore getTemplateStore() {
+ if (fStore == null) {
+ fStore = new ContributionTemplateStore (
+ getContextTypeRegistry(), LisaacPlugin
+ .getDefault().getPreferenceStore(),
+ TEMPLATES_KEY);
+ try {
+ fStore.load();
+ } catch (IOException e) {
+ LisaacPlugin
+ .getDefault()
+ .getLog()
+ .log(
+ new Status(
+ IStatus.ERROR,
+ PLUGIN_ID, IStatus.OK, "", e)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return fStore;
+ }
+
+ public ContextTypeRegistry getContextTypeRegistry() {
+ if (fRegistry == null) {
+ // create an configure the contexts available in the template editor
+ ContributionContextTypeRegistry registry= new ContributionContextTypeRegistry();
+ registry.addContextType(LisaacContextType.ID_CONTEXT_TYPE);
+
+ fRegistry= registry;
+ }
+ return fRegistry;
+ }
+
+ /**
+ * The constructor
+ */
+ public LisaacPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ // to notify project modifications
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new LisaacChangeListener());
+
+ // build all lisaac projects
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i=0; i<projects.length; i++) {
+ try {
+ if (projects[i] != null && projects[i].isOpen()) {
+ if (projects[i].getNature(LisaacNature.NATURE_ID) != null) {
+ try {
+ IContainer bin = projects[i].getFolder("lib");
+ if (bin.exists()) {
+ bin.delete(true, null);
+ }
+
+ // clean all lisaac projects to get started
+ projects[i].build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ } catch (Exception e) {
+ log(new Status(IStatus.ERROR,
+ PLUGIN_ID, IStatus.OK, "Error loading "+projects[i].getName(), e)); //$NON-NLS-1$
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static LisaacPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status status to log.
+ */
+ public static void log(final IStatus status) {
+ getDefault().getLog().log(status);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/ChangeHeader.java b/editor/eclipse/src/org/lisaac/ldt/actions/ChangeHeader.java
new file mode 100644
index 0000000..05296ef
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/ChangeHeader.java
@@ -0,0 +1,74 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.lisaac.ldt.editors.AbstractLisaacEditor;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.refactor.ChangeHeaderRefactor;
+import org.lisaac.ldt.refactor.ChangeHeaderWizard;
+
+public class ChangeHeader implements IWorkbenchWindowActionDelegate {
+
+ private IWorkbenchWindow fWindow = null;
+
+ private LisaacModel model;
+
+ public void dispose() {
+ }
+
+ public void init(IWorkbenchWindow window) {
+ fWindow = window;
+ }
+
+ public void run(IAction action) {
+ if (fWindow != null&& model != null) {
+ ChangeHeaderRefactor refactoring = new ChangeHeaderRefactor(model);
+ String name = "Change Project Headers";
+ run(new ChangeHeaderWizard(refactoring, name),
+ fWindow.getShell(), name);
+ }
+ }
+
+ public void run(RefactoringWizard wizard, Shell parent, String dialogTitle) {
+ try {
+ RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wizard);
+ operation.run(parent, dialogTitle);
+ } catch (InterruptedException exception) {
+ // Do nothing
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ model = null;
+
+ if (selection instanceof ITextSelection) {
+ if (fWindow != null) {
+ // get surrounding word
+ IWorkbenchPart part = fWindow.getPartService().getActivePart();
+ if (part instanceof AbstractLisaacEditor) {
+ IProject project = ((AbstractLisaacEditor) part)
+ .getProject();
+ model = LisaacModel.getModel(project);
+ }
+ }
+ } else if (selection instanceof IStructuredSelection) {
+ if (((IStructuredSelection) selection).getFirstElement() instanceof IResource) {
+ IResource res = (IResource) ((IStructuredSelection) selection).getFirstElement();
+ if (res.getProject() != null) {
+ model = LisaacModel.getModel(res.getProject());
+ }
+ }
+ }
+ action.setEnabled(model != null);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/CreatePrototype.java b/editor/eclipse/src/org/lisaac/ldt/actions/CreatePrototype.java
new file mode 100644
index 0000000..eb7b5f2
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/CreatePrototype.java
@@ -0,0 +1,110 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.wizards.NewPrototypeWizard;
+
+public class CreatePrototype extends Action implements IWorkbenchWindowActionDelegate {
+
+ private Shell fShell;
+ private IStructuredSelection fSelection;
+
+
+ public CreatePrototype() {
+ }
+
+ /**
+ * The action has been activated. The argument of the
+ * method represents the 'real' action sitting
+ * in the workbench UI.
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ Shell shell= getShell();
+
+ try {
+ INewWizard wizard= createWizard();
+ wizard.init(PlatformUI.getWorkbench(), getSelection());
+
+ WizardDialog dialog= new WizardDialog(shell, wizard);
+ dialog.create();
+ int res= dialog.open();
+ if (res != Window.OK) {
+ // TODO log error
+ }
+ } catch (CoreException e) {
+ // TODO log error
+ }
+ }
+
+ /**
+ * Returns the configured selection. If no selection has been configured using {@link #setSelection(IStructuredSelection)},
+ * the currently selected element of the active workbench is returned.
+ * @return the configured selection
+ */
+ protected IStructuredSelection getSelection() {
+ if (fSelection == null) {
+ return evaluateCurrentSelection();
+ }
+ return fSelection;
+ }
+
+ private IStructuredSelection evaluateCurrentSelection() {
+ IWorkbenchWindow window = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+
+ if (window != null) {
+ ISelection selection= window.getSelectionService().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ protected Shell getShell() {
+ return fShell;
+ }
+
+ // make it an abstract method if more wizard shortcuts are created
+ protected final INewWizard createWizard() throws CoreException {
+ return new NewPrototypeWizard();
+ }
+
+ /**
+ * Selection in the workbench has been changed. We
+ * can change the state of the 'real' action here
+ * if we want, but this can only happen after
+ * the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We will cache window object in order to
+ * be able to provide parent shell for the message dialog.
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+
+ /**
+ * We can use this method to dispose of any system
+ * resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/GenerateConstructor.java b/editor/eclipse/src/org/lisaac/ldt/actions/GenerateConstructor.java
new file mode 100644
index 0000000..207ba42
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/GenerateConstructor.java
@@ -0,0 +1,80 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.LisaacEditor;
+
+public class GenerateConstructor implements IWorkbenchWindowActionDelegate {
+
+
+ /**
+ * The action has been activated. The argument of the
+ * method represents the 'real' action sitting
+ * in the workbench UI.
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ IDocument document = ((LisaacEditor)part).getDocument();
+ //
+ int caret = ((LisaacEditor)part).getViewer().getTextWidget().getCaretOffset();
+ String constructor = getConstructor();
+ try {
+ document.replace(caret, 0, constructor);
+ } catch (BadLocationException e) {
+ }
+ //
+ }
+ }
+
+ public static String getConstructor() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("\n //\n // Creation.\n //\n"); //$NON-NLS-1$
+ buffer.append("\n - create:SELF <-"); //$NON-NLS-1$
+ buffer.append("\n ( + result:SELF;"); //$NON-NLS-1$
+ buffer.append("\n result := clone;"); //$NON-NLS-1$
+ buffer.append("\n result.make;"); //$NON-NLS-1$
+ buffer.append("\n result"); //$NON-NLS-1$
+ buffer.append("\n );"); //$NON-NLS-1$
+ buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n - make <-"); //$NON-NLS-1$
+ buffer.append("\n ("); //$NON-NLS-1$
+ buffer.append("\n );\n\n"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+
+ /**
+ * Selection in the workbench has been changed. We
+ * can change the state of the 'real' action here
+ * if we want, but this can only happen after
+ * the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We will cache window object in order to
+ * be able to provide parent shell for the message dialog.
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+
+ /**
+ * We can use this method to dispose of any system
+ * resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/IndentAction.java b/editor/eclipse/src/org/lisaac/ldt/actions/IndentAction.java
new file mode 100644
index 0000000..96a09e0
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/IndentAction.java
@@ -0,0 +1,79 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.AbstractLisaacEditor;
+import org.lisaac.ldt.editors.LisaacAutoEditStrategy;
+
+/**
+ * Our sample action implements workbench action delegate.
+ * The action proxy will be created by the workbench and
+ * shown in the UI. When the user tries to use the action,
+ * this delegate will be created and execution will be
+ * delegated to it.
+ * @see IWorkbenchWindowActionDelegate
+ */
+public class IndentAction implements IWorkbenchWindowActionDelegate {
+ /**
+ * The constructor.
+ */
+ public IndentAction() {
+ }
+
+ /**
+ * The action has been activated. The argument of the
+ * method represents the 'real' action sitting
+ * in the workbench UI.
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof AbstractLisaacEditor) {
+ IDocument document = ((AbstractLisaacEditor)part).getDocument();
+ //
+ LisaacAutoEditStrategy.fullIndentDocument(document);
+ //
+ }
+ }
+
+ /**
+ * Selection in the workbench has been changed. We
+ * can change the state of the 'real' action here
+ * if we want, but this can only happen after
+ * the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof AbstractLisaacEditor) {
+ action.setEnabled(true);
+ } else {
+ action.setEnabled(false);
+ }
+ }
+
+ /**
+ * We can use this method to dispose of any system
+ * resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+
+ /**
+ * We will cache window object in order to
+ * be able to provide parent shell for the message dialog.
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/RefreshEditor.java b/editor/eclipse/src/org/lisaac/ldt/actions/RefreshEditor.java
new file mode 100644
index 0000000..7bf43a3
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/RefreshEditor.java
@@ -0,0 +1,28 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.lisaac.ldt.editors.AbstractLisaacEditor;
+import org.lisaac.ldt.model.LisaacModel;
+
+public class RefreshEditor implements IEditorActionDelegate {
+
+ AbstractLisaacEditor targetEditor;
+
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ if (targetEditor instanceof AbstractLisaacEditor) {
+ this.targetEditor = (AbstractLisaacEditor) targetEditor;
+ } else {
+ this.targetEditor = null;
+ }
+ LisaacModel.currentEditor = this.targetEditor;
+ }
+
+ public void run(IAction action) {
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/RenamePrototype.java b/editor/eclipse/src/org/lisaac/ldt/actions/RenamePrototype.java
new file mode 100644
index 0000000..854c08a
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/RenamePrototype.java
@@ -0,0 +1,114 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.editors.AbstractLisaacEditor;
+import org.lisaac.ldt.editors.LisaacScanner;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.refactor.RenamePrototypeRefactor;
+import org.lisaac.ldt.refactor.RenamePrototypeWizard;
+
+public class RenamePrototype implements IWorkbenchWindowActionDelegate {
+
+ private String prototypeName;
+
+ private LisaacModel model;
+
+ private IWorkbenchWindow fWindow = null;
+
+ public void dispose() {
+ }
+
+ public void init(IWorkbenchWindow window) {
+ fWindow = window;
+ }
+
+ public void run(IAction action) {
+ if (fWindow != null && prototypeName != null && model != null) {
+ RenamePrototypeRefactor refactoring = new RenamePrototypeRefactor(
+ prototypeName, model);
+ String name = LisaacMessages.getString("RenamePrototype.0"); //$NON-NLS-1$
+ run(new RenamePrototypeWizard(refactoring, prototypeName, name),
+ fWindow.getShell(), name);
+ }
+ }
+
+ public void run(RefactoringWizard wizard, Shell parent, String dialogTitle) {
+ try {
+ RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(
+ wizard);
+ operation.run(parent, dialogTitle);
+ } catch (InterruptedException exception) {
+ // Do nothing
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ prototypeName = null;
+
+ if (selection instanceof ITextSelection) {
+ String text = ((ITextSelection) selection).getText();
+ if (/* text.length() == 0 && */fWindow != null) {
+ // get surrounding word
+ IWorkbenchPart part = fWindow.getPartService().getActivePart();
+ if (part instanceof AbstractLisaacEditor) {
+ IDocument document = ((AbstractLisaacEditor) part)
+ .getDocument();
+ IProject project = ((AbstractLisaacEditor) part)
+ .getProject();
+ model = LisaacModel.getModel(project);
+
+ try {
+ text = selectWord(document,
+ ((ITextSelection) selection).getOffset());
+ } catch (BadLocationException e) {
+ action.setEnabled(false);
+ return;
+ }
+ }
+ }
+ if (LisaacScanner.isPrototypeIdentifier(text)) {
+ prototypeName = text;
+ }
+ }
+ action.setEnabled(prototypeName != null);
+ }
+
+ protected String selectWord(IDocument doc, int caretPos)
+ throws BadLocationException {
+ int startPos, endPos;
+
+ int pos = caretPos;
+ char c;
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+ startPos = pos + 1;
+ pos = caretPos;
+ int length = doc.getLength();
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+ endPos = pos;
+ return doc.get(startPos, endPos - startPos);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/actions/ToggleComment.java b/editor/eclipse/src/org/lisaac/ldt/actions/ToggleComment.java
new file mode 100644
index 0000000..f815259
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/actions/ToggleComment.java
@@ -0,0 +1,128 @@
+package org.lisaac.ldt.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.AbstractLisaacEditor;
+
+public class ToggleComment implements IWorkbenchWindowActionDelegate {
+
+ /**
+ * The action has been activated. The argument of the
+ * method represents the 'real' action sitting
+ * in the workbench UI.
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof AbstractLisaacEditor) {
+ IDocument document = ((AbstractLisaacEditor)part).getDocument();
+ //
+ ITextSelection selection = (ITextSelection) ((AbstractLisaacEditor)part).getSelectionProvider().getSelection();
+
+ try {
+ if (selection.getStartLine() == selection.getEndLine()) {
+ // single line comment
+
+ int startPos = document.getLineOffset(selection.getStartLine());
+ int pos = startPos;
+ char c;
+ do {
+ c = document.getChar(pos);
+ if (c != ICharacterScanner.EOF) {
+ if (c == '/') {
+ pos++;
+ c = document.getChar(pos);
+ if (c != ICharacterScanner.EOF && c == '/') {
+ document.replace(pos-1, 2, "");// delete comment //$NON-NLS-1$
+ return;
+ }
+ }
+ }
+ pos++;
+ } while (c != ICharacterScanner.EOF && pos <= startPos+selection.getLength());
+
+ // add comment
+ document.replace(startPos, 0, "//"); //$NON-NLS-1$
+
+ } else {
+ // multiline comment
+ int startPos = document.getLineOffset(selection.getStartLine());
+ int pos = startPos;
+ boolean deleteComment=false;
+ char c;
+ do {
+ c = document.getChar(pos);
+ if (c != ICharacterScanner.EOF) {
+ if (c == '/') {
+ pos++;
+ c = document.getChar(pos);
+ if (c != ICharacterScanner.EOF && c == '*') {
+ document.replace(pos-1, 2, "");// delete comment //$NON-NLS-1$
+ deleteComment = true;
+ pos++;
+ }
+ }
+ if (c == '*') {
+ pos++;
+ c = document.getChar(pos);
+ if (c != ICharacterScanner.EOF && c == '/') {
+ if (deleteComment) {
+ document.replace(pos-1, 2, "");// delete comment //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ pos++;
+ } while (c != ICharacterScanner.EOF && pos <= startPos+selection.getLength());
+
+ // add comment
+ if (! deleteComment) {
+ document.replace(startPos, 0, "/*"); //$NON-NLS-1$
+ int ofs = document.getLineOffset(selection.getEndLine());
+ ofs += document.getLineLength(selection.getEndLine());
+ document.replace(ofs, 0, "*/"); //$NON-NLS-1$
+ }
+ }
+
+ } catch(BadLocationException e) {
+ }
+ //
+ }
+ }
+
+ /**
+ * Selection in the workbench has been changed. We
+ * can change the state of the 'real' action here
+ * if we want, but this can only happen after
+ * the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We will cache window object in order to
+ * be able to provide parent shell for the message dialog.
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+
+ /**
+ * We can use this method to dispose of any system
+ * resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/builder/ILisaacErrorHandler.java b/editor/eclipse/src/org/lisaac/ldt/builder/ILisaacErrorHandler.java
new file mode 100644
index 0000000..4671673
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/builder/ILisaacErrorHandler.java
@@ -0,0 +1,16 @@
+package org.lisaac.ldt.builder;
+
+import org.lisaac.ldt.model.Position;
+
+public interface ILisaacErrorHandler {
+
+ void syntaxError(String msg, Position position);
+
+ void fatalError(String msg, Position position);
+
+ void warning(String msg, Position position);
+
+ void semanticError(String msg, Position position);
+
+ void enableErrorReport(boolean enable);
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/builder/LisaacBuilder.java b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacBuilder.java
new file mode 100644
index 0000000..6e33aae
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacBuilder.java
@@ -0,0 +1,252 @@
+package org.lisaac.ldt.builder;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.Position;
+
+public class LisaacBuilder extends IncrementalProjectBuilder {
+
+ private LisaacModel model;
+
+
+ class LisaacDeltaVisitor implements IResourceDeltaVisitor {
+
+ IProgressMonitor monitor;
+
+ LisaacDeltaVisitor(IProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource resource = delta.getResource();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ // handle added resource
+ buildLisaacFile(resource, monitor);
+ break;
+ case IResourceDelta.REMOVED:
+ // handle removed resource
+ removeLisaacFile(resource);
+ break;
+ case IResourceDelta.CHANGED:
+ // handle changed resource
+ buildLisaacFile(resource, monitor);
+ break;
+ }
+ //return true to continue visiting children.
+ return true;
+ }
+ }
+
+ class LisaacResourceVisitor implements IResourceVisitor {
+ IProgressMonitor monitor;
+
+ LisaacResourceVisitor(IProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+ public boolean visit(IResource resource) {
+ buildLisaacFile(resource, monitor);
+ //return true to continue visiting children.
+ return true;
+ }
+ }
+
+ class LisaacErrorHandler implements ILisaacErrorHandler {
+
+ private IFile file;
+ private boolean doReport;
+
+ public LisaacErrorHandler(IFile file) {
+ this.file = file;
+ this.doReport = true;
+ }
+
+ public void syntaxError(String msg, Position position) {
+ if (doReport)
+ addMarker(file, msg, position, IMarker.SEVERITY_ERROR);
+ }
+
+ public void semanticError(String msg, Position position) {
+ if (doReport)
+ addMarker(file, msg, position, IMarker.SEVERITY_ERROR);
+ }
+
+ public void fatalError(String msg, Position position) {
+ if (doReport)
+ addMarker(file, msg, position, IMarker.SEVERITY_ERROR);
+ }
+
+ public void warning(String msg, Position position) {
+ if (doReport)
+ addMarker(file, msg, position, IMarker.SEVERITY_WARNING);
+ }
+
+ public void enableErrorReport(boolean enable) {
+ doReport = enable;
+ }
+ }
+
+ public static final String BUILDER_ID = "org.lisaac.ldt.builder"; //$NON-NLS-1$
+
+ private static final String MARKER_TYPE = "org.lisaac.ldt.lisaacProblem"; //$NON-NLS-1$
+
+
+ public static void addMarker(IFile file, String msg, Position position, int severity) {
+ IMarker marker = LisaacBuilder.addMarker(file, msg, position.getLine(), severity);
+ if (marker != null && position.hasRange()) {
+ try {
+ marker.setAttribute(IMarker.CHAR_START, position.getCharStart());
+ marker.setAttribute(IMarker.CHAR_END, position.getCharEnd());
+
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ public static IMarker addMarker(IFile file, String message, int lineNumber,
+ int severity) {
+ try {
+ IMarker marker = file.createMarker(MARKER_TYPE);
+ marker.setAttribute(IMarker.MESSAGE, message);
+ marker.setAttribute(IMarker.SEVERITY, severity);
+ if (lineNumber == -1) {
+ lineNumber = 1;
+ }
+ marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
+ return marker;
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
+ * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IProject[] build(int kind, Map args, IProgressMonitor monitor)
+ throws CoreException {
+
+ IProject project = getProject();
+ model = LisaacModel.getModel(project);
+ if (model == null) {
+ // create lisaac model
+ model = new LisaacModel(project);
+
+ }
+
+ monitor.beginTask(LisaacMessages.getString("LisaacBuilder.2"), 100); //$NON-NLS-1$
+
+ model.refreshPresentation();
+ monitor.worked(1);
+
+ if (kind == CLEAN_BUILD) {
+ model.refreshPath();
+ monitor.worked(10);
+
+ IContainer bin = project.getFolder("lib");
+ if (bin.exists()) {
+ bin.delete(true, monitor);
+ }
+ }
+
+ if (kind == FULL_BUILD) {
+ fullBuild(monitor);
+ } else {
+ IResourceDelta delta = getDelta(model.getProject());
+ if (delta == null) {
+ fullBuild(monitor);
+ } else {
+ incrementalBuild(delta, monitor);
+ }
+ }
+ return null;
+ }
+
+ private void buildLisaacFile(IResource resource, IProgressMonitor monitor) {
+ if (resource instanceof IFile) {
+ IFile file = (IFile) resource;
+
+ if (file.isHidden()) {
+ return;
+ }
+
+ //System.out.println("VISITING => "+file.getName());
+
+ if (resource.getName().endsWith(".li")) { //$NON-NLS-1$
+ deleteMarkers(file);
+ try {
+ LisaacErrorHandler reporter = new LisaacErrorHandler(file);
+ model.parsePrototype(file, file.getContents(), reporter);
+ } catch (Exception e) {
+ }
+ } else if (resource.getName().endsWith(".lip")) { //$NON-NLS-1$
+ deleteMarkers(file);
+ try {
+ LisaacErrorHandler reporter = new LisaacErrorHandler(file);
+ model.parseLip(file.getName(), file.getContents(), reporter);
+ } catch (Exception e) {
+ }
+ }
+ monitor.worked(1);
+ }
+ }
+
+ private void removeLisaacFile(IResource resource) {
+ if (resource instanceof IFile) {
+ IFile file = (IFile) resource;
+ if (resource.getName().endsWith(".li")) { //$NON-NLS-1$
+ deleteMarkers(file);
+ try {
+ model.removePrototype(file);
+ } catch (Exception e) {
+ }
+ } else if (resource.getName().endsWith(".lip")) { //$NON-NLS-1$
+ deleteMarkers(file);
+ try {
+ model.removeLip(file);
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ public static void deleteMarkers(IFile file) {
+ try {
+ file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO);
+ } catch (CoreException ce) {
+ }
+ }
+
+ protected void fullBuild(final IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ if (model.getProject() != null) {
+ model.getProject().accept(new LisaacResourceVisitor(monitor));
+ monitor.done();
+ }
+ } catch (CoreException e) {
+ }
+ }
+
+ protected void incrementalBuild(IResourceDelta delta,
+ IProgressMonitor monitor) throws CoreException {
+ // the visitor does the work.
+ delta.accept(new LisaacDeltaVisitor(monitor));
+ monitor.done();
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/builder/LisaacChangeListener.java b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacChangeListener.java
new file mode 100644
index 0000000..a13a510
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacChangeListener.java
@@ -0,0 +1,34 @@
+package org.lisaac.ldt.builder;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.lisaac.ldt.model.LisaacModel;
+
+public class LisaacChangeListener implements IResourceChangeListener {
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+
+ if (delta != null) {
+ IResource resource = delta.getResource();
+ if (resource != null) {
+ if (resource instanceof IWorkspaceRoot) {
+ delta = (IResourceDelta) (delta.getAffectedChildren())[0];// TODO go deeper in the delta
+ resource = delta.getResource();
+ }
+ if (resource != null) {
+ IProject project = (IProject) resource.getProject();
+ LisaacModel model = LisaacModel.getModel(project);
+
+ if (model != null) {
+ model.setCompiled(false);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/builder/LisaacNature.java b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacNature.java
new file mode 100644
index 0000000..5b1faa9
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacNature.java
@@ -0,0 +1,80 @@
+package org.lisaac.ldt.builder;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+public class LisaacNature implements IProjectNature {
+
+ /**
+ * ID of this project nature
+ */
+ public static final String NATURE_ID = "org.lisaac.ldt.lisaac"; //$NON-NLS-1$
+
+ private IProject project;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IProjectNature#configure()
+ */
+ public void configure() throws CoreException {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] commands = desc.getBuildSpec();
+
+ for (int i = 0; i < commands.length; ++i) {
+ if (commands[i].getBuilderName().equals(LisaacBuilder.BUILDER_ID)) {
+ return;
+ }
+ }
+
+ ICommand[] newCommands = new ICommand[commands.length + 1];
+ System.arraycopy(commands, 0, newCommands, 0, commands.length);
+ ICommand command = desc.newCommand();
+ command.setBuilderName(LisaacBuilder.BUILDER_ID);
+ newCommands[newCommands.length - 1] = command;
+ desc.setBuildSpec(newCommands);
+ project.setDescription(desc, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IProjectNature#deconfigure()
+ */
+ public void deconfigure() throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ if (commands[i].getBuilderName().equals(LisaacBuilder.BUILDER_ID)) {
+ ICommand[] newCommands = new ICommand[commands.length - 1];
+ System.arraycopy(commands, 0, newCommands, 0, i);
+ System.arraycopy(commands, i + 1, newCommands, i,
+ commands.length - i - 1);
+ description.setBuildSpec(newCommands);
+ return;
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IProjectNature#getProject()
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
+ */
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/builder/LisaacParseException.java b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacParseException.java
new file mode 100644
index 0000000..ab7c99e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/builder/LisaacParseException.java
@@ -0,0 +1,14 @@
+package org.lisaac.ldt.builder;
+
+public class LisaacParseException extends Exception {
+
+ int line;
+
+ LisaacParseException(String msg, int line) {
+ super(msg);
+ }
+
+ public int getLineNumber() {
+ return line;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/AbstractLisaacEditor.java b/editor/eclipse/src/org/lisaac/ldt/editors/AbstractLisaacEditor.java
new file mode 100644
index 0000000..e3e8d41
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/AbstractLisaacEditor.java
@@ -0,0 +1,260 @@
+package org.lisaac.ldt.editors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListResourceBundle;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
+import org.eclipse.jface.text.source.projection.ProjectionSupport;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+import org.eclipse.ui.texteditor.ContentAssistAction;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+import org.lisaac.ldt.views.LisaacOutlineView;
+
+/**
+ * Main class for the Lisaac editor
+ * @author Damien Bouvarel
+ */
+public class AbstractLisaacEditor extends TextEditor {
+
+ private ColorManager colorManager;
+
+ /** the outline view. */
+ private LisaacOutlineView outlineView;
+
+ private ProjectionSupport projectionSupport;
+
+
+ public AbstractLisaacEditor() {
+ super();
+ colorManager = new ColorManager(LisaacPlugin.getDefault().getPreferenceStore());
+
+ setSourceViewerConfiguration(new LisaacConfiguration(colorManager,this));
+ setDocumentProvider(new LisaacDocumentProvider());
+
+ IPreferenceStore store = LisaacPlugin.getDefault().getPreferenceStore();
+
+ // wide caret
+ store.setDefault(PREFERENCE_USE_CUSTOM_CARETS, true);
+ store.setDefault(PREFERENCE_WIDE_CARET, true);
+
+ store = getChainedPreferenceStore();
+ setPreferenceStore(store);
+ }
+
+ /**
+ * Returns the preference store to be used by this editor.
+ * @return the preference store to be used by this editor
+ */
+ private IPreferenceStore getChainedPreferenceStore() {
+ List<IPreferenceStore> stores = new ArrayList<IPreferenceStore>();
+
+ stores.add(LisaacPlugin.getDefault().getPreferenceStore());
+ stores.add(EditorsUI.getPreferenceStore());
+
+ return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[0]));
+ }
+
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+
+ ProjectionViewer viewer =(ProjectionViewer)getSourceViewer();
+
+ projectionSupport = new ProjectionSupport(viewer,getAnnotationAccess(),getSharedColors());
+ projectionSupport.install();
+
+ //turn projection mode on
+ viewer.doOperation(ProjectionViewer.TOGGLE);
+
+ annotationModel = viewer.getProjectionAnnotationModel();
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int)
+ */
+ protected ISourceViewer createSourceViewer(Composite parent,
+ IVerticalRuler ruler, int styles) {
+ ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+
+ // ensure decoration support has been created and configured.
+ getSourceViewerDecorationSupport(viewer);
+
+ return viewer;
+ }
+
+ private Annotation[] oldAnnotations;
+ private ProjectionAnnotationModel annotationModel;
+
+ public void updateFoldingStructure(ArrayList positions) {
+
+ if (annotationModel == null) {
+ return;
+ }
+
+ Annotation[] annotations = new Annotation[positions.size()];
+
+ //this will hold the new annotations along
+ //with their corresponding positions
+ HashMap newAnnotations = new HashMap();
+
+ for(int i =0;i<positions.size();i++)
+ {
+ ProjectionAnnotation annotation = new ProjectionAnnotation();
+ newAnnotations.put(annotation,positions.get(i));
+ annotations[i] = annotation;
+ }
+ annotationModel.modifyAnnotations(oldAnnotations,newAnnotations,null);
+ oldAnnotations=annotations;
+ }
+
+ public void removeFoldingStructure() {
+ annotationModel.removeAllAnnotations();
+ }
+
+ public IDocument getDocument() {
+ if (getDocumentProvider() == null) {
+ return null;
+ }
+ return getDocumentProvider().getDocument(getEditorInput());
+ }
+
+ public void dispose() {
+ colorManager.dispose();
+ super.dispose();
+ }
+
+ public static class MyResources extends ListResourceBundle {
+ public Object[][] getContents() {
+ return contents;
+ }
+
+ static final Object[][] contents = { { "CorrectionAssist", "CorrectionAssist" }, { "ContentAssistProposal", "ContentAssistProposal" }, { "TemplateProposals", "TemplateProposals" }, };
+ }
+
+ protected void createActions() {
+ super.createActions();
+
+ MyResources ressources = new MyResources();
+
+ Action action = new ContentAssistAction(ressources, "ContentAssistProposal.", this); //$NON-NLS-1$
+ String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
+ action.setActionDefinitionId(id);
+ setAction("ContentAssistProposal", action); //$NON-NLS-1$
+ markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
+ }
+
+ public ISourceViewer getViewer() {
+ return getSourceViewer();
+ }
+
+ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+ colorManager.handlePreferenceStoreChanged(event);
+ super.handlePreferenceStoreChanged(event);
+
+ String prop = event.getProperty();
+ if (prop.equals(PreferenceConstants.P_LISAAC_COMPLETION_DELAY)) {
+ IContentAssistant assistant = getSourceViewerConfiguration().getContentAssistant(getSourceViewer());
+
+ Integer delay;
+ try {
+ delay = Integer.valueOf(((String)event.getNewValue()));
+ } catch (Exception e) {
+ delay = 500;
+ }
+ ((ContentAssistant) assistant).setAutoActivationDelay(delay);
+ }
+ }
+
+ protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+ return super.affectsTextPresentation(event)
+ || colorManager.affectsTextPresentation(event);
+ }
+
+
+ /**
+ * Redraw whole text presentation of the editor
+ */
+ public void refreshPresentation() {
+ IDocument document = getDocument();
+ if (document != null) {
+ refreshPresentation(0, document.getLength());
+ }
+ }
+ /**
+ * Redraw region of text presentation of the editor
+ * @param offset redraw region offset
+ * @param length redraw region length
+ */
+ public void refreshPresentation(int offset, int length) {
+ ISourceViewer viewer = getSourceViewer();
+ if (viewer instanceof ITextViewerExtension2) {
+ ITextViewerExtension2 ext = (ITextViewerExtension2) viewer;
+ ext.invalidateTextPresentation(offset, length);
+ }
+ }
+
+ /**
+ * @return the project for the file that's being edited (or null if not available)
+ */
+ public IProject getProject() {
+ IEditorInput editorInput = this.getEditorInput();
+ if (editorInput instanceof FileEditorInput) {
+ IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class);
+ return file.getProject();
+ }
+ return null;
+ }
+
+ /**
+ * @return the file name for the file that's being edited (or null if not available)
+ */
+ public String getFileName() {
+ IEditorInput editorInput = this.getEditorInput();
+ if (editorInput instanceof FileEditorInput) {
+ IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class);
+ return file.getName();
+ }
+ return null;
+ }
+
+ /**
+ * @see AbstractTextEditor#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class required) {
+
+ if (IContentOutlinePage.class.equals(required)) {
+ if (outlineView == null) {
+ outlineView = new LisaacOutlineView(getDocumentProvider(), this);
+ }
+ return outlineView;
+ } else {
+ return super.getAdapter(required);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/ColorManager.java b/editor/eclipse/src/org/lisaac/ldt/editors/ColorManager.java
new file mode 100644
index 0000000..517e5cb
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/ColorManager.java
@@ -0,0 +1,175 @@
+package org.lisaac.ldt.editors;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.widgets.Display;
+
+public class ColorManager {
+
+ private static ColorManager instance;
+
+ protected Map<RGB,Color> fColorTable = new HashMap<RGB,Color>(10);
+ private Map<String,IToken> tokenTable = new HashMap<String,IToken>(10);
+ private Map<String,String> styleTable = new HashMap<String,String>(10);
+
+ private final IPreferenceStore preferenceStore;
+
+ private Styler operatorStyler;
+ private Styler prototypeStyler;
+ private Styler slotStyler;
+ private Styler variableStyler;
+
+ public ColorManager(IPreferenceStore preferenceStore) {
+ this.preferenceStore = preferenceStore;
+ instance = this;
+
+ operatorStyler = new DefaultStyler(ILisaacColor.PREF_OPERATOR, ILisaacColor.STYLE_OPERATOR);
+ prototypeStyler = new DefaultStyler(ILisaacColor.PREF_PROTOTYPE, ILisaacColor.STYLE_PROTOTYPE);
+ slotStyler = new DefaultStyler(ILisaacColor.PREF_SLOT, ILisaacColor.STYLE_SLOT);
+ variableStyler = new DefaultStyler(ILisaacColor.PREF_LOCAL_SLOT, ILisaacColor.STYLE_LOCAL_SLOT);
+ }
+
+ public static ColorManager getDefault() {
+ return instance;
+ }
+
+ public void dispose() {
+ Iterator<Color> e = fColorTable.values().iterator();
+ while (e.hasNext())
+ ((Color) e.next()).dispose();
+ }
+ public Color getColor(RGB rgb) {
+ Color color = (Color) fColorTable.get(rgb);
+ if (color == null) {
+ color = new Color(Display.getCurrent(), rgb);
+ fColorTable.put(rgb, color);
+ }
+ return color;
+ }
+
+ public IToken getToken(String prefKey, String styleKey) {
+ Token token = (Token) tokenTable.get(prefKey);
+ int style = convertToStyle(styleKey);
+
+ if (token == null) {
+ String colorName = preferenceStore.getString(prefKey);
+ RGB rgb = StringConverter.asRGB(colorName);
+
+ token = new Token(new TextAttribute(getColor(rgb), null, style));
+ tokenTable.put(prefKey, token);
+ styleTable.put(styleKey, prefKey);
+ } else {
+ TextAttribute attrib = (TextAttribute) token.getData();
+ if (attrib.getStyle() != style) {
+ token = new Token(new TextAttribute(attrib.getForeground(), null, style));
+ tokenTable.put(prefKey, token);
+ }
+ }
+ return token;
+ }
+
+ public IToken getToken2(String prefKey, String prefKey2) {
+ Token token = (Token) tokenTable.get(prefKey);
+ if (token == null) {
+ String colorName = preferenceStore.getString(prefKey);
+ RGB rgb = StringConverter.asRGB(colorName);
+ String colorName2 = preferenceStore.getString(prefKey2);
+ RGB rgb2 = StringConverter.asRGB(colorName2);
+ token = new Token(new TextAttribute(getColor(rgb2), getColor(rgb), SWT.NORMAL));
+ tokenTable.put(prefKey, token);
+ }
+ return token;
+ }
+
+ public boolean affectsTextPresentation(PropertyChangeEvent event) {
+ Token token = (Token) tokenTable.get(event.getProperty());
+ return (token != null) || styleTable.get(event.getProperty()) != null;
+ }
+
+ public void handlePreferenceStoreChanged (PropertyChangeEvent event) {
+ String prefKey = event.getProperty();
+ Token token = (Token) tokenTable.get(prefKey);
+ if (token != null) {
+ String colorName = preferenceStore.getString(prefKey);
+ RGB rgb = StringConverter.asRGB(colorName);
+
+ if (prefKey.equals(ILisaacColor.PREF_EXTERNAL)) {
+ String colorName2 = preferenceStore.getString(ILisaacColor.PREF_LOCAL_SLOT);
+ RGB rgb2 = StringConverter.asRGB(colorName2);
+ token.setData(new TextAttribute(getColor(rgb2), getColor(rgb), SWT.NORMAL));
+ } else {
+ token.setData(new TextAttribute(getColor(rgb)));
+ }
+ } else { // update style
+ String key = (String) styleTable.get(prefKey);
+ if (key != null) {
+ token = (Token) tokenTable.get(key);
+ if (token != null) {
+ int style = convertToStyle(prefKey);
+ TextAttribute attrib = (TextAttribute) token.getData();
+ token.setData(new TextAttribute(attrib.getForeground(), null, style));
+ }
+ }
+ }
+ }
+
+ public int convertToStyle(String prefKey) {
+ String pref = preferenceStore.getString(prefKey);
+ if (pref.equals(ILisaacColor.PREF_NORMAL)) {
+ return SWT.NORMAL;
+ }
+ if (pref.equals(ILisaacColor.PREF_BOLD)) {
+ return SWT.BOLD;
+ }
+ if (pref.equals(ILisaacColor.PREF_ITALICS)) {
+ return SWT.ITALIC;
+ }
+ if (pref.equals(ILisaacColor.PREF_UNDERLINE)) {
+ return TextAttribute.UNDERLINE;
+ }
+ return SWT.NORMAL;
+ }
+
+ public Styler getOperatorStyler() {
+ return operatorStyler;
+ }
+
+ public Styler getPrototypeStyler() {
+ return prototypeStyler;
+ }
+
+ public Styler getSlotStyler() {
+ return slotStyler;
+ }
+
+ public Styler getVariableStyler() {
+ return variableStyler;
+ }
+
+ private class DefaultStyler extends Styler {
+ String prefKey, styleKey;
+
+ public DefaultStyler(String prefKey, String styleKey) {
+ this.prefKey = prefKey;
+ this.styleKey = styleKey;
+ }
+ public void applyStyles(TextStyle textStyle) {
+ IToken token = getToken(prefKey, styleKey);
+ TextAttribute attrib = (TextAttribute) token.getData();
+ textStyle.foreground = attrib.getForeground();
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/HoverPresenter.java b/editor/eclipse/src/org/lisaac/ldt/editors/HoverPresenter.java
new file mode 100644
index 0000000..d30d9aa
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/HoverPresenter.java
@@ -0,0 +1,136 @@
+package org.lisaac.ldt.editors;
+
+import java.util.Stack;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Drawable;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.TextPresentation;
+
+
+/**
+ * Format Lisaac hover text.
+ */
+public class HoverPresenter implements DefaultInformationControl.IInformationPresenter, DefaultInformationControl.IInformationPresenterExtension {
+
+ private static final int NONE = 0;
+ private static final int BOLD = 1;
+ private static final int ITALIC = 2;
+ private static final int GRAY = 3;
+
+ protected ColorManager colorManager;
+
+ public HoverPresenter(ColorManager colorManager) {
+ this.colorManager = colorManager;
+ }
+
+ /*
+ * @see IHoverInformationPresenterExtension#updatePresentation(Drawable drawable, String, TextPresentation, int, int)
+ * @since 3.2
+ */
+ public String updatePresentation(Drawable drawable, String hoverInfo,
+ TextPresentation presentation, int maxWidth, int maxHeight) {
+
+ if (hoverInfo == null)
+ return null;
+
+ StringBuffer buffer= new StringBuffer();
+
+ int style = NONE;
+ Stack<Integer> styles = new Stack<Integer>();
+ int startOffset = 0;
+
+ int len = hoverInfo.length();
+ int i = 0;
+ int derive = 0;
+
+ while (i < len) {
+ char c = hoverInfo.charAt(i);
+
+ if (c == '<' && i < len-3) {
+ if (hoverInfo.charAt(i+1) == '/') {
+ // end of style
+
+ c = Character.toLowerCase(hoverInfo.charAt(i+2));
+ if (hoverInfo.charAt(i+3) == '>') {
+ style = styles.pop();
+ startOffset = styles.pop();
+ int styleDerive = styles.pop();
+
+ int lengthDerive = derive - styleDerive;
+
+ if (lengthDerive > 0) {
+ // FIXME ranges cannot overlap...
+ style = NONE;
+ }
+
+ switch(style) {
+ case BOLD:
+ presentation.addStyleRange(new StyleRange(
+ startOffset - styleDerive, i - startOffset - lengthDerive, null, null, SWT.BOLD));
+ break;
+ case ITALIC:
+ presentation.addStyleRange(new StyleRange(
+ startOffset - styleDerive, i - startOffset - lengthDerive, null, null, SWT.ITALIC));
+ break;
+ case GRAY:
+ Color gray = colorManager.getColor(ILisaacColor.GRAY);
+ presentation.addStyleRange(new StyleRange(
+ startOffset - styleDerive, i - startOffset - lengthDerive, gray, null, SWT.NONE));
+ break;
+ }
+ i += 3;
+ derive += 4;
+ }
+ style = NONE;
+ } else {
+ c = Character.toLowerCase(hoverInfo.charAt(i+1));
+ startOffset = i+3;
+ switch(c) {
+ case 'b':
+ style = BOLD;
+ break;
+ case 'i':
+ style = ITALIC;
+ break;
+ case 'g':
+ style = GRAY;
+ break;
+ }
+ c = hoverInfo.charAt(i+2);
+ if (c != '>') {
+ buffer.append(c);
+ style = NONE;
+ } else {
+ i += 2;
+ derive += 3;
+
+ styles.push(derive);
+ styles.push(startOffset);
+ styles.push(style);
+ }
+ }
+ } else {
+ buffer.append(c);
+ }
+ i++;
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.text.DefaultInformationControl.IInformationPresenter#updatePresentation(org.eclipse.swt.widgets.Display, java.lang.String, org.eclipse.jface.text.TextPresentation, int, int)
+ * @deprecated
+ */
+ public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {
+ return updatePresentation((Drawable)display, hoverInfo, presentation, maxWidth, maxHeight);
+ }
+}
+
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/ILisaacColor.java b/editor/eclipse/src/org/lisaac/ldt/editors/ILisaacColor.java
new file mode 100644
index 0000000..662de00
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/ILisaacColor.java
@@ -0,0 +1,50 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Associate a color to each token lexical class.
+ * @author Damien Bouvarel
+ */
+public interface ILisaacColor {
+ RGB COMMENT = new RGB(200, 50, 0);
+ RGB PROTOTYPE = new RGB(0, 128, 0);
+ RGB PROTOTYPE_STYLE = new RGB(255, 0, 0);
+ RGB KEYWORD = new RGB(128, 0, 255);
+ RGB CHARACTER = new RGB(128, 128, 255);
+ RGB STRING = new RGB(210, 150, 150);
+ RGB NUMBER = new RGB(128, 0, 255);
+ RGB OPERATOR = new RGB(200, 130, 0);
+ RGB EXTERNAL = new RGB(128, 255, 128);
+ RGB UNDEFINED = new RGB(0, 0, 255);
+ RGB DEFAULT = new RGB(0, 0, 0);
+
+ RGB GRAY = new RGB(128, 128, 128);
+
+ String PREF_NORMAL = "normal";
+ String PREF_BOLD = "bold";
+ String PREF_ITALICS = "italic";
+ String PREF_UNDERLINE = "underline";
+
+ String PREF_COMMENT = "comment_color";
+ String PREF_PROTOTYPE = "prototype_color";
+ String PREF_PROTOTYPE_STYLE = "prototype_style_color";
+ String PREF_KEYWORD = "keyword_color";
+ String PREF_SLOT = "slot_color";
+ String PREF_LOCAL_SLOT = "local_slot_color";
+ String PREF_CHARACTER = "character_color";
+ String PREF_STRING = "string_color";
+ String PREF_NUMBER = "number_color";
+ String PREF_OPERATOR = "operator_color";
+ String PREF_EXTERNAL = "external_color";
+
+ String STYLE_PROTOTYPE = "prototype_style";
+ String STYLE_PROTOTYPE_STYLE = "prototype_style_style";
+ String STYLE_KEYWORD = "keyword_style";
+ String STYLE_SLOT = "slot_style";
+ String STYLE_LOCAL_SLOT = "local_slot_style";
+ String STYLE_CHARACTER = "character_style";
+ String STYLE_STRING = "string_style";
+ String STYLE_NUMBER = "number_style";
+ String STYLE_OPERATOR = "operator_style";
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LipEditor.java b/editor/eclipse/src/org/lisaac/ldt/editors/LipEditor.java
new file mode 100644
index 0000000..61457a2
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LipEditor.java
@@ -0,0 +1,25 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Main class for the Lip editor
+ * @author Damien Bouvarel
+ */
+public class LipEditor extends AbstractLisaacEditor {
+
+ public LipEditor() {
+ super();
+ }
+
+ /**
+ * @see AbstractTextEditor#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class required) {
+ if (IContentOutlinePage.class.equals(required)) {
+ return null; // no outline
+ } else {
+ return super.getAdapter(required);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacAutoEditStrategy.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacAutoEditStrategy.java
new file mode 100644
index 0000000..08adc58
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacAutoEditStrategy.java
@@ -0,0 +1,352 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+
+
+public class LisaacAutoEditStrategy extends DefaultIndentLineAutoEditStrategy {
+
+ /**
+ * @see DefaultIndentLineAutoEditStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
+ */
+ public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
+ editDocumentCommand(d, c);
+ }
+
+ /**
+ * Customizes the given document command to edit the given document.
+ * @param document the document
+ * @param command the command
+ * @see DefaultIndentLineAutoEditStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
+ */
+ protected void editDocumentCommand(IDocument document, DocumentCommand command) {
+ String textCommand = command.text;
+
+ if (textCommand != null) {
+
+ boolean enableIndent = LisaacPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_LISAAC_INDENT);
+ if (! enableIndent) {
+ return;
+ }
+ String[] lineDelimiters = document.getLegalLineDelimiters();
+ int endOfLineIndex = TextUtilities.endsWith(lineDelimiters, textCommand);
+
+ if (endOfLineIndex > -1) {
+ // this is an end of line
+ indentOnNewLine(document, command);
+ } else if (textCommand.equals("\t")) {
+ // this is a tab
+ indentOnTab(document, command);
+ } else {
+ // this is another character or string
+ indentOnSpecificChar(document, command);
+ }
+ }
+ }
+
+ /**
+ * Indent One line.
+ * @param indentLine line to be indented
+ * @param document
+ * @param command
+ * @return last indentation for the next line
+ */
+ private static void doIndentLine(int indentLine, IDocument document, DocumentCommand command) {
+ try {
+ //
+ // find last line indent
+ //
+
+ int lastIndent = getIndentWithPreviousLine(indentLine, document);
+
+ //
+ // current line indent
+ //
+ IRegion currentLineInfo = document.getLineInformation(indentLine);
+
+ int lineStart = currentLineInfo.getOffset();
+ int lineEnd = currentLineInfo.getOffset() + currentLineInfo.getLength();
+
+ IRegion originalBlankRegion = getBlankAfterOffset(document, lineStart);
+ int currentIndent = originalBlankRegion.getLength();
+
+ // special case
+ if (lineEnd - originalBlankRegion.getOffset()+currentIndent > 8) {
+ String instr = document.get(originalBlankRegion.getOffset()+currentIndent,8);
+ if (instr.startsWith("Section ")) {
+ lastIndent = 2;
+
+ // insertion in current line
+ if (command != null) {
+ command.text = "";
+ command.offset = lineStart;
+ command.length = currentIndent;
+ } else {
+ document.replace(lineStart, currentIndent, "");
+ }
+ return;
+ }
+ }
+ int i = lineEnd-1;
+ int indent2 = 0;
+ while (i >= lineStart) {
+ char c = document.getChar(i);
+ switch (c) {
+ case '{':
+ case '(':
+ case '[':
+ if (indent2 != 0) {
+ indent2 -= 2;
+ }
+ break;
+ case '}':
+ case ')':
+ case ']':
+ indent2 += 2;
+ break;
+ case '\"':// string " "
+ do {
+ i--;
+ if (i >= lineStart) {
+ c = document.getChar(i);
+ }
+ } while (i >= lineStart && c != '\"');
+ break;
+ case '\'':// string ' '
+ do {
+ i--;
+ if (i >= lineStart) {
+ c = document.getChar(i);
+ }
+ } while (i >= lineStart && c != '\'');
+ break;
+ }
+ i--;
+ }
+ //
+ // insertion in current line
+ //
+ lastIndent -= indent2;
+
+ if (command != null) {
+ command.text = createString(lastIndent);
+ command.offset = lineStart;
+ command.length = currentIndent;
+ } else {
+ document.replace(lineStart, currentIndent, createString(lastIndent));
+ }
+
+ } catch (BadLocationException excp) {
+ // stop work
+ }
+ }
+
+ /**
+ * Get line indentation using previous line.
+ */
+ private static int getIndentWithPreviousLine(int line, IDocument document) {
+ int result = 0;
+ try {
+ //
+ // find last line indent
+ //
+ while (line > 0) {
+ line--;
+ IRegion lineRegion = document.getLineInformation(line);
+
+ int lineStart = lineRegion.getOffset();
+ int lineEnd = lineRegion.getOffset() + lineRegion.getLength();
+
+ IRegion originalBlankRegion = getBlankAfterOffset(document, document.getLineOffset(line));
+ result = originalBlankRegion.getLength();
+
+ // special case
+ if (lineEnd - originalBlankRegion.getOffset()+result > 8) {
+ String instr = document.get(originalBlankRegion.getOffset()+result,8);
+ if (instr.startsWith("Section ")) {
+ result = 2;
+ break;
+ }
+ }
+ int i = lineStart;
+ int deltaIndent = 0;
+ while (i < lineEnd) {
+ char c = document.getChar(i);
+ switch (c) {
+ case '{':
+ case '(':
+ case '[':
+ deltaIndent += 2;
+ break;
+ case '}':
+ case ')':
+ case ']':
+ if (deltaIndent != 0) {
+ deltaIndent -= 2;
+ }
+ break;
+ case '\"':// string " "
+ do {
+ i++;
+ if (i < lineEnd) {
+ c = document.getChar(i);
+ }
+ } while (i < lineEnd && c != '\"');
+ break;
+ case '\'':// string ' '
+ do {
+ i++;
+ if (i < lineEnd) {
+ c = document.getChar(i);
+ }
+ } while (i < lineEnd && c != '\'');
+ break;
+ }
+ i++;
+ }
+ result += deltaIndent;
+
+ if (getBlankEnd(document,lineStart) != lineEnd) {
+ // not empty line
+ break;
+ }
+ }
+ } catch (BadLocationException excp) {
+ // stop work
+ }
+ return result;
+ }
+
+ /**
+ * Get the blank region of given line after offset
+ */
+ private static int getBlankEnd(IDocument document, int offset) throws BadLocationException {
+ IRegion lineRegion = document.getLineInformationOfOffset(offset);
+ int blankEnd = offset;
+ int maxBlankEnd = lineRegion.getOffset() + lineRegion.getLength();
+
+ while (blankEnd < maxBlankEnd) {
+ char c = document.getChar(blankEnd);
+ if (c != ' ' && c != '\t') {
+ break;
+ }
+ blankEnd++;
+ }
+ return blankEnd;
+ }
+
+ /**
+ * Customizes the given command to edit the given document when a newline is pressed.
+ * @param document the document
+ * @param command the command
+ */
+ protected void indentOnNewLine(IDocument document, DocumentCommand command) {
+ try {
+ int p = (command.offset == document.getLength() ? command.offset - 1 : command.offset);
+ int line = document.getLineOfOffset(p);
+
+ // indent previous line
+ doIndentLine(line, document, command);
+
+ // get indent for new line
+ int indent = getIndentWithPreviousLine(line+1, document);
+
+ //
+ // indent new line
+ //
+ //IRegion info = document.getLineInformation(line);
+ command.addCommand(p/*info.getOffset() + info.getLength()*/, 0, "\n"+createString(indent), null);
+ command.shiftsCaret = true;
+ command.caretOffset = p /*info.getOffset() + info.getLength()*/;
+
+ } catch (BadLocationException e) {
+ // stop work
+ }
+ }
+
+ /**
+ * Get the blank region of given line after offset
+ */
+ private static IRegion getBlankAfterOffset(IDocument document, int offset) throws BadLocationException {
+ IRegion lineRegion = document.getLineInformationOfOffset(offset);
+ int blankEnd = offset;
+ int maxBlankEnd = lineRegion.getOffset() + lineRegion.getLength();
+
+ while (blankEnd < maxBlankEnd) {
+ char c = document.getChar(blankEnd);
+ if (c != ' ' && c != '\t') {
+ break;
+ }
+ blankEnd++;
+ }
+ return new Region(offset, blankEnd - offset);
+ }
+
+ /**
+ * Returns a blank string of the given length.
+ * @param length the length of the string to create
+ * @return a blank string of the given length
+ */
+ public static String createString(int length) {
+ StringBuffer buffer = new StringBuffer(length);
+
+ for (int index = 0 ; index < length ; index++) {
+ buffer.append(' ');
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Customizes the given command to edit the given document when a tabulation is pressed.
+ * @param document the document
+ * @param command the command
+ */
+ protected void indentOnTab(IDocument document, DocumentCommand command) {
+
+ //fullIndentDocument(document);
+
+ try {
+ int p = (command.offset == document.getLength() ? command.offset - 1 : command.offset);
+ int line = document.getLineOfOffset(p);
+
+ doIndentLine(line, document, command);
+
+ } catch (BadLocationException excp) {
+ // stop work
+ }
+ }
+
+ /**
+ * Customizes the given command to edit the given document when a specific character is pressed.
+ * @param document the document
+ * @param command the command
+ */
+ protected void indentOnSpecificChar(IDocument document, DocumentCommand command) {
+ // TODO code templates!!!
+ }
+
+ /**
+ * Indent correctly the whole document
+ * @param document the document
+ */
+ public static void fullIndentDocument(IDocument document) {
+ int line = 0;
+ int maxLine = document.getNumberOfLines();
+
+ while (line < maxLine) {
+ doIndentLine(line, document, null);
+ line++;
+ }
+ }
+
+ public static void indentLine(int line, IDocument document) {
+ doIndentLine(line, document, null);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java
new file mode 100644
index 0000000..848452d
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java
@@ -0,0 +1,162 @@
+package org.lisaac.ldt.editors;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.text.templates.TemplateProposal;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.model.LisaacCompletionParser;
+import org.lisaac.ldt.model.LisaacParser;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+import org.lisaac.ldt.templates.LisaacTemplateProcessor;
+
+
+public class LisaacCompletionProcessor implements IContentAssistProcessor {
+
+ private final IContextInformation[] NO_CONTEXTS = new IContextInformation[0];
+ private final char[] PROPOSAL_ACTIVATION_CHARS = new char[] { '.' };
+ private ICompletionProposal[] NO_COMPLETIONS = new ICompletionProposal[0];
+
+ private LisaacTemplateProcessor templates;
+
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ try {
+ boolean enableCompletion = LisaacPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_LISAAC_COMPLETION);
+ if (! enableCompletion) {
+ return null;
+ }
+
+ IDocument document = viewer.getDocument();
+ ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+
+ //
+ computeLisaacCompletion(document, offset, result);
+ if (result.size() > 1) {
+ Collections.sort(result, new Comparator<ICompletionProposal>() {
+ public int compare(ICompletionProposal o1, ICompletionProposal o2) {
+ return o1.getDisplayString().compareTo(o2.getDisplayString());
+ }
+ });
+ }
+ //
+
+ String prefix= extractPrefix(document, offset);
+
+ if (prefix != null && prefix.length() > 0) {
+ templates = new LisaacTemplateProcessor();
+ ICompletionProposal[] props = templates.computeCompletionProposals(viewer, offset);
+ for (int t=0; t<props.length; t++) {
+ TemplateProposal tp = (TemplateProposal) props[t];
+ if (tp.getDisplayString().startsWith(prefix)) {
+ result.add(props[t]);
+ }
+ }
+ }
+
+ return (ICompletionProposal[]) result.toArray(new ICompletionProposal[result.size()]);
+ } catch (Exception e) {
+ // ... log the exception ...
+ return NO_COMPLETIONS;
+ }
+
+ }
+
+ private void computeLisaacCompletion(IDocument document, int baseOffset,
+ ArrayList<ICompletionProposal> proposals) {
+ int bracketLevel=0;
+ //
+ // Rewind to '(' '{' ';' '[' ':' '<-'
+ //
+ try {
+ int pos = baseOffset-1;
+ while (pos > 0) {
+ char c = document.getChar(pos);
+ if (c == ';' || c == ':') {
+ break;
+ }
+ if (c == '-' && pos-1 > 0 && document.getChar(pos-1) == '<') {
+ break;
+ }
+ if (LisaacParser.isOperatorSymbol(c)) {
+ break;
+ }
+ if (c == '(' || c == '{' || c == '[') {
+ if (bracketLevel == 0) {
+ break;
+ }
+ bracketLevel--;
+ }
+ if (c == ')' || c == '}' || c == ']') {
+ bracketLevel++;
+ }
+ pos--;
+ }
+ if (pos > 0) {
+ //
+ // compute lisaac expression type
+ //
+ String contents = document.get(pos+1, baseOffset-1 - pos);
+
+ LisaacCompletionParser parser = new LisaacCompletionParser(contents, null);
+ parser.parseCompletions(pos+1, baseOffset, proposals);
+ }
+ } catch (BadLocationException e) {
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected String extractPrefix(IDocument document, int offset) {
+ int i= offset;
+ if (i > document.getLength())
+ return ""; //$NON-NLS-1$
+
+ try {
+ while (i > 0) {
+ char ch= document.getChar(i - 1);
+ if (!Character.isJavaIdentifierPart(ch))
+ break;
+ i--;
+ }
+
+ return document.get(i, offset - i);
+ } catch (BadLocationException e) {
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer,
+ int offset) {
+ return NO_CONTEXTS;
+ }
+
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return PROPOSAL_ACTIVATION_CHARS;
+ }
+
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ return null;
+ }
+
+ public String getErrorMessage() {
+ return "Lisaac Completion error";
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacCompletionProposal.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacCompletionProposal.java
new file mode 100644
index 0000000..aa09f36
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacCompletionProposal.java
@@ -0,0 +1,121 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+
+public class LisaacCompletionProposal implements ICompletionProposal, ICompletionProposalExtension6 {
+
+
+ /** The string to be displayed in the completion proposal popup. */
+ private StyledString fStyledString;
+
+ /** The replacement string. */
+ private String fReplacementString;
+ /** The replacement offset. */
+ private int fReplacementOffset;
+ /** The replacement length. */
+ private int fReplacementLength;
+ /** The cursor position after this proposal has been applied. */
+ private int fCursorPosition;
+ /** The image to be displayed in the completion proposal popup. */
+ private Image fImage;
+
+
+ /**
+ * Creates a new completion proposal. All fields are initialized based on the provided information.
+ *
+ * @param replacementString the actual string to be inserted into the document
+ * @param replacementOffset the offset of the text to be replaced
+ * @param replacementLength the length of the text to be replaced
+ * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal
+ */
+ public LisaacCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString) {
+ this(replacementString, replacementOffset, replacementLength, cursorPosition, image, new StyledString(displayString));
+ }
+
+ /**
+ * Creates a new completion proposal. All fields are initialized based on the provided information.
+ *
+ * @param replacementString the actual string to be inserted into the document
+ * @param replacementOffset the offset of the text to be replaced
+ * @param replacementLength the length of the text to be replaced
+ * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal
+ */
+ public LisaacCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, StyledString displayString) {
+ Assert.isNotNull(replacementString);
+ Assert.isTrue(replacementOffset >= 0);
+ Assert.isTrue(replacementLength >= 0);
+ Assert.isTrue(cursorPosition >= 0);
+
+ fReplacementString= replacementString;
+ fReplacementOffset= replacementOffset;
+ fReplacementLength= replacementLength;
+ fCursorPosition= cursorPosition;
+ fImage= image;
+ fStyledString = displayString;
+ }
+
+ /*
+ * @see ICompletionProposal#apply(IDocument)
+ */
+ public void apply(IDocument document) {
+ try {
+ document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+
+ /*
+ * @see ICompletionProposal#getSelection(IDocument)
+ */
+ public Point getSelection(IDocument document) {
+ return new Point(fReplacementOffset + fCursorPosition, 0);
+ }
+
+ /*
+ * @see ICompletionProposal#getContextInformation()
+ */
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+ /*
+ * @see ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ return fImage;
+ }
+
+ /*
+ * @see ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ if (fStyledString != null)
+ return fStyledString.getString();
+ return fReplacementString;
+ }
+
+ /*
+ * @see ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ return null;
+ }
+
+ public StyledString getStyledDisplayString() {
+ return fStyledString;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacConfiguration.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacConfiguration.java
new file mode 100644
index 0000000..78afa98
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacConfiguration.java
@@ -0,0 +1,209 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+
+/**
+ * Manage the configuration of syntax coloration for lisaac documents.
+ */
+public class LisaacConfiguration extends SourceViewerConfiguration {
+ private LisaacDoubleClickStrategy doubleClickStrategy;
+ private LisaacScanner scanner;
+ private ColorManager colorManager;
+
+ private ContentAssistant contentAssistant = null;
+ private ITextHover textHover = null;
+
+ private AbstractLisaacEditor editor;
+
+ public LisaacConfiguration(ColorManager colorManager, AbstractLisaacEditor editor) {
+ this.colorManager = colorManager;
+ this.editor = editor;
+ }
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ return new String[] {
+ IDocument.DEFAULT_CONTENT_TYPE,
+ LisaacPartitionScanner.LISAAC_COMMENT,
+ LisaacPartitionScanner.LISAAC_STRING,
+ LisaacPartitionScanner.LISAAC_CHARACTERS,
+ LisaacPartitionScanner.LISAAC_EXTERNAL
+ };
+ }
+
+ public ITextDoubleClickStrategy getDoubleClickStrategy(
+ ISourceViewer sourceViewer,
+ String contentType) {
+ if (doubleClickStrategy == null)
+ doubleClickStrategy = new LisaacDoubleClickStrategy();
+ return doubleClickStrategy;
+ }
+
+ /**
+ * Returns the content assistant ready to be used with the given source viewer.
+ * This implementation always returns <code>null</code>.
+ *
+ * @param sourceViewer the source viewer to be configured by this configuration
+ * @return a content assistant or <code>null</code> if content assist should not be supported
+ */
+ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+ if (contentAssistant == null) {
+ contentAssistant = new ContentAssistant();
+ IContentAssistProcessor cap = new LisaacCompletionProcessor();
+ contentAssistant.setContentAssistProcessor(cap, IDocument.DEFAULT_CONTENT_TYPE);
+ //
+ contentAssistant.setRepeatedInvocationMode(true);
+ contentAssistant.setStatusLineVisible(true);
+ contentAssistant.enableColoredLabels(true);
+ contentAssistant.setStatusMessage(LisaacMessages.getString("LisaacConfiguration_0")); //$NON-NLS-1$
+ //
+
+ int delay;
+ try {
+ delay = LisaacPlugin.getDefault().getPreferenceStore().getInt(PreferenceConstants.P_LISAAC_COMPLETION_DELAY);
+ } catch (Exception e) {
+ delay = 500;
+ }
+ contentAssistant.enableAutoActivation(true);
+ contentAssistant.setAutoActivationDelay(delay);
+ contentAssistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+ }
+ return contentAssistant;
+ }
+
+
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
+ if (textHover != null) {
+ return textHover;
+ }
+ if (editor != null) {
+ IProject project = editor.getProject();
+
+ LisaacModel model = LisaacModel.getModel(project);
+ textHover = new LisaacTextHover(model, editor.getFileName(), colorManager);
+ }
+ return textHover;
+ }
+
+ /**
+ * @see SourceViewerConfiguration#getAutoEditStrategies(ISourceViewer, String)
+ */
+ public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
+
+ if (contentType.equals(LisaacPartitionScanner.LISAAC_COMMENT)) {
+ return new IAutoEditStrategy[] { new DefaultIndentLineAutoEditStrategy() };
+
+ } else if (contentType.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
+ return new IAutoEditStrategy[] { new LisaacAutoEditStrategy() };
+
+ } else {
+ return super.getAutoEditStrategies(sourceViewer, contentType);
+ }
+ }
+
+ /**
+ * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
+ */
+ public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
+ return new String[]{ new String(" "), new String() }; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the hyperlink detectors which be used to detect hyperlinks
+ * in the given source viewer.
+ * @param sourceViewer the source viewer to be configured by this configuration
+ * @return an array with hyperlink detectors or <code>null</code> if no hyperlink support should be installed
+ * @since 3.1
+ */
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (sourceViewer == null)
+ return null;
+
+ return new IHyperlinkDetector[] { new LisaacHyperLinkDetector(), new URLHyperlinkDetector() };
+ }
+
+ protected LisaacScanner getLisaacScanner() {
+ if (scanner == null) {
+ scanner = new LisaacScanner(colorManager);
+ scanner.setDefaultReturnToken(
+ new Token(
+ new TextAttribute(
+ colorManager.getColor(ILisaacColor.DEFAULT))));
+ }
+ return scanner;
+ }
+
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+
+ LisaacDamagerRepairer dr = new LisaacDamagerRepairer(getLisaacScanner());
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ NonRuleBasedDamagerRepairer ndr =
+ new NonRuleBasedDamagerRepairer(colorManager.getToken(ILisaacColor.PREF_COMMENT, ILisaacColor.PREF_NORMAL));
+ reconciler.setDamager(ndr, LisaacPartitionScanner.LISAAC_COMMENT);
+ reconciler.setRepairer(ndr, LisaacPartitionScanner.LISAAC_COMMENT);
+
+ ndr = new NonRuleBasedDamagerRepairer(colorManager.getToken(ILisaacColor.PREF_STRING, ILisaacColor.STYLE_STRING));
+ reconciler.setDamager(ndr, LisaacPartitionScanner.LISAAC_STRING);
+ reconciler.setRepairer(ndr, LisaacPartitionScanner.LISAAC_STRING);
+
+ ndr = new NonRuleBasedDamagerRepairer(colorManager.getToken(ILisaacColor.PREF_CHARACTER, ILisaacColor.PREF_LOCAL_SLOT));
+ reconciler.setDamager(ndr, LisaacPartitionScanner.LISAAC_CHARACTERS);
+ reconciler.setRepairer(ndr, LisaacPartitionScanner.LISAAC_CHARACTERS);
+
+ ndr = new NonRuleBasedDamagerRepairer(colorManager.getToken2(ILisaacColor.PREF_EXTERNAL, ILisaacColor.PREF_LOCAL_SLOT));
+ reconciler.setDamager(ndr, LisaacPartitionScanner.LISAAC_EXTERNAL);
+ reconciler.setRepairer(ndr, LisaacPartitionScanner.LISAAC_EXTERNAL);
+
+ return reconciler;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getQuickAssistAssistant(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ /* public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
+ // create a content assistant:
+
+ QuickAssistAssistant assistant = new QuickAssistAssistant();
+ assistant.setQuickAssistProcessor(new LisaacQuickAssistProcessor());
+ assistant.setStatusLineVisible(true);
+ assistant.setStatusMessage("Lisaac QuickFix");
+
+
+ assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
+
+
+ return assistant;
+ }
+*/
+ /*
+ public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer){
+ QuickAssistAssistant qaa = new QuickAssistAssistant();
+ qaa.setQuickAssistProcessor(new LisaacQuickAssistProcessor());
+ qaa.setStatusLineVisible(true);
+ qaa.setStatusMessage("Lisaac QuickFix");
+ return qaa;
+ }*/
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDamagerRepairer.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDamagerRepairer.java
new file mode 100644
index 0000000..6589696
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDamagerRepairer.java
@@ -0,0 +1,60 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.jface.text.rules.Token;
+
+public class LisaacDamagerRepairer extends DefaultDamagerRepairer{
+
+ public LisaacDamagerRepairer(ITokenScanner scanner) {
+ super(scanner);
+ }
+
+ /*
+ * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
+ */
+ public void createPresentation(TextPresentation presentation, ITypedRegion region) {
+
+ if (fScanner == null) {
+ // will be removed if deprecated constructor will be removed
+ addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
+ return;
+ }
+
+ int lastStart= region.getOffset();
+ int length= 0;
+ boolean firstToken= true;
+ IToken lastToken= Token.UNDEFINED;
+ TextAttribute lastAttribute= getTokenTextAttribute(lastToken);
+
+ fScanner.setRange(fDocument, lastStart, region.getLength());
+
+ while (true) {
+ IToken token= fScanner.nextToken();
+ if (token.isEOF())
+ break;
+
+ // define text attribute for this token
+ TextAttribute attribute= getTokenTextAttribute(token);
+ if (lastAttribute != null && lastAttribute.equals(attribute)) {
+ length += fScanner.getTokenLength();
+ firstToken= false;
+ } else {
+ if (!firstToken)
+ addRange(presentation, lastStart, length, lastAttribute);
+ firstToken= false;
+ lastToken= token;
+ lastAttribute= attribute;
+ lastStart= fScanner.getTokenOffset();
+ length= fScanner.getTokenLength();
+ }
+ }
+
+ // process last token
+ addRange(presentation, lastStart, length, lastAttribute);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDocumentProvider.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDocumentProvider.java
new file mode 100644
index 0000000..7fdf706
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDocumentProvider.java
@@ -0,0 +1,32 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+
+/**
+ * Handle the creation of lisaac document.<br>
+ * Attach lisaac partitioning to this documents.
+ */
+public class LisaacDocumentProvider extends FileDocumentProvider {
+
+ protected IDocument createDocument(Object element) throws CoreException {
+ IDocument document = super.createDocument(element);
+ if (document != null) {
+ IDocumentPartitioner partitioner =
+ new FastPartitioner(
+ new LisaacPartitionScanner(),
+ new String[] {
+ LisaacPartitionScanner.LISAAC_DEFAULT,
+ LisaacPartitionScanner.LISAAC_COMMENT,
+ LisaacPartitionScanner.LISAAC_STRING,
+ LisaacPartitionScanner.LISAAC_CHARACTERS,
+ LisaacPartitionScanner.LISAAC_EXTERNAL});
+ partitioner.connect(document);
+ document.setDocumentPartitioner(partitioner);
+ }
+ return document;
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDoubleClickStrategy.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDoubleClickStrategy.java
new file mode 100644
index 0000000..7aa3ea7
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacDoubleClickStrategy.java
@@ -0,0 +1,56 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.*;
+
+public class LisaacDoubleClickStrategy implements ITextDoubleClickStrategy {
+ protected ITextViewer fText;
+
+ public void doubleClicked(ITextViewer part) {
+ int pos = part.getSelectedRange().x;
+
+ if (pos < 0)
+ return;
+
+ fText = part;
+ selectWord(pos);
+ }
+
+ protected boolean selectWord(int caretPos) {
+ IDocument doc = fText.getDocument();
+ int startPos, endPos;
+
+ try {
+ int pos = caretPos;
+ char c;
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+ startPos = pos;
+ pos = caretPos;
+ int length = doc.getLength();
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+ endPos = pos;
+ selectRange(startPos, endPos);
+ return true;
+
+ } catch (BadLocationException x) {
+ }
+ return false;
+ }
+
+ private void selectRange(int startPos, int stopPos) {
+ int offset = startPos + 1;
+ int length = stopPos - offset;
+ fText.setSelectedRange(offset, length);
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacEditor.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacEditor.java
new file mode 100644
index 0000000..e11fb81
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacEditor.java
@@ -0,0 +1,41 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+
+/**
+ * Main class for the Lisaac editor
+ * @author Damien Bouvarel
+ */
+public class LisaacEditor extends AbstractLisaacEditor {
+
+ public LisaacEditor() {
+ super();
+ }
+
+ public void refreshPresentation() {
+ super.refreshPresentation();
+
+ // refresh folding
+ boolean doFold = LisaacPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_LISAAC_FOLD);
+ if (! doFold) {
+ removeFoldingStructure();
+ return;
+ }
+ LisaacModel model = LisaacModel.getModel(getProject());
+ if (model != null) {
+ Prototype p;
+ try {
+ p = model.getPrototype(LisaacModel.extractPrototypeName(getFileName()));
+ if (p != null) {
+ updateFoldingStructure(p.getPositions());
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacHyperLinkDetector.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacHyperLinkDetector.java
new file mode 100644
index 0000000..5bfa51e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacHyperLinkDetector.java
@@ -0,0 +1,62 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+
+
+public class LisaacHyperLinkDetector extends AbstractHyperlinkDetector {
+
+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
+ IRegion region, boolean canShowMultipleHyperlinks) {
+
+ if (region == null || textViewer == null)
+ return null;
+
+ IDocument document= textViewer.getDocument();
+ if (document == null)
+ return null;
+
+ try {
+ int offset= region.getOffset();
+
+ IRegion wordRegion = selectWord(document, offset);
+ String prototypeString = document.get(wordRegion.getOffset(), wordRegion.getLength());
+
+ return new IHyperlink[] {new PrototypeHyperLink(wordRegion, prototypeString)};
+
+ } catch (BadLocationException e) {
+ return null;
+ }
+ }
+
+ protected IRegion selectWord(IDocument doc, int caretPos) throws BadLocationException {
+ int startPos, endPos;
+
+ int pos = caretPos;
+ char c;
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+ startPos = pos+1;
+ pos = caretPos;
+ int length = doc.getLength();
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+ endPos = pos;
+ return new Region(startPos, endPos - startPos);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacPartitionScanner.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacPartitionScanner.java
new file mode 100644
index 0000000..8a224af
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacPartitionScanner.java
@@ -0,0 +1,37 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.rules.*;
+
+
+/**
+ * Define rules to allow document partitioning.<br>
+ * We have two types of partition: lisaac code and lisaac comments.
+ */
+
+class LisaacPartitionScanner extends RuleBasedPartitionScanner {
+ public final static String LISAAC_COMMENT = "__lisaac_comment";
+ public final static String LISAAC_STRING = "__lisaac_string";
+ public final static String LISAAC_CHARACTERS = "__lisaac_characters";
+ public final static String LISAAC_EXTERNAL = "__lisaac_external";
+ public final static String LISAAC_DEFAULT = "__lisaac_default";
+
+ public LisaacPartitionScanner() {
+
+ IToken comment = new Token(LISAAC_COMMENT);
+ IToken string = new Token(LISAAC_STRING);
+ IToken chars = new Token(LISAAC_CHARACTERS);
+ IToken external = new Token(LISAAC_EXTERNAL);
+
+ IPredicateRule[] rules = new IPredicateRule[5];
+
+ rules[0] = new MultiLineRule("\"", "\"", string, '\\');
+ rules[1] = new SingleLineRule("'", "'", chars, '\\');
+ rules[2] = new MultiLineRule("`", "`", external, '\\');
+
+ rules[3] = new MultiLineRule("/*", "*/", comment);
+ rules[4] = new EndOfLineRule("//", comment);
+
+ setPredicateRules(rules);
+ }
+}
+
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacResourceDecorator.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacResourceDecorator.java
new file mode 100644
index 0000000..8e9babe
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacResourceDecorator.java
@@ -0,0 +1,94 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.lisaac.ldt.LisaacPlugin;
+
+/**
+ * Handle image decoration in Navigator View
+ */
+public class LisaacResourceDecorator implements ILightweightLabelDecorator {
+
+ private static ImageDescriptor OVERLAY_ERROR = LisaacPlugin.getImageDescriptor("/icons/error_co.gif");
+ private static ImageDescriptor OVERLAY_WARNING = LisaacPlugin.getImageDescriptor("/icons/warning_co.gif");
+
+ private static ImageDescriptor OVERLAY_SOURCE_FOLDER = LisaacPlugin.getImageDescriptor("/icons/source-folder.gif");
+ private static ImageDescriptor OVERLAY_LIB = LisaacPlugin.getImageDescriptor("/icons/library.gif");
+
+ public static String SOURCE_FOLDER_PROPERTY = "source_folder";
+ public static String LIB_PROPERTY = "lib";
+
+ public void decorate(Object element, IDecoration decoration) {
+ if (element instanceof IResource) {
+ int type;
+ try {
+ type = getTypeFromMarkers((IResource) element);
+ if (type == 1) {
+ decoration.addOverlay(OVERLAY_WARNING);
+ } else if (type == 2) {
+ decoration.addOverlay(OVERLAY_ERROR);
+ }
+ if (element instanceof IFolder) {
+ String sourceFolder = ((IResource) element).getPersistentProperty(
+ new QualifiedName("", SOURCE_FOLDER_PROPERTY));
+ if (sourceFolder != null && sourceFolder != "") {
+ decoration.addOverlay(OVERLAY_SOURCE_FOLDER);
+ } else {
+ String lib = ((IResource) element).getPersistentProperty(
+ new QualifiedName("", LIB_PROPERTY));
+ if (lib != null && lib != "") {
+ decoration.addOverlay(OVERLAY_LIB);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private int getTypeFromMarkers(IResource res) throws CoreException {
+ if (res == null || !res.isAccessible()) {
+ return 0;
+ }
+ int markerType = 0;
+
+ IMarker[] markers = res.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ if (markers != null) {
+ for (int i = 0; i < markers.length && (markerType != 2); i++) {
+ IMarker curr = markers[i];
+
+ int priority = curr.getAttribute(IMarker.SEVERITY, -1);
+ if (priority == IMarker.SEVERITY_WARNING) {
+ markerType = 1;
+ } else if (priority == IMarker.SEVERITY_ERROR) {
+ markerType = 2;
+ }
+ }
+ }
+ return markerType;
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ // TODO refresh decorator on marker update
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacScanner.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacScanner.java
new file mode 100644
index 0000000..b210d71
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacScanner.java
@@ -0,0 +1,334 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.rules.*;
+import org.lisaac.ldt.model.ILisaacModel;
+
+class LisaacWhitespaceDetector implements IWhitespaceDetector {
+ public boolean isWhitespace(char c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ // return c.isWhitespace();
+ }
+}
+
+class LisaacPrototypeDetector implements IWordDetector {
+ public boolean isWordPart(char c) {
+ return (Character.isLetter(c) && Character.isUpperCase(c))
+ || Character.isDigit(c) || c == '_';
+ }
+
+ public boolean isWordStart(char c) {
+ return (Character.isLetter(c) && Character.isUpperCase(c)) || c == '_';
+ }
+}
+
+class LisaacNumberDetector implements IWordDetector {
+ public boolean isWordPart(char c) {
+ return Character.isLetterOrDigit(c);
+ }
+
+ public boolean isWordStart(char c) {
+ return Character.isDigit(c);
+ }
+}
+
+class LisaacKeywordDetector implements IWordDetector {
+ public boolean isWordPart(char c) {
+ return Character.isLetter(c) && Character.isLowerCase(c);
+ }
+
+ public boolean isWordStart(char c) {
+ return Character.isLetter(c) && Character.isUpperCase(c);
+ }
+}
+
+class LisaacWordDetector implements IWordDetector {
+ public boolean isWordPart(char c) {
+ return (Character.isLetter(c) && Character.isLowerCase(c))
+ || Character.isDigit(c) || c == '_';
+ }
+
+ public boolean isWordStart(char c) {
+ return (Character.isLetter(c) && Character.isLowerCase(c)) || c == '_';
+ }
+}
+
+/**
+ * Lisaac code scanner.<br>
+ * Scan a range of a document into tokens, the scanner is used by the repairer
+ * to create the text presentation.
+ */
+public class LisaacScanner extends RuleBasedScanner {
+
+ // Lisaac tokens
+ private IToken stringToken;
+ private IToken characterToken;
+ private IToken numberToken;
+ private IToken prototypeToken;
+ private IToken prototypeStyleToken;
+ private IToken keywordToken;
+ private IToken localVariableToken;
+ private IToken operatorToken;
+ private IToken externalToken;
+ private IToken undefinedToken;
+
+ /**
+ * Creates a new Lisaac scanner.
+ */
+ public LisaacScanner(ColorManager manager) {
+ /*
+ * Create lisaac tokens.
+ */
+
+ stringToken = manager.getToken(ILisaacColor.PREF_STRING, ILisaacColor.STYLE_STRING);
+ characterToken = manager.getToken(ILisaacColor.PREF_CHARACTER, ILisaacColor.STYLE_CHARACTER);
+ numberToken = manager.getToken(ILisaacColor.PREF_NUMBER, ILisaacColor.STYLE_NUMBER);
+ prototypeToken = manager.getToken(ILisaacColor.PREF_PROTOTYPE, ILisaacColor.STYLE_PROTOTYPE);
+ prototypeStyleToken = manager.getToken(ILisaacColor.PREF_PROTOTYPE_STYLE, ILisaacColor.STYLE_PROTOTYPE_STYLE);
+ keywordToken = manager.getToken(ILisaacColor.PREF_KEYWORD, ILisaacColor.STYLE_KEYWORD);
+ localVariableToken = manager.getToken(ILisaacColor.PREF_LOCAL_SLOT, ILisaacColor.STYLE_LOCAL_SLOT);
+ operatorToken = manager.getToken(ILisaacColor.PREF_OPERATOR, ILisaacColor.STYLE_OPERATOR);
+ externalToken = manager.getToken2(ILisaacColor.PREF_EXTERNAL, ILisaacColor.PREF_LOCAL_SLOT);
+
+ undefinedToken = manager.getToken(ILisaacColor.PREF_SLOT, ILisaacColor.STYLE_SLOT);
+ //new Token(getAttribute(ILisaacColor.UNDEFINED));
+
+ /*
+ * Create basic lisaac rules.
+ */
+ IRule[] rules = new IRule[5];
+
+ // Add rule for processing strings
+ // rules[0] = new LisaacPatternRule("\"", "\"", stringToken, '\\', false, true, true);// double
+ // rules[0] = new PatternRule("'", "'", characterToken, '\\', true, true, true);// simple
+
+ // Add generic whitespace rule.
+ rules[0] = new WhitespaceRule(new LisaacWhitespaceDetector());
+
+ // keywords rule
+ WordRule wr = new WordRule(new LisaacKeywordDetector(), Token.UNDEFINED);
+ String[] keywords = ILisaacModel.keywords;
+ for (int i = 0; i < keywords.length; i++) {
+ wr.addWord(keywords[i], keywordToken);
+ }
+ rules[1] = wr;
+
+ // prototype rule
+ rules[2] = new WordRule(new LisaacPrototypeDetector(), prototypeToken);
+
+ // simple lisaac word rule
+ //rules[5] = new WordRule(new LisaacWordDetector(), undefinedToken);
+ rules[3] = new LisaacWordRule(new LisaacWordDetector(), undefinedToken, localVariableToken);
+
+ // lisaac external
+ //rules[5] = new SingleLineRule("`", "`", externalToken, '\0', true);// back
+ // quotes
+
+ // number rule
+ rules[4] = new WordRule(new LisaacNumberDetector(), numberToken);
+
+ // add basic rules
+ setRules(rules);
+ }
+
+ /*
+ * @see ITokenScanner#nextToken()
+ */
+ public IToken nextToken() {
+
+ fTokenOffset = fOffset;
+ fColumn = UNDEFINED;
+
+ //
+ // Lisaac scan
+ //
+
+ // start processing basic rules first
+ if (fRules != null) {
+ for (int i = 0; i < fRules.length; i++) {
+ IToken token = (fRules[i].evaluate(this));
+ if (!token.isUndefined())
+ return token;
+ }
+ }
+
+ // none of the basic rules fired
+ char c = (char) read();
+ if (c != ICharacterScanner.EOF) {
+ if (c == '+' || c == '-') {
+ if (getColumn() == 3) {// slot style
+ return prototypeStyleToken;
+ }
+ if (detectLocalSlot()) { // local slot style
+ return prototypeStyleToken;
+ }
+ return operatorToken;// arithmetic + or -
+ }
+ if (c == '<') {// list affect
+ c = (char) read();
+ if (c == '-') {
+ return fDefaultReturnToken;
+ } else {
+ unread();
+ return operatorToken;
+ }
+ }
+ if (c == ':') {// slot affect
+ c = (char) read();
+ if (c != '=') {
+ unread();
+ if (detectBlockType()) {
+ return prototypeToken;
+ }
+ }
+ return fDefaultReturnToken;
+ }
+ if (c == '?') {// ?= affect
+ c = (char) read();
+ if (c == '=') {
+ return fDefaultReturnToken;
+ }
+ unread();
+ return operatorToken;
+ }
+ if (c == '*' || c == '/' || c == '&' || c == '$' || c == '|'
+ || c == '>' || c == '=' || c == '!' || c == '~' || c == '@'
+ || c == '#' || c == '^') {
+ return operatorToken;
+ }
+ if (c == '{' || c == '}') {
+ return operatorToken;
+ }
+ }
+
+ unread();
+ //
+ // End of Lisaac scan
+ //
+
+ if (read() == EOF)
+ return Token.EOF;
+ return fDefaultReturnToken;
+ }
+
+ private boolean readIndentifier() {
+ char c;
+ int i = 0;
+
+ do {
+ c = (char) read();
+ i++;
+ } while (c != ICharacterScanner.EOF
+ && (Character.isLetterOrDigit(c) || c == '_'));
+ unread();
+
+ return i > 1;
+ }
+
+ private void readSpace() {
+ char c;
+
+ do {
+ c = (char) read();
+ } while (c != ICharacterScanner.EOF && Character.isWhitespace(c));
+ unread();
+ }
+
+ private boolean detectLocalSlot() {
+ int oldOffset = fOffset;
+ boolean result = false;
+
+ readSpace();
+ while (readIndentifier()) {
+ readSpace();
+ char c = (char) read();
+ if (c == ICharacterScanner.EOF)
+ break;
+
+ if (c == ':') {
+ result = true;
+ break;
+ }
+ if (c != ',')
+ break;
+
+ readSpace();
+ }
+ fOffset = oldOffset;// unread all
+ fColumn = UNDEFINED;
+ return result;
+ }
+
+ private boolean detectBlockType() {
+ int oldOffset = fOffset;
+ boolean result = false;
+
+ readSpace();
+ char c = (char) read();
+ if (c != ICharacterScanner.EOF && c == '{') {
+ int level = 1;
+ do {
+ c = (char) read();
+ if (c != ICharacterScanner.EOF) {
+ if (c == '{') {
+ level++;
+ } else if (c == '}') {
+ level--;
+
+ } else if (c == '\n' || c == '\r') {
+ break; // no multiline type
+
+ } else if (((int)c) == 65535) {
+ break; // bug!
+ }
+ }
+ } while (c != ICharacterScanner.EOF && level != 0);
+
+ if (level == 0) {
+ result = true;
+ }
+ }
+ if (! result) {
+ fOffset = oldOffset;// unread all
+ fColumn = UNDEFINED;
+ }
+ return result;
+ }
+
+ public int getOffset() {
+ return fOffset;
+ }
+
+ public static boolean isPrototypeIdentifier(String word) {
+ return detectKeyword(word, new LisaacPrototypeDetector());
+ }
+
+ public static boolean isIdentifier(String word) {
+ return detectKeyword(word, new LisaacWordDetector());
+ }
+
+ public static boolean isKeywordIdentifier(String word) {
+ return detectKeyword(word, new LisaacKeywordDetector());
+ }
+
+ private static boolean detectKeyword(String word, IWordDetector detector) {
+ int i = 0;
+ char c;
+ boolean b = true;
+
+ if (word.length() > 0 && detector.isWordStart(word.charAt(0))) {
+ if (word.length() == 1) {
+ return true;
+ }
+ i = 1;
+ do {
+ c = word.charAt(i);
+ b = detector.isWordPart(c);
+ i++;
+ } while (i < word.length() && b);
+ if (! b) {
+ return false;
+ }
+ }
+ return i == word.length();
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacTextHover.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacTextHover.java
new file mode 100644
index 0000000..08bb85d
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacTextHover.java
@@ -0,0 +1,129 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextHoverExtension;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.swt.widgets.Shell;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.IVariable;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.items.Slot;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+
+public class LisaacTextHover implements ITextHover, ITextHoverExtension {
+
+ protected LisaacModel model;
+ protected String filename;
+ protected ColorManager colorManager;
+
+ public LisaacTextHover(LisaacModel model, String filename, ColorManager colorManager) {
+ super();
+ this.model = model;
+ this.filename = filename;
+ this.colorManager = colorManager;
+ }
+
+ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+ try {
+ boolean enableHover = LisaacPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_LISAAC_HOVER);
+ if (! enableHover) {
+ return null;
+ }
+
+ if (model == null) {
+ return null;
+ }
+
+ String text = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
+ if (LisaacScanner.isPrototypeIdentifier(text)) {
+ // get prototype info
+
+ Prototype prototype = model.getPrototype(text);
+ if (prototype != null) {
+ return "<I>Prototype</I> : "+prototype.getHoverInformation();
+ }
+ } else if (LisaacScanner.isIdentifier(text)) {
+ // get slot info
+
+ Prototype prototype = model.getPrototype(LisaacModel.extractPrototypeName(filename));
+ if (prototype != null) {
+ Slot slot = prototype.getSlotFromKeyword(text, prototype.openParser(), hoverRegion.getOffset());
+ if (slot != null) {
+ return "<I>Slot</I> : "+slot.getHoverInformation();
+ } else {
+ slot = prototype.getSlot(hoverRegion.getOffset());
+ IVariable variable = slot.getVariable(text, hoverRegion.getOffset());
+ if (variable != null) {
+ return variable.getHoverInformation();
+ } else {
+ // is 'text' a slot-call argument?
+ slot = prototype.lookupSlot(text);
+ if (slot != null) {
+ return "<I>Argument</I> : "+slot.getHoverInformation();
+ }
+ }
+ }
+ }
+ }
+ } catch (BadLocationException e) {
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+
+ public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+ try {
+ return selectWord(textViewer.getDocument(), offset);
+ } catch (BadLocationException e) {
+ }
+ return new Region(offset, 0);
+ }
+
+
+ /*
+ * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
+ */
+ public IInformationControlCreator getHoverControlCreator() {
+ return new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell parent) {
+ return new DefaultInformationControl(parent, "Lisaac", new HoverPresenter(colorManager));
+ }
+ };
+ }
+
+ protected IRegion selectWord(IDocument doc, int caretPos) throws BadLocationException {
+ int startPos, endPos;
+
+ int pos = caretPos;
+ char c;
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+ startPos = pos+1;
+ pos = caretPos;
+ int length = doc.getLength();
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+ endPos = pos;
+ return new Region(startPos, endPos - startPos);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/LisaacWordRule.java b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacWordRule.java
new file mode 100644
index 0000000..2a96baf
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/LisaacWordRule.java
@@ -0,0 +1,100 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.items.Slot;
+
+public class LisaacWordRule extends WordRule {
+
+ private IToken localVariableToken;
+
+ private StringBuffer fBuffer= new StringBuffer();
+
+
+ public LisaacWordRule(IWordDetector detector, IToken defaultToken, IToken localVariableToken) {
+ super(detector, defaultToken);
+ this.localVariableToken = localVariableToken;
+ }
+
+ /*
+ * @see IRule#evaluate(ICharacterScanner)
+ */
+ public IToken evaluate(ICharacterScanner scanner) {
+ IToken result = doEvaluate(scanner);
+
+ if (result == fDefaultToken) {
+ //
+ Prototype prototype = null;
+ try {
+ prototype = LisaacModel.getCurrentPrototype();
+ } catch (CoreException e1) {
+ }
+ if (prototype == null) {
+ return result;
+ }
+ //
+ int offset = ((LisaacScanner) scanner).getOffset();
+ String word = fBuffer.toString();
+
+ try {
+ Slot slot = prototype.getSlotFromKeyword(word, prototype.openParser(), offset-word.length());
+ if (slot != null) {
+ return result;
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Slot slot = prototype.getSlot(offset);
+ if (slot != null) {
+
+ // is current word a slot argument?
+ if (slot.hasArgument(word)) {
+ return localVariableToken;
+ }
+ // is current word a slot variable?
+ if (slot.hasVariableDefinition(word, offset)) {
+ return localVariableToken;
+ }
+ }
+ }
+ return result;
+ }
+
+
+ public IToken doEvaluate(ICharacterScanner scanner) {
+ int c= scanner.read();
+ if (c != ICharacterScanner.EOF && fDetector.isWordStart((char) c)) {
+ if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
+
+ fBuffer.setLength(0);
+ do {
+ fBuffer.append((char) c);
+ c= scanner.read();
+ } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
+ scanner.unread();
+
+ String buffer= fBuffer.toString();
+ IToken token= (IToken)fWords.get(buffer);
+
+ if (token != null)
+ return token;
+
+ if (fDefaultToken.isUndefined())
+ unreadBuffer(scanner);
+
+ return fDefaultToken;
+ }
+ }
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/NonRuleBasedDamagerRepairer.java b/editor/eclipse/src/org/lisaac/ldt/editors/NonRuleBasedDamagerRepairer.java
new file mode 100644
index 0000000..7984844
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/NonRuleBasedDamagerRepairer.java
@@ -0,0 +1,138 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.swt.custom.StyleRange;
+
+public class NonRuleBasedDamagerRepairer
+ implements IPresentationDamager, IPresentationRepairer {
+
+ /** The document this object works on */
+ protected IDocument fDocument;
+ /** The default text attribute if non is returned as data by the current token */
+ protected IToken colorToken;
+
+ /**
+ * Constructor for NonRuleBasedDamagerRepairer.
+ */
+ public NonRuleBasedDamagerRepairer(IToken colorToken) {
+ this.colorToken = colorToken;
+ }
+
+ /**
+ * @see IPresentationRepairer#setDocument(IDocument)
+ */
+ public void setDocument(IDocument document) {
+ fDocument = document;
+ }
+
+ /**
+ * Returns the end offset of the line that contains the specified offset or
+ * if the offset is inside a line delimiter, the end offset of the next line.
+ *
+ * @param offset the offset whose line end offset must be computed
+ * @return the line end offset for the given offset
+ * @exception BadLocationException if offset is invalid in the current document
+ */
+ protected int endOfLineOf(int offset) throws BadLocationException {
+
+ IRegion info = fDocument.getLineInformationOfOffset(offset);
+ if (offset <= info.getOffset() + info.getLength())
+ return info.getOffset() + info.getLength();
+
+ int line = fDocument.getLineOfOffset(offset);
+ try {
+ info = fDocument.getLineInformation(line + 1);
+ return info.getOffset() + info.getLength();
+ } catch (BadLocationException x) {
+ return fDocument.getLength();
+ }
+ }
+
+ /**
+ * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+ */
+ public IRegion getDamageRegion(
+ ITypedRegion partition,
+ DocumentEvent event,
+ boolean documentPartitioningChanged) {
+ if (!documentPartitioningChanged) {
+ try {
+
+ IRegion info =
+ fDocument.getLineInformationOfOffset(event.getOffset());
+ int start = Math.max(partition.getOffset(), info.getOffset());
+
+ int end =
+ event.getOffset()
+ + (event.getText() == null
+ ? event.getLength()
+ : event.getText().length());
+
+ if (info.getOffset() <= end
+ && end <= info.getOffset() + info.getLength()) {
+ // optimize the case of the same line
+ end = info.getOffset() + info.getLength();
+ } else
+ end = endOfLineOf(end);
+
+ end =
+ Math.min(
+ partition.getOffset() + partition.getLength(),
+ end);
+ return new Region(start, end - start);
+
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return partition;
+ }
+
+ /**
+ * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
+ */
+ public void createPresentation(
+ TextPresentation presentation,
+ ITypedRegion region) {
+
+ TextAttribute attr = (TextAttribute) colorToken.getData();
+ addRange(
+ presentation,
+ region.getOffset(),
+ region.getLength(),
+ attr);
+ }
+
+ /**
+ * Adds style information to the given text presentation.
+ *
+ * @param presentation the text presentation to be extended
+ * @param offset the offset of the range to be styled
+ * @param length the length of the range to be styled
+ * @param attr the attribute describing the style of the range to be styled
+ */
+ protected void addRange(
+ TextPresentation presentation,
+ int offset,
+ int length,
+ TextAttribute attr) {
+ if (attr != null)
+ presentation.addStyleRange(
+ new StyleRange(
+ offset,
+ length,
+ attr.getForeground(),
+ attr.getBackground(),
+ attr.getStyle()));
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/editors/PrototypeHyperLink.java b/editor/eclipse/src/org/lisaac/ldt/editors/PrototypeHyperLink.java
new file mode 100644
index 0000000..7fea1c5
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/editors/PrototypeHyperLink.java
@@ -0,0 +1,181 @@
+package org.lisaac.ldt.editors;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.ide.IDE;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.items.IVariable;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.items.Slot;
+
+
+
+public class PrototypeHyperLink implements IHyperlink {
+
+ private String fPrototypeString;
+ private IRegion fRegion;
+
+ /**
+ * Creates a new Prototype hyperlink.
+ * @param region
+ * @param urlString
+ */
+ public PrototypeHyperLink(IRegion region, String string) {
+ fRegion= region;
+ fPrototypeString= string;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
+ */
+ public IRegion getHyperlinkRegion() {
+ return fRegion;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#open()
+ */
+ public void open() {
+ if (fPrototypeString != null) {
+ IProject project = null;
+ final IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ project = ((LisaacEditor)part).getProject();
+ }
+ if (part instanceof LipEditor) {
+ return;
+ }
+
+ if (project != null) {// open 'prototype' in editor, select 'slot' at 'position'
+ Prototype prototype = null;
+ Slot slot = null;
+ Position position = null;
+
+ LisaacModel model = LisaacModel.getModel(project);
+
+ if (LisaacScanner.isPrototypeIdentifier(fPrototypeString)) {
+ // prototype hyperlink
+ try {
+ prototype = model.getPrototype(fPrototypeString);
+ } catch (CoreException e) {
+ return;
+ }
+ } else {
+
+ // Slot Hyperlink
+ try {
+ prototype = LisaacModel.getCurrentPrototype();
+ slot = prototype.getSlotFromKeyword(fPrototypeString, prototype.openParser(), fRegion.getOffset());
+
+ } catch (CoreException e) {
+ return;
+ }
+ if (slot != null) {
+ // slot hyperlink
+ prototype = slot.getPrototype();
+ position = slot.getPosition();
+ } else {
+
+ // variable hyperlink
+ IVariable variable = null;
+ slot = prototype.getSlot(fRegion.getOffset());
+ if (slot != null) {
+ variable = slot.getVariable(fPrototypeString, fRegion.getOffset());
+ }
+ if (variable != null) {
+ Position p = variable.getPosition();
+ int len = fPrototypeString.length();
+ if (p.length > 0) {
+ len = p.length;
+ }
+ position = new Position(0, 0, p.offset-len, len);
+ } else {
+ // is 'text' a slot-call argument?
+ slot = prototype.lookupSlot(fPrototypeString);
+ if (slot != null) {
+ prototype = slot.getPrototype();
+ position = slot.getPosition();
+ } else {
+ prototype = null;
+ }
+ }
+ }
+ }
+ if (prototype != null) {
+ final IProject p = project;
+ final String filename = prototype.getFileName();
+ final String prototypePath = prototype.getModel().getPathManager().getFullPath(prototype.getName());
+ final Position selectPosition = position;
+
+ part.getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = w.getActivePage();
+ if (page == null) {
+ return;
+ }
+
+ if (prototypePath != null) {
+ IPath location = new Path(prototypePath);
+ IPath projectLocation = p.getLocation();
+ IFile file = null;
+
+ if (projectLocation.isPrefixOf(location)) {
+ // the file is inside the workspace
+ location = location.removeFirstSegments(projectLocation.segmentCount());
+ file = p.getFile(location);
+ } else {
+ // file is outside workspace : search in /lib
+ IContainer lib = p.getFolder("lib");
+ if (lib == null) {
+ lib = p;
+ }
+ file = lib.getFile(new Path(filename));
+ }
+
+ try {
+ IDE.openEditor(page, file);
+ if (selectPosition != null) {
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ ((LisaacEditor)part).selectAndReveal(selectPosition.offset, selectPosition.length);
+ }
+ }
+ } catch (CoreException e) {
+ // TODO open editor error
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+ }
+ fPrototypeString = null;
+ }
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return fPrototypeString;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
+ */
+ public String getTypeLabel() {
+ return null;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfiguration.java b/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfiguration.java
new file mode 100644
index 0000000..18a5e62
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfiguration.java
@@ -0,0 +1,119 @@
+package org.lisaac.ldt.launch;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.Prototype;
+
+
+public class LaunchConfiguration implements ILaunchConfigurationDelegate {
+
+ public static final String TYPE_ID = "org.lisaac.ldt.launchConfiguration";
+
+ protected LisaacCompiler compiler;
+
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+ // get project to run
+ String projectName = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROJECT, "");
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ // get run informations
+ String mainPrototype = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROTOTYPE, "main.li");
+ String programArguments = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_ARGUMENTS, "");
+
+ boolean doAlwaysCompile = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_COMPILER, true);
+ boolean doRun = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROGRAM, true);
+ boolean hasCompiled = false;
+
+ int index = mainPrototype.lastIndexOf('/');
+ if (index != -1) {
+ mainPrototype = mainPrototype.substring(index+1);
+ }
+
+ LisaacModel model = LisaacModel.getModel(project);
+ if (model != null) {
+ Prototype main = model.getPrototype(LisaacModel.extractPrototypeName(mainPrototype));
+ if (main == null || main.getSlot("main") == null) {
+ MessageDialog.openInformation(
+ null,
+ "Lisaac Plug-in",
+ mainPrototype+ " : Slot 'main' is missing.");
+ monitor.done();
+ return;
+ }
+ String outputName = main.getName().toLowerCase();
+ monitor.worked(5);
+
+ // 1. Compile project
+ if ((!doAlwaysCompile && model.needCompilation()) || doAlwaysCompile) {
+ compiler = new LisaacCompiler(model, mainPrototype, outputName, "make.lip");
+
+ // options
+ int count = 0;
+ String option;
+ do {
+ option = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_OPTION+count, "");
+ if (option != null && ! option.equals("")) {
+ compiler.addOption("-"+option);
+
+ // run / debug hack
+ if (option.compareTo(ILisaacModel.slot_debug_mode) == 0) {
+ compiler.addOption(mode);
+ } else {
+ String optionArg = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_OPTION_ARG+count, "");
+ if (! optionArg.equals("")) {
+ compiler.addOption(optionArg);
+ }
+ }
+ }
+ count++;
+ } while (option != null && ! option.equals(""));
+
+ // compile & launch project;
+ IContainer output = compiler.launchInConsole(launch, project, monitor);
+ if (output == null) {
+ MessageDialog.openInformation(
+ null,
+ "Lisaac Plug-in",
+ "Compilation Error!");
+ }
+ monitor.worked(50);
+
+ //
+ hasCompiled = true;
+ model.setCompiled(true);
+ monitor.worked(1);
+ }
+
+ // 2. Run program
+ if (doRun && !hasCompiled) {
+ IContainer bin = project.getFolder("bin");
+ if (bin == null) {
+ bin = project;
+ }
+ IFile executable = bin.getFile(new Path(outputName));
+ if (executable.exists()) {
+ String[] commandLine = {executable.getLocation().toString(), programArguments};
+ LisaacLauncher.executeCommandInConsole(launch, monitor, bin, commandLine, null);
+ } else {
+ model.setCompiled(false);
+ }
+ }
+ }
+ monitor.done();
+ }
+
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfigurationTab.java b/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfigurationTab.java
new file mode 100644
index 0000000..1f65a7b
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfigurationTab.java
@@ -0,0 +1,484 @@
+package org.lisaac.ldt.launch;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.ResourceSelectionDialog;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.lip.LIP;
+import org.lisaac.ldt.model.lip.LIPSlotCode;
+
+
+public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
+
+ public static final String LISAAC_LAUNCH_PROJECT = "launchProject"; //$NON-NLS-1$
+
+ public static final String LISAAC_LAUNCH_PROTOTYPE = "mainPrototype"; //$NON-NLS-1$
+ public static final String LISAAC_LAUNCH_COMPILER = "launchCompiler"; //$NON-NLS-1$
+
+ public static final String LISAAC_LAUNCH_PROGRAM = "launchProgram"; //$NON-NLS-1$
+ public static final String LISAAC_LAUNCH_ARGUMENTS = "programArguments"; //$NON-NLS-1$
+
+ public static final String LISAAC_LAUNCH_OPTION = "lipOption"; //$NON-NLS-1$
+ public static final String LISAAC_LAUNCH_OPTION_ARG = "lipOptionARG"; //$NON-NLS-1$
+
+ // Project UI widget.
+ private Text projectText;
+ private Text mainPrototypeText;
+ private Table lipTable;
+
+ // associated lip
+ private LIP lipCode;
+
+ private Button doLaunchCompiler;
+
+ private Button doLaunchProgram;
+ private Text argumentsText;
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Font font = parent.getFont();
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayout topLayout = new GridLayout();
+ topLayout.numColumns = 1;
+ comp.setLayout(topLayout);
+
+ // Project Options
+ Group projComp = new Group(comp, SWT.SHADOW_IN);
+ projComp.setText(LisaacMessages.getString("LaunchConfigurationTab.6")); //$NON-NLS-1$
+ GridLayout projLayout = new GridLayout();
+ projLayout.numColumns = 3;
+ projLayout.marginHeight = 0;
+ projLayout.marginWidth = 0;
+ projComp.setLayout(projLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ projComp.setLayoutData(gd);
+ projComp.setFont(font);
+
+ Label fProjLabel = new Label(projComp, SWT.NONE);
+ fProjLabel.setText(LisaacMessages.getString("LaunchConfigurationTab.7")); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ fProjLabel.setLayoutData(gd);
+ fProjLabel.setFont(font);
+
+ projectText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ projectText.setLayoutData(gd);
+ projectText.setFont(font);
+ this.projectText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ Button browseButton = new Button(projComp, SWT.PUSH);
+ browseButton.setText(LisaacMessages.getString("LaunchConfigurationTab.9")); //$NON-NLS-1$
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ gd.horizontalSpan = 1;
+ browseButton.setLayoutData(gd);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowseContainer(projectText);
+ }
+ });
+
+ Label label = new Label(projComp, SWT.NONE);
+ label.setText(LisaacMessages.getString("LaunchConfigurationTab.8")); //$NON-NLS-1$
+ gd = new GridData();
+ label.setLayoutData(gd);
+ label.setFont(font);
+
+ mainPrototypeText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ mainPrototypeText.setLayoutData(gd);
+ mainPrototypeText.setFont(font);
+ mainPrototypeText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ browseButton = new Button(projComp, SWT.PUSH);
+ browseButton.setText(LisaacMessages.getString("LaunchConfigurationTab.9")); //$NON-NLS-1$
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ browseButton.setLayoutData(gd);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowseFile(mainPrototypeText);
+ }
+ });
+
+ Label separator = new Label (comp, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // compiler options
+ Group compilerOptions = new Group(comp, SWT.SHADOW_IN);
+ compilerOptions.setText(LisaacMessages.getString("LaunchConfigurationTab.12")); //$NON-NLS-1$
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 3;
+ compilerOptions.setLayout(gl);
+ gd = new GridData(GridData.FILL_BOTH);
+ compilerOptions.setLayoutData(gd);
+
+ doLaunchCompiler = new Button(compilerOptions, SWT.CHECK);
+ doLaunchCompiler.setText("Always Compile (cannot run program)");
+ doLaunchCompiler.setSelection(false);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ doLaunchCompiler.setLayoutData(gd);
+ doLaunchCompiler.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ doLaunchProgram.setEnabled(! doLaunchCompiler.getSelection());
+ argumentsText.setEnabled(! doLaunchCompiler.getSelection());
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ // lip options
+ Composite tableGroup = new Composite(compilerOptions, SWT.NONE);
+ tableGroup.setLayout(new GridLayout(1, false));
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 1;
+ gd.verticalSpan = 3;
+ tableGroup.setLayoutData(gd);
+
+ lipTable = new Table(tableGroup, SWT.BORDER | SWT.SINGLE |
+ SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);
+ final TableColumn c1 = new TableColumn(lipTable, SWT.LEFT);
+ c1.setText(LisaacMessages.getString("LaunchConfigurationTab.15")); //$NON-NLS-1$
+ c1.setWidth(130);
+ final TableColumn c2 = new TableColumn(lipTable, SWT.LEFT);
+ c2.setText(LisaacMessages.getString("LaunchConfigurationTab.16")); //$NON-NLS-1$
+ c2.setWidth(80);
+ final TableColumn c3 = new TableColumn(lipTable, SWT.LEFT);
+ c3.setText(LisaacMessages.getString("LaunchConfigurationTab.17")); //$NON-NLS-1$
+ c3.setWidth(100);
+ lipTable.setHeaderVisible(true);
+ lipTable.setLinesVisible(true);
+ lipTable.setItemCount(4);
+ lipTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ final TableEditor editor = new TableEditor(lipTable);
+ // The editor must have the same size as the cell and must
+ // not be any smaller than 50 pixels.
+ editor.horizontalAlignment = SWT.LEFT;
+ editor.grabHorizontal = true;
+ editor.minimumWidth = 50;
+
+ lipTable.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ //
+ // Clean up any previous editor control
+ Control oldEditor = editor.getEditor();
+ if (oldEditor != null)
+ oldEditor.dispose();
+
+ // Identify the selected row
+ TableItem item = (TableItem) e.item;
+ if (item == null)
+ return;
+
+ // The control that will be the editor must be a child of the
+ // Table
+ Text newEditor = new Text(lipTable, SWT.NONE);
+ newEditor.setText(item.getText(1));
+ newEditor.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent me) {
+ Text text = (Text) editor.getEditor();
+ editor.getItem().setText(1, text.getText());
+ }
+ });
+ newEditor.selectAll();
+ newEditor.setFocus();
+ editor.setEditor(newEditor, item, 1);
+ //
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.horizontalSpan = 2;
+ tableGroup.setLayoutData(gridData);
+
+ separator = new Label (comp, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // program options
+ Group programOptions = new Group(comp, SWT.SHADOW_IN);
+ programOptions.setText("Program Options"); //$NON-NLS-1$
+ gl = new GridLayout();
+ gl.numColumns = 2;
+ programOptions.setLayout(gl);
+ programOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ doLaunchProgram = new Button(programOptions, SWT.CHECK);
+ doLaunchProgram.setText("Run the program");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ doLaunchProgram.setLayoutData(gd);
+ doLaunchProgram.setSelection(true);
+ doLaunchProgram.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (argumentsText != null) {
+ argumentsText.setEnabled(doLaunchProgram.getSelection());
+ }
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ label = new Label(programOptions, SWT.NONE);
+ label.setText("Command-Line:");
+ label.setLayoutData(new GridData(GridData.BEGINNING));
+
+ argumentsText = new Text(programOptions, SWT.SINGLE | SWT.BORDER);
+ argumentsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ argumentsText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return LisaacMessages.getString("LaunchConfigurationTab.18"); //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ String projectName = configuration.getAttribute(LISAAC_LAUNCH_PROJECT, ""); //$NON-NLS-1$
+ projectText.setText(projectName);
+
+ String mainPrototypeName = configuration.getAttribute(LISAAC_LAUNCH_PROTOTYPE, ""); //$NON-NLS-1$
+ mainPrototypeText.setText(mainPrototypeName);
+
+ boolean check = configuration.getAttribute(LISAAC_LAUNCH_COMPILER, false);
+ doLaunchCompiler.setSelection(check);
+
+ check = configuration.getAttribute(LISAAC_LAUNCH_PROGRAM, true);
+ doLaunchProgram.setSelection(check);
+
+ String commandLine = configuration.getAttribute(LISAAC_LAUNCH_ARGUMENTS, ""); //$NON-NLS-1$
+ argumentsText.setText(commandLine);
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ LisaacModel model = LisaacModel.getModel(project);
+ if (model != null) {
+ lipCode = model.getLipCode();
+ if (lipCode != null) {
+ // update table
+ lipTable.setItemCount(0);
+ for (int i=0; i<lipCode.getMethodCount(); i++) {
+ LIPSlotCode method = lipCode.getMethod(i);
+ if (method.isPublic()) {
+ String methodComment = method.getComment();
+ if (methodComment == null) {
+ methodComment = LisaacMessages.getString("LaunchConfigurationTab.23"); //$NON-NLS-1$
+ }
+ methodComment = methodComment.replaceAll("\t", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ methodComment = methodComment.replaceAll("\n", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (! lipTable.isDisposed()) {
+ TableItem item = new TableItem (lipTable, SWT.NONE);
+ item.setText(0, method.getName());
+ item.setText(2, methodComment);
+
+ if (method.getName().compareTo(ILisaacModel.slot_debug_mode) == 0) {
+ item.setChecked(true);
+ // TODO read-only -> changed in launch()
+ item.setText(1, getLaunchConfigurationDialog().getMode());
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (CoreException ce) {
+ // Log the error to the Eclipse log.
+ IStatus status = new Status(IStatus.ERROR,
+ LisaacPlugin.PLUGIN_ID, 0,
+ "Error in Lisaac launch: " + //$NON-NLS-1$
+ ce.getMessage(), ce);
+ LisaacPlugin.log(status);
+ }
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(LISAAC_LAUNCH_PROJECT, projectText.getText());
+ configuration.setAttribute(LISAAC_LAUNCH_PROTOTYPE, mainPrototypeText.getText());
+
+ configuration.setAttribute(LISAAC_LAUNCH_COMPILER, doLaunchCompiler.getSelection());
+ configuration.setAttribute(LISAAC_LAUNCH_PROGRAM, doLaunchProgram.getSelection());
+ configuration.setAttribute(LISAAC_LAUNCH_ARGUMENTS, argumentsText.getText());
+
+ TableItem[] options = lipTable.getItems();
+ if (options != null && options.length > 0) {
+ for (int i=0; i<options.length; i++) {
+ configuration.removeAttribute(LISAAC_LAUNCH_OPTION+i);// remove options
+ configuration.removeAttribute(LISAAC_LAUNCH_OPTION_ARG+i);// remove options
+ }
+ int count = 0;
+ for (int i=0; i<options.length; i++) {
+ TableItem item = options[i];
+ if (item.getChecked()) {
+ configuration.setAttribute(LISAAC_LAUNCH_OPTION+count, item.getText(0));
+ configuration.setAttribute(LISAAC_LAUNCH_OPTION_ARG+count, item.getText(1));
+ count++;
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ IProject project = getSelectedProject();
+ String projectName = ""; //$NON-NLS-1$
+ String mainPrototypeName = ""; //$NON-NLS-1$
+
+ if (project != null) {
+ projectName = project.getName();
+ mainPrototypeName = projectName + ".li"; //$NON-NLS-1$
+ }
+ configuration.setAttribute(LISAAC_LAUNCH_PROJECT, projectName);
+ configuration.setAttribute(LISAAC_LAUNCH_PROTOTYPE, mainPrototypeName);
+
+ configuration.setAttribute(LISAAC_LAUNCH_COMPILER, false);
+ configuration.setAttribute(LISAAC_LAUNCH_PROGRAM, true);
+ configuration.setAttribute(LISAAC_LAUNCH_ARGUMENTS, ""); //$NON-NLS-1$
+
+ if (lipTable != null) {
+ TableItem[] options = lipTable.getItems();
+ if (options != null && options.length > 0) {
+ for (int i=0; i<options.length; i++) {
+ configuration.removeAttribute(LISAAC_LAUNCH_OPTION+i);// remove options
+ configuration.removeAttribute(LISAAC_LAUNCH_OPTION_ARG+i);// remove options
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets the current project selected in the workbench.
+ * @return the current project selected in the workbench.
+ */
+ private IProject getSelectedProject() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if (!ss.isEmpty()) {
+ Object obj = ss.getFirstElement();
+ if (obj instanceof IResource) {
+ IResource i = (IResource) obj;
+ IProject pro = i.getProject();
+ return pro;
+ }
+ }
+ }
+ // If the editor has the focus...
+ IEditorPart part = page.getActiveEditor();
+ if (part != null) {
+ IEditorInput input = part.getEditorInput();
+ IFile file = (IFile) input.getAdapter(IFile.class);
+ return file.getProject();
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+ private void handleBrowseContainer(Text text) {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), null, false,
+ "Select Folder"); //$NON-NLS-1$
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length == 1) {
+ Object result = results[0];
+ if (result instanceof IPath) {
+ IPath ipath = (IPath) result;
+ text.setText(ipath.toString());
+ }
+ }
+ }
+ }
+
+ private void handleBrowseFile(Text text) {
+ ResourceSelectionDialog dialog = new ResourceSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Select File"); //$NON-NLS-1$
+ dialog.setInitialSelections(new Object[0]);
+ if (dialog.open() == ResourceSelectionDialog.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length == 1) {
+ Object result = results[0];
+ if (result instanceof IResource) {
+ text.setText(((IResource) result).getName());
+ }
+ }
+ }
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfigurationTabGroup.java b/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfigurationTabGroup.java
new file mode 100644
index 0000000..58e2e8d
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/launch/LaunchConfigurationTabGroup.java
@@ -0,0 +1,20 @@
+package org.lisaac.ldt.launch;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ /**
+ * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String)
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = {
+ new LaunchConfigurationTab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/launch/LisaacApplicationShortcut.java b/editor/eclipse/src/org/lisaac/ldt/launch/LisaacApplicationShortcut.java
new file mode 100644
index 0000000..1168a0f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/launch/LisaacApplicationShortcut.java
@@ -0,0 +1,98 @@
+package org.lisaac.ldt.launch;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Handle the 'Lisaac Application' run shortcut.
+ */
+public class LisaacApplicationShortcut implements ILaunchShortcut {
+
+ public LisaacApplicationShortcut() {
+ }
+
+ public void launch(ISelection selection, String mode) {
+ if(selection instanceof IStructuredSelection) {
+ Object firstSelection = ((IStructuredSelection)selection).getFirstElement();
+ if (firstSelection instanceof IFile) {
+ ILaunchConfiguration config = findLaunchConfiguration((IFile)firstSelection, mode);
+ try {
+ if(config != null)
+ config.launch(mode, null);
+ }
+ catch(CoreException coreexception) { }
+ }
+ }
+ }
+
+ public void launch(IEditorPart editor, String mode)
+ {
+ // make sure the file is saved
+ editor.getEditorSite().getPage().saveEditor(editor,true);
+ org.eclipse.ui.IEditorInput input = editor.getEditorInput();
+ ISelection selection = new StructuredSelection(input.getAdapter(org.eclipse.core.resources.IFile.class));
+ launch(selection, mode);
+ }
+
+ protected ILaunchConfiguration findLaunchConfiguration(IFile file, String mode) {
+ ILaunchConfigurationType configType = getLaunchConfigType();
+ List<ILaunchConfiguration> candidateConfigs = null;
+ try {
+ ILaunchConfiguration configs[] = getLaunchManager().getLaunchConfigurations(configType);
+ candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
+ for(int i = 0; i < configs.length; i++) {
+ ILaunchConfiguration config = configs[i];
+
+ if(config.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROTOTYPE, "").equals(file.getFullPath().lastSegment()) &&
+ config.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROJECT, "").equals(file.getProject().getFullPath().lastSegment()))
+ candidateConfigs.add(config);
+ }
+ }
+ catch(CoreException coreexception) { }
+ switch(candidateConfigs.size())
+ {
+ case 0: // '\0'
+ return createConfiguration(file);
+
+ case 1: // '\001'
+ default:
+ return (ILaunchConfiguration)candidateConfigs.get(0);
+ }
+ }
+
+ protected ILaunchConfiguration createConfiguration(IFile file)
+ {
+ ILaunchConfiguration config = null;
+ try
+ {
+ ILaunchConfigurationType configType = getLaunchConfigType();
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(file.getName()));
+ wc.setAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROJECT, file.getProject().getName());
+ wc.setAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_PROTOTYPE, file.getName());
+ config = wc.doSave();
+ }
+ catch(CoreException coreexception) { }
+ return config;
+ }
+
+ protected ILaunchConfigurationType getLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(LaunchConfiguration.TYPE_ID);
+ }
+
+ protected ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/launch/LisaacCompiler.java b/editor/eclipse/src/org/lisaac/ldt/launch/LisaacCompiler.java
new file mode 100644
index 0000000..fb3ef2a
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/launch/LisaacCompiler.java
@@ -0,0 +1,257 @@
+package org.lisaac.ldt.launch;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.jface.text.IRegion;
+import org.lisaac.ldt.builder.LisaacBuilder;
+import org.lisaac.ldt.model.AbstractLisaacParser;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.items.Prototype;
+
+public class LisaacCompiler {
+
+ protected String inputFile;
+ protected String lipFile;
+
+ protected ArrayList<String> options;
+
+ protected LisaacModel model;
+
+ protected String outputName;
+
+ // for lisaac <input_file> <lip_file> [options]
+ public LisaacCompiler(LisaacModel model, String inputFile, String outputName, String lipFile) {
+ this.inputFile = inputFile;
+ this.lipFile = lipFile;
+ this.outputName = outputName;
+ this.model = model;
+ }
+
+ // for lisaac <lip_file> --p
+ public LisaacCompiler(String lipFile) {
+ this.lipFile = lipFile;
+ }
+
+ public IContainer launchInConsole(final ILaunch launch, IProject project, IProgressMonitor monitor) throws CoreException {
+
+ String prototypePath = model.getPathManager()
+ .getFullPath(LisaacModel.extractPrototypeName(inputFile));
+
+ if (prototypePath != null) {
+ IPath location = new Path(prototypePath);
+ IPath projectLocation = project.getLocation();
+ IFile file = null;
+
+ if (projectLocation.isPrefixOf(location)) {
+ // the file is inside the workspace
+ location = location.removeFirstSegments(projectLocation.segmentCount());
+ file = project.getFile(location);
+
+ IContainer container = file.getParent();
+ if (LisaacLauncher.executeCommandInConsole(launch, monitor, container, this.toCommandLineArray(),this)) {
+ return container;
+ }
+ }
+ }
+ return null;
+ }
+
+ public Process launch(IProject project, IProgressMonitor monitor) throws CoreException {
+ return LisaacLauncher.executeCommand(monitor, project, this.toCommandLineArray());
+ }
+
+ public String[] toCommandLineArray() {
+ ArrayList<String> cmd = new ArrayList<String>();
+
+ cmd.add("lisaac ");
+ if (lipFile != null) {
+ cmd.add(lipFile);
+ }
+ if (inputFile != null) {
+ cmd.add(inputFile);
+ }
+ if (options != null) {
+ cmd.addAll(options);
+ }
+ return cmd.toArray(new String[cmd.size()]);
+ }
+
+ public String toCommandLine() {
+ StringBuffer result = new StringBuffer();
+
+ result.append("lisaac ");
+ if (lipFile != null) {
+ result.append(lipFile);
+ }
+ if (inputFile != null) {
+ result.append(" "+inputFile);
+ }
+ if (options != null) {
+ for (int i=0; i<options.size(); i++) {
+ result.append(" "+options.get(i));
+ }
+ }
+ return result.toString();
+ }
+
+ public void addOption(String option) {
+ if (options == null) {
+ options = new ArrayList<String>();
+ }
+ options.add(option);
+ }
+
+ public void moveFiles(IContainer output) throws CoreException {
+ IProject project = model.getProject();
+
+ // refresh the generated files
+ output.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ // move the generated files to bin/
+ IFolder bin = project.getFolder("bin");
+ if (! bin.exists()) {
+ bin.create(false,true,null);
+ }
+ IPath generatedPath = new Path(outputName);
+ IFile executable = output.getFile(generatedPath);
+ if (! executable.exists()) {
+ generatedPath = new Path(outputName+".exe");// FIXME platform-dependant
+ executable = output.getFile(generatedPath);
+ }
+ if (executable.exists()) {
+ IFile destFile = bin.getFile(generatedPath);
+ if (destFile.exists()) {
+ destFile.delete(true, null);
+ }
+ executable.move(bin.getFullPath().append(generatedPath), true, null);
+ }
+ moveFile(outputName+".o", output, bin);// FIXME .java, etc..
+ moveFile(outputName+".c", output, bin);
+
+ //
+ project.refreshLocal(IResource.DEPTH_INFINITE, null); // TODO usefull? try to remove
+ //
+
+ model.setCompiled(true);
+ }
+
+ private void moveFile(String filename, IContainer origin, IContainer destination) throws CoreException {
+ IPath path = new Path(filename);
+ IFile originFile = origin.getFile(path);
+
+ if (originFile.exists()) {
+ IFile destFile = destination.getFile(path);
+ if (destFile.exists()) {
+ destFile.delete(true, null);
+ }
+ originFile.move(destination.getFullPath().append(path), true, null);
+ }
+ }
+
+ public void cleanFiles() throws CoreException {
+ IContainer bin = model.getProject().getFolder("bin");
+
+ IFile executable = bin.getFile(new Path(outputName));
+ if (executable.exists()) {
+ executable.delete(true, null);
+ }
+ executable = bin.getFile(new Path(outputName+".exe"));// FIXME platform-dependant
+ if (executable.exists()) {
+ executable.delete(true, null);
+ }
+ IFile file = bin.getFile(new Path(outputName+".o"));
+ if (file.exists()) {
+ file.delete(true, null);
+ }
+ file = bin.getFile(new Path(outputName+".c")); // FIXME .java, etc..
+ if (file.exists()) {
+ file.delete(true, null);
+ }
+ }
+
+ public void showErrors(String output) throws CoreException {
+ new CompilerOutputParser(output).run(model);
+ }
+}
+
+class CompilerOutputParser extends AbstractLisaacParser {
+ public CompilerOutputParser(String contents) {
+ super(contents);
+ }
+
+ public void run(LisaacModel model) throws CoreException {
+ int startOffset = source.indexOf("--");
+ while (startOffset != -1) {
+ setPosition(startOffset+2);
+
+ if (! readCapIdentifier()) {
+ break;
+ }
+ int line, column;
+ String prototypeName;
+ String msg;
+ int severity = 0;
+
+ if (lastString.compareTo("WARNING") == 0) {
+ readWord("----------");
+ severity = 1;
+ } else if (lastString.compareTo("SYNTAX") == 0) {
+ readWord("-----------");
+ severity = 2;
+ } else if (lastString.compareTo("SEMANTIC") == 0) {
+ readWord("---------");
+ severity = 2;
+ }
+ readLine();
+ msg = new String(lastString);
+ msg = msg.replace('\r', ' ');
+ readWord("Line");
+ readInteger();
+ line = (int) lastInteger;
+ readWord("column");
+ readInteger();
+ column = (int) lastInteger;
+ readWord("in");
+ readCapIdentifier();
+ prototypeName = new String(lastString);
+
+ // add marker to file
+ Prototype prototype = model.getPrototype(prototypeName);
+ if (prototype != null) {
+ IFile file = prototype.getFile();
+ IRegion region = prototype.getRegionAt(line, column);
+
+ Position position = new Position(line, column, region.getOffset(), region.getLength());
+ LisaacBuilder.addMarker(file, msg, position, severity);
+ }
+ startOffset = source.indexOf("--", position);
+ }
+ }
+ private void readLine() {
+ if (readSpace()) {
+ string_tmp = "";
+ while (lastCharacter() != 0 && lastCharacter() != '\n') {
+ string_tmp += lastCharacter();
+ if (lastCharacter() == '\\') {
+ position = position+1;
+ readEscapeCharacter();
+ } else {
+ position = position+1;
+ }
+ }
+ position = position+1;
+ lastString = string_tmp;
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/launch/LisaacLauncher.java b/editor/eclipse/src/org/lisaac/ldt/launch/LisaacLauncher.java
new file mode 100644
index 0000000..cf76b22
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/launch/LisaacLauncher.java
@@ -0,0 +1,145 @@
+package org.lisaac.ldt.launch;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.IStreamListener;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.swt.widgets.Display;
+import org.lisaac.ldt.views.ConsoleFactory;
+import org.lisaac.ldt.views.LisaacConsole;
+
+
+public class LisaacLauncher {
+
+ public static boolean executeCommandInConsole(final ILaunch launch, IProgressMonitor monitorParent,
+ final IContainer container, final String[] commandLine, final LisaacCompiler compiler) throws CoreException {
+ // get & clear lisaac console
+ final LisaacConsole console = ConsoleFactory.getConsole();
+ console.clearConsole();
+
+ if (compiler == null) {
+ console.activate();// show console
+ }
+ final IProgressMonitor monitor = new NullProgressMonitor();
+
+ Runnable getStandardOutput = new Runnable() {
+ public void run() {
+ monitor.beginTask("Executing... ", 100);
+
+ // 1. Clean existing files
+ if (compiler != null) {
+ try {
+ compiler.cleanFiles();
+ } catch (CoreException e) {
+ }
+ monitor.worked(10);
+ }
+
+ // 2. Launch process
+ Process process = null;
+ try {
+ process = launchProcess(commandLine, container);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ monitor.worked(20);
+ if (monitor.isCanceled()) {
+ return;
+ }
+ if (process != null) {
+ monitor.setTaskName("Reading output...");
+ monitor.worked(20);
+
+ // attach process stream to Lisaac console
+ IProcess eclipseProcess = DebugPlugin.newProcess(launch,
+ process,"Lisaac Session");
+
+ // get the process output
+ final StringBuffer buffer = new StringBuffer();
+
+ IStreamListener listener = new IStreamListener() {
+ public void streamAppended(String text,
+ IStreamMonitor monitor) {
+ buffer.append(text);
+ }
+ };
+ eclipseProcess.getStreamsProxy().getOutputStreamMonitor().addListener(listener);
+ eclipseProcess.getStreamsProxy().getErrorStreamMonitor().addListener(listener);
+
+ // 3. clean files after process execution
+ if (compiler != null) {
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ }
+ try {
+ compiler.moveFiles(container);
+
+ while (! eclipseProcess.isTerminated()) {}
+ compiler.showErrors(buffer.toString());
+
+ } catch (CoreException e) {
+ }
+ }
+ }
+ monitor.done();
+ }
+ };
+ // execute action in a new thread UI safe
+ Display.getDefault().asyncExec(getStandardOutput);
+ return true;
+ }
+
+ public static Process executeCommand(IProgressMonitor monitor, IContainer container, String[] commandLine) throws CoreException {
+ monitor.beginTask("Executing...", 100);
+
+ Process process = null;
+ try {
+ process = launchProcess(commandLine, container);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ monitor.worked(20);
+ if (monitor.isCanceled()) {
+ return null;
+ }
+ return process;
+ }
+
+ /**
+ * Executes the command line at the given project location, and returns the
+ * corresponding process.
+ * @param commandLine the command line
+ * @param project the project in which the command line is executed
+ * @return the corresponding process
+ * @throws IOException if the command line can't be executed
+ */
+ public static Process launchProcess(String[] commandLine, IContainer directory) throws IOException {
+ File projectDirectory =
+ (directory != null) ? new File(directory.getLocationURI()) : null;
+
+ String cmd = concatCommandLine(commandLine);
+
+ Process process = Runtime.getRuntime().exec(cmd, null, projectDirectory);
+ return process;
+ }
+
+ private static String concatCommandLine(String[] commandLine) {
+ StringBuffer buf = new StringBuffer();
+ for (int i=0; i<commandLine.length; i++) {
+ buf.append(commandLine[i]);
+ buf.append(' ');
+ }
+ return buf.toString();
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/messages.properties b/editor/eclipse/src/org/lisaac/ldt/messages.properties
new file mode 100644
index 0000000..58c617b
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/messages.properties
@@ -0,0 +1,75 @@
+AbstractNewFileWizardPage_1=Source folder :
+AbstractNewFileWizardPage_2=Browse...
+AbstractNewFileWizardPage_3=File name :
+AbstractNewFileWizardPage_4=Select container.
+AbstractNewFileWizardPage_5=Source folder must be specified.
+AbstractNewFileWizardPage_6=File name must be specified.
+AbstractNewFileWizardPage_7=File already exists.
+LaunchConfigurationTab.10=Program Arguments
+LaunchConfigurationTab.12=Compiler Options
+LaunchConfigurationTab.13=Lisaac Path File (default : make.lip):
+LaunchConfigurationTab.14=Browse...
+LaunchConfigurationTab.15=Option
+LaunchConfigurationTab.16=Argument
+LaunchConfigurationTab.17=Description
+LaunchConfigurationTab.18=Main
+LaunchConfigurationTab.23=No comment
+LaunchConfigurationTab.6=Project Options
+LaunchConfigurationTab.7=Project:
+LaunchConfigurationTab.8=Main Prototype to run :
+LaunchConfigurationTab.9=Browse...
+LisaacBuilder.2=Build workpace...
+LisaacColoringPage.0=Lisaac Editor Syntax Coloring preferences :
+LisaacColoringPage.10=\ \ \ \ &Externals:
+LisaacColoringPage.11=\ \ \ \ &Slots:
+LisaacColoringPage.12=\ \ \ \ &Local variable:
+LisaacColoringPage.2=\ \ \ \ &Comments:
+LisaacColoringPage.3=\ \ \ \ &Prototype:
+LisaacColoringPage.4=\ \ \ \ &Slot style:
+LisaacColoringPage.5=\ \ \ \ &Keywords:
+LisaacColoringPage.6=\ \ \ \ &Characters:
+LisaacColoringPage.7=\ \ \ \ &Strings:
+LisaacColoringPage.8=\ \ \ \ &Numbers:
+LisaacColoringPage.9=\ \ \ \ &Operators:
+LisaacColoringPage.20=Bold
+LisaacColoringPage.21=Italics
+LisaacColoringPage.22=Normal
+LisaacColoringPage.23=Underline
+LisaacConfiguration_0=Lisaac Completion
+LisaacConsole.1=Lisaac Console
+LisaacEditorPage.0=&Enable Auto-Indentation
+LisaacEditorPage.1=&Enable Hovering
+LisaacEditorPage.2=Content Assist preferences
+LisaacEditorPage.3=&Enable Completion
+LisaacEditorPage.4=Auto-Activation Delay
+LisaacEditorPage.5=Enable folding
+LisaacPreferencePage.0=General settings for Lisaac Development
+LisaacPreferencePage.1=&Your name :
+LisaacPreferencePage.2=&Support for Lisaac 0.13
+LisaacProjectPropertyPage.0=Lisaac Environment Path
+LisaacProjectPropertyPage.1=Use default Lisaac Environment
+LisaacProjectPropertyPage.2=Use a project specific Lisaac Environment :
+LisaacProjectPropertyPage.3=Browse...
+LisaacProjectPropertyPage.8=Select Lisaac Environment Directory.
+NewProjectWizard_46=New Lisaac Project Wizard
+NewProjectWizard_47=New Lisaac Project
+NewProjectWizard_48=Create a lisaac project
+NewProjectWizard_49=Use default Lisaac Environment
+NewProjectWizard_50=Use a project specific Lisaac Environment :
+NewProjectWizard_51=Browse...
+NewPrototypeWizard_0=New Prototype
+NewPrototypeWizard_2=Prototype File
+NewPrototypeWizard_25=Prototype Style :
+NewPrototypeWizard_26=None
+NewPrototypeWizard_27=Expanded
+NewPrototypeWizard_28=Strict
+NewPrototypeWizard_29=Description :
+NewPrototypeWizard_3=Creates a new source file into a project
+NewPrototypeWizard_30=Inheritance :
+NewPrototypeWizard_32=Inheritance Type
+NewPrototypeWizard_34=Add...
+NewPrototypeWizard_35=Remove
+NewPrototypeWizard_36=Which slots would you like to create?
+NewPrototypeWizard_37=Main slot
+NewPrototypeWizard_38=Constructor slot
+RenamePrototype.0=Rename Prototype...
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/AbstractLisaacParser.java b/editor/eclipse/src/org/lisaac/ldt/model/AbstractLisaacParser.java
new file mode 100644
index 0000000..12b309b
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/AbstractLisaacParser.java
@@ -0,0 +1,891 @@
+package org.lisaac.ldt.model;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+
+import org.lisaac.ldt.builder.ILisaacErrorHandler;
+
+
+public class AbstractLisaacParser {
+
+ protected ILisaacErrorHandler reporter;
+
+ protected ILisaacModel model;
+
+ protected String source;
+
+ protected int position;
+
+ protected int pos_cur, pos_line, pos_col;
+ protected int begin_position;
+
+ protected String string_tmp="";
+
+
+ public Position getPosition() {
+ return getPosition(0);
+ }
+
+ public Position getPosition(int len) {
+ Position result=null;
+
+ if (position > source.length()) { // outline thread bug
+ return new Position(pos_line, pos_col, pos_cur, len);
+ }
+
+ while (pos_cur < position) {
+ if (source.charAt(pos_cur) == '\n') {
+ pos_col = 0;
+ pos_line++;
+ } else {
+ pos_col++;
+ }
+ pos_cur++;
+ }
+ if (pos_line > 32767) {
+ result = new Position(32767, pos_col, pos_cur);
+ reporter.syntaxError ("Line counter overflow.",result);
+ }
+ if (pos_col > 255) {
+ result = new Position(pos_line, 255, pos_cur);
+ reporter.syntaxError ("Column counter overflow (line too long).",result);
+ };
+ result = new Position(pos_line, pos_col, pos_cur, len);
+ return result;
+ }
+
+ public Position getLine() {
+ Position result=null;
+ int startLine = pos_cur;
+ int endLine = position+1;
+
+ while (pos_cur < position && !isEOF()) {
+ if (source.charAt(pos_cur) == '\n') {
+ pos_col = 0;
+ pos_line++;
+ startLine = pos_cur+1;
+ } else {
+ pos_col++;
+ }
+ pos_cur++;
+ }
+ if (pos_line > 32767) {
+ result = new Position(32767, pos_col, pos_cur);
+ reporter.syntaxError ("Line counter overflow.",result);
+ }
+ if (pos_col > 255) {
+ result = new Position(pos_line, 255, pos_cur);
+ reporter.syntaxError ("Column counter overflow (line too long).",result);
+ };
+ while (endLine <= source.length()-1) {
+ if (source.charAt(endLine) == '\n') {
+ break;
+ }
+ endLine++;
+ }
+ result = new Position(pos_line, pos_col, endLine, endLine - startLine);
+ return result;
+ }
+
+ public void updateLine() {
+ while (pos_cur < position) {
+ if (source.charAt(pos_cur) == '\n') {
+ pos_col = 0;
+ pos_line++;
+ } else {
+ pos_col++;
+ }
+ pos_cur++;
+ }
+ }
+
+ public int getOffset() {
+ return position;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public boolean isEOF() {
+ return position > source.length()-1;
+ }
+
+ public void setPosition(int pos) {
+ initialize();
+ position = pos;
+ }
+
+ protected long lastInteger;
+ protected String lastReal;
+ protected String lastString;
+
+ protected static String lastComment;
+ protected boolean isCatchComment;
+
+ protected boolean isParameterType;
+
+ protected void setCatchComment() {
+ isCatchComment = true;
+ lastComment = "";
+ }
+ protected void setCatchCommentOff() {
+ isCatchComment = false;
+ }
+
+ public String getLastString() {
+ return lastString;
+ }
+
+ public char lastCharacter() {
+ if (position >= source.length()) {
+ return 0;
+ }
+ return source.charAt(position);
+ }
+
+ //
+ // AMBIGU Manager.
+ //
+
+ protected int old_position;
+ protected int old_pos_cur;
+ protected int old_pos_line;
+ protected int old_pos_col;
+
+ protected void saveContext() {
+ old_position = position;
+ old_pos_cur = pos_cur;
+ old_pos_line = pos_line;
+ old_pos_col = pos_col;
+ }
+ protected void restoreContext() {
+ position = old_position;
+ pos_cur = old_pos_cur;
+ pos_line = old_pos_line;
+ pos_col = old_pos_col;
+ }
+
+ public AbstractLisaacParser(InputStream contents, ILisaacModel model) {
+ this.model = model;
+ this.reporter = model.getReporter();
+
+ // convert the input stream into string
+ try {
+ InputStreamReader reader = new InputStreamReader (contents);
+ BufferedReader buffer = new BufferedReader(reader);
+
+ StringWriter writer = new StringWriter();
+
+ String line="";
+ do {
+ line = buffer.readLine();
+ if (line != null) {
+ writer.write(line+"\n");
+ }
+ } while (line != null);
+ //
+ source = writer.toString();
+ //
+ } catch (IOException e) {
+ return; // ERROR
+ }
+ initialize();
+ }
+
+ public AbstractLisaacParser(String contents) {
+ // null reporter
+ this.reporter = new ILisaacErrorHandler() {
+ public void fatalError(String msg, Position position) {
+ }
+ public void semanticError(String msg, Position position) {
+ }
+ public void syntaxError(String msg, Position position) {
+ }
+ public void warning(String msg, Position position) {
+ }
+ public void enableErrorReport(boolean enable) {
+ }
+ };
+ source = contents;
+ initialize();
+ }
+
+ public void initialize() {
+ position = 0;
+ pos_cur = 0;
+ pos_line = 1;
+ pos_col = 0;
+ }
+
+ //
+ // Lisaac Parser
+ //
+
+ public boolean readSpace() {
+ int pos,posold;
+ int level_comment = 0;
+
+ pos = position;
+ posold = -1;
+ while (posold != position) {
+ posold = position;
+
+ // skip spaces
+ while ((lastCharacter() != 0) && (lastCharacter() <= ' ')) {
+ position++;
+ }
+ if (position < source.length()-1) {
+ // Skip C++ comment style :
+ if (lastCharacter() == '/' && source.charAt(position+1) == '/') {
+ position += 2;
+
+ if (isCatchComment)
+ lastComment += "\t";
+
+ while ((lastCharacter() != 0) && (lastCharacter() != '\n')) {
+ if (isCatchComment)
+ lastComment += lastCharacter();
+
+ lastCharacter();
+ position++;
+ }
+ if (isCatchComment)
+ lastComment += "\n";
+ }
+ }
+ if (position < source.length()-1) {
+ // Skip C comment style :
+ if (lastCharacter() == '/' && source.charAt(position+1) == '*') {
+ position += 2;
+ level_comment++;
+
+ while (lastCharacter() != 0 && level_comment != 0) {
+ if (lastCharacter() == '/' && source.charAt(position+1) == '*') {
+ position += 2;
+ level_comment++;
+ } else if (lastCharacter() == '*' && source.charAt(position+1) == '/') {
+ position += 2;
+ level_comment--;
+ } else {
+ position++;
+ }
+ }
+ if (level_comment != 0) {
+ reporter.syntaxError("End of comment not found !", getPosition());
+ }
+ }
+ }
+ }
+ // FALSE : Last character.
+ begin_position = position;
+ return (position != pos) || (lastCharacter() != 0);
+ }
+
+ public boolean readSymbol(String st) {
+ int posold,j;
+ boolean result=false;
+
+ if (! readSpace()) {
+ result = false;
+ } else {
+ posold = position;
+ j = 0;
+ while (lastCharacter() != 0 && (j <= st.length()-1 && lastCharacter() == st.charAt(j))) {
+ position++;
+ j++;
+ }
+ if (j > st.length()-1) {
+ result = true;
+ lastString = st;
+ } else {
+ position = posold;
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ public boolean readCharacter (char ch) {
+ boolean result=false;
+
+ if (! readSpace()) {
+ result = false;
+ } else {
+ if (lastCharacter() == ch) {
+ position++;
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ //-- affect -> ":=" | "<-" | "?="
+ public boolean readAffect() {
+ return readSymbol(ILisaacModel.symbol_affect_immediate) ||
+ readSymbol(ILisaacModel.symbol_affect_cast) ||
+ readSymbol(ILisaacModel.symbol_affect_code);
+ }
+
+ //-- style -> '-' | '+'
+ public char readStyle() {
+ char result;
+
+ if (readCharacter('-')) {
+ result = '-';
+ } else if (readCharacter('+')) {
+ result = '+';
+ } else {
+ result = ' ';
+ }
+ return result;
+ }
+
+ //-- identifier -> 'a'-'z' {'a'-'z' | '0'-'9' | '_'}
+ public boolean readIdentifier() {
+ boolean result=false;
+ int posold,idx;
+
+ if (! readSpace() || !Character.isLowerCase(lastCharacter())) {
+ result = false;
+ } else {
+ posold = position;
+ string_tmp = "";
+
+ while (lastCharacter() != 0 &&
+ (Character.isLowerCase(lastCharacter()) ||
+ Character.isDigit(lastCharacter()) ||
+ lastCharacter() == '_')) {
+ string_tmp += lastCharacter();
+ position++;
+ }
+ if (string_tmp.length() > 0) {
+ idx = string_tmp.lastIndexOf("__");
+ if (idx != -1) {
+ position = posold+idx;
+ reporter.syntaxError("Identifier is incorrect.", getPosition());
+ }
+ lastString = getString(string_tmp);
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ public boolean readWord(String st) {
+ int posold,idx;
+ boolean result=false;
+
+ if (! readSpace()) {
+ result = false;
+ } else {
+ posold = position;
+ idx = 0;
+
+ while (idx <= st.length()-1 && lastCharacter() == st.charAt(idx)) {
+ position++;
+ idx++;
+ }
+ if (idx > st.length()-1) {
+ lastString = st;
+ result = true;
+ } else {
+ position = posold;
+ }
+ }
+ return result;
+ }
+
+ public boolean readThisKeyword(String st) {
+ return readWord(st);
+ }
+
+ //-- keyword -> 'A'-'Z' 'a'-'z' {'a'-'z' | '0'-'9' | '_'}
+ public boolean readKeyword() {
+ boolean result=false;
+
+ if (! readSpace() || ! Character.isUpperCase(lastCharacter())) {
+ result = false;
+ } else {
+ string_tmp = "";
+ string_tmp += lastCharacter();
+ position++;
+
+ if (Character.isLowerCase(lastCharacter())) {
+ string_tmp += lastCharacter();
+ position++;
+ while (lastCharacter() != 0 &&
+ (Character.isLowerCase(lastCharacter()) ||
+ Character.isDigit(lastCharacter()) ||
+ lastCharacter() == '_')) {
+ string_tmp += lastCharacter();
+ position++;
+ }
+ lastString = getString(string_tmp);
+ result = true;
+ } else {
+ position--;
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ //-- cap_identifier -> 'A'-'Z' {'A'-'Z' | '0'-'9' | '_'}
+ public boolean readCapIdentifier() {
+ int posold,idx;
+ boolean result=false;
+ char car;
+
+ if (! readSpace() || ! Character.isUpperCase(lastCharacter())) {
+ result = false;
+ } else {
+ posold = position;
+ string_tmp = ""+lastCharacter();
+ position++;
+ isParameterType = true;
+ while (lastCharacter() != 0 &&
+ (Character.isUpperCase(lastCharacter()) ||
+ Character.isDigit(lastCharacter()) ||
+ lastCharacter() == '_')) {
+ car = lastCharacter();
+ isParameterType = isParameterType && (Character.isDigit(car));
+
+ string_tmp += car;
+ position++;
+ }
+ if (Character.isLetter(lastCharacter()) ||
+ Character.isDigit(lastCharacter()) ||
+ lastCharacter() == '_') {
+ reporter.syntaxError("Identifier is incorrect.", getPosition());
+ return false;
+ }
+ idx = string_tmp.lastIndexOf("__");
+ if (idx != -1) {
+ position = posold + idx;
+ reporter.syntaxError("Identifier is incorrect.", getPosition());
+ return false;
+ }
+ lastString = getString(string_tmp);
+ result = true;
+ }
+ return result;
+ }
+
+ //-- integer -> number
+ //-- number -> {'0'-'9'} ['d']
+ //-- | '0'-'9' {'0'-'9' | 'A'-'F' | 'a'-'f'} 'h'
+ //-- | {'0'-'7'} 'o'
+ //-- | {'0' | '1'} 'b'
+ public boolean readInteger() {
+ boolean result=false;
+ //int pos_old;
+
+ if (readSpace() && Character.isDigit(lastCharacter())) {
+ result = true;
+ string_tmp = ""+lastCharacter();
+ //pos_old = position;
+ position++;
+
+ while (isHexadecimalDigit(lastCharacter()) || lastCharacter() == '_') {
+ if (lastCharacter() != '_') {
+ string_tmp += lastCharacter();
+ }
+ position++;
+ }
+ if (lastCharacter() == 'h') {
+ try {
+ Integer integer = Integer.valueOf(string_tmp, 16);
+ lastInteger = integer.intValue();
+ } catch (Exception e) {
+ //System.out.println("Warning readInteger : "+e);// FIXME hex string
+ lastInteger = 0;
+ }
+ position++;
+ } else {
+ if (string_tmp.charAt(string_tmp.length()-1) > '9') {
+ string_tmp = string_tmp.substring(0, string_tmp.length()-1);// remove last
+ position--;
+ }
+ if (lastCharacter() == 'o') {
+ if (!isOctal(string_tmp)) {
+ reporter.syntaxError("Incorrect octal number.", getPosition());
+ }
+ lastInteger = Integer.valueOf(string_tmp, 8).intValue();
+ position++;
+ } else if (lastCharacter() == 'b') {
+ if (!isBinary(string_tmp)) {
+ reporter.syntaxError("Incorrect binary number.", getPosition());
+ }
+ lastInteger = Integer.valueOf(string_tmp, 2).intValue();
+ position++;
+ } else {
+ if (lastCharacter() == 'd') {
+ position++;
+ }
+ if (! isInteger(string_tmp)) {
+ reporter.syntaxError("Incorrect decimal number.", getPosition());
+ }
+ lastInteger = Integer.valueOf(string_tmp);
+ }
+ }
+ }
+ return result;
+ }
+
+ private boolean isInteger(String s) {
+ try {
+ Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ return true;
+ }
+
+ // True when the contents is a sequence of bits (i.e., mixed
+ // characters `0' and characters `1').
+ private boolean isBinary(String s) {
+ boolean result;
+ int i;
+
+ i = s.length()-1;
+ result = true;
+ while (result && i != 0) {
+ result = s.charAt(i) == '0' || s.charAt(i) == '1';
+ i--;
+ }
+ return result;
+ }
+
+ private boolean isOctal(String s) {
+ try {
+ Integer.parseInt(s, 8);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isHexadecimalDigit(char c) {
+ boolean result=false;
+
+ if (Character.isDigit(c)) {
+ result = true;
+ } else if (c >= 'a') {
+ result = c <= 'f';
+ } else if (c >= 'A') {
+ result = c <= 'F';
+ }
+ return result;
+ }
+
+ //-- real -> '0'-'9' {'0'-'9'_} [ '.' {'0'-'9'} ] [ 'E' ['+'|'-'] '0'-'9' {'0'-'9'}
+ public boolean readReal() {
+ boolean result=false;
+ int pos_old;
+
+ if (readSpace() && Character.isDigit(lastCharacter())) {
+ string_tmp = ""+lastCharacter();
+ pos_old = position;
+ position++;
+
+ while (Character.isDigit(lastCharacter()) || lastCharacter() == '_') {
+ if (lastCharacter() != '_') {
+ string_tmp += lastCharacter();
+ }
+ position++;
+ }
+ if (lastCharacter() == '.') {
+ string_tmp += '.';
+ position++;
+
+ if (Character.isDigit(lastCharacter())) {
+ result = true;
+ string_tmp += lastCharacter();
+ position++;
+
+ while (Character.isDigit(lastCharacter())) {
+ string_tmp += lastCharacter();
+ position++;
+ }
+ }
+ if (lastCharacter() == 'E') {
+ result = true;
+ string_tmp += 'E';
+ position++;
+
+ if (lastCharacter() == '+' || lastCharacter() == '-') {
+ string_tmp += lastCharacter();
+ position++;
+ }
+ if (Character.isDigit(lastCharacter())) {
+ string_tmp += lastCharacter();
+ position++;
+ while (Character.isDigit(lastCharacter())) {
+ string_tmp += lastCharacter();
+ position++;
+ }
+ } else {
+ reporter.syntaxError("Incorrect real number.", getPosition());
+ }
+ }
+ }
+ if (result) {
+ lastReal = getString(string_tmp);
+ } else {
+ position = pos_old;
+ }
+ }
+ return result;
+ }
+
+ public void readEscapeCharacter() {
+ int val;
+
+ if (isSeparator(lastCharacter())) {
+ position++;
+ while (lastCharacter() != 0 && isSeparator(lastCharacter())) {
+ position++;
+ }
+ if (lastCharacter() == '\\') {
+ string_tmp.substring(0, string_tmp.length()-2); // remove last
+ position++;
+ } else if (lastCharacter() != 0) {
+ reporter.syntaxError("Unknown escape sequence.", getPosition());
+ }
+ } else if (lastCharacter() != 0) {
+ char c = lastCharacter();
+
+ if (c == 'a' ||
+ c == 'b' ||
+ c == 'f' ||
+ c == 'n' ||
+ c == 'r' ||
+ c == 't' ||
+ c == 'v' ||
+ c == '\\' ||
+ c == '?' ||
+ c == '\'' ||
+ c == '\"') {
+ string_tmp += c;
+ position++;
+ } else if (lastCharacter() >= '0' && lastCharacter() <= '9') {
+ if (lastCharacter() == '0' &&
+ position < source.length() &&
+ ! isHexadecimalDigit(source.charAt(position+1))) {
+
+ string_tmp += lastCharacter();
+ position++;
+ } else {
+ String string_tmp2 = new String(string_tmp);
+ readInteger(); // result is Always TRUE.
+ string_tmp = string_tmp2;
+
+ if (lastInteger > 255) {
+ reporter.syntaxError("Invalid range character number [0,255].", getPosition());
+ }
+ val = (int) lastInteger;
+ string_tmp += (val / 64);
+ string_tmp += ((val % 64) / 8);
+ string_tmp += (val % 8);
+ if (lastCharacter() == '\\') {
+ position++;
+ } else {
+ reporter.syntaxError("Character '\' is needed.", getPosition());
+ }
+ }
+ } else {
+ reporter.syntaxError("Unknown escape sequence.", getPosition());
+ }
+ }
+ }
+
+ //-- character -> '\'' ascii '\''
+ public boolean readCharacters() {
+ boolean result=false;
+ int count=0;
+
+ if (readSpace() && lastCharacter() == '\'') {
+ //old_pos = position;
+ position++;
+ string_tmp = "";
+ while (lastCharacter() != 0 && lastCharacter() != '\n' && lastCharacter() != '\'') {
+ string_tmp += lastCharacter();
+ if (lastCharacter() == '\\') {
+ position++;
+ readEscapeCharacter();
+ count++;
+ } else {
+ position++;
+ count++;
+ }
+ }
+ if (lastCharacter() == '\'') {
+ position++;
+ lastString = getString(string_tmp);
+ if (count != 1) {
+ position = begin_position;
+ reporter.syntaxError("Character constant too long.", getPosition());
+ }
+ result = true;
+ } else {
+ position = begin_position;
+ reporter.syntaxError("Unterminated character constant.", getPosition());
+ }
+ }
+ return result;
+ }
+
+ //-- string -> '\"' ascii_string '\"'
+ public boolean readString() {
+ boolean result=false;
+
+ if (readSpace() && lastCharacter() == '\"') {
+ // old_pos = position;
+ position = position+1;
+ string_tmp = "";
+ while (lastCharacter() != 0 && lastCharacter() != '\n' && lastCharacter() != '\"') {
+ string_tmp += lastCharacter();
+ if (lastCharacter() == '\\') {
+ position = position+1;
+ readEscapeCharacter();
+ } else {
+ position = position+1;
+ }
+ }
+ if (lastCharacter() == '\"') {
+ position = position+1;
+ lastString = getString(string_tmp);
+ result = true;
+ } else {
+ position = begin_position;
+ reporter.syntaxError("Unterminated string constant.", getPosition());
+ }
+ }
+ return result;
+ }
+
+ //-- external -> '`' ascii_c_code '`'
+ public boolean readExternal() {
+ boolean result=false;
+ // int pos_old;
+
+ if ((! readSpace()) || lastCharacter() != '`') {
+ result = false;
+ } else {
+ // pos_old=position;
+ position = position+1;
+ string_tmp = "";
+ while (lastCharacter() != 0 && lastCharacter() != '`') {
+ string_tmp += lastCharacter();
+ if (lastCharacter() == '\\') {
+ position = position+1;
+ string_tmp += lastCharacter();
+ if (lastCharacter() != 0) {
+ position = position+1;
+ }
+ } else {
+ position = position+1;
+ }
+ }
+ if (lastCharacter() != 0) {
+ position = position+1;
+ lastString = getString(string_tmp);
+ result = true;
+ } else {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ private static final String operators = "!@#$%^&<|*-+=~/?\\>";
+
+ public static boolean isOperatorSymbol(char c) {
+ return operators.indexOf(c) != -1;
+ }
+
+ //-- operator -> '!' | '@' | '#' | '$' | '%' | '^' | '&' | '<' | '|'
+ //-- | '*' | '-' | '+' | '=' | '~' | '/' | '?' | '\' | '>'
+ public boolean readOperator() {
+ boolean result=false;
+ // int old_pos;
+
+ readSpace();
+ // old_pos = position;
+ string_tmp = "";
+ while (lastCharacter() != 0 &&
+ operators.indexOf(lastCharacter()) != -1) {
+ string_tmp += lastCharacter();
+ position = position+1;
+ }
+ if (string_tmp.length() > 0) {
+ lastString = getString(string_tmp);
+ if (lastString.equals(ILisaacModel.symbol_affect_immediate) ||
+ lastString.equals(ILisaacModel.symbol_affect_code) ||
+ lastString.equals(ILisaacModel.symbol_affect_cast)) {
+ reporter.syntaxError("Incorrect operator.", getPosition());
+ }
+ result = true;
+ }
+ return result;
+ }
+
+ // True when character is a separator.
+ private boolean isSeparator(char c) {
+ return c == ' ' || c == '\t' || c == '\n' ||
+ c == '\r' || c == '\0' || c == '\f'; // || c == '\v';
+ }
+
+ public String getString(String str) {
+ if (model == null) {
+ return str;
+ }
+ return model.getAliasString().get(str);
+ }
+
+
+ public ILisaacErrorHandler getReporter() {
+ return reporter;
+ }
+
+ public void readTokenAt(int line, int column) {
+ // goto (line,column) position
+ while (! isEOF()) {
+ if (source.charAt(pos_cur) == '\n') {
+ pos_col = 0;
+ pos_line++;
+ } else {
+ pos_col++;
+ }
+ if (pos_line == line && pos_col == column) {
+ position = pos_cur;
+ break;
+ }
+ pos_cur++;
+ }
+ // goto token begining
+ while (position >= 0) {
+ char c = lastCharacter();
+ if (isSeparator(c)) {
+ break;
+ }
+ position--;
+ }
+ // read token
+ position++;
+ string_tmp = "";
+ while (! isEOF()) {
+ char c = lastCharacter();
+ if (isSeparator(c)) {
+ break;
+ }
+ string_tmp += c;
+ position++;
+ }
+ lastString = string_tmp;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/AliasString.java b/editor/eclipse/src/org/lisaac/ldt/model/AliasString.java
new file mode 100644
index 0000000..c3e214c
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/AliasString.java
@@ -0,0 +1,84 @@
+package org.lisaac.ldt.model;
+
+import java.util.HashSet;
+
+public class AliasString {
+ private HashSet<String> list;
+
+ public AliasString() {
+ list = new HashSet<String>();
+
+ // add model string constants
+ list.add(ILisaacModel.section_header);
+ list.add(ILisaacModel.section_inherit);
+ list.add(ILisaacModel.section_insert);
+ list.add(ILisaacModel.section_public);
+ list.add(ILisaacModel.section_private);
+ list.add(ILisaacModel.section_interrupt);
+ list.add(ILisaacModel.section_mapping);
+ list.add(ILisaacModel.section_directory);
+ list.add(ILisaacModel.section_external);
+
+ list.add(ILisaacModel.keyword_section);
+ list.add(ILisaacModel.keyword_right);
+ list.add(ILisaacModel.keyword_left);
+ list.add(ILisaacModel.keyword_ldots);
+ list.add(ILisaacModel.keyword_old);
+ list.add(ILisaacModel.keyword_expanded);
+ list.add(ILisaacModel.keyword_strict);
+ list.add(ILisaacModel.keyword_result);
+
+ list.add(ILisaacModel.symbol_affect_immediate);
+ list.add(ILisaacModel.symbol_affect_cast);
+ list.add(ILisaacModel.symbol_affect_code);
+ list.add(ILisaacModel.symbol_auto_export);
+ list.add(ILisaacModel.symbol_equal);
+ list.add(ILisaacModel.symbol_not_equal);
+ list.add(ILisaacModel.symbol_great);
+ list.add(ILisaacModel.symbol_great_equal);
+ list.add(ILisaacModel.symbol_less);
+ list.add(ILisaacModel.symbol_less_equal);
+
+ list.add(ILisaacModel.slot_name);
+ list.add(ILisaacModel.slot_export);
+ list.add(ILisaacModel.slot_import);
+ list.add(ILisaacModel.slot_external);
+ list.add(ILisaacModel.slot_default);
+ list.add(ILisaacModel.slot_type);
+ list.add(ILisaacModel.slot_version);
+ list.add(ILisaacModel.slot_date);
+ list.add(ILisaacModel.slot_comment);
+ list.add(ILisaacModel.slot_author);
+ list.add(ILisaacModel.slot_bibliography);
+ list.add(ILisaacModel.slot_language);
+ list.add(ILisaacModel.slot_copyright);
+ list.add(ILisaacModel.slot_bug_report);
+
+ list.add(ILisaacModel.prototype_true);
+ list.add(ILisaacModel.prototype_false);
+ list.add(ILisaacModel.prototype_self);
+ list.add(ILisaacModel.prototype_string);
+ list.add(ILisaacModel.prototype_integer);
+ list.add(ILisaacModel.prototype_real);
+ list.add(ILisaacModel.prototype_boolean);
+ list.add(ILisaacModel.prototype_character);
+ list.add(ILisaacModel.prototype_block);
+
+ list.add(ILisaacModel.variable_null);
+ list.add(ILisaacModel.variable_void);
+ list.add(ILisaacModel.variable_self);
+
+ // lip
+ list.add(ILisaacModel.slot_lip);
+ list.add(ILisaacModel.slot_if);
+ list.add(ILisaacModel.slot_else);
+ list.add(ILisaacModel.slot_print);
+ }
+
+ public String get (String str) {
+ if (! list.contains(str)) {
+ list.add(str);
+ }
+ return str;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/ILisaacContext.java b/editor/eclipse/src/org/lisaac/ldt/model/ILisaacContext.java
new file mode 100644
index 0000000..168cb32
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/ILisaacContext.java
@@ -0,0 +1,20 @@
+package org.lisaac.ldt.model;
+
+import org.lisaac.ldt.model.items.Prototype;
+
+public interface ILisaacContext {
+ /**
+ * Parse the definition of the context. Returns true if the
+ * context is correctly parsed. <br>
+ * Automatically report parse errors.
+ * @param prototype The model to fill
+ * @return false if the definition of context contains at least one error
+ */
+ boolean parseDefinition(Prototype prototype);
+
+ /**
+ * Get the following context of same category in the lisaac code.
+ * @return next context in current prototype
+ */
+ ILisaacContext getNextContext();
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/ILisaacFileVisitor.java b/editor/eclipse/src/org/lisaac/ldt/model/ILisaacFileVisitor.java
new file mode 100644
index 0000000..9c16926
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/ILisaacFileVisitor.java
@@ -0,0 +1,8 @@
+package org.lisaac.ldt.model;
+
+import org.lisaac.ldt.model.items.Prototype;
+
+public interface ILisaacFileVisitor {
+
+ void visit(Prototype prototype);
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/ILisaacModel.java b/editor/eclipse/src/org/lisaac/ldt/model/ILisaacModel.java
new file mode 100644
index 0000000..f6c21b2
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/ILisaacModel.java
@@ -0,0 +1,99 @@
+package org.lisaac.ldt.model;
+
+import org.eclipse.core.resources.IProject;
+import org.lisaac.ldt.builder.ILisaacErrorHandler;
+import org.lisaac.ldt.model.lip.LIP;
+
+public interface ILisaacModel {
+
+ final String inherit_shared = "Shared";
+ final String inherit_shared_expanded = "Shared Expanded";
+ final String inherit_nonshared = "Non Shared";
+ final String inherit_nonshared_expanded = "Non Shared Expanded";
+
+ //
+ final String keyword_section = "Section";
+ final String keyword_right = "Right";
+ final String keyword_left = "Left";
+ final String keyword_ldots = "...";
+ final String keyword_old = "Old";
+ final String keyword_expanded = "Expanded";
+ final String keyword_strict = "Strict";
+ final String keyword_result = "Result";
+
+ final String symbol_affect_immediate = ":=";
+ final String symbol_affect_cast = "?=";
+ final String symbol_affect_code = "<-";
+ final String symbol_auto_export = "->";
+ final String symbol_auto_import = symbol_affect_code;
+ final String symbol_equal = "=";
+ final String symbol_not_equal = "!=";
+ final String symbol_great = ">";
+ final String symbol_great_equal = ">=";
+ final String symbol_less = "<";
+ final String symbol_less_equal = "<=";
+
+ final String section_header = "Header";
+ final String section_inherit = "Inherit";
+ final String section_insert = "Insert";
+ final String section_public = "Public";
+ final String section_private = "Private";
+ final String section_interrupt = "Interrupt";
+ final String section_mapping = "Mapping";
+ final String section_directory = "Directory";
+ final String section_external = "External";
+
+ final String slot_name = "name";
+ final String slot_export = "export";
+ final String slot_import = "import";
+ final String slot_external = "external";
+ final String slot_default = "default";
+ final String slot_type = "type";
+ final String slot_version = "version";
+ final String slot_date = "date";
+ final String slot_comment = "comment";
+ final String slot_author = "author";
+ final String slot_bibliography = "bibliography";
+ final String slot_language = "language";
+ final String slot_copyright = "copyright";
+ final String slot_bug_report = "bug_report";
+
+ final String prototype_true = "TRUE";
+ final String prototype_false = "FALSE";
+ final String prototype_self = "SELF";
+ final String prototype_string = "STRING";
+ final String prototype_integer = "INTEGER";
+ final String prototype_real = "REAL";
+ final String prototype_boolean = "BOOLEAN";
+ final String prototype_character = "CHARACTER";
+ final String prototype_block = "BLOCK";
+
+ final String variable_null = "NULL";
+ final String variable_void = "VOID";
+ final String variable_self = "Self";
+
+
+ final String[] keywords = new String[] { keyword_section, section_public,
+ section_private, section_inherit, section_header, section_insert,
+ section_mapping, section_interrupt,
+ section_external, section_directory,
+ keyword_expanded, keyword_strict,
+ keyword_left, keyword_right,
+ variable_self, keyword_old, keyword_result};
+
+
+ // lip
+ final String slot_lip = "lip";
+ final String slot_if = "if";
+ final String slot_else = "else";
+ final String slot_print = "print";
+
+ final String slot_debug_mode = "run_mode";
+
+ ILisaacErrorHandler getReporter();
+ AliasString getAliasString();
+ LisaacParser getParser();
+ LIP getLipCode();
+ IProject getProject();
+ LisaacPath getPathManager();
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/LipParser.java b/editor/eclipse/src/org/lisaac/ldt/model/LipParser.java
new file mode 100644
index 0000000..fe22d7d
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/LipParser.java
@@ -0,0 +1,465 @@
+package org.lisaac.ldt.model;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import org.lisaac.ldt.model.lip.*;
+
+
+public class LipParser extends AbstractLisaacParser {
+
+ public LIP lipFile;
+
+ public LipParser(InputStream contents, ILisaacModel model) {
+ super(contents, model);
+ this.lipFile = model.getLipCode();
+ }
+
+ public LipParser(String contents, int offset) {
+ super(contents);
+ setPosition(offset);
+ }
+
+ //
+ // Parser for LIP file.
+ //
+
+ ////PROGRAM -> { 'Section' ('Inherit' | 'Public' | 'Private') { SLOT ';' } }
+ public boolean parse() {
+ boolean result=false;
+
+ while (readThisKeyword(ILisaacModel.keyword_section)) {
+ if (readThisKeyword(ILisaacModel.section_inherit)) {
+ // { '+' string ':' STRING [ ':=' string ] ';' }
+ while (readCharacter('+')) {
+ if (! readIdentifier()) {
+ reporter.syntaxError("Identifier needed.", getLine());
+ return false;
+ }
+ if (! readCharacter(':')) {
+ reporter.syntaxError("Added ':' is needed.", getLine());
+ return false;
+ }
+ if (! readWord(ILisaacModel.prototype_string)) {
+ reporter.warning("`STRING' type needed.", getLine());
+ }
+ if (readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ if (! readString()) {
+ reporter.syntaxError("String needed.", getLine());
+ return false;
+ }
+ string_tmp = new String(lipFile.getFileName());
+ while (string_tmp.length() > 0) {
+ char c = string_tmp.charAt(string_tmp.length()-1);
+ if (c == '/' || c == '\\') {
+ break;
+ }// FIXME use index
+ string_tmp = string_tmp.substring(0, string_tmp.length()-1);
+ }
+ string_tmp += lastString;
+ } else {
+ string_tmp = "";
+ }
+ // add parent slot
+ lipFile.addParent(getString(string_tmp));
+ //
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';' is needed.", getLine());
+ return false;
+ }
+ result = true;
+ }
+ } else if (readThisKeyword(ILisaacModel.section_public) ||
+ readThisKeyword(ILisaacModel.section_private)) {
+ String section = new String(lastString);
+ while (readSlot(section)) {
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';' is needed.", getLine());
+ return false;
+ }
+ result = true;
+ }
+ } else {
+ reporter.syntaxError("`Public' or `Private' or `Inherit' needed.", getLine());
+ return false;
+ }
+ }
+ if (position < source.length()-2) {
+ result = false;
+ }
+
+ // TODO recursive parsing !!!
+ return result;
+ }
+
+ //// SLOT -> '+' identifier ':' TYPE [ ':=' EXPR_CONSTANT ]
+ //// | '-' identifier [ identifier ':' TYPE ] '<-' '(' { EXPR ';' } ')'
+ private boolean readSlot(String sec) {
+ boolean result=false;
+ LIPSlotData data=null;
+
+ if (readCharacter('+')) {
+ // Data.
+ result = true;
+ if (sec.equals(ILisaacModel.section_public)) {
+ reporter.syntaxError("No data in Public section.", getPosition(1));
+ }
+ if (! readIdentifier()) {
+ reporter.syntaxError("Identifier is incorrect.", getLine());
+ return false;
+ }
+ String n = new String(lastString);
+ if (! readCharacter(':')) {
+ reporter.syntaxError("Added ':' is needed.", getLine());
+ return false;
+ }
+ LIPConstant t = readType();
+ if (t == null) {
+ reporter.syntaxError("type is incorrect.", getLine());
+ return false;
+ }
+ data = new LIPSlotData(n, t);
+ //
+ lipFile.addData(data);
+ //
+ if (readSymbol(LisaacModel.symbol_affect_immediate)) {
+ LIPConstant cst = readExprConstant();
+ if (cst == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return false;
+ }
+ data.setValue(cst);
+ cst.free();
+ }
+ } else if (readCharacter('-')) {
+ // Function.
+ result = true;
+ if (! readIdentifier()) {
+ reporter.syntaxError("Identifier is incorrect.", getLine());
+ return false;
+ }
+ //Position pos = getPosition();
+ setCatchComment();
+
+ String n = new String(lastString);
+ if (readIdentifier()) {
+ String na = new String(lastString);
+ if (! readCharacter(':')) {
+ reporter.syntaxError("Added ':' is needed.", getLine());
+ return false;
+ }
+ LIPConstant t = readType();
+ if (t == null) {
+ reporter.syntaxError("Incorrect type.", getLine());
+ return false;
+ }
+ data = new LIPSlotData(na, t);// do not add argument do lipFile
+ }
+ //
+ if (! readSymbol(ILisaacModel.symbol_affect_code)) {
+ reporter.syntaxError("Added '<-' is needed.", getLine());
+ return false;
+ }
+ if (! readCharacter('(')) {
+ reporter.syntaxError("Added '(' is needed.", getLine());
+ return false;
+ }
+ setCatchCommentOff();
+ ArrayList<LIPCode> code = new ArrayList<LIPCode>();
+ LIPCode instr;
+ while ((instr = readExpr()) != null) {
+ code.add(instr);
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';' is needed.", getLine());
+ return false;
+ }
+ }
+ if (! readCharacter(')')) {
+ reporter.syntaxError("Added ')' is needed.", getLine());
+ return false;
+ }
+ LIPSlotCode slotCode = new LIPSlotCode(sec, n, data, code.toArray(new LIPCode[code.size()]));
+ lipFile.addMethod(slotCode);
+ if (sec.equals(ILisaacModel.section_public)) {
+ if (lastComment == null || lastComment.length() == 0) {
+ reporter.syntaxError("Comment needed.", getPosition());
+ } else {
+ slotCode.setComment(lastComment);
+ }
+ }
+ }
+ return result;
+ }
+
+ ////TYPE -> 'BOOLEAN' | 'STRING' | 'INTEGER'
+ private LIPConstant readType() {
+ LIPConstant result=null;
+
+ if (readCapIdentifier()) {
+ if (lastString.equals(ILisaacModel.prototype_integer)) {
+ result = LIPInteger.get(0);
+ } else if (lastString.equals(ILisaacModel.prototype_string)) {
+ result = LIPString.get(getString(""));
+ } else if (lastString.equals(ILisaacModel.prototype_boolean)) {
+ result = LIPBoolean.get(false);
+ } else {
+ reporter.syntaxError("Incorrect type.", getLine());
+ }
+ }
+ return result;
+ }
+
+ //// EXPR -> [ identifier !!AMBIGU!! ':=' ] EXPR_OPERATOR [ '.' FUNCTION ]
+ public LIPCode readExpr() {
+ LIPCode result=null;
+
+ saveContext(); // !! SAVE CONTEXT !!
+
+ if (readIdentifier()) {
+ String name = new String(lastString);
+ if (readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ LIPCode val = readExprOperator();
+ if (val == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ result = new LIPAffect(name, val);
+ } else {
+ restoreContext(); // !! RESTORE CONTEXT !!
+ }
+ }
+ if (result == null) {
+ result = readExprOperator();
+ if (result != null && readCharacter('.')) {
+ result = readFunction(result);
+ if (result == null) {
+ reporter.syntaxError("Incorrect slot.", getLine());
+ return null;
+ }
+ }
+ }
+ return result;
+ }
+
+ //// FUNCTION -> 'if' '{' { EXPR ';' } '}' [ 'else' '{' { EXPR ';' } '}' ]
+ //// | 'print'
+ private LIPCode readFunction(LIPCode rec) {
+ LIPCode result=null;
+ ArrayList<LIPCode> thenArray=null, elseArray=null;
+
+ if (readWord(ILisaacModel.slot_if)) {
+ thenArray = new ArrayList<LIPCode>();
+ if (! readCharacter('{')) {
+ reporter.syntaxError("Added '{' is needed.", getLine());
+ return null;
+ }
+ LIPCode val;
+ while ((val = readExpr()) != null) {
+ thenArray.add(val);
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';' is needed.", getLine());
+ return null;
+ }
+ }
+ if (! readCharacter('}')) {
+ reporter.syntaxError("Added '}' is needed.", getLine());
+ return null;
+ }
+ if (readWord(ILisaacModel.slot_else)) {
+ elseArray = new ArrayList<LIPCode>();
+ if (! readCharacter('{')) {
+ reporter.syntaxError("Added '{' is needed.", getLine());
+ return null;
+ }
+ while ((val = readExpr()) != null) {
+ elseArray.add(val);
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';' is needed.", getLine());
+ return null;
+ }
+ }
+ if (! readCharacter('}')) {
+ reporter.syntaxError("Added '}' is needed.", getLine());
+ return null;
+ }
+ }
+ result = new LIPIf(rec, thenArray.toArray(new LIPCode[thenArray.size()]),
+ elseArray.toArray(new LIPCode[elseArray.size()]));
+ } else if (readWord(ILisaacModel.slot_print)) {
+ result = new LIPPrint(rec);
+ }
+ return result;
+ }
+
+ ////EXPR_OPERATOR-> EXPR_CMP { ('|' | '&') EXPR_CMP }
+ private LIPCode readExprOperator() {
+ LIPCode result=null;
+ boolean isOr=false;
+
+ result = readExprCmp();
+ if (result != null) {
+ while ((isOr = readCharacter('|')) || readCharacter('&')) {
+ LIPCode right = readExprCmp();
+ if (right == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ if (isOr) {
+ result = new LIPBinary(result, '|', right);
+ } else {
+ result = new LIPBinary(result, '&', right);
+ }
+ }
+ }
+ return result;
+ }
+
+ ////EXPR_CMP -> EXPR_BINARY { ('='|'!='|'>'|'<'|'>='|'<=') EXPR_BINARY }
+ private LIPCode readExprCmp() {
+
+ LIPCode result = readExprBinary();
+ if (result != null) {
+ while (readSymbol(ILisaacModel.symbol_great_equal) ||
+ readSymbol(ILisaacModel.symbol_less_equal) ||
+ readSymbol(ILisaacModel.symbol_not_equal) ||
+ readSymbol(ILisaacModel.symbol_equal) ||
+ readSymbol(ILisaacModel.symbol_great) ||
+ readSymbol(ILisaacModel.symbol_less)) {
+ String op = new String(lastString);
+ LIPCode right = readExprBinary();
+ if (right == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ char type = 0;
+ if (op.equals(">=")) {
+ type = 'S';
+ } else if (op.equals("<=")) {
+ type = 'I';
+ } else if (op.equals("!=")) {
+ type = 'E';
+ } else if (op.equals("=")) {
+ type = '=';
+ } else if (op.equals(">")) {
+ type = '>';
+ } else if (op.equals("<")) {
+ type = '<';
+ }
+ result = new LIPBinary(result, type, right);
+ }
+ }
+ return result;
+ }
+
+ ////EXPR_BINARY -> EXPR_UNARY { ('-'|'+') EXPR_UNARY }
+ private LIPCode readExprBinary() {
+ boolean isSub;
+
+ LIPCode result = readExprUnary();
+ if (result != null) {
+ while ((isSub = readCharacter('-')) || readCharacter('+')) {
+ LIPCode right = readExprUnary();
+ if (right == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ if (isSub) {
+ result = new LIPBinary(result, '-', right);
+ } else {
+ result = new LIPBinary(result, '+', right);
+ }
+ }
+ }
+ return result;
+ }
+
+ //// EXPR_UNARY -> ( '-' | '!' ) EXPR_UNARY
+ //// | EXPR_BASE
+ //// | identifier [ EXPR_ARGUMENT ]
+ private LIPCode readExprUnary() {
+ LIPCode result=null;
+ boolean isNeg;
+
+ if ((isNeg = readCharacter('-')) || readCharacter('!')) {
+ result = readExprUnary();
+ if (result == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ char type;
+ if (isNeg) {
+ type = '-';
+ } else {
+ type = '+';
+ }
+ result = new LIPUnary(type, result);
+ } else if (readIdentifier()) {
+ String name = new String(lastString);
+ LIPCode arg = readExprArgument();
+ result = new LIPCall(name, arg);
+ } else {
+ result = readExprBase();
+ }
+ return result;
+ }
+
+ //// EXPR_BASE -> '(' EXPR_OPERATOR ')'
+ //// | EXPR_CONSTANT
+ private LIPCode readExprBase() {
+ LIPCode result=null;
+
+ if (readCharacter('(')) {
+ result = readExprOperator();
+ if (result == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ if (! readCharacter(')')) {
+ reporter.syntaxError("Added ')' is needed.", getLine());
+ return null;
+ }
+ } else {
+ LIPConstant v = readExprConstant();
+ if (v != null) {
+ result = new LIPValue(v);
+ }
+ }
+ return result;
+ }
+
+ ////EXPR_CONSTANT-> integer
+ //// | string
+ //// | TRUE
+ //// | FALSE
+ private LIPConstant readExprConstant() {
+ LIPConstant result=null;
+
+ if (readInteger()) {
+ result = LIPInteger.get((int)lastInteger);
+ } else if (readString()) {
+ result = LIPString.get(lastString);
+ } else if (readCapIdentifier()) {
+ if (lastString.equals(ILisaacModel.prototype_true)) {
+ result = LIPBoolean.get(true);
+ } else if (lastString.equals(ILisaacModel.prototype_false)){
+ result = LIPBoolean.get(false);
+ } else {
+ reporter.syntaxError("Type incorrect.", getLine());
+ }
+ }
+ return result;
+ }
+
+ //// EXPR_ARGUMENT-> identifier
+ //// | EXPR_BASE
+ private LIPCode readExprArgument() {
+ LIPCode result=null;
+
+ if (readIdentifier()) {
+ result = new LIPCall(lastString, null);
+ } else {
+ result = readExprBase();
+ }
+ return result;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/LisaacCompletionParser.java b/editor/eclipse/src/org/lisaac/ldt/model/LisaacCompletionParser.java
new file mode 100644
index 0000000..6799c1f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/LisaacCompletionParser.java
@@ -0,0 +1,253 @@
+package org.lisaac.ldt.model;
+
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.LisaacEditor;
+import org.lisaac.ldt.model.items.ICode;
+import org.lisaac.ldt.model.items.ITMPrototype;
+import org.lisaac.ldt.model.items.ITMRead;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.items.Slot;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeGeneric;
+import org.lisaac.ldt.model.types.TypeParameter;
+import org.lisaac.ldt.model.types.TypeSelf;
+import org.lisaac.ldt.outline.OutlineImages;
+
+public class LisaacCompletionParser extends LisaacParser {
+ protected static LisaacModel model;
+
+ protected Prototype currentPrototype;
+ protected Slot currentSlot;
+
+ protected int endOffset;
+
+ protected TypeGeneric lastGenericType;
+
+
+ public LisaacCompletionParser(String contents, LisaacModel model) {
+ super(null,contents);
+
+ if (model == null) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (w != null) {
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ model = LisaacModel.getModel(((LisaacEditor)part).getProject());
+ }
+ }
+ }
+ LisaacCompletionParser.model = model;
+ //
+ enableErrorReport(false); // turn off error reporting
+ //
+ }
+
+ /**
+ * Get the lisaac completions at baseOffset
+ * @param startOffset start offset for completion parsing
+ * @param baseOffset completion offset
+ * @param proposals list of proposals to be filled
+ * @throws CoreException
+ */
+ public void parseCompletions(int startOffset, int baseOffset, ArrayList<ICompletionProposal> proposals)
+ throws CoreException {
+ IType type;
+
+ currentPrototype = LisaacModel.getCurrentPrototype();
+ currentSlot = currentPrototype.getSlot(startOffset);
+ lastGenericType = null;
+ endOffset = -1;
+
+ // keyword match
+ while (readKeyword()) {
+ if (baseOffset != (startOffset+position)) {
+ continue;// not last keyword
+ }
+ String[] keywords = ILisaacModel.keywords;
+ for (int i = 0; i < keywords.length; i++) {
+ if (keywords[i].startsWith(lastString)) {// length(keyword[i]) >= length(lastString)
+ String keywordCompletion = keywords[i].substring(lastString.length());
+ proposals.add(new CompletionProposal(keywordCompletion,
+ baseOffset, 0, keywordCompletion.length(),
+ OutlineImages.KEYWORD, keywords[i], null, ""));
+ }
+ }
+ return;
+ }
+ setPosition(0);
+
+ // slot match
+ ICode code = readExpr();
+ if (code != null && currentPrototype != null) {
+ type = code.getType(currentSlot, currentPrototype);
+ if (type != null) {
+ if (source.charAt(position-1) == '.') {
+ //
+ // slot completion
+ //
+ if (type instanceof TypeSelf) {
+ currentPrototype = findPrototype(((TypeSelf) type).getStaticType());
+
+ } else if (type instanceof TypeParameter && lastGenericType != null) {
+ // genericity TypeParameter -> TypeSimple
+ int index = currentPrototype.getGenericIndex((TypeParameter) type);
+ if (index != -1) {
+ ITypeMono realType = lastGenericType.getGenericElt(index);
+ currentPrototype = findPrototype(realType.toString());
+ }
+ } else {
+ currentPrototype = findPrototype(type.toString());
+ }
+ if (currentPrototype != null) {
+ // compute completion result
+ currentPrototype.getSlotProposals(proposals, baseOffset, 0);
+ }
+ } else if (code instanceof ITMPrototype) {
+ // partial prototype name
+ String prefix = type.toString();
+ model.getPathManager().getPathMatch(prefix, proposals, baseOffset);
+ }
+ } else {
+ // partial name, search for matches
+ if (code instanceof ITMRead) {
+ String prefix = ((ITMRead) code).getName();
+
+ // partial local name
+ if (currentSlot != null) {
+ currentSlot.getArgumentMatchProposals(prefix, proposals, baseOffset, 0);
+ currentSlot.getLocalMatchProposals(prefix, proposals, baseOffset, 0);
+ }
+ // partial slot name (first keyword)
+ currentPrototype.lookupSlotMatch(prefix, proposals, baseOffset, 0);
+ }
+ }
+ }
+ }
+
+ //++ EXPR_MESSAGE -> EXPR_BASE { '.' SEND_MSG }
+ protected ICode readExprMessage() {
+
+ ICode result = readExprBase();
+ if (result != null) {
+ while (readCharacter('.')) {
+ if (endOffset != -1 && position == endOffset+1) {
+ break;
+ }
+ ICode lastResult = result;
+ result = readSendMsg(result);
+ if (result == null) {
+ return lastResult;
+ }
+ // update source of completion
+ IType type = lastResult.getType(currentSlot, currentPrototype);
+ if (type != null) {
+ String stringType = type.toString();
+ if (stringType != null && "SELF".compareTo(stringType) != 0) {
+ try {
+ if (type instanceof TypeParameter && lastGenericType != null) {
+ // genericity TypeParameter -> TypeSimple
+ int index = currentPrototype.getGenericIndex((TypeParameter) type);
+ if (index != -1) {
+ ITypeMono realType = lastGenericType.getGenericElt(index);
+ currentPrototype = findPrototype(realType.toString());
+ }
+ } else {
+ currentPrototype = findPrototype(stringType);
+ }
+ } catch(CoreException e) {
+ return null;
+ }
+ if (currentPrototype == null) {
+ return null;
+ }
+ if (type instanceof TypeGeneric) {
+ lastGenericType = (TypeGeneric) type;
+ }
+ if (result instanceof ITMRead) {
+ currentSlot = currentPrototype.lookupSlot(((ITMRead) result).getName());
+ } else {
+ currentSlot = null;
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+
+ public Prototype readReceiver(int startOffset, int endOffset, Prototype current) throws CoreException {
+ Prototype result=null;
+ IType type;
+
+ currentPrototype = current;
+ currentSlot = currentPrototype.getSlot(startOffset);
+ this.endOffset = endOffset;
+
+ setPosition(startOffset);
+ readSpace();
+
+ ICode code = readExpr();
+ if (code != null && currentPrototype != null) {
+ type = code.getType(currentSlot, currentPrototype);
+ if (type != null) {
+ //if (! type.equals(TypeSimple.getTypeSelf())) {
+ if (type.toString() != null && "SELF".compareTo(type.toString()) != 0) {
+ Prototype save = currentPrototype;
+ currentPrototype = findPrototype(type.toString());
+ if (currentPrototype == null) {
+ currentPrototype = save;
+ }
+ }
+ // genericity TypeParameter -> TypeSimple
+ if (type instanceof TypeParameter && lastGenericType != null) {
+ int index = currentPrototype.getGenericIndex((TypeParameter) type);
+ if (index != -1) {
+ ITypeMono realType = lastGenericType.getGenericElt(index);
+ currentPrototype = findPrototype(realType.toString());
+ }
+ }
+ result = currentPrototype;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Find and parse a lisaac prototype according to its name.
+ */
+ public static Prototype findPrototype(String prototypeName) throws CoreException {
+ IProject project = null;
+
+ if (model == null) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (w == null) {
+ return null;
+ }
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ project = ((LisaacEditor)part).getProject();
+ }
+ if (project != null) {
+ model = LisaacModel.getModel(project);
+ }
+ }
+ if (model == null) {
+ return null;
+ }
+ if (project == null) {
+ project = model.getProject();
+ }
+ return model.getPrototype(prototypeName);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/LisaacModel.java b/editor/eclipse/src/org/lisaac/ldt/model/LisaacModel.java
new file mode 100644
index 0000000..f7d3e67
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/LisaacModel.java
@@ -0,0 +1,310 @@
+package org.lisaac.ldt.model;
+
+import java.io.InputStream;
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IPartService;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.builder.ILisaacErrorHandler;
+import org.lisaac.ldt.editors.AbstractLisaacEditor;
+import org.lisaac.ldt.editors.LisaacEditor;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.lip.LIP;
+
+/**
+ * Represents Lisaac model of a project
+ * @author Damien Bouvarel
+ */
+public class LisaacModel implements ILisaacModel{
+
+ /** list of all encoutered models */
+ private static HashMap<IProject,LisaacModel> modelList;
+
+ /** list of all legal prototypes path */
+ private LisaacPath modelPath;
+
+ /** list of all encountered prototypes */
+ private HashMap<String,Prototype> prototypes;
+
+ /** lip makefile of this model */
+ private LIP lipCode;
+
+ /** project associated with this model */
+ private IProject project;
+
+ /** error handler */
+ private ILisaacErrorHandler reporter;
+
+ /** lisaac parser */
+ private LisaacParser parser;
+
+ /** string aliaser */
+ private AliasString aliasString;
+
+ /** modification flag */
+ private boolean isProjectCompiled;
+
+ public static AbstractLisaacEditor currentEditor = null;
+
+
+ public LisaacModel(IProject project) {
+ this.project = project;
+ prototypes = new HashMap<String,Prototype>();
+ aliasString = new AliasString();
+
+ // add this model to the model list
+ if (modelList == null) {
+ modelList = new HashMap<IProject,LisaacModel>();
+ }
+ modelList.put(project, this);
+
+ // create lisaac path
+ modelPath = new LisaacPath(project, "make.lip"); // TODO get lip from property page
+ isProjectCompiled = false;
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public AliasString getAliasString() {
+ return aliasString;
+ }
+ public LisaacParser getParser() {
+ return parser;
+ }
+ public LisaacPath getPathManager() {
+ return modelPath;
+ }
+ public LIP getLipCode() {
+ return lipCode;
+ }
+
+ public Prototype getPrototype(String name) throws CoreException {
+ Prototype result=null;
+
+ if (prototypes != null) {
+ result = prototypes.get(name); // prototype is already cached
+
+ if (result == null && modelPath != null) {
+ // cache new prototype
+ String prototypePath = modelPath.getFullPath(name);
+ if (prototypePath != null) {
+ IPath location = new Path(prototypePath);
+ IPath projectLocation = project.getLocation();
+ IFile file = null;
+
+ if (projectLocation.isPrefixOf(location)) {
+ // the file is inside the workspace
+ location = location.removeFirstSegments(projectLocation.segmentCount());
+ file = project.getFile(location);
+ } else {
+ // file is outside workspace : create link in /lib
+ IFolder lib = project.getFolder("lib");
+ if (!lib.exists()) {
+ lib.create(false, true, null);
+ }
+ file = lib.getFile(new Path(location.lastSegment()));
+ if (! file.isAccessible() && ! file.exists()) {
+ file.createLink(location, IResource.NONE, null);
+ //
+ //ResourceAttributes attrib = new ResourceAttributes();
+ //attrib.setReadOnly(true);
+ //file.setResourceAttributes(attrib);
+ //
+ }
+ }
+ result = parsePrototype(file, file.getContents(), new ILisaacErrorHandler() {
+ public void fatalError(String msg, Position position) {
+ }
+ public void semanticError(String msg, Position position) {
+ }
+ public void syntaxError(String msg, Position position) {
+ }
+ public void warning(String msg, Position position) {
+ }
+ public void enableErrorReport(boolean enable) {
+ }
+ });
+ }
+ }
+ }
+ return result;
+ }
+
+ public void refreshPresentation() {
+ final IWorkbenchPart part = currentEditor;
+ Display display = PlatformUI.getWorkbench().getDisplay();
+
+ if (currentEditor != null) {
+ display.asyncExec(new Runnable() {
+ public void run() {
+ ((AbstractLisaacEditor)part).refreshPresentation();
+ }
+ });
+ }
+ }
+
+ public void accept(final ILisaacFileVisitor visitor) {
+ try {
+ project.accept(new IResourceVisitor() {
+ public boolean visit(IResource resource) throws CoreException {
+ if (resource instanceof IFile) {
+ if (resource.getName().endsWith(".li")) {
+ String name = extractPrototypeName(resource.getName());
+ visitor.visit(getPrototype(name));
+ }
+ }
+ return true;
+ }
+ });
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /** parse and create part of current model */
+ public Prototype parsePrototype(IFile file, InputStream contents, ILisaacErrorHandler reporter) {
+ this.reporter = reporter;
+
+ String name = file.getName();
+ String prototypeName = extractPrototypeName(name);
+
+ modelPath.addPath(prototypeName, file.getLocation());
+
+ parser = new LisaacParser(prototypeName, contents, this);
+ Prototype prototype = new Prototype(file, prototypeName, this);
+
+ ILisaacContext context = parser.readContext();
+ while (context != null) {
+ if (context.parseDefinition(prototype)) {
+ context = parser.readContext();
+ } else {
+ context = context.getNextContext();
+ }
+ }
+ parser.setLastSection(null);// close last section
+
+ // add new prototype to current model
+ prototypes.put(prototype.getName(), prototype);
+ return prototype;
+ }
+
+ /** remove part of current model */
+ public void removePrototype(IResource resource) {
+ prototypes.remove(extractPrototypeName(resource.getName()));
+ }
+
+ /** parse and create part of current model
+ * @throws CoreException */
+ public void parseLip(String name, InputStream contents, ILisaacErrorHandler reporter) throws CoreException {
+ this.reporter = reporter;
+
+ lipCode = new LIP(name);
+ LipParser lipParser = new LipParser(contents, this);
+ if (! lipParser.parse()) {
+ reporter.syntaxError("Syntax error.", lipParser.getPosition());
+ return;
+ }
+
+ /* // parse lip parents
+ for (int i=0; i<lipCode.getParentCount(); i++) {
+ String parent = lipCode.getParent(i);
+ IFile file=null;
+ if (parent.equals("")) { // lisaac make.lip
+ // TODO get lisaac directory
+ return;
+ } else {
+ file = project.getFile(parent);
+ }
+ lipParser = new LipParser(file.getContents(), this);
+ if (! lipParser.parse()) {
+ reporter.syntaxError("Syntax error.", lipParser.getPosition());
+ }
+ }*/
+ }
+
+ /** remove part of current model */
+ public void removeLip(IResource resource) {
+ // TODO remove lip
+ }
+
+ /** get little name of prototype instead of full path */
+ public static String extractPrototypeName(String s) {
+ int idx = s.indexOf('.');
+ if (idx != -1) {
+ return (s.substring(0, idx)).toUpperCase();
+ }
+ return s.toUpperCase();
+ }
+
+ public ILisaacErrorHandler getReporter() {
+ return reporter;
+ }
+
+ /**
+ * Get the lisaac model associated with the given project.
+ * @param p A lisaac project
+ * @return The associated lisaac model
+ */
+ public static LisaacModel getModel(IProject p) {
+ if (modelList != null) {
+ return modelList.get(p);
+ }
+ return null;
+ }
+
+ public static Prototype getCurrentPrototype() throws CoreException {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (w == null) {
+ return null;
+ }
+ IPartService service = w.getPartService();
+ if (service == null) {
+ return null;
+ }
+ IWorkbenchPart part = service.getActivePart();
+ if (part == null || !(part instanceof LisaacEditor)) {
+ part = currentEditor;
+ }
+ if (part instanceof LisaacEditor) {
+ IProject project = ((LisaacEditor)part).getProject();
+ String filename = ((LisaacEditor)part).getFileName();
+
+ LisaacModel model = LisaacModel.getModel(project);
+ if (model != null) {
+ return model.getPrototype(extractPrototypeName(filename));
+ }
+ }
+ return null;
+ }
+
+ public void refreshPath() {
+ // create lisaac path
+ modelPath = new LisaacPath(project, "make.lip"); // TODO get lip from property page
+ }
+
+ public boolean needCompilation() {
+ return !isProjectCompiled;
+ }
+
+ public void setCompiled(boolean done) {
+ isProjectCompiled = done;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/LisaacParser.java b/editor/eclipse/src/org/lisaac/ldt/model/LisaacParser.java
new file mode 100644
index 0000000..cc57e8a
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/LisaacParser.java
@@ -0,0 +1,1559 @@
+package org.lisaac.ldt.model;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.lisaac.ldt.model.items.IArgument;
+import org.lisaac.ldt.model.items.ICode;
+import org.lisaac.ldt.model.items.IConstant;
+import org.lisaac.ldt.model.items.ITMArgs;
+import org.lisaac.ldt.model.items.ITMArgument;
+import org.lisaac.ldt.model.items.ITMBlock;
+import org.lisaac.ldt.model.items.ITMCharacter;
+import org.lisaac.ldt.model.items.ITMExpression;
+import org.lisaac.ldt.model.items.ITMExternal;
+import org.lisaac.ldt.model.items.ITMExternalType;
+import org.lisaac.ldt.model.items.ITMLDots;
+import org.lisaac.ldt.model.items.ITMList;
+import org.lisaac.ldt.model.items.ITMListIdf;
+import org.lisaac.ldt.model.items.ITMLocal;
+import org.lisaac.ldt.model.items.ITMNumber;
+import org.lisaac.ldt.model.items.ITMOld;
+import org.lisaac.ldt.model.items.ITMOperator;
+import org.lisaac.ldt.model.items.ITMPrototype;
+import org.lisaac.ldt.model.items.ITMRead;
+import org.lisaac.ldt.model.items.ITMReadArg1;
+import org.lisaac.ldt.model.items.ITMReadArg2;
+import org.lisaac.ldt.model.items.ITMReadArgs;
+import org.lisaac.ldt.model.items.ITMReal;
+import org.lisaac.ldt.model.items.ITMResult;
+import org.lisaac.ldt.model.items.ITMString;
+import org.lisaac.ldt.model.items.ITMWrite;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.items.Section;
+import org.lisaac.ldt.model.items.Slot;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeBlock;
+import org.lisaac.ldt.model.types.TypeGeneric;
+import org.lisaac.ldt.model.types.TypeMulti;
+import org.lisaac.ldt.model.types.TypeParameter;
+import org.lisaac.ldt.model.types.TypeSelf;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+/**
+ * Lisaac Prototype Parser
+ */
+
+
+public class LisaacParser extends AbstractLisaacParser {
+
+ private String selfType;
+
+ private ILisaacContext sectionContext;
+ private ILisaacContext slotContext;
+
+ //
+ private Slot lastSlot;
+ private ITMList lastGroup;
+ private Section lastSection;
+ //
+
+ public LisaacParser(String selfType, InputStream contents, ILisaacModel model) {
+ super(contents, model);
+ this.model = model;
+ this.selfType = selfType;
+ sectionContext = new SectionContext(this);
+ slotContext = new SlotContext(this);
+
+ initialize();
+ }
+
+ public LisaacParser(String selfType, String contents) {
+ super(contents);
+ this.selfType = selfType;
+ initialize();
+ }
+
+ public void initialize() {
+ //
+ // initialisations
+ //
+ super.initialize();
+ TypeSimple.init();
+ }
+
+ public void enableErrorReport(boolean enable) {
+ reporter.enableErrorReport(enable);
+ }
+
+ public ILisaacContext getSectionContext() {
+ return sectionContext;
+ }
+
+ public Slot getLastSlot() {
+ return lastSlot;
+ }
+
+ public void setLastSection(Section section) {
+ if (lastSection != null) {
+ // update last section length
+ Position pos = lastSection.getPosition();
+ pos.setLength(position - pos.offset);
+
+ // update link
+ lastSection.setNext(section);
+ }
+ lastSection = section;
+ }
+
+ //
+ // Lisaac Prototype Parser
+ //
+
+ //++ TYPE_LIST -> TYPE { ',' TYPE }
+ public ITypeMono[] readTypeList(boolean isSection) {
+ ArrayList<ITypeMono> lst=null;
+ ITypeMono t;
+
+ t = readType(false);
+ if (t != null) {
+ if (isSection) {
+ if (! (t instanceof TypeSimple) && ! (t instanceof TypeSelf)) {
+ reporter.syntaxError("For a section, the prototype name only (without '('...')').", getLine());
+ return null;
+ }
+ }
+ lst = new ArrayList<ITypeMono>();
+ lst.add(t);
+ while (readCharacter(',')) {
+ t = readType(false);
+ if (t == null) {
+ reporter.syntaxError("Incorrect type list.", getLine());
+ return null;
+ }
+ if (isSection) {
+ if (! (t instanceof TypeSimple) && ! (t instanceof TypeSelf)) {
+ reporter.syntaxError("For a section, the prototype name only (without '('...')').", getLine());
+ return null;
+ }
+ }
+ lst.add(t);
+ }
+ // TODO alias lst
+ }
+ if (lst != null) {
+ return lst.toArray(new ITypeMono[lst.size()]);
+ }
+ return null;
+ }
+
+ //++ TYPE -> '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
+ //++ | [type] PROTOTYPE [ CONTRACT ]
+ public ITypeMono readType (boolean isLocal) {
+ ITypeMono result=null;
+ ITypeMono[] lst=null;
+ IType typ_arg=null,typ_res=null;
+ String style=null;
+
+ if (readCharacter('{')) {
+ // '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
+ if (readCharacter('(')) {
+ // Read vector argument.
+ lst = readTypeList(false);
+ if (lst == null) {
+ reporter.syntaxError("Incorrect type list.", getLine());
+ return null;
+ }
+ if (lst.length == 1) {
+ typ_arg = lst[0];
+ } else {
+ typ_arg = TypeMulti.get(lst);
+ }
+ if (! readCharacter(')')) {
+ reporter.syntaxError("Added ')'.", getLine());
+ return null;
+ }
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';'.", getLine());
+ }
+ // Read result type.
+ lst = readTypeList(false);
+ } else {
+
+ lst = readTypeList(false);
+ if (lst != null) {
+ if (readCharacter(';')) {
+ if (lst.length == 1) {
+ typ_arg = lst[0];
+ } else {
+ typ_arg = TypeMulti.get(lst);
+ // TODO warning "Added 'typ_arg'."
+ }
+ // Read result type.
+ lst = readTypeList(false);
+ }
+ }
+ }
+ if (lst != null) {
+ if (lst.length == 1) {
+ typ_res = lst[0];
+ } else {
+ typ_res = TypeMulti.get(lst);
+ }
+ }
+ if (! readCharacter('}')) {
+ reporter.syntaxError("Added '}'.", getLine());
+ return null;
+ }
+ result = TypeBlock.get(typ_arg, typ_res);
+ } else {
+ // Expanded | Strict
+ if (readThisKeyword(ILisaacModel.keyword_expanded) ||
+ readThisKeyword(ILisaacModel.keyword_strict)) {
+
+ style = getLastString();
+ if (isLocal && (style.equals(ILisaacModel.keyword_expanded))) {
+ int len = ILisaacModel.keyword_expanded.length();
+ reporter.syntaxError("`Expanded' is not possible.", getPosition(len));
+ }
+ }
+ // PROTOTYPE
+ result = readPrototype(style);
+
+ // TODO read contract
+ }
+ return result;
+ }
+
+ //++ PROTOTYPE -> cap_identifier{('.'|'...')cap_identifier}['('PARAM_TYPE{','PARAM_TYPE}')']
+ public ITypeMono readPrototype(String style) {
+ ITypeMono result=null;
+ String name=null;
+
+ if (readCapIdentifier()) {
+ // TODO syntax {('.'|'...')cap_identifier}
+ name = getString(lastString);
+ if (readCharacter('(')) {
+ //
+ // Genericity.
+ //
+ ArrayList<ITypeMono> genericity = new ArrayList<ITypeMono>();
+ do {
+ ITypeMono t = readParamType();
+ if (t == null) {
+ reporter.syntaxError("Type needed.", getLine());
+ return null;
+ }
+ genericity.add(t);
+ } while (readCharacter(','));
+ // alias genericity array...
+ result = new TypeGeneric(name, style, genericity.toArray(new ITypeMono[genericity.size()]));
+
+ if (! readCharacter(')')) {
+ reporter.syntaxError("Added ')'.", getLine());
+ return result;
+ }
+ } else {
+ // Simple type.
+ if (isParameterType) {
+ if (style != null) {
+ reporter.warning("Style `"+style+"' for parameter type is ignored.", getPosition(name.length()));
+ }
+ result = TypeParameter.get(name);
+ } else if (style == null) {
+ if (name.equals(ILisaacModel.prototype_self)) {
+ result = TypeSelf.get(selfType);
+ } else {
+ result = TypeSimple.get(name);
+ }
+ } else {
+ if (name.equals(ILisaacModel.prototype_self)) {
+ reporter.warning("Style `"+style+"' ignored.", getPosition(name.length()));
+ result = TypeSelf.get(selfType);
+ } else {
+ if (name.equals(ILisaacModel.prototype_self)) {
+ result = TypeSelf.get(selfType);
+ } else {
+ result = TypeSimple.get(name);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ //++ PARAM_TYPE -> TYPE
+ //++ | CONSTANT
+ //++ | identifier
+ private ITypeMono readParamType() {
+ ITypeMono result = readType(false);
+ if (result == null) {
+ IConstant cst = readConstant();
+ if (cst != null) {
+ // TODO compiler not yet implemented
+ } else if (readIdentifier()) {
+ // TODO compiler not yet implemented
+ }
+ }
+ return result;
+ }
+
+ //++ SLOT -> style TYPE_SLOT [':' (TYPE|'('TYPE_LIST')') ][ affect DEF_SLOT ]';'
+ public boolean readSlot(Prototype prototype) {
+ char affect;
+ boolean result=false;
+ IType t;
+
+ char style = readStyle();
+ if (style != ' ') {
+ //
+ // Classic slot.
+ //
+ result = true;
+ lastSlot = readTypeSlot();
+ if (lastSlot == null) {
+ reporter.syntaxError("Incorrect slot declaration.", getLine());
+ return false;
+ }
+ lastSlot.setStyle(style);
+
+ if (readAffect()) {
+ affect = lastString.charAt(0);
+ } else {
+ affect = ' ';
+ }
+ // ':' (TYPE|'('TYPE_LIST')'
+ if (affect == ' ' && readCharacter(':')) {
+ if (readCharacter('(')) {
+ ITypeMono[] lt = readTypeList(false);
+ if (lt == null) {
+ reporter.syntaxError("Incorrect result type.", getLine());
+ return false;
+ }
+ if (! readCharacter(')')) {
+ reporter.warning("Added ')' is needed.", getLine());
+ }
+ t = TypeMulti.get(lt);
+ } else {
+ t = readType(false);
+ if (t == null) {
+ reporter.syntaxError("Incorrect result type.", getLine());
+ return false;
+ }
+ }
+ if (readAffect()) {
+ affect = lastString.charAt(0);
+ }
+ } else {
+ t = TypeSimple.getTypeVoid();
+ }
+ lastSlot.setResultType(t);
+ lastSlot.setAffect(affect);
+
+ setCatchComment();
+
+ if (affect != ' ') {
+ readSpace();
+
+ setCatchCommentOff();
+
+ //
+ readDefSlot();
+ //
+ }
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';'.", getLine());
+ return false;
+ }
+ // update slot body position
+ updateLine();
+ Position body = lastSlot.getPositionBody();
+ if (body.line != pos_line) {
+ body.setLength(position - body.offset);
+ } else {
+ // one line slot - delete position
+ lastSlot.setBody(null);
+ }
+
+ if (lastComment != null && lastComment.length() > 0) {
+ lastSlot.setComment(lastComment);
+ }
+ if (lastComment != null && lastSection.isInheritOrInsert()) {
+ // Add parent slot
+ Slot s = prototype.getParentSlot(lastSlot.getName());
+ if (s != null) {
+ reporter.semanticError("Double slot declaration.", getPosition());
+ } else {
+ prototype.addParentSlot(lastSlot);
+ }
+ } else {
+ // Added slot in prototype :
+ Slot s = prototype.getSlot(lastSlot.getName());
+ if (s != null) {
+ reporter.semanticError("Double slot declaration.", getPosition());
+ } else {
+ prototype.addSlot(lastSlot);
+ lastSection.addSlot(lastSlot);
+ }
+ }
+ }
+ return result;
+ }
+
+ //++ DEF_SLOT -> [CONTRACT] EXPR [CONTRACT]
+ private void readDefSlot() {
+
+ readRequire();
+ ICode expr = readExpr();
+ if (expr == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ }
+ lastSlot.setValue(expr);
+ readEnsure();
+ }
+
+ //++ TYPE_SLOT -> [ LOC_ARG '.' ] identifier [ LOC_ARG { identifier LOC_ARG } ]
+ //++ | [ LOC_ARG ] '\'' operator '\'' [("Left"|"Right") [integer]] [LOC_ARG]
+ public Slot readTypeSlot() {
+ Slot result=null;
+ IArgument arg=null;
+
+ ArrayList<IArgument> list_arg = new ArrayList<IArgument>();
+
+ arg = readLocArg(false,true);
+ if (arg == null) {
+ if (readCharacter('\'')) {
+ result = readSlotOperator(list_arg);
+ } else {
+ //arg = new ITMArgument(ILisaacModel.variable_self, TypeSimple.getTypeSelf());
+ //list_arg.add(arg); no use here?
+
+ result = readSlotKeyword(list_arg);
+ }
+ } else {
+ list_arg.add(arg);
+ if (readCharacter('.')) {
+ result = readSlotKeyword(list_arg);
+ } else if (readCharacter('\'')) {
+ result = readSlotOperator(list_arg);
+ }
+ }
+ if (result != null) {
+ result.setArgumentList(list_arg.toArray(new IArgument[list_arg.size()]));
+ }
+ return result;
+ }
+
+ private Slot readSlotKeyword(ArrayList<IArgument> list_arg) {
+ Slot result=null;
+ Position slotPosition = getPosition();
+ Position slotBody = getPosition();
+ int start_pos = position;
+
+ if (readIdentifier()) {
+ String n = new String(lastString);
+
+ ArrayList<String> keywords = new ArrayList<String>();
+ keywords.add(n);
+
+ IArgument arg = readLocArg(false,false);
+ if (arg != null) {
+ list_arg.add(arg);
+ if (readIdentifier()) {
+ // TODO section external -> syntax error
+ do {
+ n += "__" + lastString;
+ keywords.add(new String(lastString));
+
+ arg = readLocArg(false,false);
+ if (arg == null) {
+ reporter.syntaxError("Incorrect symbol.", getLine());
+ return null;
+ }
+ list_arg.add(arg);
+ } while (readIdentifier());
+ }
+ }
+ slotPosition.setLength(position - start_pos);
+ result = new Slot(slotPosition, getString(n), lastSection);
+ //
+ result.setKeywordList(keywords.toArray(new String[keywords.size()]));
+ result.setBody(slotBody);
+ //
+ }
+ return result;
+ }
+
+ //++ LOC_ARG -> identifier ':' TYPE
+ //++ | '(' LOCAL ')'
+ public IArgument readLocArg(boolean mute, boolean selfFirst) {
+ IArgument result=null;
+
+ if ((selfFirst && readThisKeyword(ILisaacModel.variable_self)) ||
+ (! selfFirst && readIdentifier())) {
+
+ int startPos = position;
+
+ //Position pos = getPosition();
+ String n = new String(lastString);
+ if (readCharacter(':') && lastCharacter() != '=') {
+ ITypeMono t = readType(true);
+ if (t == null) {
+ reporter.syntaxError("Incorrect type.", getLine());
+ return null;
+ }
+
+ // TODO SELF
+ /*if (selfFirst && (t != TypeSimple.getTypeSelf()) &&
+ ((object.name != ALIAS_STR.prototype_block) ||
+ {tb ?= t; tb = NULL})) {
+ reporter.syntaxError("Type `SELF' is needed.", getPosition());
+ }*/
+ Position p = getPosition();
+ p.offset = startPos;
+ result = new ITMArgument(n, t, p);
+ } else {
+ if (! mute) {
+ reporter.warning("Added ':' is needed.", getLine());
+ }
+ }
+ } else if (readCharacter('(')) {
+ result = readLocalArg(mute, selfFirst);
+ if (result == null) {
+ if (! mute) {
+ reporter.syntaxError("Incorrect argument definition.", getLine());
+ return null;
+ }
+ } else {
+ if (! readCharacter(')')) {
+ reporter.warning("Added ')'.", getPosition());
+ }
+ }
+ }
+ return result;
+ }
+
+ private IArgument readLocalArg(boolean m, boolean s) {
+ IArgument result=null;
+ boolean mute = m;
+ int startPos;
+
+ int firstPos = position;
+
+ if ((s && readThisKeyword(ILisaacModel.variable_self)) ||
+ readIdentifier()) {
+ List<String> name = new ArrayList<String>();
+ List<ITypeMono> type = new ArrayList<ITypeMono>();
+ int beg = 0;
+
+
+ do {
+ if (name.size() != 0 && !readIdentifier() && !mute) {
+ reporter.syntaxError("Incorrect argument identifier.", getLine());
+ return null;
+ }
+
+ startPos = position;
+
+ name.add(lastString);
+ if (readCharacter(':') && lastCharacter() != '=') {
+ mute = false;
+ ITypeMono t = readType(true);
+
+ if (t == null) {
+ reporter.syntaxError("Incorrect argument type.", getLine());
+ return null;
+ }
+ for (int i=beg; i<name.size(); i++) {
+ type.add(t);
+ }
+ beg = name.size();
+ }
+ } while (readCharacter(','));
+
+ if (beg != name.size()) {
+ if (! mute) {
+ reporter.syntaxError("Incorrect argument type.", getLine());
+ return null;
+ }
+ // free arrays..
+ } else {
+ /*if (s && (
+ type.get(0) != TypeSimple.getTypeSelf() ||
+ )) {
+ // TODO syntax_error (current_position,"Type `SELF' is needed.");
+ }*/
+
+ if (name.size() == 1) {
+ // Single Argument.
+ Position p = new Position(0,0,startPos, 0);
+
+ result = new ITMArgument(name.get(0), type.get(0), p);
+
+ // free arrays
+ } else {
+ // Vector Arguments.
+ // alias arrays...
+ TypeMulti tm = new TypeMulti(type.toArray(new ITypeMono[type.size()]));
+ result = new ITMArgs(name.toArray(new String[name.size()]), tm, getPosition(position - firstPos));
+ }
+ }
+ }
+ return result;
+ }
+
+ private Slot readSlotOperator(ArrayList<IArgument> list_arg) {
+ Slot result=null;
+ String associativity=null;
+ int priority=0;
+ Position slotPosition = getPosition();
+ Position slotBody = getPosition();
+
+ if (! readOperator()) {
+ reporter.syntaxError("Operator is needed.", getLine());
+ return null;
+ }
+ if (lastString.equals(ILisaacModel.symbol_equal) ||
+ lastString.equals(ILisaacModel.symbol_not_equal)) {
+ reporter.syntaxError("Incorrect operator.", getLine());
+ return null;
+ }
+ String name = new String(lastString);
+ slotPosition.setLength(name.length());
+
+ if (! readCharacter('\'')) {
+ reporter.warning("Added `''.", getLine());
+ }
+ if (readThisKeyword(ILisaacModel.keyword_left) ||
+ readThisKeyword(ILisaacModel.keyword_right)) {
+ associativity = new String(lastString);
+ if (readInteger()) {
+ priority = (int) lastInteger;
+ }
+ }
+ if (list_arg.isEmpty()) {
+ // Prefix operator.
+ IArgument arg = readLocArg(false, true);
+ if (arg == null) {
+ reporter.syntaxError("Operator declaration invalid.", getLine());
+ return null;
+ }
+ if (arg != null) {
+ list_arg.add(arg);
+ }
+ name = getOperator("__prefix", name);
+ if (associativity != null) {
+ reporter.syntaxError("No associativity for postfix operator.", getLine());
+ }
+ } else {
+ IArgument arg = readLocArg(false,false);
+ if (arg != null) {
+ // Infix operator.
+ list_arg.add(arg);
+ name = getOperator("__infix", name);
+ if (associativity == null) {
+ associativity = ILisaacModel.keyword_left;
+ }
+ } else {
+ // Postfix operator.
+ name = getOperator("__postfix", name);
+ if (associativity != null) {
+ reporter.syntaxError("No associativity for prefix operator.", getLine());
+ }
+ }
+ }
+ result = new Slot(slotPosition, name, lastSection);
+ result.setAssociativity(associativity, priority);
+ result.setBody(slotBody);
+
+ return result;
+ }
+
+ private String getOperator(String typ, String op) {
+ StringBuffer s = new StringBuffer(typ);
+
+
+ for (int i=0; i<op.length(); i++) {
+ char c = op.charAt(i);
+ switch (c) {
+ case '+': s.append("_add"); break;
+ case '-': s.append("_sub"); break;
+ case '~': s.append("_logicnot"); break;
+ case '!': s.append("_not"); break;
+ case '/': s.append("_div"); break;
+ case '*': s.append("_mul"); break;
+ case '^': s.append("_xor"); break;
+ case '%': s.append("_mod"); break;
+ case '>': s.append("_greater"); break;
+ case '<': s.append("_less"); break;
+ case '=': s.append("_equal"); break;
+ case '\\': s.append("_notdiv"); break;
+ case '|': s.append("_or"); break;
+ case '&': s.append("_and"); break;
+ case '$': s.append("_dollar"); break;
+ case '#': s.append("_diese"); break;
+ case '@': s.append("_at"); break;
+ case '?': s.append("_ask"); break;
+ }
+ }
+ return getString(s.toString()); // alias string
+ }
+
+ //++ EXPR -> { ASSIGN !!AMBIGU!! affect } EXPR_OPERATOR
+ //++ ASSIGN -> '(' IDF_ASSIGN { ',' IDF_ASSIGN } ')'
+ //++ | IDF_ASSIGN
+ //++ IDF_ASSIGN -> identifier { identifier }
+ public ICode readExpr() {
+ ICode result=null;
+ boolean again;
+ String string_tmp2="";
+
+ // !! AMBIGU resolution !!
+ saveContext();
+
+ if (readCharacter('(')) {
+ ArrayList<String> l_assignment = new ArrayList<String>();
+ do {
+ again = false;
+ if (readIdentifier()) {
+ //p = position - lastString.length();
+
+ string_tmp2 = new String(lastString);
+ while (readIdentifier()) {
+ string_tmp2 += "__" + lastString;
+ }
+ String name = getString(string_tmp2);
+ l_assignment.add(name);
+
+ if (readCharacter(',')) {
+ again = true;
+ }
+ }
+ } while(again);
+
+ if (!l_assignment.isEmpty() && readCharacter(')') && readAffect()) {
+ result = new ITMListIdf(l_assignment);
+
+ char affect = lastString.charAt(0);
+ ICode value = readExpr();
+ if (value == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ if (affect == '<') {
+ reporter.syntaxError("Impossible '<-' style assignment with vector.", getPosition(lastString.length()));
+ return null;
+ }
+ result = new ITMWrite(result, value, affect);
+ } else {
+ // FREE l_assignment
+ }
+ } else if (readIdentifier()) {
+ //p = position - lastString.length();
+ string_tmp2 = new String(lastString);
+ while (readIdentifier()) {
+ string_tmp2 += "__" + lastString;
+ }
+ String name = getString(string_tmp2);
+
+ if (readAffect()) {
+ result = new ITMRead(name);
+
+ char affect = lastString.charAt(0);
+ ICode value = readExpr();
+ if (value == null) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ return null;
+ }
+ result = new ITMWrite(result, value, affect);
+ }
+ }
+ if (result == null) {
+ restoreContext();
+ result = readExprOperator();
+ }
+ return result;
+ }
+
+ //++ EXPR_OPERATOR-> { operator } EXPR_MESSAGE { operator {operator} EXPR_MESSAGE } {operator}
+ private ICode readExprOperator() {
+ ICode result=null;
+ int first_msg,last_msg;
+
+ ArrayList<ICode> l_expr = new ArrayList<ICode>();
+ while (readOperator()) {
+ ICode expr = new ITMOperator(new String(lastString));
+ l_expr.add(expr);
+ }
+ ICode expr = readExprMessage();
+ if (expr == null) {
+ // Error.
+ if (l_expr.size() > 0) {
+ reporter.syntaxError("Incorrect expression.", getLine());
+ }
+ // free l_expr
+ } else {
+ // { operator {operator} EXPR_MESSAGE } {operator}
+ first_msg = l_expr.size();
+ do {
+ last_msg = l_expr.size();
+ l_expr.add(expr);
+ if (readOperator()) {
+ do {
+ expr = new ITMOperator(new String(lastString));
+ l_expr.add(expr);
+ } while (readOperator());
+
+ expr = readExprMessage();
+ } else {
+ expr = null;
+ }
+ } while (expr != null);
+
+ // Last Post-fix operator.
+ while (last_msg < l_expr.size()-1) {
+ ITMOperator itm_op = (ITMOperator) l_expr.get(last_msg+1);
+ expr = new ITMReadArg1(getOperator("__postfix", itm_op.getName()), l_expr.get(last_msg));
+
+ l_expr.set(last_msg, expr);
+ l_expr.remove(last_msg+1);
+ }
+ if (last_msg - first_msg < 3) {
+ // First Pre-fix operator.
+ while (first_msg != 0) {
+ ITMOperator itm_op = (ITMOperator) l_expr.get(first_msg - 1);
+ expr = new ITMReadArg1(getOperator("__prefix", itm_op.getName()), l_expr.get(first_msg));
+
+ l_expr.add(first_msg, expr);
+ first_msg = first_msg - 1;
+ l_expr.remove(first_msg);
+ }
+ }
+ if (l_expr.size() == 1) {
+ result = l_expr.get(0);// first
+ // free l_expr
+ } else if (l_expr.size() == 3) {
+ // Simple binary message.
+ ITMOperator itm_op = (ITMOperator) l_expr.get(1);// second
+ result = new ITMReadArg2(getOperator("__infix", itm_op.getName()),
+ l_expr.get(0),
+ l_expr.get(2));
+ // free l_expr
+ } else {
+ // Complex expression.
+ result = new ITMExpression(l_expr.toArray(new ICode[l_expr.size()]));
+ }
+ }
+ return result;
+ }
+
+ //++ EXPR_MESSAGE -> EXPR_BASE { '.' SEND_MSG }
+ protected ICode readExprMessage() {
+
+ ICode result = readExprBase();
+ if (result != null) {
+ while (readCharacter('.')) {
+ result = readSendMsg(result);
+ if (result == null) {
+ reporter.syntaxError("Incorrect message.", getLine());
+ return null;
+ }
+ }
+ }
+ return result;
+ }
+
+ //++ EXPR_BASE -> "Old" EXPR
+ //++ | EXPR_PRIMARY
+ //++ | SEND_MSG
+ public ICode readExprBase() {
+ ICode result=null;
+
+ if (readThisKeyword(ILisaacModel.keyword_old)) {
+ ICode old_value = readExpr();
+ if (old_value == null) {
+ reporter.syntaxError("Incorrect `Old' expression.", getLine());
+ return null;
+ }
+ result = new ITMOld(old_value);
+ } else {
+ result = readExprPrimary();
+ if (result == null) {
+ result = readSendMsg(null);
+ }
+ }
+ return result;
+ }
+
+ //++ EXPR_PRIMARY -> "Self"
+ //++ | result
+ //++ | PROTOTYPE
+ //++ | CONSTANT
+ //++ | '(' GROUP ')'
+ //++ | '{' [ LOC_ARG ';' !! AMBIGU!! ] GROUP '}'
+ //++ | external [ ':' ['('] TYPE ['{' TYPE_LIST '}'] [')'] ]
+ public ICode readExprPrimary() {
+ ICode result=null;
+ String result_id=null;
+ ITypeMono type=null;
+ ITMList group_sav=null;
+
+ readSpace();
+ Position pos = getPosition();
+
+ if (readThisKeyword(ILisaacModel.variable_self)) {
+ result = new ITMRead(new String(lastString));
+ } else if (readThisKeyword(ILisaacModel.keyword_result)) {
+ if (lastCharacter() == '_') {
+ position = position + 1;
+ string_tmp = "" + ILisaacModel.keyword_result + "_";
+
+ while (Character.isDigit(lastCharacter())) {
+ string_tmp += lastCharacter();
+ position = position + 1;
+ }
+ if (string_tmp.length() <= 0) {
+ reporter.syntaxError("Incorrect Result number.", getLine());
+ }
+ result_id = getString(string_tmp);
+ } else {
+ result_id = ILisaacModel.keyword_result;
+ }
+ result = new ITMRead(result_id);
+
+ } else if ((type = readPrototype(null)) != null) {
+ result = new ITMPrototype(type, pos);
+
+ } else if ((result = readConstant()) != null) {
+ } else if (readCharacter('(')) {
+ group_sav = lastGroup;
+ lastGroup = new ITMList(lastSlot, position);
+ result = lastGroup;
+
+ lastGroup.setCode(readGroup());
+ if (! readCharacter(')')) {
+ reporter.syntaxError("Added ')'.", getLine());
+ return null;
+ }
+ lastGroup.setEndOffset(position);
+ lastGroup = group_sav;
+ } else if (readCharacter('{')) {
+ group_sav = lastGroup;
+ lastGroup = new ITMList(lastSlot, position);
+
+ saveContext(); // !! SAVE CONTEXT !!
+
+ //
+ IArgument arg = readLocArg(true,false);
+ //
+ if (arg != null) {
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';'.", getLine());
+ return null;
+ }
+ } else {
+ restoreContext(); // !! RESTORE CONTEXT !!
+ }
+ result = new ITMBlock(lastGroup, arg, lastSlot);
+
+ lastGroup.setCode(readGroup());
+ if (! readCharacter('}')) {
+ reporter.syntaxError("Added '}'.", getLine());
+ return null;
+ }
+ lastGroup.setEndOffset(position);
+ lastGroup = group_sav;
+ } else if (readExternal()) {
+ if (! readCharacter(':')) {
+ result = new ITMExternal(new String(lastString));
+ } else {
+ boolean persistant = readCharacter('(');
+ ITMExternalType ext = new ITMExternalType(new String(lastString), persistant);
+ type = readType(false);
+ if (type == null) {
+ reporter.syntaxError("Incorrect type.", getLine());
+ return null;
+ }
+ ext.setType(type);
+ if (readCharacter('{')) {
+ ITypeMono[] ltype = readTypeList(false);
+ if (ltype == null) {
+ reporter.syntaxError("Incorrect live type list.", getLine());
+ return null;
+ }
+ if (! readCharacter('}')) {
+ reporter.syntaxError("Added '}'.", getLine());
+ return null;
+ }
+ ext.setTypeList(ltype);
+ }
+ if (ext.isPersistant() && (! readCharacter(')'))) {
+ reporter.syntaxError("Added '}'.", getLine());
+ return null;
+ }
+ result = ext;
+ }
+ }
+ return result;
+ }
+
+ //++ CONSTANT -> integer
+ //++ | real
+ //++ | characters
+ //++ | string
+ private IConstant readConstant() {
+ IConstant result=null;
+
+ if (readReal()) {
+ result = new ITMReal(new String(lastReal));
+ } else if (readInteger()) {
+ result = new ITMNumber(lastInteger);
+ } else if (readCharacters()) {
+ result = new ITMCharacter(new String(lastString));
+ } else if (readString()) {
+ result = new ITMString(new String(lastString));
+ }
+ return result;
+ }
+
+ //++ GROUP -> DEF_LOCAL {EXPR ';'} [ EXPR {',' {EXPR ';'} EXPR } ]
+ private ICode[] readGroup() {
+ readDefLocal();
+
+ ArrayList<ICode> result = new ArrayList<ICode>();
+ ICode e = readExpr();
+ while (e != null && readCharacter(';')) {
+ result.add(e);
+ e = readExpr();
+ }
+ if (e != null) {
+ if (readCharacter(',')) {
+ do {
+ e = new ITMResult(e);
+ result.add(e);
+ e = readExpr();
+ while (e != null && readCharacter(';')) {
+ result.add(e);
+ e = readExpr();
+ }
+ if (e == null) {
+ reporter.syntaxError("Incorrect multiple result expression.", getLine());
+ return null;
+ }
+ } while (readCharacter(','));
+ }
+ e = new ITMResult(e);
+ result.add(e);
+ }
+ return result.toArray(new ICode[result.size()]);
+ }
+
+ //++ DEF_LOCAL -> { style LOCAL ';' } !! AMBIGU !!
+ private void readDefLocal() {
+ List<ITMLocal> loc_lst;
+
+ saveContext(); // !! SAVE CONTEXT !!
+
+ char style = readStyle();
+ ArrayList<ITMLocal> local_list = new ArrayList<ITMLocal>();
+ ArrayList<ITMLocal> static_list = new ArrayList<ITMLocal>();
+
+ while (style != ' ') {
+ loc_lst = readLocal(true);
+ if (loc_lst != null) {
+ if (style == '+') {
+ local_list.addAll(loc_lst);
+ } else {
+ static_list.addAll(loc_lst);
+ }
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';'.", getLine());
+ }
+ saveContext(); // !! SAVE CONTEXT !!
+
+ style = readStyle();
+ } else {
+ restoreContext(); // !! RESTORE CONTEXT !!
+ style = ' ';
+ }
+ }
+ if (local_list.isEmpty()) {
+ // free local_list
+ } else {
+ lastGroup.setLocalList(local_list.toArray(new ITMLocal[local_list.size()]));
+ }
+ if (static_list.isEmpty()) {
+ // free static_list
+ } else {
+ lastGroup.setStaticList(static_list.toArray(new ITMLocal[static_list.size()]));
+ }
+ }
+
+ //++ SEND_MSG -> identifier [ ARGUMENT { identifier ARGUMENT } ]
+ public ICode readSendMsg(ICode firstArg) {
+ ICode result=null;
+
+ if (readIdentifier()) {
+ //
+ // Classic Message.
+ //
+ String n = getString(lastString);// create alias
+
+ // Argument list.
+ LinkedList<ICode> l_arg = new LinkedList<ICode>();
+ ICode arg = readArgument();
+ if (arg != null) {
+ l_arg.addLast(arg);
+ while (readIdentifier()) {
+ n += "__" + lastString; // FIXME: alias pb
+ arg = readArgument();
+ if (arg == null) {
+ reporter.syntaxError("Incorrect argument.", getLine());
+ return null;
+ }
+ l_arg.addLast(arg);
+ }
+ }
+ String name = getString(n); // FIXME alias pb
+ if (l_arg.isEmpty()) {
+ if (firstArg == null) {
+ // Local ou Implicite Slot without argument.
+ result = new ITMRead(name);
+ } else {
+ result = new ITMReadArg1(name, firstArg);
+ }
+ // free l_arg
+ } else if (l_arg.size() == 1) {
+ result = new ITMReadArg2(name, firstArg, l_arg.get(0));
+ // free l_arg
+ } else {
+ l_arg.addFirst(firstArg);
+ result = new ITMReadArgs(name, l_arg.toArray(new ICode[l_arg.size()]));
+ }
+ }
+ return result;
+ }
+
+ //++ ARGUMENT -> EXPR_PRIMARY
+ //++ | identifier
+ private ICode readArgument() {
+ ICode result = readExprPrimary();
+ if (result == null && readIdentifier()) {
+ result = new ITMRead(new String(lastString));
+ }
+ return result;
+ }
+
+ //++ LOCAL -> { identifier [ ':' TYPE ] ',' } identifier ':' TYPE
+ private List<ITMLocal> readLocal(boolean m) {
+ List<ITMLocal> result=null;
+ int beg = 0;
+
+ boolean mute = m;
+ if (readIdentifier()) {
+ result = new LinkedList<ITMLocal>();
+ do {
+ if (result.size() != 0 && !readIdentifier() && !mute) {
+ reporter.syntaxError("Incorrect identifier.", getLine());
+ return null;
+ }
+ ITMLocal loc = new ITMLocal(new String(lastString), getPosition());
+ result.add(loc);
+ if (readCharacter(':') && lastCharacter() != '=') {
+ mute = false;
+ ITypeMono t = readType(false);
+ if (t == null) {
+ reporter.syntaxError("Incorrect local type.", getLine());
+ return null;
+ }
+ for (int j=beg; j<result.size(); j++) {
+ result.get(j).setType(t);
+ }
+ beg = result.size(); // upper+1
+ }
+ } while(readCharacter(','));
+ if (beg != result.size()) {
+ if (mute) {
+ // free result
+ result = null;
+ } else {
+ reporter.syntaxError("Incorrect local type.", getLine());
+ return null;
+ }
+ } else {
+ }
+ }
+ return result;
+ }
+
+ public boolean readRequire() {
+ boolean result=false;
+
+ ITMList lst = readContract();
+ if (lst != null) {
+ // lastSlot.setRequire lst
+ result = true;
+ }
+ return result;
+ }
+
+ public boolean readEnsure() {
+ boolean result=false;
+
+ ITMList lst = readContract();
+ if (lst != null) {
+ // lastSlot.setEnsure lst
+ result = true;
+ }
+ return result;
+ }
+
+ //++ CONTRACT -> '[' DEF_LOCAL { ( EXPR ';' | "..." ) } ']'
+ private ITMList readContract() {
+ ITMList result = null;
+
+ if (readCharacter('[')) {
+ result = new ITMList(lastSlot, position);
+ lastGroup = result;
+
+ readDefLocal();
+
+ ArrayList<ICode> lst = new ArrayList<ICode>();
+ boolean doContinue = false;
+ do {
+ ICode e = readExpr();
+ if (e == null) {
+ doContinue = readWord(ILisaacModel.keyword_ldots);
+ if (doContinue) {
+ lst.add(new ITMLDots());
+ }
+ } else {
+ lst.add(e);
+ if (! readCharacter(';')) {
+ reporter.syntaxError("Added ';'.", getLine());
+ return null;
+ }
+ doContinue = true;
+ }
+ } while (doContinue);
+
+ if (! readCharacter(']')) {
+ reporter.syntaxError("Added ']'.", getLine());
+ return null;
+ }
+ // TODO lst add prototype void
+ result.setCode(lst.toArray(new ICode[lst.size()]));
+ result.setEndOffset(position);
+ }
+ return result;
+ }
+
+ public boolean skipUntilThisKeyword(String st) {
+ int idx;
+ int posold;
+ boolean result=false;
+
+ while (! isEOF() && ! result) {
+ idx = 0;
+ while ((readSpace() || lastCharacter() == '\n') && lastCharacter() != st.charAt(idx)) {
+ position++;
+ }
+ posold = position;
+ position++;
+ idx++;
+ if (! isEOF()) {
+ while (idx <= st.length()-1 && lastCharacter() == st.charAt(idx)) {
+ position++;
+ idx++;
+ }
+ if (idx > st.length()-1) {
+ lastString = st;
+ position = posold;
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ public String readSlotNameFromOffset(int offset, boolean modifyCurrentOffset) {
+ String result=null;
+ int oldPosition = position;
+ position = offset;
+
+ //++ TYPE_SLOT -> [ LOC_ARG '.' ] identifier [ LOC_ARG { identifier LOC_ARG } ]
+ //++ | [ LOC_ARG ] '\'' operator '\'' [("Left"|"Right") [integer]] [LOC_ARG]
+ if (! skipLocalArg(true)) {
+ if (readCharacter('\'')) {
+ result = readSlotNameOperator();
+ } else {
+ result = readSlotNameKeyword();
+ }
+ } else {
+ if (readCharacter('.')) {
+ result = readSlotNameKeyword();
+ } else if (readCharacter('\'')) {
+ result = readSlotNameOperator();
+ }
+ }
+ if (! modifyCurrentOffset) {
+ position = oldPosition;
+ }
+ return result;
+ }
+
+ //++ LOC_ARG -> identifier ':' TYPE
+ //++ | '(' LOCAL ')'
+ public boolean skipLocalArg(boolean selfFirst) {
+ boolean result=false;
+ if ((selfFirst && readThisKeyword(ILisaacModel.variable_self)) ||
+ (! selfFirst && readIdentifier())) {
+ if (readCharacter(':') && lastCharacter() != '=') {
+ return skipType();
+ }
+ } else if (readCharacter('(')) {
+ result = skipLocal(selfFirst);
+ if (! result) {
+ return false;
+ } else {
+ if (! readCharacter(')')) {
+ return false;
+ }
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ private boolean skipLocal(boolean s) {
+ boolean result = false;
+
+ if ((s && readThisKeyword(ILisaacModel.variable_self)) ||
+ readIdentifier()) {
+ int size = 0;
+ do {
+ if (size != 0 && !readIdentifier()) {
+ return false;
+ }
+ size++;
+ if (readCharacter(':') && lastCharacter() != '=') {
+ if (!skipType()) {
+ return false;
+ }
+ result = true;
+ }
+ } while (readCharacter(','));
+ }
+ return result;
+ }
+
+ private String readSlotNameKeyword() {
+ String result=null;
+
+ if (readIdentifier()) {
+ result = new String(lastString);
+
+ if (skipLocalArg(false)) {
+ if (readIdentifier()) {
+ do {
+ result += "__" + lastString;
+ if (! skipLocalArg(false)) {
+ return null;
+ }
+ } while (readIdentifier());
+ }
+ }
+ }
+ return result;
+ }
+
+ private String readSlotNameOperator() {
+ String result=null;
+
+ if (! readOperator()) {
+ return null;
+ }
+ result = new String(lastString);
+ result = getOperator("__infix", result);// TODO fix!! prefix postfix
+
+ return result;
+ }
+
+ //++ TYPE -> '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
+ //++ | [type] PROTOTYPE [ CONTRACT ]
+ public boolean skipType () {
+ boolean result=false;
+
+ if (readCharacter('{')) {
+ // '{' [ (TYPE | '(' TYPE_LIST ')') ';' ] [ TYPE_LIST ] '}'
+ if (readCharacter('(')) {
+ // Read vector argument.
+ result = skipTypeList();
+ if (! result) {
+ return false;
+ }
+ if (! readCharacter(')')) {
+ return false;
+ }
+ if (! readCharacter(';')) {
+ return false;
+ }
+ // Read result type.
+ result = skipTypeList();
+ } else {
+
+ result = skipTypeList();
+ if (result) {
+ if (readCharacter(';')) {
+ // Read result type.
+ result = skipTypeList();
+ }
+ }
+ }
+ if (! readCharacter('}')) {
+ return false;
+ }
+ result = true;
+ } else {
+ // Expanded | Strict
+ if (readThisKeyword(ILisaacModel.keyword_expanded) ||
+ readThisKeyword(ILisaacModel.keyword_strict)) {
+ }
+ // PROTOTYPE
+ result = skipPrototype();
+ // TODO read contract
+ }
+ return result;
+ }
+
+ //++ TYPE_LIST -> TYPE { ',' TYPE }
+ public boolean skipTypeList() {
+ boolean result=false;
+
+ result = skipType();
+ if (result) {
+ while (readCharacter(',')) {
+ result = skipType();
+ if (! result) {
+ return false;
+ }
+ }
+ }
+ return result;
+ }
+
+ //++ PROTOTYPE -> cap_identifier{('.'|'...')cap_identifier}['('PARAM_TYPE{','PARAM_TYPE}')']
+ public boolean skipPrototype() {
+ boolean result=false;
+
+ if (readCapIdentifier()) {
+ // TODO syntax {('.'|'...')cap_identifier}
+ if (readCharacter('(')) {
+ //
+ // Genericity.
+ //
+ do {
+ if (! skipParamType()) {
+ return false;
+ }
+ } while (readCharacter(','));
+ if (! readCharacter(')')) {
+ return false;
+ }
+ result = true;
+ } else {
+ // Simple type.
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ //++ PARAM_TYPE -> TYPE
+ //++ | CONSTANT
+ //++ | identifier
+ private boolean skipParamType() {
+ if (! skipType()) {
+ // TODO compiler not yet implemented
+ return false;
+ }
+ return true;
+ }
+
+ //++ SEND_MSG -> identifier [ ARGUMENT { identifier ARGUMENT } ]
+ public String readKeywordInSendMsg(String keyword, int keywordOffset) {
+ String result=null;
+ boolean keywordFound=false;
+
+ if (readIdentifier()) {
+ //
+ // Classic Message.
+ //
+ String n = getString(lastString);// create alias
+ if (n.compareTo(keyword) == 0 && position == keywordOffset+keyword.length()) {
+ keywordFound = true;
+ }
+ // Argument list.
+ ICode arg = readArgument();
+ if (arg != null) {
+ while (readIdentifier()) {
+ if (lastString.compareTo(keyword) == 0 && position == keywordOffset+keyword.length()) {
+ keywordFound = true;
+ }
+ n += "__" + lastString; // FIXME: alias pb
+ arg = readArgument();
+ if (arg == null) {
+ reporter.syntaxError("Incorrect argument.", getPosition());
+ return null;
+ }
+ }
+ }
+ // return slot full name
+ result = getString(n); // FIXME alias pb
+ }
+ if (! keywordFound) {
+ result = null;
+ }
+ return result;
+ }
+
+ /**
+ * Read the next context in lisaac code.
+ * @return Context at parser position
+ */
+ public ILisaacContext readContext() {
+ readSpace();
+
+ int old_pos = position;
+
+ //
+ // Try read Section Context.
+ //
+ if (readThisKeyword (ILisaacModel.keyword_section)) {
+ position = old_pos;
+ return sectionContext;
+ }
+
+ //
+ // Try read Slot Context.
+ //
+ if (readCharacter('-') || readCharacter('+')) {
+ position = old_pos;
+ return slotContext;
+ }
+ // restore old position (unread)
+ position = old_pos;
+
+ if (position >= source.length()-1) {
+ return null;
+ } else {
+ // error
+ reporter.syntaxError("Syntax error", getLine());
+ return sectionContext.getNextContext(); // go to next section
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/LisaacPath.java b/editor/eclipse/src/org/lisaac/ldt/model/LisaacPath.java
new file mode 100644
index 0000000..0872307
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/LisaacPath.java
@@ -0,0 +1,124 @@
+package org.lisaac.ldt.model;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.lisaac.ldt.launch.LisaacCompiler;
+import org.lisaac.ldt.outline.OutlineImages;
+
+
+public class LisaacPath {
+
+ private HashMap<String,String> prototypesPath;
+
+ private LisaacCompiler compiler;
+
+ private String lipFile;
+
+
+ public LisaacPath(final IProject project, String lipFile) {
+ prototypesPath = new HashMap<String,String>();
+ this.lipFile = lipFile;
+
+ refreshPath(project);
+ }
+
+ public void refreshPath(final IProject project) {
+ try {
+ compiler = new LisaacCompiler(lipFile);
+ compiler.addOption("--p");
+
+ System.out.println("===> "+compiler.toCommandLine());
+
+ try {
+ final Process process = compiler.launch(project, new NullProgressMonitor());
+
+ if (process != null) {
+ try {
+ // wait for end of process
+ process.waitFor();
+ } catch(InterruptedException e) {
+ }
+ }
+ BufferedReader bufferIn = new BufferedReader(
+ new InputStreamReader(
+ new FileInputStream(project.getLocation()+"/current_path.txt")));
+
+ String line;
+ while ((line = bufferIn.readLine()) != null) {
+ createPath(line);
+ }
+ bufferIn.close();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } catch (CoreException e) {
+ //LisaacPlugin.log(status) // TODO log error
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getFullPath(String prototypeName) {
+ if (prototypesPath.containsKey(prototypeName)) {
+ return prototypesPath.get(prototypeName);
+ }
+ return null;
+ }
+
+
+ private void createPath(String fullPath) {
+ int index = fullPath.lastIndexOf("/");
+ String prototypeName = fullPath.substring(index+1);
+ index = prototypeName.lastIndexOf(".");
+ prototypeName = prototypeName.substring(0, index).toUpperCase();
+ prototypesPath.put(prototypeName, fullPath);
+ }
+
+
+ public void getPathMatch(String prefix,
+ ArrayList<ICompletionProposal> proposals, int baseOffset) {
+
+ Collection<String> values = prototypesPath.keySet();
+ Iterator<String> it = values.iterator() ;
+ while (it.hasNext()) {
+ String name = it.next();
+ if (name.startsWith(prefix)) {
+ int lenPrefix = prefix.length();
+ int lenName = name.length();
+ proposals.add(new CompletionProposal(name, baseOffset-lenPrefix, lenPrefix, lenName,
+ OutlineImages.PROTOTYPE, name, null, null));
+ }
+ }
+ }
+
+ public void addPath(String prototypeName, IPath location) {
+ prototypesPath.put(prototypeName, location.toString());
+ }
+
+ public int getSize() {
+ return prototypesPath.size();
+ }
+
+ public Iterator<String> getPathIterator() {
+ return prototypesPath.values().iterator();
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/Position.java b/editor/eclipse/src/org/lisaac/ldt/model/Position.java
new file mode 100644
index 0000000..3c2b8fa
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/Position.java
@@ -0,0 +1,52 @@
+package org.lisaac.ldt.model;
+
+public class Position {
+ public int line;
+ //public int column;
+ public int offset;
+ public int length;
+
+ public Position(int line, int column, int offset) {
+ super();
+ this.line = line;
+ //this.column = column;
+ this.offset = offset;
+ length = 0;
+ }
+ public Position(int line, int column, int offset, int len) {
+ super();
+ this.line = line;
+ //this.column = column;
+ this.offset = offset;
+ length = len;
+ }
+
+ public int getLine() {
+ return line;
+ }
+ //public int getColumn() {
+ //return column;
+ //}
+
+ public boolean hasRange() {
+ return length != 0;
+ }
+
+ public int getCharStart() {
+ return offset-length;
+ }
+ public int getCharEnd() {
+ return offset;
+ }
+
+ public int getStartOffset() {
+ return offset;
+ }
+
+ public int length() {
+ return length;
+ }
+ public void setLength(int l) {
+ length = l;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/SectionContext.java b/editor/eclipse/src/org/lisaac/ldt/model/SectionContext.java
new file mode 100644
index 0000000..d58bf2e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/SectionContext.java
@@ -0,0 +1,318 @@
+package org.lisaac.ldt.model;
+
+import java.util.ArrayList;
+
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.model.items.Section;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeParameter;
+
+public class SectionContext implements ILisaacContext {
+
+ private LisaacParser parser;
+ private boolean firstSection;
+
+ public SectionContext(LisaacParser parser) {
+ this.parser = parser;
+ firstSection = true;
+ }
+
+ public boolean parseDefinition(Prototype prototype) {
+ Position sectionPosition;
+
+ parser.readSpace();
+
+ // read Section
+ if (! parser.readThisKeyword (ILisaacModel.keyword_section)) {
+ parser.getReporter().syntaxError("`Section' is needed.", parser.getLine());
+ return false;
+ }
+ sectionPosition = parser.getPosition();
+
+ if (firstSection) {
+ //
+ // Read Section Header.
+ //
+ if (! parser.readThisKeyword (ILisaacModel.section_header)) {
+ parser.getReporter().syntaxError("Section `Header' is needed.", parser.getLine());
+ return false;
+ }
+ firstSection = false;
+
+ if (! readSectionHeaderContent(prototype)) {
+ return false;
+ }
+ } else {
+ //
+ // Read Other Section.
+ //
+ if (parser.readKeyword()) {
+ String section = parser.getLastString();
+ if (section.equals(ILisaacModel.section_inherit) ||
+ section.equals(ILisaacModel.section_insert) ||
+ section.equals(ILisaacModel.section_interrupt) ||
+ section.equals(ILisaacModel.section_private) ||
+ section.equals(ILisaacModel.section_public) ||
+ section.equals(ILisaacModel.section_mapping) ||
+ section.equals(ILisaacModel.section_directory) ||
+ section.equals(ILisaacModel.section_external)) {
+
+ Section lastSection = new Section(prototype, section, sectionPosition);
+ parser.setLastSection(lastSection);
+
+ if (prototype.getFirstSection() == null) {// section list head
+ prototype.setFirstSection(lastSection);
+ }
+
+ if (lastSection.isInheritOrInsert() &&
+ parser.getLastSlot() != null &&
+ ! parser.getLastSlot().getSectionId().isInheritOrInsert()) {
+ parser.getReporter().syntaxError("`Section Inherit/Insert' must to be first section.", parser.getLine());
+ return false;
+
+ } else if (prototype.isExpanded() && section.equals(ILisaacModel.section_inherit)) {
+ parser.getReporter().warning("`Section Inherit' is not possible with Expanded object (Use `Section Insert').", parser.getLine());
+ }
+ } else {
+ parser.getReporter().syntaxError("Incorrect type section.", parser.getLine());
+ return false;
+ }
+ } else {
+ // TYPE_LIST.
+ ITypeMono[] t = parser.readTypeList(true);
+ if (t == null) {
+ parser.getReporter().syntaxError("Incorrect type section.", parser.getLine());
+ return false;
+ }
+ parser.setLastSection(new Section(prototype, t, sectionPosition));
+ }
+ // content of section is out of this context
+ }
+ return true;
+ }
+
+ private boolean readSectionHeaderContent(Prototype prototype) {
+ boolean result;
+ boolean first=true;
+
+ //
+ // Read Slots of Section Header.
+ //
+ do {
+ result = false;
+
+ char style = parser.readStyle();
+ if (style != ' ') {
+ result = true;
+
+ if (!first && style == '+') {
+ parser.getReporter().warning("Incorrect style slot ('-').", parser.getPosition(1));
+ }
+ if (first) {
+ first = false;
+
+ if (parser.readWord(ILisaacModel.slot_name)) {
+ //
+ // Read `name' slot.
+ //
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ if (parser.readThisKeyword(ILisaacModel.keyword_expanded) ||
+ parser.readThisKeyword(ILisaacModel.keyword_strict)) {
+ prototype.setTypeStyle(parser.getLastString());
+ }
+ prototype.setNameOffset(parser.getOffset());// for refactor
+
+ if (! parser.readCapIdentifier()) {
+ parser.getReporter().syntaxError("Prototype identifier is needed.", parser.getLine());
+ return false;
+ }
+ if (parser.getLastString().compareTo(prototype.getName()) != 0) {
+ int len = parser.getLastString().length();
+ parser.getReporter().syntaxError("Incorrect name (filename != name).", parser.getPosition(len));
+ }
+
+ if (parser.readCharacter('(')) {
+ //
+ // Generic loader.
+ //
+ if (parser.readIdentifier()) {
+ return false;
+ // TODO syntax identifier : PROTO
+ } else if (parser.readCapIdentifier()) {
+ if (! parser.isParameterType) {
+ parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
+ }
+ ArrayList<TypeParameter> genlist = new ArrayList<TypeParameter>();
+ TypeParameter param = TypeParameter.get(parser.getLastString());
+ genlist.add(param);
+
+ while (parser.readCharacter(',')) {
+ if (! parser.readCapIdentifier()) {
+ parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
+ return false;
+ }
+ if (! parser.isParameterType) {
+ parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
+ }
+ param = TypeParameter.get(parser.getLastString());
+ genlist.add(param);
+ }
+ if (! parser.readCharacter(')')) {
+ parser.getReporter().syntaxError("Added ')'.", parser.getLine());
+ return false;
+ }
+ prototype.setGenericList(genlist.toArray(new TypeParameter[genlist.size()]));
+ } else {
+ parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
+ return false;
+ }
+ }
+ } else {
+ parser.getReporter().syntaxError("Slot `name' must to be first slot.", parser.getLine());
+ }
+ } else if (parser.readWord(ILisaacModel.slot_export) ||
+ parser.readWord(ILisaacModel.slot_import)) {
+
+ // - ("export"|"import") ':=' TYPE_LIST
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ if (parser.readTypeList(false) == null) {
+ parser.getReporter().syntaxError("Incorrect type list.", parser.getLine());
+ return false;
+ }
+ // TODO store export / import
+
+ } else if (parser.readWord(ILisaacModel.slot_external)) {
+ // - "external" ':=' `<code_c>`
+
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ if (! parser.readExternal()) {
+ parser.getReporter().syntaxError("Incorrect external.", parser.getLine());
+ return false;
+ }
+ } else if (parser.readWord(ILisaacModel.slot_default)) {
+ // '-' "default" ':=' EXPR_PRIMARY
+
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ if (parser.readExprPrimary() == null) {
+ parser.getReporter().syntaxError("Incorrect expr.", parser.getLine());
+ return false;
+ }
+ // TODO check double default slot
+ // TODO set prototyp default value
+ } else if (parser.readWord(ILisaacModel.slot_type)) {
+ // '-' "type" ':=' `<type C>`
+
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ if (! parser.readExternal()) {
+ parser.getReporter().syntaxError("Incorrect external.", parser.getLine());
+ return false;
+ }
+ // TODO check double type declaration
+
+ } else if (parser.readWord(ILisaacModel.slot_version)) {
+ //
+ // Read `version' slot.
+ //
+
+ // '-' "version" ':=' integer
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ if (! parser.readInteger()) {
+ parser.getReporter().syntaxError("Incorrect number.", parser.getLine());
+ return false;
+ }
+ } else if (parser.readWord(ILisaacModel.slot_lip)) {
+
+ // '-' lip <- ( { LIP_EXPR ';' } )
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_code)) {
+ parser.getReporter().warning("Added '<-' is needed.", parser.getLine());
+ }
+ if (! parser.readCharacter('(')) {
+ parser.getReporter().warning("Added '(' is needed.", parser.getLine());
+ }
+ //
+ // LIP interpreter
+ //
+ LipParser lipParser = new LipParser(parser.getSource(), parser.getOffset());
+
+ while (lipParser.readExpr() != null) {
+ // instr.run(); // TODO interpret lip code if needed
+ if (! lipParser.readCharacter(';')) {
+ parser.getReporter().warning("Added ';' is needed.", parser.getLine());
+ }
+ }
+ if (! lipParser.readCharacter(')')) {
+ parser.getReporter().warning("Added ')' is needed.", parser.getLine());
+ }
+ parser.setPosition(lipParser.getOffset());
+
+ } else if (parser.readWord(ILisaacModel.slot_date) ||
+ parser.readWord(ILisaacModel.slot_comment) ||
+ parser.readWord(ILisaacModel.slot_author) ||
+ parser.readWord(ILisaacModel.slot_bibliography) ||
+ parser.readWord(ILisaacModel.slot_language) ||
+ parser.readWord(ILisaacModel.slot_copyright) ||
+ parser.readWord(ILisaacModel.slot_bug_report)) {
+ //
+ // Read `date', `comment', `author', `bibliography',
+ // `language', `copyright' or `bug_report' slots.
+ //
+
+ String headerSlot = new String(parser.getLastString());
+
+ // '-' ("date"|"comment"|"author"|"bibliography"|"language"|"copyright"|"bug_report")
+ // ':=' string
+ if (! parser.readSymbol(ILisaacModel.symbol_affect_immediate)) {
+ parser.getReporter().syntaxError("Added ':='.", parser.getLine());
+ return false;
+ }
+ parser.readSpace();
+ Position slotPosition = parser.getPosition();
+ if (! parser.readString()) {
+ parser.getReporter().syntaxError("Incorrect string.", parser.getLine());
+ return false;
+ }
+ if (headerSlot.equals(ILisaacModel.slot_comment)) {
+ prototype.setHeaderComment(new String(parser.getLastString()));
+ } else {
+ slotPosition.setLength(parser.getOffset() - slotPosition.offset);
+ prototype.addHeaderData(headerSlot,new String(parser.getLastString()), slotPosition);
+ }
+
+ } else {
+ parser.getReporter().syntaxError("Incorrect slot.", parser.getPosition());
+ return false;
+ }
+ if (! parser.readCharacter(';')) {
+ parser.getReporter().warning("Added ';'.", parser.getPosition());
+ }
+ }
+ } while (! parser.isEOF() && result);
+
+ return true;
+ }
+
+ public ILisaacContext getNextContext() {
+ if (parser.skipUntilThisKeyword(ILisaacModel.keyword_section)) {
+ return this;
+ }
+ return null;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/SlotContext.java b/editor/eclipse/src/org/lisaac/ldt/model/SlotContext.java
new file mode 100644
index 0000000..c58a267
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/SlotContext.java
@@ -0,0 +1,29 @@
+package org.lisaac.ldt.model;
+
+import org.lisaac.ldt.model.items.Prototype;
+
+public class SlotContext implements ILisaacContext {
+ private LisaacParser parser;
+
+ public SlotContext(LisaacParser parser) {
+ this.parser = parser;
+ }
+
+ //++ SLOT -> style TYPE_SLOT [':' (TYPE|'('TYPE_LIST')') ][ affect DEF_SLOT ]';'
+ public boolean parseDefinition(Prototype prototype) {
+ boolean result=false;
+
+ result = parser.readSlot(prototype);
+
+ return result;
+ }
+
+ public ILisaacContext getNextContext() {
+ // FIXME skip until next slot !!!!
+ if (parser.skipUntilThisKeyword(ILisaacModel.keyword_section)) {
+ return parser.getSectionContext();
+ }
+ return null;
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/IArgument.java b/editor/eclipse/src/org/lisaac/ldt/model/items/IArgument.java
new file mode 100644
index 0000000..cf8a283
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/IArgument.java
@@ -0,0 +1,22 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
+import org.lisaac.ldt.model.types.IType;
+
+public interface IArgument extends IVariable {
+
+ String getName();
+
+ IType getType();
+
+ boolean hasName(String word);
+
+ void printIn(StringBuffer buffer);
+ void styledPrintIn(StyledString buffer);
+
+ void getMatchProposals(String n, ArrayList<ICompletionProposal> matchList,
+ int offset, int length);
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ICode.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ICode.java
new file mode 100644
index 0000000..9ba6c20
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ICode.java
@@ -0,0 +1,13 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public interface ICode {
+
+ IType getType(Slot slot, Prototype prototype);
+
+ void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits);
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/IConstant.java b/editor/eclipse/src/org/lisaac/ldt/model/items/IConstant.java
new file mode 100644
index 0000000..797c218
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/IConstant.java
@@ -0,0 +1,5 @@
+package org.lisaac.ldt.model.items;
+
+public interface IConstant extends ICode {
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMArgs.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMArgs.java
new file mode 100644
index 0000000..d03bada
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMArgs.java
@@ -0,0 +1,138 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeMulti;
+import org.lisaac.ldt.outline.OutlineImages;
+
+public class ITMArgs implements IArgument {
+
+ protected String[] name;
+ protected TypeMulti type;
+
+ protected Position position;
+
+ public ITMArgs(String[] name, TypeMulti type, Position position) {
+ this.name = name;
+ this.type = type;
+ this.position = position;
+ }
+
+ public String getName() {
+ StringBuffer buffer = new StringBuffer("(");
+ for (int i=0; i<name.length; i++) {
+ buffer.append(name[i]);
+
+ if (i != name.length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(")");
+ return buffer.toString();
+ }
+
+ private int lastIndexOf(String word) {
+ for (int i=0; i<name.length; i++) {
+ if (name[i].compareTo(word) == 0) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public boolean hasName(String word) {
+ return lastIndexOf(word) != -1;
+ }
+
+ public IType getType() {
+ return null;// FIXME list arg type
+ }
+
+ public IType getArgType(String name) {
+ int index = lastIndexOf(name);
+ if (index != -1) {
+ return type.getSubType(index);
+ }
+ return null;
+ }
+
+ public void printIn(StringBuffer buffer) {
+ buffer.append("(");
+ for (int i=0; i<name.length; i++) {
+ IType subType = type.getSubType(i);
+ buffer.append(name[i]);
+ buffer.append(" : ");
+ buffer.append(subType);
+
+ if (i != name.length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(")");
+ }
+
+ public void styledPrintIn(StyledString buffer) {
+ ColorManager colors = ColorManager.getDefault();
+ buffer.append("(");
+ for (int i=0; i<name.length; i++) {
+ IType subType = type.getSubType(i);
+ buffer.append(name[i], colors.getVariableStyler());
+ buffer.append(" : ");
+ buffer.append(subType.toString(), colors.getPrototypeStyler());
+
+ if (i != name.length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(")");
+ }
+
+ public String getHoverInformation() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<I>Arguments</I> : ");
+ buffer.append("(");
+ for (int i=0; i<name.length; i++) {
+ IType subType = type.getSubType(i);
+ buffer.append("<b>"+name[i]+"</b>");
+ buffer.append(" : ");
+ buffer.append("<g>"+subType+"</g>");
+
+ if (i != name.length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(")");
+
+ return buffer.toString();
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public void getMatchProposals(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+
+ for (int i=0; i<name.length; i++) {
+ if (name[i].startsWith(n)) {
+ String match = name[i];
+ if (Slot.checkUnicity(matchList, match)) {
+ Image image = OutlineImages.PRIVATE_NONSHARED;// TODO new image for args
+
+ String partialMatch = match.substring(n.length());
+ matchList.add(new CompletionProposal(partialMatch, offset, length,
+ partialMatch.length(), image, match, null,
+ null));
+ }
+ }
+ }
+ }
+}
+
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMArgument.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMArgument.java
new file mode 100644
index 0000000..4731811
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMArgument.java
@@ -0,0 +1,88 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.outline.OutlineImages;
+
+public class ITMArgument implements IArgument {
+
+ protected String name;
+ protected ITypeMono type;
+
+ protected Position position;
+
+ public ITMArgument(String name, ITypeMono type, Position position) {
+ this.name = name;
+ this.type = type;
+ this.position = position;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public boolean hasName(String word) {
+ return name.compareTo(word) == 0;
+ }
+
+ public void printIn(StringBuffer buffer) {
+ buffer.append(name);
+ buffer.append(':');
+ buffer.append(type);
+ }
+
+ public void styledPrintIn(StyledString buffer) {
+ ColorManager colors = ColorManager.getDefault();
+ buffer.append(name, colors.getVariableStyler());
+ buffer.append(':');
+ buffer.append(type.toString(), colors.getPrototypeStyler());
+ }
+
+ public String getHoverInformation() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<I>Argument</I> : <b>");
+ buffer.append(name);
+ buffer.append("</b> <g> : ");
+ buffer.append(type.toString());
+ buffer.append("</g>");
+
+ return buffer.toString();
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public String match(String n) {
+ if (name.startsWith(n)) {
+ return name;
+ }
+ return null;
+ }
+
+ public void getMatchProposals(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+
+ String match = match(n);
+ if (match != null && Slot.checkUnicity(matchList, match)) {
+ Image image = OutlineImages.PRIVATE_NONSHARED;// TODO new image for args
+
+ String partialMatch = match.substring(n.length());
+ matchList.add(new CompletionProposal(partialMatch, offset, length,
+ partialMatch.length(), image, match, null,
+ null));
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMBlock.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMBlock.java
new file mode 100644
index 0000000..831171c
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMBlock.java
@@ -0,0 +1,51 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.LisaacParser;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeBlock;
+
+public class ITMBlock implements ICode {
+ protected ITMList list;
+ protected IArgument argument;
+
+ public ITMBlock(ITMList list, IArgument argument, Slot slot) {
+ this.list = list;
+ this.argument = argument;
+
+ if (slot != null) {
+ slot.addSubList(this);
+ }
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return TypeBlock.get(null, null); // FIXME empty block
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits) {
+ if (argument != null && list != null) {
+ IType type = argument.getType();
+ Position p = argument.getPosition();
+
+ if (p != null && type.toString().compareTo(oldName) == 0) {
+ LisaacParser parser = list.getOwner().getPrototype().openParser();
+ parser.setPosition(p.offset+p.length);
+ parser.readCharacter(':');
+ parser.readSpace();
+
+ int startOffset = parser.getOffset();
+
+ edits.add(new DeleteEdit(startOffset, oldName.length()));
+ edits.add(new InsertEdit(startOffset, newName));
+ }
+ }
+ if (list != null) {
+ list.refactorRenamePrototype(oldName, newName, edits);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMCharacter.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMCharacter.java
new file mode 100644
index 0000000..0656c92
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMCharacter.java
@@ -0,0 +1,21 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+public class ITMCharacter implements IConstant {
+
+ public ITMCharacter(String string) {
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return TypeSimple.get(ILisaacModel.prototype_character);
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExpression.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExpression.java
new file mode 100644
index 0000000..06cf4ae
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExpression.java
@@ -0,0 +1,30 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+/**
+ * operator list message
+ */
+public class ITMExpression implements ICode {
+ protected ICode[] valueList;
+
+ public ITMExpression(ICode[] list) {
+ valueList = list;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ if (valueList != null && valueList.length > 0) {
+ return valueList[valueList.length-1].getType(slot, prototype); // FIXME expr type
+ }
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits) {
+ for (int i=0; i<valueList.length; i++) {
+ valueList[i].refactorRenamePrototype(oldName, newName, edits);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExternal.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExternal.java
new file mode 100644
index 0000000..dbbeed5
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExternal.java
@@ -0,0 +1,21 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMExternal implements ICode {
+ protected String extern;
+
+ public ITMExternal(String extern) {
+ this.extern = extern;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExternalType.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExternalType.java
new file mode 100644
index 0000000..782e001
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMExternalType.java
@@ -0,0 +1,36 @@
+package org.lisaac.ldt.model.items;
+
+import org.lisaac.ldt.model.types.ITypeMono;
+
+public class ITMExternalType extends ITMExternal {
+
+ protected ITypeMono type;
+ protected ITypeMono[] typeList;
+ protected boolean persistant;
+
+ public ITMExternalType(String extern, boolean persistant) {
+ super(extern);
+ this.persistant = persistant;
+ }
+
+ public boolean isPersistant() {
+ return persistant;
+ }
+
+ public ITypeMono getType(Prototype prototype) {
+ return type;
+ }
+
+ public void setType(ITypeMono type) {
+ this.type = type;
+ }
+
+ public ITypeMono[] getTypeList() {
+ return typeList;
+ }
+
+ public void setTypeList(ITypeMono[] typeList) {
+ this.typeList = typeList;
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMLDots.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMLDots.java
new file mode 100644
index 0000000..5b39c71
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMLDots.java
@@ -0,0 +1,16 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMLDots implements ICode {
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMList.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMList.java
new file mode 100644
index 0000000..20541f6
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMList.java
@@ -0,0 +1,157 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.LisaacParser;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.outline.OutlineImages;
+
+public class ITMList implements ICode {
+ protected ICode[] code;
+ protected ITMLocal[] localList;
+ protected ITMLocal[] staticList;
+
+ protected int startOffset, endOffset;
+
+ private Slot owner;
+
+ public ITMList(Slot slot, int start) {
+ startOffset = start;
+ endOffset = startOffset;
+ owner = slot;
+ if (slot != null) {
+ slot.addSubList(this);
+ }
+ }
+
+ public Slot getOwner() {
+ return owner;
+ }
+
+ public void setEndOffset(int end) {
+ endOffset = end;
+ }
+
+ public void setCode(ICode[] code) {
+ this.code = code;
+ }
+
+ public void setLocalList(ITMLocal[] list) {
+ localList = list;
+ }
+ public void setStaticList(ITMLocal[] list) {
+ staticList = list;
+ }
+
+ public boolean hasVariableDefinition(String word) {
+ return getLocal(word) != null;
+ }
+
+ public ITMLocal getLocal(String word) {
+ if (localList != null) {
+ for (int i=0; i<localList.length; i++) {
+ if (localList[i].name.compareTo(word) == 0) {
+ return localList[i];
+ }
+ }
+ }
+ if (staticList != null) {
+ for (int i=0; i<staticList.length; i++) {
+ if (staticList[i].name.compareTo(word) == 0) {
+ return staticList[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ private List<String> getLocalMatches(String n) {
+ List<String> result = new ArrayList<String>();
+ if (localList != null) {
+ for (int i=0; i<localList.length; i++) {
+ if (localList[i].name.startsWith(n)) {
+ result.add(localList[i].name);
+ }
+ }
+ }
+ if (staticList != null) {
+ for (int i=0; i<staticList.length; i++) {
+ if (staticList[i].name.startsWith(n)) {
+ result.add(staticList[i].name);
+ }
+ }
+ }
+ return result;
+ }
+
+ public void getMatchProposals(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+ List<String> matches = getLocalMatches(n);
+
+ for (int i=0; i<matches.size(); i++) {
+ String match = matches.get(i);
+ if (Slot.checkUnicity(matchList, match)) {
+ Image image = OutlineImages.PRIVATE_NONSHARED;// TODO '+' or '-' local..
+
+ String partialMatch = match.substring(n.length());
+ matchList.add(new CompletionProposal(partialMatch, offset, length,
+ partialMatch.length(), image, match, null,
+ null));
+ }
+ }
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ if (code != null && code.length > 0) {
+ return code[code.length-1].getType(slot, prototype); // FIXME list type
+ }
+ return null;
+ }
+
+ public boolean isInside(int offset) {
+ return offset >= startOffset && offset <= endOffset;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName, List<TextEdit> edits) {
+ if (localList != null && owner != null) {
+ for (int i=0; i<localList.length; i++) {
+ createEdit(localList[i], oldName, newName, edits);
+ }
+ }
+ if (staticList != null && owner != null) {
+ for (int i=0; i<staticList.length; i++) {
+ createEdit(staticList[i], oldName, newName, edits);
+ }
+ }
+ if (code != null) {
+ for (int i=0; i<code.length; i++) {
+ code[i].refactorRenamePrototype(oldName, newName, edits);
+ }
+ }
+ }
+
+ private void createEdit(ITMLocal local, String oldName, String newName, List<TextEdit> edits) {
+ IType type = local.getType();
+ Position p = local.getPosition();
+
+ if (p != null && type.toString().compareTo(oldName) == 0) {
+ LisaacParser parser = owner.getPrototype().openParser();
+ parser.setPosition(p.offset+p.length);
+ parser.readCharacter(':');
+ parser.readSpace();
+
+ int startOffset = parser.getOffset();
+
+ edits.add(new DeleteEdit(startOffset, oldName.length()));
+ edits.add(new InsertEdit(startOffset, newName));
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMListIdf.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMListIdf.java
new file mode 100644
index 0000000..20ad159
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMListIdf.java
@@ -0,0 +1,28 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMListIdf implements ICode {
+
+ ArrayList<String> list;
+
+
+ public ITMListIdf(ArrayList<String> list) {
+ this.list = list;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMLocal.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMLocal.java
new file mode 100644
index 0000000..626afe7
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMLocal.java
@@ -0,0 +1,48 @@
+package org.lisaac.ldt.model.items;
+
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+
+/**
+ * Local declaration slot
+ */
+public class ITMLocal implements IVariable {
+ protected ITypeMono type;
+ protected String name;
+
+ protected Position position;
+
+ public ITMLocal(String name, Position position) {
+ this.position = position;
+ this.name = name;
+ }
+
+ public ITMLocal(ITypeMono type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(ITypeMono type) {
+ this.type = type;
+ }
+
+ public String getHoverInformation() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<I>Local</I> : <b>");
+ buffer.append(name);
+ buffer.append("</b> <g> : ");
+ buffer.append(type.toString());
+ buffer.append("</g>");
+
+ return buffer.toString();
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMNumber.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMNumber.java
new file mode 100644
index 0000000..9785e18
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMNumber.java
@@ -0,0 +1,22 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+public class ITMNumber implements IConstant {
+
+ public ITMNumber(long lastInteger) {
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return TypeSimple.get(ILisaacModel.prototype_integer);
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMOld.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMOld.java
new file mode 100644
index 0000000..0ea0cb6
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMOld.java
@@ -0,0 +1,25 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMOld implements ICode {
+ protected ICode value;
+
+ public ITMOld(ICode value) {
+ this.value = value;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ if (value != null) {
+ return value.getType(slot, prototype);
+ }
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMOperator.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMOperator.java
new file mode 100644
index 0000000..c99d6ec
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMOperator.java
@@ -0,0 +1,27 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMOperator implements ICode {
+ protected String name;
+
+ public ITMOperator(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMPrototype.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMPrototype.java
new file mode 100644
index 0000000..7f0de2b
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMPrototype.java
@@ -0,0 +1,34 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+
+public class ITMPrototype implements ICode {
+ protected ITypeMono type;
+
+ protected Position position;
+
+ public ITMPrototype(ITypeMono type, Position position) {
+ this.type = type;
+ this.position = position;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return type;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+
+ if (type.toString().compareTo(oldName) == 0) {
+ edits.add(new DeleteEdit(position.offset, oldName.length()));
+ edits.add(new InsertEdit(position.offset, newName));
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMRead.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMRead.java
new file mode 100644
index 0000000..a9898e6
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMRead.java
@@ -0,0 +1,55 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+public class ITMRead implements ICode {
+ protected String name;
+
+ public ITMRead(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+
+ if (slot != null) {
+ if (name.equals(ILisaacModel.variable_self)) {// type simple?
+ return TypeSimple.get(slot.getPrototype().getName());
+ }
+ IArgument arg = slot.getArgument(name);
+ if (arg != null) {
+ if (arg instanceof ITMArgs) {
+ return ((ITMArgs) arg).getArgType(name);
+ }
+ return arg.getType();
+ }
+ if (slot.getValue() instanceof ITMList) {
+ ITMList list = (ITMList) slot.getValue();
+ ITMLocal local = list.getLocal(name);
+ if (local != null) {
+ return local.getType();
+ }
+ }
+ }
+ if (prototype != null) {
+ Slot s = prototype.lookupSlot(name);
+ if (s != null) {
+ return s.getResultType();
+ }
+ }
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArg1.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArg1.java
new file mode 100644
index 0000000..6b08c01
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArg1.java
@@ -0,0 +1,20 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+
+public class ITMReadArg1 extends ITMRead {
+
+ protected ICode arg;
+
+ public ITMReadArg1(String name, ICode arg) {
+ super(name);
+ this.arg = arg;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ arg.refactorRenamePrototype(oldName, newName, edits);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArg2.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArg2.java
new file mode 100644
index 0000000..7b220ef
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArg2.java
@@ -0,0 +1,76 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.LisaacCompletionParser;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+public class ITMReadArg2 extends ITMRead {
+
+ protected ICode argFirst;
+ protected ICode argSecond;
+
+ public ITMReadArg2(String name, ICode a1, ICode a2) {
+ super(name);
+ this.argFirst = a1;
+ this.argSecond = a2;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ //
+ // operator expression.
+ //
+ if (name.startsWith("__")) { // FIXME __infix __prefix __postfix??
+
+ // Get type of left part of operator.
+ IType type = argFirst.getType(slot, prototype);
+ if (type != null) {
+ try {
+ Prototype operatorPrototype = LisaacCompletionParser.findPrototype(""+type);
+ if (operatorPrototype != null) {
+ Slot operatorSlot = operatorPrototype.lookupSlot(name);
+ if (operatorSlot != null) {
+ // return result type of operator.
+ return operatorSlot.getResultType();
+ } else {
+ if (name.compareTo("__infix_equal") == 0) {
+ // special case for '=' operator (can't be a slot)
+ return TypeSimple.getTypeBoolean();
+ }
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+ // second chance with second argument FIXME use __postfix?
+ type = argSecond.getType(slot, prototype);
+ if (type != null) {
+ try {
+ Prototype operatorPrototype = LisaacCompletionParser.findPrototype(""+type);
+ if (operatorPrototype != null) {
+ Slot operatorSlot = operatorPrototype.lookupSlot(name);
+ if (operatorSlot != null) {
+ // return result type of operator.
+ return operatorSlot.getResultType();
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+ //
+ // classic slot
+ //
+ return super.getType(slot, prototype);
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+
+ argFirst.refactorRenamePrototype(oldName, newName, edits);
+ argSecond.refactorRenamePrototype(oldName, newName, edits);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArgs.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArgs.java
new file mode 100644
index 0000000..4d819c5
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReadArgs.java
@@ -0,0 +1,21 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+
+public class ITMReadArgs extends ITMRead {
+ protected ICode[] args;
+
+ public ITMReadArgs(String name, ICode[] args) {
+ super(name);
+ this.args = args;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ for (int i=0; i<args.length; i++) {
+ args[i].refactorRenamePrototype(oldName, newName, edits);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReal.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReal.java
new file mode 100644
index 0000000..3aa345f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMReal.java
@@ -0,0 +1,22 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+public class ITMReal implements IConstant {
+
+ public ITMReal(String string) {
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return TypeSimple.get(ILisaacModel.prototype_real);
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMResult.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMResult.java
new file mode 100644
index 0000000..7cfe175
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMResult.java
@@ -0,0 +1,26 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMResult implements ICode {
+ protected ICode value;
+
+ public ITMResult(ICode value) {
+ this.value = value;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ if (value != null) {
+ return value.getType(slot, prototype);
+ }
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ value.refactorRenamePrototype(oldName, newName, edits);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMString.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMString.java
new file mode 100644
index 0000000..229c20f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMString.java
@@ -0,0 +1,25 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.TypeSimple;
+
+public class ITMString implements IConstant {
+
+ protected String string;
+
+ public ITMString(String string) {
+ this.string = string;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ return TypeSimple.get(ILisaacModel.prototype_string);
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/ITMWrite.java b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMWrite.java
new file mode 100644
index 0000000..8f8746f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/ITMWrite.java
@@ -0,0 +1,33 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.types.IType;
+
+public class ITMWrite implements ICode {
+
+ protected ICode assign;
+ protected ICode value;
+
+ protected char type;
+
+ public ITMWrite(ICode assign, ICode value, char type) {
+ super();
+ this.assign = assign;
+ this.value = value;
+ this.type = type;
+ }
+
+ public IType getType(Slot slot, Prototype prototype) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void refactorRenamePrototype(String oldName, String newName,
+ List<TextEdit> edits) {
+ assign.refactorRenamePrototype(oldName, newName, edits);
+ value.refactorRenamePrototype(oldName, newName, edits);
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/IVariable.java b/editor/eclipse/src/org/lisaac/ldt/model/items/IVariable.java
new file mode 100644
index 0000000..4060773
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/IVariable.java
@@ -0,0 +1,9 @@
+package org.lisaac.ldt.model.items;
+
+import org.lisaac.ldt.model.Position;
+
+public interface IVariable {
+ String getHoverInformation();
+
+ Position getPosition();
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/Prototype.java b/editor/eclipse/src/org/lisaac/ldt/model/items/Prototype.java
new file mode 100644
index 0000000..adac394
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/Prototype.java
@@ -0,0 +1,795 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.LisaacCompletionParser;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.LisaacParser;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeParameter;
+import org.lisaac.ldt.outline.OutlineItem;
+import org.lisaac.ldt.outline.OutlinePrototype;
+import org.lisaac.ldt.outline.OutlineSection;
+
+public class Prototype {
+ protected IFile file;
+
+ protected ILisaacModel parent;
+ protected LisaacParser parser;
+
+ protected String name;
+ protected String typeStyle;
+
+ protected HashMap<String, Slot> parentList;
+ protected HashMap<String, Slot> slotList;
+
+ // genericity
+ protected TypeParameter[] genericList;
+
+ // hover informations
+ protected String headerData;
+ protected String headerComment;
+
+ protected Section firstSection;
+
+ // refactor information
+ protected int nameOffset;
+ protected Position authorOffset;
+ protected Position bibliographyOffset;
+ protected Position copyrightOffset;
+
+ public Prototype(IFile file, String name, ILisaacModel model) {
+ this.file = file;
+ this.name = name;
+ this.parent = model;
+ this.parser = model.getParser();
+
+ slotList = new HashMap<String, Slot>();
+ parentList = new HashMap<String, Slot>();
+ }
+
+ public ILisaacModel getModel() {
+ return parent;
+ }
+
+ public boolean setName(String n) {
+ if (name != null && name.equals(n)) {
+ return false;
+ }
+ name = n;
+ return true;
+ }
+
+ public IFile getFile() {
+ return file;
+ }
+
+ public String getFileName() {
+ return file.getName();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getGenericIndex(TypeParameter param) {
+ if (genericList != null) {
+ for (int i=0; i<genericList.length; i++) {
+ if (genericList[i].equals(param)) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ public void setGenericList(TypeParameter[] list) {
+ genericList = list;
+ }
+
+ public void setHeaderComment(String comment) {
+ this.headerComment = comment;
+ }
+
+ public void addHeaderData(String slotName, String data, Position position) {
+ String info = "\n<g>" + slotName + "</g> " + data;
+ if (headerData == null) {
+ headerData = info;
+ } else {
+ this.headerData += info;
+ }
+ if (slotName.equals(ILisaacModel.slot_author)) {
+ authorOffset = position;
+ } else if (slotName.equals(ILisaacModel.slot_bibliography)) {
+ bibliographyOffset = position;
+ } else if (slotName.equals(ILisaacModel.slot_copyright)) {
+ copyrightOffset = position;
+ }
+ }
+
+
+ public LisaacParser openParser() {
+ parser.initialize();
+ return parser;
+ }
+
+ public void setTypeStyle(String s) {
+ typeStyle = s;
+ }
+
+ public String getTypeStyle() {
+ return typeStyle;
+ }
+
+ public Section getFirstSection() {
+ return firstSection;
+ }
+
+ public void setFirstSection(Section s) {
+ firstSection = s;
+ }
+
+ public boolean isExpanded() {
+ if (typeStyle != null) {
+ return typeStyle.equals(ILisaacModel.keyword_expanded)
+ || name.equals(ILisaacModel.prototype_true)
+ || name.equals(ILisaacModel.prototype_false);
+ }
+ return false;
+ }
+
+ public Slot lookupSlot(String n) {
+ Slot result = null;
+
+ //
+ // Search in 'Self'.
+ //
+ result = getSlot(n);
+ if (result == null) {
+ result = getParentSlot(n);
+ }
+
+ if (result == null) {
+ //
+ // Search in parents.
+ //
+ Collection<Slot> values = parentList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slotParent = it.next();
+ IType typeParent = slotParent.getResultType();
+ try {
+ Prototype parent = LisaacCompletionParser
+ .findPrototype("" + typeParent);
+ if (parent != null) {
+ result = parent.lookupSlot(n);
+ if (result != null) {
+ return result;
+ }
+ }
+ } catch (CoreException e) {
+ return null;
+ }
+ }
+ }
+ return result;
+ }
+
+ public Slot getSlot(String n) {
+ //
+ // Search in 'Self' only.
+ //
+ if (slotList.containsKey(n)) {
+ return slotList.get(n);
+ }
+ return null;
+ }
+
+ public Slot getParentSlot(String n) {
+ // Search in 'Self' parent.
+ if (parentList.containsKey(n)) {
+ return parentList.get(n);
+ }
+ return null;
+ }
+
+ public Slot getSlot(int offset) {
+ return getSlot(openParser(), offset);
+ }
+
+ public Slot getSlot(String s, int offset) {
+ return getSlot(new LisaacParser(null, s), offset);
+ }
+
+ public Slot getSlot(LisaacParser parser, int offset) {
+ //
+ // Use indentation to get slot
+ //
+ String source = parser.getSource();
+ boolean again;
+
+ if (offset >= source.length() - 1) {
+ return null;
+ }
+
+ do {
+ again = false;
+
+ // find beginning of line
+ while (offset > 0 && source.charAt(offset) != '\n') {
+ offset--;
+ }
+ // look at indentation
+ if (offset > 0 && source.length() > 4) {
+ if (source.charAt(offset + 1) == ' '
+ && source.charAt(offset + 2) == ' '
+ && (source.charAt(offset + 3) == '+' || source
+ .charAt(offset + 3) == '-')) {
+ String slotName = parser
+ .readSlotNameFromOffset(offset + 4, false);
+ if (slotName != null) {
+ return getSlot(slotName);
+ }
+ } else {
+ again = true;
+ offset--;
+ }
+ }
+ } while (again);
+
+ return null;
+ }
+
+ public void lookupSlotMatch(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+ //
+ // Search in 'Self'.
+ //
+ getSlotMatch(n, matchList, offset, length);
+ getParentSlotMatch(n, matchList, offset, length);
+
+ //
+ // Search in parents.
+ //
+ Collection<Slot> values = parentList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slotParent = it.next();
+ IType typeParent = slotParent.getResultType();
+ try {
+ Prototype parent = LisaacCompletionParser.findPrototype(""
+ + typeParent);
+ if (parent != null) {
+ parent.lookupSlotMatch(n, matchList, offset, length);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ public void getSlotMatch(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+ //
+ // // Search in 'Self' only.
+ //
+ Collection<Slot> values = slotList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ if (slot.match(n)) {
+ slot.getSlotMatchProposals(matchList, offset, length, n
+ .length());
+ }
+ }
+ }
+
+ public void getParentSlotMatch(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+ // Search in 'Self' parent.
+ Collection<Slot> values = parentList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ if (slot.match(n)) {
+ slot.getSlotMatchProposals(matchList, offset, length, n
+ .length());
+ }
+ }
+ }
+
+ public Slot getSlotFromKeyword(String keyword, LisaacParser parser,
+ int baseOffset) throws CoreException {
+ String source = parser.getSource();
+ int bracketLevel = 0, invBracketLevel = 0;
+ Prototype receiver = null;
+ Slot result = null;
+ char c = 0;
+
+ int offset = baseOffset;
+ if (offset >= source.length() - 1) {
+ return null;
+ }
+ //
+ parser.enableErrorReport(false); // turn off error reporting
+ //
+ while (offset > 0) {
+ //
+ // find beginning of SEND_MSG grammar rule
+ //
+
+ // Rewind to '(' '{' ';' '[' '.' '<-' 'operator'
+ c = source.charAt(offset);
+
+ if (c == '\n') {// '//' comments
+ offset = unreadSingleLineComment(offset, source);
+ continue;
+ }
+
+ if (c == '(' || c == '{' || c == '[') {
+ if (bracketLevel == 0) {
+ break;
+ }
+ bracketLevel--;
+ invBracketLevel++;
+ }
+ if (c == ')' || c == '}' || c == ']') {
+ bracketLevel++;
+ invBracketLevel--;
+ }
+
+ // strings
+ if (c == '\"' || c == '\'' || c == '`') {
+ offset = unreadString(c, offset, source);
+ continue;
+ }
+
+ // ok, we're not in nested statements
+ if (bracketLevel == 0 && invBracketLevel == 0) {
+ if (c == ';' || c == '.') {
+ break;
+ }
+ // affectation
+ if (c == '=' && source.length() - offset > 2) {
+ if (source.charAt(offset - 1) == ':'
+ || source.charAt(offset - 1) == '?') {
+ break;
+ }
+ } else if (c == '-' && source.length() - offset > 2) {
+ if (source.charAt(offset - 1) == '<') {
+ break;
+ }
+ }
+ if (LisaacParser.isOperatorSymbol(c)) {
+ if (c == '+' || c == '-') {
+ // slot definition
+ if (offset - 3 > 0 && source.charAt(offset - 1) == ' ' &&
+ source.charAt(offset - 2) == ' ' &&
+ source.charAt(offset - 3) == '\n') {
+ String slotName = parser
+ .readSlotNameFromOffset(offset + 1, false);
+
+ parser.enableErrorReport(true);// finish with parser
+
+ if (slotName != null) {
+ result = lookupSlot(slotName);
+ if (result == null) {
+ return null;
+ }
+ if (result.keywordCount() == 1) {
+ if (result.getName().compareTo(keyword) == 0) {
+ return result;
+ }
+ return null; // not a keyword
+ } else {
+ // find keyword next token
+ offset = baseOffset;
+ while (offset < source.length() - 1
+ && Character
+ .isJavaIdentifierPart(source
+ .charAt(offset))) {
+ offset++;
+ }
+ // read space
+ while (offset < source.length() - 1
+ && Character.isWhitespace(source
+ .charAt(offset))) {
+ offset++;
+ }
+ if (source.charAt(offset) != ':') {
+ return result;// 'keyword' is a slot keyword
+ }
+ return null;
+ }
+ }
+ }
+ }
+ // comments */
+ if (offset - 1 > 0 && c == '/' && source.charAt(offset - 1) == '*') {
+ offset = unreadMultiLineComment(offset, source);
+ continue;
+ }
+ break;
+ }
+ }
+ offset--;
+ }
+ if (result == null) {
+ // Slot Call.
+
+ if (c == '.') {
+ int pointOffset = offset;
+ offset--;
+ bracketLevel = 0;
+ invBracketLevel = 0;
+
+ // Rewind to '(' '{' ';' '[' '.' '<-' 'operator'
+ while (offset > 0) {
+ c = source.charAt(offset);
+
+ if (c == '(' || c == '{' || c == '[') {
+ if (bracketLevel == 0) {
+ break;
+ }
+ bracketLevel--;
+ invBracketLevel++;
+ }
+ if (c == ')' || c == '}' || c == ']') {
+ bracketLevel++;
+ invBracketLevel--;
+ }
+
+ // ok, we're not in nested statements
+ if (bracketLevel == 0 && invBracketLevel == 0) {
+ if (c == ';') {
+ break;
+ }
+ // affectation
+ if (c == '=' && source.length() - offset > 2) {
+ if (source.charAt(offset - 1) == ':'
+ || source.charAt(offset - 1) == '?') {
+ break;
+ }
+ } else if (c == '-' && source.length() - offset > 2) {
+ if (source.charAt(offset - 1) == '<') {
+ break;
+ }
+ }
+ if (LisaacParser.isOperatorSymbol(c)) {
+ break;
+ }
+ // strings
+ if (c == '\"' || c == '\'' || c == '`') {
+ offset = unreadString(c, offset, source);
+ continue;
+ }
+ }
+ offset--;
+ }
+ if (offset > 0) {
+ LisaacCompletionParser p = new LisaacCompletionParser(
+ source, (LisaacModel) getModel());
+ receiver = p
+ .readReceiver(offset + 1, pointOffset, this);
+
+ offset = pointOffset;
+ }
+ } else {
+ receiver = this;
+ }
+ parser.setPosition(offset + 1);
+ parser.readSpace();
+ String slotName = parser.readKeywordInSendMsg(keyword,
+ baseOffset);
+
+ if (slotName != null && receiver != null) {
+ result = receiver.lookupSlot(slotName);
+ }
+ }
+ //
+ parser.enableErrorReport(true); // turn on error reporting
+ //
+ return result;
+ }
+
+ private int unreadSingleLineComment(int offset, String source) {
+ int saveOffset;
+
+ offset--; // unread '\n'
+ saveOffset = offset;
+
+ while (offset > 0) {
+ char c = source.charAt(offset);
+ if (c == '\n') {// no comment in the line
+ return saveOffset;
+ }
+ if (offset - 1 > 0 && c == '/' && source.charAt(offset - 1) == '/') {
+ offset = offset - 2;
+ break;
+ }
+ if (c == '\"' || c == '\'' || c == '`') {
+ offset = unreadString(c, offset, source);
+ continue;
+ }
+ offset--;
+ }
+ if (offset < 0) {
+ offset = 0;
+ }
+ return offset;
+ }
+
+ private int unreadMultiLineComment(int offset, String source) {
+ offset -= 2; // unread '*/'
+
+ while (offset > 0) {
+ char c = source.charAt(offset);
+ // read '/*'
+ if (offset - 1 > 0 && c == '*' && source.charAt(offset - 1) == '/') {
+ offset = offset - 2;
+ break;
+ }
+ offset--;
+ }
+ if (offset < 0) {
+ offset = 0;
+ }
+ return offset;
+ }
+
+ private int unreadString(char type, int offset, String source) {
+ char c;
+ do {
+ offset--;
+ c = source.charAt(offset);
+ } while (offset > 0 && c != type);
+ if (c == type) {
+ offset--;
+ }
+ return offset;
+ }
+
+ public void addSlot(Slot s) {
+ slotList.put(s.getName(), s);
+ }
+
+ public void addParentSlot(Slot s) {
+ parentList.put(s.getName(), s);
+ }
+
+ public String getHoverInformation() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<b>");
+ buffer.append(name);
+ buffer.append("</b>");
+ if (headerComment != null) {
+ buffer.append("\n" + headerComment);
+ }
+ if (headerData != null) {
+ buffer.append("\n\n" + headerData);
+ }
+ return buffer.toString();
+ }
+
+ public List<OutlineItem> getOutlineItems() {
+ List<OutlineItem> sections = new ArrayList<OutlineItem>();
+
+ Section current = firstSection;
+ while (current != null) {
+ sections.add(new OutlineSection(current));
+ current = current.getNext();
+ }
+
+ List<OutlineItem> result = new ArrayList<OutlineItem>();
+ result.add(new OutlinePrototype(this, sections));
+ return result;
+ }
+
+ public void getSlotProposals(ArrayList<ICompletionProposal> proposals,
+ int offset, int length) {
+ Collection<Slot> values = slotList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ slot.getSlotProposals(proposals, offset, length);
+ }
+
+ values = parentList.values();
+ it = values.iterator();
+ while (it.hasNext()) {
+ Slot slotParent = it.next();
+ IType typeParent = slotParent.getResultType();
+ try {
+ Prototype parent = LisaacCompletionParser.findPrototype(""
+ + typeParent);
+ if (parent != null) {
+ parent.getSlotProposals(proposals, offset, length);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ public ArrayList<org.eclipse.jface.text.Position> getPositions() {
+ ArrayList<org.eclipse.jface.text.Position> result = new ArrayList<org.eclipse.jface.text.Position>();
+
+ // section positions
+ Section current = firstSection;
+ while (current != null) {
+ Position p = current.getPosition();
+ result.add(new org.eclipse.jface.text.Position(p.offset, p.length));
+
+ current = current.getNext();
+ }
+
+ // slot positions
+ Collection<Slot> values = slotList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ Position p = slot.getPositionBody();
+ if (p != null) {
+ result.add(new org.eclipse.jface.text.Position(p.offset, p.length));
+ }
+ }
+ return result;
+ }
+
+ public IPath getWorkspacePath() {
+ return file.getFullPath();
+ }
+
+ public Change refactorRenameSelf(String newName) {
+ TextFileChange change = new TextFileChange("Change 'name' slot in section header", file);
+
+ // rename 'name' slot
+ MultiTextEdit edit= new MultiTextEdit();
+ edit.addChild(new DeleteEdit(nameOffset, name.length()));
+ edit.addChild(new InsertEdit(nameOffset, newName));
+
+ change.setEdit(edit);
+ return change;
+ }
+
+ public Change refactorRenamePrototype(String oldName, String newName) {
+ MultiTextEdit edit= new MultiTextEdit();
+
+ // 1. refactor sections
+ Section current = firstSection;
+ while (current != null) {
+ Position p = current.getPosition();
+ ITypeMono[] typeList = current.getTypeList();
+ if (typeList != null) {
+ for (int i=0; i<typeList.length; i++) {
+ if (typeList[i].toString().compareTo(oldName) == 0) {
+ typeList[i].rename(oldName, newName);
+
+ // rename section
+ edit.addChild(new DeleteEdit(p.offset+1, p.length-1));
+ edit.addChild(new InsertEdit(p.offset+1, current.getName()+"\n\n "));
+
+ // for model invariance (other changes in refactor)
+ typeList[i].rename(newName, oldName);
+ }
+ }
+ }
+ current = current.getNext();
+ }
+
+ // 2. refactor slots
+ Collection<Slot> values = slotList.values();
+ Iterator<Slot> it = values.iterator();
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ TextEdit[] slotEdits = slot.refactorRenamePrototype(oldName, newName);
+ if (slotEdits != null) {
+ edit.addChildren(slotEdits);
+ }
+ }
+ // create change
+ if (edit.getChildrenSize() > 0) {
+ TextFileChange change = new TextFileChange("Rename prototype occurences", file);
+ change.setEdit(edit);
+ return change;
+ }
+ return null;
+ }
+
+ public Change refactorHeader(String author, String bibliography,
+ String copyright, String license) {
+ MultiTextEdit edit= new MultiTextEdit();
+
+ // update header slots.
+ refactorHeaderSlot(ILisaacModel.slot_author, authorOffset, author, edit);
+ refactorHeaderSlot(ILisaacModel.slot_bibliography, bibliographyOffset, bibliography, edit);
+ refactorHeaderSlot(ILisaacModel.slot_copyright, copyrightOffset, copyright, edit);
+
+ // update license.
+ if (license != null) {
+ int offset = getOffsetBeforeSection();
+ edit.addChild(new DeleteEdit(0, offset-1));
+ edit.addChild(new InsertEdit(0, license));
+ }
+
+ // create change
+ if (edit.getChildrenSize() > 0) {
+ TextFileChange change = new TextFileChange("Update Section Header", file);
+ change.setEdit(edit);
+ return change;
+ }
+ return null;
+ }
+
+ private void refactorHeaderSlot(String name, Position pos, String newValue, MultiTextEdit edit) {
+ if (newValue != null) {
+ if (pos != null) {
+ // slot already exist
+ edit.addChild(new DeleteEdit(pos.offset, pos.length));
+ edit.addChild(new InsertEdit(pos.offset, "\"" + newValue + "\""));
+ } else {
+ // create slot
+ String slot = "\n - " + name + " := \"" + newValue + "\";";
+ edit.addChild(new InsertEdit(getOffsetAfterName(), slot));
+ }
+ }
+ }
+
+ private int getOffsetAfterName() {
+ LisaacParser parser = openParser();
+ parser.setPosition(nameOffset);
+ parser.readCapIdentifier();
+ parser.readCharacter(';');
+
+ return parser.getOffset();
+ }
+
+ private int getOffsetBeforeSection() {
+ LisaacParser parser = openParser();
+ parser.setPosition(0);
+ if (parser.readThisKeyword (ILisaacModel.keyword_section)) {
+ return parser.getOffset() - 7;
+ }
+ return 0;
+ }
+
+ public void setNameOffset(int offset) {
+ nameOffset = offset;
+ }
+
+ public void setAuthorOffset(Position p) {
+ authorOffset = p;
+ }
+
+ public void setBibliographyOffset(Position p) {
+ bibliographyOffset = p;
+ }
+
+ public void setCopyrightOffset(Position p) {
+ copyrightOffset = p;
+ }
+
+ public IRegion getRegionAt(int line, int column) {
+ LisaacParser parser = openParser();
+ parser.readTokenAt(line, column);
+
+ return new Region(parser.getOffset(), parser.getLastString().length());
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/Section.java b/editor/eclipse/src/org/lisaac/ldt/model/items/Section.java
new file mode 100644
index 0000000..f08234e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/Section.java
@@ -0,0 +1,166 @@
+package org.lisaac.ldt.model.items;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.outline.OutlineItem;
+import org.lisaac.ldt.outline.OutlineSlot;
+
+public class Section {
+ protected Prototype prototype;
+
+ protected String name;
+ protected ITypeMono[] typeList;
+
+ protected Section next;
+
+ protected Position position;
+
+ protected LinkedList<Slot> slots;
+
+
+ public Section(Prototype prototype, String name, Position position) {
+ this.name = name;
+ this.prototype = prototype;
+ this.position = position;
+ this.next = null;
+ }
+
+ public Section(Prototype prototype, ITypeMono[] typeList, Position position) {
+ this.typeList = typeList;
+ this.prototype = prototype;
+ this.position = position;
+ this.next = null;
+ }
+
+ public String getName() {
+ if (name == null) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i=0; i<typeList.length; i++) {
+ buffer.append(typeList[i].toString());
+ if (i != typeList.length-1) {
+ buffer.append(", ");
+ }
+ }
+ return buffer.toString();
+ }
+ return name;
+ }
+
+ public ITypeMono[] getTypeList() {
+ return typeList;
+ }
+
+ public Section getNext() {
+ return next;
+ }
+
+ public void setNext(Section next) {
+ this.next = next;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public void addSlot(Slot slot) {
+ if (slots == null) {
+ slots = new LinkedList<Slot>();
+ }
+ slots.add(slot);
+ }
+
+ //
+ // Consultation
+ //
+
+ public boolean isMapping() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_mapping);
+ }
+
+ public boolean isPrivate() {
+ if (name == null) {
+ return true;
+ }
+ return name.equals(ILisaacModel.section_private);
+ }
+
+ public boolean isPublic() {
+ if (name != null) {
+ return name.equals(ILisaacModel.section_public);
+ }
+ return false;
+ }
+
+ public boolean isHeader() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_header);
+ }
+
+ public boolean isInherit() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_inherit);
+ }
+
+ public boolean isInsert() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_insert);
+ }
+
+ public boolean isInheritOrInsert() {
+ return isInherit() || isInsert();
+ }
+
+ public boolean isInterrupt() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_interrupt);
+ }
+
+ public boolean isDirectory() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_directory);
+ }
+
+ public boolean isExternal() {
+ if (name == null) {
+ return false;
+ }
+ return name.equals(ILisaacModel.section_external);
+ }
+
+ public boolean isPrivateStyle() {
+ return !isPublic() && typeList == null;
+ }
+
+ public Prototype getPrototype() {
+ return prototype;
+ }
+
+ public List<OutlineItem> getOutlineItems() {
+ List<OutlineItem> items = new ArrayList<OutlineItem>();
+
+ if (slots != null) {
+ for (int i=0; i<slots.size(); i++) {
+ items.add(new OutlineSlot(slots.get(i)));
+ }
+ }
+ return items;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/items/Slot.java b/editor/eclipse/src/org/lisaac/ldt/model/items/Slot.java
new file mode 100644
index 0000000..8245d2b
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/items/Slot.java
@@ -0,0 +1,500 @@
+ package org.lisaac.ldt.model.items;
+
+ import java.util.ArrayList;
+ import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
+ import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.editors.ColorManager;
+import org.lisaac.ldt.editors.LisaacCompletionProposal;
+ import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.model.LisaacParser;
+ import org.lisaac.ldt.model.Position;
+ import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.outline.OutlineSlot;
+
+ public class Slot {
+
+ protected Section sectionId;
+ protected Position position;
+
+ protected String name;
+ protected char style;
+ protected char affect; // ':', '?', '<'
+
+ protected IArgument[] argumentList;
+ protected IType resultType;
+
+ protected String[] keywordList;
+
+ protected ICode value;
+
+ protected ArrayList<ICode> subLists;
+
+ protected String comment;
+
+ protected Position body;
+
+ public Slot(Position position, String name, Section sectionId) {
+ this.name = name;
+ this.position = position;
+ this.sectionId = sectionId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public char getStyle() {
+ return style;
+ }
+
+ public char getAffect() {
+ return affect;
+ }
+
+ public IArgument getArgument(int i) {
+ return argumentList[i];
+ }
+
+ public Section getSectionId() {
+ return sectionId;
+ }
+
+ public IType getResultType() {
+ return resultType;
+ }
+
+ public void setArgumentList(IArgument[] argumentList) {
+ this.argumentList = argumentList;
+ }
+
+ public void setResultType(IType resultType) {
+ this.resultType = resultType;
+ }
+
+ public void setKeywordList(String[] keywordList) {
+ this.keywordList = keywordList;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public void setAffect(char affect) {
+ this.affect = affect;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public Position getPositionBody() {
+ return body;
+ }
+
+ public void setBody(Position p) {
+ body = p;
+ }
+
+ public int keywordCount() {
+ if (keywordList == null) {
+ return 0;
+ }
+ return keywordList.length;
+ }
+
+ //
+ // Value.
+ //
+
+ public void setValue(ICode v) {
+ if (affect == '<') {
+ value = v;
+ } else {
+ // TODO not yet implemented
+ }
+ }
+
+ public ICode getValue() {
+ return value;
+ }
+
+ public void addSubList(ICode list) {
+ if (subLists == null) {
+ subLists = new ArrayList<ICode>();
+ }
+ subLists.add(list);
+ }
+
+ //
+ // Access associativity & priority level.
+ //
+ protected int priorityAndLevel;
+
+ public void setAssociativity(String p, int l) {
+ if (p == null || p.equals(ILisaacModel.keyword_left)) {
+ priorityAndLevel = l;
+ } else {
+ priorityAndLevel = -l;
+ }
+ }
+
+ public String getAssociativity() {
+ String result;
+
+ if (priorityAndLevel >= 0) {
+ result = ILisaacModel.keyword_left;
+ } else {
+ result = ILisaacModel.keyword_right;
+ }
+ return result;
+ }
+
+ public int getPriority() {
+ if (priorityAndLevel < 0) {
+ return -priorityAndLevel;
+ }
+ return priorityAndLevel;
+ }
+
+ public void setStyle(char style) {
+ this.style = style;
+ }
+
+ public boolean hasArgument(String word) {
+ return getArgument(word) != null;
+ }
+
+ public IArgument getArgument(String word) {
+ if (argumentList != null) {
+ for (int i = 0; i < argumentList.length; i++) {
+ if (argumentList[i].hasName(word)) {
+ return argumentList[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean hasVariableDefinition(String word, int offset) {
+ return getVariableDefinition(word, offset) != null;
+ }
+
+ public IVariable getVariableDefinition(String word, int offset) {
+ ITMList list;
+
+ if (subLists != null) {
+ for (int i = 0; i < subLists.size(); i++) {
+ ICode c = subLists.get(i);
+
+ if (c instanceof ITMList) {
+ list = (ITMList) c;
+ if (list != null && list.isInside(offset)) {
+ // list variable
+ IVariable var = list.getLocal(word);
+ if (var != null) {
+ return var;
+ }
+ }
+ } else if (c instanceof ITMBlock) {
+ list = ((ITMBlock) c).list;
+ IArgument arg = ((ITMBlock) c).argument;
+
+ if (list != null && arg != null
+ && list.isInside(offset) && arg.hasName(word)) {
+ // block argument
+ return arg;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public IVariable getVariable(String word, int offset) {
+ IVariable result = getArgument(word);
+ if (result == null) {
+ result = getVariableDefinition(word, offset);
+ }
+ return result;
+ }
+
+ public Prototype getPrototype() {
+ return sectionId.getPrototype();
+ }
+
+ private String getOperatorName() {
+ String s = name.substring(2);
+ StringBuffer result = new StringBuffer("'");
+ int index;
+ do {
+ index = s.indexOf("_");
+ s = s.substring(index + 1);
+ if (index != -1) {
+ if (s.startsWith("add")) {
+ result.append('+');
+ } else if (s.startsWith("sub")) {
+ result.append('-');
+ } else if (s.startsWith("logicnot")) {
+ result.append('~');
+ } else if (s.startsWith("not")) {
+ result.append('!');
+ } else if (s.startsWith("div")) {
+ result.append('/');
+ } else if (s.startsWith("mul")) {
+ result.append('*');
+ } else if (s.startsWith("xor")) {
+ result.append('^');
+ } else if (s.startsWith("mod")) {
+ result.append('%');
+ } else if (s.startsWith("greater")) {
+ result.append('>');
+ } else if (s.startsWith("less")) {
+ result.append('<');
+ } else if (s.startsWith("equal")) {
+ result.append('=');
+ } else if (s.startsWith("notdiv")) {
+ result.append('\\');
+ } else if (s.startsWith("or")) {
+ result.append('|');
+ } else if (s.startsWith("and")) {
+ result.append('&');
+ } else if (s.startsWith("dollar")) {
+ result.append('$');
+ } else if (s.startsWith("diese")) {
+ result.append('#');
+ } else if (s.startsWith("at")) {
+ result.append('@');
+ } else if (s.startsWith("ask")) {
+ result.append('?');
+ }
+ }
+ } while (index != -1);
+
+ result.append('\'');
+ return result.toString();
+ }
+
+ public String getSignature(boolean isCall) {
+ if (name.startsWith("__")) {
+ return getOperatorName();
+ }
+ if (keywordList == null || keywordList.length < 1) {
+ return name;
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(keywordList[0]);
+ buffer.append(" ");
+
+ int keywordIndex = 1;
+ for (int argIndex = 0; argIndex < argumentList.length; argIndex++) {
+ if (isCall) {
+ buffer.append(argumentList[argIndex].getName());
+ } else {
+ argumentList[argIndex].printIn(buffer);
+ }
+ buffer.append(" ");
+
+ if (keywordIndex < keywordList.length) {
+ buffer.append(keywordList[keywordIndex]);
+ buffer.append(" ");
+ keywordIndex++;
+ }
+ }
+ if (!isCall && resultType.toString() != null) {
+ buffer.append(" : " + resultType);
+ }
+
+ return buffer.toString();
+ }
+
+ public StyledString getStyledSignature(boolean isCall, boolean showProto) {
+ ColorManager colors = ColorManager.getDefault();
+ StyledString result = new StyledString();
+
+ if (name.startsWith("__")) {
+ result.append(getOperatorName(), colors.getOperatorStyler());
+ return result;
+ }
+ if (keywordList == null || keywordList.length < 1) {
+ result.append(name, colors.getSlotStyler());
+ return result;
+ }
+ result.append(keywordList[0], colors.getSlotStyler());
+ result.append(" ");
+
+ int keywordIndex = 1;
+ for (int argIndex = 0; argIndex < argumentList.length; argIndex++) {
+ if (isCall) {
+ result.append(argumentList[argIndex].getName(), colors.getVariableStyler());
+ } else {
+ argumentList[argIndex].styledPrintIn(result);
+ }
+ result.append(" ");
+
+ if (keywordIndex < keywordList.length) {
+ result.append(keywordList[keywordIndex], colors.getSlotStyler());
+ result.append(" ");
+ keywordIndex++;
+ }
+ }
+ if (!isCall && resultType.toString() != null) {
+ result.append(" : ");
+ result.append(resultType.toString(), colors.getPrototypeStyler());
+ }
+ if (showProto) {
+ result.append(" - ", StyledString.QUALIFIER_STYLER);
+ result.append(getPrototype().getName(), StyledString.QUALIFIER_STYLER);
+ }
+ return result;
+ }
+
+ public void getSlotProposals(ArrayList<ICompletionProposal> proposals,
+ int offset, int length) {
+
+ if (name.startsWith("__")) {
+ // no operator in the completion.
+ return;
+ }
+ Image image = new OutlineSlot(this).getImage();
+ String displayString = getSignature(true);
+ StyledString styledString = getStyledSignature(false, true);
+
+ if (checkUnicity(proposals,styledString.getString())) {
+ proposals.add(new LisaacCompletionProposal(displayString, offset, length,
+ displayString.length() - 1, image, styledString));
+ }
+ }
+
+ public void getSlotMatchProposals(
+ ArrayList<ICompletionProposal> proposals, int offset,
+ int length, int matchLength) {
+
+ Image image = new OutlineSlot(this).getImage();
+ String displayString = getSignature(true);
+ StyledString styledString = getStyledSignature(false, true);
+
+ if (checkUnicity(proposals,styledString.getString())) {
+ displayString = displayString.substring(matchLength);
+ proposals.add(new LisaacCompletionProposal(displayString, offset, length,
+ displayString.length(), image, styledString));
+ }
+ }
+
+ public void getArgumentMatchProposals(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+
+ if (argumentList != null) {
+ for (int i = 0; i < argumentList.length; i++) {
+ argumentList[i].getMatchProposals(n,matchList, offset, length);
+ }
+ }
+ }
+
+ public void getLocalMatchProposals(String n,
+ ArrayList<ICompletionProposal> matchList, int offset, int length) {
+
+ ITMList list;
+ if (subLists != null) {
+ for (int i = 0; i < subLists.size(); i++) {
+ ICode c = subLists.get(i);
+
+ if (c instanceof ITMList) {
+ list = (ITMList) c;
+ if (list != null && list.isInside(offset)) {
+ // list variable
+ list.getMatchProposals(n, matchList, offset, length);
+ }
+ } else if (c instanceof ITMBlock) {
+ list = ((ITMBlock) c).list;
+ IArgument arg = ((ITMBlock) c).argument;
+
+ if (list != null && arg != null
+ && list.isInside(offset)) {
+ // block argument
+ arg.getMatchProposals(n, matchList, offset, length);
+ }
+ }
+ }
+ }
+ }
+
+ // FIXME cannot compare display string now... they're already unique, ex: "slot - SON" and "slot - FATHER"
+ public static boolean checkUnicity(ArrayList<ICompletionProposal> proposals, String str) {
+ for (int i=0; i<proposals.size(); i++) {
+ if (proposals.get(i).getDisplayString().compareTo(str) == 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean match(String n) {
+ return name.startsWith(n);
+ }
+
+ public String getHoverInformation() {
+ StringBuffer buffer = new StringBuffer("<b>");
+ buffer.append(getSignature(false));
+ buffer.append("</b> <I>- ");
+ buffer.append(getPrototype().getName());
+ buffer.append("</I>");
+ if (comment != null) {
+ buffer.append("\n\n<g>");
+ buffer.append(comment);
+ buffer.append("</g>");
+ }
+ return buffer.toString();
+ }
+
+ public TextEdit[] refactorRenamePrototype(String oldName, String newName) {
+ ArrayList<TextEdit> result = new ArrayList<TextEdit>();
+
+ // 1. rename arguments
+ for (int i=0; i<argumentList.length; i++) {
+ IType type = argumentList[i].getType();
+ Position p = argumentList[i].getPosition();
+
+ if (p != null && type.toString().compareTo(oldName) == 0) {
+ LisaacParser parser = getPrototype().openParser();
+ parser.setPosition(p.offset+p.length);
+ parser.readCharacter(':');
+ parser.readSpace();
+
+ int startOffset = parser.getOffset();
+
+ result.add(new DeleteEdit(startOffset, oldName.length()));
+ result.add(new InsertEdit(startOffset, newName));
+ }
+ }
+
+ // 2. rename result type
+ if (resultType != null && resultType.toString() != null) {
+ if (resultType.toString().compareTo(oldName) == 0) {
+ LisaacParser parser = getPrototype().openParser();
+ parser.setPosition(position.offset);
+ parser.readSlotNameFromOffset(position.offset, true);
+ parser.readCharacter(':');
+ parser.readSpace();
+
+ int startOffset = parser.getOffset();
+
+ result.add(new DeleteEdit(startOffset, oldName.length()));
+ result.add(new InsertEdit(startOffset, newName));
+ }
+ }
+
+ // 3. rename code
+ if (value != null) {
+ value.refactorRenamePrototype(oldName, newName, result);
+ }
+
+ if (result.size() > 0) {
+ return result.toArray(new TextEdit[result.size()]);
+ }
+ return null;
+ }
+ }
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIP.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIP.java
new file mode 100644
index 0000000..03971e9
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIP.java
@@ -0,0 +1,93 @@
+package org.lisaac.ldt.model.lip;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class LIP {
+
+ private static final String PROJECT_PATH_SLOT = "project_path";
+ private static final String LISAAC_PATH_SLOT = "path";
+
+ private String filename;
+
+ /** parent lip files */
+ protected ArrayList<String> listParent = new ArrayList<String>();
+
+ /** lip method list */
+ protected ArrayList<LIPSlotCode> listMethod = new ArrayList<LIPSlotCode>();
+
+ /** lip data */
+ protected HashMap<String,LIPSlotData> listData = new HashMap<String,LIPSlotData>();
+
+
+ public LIP(String filename) {
+ this.filename = filename;
+ }
+
+ public String getFileName() {
+ return filename;
+ }
+
+ public void addParent(String string) {
+ listParent.add(string);
+ }
+ public void addMethod(LIPSlotCode m) {
+ listMethod.add(m);
+ }
+ public void addData(LIPSlotData data) {
+ listData.put(data.getName(),data);
+ }
+
+ public ArrayList<String> getParentList() {
+ return listParent;
+ }
+
+ public void clearParents() {
+ listParent = null;
+ }
+
+ public LIPSlotCode getMethod(int i) {
+ return listMethod.get(i);
+ }
+ public int getMethodCount() {
+ return listMethod.size();
+ }
+
+ public LIPSlotCode getPublicMethod(int index) {
+ int count = 0;
+ for (int i=0; i<getMethodCount(); i++) {
+ LIPSlotCode method = getMethod(i);
+ if (method.isPublic()) {
+ if (index == count) {
+ return method;
+ }
+ count++;
+ }
+ }
+ return null;
+ }
+
+ public int getPublicMethodCount() {
+ int count = 0;
+ for (int i=0; i<getMethodCount(); i++) {
+ LIPSlotCode method = getMethod(i);
+ if (method.isPublic()) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public void addProjectPath(String projectPath) {
+ for (int i=0; i<getMethodCount(); i++) {
+ LIPSlotCode method = getMethod(i);
+ if (method.getName().compareTo(PROJECT_PATH_SLOT) == 0) {
+
+ // lip code: path (projectPath);
+ method.addLastCode(new LIPCall(LISAAC_PATH_SLOT, new LIPValue(new LIPString(projectPath))));
+ break;
+ }
+ }
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPAffect.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPAffect.java
new file mode 100644
index 0000000..aa7ca69
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPAffect.java
@@ -0,0 +1,12 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPAffect extends LIPCode {
+
+ protected String name;
+ protected LIPCode value;
+
+ public LIPAffect(String name, LIPCode value) {
+ this.name = name;
+ this.value = value;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPBinary.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPBinary.java
new file mode 100644
index 0000000..2c8b920
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPBinary.java
@@ -0,0 +1,13 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPBinary extends LIPCode {
+
+ protected LIPCode left, right;
+ protected char operator;
+
+ public LIPBinary(LIPCode left, char operator, LIPCode right) {
+ this.left = left;
+ this.right = right;
+ this.operator = operator;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPBoolean.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPBoolean.java
new file mode 100644
index 0000000..9d07d51
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPBoolean.java
@@ -0,0 +1,28 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPBoolean extends LIPConstant {
+
+ private static LIPBoolean lipTrue = new LIPBoolean(true);
+ private static LIPBoolean lipFalse = new LIPBoolean(false);
+
+ protected boolean value;
+
+ LIPBoolean(boolean i) {
+ value = i;
+ }
+
+ public static LIPBoolean get(boolean b) {
+ if (b) {
+ return lipTrue;
+ } else {
+ return lipFalse;
+ }
+ }
+
+ public void free() {;
+ }
+
+ public String getName() {
+ return "BOOLEAN";
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPCall.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPCall.java
new file mode 100644
index 0000000..2cd28f4
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPCall.java
@@ -0,0 +1,13 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPCall extends LIPCode {
+
+ protected String name;
+ protected LIPCode argument;
+
+ public LIPCall(String name, LIPCode argument) {
+ this.name = name;
+ this.argument = argument;
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPCode.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPCode.java
new file mode 100644
index 0000000..716d535
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPCode.java
@@ -0,0 +1,4 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPCode {
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPConstant.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPConstant.java
new file mode 100644
index 0000000..1e4a1f8
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPConstant.java
@@ -0,0 +1,8 @@
+package org.lisaac.ldt.model.lip;
+
+public abstract class LIPConstant {
+
+ public abstract String getName();
+
+ public abstract void free();
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPIf.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPIf.java
new file mode 100644
index 0000000..3b378af
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPIf.java
@@ -0,0 +1,15 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPIf extends LIPCode {
+
+ protected LIPCode condition;
+ protected LIPCode[] thenCode;
+ protected LIPCode[] elseCode;
+
+ public LIPIf(LIPCode condition, LIPCode[] thenCode, LIPCode[] elseCode) {
+ this.condition = condition;
+ this.thenCode = thenCode;
+ this.elseCode = elseCode;
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPInteger.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPInteger.java
new file mode 100644
index 0000000..a494883
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPInteger.java
@@ -0,0 +1,23 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPInteger extends LIPConstant {
+
+ protected int value;
+
+ LIPInteger(int i) {
+ value = i;
+ }
+
+ public static LIPInteger get(int i) {
+ // TODO storage..
+ return new LIPInteger(i);
+ }
+
+ public void free() {
+ // TODO storage.add_last Self;
+ }
+
+ public String getName() {
+ return "INTEGER";
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPPrint.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPPrint.java
new file mode 100644
index 0000000..1ceab63
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPPrint.java
@@ -0,0 +1,10 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPPrint extends LIPCode {
+
+ protected LIPCode message;
+
+ public LIPPrint(LIPCode message) {
+ this.message = message;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPSlotCode.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPSlotCode.java
new file mode 100644
index 0000000..e3f5e6d
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPSlotCode.java
@@ -0,0 +1,62 @@
+package org.lisaac.ldt.model.lip;
+
+import org.lisaac.ldt.model.ILisaacModel;
+
+public class LIPSlotCode extends LIPCode {
+ protected String section;
+
+ protected String name;
+ protected String comment;
+
+ protected LIPSlotData argument;
+ protected LIPCode[] code;
+
+ public LIPSlotCode(String section, String name, LIPSlotData argument, LIPCode[] code) {
+ this.section = section;
+ this.name = name;
+ this.argument = argument;
+ this.code = code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public boolean isPublic() {
+ return section.equals(ILisaacModel.section_public);
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer(" -");
+ result.append(name);
+ if (argument != null) {
+ result.append(" <");
+ result.append(argument);
+ result.append(">");
+ }
+ result.append(" :\n");
+ if (comment != null) {
+ result.append(comment);
+ } else {
+ result.append("\t Sorry, no comment (see `make.lip').\n");
+ }
+ return result.toString();
+ }
+
+ public void addLastCode(LIPCode instr) { // TODO use array list
+
+ LIPCode[] newCode = new LIPCode[code.length + 1];
+ System.arraycopy(code, 0, newCode, 0, code.length);
+ newCode[newCode.length - 1] = instr;
+
+ code = newCode;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPSlotData.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPSlotData.java
new file mode 100644
index 0000000..1c845e7
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPSlotData.java
@@ -0,0 +1,29 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPSlotData extends LIPCode {
+
+ protected String name;
+ protected LIPConstant value;
+
+ public LIPSlotData(String name, LIPConstant value) {
+ this.name = name;
+ this.value = value;
+ // TODO check double declaration
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(name);
+ result.append(":");
+ result.append(value.getName());
+ return result.toString();
+ }
+
+ public void setValue(LIPConstant value) {
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPString.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPString.java
new file mode 100644
index 0000000..63f710b
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPString.java
@@ -0,0 +1,23 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPString extends LIPConstant {
+
+ protected String value;
+
+ LIPString(String i) {
+ value = i;
+ }
+
+ public static LIPString get(String i) {
+ // TODO storage..
+ return new LIPString(i);
+ }
+
+ public void free() {
+ // TODO storage.add_last Self;
+ }
+
+ public String getName() {
+ return "STRING";
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPUnary.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPUnary.java
new file mode 100644
index 0000000..30d5135
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPUnary.java
@@ -0,0 +1,13 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPUnary extends LIPCode {
+
+ protected LIPCode value;
+ protected char operator;
+
+ public LIPUnary(char operator, LIPCode value) {
+ this.value = value;
+ this.operator = operator;
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPValue.java b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPValue.java
new file mode 100644
index 0000000..33ad0a3
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/lip/LIPValue.java
@@ -0,0 +1,10 @@
+package org.lisaac.ldt.model.lip;
+
+public class LIPValue extends LIPCode {
+
+ protected LIPConstant value;
+
+ public LIPValue(LIPConstant value) {
+ this.value = value;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/IType.java b/editor/eclipse/src/org/lisaac/ldt/model/types/IType.java
new file mode 100644
index 0000000..6c4441f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/IType.java
@@ -0,0 +1,8 @@
+package org.lisaac.ldt.model.types;
+
+public interface IType {
+
+ void rename(String oldName, String newName);
+
+ public String toString();
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/ITypeMono.java b/editor/eclipse/src/org/lisaac/ldt/model/types/ITypeMono.java
new file mode 100644
index 0000000..eeeed50
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/ITypeMono.java
@@ -0,0 +1,4 @@
+package org.lisaac.ldt.model.types;
+
+public interface ITypeMono extends IType {
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeBlock.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeBlock.java
new file mode 100644
index 0000000..79ebf93
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeBlock.java
@@ -0,0 +1,57 @@
+package org.lisaac.ldt.model.types;
+
+import org.lisaac.ldt.model.ILisaacModel;
+
+/**
+ * Type block definition
+ */
+public class TypeBlock implements ITypeMono {
+
+ //private static List<TypeBlock> dico;
+
+ protected IType typeArgument;
+ protected IType typeResult;
+
+ TypeBlock(IType typeArgument, IType typeResult) {
+ this.typeArgument = typeArgument;
+ this.typeResult = typeResult;
+ }
+
+ public static TypeBlock get(IType typ_arg, IType typ_res) {
+
+ return new TypeBlock(typ_arg, typ_res);
+
+ /*TypeBlock result=null;
+
+ if (dico == null) {
+ dico = new ArrayList<TypeBlock>();
+ }
+ int idx = 0;
+ while (idx < dico.size() &&
+ (!dico.get(idx).getTypeArg().equals(typ_arg) || !dico.get(idx).getTypeRes().equals(typ_res))) {
+ idx++;
+ }
+ if (idx <= dico.size()-1) {
+ result = dico.get(idx);
+ } else {
+ result = new TypeBlock(typ_arg, typ_res);
+ dico.add(result);
+ }
+ return result;*/
+ }
+
+ public IType getTypeArg() {
+ return typeArgument;
+ }
+ public IType getTypeRes() {
+ return typeResult;
+ }
+
+ public String toString() {
+ return ILisaacModel.prototype_block;
+ }
+
+ public void rename(String oldName, String newName) {
+ // TODO emit error
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeGeneric.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeGeneric.java
new file mode 100644
index 0000000..f3d9573
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeGeneric.java
@@ -0,0 +1,15 @@
+package org.lisaac.ldt.model.types;
+
+public class TypeGeneric extends TypeStyle {
+
+ protected ITypeMono[] listType;
+
+ public TypeGeneric(String name, String style, ITypeMono[] lt) {
+ super(name, style);
+ listType = lt;
+ }
+
+ public ITypeMono getGenericElt(int index) {
+ return listType[index];
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeMulti.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeMulti.java
new file mode 100644
index 0000000..934e2f0
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeMulti.java
@@ -0,0 +1,54 @@
+package org.lisaac.ldt.model.types;
+
+import java.util.*;
+
+/**
+ * List of type
+ */
+public class TypeMulti implements IType {
+
+ private static List<TypeMulti> dico;
+
+ protected ITypeMono[] listType;
+
+ public TypeMulti(ITypeMono[] lst) {
+ listType = lst;
+ }
+
+ public ITypeMono[] getTypeList() {
+ return listType;
+ }
+
+ public IType getSubType(int index) {
+ return listType[index];
+ }
+
+ public static IType get(ITypeMono[] lst) {
+ TypeMulti result=null;
+
+ if (dico == null) {
+ dico = new ArrayList<TypeMulti>();
+ }
+ int idx = 0;
+ while (idx < dico.size() && !dico.get(idx).getTypeList().equals(lst)) {
+ idx++;
+ }
+ if (idx <= dico.size()-1) {
+ result = dico.get(idx);
+ } else {
+ result = new TypeMulti(lst);
+ dico.add(result);
+ }
+ return result;
+ }
+
+ public String toString() {
+ return "(...)"; // TODO multi type print
+ }
+
+ public void rename(String oldName, String newName) {
+ for (int i=0; i<listType.length; i++) {
+ listType[i].rename(oldName, newName);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeParameter.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeParameter.java
new file mode 100644
index 0000000..4959067
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeParameter.java
@@ -0,0 +1,25 @@
+package org.lisaac.ldt.model.types;
+
+import java.util.HashMap;
+
+/**
+ * Parameter type for argument define.
+ */
+public class TypeParameter extends TypeSimple {
+
+ public TypeParameter(String name) {
+ super(name);
+ }
+
+ public static TypeParameter get(String n) {
+ TypeParameter result=null;
+
+ if (dico != null && dico.containsKey(n)) {
+ result = (TypeParameter) dico.get(n);
+ }
+ if (result == null) {
+ result = new TypeParameter(n);
+ }
+ return result;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeSelf.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeSelf.java
new file mode 100644
index 0000000..796e821
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeSelf.java
@@ -0,0 +1,39 @@
+package org.lisaac.ldt.model.types;
+
+import java.util.HashMap;
+
+public class TypeSelf implements ITypeMono {
+
+ private static HashMap<String,TypeSelf> dico;
+
+ protected String staticType;
+
+ TypeSelf(String staticType) {
+ this.staticType = staticType;
+ }
+
+ public static TypeSelf get(String n) {
+ TypeSelf result=null;
+
+ if (dico == null) {
+ dico = new HashMap<String,TypeSelf>();
+ }
+ result = dico.get(n == null ? "" : n);
+ if (result == null) {
+ result = new TypeSelf(n);
+ }
+ return result;
+ }
+
+ public String getStaticType() {
+ return staticType;
+ }
+
+ public String toString() {
+ return staticType;// ou SELF
+ }
+
+ public void rename(String oldName, String newName) {
+ // TODO emit error
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeSimple.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeSimple.java
new file mode 100644
index 0000000..7198ef4
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeSimple.java
@@ -0,0 +1,71 @@
+package org.lisaac.ldt.model.types;
+
+import java.util.HashMap;
+
+import org.lisaac.ldt.model.ILisaacModel;
+
+public class TypeSimple implements ITypeMono {
+
+ protected static HashMap<String,TypeSimple> dico;
+
+ protected String name;
+
+ TypeSimple(String name) {
+ this.name = name;
+
+ if (dico == null) {
+ dico = new HashMap<String,TypeSimple>();
+ }
+ dico.put(name, this);
+ }
+ public String getName() {
+ return name;
+ }
+
+ protected static TypeSimple typeNull;
+ protected static TypeSimple typeVoid;
+ protected static TypeSimple typeBoolean; // for '=' operator
+
+ public static void init() {
+ typeNull = new TypeSimple(ILisaacModel.variable_null);
+ typeVoid = new TypeSimple(ILisaacModel.variable_void);
+ typeBoolean = new TypeSimple(ILisaacModel.prototype_boolean);
+ }
+
+ public static TypeSimple get(String n) {
+ TypeSimple result=null;
+
+ if (dico == null) {
+ dico = new HashMap<String,TypeSimple>();
+ }
+ result = dico.get(n);
+ if (result == null) {
+ result = new TypeSimple(n);
+ }
+ return result;
+ }
+
+ public static ITypeMono getTypeVoid() {
+ return typeVoid;
+ }
+ public static ITypeMono getTypeNull() {
+ return typeNull;
+ }
+ public static ITypeMono getTypeBoolean() {
+ return typeBoolean;
+ }
+
+ public String toString() { // FIXME VOID pb
+ if (this.equals(typeVoid) || name.compareTo("VOID") == 0) {
+ return null; // do not print void type
+ }
+ return name;
+ }
+ public void rename(String oldName, String newName) {
+ if (name.compareTo(oldName) == 0) {
+ dico.put(name, null);
+ name = newName;
+ dico.put(name, this);
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/model/types/TypeStyle.java b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeStyle.java
new file mode 100644
index 0000000..7fdc595
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/model/types/TypeStyle.java
@@ -0,0 +1,43 @@
+package org.lisaac.ldt.model.types;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Type with style
+ */
+public class TypeStyle extends TypeSimple {
+
+ private static List<TypeStyle> dico;
+
+ protected String style;
+
+ TypeStyle(String name, String style) {
+ super(name);
+ this.style = style;
+ }
+
+ public String getStyle() {
+ return style;
+ }
+
+ public static TypeStyle get(String n, String s) {
+ TypeStyle result=null;
+
+ if (dico == null) {
+ dico = new ArrayList<TypeStyle>();
+ }
+ int idx = 0;
+ while (idx < dico.size() &&
+ (!dico.get(idx).getName().equals(n) || !dico.get(idx).getStyle().equals(s))) {
+ idx++;
+ }
+ if (idx <= dico.size()-1) {
+ result = dico.get(idx);
+ } else {
+ result = new TypeStyle(n, s);
+ dico.add(result);
+ }
+ return result;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlineContentProvider.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineContentProvider.java
new file mode 100644
index 0000000..fafbac2
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineContentProvider.java
@@ -0,0 +1,53 @@
+package org.lisaac.ldt.outline;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class OutlineContentProvider implements ITreeContentProvider {
+
+ /**
+ * @see ITreeContentProvider#getChildren(Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof OutlineItem) {
+ OutlineItem outlineElement = (OutlineItem) parentElement;
+ List<OutlineItem> children = outlineElement.getChildren();
+ if (children != null) {
+ return children.toArray(new Object[children.size()]);
+ }
+ } else if (parentElement instanceof Object[]) {
+ return ((Object[]) parentElement);
+ }
+ return new Object[0];
+ }
+
+
+ /**
+ * @see ITreeContentProvider#getParent(Object)
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /**
+ * @see ITreeContentProvider#hasChildren(Object)
+ */
+ public boolean hasChildren(Object element) {
+ return (getChildren(element).length > 0);
+ }
+
+ /**
+ * @see IStructuredContentProvider#getElements(Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlineImages.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineImages.java
new file mode 100644
index 0000000..a07b4b0
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineImages.java
@@ -0,0 +1,27 @@
+package org.lisaac.ldt.outline;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.LisaacPlugin;
+
+public class OutlineImages {
+ public static final Image PROTOTYPE = getImage("/icons/prototype.gif");
+
+ public static final Image PUBLIC_SHARED = getImage("/icons/public-shared.gif");
+ public static final Image PRIVATE_SHARED = getImage("/icons/private-shared.gif");
+ public static final Image PUBLIC_NONSHARED = getImage("/icons/public-nonshared.gif");
+ public static final Image PRIVATE_NONSHARED = getImage("/icons/private-nonshared.gif");
+
+ public static final Image KEYWORD = getImage("/icons/keyword.gif");
+
+ public static final Image BLANK = getImage("/icons/blank.gif");
+
+
+ public static final String SORT_ALPHA = "/icons/alphab_sort_co.gif";
+ public static final String SORT_SECTION = "/icons/sections_co.gif";
+
+ private static Image getImage(String path) {
+ ImageDescriptor descr = LisaacPlugin.getImageDescriptor(path);
+ return descr.createImage();
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlineItem.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineItem.java
new file mode 100644
index 0000000..7b4d9f2
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineItem.java
@@ -0,0 +1,43 @@
+package org.lisaac.ldt.outline;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+
+public abstract class OutlineItem implements Comparable<Object> {
+
+ public static boolean showSections = true;
+
+ protected int fstartOffset;
+ protected int fLength;
+
+ /**
+ * Returns the image which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getImage(Object)
+ */
+ public abstract Image getImage();
+
+
+ /**
+ * Returns the label which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getText(Object)
+ */
+ public abstract String getText();
+
+ public abstract StyledString getStyledText();
+
+ /**
+ * Returns the children of this element.
+ */
+ public abstract List<OutlineItem> getChildren();
+
+
+ public int startOffset() {
+ return fstartOffset;
+ }
+
+ public int length() {
+ return fLength;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlineLabelProvider.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineLabelProvider.java
new file mode 100644
index 0000000..b217a2e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineLabelProvider.java
@@ -0,0 +1,66 @@
+package org.lisaac.ldt.outline;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.graphics.Image;
+
+public class OutlineLabelProvider extends StyledCellLabelProvider {
+
+ /**
+ * @see WorkbenchLabelProvider#getImage(Object)
+ * @param element the element for which an image is created
+ * @return the image associated to the element
+ */
+ public Image getImage(Object element) {
+ if (element instanceof OutlineItem) {
+ OutlineItem item = (OutlineItem) element;
+ Image image = item.getImage();
+
+ if (image != null) {
+ return image;
+ }
+ }
+ return OutlineImages.BLANK;
+ }
+
+ /**
+ * @see WorkbenchLabelProvider#getText(Object)
+ * @param element the element for which a label is created
+ * @return the label associated to the element
+ */
+ public String getText(Object element) {
+ if (element instanceof OutlineItem) {
+ OutlineItem item = (OutlineItem) element;
+ return item.getText();
+ }
+ if (element != null) {
+ return element.toString();
+ } else {
+ return new String();
+ }
+ }
+
+ public StyledString getStyledText(Object element) {
+ if (element instanceof OutlineItem) {
+ OutlineItem item = (OutlineItem) element;
+ return item.getStyledText();
+ }
+ if (element != null) {
+ return new StyledString(element.toString());
+ } else {
+ return new StyledString();
+ }
+ }
+
+ public void update(ViewerCell cell) {
+ Object obj = cell.getElement();
+ StyledString styledString = getStyledText(obj);
+
+ cell.setText(styledString.toString());
+ cell.setStyleRanges(styledString.getStyleRanges());
+ cell.setImage(getImage(obj));
+ super.update(cell);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlinePrototype.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlinePrototype.java
new file mode 100644
index 0000000..d2e8bd0
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlinePrototype.java
@@ -0,0 +1,64 @@
+package org.lisaac.ldt.outline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
+import org.lisaac.ldt.model.items.Prototype;
+
+public class OutlinePrototype extends OutlineItem {
+ protected String name;
+
+ protected List<OutlineItem> sections;
+
+
+ public OutlinePrototype(Prototype prototype, List<OutlineItem> sections) {
+ name = prototype.getName();
+ this.sections = sections;
+ }
+
+ /**
+ * Returns the label which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getText(Object)
+ */
+ public String getText() {
+ return name;
+ }
+
+ public StyledString getStyledText() {
+ ColorManager colors = ColorManager.getDefault();
+ return new StyledString(name, colors.getPrototypeStyler());
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Returns the image which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getImage(Object)
+ */
+ public Image getImage() {
+ return OutlineImages.PROTOTYPE;
+ }
+
+ public List<OutlineItem> getChildren() {
+ List<OutlineItem> result;
+
+ if (showSections) {
+ result = sections;
+ } else {
+ result = new ArrayList<OutlineItem>();
+ for (int i=0; i<sections.size(); i++) {
+ result.addAll(((OutlineSection)sections.get(i)).slots);
+ }
+ }
+ return result;
+ }
+
+ public int compareTo(Object arg0) {
+ return 0;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlineSection.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineSection.java
new file mode 100644
index 0000000..84ea3a6
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineSection.java
@@ -0,0 +1,94 @@
+package org.lisaac.ldt.outline;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.items.Section;
+import org.lisaac.ldt.model.types.ITypeMono;
+
+public class OutlineSection extends OutlineItem {
+
+ protected Section section;
+
+ protected List<OutlineItem> slots;
+
+ public OutlineSection(Section section) {
+ this.section = section;
+ this.slots = section.getOutlineItems();
+
+ Position position = section.getPosition();
+
+ fstartOffset = position.getStartOffset() - 7;
+ fLength = 7;
+ //fstartOffset = position.getStartOffset();
+ //fLength = position.length();
+ }
+
+ /**
+ * Returns the label which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getText(Object)
+ */
+ public String getText() {
+ String result="";
+ if (section != null) {
+ if (section.getName() != null) {
+ result = section.getName();
+ } else {
+ ITypeMono[] types = section.getTypeList();
+ for (int i=0; i<types.length; i++) {
+ result += types[i];
+ if (i != types.length-1) {
+ result += ", ";
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public StyledString getStyledText() {
+ StyledString result = new StyledString();
+ ColorManager colors = ColorManager.getDefault();
+
+ if (section != null) {
+ if (section.getName() != null) {
+ result.append(section.getName());
+ } else {
+ ITypeMono[] types = section.getTypeList();
+ for (int i=0; i<types.length; i++) {
+ result.append(types[i].toString(), colors.getPrototypeStyler());
+ if (i != types.length-1) {
+ result.append(", ");
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public String toString() {
+ return getText();
+ }
+
+ /**
+ * Returns the image which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getImage(Object)
+ */
+ public Image getImage() {
+ if (section != null) {
+ return OutlineImages.PRIVATE_NONSHARED;
+ }
+ return null;
+ }
+
+ public List<OutlineItem> getChildren() {
+ return slots;
+ }
+
+ public int compareTo(Object arg0) {
+ return 0;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/outline/OutlineSlot.java b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineSlot.java
new file mode 100644
index 0000000..69eb440
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/outline/OutlineSlot.java
@@ -0,0 +1,82 @@
+package org.lisaac.ldt.outline;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.model.Position;
+import org.lisaac.ldt.model.items.Slot;
+
+public class OutlineSlot extends OutlineItem {
+
+ protected Slot slot;
+
+ public OutlineSlot(Slot slot) {
+ this.slot = slot;
+
+ Position position = slot.getPosition();
+
+ fstartOffset = position.getStartOffset();
+ fLength = position.length();
+ }
+
+ /**
+ * Returns the label which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getText(Object)
+ */
+ public String getText() {
+ String result=null;
+ if (slot != null) {
+ result = slot.getSignature(false);
+ }
+ return result;
+ }
+
+ public StyledString getStyledText() {
+ if (slot != null) {
+ return slot.getStyledSignature(false, false);
+ }
+ return null;
+ }
+
+ public String toString() {
+ return getText();
+ }
+
+ /**
+ * Returns the image which corresponds to the element, null otherwise.
+ * @see ILabelProvider#getImage(Object)
+ */
+ public Image getImage() {
+ if (slot != null) {
+ if (slot.getStyle() == '+') {
+ if (slot.getSectionId() != null &&
+ slot.getSectionId().isPrivateStyle()) {
+ return OutlineImages.PRIVATE_NONSHARED;
+ } else {
+ return OutlineImages.PUBLIC_NONSHARED;
+ }
+ } else {
+ if (slot.getSectionId() != null &&
+ slot.getSectionId().isPrivateStyle()) {
+ return OutlineImages.PRIVATE_SHARED;
+ } else {
+ return OutlineImages.PUBLIC_SHARED;
+ }
+ }
+ }
+ return null;
+ }
+
+ public List<OutlineItem> getChildren() {
+ return null;
+ }
+
+ public int compareTo(Object obj) {
+ if (obj instanceof OutlineSlot) {
+ OutlineSlot slot = (OutlineSlot) obj;
+ return getText().compareTo(slot.getText());
+ }
+ return 0;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/perspectives/LisaacPerspective.java b/editor/eclipse/src/org/lisaac/ldt/perspectives/LisaacPerspective.java
new file mode 100644
index 0000000..63cef86
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/perspectives/LisaacPerspective.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.lisaac.ldt.perspectives;
+
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.console.IConsoleConstants;
+
+/**
+ * This class is meant to serve as an example for how various contributions
+ * are made to a perspective. Note that some of the extension point id's are
+ * referred to as API constants while others are hardcoded and may be subject
+ * to change.
+ */
+public class LisaacPerspective implements IPerspectiveFactory {
+
+ private IPageLayout factory;
+
+ public LisaacPerspective() {
+ super();
+ }
+
+ public void createInitialLayout(IPageLayout factory) {
+ this.factory = factory;
+ addViews();
+ addActionSets();
+ addNewWizardShortcuts();
+ addPerspectiveShortcuts();
+ addViewShortcuts();
+ }
+
+ private void addViews() {
+ // Creates the overall folder layout.
+ // Note that each new Folder uses a percentage of the remaining EditorArea.
+
+ IFolderLayout topLeft =
+ factory.createFolder(
+ "topLeft", //NON-NLS-1
+ IPageLayout.LEFT,
+ 0.25f,
+ factory.getEditorArea());
+ topLeft.addView(IPageLayout.ID_RES_NAV);
+
+ IFolderLayout bottom =
+ factory.createFolder(
+ "bottomRight", //NON-NLS-1
+ IPageLayout.BOTTOM,
+ 0.75f,
+ factory.getEditorArea());
+ bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
+ bottom.addView("org.eclipse.team.ui.GenericHistoryView"); //NON-NLS-1
+ bottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
+
+ IFolderLayout topRight =
+ factory.createFolder(
+ "topRight", //NON-NLS-1
+ IPageLayout.RIGHT,
+ 0.80f,
+ factory.getEditorArea());
+ topRight.addView(IPageLayout.ID_OUTLINE);
+
+ factory.addFastView("org.eclipse.team.sync.views.SynchronizeView", 0.50f); //NON-NLS-1
+ }
+
+ private void addActionSets() {
+ factory.addActionSet("org.eclipse.debug.ui.launchActionSet"); //NON-NLS-1
+ //factory.addActionSet("org.eclipse.debug.ui.debugActionSet"); //NON-NLS-1
+ //factory.addActionSet("org.eclipse.debug.ui.profileActionSet"); //NON-NLS-1
+ factory.addActionSet("org.eclipse.team.ui.actionSet"); //NON-NLS-1
+ //factory.addActionSet("org.eclipse.ant.ui.actionSet.presentation"); //NON-NLS-1
+ factory.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); //NON-NLS-1
+ }
+
+ private void addPerspectiveShortcuts() {
+ factory.addPerspectiveShortcut("org.eclipse.team.ui.TeamSynchronizingPerspective"); //NON-NLS-1
+ factory.addPerspectiveShortcut("org.eclipse.ui.resourcePerspective"); //NON-NLS-1
+ }
+
+ private void addNewWizardShortcuts() {
+ factory.addNewWizardShortcut("org.lisaac.ldt.prototype");//NON-NLS-1
+ factory.addNewWizardShortcut("org.lisaac.ldt.wizard");//NON-NLS-1
+ factory.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//NON-NLS-1
+ factory.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//NON-NLS-1
+ }
+
+ private void addViewShortcuts() {
+ factory.addShowViewShortcut("org.eclipse.pde.ui.DependenciesView"); //NON-NLS-1
+ factory.addShowViewShortcut("org.eclipse.team.ui.GenericHistoryView"); //NON-NLS-1
+ factory.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
+ factory.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+ factory.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+ factory.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacColoringPage.java b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacColoringPage.java
new file mode 100644
index 0000000..c87cbd9
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacColoringPage.java
@@ -0,0 +1,110 @@
+package org.lisaac.ldt.preferences;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.*;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.ILisaacColor;
+
+/**
+ * Lisaac Syntax coloring preference page.
+ */
+public class LisaacColoringPage extends FieldEditorPreferencePage
+implements IWorkbenchPreferencePage {
+
+ private Group colorGroup;
+
+ private String[][] comboValues;
+
+ public LisaacColoringPage() {
+ super(GRID);
+ setPreferenceStore(LisaacPlugin.getDefault().getPreferenceStore());
+ }
+
+ public void createFieldEditors() {
+ colorGroup = new Group(getFieldEditorParent(),SWT.SHADOW_ETCHED_IN);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ colorGroup.setLayoutData(gd);
+ colorGroup.setLayout(new GridLayout(2, false));
+ colorGroup.setText(LisaacMessages.getString("LisaacColoringPage.0")); //$NON-NLS-1$
+
+ String bold = LisaacMessages.getString("LisaacColoringPage.20");
+ String italics = LisaacMessages.getString("LisaacColoringPage.21");
+ String normal = LisaacMessages.getString("LisaacColoringPage.22");
+ String underline = LisaacMessages.getString("LisaacColoringPage.23");
+ String[][] values = {
+ {normal, ILisaacColor.PREF_NORMAL},
+ {bold, ILisaacColor.PREF_BOLD},
+ {italics, ILisaacColor.PREF_ITALICS},
+ {underline, ILisaacColor.PREF_UNDERLINE}
+ };
+ this.comboValues = values;
+
+
+ addField(new ColorFieldEditor(
+ ILisaacColor.PREF_COMMENT,
+ LisaacMessages.getString("LisaacColoringPage.2"), colorGroup)); //$NON-NLS-1$
+
+
+ createColorField(ILisaacColor.PREF_PROTOTYPE, ILisaacColor.STYLE_PROTOTYPE,
+ LisaacMessages.getString("LisaacColoringPage.3")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_PROTOTYPE_STYLE, ILisaacColor.STYLE_PROTOTYPE_STYLE,
+ LisaacMessages.getString("LisaacColoringPage.4")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_KEYWORD, ILisaacColor.STYLE_KEYWORD,
+ LisaacMessages.getString("LisaacColoringPage.5")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_SLOT, ILisaacColor.STYLE_SLOT,
+ LisaacMessages.getString("LisaacColoringPage.11")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_LOCAL_SLOT, ILisaacColor.STYLE_LOCAL_SLOT,
+ LisaacMessages.getString("LisaacColoringPage.12")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_CHARACTER, ILisaacColor.STYLE_CHARACTER,
+ LisaacMessages.getString("LisaacColoringPage.6")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_STRING, ILisaacColor.STYLE_STRING,
+ LisaacMessages.getString("LisaacColoringPage.7")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_NUMBER, ILisaacColor.STYLE_NUMBER,
+ LisaacMessages.getString("LisaacColoringPage.8")); //$NON-NLS-1$
+
+ createColorField(ILisaacColor.PREF_OPERATOR, ILisaacColor.STYLE_OPERATOR,
+ LisaacMessages.getString("LisaacColoringPage.9")); //$NON-NLS-1$
+
+
+ addField(new ColorFieldEditor(
+ ILisaacColor.PREF_EXTERNAL,
+ LisaacMessages.getString("LisaacColoringPage.10"), colorGroup)); //$NON-NLS-1$
+ }
+
+ private void createColorField(String prefColor, String prefStyle, String tokenName) {
+ Composite c = new Composite(colorGroup, SWT.NONE);
+ c.setLayout(new GridLayout(3, false));
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ c.setLayoutData(gd);
+
+ Label label = new Label(c, SWT.NONE);
+ gd = new GridData(80, 15);
+ label.setLayoutData(gd);
+ label.setText(tokenName);
+
+ Composite c2 = new Composite(c, SWT.NONE);
+ addField(new ColorFieldEditor(prefColor, "", c2));
+
+ c2 = new Composite(c, SWT.NONE);
+ addField(new ComboFieldEditor(prefStyle, "", comboValues, c2)); //$NON-NLS-1$
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacEditorPage.java b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacEditorPage.java
new file mode 100644
index 0000000..9c5bd51
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacEditorPage.java
@@ -0,0 +1,53 @@
+package org.lisaac.ldt.preferences;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.*;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.LisaacPlugin;
+
+/**
+ * Lisaac Syntax coloring preference page.
+ */
+public class LisaacEditorPage extends FieldEditorPreferencePage
+implements IWorkbenchPreferencePage {
+
+ public LisaacEditorPage() {
+ super(GRID);
+ setPreferenceStore(LisaacPlugin.getDefault().getPreferenceStore());
+ }
+
+ public void createFieldEditors() {
+ Composite g = getFieldEditorParent();
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ g.setLayoutData(gd);
+
+
+ addField(new BooleanFieldEditor(PreferenceConstants.P_LISAAC_INDENT,
+ LisaacMessages.getString("LisaacEditorPage.0"), g)); //$NON-NLS-1$
+ addField(new BooleanFieldEditor(PreferenceConstants.P_LISAAC_HOVER,
+ LisaacMessages.getString("LisaacEditorPage.1"), g)); //$NON-NLS-1$
+ addField(new BooleanFieldEditor(PreferenceConstants.P_LISAAC_FOLD,
+ LisaacMessages.getString("LisaacEditorPage.5"), g)); //$NON-NLS-1$
+
+ Group completionGroup = new Group(g,SWT.SHADOW_ETCHED_IN);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ gd.verticalSpan = 2;
+ completionGroup.setLayoutData(gd);
+ completionGroup.setText(LisaacMessages.getString("LisaacEditorPage.2")); //$NON-NLS-1$
+
+ addField(new BooleanFieldEditor(PreferenceConstants.P_LISAAC_COMPLETION,
+ LisaacMessages.getString("LisaacEditorPage.3"), completionGroup)); //$NON-NLS-1$
+
+ addField(new StringFieldEditor(PreferenceConstants.P_LISAAC_COMPLETION_DELAY,
+ LisaacMessages.getString("LisaacEditorPage.4"), completionGroup)); //$NON-NLS-1$
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacPreferencePage.java b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacPreferencePage.java
new file mode 100644
index 0000000..c699394
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacPreferencePage.java
@@ -0,0 +1,69 @@
+package org.lisaac.ldt.preferences;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.LisaacPlugin;
+
+/**
+ * This class represents a preference page that
+ * is contributed to the Preferences dialog. By
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we
+ * can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to
+ * save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They
+ * are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can
+ * be accessed directly via the preference store.
+ */
+
+public class LisaacPreferencePage
+ extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public LisaacPreferencePage() {
+ super(GRID);
+ setPreferenceStore(LisaacPlugin.getDefault().getPreferenceStore());
+ setDescription(LisaacMessages.getString("LisaacPreferencePage.0")); //$NON-NLS-1$
+ }
+
+ /**
+ * Creates the field editors. Field editors are abstractions of
+ * the common GUI blocks needed to manipulate various types
+ * of preferences. Each field editor knows how to save and
+ * restore itself.
+ */
+ public void createFieldEditors() {
+ addField(new StringFieldEditor(PreferenceConstants.P_LISAAC_USER,
+ LisaacMessages.getString("LisaacPreferencePage.1"), getFieldEditorParent())); //$NON-NLS-1$
+
+ //addField(new DirectoryFieldEditor(PreferenceConstants.P_LISAAC_PATH,
+ // "&Lisaac Environment Directory:", getFieldEditorParent()));
+ /*addField(
+ new BooleanFieldEditor(
+ PreferenceConstants.P_BOOLEAN,
+ "&An example of a boolean preference",
+ getFieldEditorParent()));
+
+ addField(new RadioGroupFieldEditor(
+ PreferenceConstants.P_CHOICE,
+ "An example of a multiple-choice preference",
+ 1,
+ new String[][] { { "&Choice 1", "choice1" }, {
+ "C&hoice 2", "choice2" }
+ }, getFieldEditorParent()));
+ addField(
+ new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent()));
+ */
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacTemplatePage.java b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacTemplatePage.java
new file mode 100644
index 0000000..382a089
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/preferences/LisaacTemplatePage.java
@@ -0,0 +1,25 @@
+package org.lisaac.ldt.preferences;
+
+
+import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
+import org.lisaac.ldt.LisaacPlugin;
+
+
+public class LisaacTemplatePage extends TemplatePreferencePage {
+ public LisaacTemplatePage() {
+ setPreferenceStore(LisaacPlugin.getDefault().getPreferenceStore());
+ setTemplateStore(LisaacPlugin.getDefault().getTemplateStore());
+ setContextTypeRegistry(LisaacPlugin.getDefault().getContextTypeRegistry());
+ }
+
+ protected boolean isShowFormatterSetting() {
+ return true;
+ }
+
+ public boolean performOk() {
+ boolean ok = super.performOk();
+
+ LisaacPlugin.getDefault().savePluginPreferences();
+ return ok;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/preferences/PreferenceConstants.java b/editor/eclipse/src/org/lisaac/ldt/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..0756575
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/preferences/PreferenceConstants.java
@@ -0,0 +1,16 @@
+package org.lisaac.ldt.preferences;
+
+/**
+ * Constant definitions for plug-in preferences
+ */
+public class PreferenceConstants {
+
+ public static final String P_LISAAC_PATH = "lisaac_path";
+ public static final String P_LISAAC_USER = "lisaac_user";
+
+ public static final String P_LISAAC_INDENT = "lisaac_indent";
+ public static final String P_LISAAC_HOVER = "lisaac_hover";
+ public static final String P_LISAAC_FOLD = "lisaac_fold";
+ public static final String P_LISAAC_COMPLETION = "lisaac_competion";
+ public static final String P_LISAAC_COMPLETION_DELAY = "lisaac_competion_delay";
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/preferences/PreferenceInitializer.java b/editor/eclipse/src/org/lisaac/ldt/preferences/PreferenceInitializer.java
new file mode 100644
index 0000000..7bca019
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/preferences/PreferenceInitializer.java
@@ -0,0 +1,77 @@
+package org.lisaac.ldt.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.StringConverter;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.ILisaacColor;
+
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = LisaacPlugin.getDefault().getPreferenceStore();
+ //store.setDefault(PreferenceConstants.P_LISAAC_PATH, "TODO");
+
+ store.setDefault(PreferenceConstants.P_LISAAC_INDENT, true);
+ store.setDefault(PreferenceConstants.P_LISAAC_HOVER, true);
+ store.setDefault(PreferenceConstants.P_LISAAC_FOLD, true);
+ store.setDefault(PreferenceConstants.P_LISAAC_COMPLETION, true);
+ store.setDefault(PreferenceConstants.P_LISAAC_COMPLETION_DELAY, 200);
+
+ // Colors for syntax highlighting.
+ store.setDefault(
+ ILisaacColor.PREF_COMMENT,
+ StringConverter.asString(ILisaacColor.COMMENT));
+ store.setDefault(
+ ILisaacColor.PREF_PROTOTYPE,
+ StringConverter.asString(ILisaacColor.PROTOTYPE));
+ store.setDefault(
+ ILisaacColor.PREF_PROTOTYPE_STYLE,
+ StringConverter.asString(ILisaacColor.PROTOTYPE_STYLE));
+ store.setDefault(
+ ILisaacColor.PREF_KEYWORD,
+ StringConverter.asString(ILisaacColor.KEYWORD));
+ store.setDefault(
+ ILisaacColor.PREF_SLOT,
+ StringConverter.asString(ILisaacColor.UNDEFINED));
+ store.setDefault(
+ ILisaacColor.PREF_LOCAL_SLOT,
+ StringConverter.asString(ILisaacColor.DEFAULT));
+ store.setDefault(
+ ILisaacColor.PREF_CHARACTER,
+ StringConverter.asString(ILisaacColor.CHARACTER));
+ store.setDefault(
+ ILisaacColor.PREF_STRING,
+ StringConverter.asString(ILisaacColor.STRING));
+ store.setDefault(
+ ILisaacColor.PREF_NUMBER,
+ StringConverter.asString(ILisaacColor.NUMBER));
+ store.setDefault(
+ ILisaacColor.PREF_OPERATOR,
+ StringConverter.asString(ILisaacColor.OPERATOR));
+ store.setDefault(
+ ILisaacColor.PREF_EXTERNAL,
+ StringConverter.asString(ILisaacColor.EXTERNAL));
+
+ // styles
+ store.setDefault(ILisaacColor.STYLE_CHARACTER, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_KEYWORD, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_LOCAL_SLOT, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_NUMBER, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_OPERATOR, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_PROTOTYPE, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_PROTOTYPE_STYLE, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_SLOT, ILisaacColor.PREF_NORMAL);
+ store.setDefault(ILisaacColor.STYLE_STRING, ILisaacColor.PREF_NORMAL);
+ }
+}
+
diff --git a/editor/eclipse/src/org/lisaac/ldt/properties/LisaacProjectPropertyPage.java b/editor/eclipse/src/org/lisaac/ldt/properties/LisaacProjectPropertyPage.java
new file mode 100644
index 0000000..9d3219c
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/properties/LisaacProjectPropertyPage.java
@@ -0,0 +1,101 @@
+package org.lisaac.ldt.properties;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.lisaac.ldt.model.LisaacModel;
+
+public class LisaacProjectPropertyPage extends PropertyPage {
+
+ private List pathValueList;
+
+ /**
+ * Constructor for SamplePropertyPage.
+ */
+ public LisaacProjectPropertyPage() {
+ super();
+ }
+
+ private void addSection(Composite parent) {
+ Composite composite = createDefaultComposite(parent);
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Project Path");
+
+ pathValueList = new List(composite, SWT.SINGLE | SWT.BORDER);
+ GridData gd = new GridData();
+ pathValueList.setLayoutData(gd);
+
+ Button refreshPathButton = new Button(parent, SWT.PUSH);
+ refreshPathButton.setText("Refresh Lisaac Path");
+ refreshPathButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ refreshList();
+ }
+ });
+ refreshList();
+ }
+
+ /**
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+ GridData data = new GridData(GridData.FILL);
+ data.grabExcessHorizontalSpace = true;
+ composite.setLayoutData(data);
+
+ addSection(composite);
+ return composite;
+ }
+
+ private Composite createDefaultComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+
+ return composite;
+ }
+
+ public void refreshList() {
+ pathValueList.removeAll();
+
+ // Populate list
+ IProject project = (IProject) getElement();
+ LisaacModel model = LisaacModel.getModel(project);
+ if (model != null) {
+ model.getPathManager().refreshPath(project);
+
+ Iterator<String> it = model.getPathManager().getPathIterator();
+ while (it.hasNext()) {
+ pathValueList.add(it.next());
+ }
+ }
+ }
+
+ protected void performDefaults() {
+ }
+
+ public boolean performOk() {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/editor/eclipse/src/org/lisaac/ldt/refactor/ChangeHeaderRefactor.java b/editor/eclipse/src/org/lisaac/ldt/refactor/ChangeHeaderRefactor.java
new file mode 100644
index 0000000..dd7c1b3
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/refactor/ChangeHeaderRefactor.java
@@ -0,0 +1,94 @@
+package org.lisaac.ldt.refactor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.lisaac.ldt.model.AbstractLisaacParser;
+import org.lisaac.ldt.model.ILisaacFileVisitor;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.Prototype;
+
+public class ChangeHeaderRefactor extends Refactoring {
+
+ private String author, bibliography, copyright, license;
+
+ private LisaacModel model;
+
+
+ public ChangeHeaderRefactor(LisaacModel model) {
+ this.model = model;
+ }
+
+ public RefactoringStatus setLicense(String license) {
+ this.license = license;
+ return isValidLicense(license);
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public void setBibliography(String bibliography) {
+ this.bibliography = bibliography;
+ }
+
+ public void setCopyright(String copyright) {
+ this.copyright = copyright;
+ }
+
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ RefactoringStatus status = isValidLicense(license);
+ return status;
+ }
+
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ RefactoringStatus status = isValidLicense(license);
+ return status;
+ }
+
+ public Change createChange(final IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ final CompositeChange result = new CompositeChange(getName());
+
+ int work = model.getPathManager().getSize();
+ pm.beginTask("Updating headers...", work);
+
+ model.accept(new ILisaacFileVisitor() {
+ public void visit(Prototype prototype) {
+ if (prototype != null) {
+ Change change = prototype.refactorHeader(author, bibliography, copyright, license);
+ if (change != null) {
+ result.add(change);
+ }
+ }
+ pm.worked(1);
+ }
+ });
+ pm.done();
+ return result;
+ }
+
+ private RefactoringStatus isValidLicense(String source) {
+ RefactoringStatus status = new RefactoringStatus();
+ if (source != null) {
+ AbstractLisaacParser parser = new AbstractLisaacParser(source);
+ parser.readSpace();
+ int offset = parser.getOffset();
+
+ if (offset < source.length()) {
+ status.addFatalError("The license must be inside Lisaac comments");
+ }
+ }
+ return status;
+ }
+
+ public String getName() {
+ return "Change Project Headers...";
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/refactor/ChangeHeaderWizard.java b/editor/eclipse/src/org/lisaac/ldt/refactor/ChangeHeaderWizard.java
new file mode 100644
index 0000000..d8c2834
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/refactor/ChangeHeaderWizard.java
@@ -0,0 +1,128 @@
+package org.lisaac.ldt.refactor;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+class ChangeHeaderInputPage extends UserInputWizardPage {
+
+ private Text authorField;
+ private Text bibliographyField;
+ private Text copyrightField;
+ private Text licenseField;
+
+ public ChangeHeaderInputPage() {
+ super("ChangeHeaderInputPage");
+ }
+
+ public void createControl(Composite parent) {
+ Composite result= new Composite(parent, SWT.NONE);
+ setControl(result);
+
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ result.setLayout(layout);
+
+ Label label= new Label(result, SWT.NONE);
+ label.setText("&Author :");
+ authorField = createNameField(result);
+
+ label= new Label(result, SWT.NONE);
+ label.setText("&Bibliography :");
+ bibliographyField = createNameField(result);
+
+ label= new Label(result, SWT.NONE);
+ label.setText("&Copyright :");
+ copyrightField = createNameField(result);
+
+ Group group = new Group(result, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 100;
+ gd.verticalSpan = 2;
+ group.setLayoutData(gd);
+ group.setLayout(new GridLayout());
+ group.setText("&License :");
+
+ licenseField = new Text(group, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
+ licenseField.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ authorField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ handleInputChanged(authorField);
+ }
+ });
+ bibliographyField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ handleInputChanged(bibliographyField);
+ }
+ });
+ copyrightField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ handleInputChanged(copyrightField);
+ }
+ });
+ licenseField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ handleInputChanged(licenseField);
+ }
+ });
+ authorField.setFocus();
+ }
+
+ private Text createNameField(Composite result) {
+ Text field= new Text(result, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ field.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ return field;
+ }
+
+ void handleInputChanged(Text field) {
+ RefactoringStatus status= new RefactoringStatus();
+
+ ChangeHeaderRefactor refactoring = (ChangeHeaderRefactor) getRefactoring();
+ if (field == authorField) {
+ refactoring.setAuthor(field.getText());
+ } else if (field == bibliographyField) {
+ refactoring.setBibliography(field.getText());
+ } else if (field == copyrightField) {
+ refactoring.setCopyright(field.getText());
+ } else {
+ status.merge(refactoring.setLicense(field.getText()));
+ }
+ setPageComplete(!status.hasError());
+ int severity= status.getSeverity();
+ String message= status.getMessageMatchingSeverity(severity);
+ if (severity >= RefactoringStatus.INFO) {
+ setMessage(message, severity);
+ } else {
+ setMessage("", NONE); //$NON-NLS-1$
+ }
+ }
+}
+
+public class ChangeHeaderWizard extends RefactoringWizard {
+
+ ChangeHeaderInputPage page;
+
+ public ChangeHeaderWizard(Refactoring refactoring, String title) {
+ super(refactoring, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
+ setDefaultPageTitle(title);
+
+ page = new ChangeHeaderInputPage();
+ }
+
+ protected void addUserInputPages() {
+ addPage(page);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/refactor/RenamePrototypeRefactor.java b/editor/eclipse/src/org/lisaac/ldt/refactor/RenamePrototypeRefactor.java
new file mode 100644
index 0000000..0a2800c
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/refactor/RenamePrototypeRefactor.java
@@ -0,0 +1,109 @@
+package org.lisaac.ldt.refactor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.resource.RenameResourceChange;
+import org.lisaac.ldt.editors.LisaacScanner;
+import org.lisaac.ldt.model.ILisaacFileVisitor;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.Prototype;
+
+public class RenamePrototypeRefactor extends Refactoring {
+
+ private String oldName, newName;
+
+ private LisaacModel model;
+ private IPath prototypePath;
+
+ private boolean updateReferences;
+
+ public RenamePrototypeRefactor(String oldName, LisaacModel model) {
+ this.oldName = oldName;
+ this.model = model;
+ updateReferences = true;
+ }
+
+ public RefactoringStatus setNewPrototypeName(String newName) {
+ this.newName = newName;
+
+ return isValidPrototypeName(newName);
+ }
+
+ public void setUpdateReferences(boolean update) {
+ updateReferences = update;
+ }
+
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+
+ RefactoringStatus status = isValidPrototypeName(newName);
+ // ...
+ return status;
+ }
+
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ RefactoringStatus status = isValidPrototypeName(oldName);
+
+ Prototype prototype = model.getPrototype(oldName);
+ if (prototype != null) {
+ prototypePath = prototype.getWorkspacePath();
+ } else {
+ status.addFatalError("The prototype do not exist in project");
+ }
+ return status;
+ }
+
+ public Change createChange(final IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ final CompositeChange result = new CompositeChange(getName());
+
+ // 1. rename the prototype in section header
+ Prototype prototype = model.getPrototype(oldName);
+ result.add(prototype.refactorRenameSelf(newName));
+
+ // 2. rename occurences in the project program
+ if (updateReferences) {
+ int work = model.getPathManager().getSize();
+ pm.beginTask("Collecting occurences...", work);
+
+ model.accept(new ILisaacFileVisitor() {
+ public void visit(Prototype prototype) {
+ if (prototype != null) {
+ Change change = prototype.refactorRenamePrototype(oldName, newName);
+ if (change != null) {
+ result.add(change);
+ }
+ }
+ pm.worked(1);
+ }
+ });
+ }
+ // 3. rename the prototype file
+ result.add(new RenameResourceChange(prototypePath, newName.toLowerCase()+".li"));
+ pm.done();
+
+ return result;
+ }
+
+ private RefactoringStatus isValidPrototypeName(String name) {
+ RefactoringStatus status = new RefactoringStatus();
+
+ if (name.length() == 0) {
+ status.addError("Empty name");
+ } else if (! LisaacScanner.isPrototypeIdentifier(name)) {
+ status.addError("Invalid prototype name");
+ }
+ return status;
+ }
+
+ public String getName() {
+ return "Rename Prototype...";
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/refactor/RenamePrototypeWizard.java b/editor/eclipse/src/org/lisaac/ldt/refactor/RenamePrototypeWizard.java
new file mode 100644
index 0000000..fdb39be
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/refactor/RenamePrototypeWizard.java
@@ -0,0 +1,112 @@
+package org.lisaac.ldt.refactor;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+class RenamePrototypeInputPage extends UserInputWizardPage {
+
+ Text fNameField;
+
+ String prototypeToRename;
+
+ public RenamePrototypeInputPage(String prototypeToRename) {
+ super("RenamePrototypeInputPage");
+ this.prototypeToRename = prototypeToRename;
+ }
+
+ public void createControl(Composite parent) {
+ Composite result= new Composite(parent, SWT.NONE);
+ setControl(result);
+
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ result.setLayout(layout);
+
+ Label label= new Label(result, SWT.NONE);
+ label.setText("&New name:");
+
+ fNameField= createNameField(result);
+
+ final Button referenceButton= new Button(result, SWT.CHECK);
+ referenceButton.setText("&Update references");
+ GridData data= new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan= 2;
+ data.verticalIndent= 2;
+ referenceButton.setLayoutData(data);
+
+ fNameField.setText(prototypeToRename);
+
+ fNameField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ handleInputChanged();
+ }
+ });
+
+ referenceButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ RenamePrototypeRefactor refactoring = (RenamePrototypeRefactor) getRefactoring();
+ refactoring.setUpdateReferences(referenceButton.getSelection());
+ }
+ });
+
+ referenceButton.setSelection(true);
+
+ fNameField.setFocus();
+ fNameField.selectAll();
+ handleInputChanged();
+ }
+
+ private Text createNameField(Composite result) {
+ Text field= new Text(result, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ field.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ return field;
+ }
+
+ void handleInputChanged() {
+ RefactoringStatus status= new RefactoringStatus();
+
+ RenamePrototypeRefactor refactoring = (RenamePrototypeRefactor) getRefactoring();
+ status.merge(refactoring.setNewPrototypeName(fNameField.getText()));
+
+ setPageComplete(!status.hasError());
+ int severity= status.getSeverity();
+ String message= status.getMessageMatchingSeverity(severity);
+ if (severity >= RefactoringStatus.INFO) {
+ setMessage(message, severity);
+ } else {
+ setMessage("", NONE); //$NON-NLS-1$
+ }
+ }
+
+}
+
+public class RenamePrototypeWizard extends RefactoringWizard {
+
+ RenamePrototypeInputPage page;
+
+ public RenamePrototypeWizard(Refactoring refactoring, String prototypeToRename, String title) {
+ super(refactoring, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
+ setDefaultPageTitle(title);
+
+ page = new RenamePrototypeInputPage(prototypeToRename);
+ }
+
+ protected void addUserInputPages() {
+ addPage(page);
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/templates/LisaacContextType.java b/editor/eclipse/src/org/lisaac/ldt/templates/LisaacContextType.java
new file mode 100644
index 0000000..8619a7f
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/templates/LisaacContextType.java
@@ -0,0 +1,28 @@
+package org.lisaac.ldt.templates;
+
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateContextType;
+
+public class LisaacContextType extends TemplateContextType {
+ /** This context's id */
+ public static final String ID_CONTEXT_TYPE= "org.lisaac.ldt.contexttype"; //$NON-NLS-1$
+
+ /**
+ * Creates a new Lisaac context type.
+ */
+ public LisaacContextType() {
+ addGlobalResolvers();
+ }
+
+ private void addGlobalResolvers() {
+ addResolver(new GlobalTemplateVariables.Cursor());
+ addResolver(new GlobalTemplateVariables.WordSelection());
+ addResolver(new GlobalTemplateVariables.LineSelection());
+ addResolver(new GlobalTemplateVariables.Dollar());
+ addResolver(new GlobalTemplateVariables.Date());
+ addResolver(new GlobalTemplateVariables.Year());
+ addResolver(new GlobalTemplateVariables.Time());
+ addResolver(new GlobalTemplateVariables.User());
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/templates/LisaacTemplateProcessor.java b/editor/eclipse/src/org/lisaac/ldt/templates/LisaacTemplateProcessor.java
new file mode 100644
index 0000000..1321bc6
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/templates/LisaacTemplateProcessor.java
@@ -0,0 +1,48 @@
+package org.lisaac.ldt.templates;
+
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.LisaacPlugin;
+
+public class LisaacTemplateProcessor extends TemplateCompletionProcessor {
+
+
+ /**
+ * Simply return all templates.
+ *
+ * @param contextTypeId the context type, ignored in this implementation
+ * @return all templates
+ */
+ protected Template[] getTemplates(String contextTypeId) {
+ return LisaacPlugin.getDefault().getTemplateStore().getTemplates();
+ }
+
+ /**
+ * Return the XML context type that is supported by this plug-in.
+ *
+ * @param viewer the viewer, ignored in this implementation
+ * @param region the region, ignored in this implementation
+ * @return the supported XML context type
+ */
+ protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
+ return LisaacPlugin.getDefault().getContextTypeRegistry().getContextType(LisaacContextType.ID_CONTEXT_TYPE);
+ }
+
+ /**
+ * Always return the default image.
+ *
+ * @param template the template, ignored in this implementation
+ * @return the default template image
+ */
+ protected Image getImage(Template template) {
+ ImageDescriptor descr = LisaacPlugin.getImageDescriptor("icons/template.gif");
+ return descr.createImage();
+ }
+
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/views/ConsoleFactory.java b/editor/eclipse/src/org/lisaac/ldt/views/ConsoleFactory.java
new file mode 100644
index 0000000..974b4bc
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/views/ConsoleFactory.java
@@ -0,0 +1,54 @@
+package org.lisaac.ldt.views;
+
+import java.util.Arrays;
+
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleFactory;
+import org.eclipse.ui.console.IConsoleListener;
+import org.eclipse.ui.console.IConsoleManager;
+
+public class ConsoleFactory implements IConsoleFactory{
+
+ /** The console created by this factory if any. */
+ private static LisaacConsole openConsole = null;
+
+ public ConsoleFactory() {
+
+ ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(new IConsoleListener() {
+ public void consolesAdded(IConsole[] consoles) {
+ }
+ public void consolesRemoved(IConsole[] consoles) {
+ if (Arrays.asList(consoles).contains(openConsole)) {
+ openConsole = null;
+ }
+ }
+ });
+ }
+
+ /**
+ * Opens a new console.
+ */
+ public void openConsole() {
+ createConsole();
+ }
+
+ public static void createConsole() {
+ IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
+
+ if (openConsole == null) {
+ openConsole = new LisaacConsole();
+ openConsole.initializeDocument();
+
+ consoleManager.addConsoles(new IConsole[] {openConsole});
+ }
+ consoleManager.showConsoleView(openConsole);
+ }
+
+ public static LisaacConsole getConsole() {
+ if (openConsole == null) {
+ createConsole();
+ }
+ return openConsole;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/views/LisaacConsole.java b/editor/eclipse/src/org/lisaac/ldt/views/LisaacConsole.java
new file mode 100644
index 0000000..628bffb
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/views/LisaacConsole.java
@@ -0,0 +1,27 @@
+package org.lisaac.ldt.views;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.ui.console.IOConsole;
+import org.lisaac.ldt.LisaacMessages;
+
+public class LisaacConsole extends IOConsole {
+
+ public final static String CONSOLE_TYPE = "lisaacConsole"; //$NON-NLS-1$
+ public static final String CONSOLE_FONT= "org.eclipse.debug.ui.consoleFont"; //$NON-NLS-1$
+
+ public LisaacConsole() {
+ super(LisaacMessages.getString("LisaacConsole.1"), CONSOLE_TYPE, null, true); //$NON-NLS-1$
+
+ Font font = JFaceResources.getFont(CONSOLE_FONT);
+ setFont(font);
+ }
+
+ /**
+ * Set the document's initial contents.
+ * Called by ConsoleFactory.
+ */
+ void initializeDocument() {
+ getDocument().set(""); //$NON-NLS-1$
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/views/LisaacOutlineView.java b/editor/eclipse/src/org/lisaac/ldt/views/LisaacOutlineView.java
new file mode 100644
index 0000000..4b84f2d
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/views/LisaacOutlineView.java
@@ -0,0 +1,257 @@
+package org.lisaac.ldt.views;
+
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.editors.LisaacEditor;
+import org.lisaac.ldt.model.LisaacModel;
+import org.lisaac.ldt.model.items.Prototype;
+import org.lisaac.ldt.outline.OutlineContentProvider;
+import org.lisaac.ldt.outline.OutlineImages;
+import org.lisaac.ldt.outline.OutlineItem;
+import org.lisaac.ldt.outline.OutlineLabelProvider;
+
+public class LisaacOutlineView extends ContentOutlinePage implements IDocumentListener {
+
+ /** the delay before the outline view is updated. */
+ private static final long UPDATE_DELAY = 1500;
+
+ /** the document provider. */
+ private IDocumentProvider documentProvider;
+
+ /** the text editor. */
+ private AbstractDecoratedTextEditor textEditor;
+
+ /** the current document. */
+ private IDocument document;
+
+ /** the update timer which manages update task scheduling. */
+ private Timer updateTimer;
+
+
+ public LisaacOutlineView(IDocumentProvider documentProvider, AbstractDecoratedTextEditor textEditor) {
+ super();
+ this.documentProvider = documentProvider;
+ this.textEditor = textEditor;
+ createTimer();
+ }
+
+ /**
+ * @see ContentOutlinePage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ TreeViewer viewer = getTreeViewer();
+ viewer.setContentProvider(new OutlineContentProvider());
+ viewer.setLabelProvider(new OutlineLabelProvider());
+ viewer.addSelectionChangedListener(this);
+ createActions();
+
+ document = getDocument();
+ if (document != null) {
+ document.addDocumentListener(this);
+ }
+ update();
+ }
+
+ private void createActions() {
+
+ //---- Sort by name
+ Action sortByName = new Action("Sort by name", IAction.AS_CHECK_BOX) {
+
+ ViewerSorter sortByNameSorter;
+
+ public void setAlphaSort(boolean doSort) {
+ if (sortByNameSorter == null) {
+ sortByNameSorter = new ViewerSorter() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return ((Comparable) e1).compareTo(e2);
+ }
+ };
+ }
+ getTreeViewer().setSorter(doSort ? sortByNameSorter : null);
+ }
+
+ public void run() {
+ setAlphaSort(isChecked());
+ }
+ };
+ sortByName.run();
+
+ //---- Sort by name
+ Action sortBySection= new Action("Sort by Section", IAction.AS_CHECK_BOX) {
+ public void run() {
+ OutlineItem.showSections = isChecked();
+ getTreeViewer().refresh();
+ getTreeViewer().expandAll();
+ }
+ };
+ sortBySection.setChecked(true);
+
+ try {
+ sortByName.setImageDescriptor(LisaacPlugin.getImageDescriptor(OutlineImages.SORT_ALPHA));
+ sortBySection.setImageDescriptor(LisaacPlugin.getImageDescriptor(OutlineImages.SORT_SECTION));
+ } catch (Exception e) {
+ }
+
+ // Add actions to the toolbar
+ IActionBars actionBars = getSite().getActionBars();
+ IToolBarManager toolbarManager = actionBars.getToolBarManager();
+ toolbarManager.add(sortByName);
+ toolbarManager.add(sortBySection);
+ }
+
+ /**
+ * Returns the document attached to this view.
+ * @return the document attached to this view
+ */
+ public IDocument getDocument() {
+ if (document == null) {
+ document = documentProvider.getDocument(textEditor.getEditorInput());
+ }
+ return document;
+ }
+
+ /**
+ * Fired when Outline selection changed
+ * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection abstractSelection = event.getSelection();
+ IDocument document = getDocument();
+
+ if (document != null) {
+ if ((abstractSelection != null) && (abstractSelection instanceof TreeSelection)) {
+ TreeSelection selection = (TreeSelection) abstractSelection;
+ Object selectedElement = selection.getFirstElement();
+
+ if ((selectedElement != null) && (selectedElement instanceof OutlineItem)) {
+ OutlineItem item = (OutlineItem) selectedElement;
+ // select current outline item in editor
+ textEditor.selectAndReveal(item.startOffset(), item.length());
+ }
+ }
+ }
+ }
+
+ /**
+ * Sends the input to the tree viewer.
+ * @param input the input
+ */
+ public void setInput(Object input) {
+ if (!getTreeViewer().getControl().isDisposed()) {
+ getTreeViewer().setInput(input);
+ getTreeViewer().expandAll();
+ }
+ }
+
+ public void documentAboutToBeChanged(DocumentEvent event) {
+ }
+ /**
+ * Notify document modifications.
+ */
+ public void documentChanged(DocumentEvent event) {
+ document = event.getDocument();
+ update();
+ }
+
+ /**
+ * Get the outline data.
+ *
+ * @param project Current project
+ * @param filename File to outline
+ * @return List of outline items
+ * @throws CoreException
+ */
+ public List<OutlineItem> getSourceOutline(IProject project, String filename) throws CoreException {
+ LisaacModel model = LisaacModel.getModel(project);
+ if (model != null) {
+ Prototype prototype = model.getPrototype(LisaacModel.extractPrototypeName(filename));
+
+ if (prototype != null) {
+ return prototype.getOutlineItems();
+ }
+ }
+ return null;
+ }
+
+ private void createTimer() {
+ updateTimer = new Timer("org.lisaac.ldt.outlinetimer");
+ }
+
+ /**
+ * Updates the outline content view.
+ */
+ public void update() {
+ updateTimer.cancel();
+ updateTimer.purge();
+ createTimer();
+
+ OutlineUpdateTask updateTask = new OutlineUpdateTask();
+ updateTimer.schedule(updateTask, UPDATE_DELAY);
+ }
+
+ /**
+ * This class is in charge of updating the outline.
+ */
+ class OutlineUpdateTask extends TimerTask {
+ public OutlineUpdateTask() {
+ super();
+ }
+
+ /**
+ * Updates the outline content view.
+ * @see TimerTask#run()
+ */
+ public void run() {
+ final IDocument document = getDocument();
+ Display display = PlatformUI.getWorkbench().getDisplay();
+
+ if (document != null && (textEditor instanceof LisaacEditor)) {
+ IProject project = ((LisaacEditor) textEditor).getProject();
+ String filename = ((LisaacEditor) textEditor).getFileName();
+
+ try {
+ final List<OutlineItem> items = getSourceOutline(project, filename);
+
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (items != null) {
+ setInput(items.toArray(new OutlineItem[items.size()]));
+ //
+ ((LisaacEditor) textEditor).refreshPresentation();
+ //
+ }
+ }
+ });
+ } catch (CoreException e) {
+ }
+ }
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/wizards/AbstractNewFileWizard.java b/editor/eclipse/src/org/lisaac/ldt/wizards/AbstractNewFileWizard.java
new file mode 100644
index 0000000..e371f07
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/wizards/AbstractNewFileWizard.java
@@ -0,0 +1,155 @@
+package org.lisaac.ldt.wizards;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+public abstract class AbstractNewFileWizard extends Wizard implements INewWizard {
+
+ private AbstractNewFileWizardPage page;
+
+ private IStructuredSelection selection;
+
+
+ public AbstractNewFileWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ abstract protected AbstractNewFileWizardPage createPage();
+
+ /**
+ * Adding the page to the wizard.
+ */
+ public void addPages() {
+ page = createPage();
+ addPage(page);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in the wizard. We
+ * will create an operation and run it using wizard as execution context.
+ */
+ public boolean performFinish() {
+ final String containerName = page.getContainerName();
+ final String fileName = getFileNameWithExtension();
+ final InputStream stream = page.getInitialContents(fileName);
+
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException {
+ try {
+ doFinish(containerName, fileName, stream, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(),
+ "Wizard error", realException.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * The worker method. It will find the container, create the file if missing
+ * or just replace its contents, and open the editor on the newly created
+ * file.
+ */
+ private void doFinish(String containerName, String fileName, InputStream stream,
+ IProgressMonitor monitor) throws CoreException {
+ // create a sample file
+ monitor.beginTask("Creating File " + fileName, 2);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = root.findMember(new Path(containerName));
+ if (!resource.exists() || !(resource instanceof IContainer)) {
+ throwCoreException("Container does not exist.");
+ }
+ IContainer container = (IContainer) resource;
+ final IFile file = container.getFile(new Path(fileName));
+
+ try {
+ if (file.exists()) {
+ file.setContents(stream, true, true, monitor);
+ } else {
+ file.create(stream, true, monitor);
+ }
+ stream.close();
+ } catch (IOException e) {
+ }
+ monitor.worked(1);
+ monitor.setTaskName("Opening file...");
+
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, file, true);
+ } catch (PartInitException e) {
+ }
+ }
+ });
+ monitor.worked(1);
+ }
+
+ public String getFileNameWithExtension() {
+ String filename = page.getFileName();
+ int index = filename.lastIndexOf('.');
+ if (index == -1) {
+ filename += page.getFileExtension();
+ }
+ return filename;
+ }
+
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR,
+ "org.lisaac.ldt.wizards", IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if we can initialize
+ * from it.
+ *
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ protected IStructuredSelection getSelection() {
+ return selection;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/wizards/AbstractNewFileWizardPage.java b/editor/eclipse/src/org/lisaac/ldt/wizards/AbstractNewFileWizardPage.java
new file mode 100644
index 0000000..a53312e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/wizards/AbstractNewFileWizardPage.java
@@ -0,0 +1,259 @@
+package org.lisaac.ldt.wizards;
+
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.lisaac.ldt.LisaacMessages;
+
+
+public abstract class AbstractNewFileWizardPage extends WizardPage {
+
+ /** initial source folder selection */
+ private IStructuredSelection selection;
+
+ /** source folder path */
+ private Text containerText;
+
+ /** file name */
+ private Text fileText;
+
+ /** file extension */
+ private String fileExtension = ""; //$NON-NLS-1$
+
+
+ protected AbstractNewFileWizardPage(String pageName, IStructuredSelection selection) {
+ super(pageName);
+ this.selection = selection;
+ setPageComplete(false);
+ }
+
+ public String getContainerName() {
+ return containerText.getText();
+ }
+
+ public String getFileName() {
+ return fileText.getText();
+ }
+
+ public String getFileExtension() {
+ return fileExtension;
+ }
+
+ /**
+ * set the extension of files created with this wizard.
+ */
+ protected void setFileExtension(String ext) {
+ fileExtension = ext;
+ }
+
+ /**
+ * Content File Initialisation.
+ */
+ abstract protected InputStream getInitialContents(String filename);
+
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ container.setLayout(layout);
+
+ Label label = new Label(container, SWT.NULL);
+ label.setText(LisaacMessages.getString("AbstractNewFileWizardPage_1"));
+
+ containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ containerText.setLayoutData(gd);
+ containerText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+ Button button = new Button(container, SWT.PUSH);
+ button.setText(LisaacMessages.getString("AbstractNewFileWizardPage_2"));
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse();
+ }
+ });
+
+ label = new Label(container, SWT.NULL);
+ label.setText(LisaacMessages.getString("AbstractNewFileWizardPage_3"));
+
+ fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ fileText.setLayoutData(gd);
+ fileText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+
+ label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ label.setLayoutData(gd);
+
+ //
+ createAdvancedControls(container);
+ //
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ protected void createAdvancedControls(Composite parent) {
+ // should be override
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+ private void initialize() {
+ if (selection != null && selection.isEmpty() == false
+ && selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() > 1)
+ return;
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof IResource) {
+ IContainer container;
+ if (obj instanceof IContainer)
+ container = (IContainer) obj;
+ else
+ container = ((IResource) obj).getParent();
+ containerText.setText(container.getFullPath().toString());
+ fileText.setFocus();
+ }
+ }
+ fileText.setText(getInitialFileName());
+ }
+
+ protected abstract String getInitialFileName();
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+
+ private void handleBrowse() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ LisaacMessages.getString("AbstractNewFileWizardPage_4"));
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length == 1) {
+ Object result = results[0];
+ if (result instanceof IPath) {
+ IPath ipath = (IPath) result;
+ containerText.setText(ipath.toString());
+ }
+ }
+ }
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+ private void dialogChanged() {
+ String container = getContainerName();
+ String fileName = getFileName();
+
+ if (container.length() == 0) {
+ updateStatus(LisaacMessages.getString("AbstractNewFileWizardPage_5"));
+ return;
+ }
+ if (fileName.length() == 0) {
+ updateStatus(LisaacMessages.getString("AbstractNewFileWizardPage_6"));
+ return;
+ }
+ // TODO check container -> source folder !
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ /**
+ * @see WizardPage#isPageComplete()
+ */
+ public boolean isPageComplete() {
+ return !checkFolderForExistingFile() && super.isPageComplete();
+ }
+
+ /**
+ * Finds the current directory where the file should be created
+ */
+ protected boolean checkFolderForExistingFile() {
+ IContainer container = getFileContainer();
+ if (container != null) {
+ IResource file = container.getFile(new Path(fileText.getText()
+ .trim()));
+ if (file != null && file.exists()) {
+ this.setErrorMessage(LisaacMessages.getString("AbstractNewFileWizardPage_7"));
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private IContainer getFileContainer() {
+ if (containerText.getText() != null) {
+ IPath containerPath = new Path(containerText.getText().trim());
+ IContainer container = null;
+ if (containerPath.segmentCount() > 1) {
+ container = ResourcesPlugin.getWorkspace().getRoot().getFolder(
+ containerPath);
+ } else {
+ if (containerPath.segmentCount() == 1) {
+ // this is a project
+ container = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(containerText.getText().trim());
+ }
+ }
+ if (container != null && container.exists()) {
+ return container;
+ }
+ }
+ return null;
+ }
+
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ String fileName = fileText.getText().trim();
+ if (getFileContainer() != null
+ && fileName.equalsIgnoreCase(getInitialFileName())) {
+ fileText.setFocus();
+ fileText.setText(fileName);
+ fileText.setSelection(0, fileName.length()
+ - (new Path(getInitialFileName())).getFileExtension()
+ .length() - 1);
+ }
+ }
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/wizards/InputParentDialog.java b/editor/eclipse/src/org/lisaac/ldt/wizards/InputParentDialog.java
new file mode 100644
index 0000000..66afe2a
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/wizards/InputParentDialog.java
@@ -0,0 +1,72 @@
+package org.lisaac.ldt.wizards;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.lisaac.ldt.model.ILisaacModel;
+
+public class InputParentDialog extends InputDialog {
+
+ private String parentType;
+
+ public InputParentDialog(Shell parentShell, String dialogTitle) {
+ super(parentShell, dialogTitle, "Parent prototype name", "", new IInputValidator() {
+ public String isValid(String newText) {
+ if (newText.length() == 0) {
+ return "Empty name";
+ }
+ String correct = newText.toUpperCase();
+ if (newText.compareTo(correct) != 0) {
+ return "Invalid prototype name";
+ }
+ return null;
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc) Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite c = (Composite) super.createDialogArea(parent);
+
+ Label label = new Label(c, SWT.NONE);
+ label.setText("Choose Parent inheritance type");
+
+ String[] values = {
+ ILisaacModel.inherit_shared,
+ ILisaacModel.inherit_nonshared,
+ ILisaacModel.inherit_shared_expanded,
+ ILisaacModel.inherit_nonshared_expanded
+ };
+ parentType = values[0];
+
+ final Combo combo = new Combo(c, SWT.NONE);
+ combo.setItems(values);
+ combo.select(0);
+ combo.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ parentType = combo.getText();
+ }
+ });
+ return c;
+ }
+
+ public String getParentName() {
+ return getValue();
+ }
+
+ public String getParentType() {
+ return parentType;
+ }
+}
diff --git a/editor/eclipse/src/org/lisaac/ldt/wizards/NewProjectWizard.java b/editor/eclipse/src/org/lisaac/ldt/wizards/NewProjectWizard.java
new file mode 100644
index 0000000..ce37a5e
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/wizards/NewProjectWizard.java
@@ -0,0 +1,284 @@
+package org.lisaac.ldt.wizards;
+
+import java.awt.GridLayout;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.builder.LisaacNature;
+import org.lisaac.ldt.editors.LisaacResourceDecorator;
+import org.lisaac.ldt.model.LisaacModel;
+
+
+public class NewProjectWizard extends Wizard implements INewWizard {
+
+ NewProjectWizardPage mainPage;
+
+ public NewProjectWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ // called with the 'finish' button
+ public boolean performFinish() {
+ final String name;
+ final IPath path;
+ final boolean genereSrc;
+ IRunnableWithProgress op = null;
+ try {
+ name = mainPage.getProjectName();
+ path = mainPage.getLocationPath();
+ genereSrc = mainPage.generateSrc();
+
+ op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ doFinish(name, path, genereSrc, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ } catch (NullPointerException e1) {
+ e1.printStackTrace();
+ }
+
+ try {
+ getContainer().run(false, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error !", realException.getMessage()); //$NON-NLS-1$
+ return false;
+ }
+ return true;
+ }
+
+ private void doFinish(String projectName, IPath nomRep, boolean genereSrc, IProgressMonitor monitor)
+ throws CoreException
+ {
+ monitor.beginTask("Project Creation " + projectName, 4); //$NON-NLS-1$
+
+ // get project root
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+ try {
+ IProject project = root.getProject(projectName);
+ if (project.exists() && !project.isOpen()) {
+ project.open(monitor);
+ } else {
+ project.create(monitor);
+ project.open(monitor);
+ }
+ try {
+
+ // set lisaac builder
+ LisaacNature nature = new LisaacNature();
+ nature.setProject(project);
+ nature.configure();
+
+ // set lisaac nature
+ IProjectDescription description = project.getDescription();
+ description.setNatureIds(new String[]{LisaacNature.NATURE_ID});
+ project.setDescription(description, monitor);
+
+ } catch (CoreException e) {
+ // Something went wrong
+ }
+ monitor.worked(1);
+
+ //
+ new LisaacModel(project);
+ //
+
+ monitor.worked(1);
+
+ // create make file for project
+ IFile lipFile = project.getFile("make.lip"); //$NON-NLS-1$
+ if (! lipFile.exists()) {
+ lipFile.create(new ByteArrayInputStream(getLipStream(project, genereSrc)), false, monitor);
+ }
+
+ // create default folder & files in project
+ if (genereSrc) {
+ IFolder src = project.getFolder("src"); //$NON-NLS-1$
+ if (! src.exists()) {
+ src.create(false, true, monitor);
+ src.setPersistentProperty(
+ new QualifiedName("", LisaacResourceDecorator.SOURCE_FOLDER_PROPERTY),
+ "true");
+ }
+ monitor.worked(1);
+ IFile mainPrototype = src.getFile(projectName.toLowerCase()+".li"); //$NON-NLS-1$
+ if (! mainPrototype.exists()) {
+ mainPrototype.create(new ByteArrayInputStream(getMainPrototypeStream(projectName)), false, monitor);
+ }
+ }
+ IFolder bin = project.getFolder("bin"); //$NON-NLS-1$
+ if (! bin.exists()) {
+ bin.create(false,true,monitor);
+ }
+ monitor.worked(1);
+ IFolder lib = project.getFolder("lib"); //$NON-NLS-1$
+ if (! lib.exists()) {
+ // create link to lib
+ /*IPath location = new Path(lisaacPath+"/lib");// FIXME path delimiter
+ lib.createLink(location, IResource.NONE, monitor);*/
+ lib.create(false,true,monitor);
+ lib.setPersistentProperty(
+ new QualifiedName("", LisaacResourceDecorator.LIB_PROPERTY),
+ "true");
+ }
+ } catch (IOException e) {
+ MessageDialog.openError(getShell(), "Project creation Error !", e.getMessage()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ MessageDialog.openError(getShell(), "Project settings Error !", e.getMessage()); //$NON-NLS-1$
+ }
+ monitor.done();
+ }
+
+
+ public byte[] getMainPrototypeStream(String projectName) throws IOException {
+ String contents = "\nSection Header\n\n"; //$NON-NLS-1$
+ contents += " + name := "+projectName.toUpperCase()+";\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ contents += " - comment := \"Main Prototype\";\n"; //$NON-NLS-1$
+ contents += "\nSection Inherit\n\n"; //$NON-NLS-1$
+ contents += " - parent_object:OBJECT := OBJECT;\n"; //$NON-NLS-1$
+ contents += "\nSection Public\n\n"; //$NON-NLS-1$
+ contents += " - main <- \n"; //$NON-NLS-1$
+ contents += " // Main entry point.\n"; //$NON-NLS-1$
+ contents += " (\n\n"; //$NON-NLS-1$
+ contents += " \n"; //$NON-NLS-1$
+ contents += " );\n"; //$NON-NLS-1$
+ return contents.getBytes();
+ }
+
+ public byte[] getLipStream(IProject project, boolean genereSrc) throws IOException {
+ String contents = "//\n// `"+project.getName()+"` LIsaac Project file\n//"; //$NON-NLS-1$ //$NON-NLS-2$
+ contents += "\nSection Inherit\n\n"; //$NON-NLS-1$
+ contents += " + parent:STRING;\n"; //$NON-NLS-1$
+ contents += "\nSection Private\n\n"; //$NON-NLS-1$
+ contents += " + project_root:STRING := \""+project.getLocationURI().getPath()+"/\";\n\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ contents += " - project_src_path <- \n"; //$NON-NLS-1$
+ contents += " // Define the project path for source code.\n"; //$NON-NLS-1$
+ contents += " (\n"; //$NON-NLS-1$
+ if (genereSrc) {
+ contents += " path (project_root + \"src/\");\n"; //$NON-NLS-1$
+ } else {
+ contents += " path project_root;\n"; //$NON-NLS-1$
+ }
+ contents += " );\n\n"; //$NON-NLS-1$
+ contents += " - front_end <- \n"; //$NON-NLS-1$
+ contents += " // Executed by compiler, before compilation step.\n"; //$NON-NLS-1$
+ contents += " (\n"; //$NON-NLS-1$
+ contents += " project_src_path;\n"; //$NON-NLS-1$
+ contents += " general_front_end;\n"; //$NON-NLS-1$
+ contents += " );\n"; //$NON-NLS-1$
+ contents += "\nSection Public\n\n"; //$NON-NLS-1$
+ contents += " - run_mode m:STRING <- \n"; //$NON-NLS-1$
+ contents += " // Select Run Mode.\n"; //$NON-NLS-1$
+ contents += " (\n"; //$NON-NLS-1$
+ contents += " (m = \"run\").if {\n"; //$NON-NLS-1$
+ contents += " no_debug;\n"; //$NON-NLS-1$
+ contents += " } else {\n"; //$NON-NLS-1$
+ contents += " debug 15; // default level [1-20]\n"; //$NON-NLS-1$
+ contents += " };\n"; //$NON-NLS-1$
+ contents += " );\n\n"; //$NON-NLS-1$
+ contents += " - clean <- \n"; //$NON-NLS-1$
+ contents += " // Clean project.\n"; //$NON-NLS-1$
+ contents += " (\n"; //$NON-NLS-1$
+ contents += " );\n"; //$NON-NLS-1$
+ return contents.getBytes();
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setWindowTitle(LisaacMessages.getString("NewProjectWizard_46"));
+ setNeedsProgressMonitor(true);
+ mainPage = new NewProjectWizardPage(LisaacMessages.getString("NewProjectWizard_47"));
+ }
+
+ public void addPages() {
+ super.addPages();
+ addPage(mainPage);
+ }
+}
+
+class NewProjectWizardPage extends WizardNewProjectCreationPage {
+
+ Button genereSrc;
+
+ NewProjectWizardPage(String pageName) {
+ super(pageName);
+ setTitle(pageName);
+ setDescription(LisaacMessages.getString("NewProjectWizard_48"));
+ }
+
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ Composite composite = (Composite) getControl();
+
+ genereSrc = new Button(composite, SWT.CHECK);
+ genereSrc.setText("Generate src files");
+ genereSrc.setSelection(true);
+ }
+
+ public boolean generateSrc() {
+ if (! genereSrc.isDisposed()) {
+ return genereSrc.getSelection();
+ }
+ return true;
+ }
+}
+/*
+class LicenseWizardPage extends WizardPage {
+
+ private Text licenseText;
+
+ LicenseWizardPage(String pageName) {
+ super(pageName);
+ setTitle(pageName);
+ setDescription("Specify the project license");
+ }
+
+ public String getLicense() {
+ return licenseText.getText();
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ licenseText = new Text(composite, SWT.MULTI);
+ licenseText.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ setControl(composite);
+ }
+}*/
diff --git a/editor/eclipse/src/org/lisaac/ldt/wizards/NewPrototypeWizard.java b/editor/eclipse/src/org/lisaac/ldt/wizards/NewPrototypeWizard.java
new file mode 100644
index 0000000..5b3291c
--- /dev/null
+++ b/editor/eclipse/src/org/lisaac/ldt/wizards/NewPrototypeWizard.java
@@ -0,0 +1,288 @@
+package org.lisaac.ldt.wizards;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.lisaac.ldt.LisaacMessages;
+import org.lisaac.ldt.LisaacPlugin;
+import org.lisaac.ldt.actions.GenerateConstructor;
+import org.lisaac.ldt.model.ILisaacModel;
+import org.lisaac.ldt.preferences.PreferenceConstants;
+import org.eclipse.jface.dialogs.InputDialog;
+
+import java.io.*;
+
+/**
+ * Lisaac source file creator.
+ */
+public class NewPrototypeWizard extends AbstractNewFileWizard {
+
+ public NewPrototypeWizard() {
+ super();
+ setWindowTitle(LisaacMessages.getString("NewPrototypeWizard_0"));
+ }
+
+ /**
+ * Create wizard page
+ */
+ protected AbstractNewFileWizardPage createPage() {
+ return new NewPrototypeWizardPage(getSelection());
+ }
+}
+
+/**
+ * Represent the main page in "new lisaac prototype" wizard.
+ */
+class NewPrototypeWizardPage extends AbstractNewFileWizardPage {
+ final private String INITIAL_PROTOTYPE_NAME = "prototype.li"; //$NON-NLS-1$
+
+ protected Text commentField;
+
+ protected Button styleNone;
+ protected Button styleExpanded;
+ protected Button styleStrict;
+
+ protected Table tableInherit;
+
+ protected Button generateConstructor, generateMain;
+
+
+ protected NewPrototypeWizardPage(IStructuredSelection selection) {
+ super(NewPrototypeWizardPage.class.getName(), selection);
+
+ setTitle(LisaacMessages.getString("NewPrototypeWizard_2"));
+ setDescription(LisaacMessages.getString("NewPrototypeWizard_3"));
+ setFileExtension(".li"); //$NON-NLS-1$
+
+ }
+
+ public String getPrototypeDescription() {
+ return commentField.getText();
+ }
+
+ /**
+ * Return the initial content of new file.
+ */
+ protected InputStream getInitialContents(String filename) {
+ try {
+ int index = filename.lastIndexOf('.');
+ if (index != -1) {
+ filename = filename.substring(0, index);
+ }
+ return new ByteArrayInputStream(getPrototypeStream(filename));
+ } catch (IOException e) {
+ return null; // ignore and create empty comments
+ }
+ }
+
+ public byte[] getPrototypeStream(String filename) throws IOException {
+ boolean isExpanded = styleExpanded.getSelection();
+ boolean isStrict = styleExpanded.getSelection();
+
+ /* //IProject project = (IProject) ();
+ try {
+ String license = project.getPersistentProperty(new QualifiedName("",LICENSE_PROPERTY));
+ licenseText.setText(license);
+ } catch (CoreException e) {
+ }*/
+
+ String contents = "\nSection Header\n\n"; //$NON-NLS-1$
+ contents += " + name := "; //$NON-NLS-1$
+ if (isExpanded) {
+ contents += "Expanded "; //$NON-NLS-1$
+ } else if (isStrict) {
+ contents += "Strict "; //$NON-NLS-1$
+ }
+ contents += filename.toUpperCase()+";\n"; //$NON-NLS-1$
+
+ String descr = getPrototypeDescription();
+ if (descr != null && descr.length() > 0) {
+ contents += " - comment := \""+descr+"\";\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ String username = LisaacPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_LISAAC_USER);
+ if (username != null && username.length() > 0) {
+ contents += "\n - author := \""+username+"\";\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (! isExpanded) {
+ contents += "\nSection Inherit\n\n"; //$NON-NLS-1$
+ } else {
+ contents += "\nSection Insert\n\n"; //$NON-NLS-1$
+ }
+ int n = tableInherit.getItemCount();
+ if (n > 0) {
+ for (int i=0; i<n; i++) {
+ TableItem item = tableInherit.getItem(i);
+ String type = item.getText(1);
+ if (type.equals(ILisaacModel.inherit_shared) ||
+ type.equals(ILisaacModel.inherit_shared_expanded)) {
+ contents += " - "; //$NON-NLS-1$
+ } else {
+ contents += " + "; //$NON-NLS-1$
+ }
+ contents += "parent_"; //$NON-NLS-1$
+ contents += item.getText(0).toLowerCase() + ":"; //$NON-NLS-1$
+ if (type.equals(ILisaacModel.inherit_shared_expanded) ||
+ type.equals(ILisaacModel.inherit_nonshared_expanded)) {
+ contents += "Expanded " + item.getText(0); //$NON-NLS-1$
+ } else {
+ contents += item.getText(0) + " := " + item.getText(0); //$NON-NLS-1$
+ }
+ contents += ";\n"; //$NON-NLS-1$
+ }
+ } else {
+ contents += " - parent_object:OBJECT := OBJECT;\n"; //$NON-NLS-1$
+ }
+ contents += "\nSection Public\n\n"; //$NON-NLS-1$
+
+ if (generateConstructor.getSelection()) {
+ contents += GenerateConstructor.getConstructor();
+ }
+ if (generateMain.getSelection()) {
+ contents += " - main <- \n"; //$NON-NLS-1$
+ contents += " // Main entry point.\n"; //$NON-NLS-1$
+ contents += " (\n\n"; //$NON-NLS-1$
+ contents += " \n"; //$NON-NLS-1$
+ contents += " );\n"; //$NON-NLS-1$
+ }
+ return contents.getBytes();
+ }
+
+ /**
+ * Additional wizard information
+ */
+ public void createAdvancedControls(Composite parent) {
+
+ // -- Style --
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(LisaacMessages.getString("NewPrototypeWizard_25"));
+ label.setFont(parent.getFont());
+
+ Composite radioGroup = new Composite(parent, SWT.NONE);
+ radioGroup.setLayout(new RowLayout());
+ styleNone = new Button(radioGroup, SWT.RADIO);
+ styleNone.setFont(parent.getFont());
+ styleNone.setSelection(true);
+ styleNone.setText(LisaacMessages.getString("NewPrototypeWizard_26"));
+ styleExpanded = new Button(radioGroup, SWT.RADIO);
+ styleExpanded.setFont(parent.getFont());
+ styleExpanded.setText(LisaacMessages.getString("NewPrototypeWizard_27"));
+ styleStrict = new Button(radioGroup, SWT.RADIO);
+ styleStrict.setFont(parent.getFont());
+ styleStrict.setText(LisaacMessages.getString("NewPrototypeWizard_28"));
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ radioGroup.setLayoutData(gridData);
+ //
+
+ // -- Description --
+ label = new Label(parent, SWT.NONE);
+ label.setText(LisaacMessages.getString("NewPrototypeWizard_29"));
+ label.setFont(parent.getFont());
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 1;
+ label.setLayoutData(gridData);
+
+ commentField = new Text(parent, SWT.BORDER);
+ commentField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ commentField.setLayoutData(gridData);
+ //
+
+ // -- inherits --
+ label = new Label(parent, SWT.NONE);
+ label.setText(LisaacMessages.getString("NewPrototypeWizard_30"));
+ label.setFont(parent.getFont());
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 1;
+ label.setLayoutData(gridData);
+
+ Composite tableGroup = new Composite(parent, SWT.NONE);
+ tableGroup.setLayout(new RowLayout());
+
+ final Table table = new Table(tableGroup, SWT.BORDER | SWT.SINGLE |
+ SWT.H_SCROLL | SWT.FULL_SELECTION);
+ final TableColumn c1 = new TableColumn(table, SWT.LEFT);
+ c1.setText("Prototype"); //$NON-NLS-1$
+ c1.setWidth(150);
+ final TableColumn c2 = new TableColumn(table, SWT.LEFT);
+ c2.setText(LisaacMessages.getString("NewPrototypeWizard_32"));
+ c2.setWidth(100);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ final TableItem itemDefault = new TableItem(table, SWT.NONE);
+ itemDefault.setText(new String[] {"OBJECT", ILisaacModel.inherit_shared}); //$NON-NLS-1$
+
+ Composite buttonGroup = new Composite(tableGroup, SWT.NONE);
+ buttonGroup.setLayout(new GridLayout());
+ Button tableAdd = new Button(buttonGroup, SWT.PUSH);
+ tableAdd.setFont(parent.getFont());
+ tableAdd.setText(LisaacMessages.getString("NewPrototypeWizard_34"));
+ tableAdd.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ InputParentDialog input = new InputParentDialog(getShell(), "New Parent...");
+ if (input.open() == InputDialog.OK) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {input.getParentName(), input.getParentType()});
+ }
+ }
+ });
+ Button tableRemove= new Button(buttonGroup, SWT.PUSH);
+ tableRemove.setFont(parent.getFont());
+ tableRemove.setText(LisaacMessages.getString("NewPrototypeWizard_35"));
+ tableRemove.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int[] indices = table.getSelectionIndices();
+ if (indices != null && indices.length > 0) {
+ int index = indices[0];
+ table.remove(index);
+ }
+ }
+ });
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ tableGroup.setLayoutData(gridData);
+
+ tableInherit = table;
+ //
+
+ label = new Label(parent, SWT.NONE);
+ label.setText(LisaacMessages.getString("NewPrototypeWizard_36"));
+ label.setFont(parent.getFont());
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 3;
+ label.setLayoutData(gridData);
+
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 3;
+ gridData.horizontalAlignment = SWT.CENTER;
+ generateMain = new Button(parent, SWT.CHECK);
+ generateMain.setText(LisaacMessages.getString("NewPrototypeWizard_37"));
+ generateMain.setLayoutData(gridData);
+ generateConstructor = new Button(parent, SWT.CHECK);
+ generateConstructor.setText(LisaacMessages.getString("NewPrototypeWizard_38"));
+ generateConstructor.setLayoutData(gridData);
+ }
+
+ protected String getInitialFileName() {
+ return INITIAL_PROTOTYPE_NAME;
+ }
+}
diff --git a/editor/emacs/lisaac-mode.el b/editor/emacs/lisaac-mode.el
new file mode 100644
index 0000000..b400e9a
--- /dev/null
+++ b/editor/emacs/lisaac-mode.el
@@ -0,0 +1,740 @@
+;;
+;; Mode Emacs for LISAAC language 0.2.2 by Sonntag Benoit.
+;;
+;;
+;; LICENSE
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.;
+;;
+;; INSTALLATION
+;; To install, simply copy this file into a directory in your
+;; load-path and add the following two commands in your '.emacs' file:
+;;
+;; (add-to-list 'auto-mode-alist '("\\.li\\'" . lisaac-mode))
+;; (autoload 'lisaac-mode "~/lisaac-mode" "Major mode for Lisaac Programs" t)
+;;
+;; NEW FUNCTION KEY
+;; <tab> : Indent current line.
+;; [F2] : Indent all lines.
+;;
+;; [F5] : Append the Licence Header.
+;; [F6] : Append the Header section.
+;; [F7] : Append a constructor.
+;;
+;; [F10] : Display Previous Buffer.
+;; [F11] : Display the prototype pointed.
+;; [F12] : Vertical split window and display the prototype pointed.
+;;
+;; <Echap> G : Goto line.
+;;
+;; BUG REPORT
+;; - Bug coloration with external `...`
+;; - ( + to:INTEGER; truc.put 't' to 10; // to -> black!
+;;
+;; MODIFY FOR YOU :
+(defvar li-user-name "Sonntag Benoit")
+(defvar li-user-mail "sonntag at icps.u-strasbg.fr")
+
+;;
+;; Table abbrev.
+;;
+(defvar li-mode-abbrev-table nil
+ "Abbrev table used while in Lisaac mode.")
+(define-abbrev-table 'li-mode-abbrev-table ())
+
+;;
+;; Color Expression.
+;;
+
+(defvar li-color 0)
+(defvar li-comment 0)
+(defvar li-string nil)
+(defvar li-string2 nil)
+
+
+(defvar li-test 0)
+
+
+(defun li-message ()
+ ""
+ ;(insert (char-to-string (char-before (point))))
+ (setq li-point2 (point))
+ (setq li-string2 (match-string 0))
+ (setq li-char (char-before (- (point) (length li-string2))))
+ (if (and (>= li-char ?0) (<= li-char ?9))
+ (setq li-color font-lock-keyword-face)
+ (progn
+ (end-of-line)
+ (setq li-point3 (point))
+ (setq li-string (concat "....+[^a-z0-9_]" li-string2 "\\([ \t]*,[ \t]*[a-z0-9_]*\\)*[ \t]*:[^=]"))
+
+
+ (if (re-search-backward "^ \\(+\\|-\\)" (point-min) t 1)
+ (progn
+ (setq li-point4 (point))
+ (if (and (re-search-forward "<-\\|:=\\|?=\\|;" nil t 1)
+ (< li-point2 (point)))
+ (progn
+ (goto-char li-point4)
+ (if (re-search-forward li-string li-point3 t 1)
+ (setq li-color 0)
+ (setq li-color li-slot-face)
+ )
+ )
+ (progn
+ (goto-char li-point4)
+ (if (re-search-forward li-string li-point3 t 1)
+ (setq li-color 0)
+ (setq li-color font-lock-function-name-face)
+ )
+ )
+ )
+ )
+ )
+
+ ;(setq li-color (get-char-property (point) 'face))
+ )
+ )
+ (goto-char li-point2)
+ li-color
+)
+
+(defun li-declaration ()
+ ""
+ ;; Detect local declaration.
+ (if (looking-at "[ \ta-z0-9_,]*:[^=]")
+ (setq li-color font-lock-warning-face)
+ (setq li-color font-lock-variable-name-face)
+ )
+ li-color
+)
+
+(defun li-type-color ()
+ ""
+ ;; Detect local declaration.
+ (setq li-string2 (concat (downcase (match-string 0)) ".li" ))
+ (setq li-test 0)
+ (while (and (< li-test (length (mapcar (function buffer-name) (buffer-list))))
+ (not (string-equal (nth li-test (mapcar (function buffer-name) (buffer-list))) li-string2))
+ )
+ (setq li-test (+ li-test 1))
+ )
+ (if (< li-test (length (mapcar (function buffer-name) (buffer-list))))
+ (setq li-color li-type-face)
+ (setq li-color font-lock-type-face)
+ )
+
+ li-color
+)
+
+(defconst li-font-lock-keywords
+ '(
+ ;; External expression
+ ("`[^`\n]*`" 0 highlight nil)
+
+ ;; Quoted expression
+ ("'[\\].[^'\n]*'" 0 font-lock-constant-face nil)
+ ("'[^\\ '\n]'" 0 font-lock-constant-face nil)
+
+ ;; quoted expr's in comments
+ ("`[^'\n]*'" 0 font-lock-builtin-face t)
+
+ ;; Block :
+ ("\{\\|\}" 0 font-lock-comment-face nil)
+
+ ;; Assignment :
+ ("<-\\|:=\\|?=" 0 0 nil)
+
+ ;; Float notation :
+ ("[0-9_]+\.[0-9]*E[+-]?[0-9]+" 0 font-lock-keyword-face nil)
+
+ ;; Symbol declaration :
+ ("^ \\(\\+\\|-\\)" 0 font-lock-warning-face nil)
+ ("\\+\\|-" 0 (li-declaration) nil)
+
+ ;; Operators :
+ ("[!@#$%^&<|=~/>?\\*\\]+" 0 font-lock-variable-name-face nil)
+
+ ;; Major keywords :
+ ("^Section[ \t]+[a-zA-Z,\t 0-9_]+\\|Right\\|Left\\|Expanded\\|Strict\\|Old\\|Self\\|Result\\(_[1-9]\\)?"
+ 0 font-lock-keyword-face nil)
+
+ ;; Hexa-number :
+ ("[0-9][0-9_]*[A-F][0-9A-F_]*h" 0 font-lock-keyword-face nil)
+
+ ;; Prototype :
+ ("[A-Z][A-Z0-9_]*" 0 (li-type-color) nil)
+
+ ;; Identifier :
+ ("\\.[ \t\n]*[a-z][a-z0-9_]*" 0 font-lock-function-name-face nil)
+ ("[a-z]+[a-z0-9_]*" 0 (li-message) nil)
+
+ ;; Number :
+ ("[0-9][0-9_]*" 0 font-lock-keyword-face nil)
+ ("[0-9]+[0-9A-Fa-f_]*" 0 font-lock-keyword-face nil)
+ )
+ "Additional expressions to highlight in Lisaac mode.")
+
+;;
+;; Table de syntax.
+;;
+(defvar li-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ ;; Symbol
+ (modify-syntax-entry ?0 "." st)
+ (modify-syntax-entry ?2 "." st)
+ (modify-syntax-entry ?1 "." st)
+ (modify-syntax-entry ?! "." st)
+ (modify-syntax-entry ?@ "." st)
+ (modify-syntax-entry ?# "." st)
+ (modify-syntax-entry ?$ "." st)
+ (modify-syntax-entry ?% "." st)
+ (modify-syntax-entry ?^ "." st)
+ (modify-syntax-entry ?& "." st)
+ (modify-syntax-entry ?< "." st)
+ (modify-syntax-entry ?| "." st)
+ (modify-syntax-entry ?= "." st)
+ (modify-syntax-entry ?/ "." st)
+ (modify-syntax-entry ?> "." st)
+ (modify-syntax-entry ?\? "." st)
+ (modify-syntax-entry ?* "." st)
+ (modify-syntax-entry ?+ "." st)
+ (modify-syntax-entry ?- "." st)
+ ;; String, character, external.
+; (modify-syntax-entry ?\" "\"" st)
+; (modify-syntax-entry ?\' "\"" st)
+; (modify-syntax-entry ?` "$$ " st)
+ ;; Identifier
+ (modify-syntax-entry ?_ "w" st)
+ ;; Comment
+ (modify-syntax-entry ?\* ". 23" st)
+ (modify-syntax-entry ?/ ". 124b" st)
+ (modify-syntax-entry ?\n "> b" st)
+ st)
+ "Syntax table used while in Lisaac mode.")
+
+
+;;
+;; Definition press key.
+;;
+(defvar li-mode-map (make-sparse-keymap)
+ "Keymap used in Lisaac mode.")
+(global-set-key [home] 'beginning-of-line)
+(global-set-key [end] 'end-of-line)
+(define-key li-mode-map "\t" 'li-indent-command)
+(define-key li-mode-map "\r" 'li-newline-command)
+(define-key li-mode-map [f2] 'li-indent-all-command)
+(define-key li-mode-map [f5] 'li-header1-command)
+(define-key li-mode-map [f6] 'li-header2-command)
+(define-key li-mode-map [f7] 'li-header3-command)
+;(define-key li-mode-map [f8] 'li-header4-command)
+;(define-key li-mode-map [f9] 'li-while-command)
+(define-key li-mode-map [f10] 'li-previous-buffer-command)
+(define-key li-mode-map [f11] 'li-load-direct-prototype-command)
+(define-key li-mode-map [f12] 'li-load-prototype-command)
+
+;;
+;; Insertion loop command.
+;;
+
+(defun li-previous-buffer-command ()
+ "Display prototype."
+ (interactive)
+ (set-window-buffer (selected-window) (nth 0 (mapcar (function buffer-name) (buffer-list))))
+)
+
+(defun li-load-direct-prototype-command ()
+ "Display prototype."
+ (interactive)
+
+ (if (face-equal (get-char-property (point) 'face) li-type-face)
+ (progn
+ (backward-word 1)
+ (looking-at "[A-Z][A-Z0-9_]*")
+ (setq li-string2 (concat (downcase (match-string 0)) ".li" ))
+ (set-window-buffer (selected-window) li-string2)
+ )
+ )
+)
+
+(defun li-load-prototype-command ()
+ "Display prototype."
+ (interactive)
+
+ (if (face-equal (get-char-property (point) 'face) li-type-face)
+ (progn
+ (backward-word 1)
+ (looking-at "[A-Z][A-Z0-9_]*")
+ (setq li-string2 (concat (downcase (match-string 0)) ".li" ))
+
+ (split-window-vertically)
+ (set-window-buffer (selected-window) li-string2)
+ )
+ )
+)
+
+(defun li-header1-command ()
+ "Insert header standard Lisaac."
+ (interactive)
+ (insert "///////////////////////////////////////////////////////////////////////////////\n")
+ (setq li-string "// Application //\n")
+ (when (string-match "isaacos" (buffer-file-name))
+ (setq li-string "// Isaac Opearting System //\n")
+ )
+ (when (string-match "lib" (buffer-file-name))
+ (setq li-string "// Lisaac Library //\n")
+ )
+ (when (string-match "src" (buffer-file-name))
+ (setq li-string "// Lisaac Compiler //\n")
+ )
+ (when (string-match "/example" (buffer-file-name))
+ (setq li-string "// Lisaac Example //\n")
+ )
+ (insert li-string)
+ (insert "// //\n")
+ (insert "// LSIIT - ULP - CNRS - INRIA - FRANCE //\n")
+ (insert "// //\n")
+ (insert "// This program is free software: you can redistribute it and/or modify //\n")
+ (insert "// it under the terms of the GNU General Public License as published by //\n")
+ (insert "// the Free Software Foundation, either version 3 of the License, or //\n")
+ (insert "// (at your option) any later version. //\n")
+ (insert "// //\n")
+ (insert "// This program is distributed in the hope that it will be useful, //\n")
+ (insert "// but WITHOUT ANY WARRANTY; without even the implied warranty of //\n")
+ (insert "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //\n")
+ (insert "// GNU General Public License for more details. //\n")
+ (insert "// //\n")
+ (insert "// You should have received a copy of the GNU General Public License //\n")
+ (insert "// along with this program. If not, see <http://www.gnu.org/licenses/>. //\n")
+ (insert "// //\n")
+ (insert "// http://isaacproject.u-strasbg.fr/ //\n")
+ (insert "///////////////////////////////////////////////////////////////////////////////\n")
+)
+
+(defun li-header2-command ()
+ "Insert header standard Lisaac."
+ (interactive)
+ (insert "Section Header")
+ (li-newline-command)
+ (insert "\n")
+ (insert " + name := ")
+ (insert (upcase (truncate-string-to-width (buffer-name) (- (length (buffer-name)) 3) 0)))
+ (insert ";\n")
+ (insert "\n")
+ (insert " - copyright := \"2003-")
+ (insert (format-time-string "%Y"))
+ (insert " ")
+ (insert li-user-name)
+ (insert "\";\n")
+ (insert "\n")
+ (insert " - author := \"")
+ (insert li-user-name)
+ (insert " (")
+ (insert li-user-mail)
+ (insert ")\";\n")
+ (insert " - comment := \"The main prototype\";\n")
+ (insert "\n")
+ (insert "Section Inherit\n")
+ (insert "\n")
+ (insert " - parent_object:OBJECT := OBJECT;\n")
+ (insert "\n")
+ (insert "Section Public\n")
+)
+
+(defun li-header3-command ()
+ "Insert header standard Lisaac."
+ (interactive)
+ (insert "\n //\n")
+ (insert " // Creation.\n")
+ (insert " //\n")
+ (insert "\n")
+ (insert " - create:SELF <-\n")
+ (insert " ( + result:SELF;\n")
+ (insert " result := clone;\n")
+ (insert " result.make;\n")
+ (insert " result\n")
+ (insert " );\n")
+ (insert "\n")
+ (insert " - make <-\n")
+ (insert " ( \n")
+ (insert "\n")
+ (insert " );\n")
+ (insert "\n")
+ (previous-line 3)
+ (li-indent-command)
+)
+
+;(defun li-while-command ()
+; "Insert loop while Lisaac."
+; (interactive)
+; (insert ".while_do {")
+; (li-newline-command)
+; (li-newline-command)
+; (insert "}; // while_do")
+; (li-newline-command)
+; (previous-line 2)
+; (li-indent-command)
+;)
+
+;(defun li-until-command ()
+; "Insert loop until Lisaac."
+; (interactive)
+; (insert ".until_do {")
+; (li-newline-command)
+; (li-newline-command)
+; (insert "}; // until_do")
+; (li-newline-command)
+; (previous-line 2)
+; (li-indent-command)
+;)
+
+;;
+;; Insertion test command.
+;;
+
+;(defun li-cond1-command ()
+; "Insert conditionnal Lisaac."
+; (interactive)
+; (insert ".if {")
+; (li-newline-command)
+; (li-newline-command)
+; (insert "}; // if")
+; (li-newline-command)
+; (previous-line 2)
+; (li-indent-command)
+;)
+
+;(defun li-cond2-command ()
+; "Insert conditionnal Lisaac."
+; (interactive)
+; (insert ".if {")
+; (li-newline-command)
+; (li-newline-command)
+; (insert "} else {")
+; (li-newline-command)
+; (li-newline-command)
+; (insert "}; // if")
+; (li-newline-command)
+; (previous-line 4)
+; (li-indent-command)
+;)
+
+
+(defvar li-count-all 0)
+
+(defun li-indent-all-command ()
+ "All indent text"
+ (interactive)
+
+ ;; Search first line.
+ (setq li-count-all 1)
+ (beginning-of-line)
+ (while (/= (point) (point-min))
+ (setq li-count-all (+ li-count-all 1))
+ (previous-line 1)
+ (beginning-of-line))
+
+ ;; Indent each line.
+ (next-line 1)
+ (while (/= (point) (point-max))
+ (li-indent-command)
+ (next-line 1))
+
+ ;; Return current line.
+ (goto-line li-count-all)
+)
+
+;;
+;; Indentation.
+;;
+
+(defvar li-count-line 0)
+(defvar li-point 0)
+(defvar li-point2 0)
+(defvar li-point3 0)
+(defvar li-point4 0)
+(defvar li-char ?b)
+
+(defvar li-indent 0)
+(defvar li-indent-2 0)
+(defvar li-indent-base 0)
+
+(require 'font-lock)
+(defvar li-slot-face 'li-slot-face
+ "Face to use for slot major.")
+(defvar li-type-face 'li-type-face
+ "Face to use for type file.")
+
+(defun li-indent-previous ()
+ "Indent with previous line."
+ ; Search a previous line.
+ (setq li-count-line 1)
+ (previous-line 1)
+ (beginning-of-line)
+ (while (looking-at "[ \t\n]*$")
+ (setq li-count-line (+ li-count-line 1))
+ (previous-line 1)
+ (beginning-of-line))
+ ; Set position on begin of text.
+ (forward-to-indentation 0)
+
+ ; Initialization.
+ (setq li-indent-base (current-column))
+ (setq li-indent 0)
+ (setq li-point (point))
+
+ ; Particuliar case ...
+ (if (looking-at "^Section.*$")
+ (setq li-indent-base (+ li-indent-base 2)))
+
+ ; Counter of () or {} or [], with previous line.
+ (setq li-test 0)
+ (while (= li-test 0)
+ (setq li-char (char-after li-point))
+ (if (= li-char ?[)
+ (setq li-indent (+ li-indent 2)))
+ (if (= li-char ?{)
+ (setq li-indent (+ li-indent 2)))
+ (if (= li-char ?()
+ (setq li-indent (+ li-indent 2)))
+ (if (= li-char ?})
+ (if (/= li-indent 0)
+ (setq li-indent (- li-indent 2))))
+ (if (= li-char ?))
+ (if (/= li-indent 0)
+ (setq li-indent (- li-indent 2))))
+ (if (= li-char ?])
+ (if (/= li-indent 0)
+ (setq li-indent (- li-indent 2))))
+; ;; Virgule and End-of-line.
+; (if (= li-char ?,)
+; (if (= (char-after (+ li-point 1)) ?\n)
+; (setq li-indent (+ li-indent 2))))
+ ;; End-of-line.
+ (if (= li-char ?\n)
+ (setq li-test 1)) ;; Stop
+ ;; Comment //
+ (if (= li-char ?/)
+ (if (= (char-after (+ li-point 1)) ?/)
+ (setq li-test 1))) ;; Stop
+ ;; String " "
+ (if (= li-char ?")
+ (progn
+ (while (= li-test 0)
+ (setq li-point (+ li-point 1))
+ (setq li-char (char-after li-point))
+ (if (= li-char ?\n)
+ (setq li-test 1)) ;; Stop
+ (if (= li-char ?")
+ (setq li-test 1)) ;; Stop
+ )
+ (setq li-test 0))
+ )
+ ;; String ' '
+ (if (= li-char ?')
+ (progn
+ (while (= li-test 0)
+ (setq li-point (+ li-point 1))
+ (setq li-char (char-after li-point))
+ (if (= li-char ?\n)
+ (setq li-test 1)) ;; Stop
+ (if (= li-char ?')
+ (setq li-test 1)) ;; Stop
+ )
+ (setq li-test 0))
+ )
+ ;; Next character.
+ (setq li-point (+ li-point 1))
+ )
+
+ ; Next line: Current Line.
+ (while (/= li-count-line 0)
+ (setq li-count-line (- li-count-line 1))
+ (next-line 1))
+
+ ; Go to End of line.
+ (end-of-line)
+
+ ; Initialization.
+ (setq li-indent-2 0)
+ (setq li-point (point))
+
+ ; Count () or {} or [], of current line.
+ (setq li-test 0)
+ (while (= li-test 0)
+ (setq li-point (- li-point 1))
+ (setq li-char (char-after li-point))
+ (if (= li-char ?])
+ (setq li-indent-2 (+ li-indent-2 2)))
+ (if (= li-char ?})
+ (setq li-indent-2 (+ li-indent-2 2)))
+ (if (= li-char ?))
+ (setq li-indent-2 (+ li-indent-2 2)))
+ (if (= li-char ?{)
+ (if (/= li-indent-2 0)
+ (setq li-indent-2 (- li-indent-2 2))))
+ (if (= li-char ?()
+ (if (/= li-indent-2 0)
+ (setq li-indent-2 (- li-indent-2 2))))
+ (if (= li-char ?[)
+ (if (/= li-indent-2 0)
+ (setq li-indent-2 (- li-indent-2 2))))
+ (if (= li-char ?\n)
+ (setq li-test 1)) ;; Stop
+ (if (= li-char ?/)
+ (if (= (char-after (+ li-point 1)) ?/)
+ (setq li-indent-2 0)))
+ ;; String " "
+ (if (= li-char ?")
+ (progn
+ (while (= li-test 0)
+ (setq li-point (- li-point 1))
+ (setq li-char (char-after li-point))
+ (if (= li-char ?\n)
+ (setq li-test 1)) ;; Stop
+ (if (= li-char ?")
+ (setq li-test 1)) ;; Stop
+ )
+ (setq li-test 0))
+ )
+ ;; String ' '
+ (if (= li-char ?')
+ (progn
+ (while (= li-test 0)
+ (setq li-point (- li-point 1))
+ (setq li-char (char-after li-point))
+ (if (= li-char ?\n)
+ (setq li-test 1)) ;; Stop
+ (if (= li-char ?')
+ (setq li-test 1)) ;; Stop
+ )
+ (setq li-test 0))
+ )
+ )
+
+ ; Deleted spaces
+ (beginning-of-line)
+ (delete-horizontal-space)
+
+ ; Append indentation.
+ (setq li-indent (- li-indent li-indent-2))
+ (setq li-indent (+ li-indent li-indent-base))
+ (indent-to-column li-indent)
+
+ ; Go to end of line.
+ (end-of-line)
+)
+
+
+(defun li-indent-command ()
+ "indent line for Lisaac mode."
+ (interactive)
+ (beginning-of-line)
+ (if (looking-at "[ \t]*Section.*$")
+ ; then
+ (progn
+ (delete-horizontal-space)
+ (end-of-line))
+ ;else
+ (li-indent-previous))
+)
+
+;;
+;; Newline command.
+;;
+
+(defun li-newline-command ()
+ "indent line, append newline, indent line."
+ (interactive)
+ (if (looking-at "[ \t]*$")
+ ; then
+ (progn
+ (li-indent-command)
+ (newline)
+ (li-indent-command))
+ ; else
+ (newline))
+)
+
+;;
+;; autoload
+;;
+(defun lisaac-mode ()
+ "Major mode for editing typical Lisaac code."
+ (interactive)
+
+; In LaTeX-mode we want this
+; (add-hook 'LaTeX-mode-hook
+; (function (lambda ()
+; (paren-toggle-matching-quoted-paren 1)
+; (paren-toggle-matching-paired-delimiter 1))))
+(autoload 'paren-toggle-matching-paired-delimiter "mic-paren" "" t)
+;(paren-toggle-matching-quoted-paren 1)
+; (paren-toggle-matching-paired-delimiter 1)
+;(auto-overlay-load-definition
+;'latex
+;'(self ("\\$" (priority . 3) (face . (background-color . "green")))))
+;(autoload 'latex-mode "Mode Latex" "jfh" t)
+;(require 'font-latex)
+
+ ;; compatibility MS-DOS
+ (replace-string "
" "")
+ ; (global-font-lock-mode t)
+ (global-set-key "\M-g" 'goto-line)
+
+ (global-font-lock-mode t)
+
+ (kill-all-local-variables)
+ (setq mode-name "Lisaac")
+ (setq major-mode 'lisaac-mode)
+ (use-local-map li-mode-map)
+
+ (make-local-variable 'li-mode-syntax-table)
+ (set-syntax-table li-mode-syntax-table)
+
+ (make-local-variable 'parse-sexp-ignore-comments)
+ (setq parse-sexp-ignore-comments nil)
+
+ (make-local-variable 'font-lock-string-face)
+ (make-local-variable 'font-lock-defaults)
+
+ ; Creation new face.
+ (make-face 'li-slot-face)
+ (set-face-foreground 'li-slot-face "blue")
+ ;(set-face-bold-p 'li-slot-face t)
+ ;(set-face-italic-p 'li-slot-face t)
+ (set-face-underline-p 'li-slot-face t)
+ ;(set-face-background 'li-slot-face "black")
+
+ (make-face 'li-type-face)
+ (copy-face font-lock-type-face 'li-type-face)
+ (set-face-underline-p 'li-type-face t)
+
+ ;(setq font-lock-string-face '(li-font-lock-string))
+ (setq font-lock-defaults '(li-font-lock-keywords))
+
+ ;; No replace spaces by tabulations
+ (setq-default indent-tabs-mode nil)
+
+ ; For use mouse Wheel.
+ (require 'mwheel)
+ (mwheel-install)
+
+ (run-hooks 'li--mode-hook))
+
+;;
+;; End of Lisaac mode.
+;;
+(provide 'lisaac-mode)
+
+
diff --git a/editor/hippoedit/README.txt b/editor/hippoedit/README.txt
new file mode 100644
index 0000000..65e93a2
--- /dev/null
+++ b/editor/hippoedit/README.txt
@@ -0,0 +1,26 @@
+HippoEDIT
+---------
+
+http://hippoedit.com
+
+From the website:
+
+ HippoEDIT is a powerful, fast and easy to use Windows text editor, primarily
+ targeted at power users and programmers. It has modern and lightweight user
+ interface, which supports different interface schemes, Multi Tab environment,
+ seamless web and help browser, File Explorer and Project Explorer, external
+ tools integration and more smart text editor functions.
+
+It has a cool feature in that it very easily nests modes. So, in Lisaac,
+when you use the back tick `, the code inside of the back ticks are
+fully syntax highlighted as C code.
+
+It also has slot navigation for Lisaac source files.
+
+Installation
+------------
+
+1. Copy lisaac_spec.xml to C:\Program Files\HippoEDIT\data\syntax
+2. Restart HippoEDIT.
+
+.li and .lip files should now be syntax highlighted as Lisaac.
diff --git a/editor/hippoedit/lisaac_spec.xml b/editor/hippoedit/lisaac_spec.xml
new file mode 100644
index 0000000..bbf2a3d
--- /dev/null
+++ b/editor/hippoedit/lisaac_spec.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="syntax.xslt"?>
+<XMLConfigSettings>
+ <FILEINFO author="Jeremy Cowgar" type="LangSpec"/>
+ <SYNTAX id="eu" name="Lisaac" inherit="def_source" inherit_url="defsource_spec.xml">
+ <SPECIFICATION>
+ <FilePattern mask="*.li;*.lip;"/>
+ <CaseSensitive>true</CaseSensitive>
+ <OpenClose>()[]{}''""</OpenClose>
+ <EscapeChar>\</EscapeChar>
+ <Operators>?*-+/&*=<>!{}()[].</Operators>
+ <Words>0-9A-Za-z_</Words>
+ <Encoding default="866"/>
+ <HierarchySeparator>
+ <Separator text=":"/>
+ </HierarchySeparator>
+ <Bars navigation="true"/>
+ </SPECIFICATION>
+ <FORMAT>
+ <DefaultIndent>2</DefaultIndent>
+ </FORMAT>
+ <SCOPES>
+ </SCOPES>
+ <LABELS>
+ <Label group="Function" match="^\t(\-|\+)\s+(\w+)[^\n]*<-" name="Slot \2" descr="\1 \2" scope="1" image="9"/>
+ <Label group="Variable" match="^\t(\-|\+)\s+(\w+)[ \t]*:" name="Var \2" descr="\1 \2" scope="1" image="8"/>
+ </LABELS>
+ <STYLES>
+ <Style id="url" extend="true">
+ <Containers>
+ <Open id="normal" exclude="true"/>
+ <Open id="string"/>
+ <Open id="comment"/>
+ <Open id="char"/>
+ </Containers>
+ </Style>
+ <Style id="comment" name="Comments" text="1" bold="0" italic="1" underline="0" clr="#FF0000" bkclr="#FFFFFFFF">
+ <Blocks>
+ <Block open="//" close="\n"/>
+ </Blocks>
+ </Style>
+ <Style id="string" name="Strings" text="1" bold="0" italic="0" underline="0" clr="#009900" bkclr="#FFFFFFFF">
+ <Blocks>
+ <Block open=""" close="""/>
+ </Blocks>
+ </Style>
+ <Style id="char" name="Char" text="1" bold="0" italic="0" underline="0" clr="#009900" bkclr="#FFFFFFFF">
+ <Blocks>
+ <Block open="'" close="'"/>
+ </Blocks>
+ </Style>
+ <Style name="Sections" text="1" bold="0" italic="0" underline="0" clr="#CC00CC" bkclr="#FFFFFF">
+ <Keywords>
+ <Keyword text="Section" />
+ <Keyword text="Header" />
+ <Keyword text="Insert" />
+ <Keyword text="Inherit" />
+ <Keyword text="Public" />
+ <Keyword text="Private" />
+ <Keyword text="Mapping" />
+ <Keyword text="Interrput" />
+ <Keyword text="Right" />
+ <Keyword text="Left" />
+ <Keyword text="Self" />
+ <Keyword text="Old" />
+ <Keyword text="Expanded" />
+ <Keyword text="Strict" />
+ </Keywords>
+ </Style>
+ <Style id="keywords" name="Keywords" image="13" bold="1" italic="0" underline="0" clr="#0000AA" bkclr="#FFFFFFFF">
+ <Keywords>
+ <Keyword text="while" />
+ <Keyword text="while_do" />
+ <Keyword text="if" />
+ <Keyword text="else" />
+ <Keyword text="when" />
+ <Keyword text="elseif" />
+ <Keyword text="then" />
+ <Keyword text="self" />
+ <Keyword text="by" />
+ <Keyword text="to" />
+ <Keyword text="do" />
+ <Keyword text="or" />
+ <Keyword text="downto" />
+ <Keyword text="if" />
+ <Keyword text="if_true" />
+ <Keyword text="if_false" />
+ <Keyword text="shrink" />
+ </Keywords>
+ </Style>
+ <Style id="script" name="C" include="cpp:normal" bold="0" italic="0" underline="0" clr="#66666600" bkclr="Embedded Language 2 Back" overview="1">
+ <Containers>
+ <Close id="cpp:normal"/>
+ <Close id="cpp:comment"/>
+ </Containers>
+ <Blocks>
+ <Block open="`" close="`" />
+ </Blocks>
+ </Style>
+ <Style name="TODOs" text="1" bold="1" italic="1" underline="0" clr="TODOs" bkclr="#FFFFFFFF">
+ <Containers>
+ <Open id="comment"/>
+ </Containers>
+ <Blocks>
+ <Block open="TODO" close="\n"/>
+ <Block open="todo" close="\n"/>
+ </Blocks>
+ </Style>
+ </STYLES>
+ </SYNTAX>
+</XMLConfigSettings>
diff --git a/editor/kate/AUTHORS b/editor/kate/AUTHORS
new file mode 100644
index 0000000..3781b1b
--- /dev/null
+++ b/editor/kate/AUTHORS
@@ -0,0 +1 @@
+Anthony Pajot <anthony.pajot at etu.enseeiht.fr>
diff --git a/editor/kate/COPYING b/editor/kate/COPYING
new file mode 100644
index 0000000..5b6e7c6
--- /dev/null
+++ b/editor/kate/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/editor/kate/README b/editor/kate/README
new file mode 100644
index 0000000..d4e7a40
--- /dev/null
+++ b/editor/kate/README
@@ -0,0 +1,26 @@
+####################################################
+1/ Presentation
+
+The "lisaac_v2.xml" file contains a syntactically-based coloration scheme recognizing Lisaac v0.2 source code for Kate, an open-source code editor (http://www.kate-editor.org/).
+It attempts to detect lexical and syntactic errors by colorizing the code in red from the point where the error is detected, (which is not necessarily the one where the error is).
+
+
+####################################################
+2/ Installation
+
+There are 2 possibilies to install the "lisaac_v2.xml" file.
+
+* If you're not the station administrator, or if you don't want other Kate users to have direct access to this scheme, copy the file in <your_home_directory>/.kde/share/apps/katepart/syntax. There might have missing subfolders, in this case you'll have to create them.
+
+* If you're the station administrator, and if you want all the Kate users to have direct access to this scheme, copy the file in /usr/share/apps/katepart/syntax as root. Depending on the system you use, the "apps" folder could be in a different place that "/usr/share". In Debian, it's there.
+
+Once you've copied the file in the right place, restart Kate. The Lisaac coloration scheme will be available in "Sources/Lisaac v0.2". It will be automatically used when you open a file having a ".li" extension (except if you have set another preference by hand).
+
+WARNING : if you also have the mode for Lisaac v0.1, it might happen that the wrong mode is chosen when opening a lisaac file. You'll just have to switch from one to another manually depending on the version of Lisaac the source code is written for by choosing "Sources/Lisaac" or "Sources/Lisaac v0.2" in Kate.
+
+####################################################
+3/ Known limitations
+
+There are a number of issues due to the way Kate interprets the coloration schemes. So don't be surprised to have a correct coloration even if there are syntaxic errors in your source code. But do not hesitate to send me a mail at "anthony.pajot at etu.enseeiht.fr" with a copy of all or part of your lisaac code if the scheme detects an error whereas the code is correct or if Kate gets stucked while you're typing code.
+
+Enjoy !
diff --git a/editor/kate/lisaac_v2.xml b/editor/kate/lisaac_v2.xml
new file mode 100644
index 0000000..55335e4
--- /dev/null
+++ b/editor/kate/lisaac_v2.xml
@@ -0,0 +1,1246 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--kate: encoding: utf-8; indent-mode: xml; space-indent off; indent-width 4;
+ kate: tab-width 4; remove-trailing-space on; -->
+<!--**********************************************************************
+* Copyright (C) 2007 by Anthony Pajot *
+* anthony.pajot at etu.enseeiht.fr *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***********************************************************************-->
+
+
+<!DOCTYPE language SYSTEM "language.dtd"
+ [
+ <!-- toutes les regexps associés aux terminaux -->
+ <!ENTITY section "(Private|Public|Directory|Header|Mapping|Interrupt|Inherit|Insert|External)">
+ <!ENTITY lower_case "[a-z]">
+ <!ENTITY upper_case "[A-Z]">
+ <!ENTITY octal_digit "[0-7]">
+ <!ENTITY decimal_digit "[0-9]">
+ <!ENTITY hexa_digit "[0-9a-fA-F]">
+ <!ENTITY binary_digit "[0-1]">
+ <!ENTITY normal_char "[^'\\"]">
+ <!ENTITY integer_number "&decimal_digit;(_|&decimal_digit;)*">
+ <!ENTITY number "((&octal_digit;(_|&octal_digit;)*o)|&integer_number;(d?)|(&hexa_digit;(_|&hexa_digit;)*h)|(&binary_digit;(_|&binary_digit;)*b))">
+ <!ENTITY integer "&number;(KB|MB|GB)?">
+ <!ENTITY integer_or_real "(&integer;|(&integer_number;[.]&integer_number;(E([+-])?&integer_number;)?))">
+ <!ENTITY characters "\'(&normal_char;|&escape_char;|")*\'">
+ <!ENTITY characters_start "\'">
+ <!ENTITY string "\"(&normal_char;|&escape_char;|'|)*\"">
+ <!ENTITY string_start "\"">
+ <!ENTITY numeric_escape "\\&integer_or_real;\\">
+ <!ENTITY op_char_list "!@#$^&<>|*+=~/?\\:\-%">
+ <!ENTITY op_char "[&op_char_list;]">
+ <!ENTITY escape_char "([\\][tbnfrva0?\\ ]|&numeric_escape;|\\|)">
+ <!ENTITY identifier "(&lower_case;(&lower_case;|&decimal_digit;|_)*)">
+ <!ENTITY not_identifier "([^a-z0-9_])">
+ <!ENTITY ws "([\s])">
+ <!ENTITY ws_opt "&ws;*">
+ <!--oom = one or more-->
+ <!ENTITY ws_oom "&ws;+">
+ <!--ici, :=, <- et ?= seront aussi pris. donc dans les contextes ayant ca,
+ il faudra mettre la regle d'affectation avant -->
+ <!ENTITY operator "&op_char;+">
+ <!ENTITY affect "(:=|<-|[?]=)">
+ <!ENTITY cap_idf_item "&upper_case;(&upper_case;|&decimal_digit;|_)*">
+ <!ENTITY cap_identifier "&cap_idf_item;(\.&cap_idf_item;)*(\.(\.&cap_idf_item;)+)?">
+ <!ENTITY external "\`(&normal_char;|&escape_char;)*\`">
+ <!ENTITY external_start "\`">
+ <!ENTITY priority "(Left|Right)">
+ <!ENTITY style "[+-]">
+
+ <!ENTITY type "(Expanded|Separate|Strict)">
+ <!ENTITY result "Result(_&decimal_digit;(&decimal_digit;)*)?">
+
+
+ <!--le début de non terminaux, parce que c'est long sinon -->
+ <!ENTITY start_loc_arg "([(]&ws_opt;&start_local;|&identifier;&ws_opt;:[^=])" >
+ <!ENTITY start_local "&identifier;&ws_opt;([,]&ws_opt;&identifier;&ws_opt;)*(:[^=])" >
+ <!ENTITY start_type "(&type;|&cap_identifier;)" >
+ <!ENTITY start_type_list "&start_type;" >
+ <!ENTITY start_send_msg "&identifier;" >
+ <!ENTITY start_expr_primary "(Self|&cap_identifier;|&result;|&integer_or_real;|&characters_start;|&string_start;|[({]|&external_start;)">
+ <!ENTITY start_expr_base "(&start_expr_primary;|Old|&start_send_msg;)">
+ <!ENTITY start_expr_message "&start_expr_base;">
+ <!ENTITY start_expr_prefix "(&operator;|&start_expr_base;)" >
+ <!ENTITY start_expr "&start_expr_prefix;">
+ <!ENTITY start_group "(&start_def_local;|&start_expr;)"> <!--les groupes vides sont pris en compte
+ indirectements-->
+ <!ENTITY start_def_local "&style;&ws_opt;&start_local;">
+ <!ENTITY start_argument "(&identifier;|&start_expr_primary;)">
+ <!ENTITY start_contract "\[">
+ <!ENTITY start_slot "&style;">
+
+ <!--ce qui peut suivre certains non terminaux-->
+ <!ENTITY following_type_slot "(:|&affect;|;)" >
+ <!ENTITY following_local "([)]|;)" >
+ <!ENTITY following_type_list "([)]|&start_slot;|Section|&start_contract;|&identifier;|\]|;|-|<|,&ws_opt;[(])" > <!--les 3 derniers viennent de la gestion des fleches d'autocast et des exports/imports de vecteurs (-> TEST, (...))-->
+ <!ENTITY following_loc_arg "(&identifier;|&following_type_slot;|;)" >
+ <!ENTITY following_group "([)]|[}])" >
+ <!ENTITY following_expr "(&start_contract;|;|,|&following_group;)" >
+ <!ENTITY following_expr_prefix "(&affect;|&operator;|&following_expr;)" >
+ <!ENTITY following_expr_message "(&following_expr_prefix;)" >
+ <!ENTITY following_expr_base "([.]|&following_expr_message;)" >
+ <!ENTITY following_send_msg "(&following_expr_base;|[.]|&following_expr_message;)" >
+ <!ENTITY following_expr_primary "(&identifier;|&following_send_msg;|[.]|&following_expr_message;)" >
+ <!ENTITY following_prototype "(&following_loc_arg;|&following_local;|,|[(]|&following_expr_primary;|&following_type_list;)" >
+ <!ENTITY following_def_local "(&start_expr;|&following_group;|[.][.][.]||\])" >
+ <!ENTITY following_type "(&following_prototype;)" >
+
+ <!--d'autres regexps utiles de temps à autres-->
+ <!ENTITY bad_operator "(&affect;|:)[^&op_char_list;]">
+ <!ENTITY approx_type "(&cap_identifier;|\[|\]|&ws_oom;|,|Separate|Expanded)">
+
+ <!--quelques couleurs ou options d'attributs communes-->
+ <!ENTITY punctuation_style "dsNormal">
+ <!ENTITY punctuation_color "black">
+ <!ENTITY punctuation_bold "1">
+
+ <!ENTITY import_related_item_color "darkorange">
+ <!ENTITY export_related_item_color "orange">
+
+]>
+
+
+<!-- ~/.kde/share/apps/katepart/syntax/lisaac.xml -->
+<!-- http://kate.kde.org/doc/hlhowto.php -->
+<!-- http://wiki.kde.org/tiki-index.php?page=Configuring+Kate+with+variables -->
+<!-- http://www.kate-editor.org/article/writing_a_kate_highlighting_xml_file -->
+<!-- Created By Anthony Pajot <Anthony.Pajot at etu.enseeiht.fr> -->
+<!-- thanks to Mildred for his additions -->
+<language name="Lisaac v0.2" version="2.02" kateversion="2.3" section="Sources" extensions="*.li" mimetype="text/x-li" casesensitive="true" author="Anthony Pajot ( anthony.pajot at etu.enseeiht.fr )" license="GPL v2">
+ <highlighting>
+ <contexts>
+ <!--#################################################################
+ PROGRAM -> {'Section'(section|TYPE_LIST){SLOT}}[CONTRACT';']
+ ___
+ PROGRAM -> lambda {$}
+ PROGRAM -> 'Section' PROGRAM_SECTION_DEC PROGRAM_SLOT PROGRAM {'Section'}
+ PROGRAM -> CONTRACT ';' {'['}
+ PROGRAM_SECTION_DEC -> Section {Section}
+ PROGRAM_SECTION_DEC -> TYPE_LIST {START_TYPE}
+ PROGRAM_SLOT -> lambda {'Section', $}
+ PROGRAM_SLOT -> SLOT PROGRAM_SLOT {style}
+ ################################################################# -->
+ <context name="program_r1" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="Section" context="program_section_declaration" attribute="section_declaration"
+ beginRegion="Section" />
+
+ <!--pour program_slot -> lambda, on ne s'en occupe pas car on reste ici -->
+ <RegExpr String="&style;" lookAhead="true" context="program_slot_r2" />
+
+ <RegExpr String="&start_contract;" lookAhead="true" context="program_contract" />
+ </context>
+
+ <context name="program_contract" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_contract;" lookAhead="true" context="contract" />
+ <DetectChar char=";" context="#stay" attribute="semi_colon_ending_program_contract" /> <!--on devrait être à la fin de toute facon.-->
+ </context>
+
+ <context name="program_section_declaration" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="Header" context="program_header_section" attribute="header_section_name" />
+ <RegExpr String="(Inherit|Insert)" context="program_inherit_section" attribute="inherit_section_name" />
+
+ <RegExpr String="§ion;" context="#pop" attribute="section_name" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="program_section_type_list" />
+ </context>
+
+ <context name="program_section_type_list" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="(&style;|Section)" lookAhead="true" context="#pop#pop" /> <!--program_r1-->
+ <RegExpr String="&start_type;" lookAhead="true" context="header_type_list" />
+
+ </context>
+
+ <context name="program_slot_r2" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&style;" lookAhead="true" context="slot" />
+ <RegExpr String="(Section|&start_contract;)" lookAhead="true" context="#pop" endRegion="Section" /> <!--slot_program_r1-->
+ </context>
+
+ <context name="program_header_section" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&style;&ws_opt;name[^a-z0-9_]" lookAhead="true" context="program_name_slot" />
+
+ <RegExpr String="&style;" lookAhead="true" context="slot" />
+ <!--pour program_slot -> lambda, on ne s'en occupe pas car on reste ici -->
+
+ <RegExpr String="(&start_contract;|Section)" lookAhead="true" context="#pop#pop" /> <!--remontée au 1er niveau -->
+ </context>
+
+ <context name="program_name_slot" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&style;" context="#stay" attribute="slot_style" />
+ <RegExpr String="name" context="program_name_slot_dec" attribute="prototype_name_slot" />
+ <DetectChar char=";" context="#pop" attribute="semi_colon_ending_slot" />
+ </context>
+
+ <context name="program_name_slot_dec" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <Detect2Chars char=":" char1="=" context="type" attribute="slot_affectation" />
+
+ <DetectChar char=";" lookAhead="true" context="#pop" />
+
+ <Detect2Chars char="-" char1=">" lookAhead="true" context="program_name_auto_cast" />
+ <Detect2Chars char="<" char1="-" lookAhead="true" context="program_name_auto_cast" />
+ </context>
+
+ <context name="program_name_auto_cast" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <Detect2Chars char="-" char1=">" context="program_name_auto_cast_type_list" attribute="exported_types_arrow" />
+ <Detect2Chars char="<" char1="-" context="program_name_auto_cast_type_list" attribute="imported_types_arrow" />
+
+ <DetectChar char=";" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="program_name_auto_cast_type_list" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="type_list" />
+
+ <DetectChar char="," context="#stay" attribute="comma_separating_types" />
+ <DetectChar char="(" context="type_list" attribute="parenthesis_enclosing_infix_params" />
+ <DetectChar char=")" context="#stay" attribute="parenthesis_enclosing_infix_params" />
+
+ <RegExpr String="(;|<[-]|[-]>)" lookAhead="true" context="#pop" />
+ </context>
+
+
+ <context name="program_inherit_section" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&style;" context="program_inherit_slot_name" attribute="slot_style" />
+
+
+ <RegExpr String="(&start_contract;|Section)" lookAhead="true" context="#pop#pop" endRegion="Section" /> <!--remontée au 1er niveau -->
+ </context>
+
+ <context name="program_inherit_slot_name" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="program_inherit_slot_return_type" attribute="inherit_slot_name" />
+
+
+ <DetectChar char=";" context="#pop" attribute="semi_colon_ending_slot" />
+ </context>
+
+ <context name="program_inherit_slot_return_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&affect;" context="def_slot" attribute="slot_affectation" />
+
+ <DetectChar char=":" context="type" attribute="colon_before_return_type" />
+
+ <DetectChar char=";" lookAhead="true" context="#pop" />
+
+ </context>
+
+
+ <!--##################################################################
+ SLOT -> style ['(' LOCAL ')'] TYPE_SLOT[':'(TYPE | '(' TYPE_LIST ')')][affect DEF_SLOT]';'
+ ___
+ SLOT -> style SLOT_INFIX_PARAMS TYPE_SLOT SLOT_RETURN_TYPE SLOT_AFFECTED_DEF_SLOT ';' {style}
+ SLOT_INFIX_PARAMS -> lambda {identifier|"'"}
+ SLOT_INFIX_PARAMS -> '(' LOCAL ')' {'('}
+ SLOT_RETURN_TYPE -> lambda {affect}
+ SLOT_RETURN_TYPE -> ':' SLOT_RETURNED {':'}
+ SLOT_RETURNED -> TYPE {start_type }
+ SLOT_RETURNED -> '(' TYPE_LIST ')' {'(' }
+ SLOT_AFFECTED_DEF_SLOT -> lambda {';'}
+ SLOT_AFFECTED_DEF_SLOT -> affect DEF_SLOT {'affect'}
+ ##################################################################-->
+ <context name="slot" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&style;" context="slot_infix_params" attribute="slot_style" beginRegion="slot" />
+ <RegExpr String="(&identifier;|')" lookAhead="true" context="type_slot" />
+ <RegExpr String=":[^=]" lookAhead="true" context="slot_return_type" />
+ <RegExpr String="&affect;" lookAhead="true" context="slot_affected_def_slot" />
+ <DetectChar char=";" context="#pop" attribute="semi_colon_ending_slot" endRegion="slot"/>
+ </context>
+
+ <context name="slot_infix_params" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="(" attribute="parenthesis_enclosing_infix_params" context="local" />
+ <DetectChar char=")" attribute="parenthesis_enclosing_infix_params" context="#pop" />
+ <!--cas où y en a pas -->
+ <RegExpr String="(&identifier;|')" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="slot_return_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="(&affect;|;)" lookAhead="true" context="#pop" />
+ <DetectChar char=":" context="slot_returned" attribute="colon_before_return_type" /> <!--on fait passer le ":" tout seul après l'affectation, sinon une affectation du type := serait bouffée par le ":" tout seul-->
+ </context>
+
+ <context name="slot_returned" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="(&affect;|;)" lookAhead="true" context="#pop" />
+ <RegExpr String="&start_type;" lookAhead="true" context="type" /> <!--on fait passer le ":" tout seul apr� l'affectation, sinon une affectation du type := serait bouff� par le ":" tout seul-->
+ <DetectChar char="(" context="type_list" attribute="parenthesis_enclosing_returned_types" />
+ <DetectChar char=")" context="#pop" attribute="parenthesis_enclosing_returned_types" />
+ </context>
+
+ <context name="slot_affected_def_slot" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&affect;" context="def_slot" attribute="slot_affectation" />
+ <DetectChar char=";" lookAhead="true" context="#pop" />
+ </context>
+
+ <!--#################################################################
+ DEF_SLOT -> [CONTRACT] EXPR [CONTRACT]
+ ___
+ DEF_SLOT -> CONTRACT DEF_SLOT_EXPR {start_contract}
+ DEF_SLOT -> DEF_SLOT_EXPR {start_expr}
+ DEF_SLOT_EXPR -> EXPR DEF_SLOT_END_CONTRACT
+ DEF_SLOT_END_CONTRACT -> lambda {style|'Section'|$}
+ DEF_SLOT_END_CONTRACT -> CONTRACT {start_contract}
+ ###################################################################-->
+ <context name="def_slot" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_contract;" lookAhead="true" context="contract" />
+ <RegExpr String="&start_expr;" lookAhead="true" context="def_slot_expr" />
+ <RegExpr String=";" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="def_slot_expr" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr;" lookAhead="true" context="expr" />
+ <RegExpr String=";" lookAhead="true" context="#pop" />
+ <!--pour le contrat de fin -->
+ <RegExpr String="&start_contract;" lookAhead="true" context="def_slot_expr_contract" />
+ </context>
+
+ <context name="def_slot_expr_contract" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_contract;" lookAhead="true" context="contract" />
+ <RegExpr String=";" lookAhead="true" context="#pop" />
+ </context>
+
+ <!-- #################################################################
+ LOC_ARG -> identifier ':' TYPE | '(' LOCAL ')'
+ ___
+ LOC_ARG -> identifier LOC_ARG_IDENT_TYPE {identifier}
+ LOC_ARG -> LOC_ARG_LOCAL {'('}
+ LOC_ARG_IDENT_TYPE -> ':' TYPE
+ LOC_ARG_LOCAL -> '(' LOCAL ')'
+ ###################################################################-->
+ <context name="loc_arg" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="loc_arg_ident" attribute="declared_variable_name" />
+ <DetectChar char="(" lookAhead="true" context="loc_arg_local" />
+ </context>
+
+ <context name="loc_arg_ident" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+ <!--pour eviter de consommer le type de retour d'un slot -->
+ <DetectChar char=":" context="loc_arg_ident_type" attribute="colon_before_type" />
+ </context>
+
+ <context name="loc_arg_ident_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="type" />
+
+ <RegExpr String="&following_loc_arg;" lookAhead="true" context="#pop#pop#pop" />
+ </context>
+
+
+ <context name="loc_arg_local" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="(" context="local" attribute="parenthesis_enclosing_local_arguments" />
+
+ <DetectChar char=")" context="#pop#pop" attribute="parenthesis_enclosing_local_arguments" />
+ </context>
+
+
+
+ <!--#################################################################
+ TYPE_SLOT -> identifier [LOC_ARG {identifier LOC_ARG}]
+ TYPE_SLOT -> "'"operator"'" [priority[integer]] LOC_ARG
+ ___
+ TYPE_SLOT -> identifier TYPE_SLOT_PARAMS {identifier}
+ TYPE_SLOT_PARAMS -> lambda {':', affect, ';'}
+ TYPE_SLOT_PARAMS -> LOC_ARG TYPE_SLOT_KEYWORD_PARAM {'(', identifier}
+ TYPE_SLOT_KEYWORD_PARAM -> lambda {':', affect, ';'}
+ TYPE_SLOT_KEYWORD_PARAM -> identifier LOC_ARG TYPE_SLOT_KEYWORD_PARAM {identifier}
+
+ TYPE_SLOT -> "'"operator"'" TYPE_SLOT_PRIORITY TYPE_SLOT_PARAM {"'"}
+ TYPE_SLOT_PRIORITY -> lambda {identifier, ':', affect, ';'}
+ TYPE_SLOT_PRIORITY -> priority TYPE_SLOT_PRIORITY_VALUE {priority}
+ TYPE_SLOT_PRIORITY_VALUE -> lambda {identifier, '(', ':', affect, ';'}
+ TYPE_SLOT_PRIORITY_VALUE -> integer {integer}
+ TYPE_SLOT_PARAM -> lambda {':', affect, ';'}
+ TYPE_SLOT_PARAM -> LOC_ARG
+ ###################################################################-->
+ <context name="type_slot" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <!--on differencie pour les fonctions d'auto_cast, sans params pour to et un seul pour from-->
+ <RegExpr String="to_&identifier;&ws_opt;:" lookAhead="true" context="type_slot_auto_cast_slot" />
+ <RegExpr String="from_&identifier;&ws_oom;&identifier;&ws_opt;:&ws_opt;&approx_type;&ws_opt;:" lookAhead="true" context="type_slot_auto_cast_slot" />
+
+ <RegExpr String="&identifier;" context="type_slot_params" attribute="slot_name" />
+ <RegExpr String="'&operator;'" context="type_slot_priority" attribute="slot_operator" />
+ <RegExpr String="&following_type_slot;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="type_slot_auto_cast_slot" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="to_&identifier;" context="#pop" attribute="exporting_slot_name" /> <!--type_slot fini-->
+ <RegExpr String="from_&identifier;" context="type_slot_params" attribute="importing_slot_name" /> <!--type_slot pas fini, il y a un param-->
+
+ <RegExpr String="&following_type_slot;" lookAhead="true" context="#pop" />
+
+ </context>
+
+ <context name="type_slot_params" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_loc_arg;" lookAhead="true" context="loc_arg" />
+ <!-- ws_opt car on peut avoir ident(LOCAL)-->
+ <!--<RegExpr String="&identifier;(&ws_opt;&start_loc_arg;)" lookAhead="true" context="type_slot_keyword_param" />-->
+ <RegExpr String="&identifier;" lookAhead="true" context="type_slot_keyword_param" />
+ <RegExpr String="&following_type_slot;" lookAhead="true" context="#pop" /> <!--type_slot_params_r1-->
+ </context>
+
+ <context name="type_slot_keyword_param" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="loc_arg" attribute="slot_keyword" />
+ <RegExpr String="&following_type_slot;" lookAhead="true" context="#pop" /> <!--type_slot_keyword_param_r1-->
+ </context>
+
+ <context name="type_slot_priority" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&priority;" context="type_slot_priority_value" attribute="slot_operator_priority" />
+
+ <RegExpr String="&start_loc_arg;" lookAhead="true" context="loc_arg" />
+ <RegExpr String="&following_type_slot;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="type_slot_priority_value" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="(&start_loc_arg;|&following_type_slot;)" lookAhead="true" context="#pop" /><!--type_slot_priority_value_r1-->
+ <RegExpr String="&integer;" context="#pop" attribute="slot_operator_priority_value" />
+ </context>
+
+ <!--#################################################################
+ LOCAL -> {identifier[':'TYPE]','} identifier':'TYPE
+ ___
+ /*l'algorithme donne ca, mais ce n'est pas LL(1) => on utilise une version
+ moins puissante mais LL(1). Son défaut est qu'elle ne detecte pas le cas où
+ le dernier identifiant n'est pas suivi d'un type.
+
+ LOCAL -> LOCAL_PARAMS_LIST identifier LOCAL_PARAM_TYPE {identifier}
+ LOCAL_PARAMS_LIST -> lambda {pas de virgule, utiliser la prise en compte de l'ordre des règles.}
+ LOCAL_PARAMS_LIST -> identifier LOCAL_PARAM_OPTIONAL_TYPE ',' LOCAL_PARAMS_LIST {identifier}
+ LOCAL_PARAM_OPTIONAL_TYPE -> lambda {','}
+ LOCAL_PARAM_OPTIONAL_TYPE -> ':' TYPE {':'}
+ LOCAL_PARAM_TYPE -> ':' TYPE {':'}*/
+ ____ solution implémentée, qui n'a pas le défaut de la version d'au dessus :
+ LOCAL :
+ identifier ":" -> LOCAL_WITH_TYPE (en lookAhead)
+ identifier "," -> LOCAL_FOLLOWING (en lookAhead)
+ LOCAL_WITH_TYPE -> identifier LOCAL_TYPE
+ LOCAL_TYPE -> ':' TYPE LOCAL_FOLLOWING
+ LOCAL_FOLLOWING -> ','LOCAL {','}
+ LOCAL_FOLLOWING -> lambda {identifier, ':', ';', affect}
+ ################################################################# -->
+ <context name="local" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="," lookAhead="true" context="local_parameter" /> <!--pour gerer les remontées qui sont effectuées lors d'analyse de texte de la forme - slot item : TYPE, item1, item2 : TYPE2 -->
+
+ <RegExpr String="&identifier;&ws_oom;&identifier;" lookAhead="true" context="#pop" /> <!--quand on remonte d'un texte du type - slot item : TYPE keyword item2 ... , à la fin de TYPE on ne remonte qu'ici, ce qui, sans la regle précedente, fait que keyword est analysé comme un parametre.-->
+
+ <RegExpr String="&identifier;" context="local_parameter" attribute="declared_variable_name" />
+
+ <RegExpr String="&following_local;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="local_parameter" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <Detect2Chars char=":" char1="=" context="error" />
+ <DetectChar char=":" context="local_with_type" attribute="colon_before_type" />
+ <DetectChar char="," context="#pop" attribute="comma_separating_parameters" />
+ </context>
+
+ <context name="local_with_type" fallthrough="true" fallthroughContext="#pop#pop">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="type" />
+ </context>
+
+ <!--#################################################################
+ TYPE_LIST -> TYPE {',' TYPE}
+ ################################################################# -->
+ <context name="header_type_list" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <StringDetect String="Section" lookAhead="true" context="#pop" />
+ <RegExpr String="&start_type;" lookAhead="true" context="header_type" />
+ <DetectChar char="," context="header_type" attribute="comma_separating_header_types" />
+
+ <RegExpr String="&following_type_list;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="type_list" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+ <!--avant à cause de ", (" possible dans l'import/export de vecteur -->
+ <RegExpr String="&following_type_list;" lookAhead="true" context="#pop" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="type" />
+ <DetectChar char="," context="type" attribute="comma_separating_types" />
+
+ </context>
+
+
+ <!--#################################################################
+ TYPE -> [type] PROTOTYPE
+ ___
+ TYPE -> type PROTOTYPE (type}
+ TYPE -> PROTOTYPE {cap_identifier}
+ ################################################################# -->
+ <context name="header_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+ <StringDetect String="Section" lookAhead="true" context="#pop" />
+ <RegExpr String="&type;" context="header_prototype" attribute="lisaac_keyword" />
+ <RegExpr String="&cap_identifier;" lookAhead="true" context="header_prototype" />
+
+ <RegExpr String="&following_type;" lookAhead="true" context="#pop" />
+ </context>
+ <context name="type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+ <RegExpr String="&type;" context="prototype" attribute="lisaac_keyword" />
+ <RegExpr String="&cap_identifier;" lookAhead="true" context="prototype" />
+
+ <RegExpr String="&following_type;" lookAhead="true" context="#pop" />
+ </context>
+
+ <!--#################################################################
+ PROTOTYPE -> cap_identifier['('TYPE_LIST {identifier TYPE_LIST} ')']
+ ___
+ PROTOTYPE -> cap_identifier GENERIC_TYPE {cap_identifier}
+ GENERIC_TYPE -> lambda {si pas de '('}
+ GENERIC_TYPE -> '['GENERIC_TYPE_LIST']' {'('}
+ GENERIC_TYPE_LIST -> TYPE_LIST GENERIC_TYPE_LIST_FOLLOWING {start_type}
+ GENERIC_TYPE_LIST_FOLLOWING -> lambda {')'}
+ GENERIC_TYPE_LIST_FOLLOWING -> 'identifier TYPE_LIST GENERIC_TYPE_LIST_FOLLOWING {identifier}
+ ################################################################# -->
+ <context name="header_prototype" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <StringDetect String="Section" lookAhead="true" context="#pop" />
+ <RegExpr String="&cap_identifier;" context="#stay" attribute="header_type" />
+ <DetectChar char="(" lookAhead="true" context="header_generic_type" />
+
+ <RegExpr String="&following_prototype;" lookAhead="true" context="#pop" />
+ </context>
+ <context name="prototype" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&cap_identifier;" context="#stay" attribute="type" />
+ <DetectChar char="(" lookAhead="true" context="generic_type" />
+
+ <RegExpr String="&following_prototype;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="header_generic_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="(" context="header_generic_type_list" attribute="header_generic_type_bracket" />
+ <DetectChar char=")" context="#pop" attribute="header_generic_type_bracket" />
+ </context>
+ <context name="generic_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="(" context="generic_type_list" attribute="generic_type_bracket" />
+ <DetectChar char=")" context="#pop" attribute="generic_type_bracket" />
+ </context>
+
+ <context name="header_generic_type_list" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <!--on rajoute following_type_list pour eviter de boucler dans le cas où un truc
+ commencant comme un type mais faisant parti de following_type_list est trouvé avant "]".
+ l'erreur sera trouvée après.-->
+ <RegExpr String="(\)|&following_type_list;)" lookAhead="true" context="#pop" />
+ <RegExpr String="&start_type;" lookAhead="true" context="header_type_list" />
+ <RegExpr String="&identifier;" lookAhead="true" context="generic_type_list_following" />
+
+ <!--attention, ceci n'interdit pas d'avoir [identifier TYPE1...], donc c'est une approximation-->
+ </context>
+ <context name="generic_type_list" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <!--on rajoute following_type_list pour eviter de boucler dans le cas où un truc
+ commencant comme un type mais faisant parti de following_type_list est trouvé avant "]".
+ l'erreur sera trouvée après.-->
+ <RegExpr String="(\)|&following_type_list;)" lookAhead="true" context="#pop" />
+ <RegExpr String="&start_type;" lookAhead="true" context="type_list" />
+ <RegExpr String="&identifier;" lookAhead="true" context="generic_type_list_following" />
+
+ <!--attention, ceci n'interdit pas d'avoir [identifier TYPE1...], donc c'est une approximation-->
+ </context>
+
+ <context name="generic_type_list_following" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char=")" lookAhead="true" context="#pop" />
+ <RegExpr String="&identifier;" context="type_list" attribute="identifier_separating_types" />
+ </context>
+
+
+ <!--#################################################################
+ EXPR -> EXPR_PREFIX ( [affect EXPR] | {operator EXPR_PREFIX})
+ ===>
+ truc considéré :
+ EXPR -> {operator} EXPR_MESSAGE ( [affect EXPR] | {operator {operator} EXPR_MESSAGE})
+ ____
+ EXPR -> EXPR_OPERATORS EXPR_FOLLOWING
+ EXPR_OPERATORS -> lambda {start_expr_message}
+ EXPR_OPERATORS -> operator EXPR_INFIX_OPERATORS {operator}
+ EXPR_FOLLOWING -> EXPR_MESSAGE EXPR_CONTINUE {start_expr_message}
+ EXPR_CONTINUE -> lambda {';', ')', '}'}
+ EXPR_CONTINUE -> affect EXPR {affect}
+ EXPR_CONTINUE -> operator EXPR_OPERATORS EXPR_MESSAGE EXPR_CONTINUE {operator}
+
+ ################################################################# -->
+ <context name="expr" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&operator;" lookAhead="true" context="expr_operators" />
+ <RegExpr String="&start_expr_message;" lookAhead="true" context="expr_following" />
+
+ <RegExpr String="&following_expr;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_operators" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr_message;" lookAhead="true" context="#pop" />
+ <RegExpr String="&operator;" context="#stay" attribute="operator_before_expression" />
+ </context>
+
+ <context name="expr_following" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr_message;" lookAhead="true" context="expr_message" />
+ <RegExpr String="(&operator;|&affect;)" lookAhead="true" context="expr_continue" />
+
+ <RegExpr String="&following_expr;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_continue" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&affect;" context="expr" attribute="affectation" />
+ <RegExpr String="&operator;" lookAhead="true" context="expr_continue_treatment" />
+
+ <RegExpr String="&following_expr;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_continue_treatment" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&bad_operator;" lookAhead="true" context="error" />
+ <RegExpr String="&operator;" context="expr_operators" attribute="operator_between_expressions"/>
+
+ <RegExpr String="&start_expr_message;" lookAhead="true" context="expr_message" />
+
+ <RegExpr String="&following_expr;" lookAhead="true" context="#pop" />
+ </context>
+
+
+ <!--#################################################################
+ EXPR_MESSAGE -> EXPR_BASE{'.'SEND_MSG}
+ ___
+ EXPR_MESSAGE -> EXPR_BASE EXPR_MESSAGE_SLOT_CALL {start_expr_primary}
+ EXPR_MESSAGE_SLOT_CALL -> lambda {operator, ';', '}', ')' }
+ EXPR_MESSAGE_SLOT_CALL -> '.'SEND_MSG EXPR_MESSAGE_SLOT_CALL {'.'}
+
+ ################################################################# -->
+ <context name="expr_message" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr_base;" lookAhead="true" context="expr_base" />
+ <DetectChar char="." lookAhead="true" context="expr_message_slot_call" />
+
+ <RegExpr String="&following_expr_message;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_message_slot_call" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="." context="send_msg" attribute="slot_call_dot" />
+
+ <RegExpr String="&following_expr_message;" lookAhead="true" context="#pop" /><!--&following_expr_message;-->
+ </context>
+
+ <!--#################################################################
+ EXPR_BASE -> EXPR_PRIMARY | SEND_MSG | "Old" EXPR
+ ___
+ EXPR_BASE -> "Old" EXPR_BASE_FOLLOWING
+ EXPR_BASE -> SEND_MSG
+ EXPR_BASE -> EXPR_PRIMARY
+ EXPR_BASE_FOLLOWING -> identifier
+ ################################################################# -->
+ <context name="expr_base" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="Old" context="expr" attribute="lisaac_keyword" />
+ <RegExpr String="&start_send_msg;" lookAhead="true" context="send_msg_implicit" />
+ <!-- mise de expr_primary après à cause des ident qui
+ commencent comme des chiffres hexa -->
+ <RegExpr String="&start_expr_primary;" lookAhead="true" context="expr_primary" />
+ <RegExpr String="&following_expr_base;" lookAhead="true" context="#pop" />
+ </context>
+
+ <!--<context name="expr_base_following" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="#pop" attribute="called_slot_name" />
+ //<RegExpr String="(&operator;|[;)}])" lookAhead="true" context="#pop" />
+ </context>-->
+
+ <!--#################################################################
+ EXPR_PRIMARY -> "Self"
+ EXPR_PRIMARY -> result
+ EXPR_PRIMARY -> integer
+ EXPR_PRIMARY -> characters
+ EXPR_PRIMARY -> string
+ EXPR_PRIMARY -> '('GROUP')'
+ ___
+ pas de changement, les symboles directeurs sont triviaux
+
+ EXPR_PRIMARY -> '{'[LOC_ARG ';'] GROUP'}'
+ ___
+ EXPR_PRIMARY -> '{'EXPR_PRIMARY_BLOCK '}'
+ EXPR_PRIMARY_BLOCK -> LOC_ARG ';' GROUP {start_loc_arg}
+ EXPR_PRIMARY_BLOCK -> GROUP {start_group}
+
+ EXPR_PRIMARY -> PROTOTYPE
+ ___
+ EXPR_PRIMARY -> PROTOTYPE {cap_identifier}
+
+ EXPR_PRIMARY -> external[':'['(']TYPE['{'{TYPE','}TYPE'}'][')']]
+ ___
+ EXPR_PRIMARY -> external EXPR_PRIMARY1 {external}
+ EXPR_PRIMARY_EXTERNAL_CAST -> lambda {'.', operator, ';', '}', ')' }
+ EXPR_PRIMARY_EXTERNAL_CAST -> ':' EXPR_PRIMARY_EXTERNAL_TYPE {':'}
+ EXPR_PRIMARY_EXTERNAL_TYPE -> '(' EXPR_PRIMARY_EXTERNAL_MAIN_TYPE ')' {'('}
+ EXPR_PRIMARY_EXTERNAL_TYPE -> EXPR_PRIMARY_EXTERNAL_MAIN_TYPE {cap_identifier}
+ EXPR_PRIMARY_EXTERNAL_MAIN_TYPE -> TYPE EXPR_PRIMARY_EXTERNAL_SUB_TYPES
+ EXPR_PRIMARY_EXTERNAL_SUB_TYPES -> lambda {')'}
+ EXPR_PRIMARY_EXTERNAL_SUB_TYPES -> '(' TYPE EXPR_PRIMARY_EXTERNAL_OTHER_SUB_TYPES ')' {'('}
+ EXPR_PRIMARY_EXTERNAL_OTHER_SUB_TYPES -> lambda {')'}
+ EXPR_PRIMARY_EXTERNAL_OTHER_SUB_TYPES -> ',' TYPE EXPR_PRIMARY_EXTERNAL_OTHER_SUB_TYPES {','}
+ ################################################################# -->
+
+ <context name="expr_primary" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+ <RegExpr String="Self" context="#pop" attribute="self" />
+ <RegExpr String="&result;" context="#pop" attribute="result" />
+ <RegExpr String="&integer_or_real;" context="#pop" attribute="integer" />
+ <DetectChar char="(" context="expr_primary_parenthesed_group" attribute="parenthesis_surrounding_group" beginRegion="group" />
+ <DetectChar char="{" context="expr_primary_block" attribute="brace_surrounding_group" beginRegion="group" />
+ <DetectChar char=")" context="#pop" attribute="parenthesis_surrounding_group" endRegion="group" />
+ <DetectChar char="}" context="#pop" attribute="brace_surrounding_group" endRegion="group" />
+ <RegExpr String="(&cap_identifier;|&string_start;|&characters_start;|&external_start;)" lookAhead="true" context="expr_primary_not_trivial_context" />
+ </context>
+
+ <context name="expr_primary_not_trivial_context" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&cap_identifier;" lookAhead="true" context="prototype" />
+
+ <RegExpr String="&string_start;" context="expr_primary_string" attribute="string" />
+ <RegExpr String="&characters_start;" context="expr_primary_characters" attribute="characters" />
+ <RegExpr String="&external_start;" context="expr_primary_external" attribute="external" />
+
+ <RegExpr String="&following_expr_primary;" lookAhead="true" context="#pop#pop" />
+ </context>
+
+ <!--les 2 contextes qui suivent sont pour assurer qu'un group commencant par "(" finisse par ")" (resp. "{" et "}")-->
+
+ <context name="expr_primary_parenthesed_group" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char=")" lookAhead="true" context="#pop" />
+ <RegExpr String="&start_group;" lookAhead="true" context="group" />
+ </context>
+
+ <context name="expr_primary_block" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_loc_arg;" lookAhead="true" context="loc_arg" />
+ <DetectChar char=";" context="expr_primary_block_1" attribute="semi_colon_ending_block_local_arg" />
+ <RegExpr String="&start_group;" lookAhead="true" context="group" />
+ <DetectChar char="}" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_primary_block_1" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_group;" lookAhead="true" context="group" />
+ <DetectChar char="}" lookAhead="true" context="#pop" />
+ </context>
+
+
+ <context name="expr_primary_string" attribute="string" fallthrough="true" fallthroughContext="error" lineEndContext="#stay" >
+ <RegExpr String="[\\]"" context="#stay" attribute="string"/>
+ <RegExpr String=""" context="#pop" attribute="string"/>
+ <RegExpr String="(&normal_char;|&escape_char;|'|`)" context="#stay"/>
+ </context>
+
+ <context name="expr_primary_characters" attribute="characters" fallthrough="true" fallthroughContext="error">
+ <RegExpr String="[\\]'" context="#stay" />
+ <RegExpr String="'" context="#pop" attribute="string"/>
+ <RegExpr String="(&normal_char;|&escape_char;|"|`)" context="#stay"/>
+ </context>
+
+ <context name="expr_primary_external" attribute="external" fallthrough="true" fallthroughContext="error" lineEndContext="#stay">
+ <Detect2Chars char="\" char1="`" context="#stay" />
+ <DetectChar char="`" context="expr_primary_external_cast" />
+
+ <RegExpr String="@&identifier;" context="#stay" attribute="c_variable" />
+
+ <RegExpr String="(&normal_char;|&escape_char;|"|'|&ws;)" context="#stay"/>
+ </context>
+
+ <context name="expr_primary_external_cast" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String=":=" context="error" />
+ <RegExpr String="[:]&ws_opt;&start_type;" lookAhead="true" context="expr_primary_external_main_type_dp" />
+ <RegExpr String="[:]&ws_opt;[(]" lookAhead="true" context="expr_primary_external_main_type_parenthesed" />
+ <RegExpr String="(&identifier;|&operator;|[;)}])" lookAhead="true" context="#pop#pop" />
+ </context>
+
+ <context name="expr_primary_external_main_type_dp" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char=":" context="expr_primary_external_main_type" attribute="cast_colon" />
+
+ <RegExpr String="(&identifier;|&operator;|[;)}])" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_primary_external_main_type_parenthesed" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char=":" context="#stay" attribute="cast_colon" />
+
+ <DetectChar char="(" context="expr_primary_external_main_type" attribute="parenthesis_surrounding_cast" />
+
+ <DetectChar char=")" context="#pop" attribute="parenthesis_surrounding_cast" />
+ </context>
+
+ <context name="expr_primary_external_main_type" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_type;(&start_type;|\(|\)|&ws;)*[{]" lookAhead="true" context="expr_primary_external_main_type_with_sub_types" />
+ <RegExpr String="&start_type;" lookAhead="true" context="type" />
+
+ <RegExpr String="(&identifier;|&operator;|[;)}])" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="expr_primary_external_main_type_with_sub_types" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="type" />
+ <DetectChar char="{" context="expr_primary_external_sub_types" attribute="parenthesis_surrounding_cast_subtypes" />
+
+ <DetectChar char="}" context="#pop#pop" attribute="parenthesis_surrounding_cast_subtypes" />
+ </context>
+
+ <context name="expr_primary_external_sub_types" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_type;" lookAhead="true" context="type" />
+ <DetectChar char="," context="#stay" attribute="comma_separating_types" />
+
+ <DetectChar char="}" lookAhead="true" context="#pop" />
+ </context>
+
+
+ <!--#################################################################
+ GROUP -> DEF_LOCAL{EXPR';'}[EXPR{(,({EXPR';'}EXPR}]
+ pour moi il est impossible de reconnaitre avec les outils dispos
+ {EXPR';'}[EXPR{(,({EXPR';'}EXPR}],
+ je peux juste reconnaitre {[EXPR] {','EXPR }[';']}
+ ___
+
+ GROUP -> lambda {')' '}'}
+ GROUP -> DEF_LOCAL GROUP_EXPR {start_def_local}
+ GROUP_EXPR -> EXPR ','|';' GROUP_EXPR
+ GROUP_EXPR -> lambda {')' '}'}
+ ################################################################# -->
+ <context name="group" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_def_local;" lookAhead="true" context="def_local" />
+ <RegExpr String="&start_expr;" lookAhead="true" context="group_expr" />
+
+ <RegExpr String="[)}]" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="group_expr" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String=";" context="#stay" attribute="semi_colon_ending_instruction" />
+ <RegExpr String="&start_expr;" lookAhead="true" context="expr" />
+ <RegExpr String="," context="expr" attribute="comma_ending_returned_expr" />
+
+ <RegExpr String="[)}]" lookAhead="true" context="#pop" />
+ </context>
+
+ <!--#################################################################
+ CONTRACT -> '['DEF_LOCAL {(EXPR';'|"...")}']'
+ ################################################################# -->
+ <context name="contract" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <DetectChar char="[" context="def_local" attribute="bracket_surrounding_contract" />
+ <RegExpr String="(&start_expr;|[.][.][.])" lookAhead="true" context="contract_exprs" />
+
+ <DetectChar char="]" context="#pop" attribute="bracket_surrounding_contract" />
+ </context>
+
+ <context name="contract_exprs" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="[.][.][.]" context="#stay" attribute="contract_ellipsis" />
+ <RegExpr String="&start_expr;" lookAhead="true" context="contract_expr" />
+
+ <DetectChar char="]" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="contract_expr" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr;" lookAhead="true" context="expr" />
+ <DetectChar char=";" context="#pop" attribute="semi_colon_ending_contract_instruction" />
+ </context>
+
+ <!--#################################################################
+ DEF_LOCAL -> { style LOCAL';'}
+ ___
+ DEF_LOCAL -> DEF_LOCAL_FOLLOWING DEF_LOCAL
+ DEF_LOCAL -> lambda
+ DEF_LOCAL_FOLLOWING -> style LOCAL';'
+ ################################################################# -->
+ <context name="def_local" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_def_local;" lookAhead="true" context="def_local_following" />
+
+ <RegExpr String="&following_def_local;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="def_local_following" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&style;" context="local" attribute="local_variable_style" />
+ <DetectChar char=";" context="#pop" attribute="semi_colon_ending_stylized_variable_def" />
+ </context>
+
+ <!--#################################################################
+ SEND_MSG -> identifier[ ARGUMENT{ identifier ARGUMENT}]
+ ___
+ SEND_MSG -> identifier SEND_MSG_ARGS {identifier}
+ SEND_MSG_ARGS -> lambda {'.', operator, ';', '}', ')'}
+ SEND_MSG_ARGS -> ARGUMENT SEND_MSG_ARGS_FOLLOWING {start_argument}
+ SEND_MSG_ARGS_FOLLOWING -> lambda {'.', operator, ';', '}', ')'}
+ SEND_MSG_ARGS_FOLLOWING -> identifier SEND_MSG_ARGS {identifier}
+ ################################################################# -->
+ <context name="send_msg" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <!--<RegExpr String="&identifier;&ws_opt;[({]" lookAhead="true" context="send_msg_with_args" />--> <!--on a le droit de les accoler à l'identifier-->
+ <!--<RegExpr String="&identifier;&ws_oom;&start_argument;" lookAhead="true" context="send_msg_with_args" />
+
+ <RegExpr String="&identifier;" context="#pop" attribute="called_slot_name" /> -->
+ <!--<RegExpr String="&identifier;&ws_opt;&following_send_msg;" lookAhead="true" context="send_msg_only_ident" />-->
+ <!--plutot que faire le choix avec/sans arg au plus tot, comme fait au dessus, on mange directement l'identifier puis ensuite on fait le choix. Ainsi, on a pas besoin de regexp qui pourraient
+ avoir à traiter des données venant de 2 lignes successives (ident\n arg1 typiquement), ce que ne permet pas
+ le moteur de kate -->
+ <RegExpr String="&identifier;" lookAhead="true" context="send_msg_ident" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="send_msg_ident" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="send_msg_switch_param_or_not" attribute="called_slot_name" />
+ </context>
+
+ <context name="send_msg_switch_param_or_not" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="(&identifier;|&start_expr_primary;)" lookAhead="true" context="send_msg_args" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop#pop" />
+ </context>
+
+ <context name="send_msg_with_args" fallthrough="true" fallthroughContext="error">
+ <RegExpr String="&identifier;" context="send_msg_args" attribute="called_slot_name" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="send_msg_args" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="send_msg_args_following" attribute="argument_identifier" />
+ <RegExpr String="&start_expr_primary;" lookAhead="true" context="send_msg_args_following" />
+ </context>
+
+ <context name="send_msg_args_following" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr_primary;" lookAhead="true" context="expr_primary" />
+
+ <RegExpr String="&identifier;" context="#pop" attribute="called_slot_keyword" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop#pop" />
+ </context>
+
+
+
+
+
+
+ <context name="send_msg_implicit" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" lookAhead="true" context="send_msg_implicit_ident" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="send_msg_implicit_ident" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+ <!-- test if there is arguments to the message or not. If not, we call send_msg_implicit_ident_stop,
+ else we call send_msg_implicit_ident_cont. In the case we don't know (because there are
+ comments or new lines between the slot name and the following thing) we guess it is a slot
+ without arguments because it is rare to put extra things between a slot name and its argument
+ but it is more common to put variables (slots without arguments) at the end of a list, with the
+ list ending the following line -->
+
+ <RegExpr String="&identifier;&ws_opt;(&ws;&identifier;|&start_expr_primary;)" context="send_msg_implicit_ident_cont" lookAhead="true" />
+
+ <RegExpr String="&identifier;&ws_opt;(&following_send_msg;)" context="send_msg_implicit_ident_stop" lookAhead="true" />
+
+ <RegExpr String="&identifier;" context="send_msg_implicit_switch_param_or_not" attribute="called_variable_name_implicit"/>
+ </context>
+
+ <context name="send_msg_implicit_ident_stop" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="#pop#pop" attribute="called_variable_name_implicit" />
+ </context>
+
+ <context name="send_msg_implicit_ident_cont" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="send_msg_implicit_switch_param_or_not" attribute="called_slot_name_implicit" />
+ </context>
+
+ <context name="send_msg_implicit_switch_param_or_not" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="(&identifier;|&start_expr_primary;)" lookAhead="true" context="send_msg_implicit_args" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop#pop#pop" />
+ </context>
+
+ <context name="send_msg_implicit_with_args" fallthrough="true" fallthroughContext="error">
+ <RegExpr String="&identifier;" context="send_msg_implicit_args" attribute="called_slot_name_implicit" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop" />
+ </context>
+
+ <context name="send_msg_implicit_args" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&identifier;" context="send_msg_implicit_args_following" attribute="argument_identifier_implicit" />
+ <RegExpr String="&start_expr_primary;" lookAhead="true" context="send_msg_implicit_args_following" />
+ </context>
+
+ <context name="send_msg_implicit_args_following" fallthrough="true" fallthroughContext="error">
+ <IncludeRules context="comments_and_spaces" />
+
+ <RegExpr String="&start_expr_primary;" lookAhead="true" context="expr_primary" />
+
+ <RegExpr String="&identifier;" context="#pop" attribute="called_slot_keyword_implicit" />
+
+ <RegExpr String="&following_send_msg;" lookAhead="true" context="#pop#pop" />
+ </context>
+
+ <!--######################################################-->
+ <context name="comments_and_spaces" fallthrough="true" fallthroughContext="#pop">
+ <!--support des commentaires, et vidage des espaces et autres tabulations-->
+ <IncludeRules context="comments" />
+ <!--<RegExpr String="&ws_oom;" context="#stay" /> -->
+ <DetectSpaces context="#stay" />
+ </context>
+
+ <context name="comments" fallthrough="true" fallthroughContext="#pop">
+ <!--support des commentaires-->
+ <RegExpr String="/[*]" context="comment" attribute="comment" beginRegion="multiline_comment" />
+ <RegExpr String="//.*" context="#stay" attribute="comment" />
+ </context>
+
+ <context name="error" attribute="error">
+ <RegExpr String="." context="#pop" attribute="error" /> <!-- try to recover, thanks mildred for this clever tip !! -->
+ <!--<RegExpr String="." context="#stay" />-->
+ </context>
+
+ <!--############################################################-->
+ <!--le contexte pour les commentaires multi-lignes -->
+ <context name="comment" attribute="comment" fallthrough="true" fallthroughContext="#pop">
+ <RegExpr String="[*]/" context="#pop" attribute="comment" endRegion="multiline_comment" />
+ <!--evalué que si la 1ere ne marche pas.-->
+ <RegExpr String="." context="#stay" />
+ </context>
+ </contexts>
+
+
+ <itemDatas>
+
+ <itemData name="Normal" defStyleNum="dsNormal" />
+
+ <itemData name="section_declaration" defStyleNum="dsNormal" color="darkmagenta" underline="1" />
+ <itemData name="section_name" defStyleNum="dsNormal" color="darkmagenta" bold="1" underline="1" />
+ <itemData name="inherit_section_name" defStyleNum="dsNormal" color="darkred" bold="1" underline="1"/>
+ <itemData name="header_section_name" defStyleNum="dsNormal" color="darkred" bold="1" underline="1"/>
+
+ <itemData name="prototype_name_slot" defStyleNum="dsNormal" color="blue" bold="1" underline="1" />
+ <itemData name="inherit_slot_name" defStyleNum="dsNormal" color="red" bold="1" />
+ <itemData name="slot_name" defStyleNum="dsNormal" color="blue" bold="1" />
+ <itemData name="slot_keyword" defStyleNum="dsNormal" color="blue" />
+ <itemData name="slot_operator" defStyleNum="dsNormal" color="magenta" bold="1" />
+ <itemData name="slot_operator_priority" defStyleNum="dsNormal" color="red" italic="1" />
+ <itemData name="slot_operator_priority_value" defStyleNum="dsNormal" color="blue" />
+ <itemData name="declared_variable_name" defStyleNum="dsNormal" color="darkmagenta" bold="1" />
+
+
+ <itemData name="slot_style" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+
+ <itemData name="local_variable_style" defStyleNum="&punctuation_style;" color="darkgray" bold="&punctuation_bold;" />
+ <itemData name="slot_affectation" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+
+ <itemData name="imported_types_arrow" defStyleNum="&punctuation_style;" color="&import_related_item_color;" bold="&punctuation_bold;" />
+ <itemData name="importing_slot_name" defStyleNum="&punctuation_style;" color="&import_related_item_color;" bold="&punctuation_bold;" />
+
+ <itemData name="exported_types_arrow" defStyleNum="&punctuation_style;" color="&export_related_item_color;" bold="&punctuation_bold;" />
+ <itemData name="exporting_slot_name" defStyleNum="&punctuation_style;" color="&export_related_item_color;" bold="&punctuation_bold;" />
+
+
+ <itemData name="colon_before_type" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="colon_before_return_type" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" underline="1" />
+ <itemData name="cast_colon" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="comma_separating_arguments" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="comma_separating_parameters" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="comma_separating_types" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="comma_separating_header_types" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" underline="1" />
+ <itemData name="comma_ending_returned_expr" defStyleNum="&punctuation_style;" color="red" bold="&punctuation_bold;" />
+ <itemData name="semi_colon_ending_instruction" defStyleNum="&punctuation_style;" color="red" bold="&punctuation_bold;" />
+ <itemData name="semi_colon_ending_local_variable_def" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" underline="1" />
+ <itemData name="semi_colon_ending_slot" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" underline="1" />
+ <itemData name="semi_colon_ending_stylized_variable_def" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="semi_colon_ending_block_local_arg" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="semi_colon_ending_program_contract" defStyleNum="&punctuation_style;" color="red" bold="&punctuation_bold;" />
+ <itemData name="semi_colon_ending_contract_instruction" defStyleNum="&punctuation_style;" color="red" bold="&punctuation_bold;" />
+ <itemData name="slot_call_dot" defStyleNum="&punctuation_style;" color="red" bold="&punctuation_bold;" />
+ <itemData name="contract_ellipsis" defStyleNum="&punctuation_style;" color="red" bold="&punctuation_bold;" />
+ <itemData name="parenthesis_surrounding_cast" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="0" />
+ <itemData name="parenthesis_surrounding_cast_subtypes" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="0" />
+ <itemData name="parenthesis_surrounding_group" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="brace_surrounding_group" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="generic_type_bracket" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="header_generic_type_bracket" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" underline="1" />
+ <itemData name="parenthesis_enclosing_infix_params" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="parenthesis_enclosing_returned_types" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+ <itemData name="parenthesis_enclosing_local_arguments" defStyleNum="&punctuation_style;" color="&punctuation_color;" bold="&punctuation_bold;" />
+
+
+
+ <itemData name="operator_before_expression" defStyleNum="dsNormal" color="darkorange" />
+ <itemData name="operator_between_expressions" defStyleNum="dsNormal" color="darkmagenta" />
+ <itemData name="affectation" defStyleNum="dsNormal" color="darkmagenta" bold="1" />
+ <itemData name="self" defStyleNum="dsNormal" color="darkgreen" bold="1" />
+ <itemData name="result" defStyleNum="dsDecVal" />
+ <itemData name="string" defStyleNum="dsString" />
+ <itemData name="characters" defStyleNum="dsChar" />
+ <itemData name="integer" defStyleNum="dsDecVal" />
+ <itemData name="external" defStyleNum="dsString" color="darkred" />
+ <itemData name="type" defStyleNum="dsNormal" color="darkgreen" bold="1" />
+ <itemData name="header_type" defStyleNum="dsNormal" color="darkgreen" bold="1" underline="1" />
+
+ <itemData name="lisaac_keyword" defStyleNum="dsNormal" />
+
+ <itemData name="caller_identifier" defStyleNum="dsNormal" color="#0000C0" />
+ <itemData name="called_slot_name" defStyleNum="dsNormal" color="#0000C0" />
+ <itemData name="called_slot_name_implicit" defStyleNum="dsNormal" color="#0000C0" />
+ <itemData name="called_slot_variable_name_implicit" defStyleNum="dsNormal" color="black" italic="1" />
+ <itemData name="called_slot_keyword" defStyleNum="dsNormal" color="#0000C0" />
+ <itemData name="called_slot_keyword_implicit" defStyleNum="dsNormal" color="#0000C0" />
+ <itemData name="identifier_separating_types" defStyleNum="dsNormal" color="black" italic="1" />
+ <itemData name="argument_identifier" defStyleNum="dsNormal" color="black" italic="1" />
+ <itemData name="argument_identifier_implicit" defStyleNum="dsNormal" color="black" italic="1" />
+ <itemData name="c_variable" defStyleNum="dsNormal" color="blue" bold="1" />
+
+ <itemData name="comment" defStyleNum="dsComment" color="darkgreen" italic="1" />
+ <itemData name="error" defStyleNum="dsString" color="red" backgroundColor="grey" />
+ </itemDatas>
+ </highlighting>
+ <general>
+ <comments>
+ <!--<comment name="singleLine" start="//" />
+ <comment name="multiLine" start="/*" end="*/" />-->
+ </comments>
+ <keywords casesensitive="1" additionalDeliminator="`"/>
+ </general>
+</language>
\ No newline at end of file
diff --git a/editor/vim/indent/lisaac.vim b/editor/vim/indent/lisaac.vim
new file mode 100644
index 0000000..c5c46c6
--- /dev/null
+++ b/editor/vim/indent/lisaac.vim
@@ -0,0 +1,145 @@
+" Vim indent file
+" Language: Lisaac
+" Maintainer: Xavier Oswald <xoswald at debian.org>
+" Contributors: Matthieu Herrmann <matthieu.herrmann at laposte.net>
+" $Date: 2009/05/19 21:33:52
+" $Revision: 1.0
+" URL: http://isaacproject.u-strasbg.fr/
+
+" TODO:
+" - Improve string indent and if there are {, ( .... inside
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetLisaacIndent()
+setlocal indentkeys+==Section,0),0},O]
+setlocal nolisp " no lisp indent
+setlocal nosmartindent " no start tab
+setlocal nocindent " no C indent
+setlocal nosmarttab " no start tab
+setlocal expandtab " no tabs, real spaces
+setlocal autoindent " Use indent from the previous line
+setlocal tabstop=2 " tab spacing
+setlocal softtabstop=2 " 2 spaces when pressing <tab> unify
+setlocal shiftwidth=2 " unify
+
+
+" Only define the function once.
+if exists("*GetLisaacIndent")
+ finish
+endif
+
+function GetLisaacIndent()
+
+ let lnum = prevnonblank(v:lnum - 1)
+ let ind = indent(lnum)
+ let line = getline(lnum)
+ let linec = getline(v:lnum)
+ let pline = getline(pnum)
+
+ " At the start of the file use zero indent.
+" if lnum == 0
+" return 0
+" endif
+
+ """""""""""""""""
+ " NO INDENT "
+ """""""""""""""""
+
+ " Whole line String
+ if linec =~ '^.\s*\\.*\\\s*$' || linec =~ '^\s*\\.*\"'
+ return ind
+ endif
+
+ " && and ||
+ if line =~ '^.*&&\s*$' || line =~ '^.*||\s*$' "|| line =~ '^\s*{.*}.*'
+ return ind
+ endif
+
+
+ """""""""""""""""
+ " INDENT PART "
+ """""""""""""""""
+
+ if line =~ '^.*($'
+ let ind = ind + &sw
+ return ind
+ endif
+
+ " Add a 'shiftwidth' after lines that start with a Section word
+ if line =~ '^\s*Section'
+ let ind = ind + &sw
+ return ind
+ endif
+
+ " Add a 'shiftwidth' after a "(" and no ")" and not in a string
+ if line =~ '^.*(' && line !~ '^.*(.*).*' && line !~ '^.*\".*(.*\".*'
+ let ind = ind + &sw
+ return ind
+ endif
+
+ " Add a 'shiftwidth' after a "{" and no "}" and not in a string
+ " .....{ OR ......{ code;
+ " No invariant (contract)
+ if line =~ '^.*{\s*$' || line =~'^.*{.*' && line !~ '^.*\".*{.*\".*' && line !~ '^.*\\.*{.*\".*' && line !~ '^.*?\s*{' && line !~ '^\s*{.*}.*'
+ let ind = ind + &sw
+ return ind
+ endif
+
+ " Add a 'shiftwidth' after a "[" and no "]" and not in a string
+ if line =~ '^.\s[' && line !~ '^.*\[ .* \].*'
+ let ind = ind + &sw
+ return ind
+ endif
+
+ """""""""""""""""
+ " UNINDENT PART "
+ """""""""""""""""
+
+ " Unindent end block and end string
+ if linec =~ '^\s*};\s*$'
+ let ind = ind - &sw
+ return ind
+ endif
+ if linec =~ '^\s*);\s*$' || linec =~ '^\s*).*'
+ let ind = ind - &sw
+ return ind
+ endif
+
+ " Unindent Sections :
+ if linec =~ '^\s*Section'
+ let ind = ind - &sw
+ return 0
+ endif
+
+ " Unindent for ")" and not in a string
+ if linec =~ '^.*)' && linec !~ '^.*(.*).*' && linec !~ '^.*\".*).*\".*'
+ let ind = ind - &sw
+ return ind
+ endif
+
+ " Unindent for "}" and not in a sting
+ "if linec =~ '^.*}.*' && linec !~ '^.*{.*}.*'
+ if linec =~ '^.*}.*' && linec !~ '^.*{.*' && linec !~ '^.*\".*}.*\".*'
+ let ind = ind - &sw
+ return ind
+ endif
+ if linec =~ '^\s*}.*'
+ let ind = ind - &sw
+ return ind
+ endif
+
+ " Unindent for "]" and not in a string
+ if linec =~ '^\s*]' && linec !~ '^.*\[ .* \] .*'
+ let ind = ind - &sw
+ return ind
+ endif
+
+return ind
+
+endfunction
+" vim:sw=2
diff --git a/editor/vim/install_vim_plugin.sh b/editor/vim/install_vim_plugin.sh
new file mode 100644
index 0000000..b905361
--- /dev/null
+++ b/editor/vim/install_vim_plugin.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# +====================================================+
+# | Vim plugin installation script for Lisaac |
+# +====================================================+
+# | |
+# | This script will: |
+# | ----------------- |
+# | - add the lisaac.vim syntax file in your |
+# | ~/.vim/syntax/ |
+# | - add the lisaac.vim indent file in your |
+# | ~/.vim/indent/ |
+# | - add the detection if you edit an *.li file in |
+# | your ~/.vimrc |
+# | |
+# | (c) 2007 by Xavier Oswald, all right reserved |
+# | Licence GPL version 2 or later |
+# +====================================================+
+
+echo
+echo "+=================================================+"
+echo "| Vim plugin installation script for Lisaac |"
+echo "+=================================================+"
+echo
+echo -n "-> Are you sure you want to install this plugin ?(y/n)"
+read result
+echo
+
+if [ "$result" = "y" ]; then
+
+ echo "-> Copying lisaac.vim syntax file in your ~/.vim/syntax/ : OK"
+ mkdir -p ~/.vim/syntax/
+ cp -f syntax/lisaac.vim ~/.vim/syntax/
+
+ echo "-> Copying lisaac.vim indent file in your ~/.vim/indent/ : OK"
+ mkdir -p ~/.vim/indent/
+ cp -f indent/lisaac.vim ~/.vim/indent/
+
+ echo
+
+ echo -n "-> Do you want to install the default config provided by lisaac installer?(y/n)"
+ read result
+ if [ "$result" = "y" ]; then
+ echo "-> Copying the default vim config file in your ~/.vimrc : OK"
+ cp -f vimrc ~/.vimrc
+ else
+ if [ ! -f ~/.vimrc ]; then
+ touch ~/.vimr
+ fi
+ echo "syntax on" >> ~/.vimrc
+ echo "filetype plugin on" >> ~/.vimrc
+ echo "filetype indent on" >> ~/.vimrc
+ echo "au BufNewFile,BufRead *.li setf lisaac" >> ~/.vimrc
+ echo "-> Modification of your ~/.vimrc to support *.li files : OK"
+ fi
+ echo
+ echo "-> Installation finished : OK"
+else
+ echo "-> Installation of the vim plugin aborted..."
+fi
diff --git a/editor/vim/jptemplate/lisaac/do_while b/editor/vim/jptemplate/lisaac/do_while
new file mode 100644
index 0000000..a5ba3ce
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/do_while
@@ -0,0 +1,3 @@
+{
+ ${cursor}
+}.do_while {${test expression}};
diff --git a/editor/vim/jptemplate/lisaac/for b/editor/vim/jptemplate/lisaac/for
new file mode 100644
index 0000000..9dfcf4b
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/for
@@ -0,0 +1,3 @@
+${initializer expression:0}.to (${loop test expression}) do { ${iterator:i}:INTEGER;
+ ${cursor}
+};
diff --git a/editor/vim/jptemplate/lisaac/for_step b/editor/vim/jptemplate/lisaac/for_step
new file mode 100644
index 0000000..eadea7a
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/for_step
@@ -0,0 +1,3 @@
+${initializer expression:0}.to (${loop test expression}) by(${step}) do { ${iterator:i}:INTEGER;
+ ${cursor}
+};
diff --git a/editor/vim/jptemplate/lisaac/if b/editor/vim/jptemplate/lisaac/if
new file mode 100644
index 0000000..f05210d
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/if
@@ -0,0 +1,3 @@
+(${test expression}).if {
+ ${cursor}
+};
diff --git a/editor/vim/jptemplate/lisaac/if_else b/editor/vim/jptemplate/lisaac/if_else
new file mode 100644
index 0000000..3660a1a
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/if_else
@@ -0,0 +1,5 @@
+(${test expression}).if {
+ ${cursor}
+} else {
+
+};
diff --git a/editor/vim/jptemplate/lisaac/if_elseif b/editor/vim/jptemplate/lisaac/if_elseif
new file mode 100644
index 0000000..b0d7a48
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/if_elseif
@@ -0,0 +1,5 @@
+(${test expression1}).if {
+ ${cursor}
+}.elseif {${test expression2}} then {
+
+};
diff --git a/editor/vim/jptemplate/lisaac/while_do b/editor/vim/jptemplate/lisaac/while_do
new file mode 100644
index 0000000..7edb921
--- /dev/null
+++ b/editor/vim/jptemplate/lisaac/while_do
@@ -0,0 +1,3 @@
+{${test expression}}.while_do {
+ ${cursor}
+};
diff --git a/editor/vim/plugin/jptemplate.vim b/editor/vim/plugin/jptemplate.vim
new file mode 100644
index 0000000..9833ab2
--- /dev/null
+++ b/editor/vim/plugin/jptemplate.vim
@@ -0,0 +1,369 @@
+" jptemplate.vim:
+"
+" A simple yet powerful interactive templating system for VIM.
+"
+" Version 1.5 (released 2008-07-08).
+"
+" Copyright (c) 2008 Jannis Pohlmann <jannis at xfce.org>.
+"
+" This program is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 2 of the License, or (at
+" your option) any later version.
+"
+" This program is distributed in the hope that it will be useful, but
+" WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+" General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this program; if not, write to the Free Software
+" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+" MA 02111-1307 USA
+
+
+" Reserved variable names
+let s:reservedVariables = ['date','shell','interactive_shell']
+
+" Variable value history
+let s:rememberedValues = {}
+
+" Characters to be escaped before the substitute() call
+let s:escapeCharacters = '&~\'
+
+
+function! jp:Initialize ()
+
+ " List for default configuration
+ let defaults = []
+
+ " Default configuration values
+ call add (defaults, ['g:jpTemplateDir', $HOME . '/.vim/jptemplate'])
+ call add (defaults, ['g:jpTemplateKey', '<C-Tab>'])
+ call add (defaults, ['g:jpTemplateDateFormat', '%Y-%m-%d'])
+ call add (defaults, ['g:jpTemplateDefaults', {}])
+ call add (defaults, ['g:jpTemplateVerbose', 0])
+
+ " Set default configuration for non-existent variables
+ for var in filter (defaults, '!exists (v:val[0])')
+ exec 'let ' . var[0] . ' = ' . string (var[1])
+ endfor
+
+endfunction
+
+
+function! jp:GetTemplateInfo ()
+
+ " Prepare info dictionary
+ let info = {}
+
+ " Get part of the line before the cursor
+ let part = getline ('.')[0 : getpos ('.')[2]-1]
+
+ " Get start and end position of the template name
+ let info['start'] = match (part, '\(\w*\)$')
+ let info['end'] = matchend (part, '\(\w*\)$')
+
+ " Get template name
+ let info['name'] = part[info['start'] : info['end']]
+
+ " Throw exception if no template name could be found
+ if empty (info['name'])
+ throw 'No template name found at cursor'
+ endif
+
+ " Determine directory to load the template from (skip empty directories;
+ " each directory may override the ones before)
+ for dir in filter ([ 'general', &ft ], '!empty (v:val)')
+ let filename = g:jpTemplateDir .'/'. dir .'/'. info['name']
+ if filereadable (filename)
+ let info['filename'] = filename
+ endif
+ endfor
+
+ " Throw exception if the template file does not exist in any of these
+ " directories (or is not readable)
+ if !has_key (info, 'filename')
+ throw 'Template file not found'
+ endif
+
+ " Determine indentation
+ let info['indent'] = matchstr (part, '^\s\+')
+
+ " Return template name information
+ return info
+
+endfunction
+
+
+function! jp:ReadTemplate (name, filename)
+
+ " Try to read the template file and throw exception if that fails
+ try
+ return readfile (a:filename)
+ catch
+ throw 'Template "' . a:name . '" could not be found.'
+ endtry
+
+endfunction
+
+
+function! jp:UpdateCursorPosition (lines, endColumn)
+
+ " Define cursorPosition as the column to which the cursor is moved
+ let cursorPosition = -1
+
+ for cnt in range (0, a:lines)
+ " Search for ${cursor} in the current line
+ let str = getline (line ('.') + cnt)
+ let start = match (str, '${cursor}')
+ let end = matchend (str, '${cursor}')
+ let before = strpart (str, 0, start)
+ let after = strpart (str, end)
+
+ if start >= 0
+ " Remove ${cursor} and move the cursor to the desired position
+ call setline (line ('.') + cnt, before . after)
+ call cursor (line ('.') + cnt, start+1)
+
+ let cursorPosition = start
+
+ " We're done
+ break
+ endif
+ endfor
+
+ " Update cursor position in case no ${cursor} was found in the template
+ " and the resulting template was not empty
+ if cursorPosition == -1 && a:lines >= 0
+ if a:lines == 0
+ call cursor (line ('.'), a:endColumn + 1)
+ else
+ call cursor (line ('.') + a:lines, a:endColumn + 1)
+ endif
+ endif
+
+ " Return to insert mode (distinguish between 'in the middle of the line' and
+ " 'at the end of the line')
+ if col ('.') == len (getline ('.'))
+ startinsert!
+ else
+ startinsert
+ endif
+
+endfunction
+
+
+function! jp:ParseExpression (expr)
+
+ " Determine position of the separator between name and value
+ let valuepos = match (a:expr, ':')
+
+ " Extract name and value strings
+ let name = valuepos >= 0 ? strpart (a:expr, 0, valuepos) : a:expr
+ let value = valuepos >= 0 ? strpart (a:expr, valuepos + 1) : ''
+
+ " Return list with both strings
+ return [name, value]
+
+endfunction
+
+
+function! jp:EvaluateReservedVariable (name, value, variables)
+
+ let result = ''
+
+ if a:name == 'date'
+ let result = strftime (empty (a:value) ? g:jpTemplateDateFormat : a:value)
+ elseif a:name == 'shell'
+ if !empty (a:value)
+ let result = system (a:value)
+ endif
+ elseif a:name == 'interactive_shell'
+ let command = input ('interactive_shell: ', a:value)
+ if !empty (command)
+ let result = system (command)
+ endif
+ endif
+
+ return result
+
+endfunction
+
+
+function! jp:ExpandTemplate (info, template)
+
+ " Backup content before and after the template name
+ let before = strpart (getline ('.'), 0, a:info['start'])
+ let after = strpart (getline ('.'), a:info['end'])
+
+ " Merge lines of the template and then split them up again.
+ " This makes multi-line variable values possible
+ let mergedTemplate = split (join (a:template, "\n"), "\n")
+
+ " Define cnt as the number of inserted lines
+ let cnt = 0
+
+ " Remove template string if the resulting template is empty
+ if empty (mergedTemplate)
+ call setline (line ('.'), before . after)
+ call cursor (line ('.'), len (before) + 1)
+ let cnt = -1
+ else
+ " Insert template between before and after
+ for cnt in range (0, len (mergedTemplate) - 1)
+ if cnt == 0
+ call setline (line ('.'), before . mergedTemplate[cnt])
+ else
+ call append (line ('.') + cnt - 1, a:info['indent'] . mergedTemplate[cnt])
+ endif
+ if cnt == len (mergedTemplate) - 1
+ call setline (line ('.') + cnt, getline (line ('.') + cnt) . after)
+ endif
+ endfor
+ endif
+
+ " Define start and end columns of the template
+ let startColumn = len (before)
+ if empty (mergedTemplate)
+ let endColumn = startColumn
+ else
+ if cnt == 0
+ let endColumn = startColumn + len (mergedTemplate[0])
+ else
+ let endColumn = len (a:info['indent'] . mergedTemplate[len (mergedTemplate) - 1])
+ endif
+ endif
+
+ " Return number of inserted lines, start and end columns
+ return [cnt, startColumn, endColumn]
+
+endfunction
+
+
+function! jp:ProcessTemplate (info, template)
+
+ let matchpos = 0
+ let expressions = []
+ let variables = {}
+ let reserved = {}
+
+ " Make a string out of the template lines
+ let s:str = join (a:template, ' ')
+
+ " Detect all variable names of the template
+ while 1
+ " Find next variable start and end position
+ let start = match (s:str, '${[^{}]\+}', matchpos)
+ let end = matchend (s:str, '${[^{}]\+}', matchpos)
+
+ if start < 0
+ " Stop search if there is no variable left
+ break
+ else
+ " Extract variable expression (remove '${' and '}')
+ let expr = s:str[start+2 : end-2]
+
+ " Extract variable name and default value */
+ let [name, value] = jp:ParseExpression (expr)
+
+ if name == 'cursor'
+ " Skip the ${cursor} variable
+ elseif count (s:reservedVariables, name) > 0
+ let reserved[expr] = ''
+ else
+ " Only insert variables on their first appearance
+ if !has_key (variables, name)
+ " Add expression to the expression list
+ call add (expressions, expr)
+
+ " Set variable value to ''
+ let variables[name] = ''
+ endif
+
+ " Check whether local default value is defined or not
+ if empty (value)
+ " If not, check if variable value is empty
+ if empty (variables[name])
+ " If so, either set it to the last remembered value or the global
+ " default if it exists
+ if has_key (s:rememberedValues, name)
+ let variables[name] = s:rememberedValues[name]
+ elseif has_key (g:jpTemplateDefaults, name)
+ let variables[name] = g:jpTemplateDefaults[name]
+ endif
+ endif
+ else
+ " Use local default (first occurence in the template only)
+ let variables[name] = value
+ endif
+ endif
+
+ " Start next search at the end position of this expression
+ let matchpos = end
+ endif
+ endwhile
+
+ " Ask the user to enter values for all variables
+ for expr in expressions
+ let [name, value] = jp:ParseExpression (expr)
+ let variables[name] = input (name . ': ', variables[name])
+ let s:rememberedValues[name] = variables[name]
+ endfor
+
+ " Evaluate reserved variables
+ for expr in keys (reserved)
+ let [name, value] = jp:ParseExpression (expr)
+ let replacement = jp:EvaluateReservedVariable (name, value, variables)
+ let reserved[expr] = replacement
+ endfor
+
+ " Expand all variables (custom and reserved)
+ for index in range (len (a:template))
+ for expr in expressions
+ let [name, value] = jp:ParseExpression (expr)
+ let expr = '${' . name . '\(:[^{}]\+\)\?}'
+ let value = escape(variables[name], s:escapeCharacters)
+ let a:template[index] = substitute (a:template[index], expr, value, 'g')
+ endfor
+
+ for [expr, value] in items (reserved)
+ let expr = '${' . expr . '}'
+ let value = escape(value, s:escapeCharacters)
+ let a:template[index] = substitute (a:template[index], expr, value, 'g')
+ endfor
+ endfor
+
+ " Insert template into the code line by line
+ let [insertedLines, startColumn, endColumn] = jp:ExpandTemplate (a:info, a:template)
+
+ " Update the cursor position and return to insert mode
+ call jp:UpdateCursorPosition (insertedLines, endColumn)
+
+endfunction
+
+
+function! jp:InsertTemplate ()
+
+ try
+ " Detect bounds of the template name as well as the name itself
+ let info = jp:GetTemplateInfo ()
+
+ " Load the template file
+ let template = jp:ReadTemplate (info['name'], info['filename'])
+
+ " Do the hard work: Process the template
+ call jp:ProcessTemplate (info, template)
+ catch
+ " Inform the user about errors
+ echo g:jpTemplateVerbose ? v:exception . " (in " . v:throwpoint . ")" : v:exception
+ endtry
+
+endfunction
+
+
+" Initialize jptemplate configuration
+call jp:Initialize ()
+
+" Map keyboard shortcut to the template system
+exec 'imap ' . g:jpTemplateKey . ' <Esc>:call jp:InsertTemplate()<CR>'
diff --git a/editor/vim/syntax/lisaac.vim b/editor/vim/syntax/lisaac.vim
new file mode 100644
index 0000000..94edaf5
--- /dev/null
+++ b/editor/vim/syntax/lisaac.vim
@@ -0,0 +1,119 @@
+" Vim syntax file
+" Language: Lisaac
+" Maintainer: Xavier Oswald <xoswald at debian.org>
+" URL: http://isaacproject.u-strasbg.fr/
+" Last Change: 2008 November 06
+" Filenames: *.li
+
+" Quit when a syntax file was already loaded
+if !exists("main_syntax")
+ if version < 600
+ syntax clear
+ elseif exists("b:current_syntax")
+ finish
+ endif
+ " we define it here so that included files can test for it
+ let main_syntax='li'
+endif
+
+
+" keyword definitions
+" ===================
+syn keyword liFunction while while_do if else when elseif then self by to do or downto if_true if_false shrink
+syn keyword liKey Parallel Section Header Insert Inherit Public Private Mapping Interrupt Right Left Self Old Expanded Strict
+syn keyword liSpecial TODO FIXME DEBUG NOTE not_yet_implemented die_with_code BSBS XOXO JBJB
+
+" Support for String and Char
+" ===========================
+syn match liStringSpecial "^\s*\\"
+syn match liStringSpecial "\\$"
+syn match liStringSpecial "\\."
+syn region liString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=liStringSpecial
+
+" Operators
+" =========
+syn match liOperatorAffect "<-\|:=\|?=\|->"
+syn match liOperatorCmp "<\|>\|*\|/=\|=\|&&\||\|!\|?\|-?\|+?"
+syn match liOperator "+\|-\|*\|/"
+
+" Quoted expression
+" =================
+syn match liExternalExpr "`[^`\n]*`"
+syn region liQuotedExpr start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=liStringSpecial
+
+" Others
+" ======
+syn match liPrototype "[A-Z][A-Z0-9_]*"
+syn match liKey "Result\(_[0-9]*\)\="
+syn match liSlot "^\(\s\|\t\|[(]\)*\(+\|-\)\D"
+syn match liBlock "{\|}"
+syn match liElement "\(\[\|\]\)"
+syn match liSymbolDeclaration "(\|)"
+syn match liContrat "^\(\s\|\t\)*\[\(\s\|\t\)*\(\.\.\.\)\=\|\]"
+syn match liFunction "\.\w*"
+syn keyword liBoolean TRUE FALSE BOOLEAN
+
+" Support for decimal, real, binary, Hexadecimal and octal numbers
+" ================================================================
+" hexa
+syn match liNumberHexa "\<\(\d\|[ABCDEF]\)\(_\|\d\|[ABCDEF]\)*[hH]\=\>"
+
+" binary
+syn match liNumberBinary "\<[01]\(\(_\|[01]*\)[01]\)*[bB]\=\>"
+
+" decimal, binary, octal
+syn match liNumberDecimal "\<\d\(\(_\|\d*\)\d\)*[dDbBoO]\=\>"
+
+" real
+syn match liNumberFloat "\<\d\(\(_\|\d*\)\d\)*\.\d*\(E-\=\)\=\(\(_\|\d*\)\d\)*[fF]\=\>"
+
+" Comments
+" ========
+syn region liLinesComment start="/\*" end="\*/" contains=liSpecial
+syn match liQuotedExprInComment contained "`[^']*'"
+syn match liHiddenComment "//.*" contains=liQuotedExprInComment,liSpecial
+
+" The default highlighting Coloration
+" ===================================
+if version >= 508 || !exists("did_li_syn_inits")
+ if version < 508
+ let did_li_syn_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+ HiLink liNumberHexa Number
+ HiLink liNumberDecimal Number
+ HiLink liNumberBinary Number
+ HiLink liNumberFloat Float
+ HiLink liFunction Function
+ HiLink liBoolean Type
+ HiLink liKey Label
+ HiLink liString String
+ HiLink liStringSpecial SpecialChar
+ HiLink liSpecial Todo
+ HiLink liOperatorAffect Delimiter
+ HiLink liOperatorCmp Delimiter
+ HiLink liOperator Delimiter
+ HiLink liExternalExpr Define
+ HiLink liQuotedExpr Special
+ HiLink liPrototype Type
+ HiLink liSlot Keyword
+ HiLink liBlock Conditional
+ HiLink liElement keyword
+ HiLink liSymbolDeclaration Keyword
+ HiLink liContrat keyword
+ HiLink liNumber Number
+ HiLink liLinesComment Comment
+ HiLink liHiddenComment Comment
+ HiLink liQuotedExprInComment SpecialChar
+ delcommand HiLink
+endif
+
+let b:current_syntax = "li"
+
+if main_syntax == 'li'
+ unlet main_syntax
+endif
+
+" vim: ts=8
diff --git a/editor/vim/vimrc b/editor/vim/vimrc
new file mode 100644
index 0000000..90d7e64
--- /dev/null
+++ b/editor/vim/vimrc
@@ -0,0 +1,96 @@
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" DEFAULT ~/.vimrc by Xavier Oswald (x.oswald at free.fr) "
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" General
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set cf " enable error files and error jumping
+set nocompatible " Use Vim settings, rather then Vi settings (much better!).
+set autowrite " Automatically save before :next, :make etc.
+set history=50 " 50 commands in the history
+set viminfo='20,\"50 " read/write a .viminfo file, don't store more than 50
+filetype plugin on " load filetype plugins
+filetype indent on " load filetype indents
+filetype on " detect the type of file
+set backspace=indent,eol,start " more powerful backspacing
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Theme/Colors
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+syntax on " active coloration
+set background=light " default background
+colorscheme default " default coloration theme
+"NOTE: nice theme is 'colorsheme elflord' if you have a dark background
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Files/Backups
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set backup " make backup file
+set backupdir=~/.vim/backup/ " where to put backup file
+set directory=~/.vim/temp " directory is the directory for temp file
+set makeef=error.err " When using make, where should it dump the file
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" GVim UI
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Vim UI
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set ruler " show the cursor position all the time
+set cmdheight=2 " the command bar is 2 high
+set hid " you can change buffer without saving
+set backspace=2 " make backspace work normal
+set report=0 " tell us when anything is changed via :...
+set noerrorbells " don't make noise
+set ignorecase " ignore case for searching
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Visual Cues
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set showmatch " show matching brackets
+set mat=5 " how many tenths of a second to blink matching brackets for
+set nohlsearch " do not highlight searched for phrases
+set incsearch " BUT do highlight as you type you search phrase
+set so=10 " Keep 10 lines (top/bottom) for scope
+set novisualbell " don't blink
+set noerrorbells " no noise
+set laststatus=2 " always show the status line
+set showcmd " display incomplete commands
+set modeline " display the current mode
+set nostartofline " keep the cursor in the same colon when changing line
+set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Menu
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set wildmenu " menu completion
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Text Formatting/Layout
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set fo=tcrqn " See Help (complex)
+set ai " autoindent
+set si " smartindent
+set cindent " do c-style identing
+set tabstop=2 " tab spacing
+set softtabstop=2 " 2 spaces when pressing <tab> unify
+set shiftwidth=2 " unify
+set noexpandtab " real tabs please!
+set smarttab " use tabs at the start of a line, spaces elsewhere
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Perl
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+let perl_extended_vars=1 " highlight advanced perl vars inside strings
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Autocommands
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+autocmd FileType text setlocal textwidth=80
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Lisaac special support
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+au BufNewFile,BufRead *.li setf lisaac
--
Lisaac compiler
More information about the Lisaac-commits
mailing list