@@ -24,12 +24,11 @@ import qualified AST.Source as Src
24import qualified Elm.ModuleName as ModuleName
24import qualified Elm.ModuleName as ModuleName
25import qualified Elm.Package as Pkg
25import qualified Elm.Package as Pkg
26import qualified Parse.Module as Module
26import qualified Parse.Module as Module
27+import qualified Parse.Space as Space
27import qualified Parse.Variable as Var
28import qualified Parse.Variable as Var
29−import Parse.Primitives hiding (Parser, fromByteString)
29+import Parse.Primitives hiding (fromByteString)
30import qualified Parse.Primitives as P
30import qualified Parse.Primitives as P
31import qualified Reporting.Annotation as A
31import qualified Reporting.Annotation as A
32−import qualified Reporting.Error.Syntax as E
@@ -87,35 +86,49 @@ type Foreigns =
87fromByteString :: Pkg.Name -> Foreigns -> BS.ByteString -> Maybe Content
86fromByteString :: Pkg.Name -> Foreigns -> BS.ByteString -> Maybe Content
88fromByteString pkg foreigns bytes =
87fromByteString pkg foreigns bytes =
89 case P.fromByteString (parser pkg foreigns) bytes of
88 case P.fromByteString (parser pkg foreigns) bytes of
90− P.Ok content _ -> Just content
89+ P.Ok content _ ->
91− P.Err _ _ _ _ -> Nothing
90+ Just content
94−parser :: Pkg.Name -> Foreigns -> Parser Content
96+parser :: Pkg.Name -> Foreigns -> Parser () Content
95parser pkg foreigns =
97parser pkg foreigns =
96− do word2 0x2F 0x2A {-/*-} E.XXX
98+ do word2 0x2F 0x2A {-/*-} toError
97− Module.freshLine
99+ Space.chomp ignoreError
100+ Space.checkFreshLine toError
98− imports <- Module.chompImports []
101+ imports <- specialize ignoreError (Module.chompImports [])
99− word2 0x2A 0x2F {-*/-} E.XXX
102+ word2 0x2A 0x2F {-*/-} toError
100 chunks <- parseChunks (toVarTable pkg foreigns imports) Map.empty Map.empty
103 chunks <- parseChunks (toVarTable pkg foreigns imports) Map.empty Map.empty
101 return (Content imports chunks)
104 return (Content imports chunks)
107+toError :: Row -> Col -> ()
112+ignoreError :: a -> Row -> Col -> ()
105-- PARSE CHUNKS
118-- PARSE CHUNKS
108−parseChunks :: VarTable -> Enums -> Fields -> Parser [Chunk]
121+parseChunks :: VarTable -> Enums -> Fields -> Parser () [Chunk]
109parseChunks vtable enums fields =
122parseChunks vtable enums fields =
110− P.Parser $ \(P.State pos end indent row col ctx) cok _ cerr _ ->
123+ P.Parser $ \(P.State pos end indent row col) cok _ cerr _ ->
112 (# chunks, newPos, newRow, newCol #) =
125 (# chunks, newPos, newRow, newCol #) =
113 chompChunks vtable enums fields pos end row col pos []
126 chompChunks vtable enums fields pos end row col pos []
115 if newPos == end then
128 if newPos == end then
116− cok chunks (P.State newPos end indent newRow newCol ctx)
129+ cok chunks (P.State newPos end indent newRow newCol)
118− cerr row col ctx E.XXX
131+ cerr row col toError
121chompChunks :: VarTable -> Enums -> Fields -> Ptr Word8 -> Ptr Word8 -> Word16 -> Word16 -> Ptr Word8 -> [Chunk] -> (# [Chunk], Ptr Word8, Word16, Word16 #)
134chompChunks :: VarTable -> Enums -> Fields -> Ptr Word8 -> Ptr Word8 -> Word16 -> Word16 -> Ptr Word8 -> [Chunk] -> (# [Chunk], Ptr Word8, Word16, Word16 #)