Prezentacja programu PowerPoint


Classification of formal grammars



Download 66 Kb.
bet2/2
Sana04.06.2022
Hajmi66 Kb.
#636216
1   2

Classification of formal grammars

  • Regular grammars
  • Context free grammars
  • Unrestricted grammars
  • Generalization / difficulty of parsing

Parsing methods

  • Top-down parsing approach:
  • LL parsers – Left to Right,
  • Leftmost Derivation
  • Bottom-up parsing approach
  • LR parsers – Left to Right,
  • Rightmost Derivation
  • LALR parsers – Look Ahead LR
  • (use of lookahead symbols
  • to aid the parsing process)
  • GLR parsers – Generalized LR
  • (multiple parsing threads
  • in order to resolve ambiguities)

Grammar of Simple Arithmetic Expressions

  • V = {“a”, ”b”, ”d”, ”+”, ”*”, “(“, “)”}
  •  = {E, C, F}
  •  = E
  • P = {
    • ::= | “+” | “+”
    • ::= | “*” | “*”
    • ::= “(“ “)” | “a” | “b” | “d”
  • }

Grammar of Reverse Polish Notation

  • V = {“a”, ”b”, ”d”, ”+”, ”*”}
  •  = {W, Z, X, O}
  •  = W
  • P = {
    • ::= |
    • ::= |
    • ::= “a” | “b” | “d”
    • ::= “+” | “*”
  • }

(a + b) * d  a b + d *  d a b + *

  • “a”
  • “b”
  • “+”
  • “*”
  • “d”

Algorithm of finding the result of arithmetic expressions in RPN

  • START
  • Parameter
  • No
  • Yes
  • Read a symbol
  • (from the left to the right)
  • Operator
  • Yes
  • Get parameters
  • from the stack,
  • execute the operation,
  • put the result
  • on the top of the stack
  • END
  • ERROR
  • No
  • No
  • Yes
  • 2, 3, 4, 5, +, *, +,
  • Input
  • Stack
  • 2
  • 2
  • 3
  • 2, 3
  • 4
  • 2, 3, 4
  • 5
  • 2, 3, 4, 5
  • +
  • 2, 3, 9
  • *
  • 2, 27
  • +
  • 29

Download 66 Kb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish