- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 138 Articles for Compiler Design
4K+ Views
Boolean means True or False. It can also be represented by 1 or 0.Boolean Expression is the expression that returns true or false. Boolean Expression can be represented in two ways−Conditional ExpressionsFor example, If a > b{ cout Y)A = B + CSolution(1) If A < B goto(4)(2) If X > Y goto(4)(3) goto(6)(4) T = B + C(5) A = TExample3− Write three address code for a > b 𝐀𝐍𝐃 c < d 𝐀𝐍𝐃 e < f.Solution(1) If a > b goto(4)(2) t1 = 0(3) goto(5)(4) t1 = 1(5) If c < d goto(8)(6) t2 = 0(7) goto(9)(8) t2 = 1(9) If e < f goto(12)(10) t3 = 0(11) goto(13)(12) t3 = 1(13) t4 = t1 𝐀𝐍𝐃 t2(14) t5 = t4 𝐀𝐍𝐃 t3
4K+ Views
Assignment statements consist of an expression. It involves only integer variables.Abstract Translation SchemeConsider the grammar, which consists of an assignment statement.S → id = EE → E + EE → E ∗ EE → −EE → (E)E → idHere Translation of E can have two attributes −𝐄. 𝐏𝐋𝐀𝐂𝐄− It tells about the name that will hold the value of the expression.𝐄. 𝐂𝐎𝐃𝐄− It represents a sequence of three address statements evaluating the expression E in grammar represents an Assignment statement. E. CODE represents the three address codes of the statement. CODE for non-terminals on the left is the concatenation of ... Read More
28K+ Views
SolutionFirst of all this statement will be converted into Three Address Code as−t1 = a + bt2 = −t1t3 = c + dt4 = t2 ∗ t3t5 = t1 + ct6 = t4 − t5QuadrupleLocationOperatorarg 1arg 2Result(0)+abt1(1)−t1t2(2)+cdt3(3)∗t2t3t4(4)+t1ct5(5)−t4t5t6 TripleLocationOperatorarg 1arg 2(0)+ab(1)−(0)(2)+cd(3)∗(1)(2)(4)+(0)c(5)−(3)(4)Array RepresentationQuadruple is a structure that contains atmost four fields, i.e., operator, Argument 1, Argument 2, ... Read More
8K+ Views
There are three implementations used for three address code statements which are as follows −QuadruplesTriplesIndirect TriplesQuadruplesQuadruple is a structure that contains atmost four fields, i.e., operator, Argument 1, Argument 2, and Result.OperatorArgument 1Argument 2ResultFor a statement a = b + c, Quadruple Representation places + in the operator field, a in the Argument 1 field, b in Argument 2, and c in Result field.For example− Consider the Statementa = b + c * dFirst, convert this statement into Three Address code∴ Three Address code will bet1 = c ∗ dt2 = b + t1a = t2.After construction of the Three ... Read More
16K+ Views
The three-address code is a sequence of statements of the form A−=B op C, where A, B, C are either programmer-defined names, constants, or compiler-generated temporary names, the op represents an operator that can be constant or floatingpoint arithmetic operators or a Boolean valued data or a logical operator. The reason for the name “three address code” is that each statement generally includes three addresses, two for the operands, and one for the result.In the three-address code, atmost three addresses are define any statement. Two addresses for operand & one for the result.Hence, op is an operator.An only a single ... Read More
21K+ Views
Parse TreeParse tree is a hierarchical structure that defines the derivation of the grammar to yield input strings. In parsing, the string is derived using the start symbol. The root of the parse tree is that start symbol. It is the graphical description of symbols that can be terminals or non-terminals. Parse tree follows the precedence of operators. The deepest sub-tree traversed first. Therefore, the operator in the parent node has less precedence over the operator in the sub-tree.A Parse Tree for a CFG G = (V, Σ, P, S) is a tree satisfying the following conditions −Root has the ... Read More
24K+ Views
Tree in which each leaf node describes an operand & each interior node an operator. The syntax tree is shortened form of the Parse Tree.Example1 − Draw Syntax Tree for the string a + b ∗ c − d.Rules for constructing a syntax treeEach node in a syntax tree can be executed as data with multiple fields. In the node for an operator, one field recognizes the operator and the remaining field includes a pointer to the nodes for the operands. The operator is known as the label of the node. The following functions are used to create the nodes ... Read More
22K+ Views
The translation of the source code into the object code for the target machine, a compiler can produce a middle-level language code, which is referred to as intermediate code or intermediate text. There are three types of intermediate code representation are as follows −Postfix NotationIn postfix notation, the operator comes after an operand, i.e., the operator follows an operand.ExamplePostfix Notation for the expression (a+b) * (c+d) is ab + cd +*Postfix Notation for the expression (a*b) - (c+d) is ab* + cd + - .Syntax TreeA tree in which each leaf node describes an operand & each interior node an ... Read More
16K+ Views
In postfix notation, the operator appears after the operands, i.e., the operator between operands is taken out & is attached after operands.Example1 − Translate a ∗ d − (b + c) into Postfix form.Solutionad ∗ bc + −Example2 − Convert a + (b ∗⊝ c) is in Postfix form.SolutionHere ⊝ represents the unary minus operator.a b c ⊝ ∗ +Example3 − Convert Postfix Expression into Infix Expression using Stack Implementationa d ∗ bc + −SolutionString SymbolsStackad ∗ bc + −AADad*(a * d)B(a * d)bC(a * d)b c+(a ∗ d)(b + c)-(a ∗ d)-(b + c)Example4 − Calculate the value for ... Read More
20K+ Views
Intermediate code can translate the source program into the machine program. Intermediate code is generated because the compiler can’t generate machine code directly in one pass. Therefore, first, it converts the source program into intermediate code, which performs efficient generation of machine code further. The intermediate code can be represented in the form of postfix notation, syntax tree, directed acyclic graph, three address codes, Quadruples, and triples.If it can divide the compiler stages into two parts, i.e., Front end & Back end, then this phase comes in between.Example of Intermediate Code Generation −Three Address Code− These are statements of form ... Read More