Skip to content

Conversation

@h3n4l
Copy link
Member

@h3n4l h3n4l commented Jan 20, 2026

Summary

  • Extend the MongoDB Shell parser grammar to recognize all mongosh commands
  • Add 300+ test files covering all command categories
  • Grammar is permissive to support future translator implementations

Grammar Additions

Category Methods Description
Collection methods 48 find, insertOne, updateMany, aggregate, createIndex, etc.
Cursor methods 34 sort, limit, skip, forEach, toArray, hint, maxTimeMS, etc.
Database methods 39 createCollection, dropDatabase, stats, serverStatus, etc.
Bulk operations 21 initializeOrderedBulkOp, Bulk.find, Bulk.insert, etc.
Connection methods 16 Mongo(), connect(), getDB, setReadPref, etc.
Replication (rs.) 14 rs.status, rs.initiate, rs.add, rs.reconfig, etc.
Sharding (sh.) 52 sh.status, sh.enableSharding, sh.shardCollection, etc.
User management 12 createUser, dropUser, auth, etc.
Role management 10 createRole, dropRole, grantRolesToUser, etc.
Encryption 17 KeyVault, ClientEncryption via db.getMongo()
Native functions 16 cat, load, quit, pwd, sleep, etc.
Object constructors 18 ObjectId, ISODate, UUID, BinData, Binary, etc.
Query plan cache 5 db.collection.getPlanCache().list/clear/etc.
Atlas-specific 13 Search Index (4), Stream Processing sp.* (9)

Test plan

  • All 306 test files pass
  • Parser regenerates successfully with make build
  • make test passes

🤖 Generated with Claude Code

Extend the MongoDB Shell parser grammar to recognize all mongosh commands
with comprehensive test coverage.

Grammar additions:
- Collection methods: write operations, index/schema management
- Database methods: createCollection, dropDatabase, stats, serverStatus, etc.
- Cursor methods: batchSize, collation, hint, maxTimeMS, toArray, etc.
- Bulk operations: initializeOrderedBulkOp, Bulk.find, Bulk.insert, etc.
- Connection methods: Mongo(), connect(), getDB, setReadPref, etc.
- Replication methods: rs.status, rs.initiate, rs.add, rs.reconfig, etc.
- Sharding methods: sh.status, sh.enableSharding, sh.shardCollection, etc.
- Encryption methods: KeyVault, ClientEncryption via db.getMongo()
- Native shell functions: cat, load, quit, pwd, sleep, etc.
- Query plan cache: db.collection.getPlanCache().list/clear/etc.
- Atlas-specific: Search Index methods, Stream Processing (sp.*)
- Object constructors: BinData, Binary, BSONRegExp, HexData

Test files: 300+ test files covering all command categories

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 20, 2026 07:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the MongoDB Shell parser grammar to recognize all mongosh commands, transforming it from a basic parser to a comprehensive one supporting 300+ commands across 14 categories. The grammar is intentionally permissive to allow for future translator implementations.

Changes:

  • Extended grammar to support 300+ mongosh commands across collection operations, cursor methods, database administration, bulk operations, connections, replication, sharding, encryption, and Atlas-specific features
  • Added comprehensive test coverage with 306 test files organized by command category
  • Regenerated parser files from updated ANTLR grammar

Reviewed changes

Copilot reviewed 299 out of 301 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mongodb/mongoshellparser_listener.go Added 138 new Enter/Exit method pairs for grammar productions supporting all command categories
mongodb/mongoshellparser_base_visitor.go Added 152 visitor methods for new grammar productions
mongodb/mongoshellparser_base_listener.go Added 152 listener methods for new grammar productions
mongodb/mongoshell_lexer.go Extended lexer with 97 new tokens for MongoDB commands and keywords
mongodb/examples/sp-stop.js Test file for stream processor stop command
mongodb/examples/sp-start.js Test file for stream processor start command
mongodb/examples/sp-sample.js Test file for stream processor sample command
mongodb/examples/sp-processor.js Test file for stream processor access patterns
mongodb/examples/sp-process.js Test file for inline stream processing pipeline
mongodb/examples/sp-listStreamProcessors.js Test file for listing stream processors
mongodb/examples/sh-transitionToDedicatedConfigServer.js Test file for sharding config server transition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rebelice rebelice merged commit a57d4b6 into main Jan 20, 2026
5 checks passed
@rebelice rebelice deleted the vk/0c2e-mongodb-parser-m branch January 20, 2026 08:03
h3n4l added a commit that referenced this pull request Jan 21, 2026
Extend the MongoDB Shell parser grammar to recognize all mongosh commands
with comprehensive test coverage.

Grammar additions:
- Collection methods: write operations, index/schema management
- Database methods: createCollection, dropDatabase, stats, serverStatus, etc.
- Cursor methods: batchSize, collation, hint, maxTimeMS, toArray, etc.
- Bulk operations: initializeOrderedBulkOp, Bulk.find, Bulk.insert, etc.
- Connection methods: Mongo(), connect(), getDB, setReadPref, etc.
- Replication methods: rs.status, rs.initiate, rs.add, rs.reconfig, etc.
- Sharding methods: sh.status, sh.enableSharding, sh.shardCollection, etc.
- Encryption methods: KeyVault, ClientEncryption via db.getMongo()
- Native shell functions: cat, load, quit, pwd, sleep, etc.
- Query plan cache: db.collection.getPlanCache().list/clear/etc.
- Atlas-specific: Search Index methods, Stream Processing (sp.*)
- Object constructors: BinData, Binary, BSONRegExp, HexData

Test files: 300+ test files covering all command categories

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.

3 participants