Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaput committed Apr 21, 2018
0 parents commit 8479a71
Show file tree
Hide file tree
Showing 31 changed files with 584 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
@@ -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
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
.stack-work/
*.cabal
*~
__pycache__/
*.py[cod]
*$py.class
3 changes: 3 additions & 0 deletions .hindent.yaml
@@ -0,0 +1,3 @@
indent-size: 2
line-length: 80
force-trailing-newline: true
5 changes: 5 additions & 0 deletions .hlint.yaml
@@ -0,0 +1,5 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint

# Not considered useful hints:
- ignore: { name: "Redundant do" }
27 changes: 27 additions & 0 deletions .travis.yml
@@ -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
21 changes: 21 additions & 0 deletions LICENSE.txt
@@ -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.
14 changes: 14 additions & 0 deletions README.md
@@ -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
17 changes: 17 additions & 0 deletions src/build-tool/README.md
@@ -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
52 changes: 52 additions & 0 deletions src/build-tool/build.py
@@ -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()
6 changes: 6 additions & 0 deletions src/build-tool/cookiecutters/README.md
@@ -0,0 +1,6 @@
# Cookiecutters

This directory contains various [Cookiecutter] templates for use in
development of Intentio compiler.

[Cookiecutter]: https://github.com/audreyr/cookiecutter
@@ -0,0 +1,3 @@
{
"package_name": "foo-bar"
}
@@ -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
@@ -0,0 +1,9 @@
module Intentio.Foo
( someFunc
)
where

import Intentio.Prelude

someFunc :: IO ()
someFunc = putStrLn "{{cookiecutter.package_name}}"
@@ -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
@@ -0,0 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
1 change: 1 addition & 0 deletions src/build-tool/requirements.txt
@@ -0,0 +1 @@
cookiecutter==1.6.0
27 changes: 27 additions & 0 deletions src/build-tool/runcookiecutter.py
@@ -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))
]
3 changes: 3 additions & 0 deletions src/build-tool/utils.py
@@ -0,0 +1,3 @@
import os

SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22 changes: 22 additions & 0 deletions src/intentio-core/package.yaml
@@ -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
24 changes: 24 additions & 0 deletions src/intentio-core/src/Intentio/AST.hs
@@ -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)
45 changes: 45 additions & 0 deletions src/intentio-core/src/Intentio/Prelude.hs
@@ -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
)
1 change: 1 addition & 0 deletions src/intentio-core/test/Spec.hs
@@ -0,0 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
9 changes: 9 additions & 0 deletions src/intentio-interactive/app/Main.hs
@@ -0,0 +1,9 @@
module Main
where

import Intentio.Prelude

import Intentio.Interactive ( runInteractive )

main :: IO ()
main = runInteractive
21 changes: 21 additions & 0 deletions src/intentio-interactive/package.yaml
@@ -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

0 comments on commit 8479a71

Please sign in to comment.