Grammar
Test a string
Strings in the language
Exercise
Parse trees, CNF, CYK · Chapter 2.1
A context-free grammar generates a language by replacing variables with right sides of rules, starting from the start variable, until only terminals are left (Sipser, Chapter 2.1). This page tests strings, draws parse trees, finds ambiguity, and converts any grammar to Chomsky normal form step by step.
| Type | Means |
|---|---|
S -> aSb | ε | two rules for S |
-> or → | the arrow |
ε or \epsilon | the empty string |
S, A, S_0, A' | variables (capital letters) |
<EXPR> | a variable with a long name |
a, 0, +, ( | terminals (any other character) |
The first rule's left side is the start variable. Put one variable per line, or repeat a variable on several lines.
ε for the empty string.