Back to marketplace

BNF

No description yet. This curated deck is ready for daily study.

Total cards: 12•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (12)

#1
Front (Question)

What is a context-free language?

Back (Answer)

A context-free language is a set of strings and symbols that follow the rules of a context-free grammar.

#2
Front (Question)

What is a context-free grammar (CFG)?

Back (Answer)

A CFG describes which strings are possible or not possible in a language by defining a set of production rules.

#3
Front (Question)

What is a production rule in a CFG? Give examples.

Back (Answer)

A production rule specifies how one symbol can be replaced by another. Examples: a → ab (a is replaced by ab) a → aa (a is replaced by aa) b → a (b is replaced by a)

#4
Front (Question)

What is Backus-Naur Form (BNF)?

Back (Answer)

BNF is a way of notating context-free languages using statements where the left-hand side is defined by the right-hand side.

#5
Front (Question)

What are non-terminals in BNF?

Back (Answer)

Non-terminals are syntactic variables placed inside angle brackets (e.g. <expr>). They can be broken down further into terminals, other non-terminals, or both.</expr>

#6
Front (Question)

What are terminals in BNF?

Back (Answer)

Terminals are literal symbols (without brackets) that cannot be broken down further and must be taken as written values.

#7
Front (Question)

What does the pipe (|) symbol represent in BNF?

Back (Answer)

It represents the OR operator, allowing alternatives in production rules.

#8
Front (Question)

How does recursion work in BNF?

Back (Answer)

A non-terminal can be defined in terms of itself, allowing recursive definitions. This enables BNF to represent some strings that regular expressions cannot, because regex does not support recursion.

#9
Front (Question)

Why is recursion important in BNF?

Back (Answer)

It allows representation of nested or repeating structures (e.g. balanced parentheses, nested expressions) which cannot be represented by regular expressions.

#10
Front (Question)

What is a syntax diagram?

Back (Answer)

A syntax diagram is a visual representation of a regular language. Non-terminals are shown as rectangles. Terminals are shown as ellipses. Arrows connect shapes to show how strings can be formed.

#11
Front (Question)

How is each non-terminal represented in a syntax diagram?

Back (Answer)

Each non-terminal has its own separate diagram that defines its production rules visually.

#12
Front (Question)

Back (Answer)