Thursday, March 24, 2016
Discuss the capabilities of CFG
12:59 PM
No comments
The capabilities of CFG :
Context free grammars are capable of describing most of the syntax of programming language. suitable grammars for expressions can often be constructed using associatively & precedence information. So, context free grammar are most useful in describing nested structures such as balanced parentheses, matching begin-end's, corresponding if-then-else's & so on. These nested structures cannot be described by regular expression. The following grammars the string, which serves the language.
Stat ...
What is CFG?Advantages of CFG
12:52 PM
No comments
Context Free Grammar : A CFG is a way of describing language by recursive rules. A CFG consists four tuples, denoted G = {V, T, P, S}
Where,
V = Finite set of variables. [Eg. {S, E}etc.]
T = Finite set of terminals. [Eg. {a, b, c,+}etc.]
P = Finite set of productions. [Eg. E E+E]
...
What is drawback of operator precedence parsing?
12:46 PM
No comments
Drawback of operator precedence parsing :
Difficult to find token from the operator precedence parsing.
It is itself tenuous. One can't always be sure the parser accepts exactly the desired language.
Only a small class of grammar can be using operator precedence techniques.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Context Free Grammar With Example?
12:36 PM
No comments
Context Free Grammar : A CFG is a way of describing language by recursive rules. A CFG consists four tuples, denoted G = {V, T, P, S}
Where,
V = Finite set of variables. [Eg. {S, E}etc.]
T = Finite set of terminals. [Eg. {a, b, c,+}etc.]
P = Finite set of productions. [Eg. E E+E]
...
What are the differences between single pass & multi-pass compiler?
12:25 PM
No comments
The differences between single pass & multi-pass compiler :
Single Pass Compiler
Multi-Pass Compiler
1. Single pass compiler can be made to use more space than multi-pass compiler
1. Multi - pass compiler can be made to use less space than a single -pass compiler
2. Single pass compiler is faster than a multi -pass compiler
2. Multi - pass compiler is slower than a single pass compiler because each pass reads & writes an intermediate file.
...
Translate the expression -
11:55 AM
No comments
Translate the expression -
-(a+b)*(c+d)+(a+b+c) into (ii) Quadruples
At first we construct the three address code the above expression :
Three address code :
0) T1 : = a+b
1) T2 : = -T1
2) T3 : = c+d
3) T4 : = T2*T3
4) T5 : = a+b
5) T6 : = T5+c
6) T7 : = T4+T6
SL NO
OP
ARG1
ARG2
RESULT
(0)
+
a
b
T1
(1)
uminus
T1
-
T2
(2)
+
c
d
T3
...
Translate the following assignment statement A : = -B*(C+D) into three address, quadruple & triple forms
11:39 AM
No comments
Translate the following assignment statement A : = -B*(C+D) into three address, quadruple & triple forms
Here, given the expression - A: = -B*(C+D)
Three-address code :
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
These statement are represented by quadruples as shown in fig . (a)
SL NO
OP
ARG1
ARG2
RESULT
(0)
Uminus
B
-
T1
(1)
+
C
D
T2
...
Briefly describes quadruples, triples in representation of three address statements. What ate the benefits of quadruples over triples in optimizing compiler?
11:27 AM
No comments
Quardruples : Quadruples representation the three - address code by using four fields
These are -
OP, ARG1, ARG2 & RESULT.
Implementation of quadruples : Let us consider the following three - address code :
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
These statement are represented by quadruples as shown in fig . (a)
SL NO
OP
ARG1
ARG2
RESULT
...
Find the postfix notation for the following expressions -
10:11 AM
No comments
(i) (a+b) - c & (ii) a - (b+c)
(i) The postfix notation - (a+b)-c
= [ab+]-c
...
Discuss the purpose of the fields of an activation record
9:54 AM
No comments
Discuss the purpose of the fields of an activation record
Activation Code : Stack allocation collect fixed -storage by using activation record. The activation record contain the following steps -
Storage for simple name & pointers to array & other data structures local to the procedure.
Temporaries for expression evaluation & parameter passing.
Information regarding attributes for local names & formal parameters, when these cannot be determined at compile time.
The return address.
A portion to the activation record of...
Write a translation scheme for providing three -address code for Boolean expressions : "OR", "AND" and "NOT"
9:32 AM
No comments
Write a translation scheme for providing three -address code for Boolean expressions : "OR", "AND" and "NOT"
A OR B, A AND D, NOT D.
So, the translation scheme becomes -
T1 : = A OR B
T2 : = A AND D
T3 : = NOT D.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Activation Code?
9:25 AM
2 comments
Activation Code : Stack allocation collect fixed -storage by using activation record. The activation record contain the following steps -
Storage for simple name & pointers to array & other data structures local to the procedure.
Temporaries for expression evaluation & parameter passing.
Information regarding attributes for local names & formal parameters, when these cannot be determined at compile time.
The return address.
A portion to the activation record of the caller.
If You want to learn about the technology,...
What is Postfix notation/Reverse Polish notation With Example?
9:17 AM
No comments
Postfix notation/Reverse Polish notation :
It is the form of an expression obtained from postorder traversal of the
tree representing this expression. So, in the postfix notation,
operators must be placed after the operands.
Example : AB+, CD*, GH/ .
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Prefix notation/Polish notation With Example?
9:14 AM
No comments
Prefix notation/Polish notation : It is the form of an expression obtained from preorder traversal of the tree representing this expression. So, in the prefix notation, operators must be placed before the operands.
Example : +AB, *CD, /GH
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is infix notation with example?
9:08 AM
No comments
Infix notation : It is the form of an expression obtained from in order traversal of the tree representing this expression. So in the infix notation, Operators must be placed in the operands.
Example : A+B, C*D, /GH
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Intermediate Language with two properties?
9:05 AM
No comments
Intermediate Language with two properties : - After syntax & semantic analysis the compiler generates an explicit intermediate representation of the source program. This, intermediate representation as a program for an abstract machine.
It has two properties -
It should be easy to produce &
Easy to translate into the target program.
The intermediate code generates the intermediate language which is involve during code generation.
If You want to learn about the technology, computer science & engineering, web...
What is Object Program?
8:59 AM
No comments
Object Program : The output of a code generator is the object program. This takes a variety of forms : an absolute machine - language program, a locatable machine - language program, an assembly -language program & other language program.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
Explain Syntax - Directed translation
2:53 AM
No comments
Syntax - Directed translation : Syntax - directed translation schemes to describe the output to generate for each input construct. A syntax - directed translation is merely a CFG in which a program fragment called an output action ( or sometimes a semantic action or semantic rule) is associated with each production for example, suppose output action is, associated with production A tensto XYZ. The action is executed whenever the syntax analyzer recognizing in its input a sub - string w which has a derivation of the form A or ...
What is the way to represent 3-address code? Write down the advantage & disadvantage of quadruples over triples?
2:42 AM
No comments
Three Address Code: Three address statements are a sequence of statements.
Typically,
the general form A : B op C, where A, & C are either programmer
defined names. Constants or compiler - generated temporary names. Op
stands for any operator, such as a fixed or floating -point arithmatic
operator or a logical operator on Boolean -valued data. Three address
statements usually contain three addresses, two for the operands &
one for the result.
Example : Let us consider the expression A : = -B*(C+D).
We get the following...
Define different types of translation with example
2:23 AM
No comments
Different types of translation with example :
A translation is an input/output mapping. Generally three types of translation scheme are used -
Three Address Statements
Quadruples &
Triples
Three Address Statements : Three address statements are a sequence of statements.
Typically, the general form A : B op C, where A, & C are either programmer defined names. Constants or compiler - generated temporary names. Op stands for any operator, such as a fixed or floating -point arithmatic operator or a logical operator...
Wednesday, March 23, 2016
What is Suffix?
11:57 PM
No comments
Suffix : A Suffix of a string is any number of trailing symbols of that string.
Example : String abc has suffix - epsilon, c, bc, ab...
What is Prefix?
11:55 PM
No comments
Prefix : A prefix of a string is any number of leading symbols of that string.
Example : String abc has prefix - epsilon, a, bc, ab...
What is String(Word)?
11:49 PM
No comments
String(Word) : A string (word) is a finite sequence of symbols of that string .
Example : abc, 01110 are the examples of string
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Symbol?
11:46 PM
No comments
Symbol : A symbol is an abstract entity set we shall not define formally; just an point & line are not defined in geometry.
Example : Letter & digits are examples of symbol.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Lexema?
11:36 PM
No comments
Lexema : A lexema is a sequence of characters in the source program that is matched by the pattern for a token.
Example : For Pascal statement -
Cons pi = 3.1416;
Here, the sub-string pi is a lexema for the token "identifier."
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Token?
11:28 PM
No comments
Token : The string representing a program can be partitioned at the lowest level into a sequence of sub-string called tokens. Each token is a sequence of characters whose significant is possessed collectively rather than individually.
Example : Generally, these are used as tokens -
Constants, e.g. 1.2.3.4.
Operator symbols, e.g. +,-,*.EQ,
Identifiers e.g. A, H2035B, SPEED,
Keywords e.g, IF, GOTO, SUBROUTINE.
Punctuation symbols, e.g. parenthesis, brackets, coma & semicolon.
If You want to learn about the technology, computer...
What is Regular Expression? Properties of regular expression
11:16 PM
No comments
Regular Expression : The language accepts by finite automata are easily described by simple expression called regular expression.
Regular expression operators are union , concatenation & closure/star.
Properties of regular expression :
Faka Set is a regular expression & denotes the empty set.
Epsilon is regular expression & denotes the set {Epsilon}
For each a in . a is a regular expression & denotes the set {a}.If r & s are regular expressions denoting...
Using suitable block diagram shows the different phases of a compiler & briefly describes the phases.
10:50 PM
No comments
Using suitable block diagram shows the different phases of a compiler & briefly describes the phases.
Or,Describe the function of the five main component of compiler.
A compiler operates in phases, each of which transform the source program from one representation to another. Generally, these are six types of phases in compiler. These are -
Lexical Analysis
Syntax Analysis
Semantic Analysis
Intermediate code generation
Code Optimization
Code Generation
Lexical Analysis : Linear Analysis is called lexical analysis or scanning....
What is Interpreter?
10:32 PM
No comments
Interpreter : Interpreter is kinds of translator that translates & execute each source language statement before translating & executing next one but don't produce an object program.
Interpreter are frequently used to execute command language. Since each operator executed in a command language is usually an invocation of a complex routine such as high level language.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What is Assembler?
10:28 PM
No comments
Assembler : Assembly code is passed to an assembler for further processing that is, if the source language is assembly language language & the target language is machine language, Then the translator is called assembler.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOL...
What are the properties that good error detection & diagnostic should have?
10:22 PM
No comments
The properties that good error detection & diagnostic should have :
Good error diagnostic can significantly help reduce debugging & maintenance effort. These are the properties of good error detection & diagnostic -
The message should pinpoint the errors of the original source program. Rather than in terms of some internal representation that is totally mysterious to the user.
The error message should be tasteful & understandable by the user.
If You want to learn about the technology, computer science &...
From a compiler a designer point of view, what are the source of errors in compiler?
10:16 PM
No comments
From a compiler a designer point of view, the source of errors in compiler :
There are many sources to occur error. These are the source of errors in compiler-
At the very onset, the design specifications for the program may be inconsistent or faulty.
The algorithms are incorrect or inadequate (algorithmic errors).
The programmer may introduce error in implementing the algorithm - such as logical errors or coding error.
Key punching or transcription errors can occur when the program is types on to cards or into a file.
The program may...
Write the advantages of high -level language
10:17 AM
No comments
The advantages of high -level language : These are the advantages of high level language-
Ease of understanding
Naturalness
Portability &
Efficiency of use
Ease of understanding : - A high level language program is generally easier to read. Write & prove correct than is an assembly language program.
Naturalness : Much of the understanding of a high - level programming language comes from the ease with which one can express an algorithm in that language.
Portability : - User often be able to run their...
Write the necessary/motive of compiler
9:23 AM
No comments
The necessary/motive of compiler : A compiler is a program that reads a program written in one language - the source language & translates it into an equivalent program in another language - the target language.
So, the main motive of compiler that if reports to its user the presence of errors in the source program.
A compiler can also assist in producing reliable program. For Example, a compiler could check that the types of operands are compatible.
Compiler can also acts as index by using symbol table.
Some compiler makes...
Tuesday, March 22, 2016
Write some advantages & limitations of parses
11:50 AM
No comments
Write some advantages & limitations of parses.
Pass: When one or more phases are combined into a module then the module is referred as pass. A pass is read the source program to the output of the previous pas, makes the transformations specified by its phases & writes output into an intermediate file.
Advantages :
Reduced memory space.
Requires less time.
Limitations of parses :-
The interface between the lexical & syntactic analyzer can often be limited to a single token.
It is very hard to perform...
What is intermediate code? Why it is necessary in compiler?
11:41 AM
No comments
Intermediate Code : After syntax & semantic analysis the compiler generates an explicit intermediate representation of the source program. thsi, intermediate representation as a program for an abstract machine. It has two properties-
It should be easy to produce &
Easy to translate into the target program.
Necessary in compiler:
To generate machine/assembly language
To create stream of simple instructios after syntax analysis.
If You want to learn about the technology, computer science & engineering, web...
What are the types of errors found in different phases of compiler?
11:35 AM
No comments
The types of errors found in different phases of compiler-
The lexical analyzer may be unable to proceed because the next token in the source program is misspelled.
The syntaxb analyzer may be unable to infer structure for its input because a syntatic error such as a missing parenthesis has occured.
The intermediate code generation detects an operator whose operands have incompatible types.
The code optimizer, doing control flow analysis, may detect that certain statements can never be reached.
The code generator may find a compiler...
Describe the main problem in code generation
11:24 AM
No comments
The main problem in code generation:
There are three main problems occur in code generation. They are-
Deciding what machine instructions to generate.
Deciding in what order the computations should be done.
Deciding which register to use.
What instructions should we generate?
Most machines permit certain computations to be done in a variety of ways.
For Example: The target machine has an "add-one-to-storage" instruction (AOS), then for the three-address statement A : = A+1. We might generate the signal...
What is a DAG for basic blocks? Construct the DAG for the following basic blocks
10:58 AM
No comments
What is a DAG for basic blocks? Construct the DAG for the following basic blocks
DAG(Directed acyclic graph):
A Directed acyclic graph is a graph with no cycles which gives a
picture of how the value computed by each statement in a basic block is
used in subsequent statement in the block . That is, a DAG has node for
every sub-expression of the expression. An interior node represents n
operator & its child represents an operand.
DAG is mainly used to identify the same expression.
Example: Let us the following...
Describe primary structure-preserving transformations on basic blocks
10:54 AM
No comments
Describe primary structure-preserving transformations on basic blocks
Primary structure-preserving transformations on basic blocks-
Common sub-expression elimination
Dead-code elimination
Renaming of temporary variable
Interchanging of two independent-adjacent statements.
Common sub-expression elimination: Consider the basic block-
a : = b+c c : = b+c
b : = a-d d : = a-d
The 2nd and fourth statements compute same expression namely b + c -...
What do you understand by dead elimination?
10:46 AM
No comments
Dead elimination: A variable is live at a point in a program if its value can be used subsequently. Otherwise it is dead at that point. Let us a variable x is dead. That is, never subsequently used, at the point where the statement x : = y + z appears in a basic block. Then this statement may be safely removed without changing the value of the basic block.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
Write the major issues in the design of a code generator?
10:33 AM
No comments
The major issues in the design of a code generator
There are some major issues in the design of a code generator. They are -
Memory Management
Instruction selection
Register allocation
Evaluation order
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
What are the advantages of generating intermediate code?
10:30 AM
No comments
The advantages of generating intermediate code
Intermediate Code Generation: After syntax & semantic analysis the compiler generates an explicit intermediate representation of the source program. To implement intermediatecode such as -
It should be easy to produce &
Easy to translate into the target program
Retargeting is faciliated.
Finally, the representation of intermediate code is directly executed using a program, which is referred to as interpreter.
If You want to learn about the technology, computer science...
Basic Blocks
6:30 AM
No comments
Basic Blocks: A basic block is a sequence of consecutive statement in which flow of control enters at the beginning & leaves at the end without halt or possibility of branching except at the end of the basic block. The following sequence of three address statement form a basic block which is shown:
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SO...
DAG(Directed acyclic graph)
6:26 AM
No comments
DAG(Directed acyclic graph): A Directed acyclic graph is a graph with no cycles which gives a picture of how the value computed by each statement in a basic block is used in subsequent statement in the block . That is, a DAG has node for every sub-expression of the expression. An interior node represents n operator & its child represents an operand.
DAG is mainly used to identify the same expression.
Example: Let us the following expression-
a + a*(b-c)+(b-c)*d.
DAG for...