Logo en.artbmxmagazine.com

Translator; through the lexical phase of the compiler methodology

Anonim

A translator is very important in the development of a student, especially if he is a university student, since most people no longer use a physical dictionary, because it is essential to know about other languages ​​in order to develop both in the field. social as professional, and this is what the author Alix Anderson mentions in his article called "The importance of learning a second language."

article-translator-lexical-phase

As a final product of this project, the application of a translator has been developed, which when starting up performs the translation of some words. It should be mentioned that this application is not completely finished, since it is considered that later on it can also translate sentences, making use of the syntactic phase of a compiler. But for the purpose of demonstrating that the main phases of a compiler have been developed, including that of the lexicon, in an application it can be said that the objectives set are met since with the development of said project good results were obtained that later will have a educational use in the university sector.

KEYWORDS:

Application, Compiler, Translator, Syntactic, Lexical, Educational.

ABSTRACT

A translator is very important in the development of a student, especially if college, as most people no longer use a physical dictionary, because it is essential to know about other languages ​​in this way to develop both in the field social and professional, and so the author Alix Anderson mentions in his article called "the importance of learning a second language." The final product of this project has developed a translator application that the start performs the translation of some words. It should be mentioned that this application is not completed in full, as it has in mind that later can also translate sentences, using the syntactic phase of a compiler. But for purposes of demonstrating developed the main phases of a compiler, including lexical,in an application could say that the objectives are met and that with the development of this project good results were obtained that later will have an educational use in the university sector.

KEYWORDS:

Application Compiler, Translator, syntactic, lexical, Educational.

1. INTRODUCTION

Currently, it is very important to use a translator, mainly for young people since otherwise there would be a barrier between them and prevents communication, according to what is mentioned in an article published by Mercedes Errutia Cavero.

A language translator has a very important function in the life of a university student, as it saves him a lot of time because he does not have to be looking for words in a physical dictionary, and that is why it is considered that its use is more practical.

This article shows the development of a project carried out in 2015, which was to make a translator using the method of a lexical analyzer.

There are different methods to develop a language translator, some are:

  • Using compiler theory. (Building a database in Java).
  • Use for loops in c ++.

In this project, the first method is used, putting compiler theory into practice.

A compiler is a program that translates a program written in a source language, this can be seen graphically in the

Figure 1.1

Figure 1.1 - General diagram of a compiler.

A compiler is created through phases, which in turn are divided into two main parts, which are the analysis and synthesis.

Sometimes the compilation process is not straightforward, sometimes you have to go from one language to another and then to another, as can be seen in Figure 1.2, and this will depend on the complexity of the compilation.

Figure 1.2 - Diagram of a compiler with an intermediate language.

The analysis part is composed of three phases that are:

Lexicographic analysis

Syntactic analysis

Semantic analysis

The second part of the synthesis is made up of the other three phases:

Generation of intermediate code

Code optimization

Code generation.

In this compiler a lexical analyzer is implemented to carry out the translation. So one of the main objectives to demonstrate is the importance of this methodology in translation; and how this methodology was put into practice.

1.1- BACKGROUND

In 1950, GM Hooper coined the term compiler and the first works on compilers related to the translation of arithmetic formulas to code appeared on compilers related to the translation of arithmetic formulas to machine code.

Knuth develops most of the parsing techniques.

Wirth proposes the concept of intermediate code representation, separating the translation process into two phases: the front-end in charge of analyzing the source program (operations dependent only on the source language) and the back-end in charge of generating the code for the machine. object.

1.2- TRANSLATORS AND INTERPRETERS

A translator is any program that takes a text written in one language and outputs another language (called an object, Figure 1.3).

An interpreter directly executes the operations in the source program; this can be seen in Figure 1.4.

Figure 1.4 - Diagram of an interpreter.

2.- DEVELOPMENT

2.1- METHODOLOGY

