bson-transpilers
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -13,2 +13,3 @@ /* eslint complexity: 0, camelcase: 0, "new-cap": 0 */ | ||
const { removeQuotes } = require('../helper/format'); | ||
const DeclarationStore = require('./DeclarationStore'); | ||
@@ -28,2 +29,3 @@ /** | ||
this.clearImports(); | ||
this.state = { declarations: new DeclarationStore() }; | ||
} | ||
@@ -58,2 +60,10 @@ | ||
returnResultWithDeclarations(ctx) { | ||
let result = this.returnResult(ctx); | ||
if (this.getState().declarations.length() > 0) { | ||
result = `${this.getState().declarations.toString() + '\n\n'}${result}`; | ||
} | ||
return result; | ||
} | ||
/** | ||
@@ -64,8 +74,17 @@ * PUBLIC: This is the entry point for the compiler. Each visitor must define | ||
* @param {ParserRuleContext} ctx | ||
* @param {Boolean} useDeclarations - prepend the result string with declarations | ||
* @return {String} | ||
*/ | ||
start(ctx) { | ||
return this.returnResult(ctx).trim(); | ||
start(ctx, useDeclarations = false) { | ||
return (useDeclarations ? this.returnResultWithDeclarations(ctx) : this.returnResult(ctx)).trim(); | ||
} | ||
getState() { | ||
return this.state; | ||
} | ||
clearDeclarations() { | ||
this.getState().declarations.clear(); | ||
} | ||
/** | ||
@@ -337,3 +356,3 @@ * PUBLIC: As code is generated, any classes that require imports are tracked | ||
if (lhsType.argsTemplate) { | ||
rhs = lhsType.argsTemplate(l, ...rhs); | ||
rhs = lhsType.argsTemplate.bind(this.getState())(l, ...rhs); | ||
} else { | ||
@@ -502,3 +521,3 @@ rhs = `(${rhs.join(', ')})`; | ||
const rhs = lhsType.argsTemplate | ||
? lhsType.argsTemplate(lhsArg, ...args) | ||
? lhsType.argsTemplate.bind(this.getState())(lhsArg, ...args) | ||
: defaultA; | ||
@@ -525,3 +544,3 @@ const lhs = skipLhs ? '' : lhsArg; | ||
if (ctx.type.argsTemplate) { | ||
args = ctx.type.argsTemplate( | ||
args = ctx.type.argsTemplate.bind(this.getState())( | ||
this.getKeyValueList(ctx).map((k) => { | ||
@@ -536,3 +555,3 @@ return [this.getKeyStr(k), this.visit(this.getValue(k))]; | ||
if (ctx.type.template) { | ||
return ctx.type.template(args, ctx.indentDepth); | ||
return ctx.type.template.bind(this.getState())(args, ctx.indentDepth); | ||
} | ||
@@ -556,3 +575,3 @@ return this.visitChildren(ctx); | ||
const last = !visitedElements[index + 1]; | ||
return ctx.type.argsTemplate(arg, ctx.indentDepth, last); | ||
return ctx.type.argsTemplate.bind(this.getState())(arg, ctx.indentDepth, last); | ||
}).join(''); | ||
@@ -559,0 +578,0 @@ } else { |
@@ -95,3 +95,3 @@ /* eslint new-cap: 0 camelcase: 0 */ | ||
if (lhsType && lhsType.argsTemplate) { | ||
return lhsType.argsTemplate(lhs, ...args); | ||
return lhsType.argsTemplate.bind(this.getState())(lhs, ...args); | ||
} | ||
@@ -167,3 +167,3 @@ | ||
if (op === 'in' || op === 'notin') { | ||
return this.Syntax.in.template(s, op, this.visit(arr[i + 1])); | ||
return this.Syntax.in.template.bind(this.state)(s, op, this.visit(arr[i + 1])); | ||
} | ||
@@ -170,0 +170,0 @@ throw new BsonTranspilersRuntimeError(`Unrecognized operation ${op}`); |
@@ -174,3 +174,3 @@ /* eslint camelcase: 0 complexity: 0*/ | ||
const last = !visitedElements[index + 1]; | ||
return ctx.type.argsTemplate(arg, ctx.indentDepth, last); | ||
return ctx.type.argsTemplate.bind(this.getState())(arg, ctx.indentDepth, last); | ||
}); | ||
@@ -342,3 +342,3 @@ join = ''; | ||
if (this.Syntax.in) { | ||
return `${str}${this.Syntax.in.template( | ||
return `${str}${this.Syntax.in.template.bind(this.state)( | ||
this.visit(arr[i - 1]), op, this.visit(arr[i + 1]))}`; | ||
@@ -345,0 +345,0 @@ } |
@@ -62,3 +62,3 @@ /* eslint-disable no-sync */ | ||
const inputLangs = ['javascript', 'shell', 'python']; | ||
const outputLangs = ['java', 'shell', 'python', 'csharp', 'javascript', 'object', 'ruby', 'rust']; | ||
const outputLangs = ['java', 'shell', 'python', 'csharp', 'javascript', 'object', 'ruby', 'go', 'rust']; | ||
if (!fs.existsSync(dir)) { | ||
@@ -65,0 +65,0 @@ fs.mkdirSync(dir); |
28
index.js
@@ -30,2 +30,3 @@ const antlr4 = require('antlr4'); | ||
const getRubyGenerator = require('./codegeneration/ruby/Generator.js'); | ||
const getGoGenerator = require('./codegeneration/go/Generator.js'); | ||
const getRustGenerator = require('./codegeneration/rust/Generator.js'); | ||
@@ -39,2 +40,3 @@ | ||
const javascriptrubysymbols = require('./lib/symbol-table/javascripttoruby'); | ||
const javascriptgosymbols = require('./lib/symbol-table/javascripttogo'); | ||
const javascriptrustsymbols = require('./lib/symbol-table/javascripttorust'); | ||
@@ -48,2 +50,3 @@ | ||
const shellrubysymbols = require('./lib/symbol-table/shelltoruby'); | ||
const shellgosymbols = require('./lib/symbol-table/shelltogo'); | ||
const shellrustsymbols = require('./lib/symbol-table/shelltorust'); | ||
@@ -57,2 +60,3 @@ | ||
const pythonrubysymbols = require('./lib/symbol-table/pythontoruby'); | ||
const pythongosymbols = require('./lib/symbol-table/pythontogo'); | ||
const pythonrustsymbols = require('./lib/symbol-table/pythontorust'); | ||
@@ -140,4 +144,5 @@ | ||
transpiler.clearImports(); | ||
transpiler.clearDeclarations(); | ||
} | ||
return transpiler.start(tree); | ||
return transpiler.start(tree, !driverSyntax); | ||
} catch (e) { | ||
@@ -156,2 +161,3 @@ if (e.code && e.code.includes('BSONTRANSPILERS')) { | ||
transpiler.clearImports(); | ||
transpiler.clearDeclarations(); | ||
@@ -180,3 +186,3 @@ const result = {}; | ||
} | ||
return transpiler.Syntax.driver(result); | ||
return transpiler.Syntax.driver.bind(transpiler.getState())(result); | ||
}, | ||
@@ -228,2 +234,8 @@ compile: compile, | ||
), | ||
go: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getGoGenerator, | ||
javascriptgosymbols | ||
), | ||
rust: getTranspiler( | ||
@@ -273,2 +285,8 @@ loadJSTree, | ||
), | ||
go: getTranspiler( | ||
loadJSTree, | ||
getShellVisitor(getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor))), | ||
getGoGenerator, | ||
shellgosymbols | ||
), | ||
rust: getTranspiler( | ||
@@ -318,2 +336,8 @@ loadJSTree, | ||
), | ||
go: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getGoGenerator, | ||
pythongosymbols | ||
), | ||
rust: getTranspiler( | ||
@@ -320,0 +344,0 @@ loadPyTree, |
@@ -1,1 +0,1 @@ | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n#############################################\n# Sample Templates #\n# #\n# The expected arguments are commented next #\n# to the template itself. Currently all are #\n# set to null, but to define a function #\n# replace 'null' with '!!js/function > \\n #\n# and a function defined below. #\n# #\n# See the other template files for examples #\n# #\n# Good to know: #\n# lhs is left-hand-side of the expression #\n# rhs is right-hand-side of the expression #\n# All args are strings unless noted #\n# - arg? is boolean #\n# - arg# is number #\n# #\n#############################################\nTemplates:\n ########\n # Misc #\n ########\n\n # Filter out regex flags that have translations or are unsupported.\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: ''\n y: ''\n g: ''\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: ''\n l: ''\n u: ''\n\n #############################################\n # Syntax #\n # #\n # Templates for language syntax expressions #\n # #\n #############################################\n\n DriverTemplate: &DriverTemplate !!js/function >\n (spec) => {\n comment = '# Requires the MongoDB Ruby Driver\\n# https://docs.mongodb.com/ruby-driver/master/';\n\n const getKey = k => {\n let translateKey = {\n project: 'projection',\n maxTimeMS: 'max_time_ms'\n }\n return k in translateKey ? translateKey[k] : k\n };\n const options = spec.options;\n const filter = spec.filter || {}\n delete spec.options;\n delete spec.filter\n\n const connect = `client = Mongo::Client.new('${options.uri}', :database => '${options.database}')`;\n const coll = `client.database['${options.collection}']`;\n\n if ('aggregation' in spec) {\n return `${comment}\\n\\n${connect}\\nresult = ${coll}.aggregate(${spec.aggregation})`;\n }\n\n const vars = Object.keys(spec).reduce(\n (result, k) => {\n return `${result}\\n${getKey(k)} = ${spec[k]}`;\n },\n connect\n );\n\n const args = Object.keys(spec).reduce(\n (result, k) => {\n const divider = result === '' ? '' : ',\\n';\n return `${result}${divider} ${getKey(k)}: ${getKey(k)}`;\n },\n ''\n );\n\n const cmd = `result = ${coll}.find(${filter}${args ? `, {\\n${args}\\n}` : ''})`;\n\n return `${comment}\\n\\n${vars}\\n\\n${cmd}`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('is')) {\n let not = op.includes('not') ? '!' : ''\n return `${not}${lhs}.equal?(${rhs})`\n } else if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n } else if (op === '==' || op === '===') {\n return `${lhs} == ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '';\n if (op.includes('!') || op.includes('not')) {\n str = '!';\n }\n return `${str}${rhs}.include?(${lhs})`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `${s}.div(${rhs})`;\n case '**':\n return `${s} ** ${rhs}`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosTemplate: &EosSyntaxTemplate null # No args. End-of-line\n EofTemplate: &EofSyntaxTemplate null # No args. End-of-file\n FloorDivTemplate: &FloorDivSyntaxTemplate null # Args: lhs, rhs\n PowerTemplate: &PowerSyntaxTemplate null # Args: lhs, rhs\n NewTemplate: &NewSyntaxTemplate null # Args: expression, skip?, code# [to check if meant to be skipped]\n\n #############################################\n # Literal Types #\n # #\n # Templates for literal type instance. Most #\n # get passed the literal itself as an arg. #\n # #\n #############################################\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n return `/${pattern}/${flags ? flags : ''}`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null # args: literal, argType (i.e. '_string', '_decimal' etc)\n DecimalTypeTemplate: &DecimalTypeTemplate null # args: literal, argType\n LongBasicTypeTemplate: &LongBasicTypeTemplate null # args: literal, argType\n HexTypeTemplate: &HexTypeTemplate null # args: literal, argType\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal) => {\n let offset = 0;\n\n if (\n literal.charAt(0) === '0' &&\n (literal.charAt(1) === '0' || literal.charAt(1) === 'o' || literal.charAt(1) === 'O')\n ) {\n offset = 2;\n } else if (literal.charAt(0) === '0') {\n offset = 1;\n }\n\n literal = `0o${literal.substr(offset, literal.length - 1)}`;\n\n return literal;\n }\n NumericTypeTemplate: &NumericTypeTemplate null # args: literal, argType\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null # Args: single array element, nestedness, lastElement? (note: not being used atm)\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])} => ${arg[1]}`;\n }).join(',');\n\n return `{${pairs}${closingIndent}}`\n }\n\n #############################################\n # Symbols #\n # #\n # Templates for symbols, can be either #\n # functions or variables. #\n # #\n # The *SymbolTemplates return names and #\n # usually don't take any arguments. The #\n # *SymbolArgsTemplates are invoked for func #\n # calls. The first argument is always the #\n # lhs, i.e. the symbol returned from the #\n # corresponding SymbolTemplate. The rest of #\n # the arguments are the processed arguments #\n # passed to the original function. #\n # #\n #############################################\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function >\n () => {\n return 'BSON::Code'\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n if (code === undefined) {\n return '.new'\n }\n return !scope ? `.new(${singleStringify(code)})` : `WithScope.new(${singleStringify(code)}, ${scope})`\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, id) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n return !id ? '.new' : `(${singleStringify(id)})`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate null\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate !!js/function >\n () => {\n return 'BSON::DBRef'\n }\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate !!js/function >\n (lhs, coll, id, db) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n\n let db_string = db ? `,\\n '$db' => ${singleStringify(db)}` : ''\n return `.new(\\n '$ref' => ${singleStringify(coll)},\\n '$id' => ${id}${db_string}\\n)`\n }\n\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return '';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_decimal' || type === '_double') {\n return arg;\n }\n return `${arg}.to_f`;\n }\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return '';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return ''\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '' : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `:'${newStr}'`;\n } else {\n return `${newStr}.to_sym`;\n }\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n }\n return `/${singleStringify(pattern)}/${flags ? singleStringify(flags) : ''}`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.new(${arg})`;\n }\n return `.new('${arg}')`;\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MinKey';\n }\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MaxKey';\n }\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BSON::Timestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `.new(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n # non bson-specific\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return '';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `'${newStr}'.to_f`;\n } else if (type === '_decimal' || type === '_double') {\n return newStr;\n } else {\n return `${newStr}.to_f`;\n }\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Time';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n const toStr = isString ? '.strftime(\\'%a %b %d %Y %H:%M:%S %Z\\')' : '';\n\n if (date === null) {\n return `${lhs}.new.utc${toStr}`;\n }\n\n const dateStr = [\n date.getUTCFullYear(),\n date.getUTCMonth() + 1,\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds()\n ].join(', ');\n\n return `${lhs}.utc(${dateStr})${toStr}`;\n }\n\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Time.now.utc';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate !!js/function >\n (args) => {\n return '';\n }\n\n #############################################\n # Object Attributes/Methods #\n # #\n # These're variables or functions called on #\n # instantiated objects. For example, #\n # ObjectId().isValid() or Timestamp().t #\n # #\n # They follow the same pattern with the\n # *Template/*ArgsTemplates: usually no args #\n # to the Template and lhs plus any original #\n # arguments to the ArgsTemplate. #\n # #\n #############################################\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.javascript`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate !!js/function >\n () => {\n return '';\n }\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.scope`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (arg) => {\n return `${arg}`;\n }\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_time`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.legal?`\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate null\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate null\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.database`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.collection`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.id`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate !!js/function >\n (lhs) => {\n return '${lhs}.to_s';\n }\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n DoubleValueOfTemplate: &DoubleValueOfTemplate null\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate null\n Int32ValueOfTemplate: &Int32ValueOfTemplate null\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate null\n Int32ToStringTemplate: &Int32ToStringTemplate null\n Int32ToStringArgsTemplate: &Int32ToStringArgsTemplate null\n LongEqualsTemplate: &LongEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} ==`;\n }\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongAddTemplate: &LongAddTemplate !!js/function >\n (lhs) => {\n return `${lhs} +`;\n }\n LongAddArgsTemplate: &LongAddArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongSubtractTemplate: &LongSubtractTemplate !!js/function >\n (arg) => {\n return `${arg} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (arg) => {\n return `${arg} *`;\n }\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongDivTemplate: &LongDivTemplate !!js/function >\n (lhs) => {\n return `${lhs} /`;\n }\n LongDivArgsTemplate: &LongDivArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongModuloTemplate: &LongModuloTemplate !!js/function >\n (lhs) => {\n return `${lhs} %`;\n }\n LongModuloArgsTemplate: &LongModuloArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongAndTemplate: &LongAndTemplate !!js/function >\n (lhs) => {\n return `${lhs} &`;\n }\n LongAndArgsTemplate: &LongAndArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongOrTemplate: &LongOrTemplate !!js/function >\n (lhs) => {\n return `${lhs} |`;\n }\n LongOrArgsTemplate: &LongOrArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongXorTemplate: &LongXorTemplate !!js/function >\n (lhs) => {\n return `${lhs} ^`;\n }\n LongXorArgsTemplate: &LongXorArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftLeftTemplate: &LongShiftLeftTemplate !!js/function >\n (lhs) => {\n return `${lhs} <<`;\n }\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftRightTemplate: &LongShiftRightTemplate !!js/function >\n (lhs) => {\n return `${lhs} >>`;\n }\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongCompareTemplate: &LongCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} -`;\n }\n LongCompareArgsTemplate: &LongCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongIsOddTemplate: &LongIsOddTemplate !!js/function >\n (lhs) => {\n return `(${lhs} % 2) == 1`;\n }\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsZeroTemplate: &LongIsZeroTemplate !!js/function >\n (lhs) => {\n return `${lhs} == 0`;\n }\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsNegativeTemplate: &LongIsNegativeTemplate !!js/function >\n (lhs) => {\n return `${lhs} < 0`;\n }\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongNegateTemplate: &LongNegateTemplate !!js/function >\n () => {\n return '-';\n }\n LongNegateArgsTemplate: &LongNegateArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotTemplate: &LongNotTemplate !!js/function >\n () => {\n return '~';\n }\n LongNotArgsTemplate: &LongNotArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotEqualsTemplate: &LongNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} !=`;\n }\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanTemplate: &LongGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} >`;\n }\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >=`;\n }\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanTemplate: &LongLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} <`;\n }\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=`;\n }\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs} >> 32`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs} & 0x0000ffff`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampEqualsTemplate: &TimestampEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `Time.at(${lhs}.increment).utc`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate null\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=> `;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} != `;\n }\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} > `;\n }\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >= `;\n }\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanTemplate: &TimestampLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} < `;\n }\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <= `;\n }\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n SymbolValueOfTemplate: &SymbolValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolInspectTemplate: &SymbolInspectTemplate !!js/function >\n (lhs) => {\n return `${lhs}.inspect`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n let extractRegex = (lhs) => {\n let r = /^:'(.*)'$/;\n let arr = r.exec(lhs);\n return arr ? arr[1] : ''\n\n }\n let res = extractRegex(lhs)\n return res ? `'${res}'` : `${lhs}.to_s`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n\n #############################################\n # Symbol Attributes/Methods #\n # #\n # These're variables or functions called on #\n # symbols. Also called bson-utils. #\n # #\n # They are basically the same thing as #\n # object attributes/methods, but need to be #\n # distinguished since they are separate #\n # namespaces that happen to have the same #\n # name which is v confusing. #\n # #\n # For example, ObjectId().toString() is an #\n # object method, while ObjectId.fromString #\n # is a symbol attribute. These are two #\n # separate ObjectId related namespaces that #\n # don't overlap. #\n # #\n #############################################\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return '9223372036854775807';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return '-9223372036854775808';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n () => {\n return '0';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n () => {\n return '1';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n () => {\n return '-1';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}.to_i`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `.new(${arg})`;\n }\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return 'BSON::ObjectId.from_time';\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg})`;\n }\n return `(Time.at(${arg}))`;\n }\n # non bson-specific would go here, but there aren't any atm.\n\n #############################################\n # Imports #\n # #\n # Each type has a 'code' that is consistent #\n # between languages. The import templates #\n # for each code generate the required #\n # statement for each type. No args. #\n # #\n # The ImportTemplate collects everything #\n # into one statement. #\n # #\n #############################################\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n let set = new Set(Object.values(args))\n if (set.has(`require 'mongo'`)) return `require 'mongo'`\n return [...set].sort().join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `require 'mongo'`\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n int: &intType\n <<: *__type\n id: \"int\"\n code: 105\n type: *IntegerType\n attr: {}\n float: &floatType\n <<: *__type\n id: \"float\"\n code: 104\n type: *IntegerType\n attr: {}\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *ObjectType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n binary:\n callable: *var\n args: null\n attr: null\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n generation_time:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *DateType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n Binary: &BinaryType # Not currently supported\n <<: *__type\n id: \"Binary\"\n code: 102\n type: *ObjectType\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n database:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n collection:\n callable: *var\n args: null\n attr: null\n id: \"collection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n id:\n callable: *var\n args: null\n attr: null\n id: \"id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n Int64: &LongType\n <<: *__type\n id: \"Int64\"\n code: 106\n type: *ObjectType\n attr: {}\n MinKey: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKey: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Regex: &BSONRegExpType\n <<: *__type\n id: \"BSONRegExp\"\n code: 109\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"Timestamp\"\n code: 110\n type: *ObjectType\n attr:\n time:\n callable: *var\n args: null\n attr: null\n id: \"time\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n inc:\n callable: *var\n args: null\n attr: null\n id: \"inc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n as_datetime:\n <<: *__func\n id: \"inc\"\n type: *DateType\n template: *TimestampAsDateTemplate\n argsTemplate: *TimestampAsDateArgsTemplate\n Decimal128: &Decimal128Type\n <<: *__type\n id: \"Decimal128\"\n code: 112\n type: *ObjectType\n attr: {}\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectType, null ]\n namedArgs:\n scope:\n default: {}\n type: [ *ObjectType ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n namedArgs:\n oid:\n default: null\n type: [ *StringType, *ObjectIdType ]\n type: *ObjectIdType\n attr:\n from_datetime:\n <<: *__func\n id: \"ObjectIdfrom_datetime\"\n args:\n - [ \"Date\" ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n is_valid:\n <<: *__func\n id: \"is_valid\"\n args:\n - [ *StringType, ]\n type: *BoolType\n template: *ObjectIdIsValidTemplate\n argsTemplate: *ObjectIdIsValidArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n Binary: &BinarySymbol # Not currently supported\n id: \"Binary\"\n code: 102\n callable: *constructor\n args: null\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType, *StringType ]\n - [ *StringType, null ]\n namedArgs:\n database:\n default: null\n type: [ *StringType ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n Int64:\n id: \"Int64\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Regex:\n id: \"Regex\"\n code: 109\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *StringType, *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *StringType, *IntegerType ]\n type: *BSONRegExpType\n attr:\n from_native:\n <<: *__func\n id: \"from_native\"\n args:\n - [ *RegexType ]\n type: *BSONRegExpType\n template: null\n argsTemplate: null\n template: *BSONRegExpSymbolTemplate\n argsTemplate: *BSONRegExpSymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Decimal128:\n id: \"Decimal128\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n datetime: # Needs process method\n id: \"datetime\"\n code: 200\n callable: *constructor\n args:\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: {} # TODO: add more date funcs?\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n re:\n id: \"re\"\n code: 8\n callable: *var\n args: null\n type: null\n attr:\n compile:\n id: \"compile\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *IntegerType ]\n type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n id: 're.A'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n id: 're.ASCII'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n id: 're.I'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n id: 're.IGNORECASE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n id: 're.DEBUG'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n id: 're.L'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n id: 're.LOCAL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n id: 're.M'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n id: 're.MULTILINE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n id: 're.S'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n id: 're.DOTALL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n id: 're.X'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\n id: 're.VERBOSE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n template: !!js/function >\n () => {\n return '';\n }\n argsTemplate: null\n float:\n id: \"float\"\n code: 104\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *floatType\n attr: {}\n template: *DoubleSymbolTemplate\n argsTemplate: *DoubleSymbolArgsTemplate\n int:\n id: \"int\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *intType\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n"; | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n#############################################\n# Sample Templates #\n# #\n# The expected arguments are commented next #\n# to the template itself. Currently all are #\n# set to null, but to define a function #\n# replace 'null' with '!!js/function > \\n #\n# and a function defined below. #\n# #\n# See the other template files for examples #\n# #\n# Good to know: #\n# lhs is left-hand-side of the expression #\n# rhs is right-hand-side of the expression #\n# All args are strings unless noted #\n# - arg? is boolean #\n# - arg# is number #\n# #\n#############################################\nTemplates:\n ########\n # Misc #\n ########\n\n # Filter out regex flags that have translations or are unsupported.\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: ''\n y: ''\n g: ''\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: ''\n l: ''\n u: ''\n\n #############################################\n # Syntax #\n # #\n # Templates for language syntax expressions #\n # #\n #############################################\n\n DriverTemplate: &DriverTemplate !!js/function >\n (spec) => {\n comment = '# Requires the MongoDB Ruby Driver\\n# https://docs.mongodb.com/ruby-driver/master/';\n\n const getKey = k => {\n let translateKey = {\n project: 'projection',\n maxTimeMS: 'max_time_ms'\n }\n return k in translateKey ? translateKey[k] : k\n };\n const options = spec.options;\n const filter = spec.filter || {}\n delete spec.options;\n delete spec.filter\n\n const connect = `client = Mongo::Client.new('${options.uri}', :database => '${options.database}')`;\n const coll = `client.database['${options.collection}']`;\n\n if ('aggregation' in spec) {\n return `${comment}\\n\\n${connect}\\nresult = ${coll}.aggregate(${spec.aggregation})`;\n }\n\n const vars = Object.keys(spec).reduce(\n (result, k) => {\n return `${result}\\n${getKey(k)} = ${spec[k]}`;\n },\n connect\n );\n\n const args = Object.keys(spec).reduce(\n (result, k) => {\n const divider = result === '' ? '' : ',\\n';\n return `${result}${divider} ${getKey(k)}: ${getKey(k)}`;\n },\n ''\n );\n\n const cmd = `result = ${coll}.find(${filter}${args ? `, {\\n${args}\\n}` : ''})`;\n\n return `${comment}\\n\\n${vars}\\n\\n${cmd}`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('is')) {\n let not = op.includes('not') ? '!' : ''\n return `${not}${lhs}.equal?(${rhs})`\n } else if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n } else if (op === '==' || op === '===') {\n return `${lhs} == ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '';\n if (op.includes('!') || op.includes('not')) {\n str = '!';\n }\n return `${str}${rhs}.include?(${lhs})`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `${s}.div(${rhs})`;\n case '**':\n return `${s} ** ${rhs}`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosTemplate: &EosSyntaxTemplate null # No args. End-of-line\n EofTemplate: &EofSyntaxTemplate null # No args. End-of-file\n FloorDivTemplate: &FloorDivSyntaxTemplate null # Args: lhs, rhs\n PowerTemplate: &PowerSyntaxTemplate null # Args: lhs, rhs\n NewTemplate: &NewSyntaxTemplate null # Args: expression, skip?, code# [to check if meant to be skipped]\n\n #############################################\n # Literal Types #\n # #\n # Templates for literal type instance. Most #\n # get passed the literal itself as an arg. #\n # #\n #############################################\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n return `/${pattern}/${flags ? flags : ''}`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null # args: literal, argType (i.e. '_string', '_decimal' etc)\n DecimalTypeTemplate: &DecimalTypeTemplate null # args: literal, argType\n LongBasicTypeTemplate: &LongBasicTypeTemplate null # args: literal, argType\n HexTypeTemplate: &HexTypeTemplate null # args: literal, argType\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal) => {\n let offset = 0;\n\n if (\n literal.charAt(0) === '0' &&\n (literal.charAt(1) === '0' || literal.charAt(1) === 'o' || literal.charAt(1) === 'O')\n ) {\n offset = 2;\n } else if (literal.charAt(0) === '0') {\n offset = 1;\n }\n\n literal = `0o${literal.substr(offset, literal.length - 1)}`;\n\n return literal;\n }\n NumericTypeTemplate: &NumericTypeTemplate null # args: literal, argType\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null # Args: single array element, nestedness, lastElement? (note: not being used atm)\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])} => ${arg[1]}`;\n }).join(',');\n\n return `{${pairs}${closingIndent}}`\n }\n\n #############################################\n # Symbols #\n # #\n # Templates for symbols, can be either #\n # functions or variables. #\n # #\n # The *SymbolTemplates return names and #\n # usually don't take any arguments. The #\n # *SymbolArgsTemplates are invoked for func #\n # calls. The first argument is always the #\n # lhs, i.e. the symbol returned from the #\n # corresponding SymbolTemplate. The rest of #\n # the arguments are the processed arguments #\n # passed to the original function. #\n # #\n #############################################\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function >\n () => {\n return 'BSON::Code'\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n if (code === undefined) {\n return '.new'\n }\n return !scope ? `.new(${singleStringify(code)})` : `WithScope.new(${singleStringify(code)}, ${scope})`\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, id) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n return !id ? '.new' : `(${singleStringify(id)})`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate null\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate !!js/function >\n () => {\n return 'BSON::DBRef'\n }\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate !!js/function >\n (lhs, coll, id, db) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n\n let db_string = db ? `,\\n '$db' => ${singleStringify(db)}` : ''\n return `.new(\\n '$ref' => ${singleStringify(coll)},\\n '$id' => ${id}${db_string}\\n)`\n }\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return '';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_decimal' || type === '_double') {\n return arg;\n }\n return `${arg}.to_f`;\n }\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return '';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return ''\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '' : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `:'${newStr}'`;\n } else {\n return `${newStr}.to_sym`;\n }\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n }\n return `/${singleStringify(pattern)}/${flags ? singleStringify(flags) : ''}`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.new(${arg})`;\n }\n return `.new('${arg}')`;\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MinKey';\n }\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MaxKey';\n }\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BSON::Timestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `.new(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n # non bson-specific\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return '';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `'${newStr}'.to_f`;\n } else if (type === '_decimal' || type === '_double') {\n return newStr;\n } else {\n return `${newStr}.to_f`;\n }\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Time';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n const toStr = isString ? '.strftime(\\'%a %b %d %Y %H:%M:%S %Z\\')' : '';\n\n if (date === null) {\n return `${lhs}.new.utc${toStr}`;\n }\n\n const dateStr = [\n date.getUTCFullYear(),\n date.getUTCMonth() + 1,\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds()\n ].join(', ');\n\n return `${lhs}.utc(${dateStr})${toStr}`;\n }\n\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Time.now.utc';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate !!js/function >\n (args) => {\n return '';\n }\n\n #############################################\n # Object Attributes/Methods #\n # #\n # These're variables or functions called on #\n # instantiated objects. For example, #\n # ObjectId().isValid() or Timestamp().t #\n # #\n # They follow the same pattern with the\n # *Template/*ArgsTemplates: usually no args #\n # to the Template and lhs plus any original #\n # arguments to the ArgsTemplate. #\n # #\n #############################################\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.javascript`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate !!js/function >\n () => {\n return '';\n }\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.scope`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (arg) => {\n return `${arg}`;\n }\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_time`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.legal?`\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate null\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate null\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.database`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.collection`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.id`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate !!js/function >\n (lhs) => {\n return '${lhs}.to_s';\n }\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n DoubleValueOfTemplate: &DoubleValueOfTemplate null\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate null\n Int32ValueOfTemplate: &Int32ValueOfTemplate null\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate null\n Int32ToStringTemplate: &Int32ToStringTemplate null\n Int32ToStringArgsTemplate: &Int32ToStringArgsTemplate null\n LongEqualsTemplate: &LongEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} ==`;\n }\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongAddTemplate: &LongAddTemplate !!js/function >\n (lhs) => {\n return `${lhs} +`;\n }\n LongAddArgsTemplate: &LongAddArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongSubtractTemplate: &LongSubtractTemplate !!js/function >\n (arg) => {\n return `${arg} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (arg) => {\n return `${arg} *`;\n }\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongDivTemplate: &LongDivTemplate !!js/function >\n (lhs) => {\n return `${lhs} /`;\n }\n LongDivArgsTemplate: &LongDivArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongModuloTemplate: &LongModuloTemplate !!js/function >\n (lhs) => {\n return `${lhs} %`;\n }\n LongModuloArgsTemplate: &LongModuloArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongAndTemplate: &LongAndTemplate !!js/function >\n (lhs) => {\n return `${lhs} &`;\n }\n LongAndArgsTemplate: &LongAndArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongOrTemplate: &LongOrTemplate !!js/function >\n (lhs) => {\n return `${lhs} |`;\n }\n LongOrArgsTemplate: &LongOrArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongXorTemplate: &LongXorTemplate !!js/function >\n (lhs) => {\n return `${lhs} ^`;\n }\n LongXorArgsTemplate: &LongXorArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftLeftTemplate: &LongShiftLeftTemplate !!js/function >\n (lhs) => {\n return `${lhs} <<`;\n }\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftRightTemplate: &LongShiftRightTemplate !!js/function >\n (lhs) => {\n return `${lhs} >>`;\n }\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongCompareTemplate: &LongCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} -`;\n }\n LongCompareArgsTemplate: &LongCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongIsOddTemplate: &LongIsOddTemplate !!js/function >\n (lhs) => {\n return `(${lhs} % 2) == 1`;\n }\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsZeroTemplate: &LongIsZeroTemplate !!js/function >\n (lhs) => {\n return `${lhs} == 0`;\n }\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsNegativeTemplate: &LongIsNegativeTemplate !!js/function >\n (lhs) => {\n return `${lhs} < 0`;\n }\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongNegateTemplate: &LongNegateTemplate !!js/function >\n () => {\n return '-';\n }\n LongNegateArgsTemplate: &LongNegateArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotTemplate: &LongNotTemplate !!js/function >\n () => {\n return '~';\n }\n LongNotArgsTemplate: &LongNotArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotEqualsTemplate: &LongNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} !=`;\n }\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanTemplate: &LongGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} >`;\n }\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >=`;\n }\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanTemplate: &LongLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} <`;\n }\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=`;\n }\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs} >> 32`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs} & 0x0000ffff`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampEqualsTemplate: &TimestampEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `Time.at(${lhs}.increment).utc`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate null\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=> `;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} != `;\n }\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} > `;\n }\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >= `;\n }\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanTemplate: &TimestampLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} < `;\n }\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <= `;\n }\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n SymbolValueOfTemplate: &SymbolValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolInspectTemplate: &SymbolInspectTemplate !!js/function >\n (lhs) => {\n return `${lhs}.inspect`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n let extractRegex = (lhs) => {\n let r = /^:'(.*)'$/;\n let arr = r.exec(lhs);\n return arr ? arr[1] : ''\n\n }\n let res = extractRegex(lhs)\n return res ? `'${res}'` : `${lhs}.to_s`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n\n #############################################\n # Symbol Attributes/Methods #\n # #\n # These're variables or functions called on #\n # symbols. Also called bson-utils. #\n # #\n # They are basically the same thing as #\n # object attributes/methods, but need to be #\n # distinguished since they are separate #\n # namespaces that happen to have the same #\n # name which is v confusing. #\n # #\n # For example, ObjectId().toString() is an #\n # object method, while ObjectId.fromString #\n # is a symbol attribute. These are two #\n # separate ObjectId related namespaces that #\n # don't overlap. #\n # #\n #############################################\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return '9223372036854775807';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return '-9223372036854775808';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n () => {\n return '0';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n () => {\n return '1';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n () => {\n return '-1';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}.to_i`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `.new(${arg})`;\n }\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return 'BSON::ObjectId.from_time';\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg})`;\n }\n return `(Time.at(${arg}))`;\n }\n # non bson-specific would go here, but there aren't any atm.\n\n #############################################\n # Imports #\n # #\n # Each type has a 'code' that is consistent #\n # between languages. The import templates #\n # for each code generate the required #\n # statement for each type. No args. #\n # #\n # The ImportTemplate collects everything #\n # into one statement. #\n # #\n #############################################\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n let set = new Set(Object.values(args))\n if (set.has(`require 'mongo'`)) return `require 'mongo'`\n return [...set].sort().join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `require 'mongo'`\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n int: &intType\n <<: *__type\n id: \"int\"\n code: 105\n type: *IntegerType\n attr: {}\n float: &floatType\n <<: *__type\n id: \"float\"\n code: 104\n type: *IntegerType\n attr: {}\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *ObjectType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n binary:\n callable: *var\n args: null\n attr: null\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n generation_time:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *DateType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n Binary: &BinaryType # Not currently supported\n <<: *__type\n id: \"Binary\"\n code: 102\n type: *ObjectType\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n database:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n collection:\n callable: *var\n args: null\n attr: null\n id: \"collection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n id:\n callable: *var\n args: null\n attr: null\n id: \"id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n Int64: &LongType\n <<: *__type\n id: \"Int64\"\n code: 106\n type: *ObjectType\n attr: {}\n MinKey: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKey: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Regex: &BSONRegExpType\n <<: *__type\n id: \"BSONRegExp\"\n code: 109\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"Timestamp\"\n code: 110\n type: *ObjectType\n attr:\n time:\n callable: *var\n args: null\n attr: null\n id: \"time\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n inc:\n callable: *var\n args: null\n attr: null\n id: \"inc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n as_datetime:\n <<: *__func\n id: \"inc\"\n type: *DateType\n template: *TimestampAsDateTemplate\n argsTemplate: *TimestampAsDateArgsTemplate\n Decimal128: &Decimal128Type\n <<: *__type\n id: \"Decimal128\"\n code: 112\n type: *ObjectType\n attr: {}\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectType, null ]\n namedArgs:\n scope:\n default: {}\n type: [ *ObjectType ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n namedArgs:\n oid:\n default: null\n type: [ *StringType, *ObjectIdType ]\n type: *ObjectIdType\n attr:\n from_datetime:\n <<: *__func\n id: \"ObjectIdfrom_datetime\"\n args:\n - [ \"Date\" ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n is_valid:\n <<: *__func\n id: \"is_valid\"\n args:\n - [ *StringType, ]\n type: *BoolType\n template: *ObjectIdIsValidTemplate\n argsTemplate: *ObjectIdIsValidArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n Binary: &BinarySymbol # Not currently supported\n id: \"Binary\"\n code: 102\n callable: *constructor\n args: null\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType, *StringType ]\n - [ *StringType, null ]\n namedArgs:\n database:\n default: null\n type: [ *StringType ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n Int64:\n id: \"Int64\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Regex:\n id: \"Regex\"\n code: 109\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *StringType, *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *StringType, *IntegerType ]\n type: *BSONRegExpType\n attr:\n from_native:\n <<: *__func\n id: \"from_native\"\n args:\n - [ *RegexType ]\n type: *BSONRegExpType\n template: null\n argsTemplate: null\n template: *BSONRegExpSymbolTemplate\n argsTemplate: *BSONRegExpSymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Decimal128:\n id: \"Decimal128\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n datetime: # Needs process method\n id: \"datetime\"\n code: 200\n callable: *constructor\n args:\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: {} # TODO: add more date funcs?\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n re:\n id: \"re\"\n code: 8\n callable: *var\n args: null\n type: null\n attr:\n compile:\n id: \"compile\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *IntegerType ]\n type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n id: 're.A'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n id: 're.ASCII'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n id: 're.I'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n id: 're.IGNORECASE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n id: 're.DEBUG'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n id: 're.L'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n id: 're.LOCAL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n id: 're.M'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n id: 're.MULTILINE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n id: 're.S'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n id: 're.DOTALL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n id: 're.X'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\n id: 're.VERBOSE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n template: !!js/function >\n () => {\n return '';\n }\n argsTemplate: null\n float:\n id: \"float\"\n code: 104\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *floatType\n attr: {}\n template: *DoubleSymbolTemplate\n argsTemplate: *DoubleSymbolArgsTemplate\n int:\n id: \"int\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *intType\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n"; |
@@ -1,1 +0,1 @@ | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n#############################################\n# Sample Templates #\n# #\n# The expected arguments are commented next #\n# to the template itself. Currently all are #\n# set to null, but to define a function #\n# replace 'null' with '!!js/function > \\n #\n# and a function defined below. #\n# #\n# See the other template files for examples #\n# #\n# Good to know: #\n# lhs is left-hand-side of the expression #\n# rhs is right-hand-side of the expression #\n# All args are strings unless noted #\n# - arg? is boolean #\n# - arg# is number #\n# #\n#############################################\nTemplates:\n ########\n # Misc #\n ########\n\n # Filter out regex flags that have translations or are unsupported.\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: ''\n y: ''\n g: ''\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: ''\n l: ''\n u: ''\n\n #############################################\n # Syntax #\n # #\n # Templates for language syntax expressions #\n # #\n #############################################\n\n DriverTemplate: &DriverTemplate !!js/function >\n (spec) => {\n comment = '# Requires the MongoDB Ruby Driver\\n# https://docs.mongodb.com/ruby-driver/master/';\n\n const getKey = k => {\n let translateKey = {\n project: 'projection',\n maxTimeMS: 'max_time_ms'\n }\n return k in translateKey ? translateKey[k] : k\n };\n const options = spec.options;\n const filter = spec.filter || {}\n delete spec.options;\n delete spec.filter\n\n const connect = `client = Mongo::Client.new('${options.uri}', :database => '${options.database}')`;\n const coll = `client.database['${options.collection}']`;\n\n if ('aggregation' in spec) {\n return `${comment}\\n\\n${connect}\\nresult = ${coll}.aggregate(${spec.aggregation})`;\n }\n\n const vars = Object.keys(spec).reduce(\n (result, k) => {\n return `${result}\\n${getKey(k)} = ${spec[k]}`;\n },\n connect\n );\n\n const args = Object.keys(spec).reduce(\n (result, k) => {\n const divider = result === '' ? '' : ',\\n';\n return `${result}${divider} ${getKey(k)}: ${getKey(k)}`;\n },\n ''\n );\n\n const cmd = `result = ${coll}.find(${filter}${args ? `, {\\n${args}\\n}` : ''})`;\n\n return `${comment}\\n\\n${vars}\\n\\n${cmd}`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('is')) {\n let not = op.includes('not') ? '!' : ''\n return `${not}${lhs}.equal?(${rhs})`\n } else if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n } else if (op === '==' || op === '===') {\n return `${lhs} == ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '';\n if (op.includes('!') || op.includes('not')) {\n str = '!';\n }\n return `${str}${rhs}.include?(${lhs})`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `${s}.div(${rhs})`;\n case '**':\n return `${s} ** ${rhs}`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosTemplate: &EosSyntaxTemplate null # No args. End-of-line\n EofTemplate: &EofSyntaxTemplate null # No args. End-of-file\n FloorDivTemplate: &FloorDivSyntaxTemplate null # Args: lhs, rhs\n PowerTemplate: &PowerSyntaxTemplate null # Args: lhs, rhs\n NewTemplate: &NewSyntaxTemplate null # Args: expression, skip?, code# [to check if meant to be skipped]\n\n #############################################\n # Literal Types #\n # #\n # Templates for literal type instance. Most #\n # get passed the literal itself as an arg. #\n # #\n #############################################\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n return `/${pattern}/${flags ? flags : ''}`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null # args: literal, argType (i.e. '_string', '_decimal' etc)\n DecimalTypeTemplate: &DecimalTypeTemplate null # args: literal, argType\n LongBasicTypeTemplate: &LongBasicTypeTemplate null # args: literal, argType\n HexTypeTemplate: &HexTypeTemplate null # args: literal, argType\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal) => {\n let offset = 0;\n\n if (\n literal.charAt(0) === '0' &&\n (literal.charAt(1) === '0' || literal.charAt(1) === 'o' || literal.charAt(1) === 'O')\n ) {\n offset = 2;\n } else if (literal.charAt(0) === '0') {\n offset = 1;\n }\n\n literal = `0o${literal.substr(offset, literal.length - 1)}`;\n\n return literal;\n }\n NumericTypeTemplate: &NumericTypeTemplate null # args: literal, argType\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null # Args: single array element, nestedness, lastElement? (note: not being used atm)\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])} => ${arg[1]}`;\n }).join(',');\n\n return `{${pairs}${closingIndent}}`\n }\n\n #############################################\n # Symbols #\n # #\n # Templates for symbols, can be either #\n # functions or variables. #\n # #\n # The *SymbolTemplates return names and #\n # usually don't take any arguments. The #\n # *SymbolArgsTemplates are invoked for func #\n # calls. The first argument is always the #\n # lhs, i.e. the symbol returned from the #\n # corresponding SymbolTemplate. The rest of #\n # the arguments are the processed arguments #\n # passed to the original function. #\n # #\n #############################################\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function >\n () => {\n return 'BSON::Code'\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n if (code === undefined) {\n return '.new'\n }\n return !scope ? `.new(${singleStringify(code)})` : `WithScope.new(${singleStringify(code)}, ${scope})`\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, id) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n return !id ? '.new' : `(${singleStringify(id)})`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate null\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate !!js/function >\n () => {\n return 'BSON::DBRef'\n }\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate !!js/function >\n (lhs, coll, id, db) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n\n let db_string = db ? `,\\n '$db' => ${singleStringify(db)}` : ''\n return `.new(\\n '$ref' => ${singleStringify(coll)},\\n '$id' => ${id}${db_string}\\n)`\n }\n\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return '';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_decimal' || type === '_double') {\n return arg;\n }\n return `${arg}.to_f`;\n }\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return '';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return ''\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '' : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `:'${newStr}'`;\n } else {\n return `${newStr}.to_sym`;\n }\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n }\n return `/${singleStringify(pattern)}/${flags ? singleStringify(flags) : ''}`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.new(${arg})`;\n }\n return `.new('${arg}')`;\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MinKey';\n }\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MaxKey';\n }\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BSON::Timestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `.new(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n # non bson-specific\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return '';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `'${newStr}'.to_f`;\n } else if (type === '_decimal' || type === '_double') {\n return newStr;\n } else {\n return `${newStr}.to_f`;\n }\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Time';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n const toStr = isString ? '.strftime(\\'%a %b %d %Y %H:%M:%S %Z\\')' : '';\n\n if (date === null) {\n return `${lhs}.new.utc${toStr}`;\n }\n\n const dateStr = [\n date.getUTCFullYear(),\n date.getUTCMonth() + 1,\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds()\n ].join(', ');\n\n return `${lhs}.utc(${dateStr})${toStr}`;\n }\n\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Time.now.utc';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate !!js/function >\n (args) => {\n return '';\n }\n\n #############################################\n # Object Attributes/Methods #\n # #\n # These're variables or functions called on #\n # instantiated objects. For example, #\n # ObjectId().isValid() or Timestamp().t #\n # #\n # They follow the same pattern with the\n # *Template/*ArgsTemplates: usually no args #\n # to the Template and lhs plus any original #\n # arguments to the ArgsTemplate. #\n # #\n #############################################\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.javascript`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate !!js/function >\n () => {\n return '';\n }\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.scope`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (arg) => {\n return `${arg}`;\n }\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_time`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.legal?`\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate null\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate null\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.database`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.collection`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.id`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate !!js/function >\n (lhs) => {\n return '${lhs}.to_s';\n }\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n DoubleValueOfTemplate: &DoubleValueOfTemplate null\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate null\n Int32ValueOfTemplate: &Int32ValueOfTemplate null\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate null\n Int32ToStringTemplate: &Int32ToStringTemplate null\n Int32ToStringArgsTemplate: &Int32ToStringArgsTemplate null\n LongEqualsTemplate: &LongEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} ==`;\n }\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongAddTemplate: &LongAddTemplate !!js/function >\n (lhs) => {\n return `${lhs} +`;\n }\n LongAddArgsTemplate: &LongAddArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongSubtractTemplate: &LongSubtractTemplate !!js/function >\n (arg) => {\n return `${arg} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (arg) => {\n return `${arg} *`;\n }\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongDivTemplate: &LongDivTemplate !!js/function >\n (lhs) => {\n return `${lhs} /`;\n }\n LongDivArgsTemplate: &LongDivArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongModuloTemplate: &LongModuloTemplate !!js/function >\n (lhs) => {\n return `${lhs} %`;\n }\n LongModuloArgsTemplate: &LongModuloArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongAndTemplate: &LongAndTemplate !!js/function >\n (lhs) => {\n return `${lhs} &`;\n }\n LongAndArgsTemplate: &LongAndArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongOrTemplate: &LongOrTemplate !!js/function >\n (lhs) => {\n return `${lhs} |`;\n }\n LongOrArgsTemplate: &LongOrArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongXorTemplate: &LongXorTemplate !!js/function >\n (lhs) => {\n return `${lhs} ^`;\n }\n LongXorArgsTemplate: &LongXorArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftLeftTemplate: &LongShiftLeftTemplate !!js/function >\n (lhs) => {\n return `${lhs} <<`;\n }\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftRightTemplate: &LongShiftRightTemplate !!js/function >\n (lhs) => {\n return `${lhs} >>`;\n }\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongCompareTemplate: &LongCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} -`;\n }\n LongCompareArgsTemplate: &LongCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongIsOddTemplate: &LongIsOddTemplate !!js/function >\n (lhs) => {\n return `(${lhs} % 2) == 1`;\n }\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsZeroTemplate: &LongIsZeroTemplate !!js/function >\n (lhs) => {\n return `${lhs} == 0`;\n }\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsNegativeTemplate: &LongIsNegativeTemplate !!js/function >\n (lhs) => {\n return `${lhs} < 0`;\n }\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongNegateTemplate: &LongNegateTemplate !!js/function >\n () => {\n return '-';\n }\n LongNegateArgsTemplate: &LongNegateArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotTemplate: &LongNotTemplate !!js/function >\n () => {\n return '~';\n }\n LongNotArgsTemplate: &LongNotArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotEqualsTemplate: &LongNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} !=`;\n }\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanTemplate: &LongGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} >`;\n }\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >=`;\n }\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanTemplate: &LongLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} <`;\n }\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=`;\n }\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs} >> 32`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs} & 0x0000ffff`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampEqualsTemplate: &TimestampEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `Time.at(${lhs}.increment).utc`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate null\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=> `;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} != `;\n }\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} > `;\n }\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >= `;\n }\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanTemplate: &TimestampLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} < `;\n }\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <= `;\n }\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n SymbolValueOfTemplate: &SymbolValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolInspectTemplate: &SymbolInspectTemplate !!js/function >\n (lhs) => {\n return `${lhs}.inspect`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n let extractRegex = (lhs) => {\n let r = /^:'(.*)'$/;\n let arr = r.exec(lhs);\n return arr ? arr[1] : ''\n\n }\n let res = extractRegex(lhs)\n return res ? `'${res}'` : `${lhs}.to_s`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n\n #############################################\n # Symbol Attributes/Methods #\n # #\n # These're variables or functions called on #\n # symbols. Also called bson-utils. #\n # #\n # They are basically the same thing as #\n # object attributes/methods, but need to be #\n # distinguished since they are separate #\n # namespaces that happen to have the same #\n # name which is v confusing. #\n # #\n # For example, ObjectId().toString() is an #\n # object method, while ObjectId.fromString #\n # is a symbol attribute. These are two #\n # separate ObjectId related namespaces that #\n # don't overlap. #\n # #\n #############################################\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return '9223372036854775807';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return '-9223372036854775808';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n () => {\n return '0';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n () => {\n return '1';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n () => {\n return '-1';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}.to_i`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `.new(${arg})`;\n }\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return 'BSON::ObjectId.from_time';\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg})`;\n }\n return `(Time.at(${arg}))`;\n }\n # non bson-specific would go here, but there aren't any atm.\n\n #############################################\n # Imports #\n # #\n # Each type has a 'code' that is consistent #\n # between languages. The import templates #\n # for each code generate the required #\n # statement for each type. No args. #\n # #\n # The ImportTemplate collects everything #\n # into one statement. #\n # #\n #############################################\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n let set = new Set(Object.values(args))\n if (set.has(`require 'mongo'`)) return `require 'mongo'`\n return [...set].sort().join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `require 'mongo'`\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n type: *StringType\n top:\n callable: *var\n args: null\n attr: null\n id: \"top\"\n type: *IntegerType\n template: *LongTopTemplate\n argsTemplate: null\n bottom:\n callable: *var\n args: null\n attr: null\n id: \"bottom\"\n type: *IntegerType\n template: *LongBottomTemplate\n argsTemplate: null\n floatApprox:\n callable: *var\n args: null\n attr: null\n id: \"floatApprox\"\n type: *IntegerType\n template: *LongFloatApproxTemplate\n argsTemplate: null\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"TimestampFromShell\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n getTime:\n <<: *__func\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getInc:\n <<: *__func\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n t:\n callable: *var\n args: null\n attr: null\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n i:\n callable: *var\n args: null\n attr: null\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n Symbol: &SymbolType\n <<: *__type\n id: \"Symbol\"\n code: 111\n type: *ObjectType\n NumberDecimal: &Decimal128Type\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr: {}\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *ObjectIdType\n attr:\n fromDate:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n#############################################\n# Sample Templates #\n# #\n# The expected arguments are commented next #\n# to the template itself. Currently all are #\n# set to null, but to define a function #\n# replace 'null' with '!!js/function > \\n #\n# and a function defined below. #\n# #\n# See the other template files for examples #\n# #\n# Good to know: #\n# lhs is left-hand-side of the expression #\n# rhs is right-hand-side of the expression #\n# All args are strings unless noted #\n# - arg? is boolean #\n# - arg# is number #\n# #\n#############################################\nTemplates:\n ########\n # Misc #\n ########\n\n # Filter out regex flags that have translations or are unsupported.\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: ''\n y: ''\n g: ''\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: ''\n l: ''\n u: ''\n\n #############################################\n # Syntax #\n # #\n # Templates for language syntax expressions #\n # #\n #############################################\n\n DriverTemplate: &DriverTemplate !!js/function >\n (spec) => {\n comment = '# Requires the MongoDB Ruby Driver\\n# https://docs.mongodb.com/ruby-driver/master/';\n\n const getKey = k => {\n let translateKey = {\n project: 'projection',\n maxTimeMS: 'max_time_ms'\n }\n return k in translateKey ? translateKey[k] : k\n };\n const options = spec.options;\n const filter = spec.filter || {}\n delete spec.options;\n delete spec.filter\n\n const connect = `client = Mongo::Client.new('${options.uri}', :database => '${options.database}')`;\n const coll = `client.database['${options.collection}']`;\n\n if ('aggregation' in spec) {\n return `${comment}\\n\\n${connect}\\nresult = ${coll}.aggregate(${spec.aggregation})`;\n }\n\n const vars = Object.keys(spec).reduce(\n (result, k) => {\n return `${result}\\n${getKey(k)} = ${spec[k]}`;\n },\n connect\n );\n\n const args = Object.keys(spec).reduce(\n (result, k) => {\n const divider = result === '' ? '' : ',\\n';\n return `${result}${divider} ${getKey(k)}: ${getKey(k)}`;\n },\n ''\n );\n\n const cmd = `result = ${coll}.find(${filter}${args ? `, {\\n${args}\\n}` : ''})`;\n\n return `${comment}\\n\\n${vars}\\n\\n${cmd}`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('is')) {\n let not = op.includes('not') ? '!' : ''\n return `${not}${lhs}.equal?(${rhs})`\n } else if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n } else if (op === '==' || op === '===') {\n return `${lhs} == ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '';\n if (op.includes('!') || op.includes('not')) {\n str = '!';\n }\n return `${str}${rhs}.include?(${lhs})`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `${s}.div(${rhs})`;\n case '**':\n return `${s} ** ${rhs}`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosTemplate: &EosSyntaxTemplate null # No args. End-of-line\n EofTemplate: &EofSyntaxTemplate null # No args. End-of-file\n FloorDivTemplate: &FloorDivSyntaxTemplate null # Args: lhs, rhs\n PowerTemplate: &PowerSyntaxTemplate null # Args: lhs, rhs\n NewTemplate: &NewSyntaxTemplate null # Args: expression, skip?, code# [to check if meant to be skipped]\n\n #############################################\n # Literal Types #\n # #\n # Templates for literal type instance. Most #\n # get passed the literal itself as an arg. #\n # #\n #############################################\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n return `/${pattern}/${flags ? flags : ''}`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null # args: literal, argType (i.e. '_string', '_decimal' etc)\n DecimalTypeTemplate: &DecimalTypeTemplate null # args: literal, argType\n LongBasicTypeTemplate: &LongBasicTypeTemplate null # args: literal, argType\n HexTypeTemplate: &HexTypeTemplate null # args: literal, argType\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal) => {\n let offset = 0;\n\n if (\n literal.charAt(0) === '0' &&\n (literal.charAt(1) === '0' || literal.charAt(1) === 'o' || literal.charAt(1) === 'O')\n ) {\n offset = 2;\n } else if (literal.charAt(0) === '0') {\n offset = 1;\n }\n\n literal = `0o${literal.substr(offset, literal.length - 1)}`;\n\n return literal;\n }\n NumericTypeTemplate: &NumericTypeTemplate null # args: literal, argType\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null # Args: single array element, nestedness, lastElement? (note: not being used atm)\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'nil';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])} => ${arg[1]}`;\n }).join(',');\n\n return `{${pairs}${closingIndent}}`\n }\n\n #############################################\n # Symbols #\n # #\n # Templates for symbols, can be either #\n # functions or variables. #\n # #\n # The *SymbolTemplates return names and #\n # usually don't take any arguments. The #\n # *SymbolArgsTemplates are invoked for func #\n # calls. The first argument is always the #\n # lhs, i.e. the symbol returned from the #\n # corresponding SymbolTemplate. The rest of #\n # the arguments are the processed arguments #\n # passed to the original function. #\n # #\n #############################################\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function >\n () => {\n return 'BSON::Code'\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n if (code === undefined) {\n return '.new'\n }\n return !scope ? `.new(${singleStringify(code)})` : `WithScope.new(${singleStringify(code)}, ${scope})`\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, id) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n return !id ? '.new' : `(${singleStringify(id)})`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate null\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate !!js/function >\n () => {\n return 'BSON::DBRef'\n }\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate !!js/function >\n (lhs, coll, id, db) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n\n let db_string = db ? `,\\n '$db' => ${singleStringify(db)}` : ''\n return `.new(\\n '$ref' => ${singleStringify(coll)},\\n '$id' => ${id}${db_string}\\n)`\n }\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return '';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_decimal' || type === '_double') {\n return arg;\n }\n return `${arg}.to_f`;\n }\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return '';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return ''\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_integer' || type === '_long') {\n return arg;\n }\n return `${arg}.to_i`;\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '' : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `:'${newStr}'`;\n } else {\n return `${newStr}.to_sym`;\n }\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return '';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `${newStr.replace(/\\\\([\\s\\S])/g, '\\\\$1')}`;\n }\n return `/${singleStringify(pattern)}/${flags ? singleStringify(flags) : ''}`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.new(${arg})`;\n }\n return `.new('${arg}')`;\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MinKey';\n }\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate !!js/function >\n () => {\n return 'BSON::MaxKey';\n }\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate !!js/function >\n () => {\n return '.new';\n }\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BSON::Timestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `.new(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n # non bson-specific\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return '';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n const str = arg.toString();\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n return `'${newStr}'.to_f`;\n } else if (type === '_decimal' || type === '_double') {\n return newStr;\n } else {\n return `${newStr}.to_f`;\n }\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Time';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n const toStr = isString ? '.strftime(\\'%a %b %d %Y %H:%M:%S %Z\\')' : '';\n\n if (date === null) {\n return `${lhs}.new.utc${toStr}`;\n }\n\n const dateStr = [\n date.getUTCFullYear(),\n date.getUTCMonth() + 1,\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds()\n ].join(', ');\n\n return `${lhs}.utc(${dateStr})${toStr}`;\n }\n\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Time.now.utc';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate !!js/function >\n (args) => {\n return '';\n }\n\n #############################################\n # Object Attributes/Methods #\n # #\n # These're variables or functions called on #\n # instantiated objects. For example, #\n # ObjectId().isValid() or Timestamp().t #\n # #\n # They follow the same pattern with the\n # *Template/*ArgsTemplates: usually no args #\n # to the Template and lhs plus any original #\n # arguments to the ArgsTemplate. #\n # #\n #############################################\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.javascript`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate !!js/function >\n () => {\n return '';\n }\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.scope`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (arg) => {\n return `${arg}`;\n }\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_time`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.legal?`\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate null\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate null\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.database`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.collection`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.id`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate !!js/function >\n (lhs) => {\n return '${lhs}.to_s';\n }\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n DoubleValueOfTemplate: &DoubleValueOfTemplate null\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate null\n Int32ValueOfTemplate: &Int32ValueOfTemplate null\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate null\n Int32ToStringTemplate: &Int32ToStringTemplate null\n Int32ToStringArgsTemplate: &Int32ToStringArgsTemplate null\n LongEqualsTemplate: &LongEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} ==`;\n }\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongAddTemplate: &LongAddTemplate !!js/function >\n (lhs) => {\n return `${lhs} +`;\n }\n LongAddArgsTemplate: &LongAddArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongSubtractTemplate: &LongSubtractTemplate !!js/function >\n (arg) => {\n return `${arg} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (arg) => {\n return `${arg} *`;\n }\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongDivTemplate: &LongDivTemplate !!js/function >\n (lhs) => {\n return `${lhs} /`;\n }\n LongDivArgsTemplate: &LongDivArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongModuloTemplate: &LongModuloTemplate !!js/function >\n (lhs) => {\n return `${lhs} %`;\n }\n LongModuloArgsTemplate: &LongModuloArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongAndTemplate: &LongAndTemplate !!js/function >\n (lhs) => {\n return `${lhs} &`;\n }\n LongAndArgsTemplate: &LongAndArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongOrTemplate: &LongOrTemplate !!js/function >\n (lhs) => {\n return `${lhs} |`;\n }\n LongOrArgsTemplate: &LongOrArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongXorTemplate: &LongXorTemplate !!js/function >\n (lhs) => {\n return `${lhs} ^`;\n }\n LongXorArgsTemplate: &LongXorArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftLeftTemplate: &LongShiftLeftTemplate !!js/function >\n (lhs) => {\n return `${lhs} <<`;\n }\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongShiftRightTemplate: &LongShiftRightTemplate !!js/function >\n (lhs) => {\n return `${lhs} >>`;\n }\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongCompareTemplate: &LongCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} -`;\n }\n LongCompareArgsTemplate: &LongCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongIsOddTemplate: &LongIsOddTemplate !!js/function >\n (lhs) => {\n return `(${lhs} % 2) == 1`;\n }\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsZeroTemplate: &LongIsZeroTemplate !!js/function >\n (lhs) => {\n return `${lhs} == 0`;\n }\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongIsNegativeTemplate: &LongIsNegativeTemplate !!js/function >\n (lhs) => {\n return `${lhs} < 0`;\n }\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongNegateTemplate: &LongNegateTemplate !!js/function >\n () => {\n return '-';\n }\n LongNegateArgsTemplate: &LongNegateArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotTemplate: &LongNotTemplate !!js/function >\n () => {\n return '~';\n }\n LongNotArgsTemplate: &LongNotArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongNotEqualsTemplate: &LongNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} !=`;\n }\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanTemplate: &LongGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} >`;\n }\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >=`;\n }\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanTemplate: &LongLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} <`;\n }\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=`;\n }\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_f`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs} >> 32`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs} & 0x0000ffff`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampEqualsTemplate: &TimestampEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} == `;\n }\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n () => {\n return ''\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.seconds`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.increment`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `Time.at(${lhs}.increment).utc`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate null\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs} <=> `;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} != `;\n }\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} > `;\n }\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} >= `;\n }\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanTemplate: &TimestampLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs} < `;\n }\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs} <= `;\n }\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}`;\n }\n SymbolValueOfTemplate: &SymbolValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolInspectTemplate: &SymbolInspectTemplate !!js/function >\n (lhs) => {\n return `${lhs}.inspect`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n let extractRegex = (lhs) => {\n let r = /^:'(.*)'$/;\n let arr = r.exec(lhs);\n return arr ? arr[1] : ''\n\n }\n let res = extractRegex(lhs)\n return res ? `'${res}'` : `${lhs}.to_s`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.to_s`;\n }\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n\n #############################################\n # Symbol Attributes/Methods #\n # #\n # These're variables or functions called on #\n # symbols. Also called bson-utils. #\n # #\n # They are basically the same thing as #\n # object attributes/methods, but need to be #\n # distinguished since they are separate #\n # namespaces that happen to have the same #\n # name which is v confusing. #\n # #\n # For example, ObjectId().toString() is an #\n # object method, while ObjectId.fromString #\n # is a symbol attribute. These are two #\n # separate ObjectId related namespaces that #\n # don't overlap. #\n # #\n #############################################\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return '9223372036854775807';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return '-9223372036854775808';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n () => {\n return '0';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n () => {\n return '1';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n () => {\n return '-1';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}.to_i`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n () => {\n return 'BSON::Decimal128';\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `.new(${arg})`;\n }\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'BSON::ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return 'BSON::ObjectId.from_time';\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg})`;\n }\n return `(Time.at(${arg}))`;\n }\n # non bson-specific would go here, but there aren't any atm.\n\n #############################################\n # Imports #\n # #\n # Each type has a 'code' that is consistent #\n # between languages. The import templates #\n # for each code generate the required #\n # statement for each type. No args. #\n # #\n # The ImportTemplate collects everything #\n # into one statement. #\n # #\n #############################################\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n let set = new Set(Object.values(args))\n if (set.has(`require 'mongo'`)) return `require 'mongo'`\n return [...set].sort().join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `require 'mongo'`\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return `require 'bson'`\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n type: *StringType\n top:\n callable: *var\n args: null\n attr: null\n id: \"top\"\n type: *IntegerType\n template: *LongTopTemplate\n argsTemplate: null\n bottom:\n callable: *var\n args: null\n attr: null\n id: \"bottom\"\n type: *IntegerType\n template: *LongBottomTemplate\n argsTemplate: null\n floatApprox:\n callable: *var\n args: null\n attr: null\n id: \"floatApprox\"\n type: *IntegerType\n template: *LongFloatApproxTemplate\n argsTemplate: null\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"TimestampFromShell\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n getTime:\n <<: *__func\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getInc:\n <<: *__func\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n t:\n callable: *var\n args: null\n attr: null\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n i:\n callable: *var\n args: null\n attr: null\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n Symbol: &SymbolType\n <<: *__type\n id: \"Symbol\"\n code: 111\n type: *ObjectType\n NumberDecimal: &Decimal128Type\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr: {}\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *ObjectIdType\n attr:\n fromDate:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; |
{ | ||
"name": "bson-transpilers", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"apiVersion": "0.0.1", | ||
@@ -53,3 +53,3 @@ "productName": "BSON Transpilers", | ||
}, | ||
"gitHead": "2c4149184e87b8340851590663287b914d7ee63e" | ||
"gitHead": "a4e705ec6d13393d2e14e906838bb67548e7ae35" | ||
} |
@@ -6,4 +6,3 @@ # BSON-Transpilers | ||
Transpilers for building BSON documents in any language. Current support | ||
provided for `shell` `javascript` and `python` as inputs. `java`, `c#`, `node`, `shell` and `python` as | ||
outputs. | ||
provided for `shell` `javascript` and `python` as inputs. `java`, `c#`, `node`, `shell`, `python`, `ruby` and `go` as outputs. | ||
@@ -63,2 +62,53 @@ > ⚠️ `shell` output produces code that is compatible only with legacy `mongo` shell not the new `mongosh` shell. See [COMPASS-4930](https://jira.mongodb.org/browse/COMPASS-4930) for some additional context | ||
### State | ||
The `CodeGenerationVisitor` class manages a global state which is bound to the `argsTemplate` functions. This state is intended to be used as a solution for the `argsTemplate` functions to communicate with the `DriverTemplate` function. For example: | ||
```yaml | ||
ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function > | ||
(_) => { | ||
this.oneLineStatement = "Hello World"; | ||
return ''; | ||
} | ||
DriverTemplate: &DriverTemplate !!js/function > | ||
(_spec) => { | ||
return this.oneLineStatement; | ||
} | ||
``` | ||
The output of the driver syntax for this language will be the one-line statement `Hello World`. | ||
#### DeclarationStore | ||
A more practical use-case of state is to accumulate variable declarations throughout the `argsTemplate` to be rendered by the `DriverTemplate`. That is, the motivation for using `DeclarationStore` is to prepend the driver syntax with variable declarations rather than using non-idiomatic solutions such as closures. | ||
The `DeclarationStore` class maintains an internal state concerning variable declarations. For example, | ||
```javascript | ||
// within the args template | ||
(arg) => { | ||
return this.declarations.add("Temp", "objectID", (varName) => { | ||
return [ | ||
`${varName}, err := primitive.ObjectIDFromHex(${arg})`, | ||
'if err != nil {', | ||
' log.Fatal(err)', | ||
'}' | ||
].join('\n') | ||
}) | ||
} | ||
``` | ||
Note that each use of the same variable name will result in an increment being added to the declaration statement. For example, if the variable name `objectIDForTemp` is used two times the resulting declaration statements will use `objectIDForTemp` for the first declaration and `objectID2ForTemp` for the second declaration. The `add` method returns the incremented variable name, and is therefore what would be expected as the right-hand side of the statement defined by the `argsTemplate` function. | ||
The instance of the `DeclarationStore` constructed by the transpiler class is passed into the driver, syntax via state, for use: | ||
```javascript | ||
(spec) => { | ||
const comment = '// some comment' | ||
const client = 'client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(cs.String()))' | ||
return "#{comment}\n\n#{client}\n\n${this.declarations.toString()}" | ||
} | ||
``` | ||
### Errors | ||
@@ -65,0 +115,0 @@ There are a few different error classes thrown by `bson-transpilers`, each with |
Sorry, the diff of this file is too big to display
2828134
69
32104
229