Stropping (syntax)
In computer language design, stropping is a method of explicitly marking letter sequences as having a special property such as being a keyword or certain type of variable or storage location.
Stropping allows the same letter sequence to be used both as a keyword and as an identifier, and simplifies parsing in that case. Most modern programming languages do not allow this ambiguity: keywords are reserved words and cannot be used as identifiers.
In languages such as Algol 60 and Algol 68, stropping was a method of representing typographical distinctions found in the publication language in the hardware language.
Contents |
Syntaxes [edit]
A range of different syntaxes for stropping have been used:
- Algol 60 commonly used only the convention of quotes around the word (e.g.
'BEGIN'or‘BEGIN’). - Algol 68[1][2] in some implementations treat letter sequences prefixed by a single quote, ', as being keywords (e.g.,
'BEGIN)[3]
In fact it was often the case that several stropping conventions might be in use within the one language:
- Atlas Autocode had the choice of three: keywords could be
underlinedusing backspace and overstrike on a Flexowriter keyboard, they could be introduced by a%percent %symbol, or they could be typed inUPPER CASEwith no delimiting character (in which case all variables had to be in lower case). - ALGOL 68RS programs are allowed the use of several stropping variants, even within the one language processor.
Examples of different ALGOL 68 styles [edit]
Algol68 as typically published
¢ bold or underline typeface ¢ mode xint = int; xint sum sq:=0; for i while sum sq≠70×70 do sum sq+:=i↑2 od |
Quote stropping (like wikitext)
'pr' quote 'pr' 'mode' 'xint' = 'int'; 'xint' sum sq:=0; 'for' i 'while' sum sq≠70×70 'do' sum sq+:=i↑2 'od' |
For a 7-bit character code compiler
.PR UPPER .PR MODE XINT = INT; XINT sum sq:=0; FOR i WHILE sum sq/=70*70 DO sum sq+:=i**2 OD |
For a 6-bit character code compiler
.PR POINT .PR .MODE .XINT = .INT; .XINT SUM SQ:=0; .FOR I .WHILE SUM SQ .NE 70*70 .DO SUM SQ .PLUSAB I .UP 2 .OD |
Algol68 using res stropping (reserved word)
.PR RES .PR mode .xint = int; .xint sum sq:=0; for i while sum sq≠70×70 do sum sq+:=i↑2 od |
Other languages [edit]
For various reasons Fortran 77 has these "logical" values and operators: .TRUE. .FALSE. .EQ. .NE. .LT. .LE. .GT. .GE. .EQV. .NEQV. .OR. .AND. .NOT. [1]
Most modern programming languages do not use stropping - although Ruby and Perl both use sigils to identify characteristics of variables/constants: Perl to designate the type of variable, Ruby to distinguish variables from constants and to indicate scope.
See also [edit]
References [edit]
- ^ http://www.fh-jena.de/~kleine/history/languages/Algol68-RR-HardwareRepresentation.pdf
- ^ van Wijngarten et al. (1976) Section 9.3
- ^ Lindsey and van der Meulen (1977) pp.348-349
- A. van Wijngaarden; et al. (1976). Revised Report on the Algorithmic Language ALGOL 68. Springer-Verlag. ISBN 0-387-07592-5. OCLC 1991170.
- C. H. Lindsey; S. G. van der Meulen (1977). Informal Introduction to ALGOL 68. North-Holland. ISBN 0-7204-0726-5. OCLC 230034877.
- W. J. Hansen; H. J. Boom (1978). "Report on the Standard Hardware Representation for Revised ALGOL 68". Acta Informatica 9: 105–119. doi:10.1007/BF00289072.
- C.H. Lindsey, "An ISO-Code Representation for ALGOL 68" ALGOL Bulletin AB31.3.6, Issue 31, March 1970, pp. 37-60 ACM