Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
            }