From cd03a8a4c8075fd9ded7e947a822a71657af6fcf Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 13 Mar 2014 10:40:12 -0400 Subject: [PATCH] fix #6139 --- src/ast.c | 2 ++ src/jlfrontend.scm | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ast.c b/src/ast.c index d4a7e14b8790d..3c876d2e94573 100644 --- a/src/ast.c +++ b/src/ast.c @@ -477,6 +477,8 @@ jl_value_t *jl_parse_next(void) if (c == FL_EOF) return NULL; if (iscons(c)) { + if (cdr_(c) == FL_EOF) + return NULL; value_t a = car_(c); if (isfixnum(a)) { jl_lineno = numval(a); diff --git a/src/jlfrontend.scm b/src/jlfrontend.scm index 0a02bc0ba3bf1..8d0fb59d63c8f 100644 --- a/src/jlfrontend.scm +++ b/src/jlfrontend.scm @@ -181,19 +181,22 @@ (set! *ts-stack* (cdr *ts-stack*))) (define (jl-parser-next) - (skip-ws-and-comments (ts:port current-token-stream)) - (let ((lineno (input-port-line (ts:port current-token-stream)))) - (let ((e (parser-wrap (lambda () - (julia-parse current-token-stream))))) - (if (eof-object? e) - e - (cons lineno - (parser-wrap - (lambda () - (if (and (pair? e) (or (eq? (car e) 'error) - (eq? (car e) 'continue))) + (let* ((err (parser-wrap + (lambda () + (skip-ws-and-comments (ts:port current-token-stream))))) + (lineno (input-port-line (ts:port current-token-stream)))) + (cons lineno + (if (pair? err) + err + (parser-wrap + (lambda () + (let ((e (julia-parse current-token-stream))) + (if (eof-object? e) e - (expand-toplevel-expr e))))))))) + (if (and (pair? e) (or (eq? (car e) 'error) + (eq? (car e) 'continue))) + e + (expand-toplevel-expr e)))))))))) ; expand a piece of raw surface syntax to an executable thunk (define (jl-expand-to-thunk expr)