# Knife

Knife is a tool that reads input grammar in BNF format and converts it to a few Java classes that can parse the given grammar through a simple interface.

Knife doesn’t require any external libraries or dependencies. All generation is done ahead-of-time. After generating the parsing classes you can just copy them into your project.

Also, as other good parser generation tools, knife uses itself to read the input grammar.

## Features

• No runtime dependencies, knife generates pure Java code that can easily be ported to other JVM-based languages.
• Parsing is done using push-down automata without recursion.
• Knife uses an explicit API for accepting the token stream. It allows you to easily use knife with any (including your own) lexer. You can pause and resume parsing at any point. Parsing multiple token streams simultaneously is also possible.
• No complete parse-trees are being built during parsing. Reduction of the tree is done on-the-fly for performance. Optimized AST’s can be built during parsing with minimal overhead.
• If your grammar is left-recursive without A =>* A derivations (aka without cycles), knife will generate an equivalent grammar without left recursion for you.
• Syntax error recovery using panic mode approach without any additional performance overhead.