UKOOPSPILKA HIGHER EDUCATIONAL INSTITUTION “POLTAVA UNIVERSITY OF ECONOMICS AND TRADE”

EDUCATIONAL AND SCIENTIFIC INSTITUTE OF BUSINESS AND MODERN TECHNOLOGIES

FORM OF EDUCATION FULL-TIME DEPARTMENT OF MATHEMATICAL MODELING AND SOCIAL INFORMATICS

Allowed for protection

Head of Department ______Iemets Oleg (signature) «______»______2021

EXPLANATORY NOTE TO BACHELOR'S WORK

on the topic DEVELOPMENT OF SOFTWARE FOR THE SIMULATOR ON THE TOPIC "ALGORITHM FOR CONDUCTING THE LEFT FACTORIZATION OF GRAMMAR" OF THE DISTANCE LEARNING COURSE "PROGRAMMING THEORY"

in the specialty 122 "Computer Science"

Executor of work Darboe Amadou ______«___»______2021 (signature) Supervisor Ph.D., Assoc. Chernenko Oksana ______«___»______2021 (signature)

POLTAVA 2021 2

CONTENT LIST OF SYMBOLS, SYMBOLS, UNITS, ABBREVIATIONS, TERMS ...... 3 INTRODUCTION ...... 4 1. STATEMENT OF THE PROBLEM ...... 6 2. INFORMATION REVIEW ...... 8 2.1. The purposes of distance learning ...... 8 2.2. Learning management systems ...... 11 3. THEORETICAL PART ...... 20 3.1. Review of material on the topic of work ...... 20 3.2. Algorithmization of the problem on the topic of work ...... 24 3.3. Justification of the choice of software for the implementation of the task ...... 29 4. PRACTICAL PART ...... 32 4.1. Development of a block diagram to be programmed ...... 32 4.2. Description of software implementation ...... 34 4.3. Description of the program ...... 39 CONCLUSIONS ...... 46 REFERENCES ...... 48

APPENDIX A. PROGRAM CODE ...... 50

3 LIST OF SYMBOLS, SYMBOLS, UNITS, ABBREVIATIONS, TERMS Symbols, symbols, abbreviations, Explanation of symbols, abbreviations, terms symbols A non-terminal AA  product

4 INTRODUCTION

Topicality. In today's world of Internet technology, many aspects of our lives are being networked, accelerating the development of the information society and overcoming geographical barriers. An important element in education is distance learning, namely distance learning. The extent and method of using computer technology in the preparation of a distance course significantly affects the effectiveness of its application. World experience shows that the use of dynamic objects to create visual models of processes, adaptive modeling of the student in many cases significantly increases the learning effect. To organize a truly effective initial process of distance learning requires systematic work with the shell of the student and the teacher almost every day throughout the training period. An important task in teaching is the clarity of solving, solving certain tasks (tasks, problems). This can be solved through the development and implementation of distance learning simulators. In view of this, it can be noted that the software implementation of simulators is a very important area of development and research. In fact, distance learning in practice realizes what the traditional school seeks to do: to provide equal and comprehensive access to knowledge, to reveal abilities and talents, to instill the necessary skills and qualities. If we add to this the possibility of introducing all modern communication tools, innovative methods and advanced developments, we get the same form that can truly prepare a student, to give relevant and modern knowledge and skills. The purpose of the work is software implementation of the simulator on the topic "Algorithm for conducting the left factorization of grammar " of the distance course "Programming Theory". The object of development is the process of distance learning in mathematical disciplines. 5 The subject of development - a software product that implements a simulator on the topic of "Algorithm for conducting the left factorization of grammar" in the Java programming language. The list of methods used are the left factorization of grammar, the NetBeans IDE visual development environment and the object-oriented Java programming language. The work consists of four sections. In the first section the problem statement is considered. The second section describes the purposes of distance learning and learning management systems. The third section describes review of material on the topic of work, algorithmization of the problem on the topic of work, justification of the choice of software for the implementation of the task. In the fourth section - the description of development of a block diagram to be programmed, software implementation, the program. Volume of explanatory note: 54 pages, incl. main part - 42 pages, appendices - 1 page, sources - 11 titles.

6 1. STATEMENT OF THE PROBLEM

