on master help sign in
cosmetic: add vertical whitespace
aae0428Evan Czaplicki
src/Parse/Helpers.hs+21
@@ -22,6 +22,7 @@ import qualified Reporting.Error.Syntax as Syntax
22import qualified Reporting.Region as R
22import qualified Reporting.Region as R
23
23
24
24
25+
25reserveds :: [String]
26reserveds :: [String]
26reserveds =
27reserveds =
27 [ "if", "then", "else"
28 [ "if", "then", "else"
@@ -35,13 +36,17 @@ reserveds =
35 ]
36 ]
36
37
37
38
39+
38-- ERROR HELP
40-- ERROR HELP
39
41
42+
40expecting = flip (<?>)
43expecting = flip (<?>)
41
44
42
45
46+
43-- SETUP
47-- SETUP
44
48
49+
45type OpTable = Map.Map String (Int, Decl.Assoc)
50type OpTable = Map.Map String (Int, Decl.Assoc)
46type SourceM = State SourcePos
51type SourceM = State SourcePos
47type IParser a = ParsecT String OpTable SourceM a
52type IParser a = ParsecT String OpTable SourceM a
@@ -105,8 +110,10 @@ reserved word =
105 return word
110 return word
106
111
107
112
113+
108-- INFIX OPERATORS
114-- INFIX OPERATORS
109
115
116+
110anyOp :: IParser String
117anyOp :: IParser String
111anyOp =
118anyOp =
112 betwixt '`' '`' qualifiedVar
119 betwixt '`' '`' qualifiedVar
@@ -123,8 +130,10 @@ symOp =
123 _ -> return op
130 _ -> return op
124
131
125
132
133+
126-- COMMON SYMBOLS
134-- COMMON SYMBOLS
127
135
136+
128equals :: IParser String
137equals :: IParser String
129equals =
138equals =
130 string "=" <?> "an equals sign '='"
139 string "=" <?> "an equals sign '='"
@@ -147,8 +156,10 @@ commitIf check p =
147 try (lookAhead check) >> p
156 try (lookAhead check) >> p
148
157
149
158
159+
150-- SEPARATORS
160-- SEPARATORS
151
161
162+
152spaceySepBy1 :: IParser b -> IParser a -> IParser [a]
163spaceySepBy1 :: IParser b -> IParser a -> IParser [a]
153spaceySepBy1 sep parser =
164spaceySepBy1 sep parser =
154 do value <- parser
165 do value <- parser
@@ -216,8 +227,10 @@ constrainedSpacePrefix parser constraint =
216 indented
227 indented
217
228
218
229
230+
219-- SURROUNDED BY
231-- SURROUNDED BY
220
232
233+
221followedBy a b =
234followedBy a b =
222 do x <- a
235 do x <- a
223 b
236 b
@@ -255,8 +268,10 @@ brackets =
255 surround '{' '}' "bracket"
268 surround '{' '}' "bracket"
256
269
257
270
271+
258-- HELPERS FOR EXPRESSIONS
272-- HELPERS FOR EXPRESSIONS
259
273
274+
260getMyPosition :: IParser R.Position
275getMyPosition :: IParser R.Position
261getMyPosition =
276getMyPosition =
262 R.fromSourcePos <$> getPosition
277 R.fromSourcePos <$> getPosition
@@ -307,8 +322,10 @@ dot =
307 notFollowedBy (char '.')
322 notFollowedBy (char '.')
308
323
309
324
325+
310-- WHITESPACE
326-- WHITESPACE
311
327
328+
312padded :: IParser a -> IParser a
329padded :: IParser a -> IParser a
313padded p =
330padded p =
314 do whitespace
331 do whitespace
@@ -417,8 +434,10 @@ closeComment =
417 ]
434 ]
418
435
419
436
437+
420-- ODD COMBINATORS
438-- ODD COMBINATORS
421
439
440+
422failure msg = do
441failure msg = do
423 inp <- getInput
442 inp <- getInput
424 setInput ('x':inp)
443 setInput ('x':inp)
@@ -492,8 +511,10 @@ anyUntilPos pos =
492 else (:) <$> anyChar <*> anyUntilPos pos
511 else (:) <$> anyChar <*> anyUntilPos pos
493
512
494
513
514+
495-- BASIC LANGUAGE LITERALS
515-- BASIC LANGUAGE LITERALS
496
516
517+
497shader :: IParser (String, L.GLShaderTipe)
518shader :: IParser (String, L.GLShaderTipe)
498shader =
519shader =
499 do try (string "[glsl|")
520 do try (string "[glsl|")