From 1d3a48f6270a1b1027ac75a275ec9dbb547699eb Mon Sep 17 00:00:00 2001 From: daanx Date: Sat, 30 Dec 2023 06:19:16 -0800 Subject: [PATCH] add platform warning if binary install is not available --- src/Syntax/Lexer.x | 16 ++++++++-------- .../vscode/koka.language-koka/src/workspace.ts | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/Syntax/Lexer.x b/src/Syntax/Lexer.x index 38d2bfdf6..a313525b6 100644 --- a/src/Syntax/Lexer.x +++ b/src/Syntax/Lexer.x @@ -69,7 +69,7 @@ $charesc = [nrt\\\'\"] -- " @utf8unsafe = \xE2 \x80 [\x8E-\x8F\xAA-\xAE] | \xE2 \x81 [\xA6-\xA9] -@utf8 = @utf8valid +@utf8 = @utf8valid @linechar = [$graphic$space$tab]|@utf8 @commentchar = ([$graphic$space$tab] # [\/\*])|@newline|@utf8 @@ -182,10 +182,10 @@ program :- @utf8unsafe { string $ unsafeChar "raw string" } @stringraw { more id } - \"\#* { withRawDelim $ \s delim -> + \"\#* { withRawDelim $ \s delim -> if (s == delim) then -- done - pop $ \_ -> less (length delim) $ withmore $ + pop $ \_ -> less (length delim) $ withmore $ string (LexString . reverse . drop (length delim) . reverse) else if (length s > length delim) then -- too many terminating hashse @@ -267,7 +267,7 @@ startsWith [] _ = False startsWith (c:cs) (p:ps) = if (p==c) then startsWith cs ps else False unsafeChar :: String -> String -> Lex -unsafeChar kind s +unsafeChar kind s = LexError ("unsafe character in " ++ kind ++ ": \\u" ++ showHex 4 (fromEnum (head s))) ----------------------------------------------------------- @@ -302,7 +302,7 @@ reservedNames , "effect", "receffect" , "named" , "mask" - , "override" + , "override" -- deprecated , "private", "public" -- use pub @@ -415,7 +415,7 @@ data State = State { pos :: !Pos -- current position , previous :: !Char , current :: !BString , previousLex :: Lex - , rawEnd :: String + , rawEnd :: String } type Action = BString -> State -> State -> (Maybe Lex, State) @@ -464,10 +464,10 @@ withmore action rawdelim :: Action -> Action -rawdelim action +rawdelim action = \bs st0 st1 -> let s = bstringToString bs delim = "\"" ++ replicate (length s - 2) '#' - in -- trace ("raw delim: " ++ show delim) $ + in -- trace ("raw delim: " ++ show delim) $ action bs st0 st1{ rawEnd = delim } withRawDelim :: (String -> String -> Action) -> Action diff --git a/support/vscode/koka.language-koka/src/workspace.ts b/support/vscode/koka.language-koka/src/workspace.ts index 3f21775e1..d0006405c 100644 --- a/support/vscode/koka.language-koka/src/workspace.ts +++ b/support/vscode/koka.language-koka/src/workspace.ts @@ -15,9 +15,10 @@ import * as semver from "semver" // Constants -const home = os.homedir(); -const kokaExeName = (os.platform() === "win32" ? "koka.exe" : "koka") -const defaultShell = (os.platform() === "win32" ? "C:\\Windows\\System32\\cmd.exe" : null) +const home = os.homedir(); +const kokaExeName = (os.platform() === "win32" ? "koka.exe" : "koka") +const defaultShell = (os.platform() === "win32" ? "C:\\Windows\\System32\\cmd.exe" : null) +const binaryPlatforms = ["win32-x64","darwin-arm64","darwin-x64","linux-x64"] // Development: set kokaDevDir to a non-empty string to (un)install from a local bundle instead of github const kokaDevDir = "" @@ -243,9 +244,16 @@ async function installKoka(context: vscode.ExtensionContext, config: vscode.Work } } + // check platform + let warning = "" + const platform = `${os.platform()}-${os.arch()}` + if (!binaryPlatforms.includes(platform)) { + warning = `Unfortunately, it looks like your platform ${platform} does not have a binary installer -- see for build instructions. ` + } + // ask the user to install const decision = await vscode.window.showInformationMessage( - `${(reason ? reason + ". \n" : "")}Would you like to download and install the latest Koka compiler?`, + `${(reason ? reason + ". \n" : "")}${warning}Would you like to download and install the latest Koka compiler?`, { }, // modal: true }, 'Yes', 'No'