├── .gitignore ├── HISTORY ├── LICENSE ├── Makefile ├── Mod ├── Chmod.Mod ├── Compiler.Mod ├── Generator.Mod ├── Makefile ├── Parser.Mod ├── Scanner.Mod ├── SymTable.Mod └── c_chmod │ ├── c_chmod.c │ └── c_chmod.h ├── README.md ├── TODO ├── Test.Mod └── etc ├── Moduel_Ilja.Mod ├── Moduel_RealUpto.Mod └── docs ├── Parser_WorkOrder.txt ├── Parser_and_Generator.txt └── schemes ├── 00_varChar.png ├── 01_Bukva.png ├── 02_MyProc.png ├── 03_Import.png └── src ├── 00_varChar.xml ├── 01_Bukva.xml ├── 02_MyProc.xml ├── 03_Import.xml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /*.c 2 | /*.h 3 | *.o 4 | *.sym 5 | .*.tmp 6 | *.swp 7 | *.bak 8 | *.BAK 9 | Compiler 10 | Test 11 | -------------------------------------------------------------------------------- /HISTORY: -------------------------------------------------------------------------------- 1 | 27 апреля 2020 г. 2 | Контекстный анализ конструкции вызова процедур: вар-параметры. 3 | 4 | 22 апреля 2020 г. 5 | 150-я годовщина со дня рождения В. И. Ленина. 6 | Контекстный анализ: проверка типов параметров процедуры. Добавлен класс 7 | объекта Par, означающий вар-параметр. Реализован импорт псевдомодулей 8 | In и Out и процедур In.Int, Out.Int, Out.Char, Out.Ln, для чего созданы 9 | процедуры SymTable.AddProc, SymTable.AddParam. 10 | 11 | 19 апреля 2020 г. 12 | Реализован импорт модуля Out в SymTable.Import, а также процедуры 13 | Parser.QualIdent и SymTable.ThisObjInModule, позволяющие обращаться 14 | к объектам в других модулях. 15 | Реализован синтаксический анализ вызова процедуры, а частично и 16 | контекстный анализ (но типы параметров пока не проверяются). 17 | Появилась процедура Gen.MakeItem, переводящая Object в Item и процедура 18 | Gen.Call, вызываемая при обработке вызова процедуры. 19 | Вызов SymTable.Init перенесён из модуля Compiler в Parser.Init, в Parser 20 | добавлен объект dummy, который выдаёт QualIdent в случае ошибки. 21 | 22 | 17 апреля 2020 г. 23 | Процедура Parser.Type упрощена, теперь она возвращает результат в виде 24 | SymTable.Type, а не Generator.Item. Реализована синтаксическая 25 | структура IMPORT. 26 | 27 | 15 апреля 2020 г. 28 | Factor теперь устанавливает значение Item.val. SimpleExpression и Term 29 | во время компиляции производят арифметические операции над константами. 30 | При объявлении переменных распределяются их адреса (см. varsize, dc). 31 | Исправлено: При обработке целочисленных и других литералов Factor 32 | выдавал Item.mode = Var вместо Const. Добавлен класс/режим Const. 33 | 34 | 13 апреля 2020 г. 35 | Изменены константы лексического анализатора. Добавлена обработка 36 | литерного типа в процедуре Factor (41X или "A"). Строки иной длины 37 | обрабатываются лексическим анализатором, но отвергаются синтаксическим. 38 | Завершён семантический анализ. Начато добавление val в Object и Item. 39 | 40 | 12 апреля 2020 г. 41 | Добавлен тип CHAR (но Factor ещё не обрабатывает строковой литерал). 42 | Ошибки выводятся красным цветом. Переделан оператор присваивания, в его 43 | левой части теперь «обозначение», обрабатываемое процедурой Designator, 44 | производится проверка согласования типов. Expression, SimpleExpression, 45 | Term и Factor теперь передают друг другу данные через x: Item, проверяя 46 | типы, где необходимо. 47 | 48 | 5 апреля 2020 г. 49 | Новая процедура символьной таблицы ThisObj ищет текущий идентификатор. 50 | Она используется в нетерминале Type. Начальные объекты символьной 51 | таблицы теперь все имеют какое-либо имя (иначе был бы невозможен 52 | поиск). Добавлена чисто отладочная процедура OutType. 53 | 54 | 25 марта 2020 г. 55 | Доисаны процедуры Factor, Term и SimpleExpression, выполняющие 56 | теперь синтаксический анализ. 57 | 58 | 18 февраля 2020 г. 59 | Синтаксический анализ выражений: Expression, SimpleExpression, Term, 60 | Factor (не закончено). Обработка присваивания вынесена за пределы 61 | Statements. Исправлена обработка строковых литералов. 62 | 63 | 29 января 2020 г. 64 | Слегка изменена процедура Statements (добавлен цикл). Добавлены 65 | отсутствовавшие лексемы операций: деление, умножение, сравнение, а 66 | также строковой литерал. Есть проверка на максимальную длину строки. 67 | 68 | 4 апреля 2019 г. 69 | Исправлена процедура WriteDummy, теперь она создаёт работающий 70 | исполнимый файл. Процедура WriteProgramHeader в качестве размера 71 | программного сегмента выводила 30 вместо 38, также было две опечатки. 72 | 73 | 2 апреля 2019 г. 74 | Добавлена процедура Generator.WriteDummy - создаёт исполнимый файл Test 75 | с простейшей программой, выводящей на экран "Hi!". Хардкод. 76 | Файл не работает, но и не вылетает с ошибкой. 77 | Подключен модуль Chmod для того, чтобы отмечать файл как исполнимый. 78 | 79 | 2 апреля 2019 г. 80 | Реализовано объявление переменных: 81 | Написана процедура Parser.Declarations. 82 | Добавлена процедура Parser.Type (пока хардкод). 83 | Написана процедура SymTable.NewObj и диагнозтическая процедура SymTable.Display. 84 | Исправлен синтаксический разбор модуля. 85 | 86 | 26 марта 2019 г. 87 | Добавлены модули SymTable и Generator. 88 | Модуль символьной таблицы содержит типы Object и Type, а также экспортированные процедуры NewObj и Init. 89 | Модуль кодогенератора содержит только определение типа Item. 90 | В модуле синтаксического анализатора (Parser) написать псевдокод считывания объявления переменных в процедуре Declarations. 91 | 92 | 12 марта 2019 г. 93 | Исправлена обработка пустого оператора (;). 94 | 95 | 5 марта 2019 г. 96 | Компилятор разделён на три модуля: Compiler, Scanner, Parser. 97 | 98 | 5 марта 2019 г. 99 | Показан пример считывания диапазона множества {11..15}, лексема upto, приём 7FX 100 | 101 | 26 февраля 2019 г. 102 | Начат синтаксический анализатор. 103 | 104 | 26 февраля 2019 г. 105 | Лексический анализатор (сканер) частично готов. 106 | Можно переходить к синтаксическому анализатору (парсеру). 107 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PROG=Compiler 2 | 3 | VOC=/opt/voc/bin/voc 4 | CC=gcc 5 | VOCPATH=/opt/voc 6 | VOCLIBS=$(VOCPATH)/lib/libvoc-OC.a 7 | COMPILE=$(VOC) -OC -cesF 8 | 9 | all: $(PROG) 10 | 11 | $(PROG): $(PROG).sym 12 | $(CC) -fPIC -g -I $(VOCPATH)/C/include \ 13 | -o $(PROG) Parser.o Scanner.o \ 14 | SymTable.o Generator.o \ 15 | Chmod.o \ 16 | c_chmod.o \ 17 | $(PROG).o \ 18 | $(VOCLIBS) 19 | 20 | $(PROG).sym: Mod/$(PROG).Mod Parser.sym 21 | $(COMPILE) -m Mod/$(PROG).Mod 22 | 23 | Parser.sym: Mod/Parser.Mod Scanner.sym SymTable.sym Generator.sym 24 | $(COMPILE) Mod/Parser.Mod 25 | 26 | Scanner.sym: Mod/Scanner.Mod 27 | $(COMPILE) Mod/Scanner.Mod 28 | 29 | Generator.sym: Mod/Generator.Mod SymTable.sym Chmod.sym 30 | $(COMPILE) Mod/Generator.Mod 31 | 32 | SymTable.sym: Mod/SymTable.Mod 33 | $(COMPILE) Mod/SymTable.Mod 34 | 35 | Chmod.sym: Mod/Chmod.Mod c_chmod.o 36 | $(VOC) -OC -fF Mod/Chmod.Mod 37 | 38 | c_chmod.o: Mod/c_chmod/c_chmod.c Mod/c_chmod/c_chmod.h 39 | $(CC) -c Mod/c_chmod/c_chmod.c -o c_chmod.o 40 | cp Mod/c_chmod/c_chmod.h . 41 | 42 | .PHONY: run clean 43 | 44 | run: $(PROG) 45 | @clear; nl Test.Mod; ./$(PROG) 46 | 47 | clean: 48 | @rm -f *.c *.h *.o *.sym .tmp..* Test $(PROG) 49 | -------------------------------------------------------------------------------- /Mod/Chmod.Mod: -------------------------------------------------------------------------------- 1 | MODULE Chmod; 2 | IMPORT SYSTEM; 3 | 4 | PROCEDURE -AAIncludeChmodh* '#include "c_chmod.h"'; 5 | 6 | PROCEDURE -MakeExecutable* 7 | (path: ARRAY OF CHAR): INTEGER 8 | "MakeExecutable(path)"; 9 | 10 | END Chmod. 11 | -------------------------------------------------------------------------------- /Mod/Compiler.Mod: -------------------------------------------------------------------------------- 1 | (* Главный файл компилятора. 2 | Открывает файл с исходным кодом, подлежащим компиляции, 3 | передаёт его лексическому (Scanner) и синтаксическому анализатору (Parser). 4 | Запускает главную процедуру синтаксического анализатора. *) 5 | 6 | MODULE Compiler; 7 | IMPORT Out, Files, S := Scanner, P := Parser, ST := SymTable; 8 | CONST filename = "Test.Mod"; 9 | VAR F: Files.File; 10 | BEGIN 11 | F := Files.Old(filename); (* В будущем название будет браться из консоли *) 12 | IF F = NIL THEN 13 | Out.String("Файл '"); Out.String(filename); Out.String("' не найден.") 14 | ELSE 15 | S.Init(F); 16 | IF P.Compile() THEN Out.String("Компиляция прошла успешно.") 17 | ELSE Out.String("В ходе компиляции возникли ошибки.") 18 | END; 19 | Files.Close(F) 20 | END; 21 | Out.Ln 22 | END Compiler. 23 | -------------------------------------------------------------------------------- /Mod/Generator.Mod: -------------------------------------------------------------------------------- 1 | MODULE Generator; 2 | IMPORT ST := SymTable, Out, Files, Chmod; 3 | CONST fname = "Test"; 4 | TYPE 5 | Item* = RECORD 6 | mode*: INTEGER; (*Режим предмета, используются константы из SymTable*) 7 | type*: ST.Type; 8 | val*: INTEGER 9 | END; 10 | VAR 11 | F: Files.File; 12 | r: Files.Rider; 13 | 14 | PROCEDURE Byte(n: INTEGER); 15 | BEGIN 16 | Files.Write(r, CHR(n)) 17 | END Byte; 18 | 19 | PROCEDURE Word(n: INTEGER); 20 | BEGIN 21 | Files.Write(r, CHR(n MOD 100H)); 22 | Files.Write(r, CHR(n DIV 100H)) 23 | END Word; 24 | 25 | PROCEDURE DWord(n: INTEGER); 26 | BEGIN 27 | Files.Write(r, CHR(n MOD 100H)); 28 | Files.Write(r, CHR(n DIV 100H MOD 100H)); 29 | Files.Write(r, CHR(n DIV 10000H MOD 100H)); 30 | Files.Write(r, CHR(n DIV 1000000H)) 31 | END DWord; 32 | 33 | (* Выводит в файл первые 16 байтов заголовка ELF-файла *) 34 | PROCEDURE WriteElfIdent; 35 | BEGIN 36 | Byte(7FH); (* Магическое значение - ASCII DEL *) 37 | Byte(ORD("E")); (* Магические значения - слово "ELF" *) 38 | Byte(ORD("L")); 39 | Byte(ORD("F")); 40 | Byte(1); (* Класс ELF-файла: 32-разрядный (бывает ещё 64) *) 41 | Byte(1); (* Способ кодирования данных: порядок от младшего к старшему (LSB) *) 42 | Byte(1); (* Версия ELF-файла: бывает только 1 *) 43 | Byte(0); DWord(0); DWord(0) (* Набивка: просто 9 нулевых байтов *) 44 | END WriteElfIdent; 45 | 46 | (* Выводит в файл заголовок ELF-файла *) 47 | PROCEDURE WriteElfHeader; 48 | BEGIN 49 | WriteElfIdent; (* Выводит первые 16 байтов *) 50 | Word(2); (* Тип файла: исполнимый файл (бывает ещё .o и .so) *) 51 | Word(3); (* Архитектура процессора: Intel 386 *) 52 | DWord(1); (* Версия ELF-файла (ещё раз) *) 53 | DWord(08040054H); (* Вход в программу. Виртуальный адрес начала исполнения *) 54 | DWord(52); (* Смещение на начало таблицы программных заголовков *) 55 | DWord(0); (* Смещение на начало таблицы секций (в исполнимом - не нужны) *) 56 | DWord(0); (* Флаги процессора (для Intel 386 отсутствуют) *) 57 | Word(52); (* Размер заголовка ELF-файла в байтах *) 58 | Word(32); (* Размер одного программного заголовка *) 59 | Word(1); (* Количество программных заголовков *) 60 | Word(0); (* Размер заголовка секции (в исполнимом файле они не нужны) *) 61 | Word(0); (* Количество заголовков секций *) 62 | Word(0) (* Номер секции с таблицей строк (в исполнимом файле не нужны) *) 63 | END WriteElfHeader; 64 | 65 | PROCEDURE WriteProgramHeader; 66 | BEGIN 67 | DWord(1); (* Вид данного сегмента - сегмент для загрузки *) 68 | DWord(54H); (* Смещение на начало данного сегмента = 84 *) 69 | DWord(08040054H); (* Виртуальный адрес первого байта в сегменте *) 70 | DWord(08040054H); (* Физический адрес - не используется !FIXME Проверить, нужен ли здесь 0 *) 71 | DWord(38); (* Сколько сегмент занимает в файле *) 72 | DWord(38); (* Сколько сегмент занимает в файле *) 73 | DWord(5); (* Флаги сегмента: 4 + 1 = чтение + исполнение *) 74 | DWord(1000H) (* Выравнивание для виртуального адреса и смещения в файле *) 75 | END WriteProgramHeader; 76 | 77 | PROCEDURE WriteTextSegment; 78 | BEGIN 79 | Byte(0B9H); (* MOV ECX, DWORD ... *) 80 | DWord(08040054H + 34); (* Откуда брать строку *) 81 | 82 | Byte(0BAH); (* MOV EDX, DWORD ... *) 83 | DWord(04H); (* Длина строки *) 84 | 85 | Byte(0BBH); (* MOV EBX, DWORD ... *) 86 | DWord(01H); (* Куда писать: стандартное устройство вывода STDOUT *) 87 | 88 | Byte(0B8H); (* MOV EAX, DWORD ... *) 89 | DWord(04H); (* Системный вызов: write *) 90 | 91 | Byte(0CDH); (* Прерывание: INT *) 92 | Byte(080H); (* Номер прерывания *) 93 | 94 | Byte(0BBH); (* MOV EBX, DWORD ... *) 95 | DWord(01H); (* Код возврата (exit code) *) 96 | 97 | Byte(0B8H); (* MOV EAX, DWORD ... *) 98 | DWord(01H); (* Системный вызов: exit *) 99 | 100 | Byte(0CDH); (* Прерывание: INT *) 101 | Byte(080H); (* Номер прерывания *) 102 | 103 | Byte(ORD("H")); (* Строка *) 104 | Byte(ORD("i")); 105 | Byte(ORD("!")); 106 | Byte(0AH) 107 | END WriteTextSegment; 108 | 109 | PROCEDURE WriteElf; 110 | BEGIN 111 | WriteElfHeader; 112 | WriteProgramHeader; 113 | WriteTextSegment 114 | END WriteElf; 115 | 116 | PROCEDURE WriteDummy*; 117 | BEGIN 118 | F := Files.New(fname); 119 | IF F # NIL THEN 120 | Files.Set(r, F, 0); 121 | WriteElf; 122 | Files.Register(F); 123 | Files.Close(F); 124 | IF Chmod.MakeExecutable(fname) = 0 THEN END 125 | ELSE 126 | Out.String("Не могу создать файл "); 127 | Out.String(fname); Out.Ln 128 | END 129 | END WriteDummy; 130 | 131 | PROCEDURE MakeItem*(VAR x: Item; o: ST.Object); 132 | BEGIN 133 | x.mode := o.class; 134 | x.type := o.type; 135 | x.val := o.val 136 | END MakeItem; 137 | 138 | PROCEDURE Call*(VAR x: Item); 139 | BEGIN 140 | Out.String("Вызвана процедура "); 141 | Out.Int(x.val, 0); Out.Ln 142 | END Call; 143 | 144 | END Generator. 145 | -------------------------------------------------------------------------------- /Mod/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @$(MAKE) -C .. 3 | 4 | .PHONY: run clean 5 | 6 | run: $(PROG) 7 | @$(MAKE) -C .. run 8 | 9 | clean: 10 | @$(MAKE) -C .. clean 11 | -------------------------------------------------------------------------------- /Mod/Parser.Mod: -------------------------------------------------------------------------------- 1 | MODULE Parser; 2 | IMPORT Out, Files, S := Scanner, ST := SymTable, Gen := Generator; 3 | VAR sym: INTEGER; 4 | dc: INTEGER; (*Счётчик данных (data counter)*) 5 | dummy: ST.Object; (*Болванка, см. QualIdent*) 6 | 7 | PROCEDURE ^Expression(VAR x: Gen.Item); 8 | 9 | (*импорт = идент [":=" идент].*) 10 | PROCEDURE Import; 11 | VAR ident1, ident2: ARRAY 32 OF CHAR; 12 | BEGIN 13 | IF sym = S.ident THEN 14 | ident1 := S.id; 15 | S.Get(sym); 16 | IF sym = S.becomes THEN 17 | S.Get(sym); 18 | IF sym = S.ident THEN 19 | ident2 := S.id; 20 | S.Get(sym) 21 | ELSE 22 | S.Mark("Ожидается идентификатор") 23 | END 24 | ELSE 25 | ident2 := ident1 26 | END; 27 | ST.Import(ident1, ident2) 28 | ELSE 29 | S.Mark("Ожидается идентификатор") 30 | END 31 | END Import; 32 | 33 | (*СписокИмпорта = IMPORT импорт {"," импорт} ";".*) 34 | PROCEDURE ImportList; 35 | BEGIN 36 | IF sym = S.import THEN 37 | S.Get(sym); 38 | Import; 39 | WHILE sym = S.comma DO 40 | S.Get(sym); 41 | Import 42 | END; 43 | IF sym = S.semicolon THEN 44 | S.Get(sym) 45 | ELSE 46 | S.Mark("Ожидается точка с запятой") 47 | END 48 | END 49 | END ImportList; 50 | 51 | PROCEDURE Type(VAR tp: ST.Type); 52 | VAR o: ST.Object; 53 | BEGIN 54 | tp := ST.intType; (*Тип по умолчанию, используется в случае ошибки*) 55 | 56 | IF sym = S.ident THEN 57 | o := ST.ThisObj(); 58 | S.Get(sym); 59 | IF o = NIL THEN 60 | S.Mark("Нет такого типа") 61 | ELSIF o.class # ST.Typ THEN 62 | S.Mark("Это не тип") 63 | ELSE 64 | tp := o.type 65 | END 66 | ELSE (*!TODO учесть ARRAY, RECORD и др.*) 67 | S.Mark("Ожидается тип") 68 | END 69 | END Type; 70 | 71 | (*Объявления = [CONST {ОбъявлениеКонстант ";"}] 72 | [TYPE {ОбъявлениеТипов ";"}] 73 | [VAR {ОбъявлениеПеременных ";"}] 74 | {ОбъявлениеПроцедуры ";"}. 75 | ОбъявлениеПеременных = Идентификаторы ":" Тип. 76 | Идентификаторы = Идентификатор {"," Идентификатор}. 77 | Тип = уточнИдент | ТипМассив | ТипЗапись | ТипУказатель | ПроцедурныйТип. 78 | Но в начале будет только VAR, поэтому используется упрощённый вариант: 79 | Объявления = [VAR {ОбъявлениеПеременных ";"}]. 80 | ОбъявлениеПеременных = Идентификаторы ":" Тип. 81 | Идентификаторы = Идентификатор {"," Идентификатор}. 82 | Тип = Идентификатор.*) 83 | PROCEDURE Declarations(VAR varsize: INTEGER); 84 | VAR tp: ST.Type; 85 | i, n: INTEGER; 86 | o: ST.Object; 87 | names: ARRAY 30, 32 OF CHAR; 88 | BEGIN 89 | IF sym = S.var THEN (*1. Если считано слово VAR, то:*) 90 | S.Get(sym); (*Переходим к названию первой переменной*) 91 | WHILE sym = S.ident DO 92 | names[0] := S.id; 93 | S.Get(sym); (*Переходим к запятой или к двоеточию*) 94 | n := 1; 95 | WHILE sym = S.comma DO 96 | S.Get(sym); (*Переходим к названию следующей перменной*) 97 | IF sym = S.ident THEN 98 | IF n < LEN(names) THEN 99 | names[n] := S.id; 100 | INC(n) 101 | ELSE 102 | S.Mark("Слишком много переменных") 103 | END 104 | ELSE 105 | S.Mark("Ожидается идентификатор") 106 | END; 107 | S.Get(sym) (*Переходим к запятой или к двоеточию*) 108 | END; 109 | IF sym = S.colon THEN 110 | S.Get(sym); 111 | Type(tp); 112 | FOR i := 0 TO n - 1 DO 113 | o := ST.NewObj(names[i], ST.Var); 114 | o.type := tp; 115 | o.val := varsize; 116 | INC(varsize, 4);(*!TODO учитывать размер типа и выравнивание*) 117 | Out.String("Объявлена переменная "); Out.String(names[i]); 118 | Out.String(" типа "); ST.OutType(o.type); 119 | Out.String(" (адрес "); Out.Int(o.val, 0); Out.String(")."); 120 | Out.Ln 121 | END; 122 | IF sym = S.semicolon THEN 123 | S.Get(sym) 124 | ELSE 125 | S.Mark("Ожидается точка с запятой") 126 | END 127 | ELSE 128 | S.Mark("Ожидается двоеточие") 129 | END 130 | END 131 | END 132 | END Declarations; 133 | 134 | (*УПРОЩЕНО: множитель = число | литера | идент | "(" выражение ")".*) 135 | PROCEDURE Factor(VAR x: Gen.Item); 136 | VAR o: ST.Object; 137 | BEGIN 138 | IF sym = S.int THEN 139 | x.mode := ST.Const; 140 | x.type := ST.intType; 141 | x.val := S.ival; 142 | Out.String("Прочитано число "); 143 | Out.Int(S.ival, 0); Out.Ln; 144 | S.Get(sym) 145 | ELSIF sym = S.char THEN 146 | x.mode := ST.Const; 147 | x.type := ST.charType; 148 | x.val := S.ival; 149 | Out.String("Прочитана литера "); 150 | Out.Char(CHR(S.ival)); Out.Ln; 151 | S.Get(sym) 152 | ELSIF sym = S.string THEN 153 | x.mode := ST.Const; 154 | x.type := ST.charType; 155 | x.val := ORD(S.sval[0]); 156 | IF S.slen = 1 THEN 157 | Out.String("Прочитана литера "); 158 | Out.Char(S.sval[0]); Out.Ln 159 | ELSE 160 | S.Mark("Допускается только CHAR") 161 | END; 162 | S.Get(sym) 163 | ELSIF sym = S.ident THEN 164 | o := ST.ThisObj(); 165 | S.Get(sym); 166 | IF o = NIL THEN 167 | S.Mark("Идентификатор не объявлен") 168 | ELSE 169 | x.mode := o.class; 170 | x.type := o.type; 171 | x.val := o.val 172 | END 173 | ELSIF sym = S.lparen THEN 174 | S.Get(sym); 175 | Expression(x); 176 | IF sym = S.rparen THEN S.Get(sym) 177 | ELSE S.Mark("Ожидается )") 178 | END 179 | ELSE 180 | S.Mark("Ожидается число, идентификатор или (") 181 | END 182 | END Factor; 183 | 184 | (*слагаемое = множитель {ОперацияУмножения множитель}.*) 185 | PROCEDURE Term(VAR x: Gen.Item); 186 | VAR op: INTEGER; 187 | y: Gen.Item; 188 | BEGIN 189 | Factor(x); 190 | WHILE (sym = S.times) OR (sym = S.div) OR (sym = S.mod) DO 191 | op := sym; 192 | S.Get(sym); 193 | Factor(y); 194 | IF (x.type.form = ST.Int) & (y.type.form = ST.Int) THEN 195 | IF (x.mode = ST.Const) & (y.mode = ST.Const) THEN 196 | IF op = S.times THEN 197 | x.val := x.val * y.val (*!TODO проверить переполнение*) 198 | ELSE (*DIV OR MOD*) 199 | IF op = S.div THEN (*!TODO проверить деление на нуль*) 200 | x.val := x.val DIV y.val 201 | ELSE 202 | x.val := x.val MOD y.val 203 | END 204 | END 205 | ELSE 206 | IF op = S.times THEN 207 | Out.String("умножение") 208 | ELSIF op = S.div THEN 209 | Out.String("деление") 210 | ELSE 211 | Out.String("остаток от деления") 212 | END 213 | END 214 | ELSE 215 | S.Mark("Операция неприменима") 216 | END; 217 | Out.Ln 218 | END 219 | END Term; 220 | 221 | (*ПростоеВыражение = ["+"|"-"] слагаемое {ОператорСложения слагаемое}.*) 222 | PROCEDURE SimpleExpression(VAR x: Gen.Item); 223 | VAR minus: BOOLEAN; 224 | op: INTEGER; 225 | y: Gen.Item; 226 | BEGIN 227 | minus := FALSE; 228 | IF sym = S.plus THEN 229 | S.Get(sym) 230 | ELSIF sym = S.minus THEN 231 | minus := TRUE; 232 | S.Get(sym) 233 | END; 234 | Term(x); 235 | IF minus THEN 236 | IF x.type.form = ST.Int THEN 237 | IF x.mode = ST.Const THEN 238 | x.val := -x.val 239 | ELSE 240 | Out.String("Унарный минус"); Out.Ln 241 | END 242 | ELSE 243 | S.Mark("Операция унарного минуса неприменима") 244 | END 245 | END; 246 | WHILE (sym = S.plus) OR (sym = S.minus) DO 247 | op := sym; 248 | S.Get(sym); 249 | Term(y); 250 | IF (x.type.form = ST.Int) & (y.type.form = ST.Int) THEN 251 | IF (x.mode = ST.Const) & (y.mode = ST.Const) THEN 252 | IF op = S.plus THEN 253 | INC(x.val, y.val) (*!TODO проверить переполнение*) 254 | ELSE 255 | DEC(x.val, y.val) (*!TODO проверить переполнение*) 256 | END 257 | ELSE 258 | IF op = S.plus THEN 259 | Out.String("плюс") 260 | ELSE 261 | Out.String("минус") 262 | END 263 | END 264 | ELSE 265 | S.Mark("Операция неприменима") 266 | END; 267 | Out.Ln 268 | END 269 | END SimpleExpression; 270 | 271 | (*выражение = ПростоеВыражение [отношение ПростоеВыражение].*) 272 | PROCEDURE Expression(VAR x: Gen.Item); 273 | BEGIN 274 | SimpleExpression(x) 275 | END Expression; 276 | 277 | (*Присваивание = идент ":=" выражение. 278 | x - то, что слева от знака присваивания, 279 | y - то, что справа от знака присваивания.*) 280 | PROCEDURE Assignment(VAR x: Gen.Item); 281 | VAR y: Gen.Item; 282 | BEGIN 283 | S.Get(sym); (*пропускаем :=*) 284 | Expression(y); 285 | IF x.type = y.type THEN 286 | Out.String("Переменной по адресу "); 287 | Out.Int(x.val, 0); 288 | Out.String(" присвоено значение "); 289 | Out.Int(y.val, 0); Out.Char("."); Out.Ln 290 | ELSE 291 | S.Mark("Не совпадают типы") 292 | END 293 | END Assignment; 294 | 295 | (*уточнИдент = [идент "."] идент. 296 | Первый идент - это модуль. *) 297 | PROCEDURE QualIdent(VAR o: ST.Object); 298 | BEGIN 299 | o := ST.ThisObj(); 300 | S.Get(sym); 301 | IF o = NIL THEN 302 | S.Mark("Нет такого объекта") 303 | ELSE (*Объект найден...*) 304 | IF (sym = S.period) & (o.class = ST.Mod) THEN (*...и это модуль*) 305 | S.Get(sym); 306 | o := ST.ThisObjInModule(o); 307 | S.Get(sym); 308 | IF o = NIL THEN S.Mark("В модуле нет такого объекта") END 309 | END 310 | END; 311 | IF o = NIL THEN o := dummy END 312 | END QualIdent; 313 | 314 | (*Designator - обозначение. 315 | Обозначение = уточнИдент {селектор}. 316 | селектор = "[" выражение "]" | ... 317 | Но здесь упрощено: Обозначение = уточнИдент.*) 318 | PROCEDURE Designator(VAR o: ST.Object); 319 | BEGIN 320 | QualIdent(o) (*!TODO обработать селекторы*) 321 | END Designator; 322 | 323 | PROCEDURE Parameter(par: ST.Object); 324 | VAR x: Gen.Item; 325 | BEGIN 326 | Expression(x); 327 | IF par # NIL THEN 328 | IF x.type.form # par.type.form THEN 329 | S.Mark("Несогласование типов") 330 | (*!TODO вывести типы формального и фактического параметров*) 331 | ELSIF (par.class = ST.Par) & (x.mode # ST.Var) THEN 332 | S.Mark("Требуется вар-параметр") 333 | ELSE 334 | Out.String("Параметр "); Out.Int(x.val, 0); Out.Char("."); Out.Ln 335 | END 336 | END 337 | END Parameter; 338 | 339 | (*ФактическиеПараметры = "(" [выражение {"," выражение}] ")". 340 | Предусловие: sym = S.lparen. Обрабатывает до ")" включительно.*) 341 | PROCEDURE ActualParameters(VAR x: Gen.Item); 342 | VAR y: Gen.Item; 343 | par: ST.Object; 344 | n: INTEGER; (*Фактическое количество параметров*) 345 | BEGIN 346 | S.Get(sym);(*Пропускаем "("*) 347 | n := 0; 348 | IF sym # S.rparen THEN 349 | par := x.type.dsc; 350 | Parameter(par); 351 | INC(n); 352 | WHILE sym = S.comma DO 353 | S.Get(sym); (*Пропускаем ","*) 354 | IF par # NIL THEN par := par.next END; 355 | Parameter(par); 356 | INC(n) 357 | END 358 | END; 359 | IF sym = S.rparen THEN S.Get(sym) 360 | ELSE S.Mark("Не закрыта скобка") 361 | END; 362 | (*Проверка совпадения количества параметров*) 363 | IF n > x.type.nofpar THEN 364 | S.Mark("Слишком много фактических параметров") 365 | ELSIF n < x.type.nofpar THEN 366 | S.Mark("Недостаточно фактических параметров") 367 | END 368 | END ActualParameters; 369 | 370 | (*Операторы = Оператор {";" Оператор}. 371 | Оператор = [Присваивание | ВызовПроцедуры | ОператорIf | 372 | ОператорCase | ОператорWhile | ОператорRepeat | ОператорFor]. 373 | Statements/Операторы означает последовательность операторов.*) 374 | PROCEDURE Statements; 375 | VAR x: Gen.Item; 376 | o: ST.Object; 377 | BEGIN 378 | REPEAT 379 | WHILE sym = S.semicolon DO S.Get(sym) END; 380 | IF sym = S.ident THEN 381 | Designator(o); 382 | Gen.MakeItem(x, o); 383 | IF sym = S.eql THEN sym := S.becomes; S.Mark("Ожидается :=") END; 384 | IF sym = S.becomes THEN Assignment(x) 385 | ELSIF sym = S.lparen THEN (*Например: Out.Int(... *) 386 | IF x.type.form = ST.Proc THEN (*Это действительно процедура*) 387 | IF x.type.base.form # ST.NoTyp THEN (*Функциональная*) 388 | S.Mark("Не используется возвращаемое значение") 389 | ELSE 390 | ActualParameters(x); (*Обрабатывает до ")" включительно*) 391 | Gen.Call(x) 392 | END 393 | ELSE S.Mark("Это не процедура") 394 | END 395 | ELSIF x.type.form = ST.Proc THEN(*Вызов процедуры без параметров*) 396 | IF x.type.nofpar > 0 THEN S.Mark("Требуются параметры") END; 397 | IF x.type.base.form # ST.NoTyp THEN (*Функциональная*) 398 | S.Mark("Не используется возвращаемое значение") 399 | ELSE 400 | Gen.Call(x) 401 | END 402 | ELSE S.Mark("Инструкция неопознана") 403 | END 404 | END 405 | UNTIL sym # S.semicolon 406 | END Statements; 407 | 408 | (*Модуль = MODULE идент ";" [СписокИмпорта] Объявления 409 | [BEGIN Операторы] END идент ".".*) 410 | PROCEDURE Module; 411 | VAR name: ARRAY 32 OF CHAR; 412 | BEGIN 413 | IF sym = S.module THEN 414 | S.Get(sym); 415 | IF sym = S.ident THEN name := S.id; S.Get(sym) 416 | ELSE S.Mark("Ожидается идентификатор"); name[0] := 0X 417 | END; 418 | IF sym = S.semicolon THEN S.Get(sym) 419 | ELSE S.Mark("Ожидается точка с запятой") 420 | END; 421 | ImportList; 422 | dc := 80002000; 423 | Declarations(dc); 424 | IF sym = S.begin THEN S.Get(sym); Statements END; 425 | IF sym = S.end THEN 426 | S.Get(sym); 427 | IF sym = S.ident THEN 428 | IF name # S.id THEN S.Mark("Название модуля не совпадает") END; 429 | S.Get(sym) 430 | ELSE 431 | S.Mark("Ожидается название модуля") 432 | END; 433 | IF sym # S.period THEN S.Mark("Нет точки в конце модуля") END 434 | ELSE S.Mark("Ожидается END") 435 | END 436 | ELSE S.Mark("Ожидается модуль") 437 | END 438 | END Module; 439 | 440 | PROCEDURE Init; 441 | BEGIN 442 | ST.Init; 443 | NEW(dummy); dummy.class := ST.Var; dummy.type := ST.intType 444 | END Init; 445 | 446 | (*Разбирает лексемы, получаемые из модуля Scanner, в соответствии 447 | с синтаксисом языка Оберон. Возвращает TRUE в случае 448 | успешной компиляции. Вызывается из модуля Compiler. 449 | В будущем будет вызывать кодогенератор (из отдельного модуля). *) 450 | PROCEDURE Compile*(): BOOLEAN; 451 | BEGIN 452 | Init; 453 | Gen.WriteDummy; (*Сгенерировать исполнимый файл. Хардкод.*) 454 | S.Get(sym); (* олучить наперёд одну лексему*) 455 | Module; (*Запустить разбор синтаксической структуры МОДУЛЬ*) 456 | ST.Display; 457 | RETURN ~S.error 458 | END Compile; 459 | 460 | END Parser. 461 | -------------------------------------------------------------------------------- /Mod/Scanner.Mod: -------------------------------------------------------------------------------- 1 | MODULE Scanner; 2 | IMPORT Out, Files; 3 | CONST 4 | (*Лексемы*) 5 | null = 0; times* = 1; rdiv* = 2; div* = 3; mod* = 4; 6 | and* = 5; plus* = 6; minus* = 7; or* = 8; eql* = 9; 7 | neq* = 10; lss* = 11; leq* = 12; gtr* = 13; geq* = 14; 8 | in* = 15; is* = 16; arrow* = 17; period* = 18; 9 | char* = 20; int* = 21; real* = 22; false* = 23; true* = 24; 10 | nil* = 25; string* = 26; not* = 27; lparen* = 28; lbrak* = 29; 11 | lbrace* = 30; ident* = 31; 12 | if* = 32; while* = 34; repeat* = 35; case* = 36; for* = 37; 13 | comma* = 40; colon* = 41; becomes* = 42; upto* = 43; rparen* = 44; 14 | rbrak* = 45; rbrace* = 46; then* = 47; of* = 48; do* = 49; 15 | to* = 50; by* = 51; semicolon* = 52; end* = 53; bar* = 54; 16 | else* = 55; elsif* = 56; until* = 57; return* = 58; 17 | array* = 60; record* = 61; pointer* = 62; const* = 63; type* = 64; 18 | var* = 65; procedure* = 66; begin* = 67; import* = 68; module* = 69; 19 | eot = 70; 20 | 21 | VAR r: Files.Rider; 22 | ch: CHAR; 23 | id*: ARRAY 32 OF CHAR; 24 | idlen*: INTEGER; 25 | ival*: INTEGER; 26 | sval*: ARRAY 1024 OF CHAR; 27 | slen*: INTEGER; 28 | error*: BOOLEAN; 29 | 30 | PROCEDURE Color(n: INTEGER); 31 | BEGIN 32 | Out.Char(CHR(27)); Out.Char("["); 33 | Out.Int(n, 0); Out.Char("m") 34 | END Color; 35 | 36 | PROCEDURE Mark*(msg: ARRAY OF CHAR); 37 | BEGIN 38 | error := TRUE; 39 | Color(41); Color(97); 40 | Out.String("Ошибка на поз. "); 41 | Out.Int(SHORT(Files.Pos(r)), 0); 42 | Out.String(": "); Out.String(msg); 43 | Out.Char("."); Color(0); Out.Ln 44 | END Mark; 45 | 46 | PROCEDURE ReadCh; 47 | BEGIN 48 | IF r.eof THEN ch := 0X 49 | ELSE Files.Read(r, ch) 50 | END 51 | END ReadCh; 52 | 53 | PROCEDURE Get*(VAR sym: INTEGER); 54 | VAR d: ARRAY 30 OF INTEGER; (*digits*) 55 | i, dlen, base: INTEGER; 56 | BEGIN 57 | WHILE (ch # 0X) & (ch <= " ") DO 58 | ReadCh 59 | END; 60 | 61 | IF r.eof THEN sym := eot 62 | ELSIF ch = "," THEN sym := comma; ReadCh 63 | ELSIF ch = "." THEN sym := period; ReadCh 64 | ELSIF ch = ";" THEN sym := semicolon; ReadCh 65 | ELSIF ch = "+" THEN sym := plus; ReadCh 66 | ELSIF ch = "-" THEN sym := minus; ReadCh 67 | ELSIF ch = "*" THEN sym := times; ReadCh 68 | ELSIF ch = "/" THEN sym := rdiv; ReadCh 69 | ELSIF ch = "&" THEN sym := and; ReadCh 70 | ELSIF ch = "~" THEN sym := not; ReadCh 71 | ELSIF ch = "(" THEN sym := lparen; ReadCh 72 | ELSIF ch = ")" THEN sym := rparen; ReadCh 73 | ELSIF ch = "[" THEN sym := lbrak; ReadCh 74 | ELSIF ch = "]" THEN sym := rbrak; ReadCh 75 | ELSIF ch = "{" THEN sym := lbrace; ReadCh 76 | ELSIF ch = "}" THEN sym := rbrace; ReadCh 77 | ELSIF ch = "=" THEN sym := eql; ReadCh 78 | ELSIF ch = "#" THEN sym := neq; ReadCh 79 | ELSIF ch = "<" THEN ReadCh; 80 | IF ch = "=" THEN sym := leq; ReadCh 81 | ELSE sym := lss 82 | END 83 | ELSIF ch = ">" THEN ReadCh; 84 | IF ch = "=" THEN sym := geq; ReadCh 85 | ELSE sym := gtr 86 | END 87 | ELSIF ch = ":" THEN 88 | ReadCh; 89 | IF ch = "=" THEN sym := becomes; ReadCh 90 | ELSE sym := colon 91 | END 92 | ELSIF ("A" <= ch) & (ch <= "Z") OR ("a" <= ch) & (ch <= "z") THEN 93 | id[0] := ch; idlen := 1; ReadCh; 94 | WHILE ("A" <= ch) & (ch <= "Z") OR 95 | ("a" <= ch) & (ch <= "z") OR 96 | ("0" <= ch) & (ch <= "9") DO 97 | IF idlen < LEN(id) - 1 THEN 98 | id[idlen] := ch; 99 | INC(idlen) 100 | END; 101 | ReadCh 102 | END; 103 | id[idlen] := 0X; 104 | IF id = "MODULE" THEN sym := module 105 | ELSIF id = "IMPORT" THEN sym := import 106 | ELSIF id = "CONST" THEN sym := const 107 | ELSIF id = "VAR" THEN sym := var 108 | ELSIF id = "BEGIN" THEN sym := begin 109 | ELSIF id = "END" THEN sym := end 110 | ELSIF id = "IF" THEN sym := if 111 | ELSIF id = "THEN" THEN sym := then 112 | ELSIF id = "ELSE" THEN sym := else 113 | ELSIF id = "ELSIF" THEN sym := elsif 114 | ELSIF id = "WHILE" THEN sym := while 115 | ELSIF id = "DIV" THEN sym := div 116 | ELSIF id = "MOD" THEN sym := mod 117 | ELSIF id = "OR" THEN sym := or 118 | ELSE sym := ident 119 | END 120 | ELSIF ("0" <= ch) & (ch <= "9") THEN 121 | d[0] := ORD(ch) - ORD("0"); ReadCh; 122 | dlen := 1; 123 | WHILE ("0" <= ch) & (ch <= "9") OR 124 | ("A" <= ch) & (ch <= "F") DO 125 | IF dlen < LEN(d) THEN 126 | IF ("0" <= ch) & (ch <= "9") THEN d[dlen] := ORD(ch) - ORD("0") 127 | ELSE d[dlen] := ORD(ch) - ORD("A") + 10 128 | END; 129 | INC(dlen) 130 | ELSE Mark("Слишком длинное число") 131 | END; 132 | ReadCh 133 | END; 134 | sym := int; 135 | IF (ch = "X") OR (ch = "H") THEN 136 | base := 16; 137 | IF ch = "X" THEN sym := char END; 138 | ReadCh 139 | ELSE base := 10 140 | END; 141 | ival := 0; i := 0; 142 | WHILE i < dlen DO 143 | IF (base = 10) & (d[i] >= 10) THEN 144 | Mark("Некорректное число") 145 | END; 146 | ival := ival * base + d[i]; 147 | INC(i) 148 | END 149 | ELSIF ch = 22X THEN ReadCh; sym := string; 150 | slen := 0; 151 | WHILE (ch # 22X) & (ch >= " ") & (slen < LEN(sval) - 1) DO 152 | sval[slen] := ch; 153 | INC(slen); 154 | ReadCh 155 | END; 156 | IF ch = 0X THEN Mark("Неожиданный конец файла") 157 | ELSIF ch < " " THEN Mark("Недопустимая литера в строке") 158 | ELSIF ch # 22X THEN Mark("Слишком длинная строка") 159 | END; 160 | sval[slen] := 0X; 161 | (*Промотка до ближайшей кавычки*) 162 | WHILE (ch # 0X) & (ch # 22X) DO ReadCh END; 163 | ReadCh 164 | ELSE 165 | sym := null; 166 | ReadCh 167 | END 168 | END Get; 169 | 170 | PROCEDURE Init*(F: Files.File); 171 | BEGIN 172 | Files.Set(r, F, 0); 173 | ReadCh; 174 | error := FALSE 175 | END Init; 176 | 177 | END Scanner. 178 | -------------------------------------------------------------------------------- /Mod/SymTable.Mod: -------------------------------------------------------------------------------- 1 | MODULE SymTable; 2 | IMPORT Out, S := Scanner; 3 | CONST 4 | (* Классы объектов (и одновременно режимы предметов) *) 5 | Head* = 0; Const* = 1; Var* = 2; Par* = 3; Typ* = 5; Mod* = 8; 6 | (*Par - это вар-параметр*) 7 | 8 | (* Формы типов *) 9 | Char* = 3; 10 | Int* = 4; 11 | NoTyp* = 9; 12 | Proc* = 10; 13 | 14 | TYPE 15 | Object* = POINTER TO ObjDesc; 16 | Type* = POINTER TO TypeDesc; 17 | TypeDesc* = RECORD 18 | form*: INTEGER; (* Форма типа *) 19 | size*: INTEGER; (* Размер типа в байтах *) 20 | nofpar*: INTEGER; (* Количество параметров *) 21 | base*: Type; (* Тип возвращаемого значения процедуры *) 22 | dsc*: Object (* Список формальных параметров процедуры *) 23 | END; 24 | 25 | ObjDesc* = RECORD 26 | class*: INTEGER; (* Класс объекта *) 27 | type*: Type; 28 | name*: ARRAY 32 OF CHAR; 29 | val*: INTEGER; 30 | next*, dsc*: Object 31 | END; 32 | 33 | (* Назначение поля val в зависимости от значения поля class (в Object): 34 | class | val 35 | ------+----------------------- 36 | Var | адрес переменной 37 | Const | значение константы 38 | Type | не используется (пока) *) 39 | 40 | VAR 41 | curScope: Object; 42 | 43 | charType*, intType*, noType*: Type; 44 | 45 | (*Для удобочитаемой отладки*) 46 | PROCEDURE OutType*(t: Type); 47 | BEGIN 48 | IF t.form = Int THEN Out.String("целое число") 49 | ELSIF t.form = Char THEN Out.String("литера") 50 | ELSE Out.Int(t.form, 0) 51 | END 52 | END OutType; 53 | 54 | PROCEDURE MakeType(form, size: INTEGER): Type; 55 | VAR t: Type; 56 | BEGIN 57 | NEW(t); 58 | t.form := form; 59 | t.size := size; 60 | RETURN t 61 | END MakeType; 62 | 63 | PROCEDURE NewObj*(name: ARRAY OF CHAR; class: INTEGER): Object; 64 | VAR o, p: Object; 65 | BEGIN 66 | p := curScope; 67 | WHILE (p.next # NIL) & (p.next.name # name) DO p := p.next END; 68 | IF p.next = NIL THEN 69 | NEW(o); 70 | o.class := class; 71 | o.name := name; 72 | o.next := NIL; 73 | p.next := o 74 | ELSE 75 | o := p.next; 76 | S.Mark("Такой объект уже есть") 77 | END; 78 | RETURN o 79 | END NewObj; 80 | 81 | PROCEDURE ThisObjInModule*(mod: Object): Object; 82 | VAR o: Object; 83 | BEGIN 84 | o := mod.dsc; 85 | WHILE (o # NIL) & (o.name # S.id) DO o := o.next END; 86 | RETURN o 87 | END ThisObjInModule; 88 | 89 | (*Предусловие: sym = S.ident*) 90 | PROCEDURE ThisObj*(): Object; 91 | VAR o, p: Object; 92 | BEGIN 93 | p := curScope; 94 | WHILE p # NIL DO 95 | o := p.next; 96 | WHILE (o # NIL) & (o.name # S.id) DO 97 | o := o.next 98 | END; 99 | IF o = NIL THEN p := p.dsc 100 | ELSE p := NIL 101 | END 102 | END; 103 | RETURN o 104 | END ThisObj; 105 | 106 | (*Добавить процедуру в модуль*) 107 | PROCEDURE AddProc(m: Object; name: ARRAY OF CHAR; key: INTEGER): Object; 108 | VAR o, g: Object; 109 | BEGIN 110 | NEW(o); 111 | IF m.dsc = NIL THEN 112 | m.dsc := o 113 | ELSE 114 | g := m.dsc; 115 | WHILE g.next # NIL DO g := g.next END; 116 | g.next := o 117 | END; 118 | o.class := Const; 119 | o.name := name; 120 | o.val := key; 121 | o.next := NIL; 122 | o.dsc := NIL; 123 | o.type := MakeType(Proc, 4); 124 | o.type.nofpar := 0; 125 | o.type.base := noType; 126 | RETURN o 127 | END AddProc; 128 | 129 | (*Добавить формальный параметр в процедуру*) 130 | PROCEDURE AddParam(proc: Object; name: ARRAY OF CHAR; varParam: BOOLEAN; 131 | type: Type; offset: INTEGER); 132 | VAR o, p: Object; 133 | BEGIN 134 | NEW(p); 135 | IF proc.type.dsc = NIL THEN 136 | proc.type.dsc := p 137 | ELSE 138 | o := proc.type.dsc; 139 | WHILE o.next # NIL DO o := o.next END; 140 | o.next := p 141 | END; 142 | INC(proc.type.nofpar); 143 | IF varParam THEN p.class := Par ELSE p.class := Var END; 144 | p.name := name; 145 | p.val := offset; (*?*) 146 | p.type := type; 147 | p.next := NIL; 148 | p.dsc := NIL 149 | END AddParam; 150 | 151 | PROCEDURE Import*(alias, modname: ARRAY OF CHAR); 152 | VAR m, o, p: Object; 153 | tp: Type; 154 | BEGIN 155 | IF modname = "Out" THEN 156 | NEW(m); 157 | curScope.next := m; 158 | m.class := Mod; 159 | m.name := alias; 160 | m.val := 1; (*!FIXME*) 161 | m.type := NIL; 162 | m.dsc := NIL; 163 | (*Out.Char(ch)*) 164 | o := AddProc(m, "Char", 0); 165 | AddParam(o, "ch", FALSE, charType, 4); 166 | (*Out.Int(n, w)*) 167 | o := AddProc(m, "Int", 1); 168 | AddParam(o, "n", FALSE, intType, 4); 169 | AddParam(o, "w", FALSE, intType, 8); 170 | (*Out.Ln*) 171 | o := AddProc(m, "Ln", 2) 172 | ELSIF modname = "In" THEN 173 | NEW(m); 174 | m.next := curScope.next; 175 | curScope.next := m; 176 | m.class := Mod; 177 | m.name := alias; 178 | m.val := 2; (*!FIXME*) 179 | m.type := NIL; 180 | m.dsc := NIL; 181 | (*In.Int(n)*) 182 | o := AddProc(m, "Int", 0); 183 | AddParam(o, "n", TRUE, intType, 4) 184 | ELSE 185 | S.Mark("Такого модуля не существует") 186 | END; 187 | Out.String("Импортируем "); Out.String(modname); 188 | Out.String(" под псевдонимом "); Out.String(alias); 189 | Out.Char("."); Out.Ln 190 | END Import; 191 | 192 | PROCEDURE Init*; 193 | VAR o: Object; 194 | BEGIN 195 | NEW(curScope); 196 | curScope.class := Head; 197 | curScope.name[0] := 0X; 198 | curScope.next := NIL; 199 | 200 | NEW(curScope.dsc); 201 | curScope.dsc.class := Head; 202 | curScope.dsc.name[0] := 0X; 203 | curScope.dsc.dsc := NIL; 204 | 205 | NEW(o); 206 | o.class := Typ; 207 | o.name := "CHAR"; 208 | o.next := NIL; 209 | o.dsc := NIL; 210 | charType := MakeType(Char, 1); 211 | o.type := charType; 212 | curScope.dsc.next := o; 213 | 214 | NEW(o); 215 | o.class := Typ; 216 | o.name := "INTEGER"; 217 | o.next := NIL; 218 | o.dsc := NIL; 219 | intType := MakeType(Int, 4); 220 | o.type := intType; 221 | curScope.dsc.next.next := o; 222 | 223 | noType := MakeType(NoTyp, 4) 224 | END Init; 225 | 226 | PROCEDURE Display*; 227 | VAR h, p: Object; 228 | BEGIN 229 | Out.String("Содержимое символьной таблицы:"); Out.Ln; 230 | h := curScope; 231 | WHILE h # NIL DO 232 | p := h.next; 233 | WHILE p # NIL DO 234 | Out.String(" "); Out.String(p.name); Out.String(": "); 235 | IF p.class = Head THEN Out.String("заголовочный") 236 | ELSIF p.class = Var THEN 237 | Out.String("переменная типа "); OutType(p.type) 238 | ELSIF p.class = Typ THEN Out.String("тип") 239 | ELSIF p.class = Mod THEN Out.String("модуль") 240 | END; 241 | Out.Ln; 242 | p := p.next 243 | END; 244 | IF h.dsc # NIL THEN 245 | Out.String("Следующая область видимости:"); Out.Ln 246 | END; 247 | h := h.dsc 248 | END 249 | END Display; 250 | 251 | END SymTable. 252 | -------------------------------------------------------------------------------- /Mod/c_chmod/c_chmod.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int MakeExecutable(const char *path) { 4 | chmod(path, 0755); // S_IXUSR | S_IXGRP | S_IROTH 5 | } 6 | -------------------------------------------------------------------------------- /Mod/c_chmod/c_chmod.h: -------------------------------------------------------------------------------- 1 | #ifndef CHMOD_H 2 | #define CHMOD_H 3 | 4 | int MakeExecutable(const char *path); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | *English text below* 2 | 3 | # Компилятор языка программирования Оберон 4 | 5 | * Проект по созданию компилятора Оберона и написанию соответствующей книги 6 | * Сайт проекта: [freeoberon.su](https://freeoberon.su) 7 | * Репозиторий с книгой: [https://github.com/kekcleader/OberonBook] [читать PDF](https://github.com/kekcleader/OberonBook/blob/master/oberon.pdf) 8 | 9 | Исходные файлы находятся в каталоге [Mod](Mod). 10 | 11 | Желающим погрузиться в тему построения компиляторов рекомендуется ознакамливаться с исходным кодом данного проекта по нарастающей, начиная с самых первых коммитов (для более развёрнутого описания изменений см. файл [HISTORY](HISTORY)), а также с книгами Николая Вальтеровича Вирта, Сергея Залмановича Свердлова и других авторов на данную тему, с кодом компилятора в [Project Oberon](http://projectoberon.com), с сайтом [Free Oberon](https://freeoberon.su) (на этом сайте есть контактная информация). 12 | 13 | Для того, чтобы скомпилировать компилятор, необходим компилятор VOC, 14 | входящий в комплект [Free Oberon](https://freeoberon.su). Компилятор VOC 15 | находится в подкаталоге `data/bin/voc/bin` (файл `voc` на Линуксе или 16 | `voc.exe` на ОС Windows). Для Линукса также подойдёт 17 | [оригинальный компилятор VOC](https://github.com/vishaps/voc). 18 | Также можно использовать компиляторы 19 | [Ofront](https://github.com/jtempl/ofront) и 20 | [Ofront+](https://github.com/Oleg-N-Cher/OfrontPlus). 21 | 22 | При смене компилятора, пожалуйста, отредактируйте файл [Makefile](Makefile) 23 | (а именно, переменную `VOCPATH` наверху, и, возможно, другие). 24 | 25 | В будущем компилятор будет компилировать себя сам. 26 | 27 | Зайдите в каталог с исходным кодом компилятора (можно зайти как в `oberon`, так и в `oberon/Mod`) и выполните: 28 | ``` 29 | make 30 | ``` 31 | 32 | Затем запустите файл `Compiler`, или воспользуйтесь командой `make run` для теста. 33 | 34 | Для компиляции также понадобятся пакеты `make` и `gcc`: 35 | ``` 36 | sudo apt-get install -y make gcc 37 | ``` 38 | 39 | ![Oberon compiler screenshot](https://github.com/kekcleader/oberon/raw/master/etc/docs/schemes/03_Import.png) 40 | 41 | # Oberon Programming Language Compiler 42 | 43 | * A project to create an Oberon compiler and write a book about it 44 | * Project website: [freeoberon.su](https://freeoberon.su/en) 45 | * Repository of the book: [https://github.com/kekcleader/OberonBook] [read PDF](https://github.com/kekcleader/OberonBook/blob/master/oberon.pdf) 46 | 47 | The source files are in the [Mod](Mod) directory. 48 | 49 | Those wishing to dive into the topic of building compilers are advised to familiarize themselves with the source code of this project on an increasing basis, starting with the very first commits (for a more detailed description of the changes, see the [HISTORY](HISTORY) file), as well as read books by Niklaus Wirth, S. Z. Sverdlov and other authors on this topic, as well as familiarize with the compiler code of the [Project Oberon](http://projectoberon.com) and with the [Free Oberon](https://freeoberon.su/en) website (see this website for the contact information). 50 | 51 | In order to compile the compiler, you need the VOC compiler included with 52 | [Free Oberon](https://freeoberon.su/en). The VOC compiler is located in the 53 | `data/bin/voc/bin` (the file name on Linux is `voc`, and `voc.exe` on Windows). 54 | For Linux, [the original VOC compiler](https://github.com/vishaps/voc) is also 55 | suitable. You can also use 56 | [Ofront](https://github.com/jtempl/ofront) and 57 | [Ofront+](https://github.com/Oleg-N-Cher/OfrontPlus) compilers. 58 | 59 | When changing the compiler for another one, please edit the [Makefile](Makefile) 60 | (namely, the VOCPATH variable at the top, and possibly others). 61 | 62 | In the future, the compiler will compile itself. 63 | 64 | Go to the directory with the source code of the compiler (you can go into any of `oberon` or `oberon/Mod`) and run: 65 | ``` 66 | make 67 | ``` 68 | 69 | Then run the file `Compiler`, or type `make run` to test it. 70 | 71 | You will also need `make` and `gcc` packages for compilation: 72 | ``` 73 | sudo apt-get install -y make gcc 74 | ``` 75 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * Генерация машинного кода для присваивания. 2 | * Генерация машинного кода для сложения и вычитания, смены знака. 3 | * Генерация машинного кода для умножения и деления. 4 | * Генерация машинного кода для вызова процедуры. 5 | -------------------------------------------------------------------------------- /Test.Mod: -------------------------------------------------------------------------------- 1 | MODULE Test; 2 | IMPORT Out; 3 | VAR c: CHAR; 4 | BEGIN 5 | a := a + b; 6 | c := "!"; 7 | Out.Char("H"); 8 | Out.Char("i"); 9 | Out.Char(c); 10 | Out.Ln 11 | END Test. 12 | 13 | (*Пример*) 14 | SUM EAX, EBX 15 | 16 | MOV [0x80002000], DWORD 70 (* c := "F" *) 17 | 18 | MOV EAX, [0x80002000] (* (c) *) 19 | PUSH EAX 20 | 21 | CALL 0x80004000 (* Out.Char *) 22 | CALL 0x80004100 (* Out.Ln *) 23 | -------------------------------------------------------------------------------- /etc/Moduel_Ilja.Mod: -------------------------------------------------------------------------------- 1 | MODULE Moduel; 2 | IMPORT Out, Files; 3 | VAR 4 | F: Files.File; 5 | r: Files.Rider; 6 | 7 | PROCEDURE ReadAll; 8 | VAR ch: CHAR; 9 | BEGIN 10 | Files.Read(r, ch); 11 | WHILE ~r.eof DO 12 | Out.Char(ch); 13 | Files.Read(r, ch) 14 | END 15 | END ReadAll; 16 | 17 | BEGIN 18 | F := Files.Old('Test.Mod'); 19 | IF F = NIL THEN 20 | Out.String('Файл не найден.'); Out.Ln 21 | ELSE 22 | Files.Set(r, F, 0); 23 | ReadAll 24 | END 25 | END Moduel. 26 | -------------------------------------------------------------------------------- /etc/Moduel_RealUpto.Mod: -------------------------------------------------------------------------------- 1 | MODULE Moduel; 2 | IMPORT In, Out, Files; 3 | CONST 4 | null = 0; module = 1; import = 2; const = 3; var = 4; begin = 5; 5 | end = 6; if = 7; then = 8; else = 9; elsif = 10; while = 11; 6 | ident = 12; semicol = 13; colon = 14; comma = 15; period = 16; 7 | becomes = 17; equ = 18; neq = 19; les = 20; leq = 21; gtr = 22; geq = 23; 8 | lparen = 24; rparen = 25; lbrak = 26; rbrak = 27; lbrace = 28; rbrace = 29; 9 | int = 30; string = 31; not = 32; and = 33; or = 34; plus = 35; minus = 36; 10 | rdiv = 37; div = 38; mod = 39; times = 40; real = 41; upto = 42; eot = 64; 11 | VAR f: Files.File; 12 | r: Files.Rider; 13 | ch: CHAR; 14 | sym: INTEGER; 15 | id: ARRAY 32 OF CHAR; 16 | idlen: INTEGER; 17 | ival: INTEGER; 18 | rval: REAL; 19 | error: BOOLEAN; 20 | 21 | PROCEDURE ReadCh; 22 | BEGIN 23 | IF r.eof THEN ch := 0X 24 | ELSE Files.Read(r, ch) 25 | END 26 | END ReadCh; 27 | 28 | PROCEDURE Get; 29 | VAR k: REAL; 30 | BEGIN 31 | WHILE (ch # 0X) & (ch <= " ") DO 32 | ReadCh 33 | END; 34 | 35 | IF r.eof THEN sym := eot 36 | ELSIF ch = "," THEN sym := comma; ReadCh 37 | ELSIF ch = "." THEN sym := period; ReadCh 38 | ELSIF ch = ";" THEN sym := semicol; ReadCh 39 | ELSIF ch = "+" THEN sym := plus; ReadCh 40 | ELSIF ch = "-" THEN sym := minus; ReadCh 41 | ELSIF ch = "&" THEN sym := and; ReadCh 42 | ELSIF ch = "~" THEN sym := not; ReadCh 43 | ELSIF ch = "(" THEN sym := lparen; ReadCh 44 | ELSIF ch = ")" THEN sym := rparen; ReadCh 45 | ELSIF ch = "[" THEN sym := lbrak; ReadCh 46 | ELSIF ch = "]" THEN sym := rbrak; ReadCh 47 | ELSIF ch = "{" THEN sym := lbrace; ReadCh 48 | ELSIF ch = "}" THEN sym := rbrace; ReadCh 49 | ELSIF ch = ":" THEN 50 | ReadCh; 51 | IF ch = "=" THEN sym := becomes; ReadCh 52 | ELSE sym := colon 53 | END 54 | ELSIF ("A" <= ch) & (ch <= "Z") OR ("a" <= ch) & (ch <= "z") THEN 55 | id[0] := ch; idlen := 1; ReadCh; 56 | WHILE ("A" <= ch) & (ch <= "Z") OR 57 | ("a" <= ch) & (ch <= "z") OR 58 | ("0" <= ch) & (ch <= "9") DO 59 | IF idlen < LEN(id) - 1 THEN 60 | id[idlen] := ch; 61 | INC(idlen) 62 | END; 63 | ReadCh 64 | END; 65 | id[idlen] := 0X; 66 | IF id = "MODULE" THEN sym := module 67 | ELSIF id = "IMPORT" THEN sym := import 68 | ELSIF id = "CONST" THEN sym := const 69 | ELSIF id = "VAR" THEN sym := var 70 | ELSIF id = "BEGIN" THEN sym := begin 71 | ELSIF id = "END" THEN sym := end 72 | ELSIF id = "IF" THEN sym := if 73 | ELSIF id = "THEN" THEN sym := then 74 | ELSIF id = "ELSE" THEN sym := else 75 | ELSIF id = "ELSIF" THEN sym := elsif 76 | ELSIF id = "WHILE" THEN sym := while 77 | ELSIF id = "DIV" THEN sym := div 78 | ELSIF id = "MOD" THEN sym := mod 79 | ELSIF id = "OR" THEN sym := or 80 | ELSE sym := ident 81 | END 82 | ELSIF ("0" <= ch) & (ch <= "9") THEN 83 | ival := 0; 84 | REPEAT 85 | ival := ival * 10 + ORD(ch) - ORD("0"); 86 | ReadCh 87 | UNTIL (ch < "0") OR (ch > "9"); 88 | (*UNTIL ~(("0" <= ch) & (ch <= "9"));*) 89 | 90 | IF ch = '.' THEN (* REAL или ".." *) 91 | ReadCh; 92 | IF ("0" <= ch) & (ch <= "9") THEN 93 | rval := ival; k := 0.1; 94 | REPEAT 32.51 + 9/1000 = 32.519 95 | rval := rval + (ORD(ch) - ORD("0")) * k; 96 | k := k * 0.1; 97 | ReadCh 98 | UNTIL (ch < "0") OR (ch > "9"); 99 | sym := real 100 | ELSIF ch = '.' THEN 101 | sym := int; 102 | ch := 7FX 103 | ELSE sym := null 104 | END 105 | END 106 | ELSIF ch = 7FX THEN sym := upto; ReadCh 107 | ELSE 108 | sym := null; 109 | ReadCh 110 | END 111 | END Get; 112 | 113 | PROCEDURE Mark(msg: ARRAY OF CHAR); 114 | BEGIN 115 | error := TRUE; 116 | 117 | Out.String("Ошибка на поз. "); 118 | Out.Int(SHORT(Files.Pos(r)), 0); 119 | Out.String(": "); Out.String(msg); 120 | Out.Char("."); Out.Ln 121 | END Mark; 122 | 123 | PROCEDURE Declarations; 124 | BEGIN 125 | (*Пусто*) 126 | END Declarations; 127 | 128 | PROCEDURE StatSeq; 129 | VAR name: ARRAY 32 OF CHAR; 130 | BEGIN 131 | WHILE (sym = ident) OR (sym = semicol) DO 132 | IF sym = ident THEN name := id; Get; 133 | IF sym = equ THEN Get; sym := becomes; Mark("Ожидается :=") END; 134 | IF sym = becomes THEN Get; 135 | IF sym = int THEN 136 | Out.String("Переменной "); Out.String(name); 137 | Out.String(" присвоено значение "); Out.Int(ival, 0); Out.Ln; 138 | Get 139 | ELSE Get; 140 | Mark("Можно присваивать только числа") 141 | END 142 | END 143 | ELSE Get 144 | END 145 | END 146 | END StatSeq; 147 | 148 | PROCEDURE Module; 149 | VAR name: ARRAY 32 OF CHAR; 150 | BEGIN 151 | IF sym = module THEN 152 | Get; 153 | IF sym = ident THEN name := id; Get 154 | ELSE Mark("Ожидается идентификатор"); name[0] := 0X 155 | END; 156 | IF sym = semicol THEN Get 157 | ELSE Mark("Ожидается точка с запятой") 158 | END; 159 | Declarations; 160 | IF sym = begin THEN Get; StatSeq END; 161 | IF sym = end THEN 162 | Get; 163 | IF sym = ident THEN 164 | IF name # id THEN Mark("Название модуля не совпадает") END; 165 | Get; 166 | IF sym # period THEN Mark("Нет точки в конце модуля") END 167 | END 168 | ELSE Mark("Ожидается END") 169 | END 170 | ELSE Mark("Ожидается модуль") 171 | END 172 | END Module; 173 | 174 | BEGIN 175 | f := Files.Old("Test.Mod"); 176 | IF f = NIL THEN 177 | Out.String("No file"); 178 | Out.Ln 179 | ELSE 180 | Files.Set(r, f, 0); 181 | ReadCh; 182 | Get; 183 | error := FALSE; 184 | Module; 185 | IF error THEN Out.String("Были ошибки."); Out.Ln END 186 | END 187 | END Moduel. 188 | 189 | Пример работы лексического анализатора (# обозначает литеру 7FX). 190 | x := {12..15} 191 | x := {12..#15} 192 | 193 | x ident (id="x",idlen=1) 194 | := becomes 195 | { lbrace 196 | 12 int (ival=12) 197 | .. upto 198 | 15 int (ival=15) 199 | } rbrace 200 | *) 201 | 202 | -------------------------------------------------------------------------------- /etc/docs/Parser_WorkOrder.txt: -------------------------------------------------------------------------------- 1 | MODULE Z; 2 | VAR x: INTEGER; 3 | BEGIN 4 | a := 4; 5 | b := a; 6 | Out.Ln; 7 | Out.Int(b, 5) 8 | END Z. 9 | 10 | Лексич. анализатор: (scanner) 11 | ReadCh 12 | Get 13 | 14 | Кодогенератор: 15 | Процедуры генерации машинного кода 16 | 17 | Символьная таблица: 18 | NewObj 19 | ThisObj 20 | 21 | Синтаксич. анализатор: (parser) 22 | Module 23 | Imports 24 | Declarations 25 | StatSeq 26 | Qualident 27 | Ident 28 | Selector 29 | Assignment 30 | Expression 31 | SimpleExpr 32 | Term 33 | Factor 34 | Generator.Assign(x, y) 35 | 36 | Qualident 37 | Ident 38 | Selector 39 | Assignment 40 | Expression 41 | SimpleExpr 42 | Term 43 | Factor 44 | Qualident 45 | Ident 46 | Selector 47 | 48 | Generator.Assign(x, y) 49 | 50 | 51 | StatSeq = Statement {";" Statement}. 52 | 53 | Statement = IfStatement | WhileStatement | Assignment | ProcedureCall. 54 | 55 | 56 | Scanner.Mod -> Scanner.o Scanner.sym 57 | Parser.Mod -> Parser.o Parser.sym 58 | 59 | -------------------------------------------------------------------------------- /etc/docs/Parser_and_Generator.txt: -------------------------------------------------------------------------------- 1 | VAR a, c: INTEGER; 2 | --- создан Object (name="a",class=Var,type=intType,val=8001200) 3 | --- создан Object (name="c",class=Var,type=intType,val=8001204) 4 | BEGIN 5 | 6 | op = + 7 | x y 8 | a := c + 5 9 | | | | 10 | | | '-Item(mode=Const,type=intType,val=5) 11 | | '-Item(mode=Var,type=intType,val=8001204) 12 | | 13 | | LDR R0, 8001204 14 | | ADD R0, R0, 5 15 | | ._____ _____, 16 | | v 17 | | Item(mode=Reg,type=intType,val=R0) 18 | | 19 | '-Item(mode=Var,type=intType,val=8001200) 20 | 21 | STR R0, 8001200 22 | 23 | 24 | LDR R0, 8001204 25 | ADD R0, R0, 5 26 | STR R0, 8001200 27 | 28 | mode бывает Const, Var и Reg (пока). 29 | 30 | 31 | intType - это такой Object 32 | charType - это такой Object 33 | (глобальные переменные в модуле SymTable) 34 | -------------------------------------------------------------------------------- /etc/docs/schemes/00_varChar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kekcleader/oberon/fef35a91fd6fb42b411a296e72e0afa7bb7149ce/etc/docs/schemes/00_varChar.png -------------------------------------------------------------------------------- /etc/docs/schemes/01_Bukva.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kekcleader/oberon/fef35a91fd6fb42b411a296e72e0afa7bb7149ce/etc/docs/schemes/01_Bukva.png -------------------------------------------------------------------------------- /etc/docs/schemes/02_MyProc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kekcleader/oberon/fef35a91fd6fb42b411a296e72e0afa7bb7149ce/etc/docs/schemes/02_MyProc.png -------------------------------------------------------------------------------- /etc/docs/schemes/03_Import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kekcleader/oberon/fef35a91fd6fb42b411a296e72e0afa7bb7149ce/etc/docs/schemes/03_Import.png -------------------------------------------------------------------------------- /etc/docs/schemes/src/00_varChar.xml: -------------------------------------------------------------------------------- 1 | 7Rzvd5s47K/Jx+0BBkI+5ufaW9vtrt1ud98IuAkbAQZkae6vPxtsMLZJaJpAuua9PoqFLGxJlmRZpAfGq6cPsR0tb0MX+j1NcZ96YNLTNFWxLPQPQ7Y5xLD0HLCIPZcglYB77z9IexLo2nNhUkFMw9BPvagKdMIggE5agdlxHG6qaI+hX31rZC+gALh3bF+E/u256TKHWlq/hF9Bb7Gkb1bNQf5kZVNkMpNkabvhhgGBaQ+M4zBM87vV0xj6mHmUL3m/Wc3TYmAxDNImHf4Y/zX4Ob+aONuJfvPF34B1ZL4DOZVftr8mEyaDTbeUA3G4DlyIiSg9MNosvRTeR7aDn26QzBFsma581FLRbZLG4Q84Dv0wRpAgDBDa6NHzfQrqaWBqzWazMY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+B9NJV/b6yf83D4+d3brqtp+pMgewk1/ZGSAyyvVGyXshqhrEaTBD2tLqVLVU1tVc0JPw5DzfIXGfPlVf6uJZj+Dw== -------------------------------------------------------------------------------- /etc/docs/schemes/src/01_Bukva.xml: -------------------------------------------------------------------------------- 1 | 7R1rl5o68Nf4cffwFPzoA7t79tFt6+1t+w0hq7QoFrCu99ffBBIMSXBZVHAr5/S4YTJ5zUxmJpOBdtTh4uVDaK/mD4EL/I4iuS8dddRRFFkyTfgHQbYpRDe1FDALPRcj7QBfvP8AaYmha88FUQ4xDgI/9lZ5oBMsl8CJczA7DINNHu058POjruwZ4ABfHNvnof96bjxPoaZi7OA3wJvNychyt5fWLGyCjFcSzW032FAg1eqowzAI4rS0eBkCHxGP0CVtNy6ozSYWgmVcpsHVg2v3zbvRRIqfwvhxa3z6/ONKSXv5Y/trvGA82XhLKBAG66ULUCdSRx1s5l4MvqxsB9VuIM8hbB4vfPgkw2IUh8EvMAz8IISQZbCEaINnz/cJqKOoljkej4cQjscGYQxeChclZ6SCMgaCBYjDLUTBDRQNUxeLl2zi582OWRqRpTnFKFXCQBsLyCzre0dDWMBkfANJ5XdOUlnPU5QnKNzFPEE14wgE7d8MPm2+Oo71czN4ubvrT24H4Mrg6AdcuEfxYxDG82AWLG3f2kEHeQrvcO6DYIXp+hPE8RYrHHsdB3mqQ2KF22+o/XVP6RHAd9xh8jB6yT1t6acnEHpw9SDEwAImQGVmhzMQ71l9N8VDS97LvRD4duz9yastES9w06fAg1PZcd1gNlKXYWcUrEMH4Fa0mnmlI4XdaOmKuY4S0cjWU11aZK0JcXkOlvHYXng+WvUQksqDrFekR7DJyVJOjq5luI9qlSWytU8tTJnNwzLQKycCvCyZ+/spkMmjiZJAk3d9SODBKgSwOEPFj9OfyO/AFdMQzQJXOb4dRbCDpK10A2w3e5CEDZb2AmQoEPh7jZyDQa7Et4LzI4269gJZj+U0Qn/Eg8Tb1W6Qx9t7ggRRqGUdZrMY8+TqwHQ1zpbBGlOZ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qtJy5oQPWcLtX22MIW0FrHiFXfzFlFvLWKx6tHlI1lEtqPaLSKfH/PwcfTPvQVhDx1Rssrk+xOqxHmyxIdG2W4i7K8oC06yO2o/ayNCG1gfbh95MJsPk3SFxuxjDaR+4xtZj6jq4ZqT1pMd02IUSjmLM1peKA2N1yGmYFP0uofrEF27mzwMJ0vvriv9uDd/T4P+01UjCRnZq3HytSRngO8JQDayL2Mc/fU4IQWMkmrryLkgctUQJ9dRya9qVNBHQnq1qSBcKohsqtw2PtUF6T4Zbu9H+UwQmdjPGqJgQt4cM9H9KxUHU3jkgvzWai/LmJIkKZIsGKZNcK33nRmxWJ3fG++FZK47hb2qadVr+zaQmKW8p3+xlxlFrGhMi5fIC2vP2ofGJdWKZ+23xiXZCZMvEhbGDdk45hvxiVNSdt0M/sFxSaFIk71yyZ48azkEZr1WRz57O+wy04bLftjx1Y7qPhSTrXPJe4lNG1YEAfJ6N1P7HYnCtOE6P/Ih/KQxzxt0IdWzyHWV3DH7SVlPfvvk0gr+JgdOBDSTQnaZZSa/4zzOiNxzpY9q8puOMkgwVeqCLIUPSbcaBRzhyeB+DHKhBtEk6nJtRM1ZJ/3QnacNNaq5RS0tXfiYjDKm+jd3q94NZCYIXQoukaVlEHqqNKaZn56J145+FY5KQ2pQC18j5ohP3zMO8nNL2THM41tkOTq1cAWPlatK7it7WVqPRjWneqOZq2Q99Km59VmRQM0NjqT00DxTGHYbeeFJandsytrq1CQ1jpJqniB9Djnrc5ivyqQ35dH4fV6oHPaxdsboCD4troouVFj/oIReg4+7L+unjsPu/ydQrf8B -------------------------------------------------------------------------------- /etc/docs/schemes/src/02_MyProc.xml: -------------------------------------------------------------------------------- 1 | 7R1rd5u48tf4bPuhOSDeH/1Kk9Pmsanbu3e/YazYdLHxAqnj++uvBAgLSdiY2MKNfU6PC8MgJM1TMyOlo/Xnr58jdzm7Cycw6ABl8trRBh0AVMW20X8Yss4ghq1ngGnkT3KkDeCb/z9I3syhL/4ExiXEJAyDxF+WgV64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JEAtve1S7GxRTQPq870U0id9HRDOojHtfBg5DqAY1iIQpvcO9WmDkqfsLY3qbdHIgHrdol4ckD4g+PVZsrzJsLyumBzLFwkamudZi3M4nhekZ9BUdJErgv++CvyDIjYoM1MGJBIAChYpVBwocyStHjcaFa/e04MEssCsxP3sp8QXmlPiC5Ucxr+LL4C9N1+g2yjEymdjzNGQZ3fhBGKM/wM= -------------------------------------------------------------------------------- /etc/docs/schemes/src/03_Import.xml: -------------------------------------------------------------------------------- 1 | 7V1pc6M4Gv41ruqZqrjEDR9j4nS7unNsJ9Mzu1+2CCYxPdh4MG4n++tXAsQhCYwxCCemq8sBIQnEe+h5D4mRZC5fPwfWenHjzx1vJIL560i6GomiAHQd/kElb3GJKilxwUvgzpNKWcGD+z8Ht0xKt+7c2RQqhr7vhe66WGj7q5Vjh4UyKwj8XbHas+8V77q2Xhyq4MG2PLr0T3ceLuJSXdSy8i+O+7LAdxZUI76ytHDlZCSbhTX3d7kiaTqSzMD3w/ho+Wo6Hnp5+L3E7a5LrqYPFjirsE6Dyy+Tf+1+2Pb0527y+vXr5eNs4lwkw9iEb3jAzhyOPzn1g3Dhv/gry5tmpZPA367mDuoVwLOszjffX8NCARb+dMLwLSGmtQ19WLQIl15yFT5w8PYXaj82RAMX/DvpMDq5ei2cveXP7p3AXTqhEySF9IvAjGIFL05YMXo1roeGnGuYvL7Pjg/vErzBCoHjWaH7q8gSVsJZL2m9tOm978JHEQGWAi1hgUQGBBUUu9j428B2klZ5Eu7pSARER/GIqY7gQW48WVHEIQdwiyD3wS7P/iq8tpauh0ZtwlflQtKL4NbZVRG/a6KKapEWRj1S0DTVq/sp4Y3WSBrf7ZflbZM3MRJVD77KyTpw4OELOrx7+ol0a3LhKUBPkVyyPWuzgR1EbcEXx5qnJ4DZYGUtnbQKLPxnixTgpHBEt4LPhxup1nKN+nnaoD/sm4Rv6+wmt7NvuBKskhsWxcxFVt0t3NB5WFs2urqD0xvBlq7nmb7nB1Fbaa44+lyG5Zsw8P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zZl3c/WNO7y5o4X7PbniKEAxyldLGkAkBlvkt7WPSpt9vzLfthSdm3FqUOdapohEUVbWmC8iorsj5vL1pmMkLH2OV53HyqZLUZOxP384EC08DHyUfZiSE72Zx488dVOP/ -------------------------------------------------------------------------------- /etc/docs/schemes/src/README.md: -------------------------------------------------------------------------------- 1 | *English text below* 2 | 3 | # Как редактировать схемы 4 | XML-файлы можно редактировать с помощью данного веб-редактора схем: 5 | https://www.diagrameditor.com/ 6 | 7 | Затем их можно экспортировать в формате PNG в масштабе 300% и толщину рамки в 50 единиц. 8 | 9 | # How to edit the schemes 10 | The XML files can be edited using this web-based scheme editor: 11 | https://www.diagrameditor.com/ 12 | 13 | Then they can be exported as PNG using 300% zoom and a border width of 50. 14 | --------------------------------------------------------------------------------