Similar presentations:
Programming Languages. Compilers. Formal Languages
1. Programming Languages. Part 2. Compilers
2. Formal Languages
Intro to compilersFormal
Languages
3. Formal Languages
LA4. Formal Languages
Intro to compilers• Alphabet =
English
characters
• Alphabet = ASCII
• Language =
English
sentences
• Language = C
programs
5. Meaning function
Intro to compilersMeaning function
Meaning function L maps syntax to
semantics
L(E) = Meanings
reg expr
set of strings
6. Meaning function
ɛ= {“ “}
‘c’
= {“c“}
Intro to compilers
L : Exp -> Sets Strings
7. Meaning function
Intro to compilersL( ɛ ) = { “ “ }
L(‘ c ’) = { “ c “ }
L(A + B) = L(A) U L(B)
L(AB) = {ab | a from L(A) ^ b from L(B)
L(A*) = U L(Ai)
8. Meaning function
• Why use a meaning function?– Makes clear what is syntax, what is
semantics.
– Allows us to consider notation as a
separate issue
– Because expressions and meanings are
not 1-1
LA
9. Meaning function
LAMeaning function
0
1
42
107
I
IV
X
XL
10. Syntax and Semantic
0*0 + 0*
E + 00*
E + 0 + 0*
...
LA
11. Syntax and Semantic
• Meaning is many to one– Never one to many!
LA