Skip to content

[#212] Implemented Chain operator in query engine metta parser#1072

Merged
andre-senna merged 3 commits intomasterfrom
senna-212-4
Apr 16, 2026
Merged

[#212] Implemented Chain operator in query engine metta parser#1072
andre-senna merged 3 commits intomasterfrom
senna-212-4

Conversation

@andre-senna
Copy link
Copy Markdown
Contributor

Resolves #212

Final PR in the scope of #212 implementing the changes in the Querey Engine's MeTTa parser. Now Chain operator can be used in any query either as tokens or as metta expressions.

There are examples in pattern_matching_query_test.cc but the MeTTa syntax for Chain is like this:

tokens_query = {
        "CHAIN", "1", "1", "2",
            "NODE", "Symbol", "\"chimp\"",
            "NODE", "Symbol", "\"ent\"",
            "AND", "2",
                "OR", "2",
                    "LINK_TEMPLATE", "Expression", "3",
                        "NODE", "Symbol", "Inheritance",
                        "VARIABLE", "v1",
                        "NODE", "Symbol", "\"mammal\"",
                    "LINK_TEMPLATE", "Expression", "3",
                        "NODE", "Symbol", "Inheritance",
                        "VARIABLE", "v2",
                        "NODE", "Symbol", "\"mammal\"",
                "LINK_TEMPLATE", "Expression", "3",
                    "NODE", "Symbol", "Similarity",
                    "VARIABLE", "v1",
                    "VARIABLE", "v2"
};
    
metta_query =  "(chain 1 1 2 \"chimp\" \"ent\" (and (or (Inheritance $v1 \"mammal\") (Inheritance $v2 \"mammal\")) (Similarity $v1 $v2)))";

@andre-senna andre-senna self-assigned this Apr 13, 2026
@andre-senna andre-senna requested review from arturgontijo, ccgsnet and eddiebrissow and removed request for arturgontijo April 13, 2026 21:28
Comment thread src/agents/query_engine/MettaParserActions.cc Outdated
Comment thread src/agents/query_engine/MettaParserActions.cc Outdated
Comment thread src/agents/query_engine/MettaParserActions.cc
Copy link
Copy Markdown
Collaborator

@ccgsnet ccgsnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (nitpicks only)

@andre-senna andre-senna merged commit f7f9a77 into master Apr 16, 2026
2 checks passed
@andre-senna andre-senna deleted the senna-212-4 branch April 16, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement CHAIN operator in the Query Agent's query tree

2 participants