Playground

BNF Tester

Define a BNF grammar and test whether a string is in its language. Internally uses the Cocke-Younger-Kasami algorithm after CNF conversion.

Grammar & input
Result
NOinputL(G)?\text{input} \in L(G)?
Input: 1 + 2 + 3
How it works
  1. The grammar is converted to Chomsky Normal Form (ε-removal, unit-removal, binarization).
  2. CYK builds a triangular table O(n3)O(n^3) in time, checking each substring against each nonterminal.
  3. If the start symbol covers the whole string, the derivation is reconstructed cell by cell.