This file is indexed.

/usr/share/minlog/src/lr-dvr.scm is in minlog 4.0.99.20100221-5.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
; $Id: lr-dvr.scm 2198 2008-03-26 09:38:32Z schwicht $
;; ---------------------------------------------------------------------- ;;
;; FICHIER               : lr-dvr.scm                                     ;;
;; DATE DE CREATION      : Fri May 31 15:47:05 1996                       ;;
;; DERNIERE MODIFICATION : Fri May 31 15:51:13 1996                       ;;
;; ---------------------------------------------------------------------- ;;
;; Copyright (c) 1996 Dominique Boucher                                   ;;
;; ---------------------------------------------------------------------- ;;
;; The LR parser driver                                                   ;;
;;                                                                        ;;
;; lr-dvr.scm is part of the lalr.scm distribution which is free          ;;
;; software; you can redistribute it and/or modify                        ;;
;; it under the terms of the GNU General Public License as published by   ;;
;; the Free Software Foundation; either version 2, or (at your option)    ;;
;; any later version.                                                     ;;
;;                                                                        ;;
;; lalr.scm is distributed in the hope that it will be useful,            ;;
;; but WITHOUT ANY WARRANTY; without even the implied warranty of         ;;
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          ;;
;; GNU General Public License for more details.                           ;;
;;                                                                        ;;
;; You should have received a copy of the GNU General Public License      ;;
;; along with lalr.scm; see the file COPYING.  If not, write to           ;;
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  ;;
;; ---------------------------------------------------------------------- ;;

