This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8479a71
Showing
31 changed files
with
584 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{hs,lhs}] | ||
indent_size = 2 | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab |
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,6 @@ | ||
.stack-work/ | ||
*.cabal | ||
*~ | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class |
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,3 @@ | ||
indent-size: 2 | ||
line-length: 80 | ||
force-trailing-newline: true |
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,5 @@ | ||
# HLint configuration file | ||
# https://github.com/ndmitchell/hlint | ||
|
||
# Not considered useful hints: | ||
- ignore: { name: "Redundant do" } |
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,27 @@ | ||
language: generic | ||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.stack | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- libgmp-dev | ||
|
||
before_install: | ||
- mkdir -p ~/.local/bin | ||
- export PATH=$HOME/.local/bin:$PATH | ||
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' | ||
|
||
install: | ||
- travis_wait stack --no-terminal setup | ||
- stack ghc -- --version | ||
- travis_wait stack --no-terminal test --only-dependencies | ||
|
||
script: | ||
- stack --no-terminal test --haddock --no-haddock-deps --ghc-options -Werror | ||
|
||
notifications: | ||
email: false |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Marek Kaput, Anna Bukowska | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,14 @@ | ||
# Intentio | ||
|
||
[![Build Status](https://travis-ci.org/intentio-lang/intentio.svg?branch=master)](https://travis-ci.org/intentio-lang/intentio) | ||
|
||
This is the main source code repository for [Intentio]. It contains the compiler, runtime library and standard library. | ||
|
||
## License | ||
|
||
Intentio source code is released under MIT License. | ||
|
||
See the [LICENSE] file for license rights and limitations. | ||
|
||
[Intentio]: https://github.com/intentio-lang | ||
[LICENSE]: https://github.com/intentio-lang/intentio/blob/master/LICENSE.txt |
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,17 @@ | ||
# build-tool - Intentio Compiler build tools | ||
|
||
## Using build-tool | ||
|
||
The build-tool has a primary entry point, a top level x.py script: | ||
|
||
python3 ./x.py | ||
|
||
Note that if you're on Unix you should be able to execute the script directly: | ||
|
||
./x.py | ||
|
||
## Acknowledges | ||
|
||
This tools is loosely based on [rustbuild] tool from rustc source code. | ||
|
||
[rustbuild]: https://github.com/rust-lang/rust/tree/04e4d426a169a26d498bf22d2c2d01bc7b14fbcd/src/bootstrap |
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,52 @@ | ||
import argparse | ||
import datetime | ||
import sys | ||
from time import time | ||
|
||
import runcookiecutter | ||
|
||
|
||
def run(): | ||
parser = argparse.ArgumentParser( | ||
description='Build Intentio', epilog='Happy hacking!') | ||
|
||
subparsers = parser.add_subparsers(dest='cmd', title='subcommands') | ||
subparsers.required = True | ||
|
||
runcookiecutter.install_args( | ||
subparsers.add_parser('cookiecutter', help='run cookiecutter')) | ||
|
||
args = parser.parse_args() | ||
args.func(args) | ||
|
||
|
||
def main(): | ||
start_time = time() | ||
try: | ||
run() | ||
if not help_triggered(): | ||
print('Task completed successfully in', | ||
format_build_time(time() - start_time)) | ||
except (SystemExit, KeyboardInterrupt) as error: | ||
if hasattr(error, 'code') and isinstance(error.code, int): | ||
exit_code = error.code | ||
else: | ||
exit_code = 1 | ||
print(error) | ||
if not help_triggered(): | ||
print('Task completed unsuccessfully in', | ||
format_build_time(time() - start_time)) | ||
|
||
sys.exit(exit_code) | ||
|
||
|
||
def help_triggered(): | ||
return ('-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1) | ||
|
||
|
||
def format_build_time(duration): | ||
return str(datetime.timedelta(seconds=int(duration))) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,6 @@ | ||
# Cookiecutters | ||
|
||
This directory contains various [Cookiecutter] templates for use in | ||
development of Intentio compiler. | ||
|
||
[Cookiecutter]: https://github.com/audreyr/cookiecutter |
3 changes: 3 additions & 0 deletions
3
src/build-tool/cookiecutters/haskell-package/cookiecutter.json
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,3 @@ | ||
{ | ||
"package_name": "foo-bar" | ||
} |
20 changes: 20 additions & 0 deletions
20
src/build-tool/cookiecutters/haskell-package/{{cookiecutter.package_name}}/package.yaml
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,20 @@ | ||
_common: !include "../package-common.yaml" | ||
|
||
name: {{cookiecutter.package_name}} | ||
|
||
<<: *meta | ||
|
||
dependencies: | ||
- base | ||
- intentio-core | ||
|
||
library: | ||
source-dirs: src | ||
|
||
tests: | ||
{{cookiecutter.package_name}}-test: | ||
main: Spec.hs | ||
source-dirs: test | ||
dependencies: | ||
- {{cookiecutter.package_name}} | ||
- hspec |
9 changes: 9 additions & 0 deletions
9
...uild-tool/cookiecutters/haskell-package/{{cookiecutter.package_name}}/src/Intentio/Foo.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Intentio.Foo | ||
( someFunc | ||
) | ||
where | ||
|
||
import Intentio.Prelude | ||
|
||
someFunc :: IO () | ||
someFunc = putStrLn "{{cookiecutter.package_name}}" |
11 changes: 11 additions & 0 deletions
11
...tool/cookiecutters/haskell-package/{{cookiecutter.package_name}}/test/Intentio/FooSpec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Intentio.FooSpec | ||
where | ||
|
||
import Intentio.Prelude | ||
|
||
import Test.Hspec | ||
|
||
spec = do | ||
describe "{{cookiecutter.package_name}}" $ do | ||
it "should foobar" $ do | ||
1 `shouldBe` 1 |
1 change: 1 addition & 0 deletions
1
src/build-tool/cookiecutters/haskell-package/{{cookiecutter.package_name}}/test/Spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-} |
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 @@ | ||
cookiecutter==1.6.0 |
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,27 @@ | ||
from argparse import ArgumentParser | ||
import os | ||
|
||
from cookiecutter.main import cookiecutter | ||
|
||
from utils import SRC_DIR | ||
|
||
TEMPLATE_ROOT = os.path.join( | ||
os.path.dirname(os.path.abspath(__file__)), 'cookiecutters') | ||
|
||
|
||
def install_args(parser: ArgumentParser): | ||
parser.add_argument( | ||
'template_name', choices=list_available_cookiecutters()) | ||
parser.set_defaults(func=runcookiecutter) | ||
|
||
|
||
def runcookiecutter(args): | ||
cookiecutter( | ||
os.path.join(TEMPLATE_ROOT, args.template_name), output_dir=SRC_DIR) | ||
|
||
|
||
def list_available_cookiecutters(): | ||
return [ | ||
d for d in os.listdir(TEMPLATE_ROOT) | ||
if os.path.isdir(os.path.join(TEMPLATE_ROOT, d)) | ||
] |
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,3 @@ | ||
import os | ||
|
||
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
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,22 @@ | ||
_common: !include "../package-common.yaml" | ||
|
||
name: intentio-core | ||
|
||
<<: *meta | ||
|
||
dependencies: | ||
- base | ||
- mtl | ||
- protolude | ||
- text | ||
|
||
library: | ||
source-dirs: src | ||
|
||
tests: | ||
intentio-core-test: | ||
main: Spec.hs | ||
source-dirs: test | ||
dependencies: | ||
- intentio-core | ||
- hspec |
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,24 @@ | ||
module Intentio.AST | ||
where | ||
|
||
import Intentio.Prelude | ||
|
||
import Data.Text ( Text ) | ||
|
||
type Name = Text | ||
|
||
data Expr | ||
= Float Double | ||
| BinOp Op Expr Expr | ||
| Var Text | ||
| Call Name [Expr] | ||
| Function Name [Expr] Expr | ||
| Extern Name [Expr] | ||
deriving (Eq, Ord, Show) | ||
|
||
data Op | ||
= Plus | ||
| Minus | ||
| Times | ||
| Divide | ||
deriving (Eq, Ord, Show) |
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,45 @@ | ||
module Intentio.Prelude | ||
( module P | ||
, module S | ||
) | ||
where | ||
|
||
import Prelude as P | ||
( String ) | ||
|
||
import Protolude as P | ||
hiding ( MonadState | ||
, State | ||
, StateT(StateT) | ||
, put | ||
, get | ||
, gets | ||
, modify | ||
, state | ||
, withState | ||
, runState | ||
, execState | ||
, evalState | ||
, runStateT | ||
, execStateT | ||
, evalStateT | ||
) | ||
|
||
import Control.Monad.State.Strict as S | ||
( MonadState | ||
, State | ||
, StateT(StateT) | ||
, put | ||
, get | ||
, gets | ||
, modify | ||
, modify' | ||
, state | ||
, withState | ||
, runState | ||
, execState | ||
, evalState | ||
, runStateT | ||
, execStateT | ||
, evalStateT | ||
) |
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 @@ | ||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-} |
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,9 @@ | ||
module Main | ||
where | ||
|
||
import Intentio.Prelude | ||
|
||
import Intentio.Interactive ( runInteractive ) | ||
|
||
main :: IO () | ||
main = runInteractive |
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,21 @@ | ||
_common: !include "../package-common.yaml" | ||
|
||
name: intentio-interactive | ||
|
||
<<: *meta | ||
|
||
dependencies: | ||
- base | ||
- haskeline | ||
- intentio-core | ||
- text | ||
|
||
library: | ||
source-dirs: src | ||
|
||
executables: | ||
intentioi: | ||
main: Main.hs | ||
source-dirs: app | ||
dependencies: | ||
- intentio-interactive |
Oops, something went wrong.