wip: qq
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# qbe-hs
|
# qbe-hs
|
||||||
|
|
||||||
|
**fork of [qbe-hs](https://git.sr.ht/~fgaz/qbe-hs)**
|
||||||
|
|
||||||
[](https://hackage.haskell.org/package/qbe)
|
[](https://hackage.haskell.org/package/qbe)
|
||||||
[](https://builds.sr.ht/~fgaz/qbe-hs/commits/master?)
|
[](https://builds.sr.ht/~fgaz/qbe-hs/commits/master?)
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,15 @@ common common
|
|||||||
-Wredundant-constraints
|
-Wredundant-constraints
|
||||||
-Wincomplete-uni-patterns
|
-Wincomplete-uni-patterns
|
||||||
-Wincomplete-record-updates
|
-Wincomplete-record-updates
|
||||||
|
-fdefer-type-errors
|
||||||
|
-fno-show-valid-hole-fits
|
||||||
|
-fdefer-out-of-scope-variables
|
||||||
|
-Wno-typed-holes
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
library
|
library
|
||||||
import: common
|
import: common
|
||||||
exposed-modules: Language.QBE
|
exposed-modules: Language.QBE Language.QBE.QQ
|
||||||
-- other-modules:
|
-- other-modules:
|
||||||
other-extensions: DataKinds
|
other-extensions: DataKinds
|
||||||
KindSignatures
|
KindSignatures
|
||||||
@@ -63,6 +67,8 @@ library
|
|||||||
, hashable ^>= 1.4.0
|
, hashable ^>= 1.4.0
|
||||||
, deepseq ^>= 1.4.4 || ^>= 1.5
|
, deepseq ^>= 1.4.4 || ^>= 1.5
|
||||||
, prettyprinter ^>= 1.7.1
|
, prettyprinter ^>= 1.7.1
|
||||||
|
, megaparsec ^>= 9.7.0
|
||||||
|
, template-haskell
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
|
|
||||||
test-suite golden
|
test-suite golden
|
||||||
|
|||||||
43
src/Language/QBE/QQ.hs
Normal file
43
src/Language/QBE/QQ.hs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{-# LANGUAGE RankNTypes, TypeAbstractions, OverloadedStrings, ScopedTypeVariables #-}
|
||||||
|
module Language.QBE.QQ
|
||||||
|
( qbe
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import qualified Language.Haskell.TH as TH
|
||||||
|
import Language.Haskell.TH.Quote
|
||||||
|
import Data.Void
|
||||||
|
import Text.Megaparsec
|
||||||
|
import Text.Megaparsec.Char
|
||||||
|
import qualified Text.Megaparsec.Char.Lexer as L
|
||||||
|
import Language.QBE
|
||||||
|
import Data.Proxy
|
||||||
|
|
||||||
|
|
||||||
|
type P = Parsec Void String
|
||||||
|
|
||||||
|
space = L.space space1 empty empty
|
||||||
|
lexeme = L.lexeme space1
|
||||||
|
symbol = L.symbol space1
|
||||||
|
|
||||||
|
ident :: Sigil -> P (Ident t)
|
||||||
|
ident (Proxy @t) = do
|
||||||
|
case t of
|
||||||
|
AggregateTy -> char ':'
|
||||||
|
Ident <$> ""
|
||||||
|
|
||||||
|
assignment :: P Assignment
|
||||||
|
assignment = do
|
||||||
|
ident
|
||||||
|
|
||||||
|
assignmentInst :: P Inst
|
||||||
|
assignmentInst = _
|
||||||
|
|
||||||
|
qbeQuoteExp :: String -> TH.ExpQ
|
||||||
|
qbeQuoteExp = _
|
||||||
|
|
||||||
|
qbe :: QuasiQuoter
|
||||||
|
qbe = QuasiQuoter
|
||||||
|
{ quoteExp = qbeQuoteExp
|
||||||
|
, quotePat = _
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user