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.

Slides:



Advertisements
Similar presentations
Compilers Course 379K, TTH 9:30-11:00 Instructor: Dr. Doron A. Peled Office Hours: Mon 11:00-12:00.
Advertisements

Compiler construction in4020 – lecture 2 Koen Langendoen Delft University of Technology The Netherlands.
Compiler Baojian Hua Lexical Analysis (II) Compiler Baojian Hua
Lex -- a Lexical Analyzer Generator (by M.E. Lesk and Eric. Schmidt) –Given tokens specified as regular expressions, Lex automatically generates a routine.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
Prof. B. I. Khodanpur HOD – Dept. of CSE R. V. College of Engineering. ID: Subject: Computer Fundamentals (For EDUSAT) Common.
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
Compiler Construction by Muhammad Bilal Zafar (AP)
 Lex helps to specify lexical analyzers by specifying regular expression  i/p notation for lex tool is lex language and the tool itself is refered to.
COSC 120 Computer Programming
Guide To UNIX Using Linux Third Edition
410/510 1 of 20 Week 1 – Lecture 1 Introduction The Textbook Assessment Programming & Tools A v. small compiler Compiler Construction.
ETI 102 Introduction to Translation Translation as a process and a product.
OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – 23/09/20151.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Lexical Analysis - An Introduction Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at.
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
Review: Regular expression: –How do we define it? Given an alphabet, Base case: – is a regular expression that denote { }, the set that contains the empty.
COMP 3438 – Part II - Lecture 2: Lexical Analysis (I) Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ. 1.
FLEX Fast Lexical Analyzer EECS Introduction Flex is a lexical analysis (scanner) generator. Flex is provided with a user input file or Standard.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
LEX (04CS1008) A tool widely used to specify lexical analyzers for a variety of languages We refer to the tool as Lex compiler, and to its input specification.
TRANSITION DIAGRAM BASED LEXICAL ANALYZER and FINITE AUTOMATA Class date : 12 August, 2013 Prepared by : Karimgailiu R Panmei Roll no. : 11CS10020 GROUP.
Lexical Analysis: Finite Automata CS 471 September 5, 2007.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
IN LINE FUNCTION AND MACRO Macro is processed at precompilation time. An Inline function is processed at compilation time. Example : let us consider this.
Introduction to Lex Fan Wu
Practical 1-LEX Implementation
1 Lex & Yacc. 2 Compilation Process Lexical Analyzer Source Code Syntax Analyzer Symbol Table Intermed. Code Gen. Code Generator Machine Code.
Introduction to Compiling
Introduction CPSC 388 Ellen Walker Hiram College.
Compiler Construction (CS-636)
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
Chapter 1: Introduction 1 Compiler Designs and Constructions Chapter 1: Introduction Objectives: Course Objectives Introduction Dr. Mohsen Chitsaz.
1 Steps to use Flex Ravi Chotrani New York University Reviewed By Prof. Mohamed Zahran.
Scanner Generation Using SLK and Flex++ Followed by a Demo Copyright © 2015 Curt Hill.
What is a compiler? –A program that reads a program written in one language (source language) and translates it into an equivalent program in another language.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Chapter – 8 Software Tools.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
More yacc. What is yacc – Tool to produce a parser given a grammar – YACC (Yet Another Compiler Compiler) is a program designed to compile a LALR(1) grammar.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
2-1. LEX & YACC. 2 Overview  Syntax  What its program looks like –Context-free grammar, BNF  Syntax-directed translation –A grammar-oriented compiling.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
9-December-2002cse Tools © 2002 University of Washington1 Lexical and Parser Tools CSE 413, Autumn 2002 Programming Languages
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture Ahmed Ezzat.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Requirements Specification
Chapter 1 Introduction.
Introduction to Compiler Construction
Programming Languages Translator
System Programming and administration
Compiler Construction
Chapter 1 Introduction.
Compiler Lecture 1 CS510.
Lexical and Syntax Analysis
Subject Name:Sysytem Software Subject Code: 10SCS52
CS 3304 Comparative Languages
Subject: Language Processor
Syntax Analysis - 3 Chapter 4.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Chapter 1 Introduction.
Presentation transcript:

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

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

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

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.

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.

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.

Static syntax analysis.htm