Пример #1
0
 public void Handle(QueryParser parser, QueryTokenizer tokenizer, Query query)
 {
     if (tokenizer.Type == QueryTokenizer.TokenType.StatementTerminator)
     {
         if (CurrentTermGroup.stackCount > 2)
         {
             ReportPattern(query);
             SucceedingPatternTermsAreNotRequired();
         }
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.ValueDelimiter)
     {
         ReportPatternRetainSubjectAndPredicate(query);
         SucceedingPatternTermsAreNotRequired();
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.PredicateDelimiter)
     {
         ReportPatternRetainSubject(query);
         SucceedingPatternTermsAreNotRequired();
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.LiteralLanguage)
     {
         PatternTerm member = CurrentTermGroup.popGraphMember();
         CurrentTermGroup.pushGraphMember(new PlainLiteral(member.GetLabel(), tokenizer.TokenText));
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.LiteralDatatype)
     {
         PatternTerm member = CurrentTermGroup.popGraphMember();
         CurrentTermGroup.pushGraphMember(new TypedLiteral(member.GetLabel(), tokenizer.TokenText));
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.KeywordFilter)
     {
         EndTermGroup(query);
         ParseFilter(tokenizer, PatternGroup);
         StartTermGroup( );
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.BeginGeneratedBlankNode)
     {
         BlankNode node = new BlankNode();
         CurrentTermGroup.pushGraphMember(node);
         StartBlankNodeGroup();
         CurrentTermGroup.pushGraphMember(node);
     }
     else if (tokenizer.Type == QueryTokenizer.TokenType.EndGeneratedBlankNode)
     {
         EndTermGroup(query);
     }
     else
     {
         PatternTerm subjectMember = parser.ParseTokenToMember(query);
         CurrentTermGroup.pushGraphMember(subjectMember);
         SucceedingPatternTermsAreRequired();
     }
 }
Пример #2
0
            public void ReportPatternRetainSubject(Query query)
            {
                PatternTerm valueMember     = CurrentTermGroup.popGraphMember();
                PatternTerm predicateMember = CurrentTermGroup.popGraphMember();
                PatternTerm subjectMember   = CurrentTermGroup.popGraphMember();

                Pattern pattern = new Pattern(subjectMember, predicateMember, valueMember);

                PatternGroup.AddPattern(pattern);

                CurrentTermGroup.pushGraphMember(subjectMember);
            }
Пример #3
0
            public void ReportPattern(Query query)
            {
                if (Explain)
                {
                    Console.WriteLine("Reporting a new pattern");
                }
                PatternTerm valueMember     = CurrentTermGroup.popGraphMember();
                PatternTerm predicateMember = CurrentTermGroup.popGraphMember();
                PatternTerm subjectMember   = CurrentTermGroup.popGraphMember();

                Pattern pattern = new Pattern(subjectMember, predicateMember, valueMember);

                if (Explain)
                {
                    Console.WriteLine("Pattern is " + pattern);
                }
                PatternGroup.AddPattern(pattern);
            }