|
245 | 245 | ;; hash[rulename -o> (listof modeless-jf-clause?)]
|
246 | 246 | ;; compiled-pattern
|
247 | 247 | ;; derivation
|
248 |
| -;; -> match or #f |
| 248 | +;; boolean |
| 249 | +;; fail: (list/c derivation?) -> any/c |
| 250 | +;; -> match or any/c |
| 251 | +;; a list of derivations indicates the list of sub-derivations that did not match. |
249 | 252 | (define (call-modeless-judgment-form lang jf-name modeless-jf-clause-table contract-cp deriv
|
250 |
| - only-check-contracts?) |
| 253 | + only-check-contracts? |
| 254 | + [fail (λ _ #f)]) |
251 | 255 | (match deriv
|
252 | 256 | [(derivation (cons deriv-jf-name jf-args) rule-name sub-derivations)
|
253 | 257 | (cond
|
|
262 | 266 | rules
|
263 | 267 | jf-args
|
264 | 268 | sub-derivations
|
265 |
| - (λ () #f))] |
| 269 | + fail)] |
266 | 270 | [else
|
267 | 271 | (define known-rules (sort (hash-keys modeless-jf-clause-table) string<?))
|
268 | 272 | (error jf-name "unknown rule in derivation\n rule: ~.s\n known rules:~a"
|
269 | 273 | rule-name
|
270 | 274 | (apply string-append
|
271 | 275 | (for/list ([rule (in-list known-rules)])
|
272 | 276 | (format "\n ~s" rule))))]))]
|
273 |
| - [else #f])] |
274 |
| - [_ #f])) |
| 277 | + [else (fail (list deriv))])] |
| 278 | + [_ (fail (list deriv))])) |
275 | 279 |
|
276 | 280 | (define (modeless-judgment-form-check-contract jf-name contract-cp jf-args)
|
277 | 281 | (when contract-cp
|
|
300 | 304 | first-set-of-args
|
301 | 305 | maybe-more-args)))))
|
302 | 306 |
|
303 |
| -(define (modeless-jf-process-rule-candidates lang candidates jf-args sub-derivations fail) |
| 307 | +(define (modeless-jf-process-rule-candidates lang candidates jf-args sub-derivations fail [bad-derivs '()]) |
304 | 308 | (match candidates
|
305 |
| - [`() (fail)] |
| 309 | + [`() (fail (cons sub-derivations bad-derivs))] |
306 | 310 | [(cons (modeless-jf-clause conclusion-compiled-pattern
|
307 | 311 | conclusion-ids-to-duplicate
|
308 | 312 | premises-compiled-pattern
|
|
313 | 317 | premise-jf-procs)
|
314 | 318 | more-candidates)
|
315 | 319 | (define conc-mtch (match-pattern conclusion-compiled-pattern jf-args))
|
316 |
| - (define (fail-to-next-candidate) |
| 320 | + (define (fail-to-next-candidate bad-subderivs) |
317 | 321 | (modeless-jf-process-rule-candidates lang
|
318 | 322 | more-candidates
|
319 | 323 | jf-args
|
320 | 324 | sub-derivations
|
321 |
| - fail)) |
| 325 | + fail |
| 326 | + (append bad-subderivs bad-derivs))) |
322 | 327 | (cond
|
323 | 328 | [conc-mtch
|
324 | 329 | (define sub-derivations-arguments-term-list
|
|
363 | 368 | (mtch-bindings sub-derivations-mtch)
|
364 | 369 | premises-repeat-names
|
365 | 370 | premise-jf-procs
|
366 |
| - #t))) |
367 |
| - (fail-to-next-candidate)])] |
368 |
| - [else (fail-to-next-candidate)])])) |
| 371 | + #t |
| 372 | + (λ _ #f)))) |
| 373 | + (fail-to-next-candidate '())])] |
| 374 | + [else (fail-to-next-candidate '())])])) |
369 | 375 |
|
370 | 376 |
|
371 | 377 | (define (modeless-jf-process-other-conditions lang
|
|
376 | 382 | premise-jf-procs
|
377 | 383 | fail)
|
378 | 384 | (match conc+sub-bindings
|
379 |
| - [`() (fail)] |
| 385 | + ; TODO: Should this include some additional subderivations? |
| 386 | + [`() (fail '())] |
380 | 387 | [(cons conc+sub-binding conc+sub-bindings)
|
381 | 388 | (cond
|
382 | 389 | [(and (not-failure-value? (other-conditions conc+sub-binding))
|
|
385 | 392 | conc+sub-binding
|
386 | 393 | premises-repeat-names
|
387 | 394 | premise-jf-procs
|
388 |
| - #f)) |
| 395 | + #f |
| 396 | + fail)) |
389 | 397 | #t]
|
390 | 398 | [else
|
391 | 399 | (modeless-jf-process-other-conditions lang
|
|
406 | 414 | conc+sub-binding
|
407 | 415 | premises-repeat-names
|
408 | 416 | premise-jf-procs
|
409 |
| - contract-checking-only?) |
| 417 | + contract-checking-only? |
| 418 | + fail) |
410 | 419 | (let loop ([premise-jf-procs premise-jf-procs]
|
411 | 420 | [premises-repeat-names premises-repeat-names]
|
412 | 421 | [sub-derivations sub-derivations])
|
|
430 | 439 | (cond
|
431 | 440 | [(premise-jf-proc sub-derivation contract-checking-only?)
|
432 | 441 | (n-loop (- n 1) sub-derivations)]
|
433 |
| - [else #f])] |
| 442 | + [else (fail sub-derivation)])] |
434 | 443 | [_ #f])]))])))
|
435 | 444 |
|
436 | 445 | (struct modeless-jf-clause (conclusion-compiled-pattern
|
|
0 commit comments