public static void Run(ParsingResult toParse, List<IDeclaration> builtinDeclarations = null)
 {
     var analysis = new HlslSemanticAnalysis(toParse);
     analysis.SetupHlslAnalyzer(builtinDeclarations);
     analysis.Run();
 }
        private static List<IDeclaration> ParseBuiltin(string builtins, string fileName)
        {
            var builtinDeclarations = new List<IDeclaration>();

            var result = HlslParser.TryPreProcessAndParse(builtins, fileName);

            // Check that we parse builtins successfully.
            var shader = ShaderParser.Check(result, fileName);

            foreach (var declaration in shader.Declarations)
            {
                var classType = declaration as ClassType;
                if (classType != null)
                {
                    classType.Name.Text = classType.Name.Text.Trim('_');
                    BuiltinObjects.Add(classType.Name.Text, classType);
                    classType.IsBuiltIn = true;
                }
                else if (declaration is IDeclaration)
                {
                    var methodDeclaration = declaration as MethodDeclaration;
                    if (methodDeclaration != null)
                        methodDeclaration.IsBuiltin = true;
                    builtinDeclarations.Add((IDeclaration)declaration);
                }
            }

            var tempAnalysis = new HlslSemanticAnalysis(result);
            tempAnalysis.Run();

            return builtinDeclarations;
        }