State of the Art Tools for Rapid Compiler Development

What is Compiler?

A compiler is a computer program that helps you to transform the source code from a high-level language into the machine code. 

It plays an important role in the working of a system as it performs the task of translating the code written from one programming language to another without modifying the true meaning of the program code. 

The compiler also has the responsibility of making the code effective when it comes to execution time and the space required.

Features of Compiler

  • Compilation speed.
  • The correctness of machine code.
  • The meaning of code should not change.
  • Speed of machine code.
  • Good error detection.
  • Checking the code correctly according to grammar.

Compiler Construction Tools

Compiler construction tools are also known as compiler-generators or translators. They use specific algorithms for defining and implementing the component of the compiler.

1. Parser Generators.

A parser generator takes grammar as input and automatically generates source code which can parse streams of characters with the help of grammar.

It is a good tool that you should make part of your toolbox. Usually, the input is a formal specification of the grammar which the parser actually has to recognize, and also the parser has to take work like code implementing the actions at the time of recognizing the various parts of its input.
The generated code is a parser, and it accepts the sequence of characters and then tries to match the sequence against the grammar.

The parser  produces a parse tree, which portrays how grammar productions are expanded into a sentence that matches the character sequence.

The starting non-terminal of the grammar is the root of the parse tree and each node of the parse tree expands into one production of the grammar.

The concluding step of parsing is to do something useful with this parse tree. Finally, it is translated into a value of a recursive data type.

Few Parser generators are:
  • Yeti, written in Tcl,
  • taccle
  • page in Tcllib (superseded by Parser Tools)
  • Bison. GNU’s variant of YACC

2. Scanner Generators.

It takes regular expressions as their input. For example LEX for Unix Operating System, it generates lexical analyzers, generally from a specification based on regular expressions. It generates a finite automaton to recognize the regular expression.
A scanner generator is also called a lexical analyzer generator, follows the following form


The main purpose of Scanner generators is to clear the way for lexical analysis. It can also be used with a parser generator to perform lexical analysis.


Example, to interface Lex and Yacc, an open-source program that generates code for the parser in the C code.

3. Syntax-Directed Translation Engines.


What Syntax Directed Translation is? 

Syntax Directed Translation has augmented rules to the grammar that facilitate semantic analysis. 


It also involves passing information bottom-up and/or top-down the parse tree in the form of attributes attached to the nodes. 


Syntax directed translation rules use:

  1. Lexical values of nodes
  2. Constants
  3. Attributes associated with the non-terminals in their definitions.

The general approach to Syntax-Directed Translation is to construct a parse tree or syntax tree and compute the values of attributes at the nodes of the tree by visiting them in some order. 


Often, translation can be done during parsing without building an explicit tree.


Syntax-Directed Translation Engines generates intermediate code with three address formats from the input that consists of a parse tree. 


These engines have routines to traverse the parse tree and then produce the intermediate code. It has the goal of associating one or more translations with each node of the parse tree.


Each translation is defined in terms of translations at its neighbor nodes in the tree.

4. Automatic Code Generators.

Automatic Code Generation refers to using programs to generate code that the developer would otherwise have to write.


As a bonus, using Automatic code generation creates consistent, higher quality software more productively and at a higher level of abstraction than manually coding projects.




Automatic code generators accept intermediate code and convert them into Machine Language for a target machine. 


The collection of rules is used to translate each operation of the intermediate language. Each operation of the intermediate language is translated using a collection of rules and then is taken as an input by the code generator. A template matching process is used in this process.


An intermediate language statement is replaced by its equivalent machine language statement using templates. The quality of the software created is directly related to the quality of the code generator. As the quality of the code generator is improved, the quality of automatically generated programs also improves!


Let’s now discuss some advantages of code generators.

  • Code generators are 100% consistent!
  • A code generator wont misspell or miss-capitalize names. Moreover, an immediate productivity boost is gained when using a code generator. A program immediately goes from no code to at least a framework that includes all the design aspects of the program. 
  • Code generators can save even more time if there are design or requirement changes. It propagates changes throughout an entire project. 
  • The final advantage of automatic code generation deals with the level of abstraction. It is based on a PIM (platform-independent model) or PSM (platform-specific model).

5. Data Flow Engines.

Dataflow is the movement of data through a system composed of software, hardware, or a combination of both. 


It is often defined using a model or diagram in which the entire process of data movement is mapped as it passes from one component to the next within a program or a system, taking into consideration how it changes form during the process.


In its application, the program source is transformed into a Dataflow engine configuration file, which describes the operations, layout, and connections of a Dataflow engine.


Data is generally streamed from memory into the chip where operations are performed and data is forwarded directly from one computational unit or dataflow core to another, as the results are needed, without being written to the off-chip memory until the chain of processing is complete.


This tool is very helpful for code optimization, as the information is supplied by the user and intermediate code is compared to analyze any relation. It is also known as data-flow analysis. 


It helps you find out how values are transmitted from one part of the program to another.


Closing Thoughts

In this article, we discussed compiler features with its construction tools.


Often, we don't give a deep thought that these small concepts can contribute to such a big application.


This article provided the insights on phases of compiler and its importance, different features and how a program or an application works internally and how a code is generated. The main task of the compiler is to verify the entire program, so there are no syntax or semantic errors. 

Authors

Vishwakarma Institute of Technology, Pune.
Third-Year Students, Computer Department

  1. Riya Prashant Jagtap.
  2. Mansi Dilip Samant.
  3. Bhavin Manishkumar Shah.
  4. Sakshi Kailas Walzade.


Comments

  1. Well explainedπŸ‘πŸ‘πŸ€™✌

    ReplyDelete
  2. Great information on rapid compiler development

    ReplyDelete
  3. Very Informative Article....Keep It up Guy's πŸ‘πŸ‘

    ReplyDelete
  4. max informative content keep it up

    ReplyDelete
  5. Great work, nice information πŸ‘πŸ‘

    ReplyDelete
  6. Great info about compiler and its development

    ReplyDelete
  7. Detailed and properly explained.✌πŸ‘

    ReplyDelete
  8. Well organised and informative πŸ™ŒπŸ‘

    ReplyDelete
  9. Very Informative πŸ‘πŸ»πŸ‘πŸ»

    ReplyDelete

Post a Comment