Book contents
- Frontmatter
- Contents
- List of Boxes
- Preface
- Part I Introduction
- Part II Action Notation
- Part III Semantic Descriptions
- Chapter 11 Statements
- Chapter 12 Literals
- Chapter 13 Expressions
- Chapter 14 Declarations
- Chapter 15 Variables
- Chapter 16 Subprograms
- Chapter 17 Tasks
- Part IV Conclusion
- Appendices
- Bibliography
- Symbol Index
- Concept Index
Chapter 12 - Literals
Published online by Cambridge University Press: 19 January 2010
- Frontmatter
- Contents
- List of Boxes
- Preface
- Part I Introduction
- Part II Action Notation
- Part III Semantic Descriptions
- Chapter 11 Statements
- Chapter 12 Literals
- Chapter 13 Expressions
- Chapter 14 Declarations
- Chapter 15 Variables
- Chapter 16 Subprograms
- Chapter 17 Tasks
- Part IV Conclusion
- Appendices
- Bibliography
- Symbol Index
- Concept Index
Summary
Literals are lexical symbols including numerals, characters, and strings.
The semantic description of literals is facilitated by standard operations on strings.
The semantic entities required are specified ad hoc, exploiting the general data notation introduced in Chapter 5.
Literals are the simplest constructs of programming languages, with regard to both syntax and semantics. Typical examples are numeric literals, i.e., numerals, and string literals.
The description of literals is not very challenging. But we have to take care to avoid overspecification that might place unintended and impractical burdens on implementations.
For instance, it might be imagined that we could adapt the description of binary numerals in Chapter 2 immediately to decimal integer numerals, such as those in ADA. However, in the absence of syntactic limits on the length of numerals, the corresponding semantic entities would be arbitrarily-large numbers. Practical programming languages generally put implementation-dependent bounds on the magnitude of numbers. In ADA, the constants MIN_INT and MAX_INT bound the required integers, although implementations are allowed to provide further integer ‘types’ with implementation-dependent bounds.
The semantics of an integer numeral is the expected mathematical value only when that lies within bounds. Otherwise it should be some entity that represents a numeric error. The situation with literals for so-called ‘real’ numbers is similar, although it is necessary to take account of implementation-dependent lower bounds on the accuracy of ‘real’ numbers, as well as bounds on their magnitude.
- Type
- Chapter
- Information
- Action Semantics , pp. 136 - 141Publisher: Cambridge University PressPrint publication year: 1992