(define max-stack-size 500)
(define lr-dvr-debug #f)

(define (push stack sp new-cat goto-table lval)
  (let* ((state     (vector-ref stack sp))
	 (new-state (cdr (assq new-cat (vector-ref goto-table state))))
	 (new-sp    (+ sp 2)))
    (if (>= new-sp max-stack-size)
	(myerror "PARSE ERROR" "stack overflow")
	(begin
	  (vector-set! stack new-sp new-state)
	  (vector-set! stack (- new-sp 1) lval)
	  new-sp))))

(define current-token "")

(define (make-parser action-table goto-table reduction-table token-defs)
  (lambda (lexerp errorp)

    (define (action x l)
      (let ((y (assq x l)))
	(if y
	    (cdr y)
	    (cdar l))))

    (let ((stack (make-vector max-stack-size 0)))
      (let loop ((sp 0) (input (lexerp)))
	(let* ((state (vector-ref stack sp))
	       (i     (car input))
	       (act   (action i (vector-ref action-table state))))

	  (if lr-dvr-debug
	      (begin
		(display "** PARSER TRACE:")
		(display "  input=")
		(display input)
		(display "  i=")
		(display (vector-ref token-defs i))
		(display "  state=")
		(display state)
		(display "  sp=")
		(display sp)
		(newline)))

	  (cond

	   ;Input successfully parsed
	   ((eq? act 'accept)
	    (vector-ref stack 1))

	   ;Syntax error in input
	   ((eq? act '*error*)
	    (errorp "PARSE ERROR : unexpected token"
		    (string-append
		     (vector-ref token-defs i) " "
		     (if (string? (cdr input))
			 (cdr input) ""))
		    (lexerp #t))) ;cause the lexer to output current position

	   ;Shift current token on top of the stack
	   ((>= act 0)
	    (vector-set! stack (+ sp 1) (cdr input))
	    (vector-set! stack (+ sp 2) act)
	    (set! current-token CURRENT-INPUT)
	    (loop (+ sp 2) (lexerp)))

	   ;Reduce by rule (- act)
	   (else
	    (loop ((vector-ref reduction-table (- act)) stack sp goto-table)
		  input))))))))

(define (token-string? string)
  (let ((l (string->list string)))
    (or (apply and-op (map char-alphabetic? l))
	(apply and-op (map char-special? l)))))

(define (hashindex char-list hsize)
; Warning a copy of this function is in lalr.scm
; to insert predefined tokens into the hashtable
; either change both or neither 
  (let loop ((i 0) (l char-list))
    (if (null? l)
	(modulo i hsize)
	(loop (+ (* i 7) (char->integer (car l))) (cdr l)))))

(define (make-add-token token-table token-nrs)
  (let ((hsize (vector-length token-table)))
    (lambda (string token value)
      (let* ((token-nr (assoc token token-nrs))
	     (hindex (hashindex (string->list string) hsize))
	     (hlist (vector-ref token-table hindex)))
	(cond ((not token-nr)
	       (myerror "Not a valid tokenclass for " string))
	      ((not (token-string? string))
	       (myerror "Not a valid token string " string))
	      ((assoc string hlist)
	       (myerror "Attempt to redefine token" string))
	      (else
	       (vector-set! token-table hindex
			    (cons
			     (cons string (cons (cdr token-nr) value))
			     hlist))))))))

(define (make-remove-token token-table token-nrs)
  (letrec 
      ((hsize (vector-length token-table))
       (remove (lambda (list string)
		 (if (null? list)
		     (myerror "Attempt to remove a non-existing token" string)
		     (if (string=? string (caar list))
			 (cdr list)
			 (cons (car list) (remove (cdr list) string)))))))
    (lambda (string)
      (let ((hindex (hashindex (string->list string) hsize)))
	(vector-set! token-table hindex
		     (remove (vector-ref token-table hindex) string))))))

(define (make-is-token? token-table token-defs)
  (letrec 
      ((hsize (vector-length token-table))
       (info (lambda (list string)
		 (if (null? list)
		     #f
		     (if (string=? string (caar list))
			 (cons 
			  (string->symbol (vector-ref token-defs (cadar list)))
			  (cddar list))
			 (info (cdr list) string))))))
    (lambda (string)
      (let ((hindex (hashindex (string->list string) hsize)))
	(info (vector-ref token-table hindex) string)))))

(define (char-punctuation? c)
  (or (char=? c #\( )
      (char=? c #\) )
      (char=? c #\[ )
      (char=? c #\] )
      (char=? c #\{ )
      (char=? c #\} )
      (char=? c #\. )
      (char=? c #\; )
      (char=? c #\, )
      (char=? c #\" ) ))

(define (char-special? c)
  (and (not (char-alphabetic? c))
       (not (char-whitespace? c))
       (not (char-punctuation? c))
       (not (char-numeric? c))))

(define CURRENT-INPUT "")

(define (make-lexer token-table token-nrs)
  (let ( (number-nr (cdr (assoc 'number token-nrs)))
	 (hat-nr (cdr (assoc 'hat token-nrs)))
	 (prime-nr (cdr (assoc 'prime token-nrs))) 
	 (underscore-nr (cdr (assoc 'underscore token-nrs)))
	 (hatprime-nr (cdr (assoc 'hatprime token-nrs)))
	 (hatprimeunderscore-nr (cdr (assoc 'hatprimeunderscore token-nrs)))
	 (hatunderscore-nr (cdr (assoc 'hatunderscore token-nrs)))
	 (primeunderscore-nr (cdr (assoc 'primeunderscore token-nrs)))
	 (tvar-name-nr (cdr (assoc 'tvar-name token-nrs)))
	 (tconst-nr (cdr (assoc 'tconst token-nrs)))
	 (var-name-nr (cdr (assoc 'var-name token-nrs)))
	 (pvar-name-nr (cdr (assoc 'pvar-name token-nrs)))
	 (pvar-op-nr (cdr (assoc 'pvar-op token-nrs)))
	 (predconst-name-nr (cdr (assoc 'predconst-name token-nrs)))
	 (type-symbol-nr (cdr (assoc 'type-symbol token-nrs)))
	 (alg-nr (cdr (assoc 'alg token-nrs)))
	 (var-index-nr (cdr (assoc 'var-index token-nrs)))
 	 (string-nr (cdr (assoc 'string token-nrs)))
         (undefined-token-nr (cdr (assoc 'undefined-token token-nrs)))
        )
  (lambda (reader)
    (letrec
       ((current (reader))

	(previous-nr 0) ;contains the number of the previous token
                        ;or 0 for whitespace

	(next (lambda ()
		(set! current (reader))))

	(lex-number
	 (lambda (n)
	   (let ((m (+ (* 10 n) (- (char->integer current)
				   (char->integer #\0)))))
            (begin
               (next)
               (if (and current (char-numeric? current))
		     (lex-number m)
		     m)))))

       (lex-string
	(lambda ()
          (next)
	  (if current 
              (if (char=? current #\" )
		  (begin (next) '())
		  (if (char=? current #\\ )
		      (begin (next) (cons current (lex-string)))
		      (cons current (lex-string))))
	      '())))

	(lex-symbol
	 (lambda ()
	   (let ((c current))
	     (if (and c (char-alphabetic? c))
		 (begin
		   (next)
		   (cons c (lex-symbol)))
		 '()))))


	(lex-special
	 (lambda ()
	   (let ((c current))
	     (if (and c (char-special? c))
		 (begin
		   (next)
		   (cons c (lex-special)))
		 '()))))

	(hsize (vector-length token-table))
	(lex-lookup
	 (lambda (char-list)
	   (let* ((hindex (hashindex char-list hsize))
		  (hlist (vector-ref token-table hindex))
		  (token (list->string char-list))
		  (t (assoc token hlist)))
	     (set! CURRENT-INPUT token)
	     (if t
		 (cdr t)
		 (cons undefined-token-nr (list->string char-list))))))
	
	(skip-comment
	 (lambda ()
	   (next)
	   (if (not (char=? current #\newline)) (skip-comment))))


	(lexical-analyser
	 (lambda args
	   (if (null? args)
	       (let loop ()
		 (if current
		     (let ((token
			    (cond
			     ((char-whitespace? current)
			      (set! previous-nr 0) (next) (loop))
			     ((char-numeric? current)
			      (if (or (= previous-nr tvar-name-nr)
				      (= previous-nr tconst-nr)
				      (= previous-nr var-name-nr)
				      (= previous-nr pvar-name-nr)
				      (= previous-nr predconst-name-nr)
				      (= previous-nr type-symbol-nr)
				      (= previous-nr alg-nr)
				      (= previous-nr hat-nr)
				      (= previous-nr underscore-nr)
				      (= previous-nr prime-nr)
				      (= previous-nr hatprime-nr)
				      (= previous-nr hatprimeunderscore-nr)
				      (= previous-nr hatunderscore-nr)
				      (= previous-nr primeunderscore-nr)
				      (= previous-nr pvar-op-nr))
				  (cons var-index-nr (lex-number 0))
				  (cons number-nr (lex-number 0))))
			     ((char=? current #\")
			      (cons string-nr (list->string (lex-string))))
			     ((char-punctuation? current)
			      (let ((token (lex-lookup (list current))))
				(next)
				token))
			     ((char-alphabetic? current)
			      (lex-lookup (lex-symbol)))
			     ((char=? current #\/)
			      (next)
			      (if (char=? current #\/)
				  (begin 
				      (set! previous-nr 0) 
				      (skip-comment) 
				      (loop))
				  (lex-lookup (cons #\/ (lex-special)))))
			     (else (lex-lookup (lex-special))))))
		       (set! previous-nr (car token))
		       token)
		     '(0))) ;end of input
	       (reader #t)))))
	 lexical-analyser))))

(define (lexer-info terminal-table token-nrs)
  (define (insert l e) ;insert e = (string tokentype value)
     (if (null? l)     ;sorted by strings
	 (list e)
	 (if (string<? (car e) (caar l))
	     (cons e l)
	     (cons (car l) (insert (cdr l) e)))))
  (let  ((v (make-vector (length token-nrs) '())))
    (do ((i 0 (+ i 1)))
	((>= i (vector-length terminal-table)))
      (do ((l (vector-ref terminal-table i) (cdr l)))
	  ((null? l))
	(vector-set! v (cadar l) (insert (vector-ref v (cadar l)) (car l)))))
    (do ((i 0 (+ i 1))
	 (name token-nrs (cdr name)))
	((>= i (vector-length v)))
      (let ((l (vector-ref v i)))
	(if (pair? l)
	    (begin
	      (display (caar name)) (newline)
	      (do ((tl l (cdr tl)))
		  ((null? tl))
		(display tab)
		(display (caar tl))
	        (if (eq? 'var-name (caar name))
		    (begin
		      (display tab) (display ": ")
		      (display (if (caddar tl)
				   (type-to-string (caddar tl))))))
	        (if (eq? 'const (caar name))
		    (begin
		      (display tab) (display ": ")
		      (display (type-to-string (term-to-type (cddar tl))))))
		(newline))))))))

(define (string-reader string)
   (let ((pos 0)
         (l (string-length string)))
      (lambda args
         (if (null? args)
	     (if (< pos l)
		 (let ((c (string-ref string pos)))
		   (set! pos (+ pos 1))
		   c)
		 #f)
	     ;produce a string indicating current position
	     (if (> pos 20)
		 (string-append
		  (make-string 1 #\newline)
		  "..."
		  (substring string (- pos 17) (min (+ pos 20) l))
		  (make-string 1 #\newline)
                  (make-string 19 #\space)
		  "^")
		 (string-append
		  (make-string 1 #\newline)
		  (substring string 0 (min (+ pos 20) l))
		  (make-string 1 #\newline)
		  (make-string (if (zero? pos) pos (- pos 1))#\space)
		  "^"))))))

(define (port-reader filename port)
  (let ((line 1)
	(column 0))
    (lambda args
      (if (null? args)
	  (let ((c (read-char port)))
              (if (eof-object? c)
		  #f
		  (if (char=? c #\newline)
		      (begin 
			(set! line (+ line 1))
			(set! column 0)
			c)
		      (begin
			(set! column (+ column 1))
			c))))
	  (string-append
	   (make-string 1 #\newline)
	   "; file: " filename
	   ", line: " (number->string line)
	   ", column: " (number->string (- column 1)))))))