コード例 #1
0
 public virtual void VisitShaderProperties(ShaderPropertiesSyntax node)
 {
     DefaultVisit(node);
 }
コード例 #2
0
ファイル: SyntaxVisitor.cs プロジェクト: tgjones/HlslTools
 public virtual void VisitShaderProperties(ShaderPropertiesSyntax node)
 {
     DefaultVisit(node);
 }
コード例 #3
0
        private ShaderSyntax ParseUnityShader()
        {
            var shaderKeyword  = Match(SyntaxKind.ShaderKeyword);
            var nameToken      = Match(SyntaxKind.StringLiteralToken);
            var openBraceToken = Match(SyntaxKind.OpenBraceToken);

            ShaderPropertiesSyntax properties = null;

            if (Current.Kind == SyntaxKind.PropertiesKeyword)
            {
                properties = ParseUnityShaderProperties();
            }

            CgIncludeSyntax cgInclude = null;

            if (Current.Kind == SyntaxKind.CgIncludeKeyword)
            {
                cgInclude = ParseUnityCgInclude();
            }

            var statements = new List <SyntaxNode>();

            while (Current.Kind == SyntaxKind.SubShaderKeyword || Current.Kind == SyntaxKind.CategoryKeyword)
            {
                switch (Current.Kind)
                {
                case SyntaxKind.SubShaderKeyword:
                    statements.Add(ParseUnitySubShader());
                    break;

                case SyntaxKind.CategoryKeyword:
                    statements.Add(ParseUnityCategory());
                    break;
                }
            }

            var stateProperties = new List <CommandSyntax>();
            var shouldContinue  = true;

            while (shouldContinue && Current.Kind != SyntaxKind.CloseBraceToken)
            {
                switch (Current.Kind)
                {
                case SyntaxKind.FallbackKeyword:
                    stateProperties.Add(ParseUnityFallback());
                    break;

                case SyntaxKind.CustomEditorKeyword:
                    stateProperties.Add(ParseUnityCustomEditor());
                    break;

                case SyntaxKind.DependencyKeyword:
                    stateProperties.Add(ParseUnityDependency());
                    break;

                default:
                    shouldContinue = false;
                    break;
                }
            }

            var closeBraceToken = Match(SyntaxKind.CloseBraceToken);

            return(new ShaderSyntax(
                       shaderKeyword,
                       nameToken,
                       openBraceToken,
                       properties,
                       cgInclude,
                       statements,
                       stateProperties,
                       closeBraceToken));
        }