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 . ((eval
. (progn (defun apply-cabal-fmt-h () . (progn (defun apply-cabal-fmt-h ()
(haskell-mode-buffer-apply-command "cabal-fmt")) (haskell-mode-buffer-apply-command "cabal-fmt"))
(add-hook 'before-save-hook #'apply-cabal-fmt-h nil t) (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)))))))
+5
View File
@@ -55,6 +55,11 @@
guile guile
rust-analyzer rust-analyzer
wasmtime 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.CPS.Syntax
Gyehoek.Driver Gyehoek.Driver
Gyehoek.GenSym Gyehoek.GenSym
Gyehoek.Language
Gyehoek.Options Gyehoek.Options
Gyehoek.Prelude Gyehoek.Prelude
Gyehoek.Scheme.Syntax Gyehoek.Scheme.Syntax
Gyehoek.Sexp Gyehoek.Sexp
Gyehoek.Sexp.Grammar
Gyehoek.Sexp.Print
Gyehoek.Sexp.Read
Gyehoek.Sexp.Syntax
Gyehoek.Stack.Syntax Gyehoek.Stack.Syntax
Gyehoek.Stack.VM Gyehoek.Stack.VM
Gyehoek.Wasm Gyehoek.Wasm
@@ -90,6 +95,7 @@ library
, prettyprinter , prettyprinter
, process , process
, recursion-schemes , recursion-schemes
, scientific
, sexp-grammar , sexp-grammar
, string-interpolate , string-interpolate
, template-haskell , template-haskell
+6 -8
View File
@@ -77,8 +77,6 @@ inspectWasm wat = do
let wasmtools_cfg let wasmtools_cfg
= proc "wasm-tools" ["print", "-pf", "--print-operand-stack" = proc "wasm-tools" ["print", "-pf", "--print-operand-stack"
,"--color", "always", "-"] ,"--color", "always", "-"]
-- & setStdin (byteStringInput . view lazy . encodeUtf8 $ wat)
-- & setStdout byteStringOutput
& setStdin createPipe & setStdin createPipe
& setStdout createPipe & setStdout createPipe
& setStderr inherit & setStderr inherit
@@ -128,12 +126,12 @@ driver opts = do
(eval >>> fmap writeObj (eval >>> fmap writeObj
>>> T.unwords >>> T.unwords
>>> hPutStrLn FS.stdout) >>> hPutStrLn FS.stdout)
dumpOrRun False (rt_is #CPS) when (rt_is #CPS) do
(pure closedCps) closedCps
(const $ pure ()) & CPS.evalProgram
(CPS.evalProgram >>> fmap writeObj & fmap writeObj
>>> T.unwords & T.unwords
>>> hPutStrLn FS.stdout) & hPutStrLn FS.stdout
dumpOrRun opts.inspectWasm (rt_is #Wasm) dumpOrRun opts.inspectWasm (rt_is #Wasm)
(lowerProgram cps) (lowerProgram cps)
inspectWasm 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 #-} {-# LANGUAGE RecordWildCards #-}
module Gyehoek.Options module Gyehoek.Options
( Options(..) ( Options(..)
, Runtime(..)
, parser , parser
, Runtime(..)
, Language(..)
) )
where where
@@ -13,7 +14,15 @@ import Gyehoek.Prelude hiding (argument)
data Runtime = Stackify | Wasm | CPS 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 data Options = MkOptions
{ dumpClosed :: Bool { dumpClosed :: Bool
@@ -24,9 +33,20 @@ data Options = MkOptions
, inspectWasm :: Bool , inspectWasm :: Bool
, output :: FilePath , output :: FilePath
, sourceFile :: FilePath , sourceFile :: FilePath
, sourceLanguage :: Language
} }
deriving (Show, Generic) 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 runtimeReader = maybeReader \case
"stackify" -> Just (Just Stackify) "stackify" -> Just (Just Stackify)
"wasm" -> Just (Just Wasm) "wasm" -> Just (Just Wasm)
@@ -45,14 +65,24 @@ parser = do
[ long "runtime" [ long "runtime"
, short 'R' , short 'R'
, value (Just Stackify) , value (Just Stackify)
, completeWith ["stackify","wasm","cps","none"] , completeWith runtimeValues
, showDefaultWith $ const "stackify" , 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 $ output <- strOption . fold $
[ long "output" [ long "output"
, short 'o' , short 'o'
, metavar "FILE" , metavar "FILE"
, value "-" , value "-"
, action "file"
] ]
sourceFile <- argument str . fold $ sourceFile <- argument str . fold $
[ metavar "FILE" [ metavar "FILE"
+4
View File
@@ -14,6 +14,8 @@ module Gyehoek.Prelude
, IsList(fromList) , IsList(fromList)
, HasCallStack , HasCallStack
, Hashable , Hashable
, NonEmpty((:|))
, Natural
) where ) where
import Control.Lens import Control.Lens
@@ -31,4 +33,6 @@ import Data.Generics.Labels ()
import Data.String.Interpolate import Data.String.Interpolate
import GHC.Stack (HasCallStack) import GHC.Stack (HasCallStack)
import Data.Hashable (Hashable) import Data.Hashable (Hashable)
import Data.List.NonEmpty (NonEmpty((:|)))
import Numeric.Natural (Natural)
+1
View File
@@ -26,6 +26,7 @@ module Gyehoek.Sexp
, encodePrettyWith , encodePrettyWith
, encodePretty , encodePretty
, SpliceSexp(..) , SpliceSexp(..)
, Position(..)
, parseSexpsWithPos , parseSexpsWithPos
, parseSexpWithPos , parseSexpWithPos
, parseSexp , 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)