상속: AstNode
예제 #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
파일: Parser.cs 프로젝트: jonorossi/cvsi
        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;
        }