Download presentation
Presentation is loading. Please wait.
1
Denotational Semantics
Based on recursive function theory Define for each language entity both a mathematical object and a function that maps instances of that entity onto instances of the mathematical object. The method is named denotational because the mathematical objects denote the meaning of their corresponding syntactic entities. Copyright © 2006 Addison-Wesley. All rights reserved. 3-61
2
Denotational Semantics (continued)
Two simple examples: Binary numbers <bin_num> -> 0 | 1 | <bin_num> 0 | <bin_num> 1 <bin_num> <bin_num> <bin_num> 1 Copyright © 2006 Addison-Wesley. All rights reserved. 3-62
3
Denotational Semantics (continued)
The objects are simple decimal numbers. The meaning of a binary number will be its decimal equivalent. Let the domain of semantic values of the objects be N, the set of nonnegative decimal integer values. It is these objects that we wish to associate with binary numbers. The semantic function, Mbin maps the syntactic objects to the objects in N. Mbin(‘0’) = 0 Mbin(‘1’) = 1 Mbin(<bin_num>’0’) = 2 * Mbin(<bin_num>) Mbin(<bin_num>’1’) = 2 * Mbin(<bin_num>) + 1 Copyright © 2006 Addison-Wesley. All rights reserved. 3-63
4
Denotational Semantics (continued)
6 <bin_num> 3 <bin_num> 1<bin_num> 1 Mbin(<bin_num>’0’) = 2 * Mbin(<bin_num>) + 0 = 2* Mbin(‘11’) + 0 = 6 Mbin(<bin_num>’1’) = 2 * Mbin(<bin_num>) + 1 = 2* Mbin(‘1’) + 1 = 3 Mbin(‘1’) = 1 Copyright © 2006 Addison-Wesley. All rights reserved. 3-64
5
Denotational Semantics (continued)
Another example <dec_num> - > 0|1|2|3|4|5|6|7|8|9 |<dec_num>(0|1|2|3|4|5|6|7|8|9) Mdec(‘0’)=0, Mdec(‘1’) = 1, ..., Mdec(‘0’) = 9 Mdec(<dec_num>’0’) = 10 * Mdec(<dec_num>) Mdec(<dec_num>’1’) = 10 * Mdec(<dec_num>) + 1 … Mdec(<dec_num>’9’) = 10 * Mdec(<dec_num>) + 9 Copyright © 2006 Addison-Wesley. All rights reserved. 3-65
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.