@@ -11,6 +11,7 @@ import qualified Data.Map as Map
11import qualified Language.GLSL.Parser as GLP
11import qualified Language.GLSL.Parser as GLP
12import Language.GLSL.Syntax
12import Language.GLSL.Syntax
13import SourceSyntax.Helpers as Help
13import SourceSyntax.Helpers as Help
14+import SourceSyntax.Literal as Literal
14import SourceSyntax.Location as Location
15import SourceSyntax.Location as Location
15import SourceSyntax.Expression
16import SourceSyntax.Expression
16import SourceSyntax.PrettyPrint
17import SourceSyntax.PrettyPrint
@@ -328,38 +329,31 @@ markdown interpolation = try (string "[markdown|") >> closeMarkdown "" []
328 closeMarkdown (md ++ [c]) stuff
329 closeMarkdown (md ++ [c]) stuff
331−glShader :: IParser String
332+glShader :: IParser (String, Literal.GLShaderTipe)
332−glShader = try (string "[glShader|") >> closeShader "" where
335+ rawSrc <- try (string "[glShader|") >> closeShader ""
336+ case glSource rawSrc of
337+ Left err -> parserFail . show $ err
338+ Right tipe -> return (rawSrc, tipe)
333 closeShader src = choice
340 closeShader src = choice
335− try (string "|]")
342+ try (string "|]")
336− return src
343+ return src
338− c <- anyChar
345+ c <- anyChar
339− closeShader (src ++ [c])
346+ closeShader (src ++ [c])
342−data GLTipe = V3 | M4
349+glSource :: String -> Either ParseError Literal.GLShaderTipe
344−glTipeName :: GLTipe -> String
345−glTipeName V3 = "MJS.V3"
346−glTipeName M4 = "MJS.M4x4"
348−data GLShaderDecls = GLShaderDecls
349− { attribute :: Map String GLTipe
350− , uniform :: Map String GLTipe
351− , varying :: Map String GLTipe
354−--glSource :: String -> Maybe [(StorageQualifier, GLTipe, String)]
355−glSource :: String -> Maybe GLShaderDecls
356glSource src =
350glSource src =
357 case GLP.parse src of
351 case GLP.parse src of
358 Right (TranslationUnit decls) ->
352 Right (TranslationUnit decls) ->
359− Just . foldr addGLinput emptyDecls . join . map extractGLinputs $ decls
353+ Right . foldr addGLinput emptyDecls . join . map extractGLinputs $ decls
360− Left e -> Nothing
354+ Left e -> Left e
362− emptyDecls = GLShaderDecls Map.empty Map.empty Map.empty
356+ emptyDecls = Literal.GLShaderTipe Map.empty Map.empty Map.empty
363 addGLinput (qual,tipe,name) glDecls = case qual of
357 addGLinput (qual,tipe,name) glDecls = case qual of
364 Attribute -> glDecls { attribute = Map.insert name tipe $ attribute glDecls }
358 Attribute -> glDecls { attribute = Map.insert name tipe $ attribute glDecls }
365 Uniform -> glDecls { uniform = Map.insert name tipe $ uniform glDecls }
359 Uniform -> glDecls { uniform = Map.insert name tipe $ uniform glDecls }