From a6a09cf1181d5b1285e9e1b2ba8e16a7eb7079d8 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 31 Jul 2019 10:31:39 +0200 Subject: [PATCH] strictness, ci --- .gitignore | 1 + .gitlab-ci.yml | 8 ++++++++ check.dcl | 2 +- check.icl | 2 +- int.dcl | 2 +- int.icl | 2 +- parse.dcl | 4 ++-- parse.icl | 4 ++-- rts/.gitignore | 1 + rts.c => rts/rts.c | 0 rts.h => rts/rts.h | 0 scc.dcl | 2 +- scc.icl | 10 +++++----- test.bash | 29 +++++++++++++++++++++++++++++ tests/bracket.expected | 1 + 15 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 rts/.gitignore rename rts.c => rts/rts.c (100%) rename rts.h => rts/rts.h (100%) create mode 100644 test.bash create mode 100644 tests/bracket.expected diff --git a/.gitignore b/.gitignore index f89feb6..b9aa5aa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ minfp * Time Profile.pcl *.o *.prj +.tags diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5294a2c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,8 @@ +image: camilstaps/clean:nightly +test: + before_script: + - apt-get update -qq + - apt-get install -yy build-essential wget + script: + - install_clean_nightly.sh base lib-platform + - bash test.bash diff --git a/check.dcl b/check.dcl index 3c2c8b2..8abb9db 100644 --- a/check.dcl +++ b/check.dcl @@ -8,4 +8,4 @@ from ast import :: Function, :: Expression, :: Type, :: TypeDef instance toString Scheme -check :: [Either TypeDef Function] -> Either [String] (Expression, [([Char], Scheme)]) +check :: ![Either TypeDef Function] -> Either [String] (Expression, [([Char], Scheme)]) diff --git a/check.icl b/check.icl index cbd58f6..e56d555 100644 --- a/check.icl +++ b/check.icl @@ -18,7 +18,7 @@ import ast, scc import StdDebug -check :: [Either TypeDef Function] -> Either [String] (Expression, [([Char], Scheme)]) +check :: ![Either TypeDef Function] -> Either [String] (Expression, [([Char], Scheme)]) check tdfs # dups = filter (\x->length x > 1) (groupBy (\(Function i _ _) (Function j _ _)->i == j) functions) | length dups > 0 = Left ["Duplicate functions: ":[toString n\\[(Function n _ _):_]<-dups]] diff --git a/int.dcl b/int.dcl index 2e33982..fc51620 100644 --- a/int.dcl +++ b/int.dcl @@ -5,4 +5,4 @@ from ast import :: Expression, :: Value :: Eval a -int :: Expression -> Either [String] Value +int :: !Expression -> Either [String] Value diff --git a/int.icl b/int.icl index 5467559..f096200 100644 --- a/int.icl +++ b/int.icl @@ -15,7 +15,7 @@ import ast :: Eval a :== StateT [([Char], Value)] (Either [String]) a -int :: Expression -> Either [String] Value +int :: !Expression -> Either [String] Value int e = evalStateT (eval e) [(['_if'], Builtin \i->pure (Lit (Builtin \t->pure (Lit (Builtin \e-> eval i >>= \(Bool b)->pure (if b t e)))))) diff --git a/parse.dcl b/parse.dcl index 2349c5d..21da778 100644 --- a/parse.dcl +++ b/parse.dcl @@ -6,5 +6,5 @@ from ast import :: Function, :: TypeDef :: Token instance toString Token -lex :: [Char] -> Either [String] [Token] -parse :: [Token] -> Either [String] [Either TypeDef Function] +lex :: ![Char] -> Either [String] [Token] +parse :: ![Token] -> Either [String] [Either TypeDef Function] diff --git a/parse.icl b/parse.icl index b80bebb..847f1b3 100644 --- a/parse.icl +++ b/parse.icl @@ -25,7 +25,7 @@ derive gPrint Token instance toString Token where toString t = printToString t -lex :: [Char] -> Either [String] [Token] +lex :: ![Char] -> Either [String] [Token] lex [] = pure [] lex ['//\n':ts] = lex ts lex ['//',t:ts] = lex ['/','/':ts] @@ -95,7 +95,7 @@ pChainl op p = foldl (flip ($)) <$> p <*> many (flip <$> op <*> p) pChainr :: (Parser (a a -> a)) (Parser a) -> Parser a pChainr op p = flip ($) <$> p <*> (flip <$> op <*> pChainr op p) <|> p -parse :: [Token] -> Either [String] [Either TypeDef Function] +parse :: ![Token] -> Either [String] [Either TypeDef Function] parse ts = case runParser (many (Right <$> pFunction <|> Left <$> pTypeDef) <* pEof) ts [] of (Left e, _, _) = Left e (Right a, _, r) = sequence [reparse r a\\a<-a] diff --git a/rts/.gitignore b/rts/.gitignore new file mode 100644 index 0000000..5761abc --- /dev/null +++ b/rts/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/rts.c b/rts/rts.c similarity index 100% rename from rts.c rename to rts/rts.c diff --git a/rts.h b/rts/rts.h similarity index 100% rename from rts.h rename to rts/rts.h diff --git a/scc.dcl b/scc.dcl index 0bbe3c8..d9edde0 100644 --- a/scc.dcl +++ b/scc.dcl @@ -10,4 +10,4 @@ from StdClass import class Ord, class Eq * @param list of nodes together with their their successors * @return the strongly connected components */ -scc :: [(a, [a])] -> [[a]] | Eq, Ord a +scc :: ![(a, [a])] -> [[a]] | Eq, Ord a diff --git a/scc.icl b/scc.icl index 0014f50..408e647 100644 --- a/scc.icl +++ b/scc.icl @@ -3,13 +3,13 @@ implementation module scc import StdEnv, StdMaybe import Data.Map => qualified updateAt -:: St a = {nextindex :: Int, stack :: [a], map :: Map a Annot, sccs :: [[a]]} -:: Annot = {index :: Int, lowlink :: Int, onstack :: Bool} +:: St a = {nextindex :: !Int, stack :: ![a], map :: !Map a Annot, sccs :: ![[a]]} +:: Annot = {index :: !Int, lowlink :: !Int, onstack :: !Bool} -scc :: [(a, [a])] -> [[a]] | Eq, Ord a +scc :: ![(a, [a])] -> [[a]] | Eq, Ord a scc nodes = reverse (foldr (strongconnect nodes) {nextindex=zero,stack=[],map=newMap,sccs=[]} nodes).sccs where - strongconnect :: [(a, [a])] (a, [a]) (St a) -> St a | Eq, Ord a + strongconnect :: ![(a, [a])] !(a, [a]) !(St a) -> St a | Eq, Ord a strongconnect nodes (v, suc) s | isJust (get v s.map) = s # s = foldr (processSucc nodes v) @@ -26,7 +26,7 @@ where , map = foldr (alter \(Just s)->Just {s & onstack=False}) s.map scc } where - processSucc :: [(a, [a])] a a (St a) -> St a | Eq, Ord a + processSucc :: ![(a, [a])] !a !a !(St a) -> St a | Eq, Ord a processSucc nodes v w s = case get w s.map of Nothing # n = filter ((==)w o fst) nodes diff --git a/test.bash b/test.bash new file mode 100644 index 0000000..8577bdb --- /dev/null +++ b/test.bash @@ -0,0 +1,29 @@ +#!/bin/bash +set -e +shopt -s nullglob + +make minfp + +[ $# -eq 0 ] && testfiles=(tests/*.mfp) || testfiles=("${@}") + +pass=0 +skip=0 +fail=0 +for t in "${testfiles[@]}"; do + if [ ! -f "$t" ]; then + echo "$t doesn't exist" >&2 + exit 1 + fi + + exp="${t/%.mfp/.expected}" + if [ ! -f "$exp" ]; then + echo "$exp doesn't exist, skipping" >&2 + skip=$((skip+1)) + else + diff <(./minfp < "$t") "$exp" + [ $? -ne 0 ] && fail=$((fail+1)) || pass=$((pass+1)) + fi +done +echo "passed : $pass" >&2 +echo "skipped: $skip" >&2 +echo "failed : $fail" >&2 diff --git a/tests/bracket.expected b/tests/bracket.expected new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/tests/bracket.expected @@ -0,0 +1 @@ +42 -- 2.20.1