100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Lecture notes

Lecture Notes on Grammars (COMP11212)

Rating
-
Sold
-
Pages
1
Uploaded on
30-05-2024
Written in
2023/2024

Gain a thorough understanding of formal grammars with these comprehensive lecture notes for COMP11212. Covering context-free grammars and their role in language generation and parsing, these notes provide detailed explanations, examples, and diagrams. Ideal for students aiming to excel in the study of grammars and their applications in computation.

Show more Read less








Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
May 30, 2024
Number of pages
1
Written in
2023/2024
Type
Lecture notes
Professor(s)
Francisco lobo
Contains
All classes

Content preview

Grammars

Definition Definition (I UE)
*
.
18 A
context-free grammar or CFG is
given by the following : 19 : A string e is a string generated by grammar G if there is a




also called the object alphabet Sequence of strings
· an alphabet I of terminal symbol ,
.




S =
Xo = X, =... = Xn X
non-terminal symbol the elements
=
·
an
alphabet""of ,
of which are also referred to as


auxiliary characters , placeholders in some books variables, with"" called the start
of G
or
,
step the application of
,
is obtained by
such that each Xi = Vit1 one
symbol .




rules to
production a non-terminal occurring in Xi as
follows
·
a
special non-terminal Symbol Set called the start symbol
that there production rule R Y
.
Let RE
is a <
: : occur in Xi and assume
production rules of the form R where RE , non-terminal
· a
finite get of > X is a

the
Then is obtained from Zi by replacing one occurrence of R in Xi by
(EUE)
ite
and non-terminal
*

Symbol and Xe is an arbitrary string of terminal
String Y
Symbols which ,
can be read as 'R can be replaced by X:

The language generated by grammar G is the set of all strings over which are



generated by G .




I
L xample :




asbe
5 :
Example : DFA to Grammar


S xaSb xaaSbbxaaabb
i in
· = aabb

b
· S E >




anabbb
· SxaSb -aaSbbxaaaSbbbxaaaEbbb =
S W




L =
LahbIneIN] non-regular language S - aS bT

T > aT bUE


Recap W >
E


Grammars consist of a number of production rules telling us how to rewrite non-terminals into

strings of terminals and non-terminals .




A Context Free Language is one defined by a
grammar.

strict subset of the set of Context Free
The set of Regular Languages over an alphabet is a




Languages.




Parsing
Practical Example 1: Practical Example 2:


S - aBC S S > aT Ta

B > bB/E T >
aT bTlE

C > CIE a B C

S

s
· S XaBC XabBCxabaC xabacC abca = abc
b
B C
· S X aBC XaBc(XabBcCX abECa abc
=
a T A




E E A
-

I a T



E E
Practical Example 3



=ht
Se S S aas = an aea = ga




S + 55x S
S >
S + S

S -
5 xs
A SxS St S A
S > A

1 A A A A 2
A > ⑧

A = 1
0210 Context Free Languages

A >
2




Recap
A Parse Tree shows how string
a
may be generated from a
grammar .




An ambiguous where there strings that have multiple
parse trees
is
grammar one are
£3.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
jpxoi

Get to know the seller

Seller avatar
jpxoi The University of Manchester
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
1 year
Number of followers
0
Documents
20
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions