Commit b09bb57e authored by Mart Lubbers's avatar Mart Lubbers

started with cleanup, generatable makefiles and some spaces converted to tabs

parent 411151ed
......@@ -13,3 +13,5 @@ Clean System Files/
search
builddb
CloogleServer
*.prj
*.json
......@@ -3,7 +3,7 @@ module CloogleServer
import StdString, StdArray, StdList, StdFile, StdTuple, StdMisc, StdOrdList, StdBool
from StdFunc import o
import TCPIP
from TCPIP import :: IPAddress, :: Port, instance toString IPAddress
from Data.Func import $
import Data.Maybe
......@@ -14,11 +14,15 @@ import Data.Functor
import Control.Applicative
from Control.Monad import class Monad(..)
import SimpleTCPServer
import qualified StdMaybe as OldMaybe
from SimpleTCPServer import :: LogMessage{..}, serve, :: Logger
import qualified SimpleTCPServer
import TypeDB
import Type
import Levenshtein
:: OldMaybe a :== 'SimpleTCPServer'.Maybe a
:: Command = { unify :: String
, name :: String
}
......@@ -58,7 +62,7 @@ Start w
# (_, w) = fclose io w
| isNothing db = abort "stdin does not have a TypeDB\n"
# db = fromJust db
= serve (handle db) (Just log) port w
= serve (handle db) ('OldMaybe'.Just log) port w
where
help :: *File *World -> *World
help io w
......
This diff is collapsed.
BIN:=CloogleServer search builddb
PRJ:=$(addsuffix .prj,$(BIN))
CPM:=cpm
SED:=sed
.SECONDARY: $(PRJ)
.PHONY: all
all: $(BIN)
%: %.prj
$(CPM) $< \
| grep -v "^Analyzing" \
| grep -v "^Warning: Unable to setup directory cache"
%.prj:
$(CPM) project $(basename $@) create
$(SED) -i 's/\(Target:[ \t]\+\)StdEnv/\1CleanPlatform/' $@
$(SED) -i 's/[ \t]\+Path:[ \t]\+{Project}/&\n&\/CleanLevenshtein\n&\/CleanTypeUnifier\n&\/CleanTypeUnifier\/clean-compiler\/main\/\n&\/CleanTypeUnifier\/clean-compiler\/frontend\/\n&\/CleanTypeUnifier\/clean-compiler\/backend\/\n&\/CleanTypeUnifier\/clean-compiler\/main\/Unix\//' $@
$(SED) -i 's/\([ \t]\+Path:[ \t]\+\){Project}$$/&\n\1{Application}\/lib\/ArgEnv\/\n\1{Application}\/lib\/TCPIP\//' $@
$(SED) -i 's/\($(basename $@)\).exe/\1/' $@
clean:
$(RM) -r 'Clean System Files' $(BIN) $(PRJ)
......@@ -12,10 +12,12 @@ A Clean hoogle clone. Use at your own risk. Live version available
- The frontend heavily depends on [VanillaJS](http://vanilla-js.com/) so you
should have a webbrowsers that supports it.
- Set the list of libraries and `CLEAN_LIB` in `builddb.icl`. Then build
`builddb.prj` and run it:
$ cpm project builddb.prj build
- Add `envs/envs.linux64` to your `$CLEAN_HOME/etc/IDEEnvs`.
- Run `make`
- Run
$ ./builddb -h 10M > types.db
This creates a file `types.db` which holds the internal database of functions
......
definition module SimpleTCPServer
from StdOverloaded import class zero, class fromString, class toString
from Data.Maybe import ::Maybe
from StdMaybe import :: Maybe
from TCPIP import ::IPAddress, ::Port
:: LogMessage a b = Connected IPAddress
......
......@@ -6,8 +6,7 @@ import StdMaybe
instance zero (Logger a b s) where zero = \_ _ w -> (undef, w)
serve :: (a *World -> *(b,*World)) (Maybe (Logger a b s)) Port *World
-> *World | fromString a & toString b
serve :: (a *World -> *(b,*World)) (Maybe (Logger a b s)) Port *World -> *World | fromString a & toString b
serve f log port w
# (ok, mbListener, w) = openTCP_Listener port w
| not ok = abort ("Couldn't open port " +++ toString port)
......
......@@ -3,11 +3,13 @@ module builddb
// Project libraries
import qualified TypeDB as DB
// Standard libraries
import StdArray, StdBool, StdFile, StdList, StdMisc, StdString, StdFunc, StdTuple
import Data.Maybe, Text
import System.Directory, Data.Error, Data.Func, Data.Tuple
import GenEq
// StdEnv
import StdFile, StdList, StdMisc, StdArray, StdBool, StdString, StdTuple
// CleanPlatform
import Data.Maybe, Data.Either, Data.Error, Data.Func, Data.Tuple, Data.Functor
from Text import class Text(concat), instance Text String
import System.Directory, System.CommandLine
// CleanTypeUnifier
import qualified Type as T
......@@ -24,72 +26,106 @@ from general import ::Optional(..)
from syntax import ::SymbolTable, ::SymbolTableEntry, ::Ident{..}, ::SymbolPtr, ::Position(NoPos), ::Module{mod_ident,mod_defs}, ::ParsedDefinition(PD_TypeSpec,PD_Instance,PD_Class), ::FunSpecials, ::Priority, ::ParsedModule, ::SymbolType, ::ParsedInstanceAndMembers{..}, ::ParsedInstance{pi_ident,pi_types}, ::Type, ::ClassDef{class_ident,class_args}, ::TypeVar
from parse import wantModule
CLEAN_LIB :== "/opt/clean/lib/"
libraries :== [
"StdEnv"
, "StdLib"
, "ArgEnv"
, "Directory"
, "Dynamics"
, "Gast"
, "Generics"
, "MersenneTwister"
, "TCPIP"
, "clean-platform/OS-Independent"
, "clean-platform/OS-Linux"
, "clean-platform/OS-Linux-32"
, "clean-platform/OS-Linux-64"
, "clean-platform/OS-Mac"
, "clean-platform/OS-Posix"
, "clean-platform/OS-Windows"
, "clean-platform/OS-Windows-32"
, "clean-platform/OS-Windows-64"
]
:: CLI = {
help :: Bool,
version :: Bool,
root :: String,
libs :: [String]}
instance zero CLI where
zero = {
version = False,
help = False,
root = "/opt/clean/lib/",
libs = [
"StdEnv"
, "StdLib"
, "ArgEnv"
, "Directory"
, "Dynamics"
, "Gast"
, "Generics"
, "MersenneTwister"
, "TCPIP"
, "clean-platform/OS-Independent"
, "clean-platform/OS-Linux"
, "clean-platform/OS-Linux-32"
, "clean-platform/OS-Linux-64"
, "clean-platform/OS-Mac"
, "clean-platform/OS-Posix"
, "clean-platform/OS-Windows"
, "clean-platform/OS-Windows-32"
, "clean-platform/OS-Windows-64"]}
VERSION :== "Cloogle's builddb version 0.1\n"
USAGE :== concat [
VERSION, "\n",
"Usage: ./builddb [opts] > builddb.json\n\n",
"-h, --help Show this help\n",
"-r PATH Change the library root to PATH\n",
"-l PATH Add PATH to the librarypaths relative to the root\n"]
Start w
# (mods, w) = findModules` libraries w
# (st, w) = init_identifiers newHeap w
# cache = empty_cache st
# (db, w) = loop mods 'DB'.newDb cache w
# (args, w) = getCommandLine w
# (f, w) = stdio w
# f = 'DB'.saveDb db f
# (ok, w) = fclose f w
| not ok = abort "Couldn't close stdio after writing\n"
# (ok, w) = case parseCLI (tl args) of
(Left e) = fclose (f <<< e) w
(Right cli)
| cli.help = fclose (f <<< USAGE) w
| cli.version = fclose (f <<< VERSION) w
# (mods, w) = findModules` cli.libs cli.root w
# (st, w) = init_identifiers newHeap w
# cache = empty_cache st
# (db, w) = loop mods 'DB'.newDb cache w
# f = 'DB'.saveDb db f
= fclose f w
| not ok = abort "Couldn't close stdio"
= w
where
loop :: [(String,String)] 'DB'.TypeDB *DclCache *World -> *('DB'.TypeDB, *World)
loop [] db _ w = (db,w)
loop [(lib,mod):list] db cache w
# (db, cache, w) = getModuleTypes mod lib cache db w
//# db = 'DB'.putTypes sts db
= loop list db cache w
loop :: [(String,String)] 'DB'.TypeDB *DclCache *World -> *('DB'.TypeDB, *World)
loop [] db _ w = (db,w)
loop [(lib,mod):list] db cache w
# (db, cache, w) = getModuleTypes mod lib cache db w
//# db = 'DB'.putTypes sts db
= loop list db cache w
parseCLI :: [String] -> Either String CLI
parseCLI [] = Right zero
parseCLI [x:a] = case (x,a) of
("--help", xs) = (\c->{c & help=True}) <$> parseCLI xs
("--version", xs) = (\c->{c & version=True}) <$> parseCLI xs
("-l", []) = Left "'-l' requires an argument"
("-r", []) = Left "'-r' requires an argument"
("-r", [x:xs]) = (\c->{c & root=x}) <$> parseCLI xs
("-l", [x:xs]) = (\c->{c & libs=[x:c.libs]}) <$> parseCLI xs
(x, _) = Left $ "Unknown option '" +++ x +++ "'"
// Libraries Library Module
findModules` :: ![String] !*World -> *(![(String,String)], !*World)
findModules` [] w = ([], w)
findModules` [lib:libs] w
#! (mods, w) = findModules lib w
#! (moremods, w) = findModules` libs w
findModules` :: ![String] !String !*World -> *(![(String,String)], !*World)
findModules` [] _ w = ([], w)
findModules` [lib:libs] root w
#! (mods, w) = findModules lib root w
#! (moremods, w) = findModules` libs root w
= (removeDup (mods ++ moremods), w)
findModules :: !String !*World -> *(![(String,String)], !*World)
findModules lib w
#! (fps, w) = readDirectory (CLEAN_LIB +++ lib) w
findModules :: !String !String !*World -> *(![(String,String)], !*World)
findModules lib root w
#! (fps, w) = readDirectory (root +++ "/" +++ lib) w
| isError fps = ([], w)
#! fps = fromOk fps
#! mods = map (tuple lib) $ map (\s->s%(0,size s-5)) $ filter isDclModule fps
#! (moremods, w) = findModules` (map ((+++) (lib+++"/")) (filter isDirectory fps)) w
#! mods = map (tuple (root +++ lib)) $ map (\s->s%(0,size s-5)) $ filter isDclModule fps
#! (moremods, w) = findModules` (map ((+++) (lib+++"/")) (filter isDirectory fps)) root w
= (removeDup (mods ++ moremods), w)
where
isDclModule :: String -> Bool
isDclModule s = s % (size s - 4, size s - 1) == ".dcl" && s.[0] <> '_'
isDclModule :: String -> Bool
isDclModule s = s % (size s - 4, size s - 1) == ".dcl" && s.[0] <> '_'
isDirectory :: String -> Bool
isDirectory s = not $ isMember '.' $ fromString s
isDirectory :: String -> Bool
isDirectory s = not $ isMember '.' $ fromString s
getModuleTypes :: String String *DclCache 'DB'.TypeDB *World -> *('DB'.TypeDB, *DclCache, *World)
getModuleTypes mod lib cache db w
# filename = CLEAN_LIB +++ lib +++ "/" +++ mkdir mod +++ ".dcl"
# filename = lib +++ "/" +++ mkdir mod +++ ".dcl"
# (ok,f,w) = fopen filename FReadText w
| not ok = abort ("Couldn't open file " +++ filename +++ ".\n")
# (mod_id, ht) = putIdentInHashTable mod (IC_Module NoQualifiedIdents) cache.hash_table
......@@ -104,40 +140,40 @@ getModuleTypes mod lib cache db w
# db = 'DB'.putClasses (pd_classes mod pm.mod_defs) db
= (db,cache,w)
where
mkdir :: String -> String
mkdir s = toString (map (\c.case c of '.'='/'; c=c) (fromString s))
pd_typespecs :: String [ParsedDefinition] -> [('DB'.FunctionLocation, 'DB'.Type)]
pd_typespecs mod pds
# pds = filter (\pd->case pd of (PD_TypeSpec _ _ _ _ _)=True; _=False) pds
# sts = map (\(PD_TypeSpec pos id prio st funspecs) -> ('DB'.FL lib mod id.id_name,st)) pds
# sts = filter (\st->case st of (_,(Yes _))=True; _=False) sts
# sts = map (\(loc,Yes x)->(loc,'T'.toType x)) sts
= sts
pd_instances :: String [ParsedDefinition] -> [('DB'.Class, ['DB'.Type])]
pd_instances mod pds
# pds = filter (\pd->case pd of (PD_Instance _)=True; _=False) pds
= map (\(PD_Instance {pim_pi={pi_ident,pi_types}})
-> (pi_ident.id_name, map 'T'.toType pi_types)) pds
pd_classes :: String [ParsedDefinition]
-> [('DB'.ClassLocation, ['T'.TypeVar], [('DB'.FunctionName, 'T'.Type)])]
pd_classes mod pds
# pds = filter (\pd->case pd of (PD_Class _ _)=True; _=False) pds
= map (\(PD_Class {class_ident={id_name},class_args} pds)
-> let typespecs = pd_typespecs mod pds
in ('DB'.CL lib mod id_name, map 'T'.toTypeVar class_args,
[(f,t) \\ ('DB'.FL _ _ f, t) <- typespecs])) pds
mkdir :: String -> String
mkdir s = {if (c == '.') '/' c\\c<-:s}
pd_typespecs :: String [ParsedDefinition] -> [('DB'.FunctionLocation, 'DB'.Type)]
pd_typespecs mod pds
# pds = filter (\pd->case pd of (PD_TypeSpec _ _ _ _ _)=True; _=False) pds
# sts = map (\(PD_TypeSpec pos id prio st funspecs) -> ('DB'.FL lib mod id.id_name,st)) pds
# sts = filter (\st->case st of (_,(Yes _))=True; _=False) sts
# sts = map (\(loc,Yes x)->(loc,'T'.toType x)) sts
= sts
pd_instances :: String [ParsedDefinition] -> [('DB'.Class, ['DB'.Type])]
pd_instances mod pds
# pds = filter (\pd->case pd of (PD_Instance _)=True; _=False) pds
= map (\(PD_Instance {pim_pi={pi_ident,pi_types}})
-> (pi_ident.id_name, map 'T'.toType pi_types)) pds
pd_classes :: String [ParsedDefinition]
-> [('DB'.ClassLocation, ['T'.TypeVar], [('DB'.FunctionName, 'T'.Type)])]
pd_classes mod pds
# pds = filter (\pd->case pd of (PD_Class _ _)=True; _=False) pds
= map (\(PD_Class {class_ident={id_name},class_args} pds)
-> let typespecs = pd_typespecs mod pds
in ('DB'.CL lib mod id_name, map 'T'.toTypeVar class_args,
[(f,t) \\ ('DB'.FL _ _ f, t) <- typespecs])) pds
unigroups :: (Type Type -> Bool) [(a,Type)] -> [([a],Type)]
unigroups f ts = unigroups` ts []
where
unigroups` [] groups = groups
unigroups` [(a,t):ts] [] = unigroups` ts [([a],t)]
unigroups` [(a,t):ts] [(ns,ut):groups]
| f t ut = unigroups` ts [([a:ns],ut):groups]
| otherwise = unigroups` ts [(ns,ut):unigroups` [(a,t)] groups]
unigroups` [] groups = groups
unigroups` [(a,t):ts] [] = unigroups` ts [([a],t)]
unigroups` [(a,t):ts] [(ns,ut):groups]
| f t ut = unigroups` ts [([a:ns],ut):groups]
| otherwise = unigroups` ts [(ns,ut):unigroups` [(a,t)] groups]
(<+) infixr 5 :: a b -> [String] | print a & print b
(<+) a b = print a ++ print b
......@@ -159,4 +195,3 @@ wantModule` :: !*File !{#Char} !Bool !Ident !Position !Bool !*HashTable !*File !
wantModule` f s b1 i p b2 ht io fs
# (b1,b2,pm,ht,f,fs) = wantModule f s b1 i p b2 ht io fs
= ((b1,b2,pm,ht,f),fs)
This diff is collapsed.
Environment
EnvironmentName: CleanPlatform
EnvironmentPaths
Path: {Application}/lib/StdEnv
Path: {Application}/lib/Generics
Path: {Application}/lib/StdLib
Path: {Application}/lib/clean-platform/OS-Independent
Path: {Application}/lib/clean-platform/OS-Independent/Data
Path: {Application}/lib/clean-platform/OS-Independent/Database
Path: {Application}/lib/clean-platform/OS-Independent/Database/SQL
Path: {Application}/lib/clean-platform/OS-Independent/GUI
Path: {Application}/lib/clean-platform/OS-Independent/Internet
Path: {Application}/lib/clean-platform/OS-Independent/Internet/HTTP
Path: {Application}/lib/clean-platform/OS-Independent/Math
Path: {Application}/lib/clean-platform/OS-Independent/Network
Path: {Application}/lib/clean-platform/OS-Independent/System
Path: {Application}/lib/clean-platform/OS-Independent/Test
Path: {Application}/lib/clean-platform/OS-Independent/Text
Path: {Application}/lib/clean-platform/OS-Independent/Text/Encodings
Path: {Application}/lib/clean-platform/OS-Linux
Path: {Application}/lib/clean-platform/OS-Linux/Network
Path: {Application}/lib/clean-platform/OS-Linux/System
Path: {Application}/lib/clean-platform/OS-Linux-64
Path: {Application}/lib/clean-platform/OS-Linux-64/System
Path: {Application}/lib/clean-platform/OS-Linux-64/Database
Path: {Application}/lib/clean-platform/OS-Linux-64/Database/SQL
Path: {Application}/lib/clean-platform/OS-Linux-32
Path: {Application}/lib/clean-platform/OS-Linux-32/System
Path: {Application}/lib/clean-platform/OS-Linux-32/Database
Path: {Application}/lib/clean-platform/OS-Linux-32/Database/SQL
Path: {Application}/lib/clean-platform/OS-Posix
Path: {Application}/lib/clean-platform/OS-Posix/DataSources
Path: {Application}/lib/clean-platform/OS-Posix/Network
Path: {Application}/lib/clean-platform/OS-Posix/System
EnvironmentCompiler: lib/exe/cocl:-generics
EnvironmentCodeGen: lib/exe/cg
EnvironmentLinker: lib/exe/linker
EnvironmentDynLink: lib/exe/linker
EnvironmentVersion: 920
EnvironmentRedirect: False
EnvironmentCompileMethod: Pers
EnvironmentProcessor: I386
Environment64BitProcessor: True
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment