forked from qobi/R6RS-AD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest5
More file actions
executable file
·30 lines (23 loc) · 831 Bytes
/
test5
File metadata and controls
executable file
·30 lines (23 loc) · 831 Bytes
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
#!/usr/bin/env scheme-script
(import (rnrs) (nondeterministic-recognizer))
(define (with-a-telescope n)
(if (zero? n) '() (append '(p det n) (with-a-telescope (- n 1)))))
(define (grammatical-hard-sentence n)
`(det n v det n ,@(with-a-telescope n)))
(define (ungrammatical-hard-sentence n)
`(det n v det n ,@(with-a-telescope n) v))
(define *productions*
(list (make-production 's 'np 'vp)
(make-production 'vp 'v 'np)
(make-production 'vp 'v 's)
(make-production 'vp 'vp 'pp)
(make-production 'np 'np 'pp)
(make-production 'np 'det 'n)
(make-production 'pp 'p 'np)))
(write (phrase3? (grammatical-hard-sentence 13) 's *productions*))
(newline)
(write (phrase3? (ungrammatical-hard-sentence 13) 's *productions*))
(newline)
;;; Local Variables:
;;; eval: (scheme-mode)
;;; End: