Found 138 Articles for Compiler Design

What is Operator Precedence Parsing Algorithm in compiler design?

Ginni
Updated on 29-Oct-2021 13:07:17

5K+ Views

Any string of Grammar can be parsed by using stack implementation, as in shift Reduce parsing. But in operator precedence parsing shifting and reducing is done based on Precedence Relation between symbol at the top of stack & current input symbol of the input string to be parsed.The operator precedence parsing algorithm is as follows −Input − The precedence relations from some operator precedence grammar and an input string of terminals from that grammar.Output − There is no output but it can construct a skeletal parse tree as we parse, with one non-terminal labeling all interior nodes and the use ... Read More

What are LEADING and TRAILING operation of an operator precedence grammar?

Ginni
Updated on 29-Oct-2021 10:59:15

10K+ Views

LEADINGIf production is of form A → aα or A → Ba α where B is Non-terminal, and α can be any string, then the first terminal symbol on R.H.S isLeading(A) = {a}If production is of form A → Bα, if a is in LEADING (B), then a will also be in LEADING (A).TRAILINGIf production is of form  A→ αa or A → αaB where B is Non-terminal, and α can be any string then, TRAILING (A) = {a}If production is of form  A → αB. If a is in TRAILING (B), then a will be in TRAILING (A).Algorithm to ... Read More

What is Operator Precedence Parsing?

Ginni
Updated on 29-Oct-2021 08:51:37

9K+ Views

Operator Precedence Parsing is also a type of Bottom-Up Parsing that can be used to a class of Grammars known as Operator Grammar.A Grammar G is Operator Grammar if it has the following properties −Production should not contain ϵ on its right side.There should not be two adjacent non-terminals at the right side of production.Example1 − Verify whether the following Grammar is operator Grammar or not.E → E A E |(E)|idA → +| − | ∗SolutionNo, it is not an operator Grammar as it does not satisfy property 2 of operator Grammar.As it contains two adjacent Non-terminals on R.H.S of ... Read More

Construct NFA for the following language and convert it into DFA using the algorithm - L = (aa+ (bb*)c*)

Ginni
Updated on 29-Oct-2021 08:28:42

798 Views

SolutionNFA for the above language will be −Conversion from NFA to DFA −ε − closure(0) = {0, 1, 4} = AFor State AFor input symbol aFor input symbol bFor input symbol c∴ Ta = {2}∴ Tb = {5}Tc = ∅∴ ε − closure (Ta)                       = ε                      − closure (2)= {2} = B∴ ε − closure (Tb)                        = ε                        ... Read More

What is the Representation of DFA in compiler design?

Ginni
Updated on 29-Oct-2021 07:48:47

2K+ Views

Deterministic means that on each input there is one and only one state to which the automata can have the transition from its current state. In deterministic finite automata, the head can move only in one direction to scan the input tape symbols. But in the case of two-way, finite automata on scanning an input symbol the head of the tape may move in right or left from its current position.A deterministic finite automata is a set of 5 tuples and defined asM = (Q, Σ, δ, q0, F)Q: A non-empty finite set of states present in the finite control ... Read More

What is Stack Implementation of Shift Reduce Parsing in compiler design?

Ginni
Updated on 29-Oct-2021 07:30:22

5K+ Views

Shift reduce parser is a type of bottom-up parser. It uses a stack to hold grammar symbols. A parser goes on shifting the input symbols onto the stack until a handle comes on the top of the stack. When a handle occurs on the top of the stack, it implements reduction.There are the various steps of Shift Reduce Parsing which are as follows −It uses a stack and an input buffer.Insert $ at the bottom of the stack and the right end of the input string in Input Buffer.Shift: Parser shifts zero or more input symbols onto the stack until ... Read More

What is Top-Down Parsing?

Ginni
Updated on 29-Oct-2021 06:59:41

11K+ Views

In top-down parsing, the parse tree is generated from top to bottom, i.e., from root to leaves & expand till all leaves are generated.It generates the parse tree containing root as the starting symbol of the Grammar. It starts derivation from the start symbol of Grammar & performs leftmost derivation at each step.Drawback of Top-Down ParsingTop-down parsing tries to identify the left-most derivation for an input string ω which is similar to generating a parse tree for the input string ω that starts from the root and produce the nodes in a pre-defined order.The reason that top-down parsing follow the ... Read More

What are Parsing Techniques in Compiler Design?

Ginni
Updated on 29-Oct-2021 06:57:11

11K+ Views

Parsing is known as Syntax Analysis. It contains arranging the tokens as source code into grammatical phases that are used by the compiler to synthesis output generally grammatical phases of the source code are defined by parse tree. There are various types of parsing techniques which are as follows −Top-Down ParserIt generates the Parse Tree from root to leaves. In top-down parsing, the parsin begins from the start symbol and changes it into the input symbol.An example of a Top-Down Parser is Predictive Parsers, Recursive Descent Parser.Predictive Parser − Predictive Parser is also known as Non-Recursive Predictive Parsing. A predictive ... Read More

What is the role of the lexical analyzer in compiler design?

Ginni
Updated on 07-Nov-2023 05:29:58

40K+ Views

The lexical analysis is the first phase of the compiler where a lexical analyser operate as an interface between the source code and the rest of the phases of a compiler. It reads the input characters of the source program, groups them into lexemes, and produces a sequence of tokens for each lexeme. The tokens are sent to the parser for syntax analysis.If the lexical analyzer is located as a separate pass in the compiler it can need an intermediate file to locate its output, from which the parser would then takes its input. It can eliminate the need for ... Read More

What is Ambiguous Grammar?

Ginni
Updated on 26-Oct-2021 08:59:12

16K+ Views

A Grammar that makes more than one Leftmost Derivation (or Rightmost Derivation) for the similar sentence is called Ambiguous Grammar.Example − Verify whether the following Grammar is Ambiguous or Not.E → E+E|E $\ast$ E|idSolutionFor string id + id * id, there exist two parse trees.E ⇒lm $\underline{E}$+E ⇒ id+ $\underline{E}$⇒ id+$\underline{E}$ $\ast$ E⇒ id+id $\ast$ $\underline{E}$⇒ id+id $\ast$ idE ⇒lm $\underline{E}$ $\ast$ E⇒ $\underline{E}$+E $\ast$ E⇒ id+ $\underline{E}$ $\ast$ E⇒ id+id $\ast$ $\underline{E}$⇒ id+id $\ast$ idSo, the same string is generated using two different leftmost derivations. Each is having a different parse tree.∴ Two different parse trees exist for string id + id ... Read More

Previous 1 ... 7 8 9 10 11 ... 14 Next
Advertisements