📚 node [[20210516174118 context_free_grammar]]
A context-free grammar (CFG) is a set of recursive rules that describe a programming language
Context-free grammars are a set of names paired with their parsing rules.
For example:
\begin{example} \mathit{expr} \rightarrow \mathit{term}\; \mathtt{+}\; \mathit{expr}
\mathit{expr} \rightarrow \mathit{term}
\mathit{term} \rightarrow \mathit{term}\; \mathtt{*}\; \mathit{factor}
\mathit{term} \rightarrow \mathit{factor}
\mathit{factor} \rightarrow \mathtt{(}\;\mathit{expr}\;\mathtt{)}
\mathit{factor} \rightarrow \mathit{const}
\mathit{const} \rightarrow \mathit{integer} \end{example}
Therefore we know 3 * 7
is a valid expression.
📖 stoas
- public document at doc.anagora.org/20210516174118-context_free_grammar
- video call at meet.jit.si/20210516174118-context_free_grammar
⥱ context
← back
(none)
(none)
↑ pushing here
(none)
(none)
↓ pulling this
(none)
(none)
→ forward
(none)
(none)
🔎 full text search for '20210516174118 context_free_grammar'