From d224099e4af7308216774ac1777de36f925c2723 Mon Sep 17 00:00:00 2001 From: Steve Dunham Date: Fri, 27 Dec 2024 16:00:35 -0800 Subject: [PATCH] more js keywords --- TODO.md | 1 + src/Lib/Compile.idr | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 34fcc70..a595f83 100644 --- a/TODO.md +++ b/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 }` diff --git a/src/Lib/Compile.idr b/src/Lib/Compile.idr index 5414329..7087a49 100644 --- a/src/Lib/Compile.idr +++ b/src/Lib/Compile.idr @@ -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) =