


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Context-free grammars (cfgs), their components, natural language examples, and their use in describing parts of programming languages. Cfgs are essential for understanding the meaning of computer programs and are used in compilers.
Typology: Slides
1 / 26
This page cannot be seen from the preview
Don't miss anything!
A, B are variables 0, 1, # are terminals A is the start variable
SENTENCE โ NOUN-PHRASE VERB-PHRASE NOUN-PHRASE โ CMPLX-NOUN NOUN-PHRASE โ CMPLX-NOUN PREP-PHRASE VERB-PHRASE โ CMPLX-VERB VERB-PHRASE โ CMPLX-VERB PREP-PHRASE PREP-PHRASE โ PREP CMPLX-NOUN CMPLX-NOUN โ ARTICLE NOUN CMPLX-VERB โ VERB NOUN-PHRASE CMPLX-VERB โ VERB
ARTICLE โ a ARTICLE โ the NOUN โ boy NOUN โ girl NOUN โ flower VERB โ likes VERB โ touches VERB โ sees PREP โ with
variables: SENTENCE, NOUN-PHRASE, โฆ terminals: a, the, boy, girl, flower, likes, touches, sees, with start variable: SENTENCE
Variables:
A โ ฮฑ
Shorthand notation for productions
same variable on the left like
we can write this in shorthand as
E โ E + E E โ E * E E โ (E) E โ N
E โ E + E | E * E | (E) | 0 | 1 N โ 0N | 1N | 0 | 1
Variables: E, N Terminals: +, *, (, ), 0, 1 Start variable: E
N โ 0N N โ 1N N โ 0 N โ 1
L = {ฯ | ฯ โ T* and S โ* ฯ }
variables: A, B terminals: 0, 1, # start variable: A
L = {0 n #1 n : n โฅ 0}
n m m n Docsity.com
A โ ฮต | 0A | 1A
Every regular language is context-free
regular expression NFA DFA
L = {0 n #1 n : n โฅ 0}
E โ E + E โ V + E โ x + E โ x + (E) โ x + (E โ E) โ x + (V โ E) โ x + (y โ E) โ x + (y โ V) โ x + (y โ z)
x
y z
E โ E + E | E - E | (E) | V V โ x | y | z
E โ E + E โ V + E โ x + E โ x + (E) โ x + (E โ E) โ x + (V โ E) โ x + (y โ E) โ x + (y โ V) โ x + (y โ z)
x
y z
V โ x | y | z
x + y + z
x V V y z
x y
z