sábado, 26 de enero de 2019

Making Compiler Design Relevant for Students who will (Most Likely) Never Design a Compiler



Building a compiler is more than translating high-level programming languages to assembly or machine code. A compiler is an instance of translators from a source language to a target language.
In this document it is explained that we have the same structure in many translators: an input sting which is composed into tokens, these tokens are grouped into phrases and then these phrases are mapped to the output sequence determined by the structure a context in which they occur.
We also learn that compiler development tools, like lex and yacc, can be applied for many translation problems.

It is explained that Dot is a tool that reads a textual graph and produces a drawing of the graph specified. To do something like this, the following actions are needed:

1-     Read the textual graph using context-free parsing techniques
2-     Check semantic consistencies between components
3-     Construct internal representation
4-     Determine the output
5-     Modify the output
6-     Generate postscript for the graph

For translating Latex to html the translation should follow the following actions:
1-     Read the latex document using context-free parsing techniques
2-     Construct internal representation
3-     Process Latex constructs and output

We notice that the steps are less than the graph example, and it is because the source and target languages are semantically much closer in the Latex to html case.
Essentially, with both cases we can see the same main phases of the compiler. A lexical analysis and parsing, A semantic analysis, code generation and code optimization.

In Lexical analysis and parsing, the compiler refers to the type or scope of a variable. In code Generation, the compiler transverse the tree representation of a program to generate assembly or machine code for the target machine. In optimization step, the compiler basically makes code transformations to make the program faster.


No hay comentarios.:

Publicar un comentario