From bba3643e76e8d654f6eea8d705523905b44a1bd5 Mon Sep 17 00:00:00 2001 From: Kathy Gray Date: Mon, 21 Nov 2005 06:16:39 +0000 Subject: [PATCH] Fixed parsing bugs and immutable string error svn: r1358 --- .../profj/libs/java/lang/Object-composite.ss | 2 +- collects/profj/parsers/advanced-parser.ss | 3 +- collects/profj/parsers/parse-error.ss | 36 ++++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/collects/profj/libs/java/lang/Object-composite.ss b/collects/profj/libs/java/lang/Object-composite.ss index 387a8b1cbe..2c1e90b548 100644 --- a/collects/profj/libs/java/lang/Object-composite.ss +++ b/collects/profj/libs/java/lang/Object-composite.ss @@ -917,7 +917,7 @@ (define (create-java-exception class msg constructor marks) (let* ((exn (make-object class)) (str (make-java-string msg)) - (scheme-exn (make-java:exception msg marks exn))) + (scheme-exn (make-java:exception (string->immutable-string msg) marks exn))) (constructor exn str) (send exn set-exception! scheme-exn) scheme-exn)) diff --git a/collects/profj/parsers/advanced-parser.ss b/collects/profj/parsers/advanced-parser.ss index 15d77b2d08..6ee050550e 100644 --- a/collects/profj/parsers/advanced-parser.ss +++ b/collects/profj/parsers/advanced-parser.ss @@ -169,7 +169,8 @@ [(protected) (make-modifier 'protected (build-src 1))] [(private) (make-modifier 'private (build-src 1))] [(static) (make-modifier 'static (build-src 1))] - [(abstract) (make-modifier 'abstract (build-src 1))]) + [(abstract) (make-modifier 'abstract (build-src 1))] + [(final) (make-modifier 'final (build-src 1))]) ;; 19.8.1 (ClassDeclaration diff --git a/collects/profj/parsers/parse-error.ss b/collects/profj/parsers/parse-error.ss index 9fa1f335cf..ded7ec1e7c 100644 --- a/collects/profj/parsers/parse-error.ss +++ b/collects/profj/parsers/parse-error.ss @@ -1531,7 +1531,6 @@ ;Intermediate - addition of parameter id-ok? ;parse-statement: token token symbol (->token) bool bool bool-> token (define (parse-statement pre cur-tok state getter id-ok? ctor? super-seen?) - ;(printf "parse-statement state: ~a pre: ~a cur-tok: ~a~n" state pre cur-tok) (let* ((tok (get-tok cur-tok)) (kind (get-token-name tok)) (out (format-out tok)) @@ -1854,21 +1853,26 @@ (parse-error (format "Variables must be separated by commas, ~a not allowed" n-out) start ne)) (else (parse-error (format "Expected ';' or more variables, found ~a" n-out) start ne))))) (else - (if (and (advanced?) (o-bracket? tok)) - (let* ((next (getter)) - (n-tok (get-tok next))) - (cond - ((c-bracket? n-tok) - (parse-statement next (getter) 'local getter id-ok? ctor? super-seen?)) - ((o-bracket? n-tok) - (parse-error "Array types may not have [[. A closing ] is necessary before opening a new [" start - (get-end next))) - (else (parse-error (format "Array types are of form type[]. ~a is not allowed" (format-out n-tok)) - start (get-end next))))) - (parse-error - (if (java-keyword? tok) - (format "Expected a name for this variable, cannot be named reserved word ~a" kind) - (format "Expected a name for this variable, found ~a" out)) start end))))) + (cond + ((and (advanced?) (o-bracket? tok)) + (let* ((next (getter)) + (n-tok (get-tok next))) + (cond + ((c-bracket? n-tok) + (parse-statement next (getter) 'local getter id-ok? ctor? super-seen?)) + ((o-bracket? n-tok) + (parse-error "Array types may not have [[. A closing ] is necessary before opening a new [" start + (get-end next))) + (else (parse-error (format "Array types are of form type[]. ~a is not allowed" (format-out n-tok)) + start (get-end next)))))) + ((teaching-assignment-operator? tok) + (parse-error (format "Expected a type and name before ~a, found ~a ~a" + kind (format-out (get-tok pre)) kind) + ps end)) + (else (parse-error + (if (java-keyword? tok) + (format "Expected a name for this variable, cannot be named reserved word ~a" kind) + (format "Expected a name for this variable, found ~a" out)) start end)))))) ;Intermediate ((local-list) (case kind