@@ -22,6 +22,7 @@ import qualified Reporting.Error.Syntax as Syntax
22import qualified Reporting.Region as R
22import qualified Reporting.Region as R
25reserveds :: [String]
26reserveds :: [String]
26reserveds =
27reserveds =
27 [ "if", "then", "else"
28 [ "if", "then", "else"
@@ -35,13 +36,17 @@ reserveds =
38-- ERROR HELP
40-- ERROR HELP
40expecting = flip (<?>)
43expecting = flip (<?>)
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
108-- INFIX OPERATORS
114-- INFIX OPERATORS
110anyOp :: IParser String
117anyOp :: IParser String
112 betwixt '`' '`' qualifiedVar
119 betwixt '`' '`' qualifiedVar
@@ -123,8 +130,10 @@ symOp =
123 _ -> return op
130 _ -> return op
126-- COMMON SYMBOLS
134-- COMMON SYMBOLS
128equals :: IParser String
137equals :: IParser String
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
150-- SEPARATORS
160-- SEPARATORS
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 =
219-- SURROUNDED BY
231-- SURROUNDED BY
221followedBy a b =
234followedBy a b =
222 do x <- a
235 do x <- a
@@ -255,8 +268,10 @@ brackets =
255 surround '{' '}' "bracket"
268 surround '{' '}' "bracket"
258-- HELPERS FOR EXPRESSIONS
272-- HELPERS FOR EXPRESSIONS
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 '.')
310-- WHITESPACE
326-- WHITESPACE
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 =
420-- ODD COMBINATORS
438-- ODD COMBINATORS
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
495-- BASIC LANGUAGE LITERALS
515-- BASIC LANGUAGE LITERALS
497shader :: IParser (String, L.GLShaderTipe)
518shader :: IParser (String, L.GLShaderTipe)
499 do try (string "[glsl|")
520 do try (string "[glsl|")