4.4.3 - ToC (Context-Free Languages) Flashcards
What is Backus-Nour Form
A formal, mathematical way of defining syntax unambiguously
What does BNF consist of
Terminal Symbols
Production Rules
Non-Terminal Symbols
What are terminal symbols/elements
Elements that cannot be broken down anymore e.g, a letter
What are non terminal symbols or elements
Elements that are defined by constants (i.e. can’t be divided into other elements)
How do context free languages work
Context-free languages describe which strings are and are not
possible in a language by laying out production rules
What are production rules
A production rule is a statement that allows for one values to be replaced by another valid one e.g a –> aa (a can be replaced by aa)
What is a recursive statement in BNF
Where a statement is defined in terms of itself
When is recursion used in BNF
It is used as a sort of while loop when you dont know the specific length a value will take
What can BNF do that Regex cant
Represent languages that involve recursion
What is meant by this symbol:
<>
Represents a syntactic item of the language (basically a data type)
What is meant by this symbol:
::=
“Is defined by”
What are 2 other ways that BNF can be represented
- Syntax Diagrams 1:1
- Parse Trees