예제 #1
0
 internal SyntaxToken(SyntaxTree syntaxTree, TokenSlot slot, SyntaxNode parent, int position)
 {
     Position   = position;
     SyntaxTree = syntaxTree;
     Parent     = parent;
     Slot       = slot;
 }
예제 #2
0
        TokenSlot GetTokenSlot([CanBeNull] IToken terminalNode, SyntaxKind syntaxKind)
        {
            var extent = TextExtentFactory.CreateExtent(terminalNode);

            if (extent.IsMissing || !_tokens.ContainsKey(extent.Start))
            {
                // Auch wenn die GuiDeclarationSyntax nicht geparst werden kann,
                // muss dennoch immer das Eof Token angehängt werden.
                if (syntaxKind == SyntaxKind.Eof)
                {
                    var eofToken = _tokens.Values.Last();
                    if (eofToken.Kind == SyntaxKind.Eof)
                    {
                        return(eofToken);
                    }
                }

                return(TokenSlot.CreateMissingToken(kind: syntaxKind));
            }

            return(_tokens[extent.Start]);
        }
예제 #3
0
 internal SyntaxNodeOrToken([CanBeNull] SyntaxNode tokenParent, TokenSlot tokenSlot, int tokenPosition)
 {
     _nodeOrParent = tokenParent;
     _position     = tokenPosition;
     _tokenSlot    = tokenSlot;
 }
예제 #4
0
 internal SyntaxNodeOrToken([CanBeNull] SyntaxNode syntaxNode)
 {
     _nodeOrParent = syntaxNode;
     _position     = syntaxNode?.Position ?? default;
     _tokenSlot    = null;
 }