Пример #1
0
 public override AstNode GetNodeAt(int line, int pos)
 {
     //TODO add support for line detection
     foreach (NVSelector selector in _selectors)
     {
         NVSelector foundSelector = (NVSelector)selector.GetNodeAt(line, pos);
         if (foundSelector != null)
         {
             return(foundSelector);
         }
     }
     return(base.GetNodeAt(line, pos));
 }
Пример #2
0
        private NVReference ParseNVDesignator(Position startPosition)
        {
            // NVDesignator -> nvIdentifer { "." nvIdentifier [ NVActualParams ] }.

            NVReference nvReference;
            if (CurrentTokenType == TokenType.NVIdentifier)
            {
                nvReference = new NVReference(new NVDesignator(_scanner.CurrentToken.Image));
                nvReference.Position = new Position(startPosition, _scanner.CurrentPos);
                _scanner.GetToken();
            }
            else
            {
                AddError("Expected reference identifier");
                nvReference = new NVReference(new NVDesignator(""));
                nvReference.Position = new Position(startPosition, _scanner.CurrentPos);
                return nvReference;
            }

            while (CurrentTokenType == TokenType.NVDot)
            {
                Position startSelectorPosition = new Position(_scanner.CurrentPos.Start);
                Position dotPosition = new Position(_scanner.CurrentPos);
                _scanner.GetToken();

                if (CurrentTokenType == TokenType.NVIdentifier)
                {
                    Position endSelectorPosition = new Position(_scanner.CurrentPos.End);

                    NVSelector selector = new NVSelector(new NVMethodNode(
                        _scanner.CurrentToken.Image), nvReference);
                    _scanner.GetToken();

                    if (CurrentTokenType == TokenType.NVLParen)
                    {
                        selector.Actuals = ParseNVActualParams();
                        endSelectorPosition = new Position(_scanner.PreviousPos.Start);
                    }

                    selector.Position = new Position(startSelectorPosition, endSelectorPosition);

                    nvReference.Designator.Selectors.Add(selector);

                    nvReference.Position.End = new Position(endSelectorPosition);
                }
                else
                {
                    AddError("Expected identifier");

                    NVSelector selector = new NVSelector(new NVMethodNode("", null), nvReference);
                    selector.Position = new Position(dotPosition);
                    nvReference.Designator.Selectors.Add(selector);

                    nvReference.Position.End = new Position(selector.Position.End);

                    return nvReference;
                }
            }

            return nvReference;
        }