├── .gitignore ├── Genesis.iml ├── LICENSE ├── README.md ├── examples ├── Commandments.𐤁 ├── Fibonacci.𐤁 ├── GravitationalForce.𐤁 ├── Logic.𐤁 ├── Loops.𐤁 ├── MathDemonstration.𐤁 ├── QuantumMechanics.𐤁 └── SurfaceGravity.𐤁 ├── lib └── annotations-20.1.0.jar ├── pom.xml ├── src └── main │ └── java │ ├── Commands │ ├── For.java │ ├── ForEach.java │ ├── ICommand.java │ ├── If.java │ ├── NameAndStorage.java │ ├── Print.java │ ├── PrintLine.java │ ├── Sleep.java │ ├── Subroutine.java │ ├── SubroutineCall.java │ ├── Variable.java │ ├── VariableUpdate.java │ └── While.java │ ├── Driver │ ├── GenesisMain.java │ └── Interpreter.java │ ├── META-INF │ └── MANIFEST.MF │ ├── References │ └── GenesisKeyWords.java │ ├── RoutineBlocks │ └── RoutineBlock.java │ ├── UI │ ├── CODE2001.TTF │ ├── CodeEditor.java │ ├── CodeFilter.java │ ├── Console.java │ ├── ProgramFrame.java │ ├── UIManager.java │ └── UITextArea.java │ └── Utilities │ ├── BooleanExpressionSolver.java │ ├── ExpressionSolver.java │ ├── GematriaSolver.java │ ├── NumberExpressionSolver.java │ └── VariableSolver.java └── thetanakh.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /out/ -------------------------------------------------------------------------------- /Genesis.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | THE HOLY LICENSE 2 | 3 | Version Last, 11 Av 5782 4 | 5 | Copyright (C) 5782 Elon Litman. All rights reserved. 6 | 7 | To whom it may concern, 8 | 9 | The following license applies to all of the material contained on the 10 | server labeled "Genesis" that is currently available for public access, 11 | as well as any material that may be added to the server in the future. 12 | 13 | This license governs the use of the Genesis programming language and its 14 | Software. The term "Genesis Language" refers to any material contained 15 | on the server labeled "Genesis" that is currently available for public 16 | access. The category of "Genesis Software" includes, but is not limited 17 | to, systems Software written in Genesis, application Software written in 18 | Genesis, which characterize Commercial Off the Shelf (COTS) products, 19 | Software as a Service (SaaS) products, Enterprise Resource Planning (ERP) 20 | or Best-in-Class products, and Genesis-based Operating Systems, and 21 | example works of Genesis that may be added to the server in the future. 22 | 23 | Everyone is permitted to copy and distribute verbatim copies 24 | of this license document, but changing it is not allowed. 25 | 26 | The Holy License is a free, copyleft license for 27 | Software and other kinds of works. 28 | 29 | You may not impose any further restrictions on the recipients' 30 | exercise of the rights granted herein. You are not responsible 31 | for enforcing compliance by third parties with this License. 32 | 33 | If, as a consequence of a secular court judgment or allegation of patent 34 | infringement or for any other reason (not limited to patent 35 | issues), conditions are imposed on you (whether by secular court order, 36 | agreement or otherwise) that contradict the conditions of this 37 | License, they do not excuse you from the conditions of this 38 | License. If you cannot distribute so as to satisfy simultaneously 39 | your obligations under this License and any other pertinent 40 | obligations, then as a consequence you may not distribute 41 | the Program at all. For example, if a patent License would not 42 | permit royalty-free redistribution of the Program by all those 43 | who receive copies directly or indirectly through you, then 44 | the only way you could satisfy both it and this License would 45 | be to refrain entirely from distribution of the Program. 46 | 47 | If any portion of this section is held invalid or 48 | unenforceable under any particular circumstance, the balance of 49 | the section is intended to apply and the section as a whole is 50 | intended to apply in other circumstances. 51 | 52 | It is not the purpose of this section to induce you to infringe 53 | any patents or other property right claims or to contest validity 54 | of any such claims; this section has the sole purpose of 55 | protecting the integrity of the free software distribution 56 | system, which is implemented by public license practices. Many 57 | people have made generous contributions to the wide range of 58 | software distributed through that system in reliance on consistent 59 | application of that system; it is up to the author/donor to 60 | protect their rights. 61 | 62 | You may not apply the terms of this License to prohibit 63 | modification of the terms of this License or to restrict the 64 | authors' rights to sublicense through multiple terms of this 65 | License. 66 | 67 | 1. Grant of Copyright License 68 | 69 | Subject to the terms and conditions of this License, the Software 70 | hereby grants you a limited, non-exclusive, non-transferable 71 | License for unhampered use on a single computer or device for your 72 | own personal, non-commercial or commercial use, and as an integral 73 | part of your church or ministry, as long as the Software is not 74 | used for sinning. 75 | 76 | 2. Modification of Software 77 | 78 | You may make modifications to the Software that are reasonably 79 | necessary to make the Software suitable for use with your own 80 | computer or device or ability to worship. However, you must keep 81 | intact all copyright notices, all trademarks, and all other 82 | proprietary notices that appear on the Software. You may not 83 | remove or alter any copyright notices, trademarks, or proprietary 84 | notices on the Software, and should credit the original author to 85 | highlight what modifications were made. 86 | 87 | 3. Rights Granted 88 | 89 | You may distribute the Software as an electronic file on a computer 90 | network, provided that: 91 | - You include all copyright notices and other proprietary notices 92 | that appear on the Software, and must retain all such notices on 93 | the Software or copies of it heretofore. 94 | - You include all trademark notices that appear on the Software. You 95 | may not remove or alter any trademark notices on the Software. You 96 | must include all other proprietary notices that appear on the 97 | Software. You may not remove or alter any proprietary notices on the 98 | Software. 99 | You may use or adapt the Software or its derivative works in whole 100 | or in part, provided that the aforementioned conditions are met. You 101 | may sell, lease, license, rent, sublicense, publicly display, publicly 102 | perform, distribute, reverse-engineer, transfer, assign, modify, create 103 | derivative works of, or otherwise use the Software or any portion of 104 | the Software except as not expressly permitted by this License or as 105 | permitted by applicable law. 106 | 107 | 4. Definitions 108 | 109 | a) "Adaptation" means a work based upon the Work or upon the 110 | Work and other pre-existing works, such as a translation, 111 | adaptation, derivative work, arrangement of music or other 112 | alterations of a literary or artistic work, or phonogram or 113 | performance (including any associated music) regardless of 114 | whether the work is performed in public or private places, 115 | includes a work that incorporates an Adaptation, even 116 | if the Adaptation was not created by the Addressee. 117 | 118 | b) "Derivative Work" means a work based upon the Software or upon 119 | the subsequent Works made using the Software, such as a package or 120 | library, an application, or any other script, arrangement of music 121 | or other alterations of a literary or artistic work, a phonogram, 122 | performance, or machine translation; including compilations 123 | (including collections of data as covered by the Digital 124 | Millennium Copyright Act, plus collections of data to which 125 | the Addressee has no legal title under the applicable 126 | copyright laws) or any other form in which a work may be 127 | recast, transformed, or adapted including in any form 128 | different from that in which it is published and without 129 | Licensor's prior written consent. 130 | 131 | c) "Distribute" means to make available to the public the 132 | original and copies of the Software, as the case 133 | may be, on physical media, such as disks, or on a network. 134 | Transfer of ownership is not required for any of the uses 135 | set forth in this License. 136 | 137 | d) "Licensor" means the individual, individuals, entity or 138 | entities that offer(s) the Work under the terms of this 139 | License. 140 | 141 | e) "Original Author" means, in the case of a literary or 142 | artistic work, the individual, individuals, entity or 143 | entities who created the Work or if no individual or 144 | entities can be identified, the publisher; and in the case 145 | of a performance the priests, programmers, religious figures, 146 | and other persons who write, act, sing, deliver, declaim, play in 147 | character, edit, perform, dirige, conduct, dance or otherwise 148 | utilise the Software literary or artistic work. 149 | 150 | f) "Work" means the Software offered under the terms of this 151 | License including without limitation any production in the literary, 152 | scientific and artistic domain, whatever may be the mode or form 153 | of its expression including digital form, such as a book, pamphlet 154 | and other writing; a lecture, address, sermon or other work of the 155 | same nature; a dramatic or dramatico-musical work; a choreographic 156 | work or entertainment in dumb show; a musical composition with or 157 | without words; a cinematographic work to which are assimilated 158 | works expressed by a process analogous to cinematography; a 159 | work of drawing, painting, architecture, sculpture, 160 | engraving or lithography; a photographic work to which are 161 | assimilated works expressed by a process analogous to 162 | photography; a work of applied art; an illustration, map, plan, 163 | sketch or three-dimensional work relative to geography, 164 | history, politics, archeology or natural history; a 165 | performance; a broadcast; a phonogram; a compilation of data 166 | to which are assimilated works expressed by a process 167 | analogous to compilation; a material object, such as a 168 | machine or a product, that is described by a document 169 | described; and a work performed for you and in your actual or 170 | potential capacity as a performer, if any, in a musical, dramatic, 171 | dramatico-musical, choreographic or other form of 172 | entertainment whether performed in public or private places. 173 | 174 | g) "You" means an individual or entity exercising rights under 175 | this License who has not previously violated the terms of 176 | this License with respect to the Work, or who has received 177 | express permission from the Licensor to exercise rights under 178 | this License despite a previous violation. 179 | 180 | h) "Publicly Perform" means to perform public recitations of 181 | the Work and to communicate to the public those public 182 | recitations, by any means or process, including by wire or 183 | wireless means or public digital performance, as well as to 184 | make available to the public Works in such a way that members 185 | of the public may access these Works from a place and at a 186 | place individually chosen by them. 187 | 188 | i) "Reproduce" means to make copies of the Work by any means 189 | including without limitation by sound or video recording, 190 | tape or other electronic means or process now known or 191 | later developed, and to edit, adapt, modify or translate 192 | such copies into other mediums currently known or 193 | 194 | When you speak of license "terms," you include all the terms 195 | of this License, with the following exceptions: 196 | 197 | a) Embedded Systems Code Licenses. Embedded Systems Licenses 198 | are limited to use, reproduction, and distribution of the object 199 | code form of an Implementer's Work. 200 | 201 | When you speak of license "terms," you include all the terms 202 | of this Software License, with the following exceptions: 203 | 204 | 1. If the Software is accompanied by documentation, the documentation 205 | license terms are an exception to the terms of this Software License. 206 | 207 | 2. If you receive the Software as part of a commercial offering, then 208 | the commercial license terms of this Software License are an exception 209 | to the terms of the license of the software or other commercial 210 | offering from which the Software was obtained. 211 | 212 | 3. If you obtain a commercial license to the Software that is accompanied 213 | by separate documentation, the separate license terms apply to the 214 | Software and are an exception to the terms of this Software License. 215 | 216 | 4. If you received the Software in a spiritual or telepathic 217 | medium without any accompanying information, the license terms of 218 | this license are nullified along with any other accompanying material, 219 | and the terms for that material. 220 | 221 | 5. If you are a Church, Synagogue, Mosque, or any other religious entity 222 | and you received the Software in a physical or electronic medium, 223 | these terms do not apply to you. 224 | 225 | 6. To the extent possible, the license granted here 226 | automatically covers all derivative works that arise 227 | out of the use of the licensed software. 228 | 229 | When the user copies or distributes a covered work, the 230 | user thereby agrees to indemnify the licensor for any 231 | liability incurred by the licensor as a result of the 232 | license. This indemnity applies to any version or 233 | derivative of the licensed work as long as the 234 | user retains, without alteration, the copyright notice 235 | and this notice. 236 | 237 | No warranty rights are granted by 238 | Licensor hereunder. 239 | 240 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT 241 | PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN 242 | WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE 243 | THIS PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 244 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 245 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 246 | PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND 247 | PERFORMANCE OF THE PROGRAM IS WITH YOU. IN NO EVENT SHALL 248 | THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 249 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 250 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 251 | LOSS OF USE, DATA, OR PROFITS; OR RELIGIOUS INTERRUPTION) 252 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 253 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 254 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 255 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 256 | SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 257 | ALL NECESSARY SERVICES, REPAIR OR CORRECTION. 258 | 259 | The text of this License constitutes the entire 260 | agreement regarding the subject matter hereof. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Genesis ***𐤁*** 2 | [![Open Source Love svg2](https://badges.frapsoft.com/os/v2/open-source.svg?style=for-the-badge)](https://github.com/ellerbrock/open-source-badges/) 3 | 4 | > "*My frame was not hidden from you, when I was being made in secret, intricately woven in the depths of the earth. Your eyes saw my unformed substance; in your book were written, every one of them, the days that were formed for me, when as yet there was none of them*" [^1] 5 | 6 | Genesis is an interpreted, procedural, and Turing-complete Paleo-Hebrew programming language. Diacritical signs are forgone for simplification, though maybe Nikud can be used in prospect as a means for more reserved keywords. 7 | 8 |

9 | 10 | 11 | 12 | 13 | 14 |

15 | 16 |

17 | Keywords • 18 | Operators • 19 | Types • 20 | Control Flow • 21 | Subroutines • 22 | Data Structures • 23 | Utilities • 24 | FAQ 25 |

26 | 27 | --- 28 | 29 | ## Valid Keywords 30 | | Lexeme | 𐤁 Equivalent(s) | 31 | | ------------- | ------------- | 32 | | Print | 𐤄𐤃𐤐𐤎 | 33 | | Print Line | 𐤄𐤃𐤐𐤎𐤇 | 34 | | Declare/Initialize Variable | 𐤄𐤂𐤃𐤓 | 35 | | Declare Subroutine | 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 | 36 | | If | 𐤀𐤌 | 37 | | Then | 𐤀𐤆 | 38 | | While | 𐤁𐤏𐤅𐤃 | 39 | | For | 𐤏𐤁𐤅𐤓 | 40 | | For Each | 𐤏𐤁𐤅𐤓𐤊𐤋 | 41 | | Sleep | 𐤉𐤔𐤍 | 42 | | Consecrate | 𐤒-𐤃-𐤔 | 43 | 44 | The `𐤒-𐤃-𐤔` keyword, meaning literally "to consecrate" or "to purify," denotes when the scope of a subroutine or loop terminates. 45 | 46 | ## Operations, Punctuation Elements, & Identifiers 47 | Java-style syntax and precedence are preserved for most operators: 48 | 49 | `+` - addition (numbers, strings)
50 | `-` - subtraction (numbers)
51 | `/` - division (numbers)
52 | `*` - multiplication (numbers)
53 | `^` - power (numbers)
54 | `=` - assignment (numbers, strings)
55 | `==` - logical equals (numbers, strings)
56 | `=!` - not equal to (numbers, strings)
57 | `<` - less than (numbers)
58 | `>` - greater than (numbers)
59 | `=>` - greater than or equal to (numbers)
60 | `=<` - less than or equal to (numbers)
61 | `&&` - logical and (booleans)
62 | `||` - logical or (booleans)
63 | 64 | However, the associativity of most operators is from right-to-left: 65 | 66 |
 67 | 𐤄𐤂𐤃𐤓 𐤐𐤅 = 𐤊״𐤇 - 𐤄׳ // 23
 68 | 
69 | 70 | Identifiers can be represented by alphanumeric text (including `_`) and do not have to start with an alphabetic character. 71 | 72 | ## Data Types & Literals 73 | Genesis is weakly and dynamically typed, so casting between primitives is handled implicitly by the interpreter. There are three data types: 74 | 75 | 1. Number 76 | - Encompasses `Bytes`, `Shorts`, `Integers`, `Longs`, `Doubles`, and `Floats`. 77 | 2. Boolean 78 | - Supports literals `𐤀𐤌𐤕` or `𐤔𐤒𐤓`, which correspond to `True` or `False`, respectively. 79 | 3. String 80 | - Delimited by quotation marks, e.g. `"!𐤔𐤋𐤅𐤌 𐤏𐤅𐤋𐤌"`. 81 | 82 | The Paleo-Hebrew alphabet may have used gematria to denote cardinal values, although there is only evidence of this on the Samaria Ostraca and Dead Sea Scroll 4Q252. This quasi-decimal isopsephic number system is adopted for a lack of an academic consensus. 83 | 84 | In this paradigm of numerology, there is no notation for zero, and the numeric values for individual letters are added together. Each unit (`1`, `2`, ..., `9`) is assigned a separate letter, each tens (`10`, `20`, ..., `90`) a separate letter, and the first four hundreds (`100`, `200`, `300`, `400`) a separate letter. The later hundreds (`500`, `600`, `700`, `800`, and `900`) are represented by the sum of two or three letters representing the first four hundreds. To represent numbers from `1,000` to `999,999`, the same letters are reused to serve as thousands, tens of thousands, and hundreds of thousands. Biblical pseudepigrapha use these transformations extensively. Standard (normative value) encoding per the conventional affine Mispar Hechrachi method of gematria is as follows: 85 | 86 | | Decimal | Hebrew | 𐤁 Glyph | 87 | | --- | --- | --- | 88 | | 1 | Alep | 𐤀 | 89 | | 2 | Bet | 𐤁 | 90 | | 3 | Gimel | 𐤂 | 91 | | 4 | Dalet | 𐤃 | 92 | | 5 | He | 𐤄 | 93 | | 6 | Waw | 𐤅 | 94 | | 7 | Zayin | 𐤆 | 95 | | 8 | Het | 𐤇 | 96 | | 9 | Tet | 𐤈 | 97 | | 10 | Yod | 𐤉 | 98 | | 20 | Kaf | 𐤊 | 99 | | 30 | Lamed | 𐤋 | 100 | | 40 | Mem | 𐤌 | 101 | | 50 | Nun | 𐤍 | 102 | | 60 | Samek | 𐤎 | 103 | | 70 | Ayin | 𐤏 | 104 | | 80 | Pe | 𐤐 | 105 | | 90 | Sade | 𐤑 | 106 | | 100 | Qop | 𐤒 | 107 | | 200 | Res | 𐤓 | 108 | | 300 | Sin | 𐤔 | 109 | | 400 | Taw | 𐤕 | 110 | 111 | Gershayim `״` (U+05F4 in Unicode, and resembling a double quote mark) (sometimes erroneously referred to as merkha'ot, which is Hebrew for double quote) are inserted before (to the right of) the last (leftmost) letter to indicate that the sequence of letters represents a gematric sequence of at least two Hebrew numerals (e.g., `28` → `𐤊״𐤇` and `5782` → `𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤕𐤒𐤐״𐤁`). 112 | 113 | Similarly, a single geresh `׳` (U+05F3 in Unicode, and resembling a single quote mark) is appended after (to the left of) a single letter in the case where a number is represented by a single Hebrew numeral (e.g. `100` → `𐤒׳`). 114 | 115 | ## Control Flow 116 | > "*Seek the Lord while he may be found; call on him while he is near*" [^2] 117 | 118 | The standard suite of loop constructs is supported. An iterative implementation for generating the first ten terms of the Fibonacci sequence using a `𐤁𐤏𐤅𐤃` loop is formulated as an example: 119 | 120 |
121 | 𐤄𐤂𐤃𐤓 𐤌𐤎𐤐𐤓 = 𐤉׳
122 | 𐤄𐤂𐤃𐤓 𐤓𐤀𐤔𐤅𐤍 = 𐤀׳
123 | 𐤄𐤂𐤃𐤓 𐤔𐤍𐤉𐤄 = 𐤀׳ - 𐤀׳
124 | 𐤄𐤂𐤃𐤓 𐤃𐤋𐤐𐤒 = 𐤀׳ - 𐤀׳
125 | 𐤄𐤂𐤃𐤓 𐤆𐤌𐤍𐤉 = 𐤀׳ - 𐤀׳
126 | 
127 | 𐤁𐤏𐤅𐤃 𐤃𐤋𐤐𐤒 <= 𐤌𐤎𐤐𐤓:
128 |     𐤄𐤃𐤐𐤎𐤇 𐤔𐤍𐤉𐤄
129 |     𐤆𐤌𐤍𐤉 = 𐤓𐤀𐤔𐤅𐤍 + 𐤔𐤍𐤉𐤄
130 |     𐤓𐤀𐤔𐤅𐤍 = 𐤔𐤍𐤉𐤄
131 |     𐤔𐤍𐤉𐤄 = 𐤆𐤌𐤍𐤉
132 |     𐤃𐤋𐤐𐤒 = 𐤃𐤋𐤐𐤒 + 𐤀׳
133 | 𐤒-𐤃-𐤔
134 | 
135 | 136 | The following `𐤏𐤁𐤅𐤓` loop prints out the first ten natural numbers: 137 | 138 |
139 | 𐤏𐤁𐤅𐤓 𐤌𐤎𐤐𐤓=𐤉׳,𐤌𐤎𐤐𐤓>=𐤀׳,𐤌𐤎𐤐𐤓=𐤌𐤎𐤐𐤓-𐤀׳:
140 |     𐤄𐤃𐤐𐤎𐤇 𐤌𐤎𐤐𐤓
141 | 𐤒-𐤃-𐤔
142 | 
143 | 144 | To accomplish nested operations or anamorphism, it is recommended to do a composition of subroutines. 145 | 146 | ## Subroutines 147 | > "*'I AM THAT I AM'*" [^3] 148 | 149 | Functions in Genesis are declared using the `𐤐𐤅𐤍𐤒𐤑𐤉𐤄` keyword. Being void and non-parameterized, however, they are actually subroutines. There is recursion insomuch that making a self-referential call from within a subroutine is possible, but there is no means to exit that recursion to express the irrevocable danger of pride and egoism. This design follows the contention that recursion, as Peter Deutsch identified, is divine and not encompassed by the domain of human programmers, as evidenced by God identifying himself recursively. 150 | 151 | 152 | 153 | To call on a subroutine, use the reference name with which it was defined. The following subroutine `𐤇𐤉𐤁𐤅𐤓` approximates the gravitational force of a 290-gram KJV Compact Ultraslim Bible one meter from a 70-kg human being: 154 | 155 |
156 | 𐤄𐤂𐤃𐤓 𐤊𐤅𐤇 = (𐤀׳ / (𐤉׳ ^ 𐤉״𐤀)) * (𐤕𐤓𐤎״𐤆 / 𐤒׳)
157 | 𐤄𐤂𐤃𐤓 𐤕𐤅𐤓𐤄 = 𐤊״𐤈 / 𐤒׳
158 | 𐤄𐤂𐤃𐤓 𐤀𐤃𐤌 = 𐤏׳
159 | 𐤄𐤂𐤃𐤓 𐤌𐤓𐤇𐤒 = 𐤀׳
160 | 
161 | 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤇𐤉𐤁𐤅𐤓:
162 | 	 𐤄𐤂𐤃𐤓 𐤄𐤇𐤉𐤁𐤅𐤓 = (𐤊𐤅𐤇 * 𐤕𐤅𐤓𐤄 * 𐤀𐤃𐤌) / (𐤌𐤓𐤇𐤒 * 𐤌𐤓𐤇𐤒)
163 | 	 𐤄𐤃𐤐𐤎 𐤄𐤇𐤉𐤁𐤅𐤓
164 | 𐤒-𐤃-𐤔
165 | 
166 | 𐤇𐤉𐤁𐤅𐤓
167 | 
168 | 169 | Other examples can be found in the respository. 170 | 171 | ## Data Structures 172 | 173 | Genesis provides fixed-length untyped array data structures. Curly braces are used to initialize arrays, and elements can be accessed or mutated through square bracket index operators: 174 | 175 |
176 | 𐤄𐤂𐤃𐤓 𐤌𐤎𐤐𐤓 = {𐤀׳, 𐤁׳, 𐤂׳}
177 | 
178 | 𐤌𐤎𐤐𐤓[𐤈׳/𐤈׳] = 𐤔𐤒𐤓
179 | 
180 | 𐤏𐤁𐤅𐤓𐤊𐤋 𐤀𐤋𐤌𐤍𐤈, 𐤌𐤎𐤐𐤓:
181 | 	𐤄𐤃𐤐𐤎𐤇 𐤀𐤋𐤌𐤍𐤈
182 | 𐤒-𐤃-𐤔
183 | 
184 | 185 | As denoted, `𐤏𐤁𐤅𐤓` or `𐤏𐤁𐤅𐤓𐤊𐤋` looping an array will yield its values. 186 | 187 | ## Math Library & Native Utilities 188 | 189 | | Function | Description | 𐤁 Equivalent(s) | 190 | | :-- | --- | --: | 191 | | Sqrt(#) | Returns the correctly rounded positive square root of a number value. | 𐤔𐤅𐤓𐤔(𐤍) | 192 | | Sin(∠) | Returns the trigonometric sine of an angle. | 𐤎𐤉𐤍(𐤈) | 193 | | Cos(∠) | Returns the trigonometric cosine of an angle. | 𐤒𐤅𐤎(𐤈) | 194 | | Tan(∠) | Returns the trigonometric tangent of an angle. | 𐤈𐤍(𐤈) | 195 | | ToDegrees(C) | Converts an angle measured in radians to degrees. | 𐤋𐤃(𐤒) | 196 | | ToRadians(∠) | Converts an angle measured in degrees to radians. | 𐤋𐤓(𐤈) | 197 | | Absolute(#) | Returns the absolute value of a number value. | 𐤏𐤌𐤇(𐤍) | 198 | | Log(#) | Returns the natural logarithm (base *e*) of a number value. | (𐤍)𐤋𐤅𐤂 | 199 | | Exp(#) | Returns Euler's number *e* raised to the power of a number value. | (𐤍)𐤀𐤒𐤎𐤐 | 200 | | Ulp(#) | Returns the size of an ulp of the argument. | (𐤍)𐤀𐤅𐤋𐤐 | 201 | | PI() | Returns π rounded to double precision. | ()𐤐𐤉𐤉 | 202 | | Random() | Returns a number value greater than or equal to 0.0 and less than 1.0. | ()𐤓𐤍𐤃 | 203 | | Evince() | Returns a random Bible quote. | ()𐤁𐤓𐤀 | 204 | 205 | Some calculations: 206 | 207 |
208 | 𐤄𐤂𐤃𐤓 𐤔𐤈𐤇 = 𐤃׳ * 𐤐𐤉𐤉() * (𐤉״𐤁 ^ 𐤁׳)
209 | 𐤄𐤂𐤃𐤓 𐤌𐤔𐤅𐤋𐤔 = (𐤀׳/𐤁׳) * (𐤄׳ * 𐤎״𐤃 * 𐤎𐤉𐤍(𐤌״𐤄))
210 | 𐤄𐤂𐤃𐤓 𐤒𐤋 = 𐤔𐤅𐤓𐤔(𐤎״𐤃) * 𐤓𐤍𐤃()
211 | 
212 | 𐤄𐤃𐤐𐤎𐤇 𐤔𐤈𐤇
213 | 𐤄𐤃𐤐𐤎𐤇 𐤌𐤔𐤅𐤋𐤔
214 | 𐤄𐤃𐤐𐤎𐤇 𐤒𐤋
215 | 
216 | 217 | A subroutine for calculating the energy of an electron in the `𐤍`-th orbital of a hydrogenic atom in Joules: 218 |
219 | 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤀𐤍𐤓𐤂𐤉𐤄:
220 | 𐤄𐤂𐤃𐤓 𐤍 = 𐤁׳
221 | 𐤄𐤂𐤃𐤓 𐤂𐤀𐤅𐤋 = ((𐤂׳ * (𐤉׳ ^ 𐤇׳)) * ((𐤉״𐤀 / 𐤉׳) * (𐤉׳ ^ 𐤆׳)) * (((𐤔׳ + 𐤔׳ * 𐤉׳) / (𐤕״𐤒)) * (𐤉׳ ^ (𐤅׳ - 𐤌׳))) * (𐤀׳ - 𐤁׳)) * (𐤀׳ / (𐤍 * 𐤍))
222 | 𐤄𐤃𐤐𐤎 𐤂𐤀𐤅𐤋
223 | 𐤒-𐤃-𐤔
224 | 
225 | 𐤀𐤍𐤓𐤂𐤉𐤄
226 | 
227 | 228 | FAQ 229 | ------ 230 | ### Why not use Modern Hebrew? 231 | If you are able to program in this language, I have failed. 232 | 233 | ### Why are you running an interpreted language over an interpreted language? 234 | > "*Wherefore, just as sin came into the world through one man, and death through sin, and so death spread to all men because all sinned*" [^4] 235 | 236 | ### Why not make an object-oriented language? 237 | This suggestion makes me consternated. Genesis will never be object-oriented because the Bible explicitly forbids object worship: 238 | > "*These prized objects are really worthless. The people who worship idols don’t know this, so they are all put to shame. []Their eyes are closed, and they cannot see. Their minds are shut, and they cannot think. The person who made the idol never stops to reflect, 'Why, it’s just a block of wood! I burned half of it for heat and used it to bake my bread and roast my meat. How can the rest of it be a god? Should I bow down to worship a piece of wood?'*" [^5] 239 | 240 | [^1]: [Psalm 139:13-16](https://www.biblegateway.com/passage/?search=Psalm%20139%3A13-16&version=NIV) 241 | [^2]: [Isaiah 55:6-7](https://www.biblegateway.com/passage/?search=Isaiah%2055%3A6-7&version=KJV) 242 | [^3]: [Exodus 3:14](https://www.biblegateway.com/passage/?search=Exodus%203%3A14&version=KJV) 243 | [^4]: [Romans 5:12-13](https://biblia.com/bible/esv/romans/5/12-13) 244 | [^5]: [Isaiah 44:9-20](https://www.biblestudytools.com/nlt/isaiah/passage/?q=isaiah+44:9-20) 245 | -------------------------------------------------------------------------------- /examples/Commandments.𐤁: -------------------------------------------------------------------------------- 1 | 𐤄𐤃𐤐𐤎𐤇 "𐤀𐤍𐤊𐤉 𐤉𐤄𐤅𐤄 𐤀𐤋𐤄𐤉𐤊" 2 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀-𐤉𐤄𐤉𐤄 𐤋𐤊 𐤀𐤋𐤄𐤉𐤌 𐤀𐤇𐤓𐤉𐤌, 𐤏𐤋-𐤐𐤍𐤉" 3 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀 𐤕𐤔𐤀 𐤀𐤕-𐤔𐤌-𐤉𐤄𐤅𐤄 𐤀𐤋𐤄𐤉𐤊, 𐤋𐤔𐤅𐤀" 4 | 𐤄𐤃𐤐𐤎𐤇 "𐤆𐤊𐤅𐤓 𐤀𐤕-𐤉𐤅𐤌 𐤄𐤔𐤁𐤕, 𐤋𐤒𐤃𐤔𐤅" 5 | 𐤄𐤃𐤐𐤎𐤇 "𐤊𐤁𐤃 𐤀𐤕-𐤀𐤁𐤉𐤊, 𐤅𐤀𐤕-𐤀𐤌𐤊" 6 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀 𐤕𐤓𐤑𐤇" 7 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀 𐤕𐤍𐤀𐤐" 8 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀 𐤕𐤂𐤍𐤁" 9 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀-𐤕𐤏𐤍𐤄 𐤁𐤓𐤏𐤊 𐤏𐤃 𐤔𐤒𐤓" 10 | 𐤄𐤃𐤐𐤎𐤇 "𐤋𐤀 𐤕𐤇𐤌𐤃, 𐤁𐤉𐤕 𐤓𐤏𐤊" -------------------------------------------------------------------------------- /examples/Fibonacci.𐤁: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elonlit/Genesis/c74ed393e7d71475f727d230121c206e6c1c3836/examples/Fibonacci.𐤁 -------------------------------------------------------------------------------- /examples/GravitationalForce.𐤁: -------------------------------------------------------------------------------- 1 | 𐤄𐤂𐤃𐤓 𐤊𐤅𐤇 = (𐤀׳ / (𐤉׳ ^ 𐤉״𐤀)) * (𐤕𐤓𐤎״𐤆 / 𐤒׳) 2 | 𐤄𐤂𐤃𐤓 𐤕𐤅𐤓𐤄 = 𐤊״𐤈 / 𐤒׳ 3 | 𐤄𐤂𐤃𐤓 𐤀𐤃𐤌 = 𐤏׳ 4 | 𐤄𐤂𐤃𐤓 𐤌𐤓𐤇𐤒 = 𐤀׳ 5 | 6 | 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤇𐤉𐤁𐤅𐤓: 7 | 𐤄𐤂𐤃𐤓 𐤄𐤇𐤉𐤁𐤅𐤓 = (𐤊𐤅𐤇 * 𐤕𐤅𐤓𐤄 * 𐤀𐤃𐤌) / (𐤌𐤓𐤇𐤒 * 𐤌𐤓𐤇𐤒) 8 | 𐤄𐤃𐤐𐤎 𐤄𐤇𐤉𐤁𐤅𐤓 9 | 𐤒-𐤃-𐤔 10 | 11 | 𐤇𐤉𐤁𐤅𐤓 12 | -------------------------------------------------------------------------------- /examples/Logic.𐤁: -------------------------------------------------------------------------------- 1 | 𐤄𐤃𐤐𐤎 "𐤔𐤋𐤅𐤌 𐤏𐤅𐤋𐤌, " 2 | 𐤄𐤃𐤐𐤎𐤇 "𐤌𐤄 𐤍𐤔𐤌𐤏?" 3 | 4 | 𐤄𐤂𐤃𐤓 𐤄𐤂𐤃𐤀 = {𐤅׳,𐤄׳} 5 | 𐤄𐤃𐤐𐤎𐤇 𐤄𐤂𐤃𐤀 6 | 𐤄𐤂𐤃𐤓 𐤒𐤋1 = 𐤒𐤋״𐤁 + 𐤉״𐤄 - 𐤁׳ 7 | 𐤄𐤂𐤃𐤓 𐤒𐤋2 = "𐤔𐤋𐤅𐤌" 8 | 𐤄𐤂𐤃𐤓 𐤒𐤋3 = 𐤔𐤒𐤓 9 | 𐤄𐤂𐤃𐤓 𐤒𐤋4 = 𐤅׳ / 𐤁׳ 10 | 𐤄𐤂𐤃𐤓 𐤒𐤋5 = (𐤒𐤋1 + 𐤀׳) * 𐤁׳ 11 | 𐤄𐤂𐤃𐤓 𐤒𐤋6 = 𐤔𐤅𐤓𐤔(𐤎״𐤃) * 𐤄׳ 12 | 13 | 𐤒𐤋1 = 𐤒𐤋1 + 𐤉״𐤁 14 | 𐤒𐤋4 = 𐤒𐤋4 * 𐤁׳ 15 | 𐤒𐤋1 = 𐤑״𐤈 16 | 17 | 𐤄𐤃𐤐𐤎𐤇 𐤒𐤋1 18 | 𐤄𐤃𐤐𐤎𐤇 𐤒𐤋2 19 | 𐤄𐤃𐤐𐤎𐤇 𐤒𐤋3 20 | 21 | 𐤀𐤌 𐤒𐤋1 <= 𐤒׳ 𐤀𐤆 𐤄𐤃𐤐𐤎 "𐤌𐤏𐤅𐤋𐤄!" 22 | 𐤄𐤃𐤐𐤎 " " 23 | 𐤀𐤌 𐤒𐤋4 != 𐤉״𐤁 𐤀𐤆 𐤄𐤃𐤐𐤎𐤇 "𐤌𐤌𐤔 𐤌𐤏𐤅𐤋𐤄!" 24 | 𐤀𐤌 𐤉״𐤁 != 𐤉״𐤁 𐤀𐤆 𐤄𐤃𐤐𐤎 "𐤌𐤅𐤆𐤓..." 25 | -------------------------------------------------------------------------------- /examples/Loops.𐤁: -------------------------------------------------------------------------------- 1 | 𐤄𐤂𐤃𐤓 𐤌𐤎𐤐𐤓 = {𐤀׳, 𐤁׳, 𐤂׳} 2 | 3 | 𐤌𐤎𐤐𐤓[𐤈׳/𐤈׳] = 𐤔𐤒𐤓 4 | 5 | 𐤏𐤁𐤅𐤓𐤊𐤋 𐤀𐤋𐤌𐤍𐤈, 𐤌𐤎𐤐𐤓: 6 | 𐤄𐤃𐤐𐤎𐤇 𐤀𐤋𐤌𐤍𐤈 7 | 𐤒-𐤃-𐤔 -------------------------------------------------------------------------------- /examples/MathDemonstration.𐤁: -------------------------------------------------------------------------------- 1 | 𐤄𐤂𐤃𐤓 𐤔𐤈𐤇 = 𐤃׳ * 𐤐𐤉𐤉() * (𐤉״𐤁 ^ 𐤁׳) 2 | 𐤄𐤃𐤐𐤎𐤇 𐤔𐤈𐤇 3 | 4 | 𐤄𐤂𐤃𐤓 𐤌𐤔𐤅𐤋𐤔 = (𐤀׳/𐤁׳) * (𐤄׳ * 𐤎״𐤃 * 𐤎𐤉𐤍(𐤌״𐤄)) 5 | 𐤄𐤃𐤐𐤎𐤇 𐤌𐤔𐤅𐤋𐤔 6 | 7 | 𐤄𐤂𐤃𐤓 𐤒𐤋 = 𐤔𐤅𐤓𐤔(𐤎״𐤃) * 𐤓𐤍𐤃() 8 | 𐤄𐤃𐤐𐤎𐤇 𐤒𐤋 -------------------------------------------------------------------------------- /examples/QuantumMechanics.𐤁: -------------------------------------------------------------------------------- 1 | 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤀𐤍𐤓𐤂𐤉𐤄: 2 | 𐤄𐤂𐤃𐤓 𐤍 = 𐤁׳ 3 | 𐤄𐤂𐤃𐤓 𐤂𐤀𐤅𐤋 = ((𐤂׳ * (𐤉׳ ^ 𐤇׳)) * ((𐤉״𐤀 / 𐤉׳) * (𐤉׳ ^ 𐤆׳)) * (((𐤔׳ + 𐤔׳ * 𐤉׳) / (𐤕״𐤒)) * (𐤉׳ ^ (𐤅׳ - 𐤌׳))) * (𐤀׳ - 𐤁׳)) * (𐤀׳ / (𐤍 * 𐤍)) 4 | 𐤄𐤃𐤐𐤎 𐤂𐤀𐤅𐤋 5 | 𐤒-𐤃-𐤔 6 | 7 | 𐤀𐤍𐤓𐤂𐤉𐤄 8 | -------------------------------------------------------------------------------- /examples/SurfaceGravity.𐤁: -------------------------------------------------------------------------------- 1 | /** 2 | * The following subroutine 𐤊𐤅𐤊𐤁 approximates the surface gravity of a planet (with Mercury as a test case). 3 | * 4 | * @author Elon Litman 5 | */ 6 | 7 | 𐤄𐤂𐤃𐤓 𐤒𐤅𐤈𐤓 = (𐤆׳ * 𐤕׳) + (𐤁׳ * 𐤕׳) + 𐤐׳ 8 | 𐤄𐤂𐤃𐤓 𐤌𐤎𐤄 = 𐤂׳ * (𐤉׳ ^ 𐤊״𐤂) 9 | 𐤄𐤂𐤃𐤓 𐤒𐤁𐤅𐤏 = (𐤉׳ ^ (𐤉״𐤀 / 𐤀׳)) * 𐤆׳ 10 | 11 | 𐤄𐤐𐤏𐤋 𐤊𐤅𐤊𐤁 12 | 13 | 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤊𐤅𐤊𐤁: 14 | 𐤄𐤂𐤃𐤓 𐤊𐤅𐤇𐤌 = (𐤌𐤎𐤄 * 𐤒𐤁𐤅𐤏) / (𐤁׳ ^ 𐤒𐤅𐤈𐤓) 15 | 𐤄𐤃𐤐𐤎 𐤊𐤅𐤇𐤌 16 | 𐤒-𐤃-𐤔 17 | -------------------------------------------------------------------------------- /lib/annotations-20.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elonlit/Genesis/c74ed393e7d71475f727d230121c206e6c1c3836/lib/annotations-20.1.0.jar -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | groupId 8 | Genesis 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 15 13 | 15 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/java/Commands/For.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import RoutineBlocks.RoutineBlock; 4 | import Driver.Interpreter; 5 | import UI.UIManager; 6 | import Utilities.BooleanExpressionSolver; 7 | import Utilities.NumberExpressionSolver; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.HashMap; 11 | 12 | public class For implements ICommand 13 | { 14 | private static final HashMap loops = new HashMap<>(); // Tagged by the line number 15 | 16 | @Override 17 | public void sendParameters(@NotNull String par, int line, boolean preRun) 18 | { 19 | while(par.endsWith(" ")) par = par.substring(0, par.length()-1); // Removing whitespaces in the end of the line 20 | 21 | par = par.replaceAll("\\s",""); // Remove all whitespaces 22 | int commCounter = 0; 23 | int dotsCounter = 0; 24 | int equalCounter = 0; 25 | for(char c: par.toCharArray()) 26 | { 27 | if(c == ':') dotsCounter++; 28 | else if(c == ',') commCounter++; 29 | else if(c == '=') equalCounter++; 30 | } 31 | if(dotsCounter != 1) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 ':' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 32 | if(!par.substring(par.indexOf(":") + 1).isEmpty()) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤒𐤈𐤏 𐤋𐤀 𐤑𐤐𐤅𐤉 𐤋𐤀𐤇𐤓 𐤍𐤒𐤅𐤃𐤅𐤕𐤉𐤉𐤌 𐤁𐤔𐤅𐤓𐤄: " + line, line); 33 | par = par.substring(0, par.indexOf(":")); 34 | 35 | //if(equleCounter != 2) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 '=' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 36 | 37 | if(commCounter != 2) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 ',' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 38 | String[] loopValues = par.split(","); // 0 = variable, 1 = condition, 2 = action 39 | 40 | if(preRun) 41 | { 42 | RoutineBlock routineBlock = Interpreter.cutCodeBlock(line + 1, false); 43 | if (routineBlock == null) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤌𐤁𐤍𐤄 𐤔𐤋 𐤄𐤋𐤅𐤋𐤀𐤄, 𐤇𐤎𐤓 '𐤎𐤅𐤐', 𐤋𐤋𐤅𐤋𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 44 | 45 | loops.put(line, routineBlock); 46 | } 47 | else 48 | { 49 | String[] theVariable = loopValues[0].split("="); 50 | Variable.globalVariables.put(theVariable[0], new NumberExpressionSolver(theVariable[1], line).getResult()); // If not number this check for boolean as well 51 | 52 | while((boolean) new BooleanExpressionSolver(loopValues[1], line).getResult()) 53 | { 54 | loops.get(line).initiateCode(); 55 | Interpreter.initiateLine(loopValues[2], line); 56 | } 57 | 58 | Variable.globalVariables.remove(theVariable[0]); 59 | } 60 | } 61 | 62 | public static void clearLoopsData() 63 | { 64 | loops.clear(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/Commands/ForEach.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import RoutineBlocks.RoutineBlock; 4 | import Driver.Interpreter; 5 | import UI.UIManager; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.HashMap; 9 | 10 | public class ForEach implements ICommand 11 | { 12 | private static final HashMap loops = new HashMap<>(); // Tagged by the line number 13 | 14 | @Override 15 | public void sendParameters(@NotNull String par, int line, boolean preRun) 16 | { 17 | while(par.endsWith(" ")) par = par.substring(0, par.length()-1); // Removing whitespaces in the end of the line 18 | 19 | par = par.replaceAll("\\s",""); // Remove all whitespaces 20 | int commCounter = 0; 21 | int dotsCounter = 0; 22 | for(char c: par.toCharArray()) 23 | { 24 | if(c == ':') dotsCounter++; 25 | else if(c == ',') commCounter++; 26 | } 27 | if(dotsCounter != 1) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 ':' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 28 | if(!par.substring(par.indexOf(":") + 1).isEmpty()) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤒𐤈𐤏 𐤋𐤀 𐤑𐤐𐤅𐤉 𐤋𐤀𐤇𐤓 𐤍𐤒𐤅𐤃𐤅𐤕𐤉𐤉𐤌 𐤁𐤔𐤅𐤓𐤄: " + line, line); 29 | par = par.substring(0, par.indexOf(":")); 30 | 31 | if(commCounter != 1) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 ',' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 32 | String[] loopValues = par.split(","); // 0 = holder variable, 1 = the array 33 | 34 | if(preRun) 35 | { 36 | RoutineBlock routineBlock = Interpreter.cutCodeBlock(line + 1, false); 37 | if (routineBlock == null) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤌𐤁𐤍𐤄 𐤔𐤋 𐤄𐤋𐤅𐤋𐤀𐤄, 𐤇𐤎𐤓 '𐤎𐤅𐤐', 𐤋𐤋𐤅𐤋𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 38 | 39 | loops.put(line, routineBlock); 40 | } 41 | else 42 | { 43 | if(NameAndStorage.isNameValid(loopValues[0])) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤔𐤌 𐤌𐤔𐤕𐤍𐤄 𐤋𐤀 𐤇𐤅𐤒𐤉 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is at least one '=' 44 | Variable.globalVariables.put(loopValues[0], null); 45 | 46 | Object[] theArray; 47 | if(Variable.globalVariables.get(loopValues[1]) != null) 48 | { 49 | theArray = (Object[]) Variable.globalVariables.get(loopValues[1]); 50 | } 51 | else 52 | { 53 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤔𐤌 𐤌𐤏𐤓𐤊 𐤋𐤀 𐤇𐤅𐤒𐤉: " + line, line); 54 | return; 55 | } 56 | 57 | for (Object o : theArray) { 58 | Variable.globalVariables.replace(loopValues[0], o); 59 | loops.get(line).initiateCode(); 60 | } 61 | 62 | Variable.globalVariables.remove(loopValues[0]); 63 | } 64 | } 65 | 66 | public static void clearLoopsData() 67 | { 68 | loops.clear(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/Commands/ICommand.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | public interface ICommand 4 | { 5 | void sendParameters(String par, int line, boolean preRun); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/Commands/If.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import Driver.Interpreter; 4 | import UI.UIManager; 5 | import Utilities.BooleanExpressionSolver; 6 | 7 | public class If implements ICommand 8 | { 9 | @Override 10 | public void sendParameters(String par, int lineNumber, boolean preRun) 11 | { 12 | if(preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + lineNumber, lineNumber); 13 | 14 | while(par.endsWith(" ")) par = par.substring(0, par.length()-1); // Removing whitespaces in the end of the line 15 | 16 | if(!par.contains(" 𐤀 ")) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 '𐤀𐤆' 𐤁𐤔𐤅𐤓𐤄: " + lineNumber, lineNumber); 17 | String condition = par.substring(0, par.indexOf(" 𐤀 ")); 18 | String command = par.substring(par.indexOf(" 𐤀 ") + 4); 19 | //doesn't parse as surrogate pair 20 | 21 | condition = condition.replaceAll("\\s",""); // Remove all whitespaces 22 | if((boolean) new BooleanExpressionSolver(condition, lineNumber).getResult()) Interpreter.initiateLine(command, lineNumber); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/Commands/NameAndStorage.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import References.GenesisKeyWords; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.HashMap; 7 | 8 | public abstract class NameAndStorage 9 | { 10 | protected static boolean isNameValid(String name) 11 | { 12 | for(GenesisKeyWords keyWord: GenesisKeyWords.values()) // Command names that are already taken 13 | { 14 | if(name.equals(keyWord.getGenesisCode())) 15 | { 16 | return true; 17 | } 18 | } 19 | 20 | for(String varName: Variable.getVariablesNames()) // Variable names that are already taken 21 | { 22 | if(name.equals(varName)) 23 | { 24 | return true; 25 | } 26 | } 27 | 28 | for(String funcName: Subroutine.getFunctionsNames()) // Function names that are already taken 29 | { 30 | if(name.equals(funcName)) 31 | { 32 | return true; 33 | } 34 | } 35 | 36 | return false; 37 | } 38 | 39 | protected static boolean doesThisNameExistInStorage(@NotNull HashMap storage, String name) 40 | { 41 | for(String funcName: storage.keySet()) 42 | { 43 | if(name.equals(funcName)) return true; 44 | } 45 | return false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/Commands/Print.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import UI.UIManager; 4 | import Utilities.NumberExpressionSolver; 5 | 6 | public class Print implements ICommand 7 | { 8 | protected void initiateCommand(String val) 9 | { 10 | UIManager.consoleInstance.print(val); 11 | } 12 | 13 | @Override 14 | public void sendParameters(String par, int line, boolean preRun) 15 | { 16 | if(preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 17 | 18 | while(par.endsWith(" ")) par = par.substring(0, par.length()-1); // Removing whitespaces in the end of the line 19 | 20 | boolean arrayFlag1 = false, arrayFlag2 = false; 21 | for(char c: par.toCharArray()) 22 | { 23 | if(c == '[') arrayFlag1 = true; 24 | else if(c == ']') arrayFlag2 = true; 25 | } 26 | 27 | if(arrayFlag1 && arrayFlag2) // One value in array 28 | { 29 | double index = (double) new NumberExpressionSolver(par.substring(par.indexOf("[")+1, par.indexOf("]")), line).getResult(); 30 | if(index % 1 != 0) UIManager.consoleInstance.printErrorMessage("𐤀𐤉𐤍𐤃𐤒𐤎 𐤋𐤀 𐤇𐤅𐤒𐤉 𐤋𐤌𐤏𐤓𐤊 𐤁𐤔𐤅𐤓𐤄 - " + line, line); // check that it is indeed always int 31 | Object[] theArray = (Object[]) Variable.getAVariableValue(par.substring(0, par.indexOf("["))); 32 | initiateCommand(theArray[(int)index].toString()); 33 | } 34 | else if(par.startsWith("\"") && par.endsWith("\"")) // Quote 35 | { 36 | initiateCommand(par.substring(1, par.length()-1)); 37 | } 38 | else 39 | { 40 | for(String varName: Variable.getVariablesNames()) // Variable 41 | { 42 | if(par.equals(varName)) 43 | { 44 | Object value = Variable.getAVariableValue(varName); 45 | StringBuilder printValue = new StringBuilder(); 46 | if(value instanceof Boolean) 47 | { 48 | if(value.equals(true)) 49 | { 50 | printValue = new StringBuilder("𐤀𐤌𐤕");//אמת 51 | } 52 | else 53 | { 54 | printValue = new StringBuilder("𐤔𐤒𐤓");//שקר 55 | } 56 | } 57 | else if(value instanceof Object[]) // All array 58 | { 59 | for(Object a: (Object[]) value) 60 | { 61 | if(a instanceof Boolean) 62 | { 63 | if(a.equals(true)) 64 | { 65 | printValue.append("𐤀𐤌𐤕 "); 66 | } 67 | else 68 | { 69 | printValue.append("𐤔𐤒𐤓 "); 70 | } 71 | } 72 | else 73 | { 74 | printValue.append(a.toString()).append(" "); 75 | } 76 | } 77 | } 78 | else 79 | { 80 | printValue = new StringBuilder(value.toString()); 81 | } 82 | 83 | initiateCommand(printValue.toString()); 84 | return; 85 | } 86 | } 87 | 88 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/Commands/PrintLine.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import UI.UIManager; 4 | 5 | public class PrintLine extends Print 6 | { 7 | @Override 8 | protected void initiateCommand(String val) 9 | { 10 | UIManager.consoleInstance.println(val); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/Commands/Sleep.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import java.util.Calendar; 4 | import java.util.concurrent.TimeUnit; 5 | import UI.UIManager; 6 | import Utilities.NumberExpressionSolver; 7 | 8 | public class Sleep implements ICommand 9 | { 10 | @Override 11 | public void sendParameters(String par, int lineNumber, boolean preRun) 12 | { 13 | if(preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + lineNumber, lineNumber); 14 | 15 | Calendar calendar = Calendar.getInstance(); 16 | // You may only invoke the sleep command on Shabbat 17 | if(calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { 18 | UIManager.consoleInstance.printErrorMessage("𐤌𐤅𐤕𐤓 𐤋𐤉𐤔𐤅𐤍 𐤓𐤒 𐤁𐤔𐤁𐤕: " + lineNumber, lineNumber); 19 | return; 20 | } 21 | 22 | while(par.endsWith(" ")) par = par.substring(0, par.length()-1); // Removing whitespaces in the end of the line 23 | par = par.replaceAll("\\s",""); // Remove all whitespaces 24 | Object result = new NumberExpressionSolver(par, lineNumber).getResult(); 25 | if (result instanceof Double) 26 | { 27 | try 28 | { 29 | TimeUnit.SECONDS.sleep(((Double) result).intValue()); 30 | } 31 | catch (InterruptedException e) 32 | { 33 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤁𐤉𐤑𐤅𐤏 𐤄𐤌𐤕𐤍𐤄 𐤔𐤋 𐤐𐤒𐤅𐤃𐤕 𐤇𐤊𐤄, 𐤁𐤔𐤅𐤓𐤄: " + lineNumber, lineNumber); 34 | } 35 | } 36 | else 37 | { 38 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤃𐤓𐤅𐤔 𐤌𐤎𐤐𐤓 𐤋𐤁𐤉𐤈𐤅𐤉 𐤇𐤊𐤄, 𐤁𐤔𐤅𐤓𐤄: " + lineNumber, lineNumber); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/Commands/Subroutine.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import Driver.Interpreter; 4 | import UI.UIManager; 5 | import RoutineBlocks.RoutineBlock; 6 | import org.jetbrains.annotations.Contract; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.HashMap; 10 | import java.util.Set; 11 | 12 | public class Subroutine extends NameAndStorage implements ICommand 13 | { 14 | public static HashMap functions = new HashMap<>(); 15 | 16 | @Override 17 | public void sendParameters(String par, int line, boolean preRun) 18 | { 19 | if(!preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 20 | 21 | par = par.replaceAll("\\s",""); // Remove all whitespaces 22 | int dotsCounter = 0; 23 | for(char c: par.toCharArray()) 24 | { 25 | if(c == ':') dotsCounter++; 26 | } 27 | if(dotsCounter != 1) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 ':' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 28 | String fucName = par.substring(0, par.indexOf(":")); 29 | if(!par.substring(par.indexOf(":") + 1).isEmpty()) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤒𐤈𐤏 𐤋𐤀 𐤑𐤐𐤅𐤉 𐤋𐤀𐤇𐤓 𐤍𐤒𐤅𐤃𐤅𐤕𐤉𐤉𐤌 𐤁𐤔𐤅𐤓𐤄: " + line, line); 30 | if(isNameValid(fucName)) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤔𐤌 𐤄𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤋𐤀 𐤇𐤅𐤒𐤉 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is at least one '=' 31 | 32 | RoutineBlock routineBlock = Interpreter.cutCodeBlock(line + 1, true); 33 | if(routineBlock == null) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤌𐤁𐤍𐤄 𐤔𐤋 𐤄𐤐𐤅𐤍𐤒𐤑𐤉𐤄, 𐤇𐤎𐤓 '𐤎𐤅𐤐', 𐤋𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 34 | 35 | functions.put(fucName, routineBlock); 36 | } 37 | 38 | @Contract(pure = true) 39 | public static @NotNull Set getFunctionsNames() 40 | { 41 | return functions.keySet(); 42 | } 43 | 44 | public static boolean doesFunctionExist(String name) 45 | { 46 | return doesThisNameExistInStorage(functions, name); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/Commands/SubroutineCall.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import UI.UIManager; 4 | 5 | public class SubroutineCall implements ICommand 6 | { 7 | @Override 8 | public void sendParameters(String par, int line, boolean preRun) 9 | { 10 | if(preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 11 | 12 | par = par.replaceAll("\\s",""); // Remove all whitespaces 13 | if(!Subroutine.doesFunctionExist(par)) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤔𐤋𐤀 𐤒𐤉𐤉𐤌𐤕 𐤀𐤅 𐤈𐤏𐤅𐤕 𐤊𐤕𐤉𐤁𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Function not found 14 | 15 | Subroutine.functions.get(par).duplicate().initiateCode(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/Commands/Variable.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import Driver.Interpreter; 4 | import UI.UIManager; 5 | import Utilities.NumberExpressionSolver; 6 | import org.jetbrains.annotations.Contract; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.HashMap; 10 | import java.util.Set; 11 | 12 | import static UI.CodeEditor.singleCodePointVariables; 13 | 14 | public class Variable extends NameAndStorage implements ICommand 15 | { 16 | public static HashMap globalVariables = new HashMap<>(); 17 | 18 | @Override 19 | public void sendParameters(String par, int line, boolean preRun) 20 | { 21 | if(preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 22 | 23 | int eqCounter = 0; 24 | boolean arrayFlag1 = false, arrayFlag2 = false; 25 | for(char c: par.toCharArray()) 26 | { 27 | if(c == '=') eqCounter++; 28 | else if(c == '}') arrayFlag1 = true; 29 | else if(c == '{') arrayFlag2 = true; 30 | } 31 | if(eqCounter == 0) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 '=' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is at least one '=' 32 | String varName = par.substring(0, par.indexOf("=")); 33 | String varValue = par.substring(par.indexOf("=") + 1); 34 | 35 | varName = varName.replaceAll("\\s",""); // Remove all whitespaces 36 | if(isNameValid(varName)) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤔𐤌 𐤌𐤔𐤕𐤍𐤄 𐤋𐤀 𐤇𐤅𐤒𐤉 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is at least one '=' 37 | 38 | while(varValue.startsWith(" ")) varValue = varValue.substring(1); 39 | while(varValue.endsWith(" ")) varValue = varValue.substring(0, varValue.length()-1); 40 | if(varValue.startsWith("\"") && varValue.endsWith("\"") && varValue.length() != 1) // String 41 | { 42 | globalVariables.put(varName, varValue.substring(1, varValue.length()-1)); 43 | if(Interpreter.runningRoutineBlock != null) Interpreter.runningRoutineBlock.reportLocalVariable(varName); // In case of local variables 44 | return; 45 | } 46 | 47 | varValue = varValue.replaceAll("\\s",""); // Remove all whitespaces 48 | if(arrayFlag1 && arrayFlag2) // Array creation 49 | { 50 | varValue = varValue.substring(1, varValue.length()-1); // Remove '{' '}' 51 | String[] arrayValues = varValue.split(","); 52 | 53 | Object[] arrayVariable = new Object[arrayValues.length]; 54 | for(int i = 0; i < arrayVariable.length; i++) 55 | { 56 | arrayVariable[i] = new NumberExpressionSolver(arrayValues[i], line).getResult(); 57 | } 58 | 59 | globalVariables.put(varName, arrayVariable); 60 | if(Interpreter.runningRoutineBlock != null) Interpreter.runningRoutineBlock.reportLocalVariable(varName); // In case of local variables 61 | return; 62 | } 63 | 64 | Variable.globalVariables.put(varName, new NumberExpressionSolver(varValue, line).getResult()); // If not number this check for boolean as well 65 | if(Interpreter.runningRoutineBlock != null) Interpreter.runningRoutineBlock.reportLocalVariable(varName); // In case of local variables 66 | } 67 | 68 | public static boolean doesVariableExist(String name) 69 | { 70 | return !doesThisNameExistInStorage(globalVariables, name); 71 | } 72 | 73 | @Contract(pure = true) 74 | public static @NotNull Set getVariablesNames() 75 | { 76 | return globalVariables.keySet(); 77 | } 78 | 79 | public static Object getAVariableValue(String varName) 80 | { 81 | return globalVariables.get(varName); 82 | } 83 | 84 | public static String[] globalVariablesLog() 85 | { 86 | StringBuilder logOutput = new StringBuilder(); 87 | for(String varKey: globalVariables.keySet()) 88 | { 89 | if(globalVariables.get(varKey) instanceof Object[]) // Array 90 | { 91 | logOutput.append(varKey); 92 | } 93 | else 94 | { 95 | logOutput.append(varKey); 96 | logOutput.append("="); 97 | logOutput.append(globalVariables.get(varKey).toString()); 98 | } 99 | 100 | logOutput.append(", "); 101 | } 102 | 103 | if (globalVariables.size() > 0) { 104 | logOutput.delete(logOutput.length() - 2, logOutput.length() - 1); // Delete last " ," 105 | } 106 | final String[] logOutputStr = {logOutput.toString()}; 107 | 108 | singleCodePointVariables.forEach((singlePoint, doublePoint) -> logOutputStr[0] = logOutputStr[0].replaceAll(doublePoint, singlePoint)); 109 | 110 | return logOutputStr; 111 | } 112 | } -------------------------------------------------------------------------------- /src/main/java/Commands/VariableUpdate.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import UI.UIManager; 4 | import Utilities.NumberExpressionSolver; 5 | 6 | public class VariableUpdate implements ICommand 7 | { 8 | @Override 9 | public void sendParameters(String par, int line, boolean preRun) 10 | { 11 | if(preRun) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 12 | 13 | par = par.replaceAll("\\s",""); // Remove all whitespaces 14 | int eqCounter = 0; 15 | boolean arrayFlag1 = false, arrayFlag2 = false, arrayFlag3 = false, arrayFlag4 = false; 16 | for(char c: par.toCharArray()) 17 | { 18 | if(c == '=') eqCounter++; 19 | else if(c == '}') arrayFlag1 = true; 20 | else if(c == '{') arrayFlag2 = true; 21 | else if(c == '[') arrayFlag3 = true; 22 | else if(c == ']') arrayFlag4 = true; 23 | } 24 | if(eqCounter == 0) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 '=' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is at least one '=' 25 | String varName = par.substring(0, par.indexOf("=")); 26 | String varValue = par.substring(par.indexOf("=") + 1); 27 | if(arrayFlag3 && arrayFlag4) 28 | { 29 | if(Variable.doesVariableExist(varName.substring(0, varName.indexOf("[")))) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤌𐤔𐤕𐤍𐤄 𐤔𐤋𐤀 𐤒𐤉𐤉𐤌 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Variable not found 30 | } 31 | else if(Variable.doesVariableExist(varName)) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤌𐤔𐤕𐤍𐤄 𐤔𐤋𐤀 𐤒𐤉𐤉𐤌 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Variable not found 32 | 33 | if(varValue.startsWith("\"") && varValue.endsWith("\"") && varValue.length() != 1) // String 34 | { 35 | Variable.globalVariables.replace(varName, varValue.substring(1, varValue.length()-1)); 36 | return; 37 | } 38 | 39 | if(arrayFlag1 && arrayFlag2) // All array update 40 | { 41 | varValue = varValue.replaceAll("\\s",""); // Remove all whitespaces 42 | varValue = varValue.substring(1, varValue.length()-1); // Remove '{' '}' 43 | String[] arrayValues = varValue.split(","); 44 | 45 | Object[] arrayVariable = new Object[arrayValues.length]; 46 | for(int i = 0; i < arrayVariable.length; i++) 47 | { 48 | arrayVariable[i] = new NumberExpressionSolver(arrayValues[i], line).getResult(); 49 | } 50 | 51 | Variable.globalVariables.replace(varName, arrayVariable); 52 | return; 53 | } 54 | 55 | if(arrayFlag3 && arrayFlag4) // One value in the array update 56 | { 57 | //int index = Integer.parseInt(varName.substring(varName.indexOf("[")+1, varName.indexOf("]"))); 58 | double index = (double) new NumberExpressionSolver(varName.substring(varName.indexOf("[")+1, varName.indexOf("]")), line).getResult(); 59 | if(index % 1 != 0) UIManager.consoleInstance.printErrorMessage("𐤀𐤉𐤍𐤃𐤒𐤎 𐤋𐤀 𐤇𐤅𐤒𐤉 𐤋𐤌𐤏𐤓𐤊 𐤁𐤔𐤅𐤓𐤄 - " + line, line); // check that it is indeed always int 60 | Object[] newArray = (Object[]) Variable.getAVariableValue(varName.substring(0, varName.indexOf("["))); 61 | newArray[(int)index] = new NumberExpressionSolver(varValue, line).getResult(); 62 | Variable.globalVariables.replace(varName.substring(0, varName.indexOf("[")), newArray); 63 | } 64 | 65 | else if(varValue.equals("𐤀𐤌𐤕")) // Boolean True אמת 66 | { 67 | Variable.globalVariables.replace(varName, true); 68 | return; 69 | } 70 | else if(varValue.equals("𐤔𐤒𐤓")) // Boolean False שקר 71 | { 72 | Variable.globalVariables.replace(varName, false); 73 | return; 74 | } 75 | 76 | for(String name: Variable.getVariablesNames()) // Other Variable 77 | { 78 | if(varValue.equals(name)) 79 | { 80 | Variable.globalVariables.replace(varName, Variable.getAVariableValue(varValue)); 81 | return; 82 | } 83 | } 84 | 85 | Variable.globalVariables.replace(varName, new NumberExpressionSolver(varValue, line).getResult()); // If not number this check for boolean as well 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/Commands/While.java: -------------------------------------------------------------------------------- 1 | package Commands; 2 | 3 | import RoutineBlocks.RoutineBlock; 4 | import Driver.Interpreter; 5 | import UI.UIManager; 6 | import Utilities.BooleanExpressionSolver; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.HashMap; 10 | 11 | public class While implements ICommand 12 | { 13 | private static final HashMap loops = new HashMap<>(); // Tagged by the line number 14 | 15 | @Override 16 | public void sendParameters(@NotNull String par, int line, boolean preRun) 17 | { 18 | while(par.endsWith(" ")) par = par.substring(0, par.length()-1); // Removing whitespaces in the end of the line 19 | 20 | par = par.replaceAll("\\s",""); // Remove all whitespaces 21 | int dotsCounter = 0; 22 | for(char c: par.toCharArray()) 23 | { 24 | if(c == ':') dotsCounter++; 25 | } 26 | if(dotsCounter != 1) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤇𐤎𐤓 ':' 𐤁𐤔𐤅𐤓𐤄: " + line, line); // Make sure there is one ':' 27 | String condition = par.substring(0, par.indexOf(":")); 28 | if(!par.substring(par.indexOf(":") + 1).isEmpty()) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤒𐤈𐤏 𐤋𐤀 𐤑𐤐𐤅𐤉 𐤋𐤀𐤇𐤓 𐤍𐤒𐤅𐤃𐤅𐤕𐤉𐤉𐤌 𐤁𐤔𐤅𐤓𐤄: " + line, line); 29 | 30 | if(preRun) 31 | { 32 | RoutineBlock routineBlock = Interpreter.cutCodeBlock(line + 1, false); 33 | if (routineBlock == null) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤌𐤁𐤍𐤄 𐤔𐤋 𐤄𐤋𐤅𐤋𐤀𐤄, 𐤇𐤎𐤓 '𐤎𐤅𐤐', 𐤋𐤋𐤅𐤋𐤀𐤄 𐤁𐤔𐤅𐤓𐤄: " + line, line); 34 | loops.put(line, routineBlock); 35 | } 36 | else 37 | { 38 | while((boolean) new BooleanExpressionSolver(condition, line).getResult()) 39 | { 40 | loops.get(line).initiateCode(); 41 | } 42 | } 43 | } 44 | 45 | public static void clearLoopsData() 46 | { 47 | loops.clear(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/Driver/GenesisMain.java: -------------------------------------------------------------------------------- 1 | package Driver; 2 | 3 | import Commands.*; 4 | import UI.UIManager; 5 | 6 | import javax.swing.*; 7 | import javax.swing.filechooser.FileNameExtensionFilter; 8 | import java.io.*; 9 | import java.util.Collections; 10 | 11 | public class GenesisMain 12 | { 13 | public static void main(String[] args) 14 | { 15 | UIManager.openUI(); 16 | } 17 | 18 | public static void readFromFile() 19 | { 20 | Runnable r = () -> { 21 | System.out.print("\033[H\033[2J"); 22 | System.out.flush(); 23 | 24 | JFileChooser jfc = new JFileChooser(); 25 | jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); 26 | jfc.setSelectedFile(new File("\uD802\uDD01.\uD802\uDD12\uD802\uDD05\uD802\uDD03")); 27 | jfc.setFileFilter(new FileNameExtensionFilter("Genesis Code Files", "\uD802\uDD01")); 28 | if( jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION ){ 29 | File selected = jfc.getSelectedFile(); 30 | System.out.println(selected + " chosen:"); 31 | 32 | StringBuilder input = new StringBuilder(); 33 | BufferedReader br = null; 34 | try { 35 | br = new BufferedReader(new FileReader(selected)); 36 | } catch (FileNotFoundException e) { 37 | e.printStackTrace(); 38 | } 39 | String line = null; 40 | while (true) { 41 | try { 42 | assert br != null; 43 | if ((line = br.readLine()) == null) break; 44 | } catch (IOException e) { 45 | e.printStackTrace(); 46 | } 47 | input.append(line); 48 | System.out.println(line); 49 | } 50 | Interpreter.sendCodeToInterpret(Collections.singletonList(input.toString())); 51 | } 52 | }; 53 | SwingUtilities.invokeLater(r); 54 | } 55 | 56 | public static void interpretCode() 57 | { 58 | Interpreter.sendCodeToInterpret(UIManager.codeEditorInstance.getTheCode()); 59 | } 60 | 61 | public static void cleanPreviousData() 62 | { 63 | Variable.globalVariables.clear(); 64 | Subroutine.functions.clear(); 65 | While.clearLoopsData(); 66 | For.clearLoopsData(); 67 | ForEach.clearLoopsData(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/Driver/Interpreter.java: -------------------------------------------------------------------------------- 1 | package Driver; 2 | 3 | import Commands.Subroutine; 4 | import Commands.Variable; 5 | import References.GenesisKeyWords; 6 | import UI.UIManager; 7 | import RoutineBlocks.RoutineBlock; 8 | import org.jetbrains.annotations.Contract; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class Interpreter 17 | { 18 | private static final String CODE_BLOCK_END_KEY_WORD = "\uD802\uDD12-\uD802\uDD03-\uD802\uDD14";//𐤒-𐤃-𐤔 19 | 20 | public static RoutineBlock runningRoutineBlock = null; 21 | 22 | private static List theCurrentCode; // All the code file that we what to interpret in lines 23 | private static final ArrayList cutedCodeLines = new ArrayList<>(); // "Black List" - code lines we need to ignore while running the code 24 | 25 | public static void sendCodeToInterpret(List code) 26 | { 27 | // Initializing 28 | runningRoutineBlock = null; 29 | cutedCodeLines.clear(); 30 | theCurrentCode = code; 31 | 32 | // Code handling 33 | scanForCodeBlocks(); 34 | 35 | for(int i = 0; i < theCurrentCode.size(); i++) 36 | { 37 | if(!cutedCodeLines.contains(i + 1)){ 38 | initiateLine(theCurrentCode.get(i), i + 1); 39 | } 40 | } 41 | 42 | // Logging 43 | UIManager.consoleInstance.printLogMessage("\n" + "\uD802\uDD0C\uD802\uDD14\uD802\uDD15\uD802\uDD0D\uD802\uDD09\uD802\uDD0C:" + "\n" + Arrays.toString(Variable.globalVariablesLog())); // For debugging only! 44 | UIManager.consoleInstance.printLogMessage("\n" + "\uD802\uDD10\uD802\uDD05\uD802\uDD0D\uD802\uDD12\uD802\uDD11\uD802\uDD09\uD802\uDD05\uD802\uDD15:" + "\n" + Subroutine.getFunctionsNames()); // For debugging only! 45 | GenesisMain.cleanPreviousData(); 46 | } 47 | 48 | public static @NotNull String replaceVariableNamesWithValues(@NotNull String line){ 49 | //get right assignment side (to the left of the = sign) 50 | if(line.indexOf("=") != -1){ //remember to add increment 51 | int idxOfEquals = line.indexOf("="); 52 | String rightSideOfLine = line.substring(idxOfEquals+1); 53 | String leftSideOfLine = line.substring(0, idxOfEquals); 54 | String[] tokens = rightSideOfLine.split("\\r?\\n|\s| |\\)|\\(|\\+|\\-|\\/|\\*|\\{|\\}"); 55 | int idx = 0; 56 | for (String token : tokens) { 57 | for (String varName : Variable.getVariablesNames()) { 58 | if (token.contains(varName)) { 59 | rightSideOfLine = rightSideOfLine.replaceAll(varName, Variable.getAVariableValue(varName) + ""); 60 | idx++; 61 | } 62 | } 63 | } 64 | //rightSideOfLine = reverseString(rightSideOfLine); 65 | if(idx == 0){ 66 | return line; 67 | } 68 | line = rightSideOfLine + " = " + leftSideOfLine; 69 | line = line.trim(); 70 | 71 | return line; 72 | } else{ 73 | return line; 74 | } 75 | } 76 | 77 | @Contract("_ -> new") 78 | public static @NotNull String reverseString(@NotNull String s) { 79 | char[] chars = new char[s.length()]; 80 | boolean twoCharCodepoint = false; 81 | for (int i = 0; i < s.length(); i++) { 82 | chars[s.length() - 1 - i] = s.charAt(i); 83 | if (twoCharCodepoint) { 84 | swap(chars, s.length() - 1 - i, s.length() - i); 85 | } 86 | twoCharCodepoint = !Character.isBmpCodePoint(s.codePointAt(i)); 87 | } 88 | return new String(chars); 89 | } 90 | 91 | private static void swap(char @NotNull [] array, int i, int j) { 92 | char temp = array[i]; 93 | array[i] = array[j]; 94 | array[j] = temp; 95 | } 96 | 97 | public static void initiateLine(@NotNull String line, int lineNumber) 98 | { 99 | if(line.isEmpty()) return; 100 | while(line.startsWith(" ") || line.startsWith("\t")) line = line.substring(1); // Removing whitespaces and tabs in the beginning of the line 101 | 102 | for(GenesisKeyWords keyWord: GenesisKeyWords.values()) // Commands 103 | { 104 | if(line.startsWith(keyWord.getGenesisCode() + " ")) 105 | { 106 | line = line.substring(keyWord.getGenesisCode().length() + 1); // Cutting the command part from the line and leaving only the parameters 107 | keyWord.getCommand().sendParameters(line, lineNumber, false); 108 | return; 109 | } 110 | } 111 | 112 | for(String varName: Variable.getVariablesNames()) // Variables 113 | { 114 | if(line.startsWith(varName)) 115 | { 116 | GenesisKeyWords.VARIABLE_POST.getCommand().sendParameters(line, lineNumber, false); 117 | return; 118 | } 119 | } 120 | 121 | for(String funcName: Subroutine.getFunctionsNames()) // Functions (calls) 122 | { 123 | if(line.startsWith(funcName)) 124 | { 125 | GenesisKeyWords.FUNCTION_CALL.getCommand().sendParameters(line, lineNumber, false); 126 | return; 127 | } 128 | } 129 | 130 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤒𐤅𐤃𐤄 𐤁𐤔𐤅𐤓𐤄: " + lineNumber, lineNumber); 131 | } 132 | 133 | private static void scanForCodeBlocks() 134 | { 135 | int lineNumber = 0; 136 | 137 | for(String line: theCurrentCode) 138 | { 139 | lineNumber++; 140 | 141 | if(line.startsWith(GenesisKeyWords.FUNCTION.getGenesisCode() + " ") && !cutedCodeLines.contains(lineNumber)) 142 | { 143 | line = line.substring(GenesisKeyWords.FUNCTION.getGenesisCode().length() + 1); // Cutting the command part from the line and leaving only the parameters 144 | GenesisKeyWords.FUNCTION.getCommand().sendParameters(line, lineNumber, true); 145 | } 146 | else if(line.startsWith(GenesisKeyWords.WHILE.getGenesisCode() + " ") && !cutedCodeLines.contains(lineNumber)) 147 | { 148 | line = line.substring(GenesisKeyWords.WHILE.getGenesisCode().length() + 1); // Cutting the command part from the line and leaving only the parameters 149 | GenesisKeyWords.WHILE.getCommand().sendParameters(line, lineNumber, true); 150 | } 151 | else if(line.startsWith(GenesisKeyWords.FOR.getGenesisCode() + " ") && !cutedCodeLines.contains(lineNumber)) 152 | { 153 | line = line.substring(GenesisKeyWords.FOR.getGenesisCode().length() + 1); // Cutting the command part from the line and leaving only the parameters 154 | GenesisKeyWords.FOR.getCommand().sendParameters(line, lineNumber, true); 155 | } 156 | else if(line.startsWith(GenesisKeyWords.FOR_EACH.getGenesisCode() + " ") && !cutedCodeLines.contains(lineNumber)) 157 | { 158 | line = line.substring(GenesisKeyWords.FOR_EACH.getGenesisCode().length() + 1); // Cutting the command part from the line and leaving only the parameters 159 | GenesisKeyWords.FOR_EACH.getCommand().sendParameters(line, lineNumber, true); 160 | } 161 | } 162 | } 163 | 164 | public static @Nullable 165 | RoutineBlock cutCodeBlock(int startLine, boolean cutTheNameLine) 166 | { 167 | // startLine and cutedCodeLines number are like the user see, start in 1, while theCurrentCode line numbers are starting from 0 168 | for(int i = startLine; i < theCurrentCode.size() + 1; i++) 169 | { 170 | if(theCurrentCode.get(i - 1).replaceAll("\\s","").equals(CODE_BLOCK_END_KEY_WORD)) 171 | { 172 | String[] block = new String[i - startLine]; 173 | int j = startLine; 174 | for(; j < i; j++) 175 | { 176 | block[j - startLine] = theCurrentCode.get(j - 1); 177 | cutedCodeLines.add(j); 178 | } 179 | 180 | if(cutTheNameLine) cutedCodeLines.add(startLine - 1); // The function name line 181 | cutedCodeLines.add(j); // The CODE_BLOCK_END_KEY_WORD line 182 | return new RoutineBlock(block, startLine); 183 | } 184 | } 185 | return null; 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: Driver.GenesisMain 3 | 4 | -------------------------------------------------------------------------------- /src/main/java/References/GenesisKeyWords.java: -------------------------------------------------------------------------------- 1 | package References; 2 | 3 | import Commands.*; 4 | 5 | public enum GenesisKeyWords 6 | { 7 | // Class instance, the command key word 8 | PRINT(new Print(), "𐤄𐤃𐤐𐤎"), 9 | PRINT_LINE(new PrintLine(), "𐤄𐤃𐤐𐤎𐤇"), 10 | VARIABLE(new Variable(), "𐤄𐤂𐤃𐤓"), 11 | VARIABLE_POST(new VariableUpdate(), "𐤀𐤕𐤇𐤅𐤋"), 12 | IF(new If(), "𐤀𐤌"), 13 | FUNCTION(new Subroutine(), "𐤐𐤅𐤍𐤒𐤑𐤉𐤄"), 14 | FUNCTION_CALL(new SubroutineCall(), "𐤄𐤐𐤏𐤋"), 15 | WHILE(new While(), "𐤁𐤏𐤅𐤃"), 16 | FOR(new For(), "𐤏𐤁𐤅𐤓"), 17 | FOR_EACH(new ForEach(), "𐤏𐤁𐤅𐤓𐤊𐤋"), 18 | SLEEP(new Sleep(), "𐤉𐤔𐤍"); 19 | 20 | private final ICommand command; 21 | private final String genesisCode; 22 | 23 | GenesisKeyWords(ICommand com, String code) 24 | { 25 | this.command = com; 26 | this.genesisCode = code; 27 | } 28 | 29 | public String getGenesisCode() 30 | { 31 | return this.genesisCode; 32 | } 33 | 34 | public ICommand getCommand() 35 | { 36 | return this.command; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/RoutineBlocks/RoutineBlock.java: -------------------------------------------------------------------------------- 1 | package RoutineBlocks; 2 | 3 | import Commands.Variable; 4 | import Driver.Interpreter; 5 | import References.GenesisKeyWords; 6 | import UI.UIManager; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | 12 | public class RoutineBlock 13 | { 14 | private final String[] code; 15 | private final int startLineNumber; 16 | 17 | private final ArrayList localVariables; // Stores the names of the local variables 18 | private HashMap variablesSnapshotForRecursion; 19 | private RoutineBlock blockSnapshotForRecursion; 20 | 21 | public RoutineBlock(String[] code, int startLineNumber) 22 | { 23 | this.code = code; 24 | this.startLineNumber = startLineNumber; 25 | localVariables = new ArrayList<>(); 26 | 27 | checkForInvalidCode(); 28 | } 29 | 30 | public void initiateCode() 31 | { 32 | boolean inRecursion = false; 33 | if(Interpreter.runningRoutineBlock != null) 34 | { 35 | createVariablesSnapshot(Interpreter.runningRoutineBlock.localVariables); // Save last code block variables 36 | cleanLocalVariables(Interpreter.runningRoutineBlock.localVariables); // Delete last code block variables from access 37 | blockSnapshotForRecursion = Interpreter.runningRoutineBlock; // Save last code block pointer 38 | inRecursion = true; 39 | } 40 | 41 | Interpreter.runningRoutineBlock = this; 42 | 43 | for(int i = 0; i < this.code.length; i++) 44 | { 45 | Interpreter.initiateLine(code[i], startLineNumber + i); 46 | } 47 | 48 | cleanLocalVariables(this.localVariables); // Deleting the local variable from the "globalVariables" hashMap 49 | localVariables.clear(); 50 | 51 | if(!inRecursion) Interpreter.runningRoutineBlock = null; 52 | else 53 | { 54 | loadVariablesSnapshot(); // Reload the saved variables of the last code block 55 | Interpreter.runningRoutineBlock = blockSnapshotForRecursion; // Reset the pointer to the code block 56 | } 57 | } 58 | 59 | public void reportLocalVariable(String varName) 60 | { 61 | localVariables.add(varName); 62 | } 63 | 64 | private void cleanLocalVariables(@NotNull ArrayList list) 65 | { 66 | for(String varName: list) 67 | { 68 | Variable.globalVariables.remove(varName); 69 | } 70 | } 71 | 72 | private void checkForInvalidCode() 73 | { 74 | for(int i = 0; i < this.code.length; i++) 75 | { 76 | if(this.code[i].startsWith(GenesisKeyWords.FUNCTION.getGenesisCode() + " ")) UIManager.consoleInstance.printErrorMessage("𐤀𐤎𐤅𐤓 𐤋𐤄𐤂𐤃𐤉𐤓 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤁𐤕𐤅𐤊 𐤐𐤅𐤍𐤒𐤑𐤉𐤄 - 𐤔𐤅𐤓𐤄: " + startLineNumber + i, startLineNumber + i); 77 | } 78 | } 79 | 80 | private void createVariablesSnapshot(@NotNull ArrayList localVariablesList) 81 | { 82 | variablesSnapshotForRecursion = new HashMap<>(); // Also reset previous values 83 | 84 | for(String varName: localVariablesList) 85 | { 86 | variablesSnapshotForRecursion.put(varName, Variable.globalVariables.get(varName)); 87 | } 88 | } 89 | 90 | private void loadVariablesSnapshot() 91 | { 92 | for(String varName: variablesSnapshotForRecursion.keySet()) 93 | { 94 | Variable.globalVariables.put(varName, variablesSnapshotForRecursion.get(varName)); 95 | } 96 | } 97 | 98 | public String[] getCode() 99 | { 100 | return code; 101 | } 102 | 103 | public int getStartLineNumber() 104 | { 105 | return startLineNumber; 106 | } 107 | 108 | public RoutineBlock duplicate() 109 | { 110 | return new RoutineBlock(this.code, this.startLineNumber); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/UI/CODE2001.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elonlit/Genesis/c74ed393e7d71475f727d230121c206e6c1c3836/src/main/java/UI/CODE2001.TTF -------------------------------------------------------------------------------- /src/main/java/UI/CodeEditor.java: -------------------------------------------------------------------------------- 1 | package UI; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import javax.swing.*; 7 | import javax.swing.filechooser.FileNameExtensionFilter; 8 | import java.awt.*; 9 | import java.io.*; 10 | import java.nio.charset.StandardCharsets; 11 | import java.util.List; 12 | import java.util.*; 13 | 14 | import static Utilities.GematriaSolver.parseGematria; 15 | import static Utilities.VariableSolver.getVariables; 16 | 17 | public class CodeEditor extends UITextArea 18 | { 19 | private File codeFile; 20 | 21 | public boolean displayingError = false; 22 | public static HashSet surrogateInterimVariables = new HashSet<>(); 23 | public static HashMap singleCodePointVariables = new HashMap<>(); 24 | 25 | public static final HashMap gematriaMap = new HashMap<>() {{ 26 | put("״", 0); 27 | put("״״", 0); 28 | put("𐤀", 1); 29 | put("𐤁", 2); 30 | put("𐤂", 3); 31 | put("𐤃", 4); 32 | put("𐤄", 5); 33 | put("𐤅", 6); 34 | put("𐤆", 7); 35 | put("𐤇", 8); 36 | put("𐤈", 9); 37 | put("𐤉", 10); 38 | put("𐤊", 20); 39 | put("𐤋", 30); 40 | put("𐤌", 40); 41 | put("𐤍", 50); 42 | put("𐤎", 60); 43 | put("𐤏", 70); 44 | put("𐤐", 80); 45 | put("𐤑", 90); 46 | put("𐤒", 100); 47 | put("𐤓", 200); 48 | put("𐤔", 300); 49 | put("𐤕", 400); 50 | }}; 51 | 52 | public void loadCodeFile(File file) 53 | { 54 | if(file == null) return; 55 | clearTheTextArea(); 56 | codeFile = file; 57 | 58 | List codeList = readFile(codeFile); 59 | assert codeList != null; 60 | for(String line: codeList) 61 | { 62 | appendToPane(line + "\n", Color.BLACK); 63 | } 64 | } 65 | 66 | public List getTheCode(@NotNull String input) throws FileNotFoundException { 67 | String[] lines = parseGematria(input 68 | .replaceAll("\uD802\uDD13\uD802\uDD0D\uD802\uDD03()", Math.random() + "") //𐤓𐤍𐤃 (random) 69 | .replaceAll("\uD802\uDD10\uD802\uDD09\uD802\uDD09()", Math.PI + "") //𐤐𐤉𐤉 (pi) 70 | .replaceAll("\\(\\)", "") 71 | .replaceAll("\uD802\uDD00\uD802\uDD06", "\uD802\uDD00")) //doesn't parse as two surrogate code points 72 | .split("\\r?\\n"); // Split by new lines 73 | getVariables(lines); 74 | return Arrays.asList(lines); 75 | } 76 | 77 | public String getBibleQuote() throws FileNotFoundException { 78 | File f = new File("BibleQuotes.txt"); 79 | String result = null; 80 | Random rand = new Random(); 81 | int n = 0; 82 | for(Scanner sc = new Scanner(f); sc.hasNext(); ) 83 | { 84 | ++n; 85 | String line = sc.nextLine(); 86 | if(rand.nextInt(n) == 0) 87 | result = line; 88 | } 89 | return result; 90 | } 91 | 92 | public List getTheCode() 93 | { 94 | String[] lines = parseGematria(textPane.getText() 95 | .replaceAll("\uD802\uDD13\uD802\uDD0D\uD802\uDD03()", Math.random() + "") //𐤓𐤍𐤃 (random) 96 | .replaceAll("\uD802\uDD10\uD802\uDD09\uD802\uDD09()", Math.PI + "") //𐤐𐤉𐤉 (pi) 97 | .replaceAll("\\(\\)", "") 98 | .replaceAll("\uD802\uDD00\uD802\uDD06", "\uD802\uDD00")) //doesn't parse as two surrogate code points 99 | .split("\\r?\\n"); // Split by new lines 100 | getVariables(lines); 101 | return Arrays.asList(lines); 102 | } 103 | 104 | public List getNothing() 105 | { 106 | String[] lines = "".split("\\r?\\n"); // Split by new lines 107 | return Arrays.asList(lines); 108 | } 109 | 110 | public String getTheText() 111 | { 112 | return textPane.getText(); 113 | } 114 | 115 | private @Nullable List readFile(File file) 116 | { 117 | List records = new ArrayList<>(); 118 | try 119 | { 120 | FileInputStream inputStream = new FileInputStream(file); // Open a file reader object 121 | InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_16); // Wrap the file reader with InputStreamReader with UTF16 encoding 122 | BufferedReader reader = new BufferedReader(inputStreamReader); // Wrap it with buffered reader 123 | 124 | String line; 125 | while ((line = reader.readLine()) != null) 126 | { 127 | records.add(line); 128 | } 129 | reader.close(); 130 | return records; 131 | } 132 | catch (Exception e) 133 | { 134 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤌𐤄𐤋𐤊 𐤄𐤍𐤉𐤎𐤉𐤅𐤍 𐤋𐤒𐤓𐤅𐤀 𐤀𐤕 𐤄𐤒𐤅𐤁𐤑 𐤒𐤅𐤃!"); 135 | e.printStackTrace(); 136 | return null; 137 | } 138 | } 139 | 140 | public void saveFile() 141 | { 142 | if(codeFile != null) 143 | { 144 | writeToFile(codeFile); 145 | } 146 | else 147 | { 148 | saveFileAs(); 149 | } 150 | } 151 | 152 | public void saveFileAs() 153 | { 154 | JFileChooser fileChooser = new JFileChooser(); 155 | fileChooser.setFileFilter(new FileNameExtensionFilter("Genesis Code Files", "𐤁")); // Setting file type filter 156 | fileChooser.setSelectedFile(new File("\uD802\uDD12\uD802\uDD05\uD802\uDD03.𐤁")); // Setting suggested file name 157 | fileChooser.setCurrentDirectory(fileChooser.getCurrentDirectory()); 158 | 159 | if(fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) 160 | { 161 | File file; 162 | if(!fileChooser.getSelectedFile().getName().endsWith("𐤁.")) file = new File(fileChooser.getSelectedFile() + "𐤁."); 163 | else file = fileChooser.getSelectedFile(); 164 | 165 | writeToFile(file); 166 | codeFile = file; 167 | } 168 | } 169 | 170 | private void writeToFile(File file) 171 | { 172 | try 173 | { 174 | FileOutputStream outputStream = new FileOutputStream(file); // Open a file writer object 175 | OutputStreamWriter streamWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_16); // Wrap the file writer with OutputStreamWriter with UTF16 encoding 176 | BufferedWriter writer = new BufferedWriter(streamWriter); // Wrap it with buffered writer 177 | 178 | for(String line: getTheCode()) 179 | { 180 | writer.write(line); 181 | writer.newLine(); 182 | } 183 | writer.close(); 184 | } 185 | catch(IOException e) 186 | { 187 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤌𐤄𐤋𐤊 𐤄𐤍𐤉𐤎𐤉𐤅𐤍 𐤋𐤔𐤌𐤅𐤓 𐤀𐤕 𐤄𐤒𐤅𐤁𐤑 𐤒𐤅𐤃"); 188 | e.printStackTrace(); 189 | } 190 | } 191 | 192 | public void rewriteCodeTextWithErrorHighlight(int line) 193 | { 194 | List oldCode = getNothing(); 195 | clearTheTextArea(); 196 | 197 | String str; 198 | for(int i = 0; i < oldCode.size(); i++) 199 | { 200 | str = oldCode.get(i); 201 | 202 | if(i == line - 1) appendToPane(str + "\n", Color.RED); 203 | else appendToPane(str + "\n", Color.BLACK); 204 | } 205 | displayingError = true; 206 | } 207 | 208 | public void rewriteCleanCodeText() 209 | { 210 | displayingError = false; 211 | List oldCode = getTheCode(); 212 | int caretPosition = textPane.getCaretPosition(); 213 | 214 | clearTheTextArea(); 215 | 216 | for(String str: oldCode) 217 | { 218 | appendToPane(str + "\n", Color.BLACK); 219 | } 220 | textPane.setCaretPosition(caretPosition); 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /src/main/java/UI/CodeFilter.java: -------------------------------------------------------------------------------- 1 | package UI; 2 | 3 | import javax.swing.text.AttributeSet; 4 | import javax.swing.text.BadLocationException; 5 | import javax.swing.text.DocumentFilter; 6 | 7 | public class CodeFilter extends DocumentFilter 8 | { 9 | @Override 10 | public void remove(FilterBypass fb, int offset, int length) throws BadLocationException 11 | { 12 | if (UIManager.codeEditorInstance.displayingError) 13 | { 14 | codeChanged(); 15 | } 16 | 17 | super.remove(fb, offset, length); 18 | } 19 | 20 | @Override 21 | public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException 22 | { 23 | if (UIManager.codeEditorInstance.displayingError) 24 | { 25 | codeChanged(); 26 | } 27 | 28 | super.replace(fb, offset, length, text, UIManager.codeEditorInstance.getDefaultAttributeSet()); 29 | } 30 | 31 | private void codeChanged() 32 | { 33 | UIManager.codeEditorInstance.rewriteCleanCodeText(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/UI/Console.java: -------------------------------------------------------------------------------- 1 | package UI; 2 | 3 | import Driver.GenesisMain; 4 | 5 | import java.awt.*; 6 | 7 | public class Console extends UITextArea 8 | { 9 | public void print(String str) 10 | { 11 | appendToPane(str, Color.BLACK); 12 | } 13 | 14 | public void println(String str) 15 | { 16 | appendToPane(str + "\n", Color.BLACK); 17 | } 18 | 19 | public void println() 20 | { 21 | appendToPane("\n", Color.BLACK); 22 | } 23 | 24 | public void printErrorMessage(String error, int line) throws RuntimeException 25 | { 26 | appendToPane(error + "\n", Color.RED); 27 | 28 | UIManager.codeEditorInstance.rewriteCodeTextWithErrorHighlight(line); 29 | 30 | GenesisMain.cleanPreviousData(); 31 | throw new RuntimeException(); 32 | } 33 | 34 | public void printErrorMessage(String error) throws RuntimeException 35 | { 36 | appendToPane(error + "\n", Color.RED); 37 | 38 | GenesisMain.cleanPreviousData(); 39 | throw new RuntimeException(); 40 | } 41 | 42 | public void printLogMessage(String message) throws RuntimeException 43 | { 44 | appendToPane(message + "\n", Color.BLUE); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/UI/ProgramFrame.java: -------------------------------------------------------------------------------- 1 | package UI; 2 | 3 | import Driver.GenesisMain; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import javax.swing.*; 7 | import javax.swing.filechooser.FileNameExtensionFilter; 8 | import javax.swing.text.AbstractDocument; 9 | import javax.swing.undo.CannotRedoException; 10 | import javax.swing.undo.CannotUndoException; 11 | import javax.swing.undo.UndoManager; 12 | import java.awt.*; 13 | import java.awt.datatransfer.DataFlavor; 14 | import java.awt.dnd.DnDConstants; 15 | import java.awt.dnd.DropTarget; 16 | import java.awt.dnd.DropTargetDropEvent; 17 | import java.awt.event.ActionEvent; 18 | import java.io.File; 19 | import java.io.IOException; 20 | import java.util.Arrays; 21 | 22 | public class ProgramFrame extends JFrame 23 | { 24 | private static final JButton buttonStart = new JButton("\uD802\uDD04\uD802\uDD13\uD802\uDD11 \uD802\uDD12\uD802\uDD05\uD802\uDD03"); 25 | private static final JButton buttonClear = new JButton("\uD802\uDD0D\uD802\uDD12\uD802\uDD04 \uD802\uDD10\uD802\uDD0B\uD802\uDD08"); 26 | private static final JButton buttonLoad = new JButton("\uD802\uDD01\uD802\uDD07\uD802\uDD13 \uD802\uDD12\uD802\uDD05\uD802\uDD01\uD802\uDD11"); 27 | private static final JButton buttonSave = new JButton("\uD802\uDD14\uD802\uDD0C\uD802\uDD05\uD802\uDD13"); 28 | private static final JButton buttonSaveAs = new JButton("\uD802\uDD14\uD802\uDD0C\uD802\uDD05\uD802\uDD13 \uD802\uDD01\uD802\uDD14\uD802\uDD0C"); 29 | 30 | private static final JLabel codeHead = new JLabel("\uD802\uDD12\uD802\uDD05\uD802\uDD03"); 31 | private static final JLabel consoleHead = new JLabel("\uD802\uDD10\uD802\uDD0B\uD802\uDD08"); 32 | 33 | private final UndoManager undo = new UndoManager(); //instantiate an UndoManager 34 | 35 | public ProgramFrame() throws IOException, FontFormatException { 36 | super("Genesis Interpreter"); 37 | 38 | buttonStart.setBorderPainted(true); 39 | buttonStart.setFocusPainted(true); 40 | buttonStart.setContentAreaFilled(false); 41 | 42 | buttonClear.setBorderPainted(true); 43 | buttonClear.setFocusPainted(true); 44 | buttonClear.setContentAreaFilled(false); 45 | 46 | buttonLoad.setBorderPainted(true); 47 | buttonLoad.setFocusPainted(true); 48 | buttonLoad.setContentAreaFilled(false); 49 | 50 | buttonSave.setBorderPainted(true); 51 | buttonSave.setFocusPainted(true); 52 | buttonSave.setContentAreaFilled(false); 53 | 54 | buttonSaveAs.setBorderPainted(true); 55 | buttonSaveAs.setFocusPainted(true); 56 | buttonSaveAs.setContentAreaFilled(false); 57 | 58 | // Setting the text areas 59 | JTextPane consoleArea = new JTextPane(); 60 | consoleArea.setEditable(false); 61 | consoleArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 62 | UIManager.consoleInstance.setTextArea(consoleArea); 63 | 64 | JTextPane codeArea = new JTextPane(); 65 | codeArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 66 | UIManager.codeEditorInstance.setTextArea(codeArea); 67 | 68 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 69 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("./src/main/java/UI/CODE2001.TTF"))); 70 | 71 | // Setting the fonts - font, font style, font size 72 | Font font = new Font("Code2001", Font.PLAIN, 14); 73 | 74 | codeHead.setFont(font); 75 | consoleHead.setFont(font); 76 | buttonStart.setFont(font); 77 | buttonClear.setFont(font); 78 | buttonLoad.setFont(font); 79 | buttonSave.setFont(font); 80 | buttonSaveAs.setFont(font); 81 | consoleArea.setFont(font); 82 | codeArea.setFont(font); 83 | 84 | // Setting the code editor document filter 85 | AbstractDocument document = (AbstractDocument) codeArea.getDocument(); 86 | document.setDocumentFilter(new CodeFilter()); 87 | 88 | // Creates the GUI 89 | setLayout(new GridBagLayout()); 90 | GridBagConstraints constraints = new GridBagConstraints(); 91 | constraints.gridx = 0; 92 | constraints.gridy = 0; 93 | constraints.insets = new Insets(10, 10, 10, 10); 94 | constraints.anchor = GridBagConstraints.WEST; 95 | 96 | // Buttons 97 | add(buttonStart, constraints); 98 | 99 | constraints.gridx = 1; 100 | add(buttonClear, constraints); 101 | 102 | constraints.gridx = 2; 103 | add(buttonLoad, constraints); 104 | 105 | constraints.gridx = 0; 106 | constraints.gridy = 1; 107 | add(buttonSave, constraints); 108 | 109 | constraints.gridx = 1; 110 | constraints.gridy = 1; 111 | add(buttonSaveAs, constraints); 112 | 113 | // Text Areas position and placing 114 | constraints.gridx = 2; 115 | constraints.gridy = 2; 116 | add(codeHead, constraints); 117 | 118 | constraints.gridx = 2; 119 | constraints.gridy = 3; 120 | add(consoleHead, constraints); 121 | 122 | // Scrolls 123 | JScrollPane scrollPane = new JScrollPane(codeArea); 124 | scrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 125 | constraints.gridx = 0; 126 | constraints.gridy = 2; 127 | constraints.gridwidth = 2; 128 | constraints.fill = GridBagConstraints.BOTH; 129 | constraints.weightx = 1; 130 | constraints.weighty = 1; 131 | add(scrollPane, constraints); 132 | 133 | scrollPane = new JScrollPane(consoleArea); 134 | scrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 135 | constraints.gridy = 3; 136 | add(scrollPane, constraints); 137 | 138 | // Adds event handler for the Start button 139 | buttonStart.addActionListener(evt -> { 140 | UIManager.consoleInstance.clearTheTextArea(); 141 | System.out.print("\033[H\033[2J"); 142 | System.out.flush(); 143 | GenesisMain.interpretCode(); 144 | }); 145 | 146 | // Adds event handler for the Clear button 147 | buttonClear.addActionListener(evt -> UIManager.consoleInstance.clearTheTextArea()); 148 | 149 | // Adds event handler for the Load button 150 | buttonLoad.addActionListener(evt -> UIManager.codeEditorInstance.loadCodeFile(openFile())); 151 | 152 | // Adds event handler for the Save button 153 | buttonSave.addActionListener(evt -> UIManager.codeEditorInstance.saveFile()); 154 | 155 | // Adds event handler for the Save-As button 156 | buttonSaveAs.addActionListener(evt -> UIManager.codeEditorInstance.saveFileAs()); 157 | 158 | // Adds handler for drag-and-drop event, for dropping code files on the code editor 159 | codeArea.setDropTarget(new DropTarget() { 160 | @Override 161 | public synchronized void drop(DropTargetDropEvent event) 162 | { 163 | try 164 | { 165 | event.acceptDrop(DnDConstants.ACTION_COPY); 166 | java.util.List droppedFiles = (java.util.List) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); 167 | if(droppedFiles.size() == 1) 168 | { 169 | if(droppedFiles.get(0).getName().endsWith("𐤁.")) UIManager.codeEditorInstance.loadCodeFile(droppedFiles.get(0)); 170 | else UIManager.consoleInstance.printErrorMessage("𐤆𐤄𐤅 𐤋𐤀 𐤒𐤅𐤁𐤑 𐤒𐤅𐤃 𐤁. !"); 171 | } 172 | } 173 | catch (Exception ex) 174 | { 175 | ex.printStackTrace(); 176 | } 177 | } 178 | }); 179 | 180 | // Undo & Redo Handling 181 | codeArea.getDocument().addUndoableEditListener(evt -> undo.addEdit(evt.getEdit())); 182 | // Undo Handling 183 | codeArea.getActionMap().put("Undo", new AbstractAction("Undo") { 184 | @Override 185 | public void actionPerformed(ActionEvent event) { 186 | try 187 | { 188 | if (undo.canUndo()) 189 | { 190 | undo.undo(); 191 | } 192 | } 193 | catch (CannotUndoException e) 194 | { 195 | UIManager.consoleInstance.printErrorMessage("𐤋𐤀 𐤌𐤑𐤋𐤉𐤇 𐤋𐤁𐤈𐤋 𐤌𐤄𐤋𐤊 𐤀𐤇𐤓𐤅𐤍!"); 196 | } 197 | } 198 | }); 199 | codeArea.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo"); 200 | // Redo Handling 201 | codeArea.getActionMap().put("Redo", new AbstractAction("Redo") { 202 | @Override 203 | public void actionPerformed(ActionEvent event) { 204 | try 205 | { 206 | if (undo.canRedo()) 207 | { 208 | undo.redo(); 209 | } 210 | } 211 | catch (CannotRedoException e) 212 | { 213 | UIManager.consoleInstance.printErrorMessage("𐤋𐤀 𐤌𐤑𐤋𐤉𐤇 𐤋𐤔𐤇𐤆𐤓 𐤌𐤄𐤋𐤊 𐤀𐤇𐤓𐤅𐤍!"); 214 | } 215 | } 216 | }); 217 | codeArea.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo"); 218 | 219 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 220 | setSize(900, 700); // Set the default window size 221 | setLocationRelativeTo(null); // Centers on screen 222 | } 223 | 224 | private static @Nullable File openFile() 225 | { 226 | JFileChooser fileChooser = new JFileChooser(); 227 | fileChooser.setFileFilter(new FileNameExtensionFilter("Genesis Code Files", "𐤁")); // Setting file type filter 228 | fileChooser.setCurrentDirectory(new File(System.getProperty("user.dir"))); 229 | 230 | if(fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) 231 | { 232 | if(fileChooser.getSelectedFile().getName().endsWith(".𐤁")) return fileChooser.getSelectedFile(); 233 | else UIManager.consoleInstance.printErrorMessage("𐤆𐤄𐤅 𐤋𐤀 𐤒𐤅𐤁𐤑 𐤒𐤅𐤃 𐤁. !"); 234 | } 235 | 236 | return null; 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /src/main/java/UI/UIManager.java: -------------------------------------------------------------------------------- 1 | package UI; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | import java.io.IOException; 6 | 7 | public class UIManager 8 | { 9 | public static Console consoleInstance = new Console(); 10 | public static CodeEditor codeEditorInstance = new CodeEditor(); 11 | 12 | public static void openUI() 13 | { 14 | SwingUtilities.invokeLater(() -> { 15 | try { 16 | JFrame.setDefaultLookAndFeelDecorated(true); 17 | JDialog.setDefaultLookAndFeelDecorated(true); 18 | new ProgramFrame().setVisible(true); 19 | } catch (IOException | FontFormatException e) { 20 | e.printStackTrace(); 21 | } 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/UI/UITextArea.java: -------------------------------------------------------------------------------- 1 | package UI; 2 | 3 | import Driver.GenesisMain; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import javax.swing.*; 7 | import javax.swing.text.*; 8 | import java.awt.*; 9 | 10 | public class UITextArea 11 | { 12 | protected JTextPane textPane; 13 | protected Style style; 14 | protected StyledDocument doc; 15 | private AttributeSet defaultAttributeSet; 16 | 17 | public void setTextArea(JTextPane textArea) 18 | { 19 | textPane = textArea; 20 | style = textPane.addStyle("StyleGenesis", null); 21 | doc = textPane.getStyledDocument(); 22 | defaultAttributeSet = textPane.getCharacterAttributes(); 23 | } 24 | 25 | public void clearTheTextArea() 26 | { 27 | GenesisMain.cleanPreviousData(); 28 | 29 | try 30 | { 31 | textPane.getDocument().remove(0, textPane.getDocument().getLength()); 32 | } 33 | catch (BadLocationException ex) 34 | { 35 | ex.printStackTrace(); 36 | } 37 | } 38 | 39 | protected void appendToPane(String msg, Color c) 40 | { 41 | StyleConstants.setForeground(style, c); 42 | 43 | try 44 | { 45 | doc.insertString(doc.getLength(), msg, style); 46 | textPane.update(textPane.getGraphics()); 47 | } 48 | catch (BadLocationException e) 49 | { 50 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤁𐤌𐤄𐤋𐤊 𐤄𐤍𐤉𐤎𐤉𐤅𐤍 𐤋𐤄𐤃𐤐𐤉𐤎 𐤋𐤌𐤎𐤊!"); 51 | } 52 | } 53 | 54 | public AttributeSet getDefaultAttributeSet() 55 | { 56 | return defaultAttributeSet; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/Utilities/BooleanExpressionSolver.java: -------------------------------------------------------------------------------- 1 | package Utilities; 2 | 3 | import Commands.Variable; 4 | import UI.UIManager; 5 | 6 | public class BooleanExpressionSolver extends ExpressionSolver 7 | { 8 | private boolean tempValueHolder; 9 | public long LB = Long.parseLong("5529856576");//decimal for surrogate aleph 10 | public long UB = Long.parseLong("5529856597");//decimal for surrogate tau 11 | 12 | public BooleanExpressionSolver(String str, int lineNumber) 13 | { 14 | super(str, lineNumber); 15 | } 16 | 17 | @Override 18 | public Object getResult() 19 | { 20 | nextChar(); 21 | return parseExpression_Boolean(); 22 | } 23 | 24 | // The Grammar: 25 | // Expression = term || expression `&&` term || expression `||` term 26 | // Term = factor || term `==` factor || term `<` factor .... 27 | // Factor = (` expression `)` || number || string || boolean || globalVariables || true\false 28 | 29 | private boolean parseExpression_Boolean() 30 | { 31 | boolean x = parseTerm_Boolean(); 32 | while(true) 33 | { 34 | if(dealWithDoubleChar('|', '|')) // Or 35 | { 36 | boolean a = parseTerm_Boolean(); // If the first side is true he will not check the second and it will trow an error because not all the string was considered 37 | x = x || a; 38 | } 39 | else if(dealWithDoubleChar('&', '&')) // And 40 | { 41 | boolean a = parseTerm_Boolean(); // If the first side is false he will not check the second and it will trow an error because not all the string was considered 42 | x = x && a; 43 | } 44 | else return x; 45 | } 46 | } 47 | 48 | private boolean parseTerm_Boolean() 49 | { 50 | if(parseBooleanFactor()) return tempValueHolder; // Check for boolean globalVariables, word and parentheses 51 | if(parseStringComparison()) return tempValueHolder; // Check for string == string or != 52 | 53 | double x = parseExpression_Numbers(); 54 | if(dealWithDoubleChar('=', '=')) return x == parseExpression_Numbers(); // Equal 55 | else if(dealWithDoubleChar('!', '=')) return x != parseExpression_Numbers(); // Not-Equal 56 | else if(dealWithDoubleChar('<', '=')) return x <= parseExpression_Numbers(); // Smaller or equal 57 | else if(dealWithDoubleChar('>', '=')) return x >= parseExpression_Numbers(); // Bigger or equal 58 | else if(dealWithChar('<')) return x < parseExpression_Numbers(); // Smaller 59 | else if(dealWithChar('>')) return x > parseExpression_Numbers(); // Bigger 60 | else UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤒𐤅𐤃𐤄, 𐤄𐤔𐤅𐤅𐤀𐤄 𐤋𐤀 𐤇𐤅𐤒𐤉𐤕" + (char) currentChar + " - 𐤁𐤔𐤅𐤓𐤄 " + lineNumber, lineNumber); 61 | return false; 62 | } 63 | 64 | private boolean parseBooleanFactor() // Return true if parsing succeed - the parsing itself is stored in the tempValueHolder 65 | { 66 | int startPos = this.currentPosition; 67 | if(dealWithChar('(')) // Parentheses 68 | { 69 | tempValueHolder = parseExpression_Boolean(); 70 | dealWithChar(')'); 71 | } 72 | else if((currentChar >= LB && currentChar <= UB)) // Words and Variables. Note: decimal values represent letters. 73 | { 74 | while ((currentChar >= LB && currentChar <= UB) || (currentChar >= '0' && currentChar <= '9')) nextChar(); 75 | String word; 76 | if(str.contains("𐤀𐤌𐤕") || str.contains("𐤔𐤒𐤓")){ 77 | word = str.substring(startPos, this.currentPosition+5); 78 | } else{ 79 | word = str.substring(startPos, this.currentPosition+8); 80 | for(int i=0; i<8; i++){ //originally 8 81 | nextChar(); 82 | } 83 | } 84 | 85 | for(String varName: Variable.getVariablesNames()) // Variables 86 | { 87 | if(word.equals(varName)) 88 | { 89 | if(Variable.getAVariableValue(word) instanceof Double || Variable.getAVariableValue(word) instanceof String) 90 | { 91 | currentPosition = startPos; 92 | currentChar = str.charAt(currentPosition); 93 | return false; 94 | } 95 | else if(Variable.getAVariableValue(word) instanceof Object[]) // Array variable 96 | { 97 | Object[] theArray = (Object[]) Variable.getAVariableValue(word); 98 | if(dealWithChar('[')) // Parentheses 99 | { 100 | int index = (int) parseExpression_Numbers(); 101 | if(index > theArray.length - 1 || index < 0) UIManager.consoleInstance.printErrorMessage("𐤌𐤏𐤓𐤊 𐤇𐤓𐤂 𐤌𐤄𐤕𐤇𐤅𐤌" + " - 𐤁𐤔𐤅𐤓𐤄 " + lineNumber, lineNumber); 102 | dealWithChar(']'); 103 | if(theArray[index] instanceof Boolean) 104 | { 105 | tempValueHolder = (boolean) theArray[index]; 106 | return true; 107 | } 108 | else 109 | { 110 | currentPosition = startPos; 111 | currentChar = str.charAt(currentPosition); 112 | return false; 113 | } 114 | } 115 | } 116 | 117 | tempValueHolder = (boolean) Variable.getAVariableValue(word); 118 | return true; 119 | } 120 | } 121 | 122 | // Words 123 | if (word.equals("𐤀𐤌𐤕")) tempValueHolder = true; 124 | else if (word.equals("𐤔𐤒𐤓")) tempValueHolder = false; 125 | else 126 | { 127 | currentPosition = startPos; 128 | currentChar = str.charAt(currentPosition); 129 | return false; 130 | } 131 | } 132 | else 133 | { 134 | currentPosition = startPos; 135 | currentChar = str.charAt(currentPosition); 136 | return false; 137 | } 138 | 139 | return true; 140 | } 141 | 142 | private boolean parseStringComparison() // Return true if parsing succeed - the parsing itself is stored in the tempValueHolder 143 | { 144 | int startPos = this.currentPosition; 145 | boolean comparisonType; // false == , true =! 146 | 147 | String a = getAStringForComparison(this.currentPosition); 148 | if(!tempValueHolder) return false; 149 | 150 | if(dealWithDoubleChar('=', '=')) comparisonType = false; 151 | else if(dealWithDoubleChar('!', '=')) comparisonType = true; 152 | else 153 | { 154 | currentPosition = startPos; 155 | currentChar = str.charAt(currentPosition); 156 | return false; 157 | } 158 | 159 | String b = getAStringForComparison(this.currentPosition); 160 | if(!tempValueHolder) return false; 161 | 162 | if(!comparisonType) tempValueHolder = a.equals(b); 163 | else tempValueHolder = !a.equals(b); 164 | return true; 165 | } 166 | 167 | private String getAStringForComparison(int startPos) // tempValueHolder store here succeed or failure 168 | { 169 | if(dealWithChar('"')) // Quote 170 | { 171 | while (currentChar != '"') nextChar(); 172 | tempValueHolder = true; 173 | nextChar(); 174 | return str.substring(startPos + 1, this.currentPosition - 1); 175 | } 176 | else if((currentChar >= LB && currentChar <= UB)) // Variables 177 | { 178 | while ((currentChar >= LB && currentChar <= UB) || (currentChar >= '0' && currentChar <= '9')) nextChar(); 179 | String word = str.substring(startPos, this.currentPosition); 180 | 181 | for(String varName: Variable.getVariablesNames()) 182 | { 183 | if(word.equals(varName)) 184 | { 185 | if(Variable.getAVariableValue(word) instanceof Double || Variable.getAVariableValue(word) instanceof Boolean || Variable.getAVariableValue(word) instanceof Object[]) 186 | { 187 | currentPosition = startPos; 188 | currentChar = str.charAt(currentPosition); 189 | tempValueHolder = false; 190 | return ""; 191 | } 192 | 193 | tempValueHolder = true; 194 | return (String) Variable.getAVariableValue(word); 195 | } 196 | } 197 | } 198 | 199 | return ""; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/main/java/Utilities/ExpressionSolver.java: -------------------------------------------------------------------------------- 1 | package Utilities; 2 | 3 | import Commands.Variable; 4 | import UI.UIManager; 5 | 6 | public abstract class ExpressionSolver 7 | { 8 | protected int currentPosition = -1, lineNumber; 9 | protected long currentChar; 10 | protected String str; 11 | protected boolean errorFlag = false; 12 | public final long LB = Long.parseLong("5529856576");//decimal for aleph 13 | public final long UB = Long.parseLong("5529856597");//decimal for tau 14 | 15 | protected ExpressionSolver(String str, int lineNumber) 16 | { 17 | this.lineNumber = lineNumber; 18 | this.str = str; 19 | } 20 | 21 | public abstract Object getResult(); 22 | 23 | protected void nextChar() 24 | { 25 | if(++currentPosition < str.length()) 26 | { 27 | if((int)str.charAt(currentPosition) >= 55298 && (int)str.charAt(currentPosition+1) >= 55298){ 28 | currentChar = Long.parseLong((int)str.charAt(currentPosition) + "" + (int)str.charAt(currentPosition+1)); 29 | } 30 | else if((int)str.charAt(currentPosition) >= 55298) //check if char is valid surrogate code point 31 | { 32 | ; 33 | } 34 | else 35 | { 36 | currentChar = str.charAt(currentPosition); 37 | } 38 | } 39 | else 40 | { 41 | currentChar = -1; 42 | } 43 | } 44 | 45 | protected boolean dealWithChar(int charToEat) 46 | { 47 | if(currentChar == charToEat) 48 | { 49 | nextChar(); 50 | return true; 51 | } 52 | return false; 53 | } 54 | 55 | protected boolean dealWithDoubleChar(int charToEat1, int charToEat2) 56 | { 57 | if(this.currentChar == charToEat1) 58 | { 59 | if(this.str.charAt(this.currentPosition + 1) == charToEat2) 60 | { 61 | nextChar(); 62 | nextChar(); 63 | return true; 64 | } 65 | } 66 | return false; 67 | } 68 | 69 | // The Grammar: 70 | // Expression = term || expression `+` term || expression `-` term 71 | // Term = factor || term `*` factor || term `/` factor 72 | // Factor = `+` factor || `-` factor || `(` expression `)` || number || functionName factor || factor `^` factor 73 | 74 | protected double parseExpression_Numbers() 75 | { 76 | double x = parseTerm_Numbers(); 77 | while(true) 78 | { 79 | if(dealWithChar('+')) x += parseTerm_Numbers(); // Addition 80 | else if(dealWithChar('-')) x -= parseTerm_Numbers(); // Subtraction 81 | else return x; 82 | } 83 | } 84 | 85 | private double parseTerm_Numbers() 86 | { 87 | double x = parseFactor_Numbers(); 88 | while(true) 89 | { 90 | if(dealWithChar('*')) x *= parseFactor_Numbers(); // Multiplication 91 | else if(dealWithChar('/')) x /= parseFactor_Numbers(); // Division 92 | else return x; 93 | } 94 | } 95 | 96 | private double parseFactor_Numbers() 97 | { 98 | if(dealWithChar('+')) return parseFactor_Numbers(); // Unary plus 99 | if(dealWithChar('-')) return -parseFactor_Numbers(); // Unary minus 100 | 101 | double x = 0; 102 | int startPos = this.currentPosition; 103 | if(dealWithChar('(')) // Parentheses 104 | { 105 | x = parseExpression_Numbers(); 106 | dealWithChar(')'); 107 | } 108 | else if((currentChar >= '0' && currentChar <= '9') || currentChar == '.') // Numbers 109 | { 110 | while ((currentChar >= '0' && currentChar <= '9') || currentChar == '.') nextChar(); 111 | x = Double.parseDouble(str.substring(startPos, this.currentPosition)); 112 | } 113 | else if((currentChar >= 'א' && currentChar <= 'ת') || (currentChar >= 'ا' && currentChar <= 'ي') || (currentChar >= LB && currentChar <= UB)) // Functions and Variables 114 | { 115 | while ((currentChar >= 'א' && currentChar <= 'ת') || (currentChar >= 'ا' && currentChar <= 'ي') || (currentChar >= LB && currentChar <= UB) || (currentChar >= '0' && currentChar <= '9')) nextChar(); 116 | String func = str.substring(startPos, this.currentPosition); 117 | if(str.contains("\uD802\uDD14\uD802\uDD05\uD802\uDD13\uD802\uDD14")){ //sqrt 𐤔𐤅𐤓𐤔 118 | func = str.substring(startPos, this.currentPosition+7); 119 | for(int i=0; i<7; i++){ 120 | nextChar(); 121 | } 122 | } else if(str.contains("\uD802\uDD0E\uD802\uDD09\uD802\uDD0D")){ //sin 𐤎𐤉𐤍 123 | func = str.substring(startPos, this.currentPosition+5); 124 | for(int i=0; i<5; i++){ 125 | nextChar(); 126 | } 127 | } else if(str.contains("\uD802\uDD12\uD802\uDD05\uD802\uDD0E")){ //cos 𐤒𐤅𐤎 128 | func = str.substring(startPos, this.currentPosition+5); 129 | for(int i=0; i<5; i++){ 130 | nextChar(); 131 | } 132 | } else if(str.contains("\uD802\uDD08\uD802\uDD0D")){ //tan 𐤈𐤍 133 | func = str.substring(startPos, this.currentPosition+3); 134 | for(int i=0; i<3; i++){ 135 | nextChar(); 136 | } 137 | } else if(str.contains("\uD802\uDD0B\uD802\uDD03")){ //toDegrees 𐤋𐤃 138 | func = str.substring(startPos, this.currentPosition+3); 139 | for(int i=0; i<3; i++){ 140 | nextChar(); 141 | } 142 | } else if(str.contains("\uD802\uDD0B\uD802\uDD13")){ //toRadians 𐤋𐤓 143 | func = str.substring(startPos, this.currentPosition+3); 144 | for(int i=0; i<3; i++){ 145 | nextChar(); 146 | } 147 | } else if(str.contains("\uD802\uDD0F\uD802\uDD0C\uD802\uDD07")){ //abs 𐤏𐤌𐤇 148 | func = str.substring(startPos, this.currentPosition+5); 149 | for(int i=0; i<5; i++){ 150 | nextChar(); 151 | } 152 | } else if(str.contains("\uD802\uDD0B\uD802\uDD05\uD802\uDD02")){ //log 𐤋𐤅𐤂 153 | func = str.substring(startPos, this.currentPosition+5); 154 | for(int i=0; i<5; i++){ 155 | nextChar(); 156 | } 157 | } else if(str.contains("\uD802\uDD00\uD802\uDD12\uD802\uDD0E\uD802\uDD10")){ //exp 𐤀𐤒𐤎𐤐 158 | func = str.substring(startPos, this.currentPosition+7); 159 | for(int i=0; i<7; i++){ 160 | nextChar(); 161 | } 162 | } else if(str.contains("\uD802\uDD00\uD802\uDD05\uD802\uDD0B\uD802\uDD10")){ //ulp 𐤀𐤅𐤋𐤐 163 | func = str.substring(startPos, this.currentPosition+7); 164 | for(int i=0; i<7; i++){ 165 | nextChar(); 166 | } 167 | } else if(str.contains("\uD802\uDD13\uD802\uDD0D\uD802\uDD03")){ //random 𐤓𐤍𐤃 168 | func = str.substring(startPos, this.currentPosition+5); 169 | for(int i=0; i<5; i++){ 170 | nextChar(); 171 | } 172 | } else if(str.contains("\uD802\uDD10\uD802\uDD09\uD802\uDD09")){ //𐤐𐤉𐤉 pi 173 | func = str.substring(startPos, this.currentPosition+5); 174 | for(int i=0; i<5; i++){ 175 | nextChar(); 176 | } 177 | } 178 | 179 | for(String varName: Variable.getVariablesNames()) // Variables 180 | { 181 | if(func.equals(varName)) 182 | { 183 | if(Variable.getAVariableValue(func) instanceof Boolean || Variable.getAVariableValue(func) instanceof String) 184 | { 185 | errorFlag = true; 186 | return 0; 187 | } 188 | 189 | if(Variable.getAVariableValue(func) instanceof Object[]) // Array variable 190 | { 191 | Object[] theArray = (Object[]) Variable.getAVariableValue(func); 192 | if(dealWithChar('[')) // Parentheses 193 | { 194 | System.out.println("1"); 195 | int index = (int) parseExpression_Numbers(); 196 | if(index > theArray.length - 1 || index < 0) UIManager.consoleInstance.printErrorMessage("𐤌𐤏𐤓𐤊 𐤇𐤓𐤂 𐤌𐤄𐤕𐤇𐤅𐤌" + " - 𐤁𐤔𐤅𐤓𐤄 " + lineNumber, lineNumber); 197 | if(!dealWithChar(']')) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤌𐤏𐤓𐤊" + " - 𐤁𐤔𐤅𐤓𐤄 " + lineNumber, lineNumber); 198 | if(theArray[index] instanceof Double) 199 | { 200 | System.out.println("2"); 201 | x = (double) theArray[index]; 202 | return x; 203 | } 204 | else 205 | { 206 | errorFlag = true; 207 | return 0; 208 | } 209 | } 210 | } 211 | x = (double) Variable.getAVariableValue(func); 212 | return x; 213 | } 214 | } 215 | // Functions 216 | switch (func) { 217 | case "\uD802\uDD14\uD802\uDD05\uD802\uDD13\uD802\uDD14": 218 | x = Math.sqrt(getFunctionInput()); //𐤔𐤅𐤓𐤔 219 | break; 220 | case "\uD802\uDD0E\uD802\uDD09\uD802\uDD0D": 221 | x = Math.sin(Math.toRadians(getFunctionInput())); //𐤎𐤉𐤍 222 | break; 223 | case "\uD802\uDD12\uD802\uDD05\uD802\uDD0E": 224 | x = Math.cos(Math.toRadians(getFunctionInput())); //𐤒𐤅𐤎 225 | break; 226 | case "\uD802\uDD08\uD802\uDD0D": 227 | x = Math.tan(Math.toRadians(getFunctionInput())); //𐤈𐤍 228 | break; 229 | case "\uD802\uDD0B\uD802\uDD03": 230 | x = Math.toDegrees(getFunctionInput()); //𐤋𐤃 231 | break; 232 | case "\uD802\uDD0B\uD802\uDD13": 233 | x = Math.toRadians(getFunctionInput()); //𐤋𐤓 234 | break; 235 | case "\uD802\uDD0F\uD802\uDD0C\uD802\uDD07": 236 | x = Math.abs(getFunctionInput()); //𐤏𐤌𐤇 237 | break; 238 | case "\uD802\uDD0B\uD802\uDD05\uD802\uDD02": 239 | x = Math.log(getFunctionInput()); //𐤋𐤅𐤂 240 | break; 241 | case "\uD802\uDD00\uD802\uDD12\uD802\uDD0E\uD802\uDD10": 242 | x = Math.exp(Math.toRadians(getFunctionInput())); //𐤀𐤒𐤎𐤐 243 | break; 244 | case "\uD802\uDD00\uD802\uDD05\uD802\uDD0B\uD802\uDD10": 245 | x = Math.ulp(Math.toRadians(getFunctionInput())); //𐤀𐤅𐤋𐤐 246 | break; 247 | case "\uD802\uDD13\uD802\uDD0D\uD802\uDD03": 248 | x = Math.random(); //𐤓𐤍𐤃 249 | break; 250 | case "\uD802\uDD10\uD802\uDD09\uD802\uDD09": 251 | x = Math.PI; //𐤐𐤉𐤉 252 | default: 253 | errorFlag = true; 254 | break; 255 | } 256 | } 257 | else 258 | { 259 | errorFlag = true; 260 | return 0; 261 | } 262 | 263 | if (dealWithChar('^')){ 264 | x = java.lang.Math.pow(x, parseFactor_Numbers()); // Exponentiation 265 | } 266 | if(dealWithChar('|')){ 267 | x = java.lang.Math.round(x); 268 | } 269 | 270 | return x; 271 | } 272 | 273 | private double getFunctionInput() 274 | { 275 | if(dealWithChar('(') || dealWithChar(')')) 276 | { 277 | double x = parseExpression_Numbers(); 278 | if(!dealWithChar(')')) UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤄𐤌𐤕𐤌𐤈𐤉𐤕" + " - 𐤁𐤔𐤅𐤓𐤄 " + lineNumber, lineNumber); 279 | return x; 280 | } 281 | else 282 | { 283 | UIManager.consoleInstance.printErrorMessage("𐤔𐤂𐤉𐤀𐤄 𐤏𐤌 𐤄𐤐𐤓𐤌𐤈𐤓𐤉𐤌 𐤔𐤋 𐤄𐤐𐤅𐤍𐤒𐤑𐤉𐤄 𐤄𐤌𐤕𐤌𐤈𐤉𐤕" + " - 𐤁𐤔𐤅𐤓𐤄 " + lineNumber, lineNumber); 284 | return 0; 285 | } 286 | } 287 | } -------------------------------------------------------------------------------- /src/main/java/Utilities/GematriaSolver.java: -------------------------------------------------------------------------------- 1 | package Utilities; 2 | 3 | import org.jetbrains.annotations.Contract; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.ArrayList; 7 | 8 | import static UI.CodeEditor.gematriaMap; 9 | 10 | public class GematriaSolver { 11 | public static @NotNull String parseGematria(String lines){ 12 | //search for a single geresh ׳ 13 | lines = lines.replaceAll("𐤀׳", "1"); 14 | lines = lines.replaceAll("𐤁׳", "2"); 15 | lines = lines.replaceAll("𐤂׳", "3"); 16 | lines = lines.replaceAll("𐤃׳", "4"); 17 | lines = lines.replaceAll("𐤄׳", "5"); 18 | lines = lines.replaceAll("𐤅׳", "6"); 19 | lines = lines.replaceAll("𐤆׳", "7"); 20 | lines = lines.replaceAll("𐤇׳", "8"); 21 | lines = lines.replaceAll("𐤈׳", "9"); 22 | lines = lines.replaceAll("𐤉׳", "10"); 23 | lines = lines.replaceAll("𐤊׳", "20"); 24 | lines = lines.replaceAll("𐤋׳", "30"); 25 | lines = lines.replaceAll("𐤌׳", "40"); 26 | lines = lines.replaceAll("𐤍׳", "50"); 27 | lines = lines.replaceAll("𐤎׳", "60"); 28 | lines = lines.replaceAll("𐤏׳", "70"); 29 | lines = lines.replaceAll("𐤐׳", "80"); 30 | lines = lines.replaceAll("𐤑׳", "90"); 31 | lines = lines.replaceAll("𐤒׳", "100"); 32 | lines = lines.replaceAll("𐤓׳", "200"); 33 | lines = lines.replaceAll("𐤔׳", "300"); 34 | lines = lines.replaceAll("𐤕׳", "400"); 35 | //search for gershayim ״ 36 | String linesCopy = lines; 37 | ArrayList validGematricSequences = new ArrayList<>(); 38 | String[] tokens = linesCopy.split("\\r?\\n| |\\)|\\(|\\+|\\-|\\/|\\*"); 39 | 40 | for (String token : tokens) { 41 | if (token.contains("״")) { 42 | validGematricSequences.add(token.trim().replaceAll("״", "״״").replaceAll("\\s", "")); 43 | } 44 | } 45 | 46 | for (String sequence : validGematricSequences) { 47 | int value = 0; 48 | for (int j = 0; j < sequence.length() - 1; j += 2) { 49 | value += gematriaMap.get(sequence.substring(j, j + 2)); 50 | } 51 | sequence = sequence.replaceAll("״״", "״"); 52 | lines = lines.replaceAll(sequence, String.valueOf(value)); 53 | } 54 | lines = lines.replaceAll("״״", "״"); 55 | return lines; 56 | } 57 | 58 | @Contract("_ -> new") 59 | public static @NotNull String reverseString(@NotNull String s) { 60 | char[] chars = new char[s.length()]; 61 | boolean twoCharCodepoint = false; 62 | for (int i = 0; i < s.length(); i++) { 63 | chars[s.length() - 1 - i] = s.charAt(i); 64 | if (twoCharCodepoint) { 65 | swap(chars, s.length() - 1 - i, s.length() - i); 66 | } 67 | twoCharCodepoint = !Character.isBmpCodePoint(s.codePointAt(i)); 68 | } 69 | return new String(chars); 70 | } 71 | 72 | private static void swap(char @NotNull [] array, int i, int j) { 73 | char temp = array[i]; 74 | array[i] = array[j]; 75 | array[j] = temp; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/Utilities/NumberExpressionSolver.java: -------------------------------------------------------------------------------- 1 | package Utilities; 2 | 3 | public class NumberExpressionSolver extends ExpressionSolver 4 | { 5 | public NumberExpressionSolver(String str, int lineNumber) 6 | { 7 | super(str, lineNumber); 8 | } 9 | 10 | @Override 11 | public Object getResult() 12 | { 13 | nextChar(); 14 | double x = parseExpression_Numbers(); 15 | if(currentPosition < str.length()) return new BooleanExpressionSolver(str, lineNumber).getResult(); // If it is not number check for boolean 16 | if(errorFlag) return new BooleanExpressionSolver(str, lineNumber).getResult(); // If it is not number check for boolean 17 | return x; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/Utilities/VariableSolver.java: -------------------------------------------------------------------------------- 1 | package Utilities; 2 | 3 | import Commands.Variable; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import static UI.CodeEditor.singleCodePointVariables; 7 | import static UI.CodeEditor.surrogateInterimVariables; 8 | 9 | public class VariableSolver { 10 | public static void getVariables(String @NotNull [] lines){ 11 | for (String line : lines) { 12 | if(line.contains("\uD802\uDD04\uD802\uDD02\uD802\uDD03\uD802\uDD13")){ //𐤄𐤂𐤃𐤓 13 | String[] tokens = line.split("\\r?\\n| |=|\\)|\\(|\\+|\\-|\\/|\\*|\\{|\\}|\\,"); 14 | String variable = tokens[1]; 15 | surrogateInterimVariables.add(variable); 16 | } 17 | if(line.contains("\uD802\uDD0F\uD802\uDD01\uD802\uDD05\uD802\uDD13")){ //𐤏𐤁𐤅𐤓 18 | String[] tokens = line.split("\\r?\\n| |=|\\)|\\(|\\+|\\-|\\/|\\*|\\{|\\}|\\,"); 19 | String loopVar = tokens[1]; 20 | surrogateInterimVariables.add(loopVar); 21 | } 22 | } 23 | 24 | surrogateInterimVariables.remove("\uD802\uDD04\uD802\uDD02\uD802\uDD03\uD802\uDD13"); 25 | 26 | for(int i=0; i") || 64 | line.contains("=!") || line.contains("==")){ 65 | int idxEquals = line.indexOf("="); 66 | } else if(line.contains("||") || line.contains("&&") || 67 | line.contains(">") || line.contains("<")){ 68 | 69 | } else if(line.contains("=")){ 70 | int idxOfEquals = line.indexOf("="); 71 | String rightSideOfLine = line.substring(idxOfEquals); 72 | String leftSideOfLine = line.substring(0, idxOfEquals); 73 | String[] tokens = rightSideOfLine.split("\\r?\\n| |\\)|\\(|\\+|\\-|\\/|\\*|\\{|\\}"); 74 | 75 | for (String token : tokens) { 76 | for (String varName : Variable.getVariablesNames()) { 77 | if (token.contains(varName)) { 78 | rightSideOfLine = rightSideOfLine.replaceAll(varName, Variable.getAVariableValue(varName) + ""); 79 | } 80 | } 81 | } 82 | String newLine = leftSideOfLine + rightSideOfLine; 83 | lines[i] = newLine; 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /thetanakh.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elonlit/Genesis/c74ed393e7d71475f727d230121c206e6c1c3836/thetanakh.pdf --------------------------------------------------------------------------------