Grammar Production Lab

Grammar Production Lab

BNF-style subset · full-string parsing · local memory only. This is not a PEG or complete parser generator.

1. Production rules and test string

One Name ::= expression rule per line. Use quoted literals, rule references, |, and ε alone for empty. # starts a full-line comment. No regex, repetition operator, PEG slash or semantic actions. Limits: 16 rules, 48 alternatives, 12 symbols per alternative, input 80 characters, depth 2–20.

Leave the test string empty to check an ε derivation. Depth caps can prevent a complete verdict.

Enter grammar and a test string.

Comments & questions

Grammar Production Lab

Write one named production per line with ::=, quoted literal strings, rule references, | alternatives and explicit ε. The lab parses your test string, shows up to two distinct derivation trees and their leftmost steps, and explores short unique strings generated by the grammar. It rejects direct or indirect left recursion, unsupported PEG/EBNF operators and inputs beyond its stated limits instead of giving a misleading verdict.

Key features

  • Edit up to 16 BNF-style rules and 48 alternatives with quoted literal terminals
  • Parse a full test string and inspect rule/literal spans in two derivation trees
  • Show a furthest failure offset and expected literal when parsing fails
  • Detect direct, indirect and nullable-prefix left recursion before parsing
  • Generate up to 20 unique short strings and try them against the parser

How to use

  1. Enter one Name ::= expression rule per line or load the right-recursive example.
  2. Add a test string and select a bounded rule-expansion depth.
  3. Run the parser and inspect acceptance, failure position or two ambiguity witnesses.
  4. Open a tree and follow the leftmost derivation from start rule to literals.
  5. Click a generated example to parse it or download the complete local JSON report.

Use cases

  • Teach how right-recursive productions derive a sequence
  • Compare two parse trees for an ambiguous input
  • Find an indirect left-recursion cycle before implementing a top-down parser

Frequently asked questions

Is this a full BNF, EBNF or PEG implementation?

No. It is a documented BNF-style subset: quoted strings, rule names, | and explicit ε. Repetition operators, predicates, regular-expression tokens and PEG ordered choice are not accepted. | is unordered grammar alternation, not PEG priority.

What happens with left recursion?

The lab detects direct, indirect and nullable-prefix left-corner cycles and reports the cycle. This bounded top-down parser does not silently reinterpret or support such grammars; a parser generator such as Bison uses a different algorithm.

Does one tree prove the grammar is unambiguous?

No. The tool shows up to two derivations for this input within the selected depth. Two trees prove ambiguity for that input; one found tree does not prove that every input or all deeper derivations are unambiguous.

Are the generated examples a complete language listing?

No. They are unique examples from a bounded breadth-first expansion, with at most 20 results, 24 output characters and a step budget. A truncated indicator appears when a cap stops exploration.

Can an empty string be part of the grammar?

Yes. Write ε as an entire alternative, such as List ::= "a" List | ε. An empty quoted literal or blank alternative is rejected so the intent stays explicit.

Privacy

Grammar and test string stay in browser memory. No user code is evaluated or uploaded; the optional JSON download includes your source and input.

References

Related Tools

Regex TesterRegex Equivalence LabAST Query PlaygroundDOCX Style AuditorCitation ManagerDocument Search IndexSigned PDF InspectorPDF/A Archival PreflightPrint Preflight AuditorSearchable Scan PDF MakerPublication Accessibility AuditorResearch Evidence MatrixPDF Form DesignerPDF Annotation StudioPDF Object InspectorPDF Outline EditorEPUB Authoring WorkbenchDocument Version ComparatorBooklet Imposition DesignerSensitive Text RedactorHanja Reading WorkbenchDialogue Script EditorBook Index BuilderBilingual QA CheckerText Diagram EditorANSI Art StudioEmail Thread ExplorerPDF Redaction StudioRich Text SanitizerFixed Width Record DesignerPresentation Rehearsal StudioText Tokenization LabThree Way Text MergeKorean & English Braille ConverterText to SpeechTyping speed testKorean Text Pattern ReviewKorean Spelling QuizFont Preview and ComparisonHTML to MarkdownMojibake RepairSort LinesFind & ReplaceReverse TextRoman Numeral ConverterHangul Jamo ConverterKorean Initial ConsonantsAdd or Remove Line NumbersNumber to Korean WordsMorse Code ConverterROT13 & Caesar ConverterURL Slug GeneratorHTML Tag RemoverEmoji CollectionCharacter CounterUnit ConverterFile Size ConverterColor Code ConverterText DiffPDF Merge/SplitBusiness Day CalculatoriCalendar Rule LabvCard Address Book EditorJPG to PDFKorean Name RomanizerOrganize PDF PagesFancy Font GeneratorContrast CheckerColor Palette GeneratorPDF to JPGLorem Ipsum GeneratorText Template WorkbenchKorean-English Typo ConverterText CleanerOnline NotepadWord Cloud GeneratorPDF UnlockEnglish Address ConverterPDF Compressor
Explore all Text/Convert tools →Image/Media →Life/Fun →Dev Tools →