15 Highlighting Scheme source code

Highlighting Scheme code is straight forward. The only thing you have to do is setting the type option of the '\sourcebegin' and '\sourceinput' commands to scm. Therefore this section is merely a demonstration of how a '.scm' file will look like. Notice however the comment style used in the Scheme source files. In order to be recognized by ProgDoc, comments can begin with one to four semicolons.

Listing 12: doc/example.scm
;; BEGIN Factorial
(define factorial
  (lambda (n)
    (if (= n 1)
        1
        (* n (factorial (- n 1))))))
;; END Factorial

(string=? "K. Harper, M.D." ;; Taken from Section 6.3.3. (Symbols) of the R5RS 
          (symbol->string
           (string->symbol "K. Harper, M.D.")))

;; BEGIN Square
(define square
  (lambda (n)  ;; My first lambda
    (if (= n 0)
        0
;; BEGIN Recursive_Call
        (+ (square (- n 1))
           (- (+ n n) 1)))))
;; END Recursive_Call
;; END Square

Notice that we used the command \renewcommand{ \pdCommentFont}{ \bfseries\itshape} in order to set the comment font of the listings beginning with Listing 12 to bold italic.

Listing 13: doc/example.scm [Line 14 to 21]
(define square
  (lambda (n)  ;; My first lambda
    (if (= n 0)
        0
        <see Listing 14>

Listing 14: doc/example.scm [Line 19 to 20] (Referenced in Listing 13)
(+ (square (- n 1))
   (- (+ n n) 1)))))



Volker Simonis 2003-03-05