Assignment of Bachelor's Thesis
Total Page:16
File Type:pdf, Size:1020Kb
ASSIGNMENT OF BACHELOR’S THESIS Title: DET language IDE Student: Toghrul Sultanzade Supervisor: Ing. Ondřej Guth, Ph.D. Study Programme: Informatics Study Branch: Computer Science Department: Department of Theoretical Computer Science Validity: Until the end of summer semester 2020/21 Instructions The aim is to implement an integrated development environment (IDE) for DET scripting language (it is a proprietary language based on Java). The IDE should be capable of syntax highlighting, autocompletion, and error recognition. 1. Study existing parser of DET language [1] and modify it for the needs of the IDE. 2. Research existing open-source IDEs and techniques for syntax highlighting, autocompletion and error recognition. 3. Based on the research, use existing libraries and algorithms to implement the IDE and its required features as a prototype. 4. Use appropriate tools and methods to test the results. References [1] GRANKIN, Daniil. A translator of DET scripting language into Java. Bachelor's thesis. Czech technical university in Prague, 2019. Available from: http://hdl.handle.net/10467/83386. doc. Ing. Jan Janoušek, Ph.D. doc. RNDr. Ing. Marcel Jiřina, Ph.D. Head of Department Dean Prague October 17, 2019 Czech Technical University in Prague Faculty of Information Technology Department of Computer Science Bachelor's thesis DET language IDE Toghrul Sultanzade Supervisor: Ing. Ondrej Guth, Ph.D. 21st February 2020 Acknowledgements Firstly, I would like to express my appreciation and thanks to my thesis su- pervisor, Ing. Ondrej Guth, for his professional attitude and dedication to help me. The door to his office was always open, whenever I had troubles and obstacles in the process of writing the thesis. Moreover, I would like to thank my family and friends for support during writing this thesis. Declaration I hereby declare that the presented thesis is my own work and that I have cited all sources of information in accordance with the Guideline for adhering to ethical principles when elaborating an academic final thesis. I acknowledge that my thesis is subject to the rights and obligations stip- ulated by the Act No. 121/2000 Coll., the Copyright Act, as amended. In accordance with Article 46(6) of the Act, I hereby grant a nonexclusive author- ization (license) to utilize this thesis, including any and all computer programs incorporated therein or attached thereto and all corresponding documentation (hereinafter collectively referred to as the \Work"), to any and all persons that wish to utilize the Work. Such persons are entitled to use the Work for non- profit purposes only, in any way that does not detract from its value. This authorization is not limited in terms of time, location and quantity. In Prague on 21st February 2020 . Czech Technical University in Prague Faculty of Information Technology c 2020 Toghrul Sultanzade. All rights reserved. This thesis is school work as defined by Copyright Act of the Czech Republic. It has been submitted at Czech Technical University in Prague, Faculty of Information Technology. The thesis is protected by the Copyright Act and its usage without author's permission is prohibited (with exceptions defined by the Copyright Act). Citation of this thesis Sultanzade, Toghrul. DET language IDE. Bachelor's thesis. Czech Technical University in Prague, Faculty of Information Technology, 2020. Abstrakt Tato diplomov´apr´acesi d´av´aza ´ukol navrhnout a vyvinout vylepˇsen´ein- tegrovan´ev´yvojov´eprostˇred´ı, kter´evyˇreˇs´ı probl´emy a zreviduje schopnosti st´avaj´ıc´ıhoScriptovac´ıhoEditoru. Tento Scriptovac´ıEditor je uˇz´ıv´ank v´yvoji a implementaci skriptu, pouˇz´ıvaj´ıc´ıDET skriptovac´ıjazyk pops´anv diplo- mov´epr´aci[1]. DET jazyk m´asyntaxi zaloˇzenouna Java jazyce s vlastn´ımi rozˇs´ıˇren´ımireprezentuj´ıc´ıJava promˇenn´ea Java metody. Vady pˇredchoz´ıim- plementace jsou ˇreˇseny v prototypu projektu, kter´yje pˇredmˇetemt´etopr´ace. K rozvoji podpory pro DET skriptovac´ıjazyk jsou pouˇzity dneˇsn´ımodern´ı postupy. Souˇcasn´ystav je prezentov´anspoleˇcnˇes preferovanou metodologi´ı zpracov´an´ıuˇzivatelsk´ych vstup˚u. Kl´ıˇcov´aslova doplˇnov´an´ık´odu,naˇsept´av´an´ı,zv´yrazˇnov´an´ısytanxe, v´yvojov´e prostˇred´ı,skriptovac´ıjazyk, ANTLR, gramatika, AST Abstract This thesis aims to design and develop an improved integrated development environment solution, which resolves problems and revises the capabilities of the existing proprietary Scripting Editor implementation. The Scripting Editor is used to develop and implement scripts, written in DET scripting ix language that is described in the thesis [1]. DET language has Java-like syntax with custom language extension into the variables and methods of java classes. The flaws of the previous implementation are approached in the prototype project, which is the subject of this thesis. The modern and contemporary approaches are used to develop support for the DET scripting language. The state of the art is presented alongside the favored methodology of the user input processing. Keywords code completion, autocomplete, syntax highlighting, develop- ment environments, scripting language, ANTLR, grammar, AST x Contents Introduction 1 Thesis Overview . 1 1 Theoretical background 3 1.1 Algorithmic trading . 3 1.2 DET scripting language . 3 1.3 Programming Language . 4 1.4 Domain-specific language . 5 1.5 Formal Grammar . 5 1.6 Graph theory . 9 1.7 Parsing . 11 1.8 Integrated development environment . 12 1.9 Research of modern solutions . 16 1.10 Available tools to implement IDE features . 22 2 Current State 25 2.1 Text editor . 25 2.2 Features of the text editor . 25 2.3 Syntax Highlighting . 26 2.4 Code completion . 28 2.5 Key disadvantages of the current state . 29 3 Analysis and Design 33 3.1 Web IDE . 33 3.2 Features of IDE . 34 3.3 Editor framework . 36 4 Realisation 37 4.1 Environment . 37 4.2 Syntax highlighting . 39 xi 4.3 Code completion . 40 4.4 Error recognition and indication . 42 5 Testing 45 Conclusion 49 Future work . 49 Bibliography 51 A Acronyms 57 B Contents of enclosed CD 59 xii List of Figures 1.1 An example of the syntax diagram for an expression rule, from [2]. 5 1.2 Example of two different parse trees for a single sentence from a language. 8 1.3 An example of a radix tree. 11 1.4 Structure of the code completion plugin in Code::Blocks IDE, from [3] .................................... 17 1.5 The main flow of a parser in Code::Blocks . 18 1.6 An example of automatic code completion in Code::Blocks. 19 2.1 An example of using primitive types from the DET language in the AvalonEdit text editor. 27 2.2 Representation of the regular expression used to match a declared variable from source code. 29 2.3 An example of the code completion list for the word GET C. 30 2.4 An example of the code completion list for the word variable. 31 4.1 ANTLR grammar rules representing a digit or letter in a DET script. 39 5.1 Mean features score. Blue bars represent original editor, while red bars represent prototype evaluations . 46 xiii Introduction Low latency trading has been made possible by introducing informational tech- nologies into the capital markets. Algorithmic trading became widely spread during the past few decades, thus raising demand for platforms supporting scripting and real-time usage of the broker's business logic. Dynamic Elec- tronic Trading (DET) company provides one of such platforms, granting fast and discrete tools for implementing the custom routing logic. In the world of informational technologies, the development of any script or application in a plain text editor brings various complications along the way. One such complication is the time consumed by the compilation of the program only to reveal minor errors in the code. As developers are facing more challenging tasks each day, the significance of time spent on looking up the identifier or locating a particular error has increased. There has been developed an integrated development environment concept, aimed at providing development assistance in the form of various facilities. IDE has become a demanded tool ever since, saving lots of coding time. This thesis takes as a goal to design an integrated development envir- onment that supports business-driven DET scripting language. An existing parser and grammar for this language can be found in this [1]. DET language IDE is one of the various environments, that is capable of syntax highlighting, code completion and error recognition. The IDE is a lightweight web-based application, providing swift utilization support to most of the popular platforms. It helps clients to avoid searching for particular documentation entry, highlights errors on the go while the developer is writing code and displays source code in different colors and fonts to make it easier to read. Thesis Overview Chapter 1 introduces the reader to the terms, tools and concepts used in the project, as well as to the state of art. 1 Introduction Chapter 2 shows and describes an analysis of implementation problems and features of the existing environment that supports the DET language. Chapter 3 describes approaches to the problems of the old IDE and com- poses a solution. Chapter 4 discusses the implementation details of solution. Chapter 5 describes the necessary tests for the application. 2 Chapter 1 Theoretical background The project aims to implement an integrated development environment for DET scripting language, which should be capable of syntax highlighting, code completion, and error recognition. Therefore, in this chapter, I provide an overview of the most common solutions and existing frameworks available to implement theses features. In addition, I present a detailed review of the following concepts: FIX, programming language, parsing, formal grammar, terminology of graph theory, AST and IDE. 1.1 Algorithmic trading Algorithmic trading is a method of executing a large order (parent or- der) using special algorithmic instructions.