Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;
- ;;; Destructively replaces character '#' with ';'. At the time of
- ;;; writing semicolons were used only in #-commented sections.
- ;;;
- ;;; FIXME: unfortunately there is at least one use of the #-character
- ;;; in atomic class symbol --- C#. See atom types 897 & 898 in
- ;;; oplsaa.prm and smoothaa.prm. It happens that this C# atom type is
- ;;; the only place where the char # is not preceeded by a space or
- ;;; another # (cf. grep "[^ #]#" *.prm).
- ;;;
- (define (rewrite! str)
- (string-map! (lambda (c)
- (case c
- ((#\#) #\;) ; # -> ;
- (else c))) ; leave the rest alone
- str))
- (define (rewrite!! str)
- (let ((n (string-length str)))
- (let loop ((i 0) ; pointer into the string
- (f #t)) ; should we interprete evential # as a comment sign?
- (if (< i n)
- (let ((c (string-ref str i))
- (i++ (+ 1 i)))
- (if (and f (equal? c #\#))
- (begin
- (string-set! str i #\;)
- (loop i++ #t))
- (loop i++ (char-whitespace? c))))))))
- (define a (string-copy "c# #xyz# ## c# # ## ### comm#nts"))
- (rewrite!! a)
- (pretty-print a)
- (exit 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement