-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Tlang directory and add macro
- Loading branch information
1 parent
fa19fea
commit 933f786
Showing
16 changed files
with
151 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
bootstrap/src/Tlang/Codegen.hs → ...strap/src/Compiler/CodeGen/LLVM/Module.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module Language.Core.Macro | ||
( Attr (..) | ||
, Macro (..) | ||
, MacroF (..) | ||
) | ||
where | ||
|
||
import Data.Functor.Foldable.TH | ||
import Data.Functor.Foldable (Recursive) | ||
import Language.TH (fixQ) | ||
|
||
import Data.Text (Text) | ||
|
||
-- | Structure is defined by macro functionality `f` and | ||
-- result is defined by parameter `inst`, meaning | ||
-- instruction. `inst` can also be used for other | ||
-- temporary purpose for convenience. | ||
-- | ||
-- Macro may or may not be inline, block or | ||
-- special one. It may or may not involve | ||
-- customized user syntax or reading environment | ||
-- information. | ||
data Macro f inst | ||
= Inf inst | ||
| Macro (f (Macro f inst)) | ||
deriving (Functor, Foldable) | ||
|
||
instance Functor f => Applicative (Macro f) where | ||
pure = Inf | ||
(Inf f) <*> (Inf a) = Inf (f a) | ||
f <*> Macro fv = Macro ((f <*>) <$> fv) | ||
(Macro fv) <*> a = Macro ((<*> a) <$> fv) | ||
|
||
instance Functor f => Monad (Macro f) where | ||
Inf a >>= f = f a | ||
Macro fma >>= f = Macro ((>>= f) <$> fma) | ||
|
||
|
||
-- | a small expression for defining attributes | ||
data Attr | ||
= AttrI Integer -- ^ Integer value | ||
| AttrT Text -- ^ literal value | ||
| AttrS [Attr] -- ^ sequence items, take a list form | ||
| AttrC Text [Attr] -- ^ constructor value, with optional arguments | ||
| AttrP [(Text, Attr)] -- ^ associated value, take a record form | ||
deriving (Show, Eq, Ord) | ||
|
||
makeBaseFunctor $ fixQ [d| | ||
instance (Functor f) => Recursive (Macro f a) | ||
|] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.