summaryrefslogtreecommitdiff
path: root/src/jscomp.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-09-15 13:07:57 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-09-15 13:07:57 -0400
commit8e944e62818045b820f45776a396bc1b66ab3056 (patch)
tree2790236bfd930177b19eec97fc9ac1d47e9dd7d4 /src/jscomp.sml
parent69bdeb0e79c7b33260111c6c6eae332d37d28d0e (diff)
Fix JavaScript char literals; don't generate demo links to nonexistent files
Diffstat (limited to 'src/jscomp.sml')
-rw-r--r--src/jscomp.sml56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/jscomp.sml b/src/jscomp.sml
index 178591b5..ca4f047b 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -537,34 +537,34 @@ fun process file =
val strcat = strcat loc
fun jsPrim p =
- case p of
- Prim.String s =>
- str ("\""
- ^ String.translate (fn #"'" =>
- if mode = Attribute then
- "\\047"
- else
- "'"
- | #"\"" => "\\\""
- | #"<" =>
- (*if mode = Script then
- "<"
- else*)
- "\\074"
- | #"\\" => "\\\\"
- | #"\n" => "\\n"
- | #"\r" => "\\r"
- | #"\t" => "\\t"
- | ch =>
- if Char.isPrint ch then
- String.str ch
- else
- "\\" ^ padWith (#"0",
- Int.fmt StringCvt.OCT (ord ch),
- 3)) s
- ^ "\"")
- | Prim.Char ch => str ("'" ^ String.str ch ^ "'")
- | _ => str (Prim.toString p)
+ let
+ fun jsChar ch =
+ case ch of
+ #"'" =>
+ if mode = Attribute then
+ "\\047"
+ else
+ "'"
+ | #"\"" => "\\\""
+ | #"<" => "\\074"
+ | #"\\" => "\\\\"
+ | #"\n" => "\\n"
+ | #"\r" => "\\r"
+ | #"\t" => "\\t"
+ | ch =>
+ if Char.isPrint ch then
+ String.str ch
+ else
+ "\\" ^ padWith (#"0",
+ Int.fmt StringCvt.OCT (ord ch),
+ 3)
+ in
+ case p of
+ Prim.String s =>
+ str ("\"" ^ String.translate jsChar s ^ "\"")
+ | Prim.Char ch => str ("'" ^ jsChar ch ^ "'")
+ | _ => str (Prim.toString p)
+ end
fun jsPat depth inner (p, _) succ fail =
case p of