├── BUSY ├── Interlisp.pro ├── LICENSE.GPL2 ├── LICENSE.GPL3 ├── LispBuiltins.cpp ├── LispBuiltins.h ├── LispHighlighter.cpp ├── LispHighlighter.h ├── LispLexer.cpp ├── LispLexer.h ├── LispNavigator.cpp ├── LispNavigator.h ├── LispReader.cpp ├── LispReader.h ├── LispRowCol.cpp ├── LispRowCol.h ├── Navigator.qrc ├── Readme.md └── fonts ├── DejaVu.license ├── DejaVuSansMono.ttf ├── Noto.license └── NotoSans.ttf /BUSY: -------------------------------------------------------------------------------- 1 | # author: Rochus Keller (me@rochus-keller.ch) 2 | # License: GPL 3 | # https://github.com/rochus-keller/BUSY/blob/main/README.md on how to use this file 4 | 5 | if busy_version < "2023-01-15" { 6 | error("this version of BUSY is not compatible with this build") 7 | } 8 | 9 | let mtconf : Config { 10 | .cflags = [ "/O2", "/MT" ] 11 | } 12 | 13 | if (build_mode == `optimized) && (target_toolchain == `msvc) { 14 | set_defaults(target_toolchain,mtconf) 15 | } 16 | 17 | submod qt = ../LeanQt (HAVE_ITEMVIEWS) 18 | 19 | let run_moc : Moc { 20 | .sources += [ 21 | ../GuiTools/AutoMenu.h 22 | ../GuiTools/AutoShortcut.h 23 | ../GuiTools/CodeEditor.h 24 | ../GuiTools/UiFunction.h 25 | ./LispNavigator.h 26 | ] 27 | } 28 | 29 | let run_rcc : Rcc { 30 | .deps += qt.copy_rcc; 31 | .tool_dir = root_build_dir + relpath(qt); 32 | .sources += ./Navigator.qrc 33 | } 34 | 35 | let exe ! : Executable { 36 | .configs += [ qt.qt_client_config ] 37 | .sources = [ 38 | ../GuiTools/CodeEditor.cpp 39 | ../GuiTools/AutoMenu.cpp 40 | ../GuiTools/UiFunction.cpp 41 | ../GuiTools/NamedFunction.cpp 42 | ../GuiTools/AutoShortcut.cpp 43 | ./LispReader.cpp 44 | ./LispLexer.cpp 45 | ./LispHighlighter.cpp 46 | ./LispBuiltins.cpp 47 | ./LispRowCol.cpp 48 | ./LispNavigator.cpp 49 | ] 50 | .include_dirs += [ . .. ] 51 | .deps += [ qt.copy_rcc qt.libqt run_rcc run_moc ] 52 | if target_os == `win32 { 53 | .deps += qt.libqtwinmain 54 | } 55 | .name = "InterlispNavigator" 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /Interlisp.pro: -------------------------------------------------------------------------------- 1 | 2 | QT += core gui 3 | 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 5 | 6 | TARGET = InterlispNavigator 7 | TEMPLATE = app 8 | 9 | INCLUDEPATH += .. 10 | 11 | SOURCES += \ 12 | LispReader.cpp \ 13 | ../GuiTools/CodeEditor.cpp \ 14 | ../GuiTools/AutoMenu.cpp \ 15 | ../GuiTools/UiFunction.cpp \ 16 | ../GuiTools/NamedFunction.cpp \ 17 | LispLexer.cpp \ 18 | LispHighlighter.cpp \ 19 | LispBuiltins.cpp \ 20 | LispRowCol.cpp \ 21 | LispNavigator.cpp \ 22 | ../GuiTools/AutoShortcut.cpp 23 | 24 | HEADERS += \ 25 | LispReader.h \ 26 | ../GuiTools/CodeEditor.h \ 27 | ../GuiTools/AutoMenu.h \ 28 | ../GuiTools/UiFunction.h \ 29 | ../GuiTools/NamedFunction.h \ 30 | LispLexer.h \ 31 | LispHighlighter.h \ 32 | LispBuiltins.h \ 33 | LispRowCol.h \ 34 | LispNavigator.h \ 35 | ../GuiTools/AutoShortcut.h 36 | 37 | CONFIG(debug, debug|release) { 38 | DEFINES += _DEBUG 39 | } 40 | 41 | !win32 { 42 | QMAKE_CXXFLAGS += -Wno-reorder -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable 43 | } 44 | 45 | RESOURCES += \ 46 | Navigator.qrc 47 | -------------------------------------------------------------------------------- /LICENSE.GPL2: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | 342 | 343 | -------------------------------------------------------------------------------- /LICENSE.GPL3: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | 677 | -------------------------------------------------------------------------------- /LispBuiltins.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Rochus Keller 3 | * 4 | * This file is part of the Interlisp project. 5 | * 6 | * The following is the license that applies to this copy of the 7 | * file. For a license to use the file under conditions 8 | * other than those described here, please email to me@rochus-keller.ch. 9 | * 10 | * GNU General Public License Usage 11 | * This file may be used under the terms of the GNU General Public 12 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 13 | * Foundation and appearing in the file LICENSE.GPL included in 14 | * the packaging of this file. Please review the following information 15 | * to ensure GNU General Public Licensing requirements will be met: 16 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 17 | * http://www.gnu.org/copyleft/gpl.html. 18 | */ 19 | // Extracted from the index of the book "Interlisp - The Language and its usage" 20 | 21 | #include "LispBuiltins.h" 22 | using namespace Lisp; 23 | 24 | 25 | const char*Builtins::functions[]= { 26 | "ABS", 27 | "ADDASSOC", 28 | "ADDPROP", 29 | "ADDSPELL", 30 | "ADDSPELLl", 31 | "ADDSTATS", 32 | "ADDTOCOMS", 33 | "ADDTOFILE", 34 | "ADDTOFILES?", 35 | "ADD1", 36 | "ADD.OR.SUBTRACT.MATRICES", 37 | "ADVISE", 38 | "ADVISEDUMP", 39 | "ALLOCSTRING", 40 | "ALPHORDER", 41 | "AND", 42 | "ANTILOG", 43 | "APPEND", 44 | "APPLY", 45 | "APPLY*", 46 | "ARCCOS", 47 | "ARCSIN", 48 | "ARCTAN", 49 | "ARCTAN2", 50 | "ARG", 51 | "ARGLIST", 52 | "ARGTYPE", 53 | "ARRAY", 54 | "ARRAYBEG", 55 | "ARRAYORIG", 56 | "ARRAYP", 57 | "ARRAYSIZE", 58 | "ARRAYTYP", 59 | "ASKUSER", 60 | "ASSOC", 61 | "ATOM", 62 | "ATTACH", 63 | "BAKTRACE", 64 | "BKLINBUF", 65 | "BKSYSBUF", 66 | "BOUNDP", 67 | "BREAK", 68 | "BREAKCHECK", 69 | "BREAKDOWN", 70 | "BREAKIN", 71 | "BREAKREAD", 72 | "BREAKO", 73 | "BREAKl", 74 | "BRKDWNRESULTS", 75 | "BUBBLE.SORT", 76 | "BUILD-ARGUMENT-LIST", 77 | "CALLS", 78 | "CALLSCCODE", 79 | "CAR", 80 | "CASEARRAY", 81 | "CCODEP", 82 | "CDIFFERENCE", 83 | "CDR", 84 | "CHANGECALLERS", 85 | "CHANGENAME", 86 | "CHANGEPROP", 87 | "CHANGESLICE", 88 | "CHARACTER", 89 | "CHARCODE", 90 | "CHCON", 91 | "CHCON1", 92 | "CHECK.MATRIX", 93 | "CHOOZ", 94 | "CLDISABLE", 95 | "CLEANUP", 96 | "CLEARBUF", 97 | "CLEARSTK", 98 | "CLISPDEC", 99 | "CLISPIFY", 100 | "CLISPIFYFNS", 101 | "CLISPTRAN", 102 | "CLOCK", 103 | "CLOSEALL", 104 | "CLOSEF", 105 | "CLOSEF?", 106 | "CLRHASH", 107 | "CMULT", 108 | "CNDIR", 109 | "COMPARE", 110 | "COMPAREDEFS", 111 | "COMPARELISTS", 112 | "COMPILE", 113 | "COMPILEFILES", 114 | "COMPILE1", 115 | "COMPLEX", 116 | "CONCAT", 117 | "CONCATLIST", 118 | "COND", 119 | "CONS", 120 | "CONSCOUNT", 121 | "CONSTANTS", 122 | "CONTROL", 123 | "COPY", 124 | "COPYALL", 125 | "COPYARRAY", 126 | "COPYBYTES", 127 | "COPYDEF", 128 | "COPYREADTABLE", 129 | "COPYSTK", 130 | "COPYTERMTABLE", 131 | "COS", 132 | "COUNT", 133 | "COUNTDOWN", 134 | "CPLUS", 135 | "CZERO", 136 | "DATE", 137 | "DE", 138 | "DECLAREDATATYPE", 139 | "DEFINE", 140 | "DEFINEQ", 141 | "DEFLIST", 142 | "DEFMACRO", 143 | "DEFPRINT", 144 | "DELASSOC", 145 | "DELDEF", 146 | "DELETECONTROL", 147 | "DELETE.STRING", 148 | "DELFILE", 149 | "DELFROMCOMS", 150 | "DELFROMFILES", 151 | "DEPTH", 152 | "DF", 153 | "DIERENCE", 154 | "DIRECTORY", 155 | "DMPHASH", 156 | "DOCOLLECT", 157 | "DOT.PRODUCT", 158 | "DRIBBLE", 159 | "DRIBBLEFILE", 160 | "DUMMYFRAMEP", 161 | "DUMPDATABASE", 162 | "DWIM", 163 | "DWIMIFY", 164 | "DWIMIFYFNS", 165 | "ECHOCHAR", 166 | "ECHOCONTROL", 167 | "ECHOMODE", 168 | "EDITCALLERS", 169 | "EDITDEF", 170 | "EDITE", 171 | "EDITF", 172 | "EDITFINDP", 173 | "EDITFNS", 174 | "EDITL", 175 | "EDITL0", 176 | "EDITP", 177 | "EDITREC", 178 | "EDITRACEFN", 179 | "EDITV", 180 | "EDIT4E", 181 | "ELT", 182 | "ELTD", 183 | "ELTM", 184 | "ENDCOLLECT", 185 | "ENDFILE", 186 | "ENTRY#", 187 | "ENVAPPLY", 188 | "ENVEVAL", 189 | "EOFP", 190 | "EQ", 191 | "EQARRAYP", 192 | "EQLENGTH", 193 | "EQMEMB", 194 | "EQSIGNP", 195 | "EQUAL", 196 | "EQUALALL", 197 | "EQUALN", 198 | "EQP", 199 | "EQZERO", 200 | "ERROR", 201 | "ERRORMESS", 202 | "ERRORMESS1", 203 | "ERRORN", 204 | "ERRORSET", 205 | "ERRORSTRING", 206 | "ERRORX", 207 | "ERROR!", 208 | "ERSETQ", 209 | "ESUBST", 210 | "EVAL", 211 | "EVALA", 212 | "EVENP", 213 | "EVERY", 214 | "EXCHANGE", 215 | "EXPANDMACRO", 216 | "EXPRP", 217 | "EXPT", 218 | "FADDl", 219 | "FEQP", 220 | "FETCHFIELD", 221 | "ILEPOS", 222 | "FGREATERP", 223 | "FILDIR", 224 | "FILECHANGES", 225 | "FILECOMS", 226 | "FILECOMSLST", 227 | "FILECREATED", 228 | "FILEDATE", 229 | "FILEFNSLST", 230 | "FILENAMEFIELD", 231 | "FILEPKGCHANGES", 232 | "FILEPKGCOM", 233 | "FILEPKGTYPE", 234 | "FILEPOS", 235 | "FILES?", 236 | "FINDFILE", 237 | "FIX", 238 | "FIXP", 239 | "FIXSPELL", 240 | "FLESSP", 241 | "FLOAT", 242 | "FLOATP", 243 | "FLOOR", 244 | "FLTFMT", 245 | "FMAX", 246 | "FMIN", 247 | "FMINUS", 248 | "FNCHECK", 249 | "FNTYP", 250 | "FPLUS", 251 | "FQUOTIENT", 252 | "FRAMESCAN", 253 | "FREEVARS", 254 | "FREMAINDER", 255 | "FTIMES", 256 | "FULLNAME", 257 | "FUNCTION", 258 | "GAINSPACE", 259 | "GCD", 260 | "GDATE", 261 | "GENERATE", 262 | "GENERATOR", 263 | "GENSYM", 264 | "GEQ", 265 | "GETATOMVAL", 266 | "GETBRK", 267 | "GETCOMMENT", 268 | "GETCONTROL", 269 | "GETD", 270 | "GETDEF", 271 | "GETDELETECONTROL", 272 | "GETDESCRIPTORS", 273 | "GETECHOMODE", 274 | "GETEOFPTR", 275 | "GETFIELDSPECS", 276 | "GETFILEINFO", 277 | "GETFILEPTR", 278 | "GETHASH", 279 | "GETLIS", 280 | "GETPROP", 281 | "GETPROPLIST", 282 | "GETRAISE", 283 | "GETREADTABLE", 284 | "GETRELATION", 285 | "GETSEPR", 286 | "GETSYNTAX", 287 | "GETTEMPLATE", 288 | "GETTERMTABLE", 289 | "GETTOPVAL", 290 | "GLC", 291 | "GNC", 292 | "GO", 293 | "GREATERP", 294 | "HARRAY", 295 | "HARRAYP", 296 | "HARRAYSIZE", 297 | "HASDEF", 298 | "HCOPYALL", 299 | "HELP", 300 | "HISTORYFIND", 301 | "HISTORYMATCH", 302 | "HISTORYSAVE", 303 | "HPRINT", 304 | "HREAD", 305 | "I.S.OPR", 306 | "IDATE", 307 | "IDIFFERENCE", 308 | "IEQP", 309 | "IGEQ", 310 | "IGREATERP", 311 | "ILEQ", 312 | "ILESSP", 313 | "IMAG", 314 | "IMAX", 315 | "IMIN", 316 | "IMINUS", 317 | "IMOD", 318 | "INDEX-GENERATION", 319 | "INFILE", 320 | "INFILECOMS?", 321 | "INFILEP", 322 | "INPUT", 323 | "INSERT.STRING", 324 | "INTERSECTION", 325 | "IOFILE", 326 | "IPLUS", 327 | "IQUOTIENT", 328 | "IREMAINDER", 329 | "ITIMES", 330 | "KWOTE", 331 | "LAST", 332 | "LASTC", 333 | "LASTN", 334 | "LCONC", 335 | "LDIFF", 336 | "LDIFFERENCE", 337 | "LENGTH", 338 | "LEQ", 339 | "LESSP", 340 | "LINELENGTH", 341 | "LIST", 342 | "LISTFILES", 343 | "LISTGET", 344 | "LISTGETl", 345 | "LISTP", 346 | "LISTPUT", 347 | "LISTPUT1", 348 | "LISPX", 349 | "LISPXEVAL", 350 | "LISPXFIND", 351 | "LISPXPRINT", 352 | "LISPXPRINTDEF", 353 | "LISPXPRINl", 354 | "LISPXPRIN2", 355 | "LISPXREAD", 356 | "LISPXREADP", 357 | "LISPXSPACES", 358 | "LISPXSTATS", 359 | "LISPXTAB", 360 | "LISPXTERPRI", 361 | "LISPXUNREAD", 362 | "LISPXWATCH", 363 | "LISPX/", 364 | "LITATOM", 365 | "LLSH", 366 | "LOAD", 367 | "LOADCOMP", 368 | "LOADDEF", 369 | "LOADFNS", 370 | "LOADFROM", 371 | "LOADVARS", 372 | "LOAD?", 373 | "LOG", 374 | "LOGAND", 375 | "LOGNOT", 376 | "LOGOR", 377 | "LOGXOR", 378 | "LOGOUT", 379 | "LRSH", 380 | "LSH", 381 | "LSUBST", 382 | "L-CASE", 383 | "MAKEBITTABLE", 384 | "MAKEFILE", 385 | "MAKEFILES", 386 | "MAKEKEYLST", 387 | "MAKENEWCOM", 388 | "MAKE.STRING.FROM.LIST", 389 | "MAP", 390 | "MAPATOMS", 391 | "MAP2C", 392 | "MAP2CAR", 393 | "MAPC", 394 | "MAPCAR", 395 | "MAPCONC", 396 | "MAPDL", 397 | "MAPHASH", 398 | "MAPLIST", 399 | "MAPRELATION", 400 | "MAPRINT", 401 | "MARKASCHANGED", 402 | "MASTERSCOPE", 403 | "MATRIX", 404 | "MAX", 405 | "MAXP", 406 | "MDIFFERENCE", 407 | "MEAN", 408 | "MEDIAN", 409 | "MEMB", 410 | "MEMBER", 411 | "MERGE", 412 | "MERGEINSERT", 413 | "MIN", 414 | "MINP", 415 | "MINUS", 416 | "MINUSP", 417 | "MISPELLED?", 418 | "MKATOM", 419 | "MKLIST", 420 | "MKSTRING", 421 | "MOVD", 422 | "MOVD?", 423 | "MOVETOFILE", 424 | "MPLUS", 425 | "MTIMES", 426 | "MULTIFILEINDEX", 427 | "NARGS", 428 | "NCHARS", 429 | "NCONC", 430 | "NCONCl", 431 | "NCONS", 432 | "NCREATE", 433 | "NEGATE", 434 | "NEQ", 435 | "NEWISWORD", 436 | "NEW/FN", 437 | "NILL", 438 | "NLEFT", 439 | "NLISTP", 440 | "NLSETQ", 441 | "NOT", 442 | "NOTANY", 443 | "NOTEQUAL", 444 | "NOTEVERY", 445 | "NTH", 446 | "NTHCHAR", 447 | "NTHCHARCODE", 448 | "NULL", 449 | "NUMBERP", 450 | "NUMERIC-SORT", 451 | "NUMFORMATCODE", 452 | "ODDP", 453 | "ONEP", 454 | "OPENFILE", 455 | "OPENP", 456 | "OR", 457 | "OUTFILE", 458 | "OUTFILEP", 459 | "OUTPUT", 460 | "PACK", 461 | "PACKC", 462 | "PACK*", 463 | "PACKFILENAME", 464 | "PAGEFAULTS", 465 | "PARSERELATION", 466 | "PEEKC", 467 | "PF", 468 | "PLUS", 469 | "PLUSP", 470 | "POSITION", 471 | "POWEROFTWOP", 472 | "PP", 473 | "PRETTYCOMPRINT", 474 | "PRETTYDEF", 475 | "PRETTYPRINT", 476 | "PRIN1", 477 | "PRIN2", 478 | "PRIN3", 479 | "PRIN4", 480 | "PRINT", 481 | "PRINTHISTORY", 482 | "PRINTBELLS", 483 | "PRINTCOMMENT", 484 | "PRINTDATE", 485 | "PRINTDEF", 486 | "PRINTFNS", 487 | "PRINTLEVEL", 488 | "PRINTNUM", 489 | "PRODUCE", 490 | "PROG", 491 | "PROG1", 492 | "PROG2", 493 | "PROGN", 494 | "PROPNAMES", 495 | "PUTASSOC", 496 | "PUTD", 497 | "PUTDEF", 498 | "PUTDQ", 499 | "PUTDQ?", 500 | "PUTHASH", 501 | "PUTPROP", 502 | "PUTPROPS", 503 | "QUOTE", 504 | "QUOTIENT", 505 | "RADIX", 506 | "RAISE", 507 | "RAND", 508 | "RANDACCESSP", 509 | "RANDSET", 510 | "RATEST", 511 | "RATOM", 512 | "RATOMS", 513 | "READ", 514 | "READC", 515 | "READCOMMENT", 516 | "READFILE", 517 | "READLINE", 518 | "READMACROS", 519 | "READP", 520 | "READTABLEP", 521 | "READVISE", 522 | "REAL", 523 | "REALFRAMEP", 524 | "REALSTKNTH", 525 | "RECIPROCAL", 526 | "RECLOOK", 527 | "RECOMPILE", 528 | "RECORDACCESS", 529 | "RECORDFIELDNAMES", 530 | "REHASH", 531 | "RELSTK", 532 | "RELSTKP", 533 | "REMAINDER", 534 | "REMPROP", 535 | "REMPROPLIST", 536 | "REMOVE", 537 | "RENAME", 538 | "RENAMEFILE", 539 | "REPLACEFIELD", 540 | "RESET", 541 | "RESETFORM", 542 | "RESETLST", 543 | "RESETSAVE", 544 | "RESETTERMTABLE", 545 | "RESETUNDO", 546 | "RESETVAR", 547 | "RESETVARS", 548 | "RETAPPLY", 549 | "RETEVAL", 550 | "RETFROM", 551 | "RETTO", 552 | "RETURN", 553 | "REVERSE", 554 | "ROUNDED", 555 | "ROUNDTO", 556 | "RPAQ", 557 | "RPAQQ", 558 | "RPAQ?", 559 | "RPLACA", 560 | "RPLACD", 561 | "RPLCHARCODE", 562 | "RPLNODE", 563 | "RPLNODE2", 564 | "RPLSTRING", 565 | "RPT", 566 | "RPTQ", 567 | "RSH", 568 | "RSTRING", 569 | "SASSOC", 570 | "SAVEDEF", 571 | "SAVESET", 572 | "SAVESETQ", 573 | "SAVESETQQ", 574 | "SEARCHPDL", 575 | "SELCHARQ", 576 | "SELECTC", 577 | "SELECTION.SORT", 578 | "SELECTQ", 579 | "SEPRCASE", 580 | "SET", 581 | "SETA", 582 | "SETARG", 583 | "SETATOMVAL", 584 | "SETBRK", 585 | "SETCASEARRAY", 586 | "SETD", 587 | "SETERRORN", 588 | "SETFILEINFO", 589 | "SETFILEPTR", 590 | "SETLINELENGTH", 591 | "SETM", 592 | "SETPROPLIST", 593 | "SETQ", 594 | "SETQQ", 595 | "SETREADMACROFLG", 596 | "SETREADTABLE", 597 | "SETSEPR", 598 | "SETSTKNAME", 599 | "SETSYNONYM", 600 | "SETSYNTAX", 601 | "SETTERMTABLE", 602 | "SETTEMPLATE", 603 | "SETTOPVAL", 604 | "SHOWPRINT", 605 | "SHOWPRIN2", 606 | "SIGN", 607 | "SIN", 608 | "SINGLEFILEINDEX", 609 | "SKOR", 610 | "SKREAD", 611 | "SMALLP", 612 | "SMASHFILECOMS", 613 | "SOME", 614 | "SORT", 615 | "SPACES", 616 | "SPELLFILE", 617 | "SQRT", 618 | "STACKP", 619 | "STANDARD.DEVIATION", 620 | "STKAPPLY", 621 | "STKARGS", 622 | "STKEVAL", 623 | "STKNAME", 624 | "STKNTH", 625 | "STKNTHNAME", 626 | "STKPOS", 627 | "STKSCAN", 628 | "STORAGE", 629 | "STREQUAL", 630 | "STRING?", 631 | "STRMEMB", 632 | "STRPOS", 633 | "STRPOSL", 634 | "SUBATOM", 635 | "SUBLIS", 636 | "SUBPAIR", 637 | "SUBPR", 638 | "SUBRP", 639 | "SUBSET", 640 | "SUBST", 641 | "SUBSTITUTE.STRING", 642 | "SUBSTRING", 643 | "SUBl", 644 | "SYMBOLP", 645 | "SYNTAXP", 646 | "SYSIN", 647 | "SYSOUT", 648 | "SYSOUTP", 649 | "SYSPROPS", 650 | "SYSTEMTYPE", 651 | "TAB", 652 | "TAILP", 653 | "TAILP?", 654 | "TAN", 655 | "TCOMPL", 656 | "TCONC", 657 | "TERPRI", 658 | "TERMTABLEP", 659 | "TESTRELATION", 660 | "TIME", 661 | "TIMES", 662 | "TRACE", 663 | "TRANSPOSE", 664 | "TRIM", 665 | "TRUE", 666 | "TRUNCATE", 667 | "TYPESOF", 668 | "UNADVISE", 669 | "UNBREAK", 670 | "UNBREAKIN", 671 | "UNBREAK0", 672 | "UNDOLISPX", 673 | "UNDOLISPX1", 674 | "UNDONLSETQ", 675 | "UNION", 676 | "UNIQUE", 677 | "UNIQUE-UNION", 678 | "UNMARKASCHANGED", 679 | "UNPACK", 680 | "UNPACKFILENAME", 681 | "UNSAVEDEF", 682 | "UNSET", 683 | "UPDATEFN", 684 | "USERDATATYPES", 685 | "USEREXEC", 686 | "USERLISPXPRINT", 687 | "USERNAME", 688 | "U-CASE", 689 | "U-CASEP", 690 | "VALUEOF", 691 | "VARIABLES", 692 | "VARIANCE", 693 | "VIRGINFN", 694 | "WAITFORINPUT", 695 | "WHENCLOSE", 696 | "WHEREIS", 697 | "WRITEFILE", 698 | "ZERO", 699 | "ZEROP", 700 | "/MAPCONC", 701 | "/MOVD", 702 | "/PUTD", 703 | "/PUTPROP", 704 | "/REMPROP", 705 | "/RPLACA", 706 | "/RPLACD", 707 | 0 708 | }; 709 | 710 | 711 | const char*Builtins::variables[]= { 712 | "ADDSPELLFLG", 713 | "ADVISEDFNS", 714 | "AFTERSYSOUTFORMS", 715 | "ALAMS", 716 | "ARCHIVEFN", 717 | "ARCHIVELST", 718 | "BAKTRACELST", 719 | "BREAKRESETFORMS", 720 | "BRKCOMS", 721 | "BRKDW NTYPE", 722 | "BRKINFOLST", 723 | "BROKENFNS", 724 | "BUILDMAPFLG", 725 | "CHANGECHAR", 726 | "CLISPARRAY", 727 | "CLISPFLG", 728 | "CLISPHELPFLG", 729 | "CLISPIFTRANFLG", 730 | "CLISPIFYENGLSHFLG", 731 | "CLISPIFYPACKFLG", 732 | "CLISPIFYPRETTYFLG", 733 | "CLISPIFYUSERFN", 734 | "CLISPRETRANFLG", 735 | "CLREMPARSFLG", 736 | "CL:FLG", 737 | "COMMENTFLG", 738 | "COMPILETYPELST", 739 | "COMPILEUSERFN", 740 | "DFNFLG", 741 | "DIRCOMMANDS", 742 | "DISMISSINIT", 743 | "DISMISSMAX", 744 | "DWIMCHECKMRGSFLG", 745 | "DWMCHECKPROGLABELSFLG", 746 | "DWIMFLG", 747 | "DWIMIFYCOMPFLG", 748 | "DWIMIFYCOMPILEFLG", 749 | "DWIMIFYFLG", 750 | "DWIMLOADFNSFLG", 751 | "DWIMMESSGAG", 752 | "DWIMUSERFORMS", 753 | "DWIMWAIT", 754 | "EDITHISTORY", 755 | "EDITRDTBL", 756 | "ERRORTYPELST", 757 | "FAULTAPPLYFLG", 758 | "FAULTARGS", 759 | "FAULTFN", 760 | "FAULTX", 761 | "FILELST", 762 | "FILEPKGFLG", 763 | "FILERDTBL", 764 | "FIRSTCOL", 765 | "FIXSPELLDEFAULT", 766 | "FIXSPELLREL", 767 | "FUNNYATOMLST", 768 | "GAINSPACEFORMS", 769 | "GENNUM", 770 | "GREETDATES", 771 | "HELPCLOCK", 772 | "HELPDEPTH", 773 | "HELPTIME", 774 | "HISTORYSAVEFORMS", 775 | "IT", 776 | "LAMS", 777 | "LAPFLG", 778 | "LCFIL", 779 | "LISPXCOMS", 780 | "LISPXFINDSPLST", 781 | "LISPXFNS", 782 | "LISPXHISTORY", 783 | "LISPXHISTORYMACROS", 784 | "LISPXPRINTFLAG", 785 | "LISPXUSERFN", 786 | "LOADEDFILELST", 787 | "LSTFIL", 788 | "MAXLEVEL", 789 | "MAX.FIXP", 790 | "MAX.FLOATP", 791 | "MAX.SMALLP", 792 | "MIN.FIXP", 793 | "MIN.FLOATP", 794 | "MIN.SMALLP", 795 | "NLAMA", 796 | "NLAMS", 797 | "NOFIXFNSLST", 798 | "NOFIXVARSLST", 799 | "NOSPELLFLG", 800 | "NOTCOM PILEDFILES", 801 | "NOTLISTEDFILES", 802 | "PARENT", 803 | "PRETTYEQUIVLST", 804 | "PRETTYFLG", 805 | "PRETTYPRINTMACROS", 806 | "PRETTYPRINTTYPEM ACROS", 807 | "PRETTYTABFLG", 808 | "PROMPTCHARFORMS", 809 | "PROMPT#FLG", 810 | "RESETFORM S", 811 | "RUNONFLG", 812 | "SPELLINGSl", 813 | "SPELLINGS2", 814 | "SPELLINGS3", 815 | "STRF", 816 | "SVFLG", 817 | "SYSHASHARRAY", 818 | "SYSTATS", 819 | "TAIL", 820 | "TYPE-IN?", 821 | "USEMAPFLG", 822 | "USERINTERRUPTS", 823 | "USERWORDS", 824 | "IVALUE", 825 | "**COMMENT**FLG", 826 | "#CAREFULCOLUMNS", 827 | "#RPARS", 828 | 0 829 | }; 830 | -------------------------------------------------------------------------------- /LispBuiltins.h: -------------------------------------------------------------------------------- 1 | #ifndef LISPBUILTINS_H 2 | #define LISPBUILTINS_H 3 | 4 | /* 5 | * Copyright 2024 Rochus Keller 6 | * 7 | * This file is part of the Interlisp project. 8 | * 9 | * The following is the license that applies to this copy of the 10 | * file. For a license to use the file under conditions 11 | * other than those described here, please email to me@rochus-keller.ch. 12 | * 13 | * GNU General Public License Usage 14 | * This file may be used under the terms of the GNU General Public 15 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 16 | * Foundation and appearing in the file LICENSE.GPL included in 17 | * the packaging of this file. Please review the following information 18 | * to ensure GNU General Public Licensing requirements will be met: 19 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 20 | * http://www.gnu.org/copyleft/gpl.html. 21 | */ 22 | 23 | namespace Lisp 24 | { 25 | 26 | class Builtins 27 | { 28 | public: 29 | static const char* functions[]; 30 | static const char* variables[]; 31 | }; 32 | 33 | } 34 | 35 | #endif // LISPBUILTINS_H 36 | -------------------------------------------------------------------------------- /LispHighlighter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Rochus Keller 3 | * 4 | * This file is part of the Interlisp project. 5 | * 6 | * The following is the license that applies to this copy of the 7 | * library. For a license to use the library under conditions 8 | * other than those described here, please email to me@rochus-keller.ch. 9 | * 10 | * GNU General Public License Usage 11 | * This file may be used under the terms of the GNU General Public 12 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 13 | * Foundation and appearing in the file LICENSE.GPL included in 14 | * the packaging of this file. Please review the following information 15 | * to ensure GNU General Public Licensing requirements will be met: 16 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 17 | * http://www.gnu.org/copyleft/gpl.html. 18 | */ 19 | 20 | // Adopted from the Luon project 21 | 22 | #include "LispHighlighter.h" 23 | #include "LispLexer.h" 24 | #include 25 | #include 26 | #include 27 | using namespace Lisp; 28 | 29 | static const char* QUOTE; 30 | 31 | 32 | Highlighter::Highlighter(QTextDocument* parent) : 33 | QSyntaxHighlighter(parent) 34 | { 35 | QUOTE = Token::getSymbol("QUOTE").constData(); 36 | 37 | const int pointSize = parent->defaultFont().pointSize(); 38 | for( int i = 0; i < C_Max; i++ ) 39 | { 40 | d_format[i].setFontWeight(QFont::Normal); 41 | d_format[i].setForeground(Qt::black); 42 | d_format[i].setBackground(Qt::transparent); 43 | } 44 | d_format[C_Num].setForeground(QColor(0, 153, 153)); 45 | d_format[C_Str].setForeground(QColor(208, 16, 64)); 46 | d_format[C_Cmt].setForeground(QColor(153, 153, 136)); 47 | d_format[C_Func].setForeground(QColor(68, 85, 136)); 48 | d_format[C_Func].setFontWeight(QFont::Bold); 49 | d_format[C_Op1].setForeground(QColor(153, 0, 0)); 50 | d_format[C_Op1].setFontWeight(QFont::Bold); 51 | d_format[C_Op2].setForeground(QColor(153, 0, 0)); 52 | d_format[C_Op2].setFontWeight(QFont::Bold); 53 | d_format[C_Op2].setFontPointSize(pointSize * 1.2); 54 | //d_format[C_Op3].setForeground(QColor(153, 0, 0).lighter(125)); // QColor(0, 134, 179)); 55 | d_format[C_Op3].setFontWeight(QFont::Bold); 56 | d_format[C_Var].setForeground(QColor(153, 0, 115)); 57 | d_format[C_Var].setFontWeight(QFont::Bold); 58 | d_format[C_Pp].setFontWeight(QFont::Bold); 59 | d_format[C_Pp].setForeground(QColor(0, 128, 0)); 60 | d_format[C_Pp].setBackground(QColor(230, 255, 230)); 61 | 62 | //d_builtins = createBuiltins(); 63 | d_syntax.insert(Token::getSymbol("NIL").constData()); 64 | d_syntax.insert(Token::getSymbol("T").constData()); 65 | d_syntax.insert(Token::getSymbol("LAMBDA").constData()); 66 | d_syntax.insert(Token::getSymbol("NLAMBDA").constData()); 67 | } 68 | 69 | void Highlighter::addFunction(const char* bi) 70 | { 71 | d_functions << bi; 72 | } 73 | 74 | void Highlighter::addVariable(const char* bi) 75 | { 76 | d_variables << bi; 77 | } 78 | 79 | QTextCharFormat Highlighter::formatForCategory(int c) const 80 | { 81 | return d_format[c]; 82 | } 83 | 84 | void Highlighter::clearFromHere(quint32 line) 85 | { 86 | LineState::iterator i = lineState.upperBound(line); 87 | while( i != lineState.end() ) 88 | i = lineState.erase(i); 89 | } 90 | 91 | #if 0 92 | QSet Highlighter::createBuiltins(bool withLowercase) 93 | { 94 | QSet res = CodeModel::getBuitinIdents().toSet(); 95 | if( withLowercase ) 96 | { 97 | QSet tmp = res; 98 | QSet::const_iterator i; 99 | for( i = tmp.begin(); i != tmp.end(); ++i ) 100 | res.insert( (*i).toLower() ); 101 | } 102 | return res; 103 | } 104 | #endif 105 | 106 | static inline void setBackground(QTextCharFormat& f, int level) 107 | { 108 | if( level == 0 ) 109 | { 110 | f.setBackground(Qt::white); 111 | return; 112 | } 113 | QColor bgClr = QColor::fromRgb( 255, 254, 225 ); // Gelblich 114 | bgClr = QColor::fromHsv( bgClr.hue(), bgClr.saturation(), bgClr.value() - ( level*2 - 1 ) * 3 ); 115 | f.setBackground(bgClr); 116 | } 117 | 118 | static bool punctuation(const QString& str, int pos, int len) 119 | { 120 | for( int i = pos; i < qMin(pos + len, str.size()); i++ ) 121 | { 122 | if( str[i].isLetterOrNumber() ) 123 | return false; 124 | } 125 | return true; 126 | } 127 | 128 | void Highlighter::highlightBlock(const QString& text) 129 | { 130 | const int previousBlockState_ = previousBlockState(); 131 | quint8 lexerState = 0, 132 | braceDepth = 0, // nesting level of [] or () 133 | commentLevel = 0; // 0 or braceDepth where comment started 134 | if (previousBlockState_ != -1) { 135 | lexerState = previousBlockState_ & 0xff; 136 | braceDepth = (previousBlockState_ >> 8) & 0xff; 137 | commentLevel = (previousBlockState_ >> 16) & 0xff; 138 | } 139 | 140 | const quint32 line = currentBlock().blockNumber() + 1; 141 | clearFromHere(line); 142 | 143 | // we can be in a (, [, (*, " or QUOTE 144 | // [ requires memorizing the previous open occurences 145 | // ( and [ are the same category, just with different termination rules 146 | // QUOTE can start with ( or [ 147 | // A comment can include all others and behave compatible, even if the whole thing is not evaluated 148 | // But a comment can terminate with ] which affects previous [ and ( 149 | // The [ ( (* QUOTE state is separate from the " state 150 | 151 | bool inString = lexerState & 1; 152 | bool inQuote = lexerState & 2; 153 | 154 | Lexer lex; 155 | lex.setEmitComments(true); 156 | lex.setPacked(false); 157 | lex.setStream(text.toLatin1(), ""); 158 | 159 | Token t; 160 | if( inString ) 161 | { 162 | t = lex.readString(); 163 | setFormat( 0, t.len, formatForCategory(C_Str) ); 164 | if( t.val.endsWith('"') && ((t.pos.col + t.len) < 2 || text[t.pos.col + t.len - 2] != '%') ) // ": -1, %: -2 165 | inString = false; 166 | else 167 | { 168 | // the whole line is in the string 169 | // lexer state remains the same 170 | setCurrentBlockState(previousBlockState_); 171 | return; 172 | } 173 | } 174 | 175 | t = lex.nextToken(); 176 | while( t.isValid() ) 177 | { 178 | QTextCharFormat f; 179 | switch(t.type) 180 | { 181 | case Tok_lpar: 182 | braceDepth++; 183 | if( commentLevel ) 184 | f = formatForCategory(C_Cmt); 185 | else 186 | f = formatForCategory(C_Op2); 187 | break; 188 | case Tok_rpar: 189 | if( commentLevel ) 190 | { 191 | if( braceDepth == commentLevel ) 192 | commentLevel = 0; 193 | f = formatForCategory(C_Cmt); 194 | }else 195 | f = formatForCategory(C_Op2); 196 | braceDepth--; 197 | break; 198 | case Tok_lbrack: 199 | lineState[line] = braceDepth; 200 | braceDepth++; 201 | if( commentLevel ) 202 | f = formatForCategory(C_Cmt); 203 | else 204 | f = formatForCategory(C_Op2); 205 | break; 206 | case Tok_rbrack: 207 | if( commentLevel ) 208 | f = formatForCategory(C_Cmt); 209 | else 210 | f = formatForCategory(C_Op2); 211 | if( !lineState.isEmpty() ) 212 | { 213 | const quint32 lastLine = lineState.lastKey(); 214 | braceDepth = lineState.value(lastLine); 215 | lineState.remove(lastLine); 216 | if( braceDepth <= commentLevel ) 217 | commentLevel = 0; 218 | } 219 | break; 220 | case Tok_atom: 221 | if( commentLevel ) 222 | f = formatForCategory(C_Cmt); 223 | else if( d_syntax.contains(t.val.constData()) ) 224 | f = formatForCategory(C_Op1); 225 | else if( d_functions.contains(t.val.constData()) ) 226 | f = formatForCategory(C_Func); 227 | else if( d_variables.contains(t.val.constData() ) ) 228 | f = formatForCategory(C_Var); 229 | //else if( punctuation(text, t.pos.col-1, t.len ) ) 230 | // f = formatForCategory(C_Op3); 231 | else 232 | f = formatForCategory(C_Ident); 233 | if( !inString && commentLevel == 0 && t.val.constData() == QUOTE ) 234 | inQuote = true; 235 | break; 236 | case Tok_float: 237 | case Tok_integer: 238 | if( commentLevel ) 239 | f = formatForCategory(C_Cmt); 240 | else 241 | f = formatForCategory(C_Num); 242 | break; 243 | case Tok_Lattr: 244 | braceDepth++; 245 | if( commentLevel == 0 ) 246 | commentLevel = braceDepth; 247 | f = formatForCategory(C_Cmt); 248 | break; 249 | case Tok_DblQuote: 250 | Q_ASSERT( !inString ); 251 | inString = true; 252 | const Token t2 = lex.readString(); 253 | t.len += t2.len; 254 | if( t2.val.endsWith('"') ) 255 | inString = false; // string ended on the same line 256 | // else look for string end on next line 257 | if( commentLevel == 0 ) 258 | f = formatForCategory(C_Str); 259 | else 260 | f = formatForCategory(C_Cmt); 261 | break; 262 | } 263 | if( f.isValid() ) 264 | setFormat( t.pos.col-1, t.len, f ); 265 | t = lex.nextToken(); 266 | } 267 | 268 | lexerState = 0; 269 | if( inString ) 270 | lexerState |= 1; 271 | if( inQuote ) 272 | lexerState |= 2; 273 | setCurrentBlockState((commentLevel << 16) | (braceDepth << 8) | lexerState ); 274 | } 275 | 276 | 277 | 278 | -------------------------------------------------------------------------------- /LispHighlighter.h: -------------------------------------------------------------------------------- 1 | #ifndef LISPHIGHLIGHTER_H 2 | #define LISPHIGHLIGHTER_H 3 | 4 | /* 5 | * Copyright 2024 Rochus Keller 6 | * 7 | * This file is part of the Interlisp project. 8 | * 9 | * The following is the license that applies to this copy of the 10 | * library. For a license to use the library under conditions 11 | * other than those described here, please email to me@rochus-keller.ch. 12 | * 13 | * GNU General Public License Usage 14 | * This file may be used under the terms of the GNU General Public 15 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 16 | * Foundation and appearing in the file LICENSE.GPL included in 17 | * the packaging of this file. Please review the following information 18 | * to ensure GNU General Public Licensing requirements will be met: 19 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 20 | * http://www.gnu.org/copyleft/gpl.html. 21 | */ 22 | 23 | // derived from Luon Highlighter 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Lisp 30 | { 31 | class Highlighter : public QSyntaxHighlighter 32 | { 33 | public: 34 | enum { TokenProp = QTextFormat::UserProperty }; 35 | explicit Highlighter(QTextDocument *parent = 0); 36 | void addFunction(const char* bi); 37 | void addVariable(const char* bi); 38 | 39 | protected: 40 | QTextCharFormat formatForCategory(int) const; 41 | void clearFromHere(quint32 line); 42 | 43 | // overrides 44 | void highlightBlock(const QString &text); 45 | 46 | private: 47 | enum Category { C_Num, C_Str, C_Func, C_Var, C_Ident, C_Op1, C_Op2, C_Op3, C_Pp, C_Cmt, C_Max }; 48 | QTextCharFormat d_format[C_Max]; 49 | QSet d_functions, d_variables, d_syntax; 50 | typedef QMap LineState; 51 | LineState lineState; // line -> level 52 | }; 53 | } 54 | 55 | #endif // LISPHIGHLIGHTER_H 56 | -------------------------------------------------------------------------------- /LispLexer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Rochus Keller 3 | * 4 | * This file is part of the Interlisp project. 5 | * 6 | * The following is the license that applies to this copy of the 7 | * library. For a license to use the library under conditions 8 | * other than those described here, please email to me@rochus-keller.ch. 9 | * 10 | * GNU General Public License Usage 11 | * This file may be used under the terms of the GNU General Public 12 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 13 | * Foundation and appearing in the file LICENSE.GPL included in 14 | * the packaging of this file. Please review the following information 15 | * to ensure GNU General Public Licensing requirements will be met: 16 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 17 | * http://www.gnu.org/copyleft/gpl.html. 18 | */ 19 | 20 | // Adopted from the Luon project 21 | 22 | #include "LispLexer.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | using namespace Lisp; 29 | 30 | static QHash s_symbols; 31 | 32 | bool Token::isValid() const 33 | { 34 | return type != Tok_Eof && type != Tok_Invalid; 35 | } 36 | 37 | bool Token::isEof() const 38 | { 39 | return type == Tok_Eof; 40 | } 41 | 42 | const char*Token::getName() const 43 | { 44 | switch(type) 45 | { 46 | case Tok_Invalid: 47 | return "Tok_Invalid"; 48 | case Tok_Eof: 49 | return "Tok_Eof"; 50 | case Tok_lpar: 51 | return "Tok_lpar"; 52 | case Tok_rpar: 53 | return "Tok_rpar"; 54 | case Tok_lbrack: 55 | return "Tok_lbrack"; 56 | case Tok_rbrack: 57 | return "Tok_rbrack"; 58 | case Tok_string: 59 | return "Tok_string"; 60 | case Tok_atom: 61 | return "Tok_atom"; 62 | case Tok_float: 63 | return "Tok_float"; 64 | case Tok_integer: 65 | return "Tok_integer"; 66 | } 67 | 68 | return "???"; 69 | } 70 | 71 | const char*Token::getString() const 72 | { 73 | return ""; // TODO tokenTypeString(d_type); 74 | } 75 | 76 | QByteArray Token::getSymbol(const QByteArray& str) 77 | { 78 | if( str.isEmpty() ) 79 | return str; 80 | QByteArray& sym = s_symbols[str]; 81 | if( sym.isEmpty() ) 82 | sym = str; 83 | return sym; 84 | } 85 | 86 | QByteArrayList Token::getAllSymbols() 87 | { 88 | QHash::const_iterator i; 89 | QByteArrayList res; 90 | for( i = s_symbols.begin(); i != s_symbols.end(); ++i ) 91 | res.append( i.key() ); 92 | return res; 93 | } 94 | 95 | char Lexer::readc() 96 | { 97 | static char last = 0; 98 | char res; 99 | if( in && !in->atEnd() && in->getChar(&res) ) 100 | { 101 | if( res == '\r' ) 102 | { 103 | char c; 104 | in->getChar(&c); 105 | in->ungetChar(c); 106 | if( c == '\n' ) 107 | res = ' '; 108 | else 109 | res = '\n'; // immediatedly convert to \n 110 | }else if( res == 0 || (!isprint(res) && !isspace(res)) ) 111 | { 112 | if( last == '%' ) 113 | return ' '; // TODO: we need another solution, maybe (CHARACTER res); TODO: sync with Navigator::decode 114 | return readc(); // ignore all clutter 115 | } 116 | if( res == '\n' ) 117 | { 118 | pos.row++; 119 | pos.col = 1; 120 | }else 121 | pos.col++; 122 | if( res == 0 ) 123 | res = -1; 124 | Q_ASSERT(isspace(res) || isprint(res)); 125 | last = res; 126 | return res; 127 | }else 128 | { 129 | if( in && in->atEnd() && in->parent() == this ) 130 | { 131 | in->deleteLater(); 132 | in = 0; 133 | } 134 | return 0; 135 | } 136 | } 137 | 138 | void Lexer::ungetc(char c) 139 | { 140 | if( c == 0 ) 141 | return; 142 | Q_ASSERT(isspace(c) || isprint(c)); 143 | 144 | if( in && c ) 145 | { 146 | if( c == '\n' ) 147 | c = ' '; 148 | //Q_ASSERT( pos.col != 0 ); 149 | if( pos.col != 0 ) 150 | pos.col--; 151 | in->ungetChar(c); 152 | } 153 | } 154 | 155 | QByteArray Lexer::peek(int count) 156 | { 157 | if( in ) 158 | return in->peek(count); 159 | else 160 | return QByteArray(); 161 | } 162 | 163 | void Lexer::ungetstr(const QByteArray& str) 164 | { 165 | for( int i = str.size() - 1; i >= 0; i-- ) 166 | ungetc(str[i]); 167 | } 168 | 169 | Lexer::Lexer(QObject* parent):QObject(parent),in(0),emitComments(false),packed(true),inQuote(false) 170 | { 171 | 172 | } 173 | 174 | void Lexer::setStream(QIODevice* in, const QString& sourcePath) 175 | { 176 | if( in == 0 ) 177 | setStream( sourcePath ); 178 | else 179 | { 180 | this->in = in; 181 | pos.row = 1; 182 | pos.col = 1; 183 | this->sourcePath = sourcePath; 184 | } 185 | } 186 | 187 | void Lexer::setStream(const QByteArray& code, const QString& sourcePath) 188 | { 189 | QBuffer* buf = new QBuffer(this); 190 | buf->setData(code); 191 | buf->open(QIODevice::ReadOnly); 192 | in = buf; 193 | setStream( in, sourcePath ); 194 | } 195 | 196 | bool Lexer::setStream(const QString& sourcePath) 197 | { 198 | QIODevice* in = 0; 199 | 200 | QFile* file = new QFile(sourcePath, this); 201 | if( !file->open(QIODevice::ReadOnly) ) 202 | { 203 | delete file; 204 | return false; 205 | } 206 | in = file; 207 | 208 | // else 209 | setStream( in, sourcePath ); 210 | return true; 211 | } 212 | 213 | Token Lexer::nextToken() 214 | { 215 | if( !buffer.isEmpty() ) 216 | return buffer.takeLast(); 217 | else if( emitComments ) 218 | return nextTokenImp(); 219 | // else 220 | Token res = nextTokenImp(); 221 | while( res.isValid() && res.type == Tok_comment ) 222 | res = nextTokenImp(); 223 | return res; 224 | } 225 | 226 | Token Lexer::readString() 227 | { 228 | QByteArray str; 229 | int extra = 0; // count left and right quote 230 | char c; 231 | while( true ) 232 | { 233 | c = readc(); 234 | if( c == '%' ) 235 | { 236 | extra++; 237 | c = readc(); // escape 238 | }else if( c == '"' ) 239 | { 240 | str += c; 241 | break; 242 | }else if( c == 0 ) 243 | break; 244 | str += c; 245 | } 246 | return token(Tok_string, str.size() + extra, str); 247 | } 248 | 249 | void Lexer::unget(const Token& t) 250 | { 251 | buffer.push_front(t); 252 | } 253 | 254 | Token Lexer::nextTokenImp() 255 | { 256 | skipWhiteSpace(); 257 | start = pos; 258 | const char c = readc(); 259 | if( c == 0 ) 260 | return token(Tok_Eof); 261 | else if( isdigit(c) ) 262 | { 263 | // this is a number 264 | ungetc(c); 265 | return number(); 266 | }else if( c == '+' || c == '-' || c == '.' ) 267 | { 268 | const QByteArray la = peek(2); 269 | ungetc(c); 270 | if( !la.isEmpty() && isdigit(la[0]) ) 271 | return number(); 272 | else if( (c == '+' || c == '-') && la.size() == 2 && la[0] == '.' && isdigit(la[1]) ) 273 | return number(); // +/-. 274 | else 275 | return atom(); 276 | }else if( c == '"' ) 277 | { 278 | // this is a string 279 | if( !packed ) 280 | return token(Tok_DblQuote, 1); 281 | ungetc(c); 282 | return string(); 283 | }else if( c == '(' || c == '[' || c == ')' || c == ']' ) 284 | { 285 | const QByteArray la = peek(1); 286 | if( c == '(' && !la.isEmpty() && la[0] == '*' ) 287 | { 288 | if( !packed ) 289 | { 290 | readc(); 291 | return token(Tok_Lattr, 2); 292 | } 293 | ungetc(c); 294 | return comment(); 295 | } 296 | switch( c ) 297 | { 298 | case '(': 299 | return token(Tok_lpar,1); 300 | case '[': 301 | return token(Tok_lbrack,1); 302 | case ')': 303 | return token(Tok_rpar,1); 304 | case ']': 305 | return token(Tok_rbrack,1); 306 | } 307 | }else 308 | { 309 | // this is an atom 310 | ungetc(c); 311 | return atom(); 312 | } 313 | return Token(); 314 | } 315 | 316 | QList Lexer::tokens(const QString& code) 317 | { 318 | return tokens( code.toLatin1() ); 319 | } 320 | 321 | QList Lexer::tokens(const QByteArray& code, const QString& path) 322 | { 323 | QBuffer in; 324 | in.setData( code ); 325 | in.open(QIODevice::ReadOnly); 326 | setStream( &in, path ); 327 | 328 | QList res; 329 | Token t = nextToken(); 330 | while( t.isValid() ) 331 | { 332 | res << t; 333 | t = nextToken(); 334 | } 335 | return res; 336 | } 337 | 338 | void Lexer::startQuote() 339 | { 340 | inQuote = true; 341 | } 342 | 343 | void Lexer::endQuote() 344 | { 345 | inQuote = false; 346 | } 347 | 348 | Token Lexer::token(TokenType tt, int len, const QByteArray& val) 349 | { 350 | Token t( tt, start, len, val ); 351 | t.sourcePath = sourcePath; 352 | return t; 353 | } 354 | 355 | static inline int digit(char c) 356 | { 357 | if( c >= '0' && c <= '9' ) 358 | return c - '0'; 359 | else 360 | return -1; 361 | } 362 | 363 | bool Lexer::atom_delimiter(char c) 364 | { 365 | return isspace(c) || 366 | c == '(' || c == ')' || c == '[' || c == ']' || c == '"'; 367 | } 368 | 369 | Token Lexer::number() 370 | { 371 | enum Status { idle, dec_seq, dec_or_oct_seq, fraction, exponent, exponent2 } status = idle; 372 | char c = readc(); 373 | QByteArray number; 374 | number += c; 375 | if( c == '+' || c == '-' ) 376 | { 377 | status = dec_or_oct_seq; 378 | c = readc(); 379 | number += c; 380 | }else if( c == '.' ) 381 | { 382 | status = fraction; 383 | c = readc(); 384 | number += c; 385 | } 386 | 387 | while(true) 388 | { 389 | const int d = digit(c); 390 | switch(status) 391 | { 392 | case idle: 393 | if( d >= 0 && d <= 7 ) 394 | status = dec_or_oct_seq; 395 | else if( d == 8 || d == 9 ) 396 | status = dec_seq; 397 | else 398 | Q_ASSERT(false); 399 | break; 400 | case dec_or_oct_seq: 401 | case dec_seq: 402 | if( c == 'Q' ) 403 | { 404 | if( status == dec_seq ) 405 | return token(Tok_Invalid, number.size(), "invalid decimal number"); 406 | else 407 | { 408 | // octal number found 409 | bool ok; 410 | number.left(number.size()-1).toLongLong(&ok, 8); 411 | if( !ok ) 412 | return token(Tok_Invalid, number.size(), "invalid octal number"); 413 | else 414 | return token(Tok_integer, number.size(), number); 415 | } 416 | }else if( c == '.' ) 417 | status = fraction; 418 | else if( c == 'E' ) 419 | status = exponent; 420 | else if( atom_delimiter(c) ) 421 | { 422 | // not a digit and not an atom, break here 423 | number.chop(1); 424 | ungetc(c); 425 | return token(Tok_integer, number.size(), number); 426 | }else if( !isdigit(c) ) 427 | { 428 | ungetstr(number); 429 | return atom(); 430 | } 431 | // else: it's a digit 432 | break; 433 | case fraction: 434 | if( c == 'E' ) 435 | status = exponent; 436 | else if( atom_delimiter(c) ) 437 | { 438 | // not a digit and not and atom, break here 439 | number.chop(1); 440 | ungetc(c); 441 | bool ok; 442 | number.toDouble(&ok); 443 | if( !ok ) 444 | return token(Tok_Invalid, number.size(), "invalid float"); 445 | else 446 | return token(Tok_float, number.size(), number); 447 | }else if( !isdigit(c) ) 448 | { 449 | ungetstr(number); 450 | return atom(); 451 | } 452 | // else: it's a digit 453 | break; 454 | case exponent: 455 | if( c == '+' || c == '-' || d >= 0 ) 456 | status = exponent2; 457 | else 458 | return token(Tok_Invalid, number.size(), "invalid exponent"); 459 | break; 460 | case exponent2: 461 | if( atom_delimiter(c) ) 462 | { 463 | // not a digit and not an atom, break here 464 | number.chop(1); 465 | ungetc(c); 466 | bool ok; 467 | number.toDouble(&ok); 468 | if( !ok ) 469 | return token(Tok_Invalid, number.size(), "invalid float"); 470 | else 471 | return token(Tok_float, number.size(), number); 472 | }else if( !isdigit(c) ) 473 | { 474 | ungetstr(number); 475 | return atom(); 476 | } 477 | // else: it's a digit 478 | break; 479 | default: 480 | Q_ASSERT(false); 481 | } 482 | c = readc(); 483 | number += c; 484 | } 485 | Q_ASSERT(false); 486 | return Token(); 487 | } 488 | 489 | Token Lexer::atom() 490 | { 491 | QByteArray a; 492 | int extra = 0; 493 | while( true ) 494 | { 495 | char c = readc(); 496 | if( !inQuote && c == '%' ) 497 | { 498 | extra++; 499 | c = readc(); // escape 500 | }else if( c == 0 || atom_delimiter(c) || !isprint(c) ) 501 | { 502 | // atom can be terminated by 0x06 0x01, thus isprint(c) 503 | ungetc(c); 504 | break; 505 | } 506 | a += c; 507 | } 508 | a = Token::getSymbol(a); 509 | return token(Tok_atom, a.size() + extra, a); 510 | } 511 | 512 | Token Lexer::string() 513 | { 514 | char c = readc(); 515 | QByteArray str; 516 | str += c; 517 | int extra = 0; // count left and right quote 518 | while( true ) 519 | { 520 | c = readc(); 521 | if( c == '%' ) // QUOTE has no influence here, see MACHINEINDEPENDENT line 1327 522 | { 523 | extra++; 524 | c = readc(); // escape 525 | }else if( c == '"' ) 526 | { 527 | str += c; 528 | break; 529 | }else if( c == 0 ) 530 | break; 531 | str += c; 532 | } 533 | if( packed && c != '"' ) 534 | return token(Tok_Invalid, str.size() + extra, "unterminated string" ); 535 | return token(Tok_string, str.size() + extra, str); 536 | } 537 | 538 | Token Lexer::comment() 539 | { 540 | QByteArray str; 541 | // first eat (* 542 | char c = readc(); 543 | str += c; 544 | c = readc(); 545 | str += c; 546 | 547 | // now find end of comment considering included lists and strings 548 | int level = 0; 549 | bool inString = false; 550 | QList brackets; // bracket at level 551 | int extra = 0; 552 | while( true ) 553 | { 554 | c = readc(); 555 | if( c == 0 ) 556 | break; 557 | if( c == '%' ) 558 | { 559 | extra++; 560 | c = readc(); 561 | }else if( c == '"' ) 562 | { 563 | inString = !inString; 564 | }else if( !inString && c == '(' ) 565 | level++; 566 | else if( !inString && c == '[' ) 567 | { 568 | brackets << level; 569 | level++; 570 | }else if( !inString && c == ']' ) 571 | { 572 | if( brackets.isEmpty() ) 573 | { 574 | // the string is terminated by ], and we pass it back so that it 575 | // can continue to terminate until [ 576 | ungetc(c); 577 | c = ')'; 578 | str += c; 579 | break; 580 | } 581 | level = brackets.takeLast(); 582 | }else if( !inString && c == ')' ) 583 | { 584 | if( level == 0 ) 585 | { 586 | if( !brackets.isEmpty() ) 587 | return token(Tok_Invalid, str.size() + extra, "unterminated bracket in comment"); 588 | str += c; 589 | break; 590 | } 591 | level--; 592 | } 593 | str += c; 594 | } 595 | if( packed && c != ')') 596 | return token(Tok_Invalid, str.size() + extra, "unterminated comment" ); 597 | return token(Tok_comment, str.size() + extra, str); 598 | } 599 | 600 | void Lexer::skipWhiteSpace() 601 | { 602 | char c = readc(); 603 | if( c == 0 ) 604 | return; 605 | 606 | while( true ) 607 | { 608 | while( isspace(c) || !isprint(c) ) 609 | // seen in Fugue-2: c == 0x06 || c == 0x1e || c == 12 || c == 1 || c == 27 || c == 127 || c == -32 ) 610 | { 611 | if( c == 0x06 ) 612 | readc(); // skip next 613 | c = readc(); 614 | if( c == 0 ) 615 | return; 616 | } 617 | break; 618 | } 619 | ungetc(c); 620 | } 621 | -------------------------------------------------------------------------------- /LispLexer.h: -------------------------------------------------------------------------------- 1 | #ifndef LISPLEXER_H 2 | #define LISPLEXER_H 3 | 4 | /* 5 | * Copyright 2024 Rochus Keller 6 | * 7 | * This file is part of the Interlisp project. 8 | * 9 | * The following is the license that applies to this copy of the 10 | * library. For a license to use the library under conditions 11 | * other than those described here, please email to me@rochus-keller.ch. 12 | * 13 | * GNU General Public License Usage 14 | * This file may be used under the terms of the GNU General Public 15 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 16 | * Foundation and appearing in the file LICENSE.GPL included in 17 | * the packaging of this file. Please review the following information 18 | * to ensure GNU General Public Licensing requirements will be met: 19 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 20 | * http://www.gnu.org/copyleft/gpl.html. 21 | */ 22 | 23 | // Adopted from the Luon project 24 | 25 | #include 26 | #include "LispRowCol.h" 27 | 28 | class QIODevice; 29 | 30 | namespace Lisp 31 | { 32 | 33 | enum TokenType { 34 | Tok_Invalid, 35 | Tok_Eof, 36 | Tok_lpar, 37 | Tok_rpar, 38 | Tok_lbrack, 39 | Tok_rbrack, 40 | Tok_string, 41 | Tok_atom, 42 | Tok_float, 43 | Tok_integer, 44 | Tok_comment, 45 | Tok_Lattr, // (* 46 | Tok_DblQuote, // " 47 | }; 48 | 49 | struct Token 50 | { 51 | #ifdef _DEBUG 52 | union 53 | { 54 | int type; // TokenType 55 | TokenType tokenType; 56 | }; 57 | #else 58 | quint16 type; // TokenType 59 | #endif 60 | quint16 len; 61 | 62 | RowCol pos; 63 | 64 | QByteArray val; 65 | QString sourcePath; 66 | Token(quint16 t = Tok_Invalid, const RowCol& rc = RowCol(), quint16 len = 0, const QByteArray& val = QByteArray() ): 67 | type(t),pos(rc),len(len),val(val){} 68 | bool isValid() const; 69 | bool isEof() const; 70 | const char* getName() const; 71 | const char* getString() const; 72 | 73 | static QByteArray getSymbol( const QByteArray& ); 74 | static QByteArrayList getAllSymbols(); 75 | }; 76 | 77 | class Lexer : public QObject 78 | { 79 | public: 80 | Lexer(QObject *parent = 0); 81 | 82 | void setStream( QIODevice*, const QString& sourcePath ); 83 | void setStream(const QByteArray& code, const QString& sourcePath ); 84 | bool setStream(const QString& sourcePath); 85 | 86 | Token nextToken(); 87 | Token readString(); 88 | void unget(const Token&); 89 | QList tokens( const QString& code ); 90 | QList tokens( const QByteArray& code, const QString& path = QString() ); 91 | QString getSource() const { return sourcePath; } 92 | void setEmitComments(bool on) { emitComments = on; } 93 | void setPacked(bool on) { packed = on; } 94 | RowCol getPos() const { return pos; } 95 | void startQuote(); 96 | void endQuote(); 97 | 98 | static bool atom_delimiter(char); 99 | 100 | protected: 101 | Token nextTokenImp(); 102 | char readc(); 103 | void ungetc(char c); 104 | QByteArray peek(int count); 105 | void ungetstr(const QByteArray& str); 106 | Token token(TokenType tt, int len = 0, const QByteArray &val = QByteArray()); 107 | Token number(); 108 | Token atom(); 109 | Token string(); 110 | Token comment(); 111 | void skipWhiteSpace(); 112 | 113 | private: 114 | QIODevice* in; 115 | RowCol pos, start; 116 | QString sourcePath; 117 | QList buffer; 118 | bool emitComments; 119 | bool packed; 120 | bool inQuote; 121 | }; 122 | 123 | } 124 | 125 | #endif // LISPLEXER_H 126 | -------------------------------------------------------------------------------- /LispNavigator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Rochus Keller 3 | * 4 | * This file is part of the Interlisp project. 5 | * 6 | * The following is the license that applies to this copy of the 7 | * file. For a license to use the file under conditions 8 | * other than those described here, please email to me@rochus-keller.ch. 9 | * 10 | * GNU General Public License Usage 11 | * This file may be used under the terms of the GNU General Public 12 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 13 | * Foundation and appearing in the file LICENSE.GPL included in 14 | * the packaging of this file. Please review the following information 15 | * to ensure GNU General Public Licensing requirements will be met: 16 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 17 | * http://www.gnu.org/copyleft/gpl.html. 18 | */ 19 | // Adopted from the Lisa Pascal Navigator 20 | 21 | #include "LispNavigator.h" 22 | #include "LispReader.h" 23 | #include "LispLexer.h" 24 | #include "LispBuiltins.h" 25 | #include "LispHighlighter.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | static Navigator* s_this = 0; 50 | static void report(QtMsgType type, const QString& message ) 51 | { 52 | if( s_this ) 53 | { 54 | switch(type) 55 | { 56 | case QtDebugMsg: 57 | s_this->logMessage(QString("INF: ") + message); 58 | break; 59 | case QtWarningMsg: 60 | s_this->logMessage(QString("WRN: ") + message); 61 | break; 62 | case QtCriticalMsg: 63 | case QtFatalMsg: 64 | s_this->logMessage(QString("ERR: ") + message); 65 | break; 66 | } 67 | } 68 | } 69 | 70 | static QtMessageHandler s_oldHandler = 0; 71 | void messageHander(QtMsgType type, const QMessageLogContext& ctx, const QString& message) 72 | { 73 | if( s_oldHandler ) 74 | s_oldHandler(type, ctx, message ); 75 | report(type,message); 76 | } 77 | 78 | class Navigator::Viewer : public CodeEditor 79 | { 80 | public: 81 | Viewer(Navigator* p):CodeEditor(p),d_ide(p),d_list(0) 82 | { 83 | setCharPerTab(3); 84 | setShowNumbers(true); 85 | setPaintIndents(false); 86 | setReadOnly(true); 87 | installDefaultPopup(); 88 | d_hl = new Lisp::Highlighter( document() ); 89 | for(int i = 0; Lisp::Builtins::functions[i]; i++) 90 | { 91 | const char* str = Lisp::Builtins::functions[i]; 92 | d_hl->addFunction(Lisp::Token::getSymbol(QByteArray::fromRawData(str, strlen(str))).constData()); 93 | str++; 94 | } 95 | for(int i = 0; Lisp::Builtins::variables[i]; i++) 96 | { 97 | const char* str = Lisp::Builtins::variables[i]; 98 | d_hl->addVariable(Lisp::Token::getSymbol(QByteArray::fromRawData(str, strlen(str))).constData()); 99 | str++; 100 | } 101 | 102 | QSettings set; 103 | if( !set.contains("CodeEditor/Font") ) 104 | { 105 | #if defined(Q_OS_WIN32) 106 | QFont monospace("Consolas"); 107 | #elif defined(Q_OS_MAC) 108 | QFont monospace("SF Mono"); 109 | #else 110 | QFont monospace("Monospace"); 111 | #endif 112 | if( !monospace.exactMatch() ) 113 | monospace = QFont("DejaVu Sans Mono"); 114 | if( monospace.pointSizeF() < 10.0 ) 115 | monospace.setPointSizeF(10); 116 | setFont(monospace); 117 | } 118 | 119 | updateTabWidth(); 120 | } 121 | 122 | ~Viewer() 123 | { 124 | } 125 | 126 | Navigator* d_ide; 127 | Lisp::Highlighter* d_hl; 128 | Lisp::Reader::List* d_list; 129 | 130 | void clearBackHisto() 131 | { 132 | d_backHisto.clear(); 133 | } 134 | 135 | void markNonTerms(const Lisp::Reader::Refs& syms) 136 | { 137 | d_nonTerms.clear(); 138 | QTextCharFormat format; 139 | format.setBackground( QColor(237,235,243) ); 140 | foreach( const Lisp::Reader::Ref& s, syms ) 141 | { 142 | QTextCursor c( document()->findBlockByNumber( qMax(int(s.pos.row - 1),0)) ); 143 | c.setPosition( c.position() + qMax(int(s.pos.col - 1), 0) ); 144 | int pos = c.position(); 145 | c.setPosition( pos + s.len, QTextCursor::KeepAnchor ); 146 | 147 | QTextEdit::ExtraSelection sel; 148 | sel.format = format; 149 | sel.cursor = c; 150 | 151 | d_nonTerms << sel; 152 | } 153 | updateExtraSelections(); 154 | } 155 | 156 | static inline void crosslineColors(QTextCharFormat& f, int level) 157 | { 158 | level++; 159 | QColor bgClr = QColor::fromRgb( 255, 254, 225 ); // Gelblich 160 | bgClr = QColor::fromHsv( bgClr.hue(), bgClr.saturation(), bgClr.value() - ( level*2 - 1 ) * 3 ); 161 | f.setBackground(bgClr); 162 | } 163 | 164 | static inline QColor pastelColor() { 165 | return QColor(180 + rand() % 76, 180 + rand() % 76, 180 + rand() % 76); 166 | } 167 | 168 | void colorList( ESL& sum, Lisp::Reader::List* l, int level = 0 ) 169 | { 170 | const Lisp::RowCol start = l->getStart(); 171 | 172 | QTextCursor a( document()->findBlockByNumber( start.row - 1) ); 173 | //a.setPosition( a.position() + start.col - 1 + 1 ); // without lpar 174 | a.setPosition( a.position() + start.col - 1 ); // with lpar 175 | QTextCursor b( document()->findBlockByNumber( l->end.row - 1) ); 176 | b.setPosition( b.position() + l->end.col - 1 ); 177 | const int posb = b.position(); 178 | //a.setPosition( posb, QTextCursor::KeepAnchor ); // without rpar 179 | a.setPosition( posb + 1, QTextCursor::KeepAnchor ); // with rpar 180 | 181 | QTextEdit::ExtraSelection sel; 182 | #if 1 183 | //sel.format.setBackground(QColor(Qt::red).lighter(195 - (level % 10) * 5)); 184 | sel.format.setBackground(QColor(Qt::red).lighter(195 - level * 5)); 185 | #else 186 | if( level < 9 ) 187 | sel.format.setBackground(QColor(Qt::red).lighter(195 - level * 5)); 188 | else 189 | sel.format.setBackground(QColor(Qt::magenta).lighter(195 - (level-7) * 5)); 190 | #endif 191 | // crosslineColors(sel.format); 192 | sel.cursor = a; 193 | sum << sel; 194 | for( int i = 0; i < l->list.size(); i++ ) 195 | { 196 | if( l->list[i].type() == Lisp::Reader::Object::List_ ) 197 | colorList(sum, l->list[i].getList(), level + 1); 198 | } 199 | } 200 | 201 | void updateExtraSelections() 202 | { 203 | ESL sum; 204 | 205 | QTextEdit::ExtraSelection line; 206 | line.format.setBackground(QColor(Qt::yellow).lighter(170)); 207 | line.format.setProperty(QTextFormat::FullWidthSelection, true); 208 | line.cursor = textCursor(); 209 | line.cursor.clearSelection(); 210 | sum << line; 211 | 212 | if( d_list && d_list->outer ) 213 | colorList(sum, d_list); 214 | 215 | sum << d_nonTerms; 216 | 217 | 218 | sum << d_link; 219 | 220 | 221 | setExtraSelections(sum); 222 | } 223 | 224 | void mousePressEvent(QMouseEvent* e) 225 | { 226 | if( !d_link.isEmpty() ) 227 | { 228 | QTextCursor cur = cursorForPosition(e->pos()); 229 | d_ide->pushLocation( Navigator::Location( getPath(), cur.blockNumber(), cur.positionInBlock(), verticalScrollBar()->value() ) ); 230 | QApplication::restoreOverrideCursor(); 231 | d_link.clear(); 232 | } 233 | if( QApplication::keyboardModifiers() == Qt::ControlModifier ) 234 | { 235 | QTextCursor cur = cursorForPosition(e->pos()); 236 | QPair res = d_ide->findSymbolBySourcePos( 237 | getPath(),cur.blockNumber() + 1,cur.positionInBlock() + 1); 238 | if( res.first && res.first->outer ) 239 | d_list = res.first; 240 | else 241 | d_list = 0; 242 | if( res.first ) 243 | { 244 | d_ide->pushLocation( Navigator::Location( getPath(), cur.blockNumber(), cur.positionInBlock(), verticalScrollBar()->value() ) ); 245 | if( res.second >= 0 ) 246 | d_ide->showPosition( res.first->elementPositions[res.second] ); 247 | }else 248 | d_list = 0; 249 | updateExtraSelections(); 250 | }else 251 | QPlainTextEdit::mousePressEvent(e); 252 | } 253 | 254 | void mouseMoveEvent(QMouseEvent* e) 255 | { 256 | QPlainTextEdit::mouseMoveEvent(e); 257 | if( QApplication::keyboardModifiers() == Qt::ControlModifier ) 258 | { 259 | QTextCursor cur = cursorForPosition(e->pos()); 260 | QPair res = d_ide->findSymbolBySourcePos( 261 | getPath(),cur.blockNumber() + 1,cur.positionInBlock() + 1); 262 | const bool alreadyArrow = !d_link.isEmpty(); 263 | d_link.clear(); 264 | if( res.first && res.second >= 0 && res.first->list[res.second].type() == Lisp::Reader::Object::Atom_) 265 | { 266 | Q_ASSERT( res.first ); 267 | const int off = cur.positionInBlock() + 1 - res.first->elementPositions[res.second].col; 268 | cur.setPosition(cur.position() - off); 269 | cur.setPosition( cur.position() + res.first->list[res.second].getAtomLen(), QTextCursor::KeepAnchor ); 270 | 271 | QTextEdit::ExtraSelection sel; 272 | sel.cursor = cur; 273 | sel.format.setFontUnderline(true); 274 | d_link << sel; 275 | if( !alreadyArrow ) 276 | QApplication::setOverrideCursor(Qt::ArrowCursor); 277 | } 278 | if( alreadyArrow && d_link.isEmpty() ) 279 | QApplication::restoreOverrideCursor(); 280 | updateExtraSelections(); 281 | }else if( !d_link.isEmpty() ) 282 | { 283 | QApplication::restoreOverrideCursor(); 284 | d_link.clear(); 285 | updateExtraSelections(); 286 | } 287 | } 288 | 289 | void onUpdateModel() 290 | { 291 | markNonTerms(Lisp::Reader::Refs()); 292 | } 293 | }; 294 | 295 | Navigator::Navigator(QWidget *parent) 296 | : QMainWindow(parent), d_pushBackLock(false),d_lock3(false) 297 | { 298 | QWidget* pane = new QWidget(this); 299 | QVBoxLayout* vbox = new QVBoxLayout(pane); 300 | vbox->setMargin(0); 301 | vbox->setSpacing(0); 302 | 303 | title = new QLabel(this); 304 | title->setMargin(2); 305 | title->setWordWrap(true); 306 | title->setTextInteractionFlags(Qt::TextSelectableByMouse); 307 | vbox->addWidget(title); 308 | 309 | viewer = new Viewer(this); 310 | connect(viewer,SIGNAL(cursorPositionChanged()),this,SLOT(onCursor())); 311 | connect(viewer,SIGNAL(sigUpdateLocation(int,int)),this,SLOT(onUpdateLocation(int,int))); 312 | 313 | vbox->addWidget(viewer); 314 | 315 | setCentralWidget(pane); 316 | 317 | setDockNestingEnabled(true); 318 | setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea ); 319 | setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea ); 320 | setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea ); 321 | setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea ); 322 | 323 | createSourceTree(); 324 | createXref(); 325 | createLog(); 326 | createAtomList(); 327 | createProperties(); 328 | 329 | s_this = this; 330 | s_oldHandler = qInstallMessageHandler(messageHander); 331 | 332 | QSettings s; 333 | 334 | const QRect screen = QApplication::desktop()->screenGeometry(); 335 | resize( screen.width() - 20, screen.height() - 30 ); // so that restoreState works 336 | if( s.value("Fullscreen").toBool() ) 337 | showFullScreen(); 338 | else 339 | showMaximized(); 340 | 341 | const QVariant state = s.value( "DockState" ); 342 | if( !state.isNull() ) 343 | restoreState( state.toByteArray() ); 344 | 345 | new Gui::AutoShortcut( tr("ALT+Left"), this, this, SLOT(handleGoBack()) ); 346 | new Gui::AutoShortcut( tr("ALT+Right"), this, this, SLOT(handleGoForward()) ); 347 | new Gui::AutoShortcut( tr("CTRL+F"), this, viewer, SLOT(handleFind()) ); 348 | new Gui::AutoShortcut( tr("F3"), this, viewer, SLOT(handleFindAgain()) ); 349 | new Gui::AutoShortcut( tr("CTRL+G"), this, viewer, SLOT(handleGoto()) ); 350 | new QShortcut(tr("CTRL+SHIFT+F"),this,SLOT(onSearchAtom())); 351 | new QShortcut(tr("CTRL+SHIFT+A"),this,SLOT(onSelectAtom())); 352 | new QShortcut(tr("CTRL+O"),this,SLOT(onOpen()) ); 353 | 354 | } 355 | 356 | Navigator::~Navigator() 357 | { 358 | 359 | } 360 | 361 | static inline QString debang( const QString& str ) 362 | { 363 | const int pos = str.lastIndexOf('!'); 364 | if( pos == -1 ) 365 | return str; 366 | else 367 | return str.left(pos); 368 | } 369 | 370 | static QString decode(const QByteArray& source) 371 | { 372 | QByteArray bytes; 373 | const int len = source.size(); 374 | for( int i = 0; i < len; i++ ) 375 | { 376 | const char ch = source[i]; 377 | if( ch == '\r' ) 378 | { 379 | if( i >= len-1 || source[i+1] != '\n' ) 380 | bytes += '\n'; 381 | else 382 | bytes += ' '; 383 | }else if( ch == '_' ) 384 | bytes += "←"; 385 | else if( ch == '^' ) 386 | bytes += "↑"; 387 | else if( isprint(ch) || isspace(ch) ) 388 | bytes += ch; 389 | else if( !bytes.isEmpty() && bytes[bytes.size()-1] == '%' ) 390 | bytes += ' '; 391 | } 392 | return QString::fromUtf8(bytes); 393 | } 394 | 395 | static QStringList collectFiles( const QDir& dir ) 396 | { 397 | QStringList res; 398 | QStringList files = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name ); 399 | 400 | foreach( const QString& f, files ) 401 | res += collectFiles( QDir( dir.absoluteFilePath(f) ) ); 402 | 403 | const QStringList all = dir.entryList(QDir::Files, QDir::Name); 404 | QMap check; 405 | bool hasCompiled = false; 406 | foreach( const QString& a, all ) 407 | { 408 | QFileInfo info(a); 409 | const QString suff = debang(info.suffix().toLower()); 410 | if( suff.isEmpty() || suff == "lisp" ) 411 | check.insert(debang(info.baseName().toLower()), a); 412 | // not relibale; some source trees have lcom/dcom for a random subset of source files 413 | // if( suff == "lcom" || suff == "dfasl" || suff == "dcom" ) 414 | // hasCompiled = true; 415 | } 416 | 417 | foreach( const QString& a, all ) 418 | { 419 | QFileInfo info(a); 420 | if( !hasCompiled ) 421 | { 422 | const QString suff = debang(info.suffix().toLower()); 423 | if( suff == "dump" || suff == "lcom" || suff == "dfasl" || suff == "dcom" ) 424 | continue; 425 | QFile f(dir.absoluteFilePath(a)); 426 | if( f.open(QIODevice::ReadOnly) ) 427 | { 428 | const QString header = decode(f.read(20)); 429 | if( header.startsWith("(FILECREATED") || header.startsWith("(DEFINE-FILE-INFO") ) 430 | res.append(f.fileName()); 431 | else 432 | qDebug() << "no source file" << f.fileName(); 433 | } 434 | }else 435 | { 436 | const QString suff = debang(info.suffix().toLower()); 437 | if( suff == "lcom" || suff == "dfasl" || suff == "dcom" ) 438 | { 439 | const QString name = check.value(debang(info.baseName().toLower())); 440 | if( !name.isEmpty() ) 441 | res.append(dir.absoluteFilePath(name)); 442 | else 443 | qDebug() << "no source found for" << dir.absoluteFilePath(a); 444 | } 445 | } 446 | } 447 | return res; 448 | } 449 | 450 | void Navigator::load(const QString& path) 451 | { 452 | setWindowTitle(QString("%1 - Interlisp Navigator %2").arg(path).arg(QApplication::applicationVersion())); 453 | QDir::setCurrent(path); 454 | tree->clear(); 455 | title->clear(); 456 | viewer->clear(); 457 | viewer->d_list = 0; 458 | asts.clear(); 459 | xref.clear(); 460 | atoms.clear(); 461 | atomList->clear(); 462 | root = path; 463 | sourceFiles = collectFiles(path); 464 | QMap dirs; 465 | QFileIconProvider fip; 466 | foreach( const QString& f, sourceFiles) 467 | { 468 | QFileInfo info(f); 469 | QString prefix = info.path().mid(path.size()+1); 470 | QTreeWidgetItem* super = 0; 471 | if( !prefix.isEmpty() ) 472 | { 473 | super = dirs.value(prefix); 474 | if( super == 0 ) 475 | { 476 | super = new QTreeWidgetItem(tree,1); 477 | super->setText(0,prefix); 478 | super->setIcon(0, fip.icon(QFileIconProvider::Folder)); 479 | dirs[prefix] = super; 480 | } 481 | } 482 | QTreeWidgetItem* item; 483 | if( super ) 484 | item = new QTreeWidgetItem(super); 485 | else 486 | item = new QTreeWidgetItem(tree); 487 | item->setText(0, debang(info.baseName()) ); 488 | item->setIcon(0, fip.icon(QFileIconProvider::File)); 489 | item->setData(0,Qt::UserRole, f); 490 | item->setToolTip(0,f); 491 | 492 | #if 0 493 | Lisp::Lexer lex; 494 | lex.setStream(&in, f); 495 | Lisp::Token t = lex.nextToken(); 496 | while(t.isValid()) 497 | { 498 | qDebug() << t.getName() << t.pos.row << t.pos.col << t.val; 499 | t = lex.nextToken(); 500 | } 501 | if( !t.isEof() ) 502 | qCritical() << t.getName() << t.pos.row << t.pos.col << t.val; 503 | #endif 504 | } 505 | QTimer::singleShot(500,this,SLOT(onRunParser())); 506 | } 507 | 508 | void Navigator::logMessage(const QString& str) 509 | { 510 | d_msgLog->parentWidget()->show(); 511 | d_msgLog->appendPlainText(str); 512 | } 513 | 514 | void Navigator::fileDoubleClicked(QTreeWidgetItem* item, int) 515 | { 516 | if( item->type() ) 517 | return; 518 | if( QApplication::keyboardModifiers() == Qt::ControlModifier ) 519 | openGenerated(item->data(0, Qt::UserRole).toString()); 520 | else 521 | showFile(item->data(0, Qt::UserRole).toString()); 522 | } 523 | 524 | void Navigator::handleGoBack() 525 | { 526 | ENABLED_IF( d_backHisto.size() > 1 ); 527 | 528 | d_pushBackLock = true; 529 | d_forwardHisto.push_back( d_backHisto.last() ); 530 | d_backHisto.pop_back(); 531 | showFile( d_backHisto.last() ); 532 | d_pushBackLock = false; 533 | } 534 | 535 | void Navigator::handleGoForward() 536 | { 537 | ENABLED_IF( !d_forwardHisto.isEmpty() ); 538 | 539 | Location cur = d_forwardHisto.last(); 540 | d_forwardHisto.pop_back(); 541 | showFile( cur ); 542 | } 543 | 544 | void Navigator::onXrefDblClicked() 545 | { 546 | QTreeWidgetItem* item = d_xref->currentItem(); 547 | if( item ) 548 | { 549 | Lisp::Reader::Ref sym = item->data(0,Qt::UserRole).value(); // Ref 550 | QString path = item->data(1,Qt::UserRole).toString(); // path 551 | d_lock3 = true; 552 | showFile( path, sym.pos); 553 | d_lock3 = false; 554 | } 555 | } 556 | 557 | void Navigator::onCursor() 558 | { 559 | int line, col; 560 | viewer->getCursorPosition( &line, &col ); 561 | line += 1; 562 | col += 1; 563 | 564 | QPair res = findSymbolBySourcePos(viewer->getPath(), line, col); 565 | if( res.first ) 566 | { 567 | viewer->d_list = res.first; 568 | if( res.second >= 0 && res.first->list[res.second].type() == Lisp::Reader::Object::Atom_ ) 569 | { 570 | const char* atom = res.first->list[res.second].getAtom(); 571 | Lisp::RowCol rc; 572 | if( res.second < res.first->elementPositions.size() ) 573 | rc = res.first->elementPositions[res.second]; 574 | syncSelectedAtom(atom,rc); 575 | }else 576 | { 577 | d_xrefTitle->clear(); 578 | d_xref->clear(); 579 | viewer->updateExtraSelections(); 580 | } 581 | }else 582 | { 583 | viewer->d_list = 0; 584 | viewer->markNonTerms(Lisp::Reader::Refs()); 585 | } 586 | } 587 | 588 | void Navigator::onUpdateLocation(int line, int col) 589 | { 590 | if( line == 0 || col == 0 ) 591 | return; 592 | viewer->clearBackHisto(); 593 | pushLocation(Location(viewer->getPath(), line,col,viewer->verticalScrollBar()->value())); 594 | } 595 | 596 | void Navigator::onSearchAtom() 597 | { 598 | const QString pname = QInputDialog::getText(this, "Search Atom", "Enter an atom pname (case sensitive)"); 599 | if( pname.isEmpty() ) 600 | return; 601 | const char* atom = Lisp::Token::getSymbol(pname.toUtf8()); 602 | syncSelectedAtom(atom, Lisp::RowCol()); 603 | } 604 | 605 | void Navigator::onSelectAtom() 606 | { 607 | QStringList l; 608 | QByteArrayList raw = Lisp::Token::getAllSymbols(); 609 | foreach( const QByteArray& a, raw) 610 | l << decode(a); 611 | l.sort(Qt::CaseInsensitive); 612 | const QString pname = QInputDialog::getItem(this, "Select Atom", "Select an atom from the list:", l ); 613 | if( pname.isEmpty() ) 614 | return; 615 | const char* atom = Lisp::Token::getSymbol(pname.toUtf8()); 616 | syncSelectedAtom(atom, Lisp::RowCol()); 617 | } 618 | 619 | void Navigator::onAtomDblClicked(QListWidgetItem* item) 620 | { 621 | const char* atom = item->data(Qt::UserRole).toByteArray().constData(); 622 | syncSelectedAtom(atom, Lisp::RowCol()); 623 | } 624 | 625 | void Navigator::onRunParser() 626 | { 627 | QElapsedTimer t; 628 | t.start(); 629 | QApplication::setOverrideCursor(Qt::WaitCursor); 630 | 631 | foreach( const QString& f, sourceFiles) 632 | { 633 | QFile in(f); 634 | QFileInfo info(f); 635 | if( !in.open(QFile::ReadOnly) ) 636 | { 637 | qCritical() << "cannot open file for reading" << info.baseName(); 638 | continue; 639 | } 640 | Lisp::Reader r; 641 | qDebug() << "*** parsing" << info.baseName(); 642 | if( !r.read(&in, f) ) 643 | { 644 | qCritical() << "ERROR " << info.baseName() << r.getPos().row << r.getError(); 645 | } 646 | // else 647 | { 648 | Lisp::Reader::Object ast = r.getAst(); 649 | asts.insert(f, ast); 650 | 651 | Lisp::Reader::Xref::const_iterator i; 652 | for( i = r.getXref().begin(); i != r.getXref().end(); ++i ) 653 | xref[i.key()][f].append(i.value() ); 654 | 655 | Lisp::Reader::Atoms::const_iterator j; 656 | for( j = r.getAtoms().begin(); j != r.getAtoms().end(); ++j ) 657 | { 658 | Lisp::Reader::Atom& a = atoms[j.key()]; 659 | a.props.unite(j.value().props); 660 | #if 0 661 | qDebug() << "**** atom" << j.key() << "properties"; 662 | for( Lisp::Reader::Properties::const_iterator k = a.props.begin(); k != a.props.end(); ++k ) 663 | qDebug() << " " << k.key() << "=" << k.value().toString(); 664 | #endif 665 | } 666 | 667 | #if 0 668 | QTextStream out; 669 | QFile file(f + ".dump"); 670 | if( file.open(QFile::WriteOnly) ) 671 | { 672 | out.setDevice(&file); 673 | ast.print(out); 674 | } 675 | #endif 676 | #if 0 677 | QFile file(f + ".lisp"); 678 | if( file.open(QFile::WriteOnly) ) 679 | { 680 | in.reset(); 681 | QString code = decode(in.readAll()); 682 | file.write( code.toUtf8() ); 683 | } 684 | #endif 685 | } 686 | } 687 | 688 | QApplication::restoreOverrideCursor(); 689 | qDebug() << "parsed" << sourceFiles.size() << "files in" << t.elapsed() << "[ms]"; 690 | 691 | fillAtomList(); 692 | } 693 | 694 | void Navigator::onOpen() 695 | { 696 | QString path = QFileDialog::getExistingDirectory(this,tr("Open Project Directory"),QDir::currentPath() ); 697 | if( path.isEmpty() ) 698 | return; 699 | load(path); 700 | } 701 | 702 | void Navigator::onPropertiesDblClicked(QTreeWidgetItem* item, int) 703 | { 704 | syncSelectedAtom(item->data(0, Qt::UserRole).toByteArray().constData(), Lisp::RowCol()); 705 | } 706 | 707 | void Navigator::pushLocation(const Navigator::Location& loc) 708 | { 709 | if( d_pushBackLock ) 710 | return; 711 | if( !d_backHisto.isEmpty() && d_backHisto.last() == loc ) 712 | return; // o ist bereits oberstes Element auf dem Stack. 713 | d_backHisto.removeAll( loc ); 714 | d_backHisto.push_back( loc ); 715 | } 716 | 717 | void Navigator::showFile(const QString& file) 718 | { 719 | QFile f(file); 720 | viewer->d_list = 0; 721 | if( !f.open(QIODevice::ReadOnly) ) 722 | { 723 | viewer->setPlainText(tr("; cannot open file %1").arg(f.fileName())); 724 | title->clear(); 725 | return; 726 | } 727 | title->setText(debang(f.fileName().mid(root.size()+1))); 728 | const QString text = decode(f.readAll()); 729 | viewer->loadFromString(text, file); 730 | } 731 | 732 | void Navigator::showFile(const QString& file, const Lisp::RowCol& pos) 733 | { 734 | showFile(file); 735 | if( !file.isEmpty() ) 736 | showPosition(pos); 737 | } 738 | 739 | void Navigator::openGenerated(const QString& file) 740 | { 741 | Navigator::Viewer* v = new Navigator::Viewer(0); 742 | v->d_ide = this; 743 | v->setAttribute(Qt::WA_DeleteOnClose); 744 | Lisp::Reader::Object obj = asts.value(file); 745 | QString code; 746 | QTextStream out(&code); 747 | obj.print(out); 748 | v->setWindowTitle(tr("%1 - Generated").arg(file)); 749 | v->loadFromString(code,file); 750 | v->showMaximized(); 751 | } 752 | 753 | void Navigator::showPosition(const Lisp::RowCol& pos) 754 | { 755 | if( pos.row > 0 && pos.col > 0 ) 756 | { 757 | viewer->setCursorPosition( pos.row-1, pos.col-1, true ); 758 | } 759 | } 760 | 761 | void Navigator::showFile(const Navigator::Location& loc) 762 | { 763 | showFile(loc.d_file, Lisp::RowCol(loc.d_line+1, loc.d_col+1) ); 764 | viewer->verticalScrollBar()->setValue(loc.d_yoff); 765 | } 766 | 767 | void Navigator::createSourceTree() 768 | { 769 | QDockWidget* dock = new QDockWidget( tr("Source Tree"), this ); 770 | dock->setObjectName("SourceTree"); 771 | dock->setAllowedAreas( Qt::AllDockWidgetAreas ); 772 | dock->setFeatures( QDockWidget::DockWidgetMovable ); 773 | tree = new QTreeWidget(dock); 774 | tree->setAlternatingRowColors(true); 775 | tree->setHeaderHidden(true); 776 | tree->setSortingEnabled(false); 777 | tree->setAllColumnsShowFocus(true); 778 | tree->setRootIsDecorated(true); 779 | dock->setWidget(tree); 780 | addDockWidget( Qt::LeftDockWidgetArea, dock ); 781 | connect( tree,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this, SLOT(fileDoubleClicked(QTreeWidgetItem*,int))); 782 | } 783 | 784 | void Navigator::createXref() 785 | { 786 | QDockWidget* dock = new QDockWidget( tr("Xref"), this ); 787 | dock->setObjectName("Xref"); 788 | dock->setAllowedAreas( Qt::AllDockWidgetAreas ); 789 | dock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable ); 790 | QWidget* pane = new QWidget(dock); 791 | QVBoxLayout* vbox = new QVBoxLayout(pane); 792 | vbox->setMargin(0); 793 | vbox->setSpacing(0); 794 | d_xrefTitle = new QLabel(pane); 795 | d_xrefTitle->setMargin(2); 796 | d_xrefTitle->setWordWrap(true); 797 | vbox->addWidget(d_xrefTitle); 798 | d_xref = new QTreeWidget(pane); 799 | d_xref->setAlternatingRowColors(true); 800 | d_xref->setHeaderHidden(true); 801 | d_xref->setAllColumnsShowFocus(true); 802 | d_xref->setRootIsDecorated(false); 803 | vbox->addWidget(d_xref); 804 | dock->setWidget(pane); 805 | addDockWidget( Qt::RightDockWidgetArea, dock ); 806 | connect(d_xref, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(onXrefDblClicked()) ); 807 | } 808 | 809 | void Navigator::createLog() 810 | { 811 | QDockWidget* dock = new QDockWidget( tr("Message Log"), this ); 812 | dock->setObjectName("Log"); 813 | dock->setAllowedAreas( Qt::AllDockWidgetAreas ); 814 | dock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable ); 815 | d_msgLog = new QPlainTextEdit(dock); 816 | d_msgLog->setReadOnly(true); 817 | d_msgLog->setLineWrapMode( QPlainTextEdit::NoWrap ); 818 | dock->setWidget(d_msgLog); 819 | addDockWidget( Qt::BottomDockWidgetArea, dock ); 820 | new QShortcut(tr("ESC"), dock, SLOT(close()) ); 821 | } 822 | 823 | void Navigator::createAtomList() 824 | { 825 | QDockWidget* dock = new QDockWidget( tr("Atoms"), this ); 826 | dock->setObjectName("AtomList"); 827 | dock->setAllowedAreas( Qt::AllDockWidgetAreas ); 828 | dock->setFeatures( QDockWidget::DockWidgetMovable ); 829 | atomList = new QListWidget(dock); 830 | atomList->setAlternatingRowColors(true); 831 | atomList->setSortingEnabled(false); 832 | dock->setWidget(atomList); 833 | addDockWidget( Qt::LeftDockWidgetArea, dock ); 834 | connect( atomList,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(onAtomDblClicked(QListWidgetItem*))); 835 | } 836 | 837 | void Navigator::createProperties() 838 | { 839 | QDockWidget* dock = new QDockWidget( tr("Properties"), this ); 840 | dock->setObjectName("Properties"); 841 | dock->setAllowedAreas( Qt::AllDockWidgetAreas ); 842 | dock->setFeatures( QDockWidget::DockWidgetMovable ); 843 | QWidget* pane = new QWidget(dock); 844 | QVBoxLayout* vbox = new QVBoxLayout(pane); 845 | vbox->setMargin(0); 846 | vbox->setSpacing(0); 847 | propTitle = new QLabel(pane); 848 | propTitle->setMargin(2); 849 | propTitle->setWordWrap(true); 850 | vbox->addWidget(propTitle); 851 | properties = new QTreeWidget(pane); 852 | properties->setAlternatingRowColors(true); 853 | properties->setHeaderLabels(QStringList() << "Key" << "Value"); 854 | properties->setAllColumnsShowFocus(true); 855 | properties->setRootIsDecorated(false); 856 | properties->setColumnCount(2); // Name, Value 857 | vbox->addWidget(properties); 858 | dock->setWidget(pane); 859 | addDockWidget( Qt::LeftDockWidgetArea, dock ); 860 | connect(properties, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(onPropertiesDblClicked(QTreeWidgetItem*,int)) ); 861 | } 862 | 863 | void Navigator::closeEvent(QCloseEvent* event) 864 | { 865 | QSettings s; 866 | s.setValue( "DockState", saveState() ); 867 | event->setAccepted(true); 868 | } 869 | 870 | static bool sortExList( const Lisp::Reader::Ref& lhs, const Lisp::Reader::Ref& rhs ) 871 | { 872 | return lhs.pos.row < rhs.pos.row || (!(rhs.pos.row < lhs.pos.row) && lhs.pos.col < rhs.pos.col); 873 | } 874 | 875 | static inline QString roleToStr(quint8 r) 876 | { 877 | switch(r) 878 | { 879 | case Lisp::Reader::Ref::Call: 880 | return "call"; 881 | case Lisp::Reader::Ref::Func: 882 | return "func"; 883 | case Lisp::Reader::Ref::Local: 884 | return "local"; 885 | case Lisp::Reader::Ref::Param: 886 | return "param"; 887 | case Lisp::Reader::Ref::Lhs: 888 | return "lhs"; 889 | default: 890 | return ""; 891 | } 892 | } 893 | 894 | void Navigator::fillXrefForAtom(const char* atom, const Lisp::RowCol& rc) 895 | { 896 | d_xref->clear(); 897 | 898 | QHash usage = xref.value(atom); 899 | 900 | QFont f = d_xref->font(); 901 | f.setBold(true); 902 | 903 | d_xrefTitle->setText(tr("Atom %1").arg(decode(atom))); 904 | const QString curMod = viewer->getPath(); 905 | 906 | QTreeWidgetItem* black = 0; 907 | QHash::const_iterator i; 908 | for( i = usage.begin(); i != usage.end(); ++i ) 909 | { 910 | Lisp::Reader::Refs refs = i.value(); 911 | std::sort( refs.begin(), refs.end(), sortExList ); 912 | const QString modName = debang(QFileInfo(i.key()).baseName()); 913 | foreach( const Lisp::Reader::Ref& s, refs ) 914 | { 915 | QTreeWidgetItem* item = new QTreeWidgetItem(d_xref); 916 | item->setText( 0, QString("%1 (%2:%3 %4)") 917 | .arg(modName) 918 | .arg(s.pos.row).arg(s.pos.col) 919 | .arg( roleToStr(s.role) )); 920 | if( curMod == i.key() && s.pos == rc ) 921 | { 922 | item->setFont(0,f); 923 | black = item; 924 | } 925 | item->setToolTip( 0, item->text(0) ); 926 | item->setData( 0, Qt::UserRole, QVariant::fromValue( s ) ); 927 | item->setData( 1, Qt::UserRole, QVariant::fromValue( i.key()) ); 928 | if( i.key() != curMod ) 929 | item->setForeground( 0, Qt::gray ); 930 | } 931 | } 932 | if( black && !d_lock3 ) 933 | { 934 | d_xref->scrollToItem(black, QAbstractItemView::PositionAtCenter); 935 | d_xref->setCurrentItem(black); 936 | } 937 | } 938 | 939 | static inline QByteArray toBa(const char* str) 940 | { 941 | return QByteArray::fromRawData(str, strlen(str)); 942 | } 943 | 944 | void Navigator::fillProperties(const char* atom) 945 | { 946 | properties->clear(); 947 | propTitle->setText(tr("Atom %1").arg(decode(atom))); 948 | Lisp::Reader::Atoms::const_iterator i = atoms.find(atom); 949 | if( i != atoms.end() ) 950 | { 951 | Lisp::Reader::Properties::const_iterator j; 952 | for(j = i.value().props.begin(); j != i.value().props.end(); ++j ) 953 | { 954 | if( j.key() == 0 ) 955 | continue; 956 | QTreeWidgetItem* item = new QTreeWidgetItem(properties); 957 | item->setText(0, decode(j.key())); 958 | item->setData(0, Qt::UserRole, QVariant::fromValue(toBa(j.key()))); 959 | const QString str = decode(j.value().toString(true)); 960 | item->setText(1, str); 961 | item->setToolTip(1, str); 962 | } 963 | } 964 | properties->sortByColumn(0); 965 | } 966 | 967 | void Navigator::fillAtomList() 968 | { 969 | atomList->clear(); 970 | QByteArrayList raw = Lisp::Token::getAllSymbols(); 971 | foreach( const QByteArray& a, raw) 972 | { 973 | QListWidgetItem* item = new QListWidgetItem(atomList); 974 | item->setText(decode(a)); 975 | item->setData(Qt::UserRole, QVariant::fromValue(a)); 976 | } 977 | atomList->sortItems(); 978 | } 979 | 980 | void Navigator::syncSelectedAtom(const char* atom, const Lisp::RowCol& rc) 981 | { 982 | fillXrefForAtom(atom, rc); 983 | //TODO syncModView(hit->decl); 984 | 985 | QHash usage = xref.value(atom); 986 | viewer->markNonTerms(usage.value(viewer->getPath())); 987 | 988 | fillProperties(atom); 989 | } 990 | 991 | QPair Navigator::findSymbolBySourcePos(const QString& file, quint32 line, quint16 col) 992 | { 993 | Lisp::Reader::Object obj = asts.value(file); 994 | if( obj.type() != Lisp::Reader::Object::List_) 995 | return qMakePair((Lisp::Reader::List*)0,-1); 996 | Lisp::Reader::List* l = obj.getList(); 997 | return findSymbolBySourcePos(l, line, col); 998 | } 999 | 1000 | QPair Navigator::findSymbolBySourcePos(Lisp::Reader::List* l, quint32 line, quint16 col) 1001 | { 1002 | Q_ASSERT(l); 1003 | for( int i = 0; i < l->list.size(); i++ ) 1004 | { 1005 | Q_ASSERT( i < l->elementPositions.size() ); 1006 | Lisp::RowCol r = l->elementPositions[i]; 1007 | 1008 | #if 0 1009 | const QByteArray string = l->list[i].toString(); 1010 | qDebug() << "element" << i << "at" << r.row << r.col << string.left(40); 1011 | #endif 1012 | 1013 | switch( l->list[i].type() ) 1014 | { 1015 | case Lisp::Reader::Object::Float: 1016 | case Lisp::Reader::Object::Integer: 1017 | case Lisp::Reader::Object::String_: 1018 | // we're not interested in these objects 1019 | break; 1020 | case Lisp::Reader::Object::Atom_: 1021 | if( line == r.row && col >= r.col && col <= r.col + l->list[i].getAtomLen(true) ) 1022 | return qMakePair(l,i); 1023 | break; 1024 | case Lisp::Reader::Object::List_: { 1025 | const Lisp::RowCol end = l->list[i].getList()->end; 1026 | if( (line > r.row && line < end.row) || 1027 | ( line == r.row && r.row == end.row && col >= r.col && col <= end.col) || 1028 | (line == r.row && r.row != end.row && col >= r.col) || 1029 | (line == end.row && r.row != end.row && col <= end.col) ) 1030 | return findSymbolBySourcePos(l->list[i].getList(), line, col); 1031 | break; 1032 | } 1033 | default: 1034 | break; 1035 | } 1036 | } 1037 | return qMakePair(l, -1); 1038 | } 1039 | 1040 | int main(int argc, char *argv[]) 1041 | { 1042 | QApplication a(argc, argv); 1043 | a.setOrganizationName("me@rochus-keller.ch"); 1044 | a.setOrganizationDomain("github.com/rochus-keller/Interlisp"); 1045 | a.setApplicationName("InterlispNavigator"); 1046 | a.setApplicationVersion("0.3.9"); 1047 | a.setStyle("Fusion"); 1048 | 1049 | QFontDatabase::addApplicationFont(":/fonts/DejaVuSansMono.ttf"); 1050 | #ifdef Q_OS_LINUX 1051 | QFontDatabase::addApplicationFont(":/fonts/NotoSans.ttf"); 1052 | QFont af("Noto Sans",9); 1053 | a.setFont(af); 1054 | #endif 1055 | 1056 | Navigator w; 1057 | w.setWindowTitle(QString("Interlisp Navigator %1").arg(QApplication::applicationVersion())); 1058 | w.showMaximized(); 1059 | if( a.arguments().size() > 1 ) 1060 | { 1061 | w.load(a.arguments()[1]); 1062 | } 1063 | 1064 | return a.exec(); 1065 | } 1066 | 1067 | -------------------------------------------------------------------------------- /LispNavigator.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | /* 5 | * Copyright 2024 Rochus Keller 6 | * 7 | * This file is part of the Interlisp project. 8 | * 9 | * The following is the license that applies to this copy of the 10 | * file. For a license to use the file under conditions 11 | * other than those described here, please email to me@rochus-keller.ch. 12 | * 13 | * GNU General Public License Usage 14 | * This file may be used under the terms of the GNU General Public 15 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 16 | * Foundation and appearing in the file LICENSE.GPL included in 17 | * the packaging of this file. Please review the following information 18 | * to ensure GNU General Public Licensing requirements will be met: 19 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 20 | * http://www.gnu.org/copyleft/gpl.html. 21 | */ 22 | // Adopted from the Lisa Pascal Navigator 23 | 24 | #include 25 | #include "LispReader.h" 26 | 27 | class QTreeWidget; 28 | class QLabel; 29 | class QTreeWidgetItem; 30 | class CodeEditor; 31 | class QPlainTextEdit; 32 | class QListWidget; 33 | class QListWidgetItem; 34 | 35 | class Navigator : public QMainWindow 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | Navigator(QWidget *parent = 0); 41 | ~Navigator(); 42 | 43 | void load(const QString& path); 44 | void logMessage(const QString&); 45 | 46 | protected slots: 47 | void fileDoubleClicked(QTreeWidgetItem*,int); 48 | void handleGoBack(); 49 | void handleGoForward(); 50 | void onXrefDblClicked(); 51 | void onCursor(); 52 | void onUpdateLocation(int line, int col); 53 | void onSearchAtom(); 54 | void onSelectAtom(); 55 | void onAtomDblClicked(QListWidgetItem*); 56 | void onRunParser(); 57 | void onOpen(); 58 | void onPropertiesDblClicked(QTreeWidgetItem*,int); 59 | 60 | protected: 61 | struct Location 62 | { 63 | // Qt-Koordinaten 64 | quint32 d_line; 65 | quint16 d_col; 66 | quint16 d_yoff; 67 | QString d_file; 68 | bool operator==( const Location& rhs ) { return d_line == rhs.d_line && d_col == rhs.d_col && 69 | d_file == rhs.d_file; } 70 | Location(const QString& f, quint32 l, quint16 c, quint16 y ):d_file(f),d_line(l),d_col(c),d_yoff(y){} 71 | }; 72 | void pushLocation( const Location& ); 73 | void showFile(const QString& file); 74 | void showFile(const QString& file, const Lisp::RowCol& pos); 75 | void openGenerated(const QString& file); 76 | void showPosition(const Lisp::RowCol& pos); 77 | void showFile(const Location& file); 78 | void createSourceTree(); 79 | void createXref(); 80 | void createLog(); 81 | void createAtomList(); 82 | void createProperties(); 83 | void closeEvent(QCloseEvent* event); 84 | void fillXrefForAtom(const char* atom, const Lisp::RowCol& rc); 85 | void fillProperties(const char* atom); 86 | void fillAtomList(); 87 | void syncSelectedAtom(const char* atom, const Lisp::RowCol& rc); 88 | QPair findSymbolBySourcePos(const QString& file, quint32 line, quint16 col); 89 | QPair findSymbolBySourcePos(Lisp::Reader::List*, quint32 line, quint16 col); 90 | 91 | private: 92 | QTreeWidget* tree; 93 | QLabel* title; 94 | QLabel* d_xrefTitle; 95 | QTreeWidget* d_xref; 96 | QTreeWidget* properties; 97 | QLabel* propTitle; 98 | QPlainTextEdit* d_msgLog; 99 | QStringList sourceFiles; 100 | QListWidget* atomList; 101 | class Viewer; 102 | Viewer* viewer; 103 | QString root; 104 | QMap asts; 105 | QHash > xref; 106 | Lisp::Reader::Atoms atoms; 107 | QList d_backHisto; // d_backHisto.last() ist aktuell angezeigtes Objekt 108 | QList d_forwardHisto; 109 | bool d_pushBackLock, d_lock3; 110 | }; 111 | 112 | #endif // MAINWINDOW_H 113 | -------------------------------------------------------------------------------- /LispReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Rochus Keller 3 | * 4 | * This file is part of the Interlisp project. 5 | * 6 | * The following is the license that applies to this copy of the 7 | * library. For a license to use the library under conditions 8 | * other than those described here, please email to me@rochus-keller.ch. 9 | * 10 | * GNU General Public License Usage 11 | * This file may be used under the terms of the GNU General Public 12 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 13 | * Foundation and appearing in the file LICENSE.GPL included in 14 | * the packaging of this file. Please review the following information 15 | * to ensure GNU General Public Licensing requirements will be met: 16 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 17 | * http://www.gnu.org/copyleft/gpl.html. 18 | */ 19 | 20 | #include "LispReader.h" 21 | #include "LispLexer.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | using namespace Lisp; 27 | 28 | static QHash symbols; 29 | 30 | static const quint64 signbit_mask = 1LL << (64-1); 31 | static const quint64 quiet_nan_mask = 0xfffLL << 51; 32 | static const quint64 pointer_type_mask = 7LL << 48; 33 | static const quint64 pointer_mask = (1LL << 48)-1; 34 | static const quint64 int_mask = (1LL << 50) - 1; 35 | static const quint64 int_sign = 1LL << 50; 36 | static const quint64 Nil_mask = 1LL << 48; 37 | static const quint64 String_mask = 2LL << 48; 38 | static const quint64 List_mask = 3LL << 48; 39 | static const quint64 Atom_mask = 4LL << 48; 40 | static const char* STOP; 41 | static const char* NIL; 42 | static const char* DEFINEQ; 43 | static const char* QUOTE; 44 | static const char* PUTPROPS; 45 | static const char* PUTPROP; 46 | static const char* SET; 47 | static const char* SETQ; 48 | static const char* SETQQ; 49 | static const char* RPAQ; 50 | static const char* RPAQQ; 51 | static const char* PROG; 52 | static const char* LAMBDA; 53 | static const char* NLAMBDA; 54 | 55 | 56 | Reader::Reader() 57 | { 58 | 59 | } 60 | 61 | bool Reader::read(QIODevice* in, const QString& path) 62 | { 63 | List* l = new List(); 64 | ast.set(l); 65 | xref.clear(); 66 | atoms.clear(); 67 | STOP = Token::getSymbol("STOP").constData(); 68 | NIL = Token::getSymbol("NIL").constData(); 69 | DEFINEQ = Token::getSymbol("DEFINEQ").constData(); 70 | QUOTE = Token::getSymbol("QUOTE").constData(); 71 | PUTPROPS = Token::getSymbol("PUTPROPS").constData(); 72 | PUTPROP = Token::getSymbol("PUTPROP").constData(); 73 | SET = Token::getSymbol("SET").constData(); 74 | SETQ = Token::getSymbol("SETQ").constData(); 75 | SETQQ = Token::getSymbol("SETQQ").constData(); 76 | RPAQ = Token::getSymbol("RPAQ").constData(); 77 | RPAQQ = Token::getSymbol("RPAQQ").constData(); 78 | PROG = Token::getSymbol("PROG").constData(); 79 | LAMBDA = Token::getSymbol("LAMBDA").constData(); 80 | NLAMBDA = Token::getSymbol("NLAMBDA").constData(); 81 | 82 | Lexer lex; 83 | lex.setStream(in, path); 84 | 85 | while( true ) 86 | { 87 | const Token t = lex.nextToken(); 88 | lex.unget(t); 89 | Object res = next(lex, l); 90 | if( !error.isEmpty() ) 91 | return false; 92 | if( res.type() != Object::Nil_ ) 93 | { 94 | if( res.type() == Object::Atom_ ) 95 | { 96 | const char* atom = res.getAtom(); 97 | if( atom == NIL || atom == STOP ) 98 | break; 99 | xref[atom] << Ref(t.pos, t.len); 100 | } 101 | l->list.append(res); 102 | l->elementPositions.append(t.pos); 103 | 104 | }else 105 | break; 106 | } 107 | return error.isEmpty(); 108 | } 109 | 110 | Reader::Object Reader::next(Lexer& in, List* outer, Hint hint) 111 | { 112 | Object res; 113 | if( hint == Quoted ) 114 | in.startQuote(); 115 | Token t = in.nextToken(); 116 | if( hint == Quoted ) 117 | in.endQuote(); 118 | if( t.isEof() ) 119 | return Object(); 120 | pos = t.pos; 121 | if( !t.isValid() ) 122 | { 123 | report(t); 124 | return Object(); 125 | } 126 | switch( t.type ) 127 | { 128 | case Tok_integer: 129 | if( t.val.endsWith('Q') ) 130 | res = Object(t.val.left(t.val.size()-1).toLongLong()); 131 | else 132 | res = Object(t.val.toLongLong()); 133 | break; 134 | case Tok_float: 135 | res = Object(t.val.toDouble()); 136 | break; 137 | case Tok_string: 138 | res = Object(new String(t.val)); 139 | break; 140 | case Tok_atom: 141 | res = Object(t.val.constData()); 142 | break; 143 | case Tok_lpar: 144 | case Tok_lbrack: 145 | res = list(in, t.type == Tok_lbrack, outer, hint); 146 | break; 147 | case Tok_rpar: 148 | report(t, QString("unexpected token ')'")); 149 | return Object(); 150 | case Tok_rbrack: 151 | report(t, QString("unexpected token ']'")); 152 | return Object(); 153 | } 154 | 155 | // res.dump(out, line); 156 | return res; 157 | } 158 | 159 | Reader::Object Reader::list(Lexer& in, bool brack, List* outer, Hint outerHint) 160 | { 161 | List* l = new List(); 162 | l->outer = outer; 163 | Object res(l); 164 | Hint hint = None; 165 | 166 | while( true ) 167 | { 168 | Token t = in.nextToken(); 169 | if( !t.isValid() ) 170 | { 171 | report(t); 172 | res = Object(); 173 | break; 174 | } 175 | if( t.type == Tok_rpar ) 176 | { 177 | l->end = t.pos; 178 | if( brack ) 179 | { 180 | report(t,"terminating '[' by ')'"); 181 | res = Object(); 182 | } 183 | break; 184 | } 185 | if( t.type == Tok_rbrack ) 186 | { 187 | if( !brack ) 188 | in.unget(t); // shortcut to close all '(' lists up to '[' 189 | l->end = t.pos; 190 | break; 191 | } 192 | in.unget(t); 193 | Object res = next(in, l, hint); 194 | if( !error.isEmpty() ) 195 | { 196 | res = Object(); 197 | break; 198 | } 199 | l->list.append(res); 200 | l->elementPositions.append(t.pos); 201 | if( res.type() == Object::Atom_ ) 202 | { 203 | if( l->list.size() == 1 ) 204 | { 205 | const char* atom = res.getAtom(); 206 | if( atom == QUOTE ) 207 | hint = Quoted; 208 | else if( atom == PROG ) 209 | hint = Local; 210 | else if( atom == LAMBDA || atom == NLAMBDA ) 211 | hint = Param; 212 | } 213 | 214 | const bool isDecl = outerHint == Local || outerHint == Param; 215 | Ref::Role r = outerHint == Local ? Ref::Local : ( outerHint == Param ? Ref::Param : Ref::Use); 216 | if( !isDecl && l->list.size() == 1 ) 217 | { 218 | r = Ref::Call; 219 | Object o = l->getOuterFirst(); 220 | if( o.type() == Object::Atom_ && o.getAtom() == DEFINEQ ) 221 | r = Ref::Func; 222 | }else if( !isDecl && l->list.size() == 2 && 223 | (l->list.first().getAtom() == PUTPROP || 224 | l->list.first().getAtom() == PUTPROPS || 225 | l->list.first().getAtom() == SET || l->list.first().getAtom() == SETQ || 226 | l->list.first().getAtom() == SETQQ || l->list.first().getAtom() == RPAQ || 227 | l->list.first().getAtom() == RPAQQ ) ) 228 | { 229 | r = Ref::Lhs; 230 | } 231 | xref[res.getAtom()] << Ref(t.pos, t.len, r); 232 | } 233 | if( l->list.size() == 4 && (l->list[0].getAtom() == PUTPROPS || l->list[0].getAtom() == PUTPROP) ) 234 | { 235 | //qDebug() << "Property of atom" << l->list[1].getAtom() << ":" << l->list[2].toString() << "=" << res.toString(); 236 | if( l->list[1].type() == Object::Atom_ && l->list[2].type() == Object::Atom_ ) 237 | atoms[l->list[1].getAtom()].props[l->list[2].getAtom()] = res; 238 | }else if( l->list.size() >= 6 && l->list.size() % 2 == 0 && l->list[0].getAtom() == PUTPROPS ) 239 | { 240 | if( l->list[1].type() == Object::Atom_ && l->list[l->list.size()-2].type() == Object::Atom_ ) 241 | atoms[l->list[1].getAtom()].props[l->list[l->list.size()-2].getAtom()] = res; 242 | } 243 | } 244 | return res; 245 | } 246 | 247 | void Reader::report(const Token& t) 248 | { 249 | report(t, t.val); 250 | } 251 | 252 | void Reader::report(const Token& t, const QString& msg) 253 | { 254 | pos = t.pos; 255 | error = msg; 256 | } 257 | 258 | Reader::Object::Object():bits(0) 259 | { 260 | nil(); 261 | } 262 | 263 | Reader::Object::Object(double d):bits(0) 264 | { 265 | set(d); 266 | } 267 | 268 | Reader::Object::Object(qint64 i):bits(0) 269 | { 270 | set(i); 271 | } 272 | 273 | Reader::Object::Object(const char* s):bits(0) 274 | { 275 | set(s); 276 | } 277 | 278 | Reader::Object::Object(List* l):bits(0) 279 | { 280 | set(l); 281 | } 282 | 283 | Reader::Object::Object(Reader::String*s):bits(0) 284 | { 285 | set(s); 286 | } 287 | 288 | Reader::Object::Object(const Reader::Object& rhs):bits(0) 289 | { 290 | *this = rhs; 291 | } 292 | 293 | Reader::Object::~Object() 294 | { 295 | nil(); 296 | } 297 | 298 | Reader::Object&Reader::Object::operator=(const Reader::Object& rhs) 299 | { 300 | nil(); 301 | bits = rhs.bits; 302 | switch( type() ) 303 | { 304 | case List_: 305 | getList()->addRef(); 306 | break; 307 | case String_: 308 | getStr()->addRef(); 309 | break; 310 | } 311 | return *this; 312 | } 313 | 314 | void Reader::Object::set(qint64 i) 315 | { 316 | nil(); 317 | bits = 0; 318 | const quint64 u = qAbs(i); 319 | Q_ASSERT(u <= int_mask); 320 | bits |= quiet_nan_mask | u; 321 | if( i < 0 ) 322 | bits |= int_sign; 323 | } 324 | 325 | qint64 Reader::Object::getInt() const 326 | { 327 | Q_ASSERT( type() == Integer); 328 | qint64 res = bits & int_mask; 329 | if( bits & int_sign ) 330 | res = -res; 331 | return res; 332 | } 333 | 334 | void Reader::Object::set(const char* s) 335 | { 336 | nil(); 337 | bits = 0; 338 | union { const char* ss; quint64 u; }; 339 | u = 0; 340 | ss = s; // otherwise the upper 32 bits are not initialized 341 | Q_ASSERT( u <= pointer_mask ); 342 | bits |= signbit_mask | quiet_nan_mask | Atom_mask | u; 343 | } 344 | 345 | void Reader::Object::set(Reader::String* s) 346 | { 347 | nil(); 348 | if( s == 0 ) 349 | return; 350 | s->addRef(); 351 | bits = 0; 352 | union { String* ss; quint64 u; }; 353 | u = 0; 354 | ss = s; 355 | Q_ASSERT( u <= pointer_mask ); 356 | bits |= signbit_mask | quiet_nan_mask | String_mask | u; 357 | } 358 | 359 | Reader::String* Reader::Object::getStr() const 360 | { 361 | Q_ASSERT( type() == String_); 362 | return (String*)(bits & pointer_mask); 363 | } 364 | 365 | const char*Reader::Object::getAtom() const 366 | { 367 | if( type() != Atom_) 368 | return ""; 369 | const char* res = (const char*)(bits & pointer_mask); 370 | return res; 371 | } 372 | 373 | int Reader::Object::getAtomLen(bool inCode) const 374 | { 375 | const char* atom = getAtom(); 376 | int res = 0; 377 | while( *atom ) 378 | { 379 | res++; 380 | if( inCode && Lexer::atom_delimiter(*atom) ) 381 | res++; // escaped in source code 382 | atom++; 383 | } 384 | return res; 385 | } 386 | 387 | void Reader::Object::set(Reader::List* l) 388 | { 389 | nil(); 390 | if( l == 0 ) 391 | return; 392 | l->addRef(); 393 | bits = 0; 394 | union { List* ss; quint64 u; }; 395 | u = 0; 396 | ss = l; 397 | Q_ASSERT( u <= pointer_mask ); 398 | bits |= signbit_mask | quiet_nan_mask | List_mask | u; 399 | } 400 | 401 | Reader::List*Reader::Object::getList() const 402 | { 403 | Q_ASSERT( type() == List_); 404 | return (List*)(bits & pointer_mask); 405 | } 406 | 407 | void Reader::Object::set(double d) 408 | { 409 | nil(); 410 | dbl = d; 411 | } 412 | 413 | double Reader::Object::getDouble() const 414 | { 415 | Q_ASSERT( type() == Float); 416 | return dbl; 417 | } 418 | 419 | Reader::Object::Type Reader::Object::type() const 420 | { 421 | if( (bits & quiet_nan_mask) != quiet_nan_mask ) 422 | return Float; 423 | else if( bits & signbit_mask ) 424 | { 425 | const quint64 tmp = pointer_type_mask & bits; 426 | if( tmp == Nil_mask ) 427 | return Nil_; 428 | if( tmp == String_mask ) 429 | return String_; 430 | if( tmp == List_mask ) 431 | return List_; 432 | if( tmp == Atom_mask ) 433 | return Atom_; 434 | // else 435 | Q_ASSERT( false); 436 | }else 437 | return Integer; 438 | } 439 | 440 | void Reader::Object::nil() 441 | { 442 | switch( type() ) 443 | { 444 | case List_: 445 | getList()->release(); 446 | break; 447 | case String_: 448 | getStr()->release(); 449 | break; 450 | } 451 | bits = 0; 452 | bits |= signbit_mask | quiet_nan_mask | Nil_mask; 453 | } 454 | 455 | void Reader::Object::dump(QTextStream& out) const 456 | { 457 | switch( type() ) 458 | { 459 | case Float: 460 | out << "Float:" << getDouble(); 461 | break; 462 | case Integer: 463 | out << "Integer:" << getInt(); 464 | break; 465 | case Nil_: 466 | out << "NIL"; 467 | break; 468 | case String_: 469 | out << "String: " << getStr()->str; 470 | break; 471 | case List_: 472 | out << "List with " << getList()->list.size() << " elements"; 473 | break; 474 | case Atom_: 475 | out << "Atom: " << getAtom(); 476 | break; 477 | default: 478 | out << "ERROR unknown object"; 479 | break; 480 | } 481 | } 482 | 483 | void Reader::Object::print(QTextStream& out, int level) const 484 | { 485 | switch( type() ) 486 | { 487 | case Float: 488 | out << getDouble(); 489 | break; 490 | case Integer: 491 | out << getInt(); 492 | break; 493 | case Nil_: 494 | out << "NIL"; 495 | break; 496 | case String_: 497 | out << getStr()->str; 498 | break; 499 | case List_: { 500 | List* l = getList(); 501 | if( l->outer ) 502 | out << "("; 503 | if( !l->list.isEmpty() ) 504 | l->list[0].print(out, level + 1); 505 | if( l->list.size() > 1 ) 506 | { 507 | if( !l->elementPositions.isEmpty() ) 508 | out << " (*" << l->elementPositions[0].row << ":" << l->elementPositions[0].col << ")"; 509 | out << endl; 510 | } 511 | for(int i = 1; i < l->list.size(); i++ ) 512 | { 513 | out << QByteArray(level*3,' '); 514 | l->list[i].print(out, level + 1); 515 | if( i < l->list.size() - 1 ) 516 | { 517 | if( i < l->elementPositions.size() ) 518 | out << " (*" << l->elementPositions[i].row << ":" << l->elementPositions[i].col << ")"; 519 | out << endl; 520 | } 521 | } 522 | if( l->outer ) 523 | out << ")"; 524 | break; 525 | } 526 | case Atom_: 527 | out << getAtom(); 528 | break; 529 | default: 530 | out << "ERROR unknown object"; 531 | break; 532 | } 533 | } 534 | 535 | QByteArray Reader::Object::toString(bool fullList) const 536 | { 537 | switch( type() ) 538 | { 539 | case Float: 540 | return QByteArray::number(getDouble()); 541 | case Integer: 542 | return QByteArray::number(getInt()); 543 | case Nil_: 544 | return "NIL"; 545 | case String_: 546 | return getStr()->str; 547 | case List_: { 548 | List* l = getList(); 549 | if( l->list.isEmpty() ) 550 | return "()"; 551 | if( fullList ) 552 | { 553 | QByteArray res = "( "; 554 | for( int i = 0; i < l->list.size(); i++ ) 555 | { 556 | if( i != 0 ) 557 | res += " "; 558 | res += l->list[i].toString(true); 559 | } 560 | res += " )"; 561 | return res; 562 | }else 563 | return "( " + l->list.first().toString() + " ... " + QByteArray::number(l->list.size()) + " )"; 564 | } 565 | case Atom_: 566 | return getAtom(); 567 | default: 568 | return "???"; 569 | } 570 | } 571 | 572 | void Reader::List::addRef() 573 | { 574 | refcount++; 575 | } 576 | 577 | void Reader::List::release() 578 | { 579 | refcount--; 580 | if( refcount == 0 ) 581 | delete this; 582 | } 583 | 584 | Reader::Object Reader::List::getOuterFirst() const 585 | { 586 | if( outer && !outer->list.isEmpty() ) 587 | return outer->list.first(); 588 | else 589 | return Object(); 590 | } 591 | 592 | RowCol Reader::List::getStart() const 593 | { 594 | if( outer == 0 || outer->elementPositions.isEmpty() ) 595 | return RowCol(); 596 | for( int i = 0; i < outer->list.size(); i++ ) 597 | { 598 | if( outer->list[i].type() == Object::List_ && outer->list[i].getList() == this ) 599 | return outer->elementPositions[i]; 600 | } 601 | return RowCol(); 602 | } 603 | 604 | void Reader::String::addRef() 605 | { 606 | refcount++; 607 | } 608 | 609 | void Reader::String::release() 610 | { 611 | refcount--; 612 | if( refcount == 0 ) 613 | delete this; 614 | } 615 | -------------------------------------------------------------------------------- /LispReader.h: -------------------------------------------------------------------------------- 1 | #ifndef LISPREADER_H 2 | #define LISPREADER_H 3 | 4 | /* 5 | * Copyright 2024 Rochus Keller 6 | * 7 | * This file is part of the Interlisp project. 8 | * 9 | * The following is the license that applies to this copy of the 10 | * library. For a license to use the library under conditions 11 | * other than those described here, please email to me@rochus-keller.ch. 12 | * 13 | * GNU General Public License Usage 14 | * This file may be used under the terms of the GNU General Public 15 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 16 | * Foundation and appearing in the file LICENSE.GPL included in 17 | * the packaging of this file. Please review the following information 18 | * to ensure GNU General Public Licensing requirements will be met: 19 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 20 | * http://www.gnu.org/copyleft/gpl.html. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include "LispRowCol.h" 27 | 28 | class QIODevice; 29 | 30 | namespace Lisp 31 | { 32 | 33 | class Lexer; 34 | class Token; 35 | 36 | class Reader 37 | { 38 | public: 39 | class List; 40 | class String; 41 | class Object 42 | { 43 | union 44 | { 45 | double dbl; 46 | quint64 bits; 47 | }; 48 | public: 49 | enum Type { 50 | Float, 51 | Integer, 52 | Nil_, 53 | String_, 54 | List_, 55 | Atom_, 56 | }; 57 | 58 | Object(); 59 | Object(double); 60 | Object(qint64); 61 | Object(const char*); 62 | Object(List*); 63 | Object(String*); 64 | Object(const Object&); 65 | ~Object(); 66 | 67 | Object& operator=(const Object&); 68 | 69 | void set(double); 70 | double getDouble() const; 71 | void set(qint64); 72 | qint64 getInt() const; 73 | void set(const char*); // Atom 74 | void set(String*); 75 | String* getStr() const; 76 | const char* getAtom() const; 77 | int getAtomLen(bool inCode = false) const; 78 | void set(List*); 79 | List* getList() const; 80 | Type type() const; 81 | void nil(); 82 | void dump(QTextStream& out) const; 83 | void print(QTextStream& out, int level = 0) const; 84 | QByteArray toString(bool fullList = false) const; 85 | }; 86 | 87 | struct List 88 | { 89 | quint32 refcount; 90 | public: 91 | QList list; 92 | RowCol end; 93 | List* outer; 94 | QList elementPositions; 95 | 96 | List():refcount(0),outer(0){} 97 | void addRef(); 98 | void release(); 99 | Object getOuterFirst() const; 100 | RowCol getStart() const; 101 | }; 102 | 103 | struct String 104 | { 105 | quint32 refcount; 106 | public: 107 | QByteArray str; 108 | 109 | String(const QByteArray& str = QByteArray()):refcount(0),str(str){} 110 | void addRef(); 111 | void release(); 112 | }; 113 | 114 | typedef QHash Properties; 115 | struct Atom 116 | { 117 | //const char* pname; 118 | Object value; 119 | // TODO: values have local scope, not so props; therefore in a PROG scope 120 | // there must be a separate value entity in case of name override 121 | Properties props; 122 | QList vector; 123 | }; 124 | typedef QHash Atoms; 125 | 126 | struct Ref 127 | { 128 | RowCol pos; 129 | enum Role { Use, Call, Func, Param, Local, Lhs }; 130 | quint8 role; 131 | quint16 len; 132 | Ref(const RowCol& rc = RowCol(), quint16 l = 0, Role r = Use):pos(rc),role(r),len(l){} 133 | }; 134 | typedef QList Refs; 135 | typedef QHash Xref; 136 | 137 | Reader(); 138 | 139 | bool read(QIODevice*, const QString& path); 140 | const QString getError() const { return error; } 141 | const RowCol& getPos() const { return pos; } 142 | const Object& getAst() const { return ast; } 143 | const Xref& getXref() const { return xref; } 144 | const Atoms& getAtoms() const { return atoms; } 145 | 146 | private: 147 | enum Hint { None, Quoted, Local, Param }; 148 | Object next(Lexer&, List* outer, Hint hint = None); 149 | Object list(Lexer& in, bool brack, List* outer, Hint outerHint); 150 | void report(const Token&); 151 | void report(const Token&, const QString&); 152 | 153 | Object ast; 154 | QString error; 155 | RowCol pos; 156 | Xref xref; 157 | Atoms atoms; 158 | }; 159 | 160 | } 161 | 162 | Q_DECLARE_METATYPE(Lisp::Reader::Object) 163 | Q_DECLARE_METATYPE(Lisp::Reader::Ref) 164 | 165 | #endif // LISPREADER_H 166 | -------------------------------------------------------------------------------- /LispRowCol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Rochus Keller 3 | * 4 | * This file is part of the Interlisp project. 5 | * 6 | * The following is the license that applies to this copy of the 7 | * library. For a license to use the library under conditions 8 | * other than those described here, please email to me@rochus-keller.ch. 9 | * 10 | * GNU General Public License Usage 11 | * This file may be used under the terms of the GNU General Public 12 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 13 | * Foundation and appearing in the file LICENSE.GPL included in 14 | * the packaging of this file. Please review the following information 15 | * to ensure GNU General Public Licensing requirements will be met: 16 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 17 | * http://www.gnu.org/copyleft/gpl.html. 18 | */ 19 | 20 | #include "LispRowCol.h" 21 | #include 22 | using namespace Lisp; 23 | 24 | RowCol::RowCol(quint32 row, quint32 col) 25 | { 26 | if( !setRowCol(row,col) ) 27 | qWarning() << "invalid row or column number"; 28 | } 29 | 30 | bool RowCol::setRowCol(quint32 row, quint32 col) 31 | { 32 | static const quint32 maxRow = ( 1 << ROW_BIT_LEN ) - 1; 33 | static const quint32 maxCol = ( 1 << COL_BIT_LEN ) - 1; 34 | int err = 0; 35 | if( row > maxRow ) 36 | { 37 | this->row = maxRow; 38 | err++; 39 | }else if( row == 0 ) 40 | { 41 | this->row = 1; 42 | err++; 43 | }else 44 | this->row = row; 45 | if( col > maxCol ) 46 | { 47 | this->col = maxCol; 48 | err++; 49 | }else if( col == 0 ) 50 | { 51 | this->col = 1; 52 | err++; 53 | }else 54 | this->col = col; 55 | return err == 0; 56 | } 57 | -------------------------------------------------------------------------------- /LispRowCol.h: -------------------------------------------------------------------------------- 1 | #ifndef LISPROWCOL_H 2 | #define LISPROWCOL_H 3 | 4 | /* 5 | * Copyright 2024 Rochus Keller 6 | * 7 | * This file is part of the Interlisp project. 8 | * 9 | * The following is the license that applies to this copy of the 10 | * library. For a license to use the library under conditions 11 | * other than those described here, please email to me@rochus-keller.ch. 12 | * 13 | * GNU General Public License Usage 14 | * This file may be used under the terms of the GNU General Public 15 | * License (GPL) versions 2.0 or 3.0 as published by the Free Software 16 | * Foundation and appearing in the file LICENSE.GPL included in 17 | * the packaging of this file. Please review the following information 18 | * to ensure GNU General Public Licensing requirements will be met: 19 | * http://www.fsf.org/licensing/licenses/info/GPLv2.html and 20 | * http://www.gnu.org/copyleft/gpl.html. 21 | */ 22 | 23 | #include 24 | 25 | namespace Lisp 26 | { 27 | 28 | struct RowCol 29 | { 30 | enum { ROW_BIT_LEN = 19, COL_BIT_LEN = 32 - ROW_BIT_LEN - 1 }; 31 | uint row : ROW_BIT_LEN; // supports 524k lines 32 | uint col : COL_BIT_LEN; // supports 4k chars per line 33 | uint unused : 1; // the sign is used to recognize the packed representation 34 | 35 | RowCol():row(0),col(0),unused(0) {} 36 | RowCol( quint32 row, quint32 col ); 37 | bool setRowCol( quint32 row, quint32 col ); 38 | bool isValid() const { return row > 0 && col > 0; } // valid lines and cols start with 1; 0 is invalid 39 | bool operator==( const RowCol& rhs ) const { return row == rhs.row && col == rhs.col; } 40 | 41 | quint32 packed() const { return ( row << COL_BIT_LEN ) | col; } 42 | static bool isPacked( quint32 rowCol ) { return rowCol; } 43 | static quint32 unpackCol(quint32 rowCol ) { return rowCol & ( ( 1 << COL_BIT_LEN ) -1 ); } 44 | static quint32 unpackRow(quint32 rowCol ) { return ( ( rowCol ) >> COL_BIT_LEN ); } 45 | }; 46 | 47 | } 48 | 49 | #endif // LISPROWCOL_H 50 | -------------------------------------------------------------------------------- /Navigator.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fonts/DejaVuSansMono.ttf 4 | fonts/NotoSans.ttf 5 | 6 | 7 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | This project aims to build tools for Interlisp source code analysis (with cross-referencing and semantic navigation as far as possible), to support the development of a new VM compatible with old Interlisp-10 and Interlisp-D versions, and to bootstrap systems from source code. 2 | 3 | I'm particularly interested in the Interlisp-D versions which were available when Smalltalk-80 was published. Fortunately, the Computer History Museum has published a [Xerox PARC file system archive](https://xeroxparcarchive.computerhistory.org/), which - among other remarkable finds - includes the images and sources of many Interlisp-D versions. 4 | 5 | The [original Smalltalk-80 sources](http://www.wolczko.com/st80/image.tar.gz) are dated April 1983, and if we run the included image with [a compatible virtual machine](https://github.com/rochus-keller/Smalltalk), the version message in the terminal says May 31. 1983. 6 | 7 | The closest Interlisp version is "Chorus", which was released in Feb. 1983; the Xerox PARC archive includes [a Chorus image (called Lisp.sysout)](https://xeroxparcarchive.computerhistory.org/eris/lisp/chorus/basics/.index.html), but unfortunately no source code. The first version which is [available with source code is Fugue.2](https://xeroxparcarchive.computerhistory.org/eris/lisp/fugue.2/sources/.index.html); it was released around Aug. 1983; though it is unclear whether this source code version was indeed the released one, since there are syntax errors in [ADISPLAY!1](https://xeroxparcarchive.computerhistory.org/eris/lisp/fugue.2/sources/.ADISPLAY!1.html). But for now I will stick with this release. 8 | 9 | I have implemented an Interlisp Navigator (see screenshot), which I will extend as I study the sources. 10 | 11 | ![Navigator Screenshot 1](http://software.rochus-keller.ch/interlisp-navigator-screenshot-0.2.0-1.png) 12 | 13 | 14 | The next [Interlisp version with source code is Fugue.5](https://xeroxparcarchive.computerhistory.org/eris/lisp/fugue.5/.index.html), released around March 1984; the source code was completely refactored compared to Fugue.2, and there are no syntax errors. I found some [release notes](https://xeroxparcarchive.computerhistory.org/erinyes/lisp/fugue.6/doc/.CAROLRELEASE.TED!1.html) which state that if the release "survives the next few weeks of your use, it will be released outside Xerox as Carol". Carol was then indeed released around June 1984, and we have [the source code and a lot of other files](https://xeroxparcarchive.computerhistory.org/eris/lisp/carol/.index.html). The present version of the Navigator is compatible with both Fugue and Carol (I also briefly tried Koto which seems to work as well). 15 | 16 | NOTE that this project is work in progress. 17 | 18 | ### Precompiled versions 19 | 20 | The following precompiled versions are available at this time: 21 | 22 | - [Linux x86](http://software.rochus-keller.ch/InterlispTools_linux_i386.tar.gz) 23 | - [Linux x64](http://software.rochus-keller.ch/InterlispTools_linux_x64.tar.gz) 24 | - [Windows x86](http://software.rochus-keller.ch/InterlispTools_win32.zip) 25 | 26 | Just download and unpack the compressed file to a directory. Start the application by double clicking on the InterlispNavigator executable. 27 | 28 | Here is a copy of the (fixed) [Fugue.2 sources](http://software.rochus-keller.ch/interlisp-fugue-2-sources.zip) for convenience. 29 | 30 | ### Build Steps 31 | 32 | This project can be built using qmake and Qt5. Use the .pro files to run the build as described in the Qt documentation. 33 | 34 | Alternatively the navigator can be built using LeanQt and the BUSY build system (with no other dependencies than a C++98 compiler); follow these steps: 35 | 36 | 1. Create a new directory; we call it the root directory here 37 | 1. Download https://github.com/rochus-keller/Interlisp/archive/refs/heads/master.zip and unpack it to the root directory; rename the resulting directory to "Interlisp". 38 | 1. Download https://github.com/rochus-keller/GuiTools/archive/refs/heads/master.zip and unpack it to the root directory; rename the resulting directory to "GuiTools". 39 | 1. Download https://github.com/rochus-keller/LeanQt/archive/refs/heads/master.zip and unpack it to the root directory; rename the resulting directory to "LeanQt". 40 | 1. Download https://github.com/rochus-keller/BUSY/archive/refs/heads/master.zip and unpack it to the root directory; rename the resulting directory to "build". 41 | 1. Open a command line in the build directory and type `cc *.c -O2 -lm -o lua` or `cl /O2 /MD /Fe:lua.exe *.c` depending on whether you are on a Unix or Windows machine; wait a few seconds until the Lua executable is built. 42 | 1. Now type `./lua build.lua ../Interlisp` (or `lua build.lua ../Interlisp` on Windows); wait until the InterlispNavigator executable is built; you find it in the output subdirectory. 43 | 44 | ## Support 45 | 46 | If you need support or would like to post issues or feature requests please use the Github issue list at https://github.com/rochus-keller/Interlisp/issues or send an email to the author. 47 | -------------------------------------------------------------------------------- /fonts/DejaVu.license: -------------------------------------------------------------------------------- 1 | DejaVu Fonts License 2 | 3 | Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. 4 | Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below) 5 | 6 | Bitstream Vera Fonts Copyright 7 | ——————————————— 8 | 9 | Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is 10 | a trademark of Bitstream, Inc. 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of the fonts accompanying this license (“Fonts”) and associated 14 | documentation files (the “Font Software”), to reproduce and distribute the 15 | Font Software, including without limitation the rights to use, copy, merge, 16 | publish, distribute, and/or sell copies of the Font Software, and to permit 17 | persons to whom the Font Software is furnished to do so, subject to the 18 | following conditions: 19 | 20 | The above copyright and trademark notices and this permission notice shall 21 | be included in all copies of one or more of the Font Software typefaces. 22 | 23 | The Font Software may be modified, altered, or added to, and in particular 24 | the designs of glyphs or characters in the Fonts may be modified and 25 | additional glyphs or characters may be added to the Fonts, only if the fonts 26 | are renamed to names not containing either the words “Bitstream” or the word 27 | “Vera”. 28 | 29 | This License becomes null and void to the extent applicable to Fonts or Font 30 | Software that has been modified and is distributed under the “Bitstream 31 | Vera” names. 32 | 33 | The Font Software may be sold as part of a larger software package but no 34 | copy of one or more of the Font Software typefaces may be sold by itself. 35 | 36 | THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 37 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, 38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, 39 | TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME 40 | FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING 41 | ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, 42 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 43 | THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE 44 | FONT SOFTWARE. 45 | 46 | Except as contained in this notice, the names of Gnome, the Gnome 47 | Foundation, and Bitstream Inc., shall not be used in advertising or 48 | otherwise to promote the sale, use or other dealings in this Font Software 49 | without prior written authorization from the Gnome Foundation or Bitstream 50 | Inc., respectively. For further information, contact: fonts at gnome dot 51 | org. 52 | 53 | Arev Fonts Copyright 54 | ——————————————— 55 | 56 | Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining 59 | a copy of the fonts accompanying this license (“Fonts”) and 60 | associated documentation files (the “Font Software”), to reproduce 61 | and distribute the modifications to the Bitstream Vera Font Software, 62 | including without limitation the rights to use, copy, merge, publish, 63 | distribute, and/or sell copies of the Font Software, and to permit 64 | persons to whom the Font Software is furnished to do so, subject to 65 | the following conditions: 66 | 67 | The above copyright and trademark notices and this permission notice 68 | shall be included in all copies of one or more of the Font Software 69 | typefaces. 70 | 71 | The Font Software may be modified, altered, or added to, and in 72 | particular the designs of glyphs or characters in the Fonts may be 73 | modified and additional glyphs or characters may be added to the 74 | Fonts, only if the fonts are renamed to names not containing either 75 | the words “Tavmjong Bah” or the word “Arev”. 76 | 77 | This License becomes null and void to the extent applicable to Fonts 78 | or Font Software that has been modified and is distributed under the 79 | “Tavmjong Bah Arev” names. 80 | 81 | The Font Software may be sold as part of a larger software package but 82 | no copy of one or more of the Font Software typefaces may be sold by 83 | itself. 84 | 85 | THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL 89 | TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | 95 | Except as contained in this notice, the name of Tavmjong Bah shall not 96 | be used in advertising or otherwise to promote the sale, use or other 97 | dealings in this Font Software without prior written authorization 98 | from Tavmjong Bah. For further information, contact: tavmjong @ free 99 | . fr. 100 | -------------------------------------------------------------------------------- /fonts/DejaVuSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rochus-keller/Interlisp/cf4144f2fee4e097beb85270d6d5cebbe6f91be0/fonts/DejaVuSansMono.ttf -------------------------------------------------------------------------------- /fonts/Noto.license: -------------------------------------------------------------------------------- 1 | SIL Open Font License 2 | 3 | Copyright 2012 Google Inc. All Rights Reserved. 4 | 5 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 6 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 7 | 8 | —————————————————————————————- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | —————————————————————————————- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. 14 | 15 | The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. 16 | 17 | DEFINITIONS 18 | “Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. 19 | 20 | “Reserved Font Name” refers to any names specified as such after the copyright statement(s). 21 | 22 | “Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s). 23 | 24 | “Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. 25 | 26 | “Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. 27 | 28 | PERMISSION & CONDITIONS 29 | Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 30 | 31 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 32 | 33 | 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 34 | 35 | 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 36 | 37 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 38 | 39 | 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. 40 | 41 | TERMINATION 42 | This license becomes null and void if any of the above conditions are not met. 43 | 44 | DISCLAIMER 45 | THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. 46 | -------------------------------------------------------------------------------- /fonts/NotoSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rochus-keller/Interlisp/cf4144f2fee4e097beb85270d6d5cebbe6f91be0/fonts/NotoSans.ttf --------------------------------------------------------------------------------