on master help sign in
thread (ForeignPtr Word8) through more parsers
commitbb0e3b115ccf05f2e7ab45197caa3ec5a1449743 authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 3 Jun 2019, 11:52 (7 years ago) parentcf8da7d
1 file changed+12−11
compiler/src/Parse/Variable.hs+12−11
compiler/src/Parse/Variable.hs+12−11
@@ -1,5 +1,5 @@
11{-# OPTIONS_GHC -Wall #-}
2−{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples, OverloadedStrings #-}
2+{-# LANGUAGE BangPatterns, MagicHash, OverloadedStrings, UnboxedTuples #-}
33module Parse.Variable
44 ( lower
55 , upper
@@ -8,6 +8,7 @@ module Parse.Variable
88 , foreignUpper
99 , foreignAlpha
1010 , chompInnerChars
11+ , getUpperWidth
1112 , getInnerWidth
1213 , getInnerWidthHelp
1314 , reservedWords
@@ -34,13 +35,13 @@ import qualified Parse.Primitives as P
3435
3536upper :: (Row -> Col -> x) -> Parser x Name.Name
3637upper toError =
37− P.Parser $ \(P.State pos end indent row col) cok _ _ eerr ->
38+ P.Parser $ \(P.State src pos end indent row col) cok _ _ eerr ->
3839 let (# newPos, newCol #) = chompUpper pos end col in
3940 if pos == newPos then
4041 eerr row col toError
4142 else
4243 let !name = Name.fromPtr pos newPos in
43− cok name (P.State newPos end indent row newCol)
44+ cok name (P.State src newPos end indent row newCol)
4445
4546
4647
@@ -49,7 +50,7 @@ upper toError =
4950
5051lower :: (Row -> Col -> x) -> Parser x Name.Name
5152lower toError =
52− P.Parser $ \(P.State pos end indent row col) cok _ _ eerr ->
53+ P.Parser $ \(P.State src pos end indent row col) cok _ _ eerr ->
5354 let (# newPos, newCol #) = chompLower pos end col in
5455 if pos == newPos then
5556 eerr row col toError
@@ -60,7 +61,7 @@ lower toError =
6061 else
6162 let
6263 !newState =
63− P.State newPos end indent row newCol
64+ P.State src newPos end indent row newCol
6465 in
6566 cok name newState
6667
@@ -86,7 +87,7 @@ reservedWords =
8687
8788moduleName :: (Row -> Col -> x) -> Parser x Name.Name
8889moduleName toError =
89− P.Parser $ \(P.State pos end indent row col) cok _ cerr eerr ->
90+ P.Parser $ \(P.State src pos end indent row col) cok _ cerr eerr ->
9091 let
9192 (# pos1, col1 #) = chompUpper pos end col
9293 in
@@ -100,7 +101,7 @@ moduleName toError =
100101 Good ->
101102 let
102103 !name = Name.fromPtr pos newPos
103− !newState = P.State newPos end indent row newCol
104+ !newState = P.State src newPos end indent row newCol
104105 in
105106 cok name newState
106107
@@ -140,13 +141,13 @@ data Upper
140141
141142foreignUpper :: (Row -> Col -> x) -> Parser x Upper
142143foreignUpper toError =
143− P.Parser $ \(P.State pos end indent row col) cok _ _ eerr ->
144+ P.Parser $ \(P.State src pos end indent row col) cok _ _ eerr ->
144145 let (# upperStart, upperEnd, newCol #) = foreignUpperHelp pos end col in
145146 if upperStart == upperEnd then
146147 eerr row newCol toError
147148 else
148149 let
149− !newState = P.State upperEnd end indent row newCol
150+ !newState = P.State src upperEnd end indent row newCol
150151 !name = Name.fromPtr upperStart upperEnd
151152 !foreign =
152153 if upperStart == pos then
@@ -179,13 +180,13 @@ foreignUpperHelp pos end col =
179180
180181foreignAlpha :: (Row -> Col -> x) -> Parser x Src.Expr_
181182foreignAlpha toError =
182− P.Parser $ \(P.State pos end indent row col) cok _ _ eerr ->
183+ P.Parser $ \(P.State src pos end indent row col) cok _ _ eerr ->
183184 let (# alphaStart, alphaEnd, newCol, varType #) = foreignAlphaHelp pos end col in
184185 if alphaStart == alphaEnd then
185186 eerr row newCol toError
186187 else
187188 let
188− !newState = P.State alphaEnd end indent row newCol
189+ !newState = P.State src alphaEnd end indent row newCol
189190 !name = Name.fromPtr alphaStart alphaEnd
190191 in
191192 if alphaStart == pos then