@@ -7,6 +7,8 @@ import Control.Monad.State
77import Data.Char (isUpper)
88import qualified Data.Set as Set
99import qualified Data.Map as Map
10+import qualified Language.GLSL.Parser as GLP
11+import Language.GLSL.Syntax
1012import SourceSyntax.Helpers as Help
1113import SourceSyntax.Location as Location
1214import SourceSyntax.Expression
@@ -324,3 +326,22 @@ glShader = try (string "[glShader|") >> closeShader "" where
324326 c <- anyChar
325327 closeShader (src ++ [c])
326328 ]
329+
330+data GLTipe = V3 | M4
331+
332+glSource :: String -> Maybe [(StorageQualifier, GLTipe, String)]
333+glSource src =
334+ case GLP.parse src of
335+ Right (TranslationUnit decls) ->
336+ Just . join . map extractGLinputs $ decls
337+ Left e -> Nothing
338+ where
339+ extractGLinputs decl = case decl of
340+ Declaration (InitDeclaration (TypeDeclarator (FullType (Just (TypeQualSto qual)) (TypeSpec _prec (TypeSpecNoPrecision tipe _mexpr1)))) [InitDecl name _mexpr2 _mexpr3]) ->
341+ if elem qual [Attribute, Varying, Uniform]
342+ then case tipe of
343+ Vec3 -> return (qual,V3,name)
344+ Mat4 -> return (qual,M4,name)
345+ _ -> []
346+ else []
347+ _ -> []