|
662 | 662 | (first? #t)
|
663 | 663 | (t (peek-token s)))
|
664 | 664 | (if (not (memv t ops))
|
665 |
| - (begin |
666 |
| - (if (not (or (eof-object? t) (eqv? t #\newline) (closer? t))) |
667 |
| - (error (string "extra token \"" t "\" after end of expression"))) |
668 |
| - (if (or (null? ex) (pair? (cdr ex)) (not first?)) |
669 |
| - ;; () => (head) |
670 |
| - ;; (ex2 ex1) => (head ex1 ex2) |
671 |
| - ;; (ex1) if operator appeared => (head ex1) (handles "x;") |
672 |
| - (cons head (reverse! ex)) |
673 |
| - ;; (ex1) => ex1 |
674 |
| - (car ex))) |
| 665 | + (if (or (null? ex) (pair? (cdr ex)) (not first?)) |
| 666 | + ;; () => (head) |
| 667 | + ;; (ex2 ex1) => (head ex1 ex2) |
| 668 | + ;; (ex1) if operator appeared => (head ex1) (handles "x;") |
| 669 | + (cons head (reverse! ex)) |
| 670 | + ;; (ex1) => ex1 |
| 671 | + (car ex)) |
675 | 672 | (begin (take-token s)
|
676 | 673 | ;; allow input to end with the operator, as in a;b;
|
677 | 674 | (if (or (eof-object? (peek-token s))
|
|
1270 | 1267 |
|
1271 | 1268 | (define (expect-end s word)
|
1272 | 1269 | (let ((t (peek-token s)))
|
1273 |
| - (cond ((eq? t 'end) (take-token s)) |
1274 |
| - ((eof-object? t) |
1275 |
| - (error (string "incomplete: \"" word "\" at " ; NOTE: changing this may affect code in base/client.jl |
1276 |
| - current-filename ":" expect-end-current-line |
1277 |
| - " requires end"))) |
1278 |
| - (else |
1279 |
| - (error (string "\"" word "\" at " |
1280 |
| - current-filename ":" expect-end-current-line |
1281 |
| - " expected \"end\", got \"" t "\"")))))) |
| 1270 | + (if (eq? t 'end) |
| 1271 | + (take-token s) |
| 1272 | + (expect-end-error t word)))) |
| 1273 | + |
| 1274 | +(define (expect-end-error t word) |
| 1275 | + (if (eof-object? t) |
| 1276 | + (error (string "incomplete: \"" word "\" at " ; NOTE: changing this may affect code in base/client.jl |
| 1277 | + current-filename ":" expect-end-current-line |
| 1278 | + " requires end")) |
| 1279 | + (error (string "\"" word "\" at " |
| 1280 | + current-filename ":" expect-end-current-line |
| 1281 | + " expected \"end\", got \"" t "\"")))) |
1282 | 1282 |
|
1283 | 1283 | (define (parse-subtype-spec s)
|
1284 | 1284 | (parse-comparison s))
|
|
1469 | 1469 | (expect-end (take-lineendings s) "primitive type"))))))
|
1470 | 1470 |
|
1471 | 1471 | ((try)
|
1472 |
| - (let ((try-block (if (memq (require-token s) '(catch finally)) |
| 1472 | + (let ((try-block (if (memq (peek-token s) '(catch finally)) |
1473 | 1473 | '(block)
|
1474 | 1474 | (parse-block s))))
|
1475 |
| - (let loop ((nxt (require-token s)) |
| 1475 | + (let loop ((nxt (peek-token s)) |
1476 | 1476 | (catchb #f)
|
1477 | 1477 | (catchv #f)
|
1478 | 1478 | (finalb #f))
|
|
1519 | 1519 | catchb
|
1520 | 1520 | catchv
|
1521 | 1521 | fb)))
|
1522 |
| - (else (error (string "unexpected \"" nxt "\""))))))) |
| 1522 | + (else (expect-end-error nxt 'try)))))) |
1523 | 1523 | ((return) (let ((t (peek-token s)))
|
1524 | 1524 | (if (or (eqv? t #\newline) (closing-token? t))
|
1525 | 1525 | (list 'return '(null))
|
|
0 commit comments