Skip to content

Commit

Permalink
add platform warning if binary install is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Dec 30, 2023
1 parent 7b24c58 commit 1d3a48f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/Syntax/Lexer.x
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -182,10 +182,10 @@ program :-
<stringraw> @utf8unsafe { string $ unsafeChar "raw string" }
<stringraw> @stringraw { more id }
<stringraw> \"\#* { withRawDelim $ \s delim ->
<stringraw> \"\#* { 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
Expand Down Expand Up @@ -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)))
-----------------------------------------------------------
Expand Down Expand Up @@ -302,7 +302,7 @@ reservedNames
, "effect", "receffect"
, "named"
, "mask"
, "override"
, "override"
-- deprecated
, "private", "public" -- use pub
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions support/vscode/koka.language-koka/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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 <https://github.com/koka-lang/koka> 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'
Expand Down

0 comments on commit 1d3a48f

Please sign in to comment.