For the distance course "Programming Theory" you need to develop a simulator. The main tasks of the work:  describe the problem statement;  describe an overview of the purposes of distance learning and learning management systems;  give the basic concepts of the topic for use in the simulator;  develop an algorithm for the simulator and make a block diagram;  describe the programming language and technologies used in developing the program;  describe the process of implementation of the main stages of creating a simulator;  describe the instruction required by the user. The initial window should display the following information about the simulator:  topic;  surname, initials of the student;  academic group of the student. The following issues should be covered in the simulator according to the topic: 1. Recursive descent. 2. Algorithm of deleting of left recursion. 3. Left factorization. Before passing the simulator, the user should be given the opportunity to review the theoretical material on these issues. If the answer to the practical task is incorrect, a warning about the error should be displayed first, and only then an explanation of this error. Problems to solve: 7 Example 1. The grammar for arithmetic expressions with products: EET | T , TTF| F , FE  |id . After removing recursion from products for E and T, we obtain: E TE, E   TE  | , T FT,* T  FT | , FE  |id . Example 2. Consider grammar with products: S A b;

A Ac Sd  . Non-terminal S is left-recursive, thus S Aa Sda, but this recursion is not immediate. Example 3. If we have two products stmt if expr then stmt else stmt

if exp then stmt , then after being in the if input stream if , we cannot immediately select any of them. Example 4. Consider the grammar of nominal operators G  a,,,,,,,, b if then else  E S P S  with products ( i,, t e mean if,,, then else E i S correspondexp and stmt ):

S iEtS iEtSeS a Eb . After left factorization, the grammar will look like this: S iEtSS a,, S  eS E  b

8 2. INFORMATION REVIEW

2.1. The purposes of distance learning

The main goal of distance education is to overcome barriers of place and time. Learners may live in isolated, less‐populated and nonurban, rural areas and have no access to education. Other learners may have ready access to a private school or college but that college might not offer the course of study needed by that learner. Distance learning allows education to reach those who are not able to physically attend courses in universities. One of the most important purposes of distance education is to provide an opportunity of education, often on an individual basis, to learners who are not physically present in a classroom. Also, it provides equity in educational opportunities by allowing access to quality education for those who otherwise would have been denied. The aim of distance education is to provide a strong communication between students and lecturers. That's why there are also disadvantages as well as advantages of distance education. The main advantage of distance learning is that the students can study wherever, whenever, and whatever he/she wants. So, it can be said that flexibility is the most important advantage of distance learning. The other advantages of distance learning are as follows:  The students have the convenience of course materials being delivered to his/her home or office.  Students may gain useful, transferable skills, such as planning and research.  Students can make their feedback easily.  There is no waste of time in transport.  Accessing students without face‐to‐face learning opportunities.  Distance learning provides just‐in‐time learning. 9  Distance learning is associated with technology more than face‐to‐face learning.  Distance education can reach a wider audience.  Distance learning can facilitate greater learner‐instructor interaction.  Distance learning can equalize access to education.  Distance learning makes information and lecture notes open to everyone.  Distance learning minimizes the costs of stationery.  Distance learning increases the effectiveness of education through the use of items such as sound and image. Although distance learning has numerous benefits, it has some disadvantages that are listed as follows:  There is a lack of eye contact between the students and the lecturers.  It can be occasional Internet provider downtime.  Student must be more active in education environment.  The cost of developing course materials is too much, and it is needed more time to prepare course materials.  There is unconsciousness in the use of educational technology.  Distance learning is not suitable for undisciplined learners or inflexible instructors.  Laboratory and experimental courses cannot be given remotely.  Students who have little technological knowledge cannot follow the courses.  Students and instructors need to take technical training and support.  Some of the students cannot access the necessary facilities, such as computers, Internet, etc. In general, distance education is collected under two main headings: 10 1. Synchronous 2. Asynchronous Synchronous learning requires all students to participate the classes at the same time. The method of delivery is usually interactive and includes Internet chat sessions, teleconferences, telecourses, and web conferencing. Synchronous distance education is less flexible than asynchronous distance education because synchronous distance education requires all enrolled students and the teacher to be online at a specific time. Asynchronous instructions do not require simultaneous participation of all students in the class, so it is more flexible. Asynchronous instruction gives students the freedom to interact with the material and instructor at a time that is convenient for them. Internet‐based distance education has become a specific focus for at least three reasons according to the Institute for Higher Education Policy (IHEP): First, Internet is quickly becoming the predominant technology in distance education, because of its increasing telecommunications bandwidth capabilities. Second, Internet‐based distance education especially asynchronous instruction mode allows the teaching and the learning processes to occur “at any time and any place.” Provision of the interactive learning activities at any time and any place has become the most important characteristic of this technology. Third, Internet‐based distance education is, in many ways, fundamentally different from traditional classroom‐based education [2]. Internet‐based distance education must have the following features:  The identification and management of users  Preparation of online course contents  Managing courses  Monitoring and analyzing student behaviors  Assessment of students’ achievement status  The creation and management of interactive communication media

11 2.2. Learning management systems

