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