home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sharew / exoten / rec / cnvrt.hlp < prev    next >
Encoding:
Text File  |  1990-10-28  |  50.1 KB  |  1,114 lines

  1. Program structure
  2. Patterns
  3. Skeletons
  4. Comments
  5. Program File
  6. Library and Initialization
  7. Boolean Patterns
  8. Constant Patterns and Skeletons
  9. Input-Output Skeletons
  10. Directory Skeletons
  11. Arithmetic Skeletons
  12. Conditional and Iterative Skeletons
  13. Variables
  14. Intervals
  15. Lexicographic Intervals
  16. Rule Set
  17. Debugging Aids
  18. Performance
  19. Bibliography
  20. :Structure of a Convert program.
  21.  
  22.     A Convert program has the format
  23.  
  24.     ((p)(s)(v)(r)) x
  25.  
  26. where    (p) is a list of pattern definitions ((P1) p1 (P2) p2 ...)
  27.         (Pj a pattern, pj its name)
  28.  
  29.     (s) is a list of skeleton definitions ((S1) s1 (S2) s2 ...)
  30.         (Sj a skeleton, sj its name)
  31.  
  32.     (v) is a list of variables (v1 v2 ...) (each vi a number between 
  33.         0 and 30, a single space separating variables in the list;
  34.         no space whatever if no variables are declared)
  35.  
  36.     (r) is a list of rules, each having one of two possible forms:
  37.          (pattern,skeleton):    [for a repeating rule]
  38.          (pattern,skeleton);    [for a terminal rule]
  39.  
  40.     x   is the name of the program (null for the main program,
  41.         which must appear last)
  42.  
  43. Every Convert program is a function which maps a string into another
  44. string; this mapping is performed by the list of rules.  Application
  45. of the list of rules to a string procedes as follows:
  46.  
  47.     - Rules are tried in order, from first to last.
  48.  
  49.     - Trying a rule means trying to match the pattern to the
  50.       string.  If there is a match, the rule is said to apply
  51.       and the string is replaced by whatever text is produced by
  52.       the skeleton.
  53.  
  54.     - If a rule ending in a colon applies, the list is
  55.       tried from the beginning on the new string; if a rule
  56.       ending in a semicolon applies, the string produced
  57.       by the corresponding skeleton is the value of the function.
  58.  
  59.     - If no rule applies (none of the patterns match), the
  60.       string remains unchanged and is returned as the value
  61.       of the function.
  62.  
  63. Thus patterns are predicates which determine whether a string has a certain 
  64. form or not, while skeletons are string-valued entities.
  65.  
  66. Sample programs:
  67.  
  68. [the null program; as a function, it is the identity mapping]
  69. (()()()())
  70. -------------------
  71. [the canonical "display a greeting" program]
  72. (()()()(
  73.     (,Hello<,> world!);
  74. ))
  75. -------------------
  76. [a function named w to replace strings of two or more spaces by a single space]
  77. (()()()(0 1)(
  78.     (<0>  (ITR, )<1>,<0> <1>):
  79. )) w
  80. -------------------
  81. [a function named x to replace trailing spaces by tabs, for each eight columns]
  82. (()()(0 1)(
  83.     ((and,<[8]>,<0> (ITR, ))<1>,<0>(^I)(x,<1>));
  84.     ((and,<[8]>,<0>)<1>,<0>(x,<1>));
  85. )) x
  86. -------------------
  87. The first two may be placed in files by themselves, compiled and executed.
  88.  
  89. Two programs can be used together, with one calling the other. In the second 
  90. one below, the pattern 0, referenced as <:0:>, although it is only used once
  91. represents the more complicated composite (and,<[8]>,<0>). This whole phrase 
  92. is a pattern, and must be enclosed in parentheses to make a definition. There 
  93. is no conflict between variable names and pattern or skeleton names; here 0 
  94. is used in both senses.
  95.  
  96. [replace 8-column tabs by spaces]
  97. (()()(0 1 2)(
  98.     ((and,<[8]>,<0>(^I)<1>)<2>,(z,<0>)(y,<1><2>));
  99.     ((and,<[8]>,<0>)<2>,<0>(y,<2>));
  100.     (<0>(^I)<1>,(z,<0>)<1>):
  101. )) y
  102.  
  103. [fill out tab space]
  104. ((
  105.     ((and,<[8]>,<0>)) 0    [a pattern definition]
  106. )()(0)( 
  107.     (<:0:>,<0>);        [a rule using the above definition]
  108.     (,<=>        ):        [this rule appends 8 blanks to the text]
  109. )) z
  110.  
  111.  
  112. Skeletons can also be symbolized by single letters. The following program
  113. copies one file to another, which COPY could do more efficiently. (R)
  114. and (W) are read and write skeletons, respectively; (W) incorporates a
  115. variable that must have been defined by a pattern match.
  116.  
  117. [read word, write word]
  118. (()()(0)(
  119.     (<0>(^Z),(W));
  120.     (<0>,(W)(R)):
  121. )) a
  122.  
  123. [main program]
  124. (()(
  125.     ((%R,<9>.ONE,(ITR, )<-->(or, ,(^Z)))) R
  126.     ((%W,<9>.TWO,<0>)) W
  127. )(9)(
  128.     (<9>(or, ,.,<>),<<
  129.         >>(%Or,<9>.ONE)<<
  130.         >>(%Ow,<9>.TWO)<<
  131.         >>(a,(R)));
  132. ))
  133. :Patterns may have one of the forms
  134.  
  135.     xxx            [constant: string of ASCII characters between
  136.                  ! and ~, except parentheses, angle brackets,
  137.                  comma and single and double quotes; it may
  138.                  include SP, CR, LF and HT]
  139.     (<)  (>)        [constants: left and right angle brackets]
  140.     <(>  <)>        [constants: left and right parentheses]
  141.     <,>  <'>  <">        [constants: comma, single quote, double quote]
  142.     (QUO/.../)        [constant ... with delimiters /]
  143.     (DEC,n)            [the decimal byte n (mod 256)]
  144.     (HEX,n)            [the hexadecimal number n]
  145.     (^xxx)            [control characters xxx, each x in [@,_]]
  146.     <()>            [balanced parentheses]
  147.     <:a:>            [defined pattern a]
  148.     <[n]>            [interval of length n]
  149.     <[-n]>            [remaining text but the last n bytes]
  150.     <[s]>            [interval of length given by skeleton s]
  151.     <-->            [indefinite length interval]
  152.     <n>            [variable n, n between 0 and 30]
  153.     <>            [null string at the end of the text]
  154.     (LAM,(v),p)        [p with local variables given in list (v)]
  155.  
  156.     (AND,p1,p2,...,pn)    [matches if all patterns p1,..pn match]
  157.     (and,p1,p2,...,pn)    [simplified version of AND]
  158.     (OR,p1,p2,...,pn)    [first of p1,...pn to match]
  159.     (or,p1,p2,...,pn)    [simplified version of OR]
  160.     (NOT,p)            [string does not match p]
  161.     (ITR,p)            [Repeat p as much as possible]
  162.     (itr,p)            [Repeat p as little as necessary]
  163.     (IVL,m,n,)        [lexicographic interval [m,n]; m, n constants]
  164.     (ivl,s1,s2,...)        [lexicographic intervals [s1,s2],... ]
  165.     (^)            [any control character below ASCII SP]
  166.     (PWS)            [print remaining workspace]
  167.     (PWS,r)            [print remaining workspace after message r]
  168.     (PVR,n)            [print value of variable n]
  169.     (HLT)            [wait for keystroke]
  170.     (HLT,mssg)        [print mssg, wait]
  171.     (NOP,p)            [null pattern, disables p]
  172.     (f,s)            [matches text identical to value of function
  173.                  f applied to argument s (another skeleton)]
  174.     <<...>>            [null pattern]
  175. :Skeletons may take any one of the following forms
  176.  
  177.     xxx            [constant: string of ASCII characters between
  178.                  ! and ~, except parentheses, angle brackets,
  179.                  comma and single and double quotes; it may
  180.                  include SP, CR, LF and HT]
  181.     (<)  (>)        [constants: left and right angle brackets]
  182.     <(>  <)>        [constants: left and right parentheses]
  183.     <,>  <'>  <">        [constants: comma, single quote, double quote]
  184.     (QUO/.../)        [constant ... between delimiters /]
  185.     (DEC,n)            [the decimal byte n (mod 256)]
  186.     (HEX,n)            [the hexadecimal number n]
  187.     (^xxx)            [control characters xxx]
  188.     <n>            [variable n, n between 0 and 30]
  189.     (f)            [function (skeleton) f, null argument]
  190.     (f,s)            [function f, argument s (another skeleton)]
  191.     <=>            [same text used in the last comparison, or
  192.                  argument of skeleton in a definition]
  193.     <<...>>            [null skeleton]
  194.  
  195.  
  196.  
  197.  
  198.     (if,s{,p,s,s}[,p,s])    [conditional]
  199.     (IF,(v),s{,p,s,s}[,p,s]) [conditional with variables]
  200.     (nf,s{,p,s,s}[,p,s])    [negative conditional]
  201.     (NF,(v),s{,p,s,s}[,p,s]) [negative conditional with variables]
  202.     (while,s{,p,s,s}[,s])    [iterative]
  203.     (WHILE,(v),s{,p,s,s}[,p,s]) [iterative with variables]
  204.     (until,s{,p,s,s}[,s])    [iterative, negative form]
  205.     (UNTIL,(v),s{,p,s,s}[,p,s]) [iterative with variables, negative form]
  206.  
  207. :Comments enclosed in square brackets (which may be nested) may appear at any
  208. of the places indicated by periods in the following sample structure:
  209.  
  210.   .(.(.(P1)p1.(P2)p2.).(.(S1)s1.(S2)s2.).(v1 v2).(.(Pa,Sa);.(Pb,Sb):.).)x.
  211.  
  212. They may NOT appear:
  213.     - within patterns or skeletons,
  214.     - between definitions or functions and their names,
  215.     - between rules and the colon or semicolon following them.
  216.  
  217. Spaces and tabs are allowed in any of the latter two categories, besides
  218. places where comments are legal.  No spaces are allowed within a list of
  219. variables, except single spaces used to separate variable numbers appearing
  220. in the list.  Since all spaces, tabs, and similar characters are taken
  221. literally in patterns and skeletons, the pair <<...>> may be used to format
  222. programs into lines and columns;  any text enclosed (as long as it does not
  223. contain a pair of right angle brackets) will be ignored.  For example
  224.  
  225.             (and,<[8]>,<<
  226.                 >><0>)
  227. is identical to
  228.             (and,<[8]>,<0>)
  229.  
  230. :Program file.
  231. A Convert program will eventually have to be compiled and executed if it is to
  232. produce any practical results. The program responsible for first compiling it
  233. is CONVERT.REC, which requires a disk file containing the program, and which
  234. will produce a REC program to be executed. Both steps require having a REC
  235. compiler in the system, usually REC86.EXE, although REC86F.EXE and REC87.EXE
  236. may also be used; either of the latter two is required for the execution of
  237. Convert programs involving floating point operations.  The disk file bearing
  238. a Convert program must have the extension CNV; the command line
  239.  
  240.         REC86 CONVERT SOURCE
  241.  
  242. will compile the file SOURCE.CNV to produce SOURCE.REC, which can then be
  243. executed with the command line
  244.  
  245.         REC86 SOURCE [argument]
  246.  
  247. where [argument] is an optional string received by program SOURCE as the 
  248. initial text when its execution begins.
  249.  
  250. Explicit disk assignments and pathnames can be given for any of the files 
  251. mentioned in these command lines.  REC and CNV extensions are always assumed.
  252.  
  253. The execution of the compiled program requires the presence of a library, 
  254. CNVLIB.REC, in the current directory or in any of the directories specified
  255. by the PATH environment variable.  The command interpreter environment is
  256. available in variable <30>; it consists of a concatenation of NUL-terminated 
  257. strings, each having the form VAR=value.
  258.  
  259. When execution terminates, all open files are closed and whatever text 
  260. results from application of the main program to the initial string is 
  261. displayed on the console.
  262.  
  263. Since a Convert program will be compiled into a REC program, it is convenient
  264. to require that it be laid out like a REC program:
  265.  
  266.     (subroutine 1) n1 (subroutine 2) n2 ... (main program)
  267.  
  268. wherein subroutine definitions alternate with subroutine names, which are
  269. printing ASCII characters excluding the space and the 11 characters ( ) % &
  270. # ~ < > , @ and }.  CONVERT will insert the appropriate braces to get a REC 
  271. program, as well as a subroutine to initialize and load the required routines
  272. from the library.
  273.  
  274.  
  275.  
  276. Certain comments enclosed in square brackets are processed by the compiler;
  277. in order for them to be noted the program should be structured according to
  278. the following scheme:
  279.  
  280.     [SOURCE.CNV]
  281.     [Author, Date]
  282.     [comments]
  283.     [Exclude LIB]
  284.     [Include ..]
  285.  
  286.     [subroutine 'a' descriptor]
  287.     (()()()()) a
  288.  
  289.     [another subroutine]
  290.     (()()()()) b
  291.  
  292.     [main program]
  293.     (()()()())
  294.  
  295.  
  296. The comments which are processed are [xx.CNV], [Exclude LIB], and 
  297. [Include ..].
  298.  
  299. The header [SOURCE.CNV] should be upper case, and will be transformed into
  300. [SOURCE.REC] by the compiler. The header, together with the attribution of
  301. author and date help to identify the program, and with the date, its version.
  302. All this header material should be placed in balanced square brackets.
  303.  
  304. The [Exclude LIB] comment indicates the program should not include the initial-
  305. izing routine; if appearing, it overrides any [Include ..] also present.
  306. [Include ..] indicates which routines must be loaded at run time in addition
  307. to those whose inclusion is automatically determined at compile time.  Both
  308. types of comment are required only in special circumstances.
  309.  
  310. The [Include ..] comment is only required by the root program in an overlay
  311. tree, by a program requiring floating point arithmetic, or by a program using
  312. the operators ^ or ** (for exponentiation) or % (for remainder) in arguments
  313. to the formula-evaluating skeleton (#f,s) and not using explicitly the skele-
  314. tons #^ or #%.  For example, the comment [Include #.#^#%] is required for a
  315. program which would evaluate formulae containing floating point numbers and
  316. exponentiation and remainder operations, and invoking only the library function
  317. #f.
  318.  
  319. The [Exclude LIB] comment is required by the overlaying segments of an overlay
  320. tree.  More about Include and Exclude may be found in CNVADV.HLP.
  321.  
  322. The subroutines and main program then follow.  During compilation, the
  323. compiler displays for each one of them the names of patterns and skeletons
  324. they define, the variables they declare, the punctuation following each rule
  325. (: or ;), the name of the subroutine (if it is one), and a series of dots,
  326. one for each sector of compiled code written to the disk.
  327.  
  328. :Library and Initalization.  The library is contained in file CNVLIB.REC, which
  329. is sought and read during the initializing process.  The library should reside
  330. in the current directory or any of the directories given by PATH unless the
  331. command line contains an argument having one of the following forms:
  332.  
  333.     L/d:         L/pathname-ending-in-\        L/filename.ext
  334.  
  335. The first and second forms indicate CNVLIB.REC resides on the specified disk
  336. or directory, respectively; the third form indicates that the file whose name
  337. is given (and which may include a disk identifier and subdirectory path)
  338. should be used as source for the library.  No extension is assumed in the
  339. last form if one is not given explicitly.
  340.  
  341. The argument L/ is transparent to the program, that is, it will neither appear
  342. in the program's initial text nor interfere with other arguments; for instance,
  343.  
  344.         REC86 DSASM L/A: WRTSYS
  345.         REC86 DSASM WRTSYS L/A:
  346.  
  347. both produce the same result, passing the string "WRTSYS" as initial text to
  348. the program being executed (DSASM.REC).
  349. :Boolean patterns.  One of the mechanisms for generating complex patterns
  350. from simpler constituents is to form Boolean combinations of patterns. The
  351. fundamental Boolean connectives AND, OR, and NOT may be used.  In Convert, AND
  352. and OR are not binary operations, but rather may have any number of arguments;
  353. a Boolean function of a variable number of arguments has a standard definition,
  354. which follows the associative law and reduces to the binary function in that
  355. special case. Thus it is not capriciousness which requires that
  356.  
  357.         (AND)        always matches (to the null string)
  358.         (AND,p)        is the same as p (matches if p matches)
  359.         (AND,p1,p2,...)    matches when all of the pj match
  360.         (OR)        never matches
  361.         (OR,p)        is the same as p (matches if p matches)
  362.         (OR,p1,p2,...)    matches if at least one pi matches.
  363.  
  364. As is customary in many programming languages, Boolean combinations are 
  365. executed progressively, so that no more arguments are evaluated than the 
  366. minimum needed to reach a decision. The first failure in an AND, the first 
  367. match in an OR decides the expression.
  368.  
  369.  
  370.  
  371.  
  372. Convert has an alternative series of Boolean functions, namely (and,...),
  373. (or,...), and (nor,...) [which is equivalent to (NOT,(or,...))]. They exist
  374. only for reasons of efficiency.  The issue is that Convert combines variable
  375. matching with variable generation, rather than separating these two activities.
  376. This is in turn more efficient, but subject to logical paradoxes if not done
  377. correctly. Concretely, if a variable match fails, Convert will back up and
  378. retry the previous variable it identified, or will progress to the next 
  379. alternative of a preceding OR. In using the lower case Boolean operators we
  380. forsake all this jockeying in the interest of speed, but it is forsaken
  381. nevertheless.
  382.  
  383. Thus, lower case Boolean operators are to be used when the decision which
  384. they represent is final - for example if their arguments are constants. In
  385. practice, if the patterns (ITR,xxx) and (itr,xxx) are used, the searching
  386. required by a program can be assigned to them, and the lower case operators
  387. used exclusively. The upper case operators work correctly albeit more slowly.
  388.  
  389. Combining variable generation with variable matching as Convert does restrict
  390. the participation of NOT in patterns; its arguments must not contain unbound
  391. variables.
  392.  
  393.  
  394.  
  395. One of the most common uses of AND is to impose some condition on a variable,
  396. although it could also be used to parse a string in two or more different ways.
  397. For example, consider CP/M's directory entry from which we may wish to extract
  398. the file name and the extension, and ignore the rest of the block. The pattern
  399.  
  400.     (and,<[1]>(and,<[8]>,<1>)(and,<[3]>,<2>)<[20]>,<4>)
  401.  
  402. will bind the whole 32-byte string to the variable <4>, but at the same
  403. time allow us to retrieve the file name as <1>, and the extension as <2>.
  404. Both uses of AND are shown in this example. The pattern
  405.  
  406.     (and,(ITR,(and,<[1]>,(nor, ,(^I))),<0>)
  407.  
  408. will match a string free of spaces or tabs - whitespace as some say - and
  409. associate it with the variable <0>. The inner "and" prevents the null string
  410. from matching the "nor". The first argument of an AND establishes the length
  411. of the string that the remaining arguments must match. Another example would
  412. be to identify a decimal number through
  413.  
  414.     (and,(ITR,(and,<[1]>,(IVL,0,9,))),<0>).
  415.  
  416.  
  417.  
  418. The most apparent use of the Boolean OR is to express alternatives. Taken
  419. together with a mechanism to assign a name to a pattern, OR can be used to
  420. generate recursive patterns.  Given the definition
  421.  
  422.         ((or, <:s:>,)) s
  423.  
  424. we can define a series of spaces - which is either a space followed by the
  425. series, or the null string. This definition also makes use of the property,
  426. that the first viable alternative satisfies an OR.  Alternatively,
  427.  
  428.         ((OR,, <:m:>)) m
  429.  
  430. would be a pattern that rendered the null string unless a reconsideration
  431. were forced upon it. These two alternatives define respectively a maximal
  432. and a minimal string satisfying a condition defined by an OR. Equivalently,
  433.  
  434.         ((ITR, )) s
  435.         ((itr, )) m
  436.  
  437. Many other kinds of recursive definitions can be made with OR, but it is
  438. interesting to note that ITR and itr seem to be sufficient for the
  439. applications that have been encountered.
  440.  
  441. An OR with a null terminal argument is a convenient way to express optional
  442. elements of a string. Consider
  443.  
  444.         ((or,+,-,)<:d:>(or,.<:d:>,)) f
  445.  
  446. as a definition of a signed floating point number. The sign is entirely
  447. optional, as is the decimal point. According to whether <:d:> accepts the
  448. null string or not, <:f:> could match or not a single isolated decimal point.
  449. If it does not, we would have to modify the definition to make 1. into an
  450. acceptable number.
  451.  
  452. :Constant Patterns and Skeletons.  There are two types of constants: default
  453. constants and distinguished constants.  A default constant is any string
  454. including spaces, tabs, carriage returns, line feeds and printing ASCII
  455. characters (those between ! and ~) except any of the seven characters ( )
  456. < > , " and '. The first five exceptions have been reserved to delimit
  457. patterns and skeletons of diverse kinds; the last two play an exceptional role
  458. in REC and so must be given special treatment; it is the conflict with REC
  459. which keeps them from being used for quoting in Convert.  The distinguished
  460. constants are described in the remainder of this section.
  461.  
  462. The very delimiters themselves have to be quoted; for conciseness and to
  463. avoid reserving yet more symbols, we use them to quote each other:
  464.  
  465.         <(>    left parenthesis
  466.         <)>    right parenthesis
  467.         (<)    left angle
  468.         (>)    right angle
  469.         <,>    comma
  470.         <'>    single quote
  471.         <">    double quote
  472.  
  473.  
  474.  
  475. It is not convenient to incorporate control characters directly into programs,
  476. because they interfere with printing the program for reference. The pattern
  477. (CTL,xxx) proved to be unsightly, so we use the form (^xxx), in analogy to
  478. the common representation ^X for a single control character.  The characters
  479. allowed in the string xxx are those between @ and _; these bounds correspond
  480. to control characters whose values in ASCII are 0 and 31, respectively. Some
  481. useful control characters to remember are:
  482.  
  483.         (^I)    horizontal tab
  484.         (^Z)    end of file
  485.         (^MJ)    carriage return, line feed
  486.         (^[)    escape
  487.  
  488. Provision has been made for quoting a long string, too cumbersome to represent
  489. character by character using the foregoing conventions; we could write
  490.  
  491.         (QUO/.../)
  492.  
  493. wherein / could be any character not occurring in the text ..., and terminates
  494. the string with its second appearance in the pattern.
  495.  
  496.  
  497.  
  498. Two constants have been provided for recognizing (as patterns) or generating
  499. (as skeletons) bytes of binary data:
  500.  
  501.     (DEC,n)        decimal byte n (mod 256)
  502.     (HEX,k)        the shortest byte string needed to represent
  503.             the hex value k (including leading zeros in k)
  504.  
  505. For example, (DEC,2035) represents a byte whose decimal value is 243, whereas
  506. (HEX,5C) represents a byte whose decimal value is 92.  For hexadecimal strings
  507. with 3 or more digits, the string represented by (HEX,k) is machine-dependent;
  508. in microprocessors following Intel's convention, (HEX,05C) would represent two
  509. bytes, the first of which is 92 (decimal) and the second zero (the least
  510. significant byte in the lowest addressed location); on other microprocessors
  511. like the MC68000, (HEX,05C) would represent two bytes, the first one zero and
  512. the second one 92 (the most significant byte at the lowest address).  In any
  513. case, the string represented is |_ (|k|+1)/2 _| bytes long.
  514.  
  515. :Input-Output skeletons exploiting MS-DOS's BDOS:
  516.  
  517.     (%Or,pathname)            open file for reading
  518.     (%Ow,pathname)            open file for writing
  519.     (%r)                read from standard input
  520.     (%r,pathname)            read file
  521.     (%r,pathname,pattern)        read until match
  522.     (%r,pathname,patt,skt)        read, match, substitute
  523.     (%r,pathname,patt,skt,skf)    read, match, two options
  524.     (%W,pathname,xxx)        write file
  525.     (%C,pathname)            close file
  526.     (%E)                close all files
  527.     (%Lr)                get id of currently logged-in disk
  528.     (%Lw,D)                log in the given disk
  529.     (%S,pathname)            search
  530.     (%A)                search again
  531.     (%D,pathname)            delete
  532.     (%N,new_pathname,old_pathname)    rename
  533.     (%T,xxx)            type, preserve
  534.     (%t,xxx)            type, erase
  535.     (%+)                type CR,LF
  536.     (%P,xxx)            print, preserve
  537.     (%p,xxx)            print, erase
  538.  
  539. The pattern-directed READ operation is worthy of attention. There are
  540. several forms of the READ function-skeleton %r,
  541.  
  542.     (%r)                read from default
  543.     (%r,pathname)            read file
  544.     (%r,pathname,pattern)        read until match
  545.     (%r,pathname,patt,skt)        read, match, substitute
  546.     (%r,pathname,patt,skt,skf)    read, match, two options
  547.  
  548. which are progressively more complex.  Beginning with the first, the standard
  549. input is assigned, and a single line is delivered to the workspace with each 
  550. invocation, without the terminating carriage return or line feed.  The 
  551. standard input is the keyboard unless modified by means of redirection by
  552. the command interpreter.  This form gives a simple means of communication
  553. that can be especially helpful in the initial stages of program development.
  554.  
  555. The next alternative in the sequence of complexity requires the programmer
  556. to assign a specific file. The latter can be a constant, or it can be a
  557. skeleton which evaluates into the name of the file.  An example would be
  558. (%r,<7>:<8>.<9>), where the disk, file and extension have been determined
  559. separately and bound to variables 7, 8 and 9, respectively.  (%r,) is the
  560. same as (%r).
  561.  
  562. Just as in the null name case, a single line, without its terminator, is placed
  563. in the workspace with each execution of the skeleton. If the end of file has
  564. been reached, a control-Z is inserted and will be produced repeatedly each
  565. additional time an attempt is made to read the exhausted file. The file itself
  566. is buffered so that partial contents such as a single line can be read at will.
  567.  
  568. Sometimes data is not divided into lines, or it may be that the program finds
  569. it inconvenient to receive a whole line at a time. A binary file would typify
  570. the former case, the scrutiny of a file word by word or by sentences would
  571. exemplify the second. In these cases the third form of %r is useful.
  572.  
  573. The third variant, to which a pattern has been adjoined, will search the
  574. input stream until the first instance of the pattern is found, which will
  575. then be given to the workspace. Using the skeleton again will locate the
  576. second instance of the pattern, and so on.
  577.  
  578. If the file is exhausted and no match was obtained, all of the material read
  579. remains in the workspace; subsequent reads will leave the null string.  Care
  580. in the selection of the pattern must be exercised to avoid the possiblility
  581. of overflowing the workspace, which would cause program termination.
  582.  
  583.  
  584. The final two forms practically allow the incorporation of a whole pre-
  585. processor into the read command, since it allows any recognition and
  586. transformation that Convert is capable of expressing to be incorporated 
  587. into the act of reading a file; furthermore this processing can be tailored
  588. individually for each file, and even for each instance of reading.
  589.  
  590. In the next to the last case, %r leaves the value of skt if the pattern
  591. does match; otherwise all of the text (to the end of the file) is left.  In
  592. the last case, skf is a skeleton which generates the text left in the
  593. workspace if the pattern does not match the text read.
  594.  
  595. In these skeletons, if the null pattern is given [e.g. (%r,,,skt)], %r reads
  596. up to the next carriage return (or to the end of the file if no CR is found).
  597.  
  598. Finally, patterns within READ skeletons requiring unbound variables for
  599. binding may be accomodated by including a list of variables (a list of one
  600. or more numbers between 0 and 30 separated by single blanks) following the
  601. alternative name %R:
  602.  
  603.         (%R,(v1 ...),pathname,pattern)
  604.         (%R,(v1 ...),pathname,pattern,skt)
  605.         (%R,(v1 ...),pathname,pattern,skt,skf)
  606.  
  607. Skeletons performing writing operations vary as to the result they leave in
  608. the workspace.  Skeletons %T and %P leave the value of their argument; %t and
  609. %p always erase it.  In addition, %T and %t write CR and LF before sending
  610. their argument to the console, whereas %P, %p and %W write no more than the
  611. value of their arguments.
  612.  
  613. If %W is not able to write on the indicated file due to lack of space, it will
  614. leave on the workspace the unwritten portion of its argument.
  615.  
  616. (%Or,pathname) leaves the null string if it was possible to open the 
  617. indicated file; it leaves the string "Not Found" if the file could not be 
  618. opened.
  619.  
  620. In functions %r, %W, %Or, %Ow and %C the value of the skeleton designating the
  621. file is not restricted to an actual disk file, in conformity with CP/M's
  622. conventions (inherited by MS-DOS) that there may be such devices as TTY: or 
  623. EOF:. The assortment is not exactly the same, but it includes
  624.  
  625.     TTY:    console keyboard    MEM:X    named memory pseudofile
  626.     NUL:    the null file        ARR:X    named array pseudofile
  627.     CTR:X    named counter        STK:X    named stack pseudofile 
  628.         
  629.  
  630. The operations of reading via %r and writing via %W may be performed on
  631. these devices just as though they were disk files. They may be opened and
  632. closed by using %O and %C; in fact these operations are a necessity if these
  633. false devices are to be given a meaningful definition, or if they are to be
  634. removed from a program in an orderly fashion when they are no longer required.
  635.  
  636. (%W,TTY:,skel) works like (%t,skel), but without the CR/LF included by %t in
  637. its operation.  (%r,TTY:prompt) reads a line from the keyboard regardless of
  638. standard input redirection, and allows a user-defined prompt to be provided.
  639.  
  640. Every write operation on NUL: simply erases its argument; every read from NUL:
  641. returns control-Z; that is, NUL: functions as a file to which one can "write"
  642. without limit but which is permanently exhausted when read.  This pseudofile
  643. is useful in compiler and assembler construction, where for test purposes one
  644. may not want to produce, say, an object file.  In this case a variable could
  645. be bound at the beginning of the program to NUL: or to a disk file, and this
  646. variable be used in all references to the object file.
  647.  
  648. MEM:X, ARR:X and STK:X pseudofiles are dealt with in detail in CNVADV.HLP.
  649.  
  650.  
  651.  
  652.  
  653. To open and then read a counter requires only a name, of eight or less
  654. ASCII characters. Neither counters nor pseudofiles use extensions.
  655. To write a counter we have a series of parameters, whose tail may optionally
  656. be discarded at any point after the counter's name. Altogether, we can write
  657.  
  658.         (%Or,CTR:XXXXXXXX)
  659.         (%W,CTR:XXXXXXXX,val,incr)
  660.         (%r,CTR:XXXXXXXX)
  661.  
  662. Argument val is the initial value; its default is 0; incr is the increment,
  663. which may be signed and whose default is +1; the assigned value is any
  664. (sixteen bit) integer which is modified in modulo-16 arithmetic. Both of the
  665. parameters are ASCII strings representing decimal numbers, introduced into
  666. the skeleton as constants or as other skeletons which evaluate into constants
  667. of the required form.  Every time that a counter is read, its present value
  668. is reported, but the increment is added to its stored value so that it will
  669. appear at the next reading.  In the language of "C",it is a postincrementing
  670. counter. When a counter is opened, it is assigned default value 0, increment 1.
  671.  
  672. :Directory Skeletons.  It is possible to write a Convert program which will
  673. process a series of files, for example to pack several short files into
  674. a single large file. Later, with another similar program, they can be restored
  675. to their original condition. This process can be used advantageously to build
  676. up libraries, for example.  Another use would be to search for a series of
  677. files and to offer the user to process each one in turn, interactively.
  678.  
  679. To realize this sort of operation Convert offers access to the BDOS functions
  680. for directory and disk system access via the operators K and k in REC.
  681.  
  682.     (%S,pathname)            initial search for file
  683.     (%A)                subsequent search for file
  684.     (%D,pathname)            delete specified files
  685.     (%N,newpathname,oldpathname)    rename file
  686.     (%Lr)                get id of currently logged-in disk
  687.     (%Lw,D)                log in the given disk
  688.  
  689. Arguments for %S and %D may include the wildcard characters * and ?, allowing
  690. families of files to be referenced. The following scheme, showing a Main
  691. program and satellite, can be used as the basis of a Convert program which
  692. will process a series of files as given by a possibly ambiguous file reference
  693. in the initial command line.
  694.  
  695. [Program heading, including Name and Comments]
  696.  
  697. [the bulk of the program, accessed through a program called "y"]
  698. (()()()()) y
  699. ...
  700. [Gather directory entries in WS, removing status bytes]
  701. (()()(0 1)(
  702.     (Not Found(^@)<0>,<0>);
  703.     (<[9]><0>(^@)<1>,(%A)(^@)<0>(^@)<1>):
  704. )) z
  705.  
  706. [Main program: search for first]
  707. (()()(8)(
  708.     ((and,(or,<[1]>:,)(ITR,<-->\),<8>),(y,(z,(%S,<=>)(^@))));
  709. ))
  710.  
  711. %S and %A return a string starting with nine bytes (containing attributes,
  712. file length, time stamp, etc.) and the base name of the file (name, period,
  713. extension).  Thus the main program binds any disk identifier and subdirectory
  714. path to variable <8>, which then is available to any subroutine called as long
  715. as its variable list does not include 8.  "Not Found" is returned whenever the
  716. search fails. (^@) --NUL-- is used to separate file names in "z".
  717.  
  718. On arriving at the execution of "y" the workspace contains all the relevant
  719. file names --possibly none-- which were found by "z". It is advisable
  720. to gather them up all at once on entering the program, before the directory
  721. begins to change. This avoids the conflict of a new file having the same name
  722. as an old file.
  723.  
  724. For other programs to use the workspace, this directory extract must be stored
  725. in a variable and parcelled out to the programs as they are required. It will
  726. generally be sufficient to call the following program "y" and interpose it
  727. between the actual program, "x", and the main program, which already calls it.
  728.  
  729. [Get next name]
  730. (()()(0 1)(
  731.   [separate next name]    (<0>(^@)<1>,<<
  732.   [process this file]        >>(x,<8><0>))<<
  733.   [rest of files]        >><1>):
  734. )) y
  735.  
  736. "y" rebuilds a full name by prefixing the filename (bound to variable 0) with
  737. the (possibly null) disk-subdirectory path bound to <8> by the main program.
  738. "x" encounters a pathname on entry, must leave a null chain when it finishes; 
  739. but it could possibly return some additional files for processing.
  740.  
  741. :Arithmetic Skeletons.  Convert provides facilities for integer and floating
  742. point arithmetic (through skeleton #) and for character "arithmetic" (through
  743. skeleton &).  The latter facilitates upper/lower case conversions, hexadecimal
  744. dumps and access to individual bits or groups of bits within bytes.
  745.  
  746. The file CNVADV.HLP contains a detailed description of the operations possible
  747. with these two library skeletons.
  748.  
  749. :Conditional and iterative skeletons. The fundamental skeleton forms in 
  750. Convert are constants, variables and functions. In principle it is sufficient 
  751. to work with this combination because functions are readily defined and 
  752. capable of defining any construction that one wants. Thus the motivation for 
  753. introducing further skeleton forms would have to be to offer some frequently 
  754. used function as an inherent feature of the language. Other motives would be 
  755. to avoid the cumbersome ritual of defining a function if a particularly 
  756. simple action were desired, or to avoid preparing an argument for a function 
  757. and then finding that the argument would not be used after all.
  758.  
  759. Most languages have facilities for the selection of alternatives - an IF
  760. statement, or for an orderly repetition of some activity - a DO or a WHILE
  761. statement. The convenience of these constructs is widely recognized. Convert
  762. offers the conditional skeletons if, IF, nf and NF, and the iterative
  763. skeletons while, WHILE, until and UNTIL, all of which are described in
  764. detail in CNVADV.HLP.
  765.  
  766. :Variables are distinguished by decimal numbers in Convert. There is no
  767. theoretical limit to their range, but the practical range is 0-30 with the
  768. present structure of the underlying REC compiler. Few programs go beyond
  769. ten variables, many subsist with one or two, and it is possible to have a
  770. program without any variables at all.
  771.  
  772. Even if a program binds no variables, they must be enclosed in parentheses.
  773. The same is true of pattern and skeleton definitions, so that a program
  774. quadruple (()()()()) may contain some null parentheses.
  775.  
  776. A program should not bind a variable which it has not declared - that is,
  777. if a previously undefined variable appears in the pattern of one of the
  778. rules of a program where it may become defined, it must be declared in the
  779. variable list.  The variable list guarantees that the program has at its
  780. disposal new instances of the variables listed, and that those variables are
  781. unbound prior to trial of each rule in the rule set.
  782.  
  783. A variable is designated by enclosing its number within angle brackets. <0>,
  784. <8>, or <15> are examples of variables. Variables are defined by patterns and
  785. used by skeletons. Convert combines variable matching and variable generation
  786. so that a variable can be defined and then matched within the same pattern.
  787.  
  788.  
  789. Generally speaking, variables are defined by the constants which surround
  790. them; thus v<0>e would assign the value ariabl to <0> when matched against
  791. the word variable, or a null value when matched to ve. Since the null string
  792. is accepted throughout Convert, a very common type of error arises from matches
  793. involving a null string in a way that the programmer had not foreseen. Since
  794. Convert uses other pattern forms than constants, a variable need not always be
  795. delimited by a constant. <[9]>(and,<[3]>,<0>)<[20]> could be used to pick the
  796. extension out of a CP/M-style directory entry, for example.
  797.  
  798. Persons who like long or arbitrary variable names will be disappointed with
  799. Convert.  When CONVERT was built over a LISP substrate, it was possible to make
  800. arbitrary choices of variable names; this was because LISP contained a kind
  801. of preprocessor which parsed individual atoms and replaced them by their own
  802. address in a dictionary. A string parser does not necessarily want to isolate
  803. atoms, so another symbolism must be found.
  804.  
  805. Other persons find that it is much easier to work with a very concise symbolism
  806. even though it means reusing the same few symbols over and over again in each
  807. different context.  Thus one may see a complicated file of Convert programs all
  808. of which use the same series of variables <0>, <1>, ... up to the number that
  809. the given program requires. It is not hard to become accustomed to this way of
  810. thinking.
  811.  
  812. :Intervals.  There is a kind of pattern, which is technically a variable when 
  813. giving a formal definition of the syntax of Convert, but which is not treated 
  814. as a variable in this description because it is not assigned a name, and so 
  815. can't be referred to again, either in the same pattern or in the paired 
  816. skeleton of its rule. Of course, it is not lost entirely; it can be named by 
  817. participating in an AND together with a named variable. We call these unnamed 
  818. variables intervals, of which there are four kinds:
  819.  
  820.         <-->    indefinite interval
  821.         <[n]>    interval of length n
  822.         <[-n]>    all but the last n bytes
  823.         <>    null interval (no more text in workspace)
  824.  
  825. The indefinite interval simply allows us to skip over uninteresting parts of a
  826. text - for example an end-of-file embedded in a line of whatsoever length can
  827. be detected by <-->(^Z).
  828.  
  829. Tabular information can be broken into columns by specifying an interval of a
  830. determined length. Such a pattern is often paired with a named variable through
  831. an and, as in (and,<[8]>,<0>). In this sense it is a predicate, describing some
  832. property of a string, and it is reasonable that it should be compounded using
  833. the Boolean AND.
  834.  
  835. Easy access to the last n bytes of a string is obtained with <[-n]>, where
  836. n is an integer.  A pattern such as <[-1]><0> would bind the very last byte
  837. to variable <0>; if we need to keep the text preceding the last byte we can
  838. always bind it to a variable through an and: (and,<[-1]>,<1>)<0> binds all
  839. but the last byte to <1> and the last byte to <0>.  <[-n]> will of course
  840. fail if less than n bytes remain in the workspace.
  841.  
  842. A null pattern will always match a null interval, but the null designator <>
  843. refers to something slightly different; it requires that it be matched to the
  844. entire remainder of the workspace, and that that remainder be null. Thus the
  845. rule
  846.     (<>,there<'>s nothing here)
  847.  
  848. will guarantee that the workspace is empty and say so; the rule
  849.  
  850.     (,goodbye)
  851.  
  852. will ALWAYS succeed. It is a useful final rule to give a function a value.
  853.  
  854. The reason that we have to insist explicitly on a null workspace has to do
  855. with a feature of the pattern matching process which usually simplifies
  856. programs and makes them run faster.
  857.  
  858. A final UNBOUND VARIABLE, including <-->, will always match the entire
  859. remainder of the workspace. A final CONSTANT, including definite intervals
  860. and BOUND variables, will only require corresponding text, but will remain
  861. indifferent to any text or lack thereof which follows it. This is why null
  862. text will match anything, because "anything" always begins with a null
  863. character.  Historically CONVERT programs spent far too much time seeking
  864. character by character for the end of the text when it corresponded to a
  865. final variable. Likewise, it is bothersome to append a final <--> to text
  866. only whose beginning interests us.
  867.  
  868. Consider the two patterns
  869.  
  870.             <4><4>     and    <4><4><>
  871.  
  872. The first pattern matches anything: assuming it is initially unbound, the
  873. first instance of <4> binds tentatively to the null string.  Then, since
  874. the second instance of <4> is an instance of a BOUND variable, it will also
  875. match.  No constraints are placed on the rest of the workspace, so the
  876. tentative binding becomes final.  On the other hand, the second pattern
  877. matches only strings made up of two identical substrings: if the workspace
  878. text is non-null; the initial null-string trial value for the first instance
  879. of <4> causes <> to fail after the second instance of <4> matches.
  880.  
  881. There is another context in which the null-seeker <> is implicit. Suppose
  882. that we have defined balanced parentheses using the following two pattern
  883. definitions:
  884.  
  885.   [non-parenthesis]        ((and,<[1]>,(nor,<(>,<)>)) n
  886.   [balanced parenthesis]    (<(>(ITR,(or,<:p:>,<:n:>))<)>) p
  887.  
  888. and that we want to bind the variable <0> to the contents of a parenthesis
  889. pair. We would then define
  890.  
  891.   [parenthesis interior]    ((and,<:p:>,<(><0><)>)) i
  892.  
  893. where the second pattern in the "and" has implicitly the form <(><0><)><>,
  894. which ensures that the right parenthesis following <0> is the final right
  895. parenthesis that <:p:> picked out, not the first one to be found; the
  896. implicit <> is required by the definition of "and".
  897.  
  898. :A different kind of interval is the lexicographic interval.  This is a
  899. pattern that matches a string if it lies within an interval defined by
  900. two strings.  The lexicographic ordering is that induced by the ASCII
  901. code.  There are three lexicographic interval patterns:
  902.  
  903.     (IVL/x/y/)    Interval defined by constant strings x and y 
  904.             (which do not contain the delimiter /).
  905.     (ivl,s1,s2,...)    Multiple intervals delimited pairwise by skeletons
  906.             s1, s2, ... .
  907.     (^)        A single control character between NUL and US; this
  908.             is equivalent to (ivl,(^@),(^_)).
  909.  
  910. (IVL/x/y/) matches strings lying in the interval [x,y] (limits included);
  911. it will match the shortest string t satisfying x <= t <= y.  If x is the
  912. null string, IVL matches the null string trivially; if y is the null string,
  913. IVL is interpreted to match the shortest string t satisfying x <= t.
  914.  
  915. In (ivl,s1,s2,...) skeletons are taken by pairs and evaluated; if vj is the
  916. value of skeleton sj, the effect is the same as (or,(IVL/v1/v2/),...).  If
  917. there is an odd number of skeletons, a null string is assumed for the second
  918. string of the last interval.  Delimiters in ivl are always commas; the
  919. delimiter in IVL may be any character not in the interval bound strings.
  920.  
  921. :The working part of a Convert quadruple is its rule set, the fourth member
  922. of the quadruple. There is not much point to a null rule set, but it is
  923. quite possible for a program to depend on a single rule. The set has the
  924. form
  925.         (
  926.         (p1,s1):
  927.         (p2,s2);
  928.         ...
  929.         (pn,sn);
  930.         )
  931.  
  932. The outer parentheses are necessary; they define the set. The inner parentheses
  933. are also necessary, for they define the rule. It is a matter of one's personal
  934. preference as to where the external parentheses are located, but it is good
  935. programming practice to adopt a definite style and follow it, as it makes
  936. errors much easier to spot when reviewing a program.  In contrast, once the
  937. rule has commenced, every space, tab, line feed or what not counts. The comma
  938. which separates the pattern from the skeleton is a prominent part of the rule
  939. and must be placed accurately. Commas which occur within the pattern are also
  940. crucial in their placement. Commas which are really constants and part of the
  941. text must be quoted: <,>.
  942.  
  943.  
  944. The colons or semicolons which immediately follow the rules are essential, and
  945. are an inheritance from REC. They determine whether rules are to be repeated,
  946. when the colon is used, or whether the program has terminated, signalled by the
  947. semicolon. Rules are tried out in sequence, from top to bottom, left to right
  948. as they are written on paper. Several short rules can occupy the same line if
  949. convenient. If no rule applies, the workspace is left unchanged. This is still
  950. another way that the execution of a program may terminate.
  951.  
  952. There are some fine points to be considered in designing a rule set. Using a
  953. colon to produce an iterative transformation of the workspace supposes that
  954. the whole workspace is available for the transformation. If only a part of
  955. the workspace is to be subject to the transformation, the preservation of the
  956. remainder arises in a way that makes it preferable to exercise a recursive
  957. call even though it is to the same rule set. This makes counting the number
  958. of preserved fragments automatic.
  959.  
  960. Since Convert is a pattern directed language, and the pattern is presented
  961. by example and not in some other way, the rules must be stated precisely.
  962. Outside the rule more freedom is permitted, allowing the rule set to be
  963. formatted according to what the programmer considers attractive. Comments,
  964. enclosed in square brackets, have no effect on the compilation and their
  965. liberal use will enhance the program's quality.
  966.  
  967. :Debugging Aids.  Convert offers several aids to debugging programs. As with
  968. any language, programs that don't contain errors don't have to be debugged.
  969. This may look like redundant advice, but it is sound.  Good programming habits
  970. reduce errors. Although there are free-form aspects to Convert, it is still
  971. amenable to developing typical program formats and adhering to them. They
  972. promote good programming, and make lapses easier to detect. The patterns
  973.  
  974.         (PWS)        [print remaining workspace]
  975.         (PWS,mssg)    [identify printed workspace with message]
  976.         (HLT)        [stop program, wait for keystroke]
  977.         (HLT,mssg)    [print message, then halt]
  978.         (PVR,n)        [print value of variable n]
  979.         (NOP,p)        [null pattern, disables p]
  980.  
  981. are provided primarily for debugging. The rule
  982.  
  983.         ((PWS,subroutine: )(or),);
  984.  
  985. placed at the beginning of a program allows tracing by showing the workspace as
  986. each subroutine is entered; also the evolution of the workspace as repetitive
  987. rules change it.  If a given rule hangs up a calculation, it can be found
  988. by interspersing this same rule among the normal rules.
  989.  
  990. On the skeleton side of a rule, the only debugging aids are the skeleton
  991. functions %t and %T which display their argument on the console (the former
  992. nulls its argument, the latter returns it unchanged).  %T may be applied to a
  993. problematical skeleton to see what kind of a result it produces when evaluated.
  994. If a function is under suspicion, the combination
  995.  
  996.         (%T,(f,(%T,...)))
  997.  
  998. will show both the argument and the result.  To display messages without their
  999. remaining in the workspace, %t may be used:
  1000.  
  1001.         (%t,...)
  1002.  
  1003. Selective printing suffices to find the majority of errors in Convert which
  1004. are syntactically correct but the result of a poorly designed or erroneous
  1005. program. There are occasional errors which are due to flaws in the support
  1006. programs which Convert uses. These are gradually being caught and eliminated,
  1007. but the possibility always exists that an error has occurred on this more
  1008. fundamental level.
  1009.  
  1010.  
  1011.  
  1012.  
  1013. There are certain possibilities for error arising out of the resemblance 
  1014. between the symbolism of REC and the symbolism of Convert, which are activated 
  1015. when a bit of source code passes directly from Convert to REC. For example, the 
  1016. notation <:0:> for a defined pattern reference can be miswritten <0:>, 
  1017. causing ":" to pass unchanged, this may well provoke an unending loop.
  1018.  
  1019. Another source of error lies in the use of double angle brackets to generate
  1020. continuation lines for patterns or skeletons. Consider the code
  1021.  
  1022.         (pattern,<<
  1023.                 >>skeleton 1<<
  1024.                 >>skeleton 2>>
  1025.                 >>);
  1026.  
  1027. The double angle following skeleton 2 is reversed; such errors are common.
  1028. Note also that the double angles are effective only within a pattern or within
  1029. a skeleton, they cannot bridge across from one to the other. Thus,
  1030.  
  1031.         <<(pattern, skeleton)>>
  1032.  
  1033. cannot be used to "comment out" a rule.
  1034.  
  1035.  
  1036. If a program cannot be debugged with judicious use of print statements, and
  1037. following it with DEBUG appears too formidable, it is useful to revise the
  1038. intermediate REC code. If sections appear more like Convert code than REC code,
  1039. a parenthesis, angle bracket or quote is probably unbalanced. It should be
  1040. located and corrected, and the compilation tried anew.
  1041.  
  1042. It is possible to put much more selective print statements or comments in the
  1043. REC intermediate, using the operator T or inserting 'message'TL at appropriate
  1044. points. Of course, they will be lost when the intermediate is discarded in
  1045. favor of a new one when the Convert source is corrected and recompiled, so one
  1046. should not expend the effort to make elaborate insertions unless the problem
  1047. is very difficult, the intermediate is renamed to save it, or one is willing
  1048. to forego a new compilation until significant progress has been made in 
  1049. correcting the difficulties in the program.
  1050.  
  1051. :Performance. As a very rough estimate, a REC program compiles into three times
  1052. as many bytes as the source code. This factor is reduced according to the ratio
  1053. of comments to program, and when large quantities of text are quoted. Comments
  1054. result in no compiled code; quoted material goes over byte for byte plus a tiny
  1055. overhead to load it onto the pushdown list at execution time.
  1056.  
  1057. Convert programs typically produce 30% more REC object code than there was
  1058. source code, again modified by the presence of comments and the ratio of
  1059. constant patterns and skeletons to the use of variables and Boolean composites.
  1060. To this one must add the initializing code inserted by the compiler, occupying
  1061. about 1K.  Once loaded and ready to execute, a Convert program takes up about
  1062. 3.5 times as many bytes as in the source file, plus 2K of initializing code
  1063. and between 2K and 12K of library routines, depending of the program require-
  1064. ments determined by its use of library calls.
  1065.  
  1066. As a practical matter, the maximum size Convert program (in source) that a
  1067. REC compiler can execute (without recourse to overlays) is about a quarter
  1068. of the compilation area size at REC's disposal, which is about 23 or 24K
  1069. for REC80 and up to 60K for REC86.
  1070.  
  1071.  
  1072.  
  1073.  
  1074. Many of the simple programs that can be written in Convert can also be written
  1075. in assembly language, and the amount of resultant code compared. In very
  1076. general terms, the factor ranges between ten and twenty, tending to twenty.
  1077. A similar inflation is experienced in some other "high level" languages - the
  1078. "C" compiler for example. The reason for this inflation is readily found in
  1079. the formal expansion of certain structures which have to be fairly intricate
  1080. to handle general cases and can be much reduced in particular instances.
  1081.  
  1082. Programming time in Convert can be extremely short - minutes in some cases. The
  1083. inflation in program size is fully recovered when considering development time
  1084. for a program.
  1085.  
  1086. Execution time tends to follow program size. Programs written in Convert to
  1087. process files can handle them at the rate of lines per second - slow compared
  1088. to good assembly language programming, not unacceptable in an absolute sense,
  1089. and vastly faster than doing the same job manually through an editor.
  1090.  
  1091. :Bibliography.
  1092. Convert is a chain oriented adaptation of the LISP based CONVERT in
  1093.     Adolfo Guzman and Harold V. McIntosh
  1094.     "CONVERT"
  1095.     Communications of the ACM 9 604-615 (1966).
  1096.  
  1097.  Articles on string Convert are
  1098.     Gerardo Cisneros and Harold V. McIntosh
  1099.     "Introduction to the programming language Convert"
  1100.     SIGPLAN Notices 21 #4 (Apr) 48-57 (1986)
  1101.     [Translated from "Introduccion al lenguaje de
  1102.      programacion Convert", Acta Mex. de Ciencia y
  1103.      Tecnologia 3 #9 (Ene-Mar) 65-74 (1985)]
  1104.  
  1105.     Harold V. McIntosh and Gerardo Cisneros
  1106.     "The Programming Languages REC and Convert"
  1107.     SIGPLAN Notices 25 #7 (Jul) 81-94 (1990) ]
  1108.  
  1109. [CNVRT.HLP]
  1110. [Harold V. McIntosh, 11 March 1984]
  1111. [Rev.: G. Cisneros, 23 January 1986]
  1112. [Rev. for MS-DOS: G. Cisneros, 25 September 1990]
  1113. :[end]
  1114.