diff --git a/packages/bson-transpilers/codegeneration/CodeGenerationVisitor.js b/packages/bson-transpilers/codegeneration/CodeGenerationVisitor.js index e15e9119440..10ab315ca76 100644 --- a/packages/bson-transpilers/codegeneration/CodeGenerationVisitor.js +++ b/packages/bson-transpilers/codegeneration/CodeGenerationVisitor.js @@ -109,6 +109,20 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi ); } + /** + * Some grammar definitions are written so that comparisons will chain and add + * nodes with a single child when the expression does *not* match. This is a + * helper method (right now used just by Python) that skips nodes downwards + * until a node with multiple children is found, or a node matches "goal". + * + * @param {ParserRuleContext} ctx + * @param {String} goal - Optional: the name of the child to find. + * @return {ParserRuleContext} + */ + skipFakeNodesDown(ctx, goal) { /* eslint no-unused-vars: 0 */ + return ctx; + } + _getType(ctx) { if (ctx.type !== undefined) { return ctx; @@ -157,21 +171,7 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi return null; } - - /** - * Convert between numeric types. Required so that we don't end up with - * strange conversions like 'Int32(Double(2))', and can just generate '2'. - * - * @param {Array} expectedType - types to cast to. - * @param {ParserRuleContext} ctx - ctx to cast from, if valid. - * - * @returns {String} - visited result, or null on error. - */ - castType(expectedType, ctx) { - const result = this.visit(ctx); - const typedCtx = this.findTypedNode(ctx); - const type = typedCtx.type; - + compareTypes(expectedType, type, ctx, result) { // If the types are exactly the same, just return. if (expectedType.indexOf(type) !== -1 || expectedType.indexOf(type.id) !== -1) { @@ -206,32 +206,42 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi // If the expected type is "numeric", accept the number basic & bson types if (expectedType.indexOf(this.Types._numeric) !== -1 && - (numericTypes.indexOf(type) !== -1 || (type.code === 106 || - type.code === 105 || type.code === 104))) { + (numericTypes.indexOf(type) !== -1 || (type.code === 106 || + type.code === 105 || type.code === 104))) { return result; } // If the expected type is any number, accept float/int/_numeric if ((numericTypes.some((t) => ( expectedType.indexOf(t) !== -1))) && (type.code === 106 || type.code === 105 || type.code === 104 || - type === this.Types._numeric)) { + type === this.Types._numeric)) { return result; } - return null; } /** - * Some grammar definitions are written so that comparisons will chain and add - * nodes with a single child when the expression does *not* match. This is a - * helper method (right now used just by Python) that skips nodes downwards - * until a node with multiple children is found, or a node matches "goal". + * Convert between numeric types. Required so that we don't end up with + * strange conversions like 'Int32(Double(2))', and can just generate '2'. * - * @param {ParserRuleContext} ctx - * @param {String} goal - Optional: the name of the child to find. - * @return {ParserRuleContext} + * @param {Array} expectedType - types to cast to. + * @param {ParserRuleContext} ctx - ctx to cast from, if valid. + * + * @returns {String} - visited result, or null on error. */ - skipFakeNodesDown(ctx, goal) { /* eslint no-unused-vars: 0 */ - return ctx; + castType(expectedType, ctx) { + const result = this.visit(ctx); + const typedCtx = this.findTypedNode(ctx); + let type = typedCtx.type; + + let equal = this.compareTypes(expectedType, type, ctx, result); + while (equal === null) { + if (type.type === null) { + return null; + } + type = type.type; + equal = this.compareTypes(expectedType, type, ctx, result); + } + return equal; } /** @@ -242,10 +252,12 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi * possible argument types for that index. * @param {Array} args - empty if no args. * @param {String} name - The name of the function for error reporting. + * @param {Object} namedArgs - Optional: if named arguments exist, this is the + * mapping of name to default value. * * @returns {Array} - Array containing the generated output for each argument. */ - checkArguments(expected, args, name) { + checkArguments(expected, args, name, namedArgs) { const argStr = []; if (args.length === 0) { if (expected.length === 0 || expected[0].indexOf(null) !== -1) { @@ -270,7 +282,9 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi `Argument count mismatch: too few arguments passed to '${name}'` ); } - const result = this.castType(expected[i], args[i]); + + const toCompare = this.checkNamedArgs(expected[i], args[i], namedArgs); + const result = this.castType(...toCompare); if (result === null) { const typeStr = expected[i].map((e) => { const id = e && e.id ? e.id : e; @@ -318,7 +332,7 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi // Check arguments const expectedArgs = lhsType.args; let rhs = this.checkArguments( - expectedArgs, this.getArguments(ctx), lhsType.id + expectedArgs, this.getArguments(ctx), lhsType.id, lhsType.namedArgs ); // Apply the arguments template @@ -512,7 +526,7 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi // Get the original type of the argument const expectedArgs = lhsType.args; let args = this.checkArguments( - expectedArgs, this.getArguments(ctx), lhsType.id + expectedArgs, this.getArguments(ctx), lhsType.id, lhsType.namedArgs ); let argType; @@ -601,7 +615,7 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi ctx.type = type; const args = this.checkArguments( - symbolType.args, this.getArguments(ctx), type.id + symbolType.args, this.getArguments(ctx), type.id, symbolType.namedArgs ); const expectedFlags = this.Syntax.bsonRegexFlags @@ -664,15 +678,17 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi if (argList.length === 2) { const idiomatic = this.idiomatic; this.idiomatic = false; - scope = this.visit(this.getArgumentAt(ctx, 1)); - this.idiomatic = idiomatic; - scopestr = `, ${scope}`; - if (this.findTypedNode( - this.getArgumentAt(ctx, 1)).type !== this.Types._object) { + const compareTo = this.checkNamedArgs( + [this.Types._object], this.getArgumentAt(ctx, 1), symbolType.namedArgs + ); + scope = this.castType(...compareTo); + if (scope === null) { throw new BsonTranspilersArgumentError( - 'Argument type mismatch: Code requires scope to be an object' + 'Code expects argument \'scope\' to be object' ); } + this.idiomatic = idiomatic; + scopestr = `, ${scope}`; this.requiredImports[113] = true; this.requiredImports[10] = true; } @@ -697,7 +713,7 @@ module.exports = (ANTLRVisitor) => class CodeGenerationVisitor extends ANTLRVisi } const args = this.checkArguments( - lhsType.args, this.getArguments(ctx), lhsType.id + lhsType.args, this.getArguments(ctx), lhsType.id, lhsType.namedArgs ); const isNumber = this.findTypedNode( this.getArgumentAt(ctx, 0)).type.code !== 200; diff --git a/packages/bson-transpilers/codegeneration/javascript/Visitor.js b/packages/bson-transpilers/codegeneration/javascript/Visitor.js index 9227238fa44..5243ffed3d3 100644 --- a/packages/bson-transpilers/codegeneration/javascript/Visitor.js +++ b/packages/bson-transpilers/codegeneration/javascript/Visitor.js @@ -444,6 +444,16 @@ module.exports = (CodeGenerationVisitor) => class Visitor extends CodeGeneration return name ? name.replace('_stmt', '') : 'Expression'; } + /** + * There are no named arguments in javascript, so we can just return directly. + * @param {Array} expected + * @param {ParserRuleContext} node + * @return {Array} + */ + checkNamedArgs(expected, node) { + return [expected, node]; + } + /** * Execute javascript in a sandbox. * diff --git a/packages/bson-transpilers/codegeneration/python/Visitor.js b/packages/bson-transpilers/codegeneration/python/Visitor.js index 5777d34a064..e97dffafb18 100644 --- a/packages/bson-transpilers/codegeneration/python/Visitor.js +++ b/packages/bson-transpilers/codegeneration/python/Visitor.js @@ -314,63 +314,6 @@ module.exports = (CodeGenerationVisitor) => class Visitor extends CodeGeneration return this.generateNumericClass(ctx); } - executeJavascript(input) { - const sandbox = { - RegExp: RegExp - }; - const ctx = new Context(sandbox); - const res = ctx.evaluate('__result = ' + input); - ctx.destroy(); - return res; - } - - findPatternAndFlags(ctx, pythonFlags, targetFlags) { - let pattern; - - const symbolType = this.Symbols.re.attr.compile; - const argList = this.getArguments(ctx); - const args = this.checkArguments(symbolType.args, argList, symbolType.id); - - // Compile regex without flags - const raw = this.getArgumentAt(ctx, 0).getText(); - let str = raw.replace(/^([rubf]?[rubf]["']|'''|"""|'|")/gi, ''); - str = str.replace(/(["]{3}|["]|[']{3}|['])$/, ''); - try { - const regexobj = this.executeJavascript(`new RegExp(${raw.substr(-1)}${str}${raw.substr(-1)})`); - pattern = regexobj.source; - } catch (error) { - throw new BsonTranspilersRuntimeError(error.message); - } - - // Convert flags - if (args.length === 1) { - return [pattern, targetFlags.u]; - } - - const flagsArg = this.skipFakeNodesDown(argList[1]); - let visited; - if ('expr' in flagsArg.parentCtx) { // combine bitwise flags - visited = flagsArg.xor_expr().map(f => this.visit(f)); - } else { - visited = [this.visit(flagsArg)]; - } - - const translated = visited - .map(f => pythonFlags[f]) - .filter(f => f !== undefined); - - if (visited.indexOf('256') === -1) { // default is unicode without re.A - translated.push('u'); - } - - const target = translated - .map(m => targetFlags[m]) - .filter(f => f !== undefined); - - const flags = target.sort().join(''); - return [pattern, flags]; - } - processfrom_native(ctx) { ctx.type = this.Types.BSONRegExp; const symbolType = this.Symbols.Regex; @@ -480,6 +423,63 @@ module.exports = (CodeGenerationVisitor) => class Visitor extends CodeGeneration * */ + findPatternAndFlags(ctx, pythonFlags, targetFlags) { + let pattern; + + const symbolType = this.Symbols.re.attr.compile; + const argList = this.getArguments(ctx); + const args = this.checkArguments(symbolType.args, argList, symbolType.id, symbolType.namedArgs); + + // Compile regex without flags + const raw = this.getArgumentAt(ctx, 0).getText(); + let str = raw.replace(/^([rubf]?[rubf]["']|'''|"""|'|")/gi, ''); + str = str.replace(/(["]{3}|["]|[']{3}|['])$/, ''); + const input = `new RegExp(${raw.substr(-1)}${str}${raw.substr(-1)})`; + try { + const sandbox = { + RegExp: RegExp + }; + const context = new Context(sandbox); + const regexobj = context.evaluate('__result = ' + input); + context.destroy(); + pattern = regexobj.source; + } catch (error) { + throw new BsonTranspilersRuntimeError(error.message); + } + + // Convert flags + if (args.length === 1) { + return [pattern, targetFlags.u]; + } + + let flagsArg = argList[1]; + flagsArg = this.skipFakeNodesDown(this.checkNamedArgs( + [this.Types._integer], flagsArg, symbolType.namedArgs + )[1]); + let visited; + if ('expr' in flagsArg.parentCtx) { // combine bitwise flags + visited = flagsArg.xor_expr().map(f => this.visit(f)); + } else { + visited = [this.visit(flagsArg)]; + } + + const translated = visited + .map(f => pythonFlags[f]) + .filter(f => f !== undefined); + + if (visited.indexOf('256') === -1) { // default is unicode without re.A + translated.push('u'); + } + + const target = translated + .map(m => targetFlags[m]) + .filter(f => f !== undefined); + + const flags = target.sort().join(''); + return [pattern, flags]; + } + + /** * Want to throw unimplemented for comprehensions instead of reference errors. * @param {ParserRuleContext} ctx @@ -556,6 +556,31 @@ module.exports = (CodeGenerationVisitor) => class Visitor extends CodeGeneration return name ? name.replace('_stmt', '') : 'Expression'; } + /** + * If a named argument is passed in, then check against the 'namedArgs' array + * instead of positionally. + * + * @param {Array} expected + * @param {ParserRuleContext} node + * @param {Object} namedArgs + * @return {Array} + */ + checkNamedArgs(expected, node, namedArgs) { + const child = this.skipFakeNodesDown(node); + if (namedArgs && 'test' in child && child.test().length > 1) { + const name = child.test()[0].getText(); + const value = child.test()[1]; + const expectedType = namedArgs[name]; + if (expectedType === undefined) { + throw new BsonTranspilersArgumentError( + `Unknown named argument '${name}'` + ); + } + return [expectedType.type, value]; + } + return [expected, node]; + } + /* * * Accessor Functions. diff --git a/packages/bson-transpilers/grammars/Python3.g4 b/packages/bson-transpilers/grammars/Python3.g4 index 365a7d19ed7..cabf42c0acc 100644 --- a/packages/bson-transpilers/grammars/Python3.g4 +++ b/packages/bson-transpilers/grammars/Python3.g4 @@ -304,6 +304,12 @@ argument: ( test (comp_for)? | test '=' test | '**' test | '*' test ); +//argument +// : test (comp_for)? #RegularArg +// | test '=' test #KeywordArg +// | '**' test #DoubleStarArg +// | '*' test #SingleStarArg +// ; comp_iter: comp_for | comp_if; comp_for: (ASYNC)? 'for' exprlist 'in' or_test (comp_iter)?; diff --git a/packages/bson-transpilers/lib/symbol-table/pythontocsharp.js b/packages/bson-transpilers/lib/symbol-table/pythontocsharp.js index f7fe3a424fb..e55d6dba1a3 100644 --- a/packages/bson-transpilers/lib/symbol-table/pythontocsharp.js +++ b/packages/bson-transpilers/lib/symbol-table/pythontocsharp.js @@ -1 +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# C# Templates\nTemplates:\n # Misc\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: 's'\n l: ''\n u: ''\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n }\n else {\n return `${lhs} == ${rhs}`;\n }\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 `${rhs}.indexOf(${lhs}) ${str} -1`\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 EosSyntaxTemplate: &EosSyntaxTemplate null\n EofTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array\n // So far: [Symbol, Decimal128/NumberDecimal, Long/NumberLong, MinKey, MaxKey, Date.now, Double, Int32, Number, Date]\n noNew = [111, 112, 106, 107, 108, 200.1, 104, 105, 2, 200];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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 flags = flags === '' ? '' : `(?${flags})`;\n // Double-quote stringify\n const str = flags + 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 return `Regex(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal) => {\n literal = literal.replace(/[oO]+/g, '0')\n return parseInt(literal, 8).toString()\n }\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const initialIndent = '\\n' + ' '.repeat(depth-1);\n if (literal === '') {\n return 'new BsonArray()'\n }\n\n return `new BsonArray${initialIndent}{${literal}${initialIndent}}`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate !!js/function >\n (arg, depth, last) => {\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const arr = arg.split(', new').join(`, ${indent}new`)\n\n return last ? `${indent}${arr}` : `${indent}${arr},`;\n }\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'BsonNull.Value';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'BsonUndefined.Value';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return `new BsonDocument()`;\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return 'new BsonDocument()';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const initialIndent = '\\n' + ' '.repeat(depth-1);\n const doubleStringify = (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 if (args.length === 1) {\n return `new BsonDocument(${doubleStringify(args[0][0])}, ${args[0][1]})`;\n }\n\n const pairs = args.map((pair) => {\n return `${indent}{ ${doubleStringify(pair[0])}, ${pair[1]} }`;\n }).join(', ');\n\n return `new BsonDocument${initialIndent}{${pairs}${initialIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Code`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Scope`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n # Since in python, generated from attr access instead of func call, add () in template.\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Equals`;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n if (arg.indexOf('new') === 0) {\n arg = arg.replace(/new /g, '')\n }\n return `(new ${arg})`;\n }\n\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Timestamp`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate !!js/function >\n () => {\n return '';\n }\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Bytes.Length`;\n }\n BinaryToStringTemplate: &BinaryToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.SubType`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.DatabaseName`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.CollectionName`;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Id`;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\n DoubleValueOfTemplate: &DoubleValueOfTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Int32ValueOfTemplate: &Int32ValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Int32ToStringTemplate: &Int32ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\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 `(int) ${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongValueOfTemplate: &LongValueOfTemplate !!js/function >\n (lhs) => {\n return `(int) ${lhs}`;\n }\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `(double) ${lhs}`;\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 (lhs) => {\n return `${lhs} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (lhs) => {\n return `${lhs} *`;\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}`;\n }\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate !!js/function >\n () => {\n return ' % 2 == 1';\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 `(float) ${lhs}`;\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}.ToString`;\n }\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Equals`;\n }\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToUniversalTime`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Increment`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToUniversalTime()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.Increment`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new DateTime(1970, 1, 1).AddSeconds(${lhs}.Timestamp)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs}.CompareTo`;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\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}`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function > # Also has process method\n () => {\n return 'BsonJavaScript';\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n // Double quote stringify\n let newStr = code === undefined ? '' : code;\n const str = newStr;\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 code = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n return (scope === undefined) ? `(${code})` : `WithScope(${code}, ${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'BsonBinaryData';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, bytes, type) => {\n const str = bytes;\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 bytes = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n\n if (type === null) {\n return `(System.Text.Encoding.ASCII.GetBytes(${bytes}))`;\n }\n return `(System.Text.Encoding.ASCII.GetBytes(${bytes}), ${type})`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.Binary';\n }\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.Function';\n }\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.OldBinary';\n }\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UuidLegacy';\n }\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UuidStandard';\n }\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template !!js/function >\n () => {\n return 'BsonBinarySubType.MD5';\n }\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UserDefined';\n }\n DBRefSymbolTemplate: &DBRefSymbolTemplate !!js/function >\n () => {\n return 'MongoDBRef';\n }\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\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\n if (type === '_hex') {\n return `Convert.ToDouble(${arg})`;\n }\n if (type === '_string') {\n return `Convert.ToDouble(${arg})`;\n }\n\n if (type === '_decimal') {\n return arg;\n }\n\n return `${Math.round(arg).toFixed(1)}`;\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\n if (type === '_hex' || type === '_decimal' || type === '_string') {\n return `Convert.ToInt32(${arg})`;\n }\n\n return arg;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function > \n (lhs, arg) => {\n if (!arg || arg.length === 0) {\n arg = '0';\n }\n if (arg.indexOf('\\'') === 0 || arg.indexOf('\"') === 0) {\n return `Convert.ToInt64(${arg})`;\n }\n return `${arg}L`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return 'Int64.MaxValue';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return 'Int64.MinValue';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n (lhs) => {\n return '0L';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n (lhs) => {\n return '1L';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n (lhs) => {\n return '-1L';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function > # Also has process method\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}L`;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n () => {\n return 'Convert.ToInt64';\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n if (arg2) {\n return `(${arg1}, ${arg2})`\n }\n return `(${arg1}, 10)`\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate !!js/function >\n () => {\n return 'BsonMinKey';\n }\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate !!js/function >\n () => {\n return '.Value';\n }\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate !!js/function >\n () => {\n return 'BsonMaxKey';\n }\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate !!js/function >\n () => {\n return '.Value';\n }\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BsonTimestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n if (typeof arg1 === 'undefined') {\n return '(0, 0)'\n }\n return `(${arg1}, ${arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (_, arg) => {\n return arg; // no parens because generates as a string\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BsonRegularExpression';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const doubleStringify = (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 `(${doubleStringify(pattern)}${flags ? ', ' + doubleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (_, str) => { // just stringify\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 `.Parse(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Parse`;\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function > \n (lhs, arg) => {\n return `(${arg})`;\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `new ObjectId.GenerateNewId`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (isNumber) {\n return `(Convert.ToInt32(${arg}))`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate !!js/function >\n () => {\n return '';\n }\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\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\n if (type === '_string') {\n if (arg.indexOf('.') !== -1) {\n return `float.Parse(${arg})`\n }\n return `int.Parse(${arg})`;\n }\n\n if (arg.indexOf('.') !== -1) {\n return `(float) ${arg}`\n }\n return `(int) ${arg}`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'DateTime';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n let toStr = isString? '.ToString(\"ddd MMM dd yyyy HH\\':\\'mm\\':\\'ss UTC\")' : '';\n\n if (date === null) {\n return `${lhs}.Now${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 `new ${lhs}(${dateStr})${toStr}`;\n }\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'DateTime.Now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate !!js/function >\n () => {\n return '';\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function > # Also has process method\n () => {\n return 'Regex';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const universal = ['using MongoDB.Bson;', 'using MongoDB.Driver;'];\n const all = universal.concat(Object.values(args));\n return all.join('\\n');\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 !!js/function >\n () => {\n return 'using System.Text.RegularExpressions;';\n }\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate null\n 101ImportTemplate: &101ImportTemplate null\n 102ImportTemplate: &102ImportTemplate null\n 103ImportTemplate: &103ImportTemplate null\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate null\n 108ImportTemplate: &108ImportTemplate null\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate null\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate null\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate !!js/function >\n () => {\n return 'using System;';\n }\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 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, 'oid' ]\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, 'database' ]\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, 'flags' ]\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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 type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\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# C# Templates\nTemplates:\n # Misc\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: 's'\n l: ''\n u: ''\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n }\n else {\n return `${lhs} == ${rhs}`;\n }\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 `${rhs}.indexOf(${lhs}) ${str} -1`\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 EosSyntaxTemplate: &EosSyntaxTemplate null\n EofTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array\n // So far: [Symbol, Decimal128/NumberDecimal, Long/NumberLong, MinKey, MaxKey, Date.now, Double, Int32, Number, Date]\n noNew = [111, 112, 106, 107, 108, 200.1, 104, 105, 2, 200];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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 flags = flags === '' ? '' : `(?${flags})`;\n // Double-quote stringify\n const str = flags + 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 return `Regex(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal) => {\n literal = literal.replace(/[oO]+/g, '0')\n return parseInt(literal, 8).toString()\n }\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const initialIndent = '\\n' + ' '.repeat(depth-1);\n if (literal === '') {\n return 'new BsonArray()'\n }\n\n return `new BsonArray${initialIndent}{${literal}${initialIndent}}`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate !!js/function >\n (arg, depth, last) => {\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const arr = arg.split(', new').join(`, ${indent}new`)\n\n return last ? `${indent}${arr}` : `${indent}${arr},`;\n }\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'BsonNull.Value';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'BsonUndefined.Value';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return `new BsonDocument()`;\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return 'new BsonDocument()';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const initialIndent = '\\n' + ' '.repeat(depth-1);\n const doubleStringify = (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 if (args.length === 1) {\n return `new BsonDocument(${doubleStringify(args[0][0])}, ${args[0][1]})`;\n }\n\n const pairs = args.map((pair) => {\n return `${indent}{ ${doubleStringify(pair[0])}, ${pair[1]} }`;\n }).join(', ');\n\n return `new BsonDocument${initialIndent}{${pairs}${initialIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Code`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Scope`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n # Since in python, generated from attr access instead of func call, add () in template.\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Equals`;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n if (arg.indexOf('new') === 0) {\n arg = arg.replace(/new /g, '')\n }\n return `(new ${arg})`;\n }\n\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Timestamp`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate !!js/function >\n () => {\n return '';\n }\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Bytes.Length`;\n }\n BinaryToStringTemplate: &BinaryToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.SubType`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.DatabaseName`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.CollectionName`;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Id`;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\n DoubleValueOfTemplate: &DoubleValueOfTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Int32ValueOfTemplate: &Int32ValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n Int32ToStringTemplate: &Int32ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\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 `(int) ${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongValueOfTemplate: &LongValueOfTemplate !!js/function >\n (lhs) => {\n return `(int) ${lhs}`;\n }\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `(double) ${lhs}`;\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 (lhs) => {\n return `${lhs} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (lhs) => {\n return `${lhs} *`;\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}`;\n }\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate !!js/function >\n () => {\n return ' % 2 == 1';\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 `(float) ${lhs}`;\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}.ToString`;\n }\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Equals`;\n }\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToUniversalTime`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Increment`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n (lhs) => {\n return '';\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToUniversalTime()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.Increment`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new DateTime(1970, 1, 1).AddSeconds(${lhs}.Timestamp)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs}.CompareTo`;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\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}`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function > # Also has process method\n () => {\n return 'BsonJavaScript';\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n // Double quote stringify\n let newStr = code === undefined ? '' : code;\n const str = newStr;\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 code = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n return (scope === undefined) ? `(${code})` : `WithScope(${code}, ${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'BsonBinaryData';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, bytes, type) => {\n const str = bytes;\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 bytes = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n\n if (type === null) {\n return `(System.Text.Encoding.ASCII.GetBytes(${bytes}))`;\n }\n return `(System.Text.Encoding.ASCII.GetBytes(${bytes}), ${type})`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.Binary';\n }\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.Function';\n }\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.OldBinary';\n }\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UuidLegacy';\n }\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UuidStandard';\n }\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template !!js/function >\n () => {\n return 'BsonBinarySubType.MD5';\n }\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UserDefined';\n }\n DBRefSymbolTemplate: &DBRefSymbolTemplate !!js/function >\n () => {\n return 'MongoDBRef';\n }\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\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\n if (type === '_hex') {\n return `Convert.ToDouble(${arg})`;\n }\n if (type === '_string') {\n return `Convert.ToDouble(${arg})`;\n }\n\n if (type === '_decimal') {\n return arg;\n }\n\n return `${Math.round(arg).toFixed(1)}`;\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\n if (type === '_hex' || type === '_decimal' || type === '_string') {\n return `Convert.ToInt32(${arg})`;\n }\n\n return arg;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function > \n (lhs, arg) => {\n if (!arg || arg.length === 0) {\n arg = '0';\n }\n if (arg.indexOf('\\'') === 0 || arg.indexOf('\"') === 0) {\n return `Convert.ToInt64(${arg})`;\n }\n return `${arg}L`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return 'Int64.MaxValue';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return 'Int64.MinValue';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n (lhs) => {\n return '0L';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n (lhs) => {\n return '1L';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n (lhs) => {\n return '-1L';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function > # Also has process method\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}L`;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n () => {\n return 'Convert.ToInt64';\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n if (arg2) {\n return `(${arg1}, ${arg2})`\n }\n return `(${arg1}, 10)`\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate !!js/function >\n () => {\n return 'BsonMinKey';\n }\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate !!js/function >\n () => {\n return '.Value';\n }\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate !!js/function >\n () => {\n return 'BsonMaxKey';\n }\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate !!js/function >\n () => {\n return '.Value';\n }\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BsonTimestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n if (typeof arg1 === 'undefined') {\n return '(0, 0)'\n }\n return `(${arg1}, ${arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (_, arg) => {\n return arg; // no parens because generates as a string\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BsonRegularExpression';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const doubleStringify = (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 `(${doubleStringify(pattern)}${flags ? ', ' + doubleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (_, str) => { // just stringify\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 `.Parse(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.Parse`;\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function > \n (lhs, arg) => {\n return `(${arg})`;\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.ToString`;\n }\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `new ObjectId.GenerateNewId`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (isNumber) {\n return `(Convert.ToInt32(${arg}))`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate !!js/function >\n () => {\n return '';\n }\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\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\n if (type === '_string') {\n if (arg.indexOf('.') !== -1) {\n return `float.Parse(${arg})`\n }\n return `int.Parse(${arg})`;\n }\n\n if (arg.indexOf('.') !== -1) {\n return `(float) ${arg}`\n }\n return `(int) ${arg}`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'DateTime';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n let toStr = isString? '.ToString(\"ddd MMM dd yyyy HH\\':\\'mm\\':\\'ss UTC\")' : '';\n\n if (date === null) {\n return `${lhs}.Now${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 `new ${lhs}(${dateStr})${toStr}`;\n }\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'DateTime.Now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate !!js/function >\n () => {\n return '';\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function > # Also has process method\n () => {\n return 'Regex';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const universal = ['using MongoDB.Bson;', 'using MongoDB.Driver;'];\n const all = universal.concat(Object.values(args));\n return all.join('\\n');\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 !!js/function >\n () => {\n return 'using System.Text.RegularExpressions;';\n }\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate null\n 101ImportTemplate: &101ImportTemplate null\n 102ImportTemplate: &102ImportTemplate null\n 103ImportTemplate: &103ImportTemplate null\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate null\n 108ImportTemplate: &108ImportTemplate null\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate null\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate null\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate !!js/function >\n () => {\n return 'using System;';\n }\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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"; diff --git a/packages/bson-transpilers/lib/symbol-table/pythontojava.js b/packages/bson-transpilers/lib/symbol-table/pythontojava.js index 8c6ad092fab..724ada534ac 100644 --- a/packages/bson-transpilers/lib/symbol-table/pythontojava.js +++ b/packages/bson-transpilers/lib/symbol-table/pythontojava.js @@ -1 +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# Java Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: ''\n g: ''\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n }\n else {\n return `${lhs} == ${rhs}`;\n }\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}.contains(${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 EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add codes of classes that don't need new.\n // Currently: Decimal128/NumberDecimal, Long/NumberLong, Double, Int32, Number, regex, Date\n noNew = [112, 106, 104, 105, 2, 8, 200];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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 flags = flags === '' ? '' : `(?${flags})`;\n // Double escape characters except for slashes\n const escaped = pattern.replace(/\\\\/, '\\\\\\\\');\n\n // Double-quote stringify\n const str = escaped + flags;\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 `Pattern.compile(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate !!js/function >\n (literal, type) => {\n if (type === '_integer' || type === '_long' || type === '_decimal') {\n return `${literal}d`;\n }\n return `(double) ${literal}`;\n }\n LongBasicTypeTemplate: &LongBasicTypeTemplate !!js/function >\n (literal, type) => {\n if (type === '_integer' || type === '_long') {\n return `${literal}L`;\n }\n return `new Long(${literal})`;\n }\n HexTypeTemplate: &HexTypeTemplate null # TODO\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal, type) => {\n if ((literal.charAt(0) === '0' && literal.charAt(1) === '0') ||\n (literal.charAt(0) === '0' && (literal.charAt(1) === 'o' || literal.charAt(1) === 'O'))) {\n return `0${literal.substr(2, literal.length - 1)}`;\n }\n return literal;\n }\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n // TODO: figure out how to best do depth in an array and where to\n // insert and indent\n const indent = '\\n' + ' '.repeat(depth);\n // have an indent on every ', new Document' in an array not\n // entirely perfect, but at least makes this more readable/also\n // compiles\n const arr = literal.split(', new').join(`, ${indent}new`)\n\n return `Arrays.asList(${arr})`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'new BsonNull()';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'new BsonUndefined()';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal, depth) => {\n\n if (literal === '') {\n return `new Document()`;\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return 'new Document()';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const doubleStringify = (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 start = `new Document(${doubleStringify(args[0][0])}, ${args[0][1]})`;\n\n args = args.slice(1);\n const result = args.reduce((str, pair) => {\n return `${str}${indent}.append(${doubleStringify(pair[0])}, ${pair[1]})`;\n }, start);\n\n return `${result}`;\n }\n DoubleTypeTemplate: &DoubleTypeTemplate !!js/function >\n (literal, type) => {\n if (type === '_integer' || type === '_long' || type === '_decimal') {\n return `${literal}d`;\n }\n return `(double) ${literal}`;\n }\n DoubleTypeArgsTemplate: &DoubleTypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongTypeTemplate: &LongTemplate !!js/function >\n () => {\n return '';\n }\n LongTypeArgsTemplate: &LongSymbolArgsTemplate null\n # BSON Object Method templates\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toHexString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getCode()`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getScope()`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getData`;\n }\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getType()`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getDatabaseName()`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getCollectionName()`;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getId()`;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate null\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\n DoubleValueOfTemplate: &DoubleValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n Int32ValueOfTemplate: &Int32ValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n Int32ToStringTemplate: &Int32ToStringTemplate !!js/function >\n () => {\n return '';\n }\n Int32ToStringArgsTemplate: &Int32ToStringArgsTemplate !!js/function >\n (lhs) => {\n return `Integer.toString(${lhs})`;\n }\n LongEqualsTemplate: &LongEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} ==`;\n }\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `(int) ${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongValueOfTemplate: &LongValueOfTemplate !!js/function >\n (lhs) => {\n return `(int) ${lhs}`;\n }\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `(double) ${lhs}`;\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 () => {\n return 'Long.rotateLeft';\n }\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${lhs}, ${arg})`;\n }\n LongShiftRightTemplate: &LongShiftRightTemplate !!js/function >\n () => {\n return 'Long.rotateRight';\n }\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${lhs}, ${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 `(float) ${lhs}`;\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 null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTime`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTime()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getTime())`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) != 0`;\n }\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) > 0`;\n }\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) >= 0`;\n }\n TimestampLessThanTemplate: &TimestampLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) < 0`;\n }\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) <= 0`;\n }\n SymbolValueOfTemplate: &SymbolValueOfTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getSymbol`;\n }\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getSymbol`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function > # Also has process method\n () => {\n return 'Code';\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function > # Also has process method\n (lhs, code, scope) => {\n // Double quote stringify\n let newStr = code === undefined ? '' : code;\n const str = newStr;\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 code = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n return (scope === undefined) ? `(${code})` : `WithScope(${code}, ${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, bytes, type) => {\n const str = bytes;\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 bytes = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n\n if (type === null) {\n return `(${bytes}.getBytes(\"UTF-8\"))`;\n }\n return `(${type}, ${bytes}.getBytes(\"UTF-8\"))`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.BINARY';\n }\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.FUNCTION';\n }\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.BINARY';\n }\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UUID_LEGACY';\n }\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UUID_STANDARD';\n }\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template !!js/function >\n () => {\n return 'BsonBinarySubType.MD5';\n }\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.USER_DEFINED';\n }\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate !!js/function >\n (lhs, coll, id, db) => {\n const dbstr = db === undefined ? '' : `${db}, `;\n return `(${dbstr}${coll}, ${id})`;\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 === '_string') {\n return `Double.parseDouble(${arg})`;\n }\n if (type === '_integer' || type === '_long' || type === '_double' || type === '_decimal') {\n if (arg.includes('L') || arg.includes('d')) {\n return `${arg.substr(0, arg.length - 1)}d`;\n }\n return `${arg}d`;\n }\n return `(double) ${arg}`;\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 === '_string') {\n return `Integer.parseInt(${arg})`;\n }\n if (type === '_integer' || type === '_long') {\n if (arg.includes('L') || arg.includes('d')) {\n return arg.substr(0, arg.length - 1);\n }\n return arg;\n }\n return `(int) ${arg}`;\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 === '_string') {\n return `Long.parseLong(${arg})`;\n }\n if (type === '_integer' || type === '_long') {\n if (arg.includes('d') || arg.includes('L')) {\n return `${arg.substr(0, arg.length - 1)}L`;\n }\n return `${arg}L`;\n }\n return `new Long(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return 'Long.MAX_VALUE';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return 'Long.MIN_VALUE';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n () => {\n return '0L';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n () => {\n return '1L';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n () => {\n return '-1L';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function > # Also has process method\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}L`;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}L`;\n }\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `Long.parseLong`;\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BSONTimestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate null\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BsonRegularExpression';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const doubleStringify = (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 `(${doubleStringify(pattern)}${flags ? ', ' + doubleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (_, str) => { // just stringify\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 `.parse(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.parse`;\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'new ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return 'new ObjectId';\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (isNumber) {\n return `(new java.util.Date(${arg}))`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n () => {\n return 'ObjectId.isValid';\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate !!js/function >\n () => {\n return '';\n }\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\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 if (type === '_string') {\n return `Double.parseDouble(${arg})`;\n }\n if (type === '_integer' || type === '_long' || type === '_decimal') {\n if (arg.includes('L') || arg.includes('d')) {\n return `${arg.substr(0, arg.length - 1)}d`;\n }\n return `${arg}d`;\n }\n return `(double) ${arg}`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'java.util.Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n let toStr = (d) => d;\n if (isString) {\n toStr = (d) => `new SimpleDateFormat(\"EEE MMMMM dd yyyy HH:mm:ss\").format(${d})`;\n }\n if (date === null) {\n return toStr(`new ${lhs}()`);\n }\n return toStr(`new ${lhs}(${date.getTime()}L)`);\n }\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'java.util.Date';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'Pattern';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate null\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 !!js/function >\n () => {\n return 'import java.util.regex.Pattern;';\n }\n 9ImportTemplate: &9ImportTemplate !!js/function >\n () => {\n return 'import java.util.Arrays;';\n }\n 10ImportTemplate: &10ImportTemplate !!js/function >\n () => {\n return 'import org.bson.Document;';\n }\n 11ImportTemplate: &11ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonNull;';\n }\n 12ImportTemplate: &12ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonUndefined;';\n }\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Code;';\n }\n 113ImportTemplate: &113ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.CodeWithScope;';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.ObjectId;';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Binary;';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'import com.mongodb.DBRef;';\n }\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.MinKey;';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.MaxKey;';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonRegularExpression;';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.BSONTimestamp;';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Symbol;';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Decimal128;';\n }\n 114ImportTemplate: &114ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonBinarySubType;';\n }\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate !!js/function >\n () => {\n return 'import java.text.SimpleDateFormat;';\n }\n 300ImportTemplate: &300ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i && f !== 'options'))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Filters.${c};`;\n }).join('\\n');\n }\n 301ImportTemplate: &301ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Aggregates.${c};`;\n }).join('\\n');\n }\n 302ImportTemplate: &302ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Accumulators.${c};`;\n }).join('\\n');\n }\n 303ImportTemplate: &303ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Projections.${c};`;\n }).join('\\n');\n }\n 304ImportTemplate: &304ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Sorts.${c};`;\n }).join('\\n');\n }\n 305ImportTemplate: &305ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import com.mongodb.client.model.geojson.${c};`;\n }).join('\\n');\n }\n 306ImportTemplate: &306ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import com.mongodb.client.model.${c};`;\n }).join('\\n');\n }\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 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, 'oid' ]\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, 'database' ]\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, 'flags' ]\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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 type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\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# Java Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: ''\n g: ''\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} != ${rhs}`;\n }\n else {\n return `${lhs} == ${rhs}`;\n }\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}.contains(${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 EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add codes of classes that don't need new.\n // Currently: Decimal128/NumberDecimal, Long/NumberLong, Double, Int32, Number, regex, Date\n noNew = [112, 106, 104, 105, 2, 8, 200];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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 flags = flags === '' ? '' : `(?${flags})`;\n // Double escape characters except for slashes\n const escaped = pattern.replace(/\\\\/, '\\\\\\\\');\n\n // Double-quote stringify\n const str = escaped + flags;\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 `Pattern.compile(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate !!js/function >\n (literal, type) => {\n if (type === '_integer' || type === '_long' || type === '_decimal') {\n return `${literal}d`;\n }\n return `(double) ${literal}`;\n }\n LongBasicTypeTemplate: &LongBasicTypeTemplate !!js/function >\n (literal, type) => {\n if (type === '_integer' || type === '_long') {\n return `${literal}L`;\n }\n return `new Long(${literal})`;\n }\n HexTypeTemplate: &HexTypeTemplate null # TODO\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (literal, type) => {\n if ((literal.charAt(0) === '0' && literal.charAt(1) === '0') ||\n (literal.charAt(0) === '0' && (literal.charAt(1) === 'o' || literal.charAt(1) === 'O'))) {\n return `0${literal.substr(2, literal.length - 1)}`;\n }\n return literal;\n }\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n // TODO: figure out how to best do depth in an array and where to\n // insert and indent\n const indent = '\\n' + ' '.repeat(depth);\n // have an indent on every ', new Document' in an array not\n // entirely perfect, but at least makes this more readable/also\n // compiles\n const arr = literal.split(', new').join(`, ${indent}new`)\n\n return `Arrays.asList(${arr})`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'new BsonNull()';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'new BsonUndefined()';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal, depth) => {\n\n if (literal === '') {\n return `new Document()`;\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return 'new Document()';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const doubleStringify = (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 start = `new Document(${doubleStringify(args[0][0])}, ${args[0][1]})`;\n\n args = args.slice(1);\n const result = args.reduce((str, pair) => {\n return `${str}${indent}.append(${doubleStringify(pair[0])}, ${pair[1]})`;\n }, start);\n\n return `${result}`;\n }\n DoubleTypeTemplate: &DoubleTypeTemplate !!js/function >\n (literal, type) => {\n if (type === '_integer' || type === '_long' || type === '_decimal') {\n return `${literal}d`;\n }\n return `(double) ${literal}`;\n }\n DoubleTypeArgsTemplate: &DoubleTypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongTypeTemplate: &LongTemplate !!js/function >\n () => {\n return '';\n }\n LongTypeArgsTemplate: &LongSymbolArgsTemplate null\n # BSON Object Method templates\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toHexString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n CodeCodeTemplate: &CodeCodeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getCode()`;\n }\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getScope()`;\n }\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getData`;\n }\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getType()`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getDatabaseName()`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getCollectionName()`;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getId()`;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate null\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\n DoubleValueOfTemplate: &DoubleValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n Int32ValueOfTemplate: &Int32ValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n Int32ValueOfArgsTemplate: &Int32ValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n Int32ToStringTemplate: &Int32ToStringTemplate !!js/function >\n () => {\n return '';\n }\n Int32ToStringArgsTemplate: &Int32ToStringArgsTemplate !!js/function >\n (lhs) => {\n return `Integer.toString(${lhs})`;\n }\n LongEqualsTemplate: &LongEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs} ==`;\n }\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `(int) ${lhs}`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongValueOfTemplate: &LongValueOfTemplate !!js/function >\n (lhs) => {\n return `(int) ${lhs}`;\n }\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `(double) ${lhs}`;\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 () => {\n return 'Long.rotateLeft';\n }\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${lhs}, ${arg})`;\n }\n LongShiftRightTemplate: &LongShiftRightTemplate !!js/function >\n () => {\n return 'Long.rotateRight';\n }\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${lhs}, ${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 `(float) ${lhs}`;\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 null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTime`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTime()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getTime())`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) != 0`;\n }\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) > 0`;\n }\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) >= 0`;\n }\n TimestampLessThanTemplate: &TimestampLessThanTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) < 0`;\n }\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate !!js/function >\n (lhs) => {\n return `${lhs}.compareTo`;\n }\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg}) <= 0`;\n }\n SymbolValueOfTemplate: &SymbolValueOfTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getSymbol`;\n }\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getSymbol`;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString`;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate !!js/function > # Also has process method\n () => {\n return 'Code';\n }\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function > # Also has process method\n (lhs, code, scope) => {\n // Double quote stringify\n let newStr = code === undefined ? '' : code;\n const str = newStr;\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 code = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n return (scope === undefined) ? `(${code})` : `WithScope(${code}, ${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, bytes, type) => {\n const str = bytes;\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 bytes = `\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\"`;\n\n if (type === null) {\n return `(${bytes}.getBytes(\"UTF-8\"))`;\n }\n return `(${type}, ${bytes}.getBytes(\"UTF-8\"))`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.BINARY';\n }\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.FUNCTION';\n }\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.BINARY';\n }\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UUID_LEGACY';\n }\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.UUID_STANDARD';\n }\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template !!js/function >\n () => {\n return 'BsonBinarySubType.MD5';\n }\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate !!js/function >\n () => {\n return 'BsonBinarySubType.USER_DEFINED';\n }\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate !!js/function >\n (lhs, coll, id, db) => {\n const dbstr = db === undefined ? '' : `${db}, `;\n return `(${dbstr}${coll}, ${id})`;\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 === '_string') {\n return `Double.parseDouble(${arg})`;\n }\n if (type === '_integer' || type === '_long' || type === '_double' || type === '_decimal') {\n if (arg.includes('L') || arg.includes('d')) {\n return `${arg.substr(0, arg.length - 1)}d`;\n }\n return `${arg}d`;\n }\n return `(double) ${arg}`;\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 === '_string') {\n return `Integer.parseInt(${arg})`;\n }\n if (type === '_integer' || type === '_long') {\n if (arg.includes('L') || arg.includes('d')) {\n return arg.substr(0, arg.length - 1);\n }\n return arg;\n }\n return `(int) ${arg}`;\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 === '_string') {\n return `Long.parseLong(${arg})`;\n }\n if (type === '_integer' || type === '_long') {\n if (arg.includes('d') || arg.includes('L')) {\n return `${arg.substr(0, arg.length - 1)}L`;\n }\n return `${arg}L`;\n }\n return `new Long(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return 'Long.MAX_VALUE';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return 'Long.MIN_VALUE';\n }\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate !!js/function >\n () => {\n return '0L';\n }\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate !!js/function >\n () => {\n return '1L';\n }\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate !!js/function >\n () => {\n return '-1L';\n }\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate !!js/function > # Also has process method\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}L`;\n }\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate !!js/function >\n (lhs, arg) => {\n return `${arg}L`;\n }\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `Long.parseLong`;\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate !!js/function >\n () => {\n return 'BSONTimestamp';\n }\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate null\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BsonRegularExpression';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const doubleStringify = (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 `(${doubleStringify(pattern)}${flags ? ', ' + doubleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (_, str) => { // just stringify\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 `.parse(\"${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}\")`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.parse`;\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'new ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return 'new ObjectId';\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (isNumber) {\n return `(new java.util.Date(${arg}))`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n () => {\n return 'ObjectId.isValid';\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate !!js/function >\n () => {\n return '';\n }\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\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 if (type === '_string') {\n return `Double.parseDouble(${arg})`;\n }\n if (type === '_integer' || type === '_long' || type === '_decimal') {\n if (arg.includes('L') || arg.includes('d')) {\n return `${arg.substr(0, arg.length - 1)}d`;\n }\n return `${arg}d`;\n }\n return `(double) ${arg}`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'java.util.Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n let toStr = (d) => d;\n if (isString) {\n toStr = (d) => `new SimpleDateFormat(\"EEE MMMMM dd yyyy HH:mm:ss\").format(${d})`;\n }\n if (date === null) {\n return toStr(`new ${lhs}()`);\n }\n return toStr(`new ${lhs}(${date.getTime()}L)`);\n }\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'java.util.Date';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'Pattern';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate null\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 !!js/function >\n () => {\n return 'import java.util.regex.Pattern;';\n }\n 9ImportTemplate: &9ImportTemplate !!js/function >\n () => {\n return 'import java.util.Arrays;';\n }\n 10ImportTemplate: &10ImportTemplate !!js/function >\n () => {\n return 'import org.bson.Document;';\n }\n 11ImportTemplate: &11ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonNull;';\n }\n 12ImportTemplate: &12ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonUndefined;';\n }\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Code;';\n }\n 113ImportTemplate: &113ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.CodeWithScope;';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.ObjectId;';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Binary;';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'import com.mongodb.DBRef;';\n }\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.MinKey;';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.MaxKey;';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonRegularExpression;';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.BSONTimestamp;';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Symbol;';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'import org.bson.types.Decimal128;';\n }\n 114ImportTemplate: &114ImportTemplate !!js/function >\n () => {\n return 'import org.bson.BsonBinarySubType;';\n }\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate !!js/function >\n () => {\n return 'import java.text.SimpleDateFormat;';\n }\n 300ImportTemplate: &300ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i && f !== 'options'))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Filters.${c};`;\n }).join('\\n');\n }\n 301ImportTemplate: &301ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Aggregates.${c};`;\n }).join('\\n');\n }\n 302ImportTemplate: &302ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Accumulators.${c};`;\n }).join('\\n');\n }\n 303ImportTemplate: &303ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Projections.${c};`;\n }).join('\\n');\n }\n 304ImportTemplate: &304ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import static com.mongodb.client.model.Sorts.${c};`;\n }).join('\\n');\n }\n 305ImportTemplate: &305ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import com.mongodb.client.model.geojson.${c};`;\n }).join('\\n');\n }\n 306ImportTemplate: &306ImportTemplate !!js/function >\n (classes) => {\n return classes\n .filter((f, i) => (classes.indexOf(f) === i))\n .sort()\n .map((c) => {\n return `import com.mongodb.client.model.${c};`;\n }).join('\\n');\n }\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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"; diff --git a/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js b/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js index f916b2f2ce9..02c5aecfd1f 100644 --- a/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js +++ b/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js @@ -1 +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# Javascript Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n }\n return `${lhs} === ${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 `${rhs}.indexOf(${lhs}) ${str} -1`\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 EosTemplate: &EosSyntaxTemplate null\n EofTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Date.now, Decimal128/NumberDecimal, Long/NumberLong]\n noNew = [200.1, 112, 106];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\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\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\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 # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\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 !!js/function >\n (lhs) => {\n return `${lhs}.sub_type`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.db`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.namespace`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.oid`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate null\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\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 null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongValueOfTemplate: &LongValueOfTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate null\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate null\n LongAddTemplate: &LongAddTemplate null\n LongAddArgsTemplate: &LongAddArgsTemplate null\n LongSubtractTemplate: &LongSubtractTemplate null\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate null\n LongMultiplyTemplate: &LongMultiplyTemplate null\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate null\n LongDivTemplate: &LongDivTemplate null\n LongDivArgsTemplate: &LongDivArgsTemplate null\n LongModuloTemplate: &LongModuloTemplate null\n LongModuloArgsTemplate: &LongModuloArgsTemplate null\n LongAndTemplate: &LongAndTemplate null\n LongAndArgsTemplate: &LongAndArgsTemplate null\n LongOrTemplate: &LongOrTemplate null\n LongOrArgsTemplate: &LongOrArgsTemplate null\n LongXorTemplate: &LongXorTemplate null\n LongXorArgsTemplate: &LongXorArgsTemplate null\n LongShiftLeftTemplate: &LongShiftLeftTemplate null\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate null\n LongShiftRightTemplate: &LongShiftRightTemplate null\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate null\n LongCompareTemplate: &LongCompareTemplate null\n LongCompareArgsTemplate: &LongCompareArgsTemplate null\n LongIsOddTemplate: &LongIsOddTemplate null\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate null\n LongIsZeroTemplate: &LongIsZeroTemplate null\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate null\n LongIsNegativeTemplate: &LongIsNegativeTemplate null\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate null\n LongNegateTemplate: &LongNegateTemplate null\n LongNegateArgsTemplate: &LongNegateArgsTemplate null\n LongNotTemplate: &LongNotTemplate null\n LongNotArgsTemplate: &LongNotArgsTemplate null\n LongNotEqualsTemplate: &LongNotEqualsTemplate null\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate null\n LongGreaterThanTemplate: &LongGreaterThanTemplate null\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate null\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate null\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate null\n LongLessThanTemplate: &LongLessThanTemplate null\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate null\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate null\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate null\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toNumber()`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate null\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate null\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate null\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate null\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate null\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate null\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate null\n TimestampLessThanTemplate: &TimestampLessThanTemplate null\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate null\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate null\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate null\n SymbolValueOfTemplate: &SymbolValueOfTemplate null\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate null\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate null\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n code = code === undefined ? '\\'\\'' : code;\n scope = scope === undefined ? '' : `, ${scope}`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'Binary';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, buffer, subtype) => {\n return `(${buffer.toString('base64')}, '${subtype}')`;\n }\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 null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return 'Double';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'Int32';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\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 === '_string') {\n return `Long.fromString(${arg})`;\n }\n return `Long.fromNumber(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate null\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate null\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate null\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate null\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate null\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate null\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate null\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate null\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate null\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BSONRegExp';\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$2')}'`;\n }\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return '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 `.fromString(${arg})`;\n }\n return `.fromString('${arg}')`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.createFromTime`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg}.getTime() / 1000)`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.isValid`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate null\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate null\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg;\n return `(${arg})`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const bson = [];\n const other = [];\n Object.keys(args).map(\n (m) => {\n if (m > 99 && m < 200) {\n bson.push(args[m]);\n } else {\n other.push(args[m]);\n }\n }\n );\n if (bson.length) {\n other.push(`const {\\n ${bson.join(',\\n ')}\\n} = require('mongo');`);\n }\n return other.join('\\n');\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 'Code';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'Binary';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'DBRef';\n }\n 104ImportTemplate: &104ImportTemplate !!js/function >\n () => {\n return 'Double';\n }\n 105ImportTemplate: &105ImportTemplate !!js/function >\n () => {\n return 'Int32';\n }\n 106ImportTemplate: &106ImportTemplate !!js/function >\n () => {\n return 'Long';\n }\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'MinKey';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'MaxKey';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'Timestamp';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'Symbol';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'Decimal128';\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 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, 'oid' ]\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, 'database' ]\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, 'flags' ]\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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 type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\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# Javascript Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n }\n return `${lhs} === ${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 `${rhs}.indexOf(${lhs}) ${str} -1`\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 EosTemplate: &EosSyntaxTemplate null\n EofTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Date.now, Decimal128/NumberDecimal, Long/NumberLong]\n noNew = [200.1, 112, 106];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\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\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\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 # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\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 !!js/function >\n (lhs) => {\n return `${lhs}.sub_type`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.db`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.namespace`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.oid`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate null\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\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 null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongValueOfTemplate: &LongValueOfTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate null\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate null\n LongAddTemplate: &LongAddTemplate null\n LongAddArgsTemplate: &LongAddArgsTemplate null\n LongSubtractTemplate: &LongSubtractTemplate null\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate null\n LongMultiplyTemplate: &LongMultiplyTemplate null\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate null\n LongDivTemplate: &LongDivTemplate null\n LongDivArgsTemplate: &LongDivArgsTemplate null\n LongModuloTemplate: &LongModuloTemplate null\n LongModuloArgsTemplate: &LongModuloArgsTemplate null\n LongAndTemplate: &LongAndTemplate null\n LongAndArgsTemplate: &LongAndArgsTemplate null\n LongOrTemplate: &LongOrTemplate null\n LongOrArgsTemplate: &LongOrArgsTemplate null\n LongXorTemplate: &LongXorTemplate null\n LongXorArgsTemplate: &LongXorArgsTemplate null\n LongShiftLeftTemplate: &LongShiftLeftTemplate null\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate null\n LongShiftRightTemplate: &LongShiftRightTemplate null\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate null\n LongCompareTemplate: &LongCompareTemplate null\n LongCompareArgsTemplate: &LongCompareArgsTemplate null\n LongIsOddTemplate: &LongIsOddTemplate null\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate null\n LongIsZeroTemplate: &LongIsZeroTemplate null\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate null\n LongIsNegativeTemplate: &LongIsNegativeTemplate null\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate null\n LongNegateTemplate: &LongNegateTemplate null\n LongNegateArgsTemplate: &LongNegateArgsTemplate null\n LongNotTemplate: &LongNotTemplate null\n LongNotArgsTemplate: &LongNotArgsTemplate null\n LongNotEqualsTemplate: &LongNotEqualsTemplate null\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate null\n LongGreaterThanTemplate: &LongGreaterThanTemplate null\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate null\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate null\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate null\n LongLessThanTemplate: &LongLessThanTemplate null\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate null\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate null\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate null\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toNumber()`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate null\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate null\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate null\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate null\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate null\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate null\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate null\n TimestampLessThanTemplate: &TimestampLessThanTemplate null\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate null\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate null\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate null\n SymbolValueOfTemplate: &SymbolValueOfTemplate null\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate null\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate null\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n code = code === undefined ? '\\'\\'' : code;\n scope = scope === undefined ? '' : `, ${scope}`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'Binary';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, buffer, subtype) => {\n return `(${buffer.toString('base64')}, '${subtype}')`;\n }\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 null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return 'Double';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'Int32';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\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 === '_string') {\n return `Long.fromString(${arg})`;\n }\n return `Long.fromNumber(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate null\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate null\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate null\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate null\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate null\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate null\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate null\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate null\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate null\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BSONRegExp';\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$2')}'`;\n }\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return '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 `.fromString(${arg})`;\n }\n return `.fromString('${arg}')`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.createFromTime`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg}.getTime() / 1000)`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.isValid`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate null\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate null\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg;\n return `(${arg})`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const bson = [];\n const other = [];\n Object.keys(args).map(\n (m) => {\n if (m > 99 && m < 200) {\n bson.push(args[m]);\n } else {\n other.push(args[m]);\n }\n }\n );\n if (bson.length) {\n other.push(`const {\\n ${bson.join(',\\n ')}\\n} = require('mongo');`);\n }\n return other.join('\\n');\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 'Code';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'Binary';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'DBRef';\n }\n 104ImportTemplate: &104ImportTemplate !!js/function >\n () => {\n return 'Double';\n }\n 105ImportTemplate: &105ImportTemplate !!js/function >\n () => {\n return 'Int32';\n }\n 106ImportTemplate: &106ImportTemplate !!js/function >\n () => {\n return 'Long';\n }\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'MinKey';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'MaxKey';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'Timestamp';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'Symbol';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'Decimal128';\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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"; diff --git a/packages/bson-transpilers/lib/symbol-table/pythontoshell.js b/packages/bson-transpilers/lib/symbol-table/pythontoshell.js index 76a2f857b84..8dc2025d458 100644 --- a/packages/bson-transpilers/lib/symbol-table/pythontoshell.js +++ b/packages/bson-transpilers/lib/symbol-table/pythontoshell.js @@ -1 +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# Java Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n }\n return `${lhs} === ${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 `${rhs}.indexOf(${lhs}) ${str} -1`\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 EosTemplate: &EosSyntaxTemplate null\n EofTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Symbol, Double, Date.now]\n noNew = [111, 104, 200.1];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\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\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\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 stringify = (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 indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const pairs = args.map((arg) => {\n return `${indent}${stringify(arg[0])}: ${arg[1]}`;\n }).join(', ');\n\n return `{${pairs}${closingIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate !!js/function >\n (lhs) => {\n return `${lhs}.hex`;\n }\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.subtype()`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getDb()`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getCollection()`;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getId()`;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate null\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\n DoubleValueOfTemplate: &DoubleValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\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 LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString`;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.valueOf`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongValueOfTemplate: &LongValueOfTemplate null\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `${lhs}.floatApprox`;\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 (lhs) => {\n return `${lhs} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (lhs) => {\n return `${lhs} *`;\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}.floatValue()`;\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 null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\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}.getTime`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTime()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\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;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n scope = scope === undefined ? '' : `, ${scope}`;\n // Single quote stringify\n let newStr = code === undefined ? '' : code;\n const str = newStr;\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 code = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'BinData';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, bytes, type) => {\n const str = bytes;\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 bytes = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n\n if (type === null) {\n type = '0';\n }\n return `(${type}, ${bytes})`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate !!js/function >\n () => {\n return '0';\n }\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate !!js/function >\n () => {\n return '1';\n }\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate !!js/function >\n () => {\n return '2';\n }\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate !!js/function >\n () => {\n return '3';\n }\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate !!js/function >\n () => {\n return '4';\n }\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template !!js/function >\n () => {\n return '5';\n }\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate !!js/function >\n () => {\n return '80';\n }\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return '';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate !!js/function >\n (_, str) => {\n // Remove quotes\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;\n }\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'NumberInt';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return 'NumberLong';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return 'Math.max()';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return 'Math.min()';\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 > # Also has process method\n (lhs) => {\n return lhs;\n }\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null # Also has process method\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate null\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\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$2')}'`;\n }\n\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'NumberDecimal';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate null\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'new ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.fromDate`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (isNumber) {\n return `(new Date(${arg}))`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return 'new ObjectId';\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate null\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate null\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate null\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate null\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 null\n 101ImportTemplate: &101ImportTemplate null\n 102ImportTemplate: &102ImportTemplate null\n 103ImportTemplate: &103ImportTemplate null\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate null\n 108ImportTemplate: &108ImportTemplate null\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate null\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate null\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 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, 'oid' ]\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, 'database' ]\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, 'flags' ]\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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 type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\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# Java Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n }\n return `${lhs} === ${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 `${rhs}.indexOf(${lhs}) ${str} -1`\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 EosTemplate: &EosSyntaxTemplate null\n EofTemplate: &EofSyntaxTemplate null\n FloorDivTemplate: &FloorDivSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.floor(${lhs}, ${rhs})`;\n }\n PowerTemplate: &PowerSyntaxTemplate !!js/function >\n (lhs, rhs) => {\n return `Math.pow(${lhs}, ${rhs})`;\n }\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Symbol, Double, Date.now]\n noNew = [111, 104, 200.1];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\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$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\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\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\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 stringify = (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 indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const pairs = args.map((arg) => {\n return `${indent}${stringify(arg[0])}: ${arg[1]}`;\n }).join(', ');\n\n return `{${pairs}${closingIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate !!js/function >\n (lhs) => {\n return `${lhs}.hex`;\n }\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.subtype()`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getDb()`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getCollection()`;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getId()`;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n '';\n }\n DBRefToStringTemplate: &DBRefToStringTemplate null\n DBRefToStringArgsTemplate: &DBRefToStringArgsTemplate null\n DoubleValueOfTemplate: &DoubleValueOfTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n DoubleValueOfArgsTemplate: &DoubleValueOfArgsTemplate !!js/function >\n () => {\n return '';\n }\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 LongToStringTemplate: &LongToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString`;\n }\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.valueOf`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongValueOfTemplate: &LongValueOfTemplate null\n LongValueOfArgsTemplate: &LongValueOfArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate !!js/function >\n (lhs) => {\n return `${lhs}.floatApprox`;\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 (lhs) => {\n return `${lhs} -`;\n }\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate !!js/function >\n (lhs, arg) => {\n return ` ${arg}`;\n }\n LongMultiplyTemplate: &LongMultiplyTemplate !!js/function >\n (lhs) => {\n return `${lhs} *`;\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}.floatValue()`;\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 null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\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}.getTime`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTime()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getInc()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\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;\n }\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate !!js/function >\n () => {\n return '';\n }\n SymbolToStringTemplate: &SymbolToStringTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n scope = scope === undefined ? '' : `, ${scope}`;\n // Single quote stringify\n let newStr = code === undefined ? '' : code;\n const str = newStr;\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 code = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\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 BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'BinData';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, bytes, type) => {\n const str = bytes;\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 bytes = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n\n if (type === null) {\n type = '0';\n }\n return `(${type}, ${bytes})`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate !!js/function >\n () => {\n return '0';\n }\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate !!js/function >\n () => {\n return '1';\n }\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate !!js/function >\n () => {\n return '2';\n }\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate !!js/function >\n () => {\n return '3';\n }\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate !!js/function >\n () => {\n return '4';\n }\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template !!js/function >\n () => {\n return '5';\n }\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate !!js/function >\n () => {\n return '80';\n }\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return '';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate !!js/function >\n (_, str) => {\n // Remove quotes\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;\n }\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'NumberInt';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return 'NumberLong';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate !!js/function >\n () => {\n return 'Math.max()';\n }\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate !!js/function >\n () => {\n return 'Math.min()';\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 > # Also has process method\n (lhs) => {\n return lhs;\n }\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null # Also has process method\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate null\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return '';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n return arg;\n }\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\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$2')}'`;\n }\n\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'NumberDecimal';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate null\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate !!js/function >\n (lhs) => {\n return `new ${lhs}`;\n }\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate !!js/function >\n () => {\n return 'new ObjectId';\n }\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate !!js/function >\n (lhs, arg) => {\n return `(${arg})`;\n }\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.fromDate`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (isNumber) {\n return `(new Date(${arg}))`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return 'new ObjectId';\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n ObjectSymbolTemplate: &ObjectSymbolTemplate null\n ObjectSymbolArgsTemplate: &ObjectSymbolArgsTemplate null\n ObjectSymbolCreateTemplate: &ObjectSymbolCreateTemplate null\n ObjectSymbolCreateArgsTemplate: &ObjectSymbolCreateArgsTemplate null\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate null\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate null\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 null\n 101ImportTemplate: &101ImportTemplate null\n 102ImportTemplate: &102ImportTemplate null\n 103ImportTemplate: &103ImportTemplate null\n 104ImportTemplate: &104ImportTemplate null\n 105ImportTemplate: &105ImportTemplate null\n 106ImportTemplate: &106ImportTemplate null\n 107ImportTemplate: &107ImportTemplate null\n 108ImportTemplate: &108ImportTemplate null\n 109ImportTemplate: &109ImportTemplate null\n 110ImportTemplate: &110ImportTemplate null\n 111ImportTemplate: &111ImportTemplate null\n 112ImportTemplate: &112ImportTemplate null\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 eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n floorDiv:\n template: *FloorDivSyntaxTemplate\n power:\n template: *PowerSyntaxTemplate\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\nImports:\n import:\n template: *ImportTemplate\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 template: *CodeTypeTemplate\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 utcnow:\n id: \"now\"\n code: 200.1\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\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"; diff --git a/packages/bson-transpilers/symbols/python/symbols.yaml b/packages/bson-transpilers/symbols/python/symbols.yaml index f75b7973c1b..4a745e0aa6c 100644 --- a/packages/bson-transpilers/symbols/python/symbols.yaml +++ b/packages/bson-transpilers/symbols/python/symbols.yaml @@ -6,6 +6,10 @@ BsonSymbols: args: - [ *StringType ] - [ *ObjectType, null ] + namedArgs: + scope: + default: {} + type: [ *ObjectType ] type: *CodeType attr: {} template: *CodeSymbolTemplate @@ -15,7 +19,11 @@ BsonSymbols: code: 101 callable: *constructor args: - - [ *StringType, null, 'oid' ] + - [ *StringType, null ] + namedArgs: + oid: + default: null + type: [ *StringType, *ObjectIdType ] type: *ObjectIdType attr: from_datetime: @@ -52,7 +60,11 @@ BsonSymbols: args: - [ *StringType ] - [ *ObjectIdType, *StringType ] - - [ *StringType, null, 'database' ] + - [ *StringType, null ] + namedArgs: + database: + default: null + type: [ *StringType ] type: *DBRefType attr: {} template: *DBRefSymbolTemplate @@ -90,8 +102,12 @@ BsonSymbols: code: 109 callable: *constructor args: - - [ *StringType ] - - [ *StringType, *IntegerType, null, 'flags' ] + - [ *StringType ] + - [ *StringType, *IntegerType, null ] + namedArgs: + flags: + default: 0 + type: [ *StringType, *IntegerType ] type: *BSONRegExpType attr: from_native: @@ -164,14 +180,19 @@ NativeSymbols: code: 8 callable: *constructor args: - - [ *StringType ] - - [ *IntegerType, null ] + - [ *StringType ] + - [ *IntegerType, null ] + namedArgs: + flags: + default: 0 + type: [ *IntegerType ] type: *RegexType attr: {} template: *RegExpSymbolTemplate argsTemplate: *RegExpSymbolArgsTemplate A: <<: *__type + id: 're.A' type: *IntegerType template: !!js/function > () => { @@ -179,6 +200,7 @@ NativeSymbols: } ASCII: <<: *__type + id: 're.ASCII' type: *IntegerType template: !!js/function > () => { @@ -186,6 +208,7 @@ NativeSymbols: } I: <<: *__type + id: 're.I' type: *IntegerType template: !!js/function > () => { @@ -193,6 +216,7 @@ NativeSymbols: } IGNORECASE: <<: *__type + id: 're.IGNORECASE' type: *IntegerType template: !!js/function > () => { @@ -200,6 +224,7 @@ NativeSymbols: } DEBUG: <<: *__type + id: 're.DEBUG' type: *IntegerType template: !!js/function > () => { @@ -207,6 +232,7 @@ NativeSymbols: } L: <<: *__type + id: 're.L' type: *IntegerType template: !!js/function > () => { @@ -214,6 +240,7 @@ NativeSymbols: } LOCAL: <<: *__type + id: 're.LOCAL' type: *IntegerType template: !!js/function > () => { @@ -221,6 +248,7 @@ NativeSymbols: } M: <<: *__type + id: 're.M' type: *IntegerType template: !!js/function > () => { @@ -228,6 +256,7 @@ NativeSymbols: } MULTILINE: <<: *__type + id: 're.MULTILINE' type: *IntegerType template: !!js/function > () => { @@ -235,6 +264,7 @@ NativeSymbols: } S: <<: *__type + id: 're.S' type: *IntegerType template: !!js/function > () => { @@ -242,6 +272,7 @@ NativeSymbols: } DOTALL: <<: *__type + id: 're.DOTALL' type: *IntegerType template: !!js/function > () => { @@ -249,6 +280,7 @@ NativeSymbols: } X: <<: *__type + id: 're.X' type: *IntegerType template: !!js/function > () => { @@ -256,6 +288,7 @@ NativeSymbols: } VERBOSE: <<: *__type + id: 're.VERBOSE' type: *IntegerType template: !!js/function > () => { diff --git a/packages/bson-transpilers/test/yaml/bson.yaml b/packages/bson-transpilers/test/yaml/bson.yaml index 1b346c594bd..99c70bca1c3 100644 --- a/packages/bson-transpilers/test/yaml/bson.yaml +++ b/packages/bson-transpilers/test/yaml/bson.yaml @@ -58,6 +58,15 @@ tests: python: Code('function(test){console.log(test);}') java: new Code("function(test){console.log(test);}") csharp: new BsonJavaScript("function(test){console.log(test);}") + - description: 'named scope arg' + input: + python: "Code('string', scope={'x': '1'})" + output: + javascript: "new Code('string', {\n 'x': '1'\n})" + shell: "new Code('string', {\n 'x': '1'\n})" + python: "Code('string', {\n 'x': '1'\n})" + java: 'new CodeWithScope("string", new Document("x", "1"))' + csharp: 'new BsonJavaScriptWithScope("string", new BsonDocument("x", "1"))' ObjectId: - description: 'no arg' input: @@ -84,6 +93,16 @@ tests: input: javascript: new ObjectId('5a7382114ec1f67ae445f778') shell: new ObjectId('5a7382114ec1f67ae445f778') + python: ObjectId('5a7382114ec1f67ae445f778') + output: + javascript: new ObjectId('5a7382114ec1f67ae445f778') + shell: new ObjectId('5a7382114ec1f67ae445f778') + python: ObjectId('5a7382114ec1f67ae445f778') + java: new ObjectId("5a7382114ec1f67ae445f778") + csharp: new ObjectId("5a7382114ec1f67ae445f778") + - description: 'hex string arg named' + input: + python: ObjectId(oid='5a7382114ec1f67ae445f778') output: javascript: new ObjectId('5a7382114ec1f67ae445f778') shell: new ObjectId('5a7382114ec1f67ae445f778') @@ -123,6 +142,15 @@ tests: python: DBRef('coll', ObjectId(), 'db') java: new DBRef("db", "coll", new ObjectId()) csharp: new MongoDBRef("coll", new ObjectId(), "db") + - description: '(string, ObjectId, database=string) args' + input: + python: DBRef('coll', ObjectId(), database='db') + output: + javascript: new DBRef('coll', new ObjectId(), 'db') + shell: new DBRef('coll', new ObjectId(), 'db') + python: DBRef('coll', ObjectId(), 'db') + java: new DBRef("db", "coll", new ObjectId()) + csharp: new MongoDBRef("coll", new ObjectId(), "db") 32-bit integer: - description: 'NEW number arg' input: @@ -442,6 +470,15 @@ tests: python: Regex('^[a-z0-9_-]{3,16}$', 'imuxls') java: new BsonRegularExpression("^[a-z0-9_-]{3,16}$", "imuxls") csharp: new BsonRegularExpression("^[a-z0-9_-]{3,16}$", "imxs") + - description: 'with flags named' + input: + python: Regex('^[a-z0-9_-]{3,16}$', flags='imuxls') + output: + javascript: new BSONRegExp('^[a-z0-9_-]{3,16}$', 'imuxls') + shell: new RegExp('^[a-z0-9_-]{3,16}$', 'imuxls') + python: Regex('^[a-z0-9_-]{3,16}$', 'imuxls') + java: new BsonRegularExpression("^[a-z0-9_-]{3,16}$", "imuxls") + csharp: new BsonRegularExpression("^[a-z0-9_-]{3,16}$", "imxs") Symbol: - description: from string input: diff --git a/packages/bson-transpilers/test/yaml/error-argument.yaml b/packages/bson-transpilers/test/yaml/error-argument.yaml index 3a0f0d9f1d0..3ab301d4917 100644 --- a/packages/bson-transpilers/test/yaml/error-argument.yaml +++ b/packages/bson-transpilers/test/yaml/error-argument.yaml @@ -22,6 +22,16 @@ runner: !!js/function > }); } tests: + Misc: + - description: unknown named arg + input: + python: ObjectId(test='abc') + errorCode: E_BSONTRANSPILERS_ARGUMENT + - description: wrong type of named arg + input: + python: ObjectId(test={}) + errorCode: E_BSONTRANSPILERS_ARGUMENT + Code: - description: new Code without args diff --git a/packages/bson-transpilers/test/yaml/native.yaml b/packages/bson-transpilers/test/yaml/native.yaml index 55dde191171..e598a1fc1ac 100644 --- a/packages/bson-transpilers/test/yaml/native.yaml +++ b/packages/bson-transpilers/test/yaml/native.yaml @@ -850,6 +850,14 @@ tests: java: "Pattern.compile(\"abc\")" csharp: "new Regex(\"abc\")" shell: "new RegExp('abc')" + - description: "RegExp with named but only A flag" + input: + python: "re.compile('abc', flags=re.A)" + output: + javascript: "new RegExp('abc')" + java: "Pattern.compile(\"abc\")" + csharp: "new Regex(\"abc\")" + shell: "new RegExp('abc')" - description: "regex object with im flags as args" input: javascript: "new RegExp('ab+c', 'im')" @@ -861,6 +869,14 @@ tests: java: "Pattern.compile(\"ab+c(?im)\")" csharp: "new Regex(\"(?im)ab+c\")" shell: "new RegExp('ab+c', 'im')" + - description: "regex object with named flags as args" + input: + python: "re.compile('ab+c', flags=re.I | re.M | re.A)" + output: + javascript: "new RegExp('ab+c', 'im')" + java: "Pattern.compile(\"ab+c(?im)\")" + csharp: "new Regex(\"(?im)ab+c\")" + shell: "new RegExp('ab+c', 'im')" - description: "regex object with ig flags as args" input: javascript: "new RegExp('ab+c', 'ig')"