Unit 4 Unit 2 Overview of Language Pushdown
- Slides: 38
Unit – 4 Unit – 2 Overview of Language Pushdown Processor Automata Prof. Dixita Kagathara dixita. kagathara@darshan. ac. in System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
Topics to be covered • Overview of Language Processors • Programming Languages and Language Processors • Language Processing Activities • Fundamentals of language processor • Symbol tables • Data Structures for Language Processing: Search Data structures, Allocation Data Structures. Unit – 2 : Overview of Language Processor System Programming (2150708) 2 Darshan Institute of Engineering & Technology
What do you see? 10101001 00000000 10000101 0000000 110101001 0000 Binary program 10101001 00000010 10000101 00000010 10101001 00000010 10100000 10101001 00000010 10101001 0000000 110101001 00000010 What does it mean? ? 10010001 00000001 10000101 00000001 10101001 00000010 10101001 00000010 Unit – 2 : Overview of Language Processor System Programming (2150708) 3 Darshan Institute of Engineering & Technology
What do you see? Unit – 2 : Overview of Language Processor System Programming (2150708) 4 Darshan Institute of Engineering & Technology
Semantic gap 10101001 00000000 10000101 0000000 110101001 0000 Semantic Gap 10101001 00000010 10000101 00000010 10101001 00000010 10100000 10101001 00000010 Low level High level 10101001 0000000 110101001 00000010 10010001 00000001 10000101 0000 Actual Data Unit – 2 : Overview of Language Processor System Programming (2150708) Human perception 5 Darshan Institute of Engineering & Technology
Example: Semantic gap between domains Reservation system Semantic Gap Reservation Data Query Book It represents the difference between the semantic (rules) of two domains. CPU registers, Memory, I/O devices CPU Instructions Cancel Application Domain Execution Domain The designer expresses the ideas related in terms The ideas of designer, has to be interpreted in terms to the related to application domain of the software. execution domain of computer system. Unit – 2 : Overview of Language Processor System Programming (2150708) 6 Darshan Institute of Engineering & Technology
Semantic gap between domains Gap between application & programming language domain Gap between programming language & execution domain Execution Gap Specification Gap Reservation Data Query Data Structures CPU registers Memory I/O devices Functions CPU Instructions Book Cancel Application Domain Programming Language Domain Unit – 2 : Overview of Language Processor System Programming (2150708) 7 Execution Domain Darshan Institute of Engineering & Technology
Semantic gap = Specification gap + Execution gap Unit – 2 : Overview of Language Processor System Programming (2150708) 8 Darshan Institute of Engineering & Technology
Language processor • Language processor is a software which bridges a specification and/or an execution gap. Unit – 2 : Overview of Language Processor System Programming (2150708) 9 Darshan Institute of Engineering & Technology
Basic definitions • Language translator: Language translator bridges an execution gap between programming language and machine language of a computer system. Examples: Compiler, Interpreter, Assembler • De-translator: It bridges the same execution gap as language translator, but in the opposite direction. • Preprocessor: It is a language processor which bridges an execution gap but is not a language translator. • Language migrator: It bridges the specification gap between two programming languages. Unit – 2 : Overview of Language Processor System Programming (2150708) 10 Darshan Institute of Engineering & Technology
Language processing activity System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
Language processing activity Program generation Unit – 2 : Overview of Language Processor System Programming (2150708) 12 Program execution Darshan Institute of Engineering & Technology
Program generation activity • A program generation activity aims an automatic generation of a program. • Program generator is a software, which accepts the specification of a program and generates a program in target language that fulfills the specification. Errors Program specification Program in target language Program generation Unit – 2 : Overview of Language Processor System Programming (2150708) 13 Darshan Institute of Engineering & Technology
Language processing activity Program generation Unit – 2 : Overview of Language Processor System Programming (2150708) 14 Program execution Darshan Institute of Engineering & Technology
Program execution • Two models for program execution are: 1. Program Translation 2. Interpretation Unit – 2 : Overview of Language Processor System Programming (2150708) 15 Darshan Institute of Engineering & Technology
Program execution (Program translation) • The program translation model bridges the execution gap by translating a program written in programming language (PL), called source program, into an equivalent machine program or assembly language, called target program. Source Program Error Data Translator M/C language program Unit – 2 : Overview of Language Processor System Programming (2150708) 16 Results Darshan Institute of Engineering & Technology
Practical arrangement of language processors Skeletal Source Program Preprocessor Assembly Program Compiler Assembler Machine language Program Linker Data M/C language program Loader Results Unit – 2 : Overview of Language Processor System Programming (2150708) 17 Darshan Institute of Engineering & Technology
Program execution (Interpretation) • The interpreter reads the source program and stores it in its memory. • The CPU uses the program counter (PC) to note the address of the next instruction to be executed. • Steps for interpretation cycle are: 1. Fetch the statement. 2. Analyze the statement and determine what operation to be performed and which operands are their. Detect errors, if any. Memory Program counter Errors Source Program + Data Interpretation 3. Perform the operations. Unit – 2 : Overview of Language Processor System Programming (2150708) 18 Darshan Institute of Engineering & Technology
Fundamental of language processing System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
Fundamental of language processing Language processing = Analysis of Source Program + Synthesis of Target Program Language processor Source Program Analysis Phase Synthesis Phase Errors Unit – 2 : Overview of Language Processor System Programming (2150708) 20 Target Program Darshan Institute of Engineering & Technology
Phases of language processor (Toy compiler) Synthesis phase Analysis phase Lexical analysis Syntax analysis Intermediate code generation Semantic analysis Front end Unit – 2 : Overview of Language Processor System Programming (2150708) 21 Memory allocation Code generation Back end Darshan Institute of Engineering & Technology
Lexical analysis • Lexical analysis identifies the lexical unit in a source statement. • Lexical unit is called a token. • Categories of Tokens are: A = B + C Lexical analysis Id#1 Op#1 Id#2 Op#2 Id#3 1. Identifier 2. Keyword 3. Operator Symbol Type A (id#1) B (id#2) C (id#3) 4. Constant • Format of token is: Code #no Length Address • Lexical analyzer also builds symbol table. Unit – 2 : Overview of Language Processor System Programming (2150708) 22 Darshan Institute of Engineering & Technology
Syntax analysis • Syntax analysis processes the string of token to determine its grammatical structure and builds the tree structure. A = B + C Id#1 Op#1 Id#2 Op#2 Id#3 Syntax analysis = + A B Symbol Type A (id#1) B (id#2) C (id#3) Unit – 2 : Overview of Language Processor System Programming (2150708) 23 C Length Address Darshan Institute of Engineering & Technology
Semantic analysis • Semantic analysis determines the meaning of a statement by applying the semantic rules to the structure of the statement. • While processing a declaration statement, it adds information concerning the type and length of a symbol to the symbol table. Symbol Type A (id#1) Real B (id#2) Real C (id#3) Int C*(id#4) Real temp Real (id#5) Length Address 1 1 1 Unit – 2 : Overview of Language Processor System Programming (2150708) 24 = + A, real B, real C, int Semantic analysis = A, real + B, real C*, real = A, real temp, real Darshan Institute of Engineering & Technology
Intermediate code generation • Following two important properties of intermediate code are: 1. It should be easy to produce. 2. Easy to translate into target program. Symbol A (id#1) B (id#2) C (id#3) C*(id#4) temp (id#5) Type Real Int Real Length Address 1 1 1 Unit – 2 : Overview of Language Processor System Programming (2150708) 25 Convert (Id#3) to real, giving (Id#4) Add (Id#2) to (Id#4), giving (Id#5) Store (Id#5) in (Id#1) Darshan Institute of Engineering & Technology
Memory allocation The memory requirement of an identifier is computed from its type, length and dimensionality, accordingly memory is allocated to it. Symbol A B C Type Real Int Length 1 1 1 Address 2000 2001 2002 • The address of the allocated memory area is entered in the symbol table. Unit – 2 : Overview of Language Processor System Programming (2150708) 26 Darshan Institute of Engineering & Technology
Code generation • Two key decisions involved in generating good quality target code are: 1. Which instructions should be used for each of the actions in the intermediate code? 2. Which CPU registers should be used for evaluating expressions? CONV_R AREG, C CONV_R converts value of C to real and stores the result into AREG ADD_R AREG, B Adds the content of AREG and B MOVEM AREG, A Moves the content of AREG to memory area allotted to A Unit – 2 : Overview of Language Processor System Programming (2150708) 27 Darshan Institute of Engineering & Technology
Pass structure System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
Language processor pass • One complete scan of a source program is called pass. • A pass includes reading an input file and writing to the output file. • A language processor pass is the processing of every statement in a source program, or in its equivalent representation to perform language processing function. Source Program Front end (Pass I) Back end (Pass II) Target Program Intermediate representation Unit – 2 : Overview of Language Processor System Programming (2150708) 29 Darshan Institute of Engineering & Technology
Language processor pass Pass I • Perform analysis of the source program and note relevant information. Pass II • Perform synthesis of the target program. Source Program Front end (Pass I) Back end (Pass II) Target Program Intermediate representation Unit – 2 : Overview of Language Processor System Programming (2150708) 30 Darshan Institute of Engineering & Technology
Symbol table • A language processor uses the symbol table to maintain the information about attributes used in a source program. • Language processor performs following operations on the symbol table: 1. Add a symbol and its attributes: Make a new entry in the symbol table. 2. Locate a symbol’s entry: Find a symbol’s entry in the symbol table. 3. Delete a symbol’s entry: Remove the symbol’s information from the table. 4. Access a symbol’s entry: Access the entry and set, modify or copy its attribute information. Unit – 2 : Overview of Language Processor System Programming (2150708) 31 Darshan Institute of Engineering & Technology
Data structures for symbol table • Following data structures can be used for organizing symbol table’s entries: 1. Linear data structure: Entries in the symbol table occupy contiguous areas of memory. 2. Nonlinear data structure: Entries in the symbol table do not occupy contiguous areas of memory. Unit – 2 : Overview of Language Processor System Programming (2150708) 32 Darshan Institute of Engineering & Technology
Symbol table entry formats Attributes of different classes of symbols: Symbol Class Attributes Variable Type, length, number and bounds of dimensions Procedure Number of parameters, address of parameter list Function Number of parameters, address of parameter list , type of returned value, length of returned value Label Statement number Entry formats of the symbol table: 1. Fixed length entries: Each entry in the symbol table has fields for all attributes specified in the programming language. 2. Variable-length entries: the entry occupied by a symbol has fields only for the attributes specified for symbols of its class. 3. Hybrid entries: Combination of previous two. Unit – 2 : Overview of Language Processor System Programming (2150708) 33 Darshan Institute of Engineering & Technology
Search data structures System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
Search data structures • Search data structures (Search structure) are used to create and organize various tables of information and mainly used during the analysis of the program. • Types of search data structures are: 1. Sequential search organization 2. Binary search organization 3. Hash table organization 4. Linked list and tree structure organization Unit – 2 : Overview of Language Processor System Programming (2150708) 35 Darshan Institute of Engineering & Technology
Allocation data structures System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
Allocation data structures • Allocation strategy is an important factor in efficient utilization of memory. • Types of allocation data structures are: 1. Stack allocation 2. Heap allocation Unit – 2 : Overview of Language Processor System Programming (2150708) 37 Darshan Institute of Engineering & Technology
End of Unit - 2 System Programming (2150708) Unit – 2 : Overview of Language Processor Darshan Institute of Engineering & Technology
- 2 stack pda
- Pushdown automata examples
- Pushdown automata adalah
- Pushdown accounting
- Pda to cfg
- Design pushdown automata
- Pushdown automata implementation
- Contoh soal push down automata
- Pushdown automata
- Dpda vs npda
- Pushdown automata
- Pushdown automata
- Automata
- Pushdown automata
- Pushdown automata
- Pushdown automata
- C language overview
- What is an informal email
- Unit 6 review questions
- Overview of www
- Maximo overview
- Universal modelling language
- Uml
- Vertical overview
- Figure 12-1 provides an overview of the lymphatic vessels
- Pulmonary circulation
- Texas public school finance overview
- Walmart company overview
- What is stylistic overview
- Jackson structured design
- Spring framework overview
- Nagios tactical overview
- Market overview managed file transfer solutions
- Sdn nfv overview
- Sbic program overview
- Quota sap
- Ariba registration process
- Safe overview
- Rfid technology overview