Rename functions and modules
This commit is contained in:
parent
1ffaad1f5c
commit
640f98e7d5
2 changed files with 15 additions and 8 deletions
|
@ -59,7 +59,7 @@ Library
|
|||
Parse.Helpers,
|
||||
Parse.Literal,
|
||||
Parse.Module,
|
||||
Parse.Parser,
|
||||
Parse.Parse,
|
||||
Parse.Pattern,
|
||||
Parse.Type,
|
||||
Type.Constrain.Declaration,
|
||||
|
@ -126,7 +126,7 @@ Executable elm
|
|||
Parse.Helpers,
|
||||
Parse.Literal,
|
||||
Parse.Module,
|
||||
Parse.Parser,
|
||||
Parse.Parse,
|
||||
Parse.Pattern,
|
||||
Parse.Type,
|
||||
Type.Constrain.Declaration,
|
||||
|
@ -184,6 +184,7 @@ Executable elm-doc
|
|||
pretty,
|
||||
cmdargs,
|
||||
filepath,
|
||||
union-find,
|
||||
indents
|
||||
|
||||
Test-Suite test-elm
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
module Parse.Parser (parseProgram) where
|
||||
module Parse.Parse (program, dependencies) where
|
||||
|
||||
import SourceSyntax.Module
|
||||
import Control.Applicative ((<$>), (<*>))
|
||||
import Control.Monad
|
||||
import Data.Char (isSymbol, isDigit)
|
||||
|
@ -8,6 +7,7 @@ import Data.List (foldl',intercalate)
|
|||
import Text.Parsec hiding (newline,spaces)
|
||||
import qualified Text.PrettyPrint as P
|
||||
|
||||
import qualified SourceSyntax.Module as S
|
||||
import Parse.Helpers
|
||||
import Parse.Binop (infixStmt, OpTable)
|
||||
import Parse.Expression
|
||||
|
@ -22,17 +22,23 @@ freshDef = commitIf (freshLine >> (letter <|> char '_')) $ do
|
|||
decls = do d <- Decl.declaration <?> "at least one datatype or variable definition"
|
||||
(d:) <$> many freshDef
|
||||
|
||||
program = do
|
||||
program :: String -> Either [P.Doc] (S.Module t v)
|
||||
program = setupParser $ do
|
||||
optional freshLine
|
||||
(names,exports) <- option (["Main"],[]) (moduleDef `followedBy` freshLine)
|
||||
is <- (do try (lookAhead $ reserved "import")
|
||||
imports `followedBy` freshLine) <|> return []
|
||||
declarations <- decls
|
||||
optional freshLine ; optional spaces ; eof
|
||||
return $ Module names exports is declarations
|
||||
return $ S.Module names exports is declarations
|
||||
|
||||
parseProgram :: String -> Either [P.Doc] (Module t v)
|
||||
parseProgram = setupParser program
|
||||
dependencies :: String -> Either [P.Doc] (String, [String])
|
||||
dependencies =
|
||||
let getName = intercalate "." . fst in
|
||||
setupParser $ do
|
||||
optional freshLine
|
||||
(,) <$> option "Main" (getName <$> moduleDef `followedBy` freshLine)
|
||||
<*> option [] (map fst <$> imports `followedBy` freshLine)
|
||||
|
||||
setupParser :: IParser a -> String -> Either [P.Doc] a
|
||||
setupParser p source =
|
||||
|
|
Loading…
Reference in a new issue