Compare commits

3 Commits
Author SHA1 Message Date
msyds 2b6cc65327 r7rs datum ast
build / build (push) Successful in 1m28s
2026-08-20 21:53:32 -06:00
msyds 6c29f3779a fix completions
build / build (push) Successful in 1m12s
2026-08-20 18:45:22 -06:00
msyds 5a173a7a3b fix dir-locals hooks 2026-08-20 18:20:11 -06:00
12 changed files with 158 additions and 17 deletions
+8 -6
View File
@@ -1,9 +1,11 @@
((haskell-cabal-mode
((haskell-mode
. ((eval
. (progn (add-to-list 'haskell-font-lock-quasi-quote-modes
'("cps" . scheme-mode))
(add-to-list 'haskell-font-lock-quasi-quote-modes
'("scm" . scheme-mode))))))
(haskell-cabal-mode
. ((eval
. (progn (defun apply-cabal-fmt-h ()
(haskell-mode-buffer-apply-command "cabal-fmt"))
(add-hook 'before-save-hook #'apply-cabal-fmt-h nil t)
(add-to-list 'haskell-font-lock-quasi-quote-modes
'("cps" . scheme-mode))
(add-to-list 'haskell-font-lock-quasi-quote-modes
'("scm" . scheme-mode)))))))
(add-hook 'before-save-hook #'apply-cabal-fmt-h nil t))))))
+5
View File
@@ -55,6 +55,11 @@
guile
rust-analyzer
wasmtime
# bashInteractive is necessary to work around an
# optparse-applicative issue
#
# https://github.com/pcapriotti/optparse-applicative/pull/408
bashInteractive
];
};
};
+6
View File
@@ -60,10 +60,15 @@ library
Gyehoek.CPS.Syntax
Gyehoek.Driver
Gyehoek.GenSym
Gyehoek.Language
Gyehoek.Options
Gyehoek.Prelude
Gyehoek.Scheme.Syntax
Gyehoek.Sexp
Gyehoek.Sexp.Grammar
Gyehoek.Sexp.Print
Gyehoek.Sexp.Read
Gyehoek.Sexp.Syntax
Gyehoek.Stack.Syntax
Gyehoek.Stack.VM
Gyehoek.Wasm
@@ -90,6 +95,7 @@ library
, prettyprinter
, process
, recursion-schemes
, scientific
, sexp-grammar
, string-interpolate
, template-haskell
+6 -8
View File
@@ -77,8 +77,6 @@ inspectWasm wat = do
let wasmtools_cfg
= proc "wasm-tools" ["print", "-pf", "--print-operand-stack"
,"--color", "always", "-"]
-- & setStdin (byteStringInput . view lazy . encodeUtf8 $ wat)
-- & setStdout byteStringOutput
& setStdin createPipe
& setStdout createPipe
& setStderr inherit
@@ -128,12 +126,12 @@ driver opts = do
(eval >>> fmap writeObj
>>> T.unwords
>>> hPutStrLn FS.stdout)
dumpOrRun False (rt_is #CPS)
(pure closedCps)
(const $ pure ())
(CPS.evalProgram >>> fmap writeObj
>>> T.unwords
>>> hPutStrLn FS.stdout)
when (rt_is #CPS) do
closedCps
& CPS.evalProgram
& fmap writeObj
& T.unwords
& hPutStrLn FS.stdout
dumpOrRun opts.inspectWasm (rt_is #Wasm)
(lowerProgram cps)
inspectWasm
+25
View File
@@ -0,0 +1,25 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module Gyehoek.Language
( Language(..)
) where
import Data.Kind (Type)
import Gyehoek.Prelude
import Language.SexpGrammar (Position, Grammar, (:-), Sexp)
class Language l where
type Program l :: Type
languageName :: Text
programGrammar :: forall t. Grammar Position (List Sexp :- t) (Program l :- t)
readProgramFile
:: forall l es. Language l
=> FilePath -> Eff es (Program l)
readProgramFile fp = _
readProgramStringPos
:: forall l. Language l
=> Position -> Text -> Either Text (Program l)
readProgramStringPos pos s = _
+33 -3
View File
@@ -2,8 +2,9 @@
{-# LANGUAGE RecordWildCards #-}
module Gyehoek.Options
( Options(..)
, Runtime(..)
, parser
, Runtime(..)
, Language(..)
)
where
@@ -13,7 +14,15 @@ import Gyehoek.Prelude hiding (argument)
data Runtime = Stackify | Wasm | CPS
deriving (Show, Generic)
deriving (Show, Generic, Eq)
data Language
= LanguageScheme
| LanguageCPS
| LanguageClosed
| LanguageStackified
| LanguageWasm
deriving (Show, Generic, Eq)
data Options = MkOptions
{ dumpClosed :: Bool
@@ -24,9 +33,20 @@ data Options = MkOptions
, inspectWasm :: Bool
, output :: FilePath
, sourceFile :: FilePath
, sourceLanguage :: Language
}
deriving (Show, Generic)
languageValues = ["scheme","cps","closed","stackified","wasm"]
languageReader = maybeReader \case
"scheme" -> Just LanguageScheme
"cps" -> Just LanguageCPS
"closed" -> Just LanguageClosed
"stackified" -> Just LanguageStackified
"wasm" -> Just LanguageWasm
_ -> Nothing
runtimeValues = ["stackify","wasm","cps","none"]
runtimeReader = maybeReader \case
"stackify" -> Just (Just Stackify)
"wasm" -> Just (Just Wasm)
@@ -45,14 +65,24 @@ parser = do
[ long "runtime"
, short 'R'
, value (Just Stackify)
, completeWith ["stackify","wasm","cps","none"]
, completeWith runtimeValues
, showDefaultWith $ const "stackify"
, metavar "RUNTIME"
]
sourceLanguage <- option languageReader . fold $
[ long "source"
, short 'S'
, value LanguageScheme
, completeWith languageValues
, showDefaultWith $ const "scheme"
, metavar "LANGUAGE"
]
output <- strOption . fold $
[ long "output"
, short 'o'
, metavar "FILE"
, value "-"
, action "file"
]
sourceFile <- argument str . fold $
[ metavar "FILE"
+4
View File
@@ -14,6 +14,8 @@ module Gyehoek.Prelude
, IsList(fromList)
, HasCallStack
, Hashable
, NonEmpty((:|))
, Natural
) where
import Control.Lens
@@ -31,4 +33,6 @@ import Data.Generics.Labels ()
import Data.String.Interpolate
import GHC.Stack (HasCallStack)
import Data.Hashable (Hashable)
import Data.List.NonEmpty (NonEmpty((:|)))
import Numeric.Natural (Natural)
+1
View File
@@ -26,6 +26,7 @@ module Gyehoek.Sexp
, encodePrettyWith
, encodePretty
, SpliceSexp(..)
, Position(..)
, parseSexpsWithPos
, parseSexpWithPos
, parseSexp
+4
View File
@@ -0,0 +1,4 @@
module Gyehoek.Sexp.Grammar
(
) where
+4
View File
@@ -0,0 +1,4 @@
module Gyehoek.Sexp.Print
(
) where
+4
View File
@@ -0,0 +1,4 @@
module Gyehoek.Sexp.Read
(
) where
+58
View File
@@ -0,0 +1,58 @@
{-# LANGUAGE DeriveAnyClass #-}
module Gyehoek.Sexp.Syntax
( DatumF(..)
, Simple(..)
, CompoundF(..)
, Prefix(..)
, Delimiter(..)
, Label(..)
) where
import Language.Haskell.TH.Syntax (Lift)
import Data.Scientific (Scientific)
import Data.ByteString (ByteString)
import Gyehoek.Prelude hiding (Simple)
data DatumF a
= SimpleF Simple
| CompoundF (CompoundF a)
| LabeledF Label a
| LabelRefF Label
deriving stock (Show, Eq, Data, Generic, Lift)
deriving anyclass (NFData)
data Simple
= SimpleBool Bool
| SimpleNumber Scientific
| SimpleChar
| SimpleString
| SimpleSymbol
| SimpleBytevector ByteString
deriving stock (Show, Eq, Data, Generic, Lift)
deriving anyclass (NFData)
data CompoundF a
= ListF (List a)
| DotListF (NonEmpty a) a
| VectorF (List a)
| AbbrevF Prefix a
deriving stock (Show, Eq, Data, Generic, Lift)
deriving anyclass (NFData)
data Prefix
= Quote | Backtick | Comma | CommaAt
deriving stock (Show, Eq, Data, Generic, Lift)
deriving anyclass (NFData)
data Delimiter
= Paren
| Square
| Curly
deriving stock (Show, Eq, Data, Generic, Lift)
deriving anyclass (NFData)
newtype Label = MkLabel Natural
deriving stock (Data, Generic, Lift)
deriving newtype (Eq, Ord, Show)
deriving anyclass (NFData)