ParseMongoShell parses a MongoDB shell script and returns parsed statements with their ASTs. Conforms to the standard ParseStatementsFunc interface. The omni parser recovers from syntax errors by skipping to the next statement boundary. When at least one statement parses successfully, this function
(statement string)
| 44 | // returns the partial results with a nil error. A non-nil error is returned |
| 45 | // only when no statements could be parsed at all. |
| 46 | func ParseMongoShell(statement string) ([]base.ParsedStatement, error) { |
| 47 | stmts, err := mongo.Parse(statement) |
| 48 | if err != nil { |
| 49 | return nil, err |
| 50 | } |
| 51 | return convertStatements(statement, stmts), nil |
| 52 | } |
| 53 | |
| 54 | // ParseMongoShellBestEffort parses a MongoDB shell script and returns as many |
| 55 | // successfully parsed statements as possible, along with any parse errors. |