110 likes | 311 Views
ICS 482 Natural Language Processing SLR Parsing. Muhammed Al-Mulhem March 1, 2009. Constructing SLR Table. Constructing SLR Table. SLR Table - Example. Let us construct the SLR table for the augmented expression grammar. E’ → E E → E + T | T T → T * F | F F → ( E ) | id.
E N D
ICS 482Natural Language ProcessingSLR Parsing Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem
Constructing SLR Table Dr. Muhammed Al-Mulhem
Constructing SLR Table Dr. Muhammed Al-Mulhem
SLR Table - Example • Let us construct the SLR table for the augmented expression grammar. E’ → E E → E + T | T T → T * F | F F → ( E ) | id Dr. Muhammed Al-Mulhem
SLR Table - Example • Assign numbers to the grammar rules 0) E’ → E 1) E → E + T 2) E → T 3) T → T * F 4) T → F 5) F → ( E ) 6) F → id Dr. Muhammed Al-Mulhem
SLR Table - Example • The first item I0 E’ → ■ E E → ■ E + T E → ■ T T → ■ T * F T → ■ F F → ■ ( E ) F → ■ id • The FSA with all sets of items for the grammar is shown next. Dr. Muhammed Al-Mulhem
SLR Table - Example Dr. Muhammed Al-Mulhem
SLR Table - Example Dr. Muhammed Al-Mulhem
SLR Table - Example Dr. Muhammed Al-Mulhem
SLR Table - Example E’ → E E → E + T E → T T → T * F T → F F → ( E ) F → id Dr. Muhammed Al-Mulhem
SLR Table - Example Dr. Muhammed Al-Mulhem