reader: extend error message for disabled #lang

Try to give more hints to help somone who writes `#lang` twice.
This commit is contained in:
Matthew Flatt 2020-11-07 07:55:20 -07:00
parent 2b7e36b5f4
commit 1149bb8b2c
3 changed files with 111 additions and 99 deletions

View File

@ -60960,8 +60960,12 @@ static const char *startup_source =
"(let-values()" "(let-values()"
"(let-values(((in83_0) in_0)" "(let-values(((in83_0) in_0)"
"((config84_0) config_0)" "((config84_0) config_0)"
" ((temp85_0) \"`~a` not enabled\")" " ((temp85_0) \"`~a` not enabled\\n possible reason: ~a\")"
"((extend-str86_0) extend-str_0))" "((extend-str86_0) extend-str_0)"
"((temp87_0)"
"(string-append"
" \"not allowed again inside a module that already starts `#lang`,\""
" \" or not enabled for interactive evaluation\")))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" '#\\x" " '#\\x"
@ -60970,7 +60974,7 @@ static const char *startup_source =
" in83_0" " in83_0"
" config84_0" " config84_0"
" temp85_0" " temp85_0"
"(list extend-str86_0)))))" "(list extend-str86_0 temp87_0)))))"
"(values))))" "(values))))"
"(let-values(((line_0 col_0 pos_0)(port-next-location in_0)))" "(let-values(((line_0 col_0 pos_0)(port-next-location in_0)))"
"(let-values(((accum-str_0)(accum-string-init! config_0)))" "(let-values(((accum-str_0)(accum-string-init! config_0)))"
@ -61007,22 +61011,22 @@ static const char *startup_source =
"(let-values()" "(let-values()"
"(begin" "(begin"
"(consume-char/special in_0 config_0 c_0)" "(consume-char/special in_0 config_0 c_0)"
"(let-values(((in87_0) in_0)" "(let-values(((in88_0) in_0)"
"((config88_0) config_0)" "((config89_0) config_0)"
"((c89_0) c_0)" "((c90_0) c_0)"
"((temp90_0)" "((temp91_0)"
" \"found non-character while reading `#~a`\")" " \"found non-character while reading `#~a`\")"
"((extend-str91_0)" "((extend-str92_0)"
" extend-str_0))" " extend-str_0))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" c89_0" " c90_0"
" #f" " #f"
" unsafe-undefined" " unsafe-undefined"
" in87_0" " in88_0"
" config88_0" " config89_0"
" temp90_0" " temp91_0"
"(list extend-str91_0)))))" "(list extend-str92_0)))))"
"(if(if(char-whitespace? c_0)" "(if(if(char-whitespace? c_0)"
"(positive?" "(positive?"
"(accum-string-count accum-str_0))" "(accum-string-count accum-str_0))"
@ -61032,21 +61036,21 @@ static const char *startup_source =
"(char=? c_0 '#\\space)" "(char=? c_0 '#\\space)"
" #f)" " #f)"
"(let-values()" "(let-values()"
"(let-values(((in92_0) in_0)" "(let-values(((in93_0) in_0)"
"((config93_0) config_0)" "((config94_0) config_0)"
"((temp94_0)" "((temp95_0)"
" \"expected a single space after `~a`\")" " \"expected a single space after `~a`\")"
"((extend-str95_0)" "((extend-str96_0)"
" extend-str_0))" " extend-str_0))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" '#\\x" " '#\\x"
" #f" " #f"
" unsafe-undefined" " unsafe-undefined"
" in92_0" " in93_0"
" config93_0" " config94_0"
" temp94_0" " temp95_0"
"(list extend-str95_0))))" "(list extend-str96_0))))"
"(if(let-values(((or-part_0)" "(if(let-values(((or-part_0)"
"(char-lang-nonsep?" "(char-lang-nonsep?"
" c_0)))" " c_0)))"
@ -61063,71 +61067,71 @@ static const char *startup_source =
"(let-values()" "(let-values()"
"(begin" "(begin"
"(consume-char in_0 c_0)" "(consume-char in_0 c_0)"
"(let-values(((in96_0) in_0)" "(let-values(((in97_0) in_0)"
"((config97_0)" "((config98_0)"
" config_0)" " config_0)"
"((temp98_0)" "((temp99_0)"
"(string-append" "(string-append"
" \"expected only alphanumeric, `-`, `+`, `_`, or `/`\"" " \"expected only alphanumeric, `-`, `+`, `_`, or `/`\""
" \" characters for `~a`, found `~a`\"))" " \" characters for `~a`, found `~a`\"))"
"((extend-str99_0)" "((extend-str100_0)"
" extend-str_0)" " extend-str_0)"
"((c100_0) c_0))" "((c101_0) c_0))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" '#\\x" " '#\\x"
" #f" " #f"
" unsafe-undefined" " unsafe-undefined"
" in96_0" " in97_0"
" config97_0" " config98_0"
" temp98_0" " temp99_0"
"(list" "(list"
" extend-str99_0" " extend-str100_0"
" c100_0)))))))))))))))" " c101_0)))))))))))))))"
" loop_0))" " loop_0))"
"(values))))" "(values))))"
"(let-values(((lang-str_0)" "(let-values(((lang-str_0)"
"(let-values(((accum-str101_0) accum-str_0)((config102_0) config_0))" "(let-values(((accum-str102_0) accum-str_0)((config103_0) config_0))"
"(accum-string-get!.1 0 accum-str101_0 config102_0))))" "(accum-string-get!.1 0 accum-str102_0 config103_0))))"
"(let-values((()" "(let-values((()"
"(begin" "(begin"
" (if (equal? lang-str_0 \"\")" " (if (equal? lang-str_0 \"\")"
"(let-values()" "(let-values()"
"(let-values(((in103_0) in_0)" "(let-values(((in104_0) in_0)"
"((config104_0) config_0)" "((config105_0) config_0)"
"((temp105_0)" "((temp106_0)"
" \"expected a non-empty sequence of alphanumeric, `-`, `+`, `_`, or `/` after `~a~a`\")" " \"expected a non-empty sequence of alphanumeric, `-`, `+`, `_`, or `/` after `~a~a`\")"
"((extend-str106_0) extend-str_0)" "((extend-str107_0) extend-str_0)"
" ((temp107_0) (if one-space?_0 \" \" \"\")))" " ((temp108_0) (if one-space?_0 \" \" \"\")))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" '#\\x" " '#\\x"
" #f" " #f"
" unsafe-undefined" " unsafe-undefined"
" in103_0" " in104_0"
" config104_0" " config105_0"
" temp105_0" " temp106_0"
"(list extend-str106_0 temp107_0))))" "(list extend-str107_0 temp108_0))))"
"(void))" "(void))"
"(values))))" "(values))))"
"(let-values((()" "(let-values((()"
"(begin" "(begin"
"(if(char=? '#\\/(string-ref lang-str_0 0))" "(if(char=? '#\\/(string-ref lang-str_0 0))"
"(let-values()" "(let-values()"
"(let-values(((in108_0) in_0)" "(let-values(((in109_0) in_0)"
"((config109_0) config_0)" "((config110_0) config_0)"
"((temp110_0)" "((temp111_0)"
" \"expected a name that does not start `/` after `~a`\")" " \"expected a name that does not start `/` after `~a`\")"
"((extend-str111_0) extend-str_0))" "((extend-str112_0) extend-str_0))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" '#\\x" " '#\\x"
" #f" " #f"
" unsafe-undefined" " unsafe-undefined"
" in108_0" " in109_0"
" config109_0" " config110_0"
" temp110_0" " temp111_0"
"(list extend-str111_0))))" "(list extend-str112_0))))"
"(void))" "(void))"
"(values))))" "(values))))"
"(let-values((()" "(let-values((()"
@ -61136,20 +61140,20 @@ static const char *startup_source =
" '#\\/" " '#\\/"
"(string-ref lang-str_0(sub1(string-length lang-str_0))))" "(string-ref lang-str_0(sub1(string-length lang-str_0))))"
"(let-values()" "(let-values()"
"(let-values(((in112_0) in_0)" "(let-values(((in113_0) in_0)"
"((config113_0) config_0)" "((config114_0) config_0)"
"((temp114_0)" "((temp115_0)"
" \"expected a name that does not end `/` after `~a`\")" " \"expected a name that does not end `/` after `~a`\")"
"((extend-str115_0) extend-str_0))" "((extend-str116_0) extend-str_0))"
"(reader-error.1" "(reader-error.1"
" unsafe-undefined" " unsafe-undefined"
" '#\\x" " '#\\x"
" #f" " #f"
" unsafe-undefined" " unsafe-undefined"
" in112_0" " in113_0"
" config113_0" " config114_0"
" temp114_0" " temp115_0"
"(list extend-str115_0))))" "(list extend-str116_0))))"
"(void))" "(void))"
"(values))))" "(values))))"
"(let-values(((submod-path_0)" "(let-values(((submod-path_0)"
@ -61232,19 +61236,19 @@ static const char *startup_source =
"(if(eqv? c_0(car wanted_1))" "(if(eqv? c_0(car wanted_1))"
"(void)" "(void)"
"(let-values()" "(let-values()"
"(let-values(((in118_0) in_0)" "(let-values(((in119_0) in_0)"
"((config119_0) config_0)" "((config120_0) config_0)"
"((temp120_0)" "((temp121_0)"
"(let-values(((accum-str122_0) accum-str_0)" "(let-values(((accum-str123_0) accum-str_0)"
"((config123_0) config_0))" "((config124_0) config_0))"
"(accum-string-get!.1 0 accum-str122_0 config123_0)))" "(accum-string-get!.1 0 accum-str123_0 config124_0)))"
"((c121_0) c_0))" "((c122_0) c_0))"
"(bad-syntax-error.1 c121_0 in118_0 config119_0 temp120_0))))" "(bad-syntax-error.1 c122_0 in119_0 config120_0 temp121_0))))"
"(loop_0(cdr wanted_1))))))))))" "(loop_0(cdr wanted_1))))))))))"
" loop_0)" " loop_0)"
" wanted_0)" " wanted_0)"
"(let-values(((accum-str116_0) accum-str_0)((config117_0) config_0))" "(let-values(((accum-str117_0) accum-str_0)((config118_0) config_0))"
"(accum-string-get!.1 0 accum-str116_0 config117_0)))))))" "(accum-string-get!.1 0 accum-str117_0 config118_0)))))))"
"(define-values" "(define-values"
"(read-extension.1)" "(read-extension.1)"
"(lambda(get-info?30_0" "(lambda(get-info?30_0"
@ -61267,8 +61271,8 @@ static const char *startup_source =
"((read-config-coerce config_0)" "((read-config-coerce config_0)"
" #t" " #t"
" mod-path-datum_0" " mod-path-datum_0"
"(let-values(((in124_0) in_0)((config125_0) config_0))" "(let-values(((in125_0) in_0)((config126_0) config_0))"
"(port+config->srcloc.1 #f in124_0 config125_0)))" "(port+config->srcloc.1 #f in125_0 config126_0)))"
" mod-path-wrapped29_0)))" " mod-path-wrapped29_0)))"
"(let-values(((get-info?_0) get-info?30_0))" "(let-values(((get-info?_0) get-info?30_0))"
"(let-values(((who_0) who31_0))" "(let-values(((who_0) who31_0))"

