@@ -17,12 +17,12 @@ module Parse.Primitives.Variable
17import Control.Exception (assert)
17import Control.Exception (assert)
18import Data.Bits ((.&.), (.|.), shiftL)
18import Data.Bits ((.&.), (.|.), shiftL)
19import qualified Data.Char as Char
19import qualified Data.Char as Char
20+import qualified Data.Name as Name
20import qualified Data.Set as Set
21import qualified Data.Set as Set
21import Foreign.ForeignPtr (ForeignPtr)
22import Foreign.ForeignPtr (ForeignPtr)
22import GHC.Word (Word8)
23import GHC.Word (Word8)
24import qualified AST.Source as Src
25import qualified AST.Source as Src
25−import qualified Elm.Name as N
26import Parse.Primitives.Internals (Parser(..), State(..), expect, noError, unsafeIndex)
26import Parse.Primitives.Internals (Parser(..), State(..), expect, noError, unsafeIndex)
27import qualified Reporting.Error.Syntax as E
27import qualified Reporting.Error.Syntax as E
@@ -31,14 +31,14 @@ import qualified Reporting.Error.Syntax as E
31-- LOCAL UPPER
31-- LOCAL UPPER
34−upper :: Parser N.Name
34+upper :: Parser Name.Name
36 Parser $ \(State fp offset terminal indent row col ctx) cok _ _ eerr ->
36 Parser $ \(State fp offset terminal indent row col ctx) cok _ _ eerr ->
37 let (# newOffset, newCol #) = chompUpper fp offset terminal col in
37 let (# newOffset, newCol #) = chompUpper fp offset terminal col in
38 if offset == newOffset then
38 if offset == newOffset then
39 eerr (expect row col ctx E.CapVar)
39 eerr (expect row col ctx E.CapVar)
41− let !name = N.fromForeignPtr fp offset (newOffset - offset) in
41+ let !name = Name.fromByteString fp offset (newOffset - offset) in
42 cok name (State fp newOffset terminal indent row newCol ctx) noError
42 cok name (State fp newOffset terminal indent row newCol ctx) noError
@@ -46,14 +46,14 @@ upper =
46-- LOCAL LOWER
46-- LOCAL LOWER
49−lower :: Parser N.Name
49+lower :: Parser Name.Name
51 Parser $ \(State fp offset terminal indent row col ctx) cok _ _ eerr ->
51 Parser $ \(State fp offset terminal indent row col ctx) cok _ _ eerr ->
52 let (# newOffset, newCol #) = chompLower fp offset terminal col in
52 let (# newOffset, newCol #) = chompLower fp offset terminal col in
53 if offset == newOffset then
53 if offset == newOffset then
54 eerr (expect row col ctx E.LowVar)
54 eerr (expect row col ctx E.LowVar)
56− let !name = N.fromForeignPtr fp offset (newOffset - offset) in
56+ let !name = Name.fromByteString fp offset (newOffset - offset) in
57 if Set.member name reservedWords then
57 if Set.member name reservedWords then
58 eerr (expect row col ctx E.LowVar)
58 eerr (expect row col ctx E.LowVar)
@@ -61,7 +61,7 @@ lower =
63{-# NOINLINE reservedWords #-}
63{-# NOINLINE reservedWords #-}
64−reservedWords :: Set.Set N.Name
64+reservedWords :: Set.Set Name.Name
65reservedWords =
65reservedWords =
66 Set.fromList
66 Set.fromList
67 [ "if", "then", "else"
67 [ "if", "then", "else"
@@ -79,7 +79,7 @@ reservedWords =
79-- MODULE NAME
79-- MODULE NAME
82−moduleName :: Parser N.Name
82+moduleName :: Parser Name.Name
83moduleName =
83moduleName =
84 Parser $ \(State fp offset terminal indent row col ctx) cok _ _ eerr ->
84 Parser $ \(State fp offset terminal indent row col ctx) cok _ _ eerr ->
85 let (# newOffset, newCol #) = chompUpper fp offset terminal col in
85 let (# newOffset, newCol #) = chompUpper fp offset terminal col in
@@ -89,7 +89,7 @@ moduleName =
90 Good end endCol ->
90 Good end endCol ->
92− !name = N.fromForeignPtr fp offset (end - offset)
92+ !name = Name.fromByteString fp offset (end - offset)
93 !newState = State fp end terminal indent row endCol ctx
93 !newState = State fp end terminal indent row endCol ctx
95 cok name newState noError
95 cok name newState noError
@@ -119,8 +119,8 @@ moduleNameHelp fp offset terminal col =
121data Upper
121data Upper
122− = Unqualified N.Name
122+ = Unqualified Name.Name
123− | Qualified N.Name N.Name
123+ | Qualified Name.Name Name.Name
126foreignUpper :: Parser Upper
126foreignUpper :: Parser Upper
@@ -132,12 +132,12 @@ foreignUpper =
134 !newState = State fp end terminal indent row newCol ctx
134 !newState = State fp end terminal indent row newCol ctx
135− !name = N.fromForeignPtr fp start (end - start)
135+ !name = Name.fromByteString fp start (end - start)
136 !foreign =
136 !foreign =
137 if start == offset then
137 if start == offset then
138 Unqualified name
138 Unqualified name
140− let !home = N.fromForeignPtr fp offset ((start - 1) - offset) in
140+ let !home = Name.fromByteString fp offset ((start - 1) - offset) in
141 Qualified home name
141 Qualified home name
143 cok foreign newState noError
143 cok foreign newState noError
@@ -171,7 +171,7 @@ foreignAlpha =
173 !newState = State fp end terminal indent row newCol ctx
173 !newState = State fp end terminal indent row newCol ctx
174− !name = N.fromForeignPtr fp start (end - start)
174+ !name = Name.fromByteString fp start (end - start)
176 if start == offset then
176 if start == offset then
177 if Set.member name reservedWords then
177 if Set.member name reservedWords then
@@ -179,7 +179,7 @@ foreignAlpha =
180 cok (Src.Var varType name) newState noError
180 cok (Src.Var varType name) newState noError
182− let !home = N.fromForeignPtr fp offset ((start - 1) - offset) in
182+ let !home = Name.fromByteString fp offset ((start - 1) - offset) in
183 cok (Src.VarQual varType home name) newState noError
183 cok (Src.VarQual varType home name) newState noError