Computers and computer networks are rapidly becoming the preferred long‐distance communication tool, and they are evolving as a major resource in distance education. ATutor ATutor has blog, forum, photo gallery, glossary, site map, chat, directory, tests and surveys, and MyTracker tool, which tracks users’ navigational patterns. It supports Sharable Content Object Reference Model (SCORM) standards and Instructional Management Systems (IMS) packets. It is available in more than 20 languages. Some video conference softwares such as Adobe Connect, BigBlueButton, and OpenMeetings modules can be integrated in ATutor. Figure 2.1 shows web page for an ATutor course.

Figure 2.1 – ATutor Course Web Page.

Blackboard The idea behind the Blackboard Learning System is to let teachers deliver course content, especially adjusted to large courses at lower levels. The role of 12 an administrator of the system is limited to conducting basic operations such as initial course and teacher registration. The administrator is not overly dependent on it as many course management tasks, such as student and course content registration or tests and statistics check, can be carried out by a teacher. The system consists of many communication and discussion features enabling active participation of students. The possibility of the use of multimedia, an instructional option, is willingly utilized by teachers. Figure 2.2 shows the web page for a Blackboard course.

Figure 2.2 – Blackboard Course Web Page.

Claroline Claroline is an open‐source e‐learning and e‐working platform. It can work on both Windows and server systems. Claroline provides the ability to manage public education activities on the web and to create effective online courses. There is a large community of users and software developers worldwide. Claroline has rich interaction tools such as chat, forum, and wiki, but there is no survey functionality and whiteboard application. It does not require any programming skills to install, manage, and use. It supports SCORM standards. 13 Claroline allows user lists to be created and user statistics to be seen. User groups can be created in courses. Figure 2.3 shows a web page from Claroline.

Figure 2.3 – Claroline Course Web Page.

Desire2Learn Desire2Learn is a commercial educational system that supports mobile learning and web conferencing. It also has some features such as exams, discussions, assignments, quizzes, grades, and portfolio‐based activities. D2L supports foreign languages and mathematical notations. D2L also includes a learning repository, course creation tools, an e‐portfolio module, mobile delivery, analytics, and lecture capture facilities. Figure 2.4 presents web page of Desire2Learn.

Docebo Docebo LMS platform is a learning management system that is based on SaaS/cloud platform. With Docebo, users can organize, track, and distribute online courses for formal learning. The instructors can create users as well as groups and create reports about them. It was offered as open source but it is not available as open source for a while. Although Docebo is offered for education, now it is primarily used in the corporate sector. 14 Docebo is available in more than 30 languages and more than 10 countries. This platform is mobile‐ready platform, so it includes mobile learning. The features of Docebo are blogs, course catalogs, labels, and discussions. Figure 2.5 shows a course web page from Docebo.

Figure 2.4 – Desire2Learn Course Web Page.

Figure 2.5 – Docebo Course Web Page. 15 Dokeos Dokeos is an online and open‐source course management system that is widely known and freely available. It is also a learning content management system based on MySQL database and written in PHP language. Dokeos is based on Drupal, which is a content management system. It is available in standard and Professional (PRO) versions. Dokeos supports mobile and cloud learning. Also, it supports SCORM, AICC and Tin Can API compliant. Portals and assessments can be used in Dokeos system; on the other hand, it has agenda, forums, discussion forums, chat, videoconference, open questions, and assignments. It is fully compatible across all browsers and platforms. Web page of Dokeos is presented in Figure 2.6.

Figure 2.6 – Dokeos Course Web Page.

eFront eFront is a modern learning, which is also known as a course management system or learning management systems or virtual learning environment, and an educational platform. eFront is designed to help creating online courses. It has 16 many features such as project management, extended statistics, files management, reports generators, assignments builders, internal messaging system, forum, calendar, chat, survey, etc. It supports SCORM standards. eFront is content friendly by using presentations and videos. It has multiple types of test and questions. This course management system can collect and analyze surveys. It supports the blended learning. Some video conference software such as Adobe Connect, BigBlueButton, and OpenMeetings can be used with eFront. A sample course page is given in Figure 2.7.

Figure 2.7 – eFront Course Web Page.

Moodle Moodle is an online course management system that is widely known and freely available. The word Moodle stands for “Modular Object Oriented Dynamic Learning Environment” and was created by Martin Dougiamas who is a computer scientist and an educator at a university in Perth, Australia. Moodle is a software package that it is used to create Internet‐based A number of programs, namely PHP, which is a script language embedded into html codes that work in a server‐side; MySQL, which is a database management system that can run in the background and can respond to 17 requests, such as a high‐performance web server; and Apache, which is an open‐source software web server that is completely free and has a high performance, are required before the Moodle program is set up. Moodle supports mobile learning, so it has its own Moodle Mobile application. Moodle Mobile supports currently 15 languages. It has responsive design for phones and tablets. Users can download and view some course resources. A course web page from Moodle is presented in Figure 2.8.

