git @ Cat's Eye Technologies Fountain / 00b5876
Another step towards parsing initial values from the cmdline. Chris Pressey 2 years ago
3 changed file(s) with 14 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
9393
9494
9595 constructState :: [String] -> GenState
96 constructState _ = (Generating "" empty) -- FIXME
96 constructState initialParams = Generating "" (constructStore initialParams)
9797
9898 generateFrom :: Grammar -> GenState -> GenState
9999 generateFrom g state = revgen $ gen g state (production (startSymbol g) g)
147147
148148 parseFountain :: String -> Either ParseError Grammar
149149 parseFountain text = parse fountain "" text
150
151 parseConstConstraint :: String -> (Variable, Integer)
152 parseConstConstraint text = case parse unifyConst "" text of
153 Right (UnifyConst v i) -> (v, i)
22 import qualified Data.Map as Map
33
44 import Language.Fountain.Constraint
5 import Language.Fountain.Loader (parseConstConstraint) -- FIXME an unfortunate coupling
56
67
78 data Store = Store {
1415 fetch k st = Map.lookup k (table st)
1516 insert k v st = st{ table=Map.insert k v (table st), events=("insert":events st) }
1617 update f k st = st{ table=Map.update f k (table st), events=("update":events st) }
18
19 constructStore :: [String] -> Store
20 constructStore [] = empty
21 constructStore (constConstrainer:rest) =
22 let
23 (k, v) = parseConstConstraint constConstrainer
24 in
25 insert k v $ constructStore rest