Mobile Cloning

Topics: Compiler, Parsing, Compiler optimization Pages: 28 (4981 words) Published: March 3, 2013
Compiler Design

1 What is compiler?
Ans:- A compiler is a program that translates human readable source code into computer executable machine code. To do this successfully the human readable code must c omply with the syntax rules of whichever programming language it is written in. The compiler is only a program and cannot fix your programs for you. If you make a mistake, you have to correc t the syntax or it won't compile

2 compare NFA and DFA ?
Ans:DFA- single value transition function is represented
- it take more memory space
- number of state is more
- it not support null move
- backtracking is possible
-dfa is faster recognizer
NFA- multi value transition function is represented
- it take less memory space
- number of state is less
- it support null moves
- backtrakin is possible some cases
- nfa is slower recognizer
3 Define bootstrap and cross compiler?
Ans:- Bootstrap:In computing, bootstrapping (from an old expression "to pull oneself up by one's bootstraps") is a technique by which a simple computer program activates a more complicated system of programs. In the start up process of a computer system, a small program (such as BIOS) initializes and tests that a basic requirement of hardware, peripherals and external memory devices are connected. Cross compiler:A compiler that runs on one computer but produces object code for a different type of computer. Cross compilers are used to generate software that can run on computers with a new architecture or on specialpurpose devices that cannot host their own compilers. 4 Define token lexeme pattern ?

Ans:- Token-A lexical token is a sequence of characters that can be treated as a unit in the grammar of the programming languages.
Example of tokens:
Type token (id, num, real, . . . )
Punctuation tokens (IF, void, return, . . . )
Alphabetic tokens (keywords)
Example of non-tokens:
Comments, preprocessor directive, macros, blanks, tabs, newline, . . .

Lexeme-A lexeme is a sequence of characters in the source program that is matched by the pattern for a token.

For example, the pattern for the RELOP token contains six lexemes ( =, < >, , >=) so the lexical analyzer should return a RELOP token to parser whenever it sees any one of the six. Pattern-There is a set of strings in the input for which the sam e token is produced as output. This set of strings is described by a rule called a pattern associated with the token. Regular expressions are an important notation for specifying patterns. For example, the pattern for the Pascal identifier token, id, is: i d → letter (letter | digit)*. 5 What is compilation ? Describe phase of compiler with diagram . Compilation :- 1 the action or process of compiling.

2 a thing, especially a book or record, compiled from different sources. Phase of compiler:- There are 6 phases a typical compiler will implement. The major reason why separate a compiler into 6 phases is probably simplicity. Compiler design is thus full of ``Divide and Conquer'' strategy, component-level design, reusabililty and performance optimization. Lexical Analysis

Syntax Analysis
Error Recovery
Scope Analysis
Type Analysis
Code Generation




Programmer (source code

Source string


Scanner (performs lexical analysis)

Token string

‘A’, ‘=’, ‘B’, ‘+’, ‘C’, ‘;’
And symbol table with names

Parser (performs syntax analysis
based on the grammar of the
programming language)

Parse tree or abstract
syntax tree


Semantic analyzer (type checking,

Annotated parse tree or
abstract syntax tree

Intermediate code generator

Three-address code, quads,
or RTL

int2fp B
+ t1 C t2
:= t2


Three-address code, quads,
or RTL

int2fp B
+ t1 #2.3 A

Code generator

Assembly code

MOVF #2.3,r1
ADDF2 r1,r2

Peephole optimizer

Assembly code

ADDF2 #2.3,r2

6 Compare...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Cloning Essay
  • Cloning Essay
  • Cloning Research Paper
  • On Cloning Essay
  • CLONING Essay
  • cloning Essay
  • Cloning Essay
  • Cloning Essay

Become a StudyMode Member

Sign Up - It's Free