Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-5wvtr Total loading time: 0 Render date: 2024-07-18T07:23:29.793Z Has data issue: false hasContentIssue false

Chapter 12 - Literals

Published online by Cambridge University Press:  19 January 2010

Peter D. Mosses
Affiliation:
Aarhus Universitet, Denmark
Get access

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 - 141
Publisher: Cambridge University Press
Print publication year: 1992

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Literals
  • Peter D. Mosses, Aarhus Universitet, Denmark
  • Book: Action Semantics
  • Online publication: 19 January 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511569869.017
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Literals
  • Peter D. Mosses, Aarhus Universitet, Denmark
  • Book: Action Semantics
  • Online publication: 19 January 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511569869.017
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Literals
  • Peter D. Mosses, Aarhus Universitet, Denmark
  • Book: Action Semantics
  • Online publication: 19 January 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511569869.017
Available formats
×