In this project a Spanish - English translator was made, using compiler techniques learned in the course. To carry out the project, some tools were used:

  • java flex java java

The program used for the development of this project was NetBeans IDE version 8.0.2.

It was decided to use NetBeans IDE 8.0.2 because it is an integrated free development environment, and it was made primarily for the Java programming language. It is a free program with no restrictions on its use, just like the tools we work with (mentioned above). The program made is composed of the elements already mentioned that we can see in Figure 1.5.

Figure 1.5 - Elements that make up the application.

Description of tools

Now a description of the tools will be given.

Interface.java-

Figure 1.6 shows the part that contains the log where the translation results will be displayed and the buttons that contain the code.

Lexer.flex Figure 1 -.6 - General user interface.

In Figure 1.7 you can see the Lexer tool, which is used to send the type of object that has been found to be brought in, that is, it is through it that the token is called.

Figure 1.7 - Shows how the token is invoked.

Token.-

The Token tool, which can be seen in Figure 1.8, is used for the translation process, it contains the characters of a word, as well as the symbols or numbers that the application will be able to recognize.

Figure 1.8 - Token, character string

TranslatorJFlex.java. that make up the application. -

Given the regular expressions that are entered and that recognize the token, it generates the recognizing automaton automatically, as shown in Figure 1.9.

Figure 1.9 - Part where the recognizing automaton is generated.

2.2- RESULTS

The following shows how the translator works.

Step 1: First the application is executed and what is observed in Figure 1.10 will appear.

Figure 1.10 - Main screen of the application.

Step 2: Now, as shown in Figure 1.11, the word to be translated is written in the text box.

Figure 1.11 - The word to be translated is written.

Step 3: Once the word has been written, proceed to press the button

“Translate”, as shown in Figure 1.12

Figure 1.12 - Translation of the word.

Step 4: In Figure 1.13 you can see how the word is translated, now you just press the "OK" button to close this window.

Figure 1.13 - Translation results screen.

3.- CONCLUSIONS

In conclusion, it can be said that the objective set at the beginning was fulfilled and this application was solved using the lexical tool. This project is very useful for the student community, mainly university students, since at this stage of life it is more important to know about another language because that way more opportunities for development are created, both socially and professionally. Remembering that it is not yet a fully finished project, since it still needs to be able to translate sentences and analyze that said sentences are written correctly, putting into practice the syntactic phase of a compiler, since it is the one in charge of analyzing the structure of a sentence; and also verifies that the samples obtained by the lexical analyzer are within the syntactic structure of the language.

4.- REFERENCES

  • Alix Anderson (2011), The importance of learning a second language, Research article, pages 1 - 2. URL: https://www.gvsu.edu/cms3/assets/F8585381E4E9-6F8E-F7EE2083CCE4F9AC/2011/nuestros_ensayo s_- _la_importancia_de_aprender_una_segunda_l engua.pdf Mercedes Errutia Cavero (consulted in February 2016), Details on translation: importance and peculiarities of technical translation, Research article. URL: dialnet.unirioja.es/descarga/articulo/232414.p dfDragonJar (2011), How to create a translator ?, Computer security research forum. URL: http://comunidad.dragonjar.org/f201/comocrear-un-traductor-en-java-12765/Sergio Gálvez Rojas, Miguel Ángel Mora Mata (2005), Java at the top: Compilers, Book in PDF format, pages 3, 16 - 18. URL: http://www.lcc.uma.es/~galvez/ftp/libros/Co mpiladores.pdfEduardo Serna Pérez (1997), Introduction to compilers, Broadcast article, pages 5 - 8. URL: http: //www.paginasprodigy.com/edserna/curs os / compiler / notes / Notes1.pdfSofía N. Galicia Haro, Alexander Gelbukh (2007), Research in syntactic analysis for Spanish, first edition 2007, National Polytechnic Institute, pages 130 - 140.
Download the original file

Translator; through the lexical phase of the compiler methodology