INTSTR.DEF 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. (* !LIBRARY! *) DEFINITION MODULE IntStr;
  2. (* Proposed BSI/ISO Standard Modula-2 I/O Library
  3. * Copyright Roger Henry, University of Nottingham
  4. * Version WG/4.01, February 1989
  5. * Permission is given to copy this Definition Module, with the
  6. * copyright notice intact, for the purposes of evaluation and test.
  7. * At the stage of a formal draft standard, Copyright will be transferred
  8. * to BSI (and through BSI to other recognised standards bodies).
  9. * Status: for review by BSI/IST/5/13;
  10. for review by ISO/IEC JTC1/SC22/WG13
  11. --* this version editted to conform to D105 kjg September 1989 *--
  12. *)
  13. IMPORT ConvTypes;
  14. FROM ConvTypes IMPORT ScanProgress, ScanProc;
  15. (* the text form of a signed whole number is *)
  16. (* [whitespace] ["+" | "-"] digit {digit} *)
  17. PROCEDURE Scan(
  18. this: CHAR; VAR progress: ScanProgress; VAR nextScanner: ScanProc);
  19. (* corresponds to the start state of a FSA scanner for integers *)
  20. TYPE ConvResults = ConvTypes.ConvResults;
  21. PROCEDURE Format(str: ARRAY OF CHAR): ConvResults;
  22. (* pre: "str" has a string value *)
  23. (* post: returned value corresponds to format of string *)
  24. (* value with respect to the type CARDINAL *)
  25. PROCEDURE Value(str: ARRAY OF CHAR): INTEGER;
  26. (* pre: "str" has a string value *)
  27. (* and format is "allRight" with respect to INTEGER *)
  28. (* post: returned value is the corresponding INTEGER *)
  29. PROCEDURE Take(
  30. str: ARRAY OF CHAR; VAR int: INTEGER; VAR format: ConvResults
  31. );
  32. (* pre: "str" has a string value *)
  33. (* post: either value of "format" is "allRight", *)
  34. (* value of "int" is the corresponding INTEGER *)
  35. (* or value of "format" is "outOfRange", *)
  36. (* value of "int" is MAX(INTEGER) or MIN(INTEGER) *)
  37. (* or value of "format" is "wrongFormat" *)
  38. (* value of "int" is undefined *)
  39. (* or value of format is "noData" *)
  40. (* value of "int" is unchanged *)
  41. TYPE Alignment = ConvTypes.Alignment; (* left, centre, right *)
  42. PROCEDURE Length(int: INTEGER): CARDINAL;
  43. PROCEDURE Give(
  44. VAR str: ARRAY OF CHAR; int: INTEGER; width: CARDINAL; where: Alignment);
  45. (* post: as far as capacity of "str" allows, *)
  46. (* the character representation of "int" is contained in "str" *)
  47. (* in a field of at least "width" characters *)
  48. (* left, centre (numeric), or right justified; *)
  49. (* for the special case of "width" = 0, a leading space is written *)
  50. END IntStr.