Figure 2.8 – Moodle Course Web Page.

OLAT OLAT is multilingual and available in fifteen languages. OLAT runs on , Linux, OpenBSD, FreeBSD, Windows, and Mac OS X operating systems. Java SDK, Apache as a web server, Tomcat Servlet Engine as an application server, and MySQL or PostgreSQL as database are required to install OLAT. It 18 supports SCORM, IMS Content Packaging, and OTI standards. A main web page of OLAT is displayed in Figure 2.9.

Figure 2.9 – OLAT Course Web Page.

Sakai has forums, chat rooms, message center, assignments, grade book, discussions, syllabus, wikis, and WebDAV. It is designed to present mathematical notation such that it can display LaTeX equations on most pages. Sakai is under the Educational Community License (ECL). It is available in more than 20 languages. Some video conference software such as Adobe Connect, BigBlueButton, Kaltura, and OpenMeetings can be integrated in Sakai, and it has IMS Learning Tools Interoperability (LTI) standards. Figure 2.10 shows a sample web page for a course from Sakai [2]. 19

Figure 2.10 – Sakai Course Web Page.

20 3. THEORETICAL PART

3.1. Review of material on the topic of work

1. Recursive descent. Algorithm of deleting of left recursion. Recursion is one of the fundamental programming methods. While program creating, it is often necessary to reduce the initial tasks to simpler ones. The method of reducing a task to itself, but with modified initial data, is called recursion. Factorial nn! 1  2  3 comes to calculating the product of the integers from 1 to n: 0! 1, 1!  1, 4!  1  2  3  4  24 . Such a product easy to calculate by cyclic constructs, for example, cycle operator. However, n! is equal to multiplied on the product from 1 ton 1 or n! ( n  1)!  n , 0!  1, by purpose 4! 3!  4, 6!  5!  6 . In this case, the defined concept is described through itself n and through a simple concept (n  1)! . To find , you need to use the factorial function to the number , then to n  2 etc. till to 1. This means that such a factorial definition is recursive. Content and power of recursive definition, and its main purpose is that it allows to define infinite set of objects by a finite expression. Applications in which recursive procedure are used, differ by simplicity, clarity and completeness of the text as a recursive procedure decree, what should be done and more non-recursive focuses on how to do. However, because of this simplicity using of RAM memory becomes more higher, since each recursive call for local variables and also for parameters of the procedure are passed by value, gives of a new cells. Recursive descent - an algorithm of parsing, based on mutually recursive procedures (or not recursive equivalents), each of which implements one of the products of grammar. 21 Recursive descent parsing hides the risk of looping. It is possible, if the product looks like -> , because of non- terminal left-recursive. Left-recursive is non-terminal A if we have a product AA  in the grammar. If the algorithm selects these products, then since the right part starts with , the procedure for the non-terminal with will cause again. Current character that manages the process of parsing can change, if it found a match to the original terminal in the right side of the product. In this case, the product starts with a non-terminal and the current symbol remains unchanged, which causes looping [3]. Left recursion can be eliminated by rewriting of dangerous product. Left-recursive couple of products |  could be substitute by nonleft-recursive products AA  , AA   , (3.1) where α and β are chains of terminals and non-terminals, which don’t start from A, A' – new non-terminal. Products of type (3.1) is called right-recursive[4]. Example 1. The grammar for arithmetic expressions with products: EET | T , TTF| F , FE  |id . After removing recursion from products for E and T, we obtain: E TE, E   TE  | , T FT,* T  FT | , FE  |id . 22 It doesn’t matter what the total number of A -products. We can remove directly left recursion from them using this technology. We first group A - products:

AAAA 1  2 mn  1  , where βi does not begin with A . Then we replace these A -products with

AAAA 12   n  , AAAA12    m   . (3.2) Non-terminal A generates the same lines as before, but now there is no left recursion. This procedure removes all immediate left recursion, but does not delete left recursion that involves two or more steps of generation. Example 2. Consider grammar with products: S A b;

A Ac Sd  . Non-terminal S is left-recursive, thus S Aa Sda, but this recursion is not immediate. The following algorithm allows you to remove all left grammar recursions[5].

Algorithm 1 Removing of left recursion

Step 1. Arrange the non-terminals in random order AAA12,,, n . Step 2. for i :1 to n do begin for j :1 to i 1 do begin

To substitute all products that look like AAij  , with a products

Aij  2    ,where Aj  2  , are all current, Aj products.

