Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'compiler-refactor' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
NorfairKing committed Feb 9, 2016
2 parents 6e5e363 + 1769579 commit 856f62f
Show file tree
Hide file tree
Showing 56 changed files with 1,359 additions and 556 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@ spark
dist
cabal-dev
*.o
*.tix
*.hi
*.chi
*.chs.h
Expand Down
30 changes: 30 additions & 0 deletions doc/technical-details.md
@@ -0,0 +1,30 @@
---
title: Technical Details
---

```
| parse | compile | predeploy -> deploy -> check
-------------+-------------+------------------------------------------
IO part | read file | find files
non- IO part | parse AST | compile to deployments
```

# Stages
## Parse
IO part: read file
non-IO part: parse string into AST

## Compile
IO part: find files recursively
non-IO part: Compile into deployments

The only product of compilation is a list of deployments.
Because the compilation is entirely modular, the IO part can be separated entirely.
Compilation of a given compilation unit given a compilation scope can be entirely pure.
It will either return a finished list of deployments or a Filepath leading to the next unit to compile.

## Predeploy

## PostDeploy

## Check
1 change: 0 additions & 1 deletion examples/complex.sus
Expand Up @@ -30,6 +30,5 @@ card poems {
}
{
kind link
"
}
}
46 changes: 12 additions & 34 deletions makefile
@@ -1,40 +1,12 @@
NAME = spark
SRC = $(SRC_DIR)/Main.hs
BIN = $(NAME)
aGll: build test

SRC_DIR = src
TEST_DIR = test

GHC = ghc
GHC_OPTIMISATION = -O2

GHC_FLAGS = \
-fwarn-unused-imports \
-fwarn-incomplete-patterns \
-Wall \
-fno-warn-unused-do-bind \
-fno-warn-name-shadowing
GHC_SRC_DIRS = \
-i$(SRC_DIR) \
-ibenchmarks \
-i$(TEST_DIR)
GHC_OPTIONS = \
-threaded \
$(GHC_OPTIMISATION) \
$(GHC_FLAGS) \
$(GHC_SRC_DIRS)



all: bin test

build:
build: FORCE
stack build

test:
test: FORCE
stack test --test-arguments="--seed=42" # No flaky tests!

install:
install: FORCE
stack install

pedantic:
Expand All @@ -52,13 +24,19 @@ pedantic:
-fwarn-incomplete-patterns \
-fwarn-unused-do-bind \
-fno-warn-name-shadowing \
-fno-warn-orphans"

-fno-warn-overlapping-patterns \
-fno-warn-orphans" \
--test \
--test-arguments="\
--dry-run \
"\

love:
@echo "not war"

DIRTY_EXT = *.o *.hi *.bin

FORCE:

clean:
rm -f $(BIN) $(DIRTY_EXT)
2 changes: 1 addition & 1 deletion scripts/test.sh
@@ -1,2 +1,2 @@
source scripts/lib.sh
check "Test" make test
check "Test" make -B test
Binary file removed spark_test
Binary file not shown.
24 changes: 13 additions & 11 deletions src/Arguments.hs
Expand Up @@ -3,6 +3,7 @@ module Arguments where
import Options.Applicative
import System.Environment (getArgs)

import Config
import Dispatch.Types
import Types
import Utils
Expand All @@ -21,7 +22,7 @@ transformOptions (dispatch, go) = (,) <$> pure dispatch <*> configFromOptions go
configFromOptions :: GlobalOptions -> Either String SparkConfig
configFromOptions go = Right conf
where
conf = Config {
conf = defaultConfig {
conf_format_lineUp = if opt_compress go then False else opt_lineUp go
, conf_format_indent = if opt_compress go then 0 else opt_indent go
, conf_format_trailingNewline = if opt_compress go then False else opt_trailingNewline go
Expand All @@ -32,8 +33,8 @@ configFromOptions go = Right conf
, conf_compile_kind = opt_kind go
, conf_compile_override = opt_overrride go
, conf_check_thoroughness = opt_thoroughness go
, conf_deploy_replace_links = opt_replace_links go || opt_replace go
, conf_deploy_replace_files = opt_replace_files go || opt_replace go
, conf_deploy_replace_links = opt_replace_links go || opt_replace go
, conf_deploy_replace_files = opt_replace_files go || opt_replace go
, conf_deploy_replace_directories = opt_replace_directories go || opt_replace go
, conf_debug = opt_debug go
}
Expand All @@ -47,11 +48,11 @@ getOptions = do
runOptionsParser :: [String] -> ParserResult Options
runOptionsParser strs = execParserPure prefs optionsParser strs
where prefs = ParserPrefs {
prefMultiSuffix = "SPARK" -- ^ metavar suffix for multiple options
, prefDisambiguate = True -- ^ automatically disambiguate abbreviations (default: False)
, prefShowHelpOnError = True -- ^ always show help text on parse errors (default: False)
, prefBacktrack = True -- ^ backtrack to parent parser when a subcommand fails (default: True)
, prefColumns = 80 -- ^ number of columns in the terminal, used to format the help page (default: 80)
prefMultiSuffix = "SPARK" -- metavar suffix for multiple options
, prefDisambiguate = True -- automatically disambiguate abbreviations (default: False)
, prefShowHelpOnError = True -- always show help text on parse errors (default: False)
, prefBacktrack = True -- backtrack to parent parser when a subcommand fails (default: True)
, prefColumns = 80 -- number of columns in the terminal, used to format the help page (default: 80)
}

optionsParser :: ParserInfo Options
Expand Down Expand Up @@ -148,9 +149,9 @@ parseGlobalOptions = GlobalOptions
<*> option auto
( long "format"
<> short 'f'
<> value FormatText
<> value FormatJson
<> metavar "FORMAT"
<> help "Compilation format" )
<> help "Compilation format default: json" )
<*> option (Just <$> auto)
( long "kind"
<> short 'k'
Expand Down Expand Up @@ -188,4 +189,5 @@ parseGlobalOptions = GlobalOptions
)
<*> switch
( long "debug"
<> help "Show al debug information." )
<> help "Show al debug information."
)

0 comments on commit 856f62f

Please sign in to comment.