formal10_part2 - Parsing in a Grammar(L Can we recognize...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Parsing in a Grammar ( L ) Can we recognize X2 := 0 as being in L ? 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Parse Trees (in L ) A parse tree of X2 := 0 in L : Each internal node is a nonterminal; its children are the RHS of a production for that NT. The parse tree demonstrates that the grammar generates the terminal string. 2
Background image of page 2
Grammars are not Unique Consider L : Terminals letters, digits, := Nonterminals < letter > < digit > < ident > < stmt > < letterordigit > Productions Start Symbol < stmt > 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
L and L generate the same language, but yield diferent parse trees. 4
Background image of page 4
Grammars and Programming Languages Many grammars may correspond to one programming language. Good grammars: capture the logical structure of the language, use meaningful names, are easy to read, are as unambiguous as possible, . . . What does this list of desirable properties remind you of? 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
< start > ::= < stmt > < stmt > ::= < if-stmt > | < assgn > < if-stmt > ::= if < expr > then < stmt > | if < expr > then < stmt > else < stmt > < assgn > ::= < id > := < d
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 25

formal10_part2 - Parsing in a Grammar(L Can we recognize...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online