To remove left recursion among A i - products by formulas (3.2) end' 23 Justification of the algorithm ability to work is based on the fact that after the i 1 iteration of the outer loop for step 2 for any product form

Akl A a, k i should be lk . As a result, in the next iteration of the inner cycle (by j), the lower boundary m of all products of Aim A a, is subsequently increased until it is reach mi . Then, removing the immediate left recursion for

Ai -products, we obtain mi . This algorithm is guaranteed working with grammars that do not have cycles (products of type AA ) and ε- products (products of type A  ). As cycles ε-products, can be removed previously by formulas. 2. Recursive descent. Algorithm of deleting of left recursion. Left factorization is called transformation grammar in a form suitable for predictive analysis. The basic idea of the left factorization lays in when it is unclear which of the two alternative products you need to use to deploy a non-terminal A, it is necessary to redesign the A-products in way to delay the decision until when enough of characters are read from the input stream to make the right choice. Example 3. If we have two products stmt if expr then stmt else stmt

if exp then stmt , then after being in the if input stream if , we cannot immediately select any of them.

In the general case, if A 12  - two A -products and the input stream starts from a non-empty line derived from α , we cannot say whether the first or second products will be used. However, you can delay the solution by extending A to αA'. In this case, after considering the input stream that output from α, we work with A', extending it to β1 or to β2. Thus, left-factorized products come into:

AAA,. 12  24 Algorithm 2 Left factorization of grammar Step 1. For each nonterminal A you need to find longest prefix α, common for two or more of its alternatives. Step 2. If a   , that is, there is a non-trivial common prefix, we replace all A -products A 12  n  , where γ represents all alternatives which doesn’t start from α , products (A' is the new non-terminal ):

AA , A  12  n Step 3. Re-apply this transformation until no one of two alternatives will have a common prefix. Example 4. Consider the grammar of nominal operators G  a,,,,,,,, b if then else  E S P S  with products ( i,, t e mean if,,, then else E i S correspondexp and stmt ):

S iEtS iEtSeS a Eb . After left factorization, the grammar will look like this [4]: S iEtSS a,, S  eS E  b

3.2. Algorithmization of the problem on the topic of work

Step 1. The user is given the task: “Recursion is one of the fundamental programming methods. While program creating, it is often necessary to reduce the initial tasks to simpler ones. The method of reducing a task to itself, but with modified initial data, is called”. Answer options are provided:  recursion  recursive descent  left factorization 25 If the answer is correct, i.e. the first option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 2. The user is given the task: “Recursive descent is”. Answer options are provided:  a procedure, based on mutually not recursive equivalents, each of which implements one of the products of grammar  an algorithm of parsing, based on recursive, each of which implements one of the products of grammar  an algorithm of parsing, based on mutually recursive procedures (or not recursive equivalents), each of which implements one of the products of grammar If the answer is correct, i.e. the third option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 3. The user is given the task: “Left-recursive is non-terminal A if we have”. Answer options are provided:  a product AA  in the grammar  a product AA in the grammar  a product A  in the grammar If the answer is correct, i.e. the first option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 4. The user is given the task: “Left-recursive couple of products |  could be substitute by nonleft-recursive products ______, where α and β are chains of terminals and non-terminals, which don’t start from A, A' – new non-terminal”. Answer options are provided:  AA  , AA   , AA|  AA  , 26 If the answer is correct, i.e. the second option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 5. The user is given the task: “Products of type AA   ,

AA| is called”. Answer options are provided:  left-recursive  right-recursive  non-recursive If the answer is correct, i.e. the first option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 6. The user is given the task: “The grammar for arithmetic expressions with products: EET | T , TTF| F , FE  |id . After removing recursion from products for E and T, we obtain:”. Fill in the blanks: EE__,___ | , TT___, ___ | , F  ___ |id . If the answer is correct, i.e. E TE, E   TE  | , T FT,* T  FT | , FE  | . then there is a transition to the next step. If not, an error message is displayed. Step 7. The user is given the task: “Consider grammar with products: S A b;

A Ac Sd  . 27 Non-terminal S is ______, thus S Aa Sda, but this recursion is not immediate.”. Answer options are provided:  non-recursive  right-recursive  left-recursive If the answer is correct, i.e. the third option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 8. The user is given the task: “The following algorithm allows you to remove all left grammar recursions. Algorithm 1. Removing of left recursion – ”. Specify the correct sequence:

Step 1. Arrange the non-terminals in random order AAA12,,, n . Step 2.

 for j :1 to i 1 do begin

 for i :1 to n do begin

 To remove left recursion among Ai - products by formulas

 AAAA 12   n  , AAAA12    m    end

 To substitute all products that look like AAij  , with a products

Aij  2    , where Aj  2  , are all current, Aj products.  end

If the answer is correct, i.e. Step 1. Arrange the non-terminals in random order . Step 2. i :1 to n do 28 for j :1 to i 1 do begin

To substitute all products that look like AAij  , with a products

Aij  2    ,where Aj  2  , are all current, Aj products. end

To remove left recursion among A i - products by formulas

AAAA 12   n  , AAAA12    m   end then there is a transition to the next step. If not, an error message is displayed. Step 9. The user is given the task: “Left factorization is called:”. Answer options are provided:  grammar in a form suitable for predictive analysis  transformation grammar in a form suitable for predictive analysis  transformation grammar in a form not suitable for predictive analysis If the answer is correct, i.e. the second option is selected, then there is a transition to the next step. If not, an error message is displayed. Step 10. The user is given the task: “Algorithm 2. Left factorization of grammar ”. Specify the correct sequence:  If a   , that is, there is a non-trivial common prefix, we replace

all A -products A 12  n  , where γ represents all alternatives which doesn’t start from α , products (A' is the new non-terminal ):

 AA  , A  12  n  For each nonterminal A you need to find longest prefix α, common for two or more of its alternatives.  Re-apply this transformation until no one of two alternatives will have a common prefix. If the answer is correct, i.e. 29 Step 1. For each nonterminal A you need to find longest prefix α, common for two or more of its alternatives. Step 2. If a   , that is, there is a non-trivial common prefix, we replace all A -products A 12  n  , where γ represents all alternatives which doesn’t start from α , products (A' is the new non-terminal ):

AA , A  12  n Step 3. Re-apply this transformation until no one of two alternatives will have a common prefix. then there is a transition to the next step. If not, an error message is displayed. Step 11. The user is given the task: “Consider the grammar of nominal operators G  a,,,,,,,, b if then else  E S P S  with products ( i,, t e mean if,,, then else E i S correspondexp and stmt ):

S iEtS iEtSeS a Eb . After left factorization, the grammar will look like this:”. Fill in the blanks: S______a , S  _____ , E  ___ If the answer is correct, i.e. S iEtSS a,, S  eS E  b then a completion message is displayed. If not, an error message is displayed.

3.3. Justification of the choice of software for the implementation of the task

Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run 30 on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client- server web applications, with a reported 9 million developers. Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle) and released in 1995 as a core component of Sun Microsystems' Java platform. The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of the Java Community Process, Sun had relicensed most of its Java technologies under the GNU General Public License. Oracle offers its own HotSpot Java Virtual Machine, however the official reference implementation is the OpenJDK JVM which is free open source software and used by most developers and is the default JVM for almost all Linux distributions. As of March 2021, the latest version is Java 16, with Java 11, a currently supported long-term support (LTS) version, released on September 25, 2018. Oracle released the last zero-cost public update for the legacy version Java 8 LTS in January 2019 for commercial use, although it will otherwise still support Java 8 with public updates for personal use indefinitely. Other vendors have begun to offer zero-cost builds of OpenJDK 8 and 11 that are still receiving security and other upgrades [9]. NetBeans IDE is the official IDE for Java 8. With its editors, code analyzers, and converters, you can quickly and smoothly upgrade your 31 applications to use new Java 8 language constructs, such as lambdas, functional operations, and method references. Batch analyzers and converters are provided to search through multiple applications at the same time, matching patterns for conversion to new Java 8 language constructs. With its constantly improving Java Editor, many rich features and an extensive range of tools, templates and samples, NetBeans IDE sets the standard for developing with cutting edge technologies out of the box [10].

32 4. PRACTICAL PART

4.1. Development of a block diagram to be programmed

Figure 4.1 shows a block diagram of the algorithm of the simulator. Figure 4.2 shows a block diagram output error. Figure 4.3 shows a block diagram of the program operation. Figure 4.4 shows a block diagram of the next action of the program.

Begin

Output of the simulator topic, other information

Output of the problem and its solution

Providing a solution

yes Is the answer correct? Go to the next step

no

Output of the yes Output The last step? corresponding error the result

no

End

Figure 4.1 - Block diagram of the algorithm of the simulator

33

Begin

Output of the Was the mistake yes warning about the made the first time? error no

Output of an explanation of this error

End

Figure 4.2 - Block diagram output error

Begin

Output of the main page

Open theoretical no no Open practical tasks? material?

yes yes

Output theoretical Output first task material

Solving the problem and choosing the next action

Next action

End

Figure 4.3 - Block diagram of the program operation 34

Begin

yes Has the last task yes The next task? Output result been completed?

no no

Output the next task

yes yes The previous task? Is the first task open?

no no

Output the previous task

End

Figure 4.4 - Block diagram of the next action of the program

4.2. Description of software implementation

The program was created on the basis of a Java applet. Therefore, JFrame is used to display it and its name, dimensions and some properties are specified. import javax.swing.JFrame; public class Regular_languages { public static void main(String[] args) { JFrame frame = new JFrame("Simulator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applet = new JApplet(); frame.getContentPane().add(applet); applet.init(); applet.start(); frame.pack(); frame.setSize(650, 540); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); } }

35 First, the necessary elements were added to the panel and brought to the desired appearance (Fig. 4.5). In this case, NetBeans automatically generates code to add all elements of the program.

Figure 4.5 – Main page

// Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; // End of variables declaration

The following class libraries are used in program development: import java.awt.CardLayout; import java.awt.Desktop; import java.io.BufferedInputStream; import java.io.File; 36 import java.io.FileOutputStream; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane;

An int step variable was created to determine the current step with the task. Immediately it is assigned a value of 1, ie the first step. As at the wrong answer at first the warning, and only then the hint is specified variable int error is created. The value is set to 0. int step = 1; int error = 0;

Auxiliary functions for step-by-step transition were implemented. The void nextStep () function displays the next task via CardLayout. In this case, the variable step is increased by 1, the error is set to 0. If the last step (11), then a message is displayed about the shutdown of the simulator using JOptionPane.showMessageDialog. private void nextStep() { step++; if(step > 11) { JOptionPane.showMessageDialog(jPanel1, "The simulator is complited!!!", "Finish", JOptionPane.PLAIN_MESSAGE); } else { jLabel8.setVisible(false); error = 0; CardLayout cl =(CardLayout) jPanel4.getLayout(); cl.show(jPanel4, "step"+step); } } 37

The void prevStep () function, on the other hand, reduces step by 1 and displays the previous task. The error is also set to 0. private void prevStep() { step--; jLabel8.setVisible(false); error = 0; CardLayout cl =(CardLayout) jPanel4.getLayout(); cl.show(jPanel4, "step"+step); }

Reading and writing to a file is used to open the theoretical material in a separate file: BufferedInputStream and FileOutputStream. The file is opened using Desktop.getDesktop().open(file) (see Appendix A). private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { BufferedInputStream in = null; FileOutputStream fout = null; try { in = new BufferedInputStream(getClass().getResource("Theoretical.pdf").openStream()); fout = new FileOutputStream("Theoretical.pdf"); byte data[] = new byte[1024]; int count; while ((count = in.read(data, 0, 1024)) != -1) { fout.write(data, 0, count); } … if (Desktop.isDesktopSupported()) { 38 File file = new File(System.getProperty("user.dir")+"\\Theoretical.pdf"); Desktop.getDesktop().open(file); }

The transition to tasks is performed by void jButton2ActionPerformed. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { CardLayout cl =(CardLayout) jPanel1.getLayout(); cl.show(jPanel1, "card2"); }

The transition to the previous step is due to void jButton4ActionPerformed. Спочатку перевіряється чи step більше 1. First, it is checked whether step is greater than 1. If so, the function prevStep() is executed. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { if(step > 1) { prevStep(); } }

When going to the next step, the answer to the task is checked. In tasks with a choice of several options, the check is performed by jRadioButton1.isSelected(), and the fields are filled with – "TE'".equals(jTextField1.getText()). Also, if the answer is incorrect, the text of the hint is specified and the variable error is increased by 1: text = "The first option is correct"; error++;. If the answer is correct, then the nextStep()function is executed. 39 private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { String text = ""; switch(step) { case 1: if(jRadioButton1.isSelected()) { nextStep(); } else { text = "The first option is correct"; error++; } break; … if(error == 1) { jLabel8.setVisible(true); } else if (error > 1) { JOptionPane.showMessageDialog(jPanel1, text, "Error", JOptionPane.INFORMATION_MESSAGE); } }

4.3. Description of the program

After starting the simulator, the main window is displayed. It displays basic information (Fig. 4.6). 40

Figure 4.6 – Main window

Before starting the tasks, you can open the theoretical material - the button "Theoretical material (PDF)". This will open a separate PDF file. It will be created in the place where the file for starting the simulator is located (Fig. 4.7).

Figure 4.7 – Theoretical material

41 After clicking the "Practical tasks" button, the first task is displayed. Its condition, answer options are displayed. Then indicates what needs to be done (Fig. 4.8).

Figure 4.8 – First task

Choosing the answer from several options is simple. The following actions are now available: return to the previous task or go to the next one (Fig. 4.9). The transition to the previous step is possible on all tasks except the first. 42

Figure 4.9 – Actions

When going to the next step, the provided answer is checked. If the error is made for the first time, a warning is displayed (Fig. 4.10). Next time, a tooltip is displayed (Fig. 4.11).

Figure 4.10 – Warning 43

Figure 4.11 – Tooltip

If the answer is correct, the following task (Fig. 4.12) is displayed. You need to answer again and choose the next action.

Figure 4.12 – Second task 44 In addition to choosing one of the options, there are tasks where you need to fill in the fields (Fig. 4.13).

Figure 4.13 – Fill in the fields

One of the tasks is to establish a sequence. They indicate the list and next to it you need to specify the sequence (Fig. 4.14).

Figure 4.14 – Specify the sequence 45

If you answer the last step, a message is displayed about the completion of the simulator (Fig. 4.15).

Figure 4.15 – Completion of the simulator

To start the passage, you must first restart the simulator. 46 CONCLUSIONS

In this work there was an independent consideration of lecture material and mastering in the project. Consolidation of theoretical knowledge that was provided in the lecture material. An algorithm simulator for the topic "Algorithm for conducting the left factorization of grammar" of the distance learning course "Programming Theory" was also developed. Creating simulators for distance learning - this opens up a new way for us to study for students of distance (distance) form of education. The advantage of simulators is that they can be used both for student training and for self-study. The main results of the work:  describe the problem statement;  describe an overview of the purposes of distance learning and learning management systems;  give the basic concepts of the topic for use in the simulator;  develop an algorithm for the simulator and make a block diagram;  describe the programming language and technologies used in developing the program;  describe the process of implementation of the main stages of creating a simulator;  describe the instruction required by the user The initial window display the following information about the simulator: topic; surname, initials of the student; academic group of the student. The following issues are covered in the simulator according to the topic: 1. Recursive descent. 2. Algorithm of deleting of left recursion. 3. Left factorization. Before passing the simulator, the user have opportunity to review the theoretical material on these issues. If the answer to the practical task is 47 incorrect, a warning about the error displayed first, and only then an explanation of this error. The simulator implements the following tasks:  choosing one of the answer options;  filling in the fields;  establishing a sequence. If you answer the last step, a message is displayed about the completion of the simulator. To start the passage, you must first restart the simulator. 48 REFERENCES 1. Ємець О. О. Методичні рекомендації до виконання бакалаврської роботи для студентів за освітньою програмою «Комп’ютерні науки» спеціальності 122 «Комп’ютерні науки та інформаційні технології» галузь знань - 12 «Інформаційні технології»» / О.О.(Олег) Ємець. – Полтава : РВВ ПУЕТ, 2011. – 71 с. 2. Mümine K.K. A Review of Distance Learning and Learning Management Systems, Virtual Learning, Edited by Dragan Cvetkovic / K.K. Mümine, A.O. Selma.– IntechOpen, DOI: 10.5772/65222. Available from: https://www.intechopen.com/books/virtual-learning/a-review-of-distance- learning-and-learning-management-systems 3. Programming theory (Теорія програмування) [Electronic resource] / Distance learning site “Poltava university of economics and trade”.– Available from: http://www2.el.puet.edu.ua/iz/course/view.php?id=744 4. Бабій М.С. Теорія програмування: Навчальний посібник [Електронний ресурс] / М.С. Бабій, О.П. Чекалов.– Суми: Вид-во СумДУ, 2009. – 181 с. 5. Нікітченко М.С. Теоретичні основи програмування: Навчальний посібник [Електронний ресурс] / М.С. Нікітченко. – Київ: КНУ ім. Т.Г. Шевченка, 2009. – 200 с. – Режим доступу: http://ttp.unicyb.kiev.ua/doc/TOP.pdf. 6. Zykov S.V. Modern programing languages. Part I. Functional approach to programing / S.V. Zykov. – M.: MIFI, 2003. – 230 p. 7. Bondarenko М.F. Computer discrete mathematics: Course book / М.F. Bondarenko, N.V. Bilous, А.G. Rutkas. – Kharkiv: «СМІТ company», 2004. – 408 p. 8. Gross M. Theory of regular grammars / M. Gross, A. Lanten. – М.: Мir, 1971. – 294 p. 9. Java (programming language) [Electronic resource] / From Wikipedia, the free encyclopedia.– Available from: 49 https://en.wikipedia.org/wiki/Java_(programming_language) 10. NetBeans IDE The Smarter and Faster Way to Code [Electronic resource] – Available from: https://www.oracle.com/tools/technologies/netbeans- ide.html 11. Бібліографічний запис. Бібліографічний опис. Загальні вимоги та правила складання: ДСТУ 7.1-2006. – [Чинний від 2007-07-01]. – К. : Держспоживстандарт України, 2007. – 47 с. 50 APPENDIX A. PROGRAM CODE