ShaderTools.Hlsl.Parser.HlslLexer.LexSingleDirective C# (CSharp) Method

LexSingleDirective() private method

private LexSingleDirective ( bool isActive, bool endIsActive, bool afterNonWhitespaceOnLine, List triviaList ) : SyntaxNode
isActive bool
endIsActive bool
afterNonWhitespaceOnLine bool
triviaList List
return SyntaxNode
        private SyntaxNode LexSingleDirective(
            bool isActive,
            bool endIsActive,
            bool afterNonWhitespaceOnLine,
            List<SyntaxNode> triviaList)
        {
            _start = _charReader.Position;

            if (char.IsWhiteSpace(_charReader.Current))
            {
                ReadWhitespace();
                AddTrivia(triviaList, SyntaxKind.WhitespaceTrivia);
            }

            var saveMode = _mode;
            var saveExpandMacros = ExpandMacros;

            _mode = LexerMode.Directive;
            ExpandMacros = false;

            var dp = new DirectiveParser(this, _directives);
            var directive = dp.ParseDirective(isActive, endIsActive, afterNonWhitespaceOnLine);

            if (!isActive || directive.Kind != SyntaxKind.IncludeDirectiveTrivia)
                triviaList.Add(directive);

            _directives = directive.ApplyDirectives(_directives);
            ExpandMacros = saveExpandMacros;
            _mode = saveMode;

            // Directive parser sometimes leaves charReader at start of token *after* the one we want.
            _charReader.Reset(directive.GetLastChildToken().GetLastSpanIncludingTrivia().End);
            _start = _charReader.Position;

            return directive;
        }