diff options
author | Ribhav Jain <ribhav.jain@mongodb.com> | 2020-07-29 06:47:02 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-04 21:35:48 +0000 |
commit | ee837757591fb1f5f4eecd324fd2a8fa56d3a8e4 (patch) | |
tree | 0955f3255f87094ef5ae8899a52625b7f1c8c1b7 /src/mongo/db/cst/bson_lexer.cpp | |
parent | b579403c660583fdf657ad379da235537fe2396b (diff) | |
download | mongo-ee837757591fb1f5f4eecd324fd2a8fa56d3a8e4.tar.gz |
SERVER-49831 Add support for base MatchExpression in grammar
Diffstat (limited to 'src/mongo/db/cst/bson_lexer.cpp')
-rw-r--r-- | src/mongo/db/cst/bson_lexer.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mongo/db/cst/bson_lexer.cpp b/src/mongo/db/cst/bson_lexer.cpp index 6e8c4088615..a5eaebcd9aa 100644 --- a/src/mongo/db/cst/bson_lexer.cpp +++ b/src/mongo/db/cst/bson_lexer.cpp @@ -291,7 +291,27 @@ void BSONLexer::tokenize(BSONElement elem, bool includeFieldName) { } } -BSONLexer::BSONLexer(std::vector<BSONElement> pipeline) { +BSONLexer::BSONLexer(BSONObj obj, PipelineParserGen::token_type startingToken) { + + _tokens.emplace_back(startingToken, getNextLoc()); + _tokens.emplace_back(PipelineParserGen::token::START_OBJECT, getNextLoc()); + for (auto&& elem : obj) { + // Include field names in the object. + tokenize(elem, true); + } + _tokens.emplace_back(PipelineParserGen::token::END_OBJECT, getNextLoc()); + + // Final token must indicate EOF. + _tokens.emplace_back(PipelineParserGen::make_END_OF_FILE(getNextLoc())); + + // Reset the position to use in yylex(). + _position = 0; +}; + +BSONLexer::BSONLexer(std::vector<BSONElement> pipeline, + PipelineParserGen::token_type startingToken) { + + _tokens.emplace_back(startingToken, getNextLoc()); _tokens.emplace_back(PipelineParserGen::token::START_ARRAY, getNextLoc()); for (auto&& elem : pipeline) { // Don't include field names for stages of the pipeline (aka indexes of the pipeline array). |