LR(0) Parser Visualization

Write your own context-free grammar and see an LR(0) parser in action!

Written by Zak Kincaid and Shaowei Zhu

1. Write your LR(0) grammar (empty string '' represents ε):

Formatting Instructions

  • The non-terminal on the left-hand-side of the first rule is the start non-terminal
  • Write each production rule in a separate line (see example to the left)
  • Separate each token using whitespace
  • $ is reserved as the end-of-input symbol, and S' is reserved as an artificial start symbol. The grammar is automatically augmented with the rule S' ::= start $

Generate LR(0) Automaton

2. LR(0) Automaton

State Item set

3. Parsing

Start/Reset Step Forward

Partial Parse Tree