]> git.wincent.com - docvim.git/blob - lib/Docvim/Compile.hs
Prefer named imports
[docvim.git] / lib / Docvim / Compile.hs
1 module Docvim.Compile (compile) where
2
3 import Docvim.AST (Node(Project))
4 import Docvim.Visitor.Command (extractCommand)
5 import Docvim.Visitor.Commands (extractCommands)
6 import Docvim.Visitor.Footer (extractFooter)
7 import Docvim.Visitor.Function (extractFunction)
8 import Docvim.Visitor.Functions (extractFunctions)
9 import Docvim.Visitor.Mapping (extractMapping)
10 import Docvim.Visitor.Mappings (extractMappings)
11 import Docvim.Visitor.Option (extractOption)
12 import Docvim.Visitor.Options (extractOptions)
13 import Docvim.Visitor.Plugin (extractPlugin)
14 import Docvim.Visitor.Section ( injectCommands
15                               , injectFunctions
16                               , injectMappings
17                               , injectOptions
18                               )
19 import Docvim.Visitor (extract)
20
21 -- | "Compile" a set of translation units into a project.
22 compile :: [Node] -> Node
23 compile ns = do
24   let ast = foldr (\f x -> f x) (Project ns) [ injectCommands
25                                              , injectFunctions
26                                              , injectMappings
27                                              , injectOptions
28                                              ]
29   let (ast2, footer) = extract extractFooter ast
30   let (ast3, plugin) = extract extractPlugin ast2
31   let (ast4, commands) = extract extractCommands ast3
32   let (ast5, command) = extract extractCommand ast4
33   let (ast6, functions) = extract extractFunctions ast5
34   let (ast7, function) = extract extractFunction ast6
35   let (ast8, mappings) = extract extractMappings ast7
36   let (ast9, mapping) = extract extractMapping ast8
37   let (ast10, options) = extract extractOptions ast9
38   let (ast11, option) = extract extractOption ast10
39   let project = Project $ concat [ plugin
40                                  , [ast11]
41                                  , commands
42                                  , command
43                                  , mappings
44                                  , mapping
45                                  , options
46                                  , option
47                                  , functions
48                                  , function
49                                  , footer
50                                  ]
51   project