more js keywords
This commit is contained in:
1
TODO.md
1
TODO.md
@@ -4,6 +4,7 @@
|
|||||||
More comments in code! This is getting big enough that I need to re-find my bearings when fixing stuff.
|
More comments in code! This is getting big enough that I need to re-find my bearings when fixing stuff.
|
||||||
|
|
||||||
- [ ] editor - indent newline on let with no in
|
- [ ] editor - indent newline on let with no in
|
||||||
|
- I've seen this done in vi for Idris, but it seems non-trivial in vscode.
|
||||||
- [x] Move on to next decl in case of error
|
- [x] Move on to next decl in case of error
|
||||||
- [x] for parse error, seek to col 0 token and process next decl
|
- [x] for parse error, seek to col 0 token and process next decl
|
||||||
- [ ] record initialization sugar, e.g. `{ x := 1, y := 2 }`
|
- [ ] record initialization sugar, e.g. `{ x := 1, y := 2 }`
|
||||||
|
|||||||
@@ -186,17 +186,21 @@ termToJS env (CCase t alts) f =
|
|||||||
|
|
||||||
keywords : List String
|
keywords : List String
|
||||||
keywords = [
|
keywords = [
|
||||||
"var", "true", "false", "let", "case", "switch", "if", "then", "else", "String",
|
"break", "case", "catch", "continue", "debugger", "default", "delete", "do", "else",
|
||||||
"function", "void", "undefined", "null", "await", "async", "return", "const",
|
"finally", "for", "function", "if", "in", "instanceof", "new", "return", "switch",
|
||||||
"Number", "default", "for", "while", "Function", "Array", "BigInt"
|
"this", "throw", "try", "typeof", "var", "void", "while", "with",
|
||||||
|
"class", "const", "enum", "export", "extends", "import", "super",
|
||||||
|
"implements", "interface", "let", "package", "private", "protected", "public",
|
||||||
|
"static", "yield",
|
||||||
|
"null", "true", "false",
|
||||||
|
-- might not be a big issue with namespaces on names now.
|
||||||
|
"String", "Number", "Array", "BigInt"
|
||||||
]
|
]
|
||||||
|
|
||||||
||| escape identifiers for js
|
||| escape identifiers for js
|
||||||
jsIdent : String -> Doc
|
jsIdent : String -> Doc
|
||||||
jsIdent id = if elem id keywords then text ("$" ++ id) else text $ pack $ fix (unpack id)
|
jsIdent id = if elem id keywords then text ("$" ++ id) else text $ pack $ fix (unpack id)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
|
||||||
fix : List Char -> List Char
|
fix : List Char -> List Char
|
||||||
fix [] = []
|
fix [] = []
|
||||||
fix (x :: xs) =
|
fix (x :: xs) =
|
||||||
|
|||||||
Reference in New Issue
Block a user