t60_charcaret.pas 857 B

123456789101112131415161718192021222324252627
  1. program t60_charcaret;
  2. { t60 -- the two lexical character constants CALC needs: caret (^M) and
  3. decimal (#nn). CALC.PAS:113 is
  4. EofLine = ^M;
  5. `^M' is CR (13) and `#27' is ESC. Both are unquoted, both are CHARACTER
  6. constants, so `write (^M)' emits the byte CR and not the text "13" - which
  7. is why ParseAtom has to recognise them as literals, not only RdConst in a
  8. declaration.
  9. The last two lines pin the values without depending on the output bytes:
  10. EofLine and ^M are both 13, Esc and 27 are both 27. (EofLine is a plain
  11. constant, so it is a TScalar like every plain scalar constant; only the
  12. LITERAL carries the char flag. A typed `EofLine : Char = ^M' is what keeps
  13. the class - see t59.) }
  14. const
  15. EofLine = ^M;
  16. Esc = #27;
  17. begin
  18. write (^M);
  19. write (#27);
  20. writeln (EofLine = ^M);
  21. writeln (Esc = 27)
  22. end.