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.
|
||||
|
||||
- [ ] 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] for parse error, seek to col 0 token and process next decl
|
||||
- [ ] record initialization sugar, e.g. `{ x := 1, y := 2 }`
|
||||
|
||||
@@ -186,17 +186,21 @@ termToJS env (CCase t alts) f =
|
||||
|
||||
keywords : List String
|
||||
keywords = [
|
||||
"var", "true", "false", "let", "case", "switch", "if", "then", "else", "String",
|
||||
"function", "void", "undefined", "null", "await", "async", "return", "const",
|
||||
"Number", "default", "for", "while", "Function", "Array", "BigInt"
|
||||
"break", "case", "catch", "continue", "debugger", "default", "delete", "do", "else",
|
||||
"finally", "for", "function", "if", "in", "instanceof", "new", "return", "switch",
|
||||
"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
|
||||
jsIdent : String -> Doc
|
||||
jsIdent id = if elem id keywords then text ("$" ++ id) else text $ pack $ fix (unpack id)
|
||||
where
|
||||
|
||||
|
||||
fix : List Char -> List Char
|
||||
fix [] = []
|
||||
fix (x :: xs) =
|
||||
|
||||
Reference in New Issue
Block a user