iJournals: International Journal of Software & Hardware Research in Engineering (IJSHRE) ISSN-2347-4890 Volume 11 Issue 5 May 2023 M. O. Odim; S. A. Arekete; B. O. Oguntunde; A. O. Lawal, Volume 11 Issue 5, pp 31-39, May 2023 A Multi-Pass Compiler with Code Optimized Abstract Syntax Tree Authors: M. O. Odim 1 ; S. A. Arekete 2 ; B. O. Oguntunde 3 ; A. O. Lawal 4 Department of Computer Science, Redeemer’s University 1,2,3 ; Amazon Web Services (AWS) 4 odimm@run.edu.ng 1 ;areketes@run.edu.ng 2 ;oguntunden@run.edu.ng 3 ;alawalo@amazon.com 4 DOI: 10.26821/IJSHRE.11.5.2023.110409 ABSTRACT This study proposes a multi-pass compiler with code optimized abstract syntax tree based on a subset of C# as the source and C constructs as the target, with the view to enhancing the understanding of compiler design, which conceptually has been a rather difficult discourse. A single-pass compiler allows a single traversal over the source code or intermediate form. This does not allow for a distributed compilation and modular development. On the other hand, the proposed scheme decouples the type-checker from the abstract syntax tree, thus separating them into independent segments that allows a multi-pass over the source code; this in turn provides a mechanism for modular development, which encourages distributed compilation. The proposed scheme constructs the abstract syntax tree before the type- checking, thus allowing another tranversal on the intermediate form of the source code. An optimised tree was constructed after code optimisation had been conducted. The scheme is based on only small subset of C# constructs. Further study would be focused on adding more constructs. Keywords: Compiler, Code optimisation, Abstract Syntax Tree, Multi-pass compiler. 1. INTRODUCTION Compiler construction is an essential part of applied computer science, which has been traditionally regarded as a complex piece of software. It is rather worrisome that little or no attention is being paid to the relevance and knowledge of compiler construction by students and young computer scientists nowadays. This perception stems mainly from traditional methods of teaching compilers as well as the lack of available examples of small and functional compliers for real programming languages. Compiler construction requires a lot of practical engagements; however, teachings the course is based most times on methods that are too abstract for learning, which consequently, reduces the interest of the students. In addition, a number of students lack classical programming techniques and software programming capabilities required for in- depth knowledge of compiler construction [1]. The exclusion of compiler construction and language theory in many computing degrees has been reported in the literature [2], with the rationale that they are now no more vital to modern software engineering practice, regardless of the importance of compiler to computing in general. Compilers and operating systems provide the basic interfaces between a programmer and the machine. Compiler construction provides an extensively useful exercise in software engineering [3]; and hence cannot be considered to be irrelevant to modern software engineering practice. In view of the above, this study proposes a multi-pass compiler with code optimized abstract syntax tree (AST) as a tool for enhancing the art of learning compiler construction. 2. RELATED WORK A couple of efforts seeking to enhance the understanding of compiler design have been reported in the literature. For instance, [4] designed a compilation simulator that could serve as an aid to learning compiler design which was composed of a virtual machine and its machine language, a simple high-level language and its compiler simulator. The simulator could recognise, carry out and describe the syntax and lexical analysis and the code generation phases of compilation. However, the language could only recognise digits and accept