Changeset 551

Show
Ignore:
Timestamp:
06/18/08 11:58:46 (5 months ago)
Author:
weyrick
Message:

don't bail on parse errors in php interactive mode. part of #3598

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pcc/compiler/driver.scm

    r533 r551  
    5656    (dump-flow input-file) 
    5757    (dump-preprocessed input-file) 
     58    (php-repl-eval code) 
    5859    (interpret input-file) 
    5960    (debug input-file) 
     
    640641    (with-input-from-string (string-append "<?php " (mkstr code) " ?>") 
    641642       (lambda () 
    642           (%memoized-parse (read-string) 'php-lambda (format "~a : eval()'d code" *PHP-FILE* (mkstr *PHP-LINE*))) 
     643          (%memoized-parse (read-string) 'php-lambda (format "~a: eval()'d code" *PHP-FILE*)) 
    643644          )))) 
    644645 
     646(define (php-repl-token-error escape proc msg token) 
     647   (let ((outmsg (format "~%~a" msg))) 
     648      (fprint (current-error-port) outmsg) 
     649      (escape 'nop))) 
     650 
     651(define (php-repl-eval code) 
     652   (evaluate 
     653    (with-input-from-string (string-append "<?php " (mkstr code) " ?>") 
     654       (lambda () 
     655          (%do-parse (read-string) 'php-repl "Interactive Shell: " php-repl-token-error) 
     656          )))) 
    645657 
    646658(define (evaluate-from-file file name-to-use) 
     
    707719(define %%memoized-parses #f) 
    708720 
     721(define (%do-parse input-string main-name filename handler) 
     722   (with-input-from-string input-string 
     723      (lambda () 
     724         (try (parse (php-preprocess (current-input-port) filename) 
     725                     main-name filename) 
     726              handler)))) 
     727 
    709728(define (%memoized-parse input-string main-name filename) 
    710729   ;; save the result of parsing a file so that we can skip parsing it next time 
     
    712731                      ;(debug-trace 0 "Parsing " filename " for the first time") 
    713732                      (set! %%memo-miss-count (+ %%memo-miss-count 1)) 
    714                       (with-input-from-string input-string 
    715                          (lambda () 
    716                             (try (parse (php-preprocess (current-input-port) filename) 
    717                                         main-name filename) 
    718                                  handle-token-error)))))) 
     733                      (%do-parse input-string main-name filename handle-token-error)))) 
    719734      ;; I think that memoization will only help when running as a web 
    720735      ;; server, because it only speeds up the 2nd and subsequent 
  • trunk/pcc/compiler/evaluate.scm

    r544 r551  
    100100      ((list? node) (evaluate-block node)) 
    101101      ((eqv? node :next) :next) 
     102      ((eqv? node 'nop) #t) ; bad parse in interactive mode 
    102103      (else (error 'evaluate "Don't know what to do with node: " 
    103104                   (with-output-to-string 
  • trunk/pcc/compiler/target.scm

    r550 r551  
    160160                          (try 
    161161                           (begin 
    162                               (php-eval input) 
     162                              (php-repl-eval input) 
    163163                              (print)) 
    164164                           (lambda (e p m o)