Presentation is loading. Please wait.

Presentation is loading. Please wait.

THE FUNCTIONS AND PURPOSES OF TRANSLATORS TOPIC 2 CONTENT: 2.1. Types of translators 2.2. Lexical analysis 2.3. Syntax analysis 2.4. Code generation 2.5.

Similar presentations


Presentation on theme: "THE FUNCTIONS AND PURPOSES OF TRANSLATORS TOPIC 2 CONTENT: 2.1. Types of translators 2.2. Lexical analysis 2.3. Syntax analysis 2.4. Code generation 2.5."— Presentation transcript:

1 THE FUNCTIONS AND PURPOSES OF TRANSLATORS TOPIC 2 CONTENT: 2.1. Types of translators 2.2. Lexical analysis 2.3. Syntax analysis 2.4. Code generation 2.5. Linkers and loaders

2 Code generation is the technique of using or writing programs that write source code. Code generators are tools built to serve engineers in the creation of applications. Just as woodworkers use customized tools called jigs to allow them to build furniture more quickly and accurately, code generators allow engineers to concentrate on building the application while the generator handles the grunt work tasks. Code generation is not a new technique, it has been a technique in the pocket of experienced engineers for years. Code Generation in Action, Manning's first book on the subject, introduces the technique and brings it to life in a practical manner within today's frameworks. The book first covers the theory of code generation at a practical level. It covers the structure and construction of generators from very small, to full application generators.Manning Code Generation in Action.htm

3 Types of Translation: Introduction to Translation and Interpretation.htm Machine translation Also known as automatic translation, this is any translation that is done without human intervention, using software, hand-held translators, online translators such as Babelfish, etc. Machine translation is extremely limited in quality and usefulness - learn more. Machine-assisted translation Translation that is done with a machine translator and a human working together. For example, to translate "honey," the machine translator might give the options le miel and chéri so that the person could decide which one makes sense in the context. This is considerably better than machine translation, and some argue that it is more effective than human-only translation. Screen translation Translation of movies and television programs, including subtitling (where the translation is typed along the bottom of the screen) and dubbing (where the voices of native speakers of the target language are heard in place of the original actors). Sight translation Document in the source language is explained orally in the target language. This task is performed by interpreters when an article in the source language is not provided with a translation (such as a memo handed out at a meeting). Localization Adaptation of software or other products to a different culture. Localization includes translation of documents, dialog boxes, etc., as well as linguistic and cultural changes to make the product appropriate to the target country.learn more

4 Lex - A Lexical Analyzer Generator.htm Lex helps write programs whose control flow is directed by instances of regular expressions in the input stream. It is well suited for editor-script type transformations and for segmenting input in preparation for a parsing routine. Lex source is a table of regular expressions and corresponding program fragments. The table is translated to a program which reads an input stream, copying it to an output stream and partitioning the input into strings which match the given expressions. As each such string is recognized the corresponding program fragment is executed. The recognition of the expressions is performed by a deterministic finite automaton generated by Lex. The program fragments written by the user are executed in the order in which the corresponding regular expressions occur in the input stream. The lexical analysis programs written with Lex accept ambiguous specifications and choose the longest match possible at each input point. If necessary, substantial look ahead is performed on the input, but the input stream will be backed up to the end of the current partition, so that the user has general freedom to manipulate it.

5 Lex Source. The general format of Lex source is: {definitions} % {rules} % {user subroutines} where the definitions and the user subroutines are often omitted. The second % is optional, but the first is required to mark the beginning of the rules. The absolute minimum Lex program is thus % (no definitions, no rules) which translates into a program which copies the input to the output unchanged.

6 Usage There are two steps in compiling a Lex source program. First, the Lex source must be turned into a generated program in the host general purpose language. Then this program must be compiled and loaded, usually with a library of Lex subroutines. The generated program is on a file named lex.yy.c. The I/O library is defined in terms of the C standard library [6]. The C programs generated by Lex are slightly different on OS/370, because the OS compiler is less powerful than the UNIX or GCOS compilers, and does less at compile time. C programs generated on GCOS and UNIX are the same. UNIX. The library is accessed by the loader flag -ll. So an appropriate set of commands is lex source cc lex.yy.c -ll The resulting program is placed on the usual file a.out for later execution. To use Lex with Yacc see below. Although the default Lex I/O routines use the C standard library, the Lex automata themselves do not do so; if private versions of input, output and unput are given, the library can be avoided.

7 Static syntax analysis.htm


Download ppt "THE FUNCTIONS AND PURPOSES OF TRANSLATORS TOPIC 2 CONTENT: 2.1. Types of translators 2.2. Lexical analysis 2.3. Syntax analysis 2.4. Code generation 2.5."

Similar presentations


Ads by Google