View File

@ -71354,7 +71354,12 @@
(check-parameter 1/read-accept-lang config26_0) (check-parameter 1/read-accept-lang config26_0)
#f) #f)
(void) (void)
(let ((temp85_0 "`~a` not enabled")) (let ((temp85_0 "`~a` not enabled\n possible reason: ~a"))
(let ((temp87_0
(string-append
"not allowed again inside a module that already starts `#lang`,"
" or not enabled for interactive evaluation")))
(let ((temp85_1 temp85_0))
(reader-error.1 (reader-error.1
unsafe-undefined unsafe-undefined
'#\x78 '#\x78
@ -71362,8 +71367,8 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp85_0 temp85_1
(list extend-str23_0)))) (list extend-str23_0 temp87_0))))))
(call-with-values (call-with-values
(lambda () (port-next-location in25_0)) (lambda () (port-next-location in25_0))
(case-lambda (case-lambda
@ -71405,7 +71410,7 @@
(read-config/inner-source (read-config/inner-source
(read-config/outer-inner config26_0))) (read-config/outer-inner config26_0)))
(void)) (void))
(let ((temp90_0 (let ((temp91_0
"found non-character while reading `#~a`")) "found non-character while reading `#~a`"))
(reader-error.1 (reader-error.1
unsafe-undefined unsafe-undefined
@ -71414,7 +71419,7 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp90_0 temp91_0
(list extend-str23_0)))) (list extend-str23_0))))
(if (if (char-whitespace? c_0) (if (if (char-whitespace? c_0)
(positive? (positive?
@ -71424,7 +71429,7 @@
(if (if one-space?16_0 (if (if one-space?16_0
(char=? c_0 '#\x20) (char=? c_0 '#\x20)
#f) #f)
(let ((temp94_0 (let ((temp95_0
"expected a single space after `~a`")) "expected a single space after `~a`"))
(reader-error.1 (reader-error.1
unsafe-undefined unsafe-undefined
@ -71433,7 +71438,7 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp94_0 temp95_0
(list extend-str23_0))) (list extend-str23_0)))
(if (let ((or-part_0 (if (let ((or-part_0
(char-lang-nonsep? c_0))) (char-lang-nonsep? c_0)))
@ -71446,7 +71451,7 @@
(loop_0)) (loop_0))
(begin (begin
(begin (read-char in25_0) (void)) (begin (read-char in25_0) (void))
(let ((temp98_0 (let ((temp99_0
(string-append (string-append
"expected only alphanumeric, `-`, `+`, `_`, or `/`" "expected only alphanumeric, `-`, `+`, `_`, or `/`"
" characters for `~a`, found `~a`"))) " characters for `~a`, found `~a`")))
@ -71457,7 +71462,7 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp98_0 temp99_0
(list (list
extend-str23_0 extend-str23_0
c_0))))))))))))))) c_0)))))))))))))))
@ -71466,10 +71471,10 @@
(accum-string-get!.1 0 accum-str_0 config26_0))) (accum-string-get!.1 0 accum-str_0 config26_0)))
(begin (begin
(if (equal? lang-str_0 "") (if (equal? lang-str_0 "")
(let ((temp105_0 (let ((temp106_0
"expected a non-empty sequence of alphanumeric, `-`, `+`, `_`, or `/` after `~a~a`")) "expected a non-empty sequence of alphanumeric, `-`, `+`, `_`, or `/` after `~a~a`"))
(let ((temp107_0 (if one-space?16_0 " " ""))) (let ((temp108_0 (if one-space?16_0 " " "")))
(let ((temp105_1 temp105_0)) (let ((temp106_1 temp106_0))
(reader-error.1 (reader-error.1
unsafe-undefined unsafe-undefined
'#\x78 '#\x78
@ -71477,12 +71482,12 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp105_1 temp106_1
(list extend-str23_0 temp107_0))))) (list extend-str23_0 temp108_0)))))
(void)) (void))
(begin (begin
(if (char=? '#\x2f (string-ref lang-str_0 0)) (if (char=? '#\x2f (string-ref lang-str_0 0))
(let ((temp110_0 (let ((temp111_0
"expected a name that does not start `/` after `~a`")) "expected a name that does not start `/` after `~a`"))
(reader-error.1 (reader-error.1
unsafe-undefined unsafe-undefined
@ -71491,7 +71496,7 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp110_0 temp111_0
(list extend-str23_0))) (list extend-str23_0)))
(void)) (void))
(begin (begin
@ -71500,7 +71505,7 @@
(string-ref (string-ref
lang-str_0 lang-str_0
(sub1 (string-length lang-str_0)))) (sub1 (string-length lang-str_0))))
(let ((temp114_0 (let ((temp115_0
"expected a name that does not end `/` after `~a`")) "expected a name that does not end `/` after `~a`"))
(reader-error.1 (reader-error.1
unsafe-undefined unsafe-undefined
@ -71509,7 +71514,7 @@
unsafe-undefined unsafe-undefined
in25_0 in25_0
config26_0 config26_0
temp114_0 temp115_0
(list extend-str23_0))) (list extend-str23_0)))
(void)) (void))
(let ((submod-path_0 (let ((submod-path_0
@ -71592,9 +71597,9 @@
(void)) (void))
(if (eqv? c_0 (car wanted_1)) (if (eqv? c_0 (car wanted_1))
(void) (void)
(let ((temp120_0 (let ((temp121_0
(accum-string-get!.1 0 accum-str_0 config_0))) (accum-string-get!.1 0 accum-str_0 config_0)))
(bad-syntax-error.1 c_0 in_0 config_0 temp120_0))) (bad-syntax-error.1 c_0 in_0 config_0 temp121_0)))
(loop_0 (cdr wanted_1)))))))))) (loop_0 (cdr wanted_1))))))))))
(loop_0 wanted_0)) (loop_0 wanted_0))
(accum-string-get!.1 0 accum-str_0 config_0))))) (accum-string-get!.1 0 accum-str_0 config_0)))))

View File

@ -75,8 +75,11 @@
(unless (and (check-parameter read-accept-reader config) (unless (and (check-parameter read-accept-reader config)
(check-parameter read-accept-lang config)) (check-parameter read-accept-lang config))
(reader-error in config (reader-error in config
"`~a` not enabled" "`~a` not enabled\n possible reason: ~a"
extend-str)) extend-str
(string-append
"not allowed again inside a module that already starts `#lang`,"
" or not enabled for interactive evaluation")))
(define-values (line col pos) (port-next-location in)) (define-values (line col pos) (port-next-location in))