0% found this document useful (0 votes)
51 views

Assignment of Syntax Analysis

The document discusses several context-free grammars and asks questions about analyzing them: - It asks to simplify some context-free grammars (CFGs) by reducing the number of productions. - It asks whether certain CFGs are LL(1) or not and to justify the answer. - It asks to construct an operator precedence parser for a CFG. - It asks how to construct an LR(0) parser from a CFG including building the canonical collection of items and LR(0) parsing table.

Uploaded by

Hiziki Tare
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Assignment of Syntax Analysis

The document discusses several context-free grammars and asks questions about analyzing them: - It asks to simplify some context-free grammars (CFGs) by reducing the number of productions. - It asks whether certain CFGs are LL(1) or not and to justify the answer. - It asks to construct an operator precedence parser for a CFG. - It asks how to construct an LR(0) parser from a CFG including building the canonical collection of items and LR(0) parsing table.

Uploaded by

Hiziki Tare
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment of Syntax

Analysis
Dr Anil Kumar
Simplify the CFG
 S aS | A | C  S aBa | abba
 Aac | B  ABC | b
 B bb | aa  Bab | C | ε
 CaCb | ε  CaC | B | ε
 AXY  SAaA | CA | BAB
 Xx | Y  AaaBa | CDA | aa | DC
 Yy | Z  BbB | bAB | bb | aS
 PaZ | ε  CCa | bC | D
 Qb | ε  DbD | ε
 SAB | a
 ABC | b
 Bab | C
 CaC | ε
By using Top down parser, determine following grammar is
LL(1) or not. If Yes Justify, if not Justify
 S->AaB | CbB | Ba  S aBa | abba
 Ada | BC  ABC | b
 Bg | ε  Bab | C | ε
 Ch | ε  CaC | B | ε
 SBbC | cB | Ba  SAaA | CA | BAB
 Aab | Cb  AaBa | aa | DC
 BcB | BC | ε  BbB | bAB | bb
 Ch | aB | ε  CCa | bC | D | ε
 SAaB | CbB | Ba  DbD | ε
 Aha | BC
 Bg | h | ε
 C h| ε
Construct Operator Precedence Parser for the following grammar

 S(L) | a
 LL, S | S
 Also parse the following string:
 (a , ( a , a ))
How to construct LR(0) parser, canonical collection of items and LR(0) parser table

 S->AA  S aBA
 AaA | b  ABC | b
 SABC  Bab | C | ε
 AaAb|bC  CaC | B | ε
 CaAB|b
 ETE’
 E’+TE|ε
 TFT’
 T’*FT’ | ε
 F( E) | id

You might also like