Bottom-Up Parsing/Example 2: SLR(1): Difference between revisions

From Wiki**3

Root (talk | contribs)
Created page with "{{TOCright}} = Problem = S -> 1 S 1 | 1 X 0 | 2 X -> 2 | S 1 | X 2 Initial symbol: S Terminals: { 0, 1, 2 } == Solution == category:Teaching category:Compilers"
 
Root (talk | contribs)
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
= Problem =
= Problem =


S -> 1 S 1 | 1 X 0 | 2
Initial symbol: '''S'''
X -> 2 | S 1 | X 2


Initial symbol: S
Terminals: '''{ 0, 1, 2 }'''
Terminals: { 0, 1, 2 }
 
Input: '''112110'''
 
S → 1 S 1 | 1 X 0 | 2
X → 2 | S 1 | X 2
 
Is this an LR(0) grammar?
 
Describe the processing of the input by an LALR(1) parser for this grammar.


== Solution ==
== Solution ==


[[category:Teaching]]
[[category:Compiladores]]
[[category:Compilers]]
[[category:Ensino]]

Latest revision as of 09:37, 2 May 2024

Problem

Initial symbol: S

Terminals: { 0, 1, 2 }

Input: 112110

S → 1 S 1 | 1 X 0 | 2
X → 2 | S 1 | X 2

Is this an LR(0) grammar?

Describe the processing of the input by an LALR(1) parser for this grammar.

Solution