bson-transpilers
Advanced tools
Comparing version 0.0.0-next-c5eba7335c2da0b9754b4e52495c98f48ec15463 to 0.0.0-next-c64c3eb80d5fc1c2d71c9794f9b35ec86d0ff181
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint complexity: 0, camelcase: 0, "new-cap": 0 */ | ||
@@ -469,3 +470,3 @@ const { | ||
while (type !== null) { | ||
if (!(type.attr.hasOwnProperty(rhs))) { | ||
if (!(Object.prototype.hasOwnProperty.call(type.attr, rhs))) { | ||
if (type.id in this.BsonTypes && this.BsonTypes[type.id].id !== null) { // TODO: tell symbols vs types | ||
@@ -472,0 +473,0 @@ throw new BsonTranspilersAttributeError( |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for csharp code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/** | ||
@@ -2,0 +3,0 @@ * Stores declarations for use in the DriverTemplate |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
const antlr4 = require('antlr4'); | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for Go code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint complexity: 0 */ | ||
@@ -2,0 +3,0 @@ const {doubleQuoteStringify, removeQuotes} = require('../../helper/format'); |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for node code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint complexity: 0 */ | ||
@@ -2,0 +3,0 @@ const vm = require('vm'); |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint new-cap: 0 camelcase: 0 */ | ||
@@ -2,0 +3,0 @@ const bson = require('bson'); |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for php code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/** | ||
@@ -2,0 +3,0 @@ * Common functions to use in PHP templates |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for python code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint camelcase: 0 complexity: 0*/ | ||
@@ -2,0 +3,0 @@ const vm = require('vm'); |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for ruby code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for rust code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* | ||
@@ -2,0 +3,0 @@ * Class for handling edge cases for shell code generation. Defines "emit" methods. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint complexity: 0 */ | ||
@@ -35,2 +36,6 @@ const vm = require('vm'); | ||
Timestamp: bson.Timestamp, | ||
Decimal128: bson.Decimal128, | ||
Long: bson.Long, | ||
Int32: bson.Int32, | ||
Double: bson.Double, | ||
Code: function(c, s) { | ||
@@ -98,3 +103,2 @@ return new bson.Code(c, s); | ||
} | ||
if ('emitNumberDecimal' in this) { | ||
@@ -101,0 +105,0 @@ return this.emitNumberDecimal(ctx, decstr); |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint-disable no-sync */ | ||
@@ -61,3 +62,3 @@ const path = require('path'); | ||
const dir = path.join(__dirname, 'lib', 'symbol-table'); | ||
const inputLangs = ['javascript', 'shell', 'python']; | ||
const inputLangs = ['shell']; | ||
const outputLangs = ['java', 'shell', 'python', 'csharp', 'javascript', 'object', 'ruby', 'go', 'rust', 'php']; | ||
@@ -64,0 +65,0 @@ if (!fs.existsSync(dir)) { |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* eslint-disable no-console */ | ||
@@ -2,0 +3,0 @@ /* eslint-disable no-sync */ |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
const config = require('../config/error.json'); | ||
@@ -2,0 +3,0 @@ const errors = {}; |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/** | ||
@@ -2,0 +3,0 @@ * Takes in an identifier that may or may not be a string and returns a string |
168
index.js
@@ -0,9 +1,7 @@ | ||
'use strict'; | ||
const antlr4 = require('antlr4'); | ||
const ECMAScriptLexer = require('./lib/antlr/ECMAScriptLexer.js'); | ||
const ECMAScriptParser = require('./lib/antlr/ECMAScriptParser.js'); | ||
const Python3Lexer = require('./lib/antlr/Python3Lexer.js'); | ||
const Python3Parser = require('./lib/antlr/Python3Parser'); | ||
const JavascriptANTLRVisitor = require('./lib/antlr/ECMAScriptVisitor').ECMAScriptVisitor; | ||
const PythonANTLRVisitor = require('./lib/antlr/Python3Visitor').Python3Visitor; | ||
@@ -21,8 +19,5 @@ const ErrorListener = require('./codegeneration/ErrorListener.js'); | ||
const getShellVisitor = require('./codegeneration/shell/Visitor'); | ||
const getPythonVisitor = require('./codegeneration/python/Visitor'); | ||
const getJavaGenerator = require('./codegeneration/java/Generator'); | ||
const getPythonGenerator = require('./codegeneration/python/Generator'); | ||
const getCsharpGenerator = require('./codegeneration/csharp/Generator'); | ||
const getShellGenerator = require('./codegeneration/shell/Generator'); | ||
const getJavascriptGenerator = require('./codegeneration/javascript/Generator'); | ||
@@ -35,12 +30,2 @@ const getObjectGenerator = require('./codegeneration/object/Generator'); | ||
const javascriptjavasymbols = require('./lib/symbol-table/javascripttojava'); | ||
const javascriptpythonsymbols = require('./lib/symbol-table/javascripttopython'); | ||
const javascriptcsharpsymbols = require('./lib/symbol-table/javascripttocsharp'); | ||
const javascriptshellsymbols = require('./lib/symbol-table/javascripttoshell'); | ||
const javascriptobjectsymbols = require('./lib/symbol-table/javascripttoobject'); | ||
const javascriptrubysymbols = require('./lib/symbol-table/javascripttoruby'); | ||
const javascriptgosymbols = require('./lib/symbol-table/javascripttogo'); | ||
const javascriptrustsymbols = require('./lib/symbol-table/javascripttorust'); | ||
const javascriptphpsymbols = require('./lib/symbol-table/javascripttophp'); | ||
const shelljavasymbols = require('./lib/symbol-table/shelltojava'); | ||
@@ -56,12 +41,2 @@ const shellpythonsymbols = require('./lib/symbol-table/shelltopython'); | ||
const pythonjavasymbols = require('./lib/symbol-table/pythontojava'); | ||
const pythonshellsymbols = require('./lib/symbol-table/pythontoshell'); | ||
const pythoncsharpsymbols = require('./lib/symbol-table/pythontocsharp'); | ||
const pythonjavascriptsymbols = require('./lib/symbol-table/pythontojavascript'); | ||
const pythonobjectsymbols = require('./lib/symbol-table/pythontoobject'); | ||
const pythonrubysymbols = require('./lib/symbol-table/pythontoruby'); | ||
const pythongosymbols = require('./lib/symbol-table/pythontogo'); | ||
const pythonrustsymbols = require('./lib/symbol-table/pythontorust'); | ||
const pythonphpsymbols = require('./lib/symbol-table/pythontophp'); | ||
/** | ||
@@ -91,25 +66,2 @@ * Constructs the parse tree from the JS or Shell code given by the user. | ||
/** | ||
* Constructs the parse tree from the Python code given by the user. | ||
* | ||
* @param {String} input | ||
* @param {String} start - the name of the start node. Always defined in the | ||
* language-specific visitor. | ||
* @return {antlr4.ParserRuleContext} - The parse tree. | ||
*/ | ||
const loadPyTree = (input, start) => { | ||
const chars = new antlr4.InputStream(input + '\n'); // requires newline | ||
const lexer = new Python3Lexer.Python3Lexer(chars); | ||
const tokens = new antlr4.CommonTokenStream(lexer); | ||
const parser = new Python3Parser.Python3Parser(tokens); | ||
parser.buildParseTrees = true; | ||
const listener = new ErrorListener(); | ||
parser.removeErrorListeners(); // Remove the default ConsoleErrorListener | ||
parser.addErrorListener(listener); // Add back a custom error listener | ||
return parser[start](); | ||
}; | ||
const getTranspiler = (loadTree, visitor, generator, symbols) => { | ||
@@ -168,3 +120,3 @@ const Transpiler = generator(visitor); | ||
Object.keys(input).map((k) => { | ||
result[k] = k === 'options' ? input[k] : compile(input[k], idiomatic, true); | ||
result[k] = (k === 'options' || k === 'exportMode') ? input[k] : compile(input[k], idiomatic, true); | ||
}); | ||
@@ -199,58 +151,2 @@ if (!('options' in result) || | ||
module.exports = { | ||
javascript: { | ||
java: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getJavaGenerator, | ||
javascriptjavasymbols | ||
), | ||
python: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getPythonGenerator, | ||
javascriptpythonsymbols | ||
), | ||
csharp: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getCsharpGenerator, | ||
javascriptcsharpsymbols | ||
), | ||
shell: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getShellGenerator, | ||
javascriptshellsymbols | ||
), | ||
object: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getObjectGenerator, | ||
javascriptobjectsymbols | ||
), | ||
ruby: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getRubyGenerator, | ||
javascriptrubysymbols | ||
), | ||
go: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getGoGenerator, | ||
javascriptgosymbols | ||
), | ||
rust: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getRustGenerator, | ||
javascriptrustsymbols | ||
), | ||
php: getTranspiler( | ||
loadJSTree, | ||
getJavascriptVisitor(getCodeGenerationVisitor(JavascriptANTLRVisitor)), | ||
getPhpGenerator, | ||
javascriptphpsymbols | ||
) | ||
}, | ||
shell: { | ||
@@ -312,63 +208,5 @@ java: getTranspiler( | ||
}, | ||
python: { | ||
java: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getJavaGenerator, | ||
pythonjavasymbols | ||
), | ||
shell: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getShellGenerator, | ||
pythonshellsymbols | ||
), | ||
csharp: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getCsharpGenerator, | ||
pythoncsharpsymbols | ||
), | ||
javascript: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getJavascriptGenerator, | ||
pythonjavascriptsymbols | ||
), | ||
object: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getObjectGenerator, | ||
pythonobjectsymbols | ||
), | ||
ruby: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getRubyGenerator, | ||
pythonrubysymbols | ||
), | ||
go: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getGoGenerator, | ||
pythongosymbols | ||
), | ||
rust: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getRustGenerator, | ||
pythonrustsymbols | ||
), | ||
php: getTranspiler( | ||
loadPyTree, | ||
getPythonVisitor(getCodeGenerationVisitor(PythonANTLRVisitor)), | ||
getPhpGenerator, | ||
pythonphpsymbols | ||
) | ||
}, | ||
getTree: { | ||
javascript: loadJSTree, | ||
shell: loadJSTree, | ||
python: loadPyTree | ||
shell: loadJSTree | ||
} | ||
}; |
@@ -1,1 +0,1 @@ | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n# 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 DriverTemplate: &DriverTemplate !!js/function |\n (spec) => {\n const comment = `/*\n * Requires the MongoDB Node.js Driver\n * https://mongodb.github.io/node-mongodb-native\n */`;\n const translateKey = {\n project: 'projection'\n };\n\n let cmd;\n let defs;\n if ('aggregation' in spec) {\n const agg = spec.aggregation;\n cmd = `const cursor = coll.aggregate(agg);`;\n defs = `const agg = ${agg};\\n`;\n } else {\n let opts = '';\n const args = {};\n Object.keys(spec).forEach((k) => {\n if (k !== 'options') {\n args[k in translateKey ? translateKey[k] : k] = spec[k];\n }\n });\n\n if (Object.keys(args).length > 0) {\n defs = Object.keys(args).reduce((s, k) => {\n if (k !== 'filter') {\n if (opts === '') {\n opts = `${k}`;\n } else {\n opts = `${opts}, ${k}`;\n }\n }\n return `${s}const ${k} = ${args[k]};\\n`;\n }, '');\n opts = opts === '' ? '' : `, { ${opts} }`;\n }\n cmd = `const cursor = coll.find(filter${opts});`;\n }\n return `${comment}\\n\\n${defs}\n const client = await MongoClient.connect(\n '${spec.options.uri}',\n { useNewUrlParser: true, useUnifiedTopology: true }\n );\n const coll = client.db('${spec.options.database}').collection('${spec.options.collection}');\n ${cmd}\n const result = await cursor.toArray();\n await client.close();`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n } else if (op === '==' || op === '===' || op === 'is') {\n return `${lhs} === ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '!==';\n if (op.includes('!') || op.includes('not')) {\n str = '===';\n }\n return `${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 UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `Math.floor(${s}, ${rhs})`;\n case '**':\n return `Math.pow(${s}, ${rhs})`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\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 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 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 !!js/function >\n () => {\n return 'BSONSymbol';\n }\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 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(`import {\\n ${bson.join(',\\n ')}\\n} from 'mongodb';`);\n }\n return other.join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `import { MongoClient } from 'mongodb';`;\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 'BSONSymbol';\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 unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n type: *StringType\n top:\n callable: *var\n args: null\n attr: null\n id: \"top\"\n type: *IntegerType\n template: *LongTopTemplate\n argsTemplate: null\n bottom:\n callable: *var\n args: null\n attr: null\n id: \"bottom\"\n type: *IntegerType\n template: *LongBottomTemplate\n argsTemplate: null\n floatApprox:\n callable: *var\n args: null\n attr: null\n id: \"floatApprox\"\n type: *IntegerType\n template: *LongFloatApproxTemplate\n argsTemplate: null\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"TimestampFromShell\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n getTime:\n <<: *__func\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getInc:\n <<: *__func\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n t:\n callable: *var\n args: null\n attr: null\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n i:\n callable: *var\n args: null\n attr: null\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n Symbol: &SymbolType\n <<: *__type\n id: \"Symbol\"\n code: 111\n type: *ObjectType\n NumberDecimal: &Decimal128Type\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr: {}\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *ObjectIdType\n attr:\n fromDate:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n# 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 DriverTemplate: &DriverTemplate !!js/function |\n (spec) => {\n const comment = `/*\n * Requires the MongoDB Node.js Driver\n * https://mongodb.github.io/node-mongodb-native\n */`;\n const translateKey = {\n project: 'projection'\n };\n\n const exportMode = spec.exportMode;\n delete spec.exportMode;\n\n const args = {};\n Object.keys(spec).forEach((k) => {\n if (k !== 'options') {\n args[k in translateKey ? translateKey[k] : k] = spec[k];\n }\n });\n\n let cmd;\n let defs;\n if (exportMode == 'Delete Query') {\n defs = `const filter = ${args.filter};\\n`;\n cmd = `const result = coll.deleteMany(filter);`;\n }\n if ('aggregation' in spec) {\n const agg = spec.aggregation;\n cmd = `const cursor = coll.aggregate(agg);\\nconst result = await cursor.toArray();`;\n defs = `const agg = ${agg};\\n`;\n } else if (!cmd) {\n let opts = '';\n\n if (Object.keys(args).length > 0) {\n defs = Object.keys(args).reduce((s, k) => {\n if (k !== 'filter') {\n if (opts === '') {\n opts = `${k}`;\n } else {\n opts = `${opts}, ${k}`;\n }\n }\n return `${s}const ${k} = ${args[k]};\\n`;\n }, '');\n opts = opts === '' ? '' : `, { ${opts} }`;\n }\n cmd = `const cursor = coll.find(filter${opts});\\nconst result = await cursor.toArray();`;\n }\n return `${comment}\\n\\n${defs}\n const client = await MongoClient.connect(\n '${spec.options.uri}'\n );\n const coll = client.db('${spec.options.database}').collection('${spec.options.collection}');\n ${cmd}\n await client.close();`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n } else if (op === '==' || op === '===' || op === 'is') {\n return `${lhs} === ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '!==';\n if (op.includes('!') || op.includes('not')) {\n str = '===';\n }\n return `${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 UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `Math.floor(${s}, ${rhs})`;\n case '**':\n return `Math.pow(${s}, ${rhs})`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\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 null\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate null\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate null\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!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 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 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 !!js/function >\n () => {\n return 'BSONSymbol';\n }\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 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(`import {\\n ${bson.join(',\\n ')}\\n} from 'mongodb';`);\n }\n return other.join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `import { MongoClient } from 'mongodb';`;\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 'BSONSymbol';\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 unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n args:\n - [ *IntegerType, null ]\n type: *StringType\n template: *LongToStringTemplate\n argsTemplate: *LongToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongEqualsTemplate\n argsTemplate: *LongEqualsArgsTemplate\n toInt:\n <<: *__func\n id: \"toInt\"\n type: *IntegerType\n template: *LongToIntTemplate\n argsTemplate: *LongToIntArgsTemplate\n toNumber:\n <<: *__func\n id: \"toNumber\"\n type: *DecimalType\n template: *LongToNumberTemplate\n argsTemplate: *LongToNumberArgsTemplate\n compare:\n <<: *__func\n id: \"compare\"\n args:\n - [ \"Long\" ]\n type: *StringType\n template: *LongCompareTemplate\n argsTemplate: *LongCompareArgsTemplate\n isOdd:\n <<: *__func\n id: \"isOdd\"\n type: *BoolType\n template: *LongIsOddTemplate\n argsTemplate: *LongIsOddArgsTemplate\n isZero:\n <<: *__func\n id: \"isZero\"\n type: *BoolType\n template: *LongIsZeroTemplate\n argsTemplate: *LongIsZeroArgsTemplate\n isNegative:\n <<: *__func\n id: \"isNegative\"\n type: *BoolType\n template: *LongIsNegativeTemplate\n argsTemplate: *LongIsNegativeArgsTemplate\n negate:\n <<: *__func\n id: \"negate\"\n type: \"Long\"\n template: *LongNegateTemplate\n argsTemplate: *LongNegateArgsTemplate\n not:\n <<: *__func\n id: \"not\"\n type: \"Long\"\n template: *LongNotTemplate\n argsTemplate: *LongNotArgsTemplate\n notEquals:\n <<: *__func\n id: \"notEquals\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongNotEqualsTemplate\n argsTemplate: *LongNotEqualsArgsTemplate\n greaterThan:\n <<: *__func\n id: \"greaterThan\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongGreaterThanTemplate\n argsTemplate: *LongGreaterThanArgsTemplate\n greaterThanOrEqual:\n <<: *__func\n id: \"greaterThanOrEqual\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongGreaterThanOrEqualTemplate\n argsTemplate: *LongGreaterThanOrEqualArgsTemplate\n lessThan:\n <<: *__func\n id: \"lessThan\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongLessThanTemplate\n argsTemplate: *LongLessThanArgsTemplate\n lessThanOrEqual:\n <<: *__func\n id: \"lessThanOrEqual\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongLessThanOrEqualTemplate\n argsTemplate: *LongLessThanOrEqualArgsTemplate\n add:\n <<: *__func\n id: \"add\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongAddTemplate\n argsTemplate: *LongAddArgsTemplate\n subtract:\n <<: *__func\n id: \"subtract\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongSubtractTemplate\n argsTemplate: *LongSubtractArgsTemplate\n multiply:\n <<: *__func\n id: \"multiply\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongMultiplyTemplate\n argsTemplate: *LongMultiplyArgsTemplate\n div:\n <<: *__func\n id: \"div\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongDivTemplate\n argsTemplate: *LongDivArgsTemplate\n modulo:\n <<: *__func\n id: \"modulo\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongModuloTemplate\n argsTemplate: *LongModuloArgsTemplate\n and:\n <<: *__func\n id: \"and\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongAndTemplate\n argsTemplate: *LongAndArgsTemplate\n or:\n <<: *__func\n id: \"or\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongOrTemplate\n argsTemplate: *LongOrArgsTemplate\n xor:\n <<: *__func\n id: \"xor\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongXorTemplate\n argsTemplate: *LongXorArgsTemplate\n shiftLeft:\n <<: *__func\n id: \"shiftLeft\"\n args:\n - [ *IntegerType ]\n type: \"Long\"\n template: *LongShiftLeftTemplate\n argsTemplate: *LongShiftLeftArgsTemplate\n shiftRight:\n <<: *__func\n id: \"shiftRight\"\n args:\n - [ *IntegerType ]\n type: \"Long\"\n template: *LongShiftRightTemplate\n argsTemplate: *LongShiftRightArgsTemplate\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"Timestamp\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampEqualsTemplate\n argsTemplate: *TimestampEqualsArgsTemplate\n getLowBits:\n <<: *__func\n id: \"getLowBits\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getHighBits:\n <<: *__func\n id: \"getHighBits\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n compare:\n <<: *__func\n id: \"compare\"\n args:\n - [ \"Timestamp\" ]\n type: *StringType\n template: *TimestampCompareTemplate\n argsTemplate: *TimestampCompareArgsTemplate\n notEquals:\n <<: *__func\n id: \"notEquals\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampNotEqualsTemplate\n argsTemplate: *TimestampNotEqualsArgsTemplate\n greaterThan:\n <<: *__func\n id: \"greaterThan\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampGreaterThanTemplate\n argsTemplate: *TimestampGreaterThanArgsTemplate\n greaterThanOrEqual:\n <<: *__func\n id: \"greaterThanOrEqual\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampGreaterThanOrEqualTemplate\n argsTemplate: *TimestampGreaterThanOrEqualArgsTemplate\n lessThan:\n <<: *__func\n id: \"lessThan\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampLessThanTemplate\n argsTemplate: *TimestampLessThanArgsTemplate\n lessThanOrEqual:\n <<: *__func\n id: \"lessThanOrEqual\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampLessThanOrEqualTemplate\n argsTemplate: *TimestampLessThanOrEqualArgsTemplate\n BSONSymbol: &SymbolType\n <<: *__type\n id: \"BSONSymbol\"\n code: 111\n type: *ObjectType\n attr:\n valueOf:\n <<: *__func\n id: \"valueOf\"\n type: *StringType\n template: *SymbolValueOfTemplate\n argsTemplate: *SymbolValueOfArgsTemplate\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *SymbolToStringTemplate\n argsTemplate: *SymbolToStringArgsTemplate\n inspect:\n <<: *__func\n id: \"inspect\"\n type: *StringType\n template: *SymbolInspectTemplate\n argsTemplate: *SymbolInspectArgsTemplate\n Double: &DoubleType\n <<: *__type\n id: \"Double\"\n code: 104\n type: *ObjectType\n attr: {}\n Decimal128: &Decimal128Type\n <<: *__type\n id: \"Decimal128\"\n code: 112\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *Decimal128ToStringTemplate\n argsTemplate: *Decimal128ToStringArgsTemplate\n NumberDecimal: &NumberDecimalType\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *Decimal128ToStringTemplate\n argsTemplate: *Decimal128ToStringArgsTemplate\n\n\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\n BSONRegExpType: &BSONRegExpType\n <<: *__type\n id: \"BSONRegExp\"\n code: 109\n type: *ObjectType\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *ObjectIdType\n attr:\n createFromHexString:\n <<: *__func\n id: \"createFromHexString\"\n args:\n - [ *StringType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromHexStringTemplate\n argsTemplate: *ObjectIdCreateFromHexStringArgsTemplate\n createFromTime:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *NumericType, *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n isValid:\n <<: *__func\n id: \"isValid\"\n args:\n - [ *StringType ]\n type: *BoolType\n template: *ObjectIdIsValidTemplate\n argsTemplate: *ObjectIdIsValidArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n BSONRegExp:\n id: \"BSONRegExp\"\n code: 109\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *StringType, null ]\n type: *BSONRegExpType\n attr: {}\n template: *BSONRegExpSymbolTemplate\n argsTemplate: *BSONRegExpSymbolArgsTemplate\n BSONSymbol:\n id: \"BSONSymbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n Decimal128:\n id: \"Decimal128\"\n code: 112\n callable: *constructor\n args:\n - [ *ObjectType ]\n type: *Decimal128Type\n attr:\n fromString:\n id: \"fromString\"\n callable: *func\n args:\n - [ *StringType ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolFromStringTemplate\n argsTemplate: *Decimal128SymbolFromStringArgsTemplate\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n Double:\n id: \"Double\"\n code: 104\n callable: *constructor\n args:\n - [ *NumericType, *StringType ]\n type: *DoubleType\n attr: {}\n template: *DoubleSymbolTemplate\n argsTemplate: *DoubleSymbolArgsTemplate\n Int32:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n Long:\n id: \"Long\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *LongType\n attr:\n MAX_VALUE:\n id: \"MAX_VALUE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolMaxTemplate\n argsTemplate: *LongSymbolMaxArgsTemplate\n MIN_VALUE:\n id: \"MIN_VALUE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolMinTemplate\n argsTemplate: *LongSymbolMinArgsTemplate\n ZERO:\n id: \"ZERO\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolZeroTemplate\n argsTemplate: *LongSymbolZeroArgsTemplate\n ONE:\n id: \"ONE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolOneTemplate\n argsTemplate: *LongSymbolOneArgsTemplate\n NEG_ONE:\n id: \"NEG_ONE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolNegOneTemplate\n argsTemplate: *LongSymbolNegOneArgsTemplate\n fromBits:\n id: \"LongfromBits\" # Needs process method\n callable: *func\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromBitsTemplate\n argsTemplate: *LongSymbolFromBitsArgsTemplate\n fromInt:\n id: \"fromInt\"\n callable: *func\n args:\n - [ *IntegerType ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromIntTemplate\n argsTemplate: *LongSymbolFromIntArgsTemplate\n fromNumber:\n id: \"fromNumber\"\n callable: *func\n args:\n - [ *NumericType ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromNumberTemplate\n argsTemplate: *LongSymbolFromNumberArgsTemplate\n fromString:\n id: \"fromString\"\n callable: *func\n args:\n - [ *StringType ]\n - [ *IntegerType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromStringTemplate\n argsTemplate: *LongSymbolFromStringArgsTemplate\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; |
@@ -1,1 +0,1 @@ | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n#############################################\n# Sample Templates #\n# #\n# The expected arguments are commented next #\n# to the template itself. Currently all are #\n# set to null, but to define a function #\n# replace 'null' with '!!js/function > \\n #\n# and a function defined below. #\n# #\n# See the other template files for examples #\n# #\n# Good to know: #\n# lhs is left-hand-side of the expression #\n# rhs is right-hand-side of the expression #\n# All args are strings unless noted #\n# - arg? is boolean #\n# - arg# is number #\n# #\n#############################################\nTemplates:\n ########\n # Misc #\n ########\n\n # Filter out regex flags that have translations or are unsupported.\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: '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\n #############################################\n # Syntax #\n # #\n # Templates for language syntax expressions #\n # #\n #############################################\n\n DriverTemplate: &DriverTemplate null\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return lhs !== rhs;\n }\n if (op === '==' || op === '===' || op === 'is') {\n if (typeof(lhs) === 'object' && 'equals' in lhs) {\n // Use '.equals' for objects, if it exists.\n return lhs.equals(rhs);\n }\n return lhs === rhs;\n }\n if (op === '>') {\n return lhs > rhs;\n }\n if (op === '<') {\n return lhs < rhs;\n }\n if (op === '>=') {\n return lhs >= rhs;\n }\n if (op === '<=') {\n return lhs <= rhs;\n }\n throw new Error(`unrecognized operation: ${op}`);\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n if (typeof rhs === 'array') {\n return rhs.indexOf(lhs) === -1;\n }\n return !(lhs in rhs);\n }\n if (typeof rhs === 'array') {\n return rhs.indexOf(lhs) !== -1;\n }\n return lhs in rhs;\n }\n\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((t, k, i) => {\n return t && k;\n });\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((t, k, i) => {\n return t || k;\n });\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return !arg;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate !!js/function >\n (op, arg) => {\n switch(op) {\n case '+':\n return +arg;\n case '-':\n return -arg;\n case '~':\n return ~arg;\n default:\n throw new Error(`unrecognized operation: ${op}`);\n }\n }\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '+':\n return s + rhs;\n case '-':\n return s - rhs;\n case '*':\n return s * rhs;\n case '/':\n return s / rhs;\n case '**':\n return Math.pow(s, rhs);\n case '//':\n return Math.floor(s, rhs);\n case '%':\n return s % rhs;\n case '>>':\n return s >> rhs;\n case '<<':\n return s << rhs;\n case '|':\n return s | rhs;\n case '&':\n return s & rhs;\n case '^':\n return s ^ rhs;\n default:\n throw new Error(`unrecognized operation: ${op}`);\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate !!js/function >\n (arg) => {\n return arg;\n }\n EosSyntaxTemplate: &EosSyntaxTemplate !!js/function >\n () => {\n return 'a unique thing';\n }\n EofSyntaxTemplate: &EofSyntaxTemplate !!js/function >\n () => {\n return 'a unique thing';\n }\n FloorDivTemplate: &FloorDivSyntaxTemplate null # Args: lhs, rhs\n PowerTemplate: &PowerSyntaxTemplate null # Args: lhs, rhs\n NewTemplate: &NewSyntaxTemplate null # Args: expression, skip?, code# [to check if meant to be skipped]\n\n #############################################\n # Literal Types #\n # #\n # Templates for literal type instance. Most #\n # get passed the literal itself as an arg. #\n # #\n #############################################\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str.toString();\n if (\n (newStr.charAt(0) === '\"' && newStr.charAt(newStr.length - 1) === '\"') ||\n (newStr.charAt(0) === '\\'' && newStr.charAt(newStr.length - 1) === '\\'')\n ) {\n newStr = newStr.substr(1, newStr.length - 2);\n }\n return newStr;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n return new RegExp(pattern, flags);\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (str) => {\n return str.toLowerCase() === 'true';\n }\n IntegerTypeTemplate: &IntegerTypeTemplate !!js/function >\n (arg) => {\n return parseInt(arg, 10);\n }\n DecimalTypeTemplate: &DecimalTypeTemplate !!js/function >\n (arg) => {\n return parseFloat(arg);\n }\n LongBasicTypeTemplate: &LongBasicTypeTemplate !!js/function >\n (arg) => {\n return parseInt(arg, 10);\n }\n HexTypeTemplate: &HexTypeTemplate !!js/function >\n (arg) => {\n return parseInt(arg, 16);\n }\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (arg) => {\n arg = arg.replace(/[oO]/g, '')\n return parseInt(arg, 8);\n }\n NumericTypeTemplate: &NumericTypeTemplate !!js/function >\n (arg) => {\n if (arg.contains('x')) {\n return parseInt(arg, 16);\n }\n if (arg.contains('o') || arg.startsWith('0')) {\n arg = arg.replace(/o/g, '')\n return parseInt(arg, 8);\n }\n return parseFloat(arg);\n }\n ArrayTypeTemplate: &ArrayTypeTemplate null\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null # Args: single array element, nestedness, lastElement? (note: not being used atm)\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return null;\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return undefined;\n }\n ObjectTypeTemplate: &ObjectTypeTemplate null # Args: literal (for empty array, is empty string. Otherwise all set)\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate null # Args: single object element [2] (i.e. array with [key, value]), nestedness#\n\n #############################################\n # Symbols #\n # #\n # Templates for symbols, can be either #\n # functions or variables. #\n # #\n # The *SymbolTemplates return names and #\n # usually don't take any arguments. The #\n # *SymbolArgsTemplates are invoked for func #\n # calls. The first argument is always the #\n # lhs, i.e. the symbol returned from the #\n # corresponding SymbolTemplate. The rest of #\n # the arguments are the processed arguments #\n # passed to the original function. #\n # #\n #############################################\n CodeSymbolTemplate: &CodeSymbolTemplate null # No args\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate null # Args: code, scope\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null # No args\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate null # Args: lhs, string (can be empty or null for no arg)\n BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate null\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate null # No args\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null # Args: lhs, coll, id, db\n DoubleSymbolTemplate: &DoubleSymbolTemplate null # No args\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null # Args: lhs, arg, argType (i.e. '_string', '_double')\n Int32SymbolTemplate: &Int32SymbolTemplate null # No args\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate null # Args: lhs, arg, argType\n LongSymbolTemplate: &LongSymbolTemplate null # No args\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function > # Args: lhs, arg, argType\n (lhs, arg) => {\n return lhs.fromNumber(arg);\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate null # No args\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n SymbolSymbolTemplate: &SymbolSymbolTemplate null # No args\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null # Args: lhs, arg\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate null # No args\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate null # No args\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate null # Args: lhs, arg\n MinKeySymbolTemplate: &MinKeySymbolTemplate null # No args\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null # No args\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null # No args\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null # No args\n TimestampSymbolTemplate: &TimestampSymbolTemplate null # No args\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate null # Args: lhs, low, high\n # non bson-specific\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return Number;\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate null # Args: lhs, arg, argType\n DateSymbolTemplate: &DateSymbolTemplate null # No args\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n if (isString) {\n return date.toString();\n }\n return date;\n }\n\n #############################################\n # Object Attributes/Methods #\n # #\n # These're variables or functions called on #\n # instantiated objects. For example, #\n # ObjectId().isValid() or Timestamp().t #\n # #\n # They follow the same pattern with the\n # *Template/*ArgsTemplates: usually no args #\n # to the Template and lhs plus any original #\n # arguments to the ArgsTemplate. #\n # #\n #############################################\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.toString();\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.equals(rhs);\n }\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getTimestamp();\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.isValid;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate null\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate null\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.db;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.collection;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.oid;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n LongEqualsTemplate: &LongEqualsTemplate null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate null\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongValueOfTemplate: &LongValueOfTemplate null\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, rhs) => {\n return lhs.toNumber();\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.high;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.low;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getLowBits();\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getHighBits();\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getLowBits();\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getHighBits();\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs, rhs) => {\n return new Date(lhs.getHighBits() * 1000);\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\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 Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # non bson-specific\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return Date.now;\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n\n #############################################\n # Symbol Attributes/Methods #\n # #\n # These're variables or functions called on #\n # symbols. Also called bson-utils. #\n # #\n # They are basically the same thing as #\n # object attributes/methods, but need to be #\n # distinguished since they are separate #\n # namespaces that happen to have the same #\n # name which is v confusing. #\n # #\n # For example, ObjectId().toString() is an #\n # object method, while ObjectId.fromString #\n # is a symbol attribute. These are two #\n # separate ObjectId related namespaces that #\n # don't overlap. #\n # #\n #############################################\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate 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 Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.createFromTime;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate null\n # non bson-specific would go here, but there aren't any atm.\n\n #############################################\n # Imports #\n # #\n # Each type has a 'code' that is consistent #\n # between languages. The import templates #\n # for each code generate the required #\n # statement for each type. No args. #\n # #\n # The ImportTemplate collects everything #\n # into one statement. #\n # #\n #############################################\n ImportTemplate: &ImportTemplate null\n DriverImportTemplate: &DriverImportTemplate 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 unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n type: *StringType\n top:\n callable: *var\n args: null\n attr: null\n id: \"top\"\n type: *IntegerType\n template: *LongTopTemplate\n argsTemplate: null\n bottom:\n callable: *var\n args: null\n attr: null\n id: \"bottom\"\n type: *IntegerType\n template: *LongBottomTemplate\n argsTemplate: null\n floatApprox:\n callable: *var\n args: null\n attr: null\n id: \"floatApprox\"\n type: *IntegerType\n template: *LongFloatApproxTemplate\n argsTemplate: null\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"TimestampFromShell\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n getTime:\n <<: *__func\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getInc:\n <<: *__func\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n t:\n callable: *var\n args: null\n attr: null\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n i:\n callable: *var\n args: null\n attr: null\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n Symbol: &SymbolType\n <<: *__type\n id: \"Symbol\"\n code: 111\n type: *ObjectType\n NumberDecimal: &Decimal128Type\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr: {}\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *ObjectIdType\n attr:\n fromDate:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; | ||
module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n#############################################\n# Sample Templates #\n# #\n# The expected arguments are commented next #\n# to the template itself. Currently all are #\n# set to null, but to define a function #\n# replace 'null' with '!!js/function > \\n #\n# and a function defined below. #\n# #\n# See the other template files for examples #\n# #\n# Good to know: #\n# lhs is left-hand-side of the expression #\n# rhs is right-hand-side of the expression #\n# All args are strings unless noted #\n# - arg? is boolean #\n# - arg# is number #\n# #\n#############################################\nTemplates:\n ########\n # Misc #\n ########\n\n # Filter out regex flags that have translations or are unsupported.\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: '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\n #############################################\n # Syntax #\n # #\n # Templates for language syntax expressions #\n # #\n #############################################\n\n DriverTemplate: &DriverTemplate null\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return lhs !== rhs;\n }\n if (op === '==' || op === '===' || op === 'is') {\n if (typeof(lhs) === 'object' && 'equals' in lhs) {\n // Use '.equals' for objects, if it exists.\n return lhs.equals(rhs);\n }\n return lhs === rhs;\n }\n if (op === '>') {\n return lhs > rhs;\n }\n if (op === '<') {\n return lhs < rhs;\n }\n if (op === '>=') {\n return lhs >= rhs;\n }\n if (op === '<=') {\n return lhs <= rhs;\n }\n throw new Error(`unrecognized operation: ${op}`);\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n if (typeof rhs === 'array') {\n return rhs.indexOf(lhs) === -1;\n }\n return !(lhs in rhs);\n }\n if (typeof rhs === 'array') {\n return rhs.indexOf(lhs) !== -1;\n }\n return lhs in rhs;\n }\n\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((t, k, i) => {\n return t && k;\n });\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((t, k, i) => {\n return t || k;\n });\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return !arg;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate !!js/function >\n (op, arg) => {\n switch(op) {\n case '+':\n return +arg;\n case '-':\n return -arg;\n case '~':\n return ~arg;\n default:\n throw new Error(`unrecognized operation: ${op}`);\n }\n }\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '+':\n return s + rhs;\n case '-':\n return s - rhs;\n case '*':\n return s * rhs;\n case '/':\n return s / rhs;\n case '**':\n return Math.pow(s, rhs);\n case '//':\n return Math.floor(s, rhs);\n case '%':\n return s % rhs;\n case '>>':\n return s >> rhs;\n case '<<':\n return s << rhs;\n case '|':\n return s | rhs;\n case '&':\n return s & rhs;\n case '^':\n return s ^ rhs;\n default:\n throw new Error(`unrecognized operation: ${op}`);\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate !!js/function >\n (arg) => {\n return arg;\n }\n EosSyntaxTemplate: &EosSyntaxTemplate !!js/function >\n () => {\n return 'a unique thing';\n }\n EofSyntaxTemplate: &EofSyntaxTemplate !!js/function >\n () => {\n return 'a unique thing';\n }\n FloorDivTemplate: &FloorDivSyntaxTemplate null # Args: lhs, rhs\n PowerTemplate: &PowerSyntaxTemplate null # Args: lhs, rhs\n NewTemplate: &NewSyntaxTemplate null # Args: expression, skip?, code# [to check if meant to be skipped]\n\n #############################################\n # Literal Types #\n # #\n # Templates for literal type instance. Most #\n # get passed the literal itself as an arg. #\n # #\n #############################################\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str.toString();\n if (\n (newStr.charAt(0) === '\"' && newStr.charAt(newStr.length - 1) === '\"') ||\n (newStr.charAt(0) === '\\'' && newStr.charAt(newStr.length - 1) === '\\'')\n ) {\n newStr = newStr.substr(1, newStr.length - 2);\n }\n return newStr;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n return new RegExp(pattern, flags);\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (str) => {\n return str.toLowerCase() === 'true';\n }\n IntegerTypeTemplate: &IntegerTypeTemplate !!js/function >\n (arg) => {\n return parseInt(arg, 10);\n }\n DecimalTypeTemplate: &DecimalTypeTemplate !!js/function >\n (arg) => {\n return parseFloat(arg);\n }\n LongBasicTypeTemplate: &LongBasicTypeTemplate !!js/function >\n (arg) => {\n return parseInt(arg, 10);\n }\n HexTypeTemplate: &HexTypeTemplate !!js/function >\n (arg) => {\n return parseInt(arg, 16);\n }\n OctalTypeTemplate: &OctalTypeTemplate !!js/function >\n (arg) => {\n arg = arg.replace(/[oO]/g, '')\n return parseInt(arg, 8);\n }\n NumericTypeTemplate: &NumericTypeTemplate !!js/function >\n (arg) => {\n if (arg.contains('x')) {\n return parseInt(arg, 16);\n }\n if (arg.contains('o') || arg.startsWith('0')) {\n arg = arg.replace(/o/g, '')\n return parseInt(arg, 8);\n }\n return parseFloat(arg);\n }\n ArrayTypeTemplate: &ArrayTypeTemplate null\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null # Args: single array element, nestedness, lastElement? (note: not being used atm)\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return null;\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return undefined;\n }\n ObjectTypeTemplate: &ObjectTypeTemplate null # Args: literal (for empty array, is empty string. Otherwise all set)\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate null # Args: single object element [2] (i.e. array with [key, value]), nestedness#\n\n #############################################\n # Symbols #\n # #\n # Templates for symbols, can be either #\n # functions or variables. #\n # #\n # The *SymbolTemplates return names and #\n # usually don't take any arguments. The #\n # *SymbolArgsTemplates are invoked for func #\n # calls. The first argument is always the #\n # lhs, i.e. the symbol returned from the #\n # corresponding SymbolTemplate. The rest of #\n # the arguments are the processed arguments #\n # passed to the original function. #\n # #\n #############################################\n CodeSymbolTemplate: &CodeSymbolTemplate null # No args\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate null # Args: code, scope\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null # No args\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate null # Args: lhs, string (can be empty or null for no arg)\n BinarySymbolTemplate: &BinarySymbolTemplate null\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate null\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate null # No args\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null # Args: lhs, coll, id, db\n DoubleSymbolTemplate: &DoubleSymbolTemplate null # No args\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null # Args: lhs, arg, argType (i.e. '_string', '_double')\n Int32SymbolTemplate: &Int32SymbolTemplate null # No args\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate null # Args: lhs, arg, argType\n LongSymbolTemplate: &LongSymbolTemplate null # No args\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function > # Args: lhs, arg, argType\n (lhs, arg) => {\n return lhs.fromNumber(arg);\n }\n RegExpSymbolTemplate: &RegExpSymbolTemplate null # No args\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n SymbolSymbolTemplate: &SymbolSymbolTemplate null # No args\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null # Args: lhs, arg\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate null # No args\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate null # Args: lhs, pattern, flags\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate null # No args\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate null # Args: lhs, arg\n MinKeySymbolTemplate: &MinKeySymbolTemplate null # No args\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null # No args\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null # No args\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null # No args\n TimestampSymbolTemplate: &TimestampSymbolTemplate null # No args\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate null # Args: lhs, low, high\n # non bson-specific\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return Number;\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate null # Args: lhs, arg, argType\n DateSymbolTemplate: &DateSymbolTemplate null # No args\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate !!js/function >\n (lhs, date, isString) => {\n if (isString) {\n return date.toString();\n }\n return date;\n }\n\n #############################################\n # Object Attributes/Methods #\n # #\n # These're variables or functions called on #\n # instantiated objects. For example, #\n # ObjectId().isValid() or Timestamp().t #\n # #\n # They follow the same pattern with the\n # *Template/*ArgsTemplates: usually no args #\n # to the Template and lhs plus any original #\n # arguments to the ArgsTemplate. #\n # #\n #############################################\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.toString();\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.equals(rhs);\n }\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getTimestamp();\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n (lhs) => {\n return lhs;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.isValid;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate null\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate null\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.db;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.collection;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.oid;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n LongEqualsTemplate: &LongEqualsTemplate null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate null\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongValueOfTemplate: &LongValueOfTemplate null\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, rhs) => {\n return lhs.toNumber();\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.high;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.low;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getLowBits();\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getHighBits();\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\n }\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getLowBits();\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs, rhs) => {\n return lhs.getHighBits();\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs, rhs) => {\n return new Date(lhs.getHighBits() * 1000);\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n (lhs, rhs) => {\n return lhs;\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 Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # non bson-specific\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return Date.now;\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n\n #############################################\n # Symbol Attributes/Methods #\n # #\n # These're variables or functions called on #\n # symbols. Also called bson-utils. #\n # #\n # They are basically the same thing as #\n # object attributes/methods, but need to be #\n # distinguished since they are separate #\n # namespaces that happen to have the same #\n # name which is v confusing. #\n # #\n # For example, ObjectId().toString() is an #\n # object method, while ObjectId.fromString #\n # is a symbol attribute. These are two #\n # separate ObjectId related namespaces that #\n # don't overlap. #\n # #\n #############################################\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate 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 Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n (lhs, rhs) => {\n return lhs.createFromTime;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate null\n # non bson-specific would go here, but there aren't any atm.\n\n #############################################\n # Imports #\n # #\n # Each type has a 'code' that is consistent #\n # between languages. The import templates #\n # for each code generate the required #\n # statement for each type. No args. #\n # #\n # The ImportTemplate collects everything #\n # into one statement. #\n # #\n #############################################\n ImportTemplate: &ImportTemplate null\n DriverImportTemplate: &DriverImportTemplate 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 unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n args:\n - [ *IntegerType, null ]\n type: *StringType\n template: *LongToStringTemplate\n argsTemplate: *LongToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongEqualsTemplate\n argsTemplate: *LongEqualsArgsTemplate\n toInt:\n <<: *__func\n id: \"toInt\"\n type: *IntegerType\n template: *LongToIntTemplate\n argsTemplate: *LongToIntArgsTemplate\n toNumber:\n <<: *__func\n id: \"toNumber\"\n type: *DecimalType\n template: *LongToNumberTemplate\n argsTemplate: *LongToNumberArgsTemplate\n compare:\n <<: *__func\n id: \"compare\"\n args:\n - [ \"Long\" ]\n type: *StringType\n template: *LongCompareTemplate\n argsTemplate: *LongCompareArgsTemplate\n isOdd:\n <<: *__func\n id: \"isOdd\"\n type: *BoolType\n template: *LongIsOddTemplate\n argsTemplate: *LongIsOddArgsTemplate\n isZero:\n <<: *__func\n id: \"isZero\"\n type: *BoolType\n template: *LongIsZeroTemplate\n argsTemplate: *LongIsZeroArgsTemplate\n isNegative:\n <<: *__func\n id: \"isNegative\"\n type: *BoolType\n template: *LongIsNegativeTemplate\n argsTemplate: *LongIsNegativeArgsTemplate\n negate:\n <<: *__func\n id: \"negate\"\n type: \"Long\"\n template: *LongNegateTemplate\n argsTemplate: *LongNegateArgsTemplate\n not:\n <<: *__func\n id: \"not\"\n type: \"Long\"\n template: *LongNotTemplate\n argsTemplate: *LongNotArgsTemplate\n notEquals:\n <<: *__func\n id: \"notEquals\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongNotEqualsTemplate\n argsTemplate: *LongNotEqualsArgsTemplate\n greaterThan:\n <<: *__func\n id: \"greaterThan\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongGreaterThanTemplate\n argsTemplate: *LongGreaterThanArgsTemplate\n greaterThanOrEqual:\n <<: *__func\n id: \"greaterThanOrEqual\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongGreaterThanOrEqualTemplate\n argsTemplate: *LongGreaterThanOrEqualArgsTemplate\n lessThan:\n <<: *__func\n id: \"lessThan\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongLessThanTemplate\n argsTemplate: *LongLessThanArgsTemplate\n lessThanOrEqual:\n <<: *__func\n id: \"lessThanOrEqual\"\n args:\n - [ \"Long\" ]\n type: *BoolType\n template: *LongLessThanOrEqualTemplate\n argsTemplate: *LongLessThanOrEqualArgsTemplate\n add:\n <<: *__func\n id: \"add\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongAddTemplate\n argsTemplate: *LongAddArgsTemplate\n subtract:\n <<: *__func\n id: \"subtract\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongSubtractTemplate\n argsTemplate: *LongSubtractArgsTemplate\n multiply:\n <<: *__func\n id: \"multiply\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongMultiplyTemplate\n argsTemplate: *LongMultiplyArgsTemplate\n div:\n <<: *__func\n id: \"div\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongDivTemplate\n argsTemplate: *LongDivArgsTemplate\n modulo:\n <<: *__func\n id: \"modulo\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongModuloTemplate\n argsTemplate: *LongModuloArgsTemplate\n and:\n <<: *__func\n id: \"and\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongAndTemplate\n argsTemplate: *LongAndArgsTemplate\n or:\n <<: *__func\n id: \"or\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongOrTemplate\n argsTemplate: *LongOrArgsTemplate\n xor:\n <<: *__func\n id: \"xor\"\n args:\n - [ \"Long\" ]\n type: \"Long\"\n template: *LongXorTemplate\n argsTemplate: *LongXorArgsTemplate\n shiftLeft:\n <<: *__func\n id: \"shiftLeft\"\n args:\n - [ *IntegerType ]\n type: \"Long\"\n template: *LongShiftLeftTemplate\n argsTemplate: *LongShiftLeftArgsTemplate\n shiftRight:\n <<: *__func\n id: \"shiftRight\"\n args:\n - [ *IntegerType ]\n type: \"Long\"\n template: *LongShiftRightTemplate\n argsTemplate: *LongShiftRightArgsTemplate\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"Timestamp\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampEqualsTemplate\n argsTemplate: *TimestampEqualsArgsTemplate\n getLowBits:\n <<: *__func\n id: \"getLowBits\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getHighBits:\n <<: *__func\n id: \"getHighBits\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n compare:\n <<: *__func\n id: \"compare\"\n args:\n - [ \"Timestamp\" ]\n type: *StringType\n template: *TimestampCompareTemplate\n argsTemplate: *TimestampCompareArgsTemplate\n notEquals:\n <<: *__func\n id: \"notEquals\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampNotEqualsTemplate\n argsTemplate: *TimestampNotEqualsArgsTemplate\n greaterThan:\n <<: *__func\n id: \"greaterThan\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampGreaterThanTemplate\n argsTemplate: *TimestampGreaterThanArgsTemplate\n greaterThanOrEqual:\n <<: *__func\n id: \"greaterThanOrEqual\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampGreaterThanOrEqualTemplate\n argsTemplate: *TimestampGreaterThanOrEqualArgsTemplate\n lessThan:\n <<: *__func\n id: \"lessThan\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampLessThanTemplate\n argsTemplate: *TimestampLessThanArgsTemplate\n lessThanOrEqual:\n <<: *__func\n id: \"lessThanOrEqual\"\n args:\n - [ \"Timestamp\" ]\n type: *BoolType\n template: *TimestampLessThanOrEqualTemplate\n argsTemplate: *TimestampLessThanOrEqualArgsTemplate\n BSONSymbol: &SymbolType\n <<: *__type\n id: \"BSONSymbol\"\n code: 111\n type: *ObjectType\n attr:\n valueOf:\n <<: *__func\n id: \"valueOf\"\n type: *StringType\n template: *SymbolValueOfTemplate\n argsTemplate: *SymbolValueOfArgsTemplate\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *SymbolToStringTemplate\n argsTemplate: *SymbolToStringArgsTemplate\n inspect:\n <<: *__func\n id: \"inspect\"\n type: *StringType\n template: *SymbolInspectTemplate\n argsTemplate: *SymbolInspectArgsTemplate\n Double: &DoubleType\n <<: *__type\n id: \"Double\"\n code: 104\n type: *ObjectType\n attr: {}\n Decimal128: &Decimal128Type\n <<: *__type\n id: \"Decimal128\"\n code: 112\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *Decimal128ToStringTemplate\n argsTemplate: *Decimal128ToStringArgsTemplate\n NumberDecimal: &NumberDecimalType\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *Decimal128ToStringTemplate\n argsTemplate: *Decimal128ToStringArgsTemplate\n\n\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\n BSONRegExpType: &BSONRegExpType\n <<: *__type\n id: \"BSONRegExp\"\n code: 109\n type: *ObjectType\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *ObjectIdType\n attr:\n createFromHexString:\n <<: *__func\n id: \"createFromHexString\"\n args:\n - [ *StringType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromHexStringTemplate\n argsTemplate: *ObjectIdCreateFromHexStringArgsTemplate\n createFromTime:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *NumericType, *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n isValid:\n <<: *__func\n id: \"isValid\"\n args:\n - [ *StringType ]\n type: *BoolType\n template: *ObjectIdIsValidTemplate\n argsTemplate: *ObjectIdIsValidArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n BSONRegExp:\n id: \"BSONRegExp\"\n code: 109\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *StringType, null ]\n type: *BSONRegExpType\n attr: {}\n template: *BSONRegExpSymbolTemplate\n argsTemplate: *BSONRegExpSymbolArgsTemplate\n BSONSymbol:\n id: \"BSONSymbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n Decimal128:\n id: \"Decimal128\"\n code: 112\n callable: *constructor\n args:\n - [ *ObjectType ]\n type: *Decimal128Type\n attr:\n fromString:\n id: \"fromString\"\n callable: *func\n args:\n - [ *StringType ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolFromStringTemplate\n argsTemplate: *Decimal128SymbolFromStringArgsTemplate\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n Double:\n id: \"Double\"\n code: 104\n callable: *constructor\n args:\n - [ *NumericType, *StringType ]\n type: *DoubleType\n attr: {}\n template: *DoubleSymbolTemplate\n argsTemplate: *DoubleSymbolArgsTemplate\n Int32:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n Long:\n id: \"Long\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *LongType\n attr:\n MAX_VALUE:\n id: \"MAX_VALUE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolMaxTemplate\n argsTemplate: *LongSymbolMaxArgsTemplate\n MIN_VALUE:\n id: \"MIN_VALUE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolMinTemplate\n argsTemplate: *LongSymbolMinArgsTemplate\n ZERO:\n id: \"ZERO\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolZeroTemplate\n argsTemplate: *LongSymbolZeroArgsTemplate\n ONE:\n id: \"ONE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolOneTemplate\n argsTemplate: *LongSymbolOneArgsTemplate\n NEG_ONE:\n id: \"NEG_ONE\"\n callable: *var\n args: null\n type: *LongType\n attr: {}\n template: *LongSymbolNegOneTemplate\n argsTemplate: *LongSymbolNegOneArgsTemplate\n fromBits:\n id: \"LongfromBits\" # Needs process method\n callable: *func\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromBitsTemplate\n argsTemplate: *LongSymbolFromBitsArgsTemplate\n fromInt:\n id: \"fromInt\"\n callable: *func\n args:\n - [ *IntegerType ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromIntTemplate\n argsTemplate: *LongSymbolFromIntArgsTemplate\n fromNumber:\n id: \"fromNumber\"\n callable: *func\n args:\n - [ *NumericType ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromNumberTemplate\n argsTemplate: *LongSymbolFromNumberArgsTemplate\n fromString:\n id: \"fromString\"\n callable: *func\n args:\n - [ *StringType ]\n - [ *IntegerType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolFromStringTemplate\n argsTemplate: *LongSymbolFromStringArgsTemplate\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; |
{ | ||
"name": "bson-transpilers", | ||
"version": "0.0.0-next-c5eba7335c2da0b9754b4e52495c98f48ec15463", | ||
"version": "0.0.0-next-c64c3eb80d5fc1c2d71c9794f9b35ec86d0ff181", | ||
"apiVersion": "0.0.1", | ||
"productName": "BSON Transpilers", | ||
"description": "Source to source compilers using ANTLR", | ||
@@ -17,5 +16,4 @@ "contributors": [ | ||
"precompile": "node download-antlr.js", | ||
"compile": "npm run antlr4-js && npm run antlr4-py && npm run symbol-table", | ||
"compile": "npm run antlr4-js && npm run symbol-table", | ||
"antlr4-js": "java -Xmx500M -cp './antlr-4.7.2-complete.jar:$CLASSPATH' org.antlr.v4.Tool -Dlanguage=JavaScript -lib grammars -o lib/antlr -visitor -Xexact-output-dir grammars/ECMAScript.g4", | ||
"antlr4-py": "java -Xmx500M -cp './antlr-4.7.2-complete.jar:$CLASSPATH' org.antlr.v4.Tool -Dlanguage=JavaScript -lib grammars -o lib/antlr -visitor -Xexact-output-dir grammars/Python3.g4", | ||
"symbol-table": "node compile-symbol-table.js", | ||
@@ -26,3 +24,3 @@ "pretest": "npm run compile", | ||
"test-ci": "mocha", | ||
"depcheck": "depcheck", | ||
"depcheck": "compass-scripts check-peer-deps && depcheck", | ||
"check": "npm run lint && npm run depcheck", | ||
@@ -39,11 +37,11 @@ "lint": "eslint .", | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-c64c3eb80d5fc1c2d71c9794f9b35ec86d0ff181", | ||
"chai": "^4.3.4", | ||
"depcheck": "^1.4.1", | ||
"eslint": "^7.25.0", | ||
"eslint-config-mongodb-js": "^2.1.0", | ||
"mocha": "^8.4.0" | ||
"mocha": "^10.2.0" | ||
}, | ||
"dependencies": { | ||
"antlr4": "4.7.2", | ||
"bson": "^4.4.1", | ||
"bson": "^6.2.0", | ||
"js-yaml": "^3.13.1" | ||
@@ -55,3 +53,3 @@ }, | ||
}, | ||
"gitHead": "c5eba7335c2da0b9754b4e52495c98f48ec15463" | ||
"gitHead": "c64c3eb80d5fc1c2d71c9794f9b35ec86d0ff181" | ||
} |
@@ -6,8 +6,10 @@ # BSON-Transpilers | ||
Transpilers for building BSON documents in any language. Current support | ||
provided for `shell` `javascript` and `python` as inputs. `java`, `c#`, `node`, `shell`, `python`, `ruby` and `go` as outputs. | ||
provided for `shell` as inputs. `java`, `c#`, `node`, `shell`, `python`, `ruby` and `go` as outputs. | ||
> ⚠️ `shell` output produces code that is compatible only with legacy `mongo` shell not the new `mongosh` shell. See [COMPASS-4930](https://jira.mongodb.org/browse/COMPASS-4930) for some additional context | ||
See also the original presentation: https://drive.google.com/file/d/1jvwtR3k9oBUzIjL4z_VtpHvdWahfcjTK/view | ||
**NOTES:** | ||
1. A version of the code with support for `python` with corresponding test cases has been removed to avoid bundling and supporting unused code, however it can be still be found in https://github.com/mongodb-js/compass/tree/80cf701e44cd966207f956fac69e8233861b1cd5/packages/bson-transpilers. | ||
2. The `shell` output is disabled as is essentially the only input in use and it produces code that is compatible only with legacy `mongo` shell not the new `mongosh` shell. See [COMPASS-4930](https://jira.mongodb.org/browse/COMPASS-4930) for some additional context. | ||
# Usage | ||
@@ -18,3 +20,3 @@ | ||
const input = 'javascript'; | ||
const input = 'shell'; | ||
const output = 'java'; | ||
@@ -21,0 +23,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237
5
1377565
47
15866
+ Addedbson@6.10.1(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbson@4.7.2(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedieee754@1.2.1(transitive)
Updatedbson@^6.2.0