diff --git a/Aptfile b/Aptfile new file mode 100644 index 0000000..6db3ac7 --- /dev/null +++ b/Aptfile @@ -0,0 +1 @@ +swi-prolog diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..e1d4131 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node app.js diff --git a/app.js b/app.js index 7424fb4..f85cae9 100644 --- a/app.js +++ b/app.js @@ -6,8 +6,11 @@ const path = require('path') const { config } = require('./config.js') const tmp = require('./lib/tmp.js') const eye = require('./lib/eye/eye.js') -const cwm = require('./lib/cwm/cwm.js') +// const cwm = require('./lib/cwm/cwm.js') const jen3 = require('./lib/jen3/jen3.js') +const jena = require('./lib/jena/jena.js') +const triplify = require('./lib/triplify/triplify.js') +const spin3 = require('./lib/spin3/spin3.js') const { generateLink, resolveLink } = require('./lib/gen_link.js') const { checkBuiltinInput } = require('./lib/check_builtin_input.js') @@ -17,7 +20,15 @@ app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: true })) app.use('/n3/editor/s/*', (req, res) => { - res.sendFile(path.join(__dirname, "editor/index.html")); + res.sendFile(path.join(__dirname, "editor/index.html")); +}); +app.use('/n3/out', express.static("out")); +app.use('/n3/editor/out', express.static("out")); +app.use('/n3/spin3*', (req, res) => { + res.sendFile(path.join(__dirname, "editor/spin3.html")); +}); +app.use('/n3/sparql*', (req, res) => { + res.sendFile(path.join(__dirname, "editor/sparql.html")); }); app.use('/n3/editor', express.static(path.join(__dirname, "editor"))); app.use('/n3/lib/eyebrow', express.static(path.join(__dirname, "lib/eyebrow"))); @@ -46,8 +57,9 @@ app.post('/n3', (request, response) => { const data = request.body // console.log("data:", data); console.log( - "task:", data.task, - (data.system? ", system: " + data.system : "") + "task:", data.task, + (data.subTask ? ", subTask: " + data.subTask : ""), + (data.system ? ", system: " + data.system : "") ); function ctu(ret) { @@ -73,18 +85,30 @@ app.post('/n3', (request, response) => { doImperating(data, ctu) break - case 'generate_link': - doGenerateLink(data, ctu) + case 'triplify': + doTriplify(data, ctu) break - case 'resolve_link': - doResolveLink(data, ctu) + case 'query': + doQuery(data, ctu) break + case 'spin3': + doSpin3(data, ctu); + break + case 'check_builtin_input': doCheckBuiltinInput(data, ctu) break + case 'generate_link': + doGenerateLink(data, ctu) + break + + case 'resolve_link': + doResolveLink(data, ctu) + break + default: ctu({ error: 'unknown task: ' + data.task }) } @@ -93,15 +117,12 @@ app.post('/n3', (request, response) => { app.listen(config.http.port) console.log(`Listening at ${config.http.hostname}:${config.http.port}`) -function doReasoning(options, ctu) { - tmp.save(options.formula, (file) => { +async function doReasoning(options, ctu) { + let file; + try { + file = await tmp.save(options.formula) - function end(ret) { - tmp.del(file) - ctu(ret) - } - - var reasoner = null; + let reasoner = null; switch (options.system) { case "eye": reasoner = eye @@ -116,46 +137,130 @@ function doReasoning(options, ctu) { break default: - end({ error: `unsupported system: "${options.system}"` }) - break + throw `unsupported system: "${options.system}"` } - if (reasoner) - reasoner.exec(options, file, end) - }) + + const output = await reasoner.exec(options, file) + ctu({ success: output }) + + } catch (e) { + console.log(e) + ctu({ error: e + "" }) + + } finally { + await tmp.del(file) + } } -function doExplaining(options, ctu) { - tmp.save(options.formula, (file) => { +async function doExplaining(options, ctu) { + let file + try { + file = await tmp.save(options.formula) - var reasoner = null; + let reasoner = null; switch (options.system) { case "eye": reasoner = eye break default: - end({ error: `unsupported system: "${options.system}"` }) - break + throw `unsupported system: "${options.system}"` } - reasoner.exec(options, file, (explanation) => { - tmp.del(file) + const explanation = await reasoner.exec(options, file) + ctu({ success: explanation }) - ctu(explanation) - }) - }) + } catch(e) { + console.log(e) + ctu({ error: e }) + + } finally { + await tmp.del(file) + } } -function doImperating(options, ctu) { - tmp.save(options.formula, (file) => { +async function doImperating(options, ctu) { + let file + try { + file = await tmp.save(options.formula) + + const reasoner = jen3; + const code = await reasoner.exec(options, file) + ctu({ success: code }) + + } catch (e) { + console.log(e) + ctu({ error: e + "" }) + + } finally { + await tmp.del(file) + } +} - var reasoner = jen3; - reasoner.exec(options, file, (code) => { - tmp.del(file) +async function doTriplify(options, ctu) { + let file + try { + file = tmp.save(options.formula) - ctu(code) - }) - }) + const code = await triplify.exec(options, file) + ctu({ success: code }) + + } catch (e) { + console.log(e) + ctu({ error: e + "" }) + + } finally { + await tmp.del(file) + } +} + +async function doQuery(options, ctu) { + let data, query + try { + data = await tmp.save(options.data) + query = await tmp.save(options.query) + + let engine = null; + switch (options.system) { + + case "jena": + engine = jena + break + + default: + throw `unsupported system: "${options.system}"` + } + + const output = await engine.exec(options, data, query) + ctu({ success: output }) + + } catch (e) { + console.log(e) + ctu({ error: e + "" }) + + } finally { + await tmp.del(data) + await tmp.del(query) + } +} + +async function doSpin3(options, ctu) { + let data, query + try { + data = await tmp.save(options.data) + query = await tmp.save(options.query) + + const output = await spin3.exec(options, data, query); + ctu({ success: output }) + + } catch (e) { + console.log(e) + ctu({ error: e + "" }) + + } finally { + await tmp.del(data) + await tmp.del(query) + } } function doGenerateLink(options, ctu) { @@ -166,24 +271,28 @@ function doGenerateLink(options, ctu) { function doResolveLink(options, ctu) { resolveLink(options.id) - .then((data) => { + .then((data) => { // console.log("resolved link:", data); ctu({ success: data }) }) .catch((error) => { ctu({ error: error }) }) } -function doCheckBuiltinInput(options, ctu) { - tmp.save(options.definitions, (defFile) => { - tmp.save(options.test, (testFile) => { +async function doCheckBuiltinInput(options, ctu) { + let defFile, testFile + try { + defFile = await tmp.save(options.definitions) + testFile = await tmp.save(options.test) - function end(ret) { - tmp.del(defFile) - tmp.del(testFile) - ctu(ret) - } + const output = await checkBuiltinInput(defFile, testFile) + ctu({ success: output }) - checkBuiltinInput(defFile, testFile, end) - }) - }) + } catch (e) { + console.log(e) + ctu({ error: e + "" }) + + } finally { + await tmp.del(defFile) + await tmp.del(testFile) + } } diff --git a/config.js b/config.js index 4b8bbd3..7e7337d 100644 --- a/config.js +++ b/config.js @@ -1,38 +1,50 @@ config = { http: { - hostname: 'http://127.0.0.1', - port: 3002 + hostname: 'https://n3-editor.herokuapp.com', + port: ((typeof process) != "undefined" ? process.env.PORT : undefined) }, - reasoners: { + out: "/app/out", + + tools: { eye: { - exec: "/Users/wvw/git/n3/n3-editor-js/opt/eye/bin/eye", - folder: "/Users/wvw/git/n3/n3-editor-js/lib/eye" + exec: "eye", + folder: "/app/lib/eye" }, cwm: { // (use python2 for cwm) - pythonCmd: "python", - exec: "/Users/wvw/cwm-1.2.1/swap/cwm.py" + pythonCmd: "", // (python2 is not available) + exec: "" }, jen3: { - exec: "/Users/wvw/git/n3/n3-editor-js/lib/jen3/jen3.jar", - codegen: "/Users/wvw/git/n3/n3-editor-js/lib/jen3/codegen.jar", - folder: "/Users/wvw/git/n3/n3-editor-js/lib/jen3" - } + exec: "/app/lib/jen3/jen3.jar", + codegen: "/app/lib/jen3/codegen.jar", + folder: "/app/lib/jen3" + }, + jena: { + exec: "/app/lib/jena/sparql.jar", + }, + triplify: { + exec: "/app/lib/triplify/sparql2spin.jar" + }, + spin3: { + folder: "/app/lib/spin3" + }, }, link: { max_len: 50000, db: { + // mysql://b4837d17c012f1:e023e78d@us-cdbr-east-06.cleardb.net/heroku_e750abd160bbcaf?reconnect=true port: '33060', - host: 'localhost', - db: "n3_links", - user: 'root', - pwd: '' + host: "us-cdbr-east-06.cleardb.net", + db: "heroku_e750abd160bbcaf", + user: "b4837d17c012f1", + pwd: "e023e78d" } }, - path: "/Users/wvw/git/n3/n3-editor-js" + path: "/Users/wvw/git/n3/n3-editor-js" // ?? } if (typeof exports === 'object' && typeof module === 'object') diff --git a/config_heroku.js b/config_heroku.js new file mode 100644 index 0000000..7e7337d --- /dev/null +++ b/config_heroku.js @@ -0,0 +1,53 @@ +config = { + http: { + hostname: 'https://n3-editor.herokuapp.com', + port: ((typeof process) != "undefined" ? process.env.PORT : undefined) + }, + + out: "/app/out", + + tools: { + eye: { + exec: "eye", + folder: "/app/lib/eye" + }, + cwm: { + // (use python2 for cwm) + pythonCmd: "", // (python2 is not available) + exec: "" + }, + jen3: { + exec: "/app/lib/jen3/jen3.jar", + codegen: "/app/lib/jen3/codegen.jar", + folder: "/app/lib/jen3" + }, + jena: { + exec: "/app/lib/jena/sparql.jar", + }, + triplify: { + exec: "/app/lib/triplify/sparql2spin.jar" + }, + spin3: { + folder: "/app/lib/spin3" + }, + }, + + link: { + max_len: 50000, + db: { + // mysql://b4837d17c012f1:e023e78d@us-cdbr-east-06.cleardb.net/heroku_e750abd160bbcaf?reconnect=true + port: '33060', + host: "us-cdbr-east-06.cleardb.net", + db: "heroku_e750abd160bbcaf", + user: "b4837d17c012f1", + pwd: "e023e78d" + } + }, + + path: "/Users/wvw/git/n3/n3-editor-js" // ?? +} + +if (typeof exports === 'object' && typeof module === 'object') + module.exports = { + config + }; \ No newline at end of file diff --git a/config_local.js b/config_local.js index 4b8bbd3..9fd7ffe 100644 --- a/config_local.js +++ b/config_local.js @@ -4,9 +4,11 @@ config = { port: 3002 }, - reasoners: { + out: "/Users/wvw/git/n3/n3-editor-js/out", + + tools: { eye: { - exec: "/Users/wvw/git/n3/n3-editor-js/opt/eye/bin/eye", + exec: "eye", folder: "/Users/wvw/git/n3/n3-editor-js/lib/eye" }, cwm: { @@ -18,7 +20,16 @@ config = { exec: "/Users/wvw/git/n3/n3-editor-js/lib/jen3/jen3.jar", codegen: "/Users/wvw/git/n3/n3-editor-js/lib/jen3/codegen.jar", folder: "/Users/wvw/git/n3/n3-editor-js/lib/jen3" - } + }, + jena: { + exec: "/Users/wvw/git/n3/n3-editor-js/lib/jena/sparql.jar", + }, + triplify: { + exec: "/Users/wvw/git/n3/n3-editor-js/lib/triplify/sparql2spin.jar" + }, + spin3: { + folder: "/Users/wvw/git/n3/n3-editor-js/lib/spin3" + }, }, link: { diff --git a/config_ppr.js b/config_ppr.js index e9d75e3..7ddf607 100644 --- a/config_ppr.js +++ b/config_ppr.js @@ -4,7 +4,7 @@ config = { port: 3002 }, - reasoners: { + tools: { eye: { exec: "/home/woensel/projects/n3-editor-js/opt/eye/bin/eye", folder: "/home/woensel/projects/n3-editor-js/lib/eye" @@ -18,6 +18,9 @@ config = { exec: "/home/woensel/projects/n3-editor-js/lib/jen3/jen3.jar", codegen: "/home/woensel/projects/n3-editor-js/lib/jen3/codegen.jar", folder: "/home/woensel/projects/n3-editor-js/lib/jen3" + }, + triplify: { + exec: "/home/woensel/projects/n3-editor-js/lib/triplify/sparql2spin.jar" } }, diff --git a/editor/dist/n3Main.js b/editor/dist/n3Main.js index 6a63970..ed05e29 100644 --- a/editor/dist/n3Main.js +++ b/editor/dist/n3Main.js @@ -1,16722 +1,2 @@ -var n3; -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ 262: -/***/ (() => { - -/* (ignored) */ - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be in strict mode. -(() => { -"use strict"; -// ESM COMPAT FLAG -__webpack_require__.r(__webpack_exports__); - -// EXPORTS -__webpack_require__.d(__webpack_exports__, { - "parse": () => (/* binding */ parse) -}); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Token.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * A token has properties: text, type, line, character position in the line - * (so we can ignore tabs), token channel, index, and source from which - * we obtained this token. - */ -class Token { - constructor() { - this.source = null; - this.type = null; // token type of the token - this.channel = null; // The parser ignores everything not on DEFAULT_CHANNEL - this.start = null; // optional; return -1 if not implemented. - this.stop = null; // optional; return -1 if not implemented. - this.tokenIndex = null; // from 0..n-1 of the token object in the input stream - this.line = null; // line=1..n of the 1st character - this.column = null; // beginning of the line at which it occurs, 0..n-1 - this._text = null; // text of the token. - } - - getTokenSource() { - return this.source[0]; - } - - getInputStream() { - return this.source[1]; - } - - get text(){ - return this._text; - } - - set text(text) { - this._text = text; - } -} - -Token.INVALID_TYPE = 0; - -/** - * During lookahead operations, this "token" signifies we hit rule end ATN state - * and did not follow it despite needing to. - */ -Token.EPSILON = -2; - -Token.MIN_USER_TOKEN_TYPE = 1; - -Token.EOF = -1; - -/** - * All tokens go to the parser (unless skip() is called in that rule) - * on a particular "channel". The parser tunes to a particular channel - * so that whitespace etc... can go to the parser on a "hidden" channel. - */ -Token.DEFAULT_CHANNEL = 0; - -/** - * Anything on different channel than DEFAULT_CHANNEL is not parsed - * by parser. - */ -Token.HIDDEN_CHANNEL = 1; - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/polyfills/codepointat.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/*! https://mths.be/codepointat v0.2.0 by @mathias */ -if (!String.prototype.codePointAt) { - (function() { - 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` - var defineProperty = (function() { - // IE 8 only supports `Object.defineProperty` on DOM elements - let result; - try { - const object = {}; - const $defineProperty = Object.defineProperty; - result = $defineProperty(object, object, object) && $defineProperty; - } catch(error) { - /* eslint no-empty: [ "off" ] */ - } - return result; - }()); - const codePointAt = function(position) { - if (this == null) { - throw TypeError(); - } - const string = String(this); - const size = string.length; - // `ToInteger` - let index = position ? Number(position) : 0; - if (index !== index) { // better `isNaN` - index = 0; - } - // Account for out-of-bounds indices: - if (index < 0 || index >= size) { - return undefined; - } - // Get the first code unit - const first = string.charCodeAt(index); - let second; - if ( // check if it’s the start of a surrogate pair - first >= 0xD800 && first <= 0xDBFF && // high surrogate - size > index + 1 // there is a next code unit - ) { - second = string.charCodeAt(index + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - return first; - }; - if (defineProperty) { - defineProperty(String.prototype, 'codePointAt', { - 'value': codePointAt, - 'configurable': true, - 'writable': true - }); - } else { - String.prototype.codePointAt = codePointAt; - } - }()); -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/polyfills/fromcodepoint.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */ -if (!String.fromCodePoint) { - (function() { - const defineProperty = (function() { - // IE 8 only supports `Object.defineProperty` on DOM elements - let result; - try { - const object = {}; - const $defineProperty = Object.defineProperty; - result = $defineProperty(object, object, object) && $defineProperty; - } catch(error) { - /* eslint no-empty: [ "off" ] */ - } - return result; - }()); - const stringFromCharCode = String.fromCharCode; - const floor = Math.floor; - const fromCodePoint = function(_) { - const MAX_SIZE = 0x4000; - const codeUnits = []; - let highSurrogate; - let lowSurrogate; - let index = -1; - const length = arguments.length; - if (!length) { - return ''; - } - let result = ''; - while (++index < length) { - let codePoint = Number(arguments[index]); - if ( - !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` - codePoint < 0 || // not a valid Unicode code point - codePoint > 0x10FFFF || // not a valid Unicode code point - floor(codePoint) !== codePoint // not an integer - ) { - throw RangeError('Invalid code point: ' + codePoint); - } - if (codePoint <= 0xFFFF) { // BMP code point - codeUnits.push(codePoint); - } else { // Astral code point; split in surrogate halves - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - codePoint -= 0x10000; - highSurrogate = (codePoint >> 10) + 0xD800; - lowSurrogate = (codePoint % 0x400) + 0xDC00; - codeUnits.push(highSurrogate, lowSurrogate); - } - if (index + 1 === length || codeUnits.length > MAX_SIZE) { - result += stringFromCharCode.apply(null, codeUnits); - codeUnits.length = 0; - } - } - return result; - }; - if (defineProperty) { - defineProperty(String, 'fromCodePoint', { - 'value': fromCodePoint, - 'configurable': true, - 'writable': true - }); - } else { - String.fromCodePoint = fromCodePoint; - } - }()); -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/InputStream.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - -/** - * If decodeToUnicodeCodePoints is true, the input is treated - * as a series of Unicode code points. - * - * Otherwise, the input is treated as a series of 16-bit UTF-16 code - * units. - */ -class InputStream { - constructor(data, decodeToUnicodeCodePoints) { - this.name = ""; - this.strdata = data; - this.decodeToUnicodeCodePoints = decodeToUnicodeCodePoints || false; - // _loadString - Vacuum all input from a string and then treat it like a buffer. - this._index = 0; - this.data = []; - if (this.decodeToUnicodeCodePoints) { - for (let i = 0; i < this.strdata.length; ) { - const codePoint = this.strdata.codePointAt(i); - this.data.push(codePoint); - i += codePoint <= 0xFFFF ? 1 : 2; - } - } else { - this.data = new Array(this.strdata.length); - for (let i = 0; i < this.strdata.length; i++) { - const codeUnit = this.strdata.charCodeAt(i); - this.data[i] = codeUnit; - } - } - this._size = this.data.length; - } - - /** - * Reset the stream so that it's in the same state it was - * when the object was created *except* the data array is not - * touched. - */ - reset() { - this._index = 0; - } - - consume() { - if (this._index >= this._size) { - // assert this.LA(1) == Token.EOF - throw ("cannot consume EOF"); - } - this._index += 1; - } - - LA(offset) { - if (offset === 0) { - return 0; // undefined - } - if (offset < 0) { - offset += 1; // e.g., translate LA(-1) to use offset=0 - } - const pos = this._index + offset - 1; - if (pos < 0 || pos >= this._size) { // invalid - return Token.EOF; - } - return this.data[pos]; - } - - LT(offset) { - return this.LA(offset); - } - -// mark/release do nothing; we have entire buffer - mark() { - return -1; - } - - release(marker) { - } - - /** - * consume() ahead until p==_index; can't just set p=_index as we must - * update line and column. If we seek backwards, just set p - */ - seek(_index) { - if (_index <= this._index) { - this._index = _index; // just jump; don't update stream state (line, - // ...) - return; - } - // seek forward - this._index = Math.min(_index, this._size); - } - - getText(start, stop) { - if (stop >= this._size) { - stop = this._size - 1; - } - if (start >= this._size) { - return ""; - } else { - if (this.decodeToUnicodeCodePoints) { - let result = ""; - for (let i = start; i <= stop; i++) { - result += String.fromCodePoint(this.data[i]); - } - return result; - } else { - return this.strdata.slice(start, stop + 1); - } - } - } - - toString() { - return this.strdata; - } - - get index(){ - return this._index; - } - - get size(){ - return this._size; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ErrorListener.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * Provides an empty default implementation of {@link ANTLRErrorListener}. The - * default implementation of each method does nothing, but can be overridden as - * necessary. - */ -class ErrorListener { - syntaxError(recognizer, offendingSymbol, line, column, msg, e) { - } - - reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { - } - - reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { - } - - reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) { - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ConsoleErrorListener.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/** - * {@inheritDoc} - * - *

- * This implementation prints messages to {@link System//err} containing the - * values of {@code line}, {@code charPositionInLine}, and {@code msg} using - * the following format.

- * - *
- * line line:charPositionInLine msg
- * 
- * - */ -class ConsoleErrorListener extends ErrorListener { - constructor() { - super(); - } - - syntaxError(recognizer, offendingSymbol, line, column, msg, e) { - console.error("line " + line + ":" + column + " " + msg); - } -} - - -/** - * Provides a default instance of {@link ConsoleErrorListener}. - */ -ConsoleErrorListener.INSTANCE = new ConsoleErrorListener(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ProxyErrorListener.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class ProxyErrorListener extends ErrorListener { - constructor(delegates) { - super(); - if (delegates===null) { - throw "delegates"; - } - this.delegates = delegates; - return this; - } - - syntaxError(recognizer, offendingSymbol, line, column, msg, e) { - this.delegates.map(d => d.syntaxError(recognizer, offendingSymbol, line, column, msg, e)); - } - - reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { - this.delegates.map(d => d.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs)); - } - - reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { - this.delegates.map(d => d.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs)); - } - - reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) { - this.delegates.map(d => d.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs)); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Recognizer.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - -class Recognizer { - constructor() { - this._listeners = [ ConsoleErrorListener.INSTANCE ]; - this._interp = null; - this._stateNumber = -1; - } - - checkVersion(toolVersion) { - const runtimeVersion = "4.10.1"; - if (runtimeVersion!==toolVersion) { - console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion); - } - } - - addErrorListener(listener) { - this._listeners.push(listener); - } - - removeErrorListeners() { - this._listeners = []; - } - - getLiteralNames() { - return Object.getPrototypeOf(this).constructor.literalNames || []; - } - - getSymbolicNames() { - return Object.getPrototypeOf(this).constructor.symbolicNames || []; - } - - getTokenNames() { - if(!this.tokenNames) { - const literalNames = this.getLiteralNames(); - const symbolicNames = this.getSymbolicNames(); - const length = literalNames.length > symbolicNames.length ? literalNames.length : symbolicNames.length; - this.tokenNames = []; - for(let i=0; iUsed for XPath and tree pattern compilation.

- */ - getRuleIndexMap() { - const ruleNames = this.ruleNames; - if (ruleNames===null) { - throw("The current recognizer does not provide a list of rule names."); - } - let result = this.ruleIndexMapCache[ruleNames]; // todo: should it be Recognizer.ruleIndexMapCache ? - if(result===undefined) { - result = ruleNames.reduce(function(o, k, i) { o[k] = i; }); - this.ruleIndexMapCache[ruleNames] = result; - } - return result; - } - - getTokenType(tokenName) { - const ttype = this.getTokenTypeMap()[tokenName]; - if (ttype !==undefined) { - return ttype; - } else { - return Token.INVALID_TYPE; - } - } - - // What is the error header, normally line/character position information? - getErrorHeader(e) { - const line = e.getOffendingToken().line; - const column = e.getOffendingToken().column; - return "line " + line + ":" + column; - } - - /** - * How should a token be displayed in an error message? The default - * is to display just the text, but during development you might - * want to have a lot of information spit out. Override in that case - * to use t.toString() (which, for CommonToken, dumps everything about - * the token). This is better than forcing you to override a method in - * your token objects because you don't have to go modify your lexer - * so that it creates a new Java type. - * - * @deprecated This method is not called by the ANTLR 4 Runtime. Specific - * implementations of {@link ANTLRErrorStrategy} may provide a similar - * feature when necessary. For example, see - * {@link DefaultErrorStrategy//getTokenErrorDisplay}.*/ - getTokenErrorDisplay(t) { - if (t===null) { - return ""; - } - let s = t.text; - if (s===null) { - if (t.type===Token.EOF) { - s = ""; - } else { - s = "<" + t.type + ">"; - } - } - s = s.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"); - return "'" + s + "'"; - } - - getErrorListenerDispatch() { - return new ProxyErrorListener(this._listeners); - } - - /** - * subclass needs to override these if there are sempreds or actions - * that the ATN interp needs to execute - */ - sempred(localctx, ruleIndex, actionIndex) { - return true; - } - - precpred(localctx , precedence) { - return true; - } - - get state(){ - return this._stateNumber; - } - - set state(state) { - this._stateNumber = state; - } -} - -Recognizer.tokenTypeMapCache = {}; -Recognizer.ruleIndexMapCache = {}; - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CommonToken.js - - -class CommonToken extends Token { - constructor(source, type, channel, start, stop) { - super(); - this.source = source !== undefined ? source : CommonToken.EMPTY_SOURCE; - this.type = type !== undefined ? type : null; - this.channel = channel !== undefined ? channel : Token.DEFAULT_CHANNEL; - this.start = start !== undefined ? start : -1; - this.stop = stop !== undefined ? stop : -1; - this.tokenIndex = -1; - if (this.source[0] !== null) { - this.line = source[0].line; - this.column = source[0].column; - } else { - this.column = -1; - } - } - - /** - * Constructs a new {@link CommonToken} as a copy of another {@link Token}. - * - *

- * If {@code oldToken} is also a {@link CommonToken} instance, the newly - * constructed token will share a reference to the {@link //text} field and - * the {@link Pair} stored in {@link //source}. Otherwise, {@link //text} will - * be assigned the result of calling {@link //getText}, and {@link //source} - * will be constructed from the result of {@link Token//getTokenSource} and - * {@link Token//getInputStream}.

- * - * @param oldToken The token to copy. - */ - clone() { - const t = new CommonToken(this.source, this.type, this.channel, this.start, this.stop); - t.tokenIndex = this.tokenIndex; - t.line = this.line; - t.column = this.column; - t.text = this.text; - return t; - } - - toString() { - let txt = this.text; - if (txt !== null) { - txt = txt.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t"); - } else { - txt = ""; - } - return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + - txt + "',<" + this.type + ">" + - (this.channel > 0 ? ",channel=" + this.channel : "") + "," + - this.line + ":" + this.column + "]"; - } - - get text(){ - if (this._text !== null) { - return this._text; - } - const input = this.getInputStream(); - if (input === null) { - return null; - } - const n = input.size; - if (this.start < n && this.stop < n) { - return input.getText(this.start, this.stop); - } else { - return ""; - } - } - - set text(text) { - this._text = text; - } -} - -/** - * An empty {@link Pair} which is used as the default value of - * {@link //source} for tokens that do not have a source. - */ -CommonToken.EMPTY_SOURCE = [ null, null ]; - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CommonTokenFactory.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class TokenFactory {} - -/** - * This default implementation of {@link TokenFactory} creates - * {@link CommonToken} objects. - */ -class CommonTokenFactory extends TokenFactory { - constructor(copyText) { - super(); - /** - * Indicates whether {@link CommonToken//setText} should be called after - * constructing tokens to explicitly set the text. This is useful for cases - * where the input stream might not be able to provide arbitrary substrings - * of text from the input after the lexer creates a token (e.g. the - * implementation of {@link CharStream//getText} in - * {@link UnbufferedCharStream} throws an - * {@link UnsupportedOperationException}). Explicitly setting the token text - * allows {@link Token//getText} to be called at any time regardless of the - * input stream implementation. - * - *

- * The default value is {@code false} to avoid the performance and memory - * overhead of copying text for every token unless explicitly requested.

- */ - this.copyText = copyText===undefined ? false : copyText; - } - - create(source, type, text, channel, start, stop, line, column) { - const t = new CommonToken(source, type, channel, start, stop); - t.line = line; - t.column = column; - if (text !==null) { - t.text = text; - } else if (this.copyText && source[1] !==null) { - t.text = source[1].getText(start,stop); - } - return t; - } - - createThin(type, text) { - const t = new CommonToken(null, type); - t.text = text; - return t; - } -} - -/** - * The default {@link CommonTokenFactory} instance. - * - *

- * This token factory does not explicitly copy token text when constructing - * tokens.

- */ -CommonTokenFactory.DEFAULT = new CommonTokenFactory(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/RecognitionException.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * The root of the ANTLR exception hierarchy. In general, ANTLR tracks just - * 3 kinds of errors: prediction errors, failed predicate errors, and - * mismatched input errors. In each case, the parser knows where it is - * in the input, where it is in the ATN, the rule invocation stack, - * and what kind of problem occurred. - */ - -class RecognitionException extends Error { - constructor(params) { - super(params.message); - if (Error.captureStackTrace) - Error.captureStackTrace(this, RecognitionException); - this.message = params.message; - this.recognizer = params.recognizer; - this.input = params.input; - this.ctx = params.ctx; - /** - * The current {@link Token} when an error occurred. Since not all streams - * support accessing symbols by index, we have to track the {@link Token} - * instance itself - */ - this.offendingToken = null; - /** - * Get the ATN state number the parser was in at the time the error - * occurred. For {@link NoViableAltException} and - * {@link LexerNoViableAltException} exceptions, this is the - * {@link DecisionState} number. For others, it is the state whose outgoing - * edge we couldn't match. - */ - this.offendingState = -1; - if (this.recognizer!==null) { - this.offendingState = this.recognizer.state; - } - } - - /** - * Gets the set of input symbols which could potentially follow the - * previously matched symbol at the time this exception was thrown. - * - *

If the set of expected tokens is not known and could not be computed, - * this method returns {@code null}.

- * - * @return The set of token types that could potentially follow the current - * state in the ATN, or {@code null} if the information is not available. - */ - getExpectedTokens() { - if (this.recognizer!==null) { - return this.recognizer.atn.getExpectedTokens(this.offendingState, this.ctx); - } else { - return null; - } - } - - //

If the state number is not known, this method returns -1.

- toString() { - return this.message; - } -} - - - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/Interval.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/* stop is not included! */ -class Interval { - - constructor(start, stop) { - this.start = start; - this.stop = stop; - } - - clone() { - return new Interval(this.start, this.stop); - } - - contains(item) { - return item >= this.start && item < this.stop; - } - - toString() { - if(this.start===this.stop-1) { - return this.start.toString(); - } else { - return this.start.toString() + ".." + (this.stop-1).toString(); - } - } - - get length(){ - return this.stop - this.start; - } -} - -Interval.INVALID_INTERVAL = new Interval(-1, -2); - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/LexerNoViableAltException.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class LexerNoViableAltException extends RecognitionException { - constructor(lexer, input, startIndex, deadEndConfigs) { - super({message: "", recognizer: lexer, input: input, ctx: null}); - this.startIndex = startIndex; - this.deadEndConfigs = deadEndConfigs; - } - - toString() { - let symbol = ""; - if (this.startIndex >= 0 && this.startIndex < this.input.size) { - symbol = this.input.getText(new Interval(this.startIndex,this.startIndex)); - } - return "LexerNoViableAltException" + symbol; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Lexer.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - -/** - * A lexer is recognizer that draws input symbols from a character stream. - * lexer grammars result in a subclass of this object. A Lexer object - * uses simplified match() and error recovery mechanisms in the interest of speed. - */ -class Lexer extends Recognizer { - constructor(input) { - super(); - this._input = input; - this._factory = CommonTokenFactory.DEFAULT; - this._tokenFactorySourcePair = [ this, input ]; - - this._interp = null; // child classes must populate this - - /** - * The goal of all lexer rules/methods is to create a token object. - * this is an instance variable as multiple rules may collaborate to - * create a single token. nextToken will return this object after - * matching lexer rule(s). If you subclass to allow multiple token - * emissions, then set this to the last token to be matched or - * something nonnull so that the auto token emit mechanism will not - * emit another token. - */ - this._token = null; - - /** - * What character index in the stream did the current token start at? - * Needed, for example, to get the text for current token. Set at - * the start of nextToken. - */ - this._tokenStartCharIndex = -1; - - // The line on which the first character of the token resides/// - this._tokenStartLine = -1; - - // The character position of first character within the line/// - this._tokenStartColumn = -1; - - // Once we see EOF on char stream, next token will be EOF. - // If you have DONE : EOF ; then you see DONE EOF. - this._hitEOF = false; - - // The channel number for the current token/// - this._channel = Token.DEFAULT_CHANNEL; - - // The token type for the current token/// - this._type = Token.INVALID_TYPE; - - this._modeStack = []; - this._mode = Lexer.DEFAULT_MODE; - - /** - * You can set the text for the current token to override what is in - * the input char buffer. Use setText() or can set this instance var. - */ - this._text = null; - } - - reset() { - // wack Lexer state variables - if (this._input !== null) { - this._input.seek(0); // rewind the input - } - this._token = null; - this._type = Token.INVALID_TYPE; - this._channel = Token.DEFAULT_CHANNEL; - this._tokenStartCharIndex = -1; - this._tokenStartColumn = -1; - this._tokenStartLine = -1; - this._text = null; - - this._hitEOF = false; - this._mode = Lexer.DEFAULT_MODE; - this._modeStack = []; - - this._interp.reset(); - } - -// Return a token from this source; i.e., match a token on the char stream. - nextToken() { - if (this._input === null) { - throw "nextToken requires a non-null input stream."; - } - - /** - * Mark start location in char stream so unbuffered streams are - * guaranteed at least have text of current token - */ - const tokenStartMarker = this._input.mark(); - try { - for (;;) { - if (this._hitEOF) { - this.emitEOF(); - return this._token; - } - this._token = null; - this._channel = Token.DEFAULT_CHANNEL; - this._tokenStartCharIndex = this._input.index; - this._tokenStartColumn = this._interp.column; - this._tokenStartLine = this._interp.line; - this._text = null; - let continueOuter = false; - for (;;) { - this._type = Token.INVALID_TYPE; - let ttype = Lexer.SKIP; - try { - ttype = this._interp.match(this._input, this._mode); - } catch (e) { - if(e instanceof RecognitionException) { - this.notifyListeners(e); // report error - this.recover(e); - } else { - console.log(e.stack); - throw e; - } - } - if (this._input.LA(1) === Token.EOF) { - this._hitEOF = true; - } - if (this._type === Token.INVALID_TYPE) { - this._type = ttype; - } - if (this._type === Lexer.SKIP) { - continueOuter = true; - break; - } - if (this._type !== Lexer.MORE) { - break; - } - } - if (continueOuter) { - continue; - } - if (this._token === null) { - this.emit(); - } - return this._token; - } - } finally { - // make sure we release marker after match or - // unbuffered char stream will keep buffering - this._input.release(tokenStartMarker); - } - } - - /** - * Instruct the lexer to skip creating a token for current lexer rule - * and look for another token. nextToken() knows to keep looking when - * a lexer rule finishes with token set to SKIP_TOKEN. Recall that - * if token==null at end of any token rule, it creates one for you - * and emits it. - */ - skip() { - this._type = Lexer.SKIP; - } - - more() { - this._type = Lexer.MORE; - } - - mode(m) { - this._mode = m; - } - - pushMode(m) { - if (this._interp.debug) { - console.log("pushMode " + m); - } - this._modeStack.push(this._mode); - this.mode(m); - } - - popMode() { - if (this._modeStack.length === 0) { - throw "Empty Stack"; - } - if (this._interp.debug) { - console.log("popMode back to " + this._modeStack.slice(0, -1)); - } - this.mode(this._modeStack.pop()); - return this._mode; - } - - /** - * By default does not support multiple emits per nextToken invocation - * for efficiency reasons. Subclass and override this method, nextToken, - * and getToken (to push tokens into a list and pull from that list - * rather than a single variable as this implementation does). - */ - emitToken(token) { - this._token = token; - } - - /** - * The standard method called to automatically emit a token at the - * outermost lexical rule. The token object should point into the - * char buffer start..stop. If there is a text override in 'text', - * use that to set the token's text. Override this method to emit - * custom Token objects or provide a new factory. - */ - emit() { - const t = this._factory.create(this._tokenFactorySourcePair, this._type, - this._text, this._channel, this._tokenStartCharIndex, this - .getCharIndex() - 1, this._tokenStartLine, - this._tokenStartColumn); - this.emitToken(t); - return t; - } - - emitEOF() { - const cpos = this.column; - const lpos = this.line; - const eof = this._factory.create(this._tokenFactorySourcePair, Token.EOF, - null, Token.DEFAULT_CHANNEL, this._input.index, - this._input.index - 1, lpos, cpos); - this.emitToken(eof); - return eof; - } - -// What is the index of the current character of lookahead?/// - getCharIndex() { - return this._input.index; - } - - /** - * Return a list of all Token objects in input char stream. - * Forces load of all tokens. Does not include EOF token. - */ - getAllTokens() { - const tokens = []; - let t = this.nextToken(); - while (t.type !== Token.EOF) { - tokens.push(t); - t = this.nextToken(); - } - return tokens; - } - - notifyListeners(e) { - const start = this._tokenStartCharIndex; - const stop = this._input.index; - const text = this._input.getText(start, stop); - const msg = "token recognition error at: '" + this.getErrorDisplay(text) + "'"; - const listener = this.getErrorListenerDispatch(); - listener.syntaxError(this, null, this._tokenStartLine, - this._tokenStartColumn, msg, e); - } - - getErrorDisplay(s) { - const d = []; - for (let i = 0; i < s.length; i++) { - d.push(s[i]); - } - return d.join(''); - } - - getErrorDisplayForChar(c) { - if (c.charCodeAt(0) === Token.EOF) { - return ""; - } else if (c === '\n') { - return "\\n"; - } else if (c === '\t') { - return "\\t"; - } else if (c === '\r') { - return "\\r"; - } else { - return c; - } - } - - getCharErrorDisplay(c) { - return "'" + this.getErrorDisplayForChar(c) + "'"; - } - - /** - * Lexers can normally match any char in it's vocabulary after matching - * a token, so do the easy thing and just kill a character and hope - * it all works out. You can instead use the rule invocation stack - * to do sophisticated error recovery if you are in a fragment rule. - */ - recover(re) { - if (this._input.LA(1) !== Token.EOF) { - if (re instanceof LexerNoViableAltException) { - // skip a char and try again - this._interp.consume(this._input); - } else { - // TODO: Do we lose character or line position information? - this._input.consume(); - } - } - } - - get inputStream(){ - return this._input; - } - - set inputStream(input) { - this._input = null; - this._tokenFactorySourcePair = [ this, this._input ]; - this.reset(); - this._input = input; - this._tokenFactorySourcePair = [ this, this._input ]; - } - - get sourceName(){ - return this._input.sourceName; - } - - get type(){ - return this._type; - } - - set type(type) { - this._type = type; - } - - get line(){ - return this._interp.line; - } - - set line(line) { - this._interp.line = line; - } - - get column(){ - return this._interp.column; - } - - set column(column) { - this._interp.column = column; - } - - get text(){ - if (this._text !== null) { - return this._text; - } else { - return this._interp.getText(this._input); - } - } - - set text(text) { - this._text = text; - } -} - - - - -Lexer.DEFAULT_MODE = 0; -Lexer.MORE = -2; -Lexer.SKIP = -3; - -Lexer.DEFAULT_TOKEN_CHANNEL = Token.DEFAULT_CHANNEL; -Lexer.HIDDEN = Token.HIDDEN_CHANNEL; -Lexer.MIN_CHAR_VALUE = 0x0000; -Lexer.MAX_CHAR_VALUE = 0x10FFFF; - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/TokenStream.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// this is just to keep meaningful parameter types to Parser -class TokenStream {} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/BufferedTokenStream.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - -/** - * This implementation of {@link TokenStream} loads tokens from a - * {@link TokenSource} on-demand, and places the tokens in a buffer to provide - * access to any previous token by index. - * - *

- * This token stream ignores the value of {@link Token//getChannel}. If your - * parser requires the token stream filter tokens to only those on a particular - * channel, such as {@link Token//DEFAULT_CHANNEL} or - * {@link Token//HIDDEN_CHANNEL}, use a filtering token stream such a - * {@link CommonTokenStream}.

- */ -class BufferedTokenStream extends TokenStream { - constructor(tokenSource) { - - super(); - // The {@link TokenSource} from which tokens for this stream are fetched. - this.tokenSource = tokenSource; - /** - * A collection of all tokens fetched from the token source. The list is - * considered a complete view of the input once {@link //fetchedEOF} is set - * to {@code true}. - */ - this.tokens = []; - - /** - * The index into {@link //tokens} of the current token (next token to - * {@link //consume}). {@link //tokens}{@code [}{@link //p}{@code ]} should - * be - * {@link //LT LT(1)}. - * - *

This field is set to -1 when the stream is first constructed or when - * {@link //setTokenSource} is called, indicating that the first token has - * not yet been fetched from the token source. For additional information, - * see the documentation of {@link IntStream} for a description of - * Initializing Methods.

- */ - this.index = -1; - - /** - * Indicates whether the {@link Token//EOF} token has been fetched from - * {@link //tokenSource} and added to {@link //tokens}. This field improves - * performance for the following cases: - * - *
    - *
  • {@link //consume}: The lookahead check in {@link //consume} to - * prevent - * consuming the EOF symbol is optimized by checking the values of - * {@link //fetchedEOF} and {@link //p} instead of calling {@link - * //LA}.
  • - *
  • {@link //fetch}: The check to prevent adding multiple EOF symbols - * into - * {@link //tokens} is trivial with this field.
  • - *
      - */ - this.fetchedEOF = false; - } - - mark() { - return 0; - } - - release(marker) { - // no resources to release - } - - reset() { - this.seek(0); - } - - seek(index) { - this.lazyInit(); - this.index = this.adjustSeekIndex(index); - } - - get(index) { - this.lazyInit(); - return this.tokens[index]; - } - - consume() { - let skipEofCheck = false; - if (this.index >= 0) { - if (this.fetchedEOF) { - // the last token in tokens is EOF. skip check if p indexes any - // fetched token except the last. - skipEofCheck = this.index < this.tokens.length - 1; - } else { - // no EOF token in tokens. skip check if p indexes a fetched token. - skipEofCheck = this.index < this.tokens.length; - } - } else { - // not yet initialized - skipEofCheck = false; - } - if (!skipEofCheck && this.LA(1) === Token.EOF) { - throw "cannot consume EOF"; - } - if (this.sync(this.index + 1)) { - this.index = this.adjustSeekIndex(this.index + 1); - } - } - - /** - * Make sure index {@code i} in tokens has a token. - * - * @return {Boolean} {@code true} if a token is located at index {@code i}, otherwise - * {@code false}. - * @see //get(int i) - */ - sync(i) { - const n = i - this.tokens.length + 1; // how many more elements we need? - if (n > 0) { - const fetched = this.fetch(n); - return fetched >= n; - } - return true; - } - - /** - * Add {@code n} elements to buffer. - * - * @return {Number} The actual number of elements added to the buffer. - */ - fetch(n) { - if (this.fetchedEOF) { - return 0; - } - for (let i = 0; i < n; i++) { - const t = this.tokenSource.nextToken(); - t.tokenIndex = this.tokens.length; - this.tokens.push(t); - if (t.type === Token.EOF) { - this.fetchedEOF = true; - return i + 1; - } - } - return n; - } - -// Get all tokens from start..stop inclusively/// - getTokens(start, stop, types) { - if (types === undefined) { - types = null; - } - if (start < 0 || stop < 0) { - return null; - } - this.lazyInit(); - const subset = []; - if (stop >= this.tokens.length) { - stop = this.tokens.length - 1; - } - for (let i = start; i < stop; i++) { - const t = this.tokens[i]; - if (t.type === Token.EOF) { - break; - } - if (types === null || types.contains(t.type)) { - subset.push(t); - } - } - return subset; - } - - LA(i) { - return this.LT(i).type; - } - - LB(k) { - if (this.index - k < 0) { - return null; - } - return this.tokens[this.index - k]; - } - - LT(k) { - this.lazyInit(); - if (k === 0) { - return null; - } - if (k < 0) { - return this.LB(-k); - } - const i = this.index + k - 1; - this.sync(i); - if (i >= this.tokens.length) { // return EOF token - // EOF must be last token - return this.tokens[this.tokens.length - 1]; - } - return this.tokens[i]; - } - - /** - * Allowed derived classes to modify the behavior of operations which change - * the current stream position by adjusting the target token index of a seek - * operation. The default implementation simply returns {@code i}. If an - * exception is thrown in this method, the current stream index should not be - * changed. - * - *

      For example, {@link CommonTokenStream} overrides this method to ensure - * that - * the seek target is always an on-channel token.

      - * - * @param {Number} i The target token index. - * @return {Number} The adjusted target token index. - */ - adjustSeekIndex(i) { - return i; - } - - lazyInit() { - if (this.index === -1) { - this.setup(); - } - } - - setup() { - this.sync(0); - this.index = this.adjustSeekIndex(0); - } - -// Reset this token stream by setting its token source./// - setTokenSource(tokenSource) { - this.tokenSource = tokenSource; - this.tokens = []; - this.index = -1; - this.fetchedEOF = false; - } - - /** - * Given a starting index, return the index of the next token on channel. - * Return i if tokens[i] is on channel. Return -1 if there are no tokens - * on channel between i and EOF. - */ - nextTokenOnChannel(i, channel) { - this.sync(i); - if (i >= this.tokens.length) { - return -1; - } - let token = this.tokens[i]; - while (token.channel !== this.channel) { - if (token.type === Token.EOF) { - return -1; - } - i += 1; - this.sync(i); - token = this.tokens[i]; - } - return i; - } - - /** - * Given a starting index, return the index of the previous token on channel. - * Return i if tokens[i] is on channel. Return -1 if there are no tokens - * on channel between i and 0. - */ - previousTokenOnChannel(i, channel) { - while (i >= 0 && this.tokens[i].channel !== channel) { - i -= 1; - } - return i; - } - - /** - * Collect all tokens on specified channel to the right of - * the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or - * EOF. If channel is -1, find any non default channel token. - */ - getHiddenTokensToRight(tokenIndex, - channel) { - if (channel === undefined) { - channel = -1; - } - this.lazyInit(); - if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { - throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; - } - const nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL); - const from_ = tokenIndex + 1; - // if none onchannel to right, nextOnChannel=-1 so set to = last token - const to = nextOnChannel === -1 ? this.tokens.length - 1 : nextOnChannel; - return this.filterForChannel(from_, to, channel); - } - - /** - * Collect all tokens on specified channel to the left of - * the current token up until we see a token on DEFAULT_TOKEN_CHANNEL. - * If channel is -1, find any non default channel token. - */ - getHiddenTokensToLeft(tokenIndex, - channel) { - if (channel === undefined) { - channel = -1; - } - this.lazyInit(); - if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { - throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; - } - const prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL); - if (prevOnChannel === tokenIndex - 1) { - return null; - } - // if none on channel to left, prevOnChannel=-1 then from=0 - const from_ = prevOnChannel + 1; - const to = tokenIndex - 1; - return this.filterForChannel(from_, to, channel); - } - - filterForChannel(left, right, channel) { - const hidden = []; - for (let i = left; i < right + 1; i++) { - const t = this.tokens[i]; - if (channel === -1) { - if (t.channel !== Lexer.DEFAULT_TOKEN_CHANNEL) { - hidden.push(t); - } - } else if (t.channel === channel) { - hidden.push(t); - } - } - if (hidden.length === 0) { - return null; - } - return hidden; - } - - getSourceName() { - return this.tokenSource.getSourceName(); - } - -// Get the text of all tokens in this buffer./// - getText(interval) { - this.lazyInit(); - this.fill(); - if (interval === undefined || interval === null) { - interval = new Interval(0, this.tokens.length - 1); - } - let start = interval.start; - if (start instanceof Token) { - start = start.tokenIndex; - } - let stop = interval.stop; - if (stop instanceof Token) { - stop = stop.tokenIndex; - } - if (start === null || stop === null || start < 0 || stop < 0) { - return ""; - } - if (stop >= this.tokens.length) { - stop = this.tokens.length - 1; - } - let s = ""; - for (let i = start; i < stop + 1; i++) { - const t = this.tokens[i]; - if (t.type === Token.EOF) { - break; - } - s = s + t.text; - } - return s; - } - -// Get all tokens from lexer until EOF/// - fill() { - this.lazyInit(); - while (this.fetch(1000) === 1000) { - continue; - } - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CommonTokenStream.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - -/** - * This class extends {@link BufferedTokenStream} with functionality to filter - * token streams to tokens on a particular channel (tokens where - * {@link Token//getChannel} returns a particular value). - * - *

      - * This token stream provides access to all tokens by index or when calling - * methods like {@link //getText}. The channel filtering is only used for code - * accessing tokens via the lookahead methods {@link //LA}, {@link //LT}, and - * {@link //LB}.

      - * - *

      - * By default, tokens are placed on the default channel - * ({@link Token//DEFAULT_CHANNEL}), but may be reassigned by using the - * {@code ->channel(HIDDEN)} lexer command, or by using an embedded action to - * call {@link Lexer//setChannel}. - *

      - * - *

      - * Note: lexer rules which use the {@code ->skip} lexer command or call - * {@link Lexer//skip} do not produce tokens at all, so input text matched by - * such a rule will not be available as part of the token stream, regardless of - * channel.

      - */ -class CommonTokenStream extends BufferedTokenStream { - constructor(lexer, channel) { - super(lexer); - this.channel = channel===undefined ? Token.DEFAULT_CHANNEL : channel; - } - - adjustSeekIndex(i) { - return this.nextTokenOnChannel(i, this.channel); - } - - LB(k) { - if (k===0 || this.index-k<0) { - return null; - } - let i = this.index; - let n = 1; - // find k good tokens looking backwards - while (n <= k) { - // skip off-channel tokens - i = this.previousTokenOnChannel(i - 1, this.channel); - n += 1; - } - if (i < 0) { - return null; - } - return this.tokens[i]; - } - - LT(k) { - this.lazyInit(); - if (k === 0) { - return null; - } - if (k < 0) { - return this.LB(-k); - } - let i = this.index; - let n = 1; // we know tokens[pos] is a good one - // find k good tokens - while (n < k) { - // skip off-channel tokens, but make sure to not look past EOF - if (this.sync(i + 1)) { - i = this.nextTokenOnChannel(i + 1, this.channel); - } - n += 1; - } - return this.tokens[i]; - } - - // Count EOF just once. - getNumberOfOnChannelTokens() { - let n = 0; - this.fill(); - for (let i =0; i< this.tokens.length;i++) { - const t = this.tokens[i]; - if( t.channel===this.channel) { - n += 1; - } - if( t.type===Token.EOF) { - break; - } - } - return n; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/stringHashCode.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -String.prototype.seed = String.prototype.seed || Math.round(Math.random() * Math.pow(2, 32)); - -String.prototype.hashCode = function () { - const key = this.toString(); - let h1b, k1; - - const remainder = key.length & 3; // key.length % 4 - const bytes = key.length - remainder; - let h1 = String.prototype.seed; - const c1 = 0xcc9e2d51; - const c2 = 0x1b873593; - let i = 0; - - while (i < bytes) { - k1 = - ((key.charCodeAt(i) & 0xff)) | - ((key.charCodeAt(++i) & 0xff) << 8) | - ((key.charCodeAt(++i) & 0xff) << 16) | - ((key.charCodeAt(++i) & 0xff) << 24); - ++i; - - k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; - k1 = (k1 << 15) | (k1 >>> 17); - k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; - - h1 ^= k1; - h1 = (h1 << 13) | (h1 >>> 19); - h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; - h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); - } - - k1 = 0; - - switch (remainder) { - case 3: - k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; - // no-break - case 2: - k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; - // no-break - case 1: - k1 ^= (key.charCodeAt(i) & 0xff); - k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; - k1 = (k1 << 15) | (k1 >>> 17); - k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; - h1 ^= k1; - } - - h1 ^= key.length; - - h1 ^= h1 >>> 16; - h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; - h1 ^= h1 >>> 13; - h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; - h1 ^= h1 >>> 16; - - return h1 >>> 0; -}; - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/equalArrays.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -function equalArrays(a, b) { - if (!Array.isArray(a) || !Array.isArray(b)) - return false; - if (a === b) - return true; - if (a.length !== b.length) - return false; - for (let i = 0; i < a.length; i++) { - if (a[i] === b[i]) - continue; - if (!a[i].equals || !a[i].equals(b[i])) - return false; - } - return true; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/HashCode.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -class HashCode { - - constructor() { - this.count = 0; - this.hash = 0; - } - - update() { - for(let i=0;i>> (32 - 15)); - k = k * 0x1B873593; - this.count = this.count + 1; - let hash = this.hash ^ k; - hash = (hash << 13) | (hash >>> (32 - 13)); - hash = hash * 5 + 0xE6546B64; - this.hash = hash; - } - } - } - - finish() { - let hash = this.hash ^ (this.count * 4); - hash = hash ^ (hash >>> 16); - hash = hash * 0x85EBCA6B; - hash = hash ^ (hash >>> 13); - hash = hash * 0xC2B2AE35; - hash = hash ^ (hash >>> 16); - return hash; - } - - static hashStuff() { - const hash = new HashCode(); - hash.update.apply(hash, arguments); - return hash.finish(); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/standardHashCodeFunction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -function standardHashCodeFunction(a) { - return a ? a.hashCode() : -1; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/standardEqualsFunction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -function standardEqualsFunction(a, b) { - return a ? a.equals(b) : a===b; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/valueToString.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -function valueToString(v) { - return v === null ? "null" : v; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/arrayToString.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -function arrayToString(a) { - return Array.isArray(a) ? ("[" + a.map(valueToString).join(", ") + "]") : "null"; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/HashSet.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -const HASH_KEY_PREFIX = "h-"; - -class HashSet { - - constructor(hashFunction, equalsFunction) { - this.data = {}; - this.hashFunction = hashFunction || standardHashCodeFunction; - this.equalsFunction = equalsFunction || standardEqualsFunction; - } - - add(value) { - const key = HASH_KEY_PREFIX + this.hashFunction(value); - if (key in this.data) { - const values = this.data[key]; - for (let i = 0; i < values.length; i++) { - if (this.equalsFunction(value, values[i])) { - return values[i]; - } - } - values.push(value); - return value; - } else { - this.data[key] = [value]; - return value; - } - } - - has(value) { - return this.get(value) != null; - } - - get(value) { - const key = HASH_KEY_PREFIX + this.hashFunction(value); - if (key in this.data) { - const values = this.data[key]; - for (let i = 0; i < values.length; i++) { - if (this.equalsFunction(value, values[i])) { - return values[i]; - } - } - } - return null; - } - - values() { - return Object.keys(this.data).filter(key => key.startsWith(HASH_KEY_PREFIX)).flatMap(key => this.data[key], this); - } - - toString() { - return arrayToString(this.values()); - } - - get length() { - return Object.keys(this.data).filter(key => key.startsWith(HASH_KEY_PREFIX)).map(key => this.data[key].length, this).reduce((accum, item) => accum + item, 0); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/SemanticContext.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - -/** - * A tree structure used to record the semantic context in which - * an ATN configuration is valid. It's either a single predicate, - * a conjunction {@code p1&&p2}, or a sum of products {@code p1||p2}. - * - *

      I have scoped the {@link AND}, {@link OR}, and {@link Predicate} subclasses of - * {@link SemanticContext} within the scope of this outer class.

      - */ -class SemanticContext { - - hashCode() { - const hash = new HashCode(); - this.updateHashCode(hash); - return hash.finish(); - } - - /** - * For context independent predicates, we evaluate them without a local - * context (i.e., null context). That way, we can evaluate them without - * having to create proper rule-specific context during prediction (as - * opposed to the parser, which creates them naturally). In a practical - * sense, this avoids a cast exception from RuleContext to myruleContext. - * - *

      For context dependent predicates, we must pass in a local context so that - * references such as $arg evaluate properly as _localctx.arg. We only - * capture context dependent predicates in the context in which we begin - * prediction, so we passed in the outer context here in case of context - * dependent predicate evaluation.

      - */ - evaluate(parser, outerContext) {} - - /** - * Evaluate the precedence predicates for the context and reduce the result. - * - * @param parser The parser instance. - * @param outerContext The current parser context object. - * @return The simplified semantic context after precedence predicates are - * evaluated, which will be one of the following values. - *
        - *
      • {@link //NONE}: if the predicate simplifies to {@code true} after - * precedence predicates are evaluated.
      • - *
      • {@code null}: if the predicate simplifies to {@code false} after - * precedence predicates are evaluated.
      • - *
      • {@code this}: if the semantic context is not changed as a result of - * precedence predicate evaluation.
      • - *
      • A non-{@code null} {@link SemanticContext}: the new simplified - * semantic context after precedence predicates are evaluated.
      • - *
      - */ - evalPrecedence(parser, outerContext) { - return this; - } - - static andContext(a, b) { - if (a === null || a === SemanticContext.NONE) { - return b; - } - if (b === null || b === SemanticContext.NONE) { - return a; - } - const result = new AND(a, b); - if (result.opnds.length === 1) { - return result.opnds[0]; - } else { - return result; - } - } - - static orContext(a, b) { - if (a === null) { - return b; - } - if (b === null) { - return a; - } - if (a === SemanticContext.NONE || b === SemanticContext.NONE) { - return SemanticContext.NONE; - } - const result = new OR(a, b); - if (result.opnds.length === 1) { - return result.opnds[0]; - } else { - return result; - } - } -} - - - -class AND extends SemanticContext { - /** - * A semantic context which is true whenever none of the contained contexts - * is false - */ - constructor(a, b) { - super(); - const operands = new HashSet(); - if (a instanceof AND) { - a.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(a); - } - if (b instanceof AND) { - b.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(b); - } - const precedencePredicates = filterPrecedencePredicates(operands); - if (precedencePredicates.length > 0) { - // interested in the transition with the lowest precedence - let reduced = null; - precedencePredicates.map( function(p) { - if(reduced===null || p.precedence - * The evaluation of predicates by this context is short-circuiting, but - * unordered.

      - */ - evaluate(parser, outerContext) { - for (let i = 0; i < this.opnds.length; i++) { - if (!this.opnds[i].evaluate(parser, outerContext)) { - return false; - } - } - return true; - } - - evalPrecedence(parser, outerContext) { - let differs = false; - const operands = []; - for (let i = 0; i < this.opnds.length; i++) { - const context = this.opnds[i]; - const evaluated = context.evalPrecedence(parser, outerContext); - differs |= (evaluated !== context); - if (evaluated === null) { - // The AND context is false if any element is false - return null; - } else if (evaluated !== SemanticContext.NONE) { - // Reduce the result by skipping true elements - operands.push(evaluated); - } - } - if (!differs) { - return this; - } - if (operands.length === 0) { - // all elements were true, so the AND context is true - return SemanticContext.NONE; - } - let result = null; - operands.map(function(o) { - result = result === null ? o : SemanticContext.andContext(result, o); - }); - return result; - } - - toString() { - const s = this.opnds.map(o => o.toString()); - return (s.length > 3 ? s.slice(3) : s).join("&&"); - } -} - - -class OR extends SemanticContext { - /** - * A semantic context which is true whenever at least one of the contained - * contexts is true - */ - constructor(a, b) { - super(); - const operands = new HashSet(); - if (a instanceof OR) { - a.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(a); - } - if (b instanceof OR) { - b.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(b); - } - - const precedencePredicates = filterPrecedencePredicates(operands); - if (precedencePredicates.length > 0) { - // interested in the transition with the highest precedence - const s = precedencePredicates.sort(function(a, b) { - return a.compareTo(b); - }); - const reduced = s[s.length-1]; - operands.add(reduced); - } - this.opnds = Array.from(operands.values()); - } - - equals(other) { - if (this === other) { - return true; - } else if (!(other instanceof OR)) { - return false; - } else { - return equalArrays(this.opnds, other.opnds); - } - } - - updateHashCode(hash) { - hash.update(this.opnds, "OR"); - } - - /** - *

      - * The evaluation of predicates by this context is short-circuiting, but - * unordered.

      - */ - evaluate(parser, outerContext) { - for (let i = 0; i < this.opnds.length; i++) { - if (this.opnds[i].evaluate(parser, outerContext)) { - return true; - } - } - return false; - } - - evalPrecedence(parser, outerContext) { - let differs = false; - const operands = []; - for (let i = 0; i < this.opnds.length; i++) { - const context = this.opnds[i]; - const evaluated = context.evalPrecedence(parser, outerContext); - differs |= (evaluated !== context); - if (evaluated === SemanticContext.NONE) { - // The OR context is true if any element is true - return SemanticContext.NONE; - } else if (evaluated !== null) { - // Reduce the result by skipping false elements - operands.push(evaluated); - } - } - if (!differs) { - return this; - } - if (operands.length === 0) { - // all elements were false, so the OR context is false - return null; - } - const result = null; - operands.map(function(o) { - return result === null ? o : SemanticContext.orContext(result, o); - }); - return result; - } - - toString() { - const s = this.opnds.map(o => o.toString()); - return (s.length > 3 ? s.slice(3) : s).join("||"); - } -} - -function filterPrecedencePredicates(set) { - const result = []; - set.values().map( function(context) { - if (context instanceof SemanticContext.PrecedencePredicate) { - result.push(context); - } - }); - return result; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNConfig.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -function checkParams(params, isCfg) { - if(params===null) { - const result = { state:null, alt:null, context:null, semanticContext:null }; - if(isCfg) { - result.reachesIntoOuterContext = 0; - } - return result; - } else { - const props = {}; - props.state = params.state || null; - props.alt = (params.alt === undefined) ? null : params.alt; - props.context = params.context || null; - props.semanticContext = params.semanticContext || null; - if(isCfg) { - props.reachesIntoOuterContext = params.reachesIntoOuterContext || 0; - props.precedenceFilterSuppressed = params.precedenceFilterSuppressed || false; - } - return props; - } -} - -class ATNConfig { - /** - * @param {Object} params A tuple: (ATN state, predicted alt, syntactic, semantic context). - * The syntactic context is a graph-structured stack node whose - * path(s) to the root is the rule invocation(s) - * chain used to arrive at the state. The semantic context is - * the tree of semantic predicates encountered before reaching - * an ATN state - */ - constructor(params, config) { - this.checkContext(params, config); - params = checkParams(params); - config = checkParams(config, true); - // The ATN state associated with this configuration/// - this.state = params.state!==null ? params.state : config.state; - // What alt (or lexer rule) is predicted by this configuration/// - this.alt = params.alt!==null ? params.alt : config.alt; - /** - * The stack of invoking states leading to the rule/states associated - * with this config. We track only those contexts pushed during - * execution of the ATN simulator - */ - this.context = params.context!==null ? params.context : config.context; - this.semanticContext = params.semanticContext!==null ? params.semanticContext : - (config.semanticContext!==null ? config.semanticContext : SemanticContext.NONE); - // TODO: make it a boolean then - /** - * We cannot execute predicates dependent upon local context unless - * we know for sure we are in the correct context. Because there is - * no way to do this efficiently, we simply cannot evaluate - * dependent predicates unless we are in the rule that initially - * invokes the ATN simulator. - * closure() tracks the depth of how far we dip into the - * outer context: depth > 0. Note that it may not be totally - * accurate depth since I don't ever decrement - */ - this.reachesIntoOuterContext = config.reachesIntoOuterContext; - this.precedenceFilterSuppressed = config.precedenceFilterSuppressed; - } - - checkContext(params, config) { - if((params.context===null || params.context===undefined) && - (config===null || config.context===null || config.context===undefined)) { - this.context = null; - } - } - - hashCode() { - const hash = new HashCode(); - this.updateHashCode(hash); - return hash.finish(); - } - - updateHashCode(hash) { - hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext); - } - - /** - * An ATN configuration is equal to another if both have - * the same state, they predict the same alternative, and - * syntactic/semantic contexts are the same - */ - equals(other) { - if (this === other) { - return true; - } else if (! (other instanceof ATNConfig)) { - return false; - } else { - return this.state.stateNumber===other.state.stateNumber && - this.alt===other.alt && - (this.context===null ? other.context===null : this.context.equals(other.context)) && - this.semanticContext.equals(other.semanticContext) && - this.precedenceFilterSuppressed===other.precedenceFilterSuppressed; - } - } - - hashCodeForConfigSet() { - const hash = new HashCode(); - hash.update(this.state.stateNumber, this.alt, this.semanticContext); - return hash.finish(); - } - - equalsForConfigSet(other) { - if (this === other) { - return true; - } else if (! (other instanceof ATNConfig)) { - return false; - } else { - return this.state.stateNumber===other.state.stateNumber && - this.alt===other.alt && - this.semanticContext.equals(other.semanticContext); - } - } - - toString() { - return "(" + this.state + "," + this.alt + - (this.context!==null ? ",[" + this.context.toString() + "]" : "") + - (this.semanticContext !== SemanticContext.NONE ? - ("," + this.semanticContext.toString()) - : "") + - (this.reachesIntoOuterContext>0 ? - (",up=" + this.reachesIntoOuterContext) - : "") + ")"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/IntervalSet.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -class IntervalSet { - constructor() { - this.intervals = null; - this.readOnly = false; - } - - first(v) { - if (this.intervals === null || this.intervals.length===0) { - return Token.INVALID_TYPE; - } else { - return this.intervals[0].start; - } - } - - addOne(v) { - this.addInterval(new Interval(v, v + 1)); - } - - addRange(l, h) { - this.addInterval(new Interval(l, h + 1)); - } - - addInterval(toAdd) { - if (this.intervals === null) { - this.intervals = []; - this.intervals.push(toAdd.clone()); - } else { - // find insert pos - for (let pos = 0; pos < this.intervals.length; pos++) { - const existing = this.intervals[pos]; - // distinct range -> insert - if (toAdd.stop < existing.start) { - this.intervals.splice(pos, 0, toAdd); - return; - } - // contiguous range -> adjust - else if (toAdd.stop === existing.start) { - this.intervals[pos] = new Interval(toAdd.start, existing.stop) - return; - } - // overlapping range -> adjust and reduce - else if (toAdd.start <= existing.stop) { - this.intervals[pos] = new Interval(Math.min(existing.start, toAdd.start), Math.max(existing.stop, toAdd.stop)); - this.reduce(pos); - return; - } - } - // greater than any existing - this.intervals.push(toAdd.clone()); - } - } - - addSet(other) { - if (other.intervals !== null) { - other.intervals.forEach( toAdd => this.addInterval(toAdd), this); - } - return this; - } - - reduce(pos) { - // only need to reduce if pos is not the last - if (pos < this.intervals.length - 1) { - const current = this.intervals[pos]; - const next = this.intervals[pos + 1]; - // if next contained in current - if (current.stop >= next.stop) { - this.intervals.splice(pos + 1, 1); - this.reduce(pos); - } else if (current.stop >= next.start) { - this.intervals[pos] = new Interval(current.start, next.stop); - this.intervals.splice(pos + 1, 1); - } - } - } - - complement(start, stop) { - const result = new IntervalSet(); - result.addInterval(new Interval(start, stop + 1)); - if(this.intervals !== null) - this.intervals.forEach(toRemove => result.removeRange(toRemove)); - return result; - } - - contains(item) { - if (this.intervals === null) { - return false; - } else { - for (let k = 0; k < this.intervals.length; k++) { - if(this.intervals[k].contains(item)) { - return true; - } - } - return false; - } - } - - removeRange(toRemove) { - if(toRemove.start===toRemove.stop-1) { - this.removeOne(toRemove.start); - } else if (this.intervals !== null) { - let pos = 0; - for(let n=0; nexisting.start && toRemove.stop=existing.stop) { - this.intervals.splice(pos, 1); - pos = pos - 1; // need another pass - } - // check for lower boundary - else if(toRemove.start"); - } else { - names.push("'" + String.fromCharCode(existing.start) + "'"); - } - } else { - names.push("'" + String.fromCharCode(existing.start) + "'..'" + String.fromCharCode(existing.stop-1) + "'"); - } - } - if (names.length > 1) { - return "{" + names.join(", ") + "}"; - } else { - return names[0]; - } - } - - toIndexString() { - const names = []; - for (let i = 0; i < this.intervals.length; i++) { - const existing = this.intervals[i]; - if(existing.stop===existing.start+1) { - if ( existing.start===Token.EOF ) { - names.push(""); - } else { - names.push(existing.start.toString()); - } - } else { - names.push(existing.start.toString() + ".." + (existing.stop-1).toString()); - } - } - if (names.length > 1) { - return "{" + names.join(", ") + "}"; - } else { - return names[0]; - } - } - - toTokenString(literalNames, symbolicNames) { - const names = []; - for (let i = 0; i < this.intervals.length; i++) { - const existing = this.intervals[i]; - for (let j = existing.start; j < existing.stop; j++) { - names.push(this.elementName(literalNames, symbolicNames, j)); - } - } - if (names.length > 1) { - return "{" + names.join(", ") + "}"; - } else { - return names[0]; - } - } - - elementName(literalNames, symbolicNames, token) { - if (token === Token.EOF) { - return ""; - } else if (token === Token.EPSILON) { - return ""; - } else { - return literalNames[token] || symbolicNames[token]; - } - } - - get length(){ - return this.intervals.map( interval => interval.length ).reduce((acc, val) => acc + val); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/ATNState.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * The following images show the relation of states and - * {@link ATNState//transitions} for various grammar constructs. - * - *
        - * - *
      • Solid edges marked with an &//0949; indicate a required - * {@link EpsilonTransition}.
      • - * - *
      • Dashed edges indicate locations where any transition derived from - * {@link Transition} might appear.
      • - * - *
      • Dashed nodes are place holders for either a sequence of linked - * {@link BasicState} states or the inclusion of a block representing a nested - * construct in one of the forms below.
      • - * - *
      • Nodes showing multiple outgoing alternatives with a {@code ...} support - * any number of alternatives (one or more). Nodes without the {@code ...} only - * support the exact number of alternatives shown in the diagram.
      • - * - *
      - * - *

      Basic Blocks

      - * - *

      Rule

      - * - * - * - *

      Block of 1 or more alternatives

      - * - * - * - *

      Greedy Loops

      - * - *

      Greedy Closure: {@code (...)*}

      - * - * - * - *

      Greedy Positive Closure: {@code (...)+}

      - * - * - * - *

      Greedy Optional: {@code (...)?}

      - * - * - * - *

      Non-Greedy Loops

      - * - *

      Non-Greedy Closure: {@code (...)*?}

      - * - * - * - *

      Non-Greedy Positive Closure: {@code (...)+?}

      - * - * - * - *

      Non-Greedy Optional: {@code (...)??}

      - * - * - */ -class ATNState { - constructor() { - // Which ATN are we in? - this.atn = null; - this.stateNumber = ATNState.INVALID_STATE_NUMBER; - this.stateType = null; - this.ruleIndex = 0; // at runtime, we don't have Rule objects - this.epsilonOnlyTransitions = false; - // Track the transitions emanating from this ATN state. - this.transitions = []; - // Used to cache lookahead during parsing, not used during construction - this.nextTokenWithinRule = null; - } - - toString() { - return this.stateNumber; - } - - equals(other) { - if (other instanceof ATNState) { - return this.stateNumber===other.stateNumber; - } else { - return false; - } - } - - isNonGreedyExitState() { - return false; - } - - addTransition(trans, index) { - if(index===undefined) { - index = -1; - } - if (this.transitions.length===0) { - this.epsilonOnlyTransitions = trans.isEpsilon; - } else if(this.epsilonOnlyTransitions !== trans.isEpsilon) { - this.epsilonOnlyTransitions = false; - } - if (index===-1) { - this.transitions.push(trans); - } else { - this.transitions.splice(index, 1, trans); - } - } -} - -// constants for serialization -ATNState.INVALID_TYPE = 0; -ATNState.BASIC = 1; -ATNState.RULE_START = 2; -ATNState.BLOCK_START = 3; -ATNState.PLUS_BLOCK_START = 4; -ATNState.STAR_BLOCK_START = 5; -ATNState.TOKEN_START = 6; -ATNState.RULE_STOP = 7; -ATNState.BLOCK_END = 8; -ATNState.STAR_LOOP_BACK = 9; -ATNState.STAR_LOOP_ENTRY = 10; -ATNState.PLUS_LOOP_BACK = 11; -ATNState.LOOP_END = 12; - -ATNState.serializationNames = [ - "INVALID", - "BASIC", - "RULE_START", - "BLOCK_START", - "PLUS_BLOCK_START", - "STAR_BLOCK_START", - "TOKEN_START", - "RULE_STOP", - "BLOCK_END", - "STAR_LOOP_BACK", - "STAR_LOOP_ENTRY", - "PLUS_LOOP_BACK", - "LOOP_END" ]; - -ATNState.INVALID_STATE_NUMBER = -1; - - - - - - - - - - - - - - - - - - - - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/RuleStopState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/** - * The last node in the ATN for a rule, unless that rule is the start symbol. - * In that case, there is one transition to EOF. Later, we might encode - * references to all calls to this rule to compute FOLLOW sets for - * error handling - */ -class RuleStopState extends ATNState { - constructor() { - super(); - this.stateType = ATNState.RULE_STOP; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/Transition.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * An ATN transition between any two ATN states. Subclasses define - * atom, set, epsilon, action, predicate, rule transitions. - * - *

      This is a one way link. It emanates from a state (usually via a list of - * transitions) and has a target state.

      - * - *

      Since we never have to change the ATN transitions once we construct it, - * we can fix these transitions as specific classes. The DFA transitions - * on the other hand need to update the labels as it adds transitions to - * the states. We'll use the term Edge for the DFA to distinguish them from - * ATN transitions.

      - */ -class Transition { - constructor(target) { - // The target of this transition. - if (target===undefined || target===null) { - throw "target cannot be null."; - } - this.target = target; - // Are we epsilon, action, sempred? - this.isEpsilon = false; - this.label = null; - } -} - -// constants for serialization - -Transition.EPSILON = 1; -Transition.RANGE = 2; -Transition.RULE = 3; -// e.g., {isType(input.LT(1))}? -Transition.PREDICATE = 4; -Transition.ATOM = 5; -Transition.ACTION = 6; -// ~(A|B) or ~atom, wildcard, which convert to next 2 -Transition.SET = 7; -Transition.NOT_SET = 8; -Transition.WILDCARD = 9; -Transition.PRECEDENCE = 10; - -Transition.serializationNames = [ - "INVALID", - "EPSILON", - "RANGE", - "RULE", - "PREDICATE", - "ATOM", - "ACTION", - "SET", - "NOT_SET", - "WILDCARD", - "PRECEDENCE" - ]; - -Transition.serializationTypes = { - EpsilonTransition: Transition.EPSILON, - RangeTransition: Transition.RANGE, - RuleTransition: Transition.RULE, - PredicateTransition: Transition.PREDICATE, - AtomTransition: Transition.ATOM, - ActionTransition: Transition.ACTION, - SetTransition: Transition.SET, - NotSetTransition: Transition.NOT_SET, - WildcardTransition: Transition.WILDCARD, - PrecedencePredicateTransition: Transition.PRECEDENCE - }; - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/RuleTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class RuleTransition extends Transition { - constructor(ruleStart, ruleIndex, precedence, followState) { - super(ruleStart); - // ptr to the rule definition object for this rule ref - this.ruleIndex = ruleIndex; - this.precedence = precedence; - // what node to begin computations following ref to rule - this.followState = followState; - this.serializationType = Transition.RULE; - this.isEpsilon = true; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return false; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/SetTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// A transition containing a set of values. - - - - -class SetTransition extends Transition { - constructor(target, set) { - super(target); - this.serializationType = Transition.SET; - if (set !==undefined && set !==null) { - this.label = set; - } else { - this.label = new IntervalSet(); - this.label.addOne(Token.INVALID_TYPE); - } - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return this.label.contains(symbol); - } - - toString() { - return this.label.toString(); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/NotSetTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class NotSetTransition extends SetTransition { - constructor(target, set) { - super(target, set); - this.serializationType = Transition.NOT_SET; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && - !super.matches(symbol, minVocabSymbol, maxVocabSymbol); - } - - toString() { - return '~' + super.toString(); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/WildcardTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class WildcardTransition extends Transition { - constructor(target) { - super(target); - this.serializationType = Transition.WILDCARD; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; - } - - toString() { - return "."; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/AbstractPredicateTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class AbstractPredicateTransition extends Transition { - constructor(target) { - super(target); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/Tree.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * The basic notion of a tree has a parent, a payload, and a list of children. - * It is the most abstract interface for all the trees used by ANTLR. - */ -class Tree {} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/SyntaxTree.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class SyntaxTree extends Tree { -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTree.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class ParseTree extends SyntaxTree { -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/RuleNode.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class RuleNode extends ParseTree { - - getRuleContext(){ - throw new Error("missing interface implementation") - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/TerminalNode.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class TerminalNode extends ParseTree { -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ErrorNode.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class ErrorNode extends TerminalNode { -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/escapeWhitespace.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -function escapeWhitespace(s, escapeSpaces) { - s = s.replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r"); - if (escapeSpaces) { - s = s.replace(/ /g, "\u00B7"); - } - return s; -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/Trees.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - -/** A set of utility routines useful for all kinds of ANTLR trees. */ -const Trees = { - /** - * Print out a whole tree in LISP form. {@link //getNodeText} is used on the - * node payloads to get the text for the nodes. Detect - * parse trees and extract data appropriately. - */ - toStringTree: function(tree, ruleNames, recog) { - ruleNames = ruleNames || null; - recog = recog || null; - if(recog!==null) { - ruleNames = recog.ruleNames; - } - let s = Trees.getNodeText(tree, ruleNames); - s = escapeWhitespace(s, false); - const c = tree.getChildCount(); - if(c===0) { - return s; - } - let res = "(" + s + ' '; - if(c>0) { - s = Trees.toStringTree(tree.getChild(0), ruleNames); - res = res.concat(s); - } - for(let i=1;i - * Since tokens on hidden channels (e.g. whitespace or comments) are not - * added to the parse trees, they will not appear in the output of this - * method. - */ - getText() { - if (this.getChildCount() === 0) { - return ""; - } else { - return this.children.map(function (child) { - return child.getText(); - }).join(""); - } - } - - /** - * For rule associated with this parse tree internal node, return - * the outer alternative number used to match the input. Default - * implementation does not compute nor store this alt num. Create - * a subclass of ParserRuleContext with backing field and set - * option contextSuperClass. - * to set it. - */ - getAltNumber() { - // use constant value of ATN.INVALID_ALT_NUMBER to avoid circular dependency - return 0; - } - - /** - * Set the outer alternative number for this context node. Default - * implementation does nothing to avoid backing field overhead for - * trees that don't need it. Create - * a subclass of ParserRuleContext with backing field and set - * option contextSuperClass. - */ - setAltNumber(altNumber) { - } - - getChild(i) { - return null; - } - - getChildCount() { - return 0; - } - - accept(visitor) { - return visitor.visitChildren(this); - } - - /** - * Print out a whole tree, not just a node, in LISP format - * (root child1 .. childN). Print just a node if this is a leaf. - */ - toStringTree(ruleNames, recog) { - return tree_Trees.toStringTree(this, ruleNames, recog); - } - - toString(ruleNames, stop) { - ruleNames = ruleNames || null; - stop = stop || null; - let p = this; - let s = "["; - while (p !== null && p !== stop) { - if (ruleNames === null) { - if (!p.isEmpty()) { - s += p.invokingState; - } - } else { - const ri = p.ruleIndex; - const ruleName = (ri >= 0 && ri < ruleNames.length) ? ruleNames[ri] - : "" + ri; - s += ruleName; - } - if (p.parentCtx !== null && (ruleNames !== null || !p.parentCtx.isEmpty())) { - s += " "; - } - p = p.parentCtx; - } - s += "]"; - return s; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/PredictionContext.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -class PredictionContext { - - constructor(cachedHashCode) { - this.cachedHashCode = cachedHashCode; - } - - /** - * Stores the computed hash code of this {@link PredictionContext}. The hash - * code is computed in parts to match the following reference algorithm. - * - *
      -	 * private int referenceHashCode() {
      -	 * int hash = {@link MurmurHash//initialize MurmurHash.initialize}({@link
      -	 * //INITIAL_HASH});
      -	 *
      -	 * for (int i = 0; i < {@link //size()}; i++) {
      -	 * hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link //getParent
      -	 * getParent}(i));
      -	 * }
      -	 *
      -	 * for (int i = 0; i < {@link //size()}; i++) {
      -	 * hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link
      -	 * //getReturnState getReturnState}(i));
      -	 * }
      -	 *
      -	 * hash = {@link MurmurHash//finish MurmurHash.finish}(hash, 2// {@link
      -	 * //size()});
      -	 * return hash;
      -	 * }
      -	 * 
      - * This means only the {@link //EMPTY} context is in set. - */ - isEmpty() { - return this === PredictionContext.EMPTY; - } - - hasEmptyPath() { - return this.getReturnState(this.length - 1) === PredictionContext.EMPTY_RETURN_STATE; - } - - hashCode() { - return this.cachedHashCode; - } - - updateHashCode(hash) { - hash.update(this.cachedHashCode); - } -} - -/** - * Represents {@code $} in local context prediction, which means wildcard. - * {@code//+x =//}. - */ -PredictionContext.EMPTY = null; - -/** - * Represents {@code $} in an array in full context mode, when {@code $} - * doesn't mean wildcard: {@code $ + x = [$,x]}. Here, - * {@code $} = {@link //EMPTY_RETURN_STATE}. - */ -PredictionContext.EMPTY_RETURN_STATE = 0x7FFFFFFF; - -PredictionContext.globalNodeCount = 1; -PredictionContext.id = PredictionContext.globalNodeCount; - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/ArrayPredictionContext.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -class ArrayPredictionContext extends PredictionContext { - - constructor(parents, returnStates) { - /** - * Parent can be null only if full ctx mode and we make an array - * from {@link //EMPTY} and non-empty. We merge {@link //EMPTY} by using - * null parent and - * returnState == {@link //EMPTY_RETURN_STATE}. - */ - const h = new HashCode(); - h.update(parents, returnStates); - const hashCode = h.finish(); - super(hashCode); - this.parents = parents; - this.returnStates = returnStates; - return this; - } - - isEmpty() { - // since EMPTY_RETURN_STATE can only appear in the last position, we - // don't need to verify that size==1 - return this.returnStates[0] === PredictionContext.EMPTY_RETURN_STATE; - } - - getParent(index) { - return this.parents[index]; - } - - getReturnState(index) { - return this.returnStates[index]; - } - - equals(other) { - if (this === other) { - return true; - } else if (!(other instanceof ArrayPredictionContext)) { - return false; - } else if (this.hashCode() !== other.hashCode()) { - return false; // can't be same if hash is different - } else { - return equalArrays(this.returnStates, other.returnStates) && - equalArrays(this.parents, other.parents); - } - } - - toString() { - if (this.isEmpty()) { - return "[]"; - } else { - let s = "["; - for (let i = 0; i < this.returnStates.length; i++) { - if (i > 0) { - s = s + ", "; - } - if (this.returnStates[i] === PredictionContext.EMPTY_RETURN_STATE) { - s = s + "$"; - continue; - } - s = s + this.returnStates[i]; - if (this.parents[i] !== null) { - s = s + " " + this.parents[i]; - } else { - s = s + "null"; - } - } - return s + "]"; - } - } - - get length(){ - return this.returnStates.length; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/SingletonPredictionContext.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class SingletonPredictionContext extends PredictionContext { - - constructor(parent, returnState) { - let hashCode = 0; - const hash = new HashCode(); - if(parent !== null) { - hash.update(parent, returnState); - } else { - hash.update(1); - } - hashCode = hash.finish(); - super(hashCode); - this.parentCtx = parent; - this.returnState = returnState; - } - - getParent(index) { - return this.parentCtx; - } - - getReturnState(index) { - return this.returnState; - } - - equals(other) { - if (this === other) { - return true; - } else if (!(other instanceof SingletonPredictionContext)) { - return false; - } else if (this.hashCode() !== other.hashCode()) { - return false; // can't be same if hash is different - } else { - if(this.returnState !== other.returnState) - return false; - else if(this.parentCtx==null) - return other.parentCtx==null - else - return this.parentCtx.equals(other.parentCtx); - } - } - - toString() { - const up = this.parentCtx === null ? "" : this.parentCtx.toString(); - if (up.length === 0) { - if (this.returnState === PredictionContext.EMPTY_RETURN_STATE) { - return "$"; - } else { - return "" + this.returnState; - } - } else { - return "" + this.returnState + " " + up; - } - } - - get length(){ - return 1; - } - - static create(parent, returnState) { - if (returnState === PredictionContext.EMPTY_RETURN_STATE && parent === null) { - // someone can pass in the bits of an array ctx that mean $ - return PredictionContext.EMPTY; - } else { - return new SingletonPredictionContext(parent, returnState); - } - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/EmptyPredictionContext.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class EmptyPredictionContext extends SingletonPredictionContext { - - constructor() { - super(null, PredictionContext.EMPTY_RETURN_STATE); - } - - isEmpty() { - return true; - } - - getParent(index) { - return null; - } - - getReturnState(index) { - return this.returnState; - } - - equals(other) { - return this === other; - } - - toString() { - return "$"; - } -} - - -PredictionContext.EMPTY = new EmptyPredictionContext(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/HashMap.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -const HashMap_HASH_KEY_PREFIX = "h-"; - -class HashMap_HashMap { - - constructor(hashFunction, equalsFunction) { - this.data = {}; - this.hashFunction = hashFunction || standardHashCodeFunction; - this.equalsFunction = equalsFunction || standardEqualsFunction; - } - - set(key, value) { - const hashKey = HashMap_HASH_KEY_PREFIX + this.hashFunction(key); - if (hashKey in this.data) { - const entries = this.data[hashKey]; - for (let i = 0; i < entries.length; i++) { - const entry = entries[i]; - if (this.equalsFunction(key, entry.key)) { - const oldValue = entry.value; - entry.value = value; - return oldValue; - } - } - entries.push({key:key, value:value}); - return value; - } else { - this.data[hashKey] = [{key:key, value:value}]; - return value; - } - } - - containsKey(key) { - const hashKey = HashMap_HASH_KEY_PREFIX + this.hashFunction(key); - if(hashKey in this.data) { - const entries = this.data[hashKey]; - for (let i = 0; i < entries.length; i++) { - const entry = entries[i]; - if (this.equalsFunction(key, entry.key)) - return true; - } - } - return false; - } - - get(key) { - const hashKey = HashMap_HASH_KEY_PREFIX + this.hashFunction(key); - if(hashKey in this.data) { - const entries = this.data[hashKey]; - for (let i = 0; i < entries.length; i++) { - const entry = entries[i]; - if (this.equalsFunction(key, entry.key)) - return entry.value; - } - } - return null; - } - - entries() { - return Object.keys(this.data).filter(key => key.startsWith(HashMap_HASH_KEY_PREFIX)).flatMap(key => this.data[key], this); - } - - getKeys() { - return this.entries().map(e => e.key); - } - - getValues() { - return this.entries().map(e => e.value); - } - - toString() { - const ss = this.entries().map(e => '{' + e.key + ':' + e.value + '}'); - return '[' + ss.join(", ") + ']'; - } - - get length() { - return Object.keys(this.data).filter(key => key.startsWith(HashMap_HASH_KEY_PREFIX)).map(key => this.data[key].length, this).reduce((accum, item) => accum + item, 0); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/PredictionContextUtils.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - -/** - * Convert a {@link RuleContext} tree to a {@link PredictionContext} graph. - * Return {@link //EMPTY} if {@code outerContext} is empty or null. - */ -function predictionContextFromRuleContext(atn, outerContext) { - if (outerContext === undefined || outerContext === null) { - outerContext = RuleContext.EMPTY; - } - // if we are in RuleContext of start rule, s, then PredictionContext - // is EMPTY. Nobody called us. (if we are empty, return empty) - if (outerContext.parentCtx === null || outerContext === RuleContext.EMPTY) { - return PredictionContext.EMPTY; - } - // If we have a parent, convert it to a PredictionContext graph - const parent = predictionContextFromRuleContext(atn, outerContext.parentCtx); - const state = atn.states[outerContext.invokingState]; - const transition = state.transitions[0]; - return SingletonPredictionContext.create(parent, transition.followState.stateNumber); -} - - -function getCachedPredictionContext(context, contextCache, visited) { - if (context.isEmpty()) { - return context; - } - let existing = visited.get(context) || null; - if (existing !== null) { - return existing; - } - existing = contextCache.get(context); - if (existing !== null) { - visited.set(context, existing); - return existing; - } - let changed = false; - let parents = []; - for (let i = 0; i < parents.length; i++) { - const parent = getCachedPredictionContext(context.getParent(i), contextCache, visited); - if (changed || parent !== context.getParent(i)) { - if (!changed) { - parents = []; - for (let j = 0; j < context.length; j++) { - parents[j] = context.getParent(j); - } - changed = true; - } - parents[i] = parent; - } - } - if (!changed) { - contextCache.add(context); - visited.set(context, context); - return context; - } - let updated = null; - if (parents.length === 0) { - updated = PredictionContext.EMPTY; - } else if (parents.length === 1) { - updated = SingletonPredictionContext.create(parents[0], context - .getReturnState(0)); - } else { - updated = new ArrayPredictionContext(parents, context.returnStates); - } - contextCache.add(updated); - visited.set(updated, updated); - visited.set(context, updated); - - return updated; -} - -function merge(a, b, rootIsWildcard, mergeCache) { - // share same graph if both same - if (a === b) { - return a; - } - if (a instanceof SingletonPredictionContext && b instanceof SingletonPredictionContext) { - return mergeSingletons(a, b, rootIsWildcard, mergeCache); - } - // At least one of a or b is array - // If one is $ and rootIsWildcard, return $ as// wildcard - if (rootIsWildcard) { - if (a instanceof EmptyPredictionContext) { - return a; - } - if (b instanceof EmptyPredictionContext) { - return b; - } - } - // convert singleton so both are arrays to normalize - if (a instanceof SingletonPredictionContext) { - a = new ArrayPredictionContext([a.getParent()], [a.returnState]); - } - if (b instanceof SingletonPredictionContext) { - b = new ArrayPredictionContext([b.getParent()], [b.returnState]); - } - return mergeArrays(a, b, rootIsWildcard, mergeCache); -} - - -/** - * Merge two {@link ArrayPredictionContext} instances. - * - *

      Different tops, different parents.
      - *

      - * - *

      Shared top, same parents.
      - *

      - * - *

      Shared top, different parents.
      - *

      - * - *

      Shared top, all shared parents.
      - *

      - * - *

      Equal tops, merge parents and reduce top to - * {@link SingletonPredictionContext}.
      - *

      - */ -function mergeArrays(a, b, rootIsWildcard, mergeCache) { - if (mergeCache !== null) { - let previous = mergeCache.get(a, b); - if (previous !== null) { - return previous; - } - previous = mergeCache.get(b, a); - if (previous !== null) { - return previous; - } - } - // merge sorted payloads a + b => M - let i = 0; // walks a - let j = 0; // walks b - let k = 0; // walks target M array - - let mergedReturnStates = []; - let mergedParents = []; - // walk and merge to yield mergedParents, mergedReturnStates - while (i < a.returnStates.length && j < b.returnStates.length) { - const a_parent = a.parents[i]; - const b_parent = b.parents[j]; - if (a.returnStates[i] === b.returnStates[j]) { - // same payload (stack tops are equal), must yield merged singleton - const payload = a.returnStates[i]; - // $+$ = $ - const bothDollars = payload === PredictionContext.EMPTY_RETURN_STATE && - a_parent === null && b_parent === null; - const ax_ax = (a_parent !== null && b_parent !== null && a_parent === b_parent); // ax+ax - // -> - // ax - if (bothDollars || ax_ax) { - mergedParents[k] = a_parent; // choose left - mergedReturnStates[k] = payload; - } else { // ax+ay -> a'[x,y] - mergedParents[k] = merge(a_parent, b_parent, rootIsWildcard, mergeCache); - mergedReturnStates[k] = payload; - } - i += 1; // hop over left one as usual - j += 1; // but also skip one in right side since we merge - } else if (a.returnStates[i] < b.returnStates[j]) { // copy a[i] to M - mergedParents[k] = a_parent; - mergedReturnStates[k] = a.returnStates[i]; - i += 1; - } else { // b > a, copy b[j] to M - mergedParents[k] = b_parent; - mergedReturnStates[k] = b.returnStates[j]; - j += 1; - } - k += 1; - } - // copy over any payloads remaining in either array - if (i < a.returnStates.length) { - for (let p = i; p < a.returnStates.length; p++) { - mergedParents[k] = a.parents[p]; - mergedReturnStates[k] = a.returnStates[p]; - k += 1; - } - } else { - for (let p = j; p < b.returnStates.length; p++) { - mergedParents[k] = b.parents[p]; - mergedReturnStates[k] = b.returnStates[p]; - k += 1; - } - } - // trim merged if we combined a few that had same stack tops - if (k < mergedParents.length) { // write index < last position; trim - if (k === 1) { // for just one merged element, return singleton top - const a_ = SingletonPredictionContext.create(mergedParents[0], - mergedReturnStates[0]); - if (mergeCache !== null) { - mergeCache.set(a, b, a_); - } - return a_; - } - mergedParents = mergedParents.slice(0, k); - mergedReturnStates = mergedReturnStates.slice(0, k); - } - - const M = new ArrayPredictionContext(mergedParents, mergedReturnStates); - - // if we created same array as a or b, return that instead - // TODO: track whether this is possible above during merge sort for speed - if (M === a) { - if (mergeCache !== null) { - mergeCache.set(a, b, a); - } - return a; - } - if (M === b) { - if (mergeCache !== null) { - mergeCache.set(a, b, b); - } - return b; - } - combineCommonParents(mergedParents); - - if (mergeCache !== null) { - mergeCache.set(a, b, M); - } - return M; -} - - -/** - * Make pass over all M {@code parents}; merge any {@code equals()} - * ones. - */ -function combineCommonParents(parents) { - const uniqueParents = new HashMap_HashMap(); - - for (let p = 0; p < parents.length; p++) { - const parent = parents[p]; - if (!(uniqueParents.containsKey(parent))) { - uniqueParents.set(parent, parent); - } - } - for (let q = 0; q < parents.length; q++) { - parents[q] = uniqueParents.get(parents[q]); - } -} - - -/** - * Merge two {@link SingletonPredictionContext} instances. - * - *

      Stack tops equal, parents merge is same; return left graph.
      - *

      - * - *

      Same stack top, parents differ; merge parents giving array node, then - * remainders of those graphs. A new root node is created to point to the - * merged parents.
      - *

      - * - *

      Different stack tops pointing to same parent. Make array node for the - * root where both element in the root point to the same (original) - * parent.
      - *

      - * - *

      Different stack tops pointing to different parents. Make array node for - * the root where each element points to the corresponding original - * parent.
      - *

      - * - * @param a the first {@link SingletonPredictionContext} - * @param b the second {@link SingletonPredictionContext} - * @param rootIsWildcard {@code true} if this is a local-context merge, - * otherwise false to indicate a full-context merge - * @param mergeCache - */ -function mergeSingletons(a, b, rootIsWildcard, mergeCache) { - if (mergeCache !== null) { - let previous = mergeCache.get(a, b); - if (previous !== null) { - return previous; - } - previous = mergeCache.get(b, a); - if (previous !== null) { - return previous; - } - } - - const rootMerge = mergeRoot(a, b, rootIsWildcard); - if (rootMerge !== null) { - if (mergeCache !== null) { - mergeCache.set(a, b, rootMerge); - } - return rootMerge; - } - if (a.returnState === b.returnState) { - const parent = merge(a.parentCtx, b.parentCtx, rootIsWildcard, mergeCache); - // if parent is same as existing a or b parent or reduced to a parent, - // return it - if (parent === a.parentCtx) { - return a; // ax + bx = ax, if a=b - } - if (parent === b.parentCtx) { - return b; // ax + bx = bx, if a=b - } - // else: ax + ay = a'[x,y] - // merge parents x and y, giving array node with x,y then remainders - // of those graphs. dup a, a' points at merged array - // new joined parent so create new singleton pointing to it, a' - const spc = SingletonPredictionContext.create(parent, a.returnState); - if (mergeCache !== null) { - mergeCache.set(a, b, spc); - } - return spc; - } else { // a != b payloads differ - // see if we can collapse parents due to $+x parents if local ctx - let singleParent = null; - if (a === b || (a.parentCtx !== null && a.parentCtx === b.parentCtx)) { // ax + - // bx = - // [a,b]x - singleParent = a.parentCtx; - } - if (singleParent !== null) { // parents are same - // sort payloads and use same parent - const payloads = [ a.returnState, b.returnState ]; - if (a.returnState > b.returnState) { - payloads[0] = b.returnState; - payloads[1] = a.returnState; - } - const parents = [ singleParent, singleParent ]; - const apc = new ArrayPredictionContext(parents, payloads); - if (mergeCache !== null) { - mergeCache.set(a, b, apc); - } - return apc; - } - // parents differ and can't merge them. Just pack together - // into array; can't merge. - // ax + by = [ax,by] - const payloads = [ a.returnState, b.returnState ]; - let parents = [ a.parentCtx, b.parentCtx ]; - if (a.returnState > b.returnState) { // sort by payload - payloads[0] = b.returnState; - payloads[1] = a.returnState; - parents = [ b.parentCtx, a.parentCtx ]; - } - const a_ = new ArrayPredictionContext(parents, payloads); - if (mergeCache !== null) { - mergeCache.set(a, b, a_); - } - return a_; - } -} - - -/** - * Handle case where at least one of {@code a} or {@code b} is - * {@link //EMPTY}. In the following diagrams, the symbol {@code $} is used - * to represent {@link //EMPTY}. - * - *

      Local-Context Merges

      - * - *

      These local-context merge operations are used when {@code rootIsWildcard} - * is true.

      - * - *

      {@link //EMPTY} is superset of any graph; return {@link //EMPTY}.
      - *

      - * - *

      {@link //EMPTY} and anything is {@code //EMPTY}, so merged parent is - * {@code //EMPTY}; return left graph.
      - *

      - * - *

      Special case of last merge if local context.
      - *

      - * - *

      Full-Context Merges

      - * - *

      These full-context merge operations are used when {@code rootIsWildcard} - * is false.

      - * - *

      - * - *

      Must keep all contexts; {@link //EMPTY} in array is a special value (and - * null parent).
      - *

      - * - *

      - * - * @param a the first {@link SingletonPredictionContext} - * @param b the second {@link SingletonPredictionContext} - * @param rootIsWildcard {@code true} if this is a local-context merge, - * otherwise false to indicate a full-context merge - */ -function mergeRoot(a, b, rootIsWildcard) { - if (rootIsWildcard) { - if (a === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; // // + b =// - } - if (b === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; // a +// =// - } - } else { - if (a === PredictionContext.EMPTY && b === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; // $ + $ = $ - } else if (a === PredictionContext.EMPTY) { // $ + x = [$,x] - const payloads = [ b.returnState, - PredictionContext.EMPTY_RETURN_STATE ]; - const parents = [ b.parentCtx, null ]; - return new ArrayPredictionContext(parents, payloads); - } else if (b === PredictionContext.EMPTY) { // x + $ = [$,x] ($ is always first if present) - const payloads = [ a.returnState, PredictionContext.EMPTY_RETURN_STATE ]; - const parents = [ a.parentCtx, null ]; - return new ArrayPredictionContext(parents, payloads); - } - } - return null; -} - - -// ter's recursive version of Sam's getAllNodes() -function getAllContextNodes(context, nodes, visited) { - if (nodes === null) { - nodes = []; - return getAllContextNodes(context, nodes, visited); - } else if (visited === null) { - visited = new HashMap(); - return getAllContextNodes(context, nodes, visited); - } else { - if (context === null || visited.containsKey(context)) { - return nodes; - } - visited.set(context, context); - nodes.push(context); - for (let i = 0; i < context.length; i++) { - getAllContextNodes(context.getParent(i), nodes, visited); - } - return nodes; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/BitSet.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class BitSet { - - constructor() { - this.data = []; - } - - add(value) { - this.data[value] = true; - } - - or(set) { - Object.keys(set.data).map(alt => this.add(alt), this); - } - - remove(value) { - delete this.data[value]; - } - - has(value) { - return this.data[value] === true; - } - - values() { - return Object.keys(this.data); - } - - minValue() { - return Math.min.apply(null, this.values()); - } - - hashCode() { - return HashCode.hashStuff(this.values()); - } - - equals(other) { - return other instanceof BitSet && equalArrays(this.data, other.data); - } - - toString() { - return "{" + this.values().join(", ") + "}"; - } - - get length(){ - return this.values().length; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LL1Analyzer.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - - - - - - - -class LL1Analyzer { - constructor(atn) { - this.atn = atn; - } - - /** - * Calculates the SLL(1) expected lookahead set for each outgoing transition - * of an {@link ATNState}. The returned array has one element for each - * outgoing transition in {@code s}. If the closure from transition - * i leads to a semantic predicate before matching a symbol, the - * element at index i of the result will be {@code null}. - * - * @param s the ATN state - * @return the expected symbols for each outgoing transition of {@code s}. - */ - getDecisionLookahead(s) { - if (s === null) { - return null; - } - const count = s.transitions.length; - const look = []; - for(let alt=0; alt< count; alt++) { - look[alt] = new IntervalSet(); - const lookBusy = new HashSet(); - const seeThruPreds = false; // fail to get lookahead upon pred - this._LOOK(s.transition(alt).target, null, PredictionContext.EMPTY, - look[alt], lookBusy, new BitSet(), seeThruPreds, false); - // Wipe out lookahead for this alternative if we found nothing - // or we had a predicate when we !seeThruPreds - if (look[alt].length===0 || look[alt].contains(LL1Analyzer.HIT_PRED)) { - look[alt] = null; - } - } - return look; - } - - /** - * Compute set of tokens that can follow {@code s} in the ATN in the - * specified {@code ctx}. - * - *

      If {@code ctx} is {@code null} and the end of the rule containing - * {@code s} is reached, {@link Token//EPSILON} is added to the result set. - * If {@code ctx} is not {@code null} and the end of the outermost rule is - * reached, {@link Token//EOF} is added to the result set.

      - * - * @param s the ATN state - * @param stopState the ATN state to stop at. This can be a - * {@link BlockEndState} to detect epsilon paths through a closure. - * @param ctx the complete parser context, or {@code null} if the context - * should be ignored - * - * @return The set of tokens that can follow {@code s} in the ATN in the - * specified {@code ctx}. - */ - LOOK(s, stopState, ctx) { - const r = new IntervalSet(); - const seeThruPreds = true; // ignore preds; get all lookahead - ctx = ctx || null; - const lookContext = ctx!==null ? predictionContextFromRuleContext(s.atn, ctx) : null; - this._LOOK(s, stopState, lookContext, r, new HashSet(), new BitSet(), seeThruPreds, true); - return r; - } - - /** - * Compute set of tokens that can follow {@code s} in the ATN in the - * specified {@code ctx}. - * - *

      If {@code ctx} is {@code null} and {@code stopState} or the end of the - * rule containing {@code s} is reached, {@link Token//EPSILON} is added to - * the result set. If {@code ctx} is not {@code null} and {@code addEOF} is - * {@code true} and {@code stopState} or the end of the outermost rule is - * reached, {@link Token//EOF} is added to the result set.

      - * - * @param s the ATN state. - * @param stopState the ATN state to stop at. This can be a - * {@link BlockEndState} to detect epsilon paths through a closure. - * @param ctx The outer context, or {@code null} if the outer context should - * not be used. - * @param look The result lookahead set. - * @param lookBusy A set used for preventing epsilon closures in the ATN - * from causing a stack overflow. Outside code should pass - * {@code new CustomizedSet} for this argument. - * @param calledRuleStack A set used for preventing left recursion in the - * ATN from causing a stack overflow. Outside code should pass - * {@code new BitSet()} for this argument. - * @param seeThruPreds {@code true} to true semantic predicates as - * implicitly {@code true} and "see through them", otherwise {@code false} - * to treat semantic predicates as opaque and add {@link //HIT_PRED} to the - * result if one is encountered. - * @param addEOF Add {@link Token//EOF} to the result if the end of the - * outermost context is reached. This parameter has no effect if {@code ctx} - * is {@code null}. - */ - _LOOK(s, stopState , ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) { - const c = new ATNConfig({state:s, alt:0, context: ctx}, null); - if (lookBusy.has(c)) { - return; - } - lookBusy.add(c); - if (s === stopState) { - if (ctx ===null) { - look.addOne(Token.EPSILON); - return; - } else if (ctx.isEmpty() && addEOF) { - look.addOne(Token.EOF); - return; - } - } - if (s instanceof RuleStopState ) { - if (ctx ===null) { - look.addOne(Token.EPSILON); - return; - } else if (ctx.isEmpty() && addEOF) { - look.addOne(Token.EOF); - return; - } - if (ctx !== PredictionContext.EMPTY) { - const removed = calledRuleStack.has(s.ruleIndex); - try { - calledRuleStack.remove(s.ruleIndex); - // run thru all possible stack tops in ctx - for (let i = 0; i < ctx.length; i++) { - const returnState = this.atn.states[ctx.getReturnState(i)]; - this._LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF); - } - }finally { - if (removed) { - calledRuleStack.add(s.ruleIndex); - } - } - return; - } - } - for(let j=0; jIf {@code context} is {@code null}, it is treated as - * {@link ParserRuleContext//EMPTY}.

      - * - * @param stateNumber the ATN state number - * @param ctx the full parse context - * - * @return {IntervalSet} The set of potentially valid input symbols which could follow the - * specified state in the specified context. - * - * @throws IllegalArgumentException if the ATN does not contain a state with - * number {@code stateNumber} - */ - getExpectedTokens(stateNumber, ctx ) { - if ( stateNumber < 0 || stateNumber >= this.states.length ) { - throw("Invalid state number."); - } - const s = this.states[stateNumber]; - let following = this.nextTokens(s); - if (!following.contains(Token.EPSILON)) { - return following; - } - const expected = new IntervalSet(); - expected.addSet(following); - expected.removeOne(Token.EPSILON); - while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) { - const invokingState = this.states[ctx.invokingState]; - const rt = invokingState.transitions[0]; - following = this.nextTokens(rt.followState); - expected.addSet(following); - expected.removeOne(Token.EPSILON); - ctx = ctx.parentCtx; - } - if (following.contains(Token.EPSILON)) { - expected.addOne(Token.EOF); - } - return expected; - } -} - -ATN.INVALID_ALT_NUMBER = 0; - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNType.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/** - * Represents the type of recognizer an ATN applies to - */ -/* harmony default export */ const ATNType = ({ - LEXER: 0, - PARSER: 1 -}); - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BasicState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class BasicState extends ATNState { - constructor() { - super(); - this.stateType = ATNState.BASIC; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/DecisionState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class DecisionState extends ATNState { - constructor() { - super(); - this.decision = -1; - this.nonGreedy = false; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BlockStartState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/** - * The start of a regular {@code (...)} block - */ -class BlockStartState extends DecisionState { - constructor() { - super(); - this.endState = null; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BlockEndState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/** - * Terminal node of a simple {@code (a|b|c)} block - */ -class BlockEndState extends ATNState { - constructor() { - super(); - this.stateType = ATNState.BLOCK_END; - this.startState = null; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/LoopEndState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/** - * Mark the end of a * or + loop - */ -class LoopEndState extends ATNState { - constructor() { - super(); - this.stateType = ATNState.LOOP_END; - this.loopBackState = null; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/RuleStartState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class RuleStartState extends ATNState { - constructor() { - super(); - this.stateType = ATNState.RULE_START; - this.stopState = null; - this.isPrecedenceRule = false; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/TokensStartState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * The Tokens rule start state linking to each lexer rule start state - */ -class TokensStartState extends DecisionState { - constructor() { - super(); - this.stateType = ATNState.TOKEN_START; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/PlusLoopbackState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: - * one to the loop back to start of the block and one to exit. - */ -class PlusLoopbackState extends DecisionState { - constructor() { - super(); - this.stateType = ATNState.PLUS_LOOP_BACK; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/StarLoopbackState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class StarLoopbackState extends ATNState { - constructor() { - super(); - this.stateType = ATNState.STAR_LOOP_BACK; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/StarLoopEntryState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class StarLoopEntryState extends DecisionState { - constructor() { - super(); - this.stateType = ATNState.STAR_LOOP_ENTRY; - this.loopBackState = null; - // Indicates whether this state can benefit from a precedence DFA during SLL decision making. - this.isPrecedenceDecision = null; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/PlusBlockStartState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Start of {@code (A|B|...)+} loop. Technically a decision state, but - * we don't use for code generation; somebody might need it, so I'm defining - * it for completeness. In reality, the {@link PlusLoopbackState} node is the - * real decision-making note for {@code A+} - */ -class PlusBlockStartState extends BlockStartState { - constructor() { - super(); - this.stateType = ATNState.PLUS_BLOCK_START; - this.loopBackState = null; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/StarBlockStartState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * The block that begins a closure loop - */ -class StarBlockStartState extends BlockStartState { - constructor() { - super(); - this.stateType = ATNState.STAR_BLOCK_START; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BasicBlockStartState.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class BasicBlockStartState extends BlockStartState { - constructor() { - super(); - this.stateType = ATNState.BLOCK_START; - return this; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/AtomTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class AtomTransition extends Transition { - constructor(target, label) { - super(target); - // The token type or character value; or, signifies special label. - this.label_ = label; - this.label = this.makeLabel(); - this.serializationType = Transition.ATOM; - } - - makeLabel() { - const s = new IntervalSet(); - s.addOne(this.label_); - return s; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return this.label_ === symbol; - } - - toString() { - return this.label_; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/RangeTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class RangeTransition extends Transition { - constructor(target, start, stop) { - super(target); - this.serializationType = Transition.RANGE; - this.start = start; - this.stop = stop; - this.label = this.makeLabel(); - } - - makeLabel() { - const s = new IntervalSet(); - s.addRange(this.start, this.stop); - return s; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return symbol >= this.start && symbol <= this.stop; - } - - toString() { - return "'" + String.fromCharCode(this.start) + "'..'" + String.fromCharCode(this.stop) + "'"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/ActionTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class ActionTransition extends Transition { - constructor(target, ruleIndex, actionIndex, isCtxDependent) { - super(target); - this.serializationType = Transition.ACTION; - this.ruleIndex = ruleIndex; - this.actionIndex = actionIndex===undefined ? -1 : actionIndex; - this.isCtxDependent = isCtxDependent===undefined ? false : isCtxDependent; // e.g., $i ref in pred - this.isEpsilon = true; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return false; - } - - toString() { - return "action_" + this.ruleIndex + ":" + this.actionIndex; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/EpsilonTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class EpsilonTransition extends Transition { - constructor(target, outermostPrecedenceReturn) { - super(target); - this.serializationType = Transition.EPSILON; - this.isEpsilon = true; - this.outermostPrecedenceReturn = outermostPrecedenceReturn; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return false; - } - - toString() { - return "epsilon"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/Predicate.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class Predicate extends SemanticContext { - - constructor(ruleIndex, predIndex, isCtxDependent) { - super(); - this.ruleIndex = ruleIndex === undefined ? -1 : ruleIndex; - this.predIndex = predIndex === undefined ? -1 : predIndex; - this.isCtxDependent = isCtxDependent === undefined ? false : isCtxDependent; // e.g., $i ref in pred - } - - evaluate(parser, outerContext) { - const localctx = this.isCtxDependent ? outerContext : null; - return parser.sempred(localctx, this.ruleIndex, this.predIndex); - } - - updateHashCode(hash) { - hash.update(this.ruleIndex, this.predIndex, this.isCtxDependent); - } - - equals(other) { - if (this === other) { - return true; - } else if (!(other instanceof Predicate)) { - return false; - } else { - return this.ruleIndex === other.ruleIndex && - this.predIndex === other.predIndex && - this.isCtxDependent === other.isCtxDependent; - } - } - - toString() { - return "{" + this.ruleIndex + ":" + this.predIndex + "}?"; - } -} - -/** - * The default {@link SemanticContext}, which is semantically equivalent to - * a predicate of the form {@code {true}?} - */ -SemanticContext.NONE = new Predicate(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/PredicateTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -class PredicateTransition extends AbstractPredicateTransition { - constructor(target, ruleIndex, predIndex, isCtxDependent) { - super(target); - this.serializationType = Transition.PREDICATE; - this.ruleIndex = ruleIndex; - this.predIndex = predIndex; - this.isCtxDependent = isCtxDependent; // e.g., $i ref in pred - this.isEpsilon = true; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return false; - } - - getPredicate() { - return new Predicate(this.ruleIndex, this.predIndex, this.isCtxDependent); - } - - toString() { - return "pred_" + this.ruleIndex + ":" + this.predIndex; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/PrecedencePredicate.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class PrecedencePredicate extends SemanticContext { - - constructor(precedence) { - super(); - this.precedence = precedence === undefined ? 0 : precedence; - } - - evaluate(parser, outerContext) { - return parser.precpred(outerContext, this.precedence); - } - - evalPrecedence(parser, outerContext) { - if (parser.precpred(outerContext, this.precedence)) { - return SemanticContext.NONE; - } else { - return null; - } - } - - compareTo(other) { - return this.precedence - other.precedence; - } - - updateHashCode(hash) { - hash.update(this.precedence); - } - - equals(other) { - if (this === other) { - return true; - } else if (!(other instanceof PrecedencePredicate)) { - return false; - } else { - return this.precedence === other.precedence; - } - } - - toString() { - return "{" + this.precedence + ">=prec}?"; - } - -} - -// HORRIBLE workaround circular import, avoiding dynamic import -SemanticContext.PrecedencePredicate = PrecedencePredicate; - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/PrecedencePredicateTransition.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -class PrecedencePredicateTransition extends AbstractPredicateTransition { - constructor(target, precedence) { - super(target); - this.serializationType = Transition.PRECEDENCE; - this.precedence = precedence; - this.isEpsilon = true; - } - - matches(symbol, minVocabSymbol, maxVocabSymbol) { - return false; - } - - getPredicate() { - return new PrecedencePredicate(this.precedence); - } - - toString() { - return this.precedence + " >= _p"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNDeserializationOptions.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -class ATNDeserializationOptions { - constructor(copyFrom) { - if(copyFrom===undefined) { - copyFrom = null; - } - this.readOnly = false; - this.verifyATN = copyFrom===null ? true : copyFrom.verifyATN; - this.generateRuleBypassTransitions = copyFrom===null ? false : copyFrom.generateRuleBypassTransitions; - } -} - -ATNDeserializationOptions.defaultOptions = new ATNDeserializationOptions(); -ATNDeserializationOptions.defaultOptions.readOnly = true; - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerActionType.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/* harmony default export */ const LexerActionType = ({ - // The type of a {@link LexerChannelAction} action. - CHANNEL: 0, - // The type of a {@link LexerCustomAction} action - CUSTOM: 1, - // The type of a {@link LexerModeAction} action. - MODE: 2, - //The type of a {@link LexerMoreAction} action. - MORE: 3, - //The type of a {@link LexerPopModeAction} action. - POP_MODE: 4, - //The type of a {@link LexerPushModeAction} action. - PUSH_MODE: 5, - //The type of a {@link LexerSkipAction} action. - SKIP: 6, - //The type of a {@link LexerTypeAction} action. - TYPE: 7 -}); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class LexerAction { - constructor(action) { - this.actionType = action; - this.isPositionDependent = false; - } - - hashCode() { - const hash = new HashCode(); - this.updateHashCode(hash); - return hash.finish() - } - - updateHashCode(hash) { - hash.update(this.actionType); - } - - equals(other) { - return this === other; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerSkipAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code skip} lexer action by calling {@link Lexer//skip}. - * - *

      The {@code skip} command does not have any parameters, so this action is - * implemented as a singleton instance exposed by {@link //INSTANCE}.

      - */ -class LexerSkipAction extends LexerAction { - constructor() { - super(LexerActionType.SKIP); - } - - execute(lexer) { - lexer.skip(); - } - - toString() { - return "skip"; - } -} - -// Provides a singleton instance of this parameterless lexer action. -LexerSkipAction.INSTANCE = new LexerSkipAction(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerChannelAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code channel} lexer action by calling - * {@link Lexer//setChannel} with the assigned channel. - * Constructs a new {@code channel} action with the specified channel value. - * @param channel The channel value to pass to {@link Lexer//setChannel} - */ -class LexerChannelAction extends LexerAction { - constructor(channel) { - super(LexerActionType.CHANNEL); - this.channel = channel; - } - - /** - *

      This action is implemented by calling {@link Lexer//setChannel} with the - * value provided by {@link //getChannel}.

      - */ - execute(lexer) { - lexer._channel = this.channel; - } - - updateHashCode(hash) { - hash.update(this.actionType, this.channel); - } - - equals(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerChannelAction)) { - return false; - } else { - return this.channel === other.channel; - } - } - - toString() { - return "channel(" + this.channel + ")"; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerCustomAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Executes a custom lexer action by calling {@link Recognizer//action} with the - * rule and action indexes assigned to the custom action. The implementation of - * a custom action is added to the generated code for the lexer in an override - * of {@link Recognizer//action} when the grammar is compiled. - * - *

      This class may represent embedded actions created with the {...} - * syntax in ANTLR 4, as well as actions created for lexer commands where the - * command argument could not be evaluated when the grammar was compiled.

      - */ -class LexerCustomAction extends LexerAction { - /** - * Constructs a custom lexer action with the specified rule and action - * indexes. - * - * @param ruleIndex The rule index to use for calls to - * {@link Recognizer//action}. - * @param actionIndex The action index to use for calls to - * {@link Recognizer//action}. - */ - constructor(ruleIndex, actionIndex) { - super(LexerActionType.CUSTOM); - this.ruleIndex = ruleIndex; - this.actionIndex = actionIndex; - this.isPositionDependent = true; - } - - /** - *

      Custom actions are implemented by calling {@link Lexer//action} with the - * appropriate rule and action indexes.

      - */ - execute(lexer) { - lexer.action(null, this.ruleIndex, this.actionIndex); - } - - updateHashCode(hash) { - hash.update(this.actionType, this.ruleIndex, this.actionIndex); - } - - equals(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerCustomAction)) { - return false; - } else { - return this.ruleIndex === other.ruleIndex && this.actionIndex === other.actionIndex; - } - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerMoreAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code more} lexer action by calling {@link Lexer//more}. - * - *

      The {@code more} command does not have any parameters, so this action is - * implemented as a singleton instance exposed by {@link //INSTANCE}.

      - */ -class LexerMoreAction extends LexerAction { - constructor() { - super(LexerActionType.MORE); - } - - /** - *

      This action is implemented by calling {@link Lexer//popMode}.

      - */ - execute(lexer) { - lexer.more(); - } - - toString() { - return "more"; - } -} - -LexerMoreAction.INSTANCE = new LexerMoreAction(); - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerTypeAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code type} lexer action by calling {@link Lexer//setType} - * with the assigned type - */ - -class LexerTypeAction extends LexerAction { - constructor(type) { - super(LexerActionType.TYPE); - this.type = type; - } - - execute(lexer) { - lexer.type = this.type; - } - - updateHashCode(hash) { - hash.update(this.actionType, this.type); - } - - equals(other) { - if(this === other) { - return true; - } else if (! (other instanceof LexerTypeAction)) { - return false; - } else { - return this.type === other.type; - } - } - - toString() { - return "type(" + this.type + ")"; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerPushModeAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code pushMode} lexer action by calling - * {@link Lexer//pushMode} with the assigned mode - */ -class LexerPushModeAction extends LexerAction { - constructor(mode) { - super(LexerActionType.PUSH_MODE); - this.mode = mode; - } - - /** - *

      This action is implemented by calling {@link Lexer//pushMode} with the - * value provided by {@link //getMode}.

      - */ - execute(lexer) { - lexer.pushMode(this.mode); - } - - updateHashCode(hash) { - hash.update(this.actionType, this.mode); - } - - equals(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerPushModeAction)) { - return false; - } else { - return this.mode === other.mode; - } - } - - toString() { - return "pushMode(" + this.mode + ")"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerPopModeAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code popMode} lexer action by calling {@link Lexer//popMode}. - * - *

      The {@code popMode} command does not have any parameters, so this action is - * implemented as a singleton instance exposed by {@link //INSTANCE}.

      - */ -class LexerPopModeAction extends LexerAction { - constructor() { - super(LexerActionType.POP_MODE); - } - - /** - *

      This action is implemented by calling {@link Lexer//popMode}.

      - */ - execute(lexer) { - lexer.popMode(); - } - - toString() { - return "popMode"; - } -} - -LexerPopModeAction.INSTANCE = new LexerPopModeAction(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerModeAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Implements the {@code mode} lexer action by calling {@link Lexer//mode} with - * the assigned mode - */ -class LexerModeAction extends LexerAction { - constructor(mode) { - super(LexerActionType.MODE); - this.mode = mode; - } - - /** - *

      This action is implemented by calling {@link Lexer//mode} with the - * value provided by {@link //getMode}.

      - */ - execute(lexer) { - lexer.mode(this.mode); - } - - updateHashCode(hash) { - hash.update(this.actionType, this.mode); - } - - equals(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerModeAction)) { - return false; - } else { - return this.mode === other.mode; - } - } - - toString() { - return "mode(" + this.mode + ")"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNDeserializer.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const SERIALIZED_VERSION = 4; - -function initArray( length, value) { - const tmp = []; - tmp[length-1] = value; - return tmp.map(function(i) {return value;}); -} - -class ATNDeserializer { - constructor(options) { - - if ( options=== undefined || options === null ) { - options = ATNDeserializationOptions.defaultOptions; - } - this.deserializationOptions = options; - this.stateFactories = null; - this.actionFactories = null; - } - - deserialize(data) { - const legacy = this.reset(data); - this.checkVersion(legacy); - if(legacy) - this.skipUUID(); - const atn = this.readATN(); - this.readStates(atn, legacy); - this.readRules(atn, legacy); - this.readModes(atn); - const sets = []; - this.readSets(atn, sets, this.readInt.bind(this)); - if(legacy) - this.readSets(atn, sets, this.readInt32.bind(this)); - this.readEdges(atn, sets); - this.readDecisions(atn); - this.readLexerActions(atn, legacy); - this.markPrecedenceDecisions(atn); - this.verifyATN(atn); - if (this.deserializationOptions.generateRuleBypassTransitions && atn.grammarType === ATNType.PARSER ) { - this.generateRuleBypassTransitions(atn); - // re-verify after modification - this.verifyATN(atn); - } - return atn; - } - - reset(data) { - const version = data.charCodeAt ? data.charCodeAt(0) : data[0]; - if(version === SERIALIZED_VERSION - 1) { - const adjust = function (c) { - const v = c.charCodeAt(0); - return v > 1 ? v - 2 : v + 65534; - }; - const temp = data.split("").map(adjust); - // don't adjust the first value since that's the version number - temp[0] = data.charCodeAt(0); - this.data = temp; - this.pos = 0; - return true; - } else { - this.data = data - this.pos = 0; - return false; - } - } - - skipUUID() { - let count = 0; - while(count++ < 8) - this.readInt(); - } - - checkVersion(legacy) { - const version = this.readInt(); - if ( !legacy && version !== SERIALIZED_VERSION ) { - throw ("Could not deserialize ATN with version " + version + " (expected " + SERIALIZED_VERSION + ")."); - } - } - - readATN() { - const grammarType = this.readInt(); - const maxTokenType = this.readInt(); - return new ATN(grammarType, maxTokenType); - } - - readStates(atn, legacy) { - let j, pair, stateNumber; - const loopBackStateNumbers = []; - const endStateNumbers = []; - const nstates = this.readInt(); - for(let i=0; i 0) { - bypassStart.addTransition(ruleToStartState.transitions[count-1]); - ruleToStartState.transitions = ruleToStartState.transitions.slice(-1); - } - // link the new states - atn.ruleToStartState[idx].addTransition(new EpsilonTransition(bypassStart)); - bypassStop.addTransition(new EpsilonTransition(endState)); - - const matchState = new BasicState(); - atn.addState(matchState); - matchState.addTransition(new AtomTransition(bypassStop, atn.ruleToTokenType[idx])); - bypassStart.addTransition(new EpsilonTransition(matchState)); - } - - stateIsEndStateFor(state, idx) { - if ( state.ruleIndex !== idx) { - return null; - } - if (!( state instanceof StarLoopEntryState)) { - return null; - } - const maybeLoopEndState = state.transitions[state.transitions.length - 1].target; - if (!( maybeLoopEndState instanceof LoopEndState)) { - return null; - } - if (maybeLoopEndState.epsilonOnlyTransitions && - (maybeLoopEndState.transitions[0].target instanceof RuleStopState)) { - return state; - } else { - return null; - } - } - - /** - * Analyze the {@link StarLoopEntryState} states in the specified ATN to set - * the {@link StarLoopEntryState//isPrecedenceDecision} field to the - * correct value. - * @param atn The ATN. - */ - markPrecedenceDecisions(atn) { - for(let i=0; i= 0); - } else { - this.checkCondition(state.transitions.length <= 1 || (state instanceof RuleStopState)); - } - } - } - - checkCondition(condition, message) { - if (!condition) { - if (message === undefined || message===null) { - message = "IllegalState"; - } - throw (message); - } - } - - readInt() { - return this.data[this.pos++]; - } - - readInt32() { - const low = this.readInt(); - const high = this.readInt(); - return low | (high << 16); - } - - edgeFactory(atn, type, src, trg, arg1, arg2, arg3, sets) { - const target = atn.states[trg]; - switch(type) { - case Transition.EPSILON: - return new EpsilonTransition(target); - case Transition.RANGE: - return arg3 !== 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2); - case Transition.RULE: - return new RuleTransition(atn.states[arg1], arg2, arg3, target); - case Transition.PREDICATE: - return new PredicateTransition(target, arg1, arg2, arg3 !== 0); - case Transition.PRECEDENCE: - return new PrecedencePredicateTransition(target, arg1); - case Transition.ATOM: - return arg3 !== 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1); - case Transition.ACTION: - return new ActionTransition(target, arg1, arg2, arg3 !== 0); - case Transition.SET: - return new SetTransition(target, sets[arg1]); - case Transition.NOT_SET: - return new NotSetTransition(target, sets[arg1]); - case Transition.WILDCARD: - return new WildcardTransition(target); - default: - throw "The specified transition type: " + type + " is not valid."; - } - } - - stateFactory(type, ruleIndex) { - if (this.stateFactories === null) { - const sf = []; - sf[ATNState.INVALID_TYPE] = null; - sf[ATNState.BASIC] = () => new BasicState(); - sf[ATNState.RULE_START] = () => new RuleStartState(); - sf[ATNState.BLOCK_START] = () => new BasicBlockStartState(); - sf[ATNState.PLUS_BLOCK_START] = () => new PlusBlockStartState(); - sf[ATNState.STAR_BLOCK_START] = () => new StarBlockStartState(); - sf[ATNState.TOKEN_START] = () => new TokensStartState(); - sf[ATNState.RULE_STOP] = () => new RuleStopState(); - sf[ATNState.BLOCK_END] = () => new BlockEndState(); - sf[ATNState.STAR_LOOP_BACK] = () => new StarLoopbackState(); - sf[ATNState.STAR_LOOP_ENTRY] = () => new StarLoopEntryState(); - sf[ATNState.PLUS_LOOP_BACK] = () => new PlusLoopbackState(); - sf[ATNState.LOOP_END] = () => new LoopEndState(); - this.stateFactories = sf; - } - if (type>this.stateFactories.length || this.stateFactories[type] === null) { - throw("The specified state type " + type + " is not valid."); - } else { - const s = this.stateFactories[type](); - if (s!==null) { - s.ruleIndex = ruleIndex; - return s; - } - } - } - - lexerActionFactory(type, data1, data2) { - if (this.actionFactories === null) { - const af = []; - af[LexerActionType.CHANNEL] = (data1, data2) => new LexerChannelAction(data1); - af[LexerActionType.CUSTOM] = (data1, data2) => new LexerCustomAction(data1, data2); - af[LexerActionType.MODE] = (data1, data2) => new LexerModeAction(data1); - af[LexerActionType.MORE] = (data1, data2) => LexerMoreAction.INSTANCE; - af[LexerActionType.POP_MODE] = (data1, data2) => LexerPopModeAction.INSTANCE; - af[LexerActionType.PUSH_MODE] = (data1, data2) => new LexerPushModeAction(data1); - af[LexerActionType.SKIP] = (data1, data2) => LexerSkipAction.INSTANCE; - af[LexerActionType.TYPE] = (data1, data2) => new LexerTypeAction(data1); - this.actionFactories = af; - } - if (type>this.actionFactories.length || this.actionFactories[type] === null) { - throw("The specified lexer action type " + type + " is not valid."); - } else { - return this.actionFactories[type](data1, data2); - } - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNConfigSet.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - -function hashATNConfig(c) { - return c.hashCodeForConfigSet(); -} - -function equalATNConfigs(a, b) { - if ( a===b ) { - return true; - } else if ( a===null || b===null ) { - return false; - } else - return a.equalsForConfigSet(b); - } - -/** - * Specialized {@link Set}{@code <}{@link ATNConfig}{@code >} that can track - * info about the set, with support for combining similar configurations using a - * graph-structured stack - */ -class ATNConfigSet { - constructor(fullCtx) { - /** - * The reason that we need this is because we don't want the hash map to use - * the standard hash code and equals. We need all configurations with the - * same - * {@code (s,i,_,semctx)} to be equal. Unfortunately, this key effectively - * doubles - * the number of objects associated with ATNConfigs. The other solution is - * to - * use a hash table that lets us specify the equals/hashcode operation. - * All configs but hashed by (s, i, _, pi) not including context. Wiped out - * when we go readonly as this set becomes a DFA state - */ - this.configLookup = new HashSet(hashATNConfig, equalATNConfigs); - /** - * Indicates that this configuration set is part of a full context - * LL prediction. It will be used to determine how to merge $. With SLL - * it's a wildcard whereas it is not for LL context merge - */ - this.fullCtx = fullCtx === undefined ? true : fullCtx; - /** - * Indicates that the set of configurations is read-only. Do not - * allow any code to manipulate the set; DFA states will point at - * the sets and they must not change. This does not protect the other - * fields; in particular, conflictingAlts is set after - * we've made this readonly - */ - this.readOnly = false; - // Track the elements as they are added to the set; supports get(i)/// - this.configs = []; - - // TODO: these fields make me pretty uncomfortable but nice to pack up info - // together, saves recomputation - // TODO: can we track conflicts as they are added to save scanning configs - // later? - this.uniqueAlt = 0; - this.conflictingAlts = null; - - /** - * Used in parser and lexer. In lexer, it indicates we hit a pred - * while computing a closure operation. Don't make a DFA state from this - */ - this.hasSemanticContext = false; - this.dipsIntoOuterContext = false; - - this.cachedHashCode = -1; - } - - /** - * Adding a new config means merging contexts with existing configs for - * {@code (s, i, pi, _)}, where {@code s} is the - * {@link ATNConfig//state}, {@code i} is the {@link ATNConfig//alt}, and - * {@code pi} is the {@link ATNConfig//semanticContext}. We use - * {@code (s,i,pi)} as key. - * - *

      This method updates {@link //dipsIntoOuterContext} and - * {@link //hasSemanticContext} when necessary.

      - */ - add(config, mergeCache) { - if (mergeCache === undefined) { - mergeCache = null; - } - if (this.readOnly) { - throw "This set is readonly"; - } - if (config.semanticContext !== SemanticContext.NONE) { - this.hasSemanticContext = true; - } - if (config.reachesIntoOuterContext > 0) { - this.dipsIntoOuterContext = true; - } - const existing = this.configLookup.add(config); - if (existing === config) { - this.cachedHashCode = -1; - this.configs.push(config); // track order here - return true; - } - // a previous (s,i,pi,_), merge with it and save result - const rootIsWildcard = !this.fullCtx; - const merged = merge(existing.context, config.context, rootIsWildcard, mergeCache); - /** - * no need to check for existing.context, config.context in cache - * since only way to create new graphs is "call rule" and here. We - * cache at both places - */ - existing.reachesIntoOuterContext = Math.max( existing.reachesIntoOuterContext, config.reachesIntoOuterContext); - // make sure to preserve the precedence filter suppression during the merge - if (config.precedenceFilterSuppressed) { - existing.precedenceFilterSuppressed = true; - } - existing.context = merged; // replace context; no need to alt mapping - return true; - } - - getStates() { - const states = new HashSet(); - for (let i = 0; i < this.configs.length; i++) { - states.add(this.configs[i].state); - } - return states; - } - - getPredicates() { - const preds = []; - for (let i = 0; i < this.configs.length; i++) { - const c = this.configs[i].semanticContext; - if (c !== SemanticContext.NONE) { - preds.push(c.semanticContext); - } - } - return preds; - } - - optimizeConfigs(interpreter) { - if (this.readOnly) { - throw "This set is readonly"; - } - if (this.configLookup.length === 0) { - return; - } - for (let i = 0; i < this.configs.length; i++) { - const config = this.configs[i]; - config.context = interpreter.getCachedContext(config.context); - } - } - - addAll(coll) { - for (let i = 0; i < coll.length; i++) { - this.add(coll[i]); - } - return false; - } - - equals(other) { - return this === other || - (other instanceof ATNConfigSet && - equalArrays(this.configs, other.configs) && - this.fullCtx === other.fullCtx && - this.uniqueAlt === other.uniqueAlt && - this.conflictingAlts === other.conflictingAlts && - this.hasSemanticContext === other.hasSemanticContext && - this.dipsIntoOuterContext === other.dipsIntoOuterContext); - } - - hashCode() { - const hash = new HashCode(); - hash.update(this.configs); - return hash.finish(); - } - - updateHashCode(hash) { - if (this.readOnly) { - if (this.cachedHashCode === -1) { - this.cachedHashCode = this.hashCode(); - } - hash.update(this.cachedHashCode); - } else { - hash.update(this.hashCode()); - } - } - - isEmpty() { - return this.configs.length === 0; - } - - contains(item) { - if (this.configLookup === null) { - throw "This method is not implemented for readonly sets."; - } - return this.configLookup.contains(item); - } - - containsFast(item) { - if (this.configLookup === null) { - throw "This method is not implemented for readonly sets."; - } - return this.configLookup.containsFast(item); - } - - clear() { - if (this.readOnly) { - throw "This set is readonly"; - } - this.configs = []; - this.cachedHashCode = -1; - this.configLookup = new HashSet(); - } - - setReadonly(readOnly) { - this.readOnly = readOnly; - if (readOnly) { - this.configLookup = null; // can't mod, no need for lookup cache - } - } - - toString() { - return arrayToString(this.configs) + - (this.hasSemanticContext ? ",hasSemanticContext=" + this.hasSemanticContext : "") + - (this.uniqueAlt !== ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") + - (this.conflictingAlts !== null ? ",conflictingAlts=" + this.conflictingAlts : "") + - (this.dipsIntoOuterContext ? ",dipsIntoOuterContext" : ""); - } - - get items(){ - return this.configs; - } - - get length(){ - return this.configs.length; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/DFAState.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - -/** - * A DFA state represents a set of possible ATN configurations. - * As Aho, Sethi, Ullman p. 117 says "The DFA uses its state - * to keep track of all possible states the ATN can be in after - * reading each input symbol. That is to say, after reading - * input a1a2..an, the DFA is in a state that represents the - * subset T of the states of the ATN that are reachable from the - * ATN's start state along some path labeled a1a2..an." - * In conventional NFA→DFA conversion, therefore, the subset T - * would be a bitset representing the set of states the - * ATN could be in. We need to track the alt predicted by each - * state as well, however. More importantly, we need to maintain - * a stack of states, tracking the closure operations as they - * jump from rule to rule, emulating rule invocations (method calls). - * I have to add a stack to simulate the proper lookahead sequences for - * the underlying LL grammar from which the ATN was derived. - * - *

      I use a set of ATNConfig objects not simple states. An ATNConfig - * is both a state (ala normal conversion) and a RuleContext describing - * the chain of rules (if any) followed to arrive at that state.

      - * - *

      A DFA state may have multiple references to a particular state, - * but with different ATN contexts (with same or different alts) - * meaning that state was reached via a different set of rule invocations.

      - */ -class DFAState { - constructor(stateNumber, configs) { - if (stateNumber === null) { - stateNumber = -1; - } - if (configs === null) { - configs = new ATNConfigSet(); - } - this.stateNumber = stateNumber; - this.configs = configs; - /** - * {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1) - * {@link Token//EOF} maps to {@code edges[0]}. - */ - this.edges = null; - this.isAcceptState = false; - /** - * if accept state, what ttype do we match or alt do we predict? - * This is set to {@link ATN//INVALID_ALT_NUMBER} when {@link//predicates} - * {@code !=null} or {@link //requiresFullContext}. - */ - this.prediction = 0; - this.lexerActionExecutor = null; - /** - * Indicates that this state was created during SLL prediction that - * discovered a conflict between the configurations in the state. Future - * {@link ParserATNSimulator//execATN} invocations immediately jumped doing - * full context prediction if this field is true. - */ - this.requiresFullContext = false; - /** - * During SLL parsing, this is a list of predicates associated with the - * ATN configurations of the DFA state. When we have predicates, - * {@link //requiresFullContext} is {@code false} since full context - * prediction evaluates predicates - * on-the-fly. If this is not null, then {@link //prediction} is - * {@link ATN//INVALID_ALT_NUMBER}. - * - *

      We only use these for non-{@link //requiresFullContext} but - * conflicting states. That - * means we know from the context (it's $ or we don't dip into outer - * context) that it's an ambiguity not a conflict.

      - * - *

      This list is computed by {@link - * ParserATNSimulator//predicateDFAState}.

      - */ - this.predicates = null; - return this; - } - - /** - * Get the set of all alts mentioned by all ATN configurations in this - * DFA state. - */ - getAltSet() { - const alts = new HashSet(); - if (this.configs !== null) { - for (let i = 0; i < this.configs.length; i++) { - const c = this.configs[i]; - alts.add(c.alt); - } - } - if (alts.length === 0) { - return null; - } else { - return alts; - } - } - - /** - * Two {@link DFAState} instances are equal if their ATN configuration sets - * are the same. This method is used to see if a state already exists. - * - *

      Because the number of alternatives and number of ATN configurations are - * finite, there is a finite number of DFA states that can be processed. - * This is necessary to show that the algorithm terminates.

      - * - *

      Cannot test the DFA state numbers here because in - * {@link ParserATNSimulator//addDFAState} we need to know if any other state - * exists that has this exact set of ATN configurations. The - * {@link //stateNumber} is irrelevant.

      - */ - equals(other) { - // compare set of ATN configurations in this set with other - return this === other || - (other instanceof DFAState && - this.configs.equals(other.configs)); - } - - toString() { - let s = "" + this.stateNumber + ":" + this.configs; - if(this.isAcceptState) { - s = s + "=>"; - if (this.predicates !== null) - s = s + this.predicates; - else - s = s + this.prediction; - } - return s; - } - - hashCode() { - const hash = new HashCode(); - hash.update(this.configs); - return hash.finish(); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNSimulator.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - -class ATNSimulator { - constructor(atn, sharedContextCache) { - /** - * The context cache maps all PredictionContext objects that are == - * to a single cached copy. This cache is shared across all contexts - * in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet - * to use only cached nodes/graphs in addDFAState(). We don't want to - * fill this during closure() since there are lots of contexts that - * pop up but are not used ever again. It also greatly slows down closure(). - * - *

      This cache makes a huge difference in memory and a little bit in speed. - * For the Java grammar on java.*, it dropped the memory requirements - * at the end from 25M to 16M. We don't store any of the full context - * graphs in the DFA because they are limited to local context only, - * but apparently there's a lot of repetition there as well. We optimize - * the config contexts before storing the config set in the DFA states - * by literally rebuilding them with cached subgraphs only.

      - * - *

      I tried a cache for use during closure operations, that was - * whacked after each adaptivePredict(). It cost a little bit - * more time I think and doesn't save on the overall footprint - * so it's not worth the complexity.

      - */ - this.atn = atn; - this.sharedContextCache = sharedContextCache; - return this; - } - - getCachedContext(context) { - if (this.sharedContextCache ===null) { - return context; - } - const visited = new HashMap_HashMap(); - return getCachedPredictionContext(context, this.sharedContextCache, visited); - } -} - -// Must distinguish between missing edge and edge we know leads nowhere/// -ATNSimulator.ERROR = new DFAState(0x7FFFFFFF, new ATNConfigSet()); - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/OrderedATNConfigSet.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class OrderedATNConfigSet extends ATNConfigSet { - constructor() { - super(); - this.configLookup = new HashSet(); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerATNConfig.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class LexerATNConfig extends ATNConfig { - constructor(params, config) { - super(params, config); - - // This is the backing field for {@link //getLexerActionExecutor}. - const lexerActionExecutor = params.lexerActionExecutor || null; - this.lexerActionExecutor = lexerActionExecutor || (config!==null ? config.lexerActionExecutor : null); - this.passedThroughNonGreedyDecision = config!==null ? this.checkNonGreedyDecision(config, this.state) : false; - this.hashCodeForConfigSet = LexerATNConfig.prototype.hashCode; - this.equalsForConfigSet = LexerATNConfig.prototype.equals; - return this; - } - - updateHashCode(hash) { - hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext, this.passedThroughNonGreedyDecision, this.lexerActionExecutor); - } - - equals(other) { - return this === other || - (other instanceof LexerATNConfig && - this.passedThroughNonGreedyDecision === other.passedThroughNonGreedyDecision && - (this.lexerActionExecutor ? this.lexerActionExecutor.equals(other.lexerActionExecutor) : !other.lexerActionExecutor) && - super.equals(other)); - } - - checkNonGreedyDecision(source, target) { - return source.passedThroughNonGreedyDecision || - (target instanceof DecisionState) && target.nonGreedy; - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerIndexedCustomAction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/** - * This implementation of {@link LexerAction} is used for tracking input offsets - * for position-dependent actions within a {@link LexerActionExecutor}. - * - *

      This action is not serialized as part of the ATN, and is only required for - * position-dependent lexer actions which appear at a location other than the - * end of a rule. For more information about DFA optimizations employed for - * lexer actions, see {@link LexerActionExecutor//append} and - * {@link LexerActionExecutor//fixOffsetBeforeMatch}.

      - * - * Constructs a new indexed custom action by associating a character offset - * with a {@link LexerAction}. - * - *

      Note: This class is only required for lexer actions for which - * {@link LexerAction//isPositionDependent} returns {@code true}.

      - * - * @param offset The offset into the input {@link CharStream}, relative to - * the token start index, at which the specified lexer action should be - * executed. - * @param action The lexer action to execute at a particular offset in the - * input {@link CharStream}. - */ - - - -class LexerIndexedCustomAction extends LexerAction { - constructor(offset, action) { - super(action.actionType); - this.offset = offset; - this.action = action; - this.isPositionDependent = true; - } - - /** - *

      This method calls {@link //execute} on the result of {@link //getAction} - * using the provided {@code lexer}.

      - */ - execute(lexer) { - // assume the input stream position was properly set by the calling code - this.action.execute(lexer); - } - - updateHashCode(hash) { - hash.update(this.actionType, this.offset, this.action); - } - - equals(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerIndexedCustomAction)) { - return false; - } else { - return this.offset === other.offset && this.action === other.action; - } - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerActionExecutor.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -class LexerActionExecutor { - /** - * Represents an executor for a sequence of lexer actions which traversed during - * the matching operation of a lexer rule (token). - * - *

      The executor tracks position information for position-dependent lexer actions - * efficiently, ensuring that actions appearing only at the end of the rule do - * not cause bloating of the {@link DFA} created for the lexer.

      - */ - constructor(lexerActions) { - this.lexerActions = lexerActions === null ? [] : lexerActions; - /** - * Caches the result of {@link //hashCode} since the hash code is an element - * of the performance-critical {@link LexerATNConfig//hashCode} operation - */ - this.cachedHashCode = HashCode.hashStuff(lexerActions); // "".join([str(la) for la in - // lexerActions])) - return this; - } - - /** - * Creates a {@link LexerActionExecutor} which encodes the current offset - * for position-dependent lexer actions. - * - *

      Normally, when the executor encounters lexer actions where - * {@link LexerAction//isPositionDependent} returns {@code true}, it calls - * {@link IntStream//seek} on the input {@link CharStream} to set the input - * position to the end of the current token. This behavior provides - * for efficient DFA representation of lexer actions which appear at the end - * of a lexer rule, even when the lexer rule matches a variable number of - * characters.

      - * - *

      Prior to traversing a match transition in the ATN, the current offset - * from the token start index is assigned to all position-dependent lexer - * actions which have not already been assigned a fixed offset. By storing - * the offsets relative to the token start index, the DFA representation of - * lexer actions which appear in the middle of tokens remains efficient due - * to sharing among tokens of the same length, regardless of their absolute - * position in the input stream.

      - * - *

      If the current executor already has offsets assigned to all - * position-dependent lexer actions, the method returns {@code this}.

      - * - * @param offset The current offset to assign to all position-dependent - * lexer actions which do not already have offsets assigned. - * - * @return {LexerActionExecutor} A {@link LexerActionExecutor} which stores input stream offsets - * for all position-dependent lexer actions. - */ - fixOffsetBeforeMatch(offset) { - let updatedLexerActions = null; - for (let i = 0; i < this.lexerActions.length; i++) { - if (this.lexerActions[i].isPositionDependent && - !(this.lexerActions[i] instanceof LexerIndexedCustomAction)) { - if (updatedLexerActions === null) { - updatedLexerActions = this.lexerActions.concat([]); - } - updatedLexerActions[i] = new LexerIndexedCustomAction(offset, - this.lexerActions[i]); - } - } - if (updatedLexerActions === null) { - return this; - } else { - return new LexerActionExecutor(updatedLexerActions); - } - } - - /** - * Execute the actions encapsulated by this executor within the context of a - * particular {@link Lexer}. - * - *

      This method calls {@link IntStream//seek} to set the position of the - * {@code input} {@link CharStream} prior to calling - * {@link LexerAction//execute} on a position-dependent action. Before the - * method returns, the input position will be restored to the same position - * it was in when the method was invoked.

      - * - * @param lexer The lexer instance. - * @param input The input stream which is the source for the current token. - * When this method is called, the current {@link IntStream//index} for - * {@code input} should be the start of the following token, i.e. 1 - * character past the end of the current token. - * @param startIndex The token start index. This value may be passed to - * {@link IntStream//seek} to set the {@code input} position to the beginning - * of the token. - */ - execute(lexer, input, startIndex) { - let requiresSeek = false; - const stopIndex = input.index; - try { - for (let i = 0; i < this.lexerActions.length; i++) { - let lexerAction = this.lexerActions[i]; - if (lexerAction instanceof LexerIndexedCustomAction) { - const offset = lexerAction.offset; - input.seek(startIndex + offset); - lexerAction = lexerAction.action; - requiresSeek = (startIndex + offset) !== stopIndex; - } else if (lexerAction.isPositionDependent) { - input.seek(stopIndex); - requiresSeek = false; - } - lexerAction.execute(lexer); - } - } finally { - if (requiresSeek) { - input.seek(stopIndex); - } - } - } - - hashCode() { - return this.cachedHashCode; - } - - updateHashCode(hash) { - hash.update(this.cachedHashCode); - } - - equals(other) { - if (this === other) { - return true; - } else if (!(other instanceof LexerActionExecutor)) { - return false; - } else if (this.cachedHashCode != other.cachedHashCode) { - return false; - } else if (this.lexerActions.length != other.lexerActions.length) { - return false; - } else { - const numActions = this.lexerActions.length - for (let idx = 0; idx < numActions; ++idx) { - if (!this.lexerActions[idx].equals(other.lexerActions[idx])) { - return false; - } - } - return true; - } - } - - /** - * Creates a {@link LexerActionExecutor} which executes the actions for - * the input {@code lexerActionExecutor} followed by a specified - * {@code lexerAction}. - * - * @param lexerActionExecutor The executor for actions already traversed by - * the lexer while matching a token within a particular - * {@link LexerATNConfig}. If this is {@code null}, the method behaves as - * though it were an empty executor. - * @param lexerAction The lexer action to execute after the actions - * specified in {@code lexerActionExecutor}. - * - * @return {LexerActionExecutor} A {@link LexerActionExecutor} for executing the combine actions - * of {@code lexerActionExecutor} and {@code lexerAction}. - */ - static append(lexerActionExecutor, lexerAction) { - if (lexerActionExecutor === null) { - return new LexerActionExecutor([ lexerAction ]); - } - const lexerActions = lexerActionExecutor.lexerActions.concat([ lexerAction ]); - return new LexerActionExecutor(lexerActions); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerATNSimulator.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - - - - - - - -function resetSimState(sim) { - sim.index = -1; - sim.line = 0; - sim.column = -1; - sim.dfaState = null; -} - -class SimState { - constructor() { - resetSimState(this); - } - - reset() { - resetSimState(this); - } -} - -class LexerATNSimulator extends ATNSimulator { - /** - * When we hit an accept state in either the DFA or the ATN, we - * have to notify the character stream to start buffering characters - * via {@link IntStream//mark} and record the current state. The current sim state - * includes the current index into the input, the current line, - * and current character position in that line. Note that the Lexer is - * tracking the starting line and characterization of the token. These - * variables track the "state" of the simulator when it hits an accept state. - * - *

      We track these variables separately for the DFA and ATN simulation - * because the DFA simulation often has to fail over to the ATN - * simulation. If the ATN simulation fails, we need the DFA to fall - * back to its previously accepted state, if any. If the ATN succeeds, - * then the ATN does the accept and the DFA simulator that invoked it - * can simply return the predicted token type.

      - */ - constructor(recog, atn, decisionToDFA, sharedContextCache) { - super(atn, sharedContextCache); - this.decisionToDFA = decisionToDFA; - this.recog = recog; - /** - * The current token's starting index into the character stream. - * Shared across DFA to ATN simulation in case the ATN fails and the - * DFA did not have a previous accept state. In this case, we use the - * ATN-generated exception object - */ - this.startIndex = -1; - // line number 1..n within the input/// - this.line = 1; - /** - * The index of the character relative to the beginning of the line - * 0..n-1 - */ - this.column = 0; - this.mode = Lexer.DEFAULT_MODE; - /** - * Used during DFA/ATN exec to record the most recent accept configuration - * info - */ - this.prevAccept = new SimState(); - } - - copyState(simulator) { - this.column = simulator.column; - this.line = simulator.line; - this.mode = simulator.mode; - this.startIndex = simulator.startIndex; - } - - match(input, mode) { - this.mode = mode; - const mark = input.mark(); - try { - this.startIndex = input.index; - this.prevAccept.reset(); - const dfa = this.decisionToDFA[mode]; - if (dfa.s0 === null) { - return this.matchATN(input); - } else { - return this.execATN(input, dfa.s0); - } - } finally { - input.release(mark); - } - } - - reset() { - this.prevAccept.reset(); - this.startIndex = -1; - this.line = 1; - this.column = 0; - this.mode = Lexer.DEFAULT_MODE; - } - - matchATN(input) { - const startState = this.atn.modeToStartState[this.mode]; - - if (LexerATNSimulator.debug) { - console.log("matchATN mode " + this.mode + " start: " + startState); - } - const old_mode = this.mode; - const s0_closure = this.computeStartState(input, startState); - const suppressEdge = s0_closure.hasSemanticContext; - s0_closure.hasSemanticContext = false; - - const next = this.addDFAState(s0_closure); - if (!suppressEdge) { - this.decisionToDFA[this.mode].s0 = next; - } - - const predict = this.execATN(input, next); - - if (LexerATNSimulator.debug) { - console.log("DFA after matchATN: " + this.decisionToDFA[old_mode].toLexerString()); - } - return predict; - } - - execATN(input, ds0) { - if (LexerATNSimulator.debug) { - console.log("start state closure=" + ds0.configs); - } - if (ds0.isAcceptState) { - // allow zero-length tokens - this.captureSimState(this.prevAccept, input, ds0); - } - let t = input.LA(1); - let s = ds0; // s is current/from DFA state - - for (; ;) { // while more work - if (LexerATNSimulator.debug) { - console.log("execATN loop starting closure: " + s.configs); - } - - /** - * As we move src->trg, src->trg, we keep track of the previous trg to - * avoid looking up the DFA state again, which is expensive. - * If the previous target was already part of the DFA, we might - * be able to avoid doing a reach operation upon t. If s!=null, - * it means that semantic predicates didn't prevent us from - * creating a DFA state. Once we know s!=null, we check to see if - * the DFA state has an edge already for t. If so, we can just reuse - * it's configuration set; there's no point in re-computing it. - * This is kind of like doing DFA simulation within the ATN - * simulation because DFA simulation is really just a way to avoid - * computing reach/closure sets. Technically, once we know that - * we have a previously added DFA state, we could jump over to - * the DFA simulator. But, that would mean popping back and forth - * a lot and making things more complicated algorithmically. - * This optimization makes a lot of sense for loops within DFA. - * A character will take us back to an existing DFA state - * that already has lots of edges out of it. e.g., .* in comments. - * print("Target for:" + str(s) + " and:" + str(t)) - */ - let target = this.getExistingTargetState(s, t); - // print("Existing:" + str(target)) - if (target === null) { - target = this.computeTargetState(input, s, t); - // print("Computed:" + str(target)) - } - if (target === ATNSimulator.ERROR) { - break; - } - // If this is a consumable input element, make sure to consume before - // capturing the accept state so the input index, line, and char - // position accurately reflect the state of the interpreter at the - // end of the token. - if (t !== Token.EOF) { - this.consume(input); - } - if (target.isAcceptState) { - this.captureSimState(this.prevAccept, input, target); - if (t === Token.EOF) { - break; - } - } - t = input.LA(1); - s = target; // flip; current DFA target becomes new src/from state - } - return this.failOrAccept(this.prevAccept, input, s.configs, t); - } - - /** - * Get an existing target state for an edge in the DFA. If the target state - * for the edge has not yet been computed or is otherwise not available, - * this method returns {@code null}. - * - * @param s The current DFA state - * @param t The next input symbol - * @return The existing target DFA state for the given input symbol - * {@code t}, or {@code null} if the target state for this edge is not - * already cached - */ - getExistingTargetState(s, t) { - if (s.edges === null || t < LexerATNSimulator.MIN_DFA_EDGE || t > LexerATNSimulator.MAX_DFA_EDGE) { - return null; - } - - let target = s.edges[t - LexerATNSimulator.MIN_DFA_EDGE]; - if (target === undefined) { - target = null; - } - if (LexerATNSimulator.debug && target !== null) { - console.log("reuse state " + s.stateNumber + " edge to " + target.stateNumber); - } - return target; - } - - /** - * Compute a target state for an edge in the DFA, and attempt to add the - * computed state and corresponding edge to the DFA. - * - * @param input The input stream - * @param s The current DFA state - * @param t The next input symbol - * - * @return The computed target DFA state for the given input symbol - * {@code t}. If {@code t} does not lead to a valid DFA state, this method - * returns {@link //ERROR}. - */ - computeTargetState(input, s, t) { - const reach = new OrderedATNConfigSet(); - // if we don't find an existing DFA state - // Fill reach starting from closure, following t transitions - this.getReachableConfigSet(input, s.configs, reach, t); - - if (reach.items.length === 0) { // we got nowhere on t from s - if (!reach.hasSemanticContext) { - // we got nowhere on t, don't throw out this knowledge; it'd - // cause a failover from DFA later. - this.addDFAEdge(s, t, ATNSimulator.ERROR); - } - // stop when we can't match any more char - return ATNSimulator.ERROR; - } - // Add an edge from s to target DFA found/created for reach - return this.addDFAEdge(s, t, null, reach); - } - - failOrAccept(prevAccept, input, reach, t) { - if (this.prevAccept.dfaState !== null) { - const lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor; - this.accept(input, lexerActionExecutor, this.startIndex, - prevAccept.index, prevAccept.line, prevAccept.column); - return prevAccept.dfaState.prediction; - } else { - // if no accept and EOF is first char, return EOF - if (t === Token.EOF && input.index === this.startIndex) { - return Token.EOF; - } - throw new LexerNoViableAltException(this.recog, input, this.startIndex, reach); - } - } - - /** - * Given a starting configuration set, figure out all ATN configurations - * we can reach upon input {@code t}. Parameter {@code reach} is a return - * parameter. - */ - getReachableConfigSet(input, closure, reach, t) { - // this is used to skip processing for configs which have a lower priority - // than a config that already reached an accept state for the same rule - let skipAlt = ATN.INVALID_ALT_NUMBER; - for (let i = 0; i < closure.items.length; i++) { - const cfg = closure.items[i]; - const currentAltReachedAcceptState = (cfg.alt === skipAlt); - if (currentAltReachedAcceptState && cfg.passedThroughNonGreedyDecision) { - continue; - } - if (LexerATNSimulator.debug) { - console.log("testing %s at %s\n", this.getTokenName(t), cfg - .toString(this.recog, true)); - } - for (let j = 0; j < cfg.state.transitions.length; j++) { - const trans = cfg.state.transitions[j]; // for each transition - const target = this.getReachableTarget(trans, t); - if (target !== null) { - let lexerActionExecutor = cfg.lexerActionExecutor; - if (lexerActionExecutor !== null) { - lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index - this.startIndex); - } - const treatEofAsEpsilon = (t === Token.EOF); - const config = new LexerATNConfig({state: target, lexerActionExecutor: lexerActionExecutor}, cfg); - if (this.closure(input, config, reach, - currentAltReachedAcceptState, true, treatEofAsEpsilon)) { - // any remaining configs for this alt have a lower priority - // than the one that just reached an accept state. - skipAlt = cfg.alt; - } - } - } - } - } - - accept(input, lexerActionExecutor, startIndex, index, line, charPos) { - if (LexerATNSimulator.debug) { - console.log("ACTION %s\n", lexerActionExecutor); - } - // seek to after last char in token - input.seek(index); - this.line = line; - this.column = charPos; - if (lexerActionExecutor !== null && this.recog !== null) { - lexerActionExecutor.execute(this.recog, input, startIndex); - } - } - - getReachableTarget(trans, t) { - if (trans.matches(t, 0, Lexer.MAX_CHAR_VALUE)) { - return trans.target; - } else { - return null; - } - } - - computeStartState(input, p) { - const initialContext = PredictionContext.EMPTY; - const configs = new OrderedATNConfigSet(); - for (let i = 0; i < p.transitions.length; i++) { - const target = p.transitions[i].target; - const cfg = new LexerATNConfig({state: target, alt: i + 1, context: initialContext}, null); - this.closure(input, cfg, configs, false, false, false); - } - return configs; - } - - /** - * Since the alternatives within any lexer decision are ordered by - * preference, this method stops pursuing the closure as soon as an accept - * state is reached. After the first accept state is reached by depth-first - * search from {@code config}, all other (potentially reachable) states for - * this rule would have a lower priority. - * - * @return {Boolean} {@code true} if an accept state is reached, otherwise - * {@code false}. - */ - closure(input, config, configs, - currentAltReachedAcceptState, speculative, treatEofAsEpsilon) { - let cfg = null; - if (LexerATNSimulator.debug) { - console.log("closure(" + config.toString(this.recog, true) + ")"); - } - if (config.state instanceof RuleStopState) { - if (LexerATNSimulator.debug) { - if (this.recog !== null) { - console.log("closure at %s rule stop %s\n", this.recog.ruleNames[config.state.ruleIndex], config); - } else { - console.log("closure at rule stop %s\n", config); - } - } - if (config.context === null || config.context.hasEmptyPath()) { - if (config.context === null || config.context.isEmpty()) { - configs.add(config); - return true; - } else { - configs.add(new LexerATNConfig({state: config.state, context: PredictionContext.EMPTY}, config)); - currentAltReachedAcceptState = true; - } - } - if (config.context !== null && !config.context.isEmpty()) { - for (let i = 0; i < config.context.length; i++) { - if (config.context.getReturnState(i) !== PredictionContext.EMPTY_RETURN_STATE) { - const newContext = config.context.getParent(i); // "pop" return state - const returnState = this.atn.states[config.context.getReturnState(i)]; - cfg = new LexerATNConfig({state: returnState, context: newContext}, config); - currentAltReachedAcceptState = this.closure(input, cfg, - configs, currentAltReachedAcceptState, speculative, - treatEofAsEpsilon); - } - } - } - return currentAltReachedAcceptState; - } - // optimization - if (!config.state.epsilonOnlyTransitions) { - if (!currentAltReachedAcceptState || !config.passedThroughNonGreedyDecision) { - configs.add(config); - } - } - for (let j = 0; j < config.state.transitions.length; j++) { - const trans = config.state.transitions[j]; - cfg = this.getEpsilonTarget(input, config, trans, configs, speculative, treatEofAsEpsilon); - if (cfg !== null) { - currentAltReachedAcceptState = this.closure(input, cfg, configs, - currentAltReachedAcceptState, speculative, treatEofAsEpsilon); - } - } - return currentAltReachedAcceptState; - } - - // side-effect: can alter configs.hasSemanticContext - getEpsilonTarget(input, config, trans, - configs, speculative, treatEofAsEpsilon) { - let cfg = null; - if (trans.serializationType === Transition.RULE) { - const newContext = SingletonPredictionContext.create(config.context, trans.followState.stateNumber); - cfg = new LexerATNConfig({state: trans.target, context: newContext}, config); - } else if (trans.serializationType === Transition.PRECEDENCE) { - throw "Precedence predicates are not supported in lexers."; - } else if (trans.serializationType === Transition.PREDICATE) { - // Track traversing semantic predicates. If we traverse, - // we cannot add a DFA state for this "reach" computation - // because the DFA would not test the predicate again in the - // future. Rather than creating collections of semantic predicates - // like v3 and testing them on prediction, v4 will test them on the - // fly all the time using the ATN not the DFA. This is slower but - // semantically it's not used that often. One of the key elements to - // this predicate mechanism is not adding DFA states that see - // predicates immediately afterwards in the ATN. For example, - - // a : ID {p1}? | ID {p2}? ; - - // should create the start state for rule 'a' (to save start state - // competition), but should not create target of ID state. The - // collection of ATN states the following ID references includes - // states reached by traversing predicates. Since this is when we - // test them, we cannot cash the DFA state target of ID. - - if (LexerATNSimulator.debug) { - console.log("EVAL rule " + trans.ruleIndex + ":" + trans.predIndex); - } - configs.hasSemanticContext = true; - if (this.evaluatePredicate(input, trans.ruleIndex, trans.predIndex, speculative)) { - cfg = new LexerATNConfig({state: trans.target}, config); - } - } else if (trans.serializationType === Transition.ACTION) { - if (config.context === null || config.context.hasEmptyPath()) { - // execute actions anywhere in the start rule for a token. - // - // TODO: if the entry rule is invoked recursively, some - // actions may be executed during the recursive call. The - // problem can appear when hasEmptyPath() is true but - // isEmpty() is false. In this case, the config needs to be - // split into two contexts - one with just the empty path - // and another with everything but the empty path. - // Unfortunately, the current algorithm does not allow - // getEpsilonTarget to return two configurations, so - // additional modifications are needed before we can support - // the split operation. - const lexerActionExecutor = LexerActionExecutor.append(config.lexerActionExecutor, - this.atn.lexerActions[trans.actionIndex]); - cfg = new LexerATNConfig({state: trans.target, lexerActionExecutor: lexerActionExecutor}, config); - } else { - // ignore actions in referenced rules - cfg = new LexerATNConfig({state: trans.target}, config); - } - } else if (trans.serializationType === Transition.EPSILON) { - cfg = new LexerATNConfig({state: trans.target}, config); - } else if (trans.serializationType === Transition.ATOM || - trans.serializationType === Transition.RANGE || - trans.serializationType === Transition.SET) { - if (treatEofAsEpsilon) { - if (trans.matches(Token.EOF, 0, Lexer.MAX_CHAR_VALUE)) { - cfg = new LexerATNConfig({state: trans.target}, config); - } - } - } - return cfg; - } - - /** - * Evaluate a predicate specified in the lexer. - * - *

      If {@code speculative} is {@code true}, this method was called before - * {@link //consume} for the matched character. This method should call - * {@link //consume} before evaluating the predicate to ensure position - * sensitive values, including {@link Lexer//getText}, {@link Lexer//getLine}, - * and {@link Lexer//getcolumn}, properly reflect the current - * lexer state. This method should restore {@code input} and the simulator - * to the original state before returning (i.e. undo the actions made by the - * call to {@link //consume}.

      - * - * @param input The input stream. - * @param ruleIndex The rule containing the predicate. - * @param predIndex The index of the predicate within the rule. - * @param speculative {@code true} if the current index in {@code input} is - * one character before the predicate's location. - * - * @return {@code true} if the specified predicate evaluates to - * {@code true}. - */ - evaluatePredicate(input, ruleIndex, - predIndex, speculative) { - // assume true if no recognizer was provided - if (this.recog === null) { - return true; - } - if (!speculative) { - return this.recog.sempred(null, ruleIndex, predIndex); - } - const savedcolumn = this.column; - const savedLine = this.line; - const index = input.index; - const marker = input.mark(); - try { - this.consume(input); - return this.recog.sempred(null, ruleIndex, predIndex); - } finally { - this.column = savedcolumn; - this.line = savedLine; - input.seek(index); - input.release(marker); - } - } - - captureSimState(settings, input, dfaState) { - settings.index = input.index; - settings.line = this.line; - settings.column = this.column; - settings.dfaState = dfaState; - } - - addDFAEdge(from_, tk, to, cfgs) { - if (to === undefined) { - to = null; - } - if (cfgs === undefined) { - cfgs = null; - } - if (to === null && cfgs !== null) { - // leading to this call, ATNConfigSet.hasSemanticContext is used as a - // marker indicating dynamic predicate evaluation makes this edge - // dependent on the specific input sequence, so the static edge in the - // DFA should be omitted. The target DFAState is still created since - // execATN has the ability to resynchronize with the DFA state cache - // following the predicate evaluation step. - // - // TJP notes: next time through the DFA, we see a pred again and eval. - // If that gets us to a previously created (but dangling) DFA - // state, we can continue in pure DFA mode from there. - // / - const suppressEdge = cfgs.hasSemanticContext; - cfgs.hasSemanticContext = false; - - to = this.addDFAState(cfgs); - - if (suppressEdge) { - return to; - } - } - // add the edge - if (tk < LexerATNSimulator.MIN_DFA_EDGE || tk > LexerATNSimulator.MAX_DFA_EDGE) { - // Only track edges within the DFA bounds - return to; - } - if (LexerATNSimulator.debug) { - console.log("EDGE " + from_ + " -> " + to + " upon " + tk); - } - if (from_.edges === null) { - // make room for tokens 1..n and -1 masquerading as index 0 - from_.edges = []; - } - from_.edges[tk - LexerATNSimulator.MIN_DFA_EDGE] = to; // connect - - return to; - } - - /** - * Add a new DFA state if there isn't one with this set of - * configurations already. This method also detects the first - * configuration containing an ATN rule stop state. Later, when - * traversing the DFA, we will know which rule to accept. - */ - addDFAState(configs) { - const proposed = new DFAState(null, configs); - let firstConfigWithRuleStopState = null; - for (let i = 0; i < configs.items.length; i++) { - const cfg = configs.items[i]; - if (cfg.state instanceof RuleStopState) { - firstConfigWithRuleStopState = cfg; - break; - } - } - if (firstConfigWithRuleStopState !== null) { - proposed.isAcceptState = true; - proposed.lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor; - proposed.prediction = this.atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex]; - } - const dfa = this.decisionToDFA[this.mode]; - const existing = dfa.states.get(proposed); - if (existing !== null) { - return existing; - } - const newState = proposed; - newState.stateNumber = dfa.states.length; - configs.setReadonly(true); - newState.configs = configs; - dfa.states.add(newState); - return newState; - } - - getDFA(mode) { - return this.decisionToDFA[mode]; - } - -// Get the text matched so far for the current token. - getText(input) { - // index is first lookahead char, don't include. - return input.getText(this.startIndex, input.index - 1); - } - - consume(input) { - const curChar = input.LA(1); - if (curChar === "\n".charCodeAt(0)) { - this.line += 1; - this.column = 0; - } else { - this.column += 1; - } - input.consume(); - } - - getTokenName(tt) { - if (tt === -1) { - return "EOF"; - } else { - return "'" + String.fromCharCode(tt) + "'"; - } - } -} - -LexerATNSimulator.debug = false; -LexerATNSimulator.dfa_debug = false; - -LexerATNSimulator.MIN_DFA_EDGE = 0; -LexerATNSimulator.MAX_DFA_EDGE = 127; // forces unicode to stay in ATN - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/PredPrediction.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/** - * Map a predicate to a predicted alternative. - */ -class PredPrediction { - constructor(pred, alt) { - this.alt = alt; - this.pred = pred; - } - - toString() { - return "(" + this.pred + ", " + this.alt + ")"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/AltDict.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -class AltDict { - - constructor() { - this.data = {}; - } - - get(key) { - return this.data["k-" + key] || null; - } - - set(key, value) { - this.data["k-" + key] = value; - } - - values() { - return Object.keys(this.data).filter(key => key.startsWith("k-")).map(key => this.data[key], this); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/PredictionMode.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - - - -/** - * This enumeration defines the prediction modes available in ANTLR 4 along with - * utility methods for analyzing configuration sets for conflicts and/or - * ambiguities. - */ -const PredictionMode = { - /** - * The SLL(*) prediction mode. This prediction mode ignores the current - * parser context when making predictions. This is the fastest prediction - * mode, and provides correct results for many grammars. This prediction - * mode is more powerful than the prediction mode provided by ANTLR 3, but - * may result in syntax errors for grammar and input combinations which are - * not SLL. - * - *

      - * When using this prediction mode, the parser will either return a correct - * parse tree (i.e. the same parse tree that would be returned with the - * {@link //LL} prediction mode), or it will report a syntax error. If a - * syntax error is encountered when using the {@link //SLL} prediction mode, - * it may be due to either an actual syntax error in the input or indicate - * that the particular combination of grammar and input requires the more - * powerful {@link //LL} prediction abilities to complete successfully.

      - * - *

      - * This prediction mode does not provide any guarantees for prediction - * behavior for syntactically-incorrect inputs.

      - */ - SLL: 0, - - /** - * The LL(*) prediction mode. This prediction mode allows the current parser - * context to be used for resolving SLL conflicts that occur during - * prediction. This is the fastest prediction mode that guarantees correct - * parse results for all combinations of grammars with syntactically correct - * inputs. - * - *

      - * When using this prediction mode, the parser will make correct decisions - * for all syntactically-correct grammar and input combinations. However, in - * cases where the grammar is truly ambiguous this prediction mode might not - * report a precise answer for exactly which alternatives are - * ambiguous.

      - * - *

      - * This prediction mode does not provide any guarantees for prediction - * behavior for syntactically-incorrect inputs.

      - */ - LL: 1, - - /** - * - * The LL(*) prediction mode with exact ambiguity detection. In addition to - * the correctness guarantees provided by the {@link //LL} prediction mode, - * this prediction mode instructs the prediction algorithm to determine the - * complete and exact set of ambiguous alternatives for every ambiguous - * decision encountered while parsing. - * - *

      - * This prediction mode may be used for diagnosing ambiguities during - * grammar development. Due to the performance overhead of calculating sets - * of ambiguous alternatives, this prediction mode should be avoided when - * the exact results are not necessary.

      - * - *

      - * This prediction mode does not provide any guarantees for prediction - * behavior for syntactically-incorrect inputs.

      - */ - LL_EXACT_AMBIG_DETECTION: 2, - - /** - * - * Computes the SLL prediction termination condition. - * - *

      - * This method computes the SLL prediction termination condition for both of - * the following cases.

      - * - *
        - *
      • The usual SLL+LL fallback upon SLL conflict
      • - *
      • Pure SLL without LL fallback
      • - *
      - * - *

      COMBINED SLL+LL PARSING

      - * - *

      When LL-fallback is enabled upon SLL conflict, correct predictions are - * ensured regardless of how the termination condition is computed by this - * method. Due to the substantially higher cost of LL prediction, the - * prediction should only fall back to LL when the additional lookahead - * cannot lead to a unique SLL prediction.

      - * - *

      Assuming combined SLL+LL parsing, an SLL configuration set with only - * conflicting subsets should fall back to full LL, even if the - * configuration sets don't resolve to the same alternative (e.g. - * {@code {1,2}} and {@code {3,4}}. If there is at least one non-conflicting - * configuration, SLL could continue with the hopes that more lookahead will - * resolve via one of those non-conflicting configurations.

      - * - *

      Here's the prediction termination rule them: SLL (for SLL+LL parsing) - * stops when it sees only conflicting configuration subsets. In contrast, - * full LL keeps going when there is uncertainty.

      - * - *

      HEURISTIC

      - * - *

      As a heuristic, we stop prediction when we see any conflicting subset - * unless we see a state that only has one alternative associated with it. - * The single-alt-state thing lets prediction continue upon rules like - * (otherwise, it would admit defeat too soon):

      - * - *

      {@code [12|1|[], 6|2|[], 12|2|[]]. s : (ID | ID ID?) ';' ;}

      - * - *

      When the ATN simulation reaches the state before {@code ';'}, it has a - * DFA state that looks like: {@code [12|1|[], 6|2|[], 12|2|[]]}. Naturally - * {@code 12|1|[]} and {@code 12|2|[]} conflict, but we cannot stop - * processing this node because alternative to has another way to continue, - * via {@code [6|2|[]]}.

      - * - *

      It also let's us continue for this rule:

      - * - *

      {@code [1|1|[], 1|2|[], 8|3|[]] a : A | A | A B ;}

      - * - *

      After matching input A, we reach the stop state for rule A, state 1. - * State 8 is the state right before B. Clearly alternatives 1 and 2 - * conflict and no amount of further lookahead will separate the two. - * However, alternative 3 will be able to continue and so we do not stop - * working on this state. In the previous example, we're concerned with - * states associated with the conflicting alternatives. Here alt 3 is not - * associated with the conflicting configs, but since we can continue - * looking for input reasonably, don't declare the state done.

      - * - *

      PURE SLL PARSING

      - * - *

      To handle pure SLL parsing, all we have to do is make sure that we - * combine stack contexts for configurations that differ only by semantic - * predicate. From there, we can do the usual SLL termination heuristic.

      - * - *

      PREDICATES IN SLL+LL PARSING

      - * - *

      SLL decisions don't evaluate predicates until after they reach DFA stop - * states because they need to create the DFA cache that works in all - * semantic situations. In contrast, full LL evaluates predicates collected - * during start state computation so it can ignore predicates thereafter. - * This means that SLL termination detection can totally ignore semantic - * predicates.

      - * - *

      Implementation-wise, {@link ATNConfigSet} combines stack contexts but not - * semantic predicate contexts so we might see two configurations like the - * following.

      - * - *

      {@code (s, 1, x, {}), (s, 1, x', {p})}

      - * - *

      Before testing these configurations against others, we have to merge - * {@code x} and {@code x'} (without modifying the existing configurations). - * For example, we test {@code (x+x')==x''} when looking for conflicts in - * the following configurations.

      - * - *

      {@code (s, 1, x, {}), (s, 1, x', {p}), (s, 2, x'', {})}

      - * - *

      If the configuration set has predicates (as indicated by - * {@link ATNConfigSet//hasSemanticContext}), this algorithm makes a copy of - * the configurations to strip out all of the predicates so that a standard - * {@link ATNConfigSet} will merge everything ignoring predicates.

      - */ - hasSLLConflictTerminatingPrediction: function( mode, configs) { - // Configs in rule stop states indicate reaching the end of the decision - // rule (local context) or end of start rule (full context). If all - // configs meet this condition, then none of the configurations is able - // to match additional input so we terminate prediction. - // - if (PredictionMode.allConfigsInRuleStopStates(configs)) { - return true; - } - // pure SLL mode parsing - if (mode === PredictionMode.SLL) { - // Don't bother with combining configs from different semantic - // contexts if we can fail over to full LL; costs more time - // since we'll often fail over anyway. - if (configs.hasSemanticContext) { - // dup configs, tossing out semantic predicates - const dup = new ATNConfigSet(); - for(let i=0;iCan we stop looking ahead during ATN simulation or is there some - * uncertainty as to which alternative we will ultimately pick, after - * consuming more input? Even if there are partial conflicts, we might know - * that everything is going to resolve to the same minimum alternative. That - * means we can stop since no more lookahead will change that fact. On the - * other hand, there might be multiple conflicts that resolve to different - * minimums. That means we need more look ahead to decide which of those - * alternatives we should predict.

      - * - *

      The basic idea is to split the set of configurations {@code C}, into - * conflicting subsets {@code (s, _, ctx, _)} and singleton subsets with - * non-conflicting configurations. Two configurations conflict if they have - * identical {@link ATNConfig//state} and {@link ATNConfig//context} values - * but different {@link ATNConfig//alt} value, e.g. {@code (s, i, ctx, _)} - * and {@code (s, j, ctx, _)} for {@code i!=j}.

      - * - *

      Reduce these configuration subsets to the set of possible alternatives. - * You can compute the alternative subsets in one pass as follows:

      - * - *

      {@code A_s,ctx = {i | (s, i, ctx, _)}} for each configuration in - * {@code C} holding {@code s} and {@code ctx} fixed.

      - * - *

      Or in pseudo-code, for each configuration {@code c} in {@code C}:

      - * - *
      -     * map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not
      -     * alt and not pred
      -     * 
      - * - *

      The values in {@code map} are the set of {@code A_s,ctx} sets.

      - * - *

      If {@code |A_s,ctx|=1} then there is no conflict associated with - * {@code s} and {@code ctx}.

      - * - *

      Reduce the subsets to singletons by choosing a minimum of each subset. If - * the union of these alternative subsets is a singleton, then no amount of - * more lookahead will help us. We will always pick that alternative. If, - * however, there is more than one alternative, then we are uncertain which - * alternative to predict and must continue looking for resolution. We may - * or may not discover an ambiguity in the future, even if there are no - * conflicting subsets this round.

      - * - *

      The biggest sin is to terminate early because it means we've made a - * decision but were uncertain as to the eventual outcome. We haven't used - * enough lookahead. On the other hand, announcing a conflict too late is no - * big deal; you will still have the conflict. It's just inefficient. It - * might even look until the end of file.

      - * - *

      No special consideration for semantic predicates is required because - * predicates are evaluated on-the-fly for full LL prediction, ensuring that - * no configuration contains a semantic context during the termination - * check.

      - * - *

      CONFLICTING CONFIGS

      - * - *

      Two configurations {@code (s, i, x)} and {@code (s, j, x')}, conflict - * when {@code i!=j} but {@code x=x'}. Because we merge all - * {@code (s, i, _)} configurations together, that means that there are at - * most {@code n} configurations associated with state {@code s} for - * {@code n} possible alternatives in the decision. The merged stacks - * complicate the comparison of configuration contexts {@code x} and - * {@code x'}. Sam checks to see if one is a subset of the other by calling - * merge and checking to see if the merged result is either {@code x} or - * {@code x'}. If the {@code x} associated with lowest alternative {@code i} - * is the superset, then {@code i} is the only possible prediction since the - * others resolve to {@code min(i)} as well. However, if {@code x} is - * associated with {@code j>i} then at least one stack configuration for - * {@code j} is not in conflict with alternative {@code i}. The algorithm - * should keep going, looking for more lookahead due to the uncertainty.

      - * - *

      For simplicity, I'm doing a equality check between {@code x} and - * {@code x'} that lets the algorithm continue to consume lookahead longer - * than necessary. The reason I like the equality is of course the - * simplicity but also because that is the test you need to detect the - * alternatives that are actually in conflict.

      - * - *

      CONTINUE/STOP RULE

      - * - *

      Continue if union of resolved alternative sets from non-conflicting and - * conflicting alternative subsets has more than one alternative. We are - * uncertain about which alternative to predict.

      - * - *

      The complete set of alternatives, {@code [i for (_,i,_)]}, tells us which - * alternatives are still in the running for the amount of input we've - * consumed at this point. The conflicting sets let us to strip away - * configurations that won't lead to more states because we resolve - * conflicts to the configuration with a minimum alternate for the - * conflicting set.

      - * - *

      CASES

      - * - *
        - * - *
      • no conflicts and more than 1 alternative in set => continue
      • - * - *
      • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s, 3, z)}, - * {@code (s', 1, y)}, {@code (s', 2, y)} yields non-conflicting set - * {@code {3}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} = - * {@code {1,3}} => continue - *
      • - * - *
      • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)}, - * {@code (s', 2, y)}, {@code (s'', 1, z)} yields non-conflicting set - * {@code {1}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} = - * {@code {1}} => stop and predict 1
      • - * - *
      • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)}, - * {@code (s', 2, y)} yields conflicting, reduced sets {@code {1}} U - * {@code {1}} = {@code {1}} => stop and predict 1, can announce - * ambiguity {@code {1,2}}
      • - * - *
      • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 2, y)}, - * {@code (s', 3, y)} yields conflicting, reduced sets {@code {1}} U - * {@code {2}} = {@code {1,2}} => continue
      • - * - *
      • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 3, y)}, - * {@code (s', 4, y)} yields conflicting, reduced sets {@code {1}} U - * {@code {3}} = {@code {1,3}} => continue
      • - * - *
      - * - *

      EXACT AMBIGUITY DETECTION

      - * - *

      If all states report the same conflicting set of alternatives, then we - * know we have the exact ambiguity set.

      - * - *

      |A_i|>1 and - * A_i = A_j for all i, j.

      - * - *

      In other words, we continue examining lookahead until all {@code A_i} - * have more than one alternative and all {@code A_i} are the same. If - * {@code A={{1,2}, {1,3}}}, then regular LL prediction would terminate - * because the resolved set is {@code {1}}. To determine what the real - * ambiguity is, we have to know whether the ambiguity is between one and - * two or one and three so we keep going. We can only stop prediction when - * we need exact ambiguity detection when the sets look like - * {@code A={{1,2}}} or {@code {{1,2},{1,2}}}, etc...

      - */ - resolvesToJustOneViableAlt: function(altsets) { - return PredictionMode.getSingleViableAlt(altsets); - }, - - /** - * Determines if every alternative subset in {@code altsets} contains more - * than one alternative. - * - * @param altsets a collection of alternative subsets - * @return {@code true} if every {@link BitSet} in {@code altsets} has - * {@link BitSet//cardinality cardinality} > 1, otherwise {@code false} - */ - allSubsetsConflict: function(altsets) { - return ! PredictionMode.hasNonConflictingAltSet(altsets); - }, - /** - * Determines if any single alternative subset in {@code altsets} contains - * exactly one alternative. - * - * @param altsets a collection of alternative subsets - * @return {@code true} if {@code altsets} contains a {@link BitSet} with - * {@link BitSet//cardinality cardinality} 1, otherwise {@code false} - */ - hasNonConflictingAltSet: function(altsets) { - for(let i=0;i1) { - return true; - } - } - return false; - }, - - - /** - * Determines if every alternative subset in {@code altsets} is equivalent. - * - * @param altsets a collection of alternative subsets - * @return {@code true} if every member of {@code altsets} is equal to the - * others, otherwise {@code false} - */ - allSubsetsEqual: function(altsets) { - let first = null; - for(let i=0;i - * map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not - * alt and not pred - * - */ - getConflictingAltSubsets: function(configs) { - const configToAlts = new HashMap_HashMap(); - configToAlts.hashFunction = function(cfg) { HashCode.hashStuff(cfg.state.stateNumber, cfg.context); }; - configToAlts.equalsFunction = function(c1, c2) { return c1.state.stateNumber === c2.state.stateNumber && c1.context.equals(c2.context);}; - configs.items.map(function(cfg) { - let alts = configToAlts.get(cfg); - if (alts === null) { - alts = new BitSet(); - configToAlts.set(cfg, alts); - } - alts.add(cfg.alt); - }); - return configToAlts.getValues(); - }, - - /** - * Get a map from state to alt subset from a configuration set. For each - * configuration {@code c} in {@code configs}: - * - *
      -     * map[c.{@link ATNConfig//state state}] U= c.{@link ATNConfig//alt alt}
      -     * 
      - */ - getStateToAltMap: function(configs) { - const m = new AltDict(); - configs.items.map(function(c) { - let alts = m.get(c.state); - if (alts === null) { - alts = new BitSet(); - m.set(c.state, alts); - } - alts.add(c.alt); - }); - return m; - }, - - hasStateAssociatedWithOneAlt: function(configs) { - const values = PredictionMode.getStateToAltMap(configs).values(); - for(let i=0;i - * The basic complexity of the adaptive strategy makes it harder to understand. - * We begin with ATN simulation to build paths in a DFA. Subsequent prediction - * requests go through the DFA first. If they reach a state without an edge for - * the current symbol, the algorithm fails over to the ATN simulation to - * complete the DFA path for the current input (until it finds a conflict state - * or uniquely predicting state).

      - * - *

      - * All of that is done without using the outer context because we want to create - * a DFA that is not dependent upon the rule invocation stack when we do a - * prediction. One DFA works in all contexts. We avoid using context not - * necessarily because it's slower, although it can be, but because of the DFA - * caching problem. The closure routine only considers the rule invocation stack - * created during prediction beginning in the decision rule. For example, if - * prediction occurs without invoking another rule's ATN, there are no context - * stacks in the configurations. When lack of context leads to a conflict, we - * don't know if it's an ambiguity or a weakness in the strong LL(*) parsing - * strategy (versus full LL(*)).

      - * - *

      - * When SLL yields a configuration set with conflict, we rewind the input and - * retry the ATN simulation, this time using full outer context without adding - * to the DFA. Configuration context stacks will be the full invocation stacks - * from the start rule. If we get a conflict using full context, then we can - * definitively say we have a true ambiguity for that input sequence. If we - * don't get a conflict, it implies that the decision is sensitive to the outer - * context. (It is not context-sensitive in the sense of context-sensitive - * grammars.)

      - * - *

      - * The next time we reach this DFA state with an SLL conflict, through DFA - * simulation, we will again retry the ATN simulation using full context mode. - * This is slow because we can't save the results and have to "interpret" the - * ATN each time we get that input.

      - * - *

      - * CACHING FULL CONTEXT PREDICTIONS

      - * - *

      - * We could cache results from full context to predicted alternative easily and - * that saves a lot of time but doesn't work in presence of predicates. The set - * of visible predicates from the ATN start state changes depending on the - * context, because closure can fall off the end of a rule. I tried to cache - * tuples (stack context, semantic context, predicted alt) but it was slower - * than interpreting and much more complicated. Also required a huge amount of - * memory. The goal is not to create the world's fastest parser anyway. I'd like - * to keep this algorithm simple. By launching multiple threads, we can improve - * the speed of parsing across a large number of files.

      - * - *

      - * There is no strict ordering between the amount of input used by SLL vs LL, - * which makes it really hard to build a cache for full context. Let's say that - * we have input A B C that leads to an SLL conflict with full context X. That - * implies that using X we might only use A B but we could also use A B C D to - * resolve conflict. Input A B C D could predict alternative 1 in one position - * in the input and A B C E could predict alternative 2 in another position in - * input. The conflicting SLL configurations could still be non-unique in the - * full context prediction, which would lead us to requiring more input than the - * original A B C. To make a prediction cache work, we have to track the exact - * input used during the previous prediction. That amounts to a cache that maps - * X to a specific DFA for that context.

      - * - *

      - * Something should be done for left-recursive expression predictions. They are - * likely LL(1) + pred eval. Easier to do the whole SLL unless error and retry - * with full LL thing Sam does.

      - * - *

      - * AVOIDING FULL CONTEXT PREDICTION

      - * - *

      - * We avoid doing full context retry when the outer context is empty, we did not - * dip into the outer context by falling off the end of the decision state rule, - * or when we force SLL mode.

      - * - *

      - * As an example of the not dip into outer context case, consider as super - * constructor calls versus function calls. One grammar might look like - * this:

      - * - *
      - * ctorBody
      - *   : '{' superCall? stat* '}'
      - *   ;
      - * 
      - * - *

      - * Or, you might see something like

      - * - *
      - * stat
      - *   : superCall ';'
      - *   | expression ';'
      - *   | ...
      - *   ;
      - * 
      - * - *

      - * In both cases I believe that no closure operations will dip into the outer - * context. In the first case ctorBody in the worst case will stop at the '}'. - * In the 2nd case it should stop at the ';'. Both cases should stay within the - * entry rule and not dip into the outer context.

      - * - *

      - * PREDICATES

      - * - *

      - * Predicates are always evaluated if present in either SLL or LL both. SLL and - * LL simulation deals with predicates differently. SLL collects predicates as - * it performs closure operations like ANTLR v3 did. It delays predicate - * evaluation until it reaches and accept state. This allows us to cache the SLL - * ATN simulation whereas, if we had evaluated predicates on-the-fly during - * closure, the DFA state configuration sets would be different and we couldn't - * build up a suitable DFA.

      - * - *

      - * When building a DFA accept state during ATN simulation, we evaluate any - * predicates and return the sole semantically valid alternative. If there is - * more than 1 alternative, we report an ambiguity. If there are 0 alternatives, - * we throw an exception. Alternatives without predicates act like they have - * true predicates. The simple way to think about it is to strip away all - * alternatives with false predicates and choose the minimum alternative that - * remains.

      - * - *

      - * When we start in the DFA and reach an accept state that's predicated, we test - * those and return the minimum semantically viable alternative. If no - * alternatives are viable, we throw an exception.

      - * - *

      - * During full LL ATN simulation, closure always evaluates predicates and - * on-the-fly. This is crucial to reducing the configuration set size during - * closure. It hits a landmine when parsing with the Java grammar, for example, - * without this on-the-fly evaluation.

      - * - *

      - * SHARING DFA

      - * - *

      - * All instances of the same parser share the same decision DFAs through a - * static field. Each instance gets its own ATN simulator but they share the - * same {@link //decisionToDFA} field. They also share a - * {@link PredictionContextCache} object that makes sure that all - * {@link PredictionContext} objects are shared among the DFA states. This makes - * a big size difference.

      - * - *

      - * THREAD SAFETY

      - * - *

      - * The {@link ParserATNSimulator} locks on the {@link //decisionToDFA} field when - * it adds a new DFA object to that array. {@link //addDFAEdge} - * locks on the DFA for the current decision when setting the - * {@link DFAState//edges} field. {@link //addDFAState} locks on - * the DFA for the current decision when looking up a DFA state to see if it - * already exists. We must make sure that all requests to add DFA states that - * are equivalent result in the same shared DFA object. This is because lots of - * threads will be trying to update the DFA at once. The - * {@link //addDFAState} method also locks inside the DFA lock - * but this time on the shared context cache when it rebuilds the - * configurations' {@link PredictionContext} objects using cached - * subgraphs/nodes. No other locking occurs, even during DFA simulation. This is - * safe as long as we can guarantee that all threads referencing - * {@code s.edge[t]} get the same physical target {@link DFAState}, or - * {@code null}. Once into the DFA, the DFA simulation does not reference the - * {@link DFA//states} map. It follows the {@link DFAState//edges} field to new - * targets. The DFA simulator will either find {@link DFAState//edges} to be - * {@code null}, to be non-{@code null} and {@code dfa.edges[t]} null, or - * {@code dfa.edges[t]} to be non-null. The - * {@link //addDFAEdge} method could be racing to set the field - * but in either case the DFA simulator works; if {@code null}, and requests ATN - * simulation. It could also race trying to get {@code dfa.edges[t]}, but either - * way it will work because it's not doing a test and set operation.

      - * - *

      - * Starting with SLL then failing to combined SLL/LL (Two-Stage - * Parsing)

      - * - *

      - * Sam pointed out that if SLL does not give a syntax error, then there is no - * point in doing full LL, which is slower. We only have to try LL if we get a - * syntax error. For maximum speed, Sam starts the parser set to pure SLL - * mode with the {@link BailErrorStrategy}:

      - * - *
      - * parser.{@link Parser//getInterpreter() getInterpreter()}.{@link //setPredictionMode setPredictionMode}{@code (}{@link PredictionMode//SLL}{@code )};
      - * parser.{@link Parser//setErrorHandler setErrorHandler}(new {@link BailErrorStrategy}());
      - * 
      - * - *

      - * If it does not get a syntax error, then we're done. If it does get a syntax - * error, we need to retry with the combined SLL/LL strategy.

      - * - *

      - * The reason this works is as follows. If there are no SLL conflicts, then the - * grammar is SLL (at least for that input set). If there is an SLL conflict, - * the full LL analysis must yield a set of viable alternatives which is a - * subset of the alternatives reported by SLL. If the LL set is a singleton, - * then the grammar is LL but not SLL. If the LL set is the same size as the SLL - * set, the decision is SLL. If the LL set has size > 1, then that decision - * is truly ambiguous on the current input. If the LL set is smaller, then the - * SLL conflict resolution might choose an alternative that the full LL would - * rule out as a possibility based upon better context information. If that's - * the case, then the SLL parse will definitely get an error because the full LL - * analysis says it's not viable. If SLL conflict resolution chooses an - * alternative within the LL set, them both SLL and LL would choose the same - * alternative because they both choose the minimum of multiple conflicting - * alternatives.

      - * - *

      - * Let's say we have a set of SLL conflicting alternatives {@code {1, 2, 3}} and - * a smaller LL set called s. If s is {@code {2, 3}}, then SLL - * parsing will get an error because SLL will pursue alternative 1. If - * s is {@code {1, 2}} or {@code {1, 3}} then both SLL and LL will - * choose the same alternative because alternative one is the minimum of either - * set. If s is {@code {2}} or {@code {3}} then SLL will get a syntax - * error. If s is {@code {1}} then SLL will succeed.

      - * - *

      - * Of course, if the input is invalid, then we will get an error for sure in - * both SLL and LL parsing. Erroneous input will therefore require 2 passes over - * the input.

      - */ -class ParserATNSimulator extends ATNSimulator { - constructor(parser, atn, decisionToDFA, sharedContextCache) { - super(atn, sharedContextCache); - this.parser = parser; - this.decisionToDFA = decisionToDFA; - // SLL, LL, or LL + exact ambig detection?// - this.predictionMode = atn_PredictionMode.LL; - // LAME globals to avoid parameters!!!!! I need these down deep in predTransition - this._input = null; - this._startIndex = 0; - this._outerContext = null; - this._dfa = null; - /** - * Each prediction operation uses a cache for merge of prediction contexts. - * Don't keep around as it wastes huge amounts of memory. DoubleKeyMap - * isn't synchronized but we're ok since two threads shouldn't reuse same - * parser/atnsim object because it can only handle one input at a time. - * This maps graphs a and b to merged result c. (a,b)→c. We can avoid - * the merge if we ever see a and b again. Note that (b,a)→c should - * also be examined during cache lookup. - */ - this.mergeCache = null; - this.debug = false; - this.debug_closure = false; - this.debug_add = false; - this.debug_list_atn_decisions = false; - this.dfa_debug = false; - this.retry_debug = false; - } - - reset() {} - - adaptivePredict(input, decision, outerContext) { - if (this.debug || this.debug_list_atn_decisions) { - console.log("adaptivePredict decision " + decision + - " exec LA(1)==" + this.getLookaheadName(input) + - " line " + input.LT(1).line + ":" + - input.LT(1).column); - } - this._input = input; - this._startIndex = input.index; - this._outerContext = outerContext; - - const dfa = this.decisionToDFA[decision]; - this._dfa = dfa; - const m = input.mark(); - const index = input.index; - - // Now we are certain to have a specific decision's DFA - // But, do we still need an initial state? - try { - let s0; - if (dfa.precedenceDfa) { - // the start state for a precedence DFA depends on the current - // parser precedence, and is provided by a DFA method. - s0 = dfa.getPrecedenceStartState(this.parser.getPrecedence()); - } else { - // the start state for a "regular" DFA is just s0 - s0 = dfa.s0; - } - if (s0===null) { - if (outerContext===null) { - outerContext = RuleContext.EMPTY; - } - if (this.debug || this.debug_list_atn_decisions) { - console.log("predictATN decision " + dfa.decision + - " exec LA(1)==" + this.getLookaheadName(input) + - ", outerContext=" + outerContext.toString(this.parser.ruleNames)); - } - - const fullCtx = false; - let s0_closure = this.computeStartState(dfa.atnStartState, RuleContext.EMPTY, fullCtx); - - if( dfa.precedenceDfa) { - // If this is a precedence DFA, we use applyPrecedenceFilter - // to convert the computed start state to a precedence start - // state. We then use DFA.setPrecedenceStartState to set the - // appropriate start state for the precedence level rather - // than simply setting DFA.s0. - // - dfa.s0.configs = s0_closure; // not used for prediction but useful to know start configs anyway - s0_closure = this.applyPrecedenceFilter(s0_closure); - s0 = this.addDFAState(dfa, new DFAState(null, s0_closure)); - dfa.setPrecedenceStartState(this.parser.getPrecedence(), s0); - } else { - s0 = this.addDFAState(dfa, new DFAState(null, s0_closure)); - dfa.s0 = s0; - } - } - const alt = this.execATN(dfa, s0, input, index, outerContext); - if (this.debug) { - console.log("DFA after predictATN: " + dfa.toString(this.parser.literalNames, this.parser.symbolicNames)); - } - return alt; - } finally { - this._dfa = null; - this.mergeCache = null; // wack cache after each prediction - input.seek(index); - input.release(m); - } - } - - /** - * Performs ATN simulation to compute a predicted alternative based - * upon the remaining input, but also updates the DFA cache to avoid - * having to traverse the ATN again for the same input sequence. - * - * There are some key conditions we're looking for after computing a new - * set of ATN configs (proposed DFA state): - * if the set is empty, there is no viable alternative for current symbol - * does the state uniquely predict an alternative? - * does the state have a conflict that would prevent us from - * putting it on the work list? - * - * We also have some key operations to do: - * add an edge from previous DFA state to potentially new DFA state, D, - * upon current symbol but only if adding to work list, which means in all - * cases except no viable alternative (and possibly non-greedy decisions?) - * collecting predicates and adding semantic context to DFA accept states - * adding rule context to context-sensitive DFA accept states - * consuming an input symbol - * reporting a conflict - * reporting an ambiguity - * reporting a context sensitivity - * reporting insufficient predicates - * - * cover these cases: - * dead end - * single alt - * single alt + preds - * conflict - * conflict + preds - * - */ - execATN(dfa, s0, input, startIndex, outerContext ) { - if (this.debug || this.debug_list_atn_decisions) { - console.log("execATN decision " + dfa.decision + - " exec LA(1)==" + this.getLookaheadName(input) + - " line " + input.LT(1).line + ":" + input.LT(1).column); - } - let alt; - let previousD = s0; - - if (this.debug) { - console.log("s0 = " + s0); - } - let t = input.LA(1); - for(;;) { // while more work - let D = this.getExistingTargetState(previousD, t); - if(D===null) { - D = this.computeTargetState(dfa, previousD, t); - } - if(D===ATNSimulator.ERROR) { - // if any configs in previous dipped into outer context, that - // means that input up to t actually finished entry rule - // at least for SLL decision. Full LL doesn't dip into outer - // so don't need special case. - // We will get an error no matter what so delay until after - // decision; better error message. Also, no reachable target - // ATN states in SLL implies LL will also get nowhere. - // If conflict in states that dip out, choose min since we - // will get error no matter what. - const e = this.noViableAlt(input, outerContext, previousD.configs, startIndex); - input.seek(startIndex); - alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD.configs, outerContext); - if(alt!==ATN.INVALID_ALT_NUMBER) { - return alt; - } else { - throw e; - } - } - if(D.requiresFullContext && this.predictionMode !== atn_PredictionMode.SLL) { - // IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error) - let conflictingAlts = null; - if (D.predicates!==null) { - if (this.debug) { - console.log("DFA state has preds in DFA sim LL failover"); - } - const conflictIndex = input.index; - if(conflictIndex !== startIndex) { - input.seek(startIndex); - } - conflictingAlts = this.evalSemanticContext(D.predicates, outerContext, true); - if (conflictingAlts.length===1) { - if(this.debug) { - console.log("Full LL avoided"); - } - return conflictingAlts.minValue(); - } - if (conflictIndex !== startIndex) { - // restore the index so reporting the fallback to full - // context occurs with the index at the correct spot - input.seek(conflictIndex); - } - } - if (this.dfa_debug) { - console.log("ctx sensitive state " + outerContext +" in " + D); - } - const fullCtx = true; - const s0_closure = this.computeStartState(dfa.atnStartState, outerContext, fullCtx); - this.reportAttemptingFullContext(dfa, conflictingAlts, D.configs, startIndex, input.index); - alt = this.execATNWithFullContext(dfa, D, s0_closure, input, startIndex, outerContext); - return alt; - } - if (D.isAcceptState) { - if (D.predicates===null) { - return D.prediction; - } - const stopIndex = input.index; - input.seek(startIndex); - const alts = this.evalSemanticContext(D.predicates, outerContext, true); - if (alts.length===0) { - throw this.noViableAlt(input, outerContext, D.configs, startIndex); - } else if (alts.length===1) { - return alts.minValue(); - } else { - // report ambiguity after predicate evaluation to make sure the correct set of ambig alts is reported. - this.reportAmbiguity(dfa, D, startIndex, stopIndex, false, alts, D.configs); - return alts.minValue(); - } - } - previousD = D; - - if (t !== Token.EOF) { - input.consume(); - t = input.LA(1); - } - } - } - - /** - * Get an existing target state for an edge in the DFA. If the target state - * for the edge has not yet been computed or is otherwise not available, - * this method returns {@code null}. - * - * @param previousD The current DFA state - * @param t The next input symbol - * @return The existing target DFA state for the given input symbol - * {@code t}, or {@code null} if the target state for this edge is not - * already cached - */ - getExistingTargetState(previousD, t) { - const edges = previousD.edges; - if (edges===null) { - return null; - } else { - return edges[t + 1] || null; - } - } - - /** - * Compute a target state for an edge in the DFA, and attempt to add the - * computed state and corresponding edge to the DFA. - * - * @param dfa The DFA - * @param previousD The current DFA state - * @param t The next input symbol - * - * @return The computed target DFA state for the given input symbol - * {@code t}. If {@code t} does not lead to a valid DFA state, this method - * returns {@link //ERROR - */ - computeTargetState(dfa, previousD, t) { - const reach = this.computeReachSet(previousD.configs, t, false); - if(reach===null) { - this.addDFAEdge(dfa, previousD, t, ATNSimulator.ERROR); - return ATNSimulator.ERROR; - } - // create new target state; we'll add to DFA after it's complete - let D = new DFAState(null, reach); - - const predictedAlt = this.getUniqueAlt(reach); - - if (this.debug) { - const altSubSets = atn_PredictionMode.getConflictingAltSubsets(reach); - console.log("SLL altSubSets=" + arrayToString(altSubSets) + - /*", previous=" + previousD.configs + */ - ", configs=" + reach + - ", predict=" + predictedAlt + - ", allSubsetsConflict=" + - atn_PredictionMode.allSubsetsConflict(altSubSets) + ", conflictingAlts=" + - this.getConflictingAlts(reach)); - } - if (predictedAlt!==ATN.INVALID_ALT_NUMBER) { - // NO CONFLICT, UNIQUELY PREDICTED ALT - D.isAcceptState = true; - D.configs.uniqueAlt = predictedAlt; - D.prediction = predictedAlt; - } else if (atn_PredictionMode.hasSLLConflictTerminatingPrediction(this.predictionMode, reach)) { - // MORE THAN ONE VIABLE ALTERNATIVE - D.configs.conflictingAlts = this.getConflictingAlts(reach); - D.requiresFullContext = true; - // in SLL-only mode, we will stop at this state and return the minimum alt - D.isAcceptState = true; - D.prediction = D.configs.conflictingAlts.minValue(); - } - if (D.isAcceptState && D.configs.hasSemanticContext) { - this.predicateDFAState(D, this.atn.getDecisionState(dfa.decision)); - if( D.predicates!==null) { - D.prediction = ATN.INVALID_ALT_NUMBER; - } - } - // all adds to dfa are done after we've created full D state - D = this.addDFAEdge(dfa, previousD, t, D); - return D; - } - - predicateDFAState(dfaState, decisionState) { - // We need to test all predicates, even in DFA states that - // uniquely predict alternative. - const nalts = decisionState.transitions.length; - // Update DFA so reach becomes accept state with (predicate,alt) - // pairs if preds found for conflicting alts - const altsToCollectPredsFrom = this.getConflictingAltsOrUniqueAlt(dfaState.configs); - const altToPred = this.getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); - if (altToPred!==null) { - dfaState.predicates = this.getPredicatePredictions(altsToCollectPredsFrom, altToPred); - dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds - } else { - // There are preds in configs but they might go away - // when OR'd together like {p}? || NONE == NONE. If neither - // alt has preds, resolve to min alt - dfaState.prediction = altsToCollectPredsFrom.minValue(); - } - } - -// comes back with reach.uniqueAlt set to a valid alt - execATNWithFullContext(dfa, D, // how far we got before failing over - s0, - input, - startIndex, - outerContext) { - if (this.debug || this.debug_list_atn_decisions) { - console.log("execATNWithFullContext "+s0); - } - const fullCtx = true; - let foundExactAmbig = false; - let reach; - let previous = s0; - input.seek(startIndex); - let t = input.LA(1); - let predictedAlt = -1; - for (;;) { // while more work - reach = this.computeReachSet(previous, t, fullCtx); - if (reach===null) { - // if any configs in previous dipped into outer context, that - // means that input up to t actually finished entry rule - // at least for LL decision. Full LL doesn't dip into outer - // so don't need special case. - // We will get an error no matter what so delay until after - // decision; better error message. Also, no reachable target - // ATN states in SLL implies LL will also get nowhere. - // If conflict in states that dip out, choose min since we - // will get error no matter what. - const e = this.noViableAlt(input, outerContext, previous, startIndex); - input.seek(startIndex); - const alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext); - if(alt!==ATN.INVALID_ALT_NUMBER) { - return alt; - } else { - throw e; - } - } - const altSubSets = atn_PredictionMode.getConflictingAltSubsets(reach); - if(this.debug) { - console.log("LL altSubSets=" + altSubSets + ", predict=" + - atn_PredictionMode.getUniqueAlt(altSubSets) + ", resolvesToJustOneViableAlt=" + - atn_PredictionMode.resolvesToJustOneViableAlt(altSubSets)); - } - reach.uniqueAlt = this.getUniqueAlt(reach); - // unique prediction? - if(reach.uniqueAlt!==ATN.INVALID_ALT_NUMBER) { - predictedAlt = reach.uniqueAlt; - break; - } else if (this.predictionMode !== atn_PredictionMode.LL_EXACT_AMBIG_DETECTION) { - predictedAlt = atn_PredictionMode.resolvesToJustOneViableAlt(altSubSets); - if(predictedAlt !== ATN.INVALID_ALT_NUMBER) { - break; - } - } else { - // In exact ambiguity mode, we never try to terminate early. - // Just keeps scarfing until we know what the conflict is - if (atn_PredictionMode.allSubsetsConflict(altSubSets) && atn_PredictionMode.allSubsetsEqual(altSubSets)) { - foundExactAmbig = true; - predictedAlt = atn_PredictionMode.getSingleViableAlt(altSubSets); - break; - } - // else there are multiple non-conflicting subsets or - // we're not sure what the ambiguity is yet. - // So, keep going. - } - previous = reach; - if( t !== Token.EOF) { - input.consume(); - t = input.LA(1); - } - } - // If the configuration set uniquely predicts an alternative, - // without conflict, then we know that it's a full LL decision - // not SLL. - if (reach.uniqueAlt !== ATN.INVALID_ALT_NUMBER ) { - this.reportContextSensitivity(dfa, predictedAlt, reach, startIndex, input.index); - return predictedAlt; - } - // We do not check predicates here because we have checked them - // on-the-fly when doing full context prediction. - - // - // In non-exact ambiguity detection mode, we might actually be able to - // detect an exact ambiguity, but I'm not going to spend the cycles - // needed to check. We only emit ambiguity warnings in exact ambiguity - // mode. - // - // For example, we might know that we have conflicting configurations. - // But, that does not mean that there is no way forward without a - // conflict. It's possible to have nonconflicting alt subsets as in: - - // altSubSets=[{1, 2}, {1, 2}, {1}, {1, 2}] - - // from - // - // [(17,1,[5 $]), (13,1,[5 10 $]), (21,1,[5 10 $]), (11,1,[$]), - // (13,2,[5 10 $]), (21,2,[5 10 $]), (11,2,[$])] - // - // In this case, (17,1,[5 $]) indicates there is some next sequence that - // would resolve this without conflict to alternative 1. Any other viable - // next sequence, however, is associated with a conflict. We stop - // looking for input because no amount of further lookahead will alter - // the fact that we should predict alternative 1. We just can't say for - // sure that there is an ambiguity without looking further. - - this.reportAmbiguity(dfa, D, startIndex, input.index, foundExactAmbig, null, reach); - - return predictedAlt; - } - - computeReachSet(closure, t, fullCtx) { - if (this.debug) { - console.log("in computeReachSet, starting closure: " + closure); - } - if( this.mergeCache===null) { - this.mergeCache = new DoubleDict(); - } - const intermediate = new ATNConfigSet(fullCtx); - - // Configurations already in a rule stop state indicate reaching the end - // of the decision rule (local context) or end of the start rule (full - // context). Once reached, these configurations are never updated by a - // closure operation, so they are handled separately for the performance - // advantage of having a smaller intermediate set when calling closure. - // - // For full-context reach operations, separate handling is required to - // ensure that the alternative matching the longest overall sequence is - // chosen when multiple such configurations can match the input. - - let skippedStopStates = null; - - // First figure out where we can reach on input t - for (let i=0; iWhen {@code lookToEndOfRule} is true, this method uses - * {@link ATN//nextTokens} for each configuration in {@code configs} which is - * not already in a rule stop state to see if a rule stop state is reachable - * from the configuration via epsilon-only transitions.

      - * - * @param configs the configuration set to update - * @param lookToEndOfRule when true, this method checks for rule stop states - * reachable by epsilon-only transitions from each configuration in - * {@code configs}. - * - * @return {@code configs} if all configurations in {@code configs} are in a - * rule stop state, otherwise return a new configuration set containing only - * the configurations from {@code configs} which are in a rule stop state - */ - removeAllConfigsNotInRuleStopState(configs, lookToEndOfRule) { - if (atn_PredictionMode.allConfigsInRuleStopStates(configs)) { - return configs; - } - const result = new ATNConfigSet(configs.fullCtx); - for(let i=0; i - *
    • Evaluate the precedence predicates for each configuration using - * {@link SemanticContext//evalPrecedence}.
    • - *
    • Remove all configurations which predict an alternative greater than - * 1, for which another configuration that predicts alternative 1 is in the - * same ATN state with the same prediction context. This transformation is - * valid for the following reasons: - *
        - *
      • The closure block cannot contain any epsilon transitions which bypass - * the body of the closure, so all states reachable via alternative 1 are - * part of the precedence alternatives of the transformed left-recursive - * rule.
      • - *
      • The "primary" portion of a left recursive rule cannot contain an - * epsilon transition, so the only way an alternative other than 1 can exist - * in a state that is also reachable via alternative 1 is by nesting calls - * to the left-recursive rule, with the outer calls not being at the - * preferred precedence level.
      • - *
      - *
    • - * - * - *

      - * The prediction context must be considered by this filter to address - * situations like the following. - *

      - * - *
      -     * grammar TA;
      -     * prog: statement* EOF;
      -     * statement: letterA | statement letterA 'b' ;
      -     * letterA: 'a';
      -     * 
      - *
      - *

      - * If the above grammar, the ATN state immediately before the token - * reference {@code 'a'} in {@code letterA} is reachable from the left edge - * of both the primary and closure blocks of the left-recursive rule - * {@code statement}. The prediction context associated with each of these - * configurations distinguishes between them, and prevents the alternative - * which stepped out to {@code prog} (and then back in to {@code statement} - * from being eliminated by the filter. - *

      - * - * @param configs The configuration set computed by - * {@link //computeStartState} as the start state for the DFA. - * @return The transformed configuration set representing the start state - * for a precedence DFA at a particular precedence level (determined by - * calling {@link Parser//getPrecedence}) - */ - applyPrecedenceFilter(configs) { - let config; - const statesFromAlt1 = []; - const configSet = new ATNConfigSet(configs.fullCtx); - for(let i=0; i1 - // (basically a graph subtraction algorithm). - if (!config.precedenceFilterSuppressed) { - const context = statesFromAlt1[config.state.stateNumber] || null; - if (context!==null && context.equals(config.context)) { - // eliminated - continue; - } - } - configSet.add(config, this.mergeCache); - } - return configSet; - } - - getReachableTarget(trans, ttype) { - if (trans.matches(ttype, 0, this.atn.maxTokenType)) { - return trans.target; - } else { - return null; - } - } - - getPredsForAmbigAlts(ambigAlts, configs, nalts) { - // REACH=[1|1|[]|0:0, 1|2|[]|0:1] - // altToPred starts as an array of all null contexts. The entry at index i - // corresponds to alternative i. altToPred[i] may have one of three values: - // 1. null: no ATNConfig c is found such that c.alt==i - // 2. SemanticContext.NONE: At least one ATNConfig c exists such that - // c.alt==i and c.semanticContext==SemanticContext.NONE. In other words, - // alt i has at least one unpredicated config. - // 3. Non-NONE Semantic Context: There exists at least one, and for all - // ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE. - // - // From this, it is clear that NONE||anything==NONE. - // - let altToPred = []; - for(let i=0;i - * The default implementation of this method uses the following - * algorithm to identify an ATN configuration which successfully parsed the - * decision entry rule. Choosing such an alternative ensures that the - * {@link ParserRuleContext} returned by the calling rule will be complete - * and valid, and the syntax error will be reported later at a more - * localized location.

      - * - *
        - *
      • If a syntactically valid path or paths reach the end of the decision rule and - * they are semantically valid if predicated, return the min associated alt.
      • - *
      • Else, if a semantically invalid but syntactically valid path exist - * or paths exist, return the minimum associated alt. - *
      • - *
      • Otherwise, return {@link ATN//INVALID_ALT_NUMBER}.
      • - *
      - * - *

      - * In some scenarios, the algorithm described above could predict an - * alternative which will result in a {@link FailedPredicateException} in - * the parser. Specifically, this could occur if the only configuration - * capable of successfully parsing to the end of the decision rule is - * blocked by a semantic predicate. By choosing this alternative within - * {@link //adaptivePredict} instead of throwing a - * {@link NoViableAltException}, the resulting - * {@link FailedPredicateException} in the parser will identify the specific - * predicate which is preventing the parser from successfully parsing the - * decision rule, which helps developers identify and correct logic errors - * in semantic predicates. - *

      - * - * @param configs The ATN configurations which were valid immediately before - * the {@link //ERROR} state was reached - * @param outerContext The is the \gamma_0 initial parser context from the paper - * or the parser stack at the instant before prediction commences. - * - * @return The value to return from {@link //adaptivePredict}, or - * {@link ATN//INVALID_ALT_NUMBER} if a suitable alternative was not - * identified and {@link //adaptivePredict} should report an error instead - */ - getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(configs, outerContext) { - const cfgs = this.splitAccordingToSemanticValidity(configs, outerContext); - const semValidConfigs = cfgs[0]; - const semInvalidConfigs = cfgs[1]; - let alt = this.getAltThatFinishedDecisionEntryRule(semValidConfigs); - if (alt!==ATN.INVALID_ALT_NUMBER) { // semantically/syntactically viable path exists - return alt; - } - // Is there a syntactically valid path with a failed pred? - if (semInvalidConfigs.items.length>0) { - alt = this.getAltThatFinishedDecisionEntryRule(semInvalidConfigs); - if (alt!==ATN.INVALID_ALT_NUMBER) { // syntactically viable path exists - return alt; - } - } - return ATN.INVALID_ALT_NUMBER; - } - - getAltThatFinishedDecisionEntryRule(configs) { - const alts = []; - for(let i=0;i0 || ((c.state instanceof RuleStopState) && c.context.hasEmptyPath())) { - if(alts.indexOf(c.alt)<0) { - alts.push(c.alt); - } - } - } - if (alts.length===0) { - return ATN.INVALID_ALT_NUMBER; - } else { - return Math.min.apply(null, alts); - } - } - - /** - * Walk the list of configurations and split them according to - * those that have preds evaluating to true/false. If no pred, assume - * true pred and include in succeeded set. Returns Pair of sets. - * - * Create a new set so as not to alter the incoming parameter. - * - * Assumption: the input stream has been restored to the starting point - * prediction, which is where predicates need to evaluate.*/ - splitAccordingToSemanticValidity( configs, outerContext) { - const succeeded = new ATNConfigSet(configs.fullCtx); - const failed = new ATNConfigSet(configs.fullCtx); - for(let i=0;i50) { - throw "problem"; - } - } - if (config.state instanceof RuleStopState) { - // We hit rule end. If we have context info, use it - // run thru all possible stack tops in ctx - if (! config.context.isEmpty()) { - for (let i =0; i 0. - if (this._dfa !== null && this._dfa.precedenceDfa) { - if (t.outermostPrecedenceReturn === this._dfa.atnStartState.ruleIndex) { - c.precedenceFilterSuppressed = true; - } - } - - c.reachesIntoOuterContext += 1; - if (closureBusy.add(c)!==c) { - // avoid infinite recursion for right-recursive rules - continue; - } - configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method - newDepth -= 1; - if (this.debug) { - console.log("dips into outer ctx: " + c); - } - } else { - if (!t.isEpsilon && closureBusy.add(c)!==c){ - // avoid infinite recursion for EOF* and EOF+ - continue; - } - if (t instanceof RuleTransition) { - // latch when newDepth goes negative - once we step out of the entry context we can't return - if (newDepth >= 0) { - newDepth += 1; - } - } - } - this.closureCheckingStopState(c, configs, closureBusy, continueCollecting, fullCtx, newDepth, treatEofAsEpsilon); - } - } - } - - canDropLoopEntryEdgeInLeftRecursiveRule(config) { - // return False - const p = config.state; - // First check to see if we are in StarLoopEntryState generated during - // left-recursion elimination. For efficiency, also check if - // the context has an empty stack case. If so, it would mean - // global FOLLOW so we can't perform optimization - // Are we the special loop entry/exit state? or SLL wildcard - if(p.stateType !== ATNState.STAR_LOOP_ENTRY) - return false; - if(p.stateType !== ATNState.STAR_LOOP_ENTRY || !p.isPrecedenceDecision || - config.context.isEmpty() || config.context.hasEmptyPath()) - return false; - - // Require all return states to return back to the same rule that p is in. - const numCtxs = config.context.length; - for(let i=0; i=0) { - return this.parser.ruleNames[index]; - } else { - return ""; - } - } - - getEpsilonTarget(config, t, collectPredicates, inContext, fullCtx, treatEofAsEpsilon) { - switch(t.serializationType) { - case Transition.RULE: - return this.ruleTransition(config, t); - case Transition.PRECEDENCE: - return this.precedenceTransition(config, t, collectPredicates, inContext, fullCtx); - case Transition.PREDICATE: - return this.predTransition(config, t, collectPredicates, inContext, fullCtx); - case Transition.ACTION: - return this.actionTransition(config, t); - case Transition.EPSILON: - return new ATNConfig({state:t.target}, config); - case Transition.ATOM: - case Transition.RANGE: - case Transition.SET: - // EOF transitions act like epsilon transitions after the first EOF - // transition is traversed - if (treatEofAsEpsilon) { - if (t.matches(Token.EOF, 0, 1)) { - return new ATNConfig({state: t.target}, config); - } - } - return null; - default: - return null; - } - } - - actionTransition(config, t) { - if (this.debug) { - const index = t.actionIndex === -1 ? 65535 : t.actionIndex; - console.log("ACTION edge " + t.ruleIndex + ":" + index); - } - return new ATNConfig({state:t.target}, config); - } - - precedenceTransition(config, pt, collectPredicates, inContext, fullCtx) { - if (this.debug) { - console.log("PRED (collectPredicates=" + collectPredicates + ") " + - pt.precedence + ">=_p, ctx dependent=true"); - if (this.parser!==null) { - console.log("context surrounding pred is " + arrayToString(this.parser.getRuleInvocationStack())); - } - } - let c = null; - if (collectPredicates && inContext) { - if (fullCtx) { - // In full context mode, we can evaluate predicates on-the-fly - // during closure, which dramatically reduces the size of - // the config sets. It also obviates the need to test predicates - // later during conflict resolution. - const currentPosition = this._input.index; - this._input.seek(this._startIndex); - const predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext); - this._input.seek(currentPosition); - if (predSucceeds) { - c = new ATNConfig({state:pt.target}, config); // no pred context - } - } else { - const newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate()); - c = new ATNConfig({state:pt.target, semanticContext:newSemCtx}, config); - } - } else { - c = new ATNConfig({state:pt.target}, config); - } - if (this.debug) { - console.log("config from pred transition=" + c); - } - return c; - } - - predTransition(config, pt, collectPredicates, inContext, fullCtx) { - if (this.debug) { - console.log("PRED (collectPredicates=" + collectPredicates + ") " + pt.ruleIndex + - ":" + pt.predIndex + ", ctx dependent=" + pt.isCtxDependent); - if (this.parser!==null) { - console.log("context surrounding pred is " + arrayToString(this.parser.getRuleInvocationStack())); - } - } - let c = null; - if (collectPredicates && ((pt.isCtxDependent && inContext) || ! pt.isCtxDependent)) { - if (fullCtx) { - // In full context mode, we can evaluate predicates on-the-fly - // during closure, which dramatically reduces the size of - // the config sets. It also obviates the need to test predicates - // later during conflict resolution. - const currentPosition = this._input.index; - this._input.seek(this._startIndex); - const predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext); - this._input.seek(currentPosition); - if (predSucceeds) { - c = new ATNConfig({state:pt.target}, config); // no pred context - } - } else { - const newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate()); - c = new ATNConfig({state:pt.target, semanticContext:newSemCtx}, config); - } - } else { - c = new ATNConfig({state:pt.target}, config); - } - if (this.debug) { - console.log("config from pred transition=" + c); - } - return c; - } - - ruleTransition(config, t) { - if (this.debug) { - console.log("CALL rule " + this.getRuleName(t.target.ruleIndex) + ", ctx=" + config.context); - } - const returnState = t.followState; - const newContext = SingletonPredictionContext.create(config.context, returnState.stateNumber); - return new ATNConfig({state:t.target, context:newContext}, config ); - } - - getConflictingAlts(configs) { - const altsets = atn_PredictionMode.getConflictingAltSubsets(configs); - return atn_PredictionMode.getAlts(altsets); - } - - /** - * Sam pointed out a problem with the previous definition, v3, of - * ambiguous states. If we have another state associated with conflicting - * alternatives, we should keep going. For example, the following grammar - * - * s : (ID | ID ID?) ';' ; - * - * When the ATN simulation reaches the state before ';', it has a DFA - * state that looks like: [12|1|[], 6|2|[], 12|2|[]]. Naturally - * 12|1|[] and 12|2|[] conflict, but we cannot stop processing this node - * because alternative to has another way to continue, via [6|2|[]]. - * The key is that we have a single state that has config's only associated - * with a single alternative, 2, and crucially the state transitions - * among the configurations are all non-epsilon transitions. That means - * we don't consider any conflicts that include alternative 2. So, we - * ignore the conflict between alts 1 and 2. We ignore a set of - * conflicting alts when there is an intersection with an alternative - * associated with a single alt state in the state→config-list map. - * - * It's also the case that we might have two conflicting configurations but - * also a 3rd nonconflicting configuration for a different alternative: - * [1|1|[], 1|2|[], 8|3|[]]. This can come about from grammar: - * - * a : A | A | A B ; - * - * After matching input A, we reach the stop state for rule A, state 1. - * State 8 is the state right before B. Clearly alternatives 1 and 2 - * conflict and no amount of further lookahead will separate the two. - * However, alternative 3 will be able to continue and so we do not - * stop working on this state. In the previous example, we're concerned - * with states associated with the conflicting alternatives. Here alt - * 3 is not associated with the conflicting configs, but since we can continue - * looking for input reasonably, I don't declare the state done. We - * ignore a set of conflicting alts when we have an alternative - * that we still need to pursue - */ - getConflictingAltsOrUniqueAlt(configs) { - let conflictingAlts = null; - if (configs.uniqueAlt!== ATN.INVALID_ALT_NUMBER) { - conflictingAlts = new BitSet(); - conflictingAlts.add(configs.uniqueAlt); - } else { - conflictingAlts = configs.conflictingAlts; - } - return conflictingAlts; - } - - getTokenName(t) { - if (t===Token.EOF) { - return "EOF"; - } - if( this.parser!==null && this.parser.literalNames!==null) { - if (t >= this.parser.literalNames.length && t >= this.parser.symbolicNames.length) { - console.log("" + t + " ttype out of range: " + this.parser.literalNames); - console.log("" + this.parser.getInputStream().getTokens()); - } else { - const name = this.parser.literalNames[t] || this.parser.symbolicNames[t]; - return name + "<" + t + ">"; - } - } - return "" + t; - } - - getLookaheadName(input) { - return this.getTokenName(input.LA(1)); - } - - /** - * Used for debugging in adaptivePredict around execATN but I cut - * it out for clarity now that alg. works well. We can leave this - * "dead" code for a bit - */ - dumpDeadEndConfigs(nvae) { - console.log("dead end configs: "); - const decs = nvae.getDeadEndConfigs(); - for(let i=0; i0) { - const t = c.state.transitions[0]; - if (t instanceof AtomTransition) { - trans = "Atom "+ this.getTokenName(t.label); - } else if (t instanceof SetTransition) { - const neg = (t instanceof NotSetTransition); - trans = (neg ? "~" : "") + "Set " + t.set; - } - } - console.error(c.toString(this.parser, true) + ":" + trans); - } - } - - noViableAlt(input, outerContext, configs, startIndex) { - return new NoViableAltException(this.parser, input, input.get(startIndex), input.LT(1), configs, outerContext); - } - - getUniqueAlt(configs) { - let alt = ATN.INVALID_ALT_NUMBER; - for(let i=0;iIf {@code to} is {@code null}, this method returns {@code null}. - * Otherwise, this method returns the {@link DFAState} returned by calling - * {@link //addDFAState} for the {@code to} state.

      - * - * @param dfa The DFA - * @param from_ The source state for the edge - * @param t The input symbol - * @param to The target state for the edge - * - * @return If {@code to} is {@code null}, this method returns {@code null}; - * otherwise this method returns the result of calling {@link //addDFAState} - * on {@code to} - */ - addDFAEdge(dfa, from_, t, to) { - if( this.debug) { - console.log("EDGE " + from_ + " -> " + to + " upon " + this.getTokenName(t)); - } - if (to===null) { - return null; - } - to = this.addDFAState(dfa, to); // used existing if possible not incoming - if (from_===null || t < -1 || t > this.atn.maxTokenType) { - return to; - } - if (from_.edges===null) { - from_.edges = []; - } - from_.edges[t+1] = to; // connect - - if (this.debug) { - const literalNames = this.parser===null ? null : this.parser.literalNames; - const symbolicNames = this.parser===null ? null : this.parser.symbolicNames; - console.log("DFA=\n" + dfa.toString(literalNames, symbolicNames)); - } - return to; - } - - /** - * Add state {@code D} to the DFA if it is not already present, and return - * the actual instance stored in the DFA. If a state equivalent to {@code D} - * is already in the DFA, the existing state is returned. Otherwise this - * method returns {@code D} after adding it to the DFA. - * - *

      If {@code D} is {@link //ERROR}, this method returns {@link //ERROR} and - * does not change the DFA.

      - * - * @param dfa The dfa - * @param D The DFA state to add - * @return The state stored in the DFA. This will be either the existing - * state if {@code D} is already in the DFA, or {@code D} itself if the - * state was not already present - */ - addDFAState(dfa, D) { - if (D === ATNSimulator.ERROR) { - return D; - } - const existing = dfa.states.get(D); - if(existing!==null) { - return existing; - } - D.stateNumber = dfa.states.length; - if (! D.configs.readOnly) { - D.configs.optimizeConfigs(this); - D.configs.setReadonly(true); - } - dfa.states.add(D); - if (this.debug) { - console.log("adding new DFA state: " + D); - } - return D; - } - - reportAttemptingFullContext(dfa, conflictingAlts, configs, startIndex, stopIndex) { - if (this.debug || this.retry_debug) { - const interval = new Interval(startIndex, stopIndex + 1); - console.log("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs + - ", input=" + this.parser.getTokenStream().getText(interval)); - } - if (this.parser!==null) { - this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs); - } - } - - reportContextSensitivity(dfa, prediction, configs, startIndex, stopIndex) { - if (this.debug || this.retry_debug) { - const interval = new Interval(startIndex, stopIndex + 1); - console.log("reportContextSensitivity decision=" + dfa.decision + ":" + configs + - ", input=" + this.parser.getTokenStream().getText(interval)); - } - if (this.parser!==null) { - this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs); - } - } - - // If context sensitive parsing, we know it's ambiguity not conflict// - reportAmbiguity(dfa, D, startIndex, stopIndex, - exact, ambigAlts, configs ) { - if (this.debug || this.retry_debug) { - const interval = new Interval(startIndex, stopIndex + 1); - console.log("reportAmbiguity " + ambigAlts + ":" + configs + - ", input=" + this.parser.getTokenStream().getText(interval)); - } - if (this.parser!==null) { - this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs); - } - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/index.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - -/* harmony default export */ const atn = ({ ATN: ATN, ATNDeserializer: ATNDeserializer, LexerATNSimulator: LexerATNSimulator, ParserATNSimulator: ParserATNSimulator, PredictionMode: atn_PredictionMode }); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/DFASerializer.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -/** - * A DFA walker that knows how to dump them to serialized strings. - */ -class DFASerializer { - constructor(dfa, literalNames, symbolicNames) { - this.dfa = dfa; - this.literalNames = literalNames || []; - this.symbolicNames = symbolicNames || []; - } - - toString() { - if(this.dfa.s0 === null) { - return null; - } - let buf = ""; - const states = this.dfa.sortedStates(); - for(let i=0; i"); - buf = buf.concat(this.getStateString(t)); - buf = buf.concat('\n'); - } - } - } - } - return buf.length===0 ? null : buf; - } - - getEdgeLabel(i) { - if (i===0) { - return "EOF"; - } else if(this.literalNames !==null || this.symbolicNames!==null) { - return this.literalNames[i-1] || this.symbolicNames[i-1]; - } else { - return String.fromCharCode(i-1); - } - } - - getStateString(s) { - const baseStateStr = ( s.isAcceptState ? ":" : "") + "s" + s.stateNumber + ( s.requiresFullContext ? "^" : ""); - if(s.isAcceptState) { - if (s.predicates !== null) { - return baseStateStr + "=>" + arrayToString(s.predicates); - } else { - return baseStateStr + "=>" + s.prediction.toString(); - } - } else { - return baseStateStr; - } - } -} - - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/LexerDFASerializer.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class LexerDFASerializer extends DFASerializer { - constructor(dfa) { - super(dfa, null); - } - - getEdgeLabel(i) { - return "'" + String.fromCharCode(i) + "'"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/DFA.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - -class DFA { - constructor(atnStartState, decision) { - if (decision === undefined) { - decision = 0; - } - /** - * From which ATN state did we create this DFA? - */ - this.atnStartState = atnStartState; - this.decision = decision; - /** - * A set of all DFA states. Use {@link Map} so we can get old state back - * ({@link Set} only allows you to see if it's there). - */ - this._states = new HashSet(); - this.s0 = null; - /** - * {@code true} if this DFA is for a precedence decision; otherwise, - * {@code false}. This is the backing field for {@link //isPrecedenceDfa}, - * {@link //setPrecedenceDfa} - */ - this.precedenceDfa = false; - if (atnStartState instanceof StarLoopEntryState) - { - if (atnStartState.isPrecedenceDecision) { - this.precedenceDfa = true; - const precedenceState = new DFAState(null, new ATNConfigSet()); - precedenceState.edges = []; - precedenceState.isAcceptState = false; - precedenceState.requiresFullContext = false; - this.s0 = precedenceState; - } - } - } - - /** - * Get the start state for a specific precedence value. - * - * @param precedence The current precedence. - * @return The start state corresponding to the specified precedence, or - * {@code null} if no start state exists for the specified precedence. - * - * @throws IllegalStateException if this is not a precedence DFA. - * @see //isPrecedenceDfa() - */ - getPrecedenceStartState(precedence) { - if (!(this.precedenceDfa)) { - throw ("Only precedence DFAs may contain a precedence start state."); - } - // s0.edges is never null for a precedence DFA - if (precedence < 0 || precedence >= this.s0.edges.length) { - return null; - } - return this.s0.edges[precedence] || null; - } - - /** - * Set the start state for a specific precedence value. - * - * @param precedence The current precedence. - * @param startState The start state corresponding to the specified - * precedence. - * - * @throws IllegalStateException if this is not a precedence DFA. - * @see //isPrecedenceDfa() - */ - setPrecedenceStartState(precedence, startState) { - if (!(this.precedenceDfa)) { - throw ("Only precedence DFAs may contain a precedence start state."); - } - if (precedence < 0) { - return; - } - - /** - * synchronization on s0 here is ok. when the DFA is turned into a - * precedence DFA, s0 will be initialized once and not updated again - * s0.edges is never null for a precedence DFA - */ - this.s0.edges[precedence] = startState; - } - - /** - * Sets whether this is a precedence DFA. If the specified value differs - * from the current DFA configuration, the following actions are taken; - * otherwise no changes are made to the current DFA. - * - *
        - *
      • The {@link //states} map is cleared
      • - *
      • If {@code precedenceDfa} is {@code false}, the initial state - * {@link //s0} is set to {@code null}; otherwise, it is initialized to a new - * {@link DFAState} with an empty outgoing {@link DFAState//edges} array to - * store the start states for individual precedence values.
      • - *
      • The {@link //precedenceDfa} field is updated
      • - *
      - * - * @param precedenceDfa {@code true} if this is a precedence DFA; otherwise, - * {@code false} - */ - setPrecedenceDfa(precedenceDfa) { - if (this.precedenceDfa!==precedenceDfa) { - this._states = new HashSet(); - if (precedenceDfa) { - const precedenceState = new DFAState(null, new ATNConfigSet()); - precedenceState.edges = []; - precedenceState.isAcceptState = false; - precedenceState.requiresFullContext = false; - this.s0 = precedenceState; - } else { - this.s0 = null; - } - this.precedenceDfa = precedenceDfa; - } - } - - /** - * Return a list of all states in this DFA, ordered by state number. - */ - sortedStates() { - const list = this._states.values(); - return list.sort(function(a, b) { - return a.stateNumber - b.stateNumber; - }); - } - - toString(literalNames, symbolicNames) { - literalNames = literalNames || null; - symbolicNames = symbolicNames || null; - if (this.s0 === null) { - return ""; - } - const serializer = new DFASerializer(this, literalNames, symbolicNames); - return serializer.toString(); - } - - toLexerString() { - if (this.s0 === null) { - return ""; - } - const serializer = new LexerDFASerializer(this); - return serializer.toString(); - } - - get states(){ - return this._states; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/index.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - -/* harmony default export */ const dfa = ({ DFA: DFA, DFASerializer: DFASerializer, LexerDFASerializer: LexerDFASerializer, PredPrediction: PredPrediction }); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTreeListener.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -class ParseTreeListener { - visitTerminal(node) { - } - - visitErrorNode(node) { - } - - enterEveryRule(node) { - } - - exitEveryRule(node) { - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTreeVisitor.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -class ParseTreeVisitor { - visit(ctx) { - if (Array.isArray(ctx)) { - return ctx.map(function(child) { - return child.accept(this); - }, this); - } else { - return ctx.accept(this); - } - } - - visitChildren(ctx) { - if (ctx.children) { - return this.visit(ctx.children); - } else { - return null; - } - } - - visitTerminal(node) { - } - - visitErrorNode(node) { - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTreeWalker.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -class ParseTreeWalker { - - /** - * Performs a walk on the given parse tree starting at the root and going down recursively - * with depth-first search. On each node, {@link ParseTreeWalker//enterRule} is called before - * recursively walking down into child nodes, then - * {@link ParseTreeWalker//exitRule} is called after the recursive call to wind up. - * @param listener The listener used by the walker to process grammar rules - * @param t The parse tree to be walked on - */ - walk(listener, t) { - const errorNode = t instanceof ErrorNode || - (t.isErrorNode !== undefined && t.isErrorNode()); - if (errorNode) { - listener.visitErrorNode(t); - } else if (t instanceof TerminalNode) { - listener.visitTerminal(t); - } else { - this.enterRule(listener, t); - for (let i = 0; i < t.getChildCount(); i++) { - const child = t.getChild(i); - this.walk(listener, child); - } - this.exitRule(listener, t); - } - } - - /** - * Enters a grammar rule by first triggering the generic event {@link ParseTreeListener//enterEveryRule} - * then by triggering the event specific to the given parse tree node - * @param listener The listener responding to the trigger events - * @param r The grammar rule containing the rule context - */ - enterRule(listener, r) { - const ctx = r.getRuleContext(); - listener.enterEveryRule(ctx); - ctx.enterRule(listener); - } - - /** - * Exits a grammar rule by first triggering the event specific to the given parse tree node - * then by triggering the generic event {@link ParseTreeListener//exitEveryRule} - * @param listener The listener responding to the trigger events - * @param r The grammar rule containing the rule context - */ - exitRule(listener, r) { - const ctx = r.getRuleContext(); - ctx.exitRule(listener); - listener.exitEveryRule(ctx); - } -} - -ParseTreeWalker.DEFAULT = new ParseTreeWalker(); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/index.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - -/* harmony default export */ const tree = ({ Trees: tree_Trees, RuleNode: RuleNode, ErrorNode: ErrorNode, TerminalNode: TerminalNode, ParseTreeListener: ParseTreeListener, ParseTreeVisitor: ParseTreeVisitor, ParseTreeWalker: ParseTreeWalker }); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/InputMismatchException.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -/** - * This signifies any kind of mismatched input exceptions such as - * when the current input does not match the expected token. - */ -class InputMismatchException extends RecognitionException { - constructor(recognizer) { - super({message: "", recognizer: recognizer, input: recognizer.getInputStream(), ctx: recognizer._ctx}); - this.offendingToken = recognizer.getCurrentToken(); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/FailedPredicateException.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * A semantic predicate failed during validation. Validation of predicates - * occurs when normally parsing the alternative just like matching a token. - * Disambiguating predicate evaluation occurs when we test a predicate during - * prediction. - */ -class FailedPredicateException extends RecognitionException { - constructor(recognizer, predicate, message) { - super({ - message: formatMessage(predicate, message || null), recognizer: recognizer, - input: recognizer.getInputStream(), ctx: recognizer._ctx - }); - const s = recognizer._interp.atn.states[recognizer.state] - const trans = s.transitions[0] - if (trans instanceof PredicateTransition) { - this.ruleIndex = trans.ruleIndex; - this.predicateIndex = trans.predIndex; - } else { - this.ruleIndex = 0; - this.predicateIndex = 0; - } - this.predicate = predicate; - this.offendingToken = recognizer.getCurrentToken(); - } -} - - -function formatMessage(predicate, message) { - if (message !==null) { - return message; - } else { - return "failed predicate: {" + predicate + "}?"; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/DiagnosticErrorListener.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - -/** - * This implementation of {@link ANTLRErrorListener} can be used to identify - * certain potential correctness and performance problems in grammars. "Reports" - * are made by calling {@link Parser//notifyErrorListeners} with the appropriate - * message. - * - *
        - *
      • Ambiguities: These are cases where more than one path through the - * grammar can match the input.
      • - *
      • Weak context sensitivity: These are cases where full-context - * prediction resolved an SLL conflict to a unique alternative which equaled the - * minimum alternative of the SLL conflict.
      • - *
      • Strong (forced) context sensitivity: These are cases where the - * full-context prediction resolved an SLL conflict to a unique alternative, - * and the minimum alternative of the SLL conflict was found to not be - * a truly viable alternative. Two-stage parsing cannot be used for inputs where - * this situation occurs.
      • - *
      - */ -class DiagnosticErrorListener extends ErrorListener { - constructor(exactOnly) { - super(); - exactOnly = exactOnly || true; - // whether all ambiguities or only exact ambiguities are reported. - this.exactOnly = exactOnly; - } - - reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { - if (this.exactOnly && !exact) { - return; - } - const msg = "reportAmbiguity d=" + - this.getDecisionDescription(recognizer, dfa) + - ": ambigAlts=" + - this.getConflictingAlts(ambigAlts, configs) + - ", input='" + - recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'" - recognizer.notifyErrorListeners(msg); - } - - reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { - const msg = "reportAttemptingFullContext d=" + - this.getDecisionDescription(recognizer, dfa) + - ", input='" + - recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'" - recognizer.notifyErrorListeners(msg); - } - - reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) { - const msg = "reportContextSensitivity d=" + - this.getDecisionDescription(recognizer, dfa) + - ", input='" + - recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'" - recognizer.notifyErrorListeners(msg); - } - - getDecisionDescription(recognizer, dfa) { - const decision = dfa.decision - const ruleIndex = dfa.atnStartState.ruleIndex - - const ruleNames = recognizer.ruleNames - if (ruleIndex < 0 || ruleIndex >= ruleNames.length) { - return "" + decision; - } - const ruleName = ruleNames[ruleIndex] || null - if (ruleName === null || ruleName.length === 0) { - return "" + decision; - } - return `${decision} (${ruleName})`; - } - - /** - * Computes the set of conflicting or ambiguous alternatives from a - * configuration set, if that information was not already provided by the - * parser. - * - * @param reportedAlts The set of conflicting or ambiguous alternatives, as - * reported by the parser. - * @param configs The conflicting or ambiguous configuration set. - * @return Returns {@code reportedAlts} if it is not {@code null}, otherwise - * returns the set of alternatives represented in {@code configs}. - */ - getConflictingAlts(reportedAlts, configs) { - if (reportedAlts !== null) { - return reportedAlts; - } - const result = new BitSet() - for (let i = 0; i < configs.items.length; i++) { - result.add(configs.items[i].alt); - } - return `{${result.values().join(", ")}}`; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ParseCancellationException.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -class ParseCancellationException extends Error { - constructor() { - super() - Error.captureStackTrace(this, ParseCancellationException); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ErrorStrategy.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -class ErrorStrategy { - - reset(recognizer) { - } - - recoverInline(recognizer) { - } - - recover(recognizer, e) { - } - - sync(recognizer) { - } - - inErrorRecoveryMode(recognizer) { - } - - reportError(recognizer) { - } -} - - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/DefaultErrorStrategy.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - -/** - * This is the default implementation of {@link ANTLRErrorStrategy} used for - * error reporting and recovery in ANTLR parsers. - */ -class DefaultErrorStrategy extends ErrorStrategy { - constructor() { - super(); - /** - * Indicates whether the error strategy is currently "recovering from an - * error". This is used to suppress reporting multiple error messages while - * attempting to recover from a detected syntax error. - * - * @see //inErrorRecoveryMode - */ - this.errorRecoveryMode = false; - - /** - * The index into the input stream where the last error occurred. - * This is used to prevent infinite loops where an error is found - * but no token is consumed during recovery...another error is found, - * ad nauseum. This is a failsafe mechanism to guarantee that at least - * one token/tree node is consumed for two errors. - */ - this.lastErrorIndex = -1; - this.lastErrorStates = null; - this.nextTokensContext = null; - this.nextTokenState = 0; - } - - /** - *

      The default implementation simply calls {@link //endErrorCondition} to - * ensure that the handler is not in error recovery mode.

      - */ - reset(recognizer) { - this.endErrorCondition(recognizer); - } - - /** - * This method is called to enter error recovery mode when a recognition - * exception is reported. - * - * @param recognizer the parser instance - */ - beginErrorCondition(recognizer) { - this.errorRecoveryMode = true; - } - - inErrorRecoveryMode(recognizer) { - return this.errorRecoveryMode; - } - - /** - * This method is called to leave error recovery mode after recovering from - * a recognition exception. - * @param recognizer - */ - endErrorCondition(recognizer) { - this.errorRecoveryMode = false; - this.lastErrorStates = null; - this.lastErrorIndex = -1; - } - - /** - * {@inheritDoc} - *

      The default implementation simply calls {@link //endErrorCondition}.

      - */ - reportMatch(recognizer) { - this.endErrorCondition(recognizer); - } - - /** - * {@inheritDoc} - * - *

      The default implementation returns immediately if the handler is already - * in error recovery mode. Otherwise, it calls {@link //beginErrorCondition} - * and dispatches the reporting task based on the runtime type of {@code e} - * according to the following table.

      - * - *
        - *
      • {@link NoViableAltException}: Dispatches the call to - * {@link //reportNoViableAlternative}
      • - *
      • {@link InputMismatchException}: Dispatches the call to - * {@link //reportInputMismatch}
      • - *
      • {@link FailedPredicateException}: Dispatches the call to - * {@link //reportFailedPredicate}
      • - *
      • All other types: calls {@link Parser//notifyErrorListeners} to report - * the exception
      • - *
      - */ - reportError(recognizer, e) { - // if we've already reported an error and have not matched a token - // yet successfully, don't report any errors. - if(this.inErrorRecoveryMode(recognizer)) { - return; // don't report spurious errors - } - this.beginErrorCondition(recognizer); - if ( e instanceof NoViableAltException ) { - this.reportNoViableAlternative(recognizer, e); - } else if ( e instanceof InputMismatchException ) { - this.reportInputMismatch(recognizer, e); - } else if ( e instanceof FailedPredicateException ) { - this.reportFailedPredicate(recognizer, e); - } else { - console.log("unknown recognition error type: " + e.constructor.name); - console.log(e.stack); - recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e); - } - } - - /** - * - * {@inheritDoc} - * - *

      The default implementation resynchronizes the parser by consuming tokens - * until we find one in the resynchronization set--loosely the set of tokens - * that can follow the current rule.

      - * - */ - recover(recognizer, e) { - if (this.lastErrorIndex===recognizer.getInputStream().index && - this.lastErrorStates !== null && this.lastErrorStates.indexOf(recognizer.state)>=0) { - // uh oh, another error at same token index and previously-visited - // state in ATN; must be a case where LT(1) is in the recovery - // token set so nothing got consumed. Consume a single token - // at least to prevent an infinite loop; this is a failsafe. - recognizer.consume(); - } - this.lastErrorIndex = recognizer._input.index; - if (this.lastErrorStates === null) { - this.lastErrorStates = []; - } - this.lastErrorStates.push(recognizer.state); - const followSet = this.getErrorRecoverySet(recognizer) - this.consumeUntil(recognizer, followSet); - } - - /** - * The default implementation of {@link ANTLRErrorStrategy//sync} makes sure - * that the current lookahead symbol is consistent with what were expecting - * at this point in the ATN. You can call this anytime but ANTLR only - * generates code to check before subrules/loops and each iteration. - * - *

      Implements Jim Idle's magic sync mechanism in closures and optional - * subrules. E.g.,

      - * - *
      -     * a : sync ( stuff sync )* ;
      -     * sync : {consume to what can follow sync} ;
      -     * 
      - * - * At the start of a sub rule upon error, {@link //sync} performs single - * token deletion, if possible. If it can't do that, it bails on the current - * rule and uses the default error recovery, which consumes until the - * resynchronization set of the current rule. - * - *

      If the sub rule is optional ({@code (...)?}, {@code (...)*}, or block - * with an empty alternative), then the expected set includes what follows - * the subrule.

      - * - *

      During loop iteration, it consumes until it sees a token that can start a - * sub rule or what follows loop. Yes, that is pretty aggressive. We opt to - * stay in the loop as long as possible.

      - * - *

      ORIGINS

      - * - *

      Previous versions of ANTLR did a poor job of their recovery within loops. - * A single mismatch token or missing token would force the parser to bail - * out of the entire rules surrounding the loop. So, for rule

      - * - *
      -     * classDef : 'class' ID '{' member* '}'
      -     * 
      - * - * input with an extra token between members would force the parser to - * consume until it found the next class definition rather than the next - * member definition of the current class. - * - *

      This functionality cost a little bit of effort because the parser has to - * compare token set at the start of the loop and at each iteration. If for - * some reason speed is suffering for you, you can turn off this - * functionality by simply overriding this method as a blank { }.

      - * - */ - sync(recognizer) { - // If already recovering, don't try to sync - if (this.inErrorRecoveryMode(recognizer)) { - return; - } - const s = recognizer._interp.atn.states[recognizer.state]; - const la = recognizer.getTokenStream().LA(1); - // try cheaper subset first; might get lucky. seems to shave a wee bit off - const nextTokens = recognizer.atn.nextTokens(s); - if(nextTokens.contains(la)) { - this.nextTokensContext = null; - this.nextTokenState = ATNState.INVALID_STATE_NUMBER; - return; - } else if (nextTokens.contains(Token.EPSILON)) { - if(this.nextTokensContext === null) { - // It's possible the next token won't match information tracked - // by sync is restricted for performance. - this.nextTokensContext = recognizer._ctx; - this.nextTokensState = recognizer._stateNumber; - } - return; - } - switch (s.stateType) { - case ATNState.BLOCK_START: - case ATNState.STAR_BLOCK_START: - case ATNState.PLUS_BLOCK_START: - case ATNState.STAR_LOOP_ENTRY: - // report error and recover if possible - if( this.singleTokenDeletion(recognizer) !== null) { - return; - } else { - throw new InputMismatchException(recognizer); - } - case ATNState.PLUS_LOOP_BACK: - case ATNState.STAR_LOOP_BACK: - { - this.reportUnwantedToken(recognizer); - const expecting = new IntervalSet(); - expecting.addSet(recognizer.getExpectedTokens()); - const whatFollowsLoopIterationOrRule = expecting.addSet(this.getErrorRecoverySet(recognizer)); - this.consumeUntil(recognizer, whatFollowsLoopIterationOrRule); - } - break; - default: - // do nothing if we can't identify the exact kind of ATN state - } - } - - /** - * This is called by {@link //reportError} when the exception is a - * {@link NoViableAltException}. - * - * @see //reportError - * - * @param recognizer the parser instance - * @param e the recognition exception - */ - reportNoViableAlternative(recognizer, e) { - const tokens = recognizer.getTokenStream() - let input - if(tokens !== null) { - if (e.startToken.type===Token.EOF) { - input = ""; - } else { - input = tokens.getText(new Interval(e.startToken.tokenIndex, e.offendingToken.tokenIndex)); - } - } else { - input = ""; - } - const msg = "no viable alternative at input " + this.escapeWSAndQuote(input) - recognizer.notifyErrorListeners(msg, e.offendingToken, e); - } - - /** - * This is called by {@link //reportError} when the exception is an - * {@link InputMismatchException}. - * - * @see //reportError - * - * @param recognizer the parser instance - * @param e the recognition exception - */ - reportInputMismatch(recognizer, e) { - const msg = "mismatched input " + this.getTokenErrorDisplay(e.offendingToken) + - " expecting " + e.getExpectedTokens().toString(recognizer.literalNames, recognizer.symbolicNames) - recognizer.notifyErrorListeners(msg, e.offendingToken, e); - } - - /** - * This is called by {@link //reportError} when the exception is a - * {@link FailedPredicateException}. - * - * @see //reportError - * - * @param recognizer the parser instance - * @param e the recognition exception - */ - reportFailedPredicate(recognizer, e) { - const ruleName = recognizer.ruleNames[recognizer._ctx.ruleIndex] - const msg = "rule " + ruleName + " " + e.message - recognizer.notifyErrorListeners(msg, e.offendingToken, e); - } - - /** - * This method is called to report a syntax error which requires the removal - * of a token from the input stream. At the time this method is called, the - * erroneous symbol is current {@code LT(1)} symbol and has not yet been - * removed from the input stream. When this method returns, - * {@code recognizer} is in error recovery mode. - * - *

      This method is called when {@link //singleTokenDeletion} identifies - * single-token deletion as a viable recovery strategy for a mismatched - * input error.

      - * - *

      The default implementation simply returns if the handler is already in - * error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to - * enter error recovery mode, followed by calling - * {@link Parser//notifyErrorListeners}.

      - * - * @param recognizer the parser instance - * - */ - reportUnwantedToken(recognizer) { - if (this.inErrorRecoveryMode(recognizer)) { - return; - } - this.beginErrorCondition(recognizer); - const t = recognizer.getCurrentToken() - const tokenName = this.getTokenErrorDisplay(t) - const expecting = this.getExpectedTokens(recognizer) - const msg = "extraneous input " + tokenName + " expecting " + - expecting.toString(recognizer.literalNames, recognizer.symbolicNames) - recognizer.notifyErrorListeners(msg, t, null); - } - - /** - * This method is called to report a syntax error which requires the - * insertion of a missing token into the input stream. At the time this - * method is called, the missing token has not yet been inserted. When this - * method returns, {@code recognizer} is in error recovery mode. - * - *

      This method is called when {@link //singleTokenInsertion} identifies - * single-token insertion as a viable recovery strategy for a mismatched - * input error.

      - * - *

      The default implementation simply returns if the handler is already in - * error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to - * enter error recovery mode, followed by calling - * {@link Parser//notifyErrorListeners}.

      - * - * @param recognizer the parser instance - */ - reportMissingToken(recognizer) { - if ( this.inErrorRecoveryMode(recognizer)) { - return; - } - this.beginErrorCondition(recognizer); - const t = recognizer.getCurrentToken() - const expecting = this.getExpectedTokens(recognizer) - const msg = "missing " + expecting.toString(recognizer.literalNames, recognizer.symbolicNames) + - " at " + this.getTokenErrorDisplay(t) - recognizer.notifyErrorListeners(msg, t, null); - } - - /** - *

      The default implementation attempts to recover from the mismatched input - * by using single token insertion and deletion as described below. If the - * recovery attempt fails, this method throws an - * {@link InputMismatchException}.

      - * - *

      EXTRA TOKEN (single token deletion)

      - * - *

      {@code LA(1)} is not what we are looking for. If {@code LA(2)} has the - * right token, however, then assume {@code LA(1)} is some extra spurious - * token and delete it. Then consume and return the next token (which was - * the {@code LA(2)} token) as the successful result of the match operation.

      - * - *

      This recovery strategy is implemented by {@link - * //singleTokenDeletion}.

      - * - *

      MISSING TOKEN (single token insertion)

      - * - *

      If current token (at {@code LA(1)}) is consistent with what could come - * after the expected {@code LA(1)} token, then assume the token is missing - * and use the parser's {@link TokenFactory} to create it on the fly. The - * "insertion" is performed by returning the created token as the successful - * result of the match operation.

      - * - *

      This recovery strategy is implemented by {@link - * //singleTokenInsertion}.

      - * - *

      EXAMPLE

      - * - *

      For example, Input {@code i=(3;} is clearly missing the {@code ')'}. When - * the parser returns from the nested call to {@code expr}, it will have - * call chain:

      - * - *
      -     * stat → expr → atom
      -     * 
      - * - * and it will be trying to match the {@code ')'} at this point in the - * derivation: - * - *
      -     * => ID '=' '(' INT ')' ('+' atom)* ';'
      -     * ^
      -     * 
      - * - * The attempt to match {@code ')'} will fail when it sees {@code ';'} and - * call {@link //recoverInline}. To recover, it sees that {@code LA(1)==';'} - * is in the set of tokens that can follow the {@code ')'} token reference - * in rule {@code atom}. It can assume that you forgot the {@code ')'}. - */ - recoverInline(recognizer) { - // SINGLE TOKEN DELETION - const matchedSymbol = this.singleTokenDeletion(recognizer) - if (matchedSymbol !== null) { - // we have deleted the extra token. - // now, move past ttype token as if all were ok - recognizer.consume(); - return matchedSymbol; - } - // SINGLE TOKEN INSERTION - if (this.singleTokenInsertion(recognizer)) { - return this.getMissingSymbol(recognizer); - } - // even that didn't work; must throw the exception - throw new InputMismatchException(recognizer); - } - - /** - * This method implements the single-token insertion inline error recovery - * strategy. It is called by {@link //recoverInline} if the single-token - * deletion strategy fails to recover from the mismatched input. If this - * method returns {@code true}, {@code recognizer} will be in error recovery - * mode. - * - *

      This method determines whether or not single-token insertion is viable by - * checking if the {@code LA(1)} input symbol could be successfully matched - * if it were instead the {@code LA(2)} symbol. If this method returns - * {@code true}, the caller is responsible for creating and inserting a - * token with the correct type to produce this behavior.

      - * - * @param recognizer the parser instance - * @return {@code true} if single-token insertion is a viable recovery - * strategy for the current mismatched input, otherwise {@code false} - */ - singleTokenInsertion(recognizer) { - const currentSymbolType = recognizer.getTokenStream().LA(1) - // if current token is consistent with what could come after current - // ATN state, then we know we're missing a token; error recovery - // is free to conjure up and insert the missing token - const atn = recognizer._interp.atn - const currentState = atn.states[recognizer.state] - const next = currentState.transitions[0].target - const expectingAtLL2 = atn.nextTokens(next, recognizer._ctx) - if (expectingAtLL2.contains(currentSymbolType) ){ - this.reportMissingToken(recognizer); - return true; - } else { - return false; - } - } - - /** - * This method implements the single-token deletion inline error recovery - * strategy. It is called by {@link //recoverInline} to attempt to recover - * from mismatched input. If this method returns null, the parser and error - * handler state will not have changed. If this method returns non-null, - * {@code recognizer} will not be in error recovery mode since the - * returned token was a successful match. - * - *

      If the single-token deletion is successful, this method calls - * {@link //reportUnwantedToken} to report the error, followed by - * {@link Parser//consume} to actually "delete" the extraneous token. Then, - * before returning {@link //reportMatch} is called to signal a successful - * match.

      - * - * @param recognizer the parser instance - * @return the successfully matched {@link Token} instance if single-token - * deletion successfully recovers from the mismatched input, otherwise - * {@code null} - */ - singleTokenDeletion(recognizer) { - const nextTokenType = recognizer.getTokenStream().LA(2) - const expecting = this.getExpectedTokens(recognizer) - if (expecting.contains(nextTokenType)) { - this.reportUnwantedToken(recognizer); - // print("recoverFromMismatchedToken deleting " \ - // + str(recognizer.getTokenStream().LT(1)) \ - // + " since " + str(recognizer.getTokenStream().LT(2)) \ - // + " is what we want", file=sys.stderr) - recognizer.consume(); // simply delete extra token - // we want to return the token we're actually matching - const matchedSymbol = recognizer.getCurrentToken() - this.reportMatch(recognizer); // we know current token is correct - return matchedSymbol; - } else { - return null; - } - } - - /** - * Conjure up a missing token during error recovery. - * - * The recognizer attempts to recover from single missing - * symbols. But, actions might refer to that missing symbol. - * For example, x=ID {f($x);}. The action clearly assumes - * that there has been an identifier matched previously and that - * $x points at that token. If that token is missing, but - * the next token in the stream is what we want we assume that - * this token is missing and we keep going. Because we - * have to return some token to replace the missing token, - * we have to conjure one up. This method gives the user control - * over the tokens returned for missing tokens. Mostly, - * you will want to create something special for identifier - * tokens. For literals such as '{' and ',', the default - * action in the parser or tree parser works. It simply creates - * a CommonToken of the appropriate type. The text will be the token. - * If you change what tokens must be created by the lexer, - * override this method to create the appropriate tokens. - * - */ - getMissingSymbol(recognizer) { - const currentSymbol = recognizer.getCurrentToken() - const expecting = this.getExpectedTokens(recognizer) - const expectedTokenType = expecting.first() // get any element - let tokenText - if (expectedTokenType===Token.EOF) { - tokenText = ""; - } else { - tokenText = ""; - } - let current = currentSymbol - const lookback = recognizer.getTokenStream().LT(-1) - if (current.type===Token.EOF && lookback !== null) { - current = lookback; - } - return recognizer.getTokenFactory().create(current.source, - expectedTokenType, tokenText, Token.DEFAULT_CHANNEL, - -1, -1, current.line, current.column); - } - - getExpectedTokens(recognizer) { - return recognizer.getExpectedTokens(); - } - - /** - * How should a token be displayed in an error message? The default - * is to display just the text, but during development you might - * want to have a lot of information spit out. Override in that case - * to use t.toString() (which, for CommonToken, dumps everything about - * the token). This is better than forcing you to override a method in - * your token objects because you don't have to go modify your lexer - * so that it creates a new Java type. - */ - getTokenErrorDisplay(t) { - if (t === null) { - return ""; - } - let s = t.text - if (s === null) { - if (t.type===Token.EOF) { - s = ""; - } else { - s = "<" + t.type + ">"; - } - } - return this.escapeWSAndQuote(s); - } - - escapeWSAndQuote(s) { - s = s.replace(/\n/g,"\\n"); - s = s.replace(/\r/g,"\\r"); - s = s.replace(/\t/g,"\\t"); - return "'" + s + "'"; - } - - /** - * Compute the error recovery set for the current rule. During - * rule invocation, the parser pushes the set of tokens that can - * follow that rule reference on the stack; this amounts to - * computing FIRST of what follows the rule reference in the - * enclosing rule. See LinearApproximator.FIRST(). - * This local follow set only includes tokens - * from within the rule; i.e., the FIRST computation done by - * ANTLR stops at the end of a rule. - * - * EXAMPLE - * - * When you find a "no viable alt exception", the input is not - * consistent with any of the alternatives for rule r. The best - * thing to do is to consume tokens until you see something that - * can legally follow a call to r//or* any rule that called r. - * You don't want the exact set of viable next tokens because the - * input might just be missing a token--you might consume the - * rest of the input looking for one of the missing tokens. - * - * Consider grammar: - * - * a : '[' b ']' - * | '(' b ')' - * ; - * b : c '^' INT ; - * c : ID - * | INT - * ; - * - * At each rule invocation, the set of tokens that could follow - * that rule is pushed on a stack. Here are the various - * context-sensitive follow sets: - * - * FOLLOW(b1_in_a) = FIRST(']') = ']' - * FOLLOW(b2_in_a) = FIRST(')') = ')' - * FOLLOW(c_in_b) = FIRST('^') = '^' - * - * Upon erroneous input "[]", the call chain is - * - * a -> b -> c - * - * and, hence, the follow context stack is: - * - * depth follow set start of rule execution - * 0 a (from main()) - * 1 ']' b - * 2 '^' c - * - * Notice that ')' is not included, because b would have to have - * been called from a different context in rule a for ')' to be - * included. - * - * For error recovery, we cannot consider FOLLOW(c) - * (context-sensitive or otherwise). We need the combined set of - * all context-sensitive FOLLOW sets--the set of all tokens that - * could follow any reference in the call chain. We need to - * resync to one of those tokens. Note that FOLLOW(c)='^' and if - * we resync'd to that token, we'd consume until EOF. We need to - * sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}. - * In this case, for input "[]", LA(1) is ']' and in the set, so we would - * not consume anything. After printing an error, rule c would - * return normally. Rule b would not find the required '^' though. - * At this point, it gets a mismatched token error and throws an - * exception (since LA(1) is not in the viable following token - * set). The rule exception handler tries to recover, but finds - * the same recovery set and doesn't consume anything. Rule b - * exits normally returning to rule a. Now it finds the ']' (and - * with the successful match exits errorRecovery mode). - * - * So, you can see that the parser walks up the call chain looking - * for the token that was a member of the recovery set. - * - * Errors are not generated in errorRecovery mode. - * - * ANTLR's error recovery mechanism is based upon original ideas: - * - * "Algorithms + Data Structures = Programs" by Niklaus Wirth - * - * and - * - * "A note on error recovery in recursive descent parsers": - * http://portal.acm.org/citation.cfm?id=947902.947905 - * - * Later, Josef Grosch had some good ideas: - * - * "Efficient and Comfortable Error Recovery in Recursive Descent - * Parsers": - * ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip - * - * Like Grosch I implement context-sensitive FOLLOW sets that are combined - * at run-time upon error to avoid overhead during parsing. - */ - getErrorRecoverySet(recognizer) { - const atn = recognizer._interp.atn - let ctx = recognizer._ctx - const recoverSet = new IntervalSet() - while (ctx !== null && ctx.invokingState>=0) { - // compute what follows who invoked us - const invokingState = atn.states[ctx.invokingState] - const rt = invokingState.transitions[0] - const follow = atn.nextTokens(rt.followState) - recoverSet.addSet(follow); - ctx = ctx.parentCtx; - } - recoverSet.removeOne(Token.EPSILON); - return recoverSet; - } - -// Consume tokens until one matches the given token set.// - consumeUntil(recognizer, set) { - let ttype = recognizer.getTokenStream().LA(1) - while( ttype !== Token.EOF && !set.contains(ttype)) { - recognizer.consume(); - ttype = recognizer.getTokenStream().LA(1); - } - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/BailErrorStrategy.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -/** - * This implementation of {@link ANTLRErrorStrategy} responds to syntax errors - * by immediately canceling the parse operation with a - * {@link ParseCancellationException}. The implementation ensures that the - * {@link ParserRuleContext//exception} field is set for all parse tree nodes - * that were not completed prior to encountering the error. - * - *

      - * This error strategy is useful in the following scenarios.

      - * - *
        - *
      • Two-stage parsing: This error strategy allows the first - * stage of two-stage parsing to immediately terminate if an error is - * encountered, and immediately fall back to the second stage. In addition to - * avoiding wasted work by attempting to recover from errors here, the empty - * implementation of {@link BailErrorStrategy//sync} improves the performance of - * the first stage.
      • - *
      • Silent validation: When syntax errors are not being - * reported or logged, and the parse result is simply ignored if errors occur, - * the {@link BailErrorStrategy} avoids wasting work on recovering from errors - * when the result will be ignored either way.
      • - *
      - * - *

      - * {@code myparser.setErrorHandler(new BailErrorStrategy());}

      - * - * @see Parser//setErrorHandler(ANTLRErrorStrategy) - * */ -class BailErrorStrategy extends DefaultErrorStrategy { - - constructor() { - super(); - } - - /** - * Instead of recovering from exception {@code e}, re-throw it wrapped - * in a {@link ParseCancellationException} so it is not caught by the - * rule function catches. Use {@link Exception//getCause()} to get the - * original {@link RecognitionException}. - */ - recover(recognizer, e) { - let context = recognizer._ctx - while (context !== null) { - context.exception = e; - context = context.parentCtx; - } - throw new ParseCancellationException(e); - } - - /** - * Make sure we don't attempt to recover inline; if the parser - * successfully recovers, it won't throw an exception. - */ - recoverInline(recognizer) { - this.recover(recognizer, new InputMismatchException(recognizer)); - } - -// Make sure we don't attempt to recover from problems in subrules.// - sync(recognizer) { - // pass - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/index.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - - - -/* harmony default export */ const error = ({ - RecognitionException: RecognitionException, NoViableAltException: NoViableAltException, LexerNoViableAltException: LexerNoViableAltException, InputMismatchException: InputMismatchException, FailedPredicateException: FailedPredicateException, - DiagnosticErrorListener: DiagnosticErrorListener, BailErrorStrategy: BailErrorStrategy, DefaultErrorStrategy: DefaultErrorStrategy, ErrorListener: ErrorListener -}); - -// EXTERNAL MODULE: fs (ignored) -var fs_ignored_ = __webpack_require__(262); -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CharStreams.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -/** - * Utility functions to create InputStreams from various sources. - * - * All returned InputStreams support the full range of Unicode - * up to U+10FFFF (the default behavior of InputStream only supports - * code points up to U+FFFF). - */ -/* harmony default export */ const CharStreams = ({ - // Creates an InputStream from a string. - fromString: function(str) { - return new InputStream(str, true); - }, - - /** - * Asynchronously creates an InputStream from a blob given the - * encoding of the bytes in that blob (defaults to 'utf8' if - * encoding is null). - * - * Invokes onLoad(result) on success, onError(error) on - * failure. - */ - fromBlob: function(blob, encoding, onLoad, onError) { - const reader = new window.FileReader(); - reader.onload = function(e) { - const is = new InputStream(e.target.result, true); - onLoad(is); - }; - reader.onerror = onError; - reader.readAsText(blob, encoding); - }, - - /** - * Creates an InputStream from a Buffer given the - * encoding of the bytes in that buffer (defaults to 'utf8' if - * encoding is null). - */ - fromBuffer: function(buffer, encoding) { - return new InputStream(buffer.toString(encoding), true); - }, - - /** Asynchronously creates an InputStream from a file on disk given - * the encoding of the bytes in that file (defaults to 'utf8' if - * encoding is null). - * - * Invokes callback(error, result) on completion. - */ - fromPath: function(path, encoding, callback) { - fs_ignored_.readFile(path, encoding, function(err, data) { - let is = null; - if (data !== null) { - is = new InputStream(data, true); - } - callback(err, is); - }); - }, - - /** - * Synchronously creates an InputStream given a path to a file - * on disk and the encoding of the bytes in that file (defaults to - * 'utf8' if encoding is null). - */ - fromPathSync: function(path, encoding) { - const data = fs_ignored_.readFileSync(path, encoding); - return new InputStream(data, true); - } -}); - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/FileStream.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -/** - * This is an InputStream that is loaded from a file all at once - * when you construct the object. - */ -class FileStream extends InputStream { - constructor(fileName, decodeToUnicodeCodePoints) { - const data = fs_ignored_.readFileSync(fileName, "utf8"); - super(data, decodeToUnicodeCodePoints); - this.fileName = fileName; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/TraceListener.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - -class TraceListener extends ParseTreeListener { - constructor(parser) { - super(); - this.parser = parser; - } - - enterEveryRule(ctx) { - console.log("enter " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text); - } - - visitTerminal(node) { - console.log("consume " + node.symbol + " rule " + this.parser.ruleNames[this.parser._ctx.ruleIndex]); - } - - exitEveryRule(ctx) { - console.log("exit " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Parser.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - - - - -class Parser extends Recognizer { - /** - * this is all the parsing support code essentially; most of it is error - * recovery stuff. - */ - constructor(input) { - super(); - // The input stream. - this._input = null; - /** - * The error handling strategy for the parser. The default value is a new - * instance of {@link DefaultErrorStrategy}. - */ - this._errHandler = new DefaultErrorStrategy(); - this._precedenceStack = []; - this._precedenceStack.push(0); - /** - * The {@link ParserRuleContext} object for the currently executing rule. - * this is always non-null during the parsing process. - */ - this._ctx = null; - /** - * Specifies whether or not the parser should construct a parse tree during - * the parsing process. The default value is {@code true}. - */ - this.buildParseTrees = true; - /** - * When {@link //setTrace}{@code (true)} is called, a reference to the - * {@link TraceListener} is stored here so it can be easily removed in a - * later call to {@link //setTrace}{@code (false)}. The listener itself is - * implemented as a parser listener so this field is not directly used by - * other parser methods. - */ - this._tracer = null; - /** - * The list of {@link ParseTreeListener} listeners registered to receive - * events during the parse. - */ - this._parseListeners = null; - /** - * The number of syntax errors reported during parsing. this value is - * incremented each time {@link //notifyErrorListeners} is called. - */ - this._syntaxErrors = 0; - this.setInputStream(input); - } - - // reset the parser's state - reset() { - if (this._input !== null) { - this._input.seek(0); - } - this._errHandler.reset(this); - this._ctx = null; - this._syntaxErrors = 0; - this.setTrace(false); - this._precedenceStack = []; - this._precedenceStack.push(0); - if (this._interp !== null) { - this._interp.reset(); - } - } - - /** - * Match current input symbol against {@code ttype}. If the symbol type - * matches, {@link ANTLRErrorStrategy//reportMatch} and {@link //consume} are - * called to complete the match process. - * - *

      If the symbol type does not match, - * {@link ANTLRErrorStrategy//recoverInline} is called on the current error - * strategy to attempt recovery. If {@link //getBuildParseTree} is - * {@code true} and the token index of the symbol returned by - * {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to - * the parse tree by calling {@link ParserRuleContext//addErrorNode}.

      - * - * @param ttype the token type to match - * @return the matched symbol - * @throws RecognitionException if the current input symbol did not match - * {@code ttype} and the error strategy could not recover from the - * mismatched symbol - */ - match(ttype) { - let t = this.getCurrentToken(); - if (t.type === ttype) { - this._errHandler.reportMatch(this); - this.consume(); - } else { - t = this._errHandler.recoverInline(this); - if (this.buildParseTrees && t.tokenIndex === -1) { - // we must have conjured up a new token during single token - // insertion - // if it's not the current symbol - this._ctx.addErrorNode(t); - } - } - return t; - } - - /** - * Match current input symbol as a wildcard. If the symbol type matches - * (i.e. has a value greater than 0), {@link ANTLRErrorStrategy//reportMatch} - * and {@link //consume} are called to complete the match process. - * - *

      If the symbol type does not match, - * {@link ANTLRErrorStrategy//recoverInline} is called on the current error - * strategy to attempt recovery. If {@link //getBuildParseTree} is - * {@code true} and the token index of the symbol returned by - * {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to - * the parse tree by calling {@link ParserRuleContext//addErrorNode}.

      - * - * @return the matched symbol - * @throws RecognitionException if the current input symbol did not match - * a wildcard and the error strategy could not recover from the mismatched - * symbol - */ - matchWildcard() { - let t = this.getCurrentToken(); - if (t.type > 0) { - this._errHandler.reportMatch(this); - this.consume(); - } else { - t = this._errHandler.recoverInline(this); - if (this._buildParseTrees && t.tokenIndex === -1) { - // we must have conjured up a new token during single token - // insertion - // if it's not the current symbol - this._ctx.addErrorNode(t); - } - } - return t; - } - - getParseListeners() { - return this._parseListeners || []; - } - - /** - * Registers {@code listener} to receive events during the parsing process. - * - *

      To support output-preserving grammar transformations (including but not - * limited to left-recursion removal, automated left-factoring, and - * optimized code generation), calls to listener methods during the parse - * may differ substantially from calls made by - * {@link ParseTreeWalker//DEFAULT} used after the parse is complete. In - * particular, rule entry and exit events may occur in a different order - * during the parse than after the parser. In addition, calls to certain - * rule entry methods may be omitted.

      - * - *

      With the following specific exceptions, calls to listener events are - * deterministic, i.e. for identical input the calls to listener - * methods will be the same.

      - * - *
        - *
      • Alterations to the grammar used to generate code may change the - * behavior of the listener calls.
      • - *
      • Alterations to the command line options passed to ANTLR 4 when - * generating the parser may change the behavior of the listener calls.
      • - *
      • Changing the version of the ANTLR Tool used to generate the parser - * may change the behavior of the listener calls.
      • - *
      - * - * @param listener the listener to add - * - * @throws NullPointerException if {@code} listener is {@code null} - */ - addParseListener(listener) { - if (listener === null) { - throw "listener"; - } - if (this._parseListeners === null) { - this._parseListeners = []; - } - this._parseListeners.push(listener); - } - - /** - * Remove {@code listener} from the list of parse listeners. - * - *

      If {@code listener} is {@code null} or has not been added as a parse - * listener, this method does nothing.

      - * @param listener the listener to remove - */ - removeParseListener(listener) { - if (this._parseListeners !== null) { - const idx = this._parseListeners.indexOf(listener); - if (idx >= 0) { - this._parseListeners.splice(idx, 1); - } - if (this._parseListeners.length === 0) { - this._parseListeners = null; - } - } - } - - // Remove all parse listeners. - removeParseListeners() { - this._parseListeners = null; - } - - // Notify any parse listeners of an enter rule event. - triggerEnterRuleEvent() { - if (this._parseListeners !== null) { - const ctx = this._ctx; - this._parseListeners.forEach(function (listener) { - listener.enterEveryRule(ctx); - ctx.enterRule(listener); - }); - } - } - - /** - * Notify any parse listeners of an exit rule event. - * @see //addParseListener - */ - triggerExitRuleEvent() { - if (this._parseListeners !== null) { - // reverse order walk of listeners - const ctx = this._ctx; - this._parseListeners.slice(0).reverse().forEach(function (listener) { - ctx.exitRule(listener); - listener.exitEveryRule(ctx); - }); - } - } - - getTokenFactory() { - return this._input.tokenSource._factory; - } - - // Tell our token source and error strategy about a new way to create tokens. - setTokenFactory(factory) { - this._input.tokenSource._factory = factory; - } - - /** - * The ATN with bypass alternatives is expensive to create so we create it - * lazily. - * - * @throws UnsupportedOperationException if the current parser does not - * implement the {@link //getSerializedATN()} method. - */ - getATNWithBypassAlts() { - const serializedAtn = this.getSerializedATN(); - if (serializedAtn === null) { - throw "The current parser does not support an ATN with bypass alternatives."; - } - let result = this.bypassAltsAtnCache[serializedAtn]; - if (result === null) { - const deserializationOptions = new ATNDeserializationOptions(); - deserializationOptions.generateRuleBypassTransitions = true; - result = new ATNDeserializer(deserializationOptions) - .deserialize(serializedAtn); - this.bypassAltsAtnCache[serializedAtn] = result; - } - return result; - } - - getInputStream() { - return this.getTokenStream(); - } - - setInputStream(input) { - this.setTokenStream(input); - } - - getTokenStream() { - return this._input; - } - - // Set the token stream and reset the parser. - setTokenStream(input) { - this._input = null; - this.reset(); - this._input = input; - } - - /** - * Match needs to return the current input symbol, which gets put - * into the label for the associated token ref; e.g., x=ID. - */ - getCurrentToken() { - return this._input.LT(1); - } - - notifyErrorListeners(msg, offendingToken, err) { - offendingToken = offendingToken || null; - err = err || null; - if (offendingToken === null) { - offendingToken = this.getCurrentToken(); - } - this._syntaxErrors += 1; - const line = offendingToken.line; - const column = offendingToken.column; - const listener = this.getErrorListenerDispatch(); - listener.syntaxError(this, offendingToken, line, column, msg, err); - } - - /** - * Consume and return the {@linkplain //getCurrentToken current symbol}. - * - *

      E.g., given the following input with {@code A} being the current - * lookahead symbol, this function moves the cursor to {@code B} and returns - * {@code A}.

      - * - *
      -     * A B
      -     * ^
      -     * 
      - * - * If the parser is not in error recovery mode, the consumed symbol is added - * to the parse tree using {@link ParserRuleContext//addChild(Token)}, and - * {@link ParseTreeListener//visitTerminal} is called on any parse listeners. - * If the parser is in error recovery mode, the consumed symbol is - * added to the parse tree using - * {@link ParserRuleContext//addErrorNode(Token)}, and - * {@link ParseTreeListener//visitErrorNode} is called on any parse - * listeners. - */ - consume() { - const o = this.getCurrentToken(); - if (o.type !== Token.EOF) { - this.getInputStream().consume(); - } - const hasListener = this._parseListeners !== null && this._parseListeners.length > 0; - if (this.buildParseTrees || hasListener) { - let node; - if (this._errHandler.inErrorRecoveryMode(this)) { - node = this._ctx.addErrorNode(o); - } else { - node = this._ctx.addTokenNode(o); - } - node.invokingState = this.state; - if (hasListener) { - this._parseListeners.forEach(function (listener) { - if (node instanceof ErrorNode || (node.isErrorNode !== undefined && node.isErrorNode())) { - listener.visitErrorNode(node); - } else if (node instanceof TerminalNode) { - listener.visitTerminal(node); - } - }); - } - } - return o; - } - - addContextToParseTree() { - // add current context to parent if we have a parent - if (this._ctx.parentCtx !== null) { - this._ctx.parentCtx.addChild(this._ctx); - } - } - - /** - * Always called by generated parsers upon entry to a rule. Access field - * {@link //_ctx} get the current context. - */ - enterRule(localctx, state, ruleIndex) { - this.state = state; - this._ctx = localctx; - this._ctx.start = this._input.LT(1); - if (this.buildParseTrees) { - this.addContextToParseTree(); - } - this.triggerEnterRuleEvent(); - } - - exitRule() { - this._ctx.stop = this._input.LT(-1); - // trigger event on _ctx, before it reverts to parent - this.triggerExitRuleEvent(); - this.state = this._ctx.invokingState; - this._ctx = this._ctx.parentCtx; - } - - enterOuterAlt(localctx, altNum) { - localctx.setAltNumber(altNum); - // if we have new localctx, make sure we replace existing ctx - // that is previous child of parse tree - if (this.buildParseTrees && this._ctx !== localctx) { - if (this._ctx.parentCtx !== null) { - this._ctx.parentCtx.removeLastChild(); - this._ctx.parentCtx.addChild(localctx); - } - } - this._ctx = localctx; - } - - /** - * Get the precedence level for the top-most precedence rule. - * - * @return The precedence level for the top-most precedence rule, or -1 if - * the parser context is not nested within a precedence rule. - */ - getPrecedence() { - if (this._precedenceStack.length === 0) { - return -1; - } else { - return this._precedenceStack[this._precedenceStack.length - 1]; - } - } - - enterRecursionRule(localctx, state, ruleIndex, precedence) { - this.state = state; - this._precedenceStack.push(precedence); - this._ctx = localctx; - this._ctx.start = this._input.LT(1); - this.triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules - } - - // Like {@link //enterRule} but for recursive rules. - pushNewRecursionContext(localctx, state, ruleIndex) { - const previous = this._ctx; - previous.parentCtx = localctx; - previous.invokingState = state; - previous.stop = this._input.LT(-1); - - this._ctx = localctx; - this._ctx.start = previous.start; - if (this.buildParseTrees) { - this._ctx.addChild(previous); - } - this.triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules - } - - unrollRecursionContexts(parentCtx) { - this._precedenceStack.pop(); - this._ctx.stop = this._input.LT(-1); - const retCtx = this._ctx; // save current ctx (return value) - // unroll so _ctx is as it was before call to recursive method - const parseListeners = this.getParseListeners(); - if (parseListeners !== null && parseListeners.length > 0) { - while (this._ctx !== parentCtx) { - this.triggerExitRuleEvent(); - this._ctx = this._ctx.parentCtx; - } - } else { - this._ctx = parentCtx; - } - // hook into tree - retCtx.parentCtx = parentCtx; - if (this.buildParseTrees && parentCtx !== null) { - // add return ctx into invoking rule's tree - parentCtx.addChild(retCtx); - } - } - - getInvokingContext(ruleIndex) { - let ctx = this._ctx; - while (ctx !== null) { - if (ctx.ruleIndex === ruleIndex) { - return ctx; - } - ctx = ctx.parentCtx; - } - return null; - } - - precpred(localctx, precedence) { - return precedence >= this._precedenceStack[this._precedenceStack.length - 1]; - } - - inContext(context) { - // TODO: useful in parser? - return false; - } - - /** - * Checks whether or not {@code symbol} can follow the current state in the - * ATN. The behavior of this method is equivalent to the following, but is - * implemented such that the complete context-sensitive follow set does not - * need to be explicitly constructed. - * - *
      -     * return getExpectedTokens().contains(symbol);
      -     * 
      - * - * @param symbol the symbol type to check - * @return {@code true} if {@code symbol} can follow the current state in - * the ATN, otherwise {@code false}. - */ - isExpectedToken(symbol) { - const atn = this._interp.atn; - let ctx = this._ctx; - const s = atn.states[this.state]; - let following = atn.nextTokens(s); - if (following.contains(symbol)) { - return true; - } - if (!following.contains(Token.EPSILON)) { - return false; - } - while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) { - const invokingState = atn.states[ctx.invokingState]; - const rt = invokingState.transitions[0]; - following = atn.nextTokens(rt.followState); - if (following.contains(symbol)) { - return true; - } - ctx = ctx.parentCtx; - } - if (following.contains(Token.EPSILON) && symbol === Token.EOF) { - return true; - } else { - return false; - } - } - - /** - * Computes the set of input symbols which could follow the current parser - * state and context, as given by {@link //getState} and {@link //getContext}, - * respectively. - * - * @see ATN//getExpectedTokens(int, RuleContext) - */ - getExpectedTokens() { - return this._interp.atn.getExpectedTokens(this.state, this._ctx); - } - - getExpectedTokensWithinCurrentRule() { - const atn = this._interp.atn; - const s = atn.states[this.state]; - return atn.nextTokens(s); - } - - // Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found. - getRuleIndex(ruleName) { - const ruleIndex = this.getRuleIndexMap()[ruleName]; - if (ruleIndex !== null) { - return ruleIndex; - } else { - return -1; - } - } - - /** - * Return List<String> of the rule names in your parser instance - * leading up to a call to the current rule. You could override if - * you want more details such as the file/line info of where - * in the ATN a rule is invoked. - * - * this is very useful for error messages. - */ - getRuleInvocationStack(p) { - p = p || null; - if (p === null) { - p = this._ctx; - } - const stack = []; - while (p !== null) { - // compute what follows who invoked us - const ruleIndex = p.ruleIndex; - if (ruleIndex < 0) { - stack.push("n/a"); - } else { - stack.push(this.ruleNames[ruleIndex]); - } - p = p.parentCtx; - } - return stack; - } - - // For debugging and other purposes. - getDFAStrings() { - return this._interp.decisionToDFA.toString(); - } - - // For debugging and other purposes. - dumpDFA() { - let seenOne = false; - for (let i = 0; i < this._interp.decisionToDFA.length; i++) { - const dfa = this._interp.decisionToDFA[i]; - if (dfa.states.length > 0) { - if (seenOne) { - console.log(); - } - this.printer.println("Decision " + dfa.decision + ":"); - this.printer.print(dfa.toString(this.literalNames, this.symbolicNames)); - seenOne = true; - } - } - } - - /* - " printer = function() {\r\n" + - " this.println = function(s) { document.getElementById('output') += s + '\\n'; }\r\n" + - " this.print = function(s) { document.getElementById('output') += s; }\r\n" + - " };\r\n" + - */ - getSourceName() { - return this._input.sourceName; - } - - /** - * During a parse is sometimes useful to listen in on the rule entry and exit - * events as well as token matches. this is for quick and dirty debugging. - */ - setTrace(trace) { - if (!trace) { - this.removeParseListener(this._tracer); - this._tracer = null; - } else { - if (this._tracer !== null) { - this.removeParseListener(this._tracer); - } - this._tracer = new TraceListener(this); - this.addParseListener(this._tracer); - } - } -} - -/** - * this field maps from the serialized ATN string to the deserialized {@link - * ATN} with - * bypass alternatives. - * - * @see ATNDeserializationOptions//isGenerateRuleBypassTransitions() - */ -Parser.bypassAltsAtnCache = {}; - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/PredictionContextCache.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - -/** - * Used to cache {@link PredictionContext} objects. Its used for the shared - * context cash associated with contexts in DFA states. This cache - * can be used for both lexers and parsers. - */ -class PredictionContextCache { - - constructor() { - this.cache = new HashMap_HashMap(); - } - - /** - * Add a context to the cache and return it. If the context already exists, - * return that one instead and do not add a new context to the cache. - * Protect shared cache from unsafe thread access. - */ - add(ctx) { - if (ctx === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; - } - const existing = this.cache.get(ctx) || null; - if (existing !== null) { - return existing; - } - this.cache.set(ctx, ctx); - return ctx; - } - - get(ctx) { - return this.cache.get(ctx) || null; - } - - get length(){ - return this.cache.length; - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/TerminalNodeImpl.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - -class TerminalNodeImpl extends TerminalNode { - constructor(symbol) { - super(); - this.parentCtx = null; - this.symbol = symbol; - } - - getChild(i) { - return null; - } - - getSymbol() { - return this.symbol; - } - - getParent() { - return this.parentCtx; - } - - getPayload() { - return this.symbol; - } - - getSourceInterval() { - if (this.symbol === null) { - return Interval.INVALID_INTERVAL; - } - const tokenIndex = this.symbol.tokenIndex; - return new Interval(tokenIndex, tokenIndex); - } - - getChildCount() { - return 0; - } - - accept(visitor) { - return visitor.visitTerminal(this); - } - - getText() { - return this.symbol.text; - } - - toString() { - if (this.symbol.type === Token.EOF) { - return ""; - } else { - return this.symbol.text; - } - } -} - - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ErrorNodeImpl.js -/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. - * Use is of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/** - * Represents a token that was consumed during resynchronization - * rather than during a valid match operation. For example, - * we will create this kind of a node during single token insertion - * and deletion as well as during "consume until error recovery set" - * upon no viable alternative exceptions. - */ - - -class ErrorNodeImpl extends TerminalNodeImpl { - constructor(token) { - super(token); - } - - isErrorNode() { - return true; - } - - accept(visitor) { - return visitor.visitErrorNode(this); - } -} - -;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/ParserRuleContext.js -/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - - - - - - - -/** - * A rule invocation record for parsing. - * - * Contains all of the information about the current rule not stored in the - * RuleContext. It handles parse tree children list, Any ATN state - * tracing, and the default values available for rule indications: - * start, stop, rule index, current alt number, current - * ATN state. - * - * Subclasses made for each rule and grammar track the parameters, - * return values, locals, and labels specific to that rule. These - * are the objects that are returned from rules. - * - * Note text is not an actual field of a rule return value; it is computed - * from start and stop using the input stream's toString() method. I - * could add a ctor to this so that we can pass in and store the input - * stream, but I'm not sure we want to do that. It would seem to be undefined - * to get the .text property anyway if the rule matches tokens from multiple - * input streams. - * - * I do not use getters for fields of objects that are used simply to - * group values such as this aggregate. The getters/setters are there to - * satisfy the superclass interface. - */ -class ParserRuleContext extends RuleContext { - constructor(parent, invokingStateNumber) { - parent = parent || null; - invokingStateNumber = invokingStateNumber || null; - super(parent, invokingStateNumber); - this.ruleIndex = -1; - /** - * If we are debugging or building a parse tree for a visitor, - * we need to track all of the tokens and rule invocations associated - * with this rule's context. This is empty for parsing w/o tree constr. - * operation because we don't the need to track the details about - * how we parse this rule. - */ - this.children = null; - this.start = null; - this.stop = null; - /** - * The exception that forced this rule to return. If the rule successfully - * completed, this is {@code null}. - */ - this.exception = null; - } - - // COPY a ctx (I'm deliberately not using copy constructor) - copyFrom(ctx) { - // from RuleContext - this.parentCtx = ctx.parentCtx; - this.invokingState = ctx.invokingState; - this.children = null; - this.start = ctx.start; - this.stop = ctx.stop; - // copy any error nodes to alt label node - if(ctx.children) { - this.children = []; - // reset parent pointer for any error nodes - ctx.children.map(function(child) { - if (child instanceof ErrorNodeImpl) { - this.children.push(child); - child.parentCtx = this; - } - }, this); - } - } - - // Double dispatch methods for listeners - enterRule(listener) { - } - - exitRule(listener) { - } - - // Does not set parent link; other add methods do that - addChild(child) { - if (this.children === null) { - this.children = []; - } - this.children.push(child); - return child; - } - - /** Used by enterOuterAlt to toss out a RuleContext previously added as - * we entered a rule. If we have // label, we will need to remove - * generic ruleContext object. - */ - removeLastChild() { - if (this.children !== null) { - this.children.pop(); - } - } - - addTokenNode(token) { - const node = new TerminalNodeImpl(token); - this.addChild(node); - node.parentCtx = this; - return node; - } - - addErrorNode(badToken) { - const node = new ErrorNodeImpl(badToken); - this.addChild(node); - node.parentCtx = this; - return node; - } - - getChild(i, type) { - type = type || null; - if (this.children === null || i < 0 || i >= this.children.length) { - return null; - } - if (type === null) { - return this.children[i]; - } else { - for(let j=0; j= this.children.length) { - return null; - } - for(let j=0; j new src_antlr4.dfa.DFA(ds, index) ); - -class n3Lexer_n3Lexer extends src_antlr4.Lexer { - - static grammarFileName = "n3.g4"; - static channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]; - static modeNames = [ "DEFAULT_MODE" ]; - static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", "','", - "'a'", "'has'", "'is'", "'of'", "'='", "'<='", - "'=>'", "'<-'", "'!'", "'^'", "'['", "']'", "'('", - "')'", "'{'", "'}'", "'^^'" ]; - static symbolicNames = [ null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, "COMMENT", - "BooleanLiteral", "String", "IRIREF", "PNAME_NS", - "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", - "DECIMAL", "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", - "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", - "WS", "IPLSTART", "ANON", "QuickVarName", "PN_CHARS_U", - "PN_CHARS_BASE", "PN_CHARS", "BASE", "PREFIX", - "PN_PREFIX", "PN_LOCAL", "PLX", "PERCENT", "HEX", - "PN_LOCAL_ESC" ]; - static ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", - "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", - "T__13", "T__14", "T__15", "T__16", "T__17", "T__18", - "T__19", "T__20", "T__21", "COMMENT", "BooleanLiteral", - "String", "IRIREF", "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", - "LANGTAG", "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", - "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", - "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", - "UCHAR", "ECHAR", "WS", "IPLSTART", "ANON", "QuickVarName", - "PN_CHARS_U", "PN_CHARS_BASE", "PN_CHARS", "BASE", - "PREFIX", "PN_PREFIX", "PN_LOCAL", "PLX", "PERCENT", - "HEX", "PN_LOCAL_ESC" ]; - - constructor(input) { - super(input) - this._interp = new src_antlr4.atn.LexerATNSimulator(this, n3Lexer_atn, decisionsToDFA, new src_antlr4.PredictionContextCache()); - } - - get atn() { - return n3Lexer_atn; - } -} - -n3Lexer_n3Lexer.EOF = src_antlr4.Token.EOF; -n3Lexer_n3Lexer.T__0 = 1; -n3Lexer_n3Lexer.T__1 = 2; -n3Lexer_n3Lexer.T__2 = 3; -n3Lexer_n3Lexer.T__3 = 4; -n3Lexer_n3Lexer.T__4 = 5; -n3Lexer_n3Lexer.T__5 = 6; -n3Lexer_n3Lexer.T__6 = 7; -n3Lexer_n3Lexer.T__7 = 8; -n3Lexer_n3Lexer.T__8 = 9; -n3Lexer_n3Lexer.T__9 = 10; -n3Lexer_n3Lexer.T__10 = 11; -n3Lexer_n3Lexer.T__11 = 12; -n3Lexer_n3Lexer.T__12 = 13; -n3Lexer_n3Lexer.T__13 = 14; -n3Lexer_n3Lexer.T__14 = 15; -n3Lexer_n3Lexer.T__15 = 16; -n3Lexer_n3Lexer.T__16 = 17; -n3Lexer_n3Lexer.T__17 = 18; -n3Lexer_n3Lexer.T__18 = 19; -n3Lexer_n3Lexer.T__19 = 20; -n3Lexer_n3Lexer.T__20 = 21; -n3Lexer_n3Lexer.T__21 = 22; -n3Lexer_n3Lexer.COMMENT = 23; -n3Lexer_n3Lexer.BooleanLiteral = 24; -n3Lexer_n3Lexer.String = 25; -n3Lexer_n3Lexer.IRIREF = 26; -n3Lexer_n3Lexer.PNAME_NS = 27; -n3Lexer_n3Lexer.PNAME_LN = 28; -n3Lexer_n3Lexer.BLANK_NODE_LABEL = 29; -n3Lexer_n3Lexer.LANGTAG = 30; -n3Lexer_n3Lexer.INTEGER = 31; -n3Lexer_n3Lexer.DECIMAL = 32; -n3Lexer_n3Lexer.DOUBLE = 33; -n3Lexer_n3Lexer.EXPONENT = 34; -n3Lexer_n3Lexer.STRING_LITERAL_LONG_SINGLE_QUOTE = 35; -n3Lexer_n3Lexer.STRING_LITERAL_LONG_QUOTE = 36; -n3Lexer_n3Lexer.STRING_LITERAL_QUOTE = 37; -n3Lexer_n3Lexer.STRING_LITERAL_SINGLE_QUOTE = 38; -n3Lexer_n3Lexer.UCHAR = 39; -n3Lexer_n3Lexer.ECHAR = 40; -n3Lexer_n3Lexer.WS = 41; -n3Lexer_n3Lexer.IPLSTART = 42; -n3Lexer_n3Lexer.ANON = 43; -n3Lexer_n3Lexer.QuickVarName = 44; -n3Lexer_n3Lexer.PN_CHARS_U = 45; -n3Lexer_n3Lexer.PN_CHARS_BASE = 46; -n3Lexer_n3Lexer.PN_CHARS = 47; -n3Lexer_n3Lexer.BASE = 48; -n3Lexer_n3Lexer.PREFIX = 49; -n3Lexer_n3Lexer.PN_PREFIX = 50; -n3Lexer_n3Lexer.PN_LOCAL = 51; -n3Lexer_n3Lexer.PLX = 52; -n3Lexer_n3Lexer.PERCENT = 53; -n3Lexer_n3Lexer.HEX = 54; -n3Lexer_n3Lexer.PN_LOCAL_ESC = 55; - - - - -;// CONCATENATED MODULE: ./parser/n3/n3Listener.js -// Generated from n3.g4 by ANTLR 4.10.1 -// jshint ignore: start - - -// This class defines a complete listener for a parse tree produced by n3Parser. -class n3Listener extends src_antlr4.tree.ParseTreeListener { - - // Enter a parse tree produced by n3Parser#n3Doc. - enterN3Doc(ctx) { - } - - // Exit a parse tree produced by n3Parser#n3Doc. - exitN3Doc(ctx) { - } - - - // Enter a parse tree produced by n3Parser#n3Statement. - enterN3Statement(ctx) { - } - - // Exit a parse tree produced by n3Parser#n3Statement. - exitN3Statement(ctx) { - } - - - // Enter a parse tree produced by n3Parser#n3Directive. - enterN3Directive(ctx) { - } - - // Exit a parse tree produced by n3Parser#n3Directive. - exitN3Directive(ctx) { - } - - - // Enter a parse tree produced by n3Parser#sparqlDirective. - enterSparqlDirective(ctx) { - } - - // Exit a parse tree produced by n3Parser#sparqlDirective. - exitSparqlDirective(ctx) { - } - - - // Enter a parse tree produced by n3Parser#sparqlBase. - enterSparqlBase(ctx) { - } - - // Exit a parse tree produced by n3Parser#sparqlBase. - exitSparqlBase(ctx) { - } - - - // Enter a parse tree produced by n3Parser#sparqlPrefix. - enterSparqlPrefix(ctx) { - } - - // Exit a parse tree produced by n3Parser#sparqlPrefix. - exitSparqlPrefix(ctx) { - } - - - // Enter a parse tree produced by n3Parser#prefixID. - enterPrefixID(ctx) { - } - - // Exit a parse tree produced by n3Parser#prefixID. - exitPrefixID(ctx) { - } - - - // Enter a parse tree produced by n3Parser#base. - enterBase(ctx) { - } - - // Exit a parse tree produced by n3Parser#base. - exitBase(ctx) { - } - - - // Enter a parse tree produced by n3Parser#triples. - enterTriples(ctx) { - } - - // Exit a parse tree produced by n3Parser#triples. - exitTriples(ctx) { - } - - - // Enter a parse tree produced by n3Parser#predicateObjectList. - enterPredicateObjectList(ctx) { - } - - // Exit a parse tree produced by n3Parser#predicateObjectList. - exitPredicateObjectList(ctx) { - } - - - // Enter a parse tree produced by n3Parser#objectList. - enterObjectList(ctx) { - } - - // Exit a parse tree produced by n3Parser#objectList. - exitObjectList(ctx) { - } - - - // Enter a parse tree produced by n3Parser#verb. - enterVerb(ctx) { - } - - // Exit a parse tree produced by n3Parser#verb. - exitVerb(ctx) { - } - - - // Enter a parse tree produced by n3Parser#subject. - enterSubject(ctx) { - } - - // Exit a parse tree produced by n3Parser#subject. - exitSubject(ctx) { - } - - - // Enter a parse tree produced by n3Parser#predicate. - enterPredicate(ctx) { - } - - // Exit a parse tree produced by n3Parser#predicate. - exitPredicate(ctx) { - } - - - // Enter a parse tree produced by n3Parser#object. - enterObject(ctx) { - } - - // Exit a parse tree produced by n3Parser#object. - exitObject(ctx) { - } - - - // Enter a parse tree produced by n3Parser#expression. - enterExpression(ctx) { - } - - // Exit a parse tree produced by n3Parser#expression. - exitExpression(ctx) { - } - - - // Enter a parse tree produced by n3Parser#path. - enterPath(ctx) { - } - - // Exit a parse tree produced by n3Parser#path. - exitPath(ctx) { - } - - - // Enter a parse tree produced by n3Parser#pathItem. - enterPathItem(ctx) { - } - - // Exit a parse tree produced by n3Parser#pathItem. - exitPathItem(ctx) { - } - - - // Enter a parse tree produced by n3Parser#literal. - enterLiteral(ctx) { - } - - // Exit a parse tree produced by n3Parser#literal. - exitLiteral(ctx) { - } - - - // Enter a parse tree produced by n3Parser#blankNodePropertyList. - enterBlankNodePropertyList(ctx) { - } - - // Exit a parse tree produced by n3Parser#blankNodePropertyList. - exitBlankNodePropertyList(ctx) { - } - - - // Enter a parse tree produced by n3Parser#iriPropertyList. - enterIriPropertyList(ctx) { - } - - // Exit a parse tree produced by n3Parser#iriPropertyList. - exitIriPropertyList(ctx) { - } - - - // Enter a parse tree produced by n3Parser#collection. - enterCollection(ctx) { - } - - // Exit a parse tree produced by n3Parser#collection. - exitCollection(ctx) { - } - - - // Enter a parse tree produced by n3Parser#formula. - enterFormula(ctx) { - } - - // Exit a parse tree produced by n3Parser#formula. - exitFormula(ctx) { - } - - - // Enter a parse tree produced by n3Parser#formulaContent. - enterFormulaContent(ctx) { - } - - // Exit a parse tree produced by n3Parser#formulaContent. - exitFormulaContent(ctx) { - } - - - // Enter a parse tree produced by n3Parser#numericLiteral. - enterNumericLiteral(ctx) { - } - - // Exit a parse tree produced by n3Parser#numericLiteral. - exitNumericLiteral(ctx) { - } - - - // Enter a parse tree produced by n3Parser#rdfLiteral. - enterRdfLiteral(ctx) { - } - - // Exit a parse tree produced by n3Parser#rdfLiteral. - exitRdfLiteral(ctx) { - } - - - // Enter a parse tree produced by n3Parser#iri. - enterIri(ctx) { - } - - // Exit a parse tree produced by n3Parser#iri. - exitIri(ctx) { - } - - - // Enter a parse tree produced by n3Parser#prefixedName. - enterPrefixedName(ctx) { - } - - // Exit a parse tree produced by n3Parser#prefixedName. - exitPrefixedName(ctx) { - } - - - // Enter a parse tree produced by n3Parser#blankNode. - enterBlankNode(ctx) { - } - - // Exit a parse tree produced by n3Parser#blankNode. - exitBlankNode(ctx) { - } - - - // Enter a parse tree produced by n3Parser#quickVar. - enterQuickVar(ctx) { - } - - // Exit a parse tree produced by n3Parser#quickVar. - exitQuickVar(ctx) { - } - - - -} -;// CONCATENATED MODULE: ./parser/n3/n3Visitor.js -// Generated from n3.g4 by ANTLR 4.10.1 -// jshint ignore: start - - -// This class defines a complete generic visitor for a parse tree produced by n3Parser. - -class n3Visitor extends src_antlr4.tree.ParseTreeVisitor { - - // Visit a parse tree produced by n3Parser#n3Doc. - visitN3Doc(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#n3Statement. - visitN3Statement(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#n3Directive. - visitN3Directive(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#sparqlDirective. - visitSparqlDirective(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#sparqlBase. - visitSparqlBase(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#sparqlPrefix. - visitSparqlPrefix(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#prefixID. - visitPrefixID(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#base. - visitBase(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#triples. - visitTriples(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#predicateObjectList. - visitPredicateObjectList(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#objectList. - visitObjectList(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#verb. - visitVerb(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#subject. - visitSubject(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#predicate. - visitPredicate(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#object. - visitObject(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#expression. - visitExpression(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#path. - visitPath(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#pathItem. - visitPathItem(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#literal. - visitLiteral(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#blankNodePropertyList. - visitBlankNodePropertyList(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#iriPropertyList. - visitIriPropertyList(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#collection. - visitCollection(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#formula. - visitFormula(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#formulaContent. - visitFormulaContent(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#numericLiteral. - visitNumericLiteral(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#rdfLiteral. - visitRdfLiteral(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#iri. - visitIri(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#prefixedName. - visitPrefixedName(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#blankNode. - visitBlankNode(ctx) { - return this.visitChildren(ctx); - } - - - // Visit a parse tree produced by n3Parser#quickVar. - visitQuickVar(ctx) { - return this.visitChildren(ctx); - } - - - -} -;// CONCATENATED MODULE: ./parser/n3/n3Parser.js -// Generated from n3.g4 by ANTLR 4.10.1 -// jshint ignore: start - - - - -const n3Parser_serializedATN = [4,1,55,224,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7, -4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12, -2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2, -20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27, -7,27,2,28,7,28,2,29,7,29,1,0,1,0,1,0,1,0,5,0,65,8,0,10,0,12,0,68,9,0,1,0, -1,0,1,1,1,1,3,1,74,8,1,1,2,1,2,3,2,78,8,2,1,3,1,3,3,3,82,8,3,1,4,1,4,1,4, -1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,3,8,100,8,8,1,9,1,9, -1,9,1,9,1,9,1,9,3,9,108,8,9,5,9,110,8,9,10,9,12,9,113,9,9,1,10,1,10,1,10, -5,10,118,8,10,10,10,12,10,121,9,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1, -11,1,11,1,11,1,11,3,11,134,8,11,1,12,1,12,1,13,1,13,1,13,3,13,141,8,13,1, -14,1,14,1,15,1,15,1,16,1,16,1,16,1,16,1,16,3,16,152,8,16,1,17,1,17,1,17, -1,17,1,17,1,17,1,17,1,17,3,17,162,8,17,1,18,1,18,1,18,3,18,167,8,18,1,19, -1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,5,21,180,8,21,10,21,12, -21,183,9,21,1,21,1,21,1,22,1,22,3,22,189,8,22,1,22,1,22,1,23,1,23,1,23,3, -23,196,8,23,3,23,198,8,23,1,23,1,23,3,23,202,8,23,3,23,204,8,23,1,24,1,24, -1,25,1,25,1,25,1,25,3,25,212,8,25,1,26,1,26,3,26,216,8,26,1,27,1,27,1,28, -1,28,1,29,1,29,1,29,0,0,30,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32, -34,36,38,40,42,44,46,48,50,52,54,56,58,0,3,1,0,31,33,1,0,27,28,2,0,29,29, -43,43,229,0,66,1,0,0,0,2,73,1,0,0,0,4,77,1,0,0,0,6,81,1,0,0,0,8,83,1,0,0, -0,10,86,1,0,0,0,12,90,1,0,0,0,14,94,1,0,0,0,16,97,1,0,0,0,18,101,1,0,0,0, -20,114,1,0,0,0,22,133,1,0,0,0,24,135,1,0,0,0,26,140,1,0,0,0,28,142,1,0,0, -0,30,144,1,0,0,0,32,146,1,0,0,0,34,161,1,0,0,0,36,166,1,0,0,0,38,168,1,0, -0,0,40,172,1,0,0,0,42,177,1,0,0,0,44,186,1,0,0,0,46,203,1,0,0,0,48,205,1, -0,0,0,50,207,1,0,0,0,52,215,1,0,0,0,54,217,1,0,0,0,56,219,1,0,0,0,58,221, -1,0,0,0,60,61,3,2,1,0,61,62,5,1,0,0,62,65,1,0,0,0,63,65,3,6,3,0,64,60,1, -0,0,0,64,63,1,0,0,0,65,68,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,69,1,0, -0,0,68,66,1,0,0,0,69,70,5,0,0,1,70,1,1,0,0,0,71,74,3,4,2,0,72,74,3,16,8, -0,73,71,1,0,0,0,73,72,1,0,0,0,74,3,1,0,0,0,75,78,3,12,6,0,76,78,3,14,7,0, -77,75,1,0,0,0,77,76,1,0,0,0,78,5,1,0,0,0,79,82,3,8,4,0,80,82,3,10,5,0,81, -79,1,0,0,0,81,80,1,0,0,0,82,7,1,0,0,0,83,84,5,48,0,0,84,85,5,26,0,0,85,9, -1,0,0,0,86,87,5,49,0,0,87,88,5,27,0,0,88,89,5,26,0,0,89,11,1,0,0,0,90,91, -5,2,0,0,91,92,5,27,0,0,92,93,5,26,0,0,93,13,1,0,0,0,94,95,5,3,0,0,95,96, -5,26,0,0,96,15,1,0,0,0,97,99,3,24,12,0,98,100,3,18,9,0,99,98,1,0,0,0,99, -100,1,0,0,0,100,17,1,0,0,0,101,102,3,22,11,0,102,111,3,20,10,0,103,107,5, -4,0,0,104,105,3,22,11,0,105,106,3,20,10,0,106,108,1,0,0,0,107,104,1,0,0, -0,107,108,1,0,0,0,108,110,1,0,0,0,109,103,1,0,0,0,110,113,1,0,0,0,111,109, -1,0,0,0,111,112,1,0,0,0,112,19,1,0,0,0,113,111,1,0,0,0,114,119,3,28,14,0, -115,116,5,5,0,0,116,118,3,28,14,0,117,115,1,0,0,0,118,121,1,0,0,0,119,117, -1,0,0,0,119,120,1,0,0,0,120,21,1,0,0,0,121,119,1,0,0,0,122,134,3,26,13,0, -123,134,5,6,0,0,124,125,5,7,0,0,125,134,3,30,15,0,126,127,5,8,0,0,127,128, -3,30,15,0,128,129,5,9,0,0,129,134,1,0,0,0,130,134,5,10,0,0,131,134,5,11, -0,0,132,134,5,12,0,0,133,122,1,0,0,0,133,123,1,0,0,0,133,124,1,0,0,0,133, -126,1,0,0,0,133,130,1,0,0,0,133,131,1,0,0,0,133,132,1,0,0,0,134,23,1,0,0, -0,135,136,3,30,15,0,136,25,1,0,0,0,137,141,3,30,15,0,138,139,5,13,0,0,139, -141,3,30,15,0,140,137,1,0,0,0,140,138,1,0,0,0,141,27,1,0,0,0,142,143,3,30, -15,0,143,29,1,0,0,0,144,145,3,32,16,0,145,31,1,0,0,0,146,151,3,34,17,0,147, -148,5,14,0,0,148,152,3,32,16,0,149,150,5,15,0,0,150,152,3,32,16,0,151,147, -1,0,0,0,151,149,1,0,0,0,151,152,1,0,0,0,152,33,1,0,0,0,153,162,3,52,26,0, -154,162,3,56,28,0,155,162,3,58,29,0,156,162,3,42,21,0,157,162,3,38,19,0, -158,162,3,40,20,0,159,162,3,36,18,0,160,162,3,44,22,0,161,153,1,0,0,0,161, -154,1,0,0,0,161,155,1,0,0,0,161,156,1,0,0,0,161,157,1,0,0,0,161,158,1,0, -0,0,161,159,1,0,0,0,161,160,1,0,0,0,162,35,1,0,0,0,163,167,3,50,25,0,164, -167,3,48,24,0,165,167,5,24,0,0,166,163,1,0,0,0,166,164,1,0,0,0,166,165,1, -0,0,0,167,37,1,0,0,0,168,169,5,16,0,0,169,170,3,18,9,0,170,171,5,17,0,0, -171,39,1,0,0,0,172,173,5,42,0,0,173,174,3,52,26,0,174,175,3,18,9,0,175,176, -5,17,0,0,176,41,1,0,0,0,177,181,5,18,0,0,178,180,3,28,14,0,179,178,1,0,0, -0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183,181, -1,0,0,0,184,185,5,19,0,0,185,43,1,0,0,0,186,188,5,20,0,0,187,189,3,46,23, -0,188,187,1,0,0,0,188,189,1,0,0,0,189,190,1,0,0,0,190,191,5,21,0,0,191,45, -1,0,0,0,192,197,3,2,1,0,193,195,5,1,0,0,194,196,3,46,23,0,195,194,1,0,0, -0,195,196,1,0,0,0,196,198,1,0,0,0,197,193,1,0,0,0,197,198,1,0,0,0,198,204, -1,0,0,0,199,201,3,6,3,0,200,202,3,46,23,0,201,200,1,0,0,0,201,202,1,0,0, -0,202,204,1,0,0,0,203,192,1,0,0,0,203,199,1,0,0,0,204,47,1,0,0,0,205,206, -7,0,0,0,206,49,1,0,0,0,207,211,5,25,0,0,208,212,5,30,0,0,209,210,5,22,0, -0,210,212,3,52,26,0,211,208,1,0,0,0,211,209,1,0,0,0,211,212,1,0,0,0,212, -51,1,0,0,0,213,216,5,26,0,0,214,216,3,54,27,0,215,213,1,0,0,0,215,214,1, -0,0,0,216,53,1,0,0,0,217,218,7,1,0,0,218,55,1,0,0,0,219,220,7,2,0,0,220, -57,1,0,0,0,221,222,5,44,0,0,222,59,1,0,0,0,22,64,66,73,77,81,99,107,111, -119,133,140,151,161,166,181,188,195,197,201,203,211,215]; - - -const n3Parser_atn = new src_antlr4.atn.ATNDeserializer().deserialize(n3Parser_serializedATN); - -const n3Parser_decisionsToDFA = n3Parser_atn.decisionToState.map( (ds, index) => new src_antlr4.dfa.DFA(ds, index) ); - -const sharedContextCache = new src_antlr4.PredictionContextCache(); - -class n3Parser_n3Parser extends src_antlr4.Parser { - - static grammarFileName = "n3.g4"; - static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", - "','", "'a'", "'has'", "'is'", "'of'", "'='", - "'<='", "'=>'", "'<-'", "'!'", "'^'", "'['", - "']'", "'('", "')'", "'{'", "'}'", "'^^'" ]; - static symbolicNames = [ null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, "COMMENT", - "BooleanLiteral", "String", "IRIREF", "PNAME_NS", - "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", - "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", - "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", - "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", - "UCHAR", "ECHAR", "WS", "IPLSTART", "ANON", - "QuickVarName", "PN_CHARS_U", "PN_CHARS_BASE", - "PN_CHARS", "BASE", "PREFIX", "PN_PREFIX", - "PN_LOCAL", "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; - static ruleNames = [ "n3Doc", "n3Statement", "n3Directive", "sparqlDirective", - "sparqlBase", "sparqlPrefix", "prefixID", "base", - "triples", "predicateObjectList", "objectList", - "verb", "subject", "predicate", "object", "expression", - "path", "pathItem", "literal", "blankNodePropertyList", - "iriPropertyList", "collection", "formula", "formulaContent", - "numericLiteral", "rdfLiteral", "iri", "prefixedName", - "blankNode", "quickVar" ]; - - constructor(input) { - super(input); - this._interp = new src_antlr4.atn.ParserATNSimulator(this, n3Parser_atn, n3Parser_decisionsToDFA, sharedContextCache); - this.ruleNames = n3Parser_n3Parser.ruleNames; - this.literalNames = n3Parser_n3Parser.literalNames; - this.symbolicNames = n3Parser_n3Parser.symbolicNames; - } - - get atn() { - return n3Parser_atn; - } - - - - n3Doc() { - let localctx = new N3DocContext(this, this._ctx, this.state); - this.enterRule(localctx, 0, n3Parser_n3Parser.RULE_n3Doc); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 66; - this._errHandler.sync(this); - _la = this._input.LA(1); - while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser_n3Parser.T__1) | (1 << n3Parser_n3Parser.T__2) | (1 << n3Parser_n3Parser.T__15) | (1 << n3Parser_n3Parser.T__17) | (1 << n3Parser_n3Parser.T__19) | (1 << n3Parser_n3Parser.BooleanLiteral) | (1 << n3Parser_n3Parser.String) | (1 << n3Parser_n3Parser.IRIREF) | (1 << n3Parser_n3Parser.PNAME_NS) | (1 << n3Parser_n3Parser.PNAME_LN) | (1 << n3Parser_n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser_n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser_n3Parser.DECIMAL - 32)) | (1 << (n3Parser_n3Parser.DOUBLE - 32)) | (1 << (n3Parser_n3Parser.IPLSTART - 32)) | (1 << (n3Parser_n3Parser.ANON - 32)) | (1 << (n3Parser_n3Parser.QuickVarName - 32)) | (1 << (n3Parser_n3Parser.BASE - 32)) | (1 << (n3Parser_n3Parser.PREFIX - 32)))) !== 0)) { - this.state = 64; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.T__1: - case n3Parser_n3Parser.T__2: - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - this.state = 60; - this.n3Statement(); - this.state = 61; - this.match(n3Parser_n3Parser.T__0); - break; - case n3Parser_n3Parser.BASE: - case n3Parser_n3Parser.PREFIX: - this.state = 63; - this.sparqlDirective(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - this.state = 68; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 69; - this.match(n3Parser_n3Parser.EOF); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - n3Statement() { - let localctx = new N3StatementContext(this, this._ctx, this.state); - this.enterRule(localctx, 2, n3Parser_n3Parser.RULE_n3Statement); - try { - this.state = 73; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.T__1: - case n3Parser_n3Parser.T__2: - this.enterOuterAlt(localctx, 1); - this.state = 71; - this.n3Directive(); - break; - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - this.enterOuterAlt(localctx, 2); - this.state = 72; - this.triples(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - n3Directive() { - let localctx = new N3DirectiveContext(this, this._ctx, this.state); - this.enterRule(localctx, 4, n3Parser_n3Parser.RULE_n3Directive); - try { - this.state = 77; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.T__1: - this.enterOuterAlt(localctx, 1); - this.state = 75; - this.prefixID(); - break; - case n3Parser_n3Parser.T__2: - this.enterOuterAlt(localctx, 2); - this.state = 76; - this.base(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - sparqlDirective() { - let localctx = new SparqlDirectiveContext(this, this._ctx, this.state); - this.enterRule(localctx, 6, n3Parser_n3Parser.RULE_sparqlDirective); - try { - this.state = 81; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.BASE: - this.enterOuterAlt(localctx, 1); - this.state = 79; - this.sparqlBase(); - break; - case n3Parser_n3Parser.PREFIX: - this.enterOuterAlt(localctx, 2); - this.state = 80; - this.sparqlPrefix(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - sparqlBase() { - let localctx = new SparqlBaseContext(this, this._ctx, this.state); - this.enterRule(localctx, 8, n3Parser_n3Parser.RULE_sparqlBase); - try { - this.enterOuterAlt(localctx, 1); - this.state = 83; - this.match(n3Parser_n3Parser.BASE); - this.state = 84; - this.match(n3Parser_n3Parser.IRIREF); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - sparqlPrefix() { - let localctx = new SparqlPrefixContext(this, this._ctx, this.state); - this.enterRule(localctx, 10, n3Parser_n3Parser.RULE_sparqlPrefix); - try { - this.enterOuterAlt(localctx, 1); - this.state = 86; - this.match(n3Parser_n3Parser.PREFIX); - this.state = 87; - this.match(n3Parser_n3Parser.PNAME_NS); - this.state = 88; - this.match(n3Parser_n3Parser.IRIREF); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - prefixID() { - let localctx = new PrefixIDContext(this, this._ctx, this.state); - this.enterRule(localctx, 12, n3Parser_n3Parser.RULE_prefixID); - try { - this.enterOuterAlt(localctx, 1); - this.state = 90; - this.match(n3Parser_n3Parser.T__1); - this.state = 91; - this.match(n3Parser_n3Parser.PNAME_NS); - this.state = 92; - this.match(n3Parser_n3Parser.IRIREF); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - base() { - let localctx = new BaseContext(this, this._ctx, this.state); - this.enterRule(localctx, 14, n3Parser_n3Parser.RULE_base); - try { - this.enterOuterAlt(localctx, 1); - this.state = 94; - this.match(n3Parser_n3Parser.T__2); - this.state = 95; - this.match(n3Parser_n3Parser.IRIREF); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - triples() { - let localctx = new TriplesContext(this, this._ctx, this.state); - this.enterRule(localctx, 16, n3Parser_n3Parser.RULE_triples); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 97; - this.subject(); - this.state = 99; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser_n3Parser.T__5) | (1 << n3Parser_n3Parser.T__6) | (1 << n3Parser_n3Parser.T__7) | (1 << n3Parser_n3Parser.T__9) | (1 << n3Parser_n3Parser.T__10) | (1 << n3Parser_n3Parser.T__11) | (1 << n3Parser_n3Parser.T__12) | (1 << n3Parser_n3Parser.T__15) | (1 << n3Parser_n3Parser.T__17) | (1 << n3Parser_n3Parser.T__19) | (1 << n3Parser_n3Parser.BooleanLiteral) | (1 << n3Parser_n3Parser.String) | (1 << n3Parser_n3Parser.IRIREF) | (1 << n3Parser_n3Parser.PNAME_NS) | (1 << n3Parser_n3Parser.PNAME_LN) | (1 << n3Parser_n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser_n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser_n3Parser.DECIMAL - 32)) | (1 << (n3Parser_n3Parser.DOUBLE - 32)) | (1 << (n3Parser_n3Parser.IPLSTART - 32)) | (1 << (n3Parser_n3Parser.ANON - 32)) | (1 << (n3Parser_n3Parser.QuickVarName - 32)))) !== 0)) { - this.state = 98; - this.predicateObjectList(); - } - - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - predicateObjectList() { - let localctx = new PredicateObjectListContext(this, this._ctx, this.state); - this.enterRule(localctx, 18, n3Parser_n3Parser.RULE_predicateObjectList); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 101; - this.verb(); - this.state = 102; - this.objectList(); - this.state = 111; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(_la===n3Parser_n3Parser.T__3) { - this.state = 103; - this.match(n3Parser_n3Parser.T__3); - this.state = 107; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser_n3Parser.T__5) | (1 << n3Parser_n3Parser.T__6) | (1 << n3Parser_n3Parser.T__7) | (1 << n3Parser_n3Parser.T__9) | (1 << n3Parser_n3Parser.T__10) | (1 << n3Parser_n3Parser.T__11) | (1 << n3Parser_n3Parser.T__12) | (1 << n3Parser_n3Parser.T__15) | (1 << n3Parser_n3Parser.T__17) | (1 << n3Parser_n3Parser.T__19) | (1 << n3Parser_n3Parser.BooleanLiteral) | (1 << n3Parser_n3Parser.String) | (1 << n3Parser_n3Parser.IRIREF) | (1 << n3Parser_n3Parser.PNAME_NS) | (1 << n3Parser_n3Parser.PNAME_LN) | (1 << n3Parser_n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser_n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser_n3Parser.DECIMAL - 32)) | (1 << (n3Parser_n3Parser.DOUBLE - 32)) | (1 << (n3Parser_n3Parser.IPLSTART - 32)) | (1 << (n3Parser_n3Parser.ANON - 32)) | (1 << (n3Parser_n3Parser.QuickVarName - 32)))) !== 0)) { - this.state = 104; - this.verb(); - this.state = 105; - this.objectList(); - } - - this.state = 113; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - objectList() { - let localctx = new ObjectListContext(this, this._ctx, this.state); - this.enterRule(localctx, 20, n3Parser_n3Parser.RULE_objectList); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 114; - this.object(); - this.state = 119; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(_la===n3Parser_n3Parser.T__4) { - this.state = 115; - this.match(n3Parser_n3Parser.T__4); - this.state = 116; - this.object(); - this.state = 121; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - verb() { - let localctx = new VerbContext(this, this._ctx, this.state); - this.enterRule(localctx, 22, n3Parser_n3Parser.RULE_verb); - try { - this.state = 133; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.T__12: - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - this.enterOuterAlt(localctx, 1); - this.state = 122; - this.predicate(); - break; - case n3Parser_n3Parser.T__5: - this.enterOuterAlt(localctx, 2); - this.state = 123; - this.match(n3Parser_n3Parser.T__5); - break; - case n3Parser_n3Parser.T__6: - this.enterOuterAlt(localctx, 3); - this.state = 124; - this.match(n3Parser_n3Parser.T__6); - this.state = 125; - this.expression(); - break; - case n3Parser_n3Parser.T__7: - this.enterOuterAlt(localctx, 4); - this.state = 126; - this.match(n3Parser_n3Parser.T__7); - this.state = 127; - this.expression(); - this.state = 128; - this.match(n3Parser_n3Parser.T__8); - break; - case n3Parser_n3Parser.T__9: - this.enterOuterAlt(localctx, 5); - this.state = 130; - this.match(n3Parser_n3Parser.T__9); - break; - case n3Parser_n3Parser.T__10: - this.enterOuterAlt(localctx, 6); - this.state = 131; - this.match(n3Parser_n3Parser.T__10); - break; - case n3Parser_n3Parser.T__11: - this.enterOuterAlt(localctx, 7); - this.state = 132; - this.match(n3Parser_n3Parser.T__11); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - subject() { - let localctx = new SubjectContext(this, this._ctx, this.state); - this.enterRule(localctx, 24, n3Parser_n3Parser.RULE_subject); - try { - this.enterOuterAlt(localctx, 1); - this.state = 135; - this.expression(); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - predicate() { - let localctx = new PredicateContext(this, this._ctx, this.state); - this.enterRule(localctx, 26, n3Parser_n3Parser.RULE_predicate); - try { - this.enterOuterAlt(localctx, 1); - this.state = 140; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - this.state = 137; - this.expression(); - break; - case n3Parser_n3Parser.T__12: - this.state = 138; - this.match(n3Parser_n3Parser.T__12); - this.state = 139; - this.expression(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - object() { - let localctx = new ObjectContext(this, this._ctx, this.state); - this.enterRule(localctx, 28, n3Parser_n3Parser.RULE_object); - try { - this.enterOuterAlt(localctx, 1); - this.state = 142; - this.expression(); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - expression() { - let localctx = new ExpressionContext(this, this._ctx, this.state); - this.enterRule(localctx, 30, n3Parser_n3Parser.RULE_expression); - try { - this.enterOuterAlt(localctx, 1); - this.state = 144; - this.path(); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - path() { - let localctx = new PathContext(this, this._ctx, this.state); - this.enterRule(localctx, 32, n3Parser_n3Parser.RULE_path); - try { - this.enterOuterAlt(localctx, 1); - this.state = 146; - this.pathItem(); - this.state = 151; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case n3Parser_n3Parser.T__13: - this.state = 147; - this.match(n3Parser_n3Parser.T__13); - this.state = 148; - this.path(); - break; - case n3Parser_n3Parser.T__14: - this.state = 149; - this.match(n3Parser_n3Parser.T__14); - this.state = 150; - this.path(); - break; - case n3Parser_n3Parser.T__0: - case n3Parser_n3Parser.T__3: - case n3Parser_n3Parser.T__4: - case n3Parser_n3Parser.T__5: - case n3Parser_n3Parser.T__6: - case n3Parser_n3Parser.T__7: - case n3Parser_n3Parser.T__8: - case n3Parser_n3Parser.T__9: - case n3Parser_n3Parser.T__10: - case n3Parser_n3Parser.T__11: - case n3Parser_n3Parser.T__12: - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__16: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__18: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.T__20: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - break; - default: - break; - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - pathItem() { - let localctx = new PathItemContext(this, this._ctx, this.state); - this.enterRule(localctx, 34, n3Parser_n3Parser.RULE_pathItem); - try { - this.state = 161; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 153; - this.iri(); - break; - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.ANON: - this.enterOuterAlt(localctx, 2); - this.state = 154; - this.blankNode(); - break; - case n3Parser_n3Parser.QuickVarName: - this.enterOuterAlt(localctx, 3); - this.state = 155; - this.quickVar(); - break; - case n3Parser_n3Parser.T__17: - this.enterOuterAlt(localctx, 4); - this.state = 156; - this.collection(); - break; - case n3Parser_n3Parser.T__15: - this.enterOuterAlt(localctx, 5); - this.state = 157; - this.blankNodePropertyList(); - break; - case n3Parser_n3Parser.IPLSTART: - this.enterOuterAlt(localctx, 6); - this.state = 158; - this.iriPropertyList(); - break; - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - this.enterOuterAlt(localctx, 7); - this.state = 159; - this.literal(); - break; - case n3Parser_n3Parser.T__19: - this.enterOuterAlt(localctx, 8); - this.state = 160; - this.formula(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - literal() { - let localctx = new LiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 36, n3Parser_n3Parser.RULE_literal); - try { - this.state = 166; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.String: - this.enterOuterAlt(localctx, 1); - this.state = 163; - this.rdfLiteral(); - break; - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - this.enterOuterAlt(localctx, 2); - this.state = 164; - this.numericLiteral(); - break; - case n3Parser_n3Parser.BooleanLiteral: - this.enterOuterAlt(localctx, 3); - this.state = 165; - this.match(n3Parser_n3Parser.BooleanLiteral); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - blankNodePropertyList() { - let localctx = new BlankNodePropertyListContext(this, this._ctx, this.state); - this.enterRule(localctx, 38, n3Parser_n3Parser.RULE_blankNodePropertyList); - try { - this.enterOuterAlt(localctx, 1); - this.state = 168; - this.match(n3Parser_n3Parser.T__15); - this.state = 169; - this.predicateObjectList(); - this.state = 170; - this.match(n3Parser_n3Parser.T__16); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - iriPropertyList() { - let localctx = new IriPropertyListContext(this, this._ctx, this.state); - this.enterRule(localctx, 40, n3Parser_n3Parser.RULE_iriPropertyList); - try { - this.enterOuterAlt(localctx, 1); - this.state = 172; - this.match(n3Parser_n3Parser.IPLSTART); - this.state = 173; - this.iri(); - this.state = 174; - this.predicateObjectList(); - this.state = 175; - this.match(n3Parser_n3Parser.T__16); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - collection() { - let localctx = new CollectionContext(this, this._ctx, this.state); - this.enterRule(localctx, 42, n3Parser_n3Parser.RULE_collection); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 177; - this.match(n3Parser_n3Parser.T__17); - this.state = 181; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(((((_la - 16)) & ~0x1f) == 0 && ((1 << (_la - 16)) & ((1 << (n3Parser_n3Parser.T__15 - 16)) | (1 << (n3Parser_n3Parser.T__17 - 16)) | (1 << (n3Parser_n3Parser.T__19 - 16)) | (1 << (n3Parser_n3Parser.BooleanLiteral - 16)) | (1 << (n3Parser_n3Parser.String - 16)) | (1 << (n3Parser_n3Parser.IRIREF - 16)) | (1 << (n3Parser_n3Parser.PNAME_NS - 16)) | (1 << (n3Parser_n3Parser.PNAME_LN - 16)) | (1 << (n3Parser_n3Parser.BLANK_NODE_LABEL - 16)) | (1 << (n3Parser_n3Parser.INTEGER - 16)) | (1 << (n3Parser_n3Parser.DECIMAL - 16)) | (1 << (n3Parser_n3Parser.DOUBLE - 16)) | (1 << (n3Parser_n3Parser.IPLSTART - 16)) | (1 << (n3Parser_n3Parser.ANON - 16)) | (1 << (n3Parser_n3Parser.QuickVarName - 16)))) !== 0)) { - this.state = 178; - this.object(); - this.state = 183; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 184; - this.match(n3Parser_n3Parser.T__18); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - formula() { - let localctx = new FormulaContext(this, this._ctx, this.state); - this.enterRule(localctx, 44, n3Parser_n3Parser.RULE_formula); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 186; - this.match(n3Parser_n3Parser.T__19); - this.state = 188; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser_n3Parser.T__1) | (1 << n3Parser_n3Parser.T__2) | (1 << n3Parser_n3Parser.T__15) | (1 << n3Parser_n3Parser.T__17) | (1 << n3Parser_n3Parser.T__19) | (1 << n3Parser_n3Parser.BooleanLiteral) | (1 << n3Parser_n3Parser.String) | (1 << n3Parser_n3Parser.IRIREF) | (1 << n3Parser_n3Parser.PNAME_NS) | (1 << n3Parser_n3Parser.PNAME_LN) | (1 << n3Parser_n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser_n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser_n3Parser.DECIMAL - 32)) | (1 << (n3Parser_n3Parser.DOUBLE - 32)) | (1 << (n3Parser_n3Parser.IPLSTART - 32)) | (1 << (n3Parser_n3Parser.ANON - 32)) | (1 << (n3Parser_n3Parser.QuickVarName - 32)) | (1 << (n3Parser_n3Parser.BASE - 32)) | (1 << (n3Parser_n3Parser.PREFIX - 32)))) !== 0)) { - this.state = 187; - this.formulaContent(); - } - - this.state = 190; - this.match(n3Parser_n3Parser.T__20); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - formulaContent() { - let localctx = new FormulaContentContext(this, this._ctx, this.state); - this.enterRule(localctx, 46, n3Parser_n3Parser.RULE_formulaContent); - var _la = 0; // Token type - try { - this.state = 203; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.T__1: - case n3Parser_n3Parser.T__2: - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - this.enterOuterAlt(localctx, 1); - this.state = 192; - this.n3Statement(); - this.state = 197; - this._errHandler.sync(this); - _la = this._input.LA(1); - if(_la===n3Parser_n3Parser.T__0) { - this.state = 193; - this.match(n3Parser_n3Parser.T__0); - this.state = 195; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser_n3Parser.T__1) | (1 << n3Parser_n3Parser.T__2) | (1 << n3Parser_n3Parser.T__15) | (1 << n3Parser_n3Parser.T__17) | (1 << n3Parser_n3Parser.T__19) | (1 << n3Parser_n3Parser.BooleanLiteral) | (1 << n3Parser_n3Parser.String) | (1 << n3Parser_n3Parser.IRIREF) | (1 << n3Parser_n3Parser.PNAME_NS) | (1 << n3Parser_n3Parser.PNAME_LN) | (1 << n3Parser_n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser_n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser_n3Parser.DECIMAL - 32)) | (1 << (n3Parser_n3Parser.DOUBLE - 32)) | (1 << (n3Parser_n3Parser.IPLSTART - 32)) | (1 << (n3Parser_n3Parser.ANON - 32)) | (1 << (n3Parser_n3Parser.QuickVarName - 32)) | (1 << (n3Parser_n3Parser.BASE - 32)) | (1 << (n3Parser_n3Parser.PREFIX - 32)))) !== 0)) { - this.state = 194; - this.formulaContent(); - } - - } - - break; - case n3Parser_n3Parser.BASE: - case n3Parser_n3Parser.PREFIX: - this.enterOuterAlt(localctx, 2); - this.state = 199; - this.sparqlDirective(); - this.state = 201; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser_n3Parser.T__1) | (1 << n3Parser_n3Parser.T__2) | (1 << n3Parser_n3Parser.T__15) | (1 << n3Parser_n3Parser.T__17) | (1 << n3Parser_n3Parser.T__19) | (1 << n3Parser_n3Parser.BooleanLiteral) | (1 << n3Parser_n3Parser.String) | (1 << n3Parser_n3Parser.IRIREF) | (1 << n3Parser_n3Parser.PNAME_NS) | (1 << n3Parser_n3Parser.PNAME_LN) | (1 << n3Parser_n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser_n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser_n3Parser.DECIMAL - 32)) | (1 << (n3Parser_n3Parser.DOUBLE - 32)) | (1 << (n3Parser_n3Parser.IPLSTART - 32)) | (1 << (n3Parser_n3Parser.ANON - 32)) | (1 << (n3Parser_n3Parser.QuickVarName - 32)) | (1 << (n3Parser_n3Parser.BASE - 32)) | (1 << (n3Parser_n3Parser.PREFIX - 32)))) !== 0)) { - this.state = 200; - this.formulaContent(); - } - - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - numericLiteral() { - let localctx = new NumericLiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 48, n3Parser_n3Parser.RULE_numericLiteral); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 205; - _la = this._input.LA(1); - if(!(((((_la - 31)) & ~0x1f) == 0 && ((1 << (_la - 31)) & ((1 << (n3Parser_n3Parser.INTEGER - 31)) | (1 << (n3Parser_n3Parser.DECIMAL - 31)) | (1 << (n3Parser_n3Parser.DOUBLE - 31)))) !== 0))) { - this._errHandler.recoverInline(this); - } - else { - this._errHandler.reportMatch(this); - this.consume(); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - rdfLiteral() { - let localctx = new RdfLiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 50, n3Parser_n3Parser.RULE_rdfLiteral); - try { - this.enterOuterAlt(localctx, 1); - this.state = 207; - this.match(n3Parser_n3Parser.String); - this.state = 211; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case n3Parser_n3Parser.LANGTAG: - this.state = 208; - this.match(n3Parser_n3Parser.LANGTAG); - break; - case n3Parser_n3Parser.T__21: - this.state = 209; - this.match(n3Parser_n3Parser.T__21); - this.state = 210; - this.iri(); - break; - case n3Parser_n3Parser.T__0: - case n3Parser_n3Parser.T__3: - case n3Parser_n3Parser.T__4: - case n3Parser_n3Parser.T__5: - case n3Parser_n3Parser.T__6: - case n3Parser_n3Parser.T__7: - case n3Parser_n3Parser.T__8: - case n3Parser_n3Parser.T__9: - case n3Parser_n3Parser.T__10: - case n3Parser_n3Parser.T__11: - case n3Parser_n3Parser.T__12: - case n3Parser_n3Parser.T__13: - case n3Parser_n3Parser.T__14: - case n3Parser_n3Parser.T__15: - case n3Parser_n3Parser.T__16: - case n3Parser_n3Parser.T__17: - case n3Parser_n3Parser.T__18: - case n3Parser_n3Parser.T__19: - case n3Parser_n3Parser.T__20: - case n3Parser_n3Parser.BooleanLiteral: - case n3Parser_n3Parser.String: - case n3Parser_n3Parser.IRIREF: - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - case n3Parser_n3Parser.BLANK_NODE_LABEL: - case n3Parser_n3Parser.INTEGER: - case n3Parser_n3Parser.DECIMAL: - case n3Parser_n3Parser.DOUBLE: - case n3Parser_n3Parser.IPLSTART: - case n3Parser_n3Parser.ANON: - case n3Parser_n3Parser.QuickVarName: - break; - default: - break; - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - iri() { - let localctx = new IriContext(this, this._ctx, this.state); - this.enterRule(localctx, 52, n3Parser_n3Parser.RULE_iri); - try { - this.state = 215; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case n3Parser_n3Parser.IRIREF: - this.enterOuterAlt(localctx, 1); - this.state = 213; - this.match(n3Parser_n3Parser.IRIREF); - break; - case n3Parser_n3Parser.PNAME_NS: - case n3Parser_n3Parser.PNAME_LN: - this.enterOuterAlt(localctx, 2); - this.state = 214; - this.prefixedName(); - break; - default: - throw new src_antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - prefixedName() { - let localctx = new PrefixedNameContext(this, this._ctx, this.state); - this.enterRule(localctx, 54, n3Parser_n3Parser.RULE_prefixedName); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 217; - _la = this._input.LA(1); - if(!(_la===n3Parser_n3Parser.PNAME_NS || _la===n3Parser_n3Parser.PNAME_LN)) { - this._errHandler.recoverInline(this); - } - else { - this._errHandler.reportMatch(this); - this.consume(); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - blankNode() { - let localctx = new BlankNodeContext(this, this._ctx, this.state); - this.enterRule(localctx, 56, n3Parser_n3Parser.RULE_blankNode); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 219; - _la = this._input.LA(1); - if(!(_la===n3Parser_n3Parser.BLANK_NODE_LABEL || _la===n3Parser_n3Parser.ANON)) { - this._errHandler.recoverInline(this); - } - else { - this._errHandler.reportMatch(this); - this.consume(); - } - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - - - quickVar() { - let localctx = new QuickVarContext(this, this._ctx, this.state); - this.enterRule(localctx, 58, n3Parser_n3Parser.RULE_quickVar); - try { - this.enterOuterAlt(localctx, 1); - this.state = 221; - this.match(n3Parser_n3Parser.QuickVarName); - } catch (re) { - if(re instanceof src_antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; - } - - -} - -n3Parser_n3Parser.EOF = src_antlr4.Token.EOF; -n3Parser_n3Parser.T__0 = 1; -n3Parser_n3Parser.T__1 = 2; -n3Parser_n3Parser.T__2 = 3; -n3Parser_n3Parser.T__3 = 4; -n3Parser_n3Parser.T__4 = 5; -n3Parser_n3Parser.T__5 = 6; -n3Parser_n3Parser.T__6 = 7; -n3Parser_n3Parser.T__7 = 8; -n3Parser_n3Parser.T__8 = 9; -n3Parser_n3Parser.T__9 = 10; -n3Parser_n3Parser.T__10 = 11; -n3Parser_n3Parser.T__11 = 12; -n3Parser_n3Parser.T__12 = 13; -n3Parser_n3Parser.T__13 = 14; -n3Parser_n3Parser.T__14 = 15; -n3Parser_n3Parser.T__15 = 16; -n3Parser_n3Parser.T__16 = 17; -n3Parser_n3Parser.T__17 = 18; -n3Parser_n3Parser.T__18 = 19; -n3Parser_n3Parser.T__19 = 20; -n3Parser_n3Parser.T__20 = 21; -n3Parser_n3Parser.T__21 = 22; -n3Parser_n3Parser.COMMENT = 23; -n3Parser_n3Parser.BooleanLiteral = 24; -n3Parser_n3Parser.String = 25; -n3Parser_n3Parser.IRIREF = 26; -n3Parser_n3Parser.PNAME_NS = 27; -n3Parser_n3Parser.PNAME_LN = 28; -n3Parser_n3Parser.BLANK_NODE_LABEL = 29; -n3Parser_n3Parser.LANGTAG = 30; -n3Parser_n3Parser.INTEGER = 31; -n3Parser_n3Parser.DECIMAL = 32; -n3Parser_n3Parser.DOUBLE = 33; -n3Parser_n3Parser.EXPONENT = 34; -n3Parser_n3Parser.STRING_LITERAL_LONG_SINGLE_QUOTE = 35; -n3Parser_n3Parser.STRING_LITERAL_LONG_QUOTE = 36; -n3Parser_n3Parser.STRING_LITERAL_QUOTE = 37; -n3Parser_n3Parser.STRING_LITERAL_SINGLE_QUOTE = 38; -n3Parser_n3Parser.UCHAR = 39; -n3Parser_n3Parser.ECHAR = 40; -n3Parser_n3Parser.WS = 41; -n3Parser_n3Parser.IPLSTART = 42; -n3Parser_n3Parser.ANON = 43; -n3Parser_n3Parser.QuickVarName = 44; -n3Parser_n3Parser.PN_CHARS_U = 45; -n3Parser_n3Parser.PN_CHARS_BASE = 46; -n3Parser_n3Parser.PN_CHARS = 47; -n3Parser_n3Parser.BASE = 48; -n3Parser_n3Parser.PREFIX = 49; -n3Parser_n3Parser.PN_PREFIX = 50; -n3Parser_n3Parser.PN_LOCAL = 51; -n3Parser_n3Parser.PLX = 52; -n3Parser_n3Parser.PERCENT = 53; -n3Parser_n3Parser.HEX = 54; -n3Parser_n3Parser.PN_LOCAL_ESC = 55; - -n3Parser_n3Parser.RULE_n3Doc = 0; -n3Parser_n3Parser.RULE_n3Statement = 1; -n3Parser_n3Parser.RULE_n3Directive = 2; -n3Parser_n3Parser.RULE_sparqlDirective = 3; -n3Parser_n3Parser.RULE_sparqlBase = 4; -n3Parser_n3Parser.RULE_sparqlPrefix = 5; -n3Parser_n3Parser.RULE_prefixID = 6; -n3Parser_n3Parser.RULE_base = 7; -n3Parser_n3Parser.RULE_triples = 8; -n3Parser_n3Parser.RULE_predicateObjectList = 9; -n3Parser_n3Parser.RULE_objectList = 10; -n3Parser_n3Parser.RULE_verb = 11; -n3Parser_n3Parser.RULE_subject = 12; -n3Parser_n3Parser.RULE_predicate = 13; -n3Parser_n3Parser.RULE_object = 14; -n3Parser_n3Parser.RULE_expression = 15; -n3Parser_n3Parser.RULE_path = 16; -n3Parser_n3Parser.RULE_pathItem = 17; -n3Parser_n3Parser.RULE_literal = 18; -n3Parser_n3Parser.RULE_blankNodePropertyList = 19; -n3Parser_n3Parser.RULE_iriPropertyList = 20; -n3Parser_n3Parser.RULE_collection = 21; -n3Parser_n3Parser.RULE_formula = 22; -n3Parser_n3Parser.RULE_formulaContent = 23; -n3Parser_n3Parser.RULE_numericLiteral = 24; -n3Parser_n3Parser.RULE_rdfLiteral = 25; -n3Parser_n3Parser.RULE_iri = 26; -n3Parser_n3Parser.RULE_prefixedName = 27; -n3Parser_n3Parser.RULE_blankNode = 28; -n3Parser_n3Parser.RULE_quickVar = 29; - -class N3DocContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_n3Doc; - } - - EOF() { - return this.getToken(n3Parser_n3Parser.EOF, 0); - }; - - n3Statement = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(N3StatementContext); - } else { - return this.getTypedRuleContext(N3StatementContext,i); - } - }; - - sparqlDirective = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(SparqlDirectiveContext); - } else { - return this.getTypedRuleContext(SparqlDirectiveContext,i); - } - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterN3Doc(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitN3Doc(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitN3Doc(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class N3StatementContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_n3Statement; - } - - n3Directive() { - return this.getTypedRuleContext(N3DirectiveContext,0); - }; - - triples() { - return this.getTypedRuleContext(TriplesContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterN3Statement(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitN3Statement(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitN3Statement(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class N3DirectiveContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_n3Directive; - } - - prefixID() { - return this.getTypedRuleContext(PrefixIDContext,0); - }; - - base() { - return this.getTypedRuleContext(BaseContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterN3Directive(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitN3Directive(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitN3Directive(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class SparqlDirectiveContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_sparqlDirective; - } - - sparqlBase() { - return this.getTypedRuleContext(SparqlBaseContext,0); - }; - - sparqlPrefix() { - return this.getTypedRuleContext(SparqlPrefixContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterSparqlDirective(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitSparqlDirective(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitSparqlDirective(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class SparqlBaseContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_sparqlBase; - } - - BASE() { - return this.getToken(n3Parser_n3Parser.BASE, 0); - }; - - IRIREF() { - return this.getToken(n3Parser_n3Parser.IRIREF, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterSparqlBase(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitSparqlBase(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitSparqlBase(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class SparqlPrefixContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_sparqlPrefix; - } - - PREFIX() { - return this.getToken(n3Parser_n3Parser.PREFIX, 0); - }; - - PNAME_NS() { - return this.getToken(n3Parser_n3Parser.PNAME_NS, 0); - }; - - IRIREF() { - return this.getToken(n3Parser_n3Parser.IRIREF, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterSparqlPrefix(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitSparqlPrefix(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitSparqlPrefix(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class PrefixIDContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_prefixID; - } - - PNAME_NS() { - return this.getToken(n3Parser_n3Parser.PNAME_NS, 0); - }; - - IRIREF() { - return this.getToken(n3Parser_n3Parser.IRIREF, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterPrefixID(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitPrefixID(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitPrefixID(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class BaseContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_base; - } - - IRIREF() { - return this.getToken(n3Parser_n3Parser.IRIREF, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterBase(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitBase(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitBase(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class TriplesContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_triples; - } - - subject() { - return this.getTypedRuleContext(SubjectContext,0); - }; - - predicateObjectList() { - return this.getTypedRuleContext(PredicateObjectListContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterTriples(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitTriples(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitTriples(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class PredicateObjectListContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_predicateObjectList; - } - - verb = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(VerbContext); - } else { - return this.getTypedRuleContext(VerbContext,i); - } - }; - - objectList = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectListContext); - } else { - return this.getTypedRuleContext(ObjectListContext,i); - } - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterPredicateObjectList(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitPredicateObjectList(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitPredicateObjectList(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class ObjectListContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_objectList; - } - - object = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectContext); - } else { - return this.getTypedRuleContext(ObjectContext,i); - } - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterObjectList(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitObjectList(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitObjectList(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class VerbContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_verb; - } - - predicate() { - return this.getTypedRuleContext(PredicateContext,0); - }; - - expression() { - return this.getTypedRuleContext(ExpressionContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterVerb(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitVerb(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitVerb(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class SubjectContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_subject; - } - - expression() { - return this.getTypedRuleContext(ExpressionContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterSubject(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitSubject(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitSubject(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class PredicateContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_predicate; - } - - expression() { - return this.getTypedRuleContext(ExpressionContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterPredicate(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitPredicate(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitPredicate(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class ObjectContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_object; - } - - expression() { - return this.getTypedRuleContext(ExpressionContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterObject(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitObject(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitObject(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class ExpressionContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_expression; - } - - path() { - return this.getTypedRuleContext(PathContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterExpression(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitExpression(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitExpression(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class PathContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_path; - } - - pathItem() { - return this.getTypedRuleContext(PathItemContext,0); - }; - - path() { - return this.getTypedRuleContext(PathContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterPath(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitPath(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitPath(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class PathItemContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_pathItem; - } - - iri() { - return this.getTypedRuleContext(IriContext,0); - }; - - blankNode() { - return this.getTypedRuleContext(BlankNodeContext,0); - }; - - quickVar() { - return this.getTypedRuleContext(QuickVarContext,0); - }; - - collection() { - return this.getTypedRuleContext(CollectionContext,0); - }; - - blankNodePropertyList() { - return this.getTypedRuleContext(BlankNodePropertyListContext,0); - }; - - iriPropertyList() { - return this.getTypedRuleContext(IriPropertyListContext,0); - }; - - literal() { - return this.getTypedRuleContext(LiteralContext,0); - }; - - formula() { - return this.getTypedRuleContext(FormulaContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterPathItem(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitPathItem(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitPathItem(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class LiteralContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_literal; - } - - rdfLiteral() { - return this.getTypedRuleContext(RdfLiteralContext,0); - }; - - numericLiteral() { - return this.getTypedRuleContext(NumericLiteralContext,0); - }; - - BooleanLiteral() { - return this.getToken(n3Parser_n3Parser.BooleanLiteral, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterLiteral(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitLiteral(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitLiteral(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class BlankNodePropertyListContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_blankNodePropertyList; - } - - predicateObjectList() { - return this.getTypedRuleContext(PredicateObjectListContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterBlankNodePropertyList(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitBlankNodePropertyList(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitBlankNodePropertyList(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class IriPropertyListContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_iriPropertyList; - } - - IPLSTART() { - return this.getToken(n3Parser_n3Parser.IPLSTART, 0); - }; - - iri() { - return this.getTypedRuleContext(IriContext,0); - }; - - predicateObjectList() { - return this.getTypedRuleContext(PredicateObjectListContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterIriPropertyList(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitIriPropertyList(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitIriPropertyList(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class CollectionContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_collection; - } - - object = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectContext); - } else { - return this.getTypedRuleContext(ObjectContext,i); - } - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterCollection(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitCollection(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitCollection(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class FormulaContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_formula; - } - - formulaContent() { - return this.getTypedRuleContext(FormulaContentContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterFormula(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitFormula(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitFormula(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class FormulaContentContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_formulaContent; - } - - n3Statement() { - return this.getTypedRuleContext(N3StatementContext,0); - }; - - formulaContent() { - return this.getTypedRuleContext(FormulaContentContext,0); - }; - - sparqlDirective() { - return this.getTypedRuleContext(SparqlDirectiveContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterFormulaContent(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitFormulaContent(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitFormulaContent(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class NumericLiteralContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_numericLiteral; - } - - INTEGER() { - return this.getToken(n3Parser_n3Parser.INTEGER, 0); - }; - - DECIMAL() { - return this.getToken(n3Parser_n3Parser.DECIMAL, 0); - }; - - DOUBLE() { - return this.getToken(n3Parser_n3Parser.DOUBLE, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterNumericLiteral(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitNumericLiteral(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitNumericLiteral(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class RdfLiteralContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_rdfLiteral; - } - - String() { - return this.getToken(n3Parser_n3Parser.String, 0); - }; - - LANGTAG() { - return this.getToken(n3Parser_n3Parser.LANGTAG, 0); - }; - - iri() { - return this.getTypedRuleContext(IriContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterRdfLiteral(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitRdfLiteral(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitRdfLiteral(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class IriContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_iri; - } - - IRIREF() { - return this.getToken(n3Parser_n3Parser.IRIREF, 0); - }; - - prefixedName() { - return this.getTypedRuleContext(PrefixedNameContext,0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterIri(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitIri(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitIri(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class PrefixedNameContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_prefixedName; - } - - PNAME_NS() { - return this.getToken(n3Parser_n3Parser.PNAME_NS, 0); - }; - - PNAME_LN() { - return this.getToken(n3Parser_n3Parser.PNAME_LN, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterPrefixedName(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitPrefixedName(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitPrefixedName(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class BlankNodeContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_blankNode; - } - - BLANK_NODE_LABEL() { - return this.getToken(n3Parser_n3Parser.BLANK_NODE_LABEL, 0); - }; - - ANON() { - return this.getToken(n3Parser_n3Parser.ANON, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterBlankNode(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitBlankNode(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitBlankNode(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - -class QuickVarContext extends src_antlr4.ParserRuleContext { - - constructor(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - super(parent, invokingState); - this.parser = parser; - this.ruleIndex = n3Parser_n3Parser.RULE_quickVar; - } - - QuickVarName() { - return this.getToken(n3Parser_n3Parser.QuickVarName, 0); - }; - - enterRule(listener) { - if(listener instanceof n3Listener ) { - listener.enterQuickVar(this); - } - } - - exitRule(listener) { - if(listener instanceof n3Listener ) { - listener.exitQuickVar(this); - } - } - - accept(visitor) { - if ( visitor instanceof n3Visitor ) { - return visitor.visitQuickVar(this); - } else { - return visitor.visitChildren(this); - } - } - - -} - - - - -n3Parser_n3Parser.N3DocContext = N3DocContext; -n3Parser_n3Parser.N3StatementContext = N3StatementContext; -n3Parser_n3Parser.N3DirectiveContext = N3DirectiveContext; -n3Parser_n3Parser.SparqlDirectiveContext = SparqlDirectiveContext; -n3Parser_n3Parser.SparqlBaseContext = SparqlBaseContext; -n3Parser_n3Parser.SparqlPrefixContext = SparqlPrefixContext; -n3Parser_n3Parser.PrefixIDContext = PrefixIDContext; -n3Parser_n3Parser.BaseContext = BaseContext; -n3Parser_n3Parser.TriplesContext = TriplesContext; -n3Parser_n3Parser.PredicateObjectListContext = PredicateObjectListContext; -n3Parser_n3Parser.ObjectListContext = ObjectListContext; -n3Parser_n3Parser.VerbContext = VerbContext; -n3Parser_n3Parser.SubjectContext = SubjectContext; -n3Parser_n3Parser.PredicateContext = PredicateContext; -n3Parser_n3Parser.ObjectContext = ObjectContext; -n3Parser_n3Parser.ExpressionContext = ExpressionContext; -n3Parser_n3Parser.PathContext = PathContext; -n3Parser_n3Parser.PathItemContext = PathItemContext; -n3Parser_n3Parser.LiteralContext = LiteralContext; -n3Parser_n3Parser.BlankNodePropertyListContext = BlankNodePropertyListContext; -n3Parser_n3Parser.IriPropertyListContext = IriPropertyListContext; -n3Parser_n3Parser.CollectionContext = CollectionContext; -n3Parser_n3Parser.FormulaContext = FormulaContext; -n3Parser_n3Parser.FormulaContentContext = FormulaContentContext; -n3Parser_n3Parser.NumericLiteralContext = NumericLiteralContext; -n3Parser_n3Parser.RdfLiteralContext = RdfLiteralContext; -n3Parser_n3Parser.IriContext = IriContext; -n3Parser_n3Parser.PrefixedNameContext = PrefixedNameContext; -n3Parser_n3Parser.BlankNodeContext = BlankNodeContext; -n3Parser_n3Parser.QuickVarContext = QuickVarContext; - -;// CONCATENATED MODULE: ./parser/n3/n3PrefixListener.js - - -class n3PrefixListener extends n3Listener { - - constructor(listener) { - super(); - - this.listener = listener; - this.prefixes = {}; - } - - // Exit a parse tree produced by n3Parser#sparqlPrefix. - exitSparqlPrefix(ctx) { - this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); - } - - // Exit a parse tree produced by n3Parser#prefixID. - exitPrefixID(ctx) { - this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); - } - - processPrefix(pNameNs, iriRef) { - if (pNameNs == null) - return - - var prefix = pNameNs.getText().trim(); - prefix = prefix.substring(0, prefix.length - 1) - - var uri = this.iri(iriRef); - this.prefixes[prefix] = uri; - } - - // Exit a parse tree produced by n3Parser#prefixedName. - exitPrefixedName(ctx) { - var pNameLn = ctx.PNAME_LN(); - - if (pNameLn != null) { - var pName = pNameLn.getText().trim(); - var prefix = pName.substring(0, pName.indexOf(":")).trim(); - - if (prefix == "") - return; - - if (this.prefixes[prefix] === undefined) { - var line = ctx.start.line - var start = ctx.start.column - var end = start + prefix.length - - this.listener.unknownPrefix(prefix, pName, line, start, end); - } - } - } - - text(node) { - if (node == null) - return null; - - return node.getText().trim(); - } - - iri(node) { - var s = this.text(node); - return s.substring(1, s.length - 1); - } -} -;// CONCATENATED MODULE: ./parser/n3/n3PrintVisitor.js -// var n3Visitor = require('./n3Visitor').n3Visitor -// var n3Parser = require('./n3Parser').n3Parser - - - -class n3PrintVisitor extends n3Visitor { - - constructor(listener) { - super(); - - this.listener = listener; - this.lvl = 0 - } - - // Visit a parse tree produced by n3Parser#n3Doc. - visitN3Doc(ctx) { - this.print("N3Doc") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#n3Statement. - visitN3Statement(ctx) { - this.print("N3Statement") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#n3Directive. - visitN3Directive(ctx) { - this.print("N3Directive") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#sparqlDirective. - visitSparqlDirective(ctx) { - this.print("SparqlDirective") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#sparqlBase. - visitSparqlBase(ctx) { - this.print("SparqlBase") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#sparqlPrefix. - visitSparqlPrefix(ctx) { - this.print("SparqlPrefix") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#prefixID. - visitPrefixID(ctx) { - this.print("PrefixID") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#base. - visitBase(ctx) { - this.print("Base") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#triples. - visitTriples(ctx) { - this.print("Triples") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#predicateObjectList. - visitPredicateObjectList(ctx) { - this.print("PredicateObjectList") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#objectList. - visitObjectList(ctx) { - this.print("ObjectList") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#verb. - visitVerb(ctx) { - this.print("Verb") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#subject. - visitSubject(ctx) { - this.print("Subject") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#predicate. - visitPredicate(ctx) { - this.print("Predicate") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#object. - visitObject(ctx) { - this.print("Object") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#expression. - visitExpression(ctx) { - this.print("Expression") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#path. - visitPath(ctx) { - this.print("Path") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#pathItem. - visitPathItem(ctx) { - this.print("PathItem") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#literal. - visitLiteral(ctx) { - this.print("Literal") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#blankNodePropertyList. - visitBlankNodePropertyList(ctx) { - this.print("BlankNodePropertyList") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#collection. - visitCollection(ctx) { - this.print("Collection") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#formula. - visitFormula(ctx) { - this.print("Formula") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#formulaContent. - visitFormulaContent(ctx) { - this.print("FormulaContent") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#numericLiteral. - visitNumericLiteral(ctx) { - this.print("NumericLiteral") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#rdfLiteral. - visitRdfLiteral(ctx) { - this.print("RdfLiteral") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#iri. - visitIri(ctx) { - this.print("Iri") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#iriList. - visitIriList(ctx) { - this.print("IriList") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#prefixedName. - visitPrefixedName(ctx) { - this.print("PrefixedName") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#blankNode. - visitBlankNode(ctx) { - this.print("BlankNode") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#quickVar. - visitQuickVar(ctx) { - this.print("QuickVar") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#existential. - visitExistential(ctx) { - this.print("Existential") - return this.doVisitChildren(ctx) - } - - - // Visit a parse tree produced by n3Parser#universal. - visitUniversal(ctx) { - this.print("Universal") - return this.doVisitChildren(ctx) - } - - - incrLvl() { - this.lvl++; - } - - decrLvl() { - this.lvl--; - } - - print(el) { - var ws = new Array(this.lvl + 1).join(" "); - var out = ws + el + "\n"; - - this.listener.newAstLine(out); - } - - doVisitChildren(ctx) { - this.lvl++; - this.visitChildren(ctx); - this.lvl--; - } - - visitChildren(node) { - var result = null; // this.defaultResult() - var n = node.getChildCount() - for (var i = 0; i < n; i++) { - // if (!this.shouldVisitNextChild(node, result)) { - // break - // } - - var c = node.getChild(i) - if (c.symbol !== undefined) { - var out = "' " + c + " '"; - var type = c.symbol.type - if (type != -1 && n3Parser_n3Parser.symbolicNames[type] !== null) - out += " (" + n3Parser_n3Parser.symbolicNames[type] + ")" - this.print(out) - - } else { - result = c.accept(this); - // result = this.aggregateResult(result, childResult); - } - } - - return result - } -} -;// CONCATENATED MODULE: ./parser/n3/index.js -// - CommonJS -// var antlr4 = require('antlr4'); -// var N3Lexer = require('./n3Lexer').n3Lexer; -// var N3Parser = require('./n3Parser').n3Parser; -// var N3PrefixListener = require('./n3PrefixListener').n3PrefixListener; -// var N3PrintListener = require('./n3PrintListener').n3PrintListener; -// var N3PrintVisitor = require('./n3PrintVisitor').n3PrintVisitor; - -// - ES6 - - - - - - - - -function parse(input, listener) { - var chars = new InputStream(input); - - var n3Lexer = new n3Lexer_n3Lexer(chars); - n3Lexer.removeErrorListeners(); - n3Lexer.addErrorListener(listener); - - var tokens = new CommonTokenStream(n3Lexer); - - var n3Parser = new n3Parser_n3Parser(tokens); - n3Parser.removeErrorListeners(); - n3Parser.removeParseListeners(); - - if (listener.syntaxError) - // will call listener with any syntax (parser/lexer) error - n3Parser.addErrorListener(listener); - - if (listener.unknownPrefix) - // will call listener with any prefix errors - n3Parser.addParseListener(new n3PrefixListener(listener)); - - // if (listener.newAstLine) - // // will call listener with individual ast lines - // n3Parser.addParseListener(new N3PrintListener(listener)); - - var ast = n3Parser.n3Doc() - if (listener.newAstLine) - new n3PrintVisitor(listener).visit(ast) -} - -// exports.parse = parse; -})(); - -n3 = __webpack_exports__; -/******/ })() -; \ No newline at end of file +/*! For license information please see n3Main.js.LICENSE.txt */ +var n3;(()=>{var t={262:()=>{}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i](r,r.exports,s),r.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";s.r(i),s.d(i,{format:()=>us,parse:()=>cs});class t{constructor(){this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null}getTokenSource(){return this.source[0]}getInputStream(){return this.source[1]}get text(){return this._text}set text(t){this._text=t}}t.INVALID_TYPE=0,t.EPSILON=-2,t.MIN_USER_TOKEN_TYPE=1,t.EOF=-1,t.DEFAULT_CHANNEL=0,t.HIDDEN_CHANNEL=1,String.prototype.codePointAt||function(){var t=function(){let t;try{const e={},s=Object.defineProperty;t=s(e,e,e)&&s}catch(t){}return t}();const e=function(t){if(null==this)throw TypeError();const e=String(this),s=e.length;let i=t?Number(t):0;if(i!=i&&(i=0),i<0||i>=s)return;const n=e.charCodeAt(i);let r;return n>=55296&&n<=56319&&s>i+1&&(r=e.charCodeAt(i+1),r>=56320&&r<=57343)?1024*(n-55296)+r-56320+65536:n};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),String.fromCodePoint||function(){const t=function(){let t;try{const e={},s=Object.defineProperty;t=s(e,e,e)&&s}catch(t){}return t}(),e=String.fromCharCode,s=Math.floor,i=function(t){const i=16384,n=[];let r,o,a=-1;const l=arguments.length;if(!l)return"";let h="";for(;++a1114111||s(t)!==t)throw RangeError("Invalid code point: "+t);t<=65535?n.push(t):(t-=65536,r=55296+(t>>10),o=t%1024+56320,n.push(r,o)),(a+1===l||n.length>i)&&(h+=e.apply(null,n),n.length=0)}return h};t?t(String,"fromCodePoint",{value:i,configurable:!0,writable:!0}):String.fromCodePoint=i}();class e{constructor(t,e){if(this.name="",this.strdata=t,this.decodeToUnicodeCodePoints=e||!1,this._index=0,this.data=[],this.decodeToUnicodeCodePoints)for(let t=0;t=this._size)throw"cannot consume EOF";this._index+=1}LA(e){if(0===e)return 0;e<0&&(e+=1);const s=this._index+e-1;return s<0||s>=this._size?t.EOF:this.data[s]}LT(t){return this.LA(t)}mark(){return-1}release(t){}seek(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)}getText(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){let s="";for(let i=t;i<=e;i++)s+=String.fromCodePoint(this.data[i]);return s}return this.strdata.slice(t,e+1)}toString(){return this.strdata}get index(){return this._index}get size(){return this._size}}class n{syntaxError(t,e,s,i,n,r){}reportAmbiguity(t,e,s,i,n,r,o){}reportAttemptingFullContext(t,e,s,i,n,r){}reportContextSensitivity(t,e,s,i,n,r){}}class r extends n{constructor(){super()}syntaxError(t,e,s,i,n,r){console.error("line "+s+":"+i+" "+n)}}r.INSTANCE=new r;class o extends n{constructor(t){if(super(),null===t)throw"delegates";return this.delegates=t,this}syntaxError(t,e,s,i,n,r){this.delegates.map((o=>o.syntaxError(t,e,s,i,n,r)))}reportAmbiguity(t,e,s,i,n,r,o){this.delegates.map((a=>a.reportAmbiguity(t,e,s,i,n,r,o)))}reportAttemptingFullContext(t,e,s,i,n,r){this.delegates.map((o=>o.reportAttemptingFullContext(t,e,s,i,n,r)))}reportContextSensitivity(t,e,s,i,n,r){this.delegates.map((o=>o.reportContextSensitivity(t,e,s,i,n,r)))}}class a{constructor(){this._listeners=[r.INSTANCE],this._interp=null,this._stateNumber=-1}checkVersion(t){"4.10.1"!==t&&console.log("ANTLR runtime and generated code versions disagree: 4.10.1!="+t)}addErrorListener(t){this._listeners.push(t)}removeErrorListeners(){this._listeners=[]}getLiteralNames(){return Object.getPrototypeOf(this).constructor.literalNames||[]}getSymbolicNames(){return Object.getPrototypeOf(this).constructor.symbolicNames||[]}getTokenNames(){if(!this.tokenNames){const t=this.getLiteralNames(),e=this.getSymbolicNames(),s=t.length>e.length?t.length:e.length;this.tokenNames=[];for(let i=0;i";let s=e.text;return null===s&&(s=e.type===t.EOF?"":"<"+e.type+">"),s=s.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"),"'"+s+"'"}getErrorListenerDispatch(){return new o(this._listeners)}sempred(t,e,s){return!0}precpred(t,e){return!0}get state(){return this._stateNumber}set state(t){this._stateNumber=t}}a.tokenTypeMapCache={},a.ruleIndexMapCache={};class l extends t{constructor(e,s,i,n,r){super(),this.source=void 0!==e?e:l.EMPTY_SOURCE,this.type=void 0!==s?s:null,this.channel=void 0!==i?i:t.DEFAULT_CHANNEL,this.start=void 0!==n?n:-1,this.stop=void 0!==r?r:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=e[0].line,this.column=e[0].column):this.column=-1}clone(){const t=new l(this.source,this.type,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,t.text=this.text,t}toString(){let t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"}get text(){if(null!==this._text)return this._text;const t=this.getInputStream();if(null===t)return null;const e=t.size;return this.start"}set text(t){this._text=t}}l.EMPTY_SOURCE=[null,null];class h extends class{}{constructor(t){super(),this.copyText=void 0!==t&&t}create(t,e,s,i,n,r,o,a){const h=new l(t,e,i,n,r);return h.line=o,h.column=a,null!==s?h.text=s:this.copyText&&null!==t[1]&&(h.text=t[1].getText(n,r)),h}createThin(t,e){const s=new l(null,t);return s.text=e,s}}h.DEFAULT=new h;class c extends Error{constructor(t){super(t.message),Error.captureStackTrace&&Error.captureStackTrace(this,c),this.message=t.message,this.recognizer=t.recognizer,this.input=t.input,this.ctx=t.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}}class u{constructor(t,e){this.start=t,this.stop=e}clone(){return new u(this.start,this.stop)}contains(t){return t>=this.start&&t=0&&this.startIndex":"\n"===e?"\\n":"\t"===e?"\\t":"\r"===e?"\\r":e}getCharErrorDisplay(t){return"'"+this.getErrorDisplayForChar(t)+"'"}recover(e){this._input.LA(1)!==t.EOF&&(e instanceof d?this._interp.consume(this._input):this._input.consume())}get inputStream(){return this._input}set inputStream(t){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=t,this._tokenFactorySourcePair=[this,this._input]}get sourceName(){return this._input.sourceName}get type(){return this._type}set type(t){this._type=t}get line(){return this._interp.line}set line(t){this._interp.line=t}get column(){return this._interp.column}set column(t){this._interp.column=t}get text(){return null!==this._text?this._text:this._interp.getText(this._input)}set text(t){this._text=t}}p.DEFAULT_MODE=0,p.MORE=-2,p.SKIP=-3,p.DEFAULT_TOKEN_CHANNEL=t.DEFAULT_CHANNEL,p.HIDDEN=t.HIDDEN_CHANNEL,p.MIN_CHAR_VALUE=0,p.MAX_CHAR_VALUE=1114111;class g extends class extends class{}{constructor(t){super(),this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}mark(){return 0}release(t){}reset(){this.seek(0)}seek(t){this.lazyInit(),this.index=this.adjustSeekIndex(t)}get(t){return this.lazyInit(),this.tokens[t]}consume(){let e=!1;if(e=this.index>=0&&(this.fetchedEOF?this.index0)||this.fetch(e)>=e}fetch(e){if(this.fetchedEOF)return 0;for(let s=0;s=this.tokens.length&&(s=this.tokens.length-1);for(let r=e;r=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]}adjustSeekIndex(t){return t}lazyInit(){-1===this.index&&this.setup()}setup(){this.sync(0),this.index=this.adjustSeekIndex(0)}setTokenSource(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}nextTokenOnChannel(e,s){if(this.sync(e),e>=this.tokens.length)return-1;let i=this.tokens[e];for(;i.channel!==this.channel;){if(i.type===t.EOF)return-1;e+=1,this.sync(e),i=this.tokens[e]}return e}previousTokenOnChannel(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t}getHiddenTokensToRight(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const s=this.nextTokenOnChannel(t+1,p.DEFAULT_TOKEN_CHANNEL),i=t+1,n=-1===s?this.tokens.length-1:s;return this.filterForChannel(i,n,e)}getHiddenTokensToLeft(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const s=this.previousTokenOnChannel(t-1,p.DEFAULT_TOKEN_CHANNEL);if(s===t-1)return null;const i=s+1,n=t-1;return this.filterForChannel(i,n,e)}filterForChannel(t,e,s){const i=[];for(let n=t;n=this.tokens.length&&(i=this.tokens.length-1);let n="";for(let e=s;e>>16)*o&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*a+(((s>>>16)*a&65535)<<16)&4294967295,r^=s,r=r<<13|r>>>19,e=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=27492+(65535&e)+((58964+(e>>>16)&65535)<<16);switch(s=0,i){case 3:s^=(255&t.charCodeAt(l+2))<<16;case 2:s^=(255&t.charCodeAt(l+1))<<8;case 1:s^=255&t.charCodeAt(l),s=(65535&s)*o+(((s>>>16)*o&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*a+(((s>>>16)*a&65535)<<16)&4294967295,r^=s}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0};class f{constructor(){this.count=0,this.hash=0}update(){for(let t=0;t>>17,t*=461845907,this.count=this.count+1;let s=this.hash^t;s=s<<13|s>>>19,s=5*s+3864292196,this.hash=s}}}finish(){let t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16,t}static hashStuff(){const t=new f;return t.update.apply(t,arguments),t.finish()}}function _(t){return t?t.hashCode():-1}function T(t,e){return t?t.equals(e):t===e}function E(t){return null===t?"null":t}function C(t){return Array.isArray(t)?"["+t.map(E).join(", ")+"]":"null"}const S="h-";class m{constructor(t,e){this.data={},this.hashFunction=t||_,this.equalsFunction=e||T}add(t){const e=S+this.hashFunction(t);if(e in this.data){const s=this.data[e];for(let e=0;et.startsWith(S))).flatMap((t=>this.data[t]),this)}toString(){return C(this.values())}get length(){return Object.keys(this.data).filter((t=>t.startsWith(S))).map((t=>this.data[t].length),this).reduce(((t,e)=>t+e),0)}}class A{hashCode(){const t=new f;return this.updateHashCode(t),t.finish()}evaluate(t,e){}evalPrecedence(t,e){return this}static andContext(t,e){if(null===t||t===A.NONE)return e;if(null===e||e===A.NONE)return t;const s=new N(t,e);return 1===s.opnds.length?s.opnds[0]:s}static orContext(t,e){if(null===t)return e;if(null===e)return t;if(t===A.NONE||e===A.NONE)return A.NONE;const s=new L(t,e);return 1===s.opnds.length?s.opnds[0]:s}}class N extends A{constructor(t,e){super();const s=new m;t instanceof N?t.opnds.map((function(t){s.add(t)})):s.add(t),e instanceof N?e.opnds.map((function(t){s.add(t)})):s.add(e);const i=R(s);if(i.length>0){let t=null;i.map((function(e){(null===t||e.precedencet.toString()));return(t.length>3?t.slice(3):t).join("&&")}}class L extends A{constructor(t,e){super();const s=new m;t instanceof L?t.opnds.map((function(t){s.add(t)})):s.add(t),e instanceof L?e.opnds.map((function(t){s.add(t)})):s.add(e);const i=R(s);if(i.length>0){const t=i.sort((function(t,e){return t.compareTo(e)})),e=t[t.length-1];s.add(e)}this.opnds=Array.from(s.values())}equals(t){return this===t||t instanceof L&&x(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"OR")}evaluate(t,e){for(let s=0;st.toString()));return(t.length>3?t.slice(3):t).join("||")}}function R(t){const e=[];return t.values().map((function(t){t instanceof A.PrecedencePredicate&&e.push(t)})),e}function I(t,e){if(null===t){const t={state:null,alt:null,context:null,semanticContext:null};return e&&(t.reachesIntoOuterContext=0),t}{const s={};return s.state=t.state||null,s.alt=void 0===t.alt?null:t.alt,s.context=t.context||null,s.semanticContext=t.semanticContext||null,e&&(s.reachesIntoOuterContext=t.reachesIntoOuterContext||0,s.precedenceFilterSuppressed=t.precedenceFilterSuppressed||!1),s}}class v{constructor(t,e){this.checkContext(t,e),t=I(t),e=I(e,!0),this.state=null!==t.state?t.state:e.state,this.alt=null!==t.alt?t.alt:e.alt,this.context=null!==t.context?t.context:e.context,this.semanticContext=null!==t.semanticContext?t.semanticContext:null!==e.semanticContext?e.semanticContext:A.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,this.precedenceFilterSuppressed=e.precedenceFilterSuppressed}checkContext(t,e){null!==t.context&&void 0!==t.context||null!==e&&null!==e.context&&void 0!==e.context||(this.context=null)}hashCode(){const t=new f;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)}equals(t){return this===t||t instanceof v&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&(null===this.context?null===t.context:this.context.equals(t.context))&&this.semanticContext.equals(t.semanticContext)&&this.precedenceFilterSuppressed===t.precedenceFilterSuppressed}hashCodeForConfigSet(){const t=new f;return t.update(this.state.stateNumber,this.alt,this.semanticContext),t.finish()}equalsForConfigSet(t){return this===t||t instanceof v&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&this.semanticContext.equals(t.semanticContext)}toString(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==A.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}class y{constructor(){this.intervals=null,this.readOnly=!1}first(e){return null===this.intervals||0===this.intervals.length?t.INVALID_TYPE:this.intervals[0].start}addOne(t){this.addInterval(new u(t,t+1))}addRange(t,e){this.addInterval(new u(t,e+1))}addInterval(t){if(null===this.intervals)this.intervals=[],this.intervals.push(t.clone());else{for(let e=0;ethis.addInterval(t)),this),this}reduce(t){if(t=s.stop?(this.intervals.splice(t+1,1),this.reduce(t)):e.stop>=s.start&&(this.intervals[t]=new u(e.start,s.stop),this.intervals.splice(t+1,1))}}complement(t,e){const s=new y;return s.addInterval(new u(t,e+1)),null!==this.intervals&&this.intervals.forEach((t=>s.removeRange(t))),s}contains(t){if(null===this.intervals)return!1;for(let e=0;es.start&&t.stop=s.stop?(this.intervals.splice(e,1),e-=1):t.start"):e.push("'"+String.fromCharCode(i.start)+"'"):e.push("'"+String.fromCharCode(i.start)+"'..'"+String.fromCharCode(i.stop-1)+"'")}return e.length>1?"{"+e.join(", ")+"}":e[0]}toIndexString(){const e=[];for(let s=0;s"):e.push(i.start.toString()):e.push(i.start.toString()+".."+(i.stop-1).toString())}return e.length>1?"{"+e.join(", ")+"}":e[0]}toTokenString(t,e){const s=[];for(let i=0;i1?"{"+s.join(", ")+"}":s[0]}elementName(e,s,i){return i===t.EOF?"":i===t.EPSILON?"":e[i]||s[i]}get length(){return this.intervals.map((t=>t.length)).reduce(((t,e)=>t+e))}}class k{constructor(){this.atn=null,this.stateNumber=k.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null}toString(){return this.stateNumber}equals(t){return t instanceof k&&this.stateNumber===t.stateNumber}isNonGreedyExitState(){return!1}addTransition(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)}}k.INVALID_TYPE=0,k.BASIC=1,k.RULE_START=2,k.BLOCK_START=3,k.PLUS_BLOCK_START=4,k.STAR_BLOCK_START=5,k.TOKEN_START=6,k.RULE_STOP=7,k.BLOCK_END=8,k.STAR_LOOP_BACK=9,k.STAR_LOOP_ENTRY=10,k.PLUS_LOOP_BACK=11,k.LOOP_END=12,k.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],k.INVALID_STATE_NUMBER=-1;class O extends k{constructor(){return super(),this.stateType=k.RULE_STOP,this}}class P{constructor(t){if(null==t)throw"target cannot be null.";this.target=t,this.isEpsilon=!1,this.label=null}}P.EPSILON=1,P.RANGE=2,P.RULE=3,P.PREDICATE=4,P.ATOM=5,P.ACTION=6,P.SET=7,P.NOT_SET=8,P.WILDCARD=9,P.PRECEDENCE=10,P.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],P.serializationTypes={EpsilonTransition:P.EPSILON,RangeTransition:P.RANGE,RuleTransition:P.RULE,PredicateTransition:P.PREDICATE,AtomTransition:P.ATOM,ActionTransition:P.ACTION,SetTransition:P.SET,NotSetTransition:P.NOT_SET,WildcardTransition:P.WILDCARD,PrecedencePredicateTransition:P.PRECEDENCE};class b extends P{constructor(t,e,s,i){super(t),this.ruleIndex=e,this.precedence=s,this.followState=i,this.serializationType=P.RULE,this.isEpsilon=!0}matches(t,e,s){return!1}}class w extends P{constructor(e,s){super(e),this.serializationType=P.SET,null!=s?this.label=s:(this.label=new y,this.label.addOne(t.INVALID_TYPE))}matches(t,e,s){return this.label.contains(t)}toString(){return this.label.toString()}}class D extends w{constructor(t,e){super(t,e),this.serializationType=P.NOT_SET}matches(t,e,s){return t>=e&&t<=s&&!super.matches(t,e,s)}toString(){return"~"+super.toString()}}class F extends P{constructor(t){super(t),this.serializationType=P.WILDCARD}matches(t,e,s){return t>=e&&t<=s}toString(){return"."}}class U extends P{constructor(t){super(t)}}class V extends class extends class{}{}{}class M extends V{getRuleContext(){throw new Error("missing interface implementation")}}class H extends V{}class B extends H{}const q={toStringTree:function(t,e,s){e=e||null,null!==(s=s||null)&&(e=s.ruleNames);let i=q.getNodeText(t,e);i=function(t,e){return t=t.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(i);const n=t.getChildCount();if(0===n)return i;let r="("+i+" ";n>0&&(i=q.toStringTree(t.getChild(0),e),r=r.concat(i));for(let s=1;s=0&&e0&&(t+=", "),this.returnStates[e]!==z.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"}}get length(){return this.returnStates.length}}class Y extends z{constructor(t,e){let s=0;const i=new f;null!==t?i.update(t,e):i.update(1),s=i.finish(),super(s),this.parentCtx=t,this.returnState=e}getParent(t){return this.parentCtx}getReturnState(t){return this.returnState}equals(t){return this===t||t instanceof Y&&this.hashCode()===t.hashCode()&&this.returnState===t.returnState&&(null==this.parentCtx?null==t.parentCtx:this.parentCtx.equals(t.parentCtx))}toString(){const t=null===this.parentCtx?"":this.parentCtx.toString();return 0===t.length?this.returnState===z.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+t}get length(){return 1}static create(t,e){return e===z.EMPTY_RETURN_STATE&&null===t?z.EMPTY:new Y(t,e)}}class Q extends Y{constructor(){super(null,z.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(t){return null}getReturnState(t){return this.returnState}equals(t){return this===t}toString(){return"$"}}z.EMPTY=new Q;const X="h-";class W{constructor(t,e){this.data={},this.hashFunction=t||_,this.equalsFunction=e||T}set(t,e){const s=X+this.hashFunction(t);if(s in this.data){const i=this.data[s];for(let s=0;st.startsWith(X))).flatMap((t=>this.data[t]),this)}getKeys(){return this.entries().map((t=>t.key))}getValues(){return this.entries().map((t=>t.value))}toString(){return"["+this.entries().map((t=>"{"+t.key+":"+t.value+"}")).join(", ")+"]"}get length(){return Object.keys(this.data).filter((t=>t.startsWith(X))).map((t=>this.data[t].length),this).reduce(((t,e)=>t+e),0)}}function $(t,e){if(null==e&&(e=G.EMPTY),null===e.parentCtx||e===G.EMPTY)return z.EMPTY;const s=$(t,e.parentCtx),i=t.states[e.invokingState].transitions[0];return Y.create(s,i.followState.stateNumber)}function J(t,e,s){if(t.isEmpty())return t;let i=s.get(t)||null;if(null!==i)return i;if(i=e.get(t),null!==i)return s.set(t,i),i;let n=!1,r=[];for(let i=0;ie.returnState&&(n[0]=e.returnState,n[1]=t.returnState);const r=new K([s,s],n);return null!==i&&i.set(t,e,r),r}const n=[t.returnState,e.returnState];let r=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(n[0]=e.returnState,n[1]=t.returnState,r=[e.parentCtx,t.parentCtx]);const o=new K(r,n);return null!==i&&i.set(t,e,o),o}}(t,e,s,i);if(s){if(t instanceof Q)return t;if(e instanceof Q)return e}return t instanceof Y&&(t=new K([t.getParent()],[t.returnState])),e instanceof Y&&(e=new K([e.getParent()],[e.returnState])),function(t,e,s,i){if(null!==i){let s=i.get(t,e);if(null!==s)return s;if(s=i.get(e,t),null!==s)return s}let n=0,r=0,o=0,a=[],l=[];for(;nthis.add(t)),this)}remove(t){delete this.data[t]}has(t){return!0===this.data[t]}values(){return Object.keys(this.data)}minValue(){return Math.min.apply(null,this.values())}hashCode(){return f.hashStuff(this.values())}equals(t){return t instanceof tt&&x(this.data,t.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.values().length}}class et{constructor(t){this.atn=t}getDecisionLookahead(t){if(null===t)return null;const e=t.transitions.length,s=[];for(let i=0;i=this.states.length)throw"Invalid state number.";const i=this.states[e];let n=this.nextTokens(i);if(!n.contains(t.EPSILON))return n;const r=new y;for(r.addSet(n),r.removeOne(t.EPSILON);null!==s&&s.invokingState>=0&&n.contains(t.EPSILON);){const e=this.states[s.invokingState].transitions[0];n=this.nextTokens(e.followState),r.addSet(n),r.removeOne(t.EPSILON),s=s.parentCtx}return n.contains(t.EPSILON)&&r.addOne(t.EOF),r}}st.INVALID_ALT_NUMBER=0;class it extends k{constructor(){super(),this.stateType=k.BASIC}}class nt extends k{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class rt extends nt{constructor(){return super(),this.endState=null,this}}class ot extends k{constructor(){return super(),this.stateType=k.BLOCK_END,this.startState=null,this}}class at extends k{constructor(){return super(),this.stateType=k.LOOP_END,this.loopBackState=null,this}}class lt extends k{constructor(){return super(),this.stateType=k.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class ht extends nt{constructor(){return super(),this.stateType=k.TOKEN_START,this}}class ct extends nt{constructor(){return super(),this.stateType=k.PLUS_LOOP_BACK,this}}class ut extends k{constructor(){return super(),this.stateType=k.STAR_LOOP_BACK,this}}class dt extends nt{constructor(){return super(),this.stateType=k.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class pt extends rt{constructor(){return super(),this.stateType=k.PLUS_BLOCK_START,this.loopBackState=null,this}}class gt extends rt{constructor(){return super(),this.stateType=k.STAR_BLOCK_START,this}}class xt extends rt{constructor(){return super(),this.stateType=k.BLOCK_START,this}}class ft extends P{constructor(t,e){super(t),this.label_=e,this.label=this.makeLabel(),this.serializationType=P.ATOM}makeLabel(){const t=new y;return t.addOne(this.label_),t}matches(t,e,s){return this.label_===t}toString(){return this.label_}}class _t extends P{constructor(t,e,s){super(t),this.serializationType=P.RANGE,this.start=e,this.stop=s,this.label=this.makeLabel()}makeLabel(){const t=new y;return t.addRange(this.start,this.stop),t}matches(t,e,s){return t>=this.start&&t<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}}class Tt extends P{constructor(t,e,s,i){super(t),this.serializationType=P.ACTION,this.ruleIndex=e,this.actionIndex=void 0===s?-1:s,this.isCtxDependent=void 0!==i&&i,this.isEpsilon=!0}matches(t,e,s){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}}class Et extends P{constructor(t,e){super(t),this.serializationType=P.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e}matches(t,e,s){return!1}toString(){return"epsilon"}}class Ct extends A{constructor(t,e,s){super(),this.ruleIndex=void 0===t?-1:t,this.predIndex=void 0===e?-1:e,this.isCtxDependent=void 0!==s&&s}evaluate(t,e){const s=this.isCtxDependent?e:null;return t.sempred(s,this.ruleIndex,this.predIndex)}updateHashCode(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)}equals(t){return this===t||t instanceof Ct&&this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}A.NONE=new Ct;class St extends U{constructor(t,e,s,i){super(t),this.serializationType=P.PREDICATE,this.ruleIndex=e,this.predIndex=s,this.isCtxDependent=i,this.isEpsilon=!0}matches(t,e,s){return!1}getPredicate(){return new Ct(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class mt extends A{constructor(t){super(),this.precedence=void 0===t?0:t}evaluate(t,e){return t.precpred(e,this.precedence)}evalPrecedence(t,e){return t.precpred(e,this.precedence)?A.NONE:null}compareTo(t){return this.precedence-t.precedence}updateHashCode(t){t.update(this.precedence)}equals(t){return this===t||t instanceof mt&&this.precedence===t.precedence}toString(){return"{"+this.precedence+">=prec}?"}}A.PrecedencePredicate=mt;class At extends U{constructor(t,e){super(t),this.serializationType=P.PRECEDENCE,this.precedence=e,this.isEpsilon=!0}matches(t,e,s){return!1}getPredicate(){return new mt(this.precedence)}toString(){return this.precedence+" >= _p"}}class Nt{constructor(t){void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions}}Nt.defaultOptions=new Nt,Nt.defaultOptions.readOnly=!0;class Lt{constructor(t){this.actionType=t,this.isPositionDependent=!1}hashCode(){const t=new f;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.actionType)}equals(t){return this===t}}class Rt extends Lt{constructor(){super(6)}execute(t){t.skip()}toString(){return"skip"}}Rt.INSTANCE=new Rt;class It extends Lt{constructor(t){super(0),this.channel=t}execute(t){t._channel=this.channel}updateHashCode(t){t.update(this.actionType,this.channel)}equals(t){return this===t||t instanceof It&&this.channel===t.channel}toString(){return"channel("+this.channel+")"}}class vt extends Lt{constructor(t,e){super(1),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0}execute(t){t.action(null,this.ruleIndex,this.actionIndex)}updateHashCode(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)}equals(t){return this===t||t instanceof vt&&this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex}}class yt extends Lt{constructor(){super(3)}execute(t){t.more()}toString(){return"more"}}yt.INSTANCE=new yt;class kt extends Lt{constructor(t){super(7),this.type=t}execute(t){t.type=this.type}updateHashCode(t){t.update(this.actionType,this.type)}equals(t){return this===t||t instanceof kt&&this.type===t.type}toString(){return"type("+this.type+")"}}class Ot extends Lt{constructor(t){super(5),this.mode=t}execute(t){t.pushMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof Ot&&this.mode===t.mode}toString(){return"pushMode("+this.mode+")"}}class Pt extends Lt{constructor(){super(4)}execute(t){t.popMode()}toString(){return"popMode"}}Pt.INSTANCE=new Pt;class bt extends Lt{constructor(t){super(2),this.mode=t}execute(t){t.mode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof bt&&this.mode===t.mode}toString(){return"mode("+this.mode+")"}}function wt(t,e){const s=[];return s[t-1]=e,s.map((function(t){return e}))}class Dt{constructor(t){null==t&&(t=Nt.defaultOptions),this.deserializationOptions=t,this.stateFactories=null,this.actionFactories=null}deserialize(t){const e=this.reset(t);this.checkVersion(e),e&&this.skipUUID();const s=this.readATN();this.readStates(s,e),this.readRules(s,e),this.readModes(s);const i=[];return this.readSets(s,i,this.readInt.bind(this)),e&&this.readSets(s,i,this.readInt32.bind(this)),this.readEdges(s,i),this.readDecisions(s),this.readLexerActions(s,e),this.markPrecedenceDecisions(s),this.verifyATN(s),this.deserializationOptions.generateRuleBypassTransitions&&1===s.grammarType&&(this.generateRuleBypassTransitions(s),this.verifyATN(s)),s}reset(t){if(3===(t.charCodeAt?t.charCodeAt(0):t[0])){const e=function(t){const e=t.charCodeAt(0);return e>1?e-2:e+65534},s=t.split("").map(e);return s[0]=t.charCodeAt(0),this.data=s,this.pos=0,!0}return this.data=t,this.pos=0,!1}skipUUID(){let t=0;for(;t++<8;)this.readInt()}checkVersion(t){const e=this.readInt();if(!t&&4!==e)throw"Could not deserialize ATN with version "+e+" (expected 4)."}readATN(){const t=this.readInt(),e=this.readInt();return new st(t,e)}readStates(t,e){let s,i,n;const r=[],o=[],a=this.readInt();for(let s=0;s0;)n.addTransition(l.transitions[h-1]),l.transitions=l.transitions.slice(-1);t.ruleToStartState[e].addTransition(new Et(n)),r.addTransition(new Et(a));const c=new it;t.addState(c),c.addTransition(new ft(r,t.ruleToTokenType[e])),n.addTransition(new Et(c))}stateIsEndStateFor(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof dt))return null;const s=t.transitions[t.transitions.length-1].target;return s instanceof at&&s.epsilonOnlyTransitions&&s.transitions[0].target instanceof O?t:null}markPrecedenceDecisions(t){for(let e=0;e=0):this.checkCondition(s.transitions.length<=1||s instanceof O)}}checkCondition(t,e){if(!t)throw null==e&&(e="IllegalState"),e}readInt(){return this.data[this.pos++]}readInt32(){return this.readInt()|this.readInt()<<16}edgeFactory(e,s,i,n,r,o,a,l){const h=e.states[n];switch(s){case P.EPSILON:return new Et(h);case P.RANGE:return new _t(h,0!==a?t.EOF:r,o);case P.RULE:return new b(e.states[r],o,a,h);case P.PREDICATE:return new St(h,r,o,0!==a);case P.PRECEDENCE:return new At(h,r);case P.ATOM:return new ft(h,0!==a?t.EOF:r);case P.ACTION:return new Tt(h,r,o,0!==a);case P.SET:return new w(h,l[r]);case P.NOT_SET:return new D(h,l[r]);case P.WILDCARD:return new F(h);default:throw"The specified transition type: "+s+" is not valid."}}stateFactory(t,e){if(null===this.stateFactories){const t=[];t[k.INVALID_TYPE]=null,t[k.BASIC]=()=>new it,t[k.RULE_START]=()=>new lt,t[k.BLOCK_START]=()=>new xt,t[k.PLUS_BLOCK_START]=()=>new pt,t[k.STAR_BLOCK_START]=()=>new gt,t[k.TOKEN_START]=()=>new ht,t[k.RULE_STOP]=()=>new O,t[k.BLOCK_END]=()=>new ot,t[k.STAR_LOOP_BACK]=()=>new ut,t[k.STAR_LOOP_ENTRY]=()=>new dt,t[k.PLUS_LOOP_BACK]=()=>new ct,t[k.LOOP_END]=()=>new at,this.stateFactories=t}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";{const s=this.stateFactories[t]();if(null!==s)return s.ruleIndex=e,s}}lexerActionFactory(t,e,s){if(null===this.actionFactories){const t=[];t[0]=(t,e)=>new It(t),t[1]=(t,e)=>new vt(t,e),t[2]=(t,e)=>new bt(t),t[3]=(t,e)=>yt.INSTANCE,t[4]=(t,e)=>Pt.INSTANCE,t[5]=(t,e)=>new Ot(t),t[6]=(t,e)=>Rt.INSTANCE,t[7]=(t,e)=>new kt(t),this.actionFactories=t}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,s)}}function Ft(t){return t.hashCodeForConfigSet()}function Ut(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}class Vt{constructor(t){this.configLookup=new m(Ft,Ut),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1}add(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==A.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);const s=this.configLookup.add(t);if(s===t)return this.cachedHashCode=-1,this.configs.push(t),!0;const i=!this.fullCtx,n=Z(s.context,t.context,i,e);return s.reachesIntoOuterContext=Math.max(s.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(s.precedenceFilterSuppressed=!0),s.context=n,!0}getStates(){const t=new m;for(let e=0;eYt.MAX_DFA_EDGE)return null;let s=t.edges[e-Yt.MIN_DFA_EDGE];return void 0===s&&(s=null),Yt.debug&&null!==s&&console.log("reuse state "+t.stateNumber+" edge to "+s.stateNumber),s}computeTargetState(t,e,s){const i=new Bt;return this.getReachableConfigSet(t,e.configs,i,s),0===i.items.length?(i.hasSemanticContext||this.addDFAEdge(e,s,Ht.ERROR),Ht.ERROR):this.addDFAEdge(e,s,null,i)}failOrAccept(e,s,i,n){if(null!==this.prevAccept.dfaState){const t=e.dfaState.lexerActionExecutor;return this.accept(s,t,this.startIndex,e.index,e.line,e.column),e.dfaState.prediction}if(n===t.EOF&&s.index===this.startIndex)return t.EOF;throw new d(this.recog,s,this.startIndex,i)}getReachableConfigSet(e,s,i,n){let r=st.INVALID_ALT_NUMBER;for(let o=0;oYt.MAX_DFA_EDGE||(Yt.debug&&console.log("EDGE "+t+" -> "+s+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-Yt.MIN_DFA_EDGE]=s),s}addDFAState(t){const e=new Mt(null,t);let s=null;for(let e=0;et.startsWith("k-"))).map((t=>this.data[t]),this)}}const Wt={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(t,e){if(Wt.allConfigsInRuleStopStates(e))return!0;if(t===Wt.SLL&&e.hasSemanticContext){const t=new Vt;for(let s=0;s1)return!0;return!1},allSubsetsEqual:function(t){let e=null;for(let s=0;s0&&(r=this.getAltThatFinishedDecisionEntryRule(n),r!==st.INVALID_ALT_NUMBER)?r:st.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(t){const e=[];for(let s=0;s0||i.state instanceof O&&i.context.hasEmptyPath())&&e.indexOf(i.alt)<0&&e.push(i.alt)}return 0===e.length?st.INVALID_ALT_NUMBER:Math.min.apply(null,e)}splitAccordingToSemanticValidity(t,e){const s=new Vt(t.fullCtx),i=new Vt(t.fullCtx);for(let n=0;n50))throw"problem";if(t.state instanceof O){if(!t.context.isEmpty()){for(let a=0;a=0&&(i+=1)}this.closureCheckingStopState(u,e,s,c,n,i,o)}}}canDropLoopEntryEdgeInLeftRecursiveRule(t){const e=t.state;if(e.stateType!==k.STAR_LOOP_ENTRY)return!1;if(e.stateType!==k.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;const s=t.context.length;for(let i=0;i=0?this.parser.ruleNames[t]:""}getEpsilonTarget(e,s,i,n,r,o){switch(s.serializationType){case P.RULE:return this.ruleTransition(e,s);case P.PRECEDENCE:return this.precedenceTransition(e,s,i,n,r);case P.PREDICATE:return this.predTransition(e,s,i,n,r);case P.ACTION:return this.actionTransition(e,s);case P.EPSILON:return new v({state:s.target},e);case P.ATOM:case P.RANGE:case P.SET:return o&&s.matches(t.EOF,0,1)?new v({state:s.target},e):null;default:return null}}actionTransition(t,e){if(this.debug){const t=-1===e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+t)}return new v({state:e.target},t)}precedenceTransition(t,e,s,i,n){this.debug&&(console.log("PRED (collectPredicates="+s+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+C(this.parser.getRuleInvocationStack())));let r=null;if(s&&i)if(n){const s=this._input.index;this._input.seek(this._startIndex);const i=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(s),i&&(r=new v({state:e.target},t))}else{const s=A.andContext(t.semanticContext,e.getPredicate());r=new v({state:e.target,semanticContext:s},t)}else r=new v({state:e.target},t);return this.debug&&console.log("config from pred transition="+r),r}predTransition(t,e,s,i,n){this.debug&&(console.log("PRED (collectPredicates="+s+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+C(this.parser.getRuleInvocationStack())));let r=null;if(s&&(e.isCtxDependent&&i||!e.isCtxDependent))if(n){const s=this._input.index;this._input.seek(this._startIndex);const i=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(s),i&&(r=new v({state:e.target},t))}else{const s=A.andContext(t.semanticContext,e.getPredicate());r=new v({state:e.target,semanticContext:s},t)}else r=new v({state:e.target},t);return this.debug&&console.log("config from pred transition="+r),r}ruleTransition(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);const s=e.followState,i=Y.create(t.context,s.stateNumber);return new v({state:e.target,context:i},t)}getConflictingAlts(t){const e=$t.getConflictingAltSubsets(t);return $t.getAlts(e)}getConflictingAltsOrUniqueAlt(t){let e=null;return t.uniqueAlt!==st.INVALID_ALT_NUMBER?(e=new tt,e.add(t.uniqueAlt)):e=t.conflictingAlts,e}getTokenName(e){if(e===t.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(e>=this.parser.literalNames.length&&e>=this.parser.symbolicNames.length))return(this.parser.literalNames[e]||this.parser.symbolicNames[e])+"<"+e+">";console.log(e+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+e}getLookaheadName(t){return this.getTokenName(t.LA(1))}dumpDeadEndConfigs(t){console.log("dead end configs: ");const e=t.getDeadEndConfigs();for(let t=0;t0){const t=s.state.transitions[0];t instanceof ft?i="Atom "+this.getTokenName(t.label):t instanceof w&&(i=(t instanceof D?"~":"")+"Set "+t.set)}console.error(s.toString(this.parser,!0)+":"+i)}}noViableAlt(t,e,s,i){return new Jt(this.parser,t,t.get(i),t.LT(1),s,e)}getUniqueAlt(t){let e=st.INVALID_ALT_NUMBER;for(let s=0;s "+i+" upon "+this.getTokenName(s)),null===i)return null;if(i=this.addDFAState(t,i),null===e||s<-1||s>this.atn.maxTokenType)return i;if(null===e.edges&&(e.edges=[]),e.edges[s+1]=i,this.debug){const e=null===this.parser?null:this.parser.literalNames,s=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(e,s))}return i}addDFAState(t,e){if(e===Ht.ERROR)return e;const s=t.states.get(e);return null!==s?s:(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)}reportAttemptingFullContext(t,e,s,i,n){if(this.debug||this.retry_debug){const e=new u(i,n+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+s+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser,t,i,n,e,s)}reportContextSensitivity(t,e,s,i,n){if(this.debug||this.retry_debug){const e=new u(i,n+1);console.log("reportContextSensitivity decision="+t.decision+":"+s+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser,t,i,n,e,s)}reportAmbiguity(t,e,s,i,n,r,o){if(this.debug||this.retry_debug){const t=new u(s,i+1);console.log("reportAmbiguity "+r+":"+o+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser,t,s,i,n,r,o)}},PredictionMode:$t};class ee{constructor(t,e,s){this.dfa=t,this.literalNames=e||[],this.symbolicNames=s||[]}toString(){if(null===this.dfa.s0)return null;let t="";const e=this.dfa.sortedStates();for(let s=0;s"),t=t.concat(this.getStateString(e)),t=t.concat("\n"))}}}return 0===t.length?null:t}getEdgeLabel(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)}getStateString(t){const e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+C(t.predicates):e+"=>"+t.prediction.toString():e}}class se extends ee{constructor(t){super(t,null)}getEdgeLabel(t){return"'"+String.fromCharCode(t)+"'"}}const ie={DFA:class{constructor(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new m,this.s0=null,this.precedenceDfa=!1,t instanceof dt&&t.isPrecedenceDecision){this.precedenceDfa=!0;const t=new Mt(null,new Vt);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}}getPrecedenceStartState(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null}setPrecedenceStartState(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)}setPrecedenceDfa(t){if(this.precedenceDfa!==t){if(this._states=new m,t){const t=new Mt(null,new Vt);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}else this.s0=null;this.precedenceDfa=t}}sortedStates(){return this._states.values().sort((function(t,e){return t.stateNumber-e.stateNumber}))}toString(t,e){return t=t||null,e=e||null,null===this.s0?"":new ee(this,t,e).toString()}toLexerString(){return null===this.s0?"":new se(this).toString()}get states(){return this._states}},DFASerializer:ee,LexerDFASerializer:se,PredPrediction:Qt};class ne{visitTerminal(t){}visitErrorNode(t){}enterEveryRule(t){}exitEveryRule(t){}}class re{walk(t,e){if(e instanceof B||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof H)t.visitTerminal(e);else{this.enterRule(t,e);for(let s=0;s=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);const s=this.getErrorRecoverySet(t);this.consumeUntil(t,s)}sync(e){if(this.inErrorRecoveryMode(e))return;const s=e._interp.atn.states[e.state],i=e.getTokenStream().LA(1),n=e.atn.nextTokens(s);if(n.contains(i))return this.nextTokensContext=null,void(this.nextTokenState=k.INVALID_STATE_NUMBER);if(n.contains(t.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=e._ctx,this.nextTokensState=e._stateNumber);else switch(s.stateType){case k.BLOCK_START:case k.STAR_BLOCK_START:case k.PLUS_BLOCK_START:case k.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(e))return;throw new ae(e);case k.PLUS_LOOP_BACK:case k.STAR_LOOP_BACK:{this.reportUnwantedToken(e);const t=new y;t.addSet(e.getExpectedTokens());const s=t.addSet(this.getErrorRecoverySet(e));this.consumeUntil(e,s)}}}reportNoViableAlternative(e,s){const i=e.getTokenStream();let n;n=null!==i?s.startToken.type===t.EOF?"":i.getText(new u(s.startToken.tokenIndex,s.offendingToken.tokenIndex)):"";const r="no viable alternative at input "+this.escapeWSAndQuote(n);e.notifyErrorListeners(r,s.offendingToken,s)}reportInputMismatch(t,e){const s="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(s,e.offendingToken,e)}reportFailedPredicate(t,e){const s="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(s,e.offendingToken,e)}reportUnwantedToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),s="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(s,e,null)}reportMissingToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),s="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(s,e,null)}recoverInline(t){const e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new ae(t)}singleTokenInsertion(t){const e=t.getTokenStream().LA(1),s=t._interp.atn,i=s.states[t.state].transitions[0].target;return!!s.nextTokens(i,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)}singleTokenDeletion(t){const e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();const e=t.getCurrentToken();return this.reportMatch(t),e}return null}getMissingSymbol(e){const s=e.getCurrentToken(),i=this.getExpectedTokens(e).first();let n;n=i===t.EOF?"":"";let r=s;const o=e.getTokenStream().LT(-1);return r.type===t.EOF&&null!==o&&(r=o),e.getTokenFactory().create(r.source,i,n,t.DEFAULT_CHANNEL,-1,-1,r.line,r.column)}getExpectedTokens(t){return t.getExpectedTokens()}getTokenErrorDisplay(e){if(null===e)return"";let s=e.text;return null===s&&(s=e.type===t.EOF?"":"<"+e.type+">"),this.escapeWSAndQuote(s)}escapeWSAndQuote(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"}getErrorRecoverySet(e){const s=e._interp.atn;let i=e._ctx;const n=new y;for(;null!==i&&i.invokingState>=0;){const t=s.states[i.invokingState].transitions[0],e=s.nextTokens(t.followState);n.addSet(e),i=i.parentCtx}return n.removeOne(t.EPSILON),n}consumeUntil(e,s){let i=e.getTokenStream().LA(1);for(;i!==t.EOF&&!s.contains(i);)e.consume(),i=e.getTokenStream().LA(1)}}const de={RecognitionException:c,NoViableAltException:Jt,LexerNoViableAltException:d,InputMismatchException:ae,FailedPredicateException:le,DiagnosticErrorListener:class extends n{constructor(t){super(),t=t||!0,this.exactOnly=t}reportAmbiguity(t,e,s,i,n,r,o){if(this.exactOnly&&!n)return;const a="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(r,o)+", input='"+t.getTokenStream().getText(new u(s,i))+"'";t.notifyErrorListeners(a)}reportAttemptingFullContext(t,e,s,i,n,r){const o="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new u(s,i))+"'";t.notifyErrorListeners(o)}reportContextSensitivity(t,e,s,i,n,r){const o="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new u(s,i))+"'";t.notifyErrorListeners(o)}getDecisionDescription(t,e){const s=e.decision,i=e.atnStartState.ruleIndex,n=t.ruleNames;if(i<0||i>=n.length)return""+s;const r=n[i]||null;return null===r||0===r.length?""+s:`${s} (${r})`}getConflictingAlts(t,e){if(null!==t)return t;const s=new tt;for(let t=0;t=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}}removeParseListeners(){this._parseListeners=null}triggerEnterRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.forEach((function(e){e.enterEveryRule(t),t.enterRule(e)}))}}triggerExitRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.slice(0).reverse().forEach((function(e){t.exitRule(e),e.exitEveryRule(t)}))}}getTokenFactory(){return this._input.tokenSource._factory}setTokenFactory(t){this._input.tokenSource._factory=t}getATNWithBypassAlts(){const t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";let e=this.bypassAltsAtnCache[t];if(null===e){const s=new Nt;s.generateRuleBypassTransitions=!0,e=new Dt(s).deserialize(t),this.bypassAltsAtnCache[t]=e}return e}getInputStream(){return this.getTokenStream()}setInputStream(t){this.setTokenStream(t)}getTokenStream(){return this._input}setTokenStream(t){this._input=null,this.reset(),this._input=t}getCurrentToken(){return this._input.LT(1)}notifyErrorListeners(t,e,s){s=s||null,null===(e=e||null)&&(e=this.getCurrentToken()),this._syntaxErrors+=1;const i=e.line,n=e.column;this.getErrorListenerDispatch().syntaxError(this,e,i,n,t,s)}consume(){const e=this.getCurrentToken();e.type!==t.EOF&&this.getInputStream().consume();const s=null!==this._parseListeners&&this._parseListeners.length>0;if(this.buildParseTrees||s){let t;t=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(e):this._ctx.addTokenNode(e),t.invokingState=this.state,s&&this._parseListeners.forEach((function(e){t instanceof B||void 0!==t.isErrorNode&&t.isErrorNode()?e.visitErrorNode(t):t instanceof H&&e.visitTerminal(t)}))}return e}addContextToParseTree(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)}enterRule(t,e,s){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this._ctx.stop=this._input.LT(-1),this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx}enterOuterAlt(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t}getPrecedence(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]}enterRecursionRule(t,e,s,i){this.state=e,this._precedenceStack.push(i),this._ctx=t,this._ctx.start=this._input.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(t,e,s){const i=this._ctx;i.parentCtx=t,i.invokingState=e,i.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=i.start,this.buildParseTrees&&this._ctx.addChild(i),this.triggerEnterRuleEvent()}unrollRecursionContexts(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);const e=this._ctx,s=this.getParseListeners();if(null!==s&&s.length>0)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)}getInvokingContext(t){let e=this._ctx;for(;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null}precpred(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]}inContext(t){return!1}isExpectedToken(e){const s=this._interp.atn;let i=this._ctx;const n=s.states[this.state];let r=s.nextTokens(n);if(r.contains(e))return!0;if(!r.contains(t.EPSILON))return!1;for(;null!==i&&i.invokingState>=0&&r.contains(t.EPSILON);){const t=s.states[i.invokingState].transitions[0];if(r=s.nextTokens(t.followState),r.contains(e))return!0;i=i.parentCtx}return!(!r.contains(t.EPSILON)||e!==t.EOF)}getExpectedTokens(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)}getExpectedTokensWithinCurrentRule(){const t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)}getRuleIndex(t){const e=this.getRuleIndexMap()[t];return null!==e?e:-1}getRuleInvocationStack(t){null===(t=t||null)&&(t=this._ctx);const e=[];for(;null!==t;){const s=t.ruleIndex;s<0?e.push("n/a"):e.push(this.ruleNames[s]),t=t.parentCtx}return e}getDFAStrings(){return this._interp.decisionToDFA.toString()}dumpDFA(){let t=!1;for(let e=0;e0&&(t&&console.log(),this.printer.println("Decision "+s.decision+":"),this.printer.print(s.toString(this.literalNames,this.symbolicNames)),t=!0)}}getSourceName(){return this._input.sourceName}setTrace(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new xe(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}fe.bypassAltsAtnCache={};class _e extends H{constructor(t){super(),this.parentCtx=null,this.symbol=t}getChild(t){return null}getSymbol(){return this.symbol}getParent(){return this.parentCtx}getPayload(){return this.symbol}getSourceInterval(){if(null===this.symbol)return u.INVALID_INTERVAL;const t=this.symbol.tokenIndex;return new u(t,t)}getChildCount(){return 0}accept(t){return t.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===t.EOF?"":this.symbol.text}}class Te extends _e{constructor(t){super(t)}isErrorNode(){return!0}accept(t){return t.visitErrorNode(this)}}class Ee extends G{constructor(t,e){super(t=t||null,e=e||null),this.ruleIndex=-1,this.children=null,this.start=null,this.stop=null,this.exception=null}copyFrom(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map((function(t){t instanceof Te&&(this.children.push(t),t.parentCtx=this)}),this))}enterRule(t){}exitRule(t){}addChild(t){return null===this.children&&(this.children=[]),this.children.push(t),t}removeLastChild(){null!==this.children&&this.children.pop()}addTokenNode(t){const e=new _e(t);return this.addChild(e),e.parentCtx=this,e}addErrorNode(t){const e=new Te(t);return this.addChild(e),e.parentCtx=this,e}getChild(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(let s=0;s=this.children.length)return null;for(let s=0;snew Se.dfa.DFA(t,e)));class Ne extends Se.Lexer{static grammarFileName="n3.g4";static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static modeNames=["DEFAULT_MODE"];static literalNames=[null,"'.'","'@prefix'","'@base'","';'","','","'a'","'has'","'is'","'of'","'='","'<='","'=>'","'<-'","'!'","'^'","'['","']'","'('","')'","'{'","'}'","'^^'"];static symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"COMMENT","BooleanLiteral","String","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","IPLSTART","ANON","QuickVarName","PN_CHARS_U","PN_CHARS_BASE","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];static ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","T__13","T__14","T__15","T__16","T__17","T__18","T__19","T__20","T__21","COMMENT","BooleanLiteral","String","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","IPLSTART","ANON","QuickVarName","PN_CHARS_U","PN_CHARS_BASE","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];constructor(t){super(t),this._interp=new Se.atn.LexerATNSimulator(this,me,Ae,new Se.PredictionContextCache)}get atn(){return me}}Ne.EOF=Se.Token.EOF,Ne.T__0=1,Ne.T__1=2,Ne.T__2=3,Ne.T__3=4,Ne.T__4=5,Ne.T__5=6,Ne.T__6=7,Ne.T__7=8,Ne.T__8=9,Ne.T__9=10,Ne.T__10=11,Ne.T__11=12,Ne.T__12=13,Ne.T__13=14,Ne.T__14=15,Ne.T__15=16,Ne.T__16=17,Ne.T__17=18,Ne.T__18=19,Ne.T__19=20,Ne.T__20=21,Ne.T__21=22,Ne.COMMENT=23,Ne.BooleanLiteral=24,Ne.String=25,Ne.IRIREF=26,Ne.PNAME_NS=27,Ne.PNAME_LN=28,Ne.BLANK_NODE_LABEL=29,Ne.LANGTAG=30,Ne.INTEGER=31,Ne.DECIMAL=32,Ne.DOUBLE=33,Ne.EXPONENT=34,Ne.STRING_LITERAL_LONG_SINGLE_QUOTE=35,Ne.STRING_LITERAL_LONG_QUOTE=36,Ne.STRING_LITERAL_QUOTE=37,Ne.STRING_LITERAL_SINGLE_QUOTE=38,Ne.UCHAR=39,Ne.ECHAR=40,Ne.WS=41,Ne.IPLSTART=42,Ne.ANON=43,Ne.QuickVarName=44,Ne.PN_CHARS_U=45,Ne.PN_CHARS_BASE=46,Ne.PN_CHARS=47,Ne.BASE=48,Ne.PREFIX=49,Ne.PN_PREFIX=50,Ne.PN_LOCAL=51,Ne.PLX=52,Ne.PERCENT=53,Ne.HEX=54,Ne.PN_LOCAL_ESC=55;class Le extends Se.tree.ParseTreeListener{enterN3Doc(t){}exitN3Doc(t){}enterN3Statement(t){}exitN3Statement(t){}enterN3Directive(t){}exitN3Directive(t){}enterSparqlDirective(t){}exitSparqlDirective(t){}enterSparqlBase(t){}exitSparqlBase(t){}enterSparqlPrefix(t){}exitSparqlPrefix(t){}enterPrefixID(t){}exitPrefixID(t){}enterBase(t){}exitBase(t){}enterTriples(t){}exitTriples(t){}enterPredicateObjectList(t){}exitPredicateObjectList(t){}enterObjectList(t){}exitObjectList(t){}enterVerb(t){}exitVerb(t){}enterSubject(t){}exitSubject(t){}enterPredicate(t){}exitPredicate(t){}enterObject(t){}exitObject(t){}enterExpression(t){}exitExpression(t){}enterPath(t){}exitPath(t){}enterPathItem(t){}exitPathItem(t){}enterLiteral(t){}exitLiteral(t){}enterBlankNodePropertyList(t){}exitBlankNodePropertyList(t){}enterIriPropertyList(t){}exitIriPropertyList(t){}enterCollection(t){}exitCollection(t){}enterFormula(t){}exitFormula(t){}enterFormulaContent(t){}exitFormulaContent(t){}enterNumericLiteral(t){}exitNumericLiteral(t){}enterRdfLiteral(t){}exitRdfLiteral(t){}enterIri(t){}exitIri(t){}enterPrefixedName(t){}exitPrefixedName(t){}enterBlankNode(t){}exitBlankNode(t){}enterQuickVar(t){}exitQuickVar(t){}}class Re extends Se.tree.ParseTreeVisitor{visitN3Doc(t){return this.visitChildren(t)}visitN3Statement(t){return this.visitChildren(t)}visitN3Directive(t){return this.visitChildren(t)}visitSparqlDirective(t){return this.visitChildren(t)}visitSparqlBase(t){return this.visitChildren(t)}visitSparqlPrefix(t){return this.visitChildren(t)}visitPrefixID(t){return this.visitChildren(t)}visitBase(t){return this.visitChildren(t)}visitTriples(t){return this.visitChildren(t)}visitPredicateObjectList(t){return this.visitChildren(t)}visitObjectList(t){return this.visitChildren(t)}visitVerb(t){return this.visitChildren(t)}visitSubject(t){return this.visitChildren(t)}visitPredicate(t){return this.visitChildren(t)}visitObject(t){return this.visitChildren(t)}visitExpression(t){return this.visitChildren(t)}visitPath(t){return this.visitChildren(t)}visitPathItem(t){return this.visitChildren(t)}visitLiteral(t){return this.visitChildren(t)}visitBlankNodePropertyList(t){return this.visitChildren(t)}visitIriPropertyList(t){return this.visitChildren(t)}visitCollection(t){return this.visitChildren(t)}visitFormula(t){return this.visitChildren(t)}visitFormulaContent(t){return this.visitChildren(t)}visitNumericLiteral(t){return this.visitChildren(t)}visitRdfLiteral(t){return this.visitChildren(t)}visitIri(t){return this.visitChildren(t)}visitPrefixedName(t){return this.visitChildren(t)}visitBlankNode(t){return this.visitChildren(t)}visitQuickVar(t){return this.visitChildren(t)}}const Ie=(new Se.atn.ATNDeserializer).deserialize([4,1,55,224,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,1,0,1,0,1,0,1,0,5,0,65,8,0,10,0,12,0,68,9,0,1,0,1,0,1,1,1,1,3,1,74,8,1,1,2,1,2,3,2,78,8,2,1,3,1,3,3,3,82,8,3,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,3,8,100,8,8,1,9,1,9,1,9,1,9,1,9,1,9,3,9,108,8,9,5,9,110,8,9,10,9,12,9,113,9,9,1,10,1,10,1,10,5,10,118,8,10,10,10,12,10,121,9,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,3,11,134,8,11,1,12,1,12,1,13,1,13,1,13,3,13,141,8,13,1,14,1,14,1,15,1,15,1,16,1,16,1,16,1,16,1,16,3,16,152,8,16,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,3,17,162,8,17,1,18,1,18,1,18,3,18,167,8,18,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,5,21,180,8,21,10,21,12,21,183,9,21,1,21,1,21,1,22,1,22,3,22,189,8,22,1,22,1,22,1,23,1,23,1,23,3,23,196,8,23,3,23,198,8,23,1,23,1,23,3,23,202,8,23,3,23,204,8,23,1,24,1,24,1,25,1,25,1,25,1,25,3,25,212,8,25,1,26,1,26,3,26,216,8,26,1,27,1,27,1,28,1,28,1,29,1,29,1,29,0,0,30,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,0,3,1,0,31,33,1,0,27,28,2,0,29,29,43,43,229,0,66,1,0,0,0,2,73,1,0,0,0,4,77,1,0,0,0,6,81,1,0,0,0,8,83,1,0,0,0,10,86,1,0,0,0,12,90,1,0,0,0,14,94,1,0,0,0,16,97,1,0,0,0,18,101,1,0,0,0,20,114,1,0,0,0,22,133,1,0,0,0,24,135,1,0,0,0,26,140,1,0,0,0,28,142,1,0,0,0,30,144,1,0,0,0,32,146,1,0,0,0,34,161,1,0,0,0,36,166,1,0,0,0,38,168,1,0,0,0,40,172,1,0,0,0,42,177,1,0,0,0,44,186,1,0,0,0,46,203,1,0,0,0,48,205,1,0,0,0,50,207,1,0,0,0,52,215,1,0,0,0,54,217,1,0,0,0,56,219,1,0,0,0,58,221,1,0,0,0,60,61,3,2,1,0,61,62,5,1,0,0,62,65,1,0,0,0,63,65,3,6,3,0,64,60,1,0,0,0,64,63,1,0,0,0,65,68,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,69,1,0,0,0,68,66,1,0,0,0,69,70,5,0,0,1,70,1,1,0,0,0,71,74,3,4,2,0,72,74,3,16,8,0,73,71,1,0,0,0,73,72,1,0,0,0,74,3,1,0,0,0,75,78,3,12,6,0,76,78,3,14,7,0,77,75,1,0,0,0,77,76,1,0,0,0,78,5,1,0,0,0,79,82,3,8,4,0,80,82,3,10,5,0,81,79,1,0,0,0,81,80,1,0,0,0,82,7,1,0,0,0,83,84,5,48,0,0,84,85,5,26,0,0,85,9,1,0,0,0,86,87,5,49,0,0,87,88,5,27,0,0,88,89,5,26,0,0,89,11,1,0,0,0,90,91,5,2,0,0,91,92,5,27,0,0,92,93,5,26,0,0,93,13,1,0,0,0,94,95,5,3,0,0,95,96,5,26,0,0,96,15,1,0,0,0,97,99,3,24,12,0,98,100,3,18,9,0,99,98,1,0,0,0,99,100,1,0,0,0,100,17,1,0,0,0,101,102,3,22,11,0,102,111,3,20,10,0,103,107,5,4,0,0,104,105,3,22,11,0,105,106,3,20,10,0,106,108,1,0,0,0,107,104,1,0,0,0,107,108,1,0,0,0,108,110,1,0,0,0,109,103,1,0,0,0,110,113,1,0,0,0,111,109,1,0,0,0,111,112,1,0,0,0,112,19,1,0,0,0,113,111,1,0,0,0,114,119,3,28,14,0,115,116,5,5,0,0,116,118,3,28,14,0,117,115,1,0,0,0,118,121,1,0,0,0,119,117,1,0,0,0,119,120,1,0,0,0,120,21,1,0,0,0,121,119,1,0,0,0,122,134,3,26,13,0,123,134,5,6,0,0,124,125,5,7,0,0,125,134,3,30,15,0,126,127,5,8,0,0,127,128,3,30,15,0,128,129,5,9,0,0,129,134,1,0,0,0,130,134,5,10,0,0,131,134,5,11,0,0,132,134,5,12,0,0,133,122,1,0,0,0,133,123,1,0,0,0,133,124,1,0,0,0,133,126,1,0,0,0,133,130,1,0,0,0,133,131,1,0,0,0,133,132,1,0,0,0,134,23,1,0,0,0,135,136,3,30,15,0,136,25,1,0,0,0,137,141,3,30,15,0,138,139,5,13,0,0,139,141,3,30,15,0,140,137,1,0,0,0,140,138,1,0,0,0,141,27,1,0,0,0,142,143,3,30,15,0,143,29,1,0,0,0,144,145,3,32,16,0,145,31,1,0,0,0,146,151,3,34,17,0,147,148,5,14,0,0,148,152,3,32,16,0,149,150,5,15,0,0,150,152,3,32,16,0,151,147,1,0,0,0,151,149,1,0,0,0,151,152,1,0,0,0,152,33,1,0,0,0,153,162,3,52,26,0,154,162,3,56,28,0,155,162,3,58,29,0,156,162,3,42,21,0,157,162,3,38,19,0,158,162,3,40,20,0,159,162,3,36,18,0,160,162,3,44,22,0,161,153,1,0,0,0,161,154,1,0,0,0,161,155,1,0,0,0,161,156,1,0,0,0,161,157,1,0,0,0,161,158,1,0,0,0,161,159,1,0,0,0,161,160,1,0,0,0,162,35,1,0,0,0,163,167,3,50,25,0,164,167,3,48,24,0,165,167,5,24,0,0,166,163,1,0,0,0,166,164,1,0,0,0,166,165,1,0,0,0,167,37,1,0,0,0,168,169,5,16,0,0,169,170,3,18,9,0,170,171,5,17,0,0,171,39,1,0,0,0,172,173,5,42,0,0,173,174,3,52,26,0,174,175,3,18,9,0,175,176,5,17,0,0,176,41,1,0,0,0,177,181,5,18,0,0,178,180,3,28,14,0,179,178,1,0,0,0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183,181,1,0,0,0,184,185,5,19,0,0,185,43,1,0,0,0,186,188,5,20,0,0,187,189,3,46,23,0,188,187,1,0,0,0,188,189,1,0,0,0,189,190,1,0,0,0,190,191,5,21,0,0,191,45,1,0,0,0,192,197,3,2,1,0,193,195,5,1,0,0,194,196,3,46,23,0,195,194,1,0,0,0,195,196,1,0,0,0,196,198,1,0,0,0,197,193,1,0,0,0,197,198,1,0,0,0,198,204,1,0,0,0,199,201,3,6,3,0,200,202,3,46,23,0,201,200,1,0,0,0,201,202,1,0,0,0,202,204,1,0,0,0,203,192,1,0,0,0,203,199,1,0,0,0,204,47,1,0,0,0,205,206,7,0,0,0,206,49,1,0,0,0,207,211,5,25,0,0,208,212,5,30,0,0,209,210,5,22,0,0,210,212,3,52,26,0,211,208,1,0,0,0,211,209,1,0,0,0,211,212,1,0,0,0,212,51,1,0,0,0,213,216,5,26,0,0,214,216,3,54,27,0,215,213,1,0,0,0,215,214,1,0,0,0,216,53,1,0,0,0,217,218,7,1,0,0,218,55,1,0,0,0,219,220,7,2,0,0,220,57,1,0,0,0,221,222,5,44,0,0,222,59,1,0,0,0,22,64,66,73,77,81,99,107,111,119,133,140,151,161,166,181,188,195,197,201,203,211,215]),ve=Ie.decisionToState.map(((t,e)=>new Se.dfa.DFA(t,e))),ye=new Se.PredictionContextCache;class ke extends Se.Parser{static grammarFileName="java-escape";static literalNames=[null,"'.'","'@prefix'","'@base'","';'","','","'a'","'has'","'is'","'of'","'='","'<='","'=>'","'<-'","'!'","'^'","'['","']'","'('","')'","'{'","'}'","'^^'"];static symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"COMMENT","BooleanLiteral","String","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","IPLSTART","ANON","QuickVarName","PN_CHARS_U","PN_CHARS_BASE","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];static ruleNames=["n3Doc","n3Statement","n3Directive","sparqlDirective","sparqlBase","sparqlPrefix","prefixID","base","triples","predicateObjectList","objectList","verb","subject","predicate","object","expression","path","pathItem","literal","blankNodePropertyList","iriPropertyList","collection","formula","formulaContent","numericLiteral","rdfLiteral","iri","prefixedName","blankNode","quickVar"];constructor(t){super(t),this._interp=new Se.atn.ParserATNSimulator(this,Ie,ve,ye),this.ruleNames=ke.ruleNames,this.literalNames=ke.literalNames,this.symbolicNames=ke.symbolicNames}get atn(){return Ie}n3Doc(){let t=new Oe(this,this._ctx,this.state);this.enterRule(t,0,ke.RULE_n3Doc);var e=0;try{for(this.enterOuterAlt(t,1),this.state=66,this._errHandler.sync(this),e=this._input.LA(1);0==(-32&e)&&0!=(1<{void 0!==s.symbol?(e||19!=t.parentCtx.ruleIndex&&20!=t.parentCtx.ruleIndex&&(e=!0,this.incrIndent()),this.print(s),this.appendNewline()):(s.accept(this),this.separate(" "))})),e&&this.decrIndent()}visitObjectList(t){this.logVisit("ObjectList"),this.doVisitChildren(t," ")}visitVerb(t){return this.logVisit("Verb"),this.doVisitChildren(t)}visitSubject(t){return this.logVisit("Subject"),this.doVisitChildren(t)}visitPredicate(t){return this.logVisit("Predicate"),this.doVisitChildren(t)}visitObject(t){return this.logVisit("Object"),this.doVisitChildren(t)}visitExpression(t){return this.logVisit("Expression"),this.doVisitChildren(t)}visitPath(t){return this.logVisit("Path"),this.doVisitChildren(t)}visitPathItem(t){return this.logVisit("PathItem"),this.doVisitChildren(t)}visitLiteral(t){return this.logVisit("Literal"),this.doVisitChildren(t)}visitBlankNodePropertyList(t){this.logVisit("BlankNodePropertyList"),this.print(t.getChild(0)),this.incrIndent(),this.appendNewline();for(let e=1;e1&&this.appendNewline(),t.getChild(e).accept(this);this.decrIndent(),this.appendNewline(),this.print(t.getChild(t.getChildCount()-1))}else this.doVisitChildren(t," ")}hasSomeDescendant(t,e){return t.ruleIndex==e||!!t.children&&t.children.some((t=>this.hasSomeDescendant(t,e)))}visitFormula(t){this.logVisit("Formula"),2!=t.getChildCount()?(this.config.graphOnNewline&&this.appendNewline(),this.print(t.getChild(0)),this.incrIndent(),this.appendNewline(),t.getChild(1).accept(this),this.decrIndent(),this.appendNewline(),this.print(t.getChild(2)),this.config.graphOnNewline&&this.appendNewline()):this.doVisitChildren(t)}visitFormulaContent(t){this.logVisit("FormulaContent"),this.visitGraphContents(t)}visitNumericLiteral(t){return this.logVisit("NumericLiteral"),this.doVisitChildren(t)}visitRdfLiteral(t){return this.logVisit("RdfLiteral"),this.doVisitChildren(t)}visitIri(t){return this.logVisit("Iri"),this.doVisitChildren(t)}visitIriList(t){return this.logVisit("IriList"),this.doVisitChildren(t)}visitPrefixedName(t){return this.logVisit("PrefixedName"),this.doVisitChildren(t)}visitBlankNode(t){return this.logVisit("BlankNode"),this.doVisitChildren(t)}visitQuickVar(t){return this.logVisit("QuickVar"),this.doVisitChildren(t)}visitExistential(t){return this.logVisit("Existential"),this.doVisitChildren(t)}visitUniversal(t){return this.logVisit("Universal"),this.doVisitChildren(t)}incrIndent(t){this.indent+=this.config.tab+(t||0)}decrIndent(t){this.indent-=this.config.tab+(t||0)}visitGraphContents(t){let e=t.getChildCount();for(let s=0;s0&&this.separate(e),void 0!==i.symbol){let t=i.toString();this.print(t)}else i.accept(this)}}logVisit(t){}appendNewline(){/.*\n\s*$/g.test(this.str)&&(this.str=this.str.trim()),this.print("\n"+new Array(this.indent).join(" "))}separate(t){" "==t&&/.*\s+$/g.test(this.str)||this.print(t)}print(t){""!=t&&(this.str+=t)}}function cs(t,s){var i=new e(t),n=new Ne(i);n.removeErrorListeners(),n.addErrorListener(s);var r=new g(n),o=new ke(r);o.removeErrorListeners(),o.removeParseListeners(),s.syntaxError&&o.addErrorListener(s),s.unknownPrefix&&o.addParseListener(new as(s));var a=o.n3Doc();s.newAstLine&&new ls(s).visit(a)}function us(t,s){var i=new e(t),n=new Ne(i),r=new g(n);let o=new ke(r).n3Doc();return new hs(s).visitN3Doc(o)}})(),n3=i})(); \ No newline at end of file diff --git a/editor/dist/n3Main.js.LICENSE.txt b/editor/dist/n3Main.js.LICENSE.txt new file mode 100644 index 0000000..90fe869 --- /dev/null +++ b/editor/dist/n3Main.js.LICENSE.txt @@ -0,0 +1,3 @@ +/*! https://mths.be/codepointat v0.2.0 by @mathias */ + +/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */ diff --git a/editor/dist/n3Main_nodrop_umd.js b/editor/dist/n3Main_nodrop_umd.js new file mode 100644 index 0000000..361ba62 --- /dev/null +++ b/editor/dist/n3Main_nodrop_umd.js @@ -0,0 +1,17448 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["n3Main"] = factory(); + else + root["n3Main"] = factory(); +})(this, () => { +return /******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ 262: +/***/ (() => { + +/* (ignored) */ + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +(() => { +"use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "format": () => (/* binding */ format), + "parse": () => (/* binding */ parse) +}); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Token.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * A token has properties: text, type, line, character position in the line + * (so we can ignore tabs), token channel, index, and source from which + * we obtained this token. + */ +class Token { + constructor() { + this.source = null; + this.type = null; // token type of the token + this.channel = null; // The parser ignores everything not on DEFAULT_CHANNEL + this.start = null; // optional; return -1 if not implemented. + this.stop = null; // optional; return -1 if not implemented. + this.tokenIndex = null; // from 0..n-1 of the token object in the input stream + this.line = null; // line=1..n of the 1st character + this.column = null; // beginning of the line at which it occurs, 0..n-1 + this._text = null; // text of the token. + } + + getTokenSource() { + return this.source[0]; + } + + getInputStream() { + return this.source[1]; + } + + get text(){ + return this._text; + } + + set text(text) { + this._text = text; + } +} + +Token.INVALID_TYPE = 0; + +/** + * During lookahead operations, this "token" signifies we hit rule end ATN state + * and did not follow it despite needing to. + */ +Token.EPSILON = -2; + +Token.MIN_USER_TOKEN_TYPE = 1; + +Token.EOF = -1; + +/** + * All tokens go to the parser (unless skip() is called in that rule) + * on a particular "channel". The parser tunes to a particular channel + * so that whitespace etc... can go to the parser on a "hidden" channel. + */ +Token.DEFAULT_CHANNEL = 0; + +/** + * Anything on different channel than DEFAULT_CHANNEL is not parsed + * by parser. + */ +Token.HIDDEN_CHANNEL = 1; + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/polyfills/codepointat.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/*! https://mths.be/codepointat v0.2.0 by @mathias */ +if (!String.prototype.codePointAt) { + (function() { + 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` + var defineProperty = (function() { + // IE 8 only supports `Object.defineProperty` on DOM elements + let result; + try { + const object = {}; + const $defineProperty = Object.defineProperty; + result = $defineProperty(object, object, object) && $defineProperty; + } catch(error) { + /* eslint no-empty: [ "off" ] */ + } + return result; + }()); + const codePointAt = function(position) { + if (this == null) { + throw TypeError(); + } + const string = String(this); + const size = string.length; + // `ToInteger` + let index = position ? Number(position) : 0; + if (index !== index) { // better `isNaN` + index = 0; + } + // Account for out-of-bounds indices: + if (index < 0 || index >= size) { + return undefined; + } + // Get the first code unit + const first = string.charCodeAt(index); + let second; + if ( // check if it’s the start of a surrogate pair + first >= 0xD800 && first <= 0xDBFF && // high surrogate + size > index + 1 // there is a next code unit + ) { + second = string.charCodeAt(index + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + if (defineProperty) { + defineProperty(String.prototype, 'codePointAt', { + 'value': codePointAt, + 'configurable': true, + 'writable': true + }); + } else { + String.prototype.codePointAt = codePointAt; + } + }()); +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/polyfills/fromcodepoint.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */ +if (!String.fromCodePoint) { + (function() { + const defineProperty = (function() { + // IE 8 only supports `Object.defineProperty` on DOM elements + let result; + try { + const object = {}; + const $defineProperty = Object.defineProperty; + result = $defineProperty(object, object, object) && $defineProperty; + } catch(error) { + /* eslint no-empty: [ "off" ] */ + } + return result; + }()); + const stringFromCharCode = String.fromCharCode; + const floor = Math.floor; + const fromCodePoint = function(_) { + const MAX_SIZE = 0x4000; + const codeUnits = []; + let highSurrogate; + let lowSurrogate; + let index = -1; + const length = arguments.length; + if (!length) { + return ''; + } + let result = ''; + while (++index < length) { + let codePoint = Number(arguments[index]); + if ( + !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` + codePoint < 0 || // not a valid Unicode code point + codePoint > 0x10FFFF || // not a valid Unicode code point + floor(codePoint) !== codePoint // not an integer + ) { + throw RangeError('Invalid code point: ' + codePoint); + } + if (codePoint <= 0xFFFF) { // BMP code point + codeUnits.push(codePoint); + } else { // Astral code point; split in surrogate halves + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + codePoint -= 0x10000; + highSurrogate = (codePoint >> 10) + 0xD800; + lowSurrogate = (codePoint % 0x400) + 0xDC00; + codeUnits.push(highSurrogate, lowSurrogate); + } + if (index + 1 === length || codeUnits.length > MAX_SIZE) { + result += stringFromCharCode.apply(null, codeUnits); + codeUnits.length = 0; + } + } + return result; + }; + if (defineProperty) { + defineProperty(String, 'fromCodePoint', { + 'value': fromCodePoint, + 'configurable': true, + 'writable': true + }); + } else { + String.fromCodePoint = fromCodePoint; + } + }()); +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/InputStream.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + +/** + * If decodeToUnicodeCodePoints is true, the input is treated + * as a series of Unicode code points. + * + * Otherwise, the input is treated as a series of 16-bit UTF-16 code + * units. + */ +class InputStream { + constructor(data, decodeToUnicodeCodePoints) { + this.name = ""; + this.strdata = data; + this.decodeToUnicodeCodePoints = decodeToUnicodeCodePoints || false; + // _loadString - Vacuum all input from a string and then treat it like a buffer. + this._index = 0; + this.data = []; + if (this.decodeToUnicodeCodePoints) { + for (let i = 0; i < this.strdata.length; ) { + const codePoint = this.strdata.codePointAt(i); + this.data.push(codePoint); + i += codePoint <= 0xFFFF ? 1 : 2; + } + } else { + this.data = new Array(this.strdata.length); + for (let i = 0; i < this.strdata.length; i++) { + const codeUnit = this.strdata.charCodeAt(i); + this.data[i] = codeUnit; + } + } + this._size = this.data.length; + } + + /** + * Reset the stream so that it's in the same state it was + * when the object was created *except* the data array is not + * touched. + */ + reset() { + this._index = 0; + } + + consume() { + if (this._index >= this._size) { + // assert this.LA(1) == Token.EOF + throw ("cannot consume EOF"); + } + this._index += 1; + } + + LA(offset) { + if (offset === 0) { + return 0; // undefined + } + if (offset < 0) { + offset += 1; // e.g., translate LA(-1) to use offset=0 + } + const pos = this._index + offset - 1; + if (pos < 0 || pos >= this._size) { // invalid + return Token.EOF; + } + return this.data[pos]; + } + + LT(offset) { + return this.LA(offset); + } + +// mark/release do nothing; we have entire buffer + mark() { + return -1; + } + + release(marker) { + } + + /** + * consume() ahead until p==_index; can't just set p=_index as we must + * update line and column. If we seek backwards, just set p + */ + seek(_index) { + if (_index <= this._index) { + this._index = _index; // just jump; don't update stream state (line, + // ...) + return; + } + // seek forward + this._index = Math.min(_index, this._size); + } + + getText(start, stop) { + if (stop >= this._size) { + stop = this._size - 1; + } + if (start >= this._size) { + return ""; + } else { + if (this.decodeToUnicodeCodePoints) { + let result = ""; + for (let i = start; i <= stop; i++) { + result += String.fromCodePoint(this.data[i]); + } + return result; + } else { + return this.strdata.slice(start, stop + 1); + } + } + } + + toString() { + return this.strdata; + } + + get index(){ + return this._index; + } + + get size(){ + return this._size; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ErrorListener.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * Provides an empty default implementation of {@link ANTLRErrorListener}. The + * default implementation of each method does nothing, but can be overridden as + * necessary. + */ +class ErrorListener { + syntaxError(recognizer, offendingSymbol, line, column, msg, e) { + } + + reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { + } + + reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { + } + + reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) { + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ConsoleErrorListener.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/** + * {@inheritDoc} + * + *

      + * This implementation prints messages to {@link System//err} containing the + * values of {@code line}, {@code charPositionInLine}, and {@code msg} using + * the following format.

      + * + *
      + * line line:charPositionInLine msg
      + * 
      + * + */ +class ConsoleErrorListener extends ErrorListener { + constructor() { + super(); + } + + syntaxError(recognizer, offendingSymbol, line, column, msg, e) { + console.error("line " + line + ":" + column + " " + msg); + } +} + + +/** + * Provides a default instance of {@link ConsoleErrorListener}. + */ +ConsoleErrorListener.INSTANCE = new ConsoleErrorListener(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ProxyErrorListener.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class ProxyErrorListener extends ErrorListener { + constructor(delegates) { + super(); + if (delegates===null) { + throw "delegates"; + } + this.delegates = delegates; + return this; + } + + syntaxError(recognizer, offendingSymbol, line, column, msg, e) { + this.delegates.map(d => d.syntaxError(recognizer, offendingSymbol, line, column, msg, e)); + } + + reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { + this.delegates.map(d => d.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs)); + } + + reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { + this.delegates.map(d => d.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs)); + } + + reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) { + this.delegates.map(d => d.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs)); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Recognizer.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + +class Recognizer { + constructor() { + this._listeners = [ ConsoleErrorListener.INSTANCE ]; + this._interp = null; + this._stateNumber = -1; + } + + checkVersion(toolVersion) { + const runtimeVersion = "4.10.1"; + if (runtimeVersion!==toolVersion) { + console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion); + } + } + + addErrorListener(listener) { + this._listeners.push(listener); + } + + removeErrorListeners() { + this._listeners = []; + } + + getLiteralNames() { + return Object.getPrototypeOf(this).constructor.literalNames || []; + } + + getSymbolicNames() { + return Object.getPrototypeOf(this).constructor.symbolicNames || []; + } + + getTokenNames() { + if(!this.tokenNames) { + const literalNames = this.getLiteralNames(); + const symbolicNames = this.getSymbolicNames(); + const length = literalNames.length > symbolicNames.length ? literalNames.length : symbolicNames.length; + this.tokenNames = []; + for(let i=0; iUsed for XPath and tree pattern compilation.

      + */ + getRuleIndexMap() { + const ruleNames = this.ruleNames; + if (ruleNames===null) { + throw("The current recognizer does not provide a list of rule names."); + } + let result = this.ruleIndexMapCache[ruleNames]; // todo: should it be Recognizer.ruleIndexMapCache ? + if(result===undefined) { + result = ruleNames.reduce(function(o, k, i) { o[k] = i; }); + this.ruleIndexMapCache[ruleNames] = result; + } + return result; + } + + getTokenType(tokenName) { + const ttype = this.getTokenTypeMap()[tokenName]; + if (ttype !==undefined) { + return ttype; + } else { + return Token.INVALID_TYPE; + } + } + + // What is the error header, normally line/character position information? + getErrorHeader(e) { + const line = e.getOffendingToken().line; + const column = e.getOffendingToken().column; + return "line " + line + ":" + column; + } + + /** + * How should a token be displayed in an error message? The default + * is to display just the text, but during development you might + * want to have a lot of information spit out. Override in that case + * to use t.toString() (which, for CommonToken, dumps everything about + * the token). This is better than forcing you to override a method in + * your token objects because you don't have to go modify your lexer + * so that it creates a new Java type. + * + * @deprecated This method is not called by the ANTLR 4 Runtime. Specific + * implementations of {@link ANTLRErrorStrategy} may provide a similar + * feature when necessary. For example, see + * {@link DefaultErrorStrategy//getTokenErrorDisplay}.*/ + getTokenErrorDisplay(t) { + if (t===null) { + return ""; + } + let s = t.text; + if (s===null) { + if (t.type===Token.EOF) { + s = ""; + } else { + s = "<" + t.type + ">"; + } + } + s = s.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"); + return "'" + s + "'"; + } + + getErrorListenerDispatch() { + return new ProxyErrorListener(this._listeners); + } + + /** + * subclass needs to override these if there are sempreds or actions + * that the ATN interp needs to execute + */ + sempred(localctx, ruleIndex, actionIndex) { + return true; + } + + precpred(localctx , precedence) { + return true; + } + + get state(){ + return this._stateNumber; + } + + set state(state) { + this._stateNumber = state; + } +} + +Recognizer.tokenTypeMapCache = {}; +Recognizer.ruleIndexMapCache = {}; + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CommonToken.js + + +class CommonToken extends Token { + constructor(source, type, channel, start, stop) { + super(); + this.source = source !== undefined ? source : CommonToken.EMPTY_SOURCE; + this.type = type !== undefined ? type : null; + this.channel = channel !== undefined ? channel : Token.DEFAULT_CHANNEL; + this.start = start !== undefined ? start : -1; + this.stop = stop !== undefined ? stop : -1; + this.tokenIndex = -1; + if (this.source[0] !== null) { + this.line = source[0].line; + this.column = source[0].column; + } else { + this.column = -1; + } + } + + /** + * Constructs a new {@link CommonToken} as a copy of another {@link Token}. + * + *

      + * If {@code oldToken} is also a {@link CommonToken} instance, the newly + * constructed token will share a reference to the {@link //text} field and + * the {@link Pair} stored in {@link //source}. Otherwise, {@link //text} will + * be assigned the result of calling {@link //getText}, and {@link //source} + * will be constructed from the result of {@link Token//getTokenSource} and + * {@link Token//getInputStream}.

      + * + * @param oldToken The token to copy. + */ + clone() { + const t = new CommonToken(this.source, this.type, this.channel, this.start, this.stop); + t.tokenIndex = this.tokenIndex; + t.line = this.line; + t.column = this.column; + t.text = this.text; + return t; + } + + toString() { + let txt = this.text; + if (txt !== null) { + txt = txt.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t"); + } else { + txt = ""; + } + return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + + txt + "',<" + this.type + ">" + + (this.channel > 0 ? ",channel=" + this.channel : "") + "," + + this.line + ":" + this.column + "]"; + } + + get text(){ + if (this._text !== null) { + return this._text; + } + const input = this.getInputStream(); + if (input === null) { + return null; + } + const n = input.size; + if (this.start < n && this.stop < n) { + return input.getText(this.start, this.stop); + } else { + return ""; + } + } + + set text(text) { + this._text = text; + } +} + +/** + * An empty {@link Pair} which is used as the default value of + * {@link //source} for tokens that do not have a source. + */ +CommonToken.EMPTY_SOURCE = [ null, null ]; + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CommonTokenFactory.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class TokenFactory {} + +/** + * This default implementation of {@link TokenFactory} creates + * {@link CommonToken} objects. + */ +class CommonTokenFactory extends TokenFactory { + constructor(copyText) { + super(); + /** + * Indicates whether {@link CommonToken//setText} should be called after + * constructing tokens to explicitly set the text. This is useful for cases + * where the input stream might not be able to provide arbitrary substrings + * of text from the input after the lexer creates a token (e.g. the + * implementation of {@link CharStream//getText} in + * {@link UnbufferedCharStream} throws an + * {@link UnsupportedOperationException}). Explicitly setting the token text + * allows {@link Token//getText} to be called at any time regardless of the + * input stream implementation. + * + *

      + * The default value is {@code false} to avoid the performance and memory + * overhead of copying text for every token unless explicitly requested.

      + */ + this.copyText = copyText===undefined ? false : copyText; + } + + create(source, type, text, channel, start, stop, line, column) { + const t = new CommonToken(source, type, channel, start, stop); + t.line = line; + t.column = column; + if (text !==null) { + t.text = text; + } else if (this.copyText && source[1] !==null) { + t.text = source[1].getText(start,stop); + } + return t; + } + + createThin(type, text) { + const t = new CommonToken(null, type); + t.text = text; + return t; + } +} + +/** + * The default {@link CommonTokenFactory} instance. + * + *

      + * This token factory does not explicitly copy token text when constructing + * tokens.

      + */ +CommonTokenFactory.DEFAULT = new CommonTokenFactory(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/RecognitionException.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * The root of the ANTLR exception hierarchy. In general, ANTLR tracks just + * 3 kinds of errors: prediction errors, failed predicate errors, and + * mismatched input errors. In each case, the parser knows where it is + * in the input, where it is in the ATN, the rule invocation stack, + * and what kind of problem occurred. + */ + +class RecognitionException extends Error { + constructor(params) { + super(params.message); + if (Error.captureStackTrace) + Error.captureStackTrace(this, RecognitionException); + this.message = params.message; + this.recognizer = params.recognizer; + this.input = params.input; + this.ctx = params.ctx; + /** + * The current {@link Token} when an error occurred. Since not all streams + * support accessing symbols by index, we have to track the {@link Token} + * instance itself + */ + this.offendingToken = null; + /** + * Get the ATN state number the parser was in at the time the error + * occurred. For {@link NoViableAltException} and + * {@link LexerNoViableAltException} exceptions, this is the + * {@link DecisionState} number. For others, it is the state whose outgoing + * edge we couldn't match. + */ + this.offendingState = -1; + if (this.recognizer!==null) { + this.offendingState = this.recognizer.state; + } + } + + /** + * Gets the set of input symbols which could potentially follow the + * previously matched symbol at the time this exception was thrown. + * + *

      If the set of expected tokens is not known and could not be computed, + * this method returns {@code null}.

      + * + * @return The set of token types that could potentially follow the current + * state in the ATN, or {@code null} if the information is not available. + */ + getExpectedTokens() { + if (this.recognizer!==null) { + return this.recognizer.atn.getExpectedTokens(this.offendingState, this.ctx); + } else { + return null; + } + } + + //

      If the state number is not known, this method returns -1.

      + toString() { + return this.message; + } +} + + + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/Interval.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/* stop is not included! */ +class Interval { + + constructor(start, stop) { + this.start = start; + this.stop = stop; + } + + clone() { + return new Interval(this.start, this.stop); + } + + contains(item) { + return item >= this.start && item < this.stop; + } + + toString() { + if(this.start===this.stop-1) { + return this.start.toString(); + } else { + return this.start.toString() + ".." + (this.stop-1).toString(); + } + } + + get length(){ + return this.stop - this.start; + } +} + +Interval.INVALID_INTERVAL = new Interval(-1, -2); + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/LexerNoViableAltException.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class LexerNoViableAltException extends RecognitionException { + constructor(lexer, input, startIndex, deadEndConfigs) { + super({message: "", recognizer: lexer, input: input, ctx: null}); + this.startIndex = startIndex; + this.deadEndConfigs = deadEndConfigs; + } + + toString() { + let symbol = ""; + if (this.startIndex >= 0 && this.startIndex < this.input.size) { + symbol = this.input.getText(new Interval(this.startIndex,this.startIndex)); + } + return "LexerNoViableAltException" + symbol; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Lexer.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + +/** + * A lexer is recognizer that draws input symbols from a character stream. + * lexer grammars result in a subclass of this object. A Lexer object + * uses simplified match() and error recovery mechanisms in the interest of speed. + */ +class Lexer extends Recognizer { + constructor(input) { + super(); + this._input = input; + this._factory = CommonTokenFactory.DEFAULT; + this._tokenFactorySourcePair = [ this, input ]; + + this._interp = null; // child classes must populate this + + /** + * The goal of all lexer rules/methods is to create a token object. + * this is an instance variable as multiple rules may collaborate to + * create a single token. nextToken will return this object after + * matching lexer rule(s). If you subclass to allow multiple token + * emissions, then set this to the last token to be matched or + * something nonnull so that the auto token emit mechanism will not + * emit another token. + */ + this._token = null; + + /** + * What character index in the stream did the current token start at? + * Needed, for example, to get the text for current token. Set at + * the start of nextToken. + */ + this._tokenStartCharIndex = -1; + + // The line on which the first character of the token resides/// + this._tokenStartLine = -1; + + // The character position of first character within the line/// + this._tokenStartColumn = -1; + + // Once we see EOF on char stream, next token will be EOF. + // If you have DONE : EOF ; then you see DONE EOF. + this._hitEOF = false; + + // The channel number for the current token/// + this._channel = Token.DEFAULT_CHANNEL; + + // The token type for the current token/// + this._type = Token.INVALID_TYPE; + + this._modeStack = []; + this._mode = Lexer.DEFAULT_MODE; + + /** + * You can set the text for the current token to override what is in + * the input char buffer. Use setText() or can set this instance var. + */ + this._text = null; + } + + reset() { + // wack Lexer state variables + if (this._input !== null) { + this._input.seek(0); // rewind the input + } + this._token = null; + this._type = Token.INVALID_TYPE; + this._channel = Token.DEFAULT_CHANNEL; + this._tokenStartCharIndex = -1; + this._tokenStartColumn = -1; + this._tokenStartLine = -1; + this._text = null; + + this._hitEOF = false; + this._mode = Lexer.DEFAULT_MODE; + this._modeStack = []; + + this._interp.reset(); + } + +// Return a token from this source; i.e., match a token on the char stream. + nextToken() { + if (this._input === null) { + throw "nextToken requires a non-null input stream."; + } + + /** + * Mark start location in char stream so unbuffered streams are + * guaranteed at least have text of current token + */ + const tokenStartMarker = this._input.mark(); + try { + for (;;) { + if (this._hitEOF) { + this.emitEOF(); + return this._token; + } + this._token = null; + this._channel = Token.DEFAULT_CHANNEL; + this._tokenStartCharIndex = this._input.index; + this._tokenStartColumn = this._interp.column; + this._tokenStartLine = this._interp.line; + this._text = null; + let continueOuter = false; + for (;;) { + this._type = Token.INVALID_TYPE; + let ttype = Lexer.SKIP; + try { + ttype = this._interp.match(this._input, this._mode); + } catch (e) { + if(e instanceof RecognitionException) { + this.notifyListeners(e); // report error + this.recover(e); + } else { + console.log(e.stack); + throw e; + } + } + if (this._input.LA(1) === Token.EOF) { + this._hitEOF = true; + } + if (this._type === Token.INVALID_TYPE) { + this._type = ttype; + } + if (this._type === Lexer.SKIP) { + continueOuter = true; + break; + } + if (this._type !== Lexer.MORE) { + break; + } + } + if (continueOuter) { + continue; + } + if (this._token === null) { + this.emit(); + } + return this._token; + } + } finally { + // make sure we release marker after match or + // unbuffered char stream will keep buffering + this._input.release(tokenStartMarker); + } + } + + /** + * Instruct the lexer to skip creating a token for current lexer rule + * and look for another token. nextToken() knows to keep looking when + * a lexer rule finishes with token set to SKIP_TOKEN. Recall that + * if token==null at end of any token rule, it creates one for you + * and emits it. + */ + skip() { + this._type = Lexer.SKIP; + } + + more() { + this._type = Lexer.MORE; + } + + mode(m) { + this._mode = m; + } + + pushMode(m) { + if (this._interp.debug) { + console.log("pushMode " + m); + } + this._modeStack.push(this._mode); + this.mode(m); + } + + popMode() { + if (this._modeStack.length === 0) { + throw "Empty Stack"; + } + if (this._interp.debug) { + console.log("popMode back to " + this._modeStack.slice(0, -1)); + } + this.mode(this._modeStack.pop()); + return this._mode; + } + + /** + * By default does not support multiple emits per nextToken invocation + * for efficiency reasons. Subclass and override this method, nextToken, + * and getToken (to push tokens into a list and pull from that list + * rather than a single variable as this implementation does). + */ + emitToken(token) { + this._token = token; + } + + /** + * The standard method called to automatically emit a token at the + * outermost lexical rule. The token object should point into the + * char buffer start..stop. If there is a text override in 'text', + * use that to set the token's text. Override this method to emit + * custom Token objects or provide a new factory. + */ + emit() { + const t = this._factory.create(this._tokenFactorySourcePair, this._type, + this._text, this._channel, this._tokenStartCharIndex, this + .getCharIndex() - 1, this._tokenStartLine, + this._tokenStartColumn); + this.emitToken(t); + return t; + } + + emitEOF() { + const cpos = this.column; + const lpos = this.line; + const eof = this._factory.create(this._tokenFactorySourcePair, Token.EOF, + null, Token.DEFAULT_CHANNEL, this._input.index, + this._input.index - 1, lpos, cpos); + this.emitToken(eof); + return eof; + } + +// What is the index of the current character of lookahead?/// + getCharIndex() { + return this._input.index; + } + + /** + * Return a list of all Token objects in input char stream. + * Forces load of all tokens. Does not include EOF token. + */ + getAllTokens() { + const tokens = []; + let t = this.nextToken(); + while (t.type !== Token.EOF) { + tokens.push(t); + t = this.nextToken(); + } + return tokens; + } + + notifyListeners(e) { + const start = this._tokenStartCharIndex; + const stop = this._input.index; + const text = this._input.getText(start, stop); + const msg = "token recognition error at: '" + this.getErrorDisplay(text) + "'"; + const listener = this.getErrorListenerDispatch(); + listener.syntaxError(this, null, this._tokenStartLine, + this._tokenStartColumn, msg, e); + } + + getErrorDisplay(s) { + const d = []; + for (let i = 0; i < s.length; i++) { + d.push(s[i]); + } + return d.join(''); + } + + getErrorDisplayForChar(c) { + if (c.charCodeAt(0) === Token.EOF) { + return ""; + } else if (c === '\n') { + return "\\n"; + } else if (c === '\t') { + return "\\t"; + } else if (c === '\r') { + return "\\r"; + } else { + return c; + } + } + + getCharErrorDisplay(c) { + return "'" + this.getErrorDisplayForChar(c) + "'"; + } + + /** + * Lexers can normally match any char in it's vocabulary after matching + * a token, so do the easy thing and just kill a character and hope + * it all works out. You can instead use the rule invocation stack + * to do sophisticated error recovery if you are in a fragment rule. + */ + recover(re) { + if (this._input.LA(1) !== Token.EOF) { + if (re instanceof LexerNoViableAltException) { + // skip a char and try again + this._interp.consume(this._input); + } else { + // TODO: Do we lose character or line position information? + this._input.consume(); + } + } + } + + get inputStream(){ + return this._input; + } + + set inputStream(input) { + this._input = null; + this._tokenFactorySourcePair = [ this, this._input ]; + this.reset(); + this._input = input; + this._tokenFactorySourcePair = [ this, this._input ]; + } + + get sourceName(){ + return this._input.sourceName; + } + + get type(){ + return this._type; + } + + set type(type) { + this._type = type; + } + + get line(){ + return this._interp.line; + } + + set line(line) { + this._interp.line = line; + } + + get column(){ + return this._interp.column; + } + + set column(column) { + this._interp.column = column; + } + + get text(){ + if (this._text !== null) { + return this._text; + } else { + return this._interp.getText(this._input); + } + } + + set text(text) { + this._text = text; + } +} + + + + +Lexer.DEFAULT_MODE = 0; +Lexer.MORE = -2; +Lexer.SKIP = -3; + +Lexer.DEFAULT_TOKEN_CHANNEL = Token.DEFAULT_CHANNEL; +Lexer.HIDDEN = Token.HIDDEN_CHANNEL; +Lexer.MIN_CHAR_VALUE = 0x0000; +Lexer.MAX_CHAR_VALUE = 0x10FFFF; + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/TokenStream.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +// this is just to keep meaningful parameter types to Parser +class TokenStream {} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/BufferedTokenStream.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + +/** + * This implementation of {@link TokenStream} loads tokens from a + * {@link TokenSource} on-demand, and places the tokens in a buffer to provide + * access to any previous token by index. + * + *

      + * This token stream ignores the value of {@link Token//getChannel}. If your + * parser requires the token stream filter tokens to only those on a particular + * channel, such as {@link Token//DEFAULT_CHANNEL} or + * {@link Token//HIDDEN_CHANNEL}, use a filtering token stream such a + * {@link CommonTokenStream}.

      + */ +class BufferedTokenStream extends TokenStream { + constructor(tokenSource) { + + super(); + // The {@link TokenSource} from which tokens for this stream are fetched. + this.tokenSource = tokenSource; + /** + * A collection of all tokens fetched from the token source. The list is + * considered a complete view of the input once {@link //fetchedEOF} is set + * to {@code true}. + */ + this.tokens = []; + + /** + * The index into {@link //tokens} of the current token (next token to + * {@link //consume}). {@link //tokens}{@code [}{@link //p}{@code ]} should + * be + * {@link //LT LT(1)}. + * + *

      This field is set to -1 when the stream is first constructed or when + * {@link //setTokenSource} is called, indicating that the first token has + * not yet been fetched from the token source. For additional information, + * see the documentation of {@link IntStream} for a description of + * Initializing Methods.

      + */ + this.index = -1; + + /** + * Indicates whether the {@link Token//EOF} token has been fetched from + * {@link //tokenSource} and added to {@link //tokens}. This field improves + * performance for the following cases: + * + *
        + *
      • {@link //consume}: The lookahead check in {@link //consume} to + * prevent + * consuming the EOF symbol is optimized by checking the values of + * {@link //fetchedEOF} and {@link //p} instead of calling {@link + * //LA}.
      • + *
      • {@link //fetch}: The check to prevent adding multiple EOF symbols + * into + * {@link //tokens} is trivial with this field.
      • + *
          + */ + this.fetchedEOF = false; + } + + mark() { + return 0; + } + + release(marker) { + // no resources to release + } + + reset() { + this.seek(0); + } + + seek(index) { + this.lazyInit(); + this.index = this.adjustSeekIndex(index); + } + + get(index) { + this.lazyInit(); + return this.tokens[index]; + } + + consume() { + let skipEofCheck = false; + if (this.index >= 0) { + if (this.fetchedEOF) { + // the last token in tokens is EOF. skip check if p indexes any + // fetched token except the last. + skipEofCheck = this.index < this.tokens.length - 1; + } else { + // no EOF token in tokens. skip check if p indexes a fetched token. + skipEofCheck = this.index < this.tokens.length; + } + } else { + // not yet initialized + skipEofCheck = false; + } + if (!skipEofCheck && this.LA(1) === Token.EOF) { + throw "cannot consume EOF"; + } + if (this.sync(this.index + 1)) { + this.index = this.adjustSeekIndex(this.index + 1); + } + } + + /** + * Make sure index {@code i} in tokens has a token. + * + * @return {Boolean} {@code true} if a token is located at index {@code i}, otherwise + * {@code false}. + * @see //get(int i) + */ + sync(i) { + const n = i - this.tokens.length + 1; // how many more elements we need? + if (n > 0) { + const fetched = this.fetch(n); + return fetched >= n; + } + return true; + } + + /** + * Add {@code n} elements to buffer. + * + * @return {Number} The actual number of elements added to the buffer. + */ + fetch(n) { + if (this.fetchedEOF) { + return 0; + } + for (let i = 0; i < n; i++) { + const t = this.tokenSource.nextToken(); + t.tokenIndex = this.tokens.length; + this.tokens.push(t); + if (t.type === Token.EOF) { + this.fetchedEOF = true; + return i + 1; + } + } + return n; + } + +// Get all tokens from start..stop inclusively/// + getTokens(start, stop, types) { + if (types === undefined) { + types = null; + } + if (start < 0 || stop < 0) { + return null; + } + this.lazyInit(); + const subset = []; + if (stop >= this.tokens.length) { + stop = this.tokens.length - 1; + } + for (let i = start; i < stop; i++) { + const t = this.tokens[i]; + if (t.type === Token.EOF) { + break; + } + if (types === null || types.contains(t.type)) { + subset.push(t); + } + } + return subset; + } + + LA(i) { + return this.LT(i).type; + } + + LB(k) { + if (this.index - k < 0) { + return null; + } + return this.tokens[this.index - k]; + } + + LT(k) { + this.lazyInit(); + if (k === 0) { + return null; + } + if (k < 0) { + return this.LB(-k); + } + const i = this.index + k - 1; + this.sync(i); + if (i >= this.tokens.length) { // return EOF token + // EOF must be last token + return this.tokens[this.tokens.length - 1]; + } + return this.tokens[i]; + } + + /** + * Allowed derived classes to modify the behavior of operations which change + * the current stream position by adjusting the target token index of a seek + * operation. The default implementation simply returns {@code i}. If an + * exception is thrown in this method, the current stream index should not be + * changed. + * + *

          For example, {@link CommonTokenStream} overrides this method to ensure + * that + * the seek target is always an on-channel token.

          + * + * @param {Number} i The target token index. + * @return {Number} The adjusted target token index. + */ + adjustSeekIndex(i) { + return i; + } + + lazyInit() { + if (this.index === -1) { + this.setup(); + } + } + + setup() { + this.sync(0); + this.index = this.adjustSeekIndex(0); + } + +// Reset this token stream by setting its token source./// + setTokenSource(tokenSource) { + this.tokenSource = tokenSource; + this.tokens = []; + this.index = -1; + this.fetchedEOF = false; + } + + /** + * Given a starting index, return the index of the next token on channel. + * Return i if tokens[i] is on channel. Return -1 if there are no tokens + * on channel between i and EOF. + */ + nextTokenOnChannel(i, channel) { + this.sync(i); + if (i >= this.tokens.length) { + return -1; + } + let token = this.tokens[i]; + while (token.channel !== this.channel) { + if (token.type === Token.EOF) { + return -1; + } + i += 1; + this.sync(i); + token = this.tokens[i]; + } + return i; + } + + /** + * Given a starting index, return the index of the previous token on channel. + * Return i if tokens[i] is on channel. Return -1 if there are no tokens + * on channel between i and 0. + */ + previousTokenOnChannel(i, channel) { + while (i >= 0 && this.tokens[i].channel !== channel) { + i -= 1; + } + return i; + } + + /** + * Collect all tokens on specified channel to the right of + * the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or + * EOF. If channel is -1, find any non default channel token. + */ + getHiddenTokensToRight(tokenIndex, + channel) { + if (channel === undefined) { + channel = -1; + } + this.lazyInit(); + if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { + throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; + } + const nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL); + const from_ = tokenIndex + 1; + // if none onchannel to right, nextOnChannel=-1 so set to = last token + const to = nextOnChannel === -1 ? this.tokens.length - 1 : nextOnChannel; + return this.filterForChannel(from_, to, channel); + } + + /** + * Collect all tokens on specified channel to the left of + * the current token up until we see a token on DEFAULT_TOKEN_CHANNEL. + * If channel is -1, find any non default channel token. + */ + getHiddenTokensToLeft(tokenIndex, + channel) { + if (channel === undefined) { + channel = -1; + } + this.lazyInit(); + if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { + throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; + } + const prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL); + if (prevOnChannel === tokenIndex - 1) { + return null; + } + // if none on channel to left, prevOnChannel=-1 then from=0 + const from_ = prevOnChannel + 1; + const to = tokenIndex - 1; + return this.filterForChannel(from_, to, channel); + } + + filterForChannel(left, right, channel) { + const hidden = []; + for (let i = left; i < right + 1; i++) { + const t = this.tokens[i]; + if (channel === -1) { + if (t.channel !== Lexer.DEFAULT_TOKEN_CHANNEL) { + hidden.push(t); + } + } else if (t.channel === channel) { + hidden.push(t); + } + } + if (hidden.length === 0) { + return null; + } + return hidden; + } + + getSourceName() { + return this.tokenSource.getSourceName(); + } + +// Get the text of all tokens in this buffer./// + getText(interval) { + this.lazyInit(); + this.fill(); + if (interval === undefined || interval === null) { + interval = new Interval(0, this.tokens.length - 1); + } + let start = interval.start; + if (start instanceof Token) { + start = start.tokenIndex; + } + let stop = interval.stop; + if (stop instanceof Token) { + stop = stop.tokenIndex; + } + if (start === null || stop === null || start < 0 || stop < 0) { + return ""; + } + if (stop >= this.tokens.length) { + stop = this.tokens.length - 1; + } + let s = ""; + for (let i = start; i < stop + 1; i++) { + const t = this.tokens[i]; + if (t.type === Token.EOF) { + break; + } + s = s + t.text; + } + return s; + } + +// Get all tokens from lexer until EOF/// + fill() { + this.lazyInit(); + while (this.fetch(1000) === 1000) { + continue; + } + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CommonTokenStream.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + +/** + * This class extends {@link BufferedTokenStream} with functionality to filter + * token streams to tokens on a particular channel (tokens where + * {@link Token//getChannel} returns a particular value). + * + *

          + * This token stream provides access to all tokens by index or when calling + * methods like {@link //getText}. The channel filtering is only used for code + * accessing tokens via the lookahead methods {@link //LA}, {@link //LT}, and + * {@link //LB}.

          + * + *

          + * By default, tokens are placed on the default channel + * ({@link Token//DEFAULT_CHANNEL}), but may be reassigned by using the + * {@code ->channel(HIDDEN)} lexer command, or by using an embedded action to + * call {@link Lexer//setChannel}. + *

          + * + *

          + * Note: lexer rules which use the {@code ->skip} lexer command or call + * {@link Lexer//skip} do not produce tokens at all, so input text matched by + * such a rule will not be available as part of the token stream, regardless of + * channel.

          + */ +class CommonTokenStream extends BufferedTokenStream { + constructor(lexer, channel) { + super(lexer); + this.channel = channel===undefined ? Token.DEFAULT_CHANNEL : channel; + } + + adjustSeekIndex(i) { + return this.nextTokenOnChannel(i, this.channel); + } + + LB(k) { + if (k===0 || this.index-k<0) { + return null; + } + let i = this.index; + let n = 1; + // find k good tokens looking backwards + while (n <= k) { + // skip off-channel tokens + i = this.previousTokenOnChannel(i - 1, this.channel); + n += 1; + } + if (i < 0) { + return null; + } + return this.tokens[i]; + } + + LT(k) { + this.lazyInit(); + if (k === 0) { + return null; + } + if (k < 0) { + return this.LB(-k); + } + let i = this.index; + let n = 1; // we know tokens[pos] is a good one + // find k good tokens + while (n < k) { + // skip off-channel tokens, but make sure to not look past EOF + if (this.sync(i + 1)) { + i = this.nextTokenOnChannel(i + 1, this.channel); + } + n += 1; + } + return this.tokens[i]; + } + + // Count EOF just once. + getNumberOfOnChannelTokens() { + let n = 0; + this.fill(); + for (let i =0; i< this.tokens.length;i++) { + const t = this.tokens[i]; + if( t.channel===this.channel) { + n += 1; + } + if( t.type===Token.EOF) { + break; + } + } + return n; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/stringHashCode.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +String.prototype.seed = String.prototype.seed || Math.round(Math.random() * Math.pow(2, 32)); + +String.prototype.hashCode = function () { + const key = this.toString(); + let h1b, k1; + + const remainder = key.length & 3; // key.length % 4 + const bytes = key.length - remainder; + let h1 = String.prototype.seed; + const c1 = 0xcc9e2d51; + const c2 = 0x1b873593; + let i = 0; + + while (i < bytes) { + k1 = + ((key.charCodeAt(i) & 0xff)) | + ((key.charCodeAt(++i) & 0xff) << 8) | + ((key.charCodeAt(++i) & 0xff) << 16) | + ((key.charCodeAt(++i) & 0xff) << 24); + ++i; + + k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; + k1 = (k1 << 15) | (k1 >>> 17); + k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; + + h1 ^= k1; + h1 = (h1 << 13) | (h1 >>> 19); + h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; + h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); + } + + k1 = 0; + + switch (remainder) { + case 3: + k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; + // no-break + case 2: + k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; + // no-break + case 1: + k1 ^= (key.charCodeAt(i) & 0xff); + k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; + k1 = (k1 << 15) | (k1 >>> 17); + k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; + h1 ^= k1; + } + + h1 ^= key.length; + + h1 ^= h1 >>> 16; + h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; + h1 ^= h1 >>> 13; + h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; + h1 ^= h1 >>> 16; + + return h1 >>> 0; +}; + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/equalArrays.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +function equalArrays(a, b) { + if (!Array.isArray(a) || !Array.isArray(b)) + return false; + if (a === b) + return true; + if (a.length !== b.length) + return false; + for (let i = 0; i < a.length; i++) { + if (a[i] === b[i]) + continue; + if (!a[i].equals || !a[i].equals(b[i])) + return false; + } + return true; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/HashCode.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +class HashCode { + + constructor() { + this.count = 0; + this.hash = 0; + } + + update() { + for(let i=0;i>> (32 - 15)); + k = k * 0x1B873593; + this.count = this.count + 1; + let hash = this.hash ^ k; + hash = (hash << 13) | (hash >>> (32 - 13)); + hash = hash * 5 + 0xE6546B64; + this.hash = hash; + } + } + } + + finish() { + let hash = this.hash ^ (this.count * 4); + hash = hash ^ (hash >>> 16); + hash = hash * 0x85EBCA6B; + hash = hash ^ (hash >>> 13); + hash = hash * 0xC2B2AE35; + hash = hash ^ (hash >>> 16); + return hash; + } + + static hashStuff() { + const hash = new HashCode(); + hash.update.apply(hash, arguments); + return hash.finish(); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/standardHashCodeFunction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +function standardHashCodeFunction(a) { + return a ? a.hashCode() : -1; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/standardEqualsFunction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +function standardEqualsFunction(a, b) { + return a ? a.equals(b) : a===b; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/valueToString.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +function valueToString(v) { + return v === null ? "null" : v; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/arrayToString.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +function arrayToString(a) { + return Array.isArray(a) ? ("[" + a.map(valueToString).join(", ") + "]") : "null"; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/HashSet.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +const HASH_KEY_PREFIX = "h-"; + +class HashSet { + + constructor(hashFunction, equalsFunction) { + this.data = {}; + this.hashFunction = hashFunction || standardHashCodeFunction; + this.equalsFunction = equalsFunction || standardEqualsFunction; + } + + add(value) { + const key = HASH_KEY_PREFIX + this.hashFunction(value); + if (key in this.data) { + const values = this.data[key]; + for (let i = 0; i < values.length; i++) { + if (this.equalsFunction(value, values[i])) { + return values[i]; + } + } + values.push(value); + return value; + } else { + this.data[key] = [value]; + return value; + } + } + + has(value) { + return this.get(value) != null; + } + + get(value) { + const key = HASH_KEY_PREFIX + this.hashFunction(value); + if (key in this.data) { + const values = this.data[key]; + for (let i = 0; i < values.length; i++) { + if (this.equalsFunction(value, values[i])) { + return values[i]; + } + } + } + return null; + } + + values() { + return Object.keys(this.data).filter(key => key.startsWith(HASH_KEY_PREFIX)).flatMap(key => this.data[key], this); + } + + toString() { + return arrayToString(this.values()); + } + + get length() { + return Object.keys(this.data).filter(key => key.startsWith(HASH_KEY_PREFIX)).map(key => this.data[key].length, this).reduce((accum, item) => accum + item, 0); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/SemanticContext.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + +/** + * A tree structure used to record the semantic context in which + * an ATN configuration is valid. It's either a single predicate, + * a conjunction {@code p1&&p2}, or a sum of products {@code p1||p2}. + * + *

          I have scoped the {@link AND}, {@link OR}, and {@link Predicate} subclasses of + * {@link SemanticContext} within the scope of this outer class.

          + */ +class SemanticContext { + + hashCode() { + const hash = new HashCode(); + this.updateHashCode(hash); + return hash.finish(); + } + + /** + * For context independent predicates, we evaluate them without a local + * context (i.e., null context). That way, we can evaluate them without + * having to create proper rule-specific context during prediction (as + * opposed to the parser, which creates them naturally). In a practical + * sense, this avoids a cast exception from RuleContext to myruleContext. + * + *

          For context dependent predicates, we must pass in a local context so that + * references such as $arg evaluate properly as _localctx.arg. We only + * capture context dependent predicates in the context in which we begin + * prediction, so we passed in the outer context here in case of context + * dependent predicate evaluation.

          + */ + evaluate(parser, outerContext) {} + + /** + * Evaluate the precedence predicates for the context and reduce the result. + * + * @param parser The parser instance. + * @param outerContext The current parser context object. + * @return The simplified semantic context after precedence predicates are + * evaluated, which will be one of the following values. + *
            + *
          • {@link //NONE}: if the predicate simplifies to {@code true} after + * precedence predicates are evaluated.
          • + *
          • {@code null}: if the predicate simplifies to {@code false} after + * precedence predicates are evaluated.
          • + *
          • {@code this}: if the semantic context is not changed as a result of + * precedence predicate evaluation.
          • + *
          • A non-{@code null} {@link SemanticContext}: the new simplified + * semantic context after precedence predicates are evaluated.
          • + *
          + */ + evalPrecedence(parser, outerContext) { + return this; + } + + static andContext(a, b) { + if (a === null || a === SemanticContext.NONE) { + return b; + } + if (b === null || b === SemanticContext.NONE) { + return a; + } + const result = new AND(a, b); + if (result.opnds.length === 1) { + return result.opnds[0]; + } else { + return result; + } + } + + static orContext(a, b) { + if (a === null) { + return b; + } + if (b === null) { + return a; + } + if (a === SemanticContext.NONE || b === SemanticContext.NONE) { + return SemanticContext.NONE; + } + const result = new OR(a, b); + if (result.opnds.length === 1) { + return result.opnds[0]; + } else { + return result; + } + } +} + + + +class AND extends SemanticContext { + /** + * A semantic context which is true whenever none of the contained contexts + * is false + */ + constructor(a, b) { + super(); + const operands = new HashSet(); + if (a instanceof AND) { + a.opnds.map(function(o) { + operands.add(o); + }); + } else { + operands.add(a); + } + if (b instanceof AND) { + b.opnds.map(function(o) { + operands.add(o); + }); + } else { + operands.add(b); + } + const precedencePredicates = filterPrecedencePredicates(operands); + if (precedencePredicates.length > 0) { + // interested in the transition with the lowest precedence + let reduced = null; + precedencePredicates.map( function(p) { + if(reduced===null || p.precedence + * The evaluation of predicates by this context is short-circuiting, but + * unordered.

          + */ + evaluate(parser, outerContext) { + for (let i = 0; i < this.opnds.length; i++) { + if (!this.opnds[i].evaluate(parser, outerContext)) { + return false; + } + } + return true; + } + + evalPrecedence(parser, outerContext) { + let differs = false; + const operands = []; + for (let i = 0; i < this.opnds.length; i++) { + const context = this.opnds[i]; + const evaluated = context.evalPrecedence(parser, outerContext); + differs |= (evaluated !== context); + if (evaluated === null) { + // The AND context is false if any element is false + return null; + } else if (evaluated !== SemanticContext.NONE) { + // Reduce the result by skipping true elements + operands.push(evaluated); + } + } + if (!differs) { + return this; + } + if (operands.length === 0) { + // all elements were true, so the AND context is true + return SemanticContext.NONE; + } + let result = null; + operands.map(function(o) { + result = result === null ? o : SemanticContext.andContext(result, o); + }); + return result; + } + + toString() { + const s = this.opnds.map(o => o.toString()); + return (s.length > 3 ? s.slice(3) : s).join("&&"); + } +} + + +class OR extends SemanticContext { + /** + * A semantic context which is true whenever at least one of the contained + * contexts is true + */ + constructor(a, b) { + super(); + const operands = new HashSet(); + if (a instanceof OR) { + a.opnds.map(function(o) { + operands.add(o); + }); + } else { + operands.add(a); + } + if (b instanceof OR) { + b.opnds.map(function(o) { + operands.add(o); + }); + } else { + operands.add(b); + } + + const precedencePredicates = filterPrecedencePredicates(operands); + if (precedencePredicates.length > 0) { + // interested in the transition with the highest precedence + const s = precedencePredicates.sort(function(a, b) { + return a.compareTo(b); + }); + const reduced = s[s.length-1]; + operands.add(reduced); + } + this.opnds = Array.from(operands.values()); + } + + equals(other) { + if (this === other) { + return true; + } else if (!(other instanceof OR)) { + return false; + } else { + return equalArrays(this.opnds, other.opnds); + } + } + + updateHashCode(hash) { + hash.update(this.opnds, "OR"); + } + + /** + *

          + * The evaluation of predicates by this context is short-circuiting, but + * unordered.

          + */ + evaluate(parser, outerContext) { + for (let i = 0; i < this.opnds.length; i++) { + if (this.opnds[i].evaluate(parser, outerContext)) { + return true; + } + } + return false; + } + + evalPrecedence(parser, outerContext) { + let differs = false; + const operands = []; + for (let i = 0; i < this.opnds.length; i++) { + const context = this.opnds[i]; + const evaluated = context.evalPrecedence(parser, outerContext); + differs |= (evaluated !== context); + if (evaluated === SemanticContext.NONE) { + // The OR context is true if any element is true + return SemanticContext.NONE; + } else if (evaluated !== null) { + // Reduce the result by skipping false elements + operands.push(evaluated); + } + } + if (!differs) { + return this; + } + if (operands.length === 0) { + // all elements were false, so the OR context is false + return null; + } + const result = null; + operands.map(function(o) { + return result === null ? o : SemanticContext.orContext(result, o); + }); + return result; + } + + toString() { + const s = this.opnds.map(o => o.toString()); + return (s.length > 3 ? s.slice(3) : s).join("||"); + } +} + +function filterPrecedencePredicates(set) { + const result = []; + set.values().map( function(context) { + if (context instanceof SemanticContext.PrecedencePredicate) { + result.push(context); + } + }); + return result; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNConfig.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +function checkParams(params, isCfg) { + if(params===null) { + const result = { state:null, alt:null, context:null, semanticContext:null }; + if(isCfg) { + result.reachesIntoOuterContext = 0; + } + return result; + } else { + const props = {}; + props.state = params.state || null; + props.alt = (params.alt === undefined) ? null : params.alt; + props.context = params.context || null; + props.semanticContext = params.semanticContext || null; + if(isCfg) { + props.reachesIntoOuterContext = params.reachesIntoOuterContext || 0; + props.precedenceFilterSuppressed = params.precedenceFilterSuppressed || false; + } + return props; + } +} + +class ATNConfig { + /** + * @param {Object} params A tuple: (ATN state, predicted alt, syntactic, semantic context). + * The syntactic context is a graph-structured stack node whose + * path(s) to the root is the rule invocation(s) + * chain used to arrive at the state. The semantic context is + * the tree of semantic predicates encountered before reaching + * an ATN state + */ + constructor(params, config) { + this.checkContext(params, config); + params = checkParams(params); + config = checkParams(config, true); + // The ATN state associated with this configuration/// + this.state = params.state!==null ? params.state : config.state; + // What alt (or lexer rule) is predicted by this configuration/// + this.alt = params.alt!==null ? params.alt : config.alt; + /** + * The stack of invoking states leading to the rule/states associated + * with this config. We track only those contexts pushed during + * execution of the ATN simulator + */ + this.context = params.context!==null ? params.context : config.context; + this.semanticContext = params.semanticContext!==null ? params.semanticContext : + (config.semanticContext!==null ? config.semanticContext : SemanticContext.NONE); + // TODO: make it a boolean then + /** + * We cannot execute predicates dependent upon local context unless + * we know for sure we are in the correct context. Because there is + * no way to do this efficiently, we simply cannot evaluate + * dependent predicates unless we are in the rule that initially + * invokes the ATN simulator. + * closure() tracks the depth of how far we dip into the + * outer context: depth > 0. Note that it may not be totally + * accurate depth since I don't ever decrement + */ + this.reachesIntoOuterContext = config.reachesIntoOuterContext; + this.precedenceFilterSuppressed = config.precedenceFilterSuppressed; + } + + checkContext(params, config) { + if((params.context===null || params.context===undefined) && + (config===null || config.context===null || config.context===undefined)) { + this.context = null; + } + } + + hashCode() { + const hash = new HashCode(); + this.updateHashCode(hash); + return hash.finish(); + } + + updateHashCode(hash) { + hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext); + } + + /** + * An ATN configuration is equal to another if both have + * the same state, they predict the same alternative, and + * syntactic/semantic contexts are the same + */ + equals(other) { + if (this === other) { + return true; + } else if (! (other instanceof ATNConfig)) { + return false; + } else { + return this.state.stateNumber===other.state.stateNumber && + this.alt===other.alt && + (this.context===null ? other.context===null : this.context.equals(other.context)) && + this.semanticContext.equals(other.semanticContext) && + this.precedenceFilterSuppressed===other.precedenceFilterSuppressed; + } + } + + hashCodeForConfigSet() { + const hash = new HashCode(); + hash.update(this.state.stateNumber, this.alt, this.semanticContext); + return hash.finish(); + } + + equalsForConfigSet(other) { + if (this === other) { + return true; + } else if (! (other instanceof ATNConfig)) { + return false; + } else { + return this.state.stateNumber===other.state.stateNumber && + this.alt===other.alt && + this.semanticContext.equals(other.semanticContext); + } + } + + toString() { + return "(" + this.state + "," + this.alt + + (this.context!==null ? ",[" + this.context.toString() + "]" : "") + + (this.semanticContext !== SemanticContext.NONE ? + ("," + this.semanticContext.toString()) + : "") + + (this.reachesIntoOuterContext>0 ? + (",up=" + this.reachesIntoOuterContext) + : "") + ")"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/IntervalSet.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +class IntervalSet { + constructor() { + this.intervals = null; + this.readOnly = false; + } + + first(v) { + if (this.intervals === null || this.intervals.length===0) { + return Token.INVALID_TYPE; + } else { + return this.intervals[0].start; + } + } + + addOne(v) { + this.addInterval(new Interval(v, v + 1)); + } + + addRange(l, h) { + this.addInterval(new Interval(l, h + 1)); + } + + addInterval(toAdd) { + if (this.intervals === null) { + this.intervals = []; + this.intervals.push(toAdd.clone()); + } else { + // find insert pos + for (let pos = 0; pos < this.intervals.length; pos++) { + const existing = this.intervals[pos]; + // distinct range -> insert + if (toAdd.stop < existing.start) { + this.intervals.splice(pos, 0, toAdd); + return; + } + // contiguous range -> adjust + else if (toAdd.stop === existing.start) { + this.intervals[pos] = new Interval(toAdd.start, existing.stop) + return; + } + // overlapping range -> adjust and reduce + else if (toAdd.start <= existing.stop) { + this.intervals[pos] = new Interval(Math.min(existing.start, toAdd.start), Math.max(existing.stop, toAdd.stop)); + this.reduce(pos); + return; + } + } + // greater than any existing + this.intervals.push(toAdd.clone()); + } + } + + addSet(other) { + if (other.intervals !== null) { + other.intervals.forEach( toAdd => this.addInterval(toAdd), this); + } + return this; + } + + reduce(pos) { + // only need to reduce if pos is not the last + if (pos < this.intervals.length - 1) { + const current = this.intervals[pos]; + const next = this.intervals[pos + 1]; + // if next contained in current + if (current.stop >= next.stop) { + this.intervals.splice(pos + 1, 1); + this.reduce(pos); + } else if (current.stop >= next.start) { + this.intervals[pos] = new Interval(current.start, next.stop); + this.intervals.splice(pos + 1, 1); + } + } + } + + complement(start, stop) { + const result = new IntervalSet(); + result.addInterval(new Interval(start, stop + 1)); + if(this.intervals !== null) + this.intervals.forEach(toRemove => result.removeRange(toRemove)); + return result; + } + + contains(item) { + if (this.intervals === null) { + return false; + } else { + for (let k = 0; k < this.intervals.length; k++) { + if(this.intervals[k].contains(item)) { + return true; + } + } + return false; + } + } + + removeRange(toRemove) { + if(toRemove.start===toRemove.stop-1) { + this.removeOne(toRemove.start); + } else if (this.intervals !== null) { + let pos = 0; + for(let n=0; nexisting.start && toRemove.stop=existing.stop) { + this.intervals.splice(pos, 1); + pos = pos - 1; // need another pass + } + // check for lower boundary + else if(toRemove.start"); + } else { + names.push("'" + String.fromCharCode(existing.start) + "'"); + } + } else { + names.push("'" + String.fromCharCode(existing.start) + "'..'" + String.fromCharCode(existing.stop-1) + "'"); + } + } + if (names.length > 1) { + return "{" + names.join(", ") + "}"; + } else { + return names[0]; + } + } + + toIndexString() { + const names = []; + for (let i = 0; i < this.intervals.length; i++) { + const existing = this.intervals[i]; + if(existing.stop===existing.start+1) { + if ( existing.start===Token.EOF ) { + names.push(""); + } else { + names.push(existing.start.toString()); + } + } else { + names.push(existing.start.toString() + ".." + (existing.stop-1).toString()); + } + } + if (names.length > 1) { + return "{" + names.join(", ") + "}"; + } else { + return names[0]; + } + } + + toTokenString(literalNames, symbolicNames) { + const names = []; + for (let i = 0; i < this.intervals.length; i++) { + const existing = this.intervals[i]; + for (let j = existing.start; j < existing.stop; j++) { + names.push(this.elementName(literalNames, symbolicNames, j)); + } + } + if (names.length > 1) { + return "{" + names.join(", ") + "}"; + } else { + return names[0]; + } + } + + elementName(literalNames, symbolicNames, token) { + if (token === Token.EOF) { + return ""; + } else if (token === Token.EPSILON) { + return ""; + } else { + return literalNames[token] || symbolicNames[token]; + } + } + + get length(){ + return this.intervals.map( interval => interval.length ).reduce((acc, val) => acc + val); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/ATNState.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * The following images show the relation of states and + * {@link ATNState//transitions} for various grammar constructs. + * + *
            + * + *
          • Solid edges marked with an &//0949; indicate a required + * {@link EpsilonTransition}.
          • + * + *
          • Dashed edges indicate locations where any transition derived from + * {@link Transition} might appear.
          • + * + *
          • Dashed nodes are place holders for either a sequence of linked + * {@link BasicState} states or the inclusion of a block representing a nested + * construct in one of the forms below.
          • + * + *
          • Nodes showing multiple outgoing alternatives with a {@code ...} support + * any number of alternatives (one or more). Nodes without the {@code ...} only + * support the exact number of alternatives shown in the diagram.
          • + * + *
          + * + *

          Basic Blocks

          + * + *

          Rule

          + * + * + * + *

          Block of 1 or more alternatives

          + * + * + * + *

          Greedy Loops

          + * + *

          Greedy Closure: {@code (...)*}

          + * + * + * + *

          Greedy Positive Closure: {@code (...)+}

          + * + * + * + *

          Greedy Optional: {@code (...)?}

          + * + * + * + *

          Non-Greedy Loops

          + * + *

          Non-Greedy Closure: {@code (...)*?}

          + * + * + * + *

          Non-Greedy Positive Closure: {@code (...)+?}

          + * + * + * + *

          Non-Greedy Optional: {@code (...)??}

          + * + * + */ +class ATNState { + constructor() { + // Which ATN are we in? + this.atn = null; + this.stateNumber = ATNState.INVALID_STATE_NUMBER; + this.stateType = null; + this.ruleIndex = 0; // at runtime, we don't have Rule objects + this.epsilonOnlyTransitions = false; + // Track the transitions emanating from this ATN state. + this.transitions = []; + // Used to cache lookahead during parsing, not used during construction + this.nextTokenWithinRule = null; + } + + toString() { + return this.stateNumber; + } + + equals(other) { + if (other instanceof ATNState) { + return this.stateNumber===other.stateNumber; + } else { + return false; + } + } + + isNonGreedyExitState() { + return false; + } + + addTransition(trans, index) { + if(index===undefined) { + index = -1; + } + if (this.transitions.length===0) { + this.epsilonOnlyTransitions = trans.isEpsilon; + } else if(this.epsilonOnlyTransitions !== trans.isEpsilon) { + this.epsilonOnlyTransitions = false; + } + if (index===-1) { + this.transitions.push(trans); + } else { + this.transitions.splice(index, 1, trans); + } + } +} + +// constants for serialization +ATNState.INVALID_TYPE = 0; +ATNState.BASIC = 1; +ATNState.RULE_START = 2; +ATNState.BLOCK_START = 3; +ATNState.PLUS_BLOCK_START = 4; +ATNState.STAR_BLOCK_START = 5; +ATNState.TOKEN_START = 6; +ATNState.RULE_STOP = 7; +ATNState.BLOCK_END = 8; +ATNState.STAR_LOOP_BACK = 9; +ATNState.STAR_LOOP_ENTRY = 10; +ATNState.PLUS_LOOP_BACK = 11; +ATNState.LOOP_END = 12; + +ATNState.serializationNames = [ + "INVALID", + "BASIC", + "RULE_START", + "BLOCK_START", + "PLUS_BLOCK_START", + "STAR_BLOCK_START", + "TOKEN_START", + "RULE_STOP", + "BLOCK_END", + "STAR_LOOP_BACK", + "STAR_LOOP_ENTRY", + "PLUS_LOOP_BACK", + "LOOP_END" ]; + +ATNState.INVALID_STATE_NUMBER = -1; + + + + + + + + + + + + + + + + + + + + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/RuleStopState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/** + * The last node in the ATN for a rule, unless that rule is the start symbol. + * In that case, there is one transition to EOF. Later, we might encode + * references to all calls to this rule to compute FOLLOW sets for + * error handling + */ +class RuleStopState extends ATNState { + constructor() { + super(); + this.stateType = ATNState.RULE_STOP; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/Transition.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * An ATN transition between any two ATN states. Subclasses define + * atom, set, epsilon, action, predicate, rule transitions. + * + *

          This is a one way link. It emanates from a state (usually via a list of + * transitions) and has a target state.

          + * + *

          Since we never have to change the ATN transitions once we construct it, + * we can fix these transitions as specific classes. The DFA transitions + * on the other hand need to update the labels as it adds transitions to + * the states. We'll use the term Edge for the DFA to distinguish them from + * ATN transitions.

          + */ +class Transition { + constructor(target) { + // The target of this transition. + if (target===undefined || target===null) { + throw "target cannot be null."; + } + this.target = target; + // Are we epsilon, action, sempred? + this.isEpsilon = false; + this.label = null; + } +} + +// constants for serialization + +Transition.EPSILON = 1; +Transition.RANGE = 2; +Transition.RULE = 3; +// e.g., {isType(input.LT(1))}? +Transition.PREDICATE = 4; +Transition.ATOM = 5; +Transition.ACTION = 6; +// ~(A|B) or ~atom, wildcard, which convert to next 2 +Transition.SET = 7; +Transition.NOT_SET = 8; +Transition.WILDCARD = 9; +Transition.PRECEDENCE = 10; + +Transition.serializationNames = [ + "INVALID", + "EPSILON", + "RANGE", + "RULE", + "PREDICATE", + "ATOM", + "ACTION", + "SET", + "NOT_SET", + "WILDCARD", + "PRECEDENCE" + ]; + +Transition.serializationTypes = { + EpsilonTransition: Transition.EPSILON, + RangeTransition: Transition.RANGE, + RuleTransition: Transition.RULE, + PredicateTransition: Transition.PREDICATE, + AtomTransition: Transition.ATOM, + ActionTransition: Transition.ACTION, + SetTransition: Transition.SET, + NotSetTransition: Transition.NOT_SET, + WildcardTransition: Transition.WILDCARD, + PrecedencePredicateTransition: Transition.PRECEDENCE + }; + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/RuleTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class RuleTransition extends Transition { + constructor(ruleStart, ruleIndex, precedence, followState) { + super(ruleStart); + // ptr to the rule definition object for this rule ref + this.ruleIndex = ruleIndex; + this.precedence = precedence; + // what node to begin computations following ref to rule + this.followState = followState; + this.serializationType = Transition.RULE; + this.isEpsilon = true; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return false; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/SetTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +// A transition containing a set of values. + + + + +class SetTransition extends Transition { + constructor(target, set) { + super(target); + this.serializationType = Transition.SET; + if (set !==undefined && set !==null) { + this.label = set; + } else { + this.label = new IntervalSet(); + this.label.addOne(Token.INVALID_TYPE); + } + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return this.label.contains(symbol); + } + + toString() { + return this.label.toString(); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/NotSetTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class NotSetTransition extends SetTransition { + constructor(target, set) { + super(target, set); + this.serializationType = Transition.NOT_SET; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && + !super.matches(symbol, minVocabSymbol, maxVocabSymbol); + } + + toString() { + return '~' + super.toString(); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/WildcardTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class WildcardTransition extends Transition { + constructor(target) { + super(target); + this.serializationType = Transition.WILDCARD; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; + } + + toString() { + return "."; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/AbstractPredicateTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class AbstractPredicateTransition extends Transition { + constructor(target) { + super(target); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/Tree.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * The basic notion of a tree has a parent, a payload, and a list of children. + * It is the most abstract interface for all the trees used by ANTLR. + */ +class Tree {} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/SyntaxTree.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class SyntaxTree extends Tree { +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTree.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class ParseTree extends SyntaxTree { +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/RuleNode.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class RuleNode extends ParseTree { + + getRuleContext(){ + throw new Error("missing interface implementation") + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/TerminalNode.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class TerminalNode extends ParseTree { +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ErrorNode.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class ErrorNode extends TerminalNode { +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/utils/escapeWhitespace.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +function escapeWhitespace(s, escapeSpaces) { + s = s.replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r"); + if (escapeSpaces) { + s = s.replace(/ /g, "\u00B7"); + } + return s; +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/Trees.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + +/** A set of utility routines useful for all kinds of ANTLR trees. */ +const Trees = { + /** + * Print out a whole tree in LISP form. {@link //getNodeText} is used on the + * node payloads to get the text for the nodes. Detect + * parse trees and extract data appropriately. + */ + toStringTree: function(tree, ruleNames, recog) { + ruleNames = ruleNames || null; + recog = recog || null; + if(recog!==null) { + ruleNames = recog.ruleNames; + } + let s = Trees.getNodeText(tree, ruleNames); + s = escapeWhitespace(s, false); + const c = tree.getChildCount(); + if(c===0) { + return s; + } + let res = "(" + s + ' '; + if(c>0) { + s = Trees.toStringTree(tree.getChild(0), ruleNames); + res = res.concat(s); + } + for(let i=1;i + * Since tokens on hidden channels (e.g. whitespace or comments) are not + * added to the parse trees, they will not appear in the output of this + * method. + */ + getText() { + if (this.getChildCount() === 0) { + return ""; + } else { + return this.children.map(function (child) { + return child.getText(); + }).join(""); + } + } + + /** + * For rule associated with this parse tree internal node, return + * the outer alternative number used to match the input. Default + * implementation does not compute nor store this alt num. Create + * a subclass of ParserRuleContext with backing field and set + * option contextSuperClass. + * to set it. + */ + getAltNumber() { + // use constant value of ATN.INVALID_ALT_NUMBER to avoid circular dependency + return 0; + } + + /** + * Set the outer alternative number for this context node. Default + * implementation does nothing to avoid backing field overhead for + * trees that don't need it. Create + * a subclass of ParserRuleContext with backing field and set + * option contextSuperClass. + */ + setAltNumber(altNumber) { + } + + getChild(i) { + return null; + } + + getChildCount() { + return 0; + } + + accept(visitor) { + return visitor.visitChildren(this); + } + + /** + * Print out a whole tree, not just a node, in LISP format + * (root child1 .. childN). Print just a node if this is a leaf. + */ + toStringTree(ruleNames, recog) { + return tree_Trees.toStringTree(this, ruleNames, recog); + } + + toString(ruleNames, stop) { + ruleNames = ruleNames || null; + stop = stop || null; + let p = this; + let s = "["; + while (p !== null && p !== stop) { + if (ruleNames === null) { + if (!p.isEmpty()) { + s += p.invokingState; + } + } else { + const ri = p.ruleIndex; + const ruleName = (ri >= 0 && ri < ruleNames.length) ? ruleNames[ri] + : "" + ri; + s += ruleName; + } + if (p.parentCtx !== null && (ruleNames !== null || !p.parentCtx.isEmpty())) { + s += " "; + } + p = p.parentCtx; + } + s += "]"; + return s; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/PredictionContext.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +class PredictionContext { + + constructor(cachedHashCode) { + this.cachedHashCode = cachedHashCode; + } + + /** + * Stores the computed hash code of this {@link PredictionContext}. The hash + * code is computed in parts to match the following reference algorithm. + * + *
          +	 * private int referenceHashCode() {
          +	 * int hash = {@link MurmurHash//initialize MurmurHash.initialize}({@link
          +	 * //INITIAL_HASH});
          +	 *
          +	 * for (int i = 0; i < {@link //size()}; i++) {
          +	 * hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link //getParent
          +	 * getParent}(i));
          +	 * }
          +	 *
          +	 * for (int i = 0; i < {@link //size()}; i++) {
          +	 * hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link
          +	 * //getReturnState getReturnState}(i));
          +	 * }
          +	 *
          +	 * hash = {@link MurmurHash//finish MurmurHash.finish}(hash, 2// {@link
          +	 * //size()});
          +	 * return hash;
          +	 * }
          +	 * 
          + * This means only the {@link //EMPTY} context is in set. + */ + isEmpty() { + return this === PredictionContext.EMPTY; + } + + hasEmptyPath() { + return this.getReturnState(this.length - 1) === PredictionContext.EMPTY_RETURN_STATE; + } + + hashCode() { + return this.cachedHashCode; + } + + updateHashCode(hash) { + hash.update(this.cachedHashCode); + } +} + +/** + * Represents {@code $} in local context prediction, which means wildcard. + * {@code//+x =//}. + */ +PredictionContext.EMPTY = null; + +/** + * Represents {@code $} in an array in full context mode, when {@code $} + * doesn't mean wildcard: {@code $ + x = [$,x]}. Here, + * {@code $} = {@link //EMPTY_RETURN_STATE}. + */ +PredictionContext.EMPTY_RETURN_STATE = 0x7FFFFFFF; + +PredictionContext.globalNodeCount = 1; +PredictionContext.id = PredictionContext.globalNodeCount; + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/ArrayPredictionContext.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +class ArrayPredictionContext extends PredictionContext { + + constructor(parents, returnStates) { + /** + * Parent can be null only if full ctx mode and we make an array + * from {@link //EMPTY} and non-empty. We merge {@link //EMPTY} by using + * null parent and + * returnState == {@link //EMPTY_RETURN_STATE}. + */ + const h = new HashCode(); + h.update(parents, returnStates); + const hashCode = h.finish(); + super(hashCode); + this.parents = parents; + this.returnStates = returnStates; + return this; + } + + isEmpty() { + // since EMPTY_RETURN_STATE can only appear in the last position, we + // don't need to verify that size==1 + return this.returnStates[0] === PredictionContext.EMPTY_RETURN_STATE; + } + + getParent(index) { + return this.parents[index]; + } + + getReturnState(index) { + return this.returnStates[index]; + } + + equals(other) { + if (this === other) { + return true; + } else if (!(other instanceof ArrayPredictionContext)) { + return false; + } else if (this.hashCode() !== other.hashCode()) { + return false; // can't be same if hash is different + } else { + return equalArrays(this.returnStates, other.returnStates) && + equalArrays(this.parents, other.parents); + } + } + + toString() { + if (this.isEmpty()) { + return "[]"; + } else { + let s = "["; + for (let i = 0; i < this.returnStates.length; i++) { + if (i > 0) { + s = s + ", "; + } + if (this.returnStates[i] === PredictionContext.EMPTY_RETURN_STATE) { + s = s + "$"; + continue; + } + s = s + this.returnStates[i]; + if (this.parents[i] !== null) { + s = s + " " + this.parents[i]; + } else { + s = s + "null"; + } + } + return s + "]"; + } + } + + get length(){ + return this.returnStates.length; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/SingletonPredictionContext.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class SingletonPredictionContext extends PredictionContext { + + constructor(parent, returnState) { + let hashCode = 0; + const hash = new HashCode(); + if(parent !== null) { + hash.update(parent, returnState); + } else { + hash.update(1); + } + hashCode = hash.finish(); + super(hashCode); + this.parentCtx = parent; + this.returnState = returnState; + } + + getParent(index) { + return this.parentCtx; + } + + getReturnState(index) { + return this.returnState; + } + + equals(other) { + if (this === other) { + return true; + } else if (!(other instanceof SingletonPredictionContext)) { + return false; + } else if (this.hashCode() !== other.hashCode()) { + return false; // can't be same if hash is different + } else { + if(this.returnState !== other.returnState) + return false; + else if(this.parentCtx==null) + return other.parentCtx==null + else + return this.parentCtx.equals(other.parentCtx); + } + } + + toString() { + const up = this.parentCtx === null ? "" : this.parentCtx.toString(); + if (up.length === 0) { + if (this.returnState === PredictionContext.EMPTY_RETURN_STATE) { + return "$"; + } else { + return "" + this.returnState; + } + } else { + return "" + this.returnState + " " + up; + } + } + + get length(){ + return 1; + } + + static create(parent, returnState) { + if (returnState === PredictionContext.EMPTY_RETURN_STATE && parent === null) { + // someone can pass in the bits of an array ctx that mean $ + return PredictionContext.EMPTY; + } else { + return new SingletonPredictionContext(parent, returnState); + } + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/EmptyPredictionContext.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class EmptyPredictionContext extends SingletonPredictionContext { + + constructor() { + super(null, PredictionContext.EMPTY_RETURN_STATE); + } + + isEmpty() { + return true; + } + + getParent(index) { + return null; + } + + getReturnState(index) { + return this.returnState; + } + + equals(other) { + return this === other; + } + + toString() { + return "$"; + } +} + + +PredictionContext.EMPTY = new EmptyPredictionContext(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/HashMap.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +const HashMap_HASH_KEY_PREFIX = "h-"; + +class HashMap_HashMap { + + constructor(hashFunction, equalsFunction) { + this.data = {}; + this.hashFunction = hashFunction || standardHashCodeFunction; + this.equalsFunction = equalsFunction || standardEqualsFunction; + } + + set(key, value) { + const hashKey = HashMap_HASH_KEY_PREFIX + this.hashFunction(key); + if (hashKey in this.data) { + const entries = this.data[hashKey]; + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + if (this.equalsFunction(key, entry.key)) { + const oldValue = entry.value; + entry.value = value; + return oldValue; + } + } + entries.push({key:key, value:value}); + return value; + } else { + this.data[hashKey] = [{key:key, value:value}]; + return value; + } + } + + containsKey(key) { + const hashKey = HashMap_HASH_KEY_PREFIX + this.hashFunction(key); + if(hashKey in this.data) { + const entries = this.data[hashKey]; + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + if (this.equalsFunction(key, entry.key)) + return true; + } + } + return false; + } + + get(key) { + const hashKey = HashMap_HASH_KEY_PREFIX + this.hashFunction(key); + if(hashKey in this.data) { + const entries = this.data[hashKey]; + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + if (this.equalsFunction(key, entry.key)) + return entry.value; + } + } + return null; + } + + entries() { + return Object.keys(this.data).filter(key => key.startsWith(HashMap_HASH_KEY_PREFIX)).flatMap(key => this.data[key], this); + } + + getKeys() { + return this.entries().map(e => e.key); + } + + getValues() { + return this.entries().map(e => e.value); + } + + toString() { + const ss = this.entries().map(e => '{' + e.key + ':' + e.value + '}'); + return '[' + ss.join(", ") + ']'; + } + + get length() { + return Object.keys(this.data).filter(key => key.startsWith(HashMap_HASH_KEY_PREFIX)).map(key => this.data[key].length, this).reduce((accum, item) => accum + item, 0); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/PredictionContextUtils.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + +/** + * Convert a {@link RuleContext} tree to a {@link PredictionContext} graph. + * Return {@link //EMPTY} if {@code outerContext} is empty or null. + */ +function predictionContextFromRuleContext(atn, outerContext) { + if (outerContext === undefined || outerContext === null) { + outerContext = RuleContext.EMPTY; + } + // if we are in RuleContext of start rule, s, then PredictionContext + // is EMPTY. Nobody called us. (if we are empty, return empty) + if (outerContext.parentCtx === null || outerContext === RuleContext.EMPTY) { + return PredictionContext.EMPTY; + } + // If we have a parent, convert it to a PredictionContext graph + const parent = predictionContextFromRuleContext(atn, outerContext.parentCtx); + const state = atn.states[outerContext.invokingState]; + const transition = state.transitions[0]; + return SingletonPredictionContext.create(parent, transition.followState.stateNumber); +} + + +function getCachedPredictionContext(context, contextCache, visited) { + if (context.isEmpty()) { + return context; + } + let existing = visited.get(context) || null; + if (existing !== null) { + return existing; + } + existing = contextCache.get(context); + if (existing !== null) { + visited.set(context, existing); + return existing; + } + let changed = false; + let parents = []; + for (let i = 0; i < parents.length; i++) { + const parent = getCachedPredictionContext(context.getParent(i), contextCache, visited); + if (changed || parent !== context.getParent(i)) { + if (!changed) { + parents = []; + for (let j = 0; j < context.length; j++) { + parents[j] = context.getParent(j); + } + changed = true; + } + parents[i] = parent; + } + } + if (!changed) { + contextCache.add(context); + visited.set(context, context); + return context; + } + let updated = null; + if (parents.length === 0) { + updated = PredictionContext.EMPTY; + } else if (parents.length === 1) { + updated = SingletonPredictionContext.create(parents[0], context + .getReturnState(0)); + } else { + updated = new ArrayPredictionContext(parents, context.returnStates); + } + contextCache.add(updated); + visited.set(updated, updated); + visited.set(context, updated); + + return updated; +} + +function merge(a, b, rootIsWildcard, mergeCache) { + // share same graph if both same + if (a === b) { + return a; + } + if (a instanceof SingletonPredictionContext && b instanceof SingletonPredictionContext) { + return mergeSingletons(a, b, rootIsWildcard, mergeCache); + } + // At least one of a or b is array + // If one is $ and rootIsWildcard, return $ as// wildcard + if (rootIsWildcard) { + if (a instanceof EmptyPredictionContext) { + return a; + } + if (b instanceof EmptyPredictionContext) { + return b; + } + } + // convert singleton so both are arrays to normalize + if (a instanceof SingletonPredictionContext) { + a = new ArrayPredictionContext([a.getParent()], [a.returnState]); + } + if (b instanceof SingletonPredictionContext) { + b = new ArrayPredictionContext([b.getParent()], [b.returnState]); + } + return mergeArrays(a, b, rootIsWildcard, mergeCache); +} + + +/** + * Merge two {@link ArrayPredictionContext} instances. + * + *

          Different tops, different parents.
          + *

          + * + *

          Shared top, same parents.
          + *

          + * + *

          Shared top, different parents.
          + *

          + * + *

          Shared top, all shared parents.
          + *

          + * + *

          Equal tops, merge parents and reduce top to + * {@link SingletonPredictionContext}.
          + *

          + */ +function mergeArrays(a, b, rootIsWildcard, mergeCache) { + if (mergeCache !== null) { + let previous = mergeCache.get(a, b); + if (previous !== null) { + return previous; + } + previous = mergeCache.get(b, a); + if (previous !== null) { + return previous; + } + } + // merge sorted payloads a + b => M + let i = 0; // walks a + let j = 0; // walks b + let k = 0; // walks target M array + + let mergedReturnStates = []; + let mergedParents = []; + // walk and merge to yield mergedParents, mergedReturnStates + while (i < a.returnStates.length && j < b.returnStates.length) { + const a_parent = a.parents[i]; + const b_parent = b.parents[j]; + if (a.returnStates[i] === b.returnStates[j]) { + // same payload (stack tops are equal), must yield merged singleton + const payload = a.returnStates[i]; + // $+$ = $ + const bothDollars = payload === PredictionContext.EMPTY_RETURN_STATE && + a_parent === null && b_parent === null; + const ax_ax = (a_parent !== null && b_parent !== null && a_parent === b_parent); // ax+ax + // -> + // ax + if (bothDollars || ax_ax) { + mergedParents[k] = a_parent; // choose left + mergedReturnStates[k] = payload; + } else { // ax+ay -> a'[x,y] + mergedParents[k] = merge(a_parent, b_parent, rootIsWildcard, mergeCache); + mergedReturnStates[k] = payload; + } + i += 1; // hop over left one as usual + j += 1; // but also skip one in right side since we merge + } else if (a.returnStates[i] < b.returnStates[j]) { // copy a[i] to M + mergedParents[k] = a_parent; + mergedReturnStates[k] = a.returnStates[i]; + i += 1; + } else { // b > a, copy b[j] to M + mergedParents[k] = b_parent; + mergedReturnStates[k] = b.returnStates[j]; + j += 1; + } + k += 1; + } + // copy over any payloads remaining in either array + if (i < a.returnStates.length) { + for (let p = i; p < a.returnStates.length; p++) { + mergedParents[k] = a.parents[p]; + mergedReturnStates[k] = a.returnStates[p]; + k += 1; + } + } else { + for (let p = j; p < b.returnStates.length; p++) { + mergedParents[k] = b.parents[p]; + mergedReturnStates[k] = b.returnStates[p]; + k += 1; + } + } + // trim merged if we combined a few that had same stack tops + if (k < mergedParents.length) { // write index < last position; trim + if (k === 1) { // for just one merged element, return singleton top + const a_ = SingletonPredictionContext.create(mergedParents[0], + mergedReturnStates[0]); + if (mergeCache !== null) { + mergeCache.set(a, b, a_); + } + return a_; + } + mergedParents = mergedParents.slice(0, k); + mergedReturnStates = mergedReturnStates.slice(0, k); + } + + const M = new ArrayPredictionContext(mergedParents, mergedReturnStates); + + // if we created same array as a or b, return that instead + // TODO: track whether this is possible above during merge sort for speed + if (M === a) { + if (mergeCache !== null) { + mergeCache.set(a, b, a); + } + return a; + } + if (M === b) { + if (mergeCache !== null) { + mergeCache.set(a, b, b); + } + return b; + } + combineCommonParents(mergedParents); + + if (mergeCache !== null) { + mergeCache.set(a, b, M); + } + return M; +} + + +/** + * Make pass over all M {@code parents}; merge any {@code equals()} + * ones. + */ +function combineCommonParents(parents) { + const uniqueParents = new HashMap_HashMap(); + + for (let p = 0; p < parents.length; p++) { + const parent = parents[p]; + if (!(uniqueParents.containsKey(parent))) { + uniqueParents.set(parent, parent); + } + } + for (let q = 0; q < parents.length; q++) { + parents[q] = uniqueParents.get(parents[q]); + } +} + + +/** + * Merge two {@link SingletonPredictionContext} instances. + * + *

          Stack tops equal, parents merge is same; return left graph.
          + *

          + * + *

          Same stack top, parents differ; merge parents giving array node, then + * remainders of those graphs. A new root node is created to point to the + * merged parents.
          + *

          + * + *

          Different stack tops pointing to same parent. Make array node for the + * root where both element in the root point to the same (original) + * parent.
          + *

          + * + *

          Different stack tops pointing to different parents. Make array node for + * the root where each element points to the corresponding original + * parent.
          + *

          + * + * @param a the first {@link SingletonPredictionContext} + * @param b the second {@link SingletonPredictionContext} + * @param rootIsWildcard {@code true} if this is a local-context merge, + * otherwise false to indicate a full-context merge + * @param mergeCache + */ +function mergeSingletons(a, b, rootIsWildcard, mergeCache) { + if (mergeCache !== null) { + let previous = mergeCache.get(a, b); + if (previous !== null) { + return previous; + } + previous = mergeCache.get(b, a); + if (previous !== null) { + return previous; + } + } + + const rootMerge = mergeRoot(a, b, rootIsWildcard); + if (rootMerge !== null) { + if (mergeCache !== null) { + mergeCache.set(a, b, rootMerge); + } + return rootMerge; + } + if (a.returnState === b.returnState) { + const parent = merge(a.parentCtx, b.parentCtx, rootIsWildcard, mergeCache); + // if parent is same as existing a or b parent or reduced to a parent, + // return it + if (parent === a.parentCtx) { + return a; // ax + bx = ax, if a=b + } + if (parent === b.parentCtx) { + return b; // ax + bx = bx, if a=b + } + // else: ax + ay = a'[x,y] + // merge parents x and y, giving array node with x,y then remainders + // of those graphs. dup a, a' points at merged array + // new joined parent so create new singleton pointing to it, a' + const spc = SingletonPredictionContext.create(parent, a.returnState); + if (mergeCache !== null) { + mergeCache.set(a, b, spc); + } + return spc; + } else { // a != b payloads differ + // see if we can collapse parents due to $+x parents if local ctx + let singleParent = null; + if (a === b || (a.parentCtx !== null && a.parentCtx === b.parentCtx)) { // ax + + // bx = + // [a,b]x + singleParent = a.parentCtx; + } + if (singleParent !== null) { // parents are same + // sort payloads and use same parent + const payloads = [ a.returnState, b.returnState ]; + if (a.returnState > b.returnState) { + payloads[0] = b.returnState; + payloads[1] = a.returnState; + } + const parents = [ singleParent, singleParent ]; + const apc = new ArrayPredictionContext(parents, payloads); + if (mergeCache !== null) { + mergeCache.set(a, b, apc); + } + return apc; + } + // parents differ and can't merge them. Just pack together + // into array; can't merge. + // ax + by = [ax,by] + const payloads = [ a.returnState, b.returnState ]; + let parents = [ a.parentCtx, b.parentCtx ]; + if (a.returnState > b.returnState) { // sort by payload + payloads[0] = b.returnState; + payloads[1] = a.returnState; + parents = [ b.parentCtx, a.parentCtx ]; + } + const a_ = new ArrayPredictionContext(parents, payloads); + if (mergeCache !== null) { + mergeCache.set(a, b, a_); + } + return a_; + } +} + + +/** + * Handle case where at least one of {@code a} or {@code b} is + * {@link //EMPTY}. In the following diagrams, the symbol {@code $} is used + * to represent {@link //EMPTY}. + * + *

          Local-Context Merges

          + * + *

          These local-context merge operations are used when {@code rootIsWildcard} + * is true.

          + * + *

          {@link //EMPTY} is superset of any graph; return {@link //EMPTY}.
          + *

          + * + *

          {@link //EMPTY} and anything is {@code //EMPTY}, so merged parent is + * {@code //EMPTY}; return left graph.
          + *

          + * + *

          Special case of last merge if local context.
          + *

          + * + *

          Full-Context Merges

          + * + *

          These full-context merge operations are used when {@code rootIsWildcard} + * is false.

          + * + *

          + * + *

          Must keep all contexts; {@link //EMPTY} in array is a special value (and + * null parent).
          + *

          + * + *

          + * + * @param a the first {@link SingletonPredictionContext} + * @param b the second {@link SingletonPredictionContext} + * @param rootIsWildcard {@code true} if this is a local-context merge, + * otherwise false to indicate a full-context merge + */ +function mergeRoot(a, b, rootIsWildcard) { + if (rootIsWildcard) { + if (a === PredictionContext.EMPTY) { + return PredictionContext.EMPTY; // // + b =// + } + if (b === PredictionContext.EMPTY) { + return PredictionContext.EMPTY; // a +// =// + } + } else { + if (a === PredictionContext.EMPTY && b === PredictionContext.EMPTY) { + return PredictionContext.EMPTY; // $ + $ = $ + } else if (a === PredictionContext.EMPTY) { // $ + x = [$,x] + const payloads = [ b.returnState, + PredictionContext.EMPTY_RETURN_STATE ]; + const parents = [ b.parentCtx, null ]; + return new ArrayPredictionContext(parents, payloads); + } else if (b === PredictionContext.EMPTY) { // x + $ = [$,x] ($ is always first if present) + const payloads = [ a.returnState, PredictionContext.EMPTY_RETURN_STATE ]; + const parents = [ a.parentCtx, null ]; + return new ArrayPredictionContext(parents, payloads); + } + } + return null; +} + + +// ter's recursive version of Sam's getAllNodes() +function getAllContextNodes(context, nodes, visited) { + if (nodes === null) { + nodes = []; + return getAllContextNodes(context, nodes, visited); + } else if (visited === null) { + visited = new HashMap(); + return getAllContextNodes(context, nodes, visited); + } else { + if (context === null || visited.containsKey(context)) { + return nodes; + } + visited.set(context, context); + nodes.push(context); + for (let i = 0; i < context.length; i++) { + getAllContextNodes(context.getParent(i), nodes, visited); + } + return nodes; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/BitSet.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class BitSet { + + constructor() { + this.data = []; + } + + add(value) { + this.data[value] = true; + } + + or(set) { + Object.keys(set.data).map(alt => this.add(alt), this); + } + + remove(value) { + delete this.data[value]; + } + + has(value) { + return this.data[value] === true; + } + + values() { + return Object.keys(this.data); + } + + minValue() { + return Math.min.apply(null, this.values()); + } + + hashCode() { + return HashCode.hashStuff(this.values()); + } + + equals(other) { + return other instanceof BitSet && equalArrays(this.data, other.data); + } + + toString() { + return "{" + this.values().join(", ") + "}"; + } + + get length(){ + return this.values().length; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LL1Analyzer.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + + + + + + + +class LL1Analyzer { + constructor(atn) { + this.atn = atn; + } + + /** + * Calculates the SLL(1) expected lookahead set for each outgoing transition + * of an {@link ATNState}. The returned array has one element for each + * outgoing transition in {@code s}. If the closure from transition + * i leads to a semantic predicate before matching a symbol, the + * element at index i of the result will be {@code null}. + * + * @param s the ATN state + * @return the expected symbols for each outgoing transition of {@code s}. + */ + getDecisionLookahead(s) { + if (s === null) { + return null; + } + const count = s.transitions.length; + const look = []; + for(let alt=0; alt< count; alt++) { + look[alt] = new IntervalSet(); + const lookBusy = new HashSet(); + const seeThruPreds = false; // fail to get lookahead upon pred + this._LOOK(s.transition(alt).target, null, PredictionContext.EMPTY, + look[alt], lookBusy, new BitSet(), seeThruPreds, false); + // Wipe out lookahead for this alternative if we found nothing + // or we had a predicate when we !seeThruPreds + if (look[alt].length===0 || look[alt].contains(LL1Analyzer.HIT_PRED)) { + look[alt] = null; + } + } + return look; + } + + /** + * Compute set of tokens that can follow {@code s} in the ATN in the + * specified {@code ctx}. + * + *

          If {@code ctx} is {@code null} and the end of the rule containing + * {@code s} is reached, {@link Token//EPSILON} is added to the result set. + * If {@code ctx} is not {@code null} and the end of the outermost rule is + * reached, {@link Token//EOF} is added to the result set.

          + * + * @param s the ATN state + * @param stopState the ATN state to stop at. This can be a + * {@link BlockEndState} to detect epsilon paths through a closure. + * @param ctx the complete parser context, or {@code null} if the context + * should be ignored + * + * @return The set of tokens that can follow {@code s} in the ATN in the + * specified {@code ctx}. + */ + LOOK(s, stopState, ctx) { + const r = new IntervalSet(); + const seeThruPreds = true; // ignore preds; get all lookahead + ctx = ctx || null; + const lookContext = ctx!==null ? predictionContextFromRuleContext(s.atn, ctx) : null; + this._LOOK(s, stopState, lookContext, r, new HashSet(), new BitSet(), seeThruPreds, true); + return r; + } + + /** + * Compute set of tokens that can follow {@code s} in the ATN in the + * specified {@code ctx}. + * + *

          If {@code ctx} is {@code null} and {@code stopState} or the end of the + * rule containing {@code s} is reached, {@link Token//EPSILON} is added to + * the result set. If {@code ctx} is not {@code null} and {@code addEOF} is + * {@code true} and {@code stopState} or the end of the outermost rule is + * reached, {@link Token//EOF} is added to the result set.

          + * + * @param s the ATN state. + * @param stopState the ATN state to stop at. This can be a + * {@link BlockEndState} to detect epsilon paths through a closure. + * @param ctx The outer context, or {@code null} if the outer context should + * not be used. + * @param look The result lookahead set. + * @param lookBusy A set used for preventing epsilon closures in the ATN + * from causing a stack overflow. Outside code should pass + * {@code new CustomizedSet} for this argument. + * @param calledRuleStack A set used for preventing left recursion in the + * ATN from causing a stack overflow. Outside code should pass + * {@code new BitSet()} for this argument. + * @param seeThruPreds {@code true} to true semantic predicates as + * implicitly {@code true} and "see through them", otherwise {@code false} + * to treat semantic predicates as opaque and add {@link //HIT_PRED} to the + * result if one is encountered. + * @param addEOF Add {@link Token//EOF} to the result if the end of the + * outermost context is reached. This parameter has no effect if {@code ctx} + * is {@code null}. + */ + _LOOK(s, stopState , ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) { + const c = new ATNConfig({state:s, alt:0, context: ctx}, null); + if (lookBusy.has(c)) { + return; + } + lookBusy.add(c); + if (s === stopState) { + if (ctx ===null) { + look.addOne(Token.EPSILON); + return; + } else if (ctx.isEmpty() && addEOF) { + look.addOne(Token.EOF); + return; + } + } + if (s instanceof RuleStopState ) { + if (ctx ===null) { + look.addOne(Token.EPSILON); + return; + } else if (ctx.isEmpty() && addEOF) { + look.addOne(Token.EOF); + return; + } + if (ctx !== PredictionContext.EMPTY) { + const removed = calledRuleStack.has(s.ruleIndex); + try { + calledRuleStack.remove(s.ruleIndex); + // run thru all possible stack tops in ctx + for (let i = 0; i < ctx.length; i++) { + const returnState = this.atn.states[ctx.getReturnState(i)]; + this._LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF); + } + }finally { + if (removed) { + calledRuleStack.add(s.ruleIndex); + } + } + return; + } + } + for(let j=0; jIf {@code context} is {@code null}, it is treated as + * {@link ParserRuleContext//EMPTY}.

          + * + * @param stateNumber the ATN state number + * @param ctx the full parse context + * + * @return {IntervalSet} The set of potentially valid input symbols which could follow the + * specified state in the specified context. + * + * @throws IllegalArgumentException if the ATN does not contain a state with + * number {@code stateNumber} + */ + getExpectedTokens(stateNumber, ctx ) { + if ( stateNumber < 0 || stateNumber >= this.states.length ) { + throw("Invalid state number."); + } + const s = this.states[stateNumber]; + let following = this.nextTokens(s); + if (!following.contains(Token.EPSILON)) { + return following; + } + const expected = new IntervalSet(); + expected.addSet(following); + expected.removeOne(Token.EPSILON); + while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) { + const invokingState = this.states[ctx.invokingState]; + const rt = invokingState.transitions[0]; + following = this.nextTokens(rt.followState); + expected.addSet(following); + expected.removeOne(Token.EPSILON); + ctx = ctx.parentCtx; + } + if (following.contains(Token.EPSILON)) { + expected.addOne(Token.EOF); + } + return expected; + } +} + +ATN.INVALID_ALT_NUMBER = 0; + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNType.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +/** + * Represents the type of recognizer an ATN applies to + */ +/* harmony default export */ const ATNType = ({ + LEXER: 0, + PARSER: 1 +}); + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BasicState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class BasicState extends ATNState { + constructor() { + super(); + this.stateType = ATNState.BASIC; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/DecisionState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class DecisionState extends ATNState { + constructor() { + super(); + this.decision = -1; + this.nonGreedy = false; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BlockStartState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/** + * The start of a regular {@code (...)} block + */ +class BlockStartState extends DecisionState { + constructor() { + super(); + this.endState = null; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BlockEndState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/** + * Terminal node of a simple {@code (a|b|c)} block + */ +class BlockEndState extends ATNState { + constructor() { + super(); + this.stateType = ATNState.BLOCK_END; + this.startState = null; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/LoopEndState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/** + * Mark the end of a * or + loop + */ +class LoopEndState extends ATNState { + constructor() { + super(); + this.stateType = ATNState.LOOP_END; + this.loopBackState = null; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/RuleStartState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class RuleStartState extends ATNState { + constructor() { + super(); + this.stateType = ATNState.RULE_START; + this.stopState = null; + this.isPrecedenceRule = false; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/TokensStartState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * The Tokens rule start state linking to each lexer rule start state + */ +class TokensStartState extends DecisionState { + constructor() { + super(); + this.stateType = ATNState.TOKEN_START; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/PlusLoopbackState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: + * one to the loop back to start of the block and one to exit. + */ +class PlusLoopbackState extends DecisionState { + constructor() { + super(); + this.stateType = ATNState.PLUS_LOOP_BACK; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/StarLoopbackState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class StarLoopbackState extends ATNState { + constructor() { + super(); + this.stateType = ATNState.STAR_LOOP_BACK; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/StarLoopEntryState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class StarLoopEntryState extends DecisionState { + constructor() { + super(); + this.stateType = ATNState.STAR_LOOP_ENTRY; + this.loopBackState = null; + // Indicates whether this state can benefit from a precedence DFA during SLL decision making. + this.isPrecedenceDecision = null; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/PlusBlockStartState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Start of {@code (A|B|...)+} loop. Technically a decision state, but + * we don't use for code generation; somebody might need it, so I'm defining + * it for completeness. In reality, the {@link PlusLoopbackState} node is the + * real decision-making note for {@code A+} + */ +class PlusBlockStartState extends BlockStartState { + constructor() { + super(); + this.stateType = ATNState.PLUS_BLOCK_START; + this.loopBackState = null; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/StarBlockStartState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * The block that begins a closure loop + */ +class StarBlockStartState extends BlockStartState { + constructor() { + super(); + this.stateType = ATNState.STAR_BLOCK_START; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/state/BasicBlockStartState.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class BasicBlockStartState extends BlockStartState { + constructor() { + super(); + this.stateType = ATNState.BLOCK_START; + return this; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/AtomTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class AtomTransition extends Transition { + constructor(target, label) { + super(target); + // The token type or character value; or, signifies special label. + this.label_ = label; + this.label = this.makeLabel(); + this.serializationType = Transition.ATOM; + } + + makeLabel() { + const s = new IntervalSet(); + s.addOne(this.label_); + return s; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return this.label_ === symbol; + } + + toString() { + return this.label_; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/RangeTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class RangeTransition extends Transition { + constructor(target, start, stop) { + super(target); + this.serializationType = Transition.RANGE; + this.start = start; + this.stop = stop; + this.label = this.makeLabel(); + } + + makeLabel() { + const s = new IntervalSet(); + s.addRange(this.start, this.stop); + return s; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return symbol >= this.start && symbol <= this.stop; + } + + toString() { + return "'" + String.fromCharCode(this.start) + "'..'" + String.fromCharCode(this.stop) + "'"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/ActionTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class ActionTransition extends Transition { + constructor(target, ruleIndex, actionIndex, isCtxDependent) { + super(target); + this.serializationType = Transition.ACTION; + this.ruleIndex = ruleIndex; + this.actionIndex = actionIndex===undefined ? -1 : actionIndex; + this.isCtxDependent = isCtxDependent===undefined ? false : isCtxDependent; // e.g., $i ref in pred + this.isEpsilon = true; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return false; + } + + toString() { + return "action_" + this.ruleIndex + ":" + this.actionIndex; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/EpsilonTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class EpsilonTransition extends Transition { + constructor(target, outermostPrecedenceReturn) { + super(target); + this.serializationType = Transition.EPSILON; + this.isEpsilon = true; + this.outermostPrecedenceReturn = outermostPrecedenceReturn; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return false; + } + + toString() { + return "epsilon"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/Predicate.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class Predicate extends SemanticContext { + + constructor(ruleIndex, predIndex, isCtxDependent) { + super(); + this.ruleIndex = ruleIndex === undefined ? -1 : ruleIndex; + this.predIndex = predIndex === undefined ? -1 : predIndex; + this.isCtxDependent = isCtxDependent === undefined ? false : isCtxDependent; // e.g., $i ref in pred + } + + evaluate(parser, outerContext) { + const localctx = this.isCtxDependent ? outerContext : null; + return parser.sempred(localctx, this.ruleIndex, this.predIndex); + } + + updateHashCode(hash) { + hash.update(this.ruleIndex, this.predIndex, this.isCtxDependent); + } + + equals(other) { + if (this === other) { + return true; + } else if (!(other instanceof Predicate)) { + return false; + } else { + return this.ruleIndex === other.ruleIndex && + this.predIndex === other.predIndex && + this.isCtxDependent === other.isCtxDependent; + } + } + + toString() { + return "{" + this.ruleIndex + ":" + this.predIndex + "}?"; + } +} + +/** + * The default {@link SemanticContext}, which is semantically equivalent to + * a predicate of the form {@code {true}?} + */ +SemanticContext.NONE = new Predicate(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/PredicateTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +class PredicateTransition extends AbstractPredicateTransition { + constructor(target, ruleIndex, predIndex, isCtxDependent) { + super(target); + this.serializationType = Transition.PREDICATE; + this.ruleIndex = ruleIndex; + this.predIndex = predIndex; + this.isCtxDependent = isCtxDependent; // e.g., $i ref in pred + this.isEpsilon = true; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return false; + } + + getPredicate() { + return new Predicate(this.ruleIndex, this.predIndex, this.isCtxDependent); + } + + toString() { + return "pred_" + this.ruleIndex + ":" + this.predIndex; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/PrecedencePredicate.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class PrecedencePredicate extends SemanticContext { + + constructor(precedence) { + super(); + this.precedence = precedence === undefined ? 0 : precedence; + } + + evaluate(parser, outerContext) { + return parser.precpred(outerContext, this.precedence); + } + + evalPrecedence(parser, outerContext) { + if (parser.precpred(outerContext, this.precedence)) { + return SemanticContext.NONE; + } else { + return null; + } + } + + compareTo(other) { + return this.precedence - other.precedence; + } + + updateHashCode(hash) { + hash.update(this.precedence); + } + + equals(other) { + if (this === other) { + return true; + } else if (!(other instanceof PrecedencePredicate)) { + return false; + } else { + return this.precedence === other.precedence; + } + } + + toString() { + return "{" + this.precedence + ">=prec}?"; + } + +} + +// HORRIBLE workaround circular import, avoiding dynamic import +SemanticContext.PrecedencePredicate = PrecedencePredicate; + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/transition/PrecedencePredicateTransition.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +class PrecedencePredicateTransition extends AbstractPredicateTransition { + constructor(target, precedence) { + super(target); + this.serializationType = Transition.PRECEDENCE; + this.precedence = precedence; + this.isEpsilon = true; + } + + matches(symbol, minVocabSymbol, maxVocabSymbol) { + return false; + } + + getPredicate() { + return new PrecedencePredicate(this.precedence); + } + + toString() { + return this.precedence + " >= _p"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNDeserializationOptions.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +class ATNDeserializationOptions { + constructor(copyFrom) { + if(copyFrom===undefined) { + copyFrom = null; + } + this.readOnly = false; + this.verifyATN = copyFrom===null ? true : copyFrom.verifyATN; + this.generateRuleBypassTransitions = copyFrom===null ? false : copyFrom.generateRuleBypassTransitions; + } +} + +ATNDeserializationOptions.defaultOptions = new ATNDeserializationOptions(); +ATNDeserializationOptions.defaultOptions.readOnly = true; + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerActionType.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/* harmony default export */ const LexerActionType = ({ + // The type of a {@link LexerChannelAction} action. + CHANNEL: 0, + // The type of a {@link LexerCustomAction} action + CUSTOM: 1, + // The type of a {@link LexerModeAction} action. + MODE: 2, + //The type of a {@link LexerMoreAction} action. + MORE: 3, + //The type of a {@link LexerPopModeAction} action. + POP_MODE: 4, + //The type of a {@link LexerPushModeAction} action. + PUSH_MODE: 5, + //The type of a {@link LexerSkipAction} action. + SKIP: 6, + //The type of a {@link LexerTypeAction} action. + TYPE: 7 +}); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class LexerAction { + constructor(action) { + this.actionType = action; + this.isPositionDependent = false; + } + + hashCode() { + const hash = new HashCode(); + this.updateHashCode(hash); + return hash.finish() + } + + updateHashCode(hash) { + hash.update(this.actionType); + } + + equals(other) { + return this === other; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerSkipAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code skip} lexer action by calling {@link Lexer//skip}. + * + *

          The {@code skip} command does not have any parameters, so this action is + * implemented as a singleton instance exposed by {@link //INSTANCE}.

          + */ +class LexerSkipAction extends LexerAction { + constructor() { + super(LexerActionType.SKIP); + } + + execute(lexer) { + lexer.skip(); + } + + toString() { + return "skip"; + } +} + +// Provides a singleton instance of this parameterless lexer action. +LexerSkipAction.INSTANCE = new LexerSkipAction(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerChannelAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code channel} lexer action by calling + * {@link Lexer//setChannel} with the assigned channel. + * Constructs a new {@code channel} action with the specified channel value. + * @param channel The channel value to pass to {@link Lexer//setChannel} + */ +class LexerChannelAction extends LexerAction { + constructor(channel) { + super(LexerActionType.CHANNEL); + this.channel = channel; + } + + /** + *

          This action is implemented by calling {@link Lexer//setChannel} with the + * value provided by {@link //getChannel}.

          + */ + execute(lexer) { + lexer._channel = this.channel; + } + + updateHashCode(hash) { + hash.update(this.actionType, this.channel); + } + + equals(other) { + if (this === other) { + return true; + } else if (! (other instanceof LexerChannelAction)) { + return false; + } else { + return this.channel === other.channel; + } + } + + toString() { + return "channel(" + this.channel + ")"; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerCustomAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Executes a custom lexer action by calling {@link Recognizer//action} with the + * rule and action indexes assigned to the custom action. The implementation of + * a custom action is added to the generated code for the lexer in an override + * of {@link Recognizer//action} when the grammar is compiled. + * + *

          This class may represent embedded actions created with the {...} + * syntax in ANTLR 4, as well as actions created for lexer commands where the + * command argument could not be evaluated when the grammar was compiled.

          + */ +class LexerCustomAction extends LexerAction { + /** + * Constructs a custom lexer action with the specified rule and action + * indexes. + * + * @param ruleIndex The rule index to use for calls to + * {@link Recognizer//action}. + * @param actionIndex The action index to use for calls to + * {@link Recognizer//action}. + */ + constructor(ruleIndex, actionIndex) { + super(LexerActionType.CUSTOM); + this.ruleIndex = ruleIndex; + this.actionIndex = actionIndex; + this.isPositionDependent = true; + } + + /** + *

          Custom actions are implemented by calling {@link Lexer//action} with the + * appropriate rule and action indexes.

          + */ + execute(lexer) { + lexer.action(null, this.ruleIndex, this.actionIndex); + } + + updateHashCode(hash) { + hash.update(this.actionType, this.ruleIndex, this.actionIndex); + } + + equals(other) { + if (this === other) { + return true; + } else if (! (other instanceof LexerCustomAction)) { + return false; + } else { + return this.ruleIndex === other.ruleIndex && this.actionIndex === other.actionIndex; + } + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerMoreAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code more} lexer action by calling {@link Lexer//more}. + * + *

          The {@code more} command does not have any parameters, so this action is + * implemented as a singleton instance exposed by {@link //INSTANCE}.

          + */ +class LexerMoreAction extends LexerAction { + constructor() { + super(LexerActionType.MORE); + } + + /** + *

          This action is implemented by calling {@link Lexer//popMode}.

          + */ + execute(lexer) { + lexer.more(); + } + + toString() { + return "more"; + } +} + +LexerMoreAction.INSTANCE = new LexerMoreAction(); + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerTypeAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code type} lexer action by calling {@link Lexer//setType} + * with the assigned type + */ + +class LexerTypeAction extends LexerAction { + constructor(type) { + super(LexerActionType.TYPE); + this.type = type; + } + + execute(lexer) { + lexer.type = this.type; + } + + updateHashCode(hash) { + hash.update(this.actionType, this.type); + } + + equals(other) { + if(this === other) { + return true; + } else if (! (other instanceof LexerTypeAction)) { + return false; + } else { + return this.type === other.type; + } + } + + toString() { + return "type(" + this.type + ")"; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerPushModeAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code pushMode} lexer action by calling + * {@link Lexer//pushMode} with the assigned mode + */ +class LexerPushModeAction extends LexerAction { + constructor(mode) { + super(LexerActionType.PUSH_MODE); + this.mode = mode; + } + + /** + *

          This action is implemented by calling {@link Lexer//pushMode} with the + * value provided by {@link //getMode}.

          + */ + execute(lexer) { + lexer.pushMode(this.mode); + } + + updateHashCode(hash) { + hash.update(this.actionType, this.mode); + } + + equals(other) { + if (this === other) { + return true; + } else if (! (other instanceof LexerPushModeAction)) { + return false; + } else { + return this.mode === other.mode; + } + } + + toString() { + return "pushMode(" + this.mode + ")"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerPopModeAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code popMode} lexer action by calling {@link Lexer//popMode}. + * + *

          The {@code popMode} command does not have any parameters, so this action is + * implemented as a singleton instance exposed by {@link //INSTANCE}.

          + */ +class LexerPopModeAction extends LexerAction { + constructor() { + super(LexerActionType.POP_MODE); + } + + /** + *

          This action is implemented by calling {@link Lexer//popMode}.

          + */ + execute(lexer) { + lexer.popMode(); + } + + toString() { + return "popMode"; + } +} + +LexerPopModeAction.INSTANCE = new LexerPopModeAction(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerModeAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Implements the {@code mode} lexer action by calling {@link Lexer//mode} with + * the assigned mode + */ +class LexerModeAction extends LexerAction { + constructor(mode) { + super(LexerActionType.MODE); + this.mode = mode; + } + + /** + *

          This action is implemented by calling {@link Lexer//mode} with the + * value provided by {@link //getMode}.

          + */ + execute(lexer) { + lexer.mode(this.mode); + } + + updateHashCode(hash) { + hash.update(this.actionType, this.mode); + } + + equals(other) { + if (this === other) { + return true; + } else if (! (other instanceof LexerModeAction)) { + return false; + } else { + return this.mode === other.mode; + } + } + + toString() { + return "mode(" + this.mode + ")"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNDeserializer.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +const SERIALIZED_VERSION = 4; + +function initArray( length, value) { + const tmp = []; + tmp[length-1] = value; + return tmp.map(function(i) {return value;}); +} + +class ATNDeserializer { + constructor(options) { + + if ( options=== undefined || options === null ) { + options = ATNDeserializationOptions.defaultOptions; + } + this.deserializationOptions = options; + this.stateFactories = null; + this.actionFactories = null; + } + + deserialize(data) { + const legacy = this.reset(data); + this.checkVersion(legacy); + if(legacy) + this.skipUUID(); + const atn = this.readATN(); + this.readStates(atn, legacy); + this.readRules(atn, legacy); + this.readModes(atn); + const sets = []; + this.readSets(atn, sets, this.readInt.bind(this)); + if(legacy) + this.readSets(atn, sets, this.readInt32.bind(this)); + this.readEdges(atn, sets); + this.readDecisions(atn); + this.readLexerActions(atn, legacy); + this.markPrecedenceDecisions(atn); + this.verifyATN(atn); + if (this.deserializationOptions.generateRuleBypassTransitions && atn.grammarType === ATNType.PARSER ) { + this.generateRuleBypassTransitions(atn); + // re-verify after modification + this.verifyATN(atn); + } + return atn; + } + + reset(data) { + const version = data.charCodeAt ? data.charCodeAt(0) : data[0]; + if(version === SERIALIZED_VERSION - 1) { + const adjust = function (c) { + const v = c.charCodeAt(0); + return v > 1 ? v - 2 : v + 65534; + }; + const temp = data.split("").map(adjust); + // don't adjust the first value since that's the version number + temp[0] = data.charCodeAt(0); + this.data = temp; + this.pos = 0; + return true; + } else { + this.data = data + this.pos = 0; + return false; + } + } + + skipUUID() { + let count = 0; + while(count++ < 8) + this.readInt(); + } + + checkVersion(legacy) { + const version = this.readInt(); + if ( !legacy && version !== SERIALIZED_VERSION ) { + throw ("Could not deserialize ATN with version " + version + " (expected " + SERIALIZED_VERSION + ")."); + } + } + + readATN() { + const grammarType = this.readInt(); + const maxTokenType = this.readInt(); + return new ATN(grammarType, maxTokenType); + } + + readStates(atn, legacy) { + let j, pair, stateNumber; + const loopBackStateNumbers = []; + const endStateNumbers = []; + const nstates = this.readInt(); + for(let i=0; i 0) { + bypassStart.addTransition(ruleToStartState.transitions[count-1]); + ruleToStartState.transitions = ruleToStartState.transitions.slice(-1); + } + // link the new states + atn.ruleToStartState[idx].addTransition(new EpsilonTransition(bypassStart)); + bypassStop.addTransition(new EpsilonTransition(endState)); + + const matchState = new BasicState(); + atn.addState(matchState); + matchState.addTransition(new AtomTransition(bypassStop, atn.ruleToTokenType[idx])); + bypassStart.addTransition(new EpsilonTransition(matchState)); + } + + stateIsEndStateFor(state, idx) { + if ( state.ruleIndex !== idx) { + return null; + } + if (!( state instanceof StarLoopEntryState)) { + return null; + } + const maybeLoopEndState = state.transitions[state.transitions.length - 1].target; + if (!( maybeLoopEndState instanceof LoopEndState)) { + return null; + } + if (maybeLoopEndState.epsilonOnlyTransitions && + (maybeLoopEndState.transitions[0].target instanceof RuleStopState)) { + return state; + } else { + return null; + } + } + + /** + * Analyze the {@link StarLoopEntryState} states in the specified ATN to set + * the {@link StarLoopEntryState//isPrecedenceDecision} field to the + * correct value. + * @param atn The ATN. + */ + markPrecedenceDecisions(atn) { + for(let i=0; i= 0); + } else { + this.checkCondition(state.transitions.length <= 1 || (state instanceof RuleStopState)); + } + } + } + + checkCondition(condition, message) { + if (!condition) { + if (message === undefined || message===null) { + message = "IllegalState"; + } + throw (message); + } + } + + readInt() { + return this.data[this.pos++]; + } + + readInt32() { + const low = this.readInt(); + const high = this.readInt(); + return low | (high << 16); + } + + edgeFactory(atn, type, src, trg, arg1, arg2, arg3, sets) { + const target = atn.states[trg]; + switch(type) { + case Transition.EPSILON: + return new EpsilonTransition(target); + case Transition.RANGE: + return arg3 !== 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2); + case Transition.RULE: + return new RuleTransition(atn.states[arg1], arg2, arg3, target); + case Transition.PREDICATE: + return new PredicateTransition(target, arg1, arg2, arg3 !== 0); + case Transition.PRECEDENCE: + return new PrecedencePredicateTransition(target, arg1); + case Transition.ATOM: + return arg3 !== 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1); + case Transition.ACTION: + return new ActionTransition(target, arg1, arg2, arg3 !== 0); + case Transition.SET: + return new SetTransition(target, sets[arg1]); + case Transition.NOT_SET: + return new NotSetTransition(target, sets[arg1]); + case Transition.WILDCARD: + return new WildcardTransition(target); + default: + throw "The specified transition type: " + type + " is not valid."; + } + } + + stateFactory(type, ruleIndex) { + if (this.stateFactories === null) { + const sf = []; + sf[ATNState.INVALID_TYPE] = null; + sf[ATNState.BASIC] = () => new BasicState(); + sf[ATNState.RULE_START] = () => new RuleStartState(); + sf[ATNState.BLOCK_START] = () => new BasicBlockStartState(); + sf[ATNState.PLUS_BLOCK_START] = () => new PlusBlockStartState(); + sf[ATNState.STAR_BLOCK_START] = () => new StarBlockStartState(); + sf[ATNState.TOKEN_START] = () => new TokensStartState(); + sf[ATNState.RULE_STOP] = () => new RuleStopState(); + sf[ATNState.BLOCK_END] = () => new BlockEndState(); + sf[ATNState.STAR_LOOP_BACK] = () => new StarLoopbackState(); + sf[ATNState.STAR_LOOP_ENTRY] = () => new StarLoopEntryState(); + sf[ATNState.PLUS_LOOP_BACK] = () => new PlusLoopbackState(); + sf[ATNState.LOOP_END] = () => new LoopEndState(); + this.stateFactories = sf; + } + if (type>this.stateFactories.length || this.stateFactories[type] === null) { + throw("The specified state type " + type + " is not valid."); + } else { + const s = this.stateFactories[type](); + if (s!==null) { + s.ruleIndex = ruleIndex; + return s; + } + } + } + + lexerActionFactory(type, data1, data2) { + if (this.actionFactories === null) { + const af = []; + af[LexerActionType.CHANNEL] = (data1, data2) => new LexerChannelAction(data1); + af[LexerActionType.CUSTOM] = (data1, data2) => new LexerCustomAction(data1, data2); + af[LexerActionType.MODE] = (data1, data2) => new LexerModeAction(data1); + af[LexerActionType.MORE] = (data1, data2) => LexerMoreAction.INSTANCE; + af[LexerActionType.POP_MODE] = (data1, data2) => LexerPopModeAction.INSTANCE; + af[LexerActionType.PUSH_MODE] = (data1, data2) => new LexerPushModeAction(data1); + af[LexerActionType.SKIP] = (data1, data2) => LexerSkipAction.INSTANCE; + af[LexerActionType.TYPE] = (data1, data2) => new LexerTypeAction(data1); + this.actionFactories = af; + } + if (type>this.actionFactories.length || this.actionFactories[type] === null) { + throw("The specified lexer action type " + type + " is not valid."); + } else { + return this.actionFactories[type](data1, data2); + } + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNConfigSet.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + +function hashATNConfig(c) { + return c.hashCodeForConfigSet(); +} + +function equalATNConfigs(a, b) { + if ( a===b ) { + return true; + } else if ( a===null || b===null ) { + return false; + } else + return a.equalsForConfigSet(b); + } + +/** + * Specialized {@link Set}{@code <}{@link ATNConfig}{@code >} that can track + * info about the set, with support for combining similar configurations using a + * graph-structured stack + */ +class ATNConfigSet { + constructor(fullCtx) { + /** + * The reason that we need this is because we don't want the hash map to use + * the standard hash code and equals. We need all configurations with the + * same + * {@code (s,i,_,semctx)} to be equal. Unfortunately, this key effectively + * doubles + * the number of objects associated with ATNConfigs. The other solution is + * to + * use a hash table that lets us specify the equals/hashcode operation. + * All configs but hashed by (s, i, _, pi) not including context. Wiped out + * when we go readonly as this set becomes a DFA state + */ + this.configLookup = new HashSet(hashATNConfig, equalATNConfigs); + /** + * Indicates that this configuration set is part of a full context + * LL prediction. It will be used to determine how to merge $. With SLL + * it's a wildcard whereas it is not for LL context merge + */ + this.fullCtx = fullCtx === undefined ? true : fullCtx; + /** + * Indicates that the set of configurations is read-only. Do not + * allow any code to manipulate the set; DFA states will point at + * the sets and they must not change. This does not protect the other + * fields; in particular, conflictingAlts is set after + * we've made this readonly + */ + this.readOnly = false; + // Track the elements as they are added to the set; supports get(i)/// + this.configs = []; + + // TODO: these fields make me pretty uncomfortable but nice to pack up info + // together, saves recomputation + // TODO: can we track conflicts as they are added to save scanning configs + // later? + this.uniqueAlt = 0; + this.conflictingAlts = null; + + /** + * Used in parser and lexer. In lexer, it indicates we hit a pred + * while computing a closure operation. Don't make a DFA state from this + */ + this.hasSemanticContext = false; + this.dipsIntoOuterContext = false; + + this.cachedHashCode = -1; + } + + /** + * Adding a new config means merging contexts with existing configs for + * {@code (s, i, pi, _)}, where {@code s} is the + * {@link ATNConfig//state}, {@code i} is the {@link ATNConfig//alt}, and + * {@code pi} is the {@link ATNConfig//semanticContext}. We use + * {@code (s,i,pi)} as key. + * + *

          This method updates {@link //dipsIntoOuterContext} and + * {@link //hasSemanticContext} when necessary.

          + */ + add(config, mergeCache) { + if (mergeCache === undefined) { + mergeCache = null; + } + if (this.readOnly) { + throw "This set is readonly"; + } + if (config.semanticContext !== SemanticContext.NONE) { + this.hasSemanticContext = true; + } + if (config.reachesIntoOuterContext > 0) { + this.dipsIntoOuterContext = true; + } + const existing = this.configLookup.add(config); + if (existing === config) { + this.cachedHashCode = -1; + this.configs.push(config); // track order here + return true; + } + // a previous (s,i,pi,_), merge with it and save result + const rootIsWildcard = !this.fullCtx; + const merged = merge(existing.context, config.context, rootIsWildcard, mergeCache); + /** + * no need to check for existing.context, config.context in cache + * since only way to create new graphs is "call rule" and here. We + * cache at both places + */ + existing.reachesIntoOuterContext = Math.max( existing.reachesIntoOuterContext, config.reachesIntoOuterContext); + // make sure to preserve the precedence filter suppression during the merge + if (config.precedenceFilterSuppressed) { + existing.precedenceFilterSuppressed = true; + } + existing.context = merged; // replace context; no need to alt mapping + return true; + } + + getStates() { + const states = new HashSet(); + for (let i = 0; i < this.configs.length; i++) { + states.add(this.configs[i].state); + } + return states; + } + + getPredicates() { + const preds = []; + for (let i = 0; i < this.configs.length; i++) { + const c = this.configs[i].semanticContext; + if (c !== SemanticContext.NONE) { + preds.push(c.semanticContext); + } + } + return preds; + } + + optimizeConfigs(interpreter) { + if (this.readOnly) { + throw "This set is readonly"; + } + if (this.configLookup.length === 0) { + return; + } + for (let i = 0; i < this.configs.length; i++) { + const config = this.configs[i]; + config.context = interpreter.getCachedContext(config.context); + } + } + + addAll(coll) { + for (let i = 0; i < coll.length; i++) { + this.add(coll[i]); + } + return false; + } + + equals(other) { + return this === other || + (other instanceof ATNConfigSet && + equalArrays(this.configs, other.configs) && + this.fullCtx === other.fullCtx && + this.uniqueAlt === other.uniqueAlt && + this.conflictingAlts === other.conflictingAlts && + this.hasSemanticContext === other.hasSemanticContext && + this.dipsIntoOuterContext === other.dipsIntoOuterContext); + } + + hashCode() { + const hash = new HashCode(); + hash.update(this.configs); + return hash.finish(); + } + + updateHashCode(hash) { + if (this.readOnly) { + if (this.cachedHashCode === -1) { + this.cachedHashCode = this.hashCode(); + } + hash.update(this.cachedHashCode); + } else { + hash.update(this.hashCode()); + } + } + + isEmpty() { + return this.configs.length === 0; + } + + contains(item) { + if (this.configLookup === null) { + throw "This method is not implemented for readonly sets."; + } + return this.configLookup.contains(item); + } + + containsFast(item) { + if (this.configLookup === null) { + throw "This method is not implemented for readonly sets."; + } + return this.configLookup.containsFast(item); + } + + clear() { + if (this.readOnly) { + throw "This set is readonly"; + } + this.configs = []; + this.cachedHashCode = -1; + this.configLookup = new HashSet(); + } + + setReadonly(readOnly) { + this.readOnly = readOnly; + if (readOnly) { + this.configLookup = null; // can't mod, no need for lookup cache + } + } + + toString() { + return arrayToString(this.configs) + + (this.hasSemanticContext ? ",hasSemanticContext=" + this.hasSemanticContext : "") + + (this.uniqueAlt !== ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") + + (this.conflictingAlts !== null ? ",conflictingAlts=" + this.conflictingAlts : "") + + (this.dipsIntoOuterContext ? ",dipsIntoOuterContext" : ""); + } + + get items(){ + return this.configs; + } + + get length(){ + return this.configs.length; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/DFAState.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + +/** + * A DFA state represents a set of possible ATN configurations. + * As Aho, Sethi, Ullman p. 117 says "The DFA uses its state + * to keep track of all possible states the ATN can be in after + * reading each input symbol. That is to say, after reading + * input a1a2..an, the DFA is in a state that represents the + * subset T of the states of the ATN that are reachable from the + * ATN's start state along some path labeled a1a2..an." + * In conventional NFA→DFA conversion, therefore, the subset T + * would be a bitset representing the set of states the + * ATN could be in. We need to track the alt predicted by each + * state as well, however. More importantly, we need to maintain + * a stack of states, tracking the closure operations as they + * jump from rule to rule, emulating rule invocations (method calls). + * I have to add a stack to simulate the proper lookahead sequences for + * the underlying LL grammar from which the ATN was derived. + * + *

          I use a set of ATNConfig objects not simple states. An ATNConfig + * is both a state (ala normal conversion) and a RuleContext describing + * the chain of rules (if any) followed to arrive at that state.

          + * + *

          A DFA state may have multiple references to a particular state, + * but with different ATN contexts (with same or different alts) + * meaning that state was reached via a different set of rule invocations.

          + */ +class DFAState { + constructor(stateNumber, configs) { + if (stateNumber === null) { + stateNumber = -1; + } + if (configs === null) { + configs = new ATNConfigSet(); + } + this.stateNumber = stateNumber; + this.configs = configs; + /** + * {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1) + * {@link Token//EOF} maps to {@code edges[0]}. + */ + this.edges = null; + this.isAcceptState = false; + /** + * if accept state, what ttype do we match or alt do we predict? + * This is set to {@link ATN//INVALID_ALT_NUMBER} when {@link//predicates} + * {@code !=null} or {@link //requiresFullContext}. + */ + this.prediction = 0; + this.lexerActionExecutor = null; + /** + * Indicates that this state was created during SLL prediction that + * discovered a conflict between the configurations in the state. Future + * {@link ParserATNSimulator//execATN} invocations immediately jumped doing + * full context prediction if this field is true. + */ + this.requiresFullContext = false; + /** + * During SLL parsing, this is a list of predicates associated with the + * ATN configurations of the DFA state. When we have predicates, + * {@link //requiresFullContext} is {@code false} since full context + * prediction evaluates predicates + * on-the-fly. If this is not null, then {@link //prediction} is + * {@link ATN//INVALID_ALT_NUMBER}. + * + *

          We only use these for non-{@link //requiresFullContext} but + * conflicting states. That + * means we know from the context (it's $ or we don't dip into outer + * context) that it's an ambiguity not a conflict.

          + * + *

          This list is computed by {@link + * ParserATNSimulator//predicateDFAState}.

          + */ + this.predicates = null; + return this; + } + + /** + * Get the set of all alts mentioned by all ATN configurations in this + * DFA state. + */ + getAltSet() { + const alts = new HashSet(); + if (this.configs !== null) { + for (let i = 0; i < this.configs.length; i++) { + const c = this.configs[i]; + alts.add(c.alt); + } + } + if (alts.length === 0) { + return null; + } else { + return alts; + } + } + + /** + * Two {@link DFAState} instances are equal if their ATN configuration sets + * are the same. This method is used to see if a state already exists. + * + *

          Because the number of alternatives and number of ATN configurations are + * finite, there is a finite number of DFA states that can be processed. + * This is necessary to show that the algorithm terminates.

          + * + *

          Cannot test the DFA state numbers here because in + * {@link ParserATNSimulator//addDFAState} we need to know if any other state + * exists that has this exact set of ATN configurations. The + * {@link //stateNumber} is irrelevant.

          + */ + equals(other) { + // compare set of ATN configurations in this set with other + return this === other || + (other instanceof DFAState && + this.configs.equals(other.configs)); + } + + toString() { + let s = "" + this.stateNumber + ":" + this.configs; + if(this.isAcceptState) { + s = s + "=>"; + if (this.predicates !== null) + s = s + this.predicates; + else + s = s + this.prediction; + } + return s; + } + + hashCode() { + const hash = new HashCode(); + hash.update(this.configs); + return hash.finish(); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/ATNSimulator.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + +class ATNSimulator { + constructor(atn, sharedContextCache) { + /** + * The context cache maps all PredictionContext objects that are == + * to a single cached copy. This cache is shared across all contexts + * in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet + * to use only cached nodes/graphs in addDFAState(). We don't want to + * fill this during closure() since there are lots of contexts that + * pop up but are not used ever again. It also greatly slows down closure(). + * + *

          This cache makes a huge difference in memory and a little bit in speed. + * For the Java grammar on java.*, it dropped the memory requirements + * at the end from 25M to 16M. We don't store any of the full context + * graphs in the DFA because they are limited to local context only, + * but apparently there's a lot of repetition there as well. We optimize + * the config contexts before storing the config set in the DFA states + * by literally rebuilding them with cached subgraphs only.

          + * + *

          I tried a cache for use during closure operations, that was + * whacked after each adaptivePredict(). It cost a little bit + * more time I think and doesn't save on the overall footprint + * so it's not worth the complexity.

          + */ + this.atn = atn; + this.sharedContextCache = sharedContextCache; + return this; + } + + getCachedContext(context) { + if (this.sharedContextCache ===null) { + return context; + } + const visited = new HashMap_HashMap(); + return getCachedPredictionContext(context, this.sharedContextCache, visited); + } +} + +// Must distinguish between missing edge and edge we know leads nowhere/// +ATNSimulator.ERROR = new DFAState(0x7FFFFFFF, new ATNConfigSet()); + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/OrderedATNConfigSet.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class OrderedATNConfigSet extends ATNConfigSet { + constructor() { + super(); + this.configLookup = new HashSet(); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerATNConfig.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class LexerATNConfig extends ATNConfig { + constructor(params, config) { + super(params, config); + + // This is the backing field for {@link //getLexerActionExecutor}. + const lexerActionExecutor = params.lexerActionExecutor || null; + this.lexerActionExecutor = lexerActionExecutor || (config!==null ? config.lexerActionExecutor : null); + this.passedThroughNonGreedyDecision = config!==null ? this.checkNonGreedyDecision(config, this.state) : false; + this.hashCodeForConfigSet = LexerATNConfig.prototype.hashCode; + this.equalsForConfigSet = LexerATNConfig.prototype.equals; + return this; + } + + updateHashCode(hash) { + hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext, this.passedThroughNonGreedyDecision, this.lexerActionExecutor); + } + + equals(other) { + return this === other || + (other instanceof LexerATNConfig && + this.passedThroughNonGreedyDecision === other.passedThroughNonGreedyDecision && + (this.lexerActionExecutor ? this.lexerActionExecutor.equals(other.lexerActionExecutor) : !other.lexerActionExecutor) && + super.equals(other)); + } + + checkNonGreedyDecision(source, target) { + return source.passedThroughNonGreedyDecision || + (target instanceof DecisionState) && target.nonGreedy; + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/action/LexerIndexedCustomAction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/** + * This implementation of {@link LexerAction} is used for tracking input offsets + * for position-dependent actions within a {@link LexerActionExecutor}. + * + *

          This action is not serialized as part of the ATN, and is only required for + * position-dependent lexer actions which appear at a location other than the + * end of a rule. For more information about DFA optimizations employed for + * lexer actions, see {@link LexerActionExecutor//append} and + * {@link LexerActionExecutor//fixOffsetBeforeMatch}.

          + * + * Constructs a new indexed custom action by associating a character offset + * with a {@link LexerAction}. + * + *

          Note: This class is only required for lexer actions for which + * {@link LexerAction//isPositionDependent} returns {@code true}.

          + * + * @param offset The offset into the input {@link CharStream}, relative to + * the token start index, at which the specified lexer action should be + * executed. + * @param action The lexer action to execute at a particular offset in the + * input {@link CharStream}. + */ + + + +class LexerIndexedCustomAction extends LexerAction { + constructor(offset, action) { + super(action.actionType); + this.offset = offset; + this.action = action; + this.isPositionDependent = true; + } + + /** + *

          This method calls {@link //execute} on the result of {@link //getAction} + * using the provided {@code lexer}.

          + */ + execute(lexer) { + // assume the input stream position was properly set by the calling code + this.action.execute(lexer); + } + + updateHashCode(hash) { + hash.update(this.actionType, this.offset, this.action); + } + + equals(other) { + if (this === other) { + return true; + } else if (! (other instanceof LexerIndexedCustomAction)) { + return false; + } else { + return this.offset === other.offset && this.action === other.action; + } + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerActionExecutor.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +class LexerActionExecutor { + /** + * Represents an executor for a sequence of lexer actions which traversed during + * the matching operation of a lexer rule (token). + * + *

          The executor tracks position information for position-dependent lexer actions + * efficiently, ensuring that actions appearing only at the end of the rule do + * not cause bloating of the {@link DFA} created for the lexer.

          + */ + constructor(lexerActions) { + this.lexerActions = lexerActions === null ? [] : lexerActions; + /** + * Caches the result of {@link //hashCode} since the hash code is an element + * of the performance-critical {@link LexerATNConfig//hashCode} operation + */ + this.cachedHashCode = HashCode.hashStuff(lexerActions); // "".join([str(la) for la in + // lexerActions])) + return this; + } + + /** + * Creates a {@link LexerActionExecutor} which encodes the current offset + * for position-dependent lexer actions. + * + *

          Normally, when the executor encounters lexer actions where + * {@link LexerAction//isPositionDependent} returns {@code true}, it calls + * {@link IntStream//seek} on the input {@link CharStream} to set the input + * position to the end of the current token. This behavior provides + * for efficient DFA representation of lexer actions which appear at the end + * of a lexer rule, even when the lexer rule matches a variable number of + * characters.

          + * + *

          Prior to traversing a match transition in the ATN, the current offset + * from the token start index is assigned to all position-dependent lexer + * actions which have not already been assigned a fixed offset. By storing + * the offsets relative to the token start index, the DFA representation of + * lexer actions which appear in the middle of tokens remains efficient due + * to sharing among tokens of the same length, regardless of their absolute + * position in the input stream.

          + * + *

          If the current executor already has offsets assigned to all + * position-dependent lexer actions, the method returns {@code this}.

          + * + * @param offset The current offset to assign to all position-dependent + * lexer actions which do not already have offsets assigned. + * + * @return {LexerActionExecutor} A {@link LexerActionExecutor} which stores input stream offsets + * for all position-dependent lexer actions. + */ + fixOffsetBeforeMatch(offset) { + let updatedLexerActions = null; + for (let i = 0; i < this.lexerActions.length; i++) { + if (this.lexerActions[i].isPositionDependent && + !(this.lexerActions[i] instanceof LexerIndexedCustomAction)) { + if (updatedLexerActions === null) { + updatedLexerActions = this.lexerActions.concat([]); + } + updatedLexerActions[i] = new LexerIndexedCustomAction(offset, + this.lexerActions[i]); + } + } + if (updatedLexerActions === null) { + return this; + } else { + return new LexerActionExecutor(updatedLexerActions); + } + } + + /** + * Execute the actions encapsulated by this executor within the context of a + * particular {@link Lexer}. + * + *

          This method calls {@link IntStream//seek} to set the position of the + * {@code input} {@link CharStream} prior to calling + * {@link LexerAction//execute} on a position-dependent action. Before the + * method returns, the input position will be restored to the same position + * it was in when the method was invoked.

          + * + * @param lexer The lexer instance. + * @param input The input stream which is the source for the current token. + * When this method is called, the current {@link IntStream//index} for + * {@code input} should be the start of the following token, i.e. 1 + * character past the end of the current token. + * @param startIndex The token start index. This value may be passed to + * {@link IntStream//seek} to set the {@code input} position to the beginning + * of the token. + */ + execute(lexer, input, startIndex) { + let requiresSeek = false; + const stopIndex = input.index; + try { + for (let i = 0; i < this.lexerActions.length; i++) { + let lexerAction = this.lexerActions[i]; + if (lexerAction instanceof LexerIndexedCustomAction) { + const offset = lexerAction.offset; + input.seek(startIndex + offset); + lexerAction = lexerAction.action; + requiresSeek = (startIndex + offset) !== stopIndex; + } else if (lexerAction.isPositionDependent) { + input.seek(stopIndex); + requiresSeek = false; + } + lexerAction.execute(lexer); + } + } finally { + if (requiresSeek) { + input.seek(stopIndex); + } + } + } + + hashCode() { + return this.cachedHashCode; + } + + updateHashCode(hash) { + hash.update(this.cachedHashCode); + } + + equals(other) { + if (this === other) { + return true; + } else if (!(other instanceof LexerActionExecutor)) { + return false; + } else if (this.cachedHashCode != other.cachedHashCode) { + return false; + } else if (this.lexerActions.length != other.lexerActions.length) { + return false; + } else { + const numActions = this.lexerActions.length + for (let idx = 0; idx < numActions; ++idx) { + if (!this.lexerActions[idx].equals(other.lexerActions[idx])) { + return false; + } + } + return true; + } + } + + /** + * Creates a {@link LexerActionExecutor} which executes the actions for + * the input {@code lexerActionExecutor} followed by a specified + * {@code lexerAction}. + * + * @param lexerActionExecutor The executor for actions already traversed by + * the lexer while matching a token within a particular + * {@link LexerATNConfig}. If this is {@code null}, the method behaves as + * though it were an empty executor. + * @param lexerAction The lexer action to execute after the actions + * specified in {@code lexerActionExecutor}. + * + * @return {LexerActionExecutor} A {@link LexerActionExecutor} for executing the combine actions + * of {@code lexerActionExecutor} and {@code lexerAction}. + */ + static append(lexerActionExecutor, lexerAction) { + if (lexerActionExecutor === null) { + return new LexerActionExecutor([ lexerAction ]); + } + const lexerActions = lexerActionExecutor.lexerActions.concat([ lexerAction ]); + return new LexerActionExecutor(lexerActions); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/LexerATNSimulator.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + + + + + + + +function resetSimState(sim) { + sim.index = -1; + sim.line = 0; + sim.column = -1; + sim.dfaState = null; +} + +class SimState { + constructor() { + resetSimState(this); + } + + reset() { + resetSimState(this); + } +} + +class LexerATNSimulator extends ATNSimulator { + /** + * When we hit an accept state in either the DFA or the ATN, we + * have to notify the character stream to start buffering characters + * via {@link IntStream//mark} and record the current state. The current sim state + * includes the current index into the input, the current line, + * and current character position in that line. Note that the Lexer is + * tracking the starting line and characterization of the token. These + * variables track the "state" of the simulator when it hits an accept state. + * + *

          We track these variables separately for the DFA and ATN simulation + * because the DFA simulation often has to fail over to the ATN + * simulation. If the ATN simulation fails, we need the DFA to fall + * back to its previously accepted state, if any. If the ATN succeeds, + * then the ATN does the accept and the DFA simulator that invoked it + * can simply return the predicted token type.

          + */ + constructor(recog, atn, decisionToDFA, sharedContextCache) { + super(atn, sharedContextCache); + this.decisionToDFA = decisionToDFA; + this.recog = recog; + /** + * The current token's starting index into the character stream. + * Shared across DFA to ATN simulation in case the ATN fails and the + * DFA did not have a previous accept state. In this case, we use the + * ATN-generated exception object + */ + this.startIndex = -1; + // line number 1..n within the input/// + this.line = 1; + /** + * The index of the character relative to the beginning of the line + * 0..n-1 + */ + this.column = 0; + this.mode = Lexer.DEFAULT_MODE; + /** + * Used during DFA/ATN exec to record the most recent accept configuration + * info + */ + this.prevAccept = new SimState(); + } + + copyState(simulator) { + this.column = simulator.column; + this.line = simulator.line; + this.mode = simulator.mode; + this.startIndex = simulator.startIndex; + } + + match(input, mode) { + this.mode = mode; + const mark = input.mark(); + try { + this.startIndex = input.index; + this.prevAccept.reset(); + const dfa = this.decisionToDFA[mode]; + if (dfa.s0 === null) { + return this.matchATN(input); + } else { + return this.execATN(input, dfa.s0); + } + } finally { + input.release(mark); + } + } + + reset() { + this.prevAccept.reset(); + this.startIndex = -1; + this.line = 1; + this.column = 0; + this.mode = Lexer.DEFAULT_MODE; + } + + matchATN(input) { + const startState = this.atn.modeToStartState[this.mode]; + + if (LexerATNSimulator.debug) { + console.log("matchATN mode " + this.mode + " start: " + startState); + } + const old_mode = this.mode; + const s0_closure = this.computeStartState(input, startState); + const suppressEdge = s0_closure.hasSemanticContext; + s0_closure.hasSemanticContext = false; + + const next = this.addDFAState(s0_closure); + if (!suppressEdge) { + this.decisionToDFA[this.mode].s0 = next; + } + + const predict = this.execATN(input, next); + + if (LexerATNSimulator.debug) { + console.log("DFA after matchATN: " + this.decisionToDFA[old_mode].toLexerString()); + } + return predict; + } + + execATN(input, ds0) { + if (LexerATNSimulator.debug) { + console.log("start state closure=" + ds0.configs); + } + if (ds0.isAcceptState) { + // allow zero-length tokens + this.captureSimState(this.prevAccept, input, ds0); + } + let t = input.LA(1); + let s = ds0; // s is current/from DFA state + + for (; ;) { // while more work + if (LexerATNSimulator.debug) { + console.log("execATN loop starting closure: " + s.configs); + } + + /** + * As we move src->trg, src->trg, we keep track of the previous trg to + * avoid looking up the DFA state again, which is expensive. + * If the previous target was already part of the DFA, we might + * be able to avoid doing a reach operation upon t. If s!=null, + * it means that semantic predicates didn't prevent us from + * creating a DFA state. Once we know s!=null, we check to see if + * the DFA state has an edge already for t. If so, we can just reuse + * it's configuration set; there's no point in re-computing it. + * This is kind of like doing DFA simulation within the ATN + * simulation because DFA simulation is really just a way to avoid + * computing reach/closure sets. Technically, once we know that + * we have a previously added DFA state, we could jump over to + * the DFA simulator. But, that would mean popping back and forth + * a lot and making things more complicated algorithmically. + * This optimization makes a lot of sense for loops within DFA. + * A character will take us back to an existing DFA state + * that already has lots of edges out of it. e.g., .* in comments. + * print("Target for:" + str(s) + " and:" + str(t)) + */ + let target = this.getExistingTargetState(s, t); + // print("Existing:" + str(target)) + if (target === null) { + target = this.computeTargetState(input, s, t); + // print("Computed:" + str(target)) + } + if (target === ATNSimulator.ERROR) { + break; + } + // If this is a consumable input element, make sure to consume before + // capturing the accept state so the input index, line, and char + // position accurately reflect the state of the interpreter at the + // end of the token. + if (t !== Token.EOF) { + this.consume(input); + } + if (target.isAcceptState) { + this.captureSimState(this.prevAccept, input, target); + if (t === Token.EOF) { + break; + } + } + t = input.LA(1); + s = target; // flip; current DFA target becomes new src/from state + } + return this.failOrAccept(this.prevAccept, input, s.configs, t); + } + + /** + * Get an existing target state for an edge in the DFA. If the target state + * for the edge has not yet been computed or is otherwise not available, + * this method returns {@code null}. + * + * @param s The current DFA state + * @param t The next input symbol + * @return The existing target DFA state for the given input symbol + * {@code t}, or {@code null} if the target state for this edge is not + * already cached + */ + getExistingTargetState(s, t) { + if (s.edges === null || t < LexerATNSimulator.MIN_DFA_EDGE || t > LexerATNSimulator.MAX_DFA_EDGE) { + return null; + } + + let target = s.edges[t - LexerATNSimulator.MIN_DFA_EDGE]; + if (target === undefined) { + target = null; + } + if (LexerATNSimulator.debug && target !== null) { + console.log("reuse state " + s.stateNumber + " edge to " + target.stateNumber); + } + return target; + } + + /** + * Compute a target state for an edge in the DFA, and attempt to add the + * computed state and corresponding edge to the DFA. + * + * @param input The input stream + * @param s The current DFA state + * @param t The next input symbol + * + * @return The computed target DFA state for the given input symbol + * {@code t}. If {@code t} does not lead to a valid DFA state, this method + * returns {@link //ERROR}. + */ + computeTargetState(input, s, t) { + const reach = new OrderedATNConfigSet(); + // if we don't find an existing DFA state + // Fill reach starting from closure, following t transitions + this.getReachableConfigSet(input, s.configs, reach, t); + + if (reach.items.length === 0) { // we got nowhere on t from s + if (!reach.hasSemanticContext) { + // we got nowhere on t, don't throw out this knowledge; it'd + // cause a failover from DFA later. + this.addDFAEdge(s, t, ATNSimulator.ERROR); + } + // stop when we can't match any more char + return ATNSimulator.ERROR; + } + // Add an edge from s to target DFA found/created for reach + return this.addDFAEdge(s, t, null, reach); + } + + failOrAccept(prevAccept, input, reach, t) { + if (this.prevAccept.dfaState !== null) { + const lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor; + this.accept(input, lexerActionExecutor, this.startIndex, + prevAccept.index, prevAccept.line, prevAccept.column); + return prevAccept.dfaState.prediction; + } else { + // if no accept and EOF is first char, return EOF + if (t === Token.EOF && input.index === this.startIndex) { + return Token.EOF; + } + throw new LexerNoViableAltException(this.recog, input, this.startIndex, reach); + } + } + + /** + * Given a starting configuration set, figure out all ATN configurations + * we can reach upon input {@code t}. Parameter {@code reach} is a return + * parameter. + */ + getReachableConfigSet(input, closure, reach, t) { + // this is used to skip processing for configs which have a lower priority + // than a config that already reached an accept state for the same rule + let skipAlt = ATN.INVALID_ALT_NUMBER; + for (let i = 0; i < closure.items.length; i++) { + const cfg = closure.items[i]; + const currentAltReachedAcceptState = (cfg.alt === skipAlt); + if (currentAltReachedAcceptState && cfg.passedThroughNonGreedyDecision) { + continue; + } + if (LexerATNSimulator.debug) { + console.log("testing %s at %s\n", this.getTokenName(t), cfg + .toString(this.recog, true)); + } + for (let j = 0; j < cfg.state.transitions.length; j++) { + const trans = cfg.state.transitions[j]; // for each transition + const target = this.getReachableTarget(trans, t); + if (target !== null) { + let lexerActionExecutor = cfg.lexerActionExecutor; + if (lexerActionExecutor !== null) { + lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index - this.startIndex); + } + const treatEofAsEpsilon = (t === Token.EOF); + const config = new LexerATNConfig({state: target, lexerActionExecutor: lexerActionExecutor}, cfg); + if (this.closure(input, config, reach, + currentAltReachedAcceptState, true, treatEofAsEpsilon)) { + // any remaining configs for this alt have a lower priority + // than the one that just reached an accept state. + skipAlt = cfg.alt; + } + } + } + } + } + + accept(input, lexerActionExecutor, startIndex, index, line, charPos) { + if (LexerATNSimulator.debug) { + console.log("ACTION %s\n", lexerActionExecutor); + } + // seek to after last char in token + input.seek(index); + this.line = line; + this.column = charPos; + if (lexerActionExecutor !== null && this.recog !== null) { + lexerActionExecutor.execute(this.recog, input, startIndex); + } + } + + getReachableTarget(trans, t) { + if (trans.matches(t, 0, Lexer.MAX_CHAR_VALUE)) { + return trans.target; + } else { + return null; + } + } + + computeStartState(input, p) { + const initialContext = PredictionContext.EMPTY; + const configs = new OrderedATNConfigSet(); + for (let i = 0; i < p.transitions.length; i++) { + const target = p.transitions[i].target; + const cfg = new LexerATNConfig({state: target, alt: i + 1, context: initialContext}, null); + this.closure(input, cfg, configs, false, false, false); + } + return configs; + } + + /** + * Since the alternatives within any lexer decision are ordered by + * preference, this method stops pursuing the closure as soon as an accept + * state is reached. After the first accept state is reached by depth-first + * search from {@code config}, all other (potentially reachable) states for + * this rule would have a lower priority. + * + * @return {Boolean} {@code true} if an accept state is reached, otherwise + * {@code false}. + */ + closure(input, config, configs, + currentAltReachedAcceptState, speculative, treatEofAsEpsilon) { + let cfg = null; + if (LexerATNSimulator.debug) { + console.log("closure(" + config.toString(this.recog, true) + ")"); + } + if (config.state instanceof RuleStopState) { + if (LexerATNSimulator.debug) { + if (this.recog !== null) { + console.log("closure at %s rule stop %s\n", this.recog.ruleNames[config.state.ruleIndex], config); + } else { + console.log("closure at rule stop %s\n", config); + } + } + if (config.context === null || config.context.hasEmptyPath()) { + if (config.context === null || config.context.isEmpty()) { + configs.add(config); + return true; + } else { + configs.add(new LexerATNConfig({state: config.state, context: PredictionContext.EMPTY}, config)); + currentAltReachedAcceptState = true; + } + } + if (config.context !== null && !config.context.isEmpty()) { + for (let i = 0; i < config.context.length; i++) { + if (config.context.getReturnState(i) !== PredictionContext.EMPTY_RETURN_STATE) { + const newContext = config.context.getParent(i); // "pop" return state + const returnState = this.atn.states[config.context.getReturnState(i)]; + cfg = new LexerATNConfig({state: returnState, context: newContext}, config); + currentAltReachedAcceptState = this.closure(input, cfg, + configs, currentAltReachedAcceptState, speculative, + treatEofAsEpsilon); + } + } + } + return currentAltReachedAcceptState; + } + // optimization + if (!config.state.epsilonOnlyTransitions) { + if (!currentAltReachedAcceptState || !config.passedThroughNonGreedyDecision) { + configs.add(config); + } + } + for (let j = 0; j < config.state.transitions.length; j++) { + const trans = config.state.transitions[j]; + cfg = this.getEpsilonTarget(input, config, trans, configs, speculative, treatEofAsEpsilon); + if (cfg !== null) { + currentAltReachedAcceptState = this.closure(input, cfg, configs, + currentAltReachedAcceptState, speculative, treatEofAsEpsilon); + } + } + return currentAltReachedAcceptState; + } + + // side-effect: can alter configs.hasSemanticContext + getEpsilonTarget(input, config, trans, + configs, speculative, treatEofAsEpsilon) { + let cfg = null; + if (trans.serializationType === Transition.RULE) { + const newContext = SingletonPredictionContext.create(config.context, trans.followState.stateNumber); + cfg = new LexerATNConfig({state: trans.target, context: newContext}, config); + } else if (trans.serializationType === Transition.PRECEDENCE) { + throw "Precedence predicates are not supported in lexers."; + } else if (trans.serializationType === Transition.PREDICATE) { + // Track traversing semantic predicates. If we traverse, + // we cannot add a DFA state for this "reach" computation + // because the DFA would not test the predicate again in the + // future. Rather than creating collections of semantic predicates + // like v3 and testing them on prediction, v4 will test them on the + // fly all the time using the ATN not the DFA. This is slower but + // semantically it's not used that often. One of the key elements to + // this predicate mechanism is not adding DFA states that see + // predicates immediately afterwards in the ATN. For example, + + // a : ID {p1}? | ID {p2}? ; + + // should create the start state for rule 'a' (to save start state + // competition), but should not create target of ID state. The + // collection of ATN states the following ID references includes + // states reached by traversing predicates. Since this is when we + // test them, we cannot cash the DFA state target of ID. + + if (LexerATNSimulator.debug) { + console.log("EVAL rule " + trans.ruleIndex + ":" + trans.predIndex); + } + configs.hasSemanticContext = true; + if (this.evaluatePredicate(input, trans.ruleIndex, trans.predIndex, speculative)) { + cfg = new LexerATNConfig({state: trans.target}, config); + } + } else if (trans.serializationType === Transition.ACTION) { + if (config.context === null || config.context.hasEmptyPath()) { + // execute actions anywhere in the start rule for a token. + // + // TODO: if the entry rule is invoked recursively, some + // actions may be executed during the recursive call. The + // problem can appear when hasEmptyPath() is true but + // isEmpty() is false. In this case, the config needs to be + // split into two contexts - one with just the empty path + // and another with everything but the empty path. + // Unfortunately, the current algorithm does not allow + // getEpsilonTarget to return two configurations, so + // additional modifications are needed before we can support + // the split operation. + const lexerActionExecutor = LexerActionExecutor.append(config.lexerActionExecutor, + this.atn.lexerActions[trans.actionIndex]); + cfg = new LexerATNConfig({state: trans.target, lexerActionExecutor: lexerActionExecutor}, config); + } else { + // ignore actions in referenced rules + cfg = new LexerATNConfig({state: trans.target}, config); + } + } else if (trans.serializationType === Transition.EPSILON) { + cfg = new LexerATNConfig({state: trans.target}, config); + } else if (trans.serializationType === Transition.ATOM || + trans.serializationType === Transition.RANGE || + trans.serializationType === Transition.SET) { + if (treatEofAsEpsilon) { + if (trans.matches(Token.EOF, 0, Lexer.MAX_CHAR_VALUE)) { + cfg = new LexerATNConfig({state: trans.target}, config); + } + } + } + return cfg; + } + + /** + * Evaluate a predicate specified in the lexer. + * + *

          If {@code speculative} is {@code true}, this method was called before + * {@link //consume} for the matched character. This method should call + * {@link //consume} before evaluating the predicate to ensure position + * sensitive values, including {@link Lexer//getText}, {@link Lexer//getLine}, + * and {@link Lexer//getcolumn}, properly reflect the current + * lexer state. This method should restore {@code input} and the simulator + * to the original state before returning (i.e. undo the actions made by the + * call to {@link //consume}.

          + * + * @param input The input stream. + * @param ruleIndex The rule containing the predicate. + * @param predIndex The index of the predicate within the rule. + * @param speculative {@code true} if the current index in {@code input} is + * one character before the predicate's location. + * + * @return {@code true} if the specified predicate evaluates to + * {@code true}. + */ + evaluatePredicate(input, ruleIndex, + predIndex, speculative) { + // assume true if no recognizer was provided + if (this.recog === null) { + return true; + } + if (!speculative) { + return this.recog.sempred(null, ruleIndex, predIndex); + } + const savedcolumn = this.column; + const savedLine = this.line; + const index = input.index; + const marker = input.mark(); + try { + this.consume(input); + return this.recog.sempred(null, ruleIndex, predIndex); + } finally { + this.column = savedcolumn; + this.line = savedLine; + input.seek(index); + input.release(marker); + } + } + + captureSimState(settings, input, dfaState) { + settings.index = input.index; + settings.line = this.line; + settings.column = this.column; + settings.dfaState = dfaState; + } + + addDFAEdge(from_, tk, to, cfgs) { + if (to === undefined) { + to = null; + } + if (cfgs === undefined) { + cfgs = null; + } + if (to === null && cfgs !== null) { + // leading to this call, ATNConfigSet.hasSemanticContext is used as a + // marker indicating dynamic predicate evaluation makes this edge + // dependent on the specific input sequence, so the static edge in the + // DFA should be omitted. The target DFAState is still created since + // execATN has the ability to resynchronize with the DFA state cache + // following the predicate evaluation step. + // + // TJP notes: next time through the DFA, we see a pred again and eval. + // If that gets us to a previously created (but dangling) DFA + // state, we can continue in pure DFA mode from there. + // / + const suppressEdge = cfgs.hasSemanticContext; + cfgs.hasSemanticContext = false; + + to = this.addDFAState(cfgs); + + if (suppressEdge) { + return to; + } + } + // add the edge + if (tk < LexerATNSimulator.MIN_DFA_EDGE || tk > LexerATNSimulator.MAX_DFA_EDGE) { + // Only track edges within the DFA bounds + return to; + } + if (LexerATNSimulator.debug) { + console.log("EDGE " + from_ + " -> " + to + " upon " + tk); + } + if (from_.edges === null) { + // make room for tokens 1..n and -1 masquerading as index 0 + from_.edges = []; + } + from_.edges[tk - LexerATNSimulator.MIN_DFA_EDGE] = to; // connect + + return to; + } + + /** + * Add a new DFA state if there isn't one with this set of + * configurations already. This method also detects the first + * configuration containing an ATN rule stop state. Later, when + * traversing the DFA, we will know which rule to accept. + */ + addDFAState(configs) { + const proposed = new DFAState(null, configs); + let firstConfigWithRuleStopState = null; + for (let i = 0; i < configs.items.length; i++) { + const cfg = configs.items[i]; + if (cfg.state instanceof RuleStopState) { + firstConfigWithRuleStopState = cfg; + break; + } + } + if (firstConfigWithRuleStopState !== null) { + proposed.isAcceptState = true; + proposed.lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor; + proposed.prediction = this.atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex]; + } + const dfa = this.decisionToDFA[this.mode]; + const existing = dfa.states.get(proposed); + if (existing !== null) { + return existing; + } + const newState = proposed; + newState.stateNumber = dfa.states.length; + configs.setReadonly(true); + newState.configs = configs; + dfa.states.add(newState); + return newState; + } + + getDFA(mode) { + return this.decisionToDFA[mode]; + } + +// Get the text matched so far for the current token. + getText(input) { + // index is first lookahead char, don't include. + return input.getText(this.startIndex, input.index - 1); + } + + consume(input) { + const curChar = input.LA(1); + if (curChar === "\n".charCodeAt(0)) { + this.line += 1; + this.column = 0; + } else { + this.column += 1; + } + input.consume(); + } + + getTokenName(tt) { + if (tt === -1) { + return "EOF"; + } else { + return "'" + String.fromCharCode(tt) + "'"; + } + } +} + +LexerATNSimulator.debug = false; +LexerATNSimulator.dfa_debug = false; + +LexerATNSimulator.MIN_DFA_EDGE = 0; +LexerATNSimulator.MAX_DFA_EDGE = 127; // forces unicode to stay in ATN + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/PredPrediction.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/** + * Map a predicate to a predicted alternative. + */ +class PredPrediction { + constructor(pred, alt) { + this.alt = alt; + this.pred = pred; + } + + toString() { + return "(" + this.pred + ", " + this.alt + ")"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/misc/AltDict.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +class AltDict { + + constructor() { + this.data = {}; + } + + get(key) { + return this.data["k-" + key] || null; + } + + set(key, value) { + this.data["k-" + key] = value; + } + + values() { + return Object.keys(this.data).filter(key => key.startsWith("k-")).map(key => this.data[key], this); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/PredictionMode.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + + + +/** + * This enumeration defines the prediction modes available in ANTLR 4 along with + * utility methods for analyzing configuration sets for conflicts and/or + * ambiguities. + */ +const PredictionMode = { + /** + * The SLL(*) prediction mode. This prediction mode ignores the current + * parser context when making predictions. This is the fastest prediction + * mode, and provides correct results for many grammars. This prediction + * mode is more powerful than the prediction mode provided by ANTLR 3, but + * may result in syntax errors for grammar and input combinations which are + * not SLL. + * + *

          + * When using this prediction mode, the parser will either return a correct + * parse tree (i.e. the same parse tree that would be returned with the + * {@link //LL} prediction mode), or it will report a syntax error. If a + * syntax error is encountered when using the {@link //SLL} prediction mode, + * it may be due to either an actual syntax error in the input or indicate + * that the particular combination of grammar and input requires the more + * powerful {@link //LL} prediction abilities to complete successfully.

          + * + *

          + * This prediction mode does not provide any guarantees for prediction + * behavior for syntactically-incorrect inputs.

          + */ + SLL: 0, + + /** + * The LL(*) prediction mode. This prediction mode allows the current parser + * context to be used for resolving SLL conflicts that occur during + * prediction. This is the fastest prediction mode that guarantees correct + * parse results for all combinations of grammars with syntactically correct + * inputs. + * + *

          + * When using this prediction mode, the parser will make correct decisions + * for all syntactically-correct grammar and input combinations. However, in + * cases where the grammar is truly ambiguous this prediction mode might not + * report a precise answer for exactly which alternatives are + * ambiguous.

          + * + *

          + * This prediction mode does not provide any guarantees for prediction + * behavior for syntactically-incorrect inputs.

          + */ + LL: 1, + + /** + * + * The LL(*) prediction mode with exact ambiguity detection. In addition to + * the correctness guarantees provided by the {@link //LL} prediction mode, + * this prediction mode instructs the prediction algorithm to determine the + * complete and exact set of ambiguous alternatives for every ambiguous + * decision encountered while parsing. + * + *

          + * This prediction mode may be used for diagnosing ambiguities during + * grammar development. Due to the performance overhead of calculating sets + * of ambiguous alternatives, this prediction mode should be avoided when + * the exact results are not necessary.

          + * + *

          + * This prediction mode does not provide any guarantees for prediction + * behavior for syntactically-incorrect inputs.

          + */ + LL_EXACT_AMBIG_DETECTION: 2, + + /** + * + * Computes the SLL prediction termination condition. + * + *

          + * This method computes the SLL prediction termination condition for both of + * the following cases.

          + * + *
            + *
          • The usual SLL+LL fallback upon SLL conflict
          • + *
          • Pure SLL without LL fallback
          • + *
          + * + *

          COMBINED SLL+LL PARSING

          + * + *

          When LL-fallback is enabled upon SLL conflict, correct predictions are + * ensured regardless of how the termination condition is computed by this + * method. Due to the substantially higher cost of LL prediction, the + * prediction should only fall back to LL when the additional lookahead + * cannot lead to a unique SLL prediction.

          + * + *

          Assuming combined SLL+LL parsing, an SLL configuration set with only + * conflicting subsets should fall back to full LL, even if the + * configuration sets don't resolve to the same alternative (e.g. + * {@code {1,2}} and {@code {3,4}}. If there is at least one non-conflicting + * configuration, SLL could continue with the hopes that more lookahead will + * resolve via one of those non-conflicting configurations.

          + * + *

          Here's the prediction termination rule them: SLL (for SLL+LL parsing) + * stops when it sees only conflicting configuration subsets. In contrast, + * full LL keeps going when there is uncertainty.

          + * + *

          HEURISTIC

          + * + *

          As a heuristic, we stop prediction when we see any conflicting subset + * unless we see a state that only has one alternative associated with it. + * The single-alt-state thing lets prediction continue upon rules like + * (otherwise, it would admit defeat too soon):

          + * + *

          {@code [12|1|[], 6|2|[], 12|2|[]]. s : (ID | ID ID?) ';' ;}

          + * + *

          When the ATN simulation reaches the state before {@code ';'}, it has a + * DFA state that looks like: {@code [12|1|[], 6|2|[], 12|2|[]]}. Naturally + * {@code 12|1|[]} and {@code 12|2|[]} conflict, but we cannot stop + * processing this node because alternative to has another way to continue, + * via {@code [6|2|[]]}.

          + * + *

          It also let's us continue for this rule:

          + * + *

          {@code [1|1|[], 1|2|[], 8|3|[]] a : A | A | A B ;}

          + * + *

          After matching input A, we reach the stop state for rule A, state 1. + * State 8 is the state right before B. Clearly alternatives 1 and 2 + * conflict and no amount of further lookahead will separate the two. + * However, alternative 3 will be able to continue and so we do not stop + * working on this state. In the previous example, we're concerned with + * states associated with the conflicting alternatives. Here alt 3 is not + * associated with the conflicting configs, but since we can continue + * looking for input reasonably, don't declare the state done.

          + * + *

          PURE SLL PARSING

          + * + *

          To handle pure SLL parsing, all we have to do is make sure that we + * combine stack contexts for configurations that differ only by semantic + * predicate. From there, we can do the usual SLL termination heuristic.

          + * + *

          PREDICATES IN SLL+LL PARSING

          + * + *

          SLL decisions don't evaluate predicates until after they reach DFA stop + * states because they need to create the DFA cache that works in all + * semantic situations. In contrast, full LL evaluates predicates collected + * during start state computation so it can ignore predicates thereafter. + * This means that SLL termination detection can totally ignore semantic + * predicates.

          + * + *

          Implementation-wise, {@link ATNConfigSet} combines stack contexts but not + * semantic predicate contexts so we might see two configurations like the + * following.

          + * + *

          {@code (s, 1, x, {}), (s, 1, x', {p})}

          + * + *

          Before testing these configurations against others, we have to merge + * {@code x} and {@code x'} (without modifying the existing configurations). + * For example, we test {@code (x+x')==x''} when looking for conflicts in + * the following configurations.

          + * + *

          {@code (s, 1, x, {}), (s, 1, x', {p}), (s, 2, x'', {})}

          + * + *

          If the configuration set has predicates (as indicated by + * {@link ATNConfigSet//hasSemanticContext}), this algorithm makes a copy of + * the configurations to strip out all of the predicates so that a standard + * {@link ATNConfigSet} will merge everything ignoring predicates.

          + */ + hasSLLConflictTerminatingPrediction: function( mode, configs) { + // Configs in rule stop states indicate reaching the end of the decision + // rule (local context) or end of start rule (full context). If all + // configs meet this condition, then none of the configurations is able + // to match additional input so we terminate prediction. + // + if (PredictionMode.allConfigsInRuleStopStates(configs)) { + return true; + } + // pure SLL mode parsing + if (mode === PredictionMode.SLL) { + // Don't bother with combining configs from different semantic + // contexts if we can fail over to full LL; costs more time + // since we'll often fail over anyway. + if (configs.hasSemanticContext) { + // dup configs, tossing out semantic predicates + const dup = new ATNConfigSet(); + for(let i=0;iCan we stop looking ahead during ATN simulation or is there some + * uncertainty as to which alternative we will ultimately pick, after + * consuming more input? Even if there are partial conflicts, we might know + * that everything is going to resolve to the same minimum alternative. That + * means we can stop since no more lookahead will change that fact. On the + * other hand, there might be multiple conflicts that resolve to different + * minimums. That means we need more look ahead to decide which of those + * alternatives we should predict.

          + * + *

          The basic idea is to split the set of configurations {@code C}, into + * conflicting subsets {@code (s, _, ctx, _)} and singleton subsets with + * non-conflicting configurations. Two configurations conflict if they have + * identical {@link ATNConfig//state} and {@link ATNConfig//context} values + * but different {@link ATNConfig//alt} value, e.g. {@code (s, i, ctx, _)} + * and {@code (s, j, ctx, _)} for {@code i!=j}.

          + * + *

          Reduce these configuration subsets to the set of possible alternatives. + * You can compute the alternative subsets in one pass as follows:

          + * + *

          {@code A_s,ctx = {i | (s, i, ctx, _)}} for each configuration in + * {@code C} holding {@code s} and {@code ctx} fixed.

          + * + *

          Or in pseudo-code, for each configuration {@code c} in {@code C}:

          + * + *
          +     * map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not
          +     * alt and not pred
          +     * 
          + * + *

          The values in {@code map} are the set of {@code A_s,ctx} sets.

          + * + *

          If {@code |A_s,ctx|=1} then there is no conflict associated with + * {@code s} and {@code ctx}.

          + * + *

          Reduce the subsets to singletons by choosing a minimum of each subset. If + * the union of these alternative subsets is a singleton, then no amount of + * more lookahead will help us. We will always pick that alternative. If, + * however, there is more than one alternative, then we are uncertain which + * alternative to predict and must continue looking for resolution. We may + * or may not discover an ambiguity in the future, even if there are no + * conflicting subsets this round.

          + * + *

          The biggest sin is to terminate early because it means we've made a + * decision but were uncertain as to the eventual outcome. We haven't used + * enough lookahead. On the other hand, announcing a conflict too late is no + * big deal; you will still have the conflict. It's just inefficient. It + * might even look until the end of file.

          + * + *

          No special consideration for semantic predicates is required because + * predicates are evaluated on-the-fly for full LL prediction, ensuring that + * no configuration contains a semantic context during the termination + * check.

          + * + *

          CONFLICTING CONFIGS

          + * + *

          Two configurations {@code (s, i, x)} and {@code (s, j, x')}, conflict + * when {@code i!=j} but {@code x=x'}. Because we merge all + * {@code (s, i, _)} configurations together, that means that there are at + * most {@code n} configurations associated with state {@code s} for + * {@code n} possible alternatives in the decision. The merged stacks + * complicate the comparison of configuration contexts {@code x} and + * {@code x'}. Sam checks to see if one is a subset of the other by calling + * merge and checking to see if the merged result is either {@code x} or + * {@code x'}. If the {@code x} associated with lowest alternative {@code i} + * is the superset, then {@code i} is the only possible prediction since the + * others resolve to {@code min(i)} as well. However, if {@code x} is + * associated with {@code j>i} then at least one stack configuration for + * {@code j} is not in conflict with alternative {@code i}. The algorithm + * should keep going, looking for more lookahead due to the uncertainty.

          + * + *

          For simplicity, I'm doing a equality check between {@code x} and + * {@code x'} that lets the algorithm continue to consume lookahead longer + * than necessary. The reason I like the equality is of course the + * simplicity but also because that is the test you need to detect the + * alternatives that are actually in conflict.

          + * + *

          CONTINUE/STOP RULE

          + * + *

          Continue if union of resolved alternative sets from non-conflicting and + * conflicting alternative subsets has more than one alternative. We are + * uncertain about which alternative to predict.

          + * + *

          The complete set of alternatives, {@code [i for (_,i,_)]}, tells us which + * alternatives are still in the running for the amount of input we've + * consumed at this point. The conflicting sets let us to strip away + * configurations that won't lead to more states because we resolve + * conflicts to the configuration with a minimum alternate for the + * conflicting set.

          + * + *

          CASES

          + * + *
            + * + *
          • no conflicts and more than 1 alternative in set => continue
          • + * + *
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s, 3, z)}, + * {@code (s', 1, y)}, {@code (s', 2, y)} yields non-conflicting set + * {@code {3}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} = + * {@code {1,3}} => continue + *
          • + * + *
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)}, + * {@code (s', 2, y)}, {@code (s'', 1, z)} yields non-conflicting set + * {@code {1}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} = + * {@code {1}} => stop and predict 1
          • + * + *
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)}, + * {@code (s', 2, y)} yields conflicting, reduced sets {@code {1}} U + * {@code {1}} = {@code {1}} => stop and predict 1, can announce + * ambiguity {@code {1,2}}
          • + * + *
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 2, y)}, + * {@code (s', 3, y)} yields conflicting, reduced sets {@code {1}} U + * {@code {2}} = {@code {1,2}} => continue
          • + * + *
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 3, y)}, + * {@code (s', 4, y)} yields conflicting, reduced sets {@code {1}} U + * {@code {3}} = {@code {1,3}} => continue
          • + * + *
          + * + *

          EXACT AMBIGUITY DETECTION

          + * + *

          If all states report the same conflicting set of alternatives, then we + * know we have the exact ambiguity set.

          + * + *

          |A_i|>1 and + * A_i = A_j for all i, j.

          + * + *

          In other words, we continue examining lookahead until all {@code A_i} + * have more than one alternative and all {@code A_i} are the same. If + * {@code A={{1,2}, {1,3}}}, then regular LL prediction would terminate + * because the resolved set is {@code {1}}. To determine what the real + * ambiguity is, we have to know whether the ambiguity is between one and + * two or one and three so we keep going. We can only stop prediction when + * we need exact ambiguity detection when the sets look like + * {@code A={{1,2}}} or {@code {{1,2},{1,2}}}, etc...

          + */ + resolvesToJustOneViableAlt: function(altsets) { + return PredictionMode.getSingleViableAlt(altsets); + }, + + /** + * Determines if every alternative subset in {@code altsets} contains more + * than one alternative. + * + * @param altsets a collection of alternative subsets + * @return {@code true} if every {@link BitSet} in {@code altsets} has + * {@link BitSet//cardinality cardinality} > 1, otherwise {@code false} + */ + allSubsetsConflict: function(altsets) { + return ! PredictionMode.hasNonConflictingAltSet(altsets); + }, + /** + * Determines if any single alternative subset in {@code altsets} contains + * exactly one alternative. + * + * @param altsets a collection of alternative subsets + * @return {@code true} if {@code altsets} contains a {@link BitSet} with + * {@link BitSet//cardinality cardinality} 1, otherwise {@code false} + */ + hasNonConflictingAltSet: function(altsets) { + for(let i=0;i1) { + return true; + } + } + return false; + }, + + + /** + * Determines if every alternative subset in {@code altsets} is equivalent. + * + * @param altsets a collection of alternative subsets + * @return {@code true} if every member of {@code altsets} is equal to the + * others, otherwise {@code false} + */ + allSubsetsEqual: function(altsets) { + let first = null; + for(let i=0;i + * map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not + * alt and not pred + * + */ + getConflictingAltSubsets: function(configs) { + const configToAlts = new HashMap_HashMap(); + configToAlts.hashFunction = function(cfg) { HashCode.hashStuff(cfg.state.stateNumber, cfg.context); }; + configToAlts.equalsFunction = function(c1, c2) { return c1.state.stateNumber === c2.state.stateNumber && c1.context.equals(c2.context);}; + configs.items.map(function(cfg) { + let alts = configToAlts.get(cfg); + if (alts === null) { + alts = new BitSet(); + configToAlts.set(cfg, alts); + } + alts.add(cfg.alt); + }); + return configToAlts.getValues(); + }, + + /** + * Get a map from state to alt subset from a configuration set. For each + * configuration {@code c} in {@code configs}: + * + *
          +     * map[c.{@link ATNConfig//state state}] U= c.{@link ATNConfig//alt alt}
          +     * 
          + */ + getStateToAltMap: function(configs) { + const m = new AltDict(); + configs.items.map(function(c) { + let alts = m.get(c.state); + if (alts === null) { + alts = new BitSet(); + m.set(c.state, alts); + } + alts.add(c.alt); + }); + return m; + }, + + hasStateAssociatedWithOneAlt: function(configs) { + const values = PredictionMode.getStateToAltMap(configs).values(); + for(let i=0;i + * The basic complexity of the adaptive strategy makes it harder to understand. + * We begin with ATN simulation to build paths in a DFA. Subsequent prediction + * requests go through the DFA first. If they reach a state without an edge for + * the current symbol, the algorithm fails over to the ATN simulation to + * complete the DFA path for the current input (until it finds a conflict state + * or uniquely predicting state).

          + * + *

          + * All of that is done without using the outer context because we want to create + * a DFA that is not dependent upon the rule invocation stack when we do a + * prediction. One DFA works in all contexts. We avoid using context not + * necessarily because it's slower, although it can be, but because of the DFA + * caching problem. The closure routine only considers the rule invocation stack + * created during prediction beginning in the decision rule. For example, if + * prediction occurs without invoking another rule's ATN, there are no context + * stacks in the configurations. When lack of context leads to a conflict, we + * don't know if it's an ambiguity or a weakness in the strong LL(*) parsing + * strategy (versus full LL(*)).

          + * + *

          + * When SLL yields a configuration set with conflict, we rewind the input and + * retry the ATN simulation, this time using full outer context without adding + * to the DFA. Configuration context stacks will be the full invocation stacks + * from the start rule. If we get a conflict using full context, then we can + * definitively say we have a true ambiguity for that input sequence. If we + * don't get a conflict, it implies that the decision is sensitive to the outer + * context. (It is not context-sensitive in the sense of context-sensitive + * grammars.)

          + * + *

          + * The next time we reach this DFA state with an SLL conflict, through DFA + * simulation, we will again retry the ATN simulation using full context mode. + * This is slow because we can't save the results and have to "interpret" the + * ATN each time we get that input.

          + * + *

          + * CACHING FULL CONTEXT PREDICTIONS

          + * + *

          + * We could cache results from full context to predicted alternative easily and + * that saves a lot of time but doesn't work in presence of predicates. The set + * of visible predicates from the ATN start state changes depending on the + * context, because closure can fall off the end of a rule. I tried to cache + * tuples (stack context, semantic context, predicted alt) but it was slower + * than interpreting and much more complicated. Also required a huge amount of + * memory. The goal is not to create the world's fastest parser anyway. I'd like + * to keep this algorithm simple. By launching multiple threads, we can improve + * the speed of parsing across a large number of files.

          + * + *

          + * There is no strict ordering between the amount of input used by SLL vs LL, + * which makes it really hard to build a cache for full context. Let's say that + * we have input A B C that leads to an SLL conflict with full context X. That + * implies that using X we might only use A B but we could also use A B C D to + * resolve conflict. Input A B C D could predict alternative 1 in one position + * in the input and A B C E could predict alternative 2 in another position in + * input. The conflicting SLL configurations could still be non-unique in the + * full context prediction, which would lead us to requiring more input than the + * original A B C. To make a prediction cache work, we have to track the exact + * input used during the previous prediction. That amounts to a cache that maps + * X to a specific DFA for that context.

          + * + *

          + * Something should be done for left-recursive expression predictions. They are + * likely LL(1) + pred eval. Easier to do the whole SLL unless error and retry + * with full LL thing Sam does.

          + * + *

          + * AVOIDING FULL CONTEXT PREDICTION

          + * + *

          + * We avoid doing full context retry when the outer context is empty, we did not + * dip into the outer context by falling off the end of the decision state rule, + * or when we force SLL mode.

          + * + *

          + * As an example of the not dip into outer context case, consider as super + * constructor calls versus function calls. One grammar might look like + * this:

          + * + *
          + * ctorBody
          + *   : '{' superCall? stat* '}'
          + *   ;
          + * 
          + * + *

          + * Or, you might see something like

          + * + *
          + * stat
          + *   : superCall ';'
          + *   | expression ';'
          + *   | ...
          + *   ;
          + * 
          + * + *

          + * In both cases I believe that no closure operations will dip into the outer + * context. In the first case ctorBody in the worst case will stop at the '}'. + * In the 2nd case it should stop at the ';'. Both cases should stay within the + * entry rule and not dip into the outer context.

          + * + *

          + * PREDICATES

          + * + *

          + * Predicates are always evaluated if present in either SLL or LL both. SLL and + * LL simulation deals with predicates differently. SLL collects predicates as + * it performs closure operations like ANTLR v3 did. It delays predicate + * evaluation until it reaches and accept state. This allows us to cache the SLL + * ATN simulation whereas, if we had evaluated predicates on-the-fly during + * closure, the DFA state configuration sets would be different and we couldn't + * build up a suitable DFA.

          + * + *

          + * When building a DFA accept state during ATN simulation, we evaluate any + * predicates and return the sole semantically valid alternative. If there is + * more than 1 alternative, we report an ambiguity. If there are 0 alternatives, + * we throw an exception. Alternatives without predicates act like they have + * true predicates. The simple way to think about it is to strip away all + * alternatives with false predicates and choose the minimum alternative that + * remains.

          + * + *

          + * When we start in the DFA and reach an accept state that's predicated, we test + * those and return the minimum semantically viable alternative. If no + * alternatives are viable, we throw an exception.

          + * + *

          + * During full LL ATN simulation, closure always evaluates predicates and + * on-the-fly. This is crucial to reducing the configuration set size during + * closure. It hits a landmine when parsing with the Java grammar, for example, + * without this on-the-fly evaluation.

          + * + *

          + * SHARING DFA

          + * + *

          + * All instances of the same parser share the same decision DFAs through a + * static field. Each instance gets its own ATN simulator but they share the + * same {@link //decisionToDFA} field. They also share a + * {@link PredictionContextCache} object that makes sure that all + * {@link PredictionContext} objects are shared among the DFA states. This makes + * a big size difference.

          + * + *

          + * THREAD SAFETY

          + * + *

          + * The {@link ParserATNSimulator} locks on the {@link //decisionToDFA} field when + * it adds a new DFA object to that array. {@link //addDFAEdge} + * locks on the DFA for the current decision when setting the + * {@link DFAState//edges} field. {@link //addDFAState} locks on + * the DFA for the current decision when looking up a DFA state to see if it + * already exists. We must make sure that all requests to add DFA states that + * are equivalent result in the same shared DFA object. This is because lots of + * threads will be trying to update the DFA at once. The + * {@link //addDFAState} method also locks inside the DFA lock + * but this time on the shared context cache when it rebuilds the + * configurations' {@link PredictionContext} objects using cached + * subgraphs/nodes. No other locking occurs, even during DFA simulation. This is + * safe as long as we can guarantee that all threads referencing + * {@code s.edge[t]} get the same physical target {@link DFAState}, or + * {@code null}. Once into the DFA, the DFA simulation does not reference the + * {@link DFA//states} map. It follows the {@link DFAState//edges} field to new + * targets. The DFA simulator will either find {@link DFAState//edges} to be + * {@code null}, to be non-{@code null} and {@code dfa.edges[t]} null, or + * {@code dfa.edges[t]} to be non-null. The + * {@link //addDFAEdge} method could be racing to set the field + * but in either case the DFA simulator works; if {@code null}, and requests ATN + * simulation. It could also race trying to get {@code dfa.edges[t]}, but either + * way it will work because it's not doing a test and set operation.

          + * + *

          + * Starting with SLL then failing to combined SLL/LL (Two-Stage + * Parsing)

          + * + *

          + * Sam pointed out that if SLL does not give a syntax error, then there is no + * point in doing full LL, which is slower. We only have to try LL if we get a + * syntax error. For maximum speed, Sam starts the parser set to pure SLL + * mode with the {@link BailErrorStrategy}:

          + * + *
          + * parser.{@link Parser//getInterpreter() getInterpreter()}.{@link //setPredictionMode setPredictionMode}{@code (}{@link PredictionMode//SLL}{@code )};
          + * parser.{@link Parser//setErrorHandler setErrorHandler}(new {@link BailErrorStrategy}());
          + * 
          + * + *

          + * If it does not get a syntax error, then we're done. If it does get a syntax + * error, we need to retry with the combined SLL/LL strategy.

          + * + *

          + * The reason this works is as follows. If there are no SLL conflicts, then the + * grammar is SLL (at least for that input set). If there is an SLL conflict, + * the full LL analysis must yield a set of viable alternatives which is a + * subset of the alternatives reported by SLL. If the LL set is a singleton, + * then the grammar is LL but not SLL. If the LL set is the same size as the SLL + * set, the decision is SLL. If the LL set has size > 1, then that decision + * is truly ambiguous on the current input. If the LL set is smaller, then the + * SLL conflict resolution might choose an alternative that the full LL would + * rule out as a possibility based upon better context information. If that's + * the case, then the SLL parse will definitely get an error because the full LL + * analysis says it's not viable. If SLL conflict resolution chooses an + * alternative within the LL set, them both SLL and LL would choose the same + * alternative because they both choose the minimum of multiple conflicting + * alternatives.

          + * + *

          + * Let's say we have a set of SLL conflicting alternatives {@code {1, 2, 3}} and + * a smaller LL set called s. If s is {@code {2, 3}}, then SLL + * parsing will get an error because SLL will pursue alternative 1. If + * s is {@code {1, 2}} or {@code {1, 3}} then both SLL and LL will + * choose the same alternative because alternative one is the minimum of either + * set. If s is {@code {2}} or {@code {3}} then SLL will get a syntax + * error. If s is {@code {1}} then SLL will succeed.

          + * + *

          + * Of course, if the input is invalid, then we will get an error for sure in + * both SLL and LL parsing. Erroneous input will therefore require 2 passes over + * the input.

          + */ +class ParserATNSimulator extends ATNSimulator { + constructor(parser, atn, decisionToDFA, sharedContextCache) { + super(atn, sharedContextCache); + this.parser = parser; + this.decisionToDFA = decisionToDFA; + // SLL, LL, or LL + exact ambig detection?// + this.predictionMode = atn_PredictionMode.LL; + // LAME globals to avoid parameters!!!!! I need these down deep in predTransition + this._input = null; + this._startIndex = 0; + this._outerContext = null; + this._dfa = null; + /** + * Each prediction operation uses a cache for merge of prediction contexts. + * Don't keep around as it wastes huge amounts of memory. DoubleKeyMap + * isn't synchronized but we're ok since two threads shouldn't reuse same + * parser/atnsim object because it can only handle one input at a time. + * This maps graphs a and b to merged result c. (a,b)→c. We can avoid + * the merge if we ever see a and b again. Note that (b,a)→c should + * also be examined during cache lookup. + */ + this.mergeCache = null; + this.debug = false; + this.debug_closure = false; + this.debug_add = false; + this.debug_list_atn_decisions = false; + this.dfa_debug = false; + this.retry_debug = false; + } + + reset() {} + + adaptivePredict(input, decision, outerContext) { + if (this.debug || this.debug_list_atn_decisions) { + console.log("adaptivePredict decision " + decision + + " exec LA(1)==" + this.getLookaheadName(input) + + " line " + input.LT(1).line + ":" + + input.LT(1).column); + } + this._input = input; + this._startIndex = input.index; + this._outerContext = outerContext; + + const dfa = this.decisionToDFA[decision]; + this._dfa = dfa; + const m = input.mark(); + const index = input.index; + + // Now we are certain to have a specific decision's DFA + // But, do we still need an initial state? + try { + let s0; + if (dfa.precedenceDfa) { + // the start state for a precedence DFA depends on the current + // parser precedence, and is provided by a DFA method. + s0 = dfa.getPrecedenceStartState(this.parser.getPrecedence()); + } else { + // the start state for a "regular" DFA is just s0 + s0 = dfa.s0; + } + if (s0===null) { + if (outerContext===null) { + outerContext = RuleContext.EMPTY; + } + if (this.debug || this.debug_list_atn_decisions) { + console.log("predictATN decision " + dfa.decision + + " exec LA(1)==" + this.getLookaheadName(input) + + ", outerContext=" + outerContext.toString(this.parser.ruleNames)); + } + + const fullCtx = false; + let s0_closure = this.computeStartState(dfa.atnStartState, RuleContext.EMPTY, fullCtx); + + if( dfa.precedenceDfa) { + // If this is a precedence DFA, we use applyPrecedenceFilter + // to convert the computed start state to a precedence start + // state. We then use DFA.setPrecedenceStartState to set the + // appropriate start state for the precedence level rather + // than simply setting DFA.s0. + // + dfa.s0.configs = s0_closure; // not used for prediction but useful to know start configs anyway + s0_closure = this.applyPrecedenceFilter(s0_closure); + s0 = this.addDFAState(dfa, new DFAState(null, s0_closure)); + dfa.setPrecedenceStartState(this.parser.getPrecedence(), s0); + } else { + s0 = this.addDFAState(dfa, new DFAState(null, s0_closure)); + dfa.s0 = s0; + } + } + const alt = this.execATN(dfa, s0, input, index, outerContext); + if (this.debug) { + console.log("DFA after predictATN: " + dfa.toString(this.parser.literalNames, this.parser.symbolicNames)); + } + return alt; + } finally { + this._dfa = null; + this.mergeCache = null; // wack cache after each prediction + input.seek(index); + input.release(m); + } + } + + /** + * Performs ATN simulation to compute a predicted alternative based + * upon the remaining input, but also updates the DFA cache to avoid + * having to traverse the ATN again for the same input sequence. + * + * There are some key conditions we're looking for after computing a new + * set of ATN configs (proposed DFA state): + * if the set is empty, there is no viable alternative for current symbol + * does the state uniquely predict an alternative? + * does the state have a conflict that would prevent us from + * putting it on the work list? + * + * We also have some key operations to do: + * add an edge from previous DFA state to potentially new DFA state, D, + * upon current symbol but only if adding to work list, which means in all + * cases except no viable alternative (and possibly non-greedy decisions?) + * collecting predicates and adding semantic context to DFA accept states + * adding rule context to context-sensitive DFA accept states + * consuming an input symbol + * reporting a conflict + * reporting an ambiguity + * reporting a context sensitivity + * reporting insufficient predicates + * + * cover these cases: + * dead end + * single alt + * single alt + preds + * conflict + * conflict + preds + * + */ + execATN(dfa, s0, input, startIndex, outerContext ) { + if (this.debug || this.debug_list_atn_decisions) { + console.log("execATN decision " + dfa.decision + + " exec LA(1)==" + this.getLookaheadName(input) + + " line " + input.LT(1).line + ":" + input.LT(1).column); + } + let alt; + let previousD = s0; + + if (this.debug) { + console.log("s0 = " + s0); + } + let t = input.LA(1); + for(;;) { // while more work + let D = this.getExistingTargetState(previousD, t); + if(D===null) { + D = this.computeTargetState(dfa, previousD, t); + } + if(D===ATNSimulator.ERROR) { + // if any configs in previous dipped into outer context, that + // means that input up to t actually finished entry rule + // at least for SLL decision. Full LL doesn't dip into outer + // so don't need special case. + // We will get an error no matter what so delay until after + // decision; better error message. Also, no reachable target + // ATN states in SLL implies LL will also get nowhere. + // If conflict in states that dip out, choose min since we + // will get error no matter what. + const e = this.noViableAlt(input, outerContext, previousD.configs, startIndex); + input.seek(startIndex); + alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD.configs, outerContext); + if(alt!==ATN.INVALID_ALT_NUMBER) { + return alt; + } else { + throw e; + } + } + if(D.requiresFullContext && this.predictionMode !== atn_PredictionMode.SLL) { + // IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error) + let conflictingAlts = null; + if (D.predicates!==null) { + if (this.debug) { + console.log("DFA state has preds in DFA sim LL failover"); + } + const conflictIndex = input.index; + if(conflictIndex !== startIndex) { + input.seek(startIndex); + } + conflictingAlts = this.evalSemanticContext(D.predicates, outerContext, true); + if (conflictingAlts.length===1) { + if(this.debug) { + console.log("Full LL avoided"); + } + return conflictingAlts.minValue(); + } + if (conflictIndex !== startIndex) { + // restore the index so reporting the fallback to full + // context occurs with the index at the correct spot + input.seek(conflictIndex); + } + } + if (this.dfa_debug) { + console.log("ctx sensitive state " + outerContext +" in " + D); + } + const fullCtx = true; + const s0_closure = this.computeStartState(dfa.atnStartState, outerContext, fullCtx); + this.reportAttemptingFullContext(dfa, conflictingAlts, D.configs, startIndex, input.index); + alt = this.execATNWithFullContext(dfa, D, s0_closure, input, startIndex, outerContext); + return alt; + } + if (D.isAcceptState) { + if (D.predicates===null) { + return D.prediction; + } + const stopIndex = input.index; + input.seek(startIndex); + const alts = this.evalSemanticContext(D.predicates, outerContext, true); + if (alts.length===0) { + throw this.noViableAlt(input, outerContext, D.configs, startIndex); + } else if (alts.length===1) { + return alts.minValue(); + } else { + // report ambiguity after predicate evaluation to make sure the correct set of ambig alts is reported. + this.reportAmbiguity(dfa, D, startIndex, stopIndex, false, alts, D.configs); + return alts.minValue(); + } + } + previousD = D; + + if (t !== Token.EOF) { + input.consume(); + t = input.LA(1); + } + } + } + + /** + * Get an existing target state for an edge in the DFA. If the target state + * for the edge has not yet been computed or is otherwise not available, + * this method returns {@code null}. + * + * @param previousD The current DFA state + * @param t The next input symbol + * @return The existing target DFA state for the given input symbol + * {@code t}, or {@code null} if the target state for this edge is not + * already cached + */ + getExistingTargetState(previousD, t) { + const edges = previousD.edges; + if (edges===null) { + return null; + } else { + return edges[t + 1] || null; + } + } + + /** + * Compute a target state for an edge in the DFA, and attempt to add the + * computed state and corresponding edge to the DFA. + * + * @param dfa The DFA + * @param previousD The current DFA state + * @param t The next input symbol + * + * @return The computed target DFA state for the given input symbol + * {@code t}. If {@code t} does not lead to a valid DFA state, this method + * returns {@link //ERROR + */ + computeTargetState(dfa, previousD, t) { + const reach = this.computeReachSet(previousD.configs, t, false); + if(reach===null) { + this.addDFAEdge(dfa, previousD, t, ATNSimulator.ERROR); + return ATNSimulator.ERROR; + } + // create new target state; we'll add to DFA after it's complete + let D = new DFAState(null, reach); + + const predictedAlt = this.getUniqueAlt(reach); + + if (this.debug) { + const altSubSets = atn_PredictionMode.getConflictingAltSubsets(reach); + console.log("SLL altSubSets=" + arrayToString(altSubSets) + + /*", previous=" + previousD.configs + */ + ", configs=" + reach + + ", predict=" + predictedAlt + + ", allSubsetsConflict=" + + atn_PredictionMode.allSubsetsConflict(altSubSets) + ", conflictingAlts=" + + this.getConflictingAlts(reach)); + } + if (predictedAlt!==ATN.INVALID_ALT_NUMBER) { + // NO CONFLICT, UNIQUELY PREDICTED ALT + D.isAcceptState = true; + D.configs.uniqueAlt = predictedAlt; + D.prediction = predictedAlt; + } else if (atn_PredictionMode.hasSLLConflictTerminatingPrediction(this.predictionMode, reach)) { + // MORE THAN ONE VIABLE ALTERNATIVE + D.configs.conflictingAlts = this.getConflictingAlts(reach); + D.requiresFullContext = true; + // in SLL-only mode, we will stop at this state and return the minimum alt + D.isAcceptState = true; + D.prediction = D.configs.conflictingAlts.minValue(); + } + if (D.isAcceptState && D.configs.hasSemanticContext) { + this.predicateDFAState(D, this.atn.getDecisionState(dfa.decision)); + if( D.predicates!==null) { + D.prediction = ATN.INVALID_ALT_NUMBER; + } + } + // all adds to dfa are done after we've created full D state + D = this.addDFAEdge(dfa, previousD, t, D); + return D; + } + + predicateDFAState(dfaState, decisionState) { + // We need to test all predicates, even in DFA states that + // uniquely predict alternative. + const nalts = decisionState.transitions.length; + // Update DFA so reach becomes accept state with (predicate,alt) + // pairs if preds found for conflicting alts + const altsToCollectPredsFrom = this.getConflictingAltsOrUniqueAlt(dfaState.configs); + const altToPred = this.getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); + if (altToPred!==null) { + dfaState.predicates = this.getPredicatePredictions(altsToCollectPredsFrom, altToPred); + dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds + } else { + // There are preds in configs but they might go away + // when OR'd together like {p}? || NONE == NONE. If neither + // alt has preds, resolve to min alt + dfaState.prediction = altsToCollectPredsFrom.minValue(); + } + } + +// comes back with reach.uniqueAlt set to a valid alt + execATNWithFullContext(dfa, D, // how far we got before failing over + s0, + input, + startIndex, + outerContext) { + if (this.debug || this.debug_list_atn_decisions) { + console.log("execATNWithFullContext "+s0); + } + const fullCtx = true; + let foundExactAmbig = false; + let reach; + let previous = s0; + input.seek(startIndex); + let t = input.LA(1); + let predictedAlt = -1; + for (;;) { // while more work + reach = this.computeReachSet(previous, t, fullCtx); + if (reach===null) { + // if any configs in previous dipped into outer context, that + // means that input up to t actually finished entry rule + // at least for LL decision. Full LL doesn't dip into outer + // so don't need special case. + // We will get an error no matter what so delay until after + // decision; better error message. Also, no reachable target + // ATN states in SLL implies LL will also get nowhere. + // If conflict in states that dip out, choose min since we + // will get error no matter what. + const e = this.noViableAlt(input, outerContext, previous, startIndex); + input.seek(startIndex); + const alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext); + if(alt!==ATN.INVALID_ALT_NUMBER) { + return alt; + } else { + throw e; + } + } + const altSubSets = atn_PredictionMode.getConflictingAltSubsets(reach); + if(this.debug) { + console.log("LL altSubSets=" + altSubSets + ", predict=" + + atn_PredictionMode.getUniqueAlt(altSubSets) + ", resolvesToJustOneViableAlt=" + + atn_PredictionMode.resolvesToJustOneViableAlt(altSubSets)); + } + reach.uniqueAlt = this.getUniqueAlt(reach); + // unique prediction? + if(reach.uniqueAlt!==ATN.INVALID_ALT_NUMBER) { + predictedAlt = reach.uniqueAlt; + break; + } else if (this.predictionMode !== atn_PredictionMode.LL_EXACT_AMBIG_DETECTION) { + predictedAlt = atn_PredictionMode.resolvesToJustOneViableAlt(altSubSets); + if(predictedAlt !== ATN.INVALID_ALT_NUMBER) { + break; + } + } else { + // In exact ambiguity mode, we never try to terminate early. + // Just keeps scarfing until we know what the conflict is + if (atn_PredictionMode.allSubsetsConflict(altSubSets) && atn_PredictionMode.allSubsetsEqual(altSubSets)) { + foundExactAmbig = true; + predictedAlt = atn_PredictionMode.getSingleViableAlt(altSubSets); + break; + } + // else there are multiple non-conflicting subsets or + // we're not sure what the ambiguity is yet. + // So, keep going. + } + previous = reach; + if( t !== Token.EOF) { + input.consume(); + t = input.LA(1); + } + } + // If the configuration set uniquely predicts an alternative, + // without conflict, then we know that it's a full LL decision + // not SLL. + if (reach.uniqueAlt !== ATN.INVALID_ALT_NUMBER ) { + this.reportContextSensitivity(dfa, predictedAlt, reach, startIndex, input.index); + return predictedAlt; + } + // We do not check predicates here because we have checked them + // on-the-fly when doing full context prediction. + + // + // In non-exact ambiguity detection mode, we might actually be able to + // detect an exact ambiguity, but I'm not going to spend the cycles + // needed to check. We only emit ambiguity warnings in exact ambiguity + // mode. + // + // For example, we might know that we have conflicting configurations. + // But, that does not mean that there is no way forward without a + // conflict. It's possible to have nonconflicting alt subsets as in: + + // altSubSets=[{1, 2}, {1, 2}, {1}, {1, 2}] + + // from + // + // [(17,1,[5 $]), (13,1,[5 10 $]), (21,1,[5 10 $]), (11,1,[$]), + // (13,2,[5 10 $]), (21,2,[5 10 $]), (11,2,[$])] + // + // In this case, (17,1,[5 $]) indicates there is some next sequence that + // would resolve this without conflict to alternative 1. Any other viable + // next sequence, however, is associated with a conflict. We stop + // looking for input because no amount of further lookahead will alter + // the fact that we should predict alternative 1. We just can't say for + // sure that there is an ambiguity without looking further. + + this.reportAmbiguity(dfa, D, startIndex, input.index, foundExactAmbig, null, reach); + + return predictedAlt; + } + + computeReachSet(closure, t, fullCtx) { + if (this.debug) { + console.log("in computeReachSet, starting closure: " + closure); + } + if( this.mergeCache===null) { + this.mergeCache = new DoubleDict(); + } + const intermediate = new ATNConfigSet(fullCtx); + + // Configurations already in a rule stop state indicate reaching the end + // of the decision rule (local context) or end of the start rule (full + // context). Once reached, these configurations are never updated by a + // closure operation, so they are handled separately for the performance + // advantage of having a smaller intermediate set when calling closure. + // + // For full-context reach operations, separate handling is required to + // ensure that the alternative matching the longest overall sequence is + // chosen when multiple such configurations can match the input. + + let skippedStopStates = null; + + // First figure out where we can reach on input t + for (let i=0; iWhen {@code lookToEndOfRule} is true, this method uses + * {@link ATN//nextTokens} for each configuration in {@code configs} which is + * not already in a rule stop state to see if a rule stop state is reachable + * from the configuration via epsilon-only transitions.

          + * + * @param configs the configuration set to update + * @param lookToEndOfRule when true, this method checks for rule stop states + * reachable by epsilon-only transitions from each configuration in + * {@code configs}. + * + * @return {@code configs} if all configurations in {@code configs} are in a + * rule stop state, otherwise return a new configuration set containing only + * the configurations from {@code configs} which are in a rule stop state + */ + removeAllConfigsNotInRuleStopState(configs, lookToEndOfRule) { + if (atn_PredictionMode.allConfigsInRuleStopStates(configs)) { + return configs; + } + const result = new ATNConfigSet(configs.fullCtx); + for(let i=0; i + *
        • Evaluate the precedence predicates for each configuration using + * {@link SemanticContext//evalPrecedence}.
        • + *
        • Remove all configurations which predict an alternative greater than + * 1, for which another configuration that predicts alternative 1 is in the + * same ATN state with the same prediction context. This transformation is + * valid for the following reasons: + *
            + *
          • The closure block cannot contain any epsilon transitions which bypass + * the body of the closure, so all states reachable via alternative 1 are + * part of the precedence alternatives of the transformed left-recursive + * rule.
          • + *
          • The "primary" portion of a left recursive rule cannot contain an + * epsilon transition, so the only way an alternative other than 1 can exist + * in a state that is also reachable via alternative 1 is by nesting calls + * to the left-recursive rule, with the outer calls not being at the + * preferred precedence level.
          • + *
          + *
        • + * + * + *

          + * The prediction context must be considered by this filter to address + * situations like the following. + *

          + * + *
          +     * grammar TA;
          +     * prog: statement* EOF;
          +     * statement: letterA | statement letterA 'b' ;
          +     * letterA: 'a';
          +     * 
          + *
          + *

          + * If the above grammar, the ATN state immediately before the token + * reference {@code 'a'} in {@code letterA} is reachable from the left edge + * of both the primary and closure blocks of the left-recursive rule + * {@code statement}. The prediction context associated with each of these + * configurations distinguishes between them, and prevents the alternative + * which stepped out to {@code prog} (and then back in to {@code statement} + * from being eliminated by the filter. + *

          + * + * @param configs The configuration set computed by + * {@link //computeStartState} as the start state for the DFA. + * @return The transformed configuration set representing the start state + * for a precedence DFA at a particular precedence level (determined by + * calling {@link Parser//getPrecedence}) + */ + applyPrecedenceFilter(configs) { + let config; + const statesFromAlt1 = []; + const configSet = new ATNConfigSet(configs.fullCtx); + for(let i=0; i1 + // (basically a graph subtraction algorithm). + if (!config.precedenceFilterSuppressed) { + const context = statesFromAlt1[config.state.stateNumber] || null; + if (context!==null && context.equals(config.context)) { + // eliminated + continue; + } + } + configSet.add(config, this.mergeCache); + } + return configSet; + } + + getReachableTarget(trans, ttype) { + if (trans.matches(ttype, 0, this.atn.maxTokenType)) { + return trans.target; + } else { + return null; + } + } + + getPredsForAmbigAlts(ambigAlts, configs, nalts) { + // REACH=[1|1|[]|0:0, 1|2|[]|0:1] + // altToPred starts as an array of all null contexts. The entry at index i + // corresponds to alternative i. altToPred[i] may have one of three values: + // 1. null: no ATNConfig c is found such that c.alt==i + // 2. SemanticContext.NONE: At least one ATNConfig c exists such that + // c.alt==i and c.semanticContext==SemanticContext.NONE. In other words, + // alt i has at least one unpredicated config. + // 3. Non-NONE Semantic Context: There exists at least one, and for all + // ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE. + // + // From this, it is clear that NONE||anything==NONE. + // + let altToPred = []; + for(let i=0;i + * The default implementation of this method uses the following + * algorithm to identify an ATN configuration which successfully parsed the + * decision entry rule. Choosing such an alternative ensures that the + * {@link ParserRuleContext} returned by the calling rule will be complete + * and valid, and the syntax error will be reported later at a more + * localized location.

          + * + *
            + *
          • If a syntactically valid path or paths reach the end of the decision rule and + * they are semantically valid if predicated, return the min associated alt.
          • + *
          • Else, if a semantically invalid but syntactically valid path exist + * or paths exist, return the minimum associated alt. + *
          • + *
          • Otherwise, return {@link ATN//INVALID_ALT_NUMBER}.
          • + *
          + * + *

          + * In some scenarios, the algorithm described above could predict an + * alternative which will result in a {@link FailedPredicateException} in + * the parser. Specifically, this could occur if the only configuration + * capable of successfully parsing to the end of the decision rule is + * blocked by a semantic predicate. By choosing this alternative within + * {@link //adaptivePredict} instead of throwing a + * {@link NoViableAltException}, the resulting + * {@link FailedPredicateException} in the parser will identify the specific + * predicate which is preventing the parser from successfully parsing the + * decision rule, which helps developers identify and correct logic errors + * in semantic predicates. + *

          + * + * @param configs The ATN configurations which were valid immediately before + * the {@link //ERROR} state was reached + * @param outerContext The is the \gamma_0 initial parser context from the paper + * or the parser stack at the instant before prediction commences. + * + * @return The value to return from {@link //adaptivePredict}, or + * {@link ATN//INVALID_ALT_NUMBER} if a suitable alternative was not + * identified and {@link //adaptivePredict} should report an error instead + */ + getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(configs, outerContext) { + const cfgs = this.splitAccordingToSemanticValidity(configs, outerContext); + const semValidConfigs = cfgs[0]; + const semInvalidConfigs = cfgs[1]; + let alt = this.getAltThatFinishedDecisionEntryRule(semValidConfigs); + if (alt!==ATN.INVALID_ALT_NUMBER) { // semantically/syntactically viable path exists + return alt; + } + // Is there a syntactically valid path with a failed pred? + if (semInvalidConfigs.items.length>0) { + alt = this.getAltThatFinishedDecisionEntryRule(semInvalidConfigs); + if (alt!==ATN.INVALID_ALT_NUMBER) { // syntactically viable path exists + return alt; + } + } + return ATN.INVALID_ALT_NUMBER; + } + + getAltThatFinishedDecisionEntryRule(configs) { + const alts = []; + for(let i=0;i0 || ((c.state instanceof RuleStopState) && c.context.hasEmptyPath())) { + if(alts.indexOf(c.alt)<0) { + alts.push(c.alt); + } + } + } + if (alts.length===0) { + return ATN.INVALID_ALT_NUMBER; + } else { + return Math.min.apply(null, alts); + } + } + + /** + * Walk the list of configurations and split them according to + * those that have preds evaluating to true/false. If no pred, assume + * true pred and include in succeeded set. Returns Pair of sets. + * + * Create a new set so as not to alter the incoming parameter. + * + * Assumption: the input stream has been restored to the starting point + * prediction, which is where predicates need to evaluate.*/ + splitAccordingToSemanticValidity( configs, outerContext) { + const succeeded = new ATNConfigSet(configs.fullCtx); + const failed = new ATNConfigSet(configs.fullCtx); + for(let i=0;i50) { + throw "problem"; + } + } + if (config.state instanceof RuleStopState) { + // We hit rule end. If we have context info, use it + // run thru all possible stack tops in ctx + if (! config.context.isEmpty()) { + for (let i =0; i 0. + if (this._dfa !== null && this._dfa.precedenceDfa) { + if (t.outermostPrecedenceReturn === this._dfa.atnStartState.ruleIndex) { + c.precedenceFilterSuppressed = true; + } + } + + c.reachesIntoOuterContext += 1; + if (closureBusy.add(c)!==c) { + // avoid infinite recursion for right-recursive rules + continue; + } + configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method + newDepth -= 1; + if (this.debug) { + console.log("dips into outer ctx: " + c); + } + } else { + if (!t.isEpsilon && closureBusy.add(c)!==c){ + // avoid infinite recursion for EOF* and EOF+ + continue; + } + if (t instanceof RuleTransition) { + // latch when newDepth goes negative - once we step out of the entry context we can't return + if (newDepth >= 0) { + newDepth += 1; + } + } + } + this.closureCheckingStopState(c, configs, closureBusy, continueCollecting, fullCtx, newDepth, treatEofAsEpsilon); + } + } + } + + canDropLoopEntryEdgeInLeftRecursiveRule(config) { + // return False + const p = config.state; + // First check to see if we are in StarLoopEntryState generated during + // left-recursion elimination. For efficiency, also check if + // the context has an empty stack case. If so, it would mean + // global FOLLOW so we can't perform optimization + // Are we the special loop entry/exit state? or SLL wildcard + if(p.stateType !== ATNState.STAR_LOOP_ENTRY) + return false; + if(p.stateType !== ATNState.STAR_LOOP_ENTRY || !p.isPrecedenceDecision || + config.context.isEmpty() || config.context.hasEmptyPath()) + return false; + + // Require all return states to return back to the same rule that p is in. + const numCtxs = config.context.length; + for(let i=0; i=0) { + return this.parser.ruleNames[index]; + } else { + return ""; + } + } + + getEpsilonTarget(config, t, collectPredicates, inContext, fullCtx, treatEofAsEpsilon) { + switch(t.serializationType) { + case Transition.RULE: + return this.ruleTransition(config, t); + case Transition.PRECEDENCE: + return this.precedenceTransition(config, t, collectPredicates, inContext, fullCtx); + case Transition.PREDICATE: + return this.predTransition(config, t, collectPredicates, inContext, fullCtx); + case Transition.ACTION: + return this.actionTransition(config, t); + case Transition.EPSILON: + return new ATNConfig({state:t.target}, config); + case Transition.ATOM: + case Transition.RANGE: + case Transition.SET: + // EOF transitions act like epsilon transitions after the first EOF + // transition is traversed + if (treatEofAsEpsilon) { + if (t.matches(Token.EOF, 0, 1)) { + return new ATNConfig({state: t.target}, config); + } + } + return null; + default: + return null; + } + } + + actionTransition(config, t) { + if (this.debug) { + const index = t.actionIndex === -1 ? 65535 : t.actionIndex; + console.log("ACTION edge " + t.ruleIndex + ":" + index); + } + return new ATNConfig({state:t.target}, config); + } + + precedenceTransition(config, pt, collectPredicates, inContext, fullCtx) { + if (this.debug) { + console.log("PRED (collectPredicates=" + collectPredicates + ") " + + pt.precedence + ">=_p, ctx dependent=true"); + if (this.parser!==null) { + console.log("context surrounding pred is " + arrayToString(this.parser.getRuleInvocationStack())); + } + } + let c = null; + if (collectPredicates && inContext) { + if (fullCtx) { + // In full context mode, we can evaluate predicates on-the-fly + // during closure, which dramatically reduces the size of + // the config sets. It also obviates the need to test predicates + // later during conflict resolution. + const currentPosition = this._input.index; + this._input.seek(this._startIndex); + const predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext); + this._input.seek(currentPosition); + if (predSucceeds) { + c = new ATNConfig({state:pt.target}, config); // no pred context + } + } else { + const newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate()); + c = new ATNConfig({state:pt.target, semanticContext:newSemCtx}, config); + } + } else { + c = new ATNConfig({state:pt.target}, config); + } + if (this.debug) { + console.log("config from pred transition=" + c); + } + return c; + } + + predTransition(config, pt, collectPredicates, inContext, fullCtx) { + if (this.debug) { + console.log("PRED (collectPredicates=" + collectPredicates + ") " + pt.ruleIndex + + ":" + pt.predIndex + ", ctx dependent=" + pt.isCtxDependent); + if (this.parser!==null) { + console.log("context surrounding pred is " + arrayToString(this.parser.getRuleInvocationStack())); + } + } + let c = null; + if (collectPredicates && ((pt.isCtxDependent && inContext) || ! pt.isCtxDependent)) { + if (fullCtx) { + // In full context mode, we can evaluate predicates on-the-fly + // during closure, which dramatically reduces the size of + // the config sets. It also obviates the need to test predicates + // later during conflict resolution. + const currentPosition = this._input.index; + this._input.seek(this._startIndex); + const predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext); + this._input.seek(currentPosition); + if (predSucceeds) { + c = new ATNConfig({state:pt.target}, config); // no pred context + } + } else { + const newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate()); + c = new ATNConfig({state:pt.target, semanticContext:newSemCtx}, config); + } + } else { + c = new ATNConfig({state:pt.target}, config); + } + if (this.debug) { + console.log("config from pred transition=" + c); + } + return c; + } + + ruleTransition(config, t) { + if (this.debug) { + console.log("CALL rule " + this.getRuleName(t.target.ruleIndex) + ", ctx=" + config.context); + } + const returnState = t.followState; + const newContext = SingletonPredictionContext.create(config.context, returnState.stateNumber); + return new ATNConfig({state:t.target, context:newContext}, config ); + } + + getConflictingAlts(configs) { + const altsets = atn_PredictionMode.getConflictingAltSubsets(configs); + return atn_PredictionMode.getAlts(altsets); + } + + /** + * Sam pointed out a problem with the previous definition, v3, of + * ambiguous states. If we have another state associated with conflicting + * alternatives, we should keep going. For example, the following grammar + * + * s : (ID | ID ID?) ';' ; + * + * When the ATN simulation reaches the state before ';', it has a DFA + * state that looks like: [12|1|[], 6|2|[], 12|2|[]]. Naturally + * 12|1|[] and 12|2|[] conflict, but we cannot stop processing this node + * because alternative to has another way to continue, via [6|2|[]]. + * The key is that we have a single state that has config's only associated + * with a single alternative, 2, and crucially the state transitions + * among the configurations are all non-epsilon transitions. That means + * we don't consider any conflicts that include alternative 2. So, we + * ignore the conflict between alts 1 and 2. We ignore a set of + * conflicting alts when there is an intersection with an alternative + * associated with a single alt state in the state→config-list map. + * + * It's also the case that we might have two conflicting configurations but + * also a 3rd nonconflicting configuration for a different alternative: + * [1|1|[], 1|2|[], 8|3|[]]. This can come about from grammar: + * + * a : A | A | A B ; + * + * After matching input A, we reach the stop state for rule A, state 1. + * State 8 is the state right before B. Clearly alternatives 1 and 2 + * conflict and no amount of further lookahead will separate the two. + * However, alternative 3 will be able to continue and so we do not + * stop working on this state. In the previous example, we're concerned + * with states associated with the conflicting alternatives. Here alt + * 3 is not associated with the conflicting configs, but since we can continue + * looking for input reasonably, I don't declare the state done. We + * ignore a set of conflicting alts when we have an alternative + * that we still need to pursue + */ + getConflictingAltsOrUniqueAlt(configs) { + let conflictingAlts = null; + if (configs.uniqueAlt!== ATN.INVALID_ALT_NUMBER) { + conflictingAlts = new BitSet(); + conflictingAlts.add(configs.uniqueAlt); + } else { + conflictingAlts = configs.conflictingAlts; + } + return conflictingAlts; + } + + getTokenName(t) { + if (t===Token.EOF) { + return "EOF"; + } + if( this.parser!==null && this.parser.literalNames!==null) { + if (t >= this.parser.literalNames.length && t >= this.parser.symbolicNames.length) { + console.log("" + t + " ttype out of range: " + this.parser.literalNames); + console.log("" + this.parser.getInputStream().getTokens()); + } else { + const name = this.parser.literalNames[t] || this.parser.symbolicNames[t]; + return name + "<" + t + ">"; + } + } + return "" + t; + } + + getLookaheadName(input) { + return this.getTokenName(input.LA(1)); + } + + /** + * Used for debugging in adaptivePredict around execATN but I cut + * it out for clarity now that alg. works well. We can leave this + * "dead" code for a bit + */ + dumpDeadEndConfigs(nvae) { + console.log("dead end configs: "); + const decs = nvae.getDeadEndConfigs(); + for(let i=0; i0) { + const t = c.state.transitions[0]; + if (t instanceof AtomTransition) { + trans = "Atom "+ this.getTokenName(t.label); + } else if (t instanceof SetTransition) { + const neg = (t instanceof NotSetTransition); + trans = (neg ? "~" : "") + "Set " + t.set; + } + } + console.error(c.toString(this.parser, true) + ":" + trans); + } + } + + noViableAlt(input, outerContext, configs, startIndex) { + return new NoViableAltException(this.parser, input, input.get(startIndex), input.LT(1), configs, outerContext); + } + + getUniqueAlt(configs) { + let alt = ATN.INVALID_ALT_NUMBER; + for(let i=0;iIf {@code to} is {@code null}, this method returns {@code null}. + * Otherwise, this method returns the {@link DFAState} returned by calling + * {@link //addDFAState} for the {@code to} state.

          + * + * @param dfa The DFA + * @param from_ The source state for the edge + * @param t The input symbol + * @param to The target state for the edge + * + * @return If {@code to} is {@code null}, this method returns {@code null}; + * otherwise this method returns the result of calling {@link //addDFAState} + * on {@code to} + */ + addDFAEdge(dfa, from_, t, to) { + if( this.debug) { + console.log("EDGE " + from_ + " -> " + to + " upon " + this.getTokenName(t)); + } + if (to===null) { + return null; + } + to = this.addDFAState(dfa, to); // used existing if possible not incoming + if (from_===null || t < -1 || t > this.atn.maxTokenType) { + return to; + } + if (from_.edges===null) { + from_.edges = []; + } + from_.edges[t+1] = to; // connect + + if (this.debug) { + const literalNames = this.parser===null ? null : this.parser.literalNames; + const symbolicNames = this.parser===null ? null : this.parser.symbolicNames; + console.log("DFA=\n" + dfa.toString(literalNames, symbolicNames)); + } + return to; + } + + /** + * Add state {@code D} to the DFA if it is not already present, and return + * the actual instance stored in the DFA. If a state equivalent to {@code D} + * is already in the DFA, the existing state is returned. Otherwise this + * method returns {@code D} after adding it to the DFA. + * + *

          If {@code D} is {@link //ERROR}, this method returns {@link //ERROR} and + * does not change the DFA.

          + * + * @param dfa The dfa + * @param D The DFA state to add + * @return The state stored in the DFA. This will be either the existing + * state if {@code D} is already in the DFA, or {@code D} itself if the + * state was not already present + */ + addDFAState(dfa, D) { + if (D === ATNSimulator.ERROR) { + return D; + } + const existing = dfa.states.get(D); + if(existing!==null) { + return existing; + } + D.stateNumber = dfa.states.length; + if (! D.configs.readOnly) { + D.configs.optimizeConfigs(this); + D.configs.setReadonly(true); + } + dfa.states.add(D); + if (this.debug) { + console.log("adding new DFA state: " + D); + } + return D; + } + + reportAttemptingFullContext(dfa, conflictingAlts, configs, startIndex, stopIndex) { + if (this.debug || this.retry_debug) { + const interval = new Interval(startIndex, stopIndex + 1); + console.log("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs + + ", input=" + this.parser.getTokenStream().getText(interval)); + } + if (this.parser!==null) { + this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs); + } + } + + reportContextSensitivity(dfa, prediction, configs, startIndex, stopIndex) { + if (this.debug || this.retry_debug) { + const interval = new Interval(startIndex, stopIndex + 1); + console.log("reportContextSensitivity decision=" + dfa.decision + ":" + configs + + ", input=" + this.parser.getTokenStream().getText(interval)); + } + if (this.parser!==null) { + this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs); + } + } + + // If context sensitive parsing, we know it's ambiguity not conflict// + reportAmbiguity(dfa, D, startIndex, stopIndex, + exact, ambigAlts, configs ) { + if (this.debug || this.retry_debug) { + const interval = new Interval(startIndex, stopIndex + 1); + console.log("reportAmbiguity " + ambigAlts + ":" + configs + + ", input=" + this.parser.getTokenStream().getText(interval)); + } + if (this.parser!==null) { + this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs); + } + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/index.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + +/* harmony default export */ const atn = ({ ATN: ATN, ATNDeserializer: ATNDeserializer, LexerATNSimulator: LexerATNSimulator, ParserATNSimulator: ParserATNSimulator, PredictionMode: atn_PredictionMode }); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/DFASerializer.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +/** + * A DFA walker that knows how to dump them to serialized strings. + */ +class DFASerializer { + constructor(dfa, literalNames, symbolicNames) { + this.dfa = dfa; + this.literalNames = literalNames || []; + this.symbolicNames = symbolicNames || []; + } + + toString() { + if(this.dfa.s0 === null) { + return null; + } + let buf = ""; + const states = this.dfa.sortedStates(); + for(let i=0; i"); + buf = buf.concat(this.getStateString(t)); + buf = buf.concat('\n'); + } + } + } + } + return buf.length===0 ? null : buf; + } + + getEdgeLabel(i) { + if (i===0) { + return "EOF"; + } else if(this.literalNames !==null || this.symbolicNames!==null) { + return this.literalNames[i-1] || this.symbolicNames[i-1]; + } else { + return String.fromCharCode(i-1); + } + } + + getStateString(s) { + const baseStateStr = ( s.isAcceptState ? ":" : "") + "s" + s.stateNumber + ( s.requiresFullContext ? "^" : ""); + if(s.isAcceptState) { + if (s.predicates !== null) { + return baseStateStr + "=>" + arrayToString(s.predicates); + } else { + return baseStateStr + "=>" + s.prediction.toString(); + } + } else { + return baseStateStr; + } + } +} + + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/LexerDFASerializer.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class LexerDFASerializer extends DFASerializer { + constructor(dfa) { + super(dfa, null); + } + + getEdgeLabel(i) { + return "'" + String.fromCharCode(i) + "'"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/DFA.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + +class DFA { + constructor(atnStartState, decision) { + if (decision === undefined) { + decision = 0; + } + /** + * From which ATN state did we create this DFA? + */ + this.atnStartState = atnStartState; + this.decision = decision; + /** + * A set of all DFA states. Use {@link Map} so we can get old state back + * ({@link Set} only allows you to see if it's there). + */ + this._states = new HashSet(); + this.s0 = null; + /** + * {@code true} if this DFA is for a precedence decision; otherwise, + * {@code false}. This is the backing field for {@link //isPrecedenceDfa}, + * {@link //setPrecedenceDfa} + */ + this.precedenceDfa = false; + if (atnStartState instanceof StarLoopEntryState) + { + if (atnStartState.isPrecedenceDecision) { + this.precedenceDfa = true; + const precedenceState = new DFAState(null, new ATNConfigSet()); + precedenceState.edges = []; + precedenceState.isAcceptState = false; + precedenceState.requiresFullContext = false; + this.s0 = precedenceState; + } + } + } + + /** + * Get the start state for a specific precedence value. + * + * @param precedence The current precedence. + * @return The start state corresponding to the specified precedence, or + * {@code null} if no start state exists for the specified precedence. + * + * @throws IllegalStateException if this is not a precedence DFA. + * @see //isPrecedenceDfa() + */ + getPrecedenceStartState(precedence) { + if (!(this.precedenceDfa)) { + throw ("Only precedence DFAs may contain a precedence start state."); + } + // s0.edges is never null for a precedence DFA + if (precedence < 0 || precedence >= this.s0.edges.length) { + return null; + } + return this.s0.edges[precedence] || null; + } + + /** + * Set the start state for a specific precedence value. + * + * @param precedence The current precedence. + * @param startState The start state corresponding to the specified + * precedence. + * + * @throws IllegalStateException if this is not a precedence DFA. + * @see //isPrecedenceDfa() + */ + setPrecedenceStartState(precedence, startState) { + if (!(this.precedenceDfa)) { + throw ("Only precedence DFAs may contain a precedence start state."); + } + if (precedence < 0) { + return; + } + + /** + * synchronization on s0 here is ok. when the DFA is turned into a + * precedence DFA, s0 will be initialized once and not updated again + * s0.edges is never null for a precedence DFA + */ + this.s0.edges[precedence] = startState; + } + + /** + * Sets whether this is a precedence DFA. If the specified value differs + * from the current DFA configuration, the following actions are taken; + * otherwise no changes are made to the current DFA. + * + *
            + *
          • The {@link //states} map is cleared
          • + *
          • If {@code precedenceDfa} is {@code false}, the initial state + * {@link //s0} is set to {@code null}; otherwise, it is initialized to a new + * {@link DFAState} with an empty outgoing {@link DFAState//edges} array to + * store the start states for individual precedence values.
          • + *
          • The {@link //precedenceDfa} field is updated
          • + *
          + * + * @param precedenceDfa {@code true} if this is a precedence DFA; otherwise, + * {@code false} + */ + setPrecedenceDfa(precedenceDfa) { + if (this.precedenceDfa!==precedenceDfa) { + this._states = new HashSet(); + if (precedenceDfa) { + const precedenceState = new DFAState(null, new ATNConfigSet()); + precedenceState.edges = []; + precedenceState.isAcceptState = false; + precedenceState.requiresFullContext = false; + this.s0 = precedenceState; + } else { + this.s0 = null; + } + this.precedenceDfa = precedenceDfa; + } + } + + /** + * Return a list of all states in this DFA, ordered by state number. + */ + sortedStates() { + const list = this._states.values(); + return list.sort(function(a, b) { + return a.stateNumber - b.stateNumber; + }); + } + + toString(literalNames, symbolicNames) { + literalNames = literalNames || null; + symbolicNames = symbolicNames || null; + if (this.s0 === null) { + return ""; + } + const serializer = new DFASerializer(this, literalNames, symbolicNames); + return serializer.toString(); + } + + toLexerString() { + if (this.s0 === null) { + return ""; + } + const serializer = new LexerDFASerializer(this); + return serializer.toString(); + } + + get states(){ + return this._states; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/dfa/index.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + +/* harmony default export */ const dfa = ({ DFA: DFA, DFASerializer: DFASerializer, LexerDFASerializer: LexerDFASerializer, PredPrediction: PredPrediction }); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTreeListener.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +class ParseTreeListener { + visitTerminal(node) { + } + + visitErrorNode(node) { + } + + enterEveryRule(node) { + } + + exitEveryRule(node) { + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTreeVisitor.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +class ParseTreeVisitor { + visit(ctx) { + if (Array.isArray(ctx)) { + return ctx.map(function(child) { + return child.accept(this); + }, this); + } else { + return ctx.accept(this); + } + } + + visitChildren(ctx) { + if (ctx.children) { + return this.visit(ctx.children); + } else { + return null; + } + } + + visitTerminal(node) { + } + + visitErrorNode(node) { + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ParseTreeWalker.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +class ParseTreeWalker { + + /** + * Performs a walk on the given parse tree starting at the root and going down recursively + * with depth-first search. On each node, {@link ParseTreeWalker//enterRule} is called before + * recursively walking down into child nodes, then + * {@link ParseTreeWalker//exitRule} is called after the recursive call to wind up. + * @param listener The listener used by the walker to process grammar rules + * @param t The parse tree to be walked on + */ + walk(listener, t) { + const errorNode = t instanceof ErrorNode || + (t.isErrorNode !== undefined && t.isErrorNode()); + if (errorNode) { + listener.visitErrorNode(t); + } else if (t instanceof TerminalNode) { + listener.visitTerminal(t); + } else { + this.enterRule(listener, t); + for (let i = 0; i < t.getChildCount(); i++) { + const child = t.getChild(i); + this.walk(listener, child); + } + this.exitRule(listener, t); + } + } + + /** + * Enters a grammar rule by first triggering the generic event {@link ParseTreeListener//enterEveryRule} + * then by triggering the event specific to the given parse tree node + * @param listener The listener responding to the trigger events + * @param r The grammar rule containing the rule context + */ + enterRule(listener, r) { + const ctx = r.getRuleContext(); + listener.enterEveryRule(ctx); + ctx.enterRule(listener); + } + + /** + * Exits a grammar rule by first triggering the event specific to the given parse tree node + * then by triggering the generic event {@link ParseTreeListener//exitEveryRule} + * @param listener The listener responding to the trigger events + * @param r The grammar rule containing the rule context + */ + exitRule(listener, r) { + const ctx = r.getRuleContext(); + ctx.exitRule(listener); + listener.exitEveryRule(ctx); + } +} + +ParseTreeWalker.DEFAULT = new ParseTreeWalker(); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/index.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + +/* harmony default export */ const tree = ({ Trees: tree_Trees, RuleNode: RuleNode, ErrorNode: ErrorNode, TerminalNode: TerminalNode, ParseTreeListener: ParseTreeListener, ParseTreeVisitor: ParseTreeVisitor, ParseTreeWalker: ParseTreeWalker }); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/InputMismatchException.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +/** + * This signifies any kind of mismatched input exceptions such as + * when the current input does not match the expected token. + */ +class InputMismatchException extends RecognitionException { + constructor(recognizer) { + super({message: "", recognizer: recognizer, input: recognizer.getInputStream(), ctx: recognizer._ctx}); + this.offendingToken = recognizer.getCurrentToken(); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/FailedPredicateException.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * A semantic predicate failed during validation. Validation of predicates + * occurs when normally parsing the alternative just like matching a token. + * Disambiguating predicate evaluation occurs when we test a predicate during + * prediction. + */ +class FailedPredicateException extends RecognitionException { + constructor(recognizer, predicate, message) { + super({ + message: formatMessage(predicate, message || null), recognizer: recognizer, + input: recognizer.getInputStream(), ctx: recognizer._ctx + }); + const s = recognizer._interp.atn.states[recognizer.state] + const trans = s.transitions[0] + if (trans instanceof PredicateTransition) { + this.ruleIndex = trans.ruleIndex; + this.predicateIndex = trans.predIndex; + } else { + this.ruleIndex = 0; + this.predicateIndex = 0; + } + this.predicate = predicate; + this.offendingToken = recognizer.getCurrentToken(); + } +} + + +function formatMessage(predicate, message) { + if (message !==null) { + return message; + } else { + return "failed predicate: {" + predicate + "}?"; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/DiagnosticErrorListener.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + +/** + * This implementation of {@link ANTLRErrorListener} can be used to identify + * certain potential correctness and performance problems in grammars. "Reports" + * are made by calling {@link Parser//notifyErrorListeners} with the appropriate + * message. + * + *
            + *
          • Ambiguities: These are cases where more than one path through the + * grammar can match the input.
          • + *
          • Weak context sensitivity: These are cases where full-context + * prediction resolved an SLL conflict to a unique alternative which equaled the + * minimum alternative of the SLL conflict.
          • + *
          • Strong (forced) context sensitivity: These are cases where the + * full-context prediction resolved an SLL conflict to a unique alternative, + * and the minimum alternative of the SLL conflict was found to not be + * a truly viable alternative. Two-stage parsing cannot be used for inputs where + * this situation occurs.
          • + *
          + */ +class DiagnosticErrorListener extends ErrorListener { + constructor(exactOnly) { + super(); + exactOnly = exactOnly || true; + // whether all ambiguities or only exact ambiguities are reported. + this.exactOnly = exactOnly; + } + + reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { + if (this.exactOnly && !exact) { + return; + } + const msg = "reportAmbiguity d=" + + this.getDecisionDescription(recognizer, dfa) + + ": ambigAlts=" + + this.getConflictingAlts(ambigAlts, configs) + + ", input='" + + recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'" + recognizer.notifyErrorListeners(msg); + } + + reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { + const msg = "reportAttemptingFullContext d=" + + this.getDecisionDescription(recognizer, dfa) + + ", input='" + + recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'" + recognizer.notifyErrorListeners(msg); + } + + reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) { + const msg = "reportContextSensitivity d=" + + this.getDecisionDescription(recognizer, dfa) + + ", input='" + + recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'" + recognizer.notifyErrorListeners(msg); + } + + getDecisionDescription(recognizer, dfa) { + const decision = dfa.decision + const ruleIndex = dfa.atnStartState.ruleIndex + + const ruleNames = recognizer.ruleNames + if (ruleIndex < 0 || ruleIndex >= ruleNames.length) { + return "" + decision; + } + const ruleName = ruleNames[ruleIndex] || null + if (ruleName === null || ruleName.length === 0) { + return "" + decision; + } + return `${decision} (${ruleName})`; + } + + /** + * Computes the set of conflicting or ambiguous alternatives from a + * configuration set, if that information was not already provided by the + * parser. + * + * @param reportedAlts The set of conflicting or ambiguous alternatives, as + * reported by the parser. + * @param configs The conflicting or ambiguous configuration set. + * @return Returns {@code reportedAlts} if it is not {@code null}, otherwise + * returns the set of alternatives represented in {@code configs}. + */ + getConflictingAlts(reportedAlts, configs) { + if (reportedAlts !== null) { + return reportedAlts; + } + const result = new BitSet() + for (let i = 0; i < configs.items.length; i++) { + result.add(configs.items[i].alt); + } + return `{${result.values().join(", ")}}`; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ParseCancellationException.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +class ParseCancellationException extends Error { + constructor() { + super() + Error.captureStackTrace(this, ParseCancellationException); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/ErrorStrategy.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +class ErrorStrategy { + + reset(recognizer) { + } + + recoverInline(recognizer) { + } + + recover(recognizer, e) { + } + + sync(recognizer) { + } + + inErrorRecoveryMode(recognizer) { + } + + reportError(recognizer) { + } +} + + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/DefaultErrorStrategy.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + +/** + * This is the default implementation of {@link ANTLRErrorStrategy} used for + * error reporting and recovery in ANTLR parsers. + */ +class DefaultErrorStrategy extends ErrorStrategy { + constructor() { + super(); + /** + * Indicates whether the error strategy is currently "recovering from an + * error". This is used to suppress reporting multiple error messages while + * attempting to recover from a detected syntax error. + * + * @see //inErrorRecoveryMode + */ + this.errorRecoveryMode = false; + + /** + * The index into the input stream where the last error occurred. + * This is used to prevent infinite loops where an error is found + * but no token is consumed during recovery...another error is found, + * ad nauseum. This is a failsafe mechanism to guarantee that at least + * one token/tree node is consumed for two errors. + */ + this.lastErrorIndex = -1; + this.lastErrorStates = null; + this.nextTokensContext = null; + this.nextTokenState = 0; + } + + /** + *

          The default implementation simply calls {@link //endErrorCondition} to + * ensure that the handler is not in error recovery mode.

          + */ + reset(recognizer) { + this.endErrorCondition(recognizer); + } + + /** + * This method is called to enter error recovery mode when a recognition + * exception is reported. + * + * @param recognizer the parser instance + */ + beginErrorCondition(recognizer) { + this.errorRecoveryMode = true; + } + + inErrorRecoveryMode(recognizer) { + return this.errorRecoveryMode; + } + + /** + * This method is called to leave error recovery mode after recovering from + * a recognition exception. + * @param recognizer + */ + endErrorCondition(recognizer) { + this.errorRecoveryMode = false; + this.lastErrorStates = null; + this.lastErrorIndex = -1; + } + + /** + * {@inheritDoc} + *

          The default implementation simply calls {@link //endErrorCondition}.

          + */ + reportMatch(recognizer) { + this.endErrorCondition(recognizer); + } + + /** + * {@inheritDoc} + * + *

          The default implementation returns immediately if the handler is already + * in error recovery mode. Otherwise, it calls {@link //beginErrorCondition} + * and dispatches the reporting task based on the runtime type of {@code e} + * according to the following table.

          + * + *
            + *
          • {@link NoViableAltException}: Dispatches the call to + * {@link //reportNoViableAlternative}
          • + *
          • {@link InputMismatchException}: Dispatches the call to + * {@link //reportInputMismatch}
          • + *
          • {@link FailedPredicateException}: Dispatches the call to + * {@link //reportFailedPredicate}
          • + *
          • All other types: calls {@link Parser//notifyErrorListeners} to report + * the exception
          • + *
          + */ + reportError(recognizer, e) { + // if we've already reported an error and have not matched a token + // yet successfully, don't report any errors. + if(this.inErrorRecoveryMode(recognizer)) { + return; // don't report spurious errors + } + this.beginErrorCondition(recognizer); + if ( e instanceof NoViableAltException ) { + this.reportNoViableAlternative(recognizer, e); + } else if ( e instanceof InputMismatchException ) { + this.reportInputMismatch(recognizer, e); + } else if ( e instanceof FailedPredicateException ) { + this.reportFailedPredicate(recognizer, e); + } else { + console.log("unknown recognition error type: " + e.constructor.name); + console.log(e.stack); + recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e); + } + } + + /** + * + * {@inheritDoc} + * + *

          The default implementation resynchronizes the parser by consuming tokens + * until we find one in the resynchronization set--loosely the set of tokens + * that can follow the current rule.

          + * + */ + recover(recognizer, e) { + if (this.lastErrorIndex===recognizer.getInputStream().index && + this.lastErrorStates !== null && this.lastErrorStates.indexOf(recognizer.state)>=0) { + // uh oh, another error at same token index and previously-visited + // state in ATN; must be a case where LT(1) is in the recovery + // token set so nothing got consumed. Consume a single token + // at least to prevent an infinite loop; this is a failsafe. + recognizer.consume(); + } + this.lastErrorIndex = recognizer._input.index; + if (this.lastErrorStates === null) { + this.lastErrorStates = []; + } + this.lastErrorStates.push(recognizer.state); + const followSet = this.getErrorRecoverySet(recognizer) + this.consumeUntil(recognizer, followSet); + } + + /** + * The default implementation of {@link ANTLRErrorStrategy//sync} makes sure + * that the current lookahead symbol is consistent with what were expecting + * at this point in the ATN. You can call this anytime but ANTLR only + * generates code to check before subrules/loops and each iteration. + * + *

          Implements Jim Idle's magic sync mechanism in closures and optional + * subrules. E.g.,

          + * + *
          +     * a : sync ( stuff sync )* ;
          +     * sync : {consume to what can follow sync} ;
          +     * 
          + * + * At the start of a sub rule upon error, {@link //sync} performs single + * token deletion, if possible. If it can't do that, it bails on the current + * rule and uses the default error recovery, which consumes until the + * resynchronization set of the current rule. + * + *

          If the sub rule is optional ({@code (...)?}, {@code (...)*}, or block + * with an empty alternative), then the expected set includes what follows + * the subrule.

          + * + *

          During loop iteration, it consumes until it sees a token that can start a + * sub rule or what follows loop. Yes, that is pretty aggressive. We opt to + * stay in the loop as long as possible.

          + * + *

          ORIGINS

          + * + *

          Previous versions of ANTLR did a poor job of their recovery within loops. + * A single mismatch token or missing token would force the parser to bail + * out of the entire rules surrounding the loop. So, for rule

          + * + *
          +     * classDef : 'class' ID '{' member* '}'
          +     * 
          + * + * input with an extra token between members would force the parser to + * consume until it found the next class definition rather than the next + * member definition of the current class. + * + *

          This functionality cost a little bit of effort because the parser has to + * compare token set at the start of the loop and at each iteration. If for + * some reason speed is suffering for you, you can turn off this + * functionality by simply overriding this method as a blank { }.

          + * + */ + sync(recognizer) { + // If already recovering, don't try to sync + if (this.inErrorRecoveryMode(recognizer)) { + return; + } + const s = recognizer._interp.atn.states[recognizer.state]; + const la = recognizer.getTokenStream().LA(1); + // try cheaper subset first; might get lucky. seems to shave a wee bit off + const nextTokens = recognizer.atn.nextTokens(s); + if(nextTokens.contains(la)) { + this.nextTokensContext = null; + this.nextTokenState = ATNState.INVALID_STATE_NUMBER; + return; + } else if (nextTokens.contains(Token.EPSILON)) { + if(this.nextTokensContext === null) { + // It's possible the next token won't match information tracked + // by sync is restricted for performance. + this.nextTokensContext = recognizer._ctx; + this.nextTokensState = recognizer._stateNumber; + } + return; + } + switch (s.stateType) { + case ATNState.BLOCK_START: + case ATNState.STAR_BLOCK_START: + case ATNState.PLUS_BLOCK_START: + case ATNState.STAR_LOOP_ENTRY: + // report error and recover if possible + if( this.singleTokenDeletion(recognizer) !== null) { + return; + } else { + throw new InputMismatchException(recognizer); + } + case ATNState.PLUS_LOOP_BACK: + case ATNState.STAR_LOOP_BACK: + { + this.reportUnwantedToken(recognizer); + const expecting = new IntervalSet(); + expecting.addSet(recognizer.getExpectedTokens()); + const whatFollowsLoopIterationOrRule = expecting.addSet(this.getErrorRecoverySet(recognizer)); + this.consumeUntil(recognizer, whatFollowsLoopIterationOrRule); + } + break; + default: + // do nothing if we can't identify the exact kind of ATN state + } + } + + /** + * This is called by {@link //reportError} when the exception is a + * {@link NoViableAltException}. + * + * @see //reportError + * + * @param recognizer the parser instance + * @param e the recognition exception + */ + reportNoViableAlternative(recognizer, e) { + const tokens = recognizer.getTokenStream() + let input + if(tokens !== null) { + if (e.startToken.type===Token.EOF) { + input = ""; + } else { + input = tokens.getText(new Interval(e.startToken.tokenIndex, e.offendingToken.tokenIndex)); + } + } else { + input = ""; + } + const msg = "no viable alternative at input " + this.escapeWSAndQuote(input) + recognizer.notifyErrorListeners(msg, e.offendingToken, e); + } + + /** + * This is called by {@link //reportError} when the exception is an + * {@link InputMismatchException}. + * + * @see //reportError + * + * @param recognizer the parser instance + * @param e the recognition exception + */ + reportInputMismatch(recognizer, e) { + const msg = "mismatched input " + this.getTokenErrorDisplay(e.offendingToken) + + " expecting " + e.getExpectedTokens().toString(recognizer.literalNames, recognizer.symbolicNames) + recognizer.notifyErrorListeners(msg, e.offendingToken, e); + } + + /** + * This is called by {@link //reportError} when the exception is a + * {@link FailedPredicateException}. + * + * @see //reportError + * + * @param recognizer the parser instance + * @param e the recognition exception + */ + reportFailedPredicate(recognizer, e) { + const ruleName = recognizer.ruleNames[recognizer._ctx.ruleIndex] + const msg = "rule " + ruleName + " " + e.message + recognizer.notifyErrorListeners(msg, e.offendingToken, e); + } + + /** + * This method is called to report a syntax error which requires the removal + * of a token from the input stream. At the time this method is called, the + * erroneous symbol is current {@code LT(1)} symbol and has not yet been + * removed from the input stream. When this method returns, + * {@code recognizer} is in error recovery mode. + * + *

          This method is called when {@link //singleTokenDeletion} identifies + * single-token deletion as a viable recovery strategy for a mismatched + * input error.

          + * + *

          The default implementation simply returns if the handler is already in + * error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to + * enter error recovery mode, followed by calling + * {@link Parser//notifyErrorListeners}.

          + * + * @param recognizer the parser instance + * + */ + reportUnwantedToken(recognizer) { + if (this.inErrorRecoveryMode(recognizer)) { + return; + } + this.beginErrorCondition(recognizer); + const t = recognizer.getCurrentToken() + const tokenName = this.getTokenErrorDisplay(t) + const expecting = this.getExpectedTokens(recognizer) + const msg = "extraneous input " + tokenName + " expecting " + + expecting.toString(recognizer.literalNames, recognizer.symbolicNames) + recognizer.notifyErrorListeners(msg, t, null); + } + + /** + * This method is called to report a syntax error which requires the + * insertion of a missing token into the input stream. At the time this + * method is called, the missing token has not yet been inserted. When this + * method returns, {@code recognizer} is in error recovery mode. + * + *

          This method is called when {@link //singleTokenInsertion} identifies + * single-token insertion as a viable recovery strategy for a mismatched + * input error.

          + * + *

          The default implementation simply returns if the handler is already in + * error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to + * enter error recovery mode, followed by calling + * {@link Parser//notifyErrorListeners}.

          + * + * @param recognizer the parser instance + */ + reportMissingToken(recognizer) { + if ( this.inErrorRecoveryMode(recognizer)) { + return; + } + this.beginErrorCondition(recognizer); + const t = recognizer.getCurrentToken() + const expecting = this.getExpectedTokens(recognizer) + const msg = "missing " + expecting.toString(recognizer.literalNames, recognizer.symbolicNames) + + " at " + this.getTokenErrorDisplay(t) + recognizer.notifyErrorListeners(msg, t, null); + } + + /** + *

          The default implementation attempts to recover from the mismatched input + * by using single token insertion and deletion as described below. If the + * recovery attempt fails, this method throws an + * {@link InputMismatchException}.

          + * + *

          EXTRA TOKEN (single token deletion)

          + * + *

          {@code LA(1)} is not what we are looking for. If {@code LA(2)} has the + * right token, however, then assume {@code LA(1)} is some extra spurious + * token and delete it. Then consume and return the next token (which was + * the {@code LA(2)} token) as the successful result of the match operation.

          + * + *

          This recovery strategy is implemented by {@link + * //singleTokenDeletion}.

          + * + *

          MISSING TOKEN (single token insertion)

          + * + *

          If current token (at {@code LA(1)}) is consistent with what could come + * after the expected {@code LA(1)} token, then assume the token is missing + * and use the parser's {@link TokenFactory} to create it on the fly. The + * "insertion" is performed by returning the created token as the successful + * result of the match operation.

          + * + *

          This recovery strategy is implemented by {@link + * //singleTokenInsertion}.

          + * + *

          EXAMPLE

          + * + *

          For example, Input {@code i=(3;} is clearly missing the {@code ')'}. When + * the parser returns from the nested call to {@code expr}, it will have + * call chain:

          + * + *
          +     * stat → expr → atom
          +     * 
          + * + * and it will be trying to match the {@code ')'} at this point in the + * derivation: + * + *
          +     * => ID '=' '(' INT ')' ('+' atom)* ';'
          +     * ^
          +     * 
          + * + * The attempt to match {@code ')'} will fail when it sees {@code ';'} and + * call {@link //recoverInline}. To recover, it sees that {@code LA(1)==';'} + * is in the set of tokens that can follow the {@code ')'} token reference + * in rule {@code atom}. It can assume that you forgot the {@code ')'}. + */ + recoverInline(recognizer) { + // SINGLE TOKEN DELETION + const matchedSymbol = this.singleTokenDeletion(recognizer) + if (matchedSymbol !== null) { + // we have deleted the extra token. + // now, move past ttype token as if all were ok + recognizer.consume(); + return matchedSymbol; + } + // SINGLE TOKEN INSERTION + if (this.singleTokenInsertion(recognizer)) { + return this.getMissingSymbol(recognizer); + } + // even that didn't work; must throw the exception + throw new InputMismatchException(recognizer); + } + + /** + * This method implements the single-token insertion inline error recovery + * strategy. It is called by {@link //recoverInline} if the single-token + * deletion strategy fails to recover from the mismatched input. If this + * method returns {@code true}, {@code recognizer} will be in error recovery + * mode. + * + *

          This method determines whether or not single-token insertion is viable by + * checking if the {@code LA(1)} input symbol could be successfully matched + * if it were instead the {@code LA(2)} symbol. If this method returns + * {@code true}, the caller is responsible for creating and inserting a + * token with the correct type to produce this behavior.

          + * + * @param recognizer the parser instance + * @return {@code true} if single-token insertion is a viable recovery + * strategy for the current mismatched input, otherwise {@code false} + */ + singleTokenInsertion(recognizer) { + const currentSymbolType = recognizer.getTokenStream().LA(1) + // if current token is consistent with what could come after current + // ATN state, then we know we're missing a token; error recovery + // is free to conjure up and insert the missing token + const atn = recognizer._interp.atn + const currentState = atn.states[recognizer.state] + const next = currentState.transitions[0].target + const expectingAtLL2 = atn.nextTokens(next, recognizer._ctx) + if (expectingAtLL2.contains(currentSymbolType) ){ + this.reportMissingToken(recognizer); + return true; + } else { + return false; + } + } + + /** + * This method implements the single-token deletion inline error recovery + * strategy. It is called by {@link //recoverInline} to attempt to recover + * from mismatched input. If this method returns null, the parser and error + * handler state will not have changed. If this method returns non-null, + * {@code recognizer} will not be in error recovery mode since the + * returned token was a successful match. + * + *

          If the single-token deletion is successful, this method calls + * {@link //reportUnwantedToken} to report the error, followed by + * {@link Parser//consume} to actually "delete" the extraneous token. Then, + * before returning {@link //reportMatch} is called to signal a successful + * match.

          + * + * @param recognizer the parser instance + * @return the successfully matched {@link Token} instance if single-token + * deletion successfully recovers from the mismatched input, otherwise + * {@code null} + */ + singleTokenDeletion(recognizer) { + const nextTokenType = recognizer.getTokenStream().LA(2) + const expecting = this.getExpectedTokens(recognizer) + if (expecting.contains(nextTokenType)) { + this.reportUnwantedToken(recognizer); + // print("recoverFromMismatchedToken deleting " \ + // + str(recognizer.getTokenStream().LT(1)) \ + // + " since " + str(recognizer.getTokenStream().LT(2)) \ + // + " is what we want", file=sys.stderr) + recognizer.consume(); // simply delete extra token + // we want to return the token we're actually matching + const matchedSymbol = recognizer.getCurrentToken() + this.reportMatch(recognizer); // we know current token is correct + return matchedSymbol; + } else { + return null; + } + } + + /** + * Conjure up a missing token during error recovery. + * + * The recognizer attempts to recover from single missing + * symbols. But, actions might refer to that missing symbol. + * For example, x=ID {f($x);}. The action clearly assumes + * that there has been an identifier matched previously and that + * $x points at that token. If that token is missing, but + * the next token in the stream is what we want we assume that + * this token is missing and we keep going. Because we + * have to return some token to replace the missing token, + * we have to conjure one up. This method gives the user control + * over the tokens returned for missing tokens. Mostly, + * you will want to create something special for identifier + * tokens. For literals such as '{' and ',', the default + * action in the parser or tree parser works. It simply creates + * a CommonToken of the appropriate type. The text will be the token. + * If you change what tokens must be created by the lexer, + * override this method to create the appropriate tokens. + * + */ + getMissingSymbol(recognizer) { + const currentSymbol = recognizer.getCurrentToken() + const expecting = this.getExpectedTokens(recognizer) + const expectedTokenType = expecting.first() // get any element + let tokenText + if (expectedTokenType===Token.EOF) { + tokenText = ""; + } else { + tokenText = ""; + } + let current = currentSymbol + const lookback = recognizer.getTokenStream().LT(-1) + if (current.type===Token.EOF && lookback !== null) { + current = lookback; + } + return recognizer.getTokenFactory().create(current.source, + expectedTokenType, tokenText, Token.DEFAULT_CHANNEL, + -1, -1, current.line, current.column); + } + + getExpectedTokens(recognizer) { + return recognizer.getExpectedTokens(); + } + + /** + * How should a token be displayed in an error message? The default + * is to display just the text, but during development you might + * want to have a lot of information spit out. Override in that case + * to use t.toString() (which, for CommonToken, dumps everything about + * the token). This is better than forcing you to override a method in + * your token objects because you don't have to go modify your lexer + * so that it creates a new Java type. + */ + getTokenErrorDisplay(t) { + if (t === null) { + return ""; + } + let s = t.text + if (s === null) { + if (t.type===Token.EOF) { + s = ""; + } else { + s = "<" + t.type + ">"; + } + } + return this.escapeWSAndQuote(s); + } + + escapeWSAndQuote(s) { + s = s.replace(/\n/g,"\\n"); + s = s.replace(/\r/g,"\\r"); + s = s.replace(/\t/g,"\\t"); + return "'" + s + "'"; + } + + /** + * Compute the error recovery set for the current rule. During + * rule invocation, the parser pushes the set of tokens that can + * follow that rule reference on the stack; this amounts to + * computing FIRST of what follows the rule reference in the + * enclosing rule. See LinearApproximator.FIRST(). + * This local follow set only includes tokens + * from within the rule; i.e., the FIRST computation done by + * ANTLR stops at the end of a rule. + * + * EXAMPLE + * + * When you find a "no viable alt exception", the input is not + * consistent with any of the alternatives for rule r. The best + * thing to do is to consume tokens until you see something that + * can legally follow a call to r//or* any rule that called r. + * You don't want the exact set of viable next tokens because the + * input might just be missing a token--you might consume the + * rest of the input looking for one of the missing tokens. + * + * Consider grammar: + * + * a : '[' b ']' + * | '(' b ')' + * ; + * b : c '^' INT ; + * c : ID + * | INT + * ; + * + * At each rule invocation, the set of tokens that could follow + * that rule is pushed on a stack. Here are the various + * context-sensitive follow sets: + * + * FOLLOW(b1_in_a) = FIRST(']') = ']' + * FOLLOW(b2_in_a) = FIRST(')') = ')' + * FOLLOW(c_in_b) = FIRST('^') = '^' + * + * Upon erroneous input "[]", the call chain is + * + * a -> b -> c + * + * and, hence, the follow context stack is: + * + * depth follow set start of rule execution + * 0 a (from main()) + * 1 ']' b + * 2 '^' c + * + * Notice that ')' is not included, because b would have to have + * been called from a different context in rule a for ')' to be + * included. + * + * For error recovery, we cannot consider FOLLOW(c) + * (context-sensitive or otherwise). We need the combined set of + * all context-sensitive FOLLOW sets--the set of all tokens that + * could follow any reference in the call chain. We need to + * resync to one of those tokens. Note that FOLLOW(c)='^' and if + * we resync'd to that token, we'd consume until EOF. We need to + * sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}. + * In this case, for input "[]", LA(1) is ']' and in the set, so we would + * not consume anything. After printing an error, rule c would + * return normally. Rule b would not find the required '^' though. + * At this point, it gets a mismatched token error and throws an + * exception (since LA(1) is not in the viable following token + * set). The rule exception handler tries to recover, but finds + * the same recovery set and doesn't consume anything. Rule b + * exits normally returning to rule a. Now it finds the ']' (and + * with the successful match exits errorRecovery mode). + * + * So, you can see that the parser walks up the call chain looking + * for the token that was a member of the recovery set. + * + * Errors are not generated in errorRecovery mode. + * + * ANTLR's error recovery mechanism is based upon original ideas: + * + * "Algorithms + Data Structures = Programs" by Niklaus Wirth + * + * and + * + * "A note on error recovery in recursive descent parsers": + * http://portal.acm.org/citation.cfm?id=947902.947905 + * + * Later, Josef Grosch had some good ideas: + * + * "Efficient and Comfortable Error Recovery in Recursive Descent + * Parsers": + * ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip + * + * Like Grosch I implement context-sensitive FOLLOW sets that are combined + * at run-time upon error to avoid overhead during parsing. + */ + getErrorRecoverySet(recognizer) { + const atn = recognizer._interp.atn + let ctx = recognizer._ctx + const recoverSet = new IntervalSet() + while (ctx !== null && ctx.invokingState>=0) { + // compute what follows who invoked us + const invokingState = atn.states[ctx.invokingState] + const rt = invokingState.transitions[0] + const follow = atn.nextTokens(rt.followState) + recoverSet.addSet(follow); + ctx = ctx.parentCtx; + } + recoverSet.removeOne(Token.EPSILON); + return recoverSet; + } + +// Consume tokens until one matches the given token set.// + consumeUntil(recognizer, set) { + let ttype = recognizer.getTokenStream().LA(1) + while( ttype !== Token.EOF && !set.contains(ttype)) { + recognizer.consume(); + ttype = recognizer.getTokenStream().LA(1); + } + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/BailErrorStrategy.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +/** + * This implementation of {@link ANTLRErrorStrategy} responds to syntax errors + * by immediately canceling the parse operation with a + * {@link ParseCancellationException}. The implementation ensures that the + * {@link ParserRuleContext//exception} field is set for all parse tree nodes + * that were not completed prior to encountering the error. + * + *

          + * This error strategy is useful in the following scenarios.

          + * + *
            + *
          • Two-stage parsing: This error strategy allows the first + * stage of two-stage parsing to immediately terminate if an error is + * encountered, and immediately fall back to the second stage. In addition to + * avoiding wasted work by attempting to recover from errors here, the empty + * implementation of {@link BailErrorStrategy//sync} improves the performance of + * the first stage.
          • + *
          • Silent validation: When syntax errors are not being + * reported or logged, and the parse result is simply ignored if errors occur, + * the {@link BailErrorStrategy} avoids wasting work on recovering from errors + * when the result will be ignored either way.
          • + *
          + * + *

          + * {@code myparser.setErrorHandler(new BailErrorStrategy());}

          + * + * @see Parser//setErrorHandler(ANTLRErrorStrategy) + * */ +class BailErrorStrategy extends DefaultErrorStrategy { + + constructor() { + super(); + } + + /** + * Instead of recovering from exception {@code e}, re-throw it wrapped + * in a {@link ParseCancellationException} so it is not caught by the + * rule function catches. Use {@link Exception//getCause()} to get the + * original {@link RecognitionException}. + */ + recover(recognizer, e) { + let context = recognizer._ctx + while (context !== null) { + context.exception = e; + context = context.parentCtx; + } + throw new ParseCancellationException(e); + } + + /** + * Make sure we don't attempt to recover inline; if the parser + * successfully recovers, it won't throw an exception. + */ + recoverInline(recognizer) { + this.recover(recognizer, new InputMismatchException(recognizer)); + } + +// Make sure we don't attempt to recover from problems in subrules.// + sync(recognizer) { + // pass + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/error/index.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + + + +/* harmony default export */ const error = ({ + RecognitionException: RecognitionException, NoViableAltException: NoViableAltException, LexerNoViableAltException: LexerNoViableAltException, InputMismatchException: InputMismatchException, FailedPredicateException: FailedPredicateException, + DiagnosticErrorListener: DiagnosticErrorListener, BailErrorStrategy: BailErrorStrategy, DefaultErrorStrategy: DefaultErrorStrategy, ErrorListener: ErrorListener +}); + +// EXTERNAL MODULE: fs (ignored) +var fs_ignored_ = __webpack_require__(262); +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/CharStreams.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +/** + * Utility functions to create InputStreams from various sources. + * + * All returned InputStreams support the full range of Unicode + * up to U+10FFFF (the default behavior of InputStream only supports + * code points up to U+FFFF). + */ +/* harmony default export */ const CharStreams = ({ + // Creates an InputStream from a string. + fromString: function(str) { + return new InputStream(str, true); + }, + + /** + * Asynchronously creates an InputStream from a blob given the + * encoding of the bytes in that blob (defaults to 'utf8' if + * encoding is null). + * + * Invokes onLoad(result) on success, onError(error) on + * failure. + */ + fromBlob: function(blob, encoding, onLoad, onError) { + const reader = new window.FileReader(); + reader.onload = function(e) { + const is = new InputStream(e.target.result, true); + onLoad(is); + }; + reader.onerror = onError; + reader.readAsText(blob, encoding); + }, + + /** + * Creates an InputStream from a Buffer given the + * encoding of the bytes in that buffer (defaults to 'utf8' if + * encoding is null). + */ + fromBuffer: function(buffer, encoding) { + return new InputStream(buffer.toString(encoding), true); + }, + + /** Asynchronously creates an InputStream from a file on disk given + * the encoding of the bytes in that file (defaults to 'utf8' if + * encoding is null). + * + * Invokes callback(error, result) on completion. + */ + fromPath: function(path, encoding, callback) { + fs_ignored_.readFile(path, encoding, function(err, data) { + let is = null; + if (data !== null) { + is = new InputStream(data, true); + } + callback(err, is); + }); + }, + + /** + * Synchronously creates an InputStream given a path to a file + * on disk and the encoding of the bytes in that file (defaults to + * 'utf8' if encoding is null). + */ + fromPathSync: function(path, encoding) { + const data = fs_ignored_.readFileSync(path, encoding); + return new InputStream(data, true); + } +}); + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/FileStream.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +/** + * This is an InputStream that is loaded from a file all at once + * when you construct the object. + */ +class FileStream extends InputStream { + constructor(fileName, decodeToUnicodeCodePoints) { + const data = fs_ignored_.readFileSync(fileName, "utf8"); + super(data, decodeToUnicodeCodePoints); + this.fileName = fileName; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/TraceListener.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + +class TraceListener extends ParseTreeListener { + constructor(parser) { + super(); + this.parser = parser; + } + + enterEveryRule(ctx) { + console.log("enter " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text); + } + + visitTerminal(node) { + console.log("consume " + node.symbol + " rule " + this.parser.ruleNames[this.parser._ctx.ruleIndex]); + } + + exitEveryRule(ctx) { + console.log("exit " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/Parser.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + + + + +class Parser extends Recognizer { + /** + * this is all the parsing support code essentially; most of it is error + * recovery stuff. + */ + constructor(input) { + super(); + // The input stream. + this._input = null; + /** + * The error handling strategy for the parser. The default value is a new + * instance of {@link DefaultErrorStrategy}. + */ + this._errHandler = new DefaultErrorStrategy(); + this._precedenceStack = []; + this._precedenceStack.push(0); + /** + * The {@link ParserRuleContext} object for the currently executing rule. + * this is always non-null during the parsing process. + */ + this._ctx = null; + /** + * Specifies whether or not the parser should construct a parse tree during + * the parsing process. The default value is {@code true}. + */ + this.buildParseTrees = true; + /** + * When {@link //setTrace}{@code (true)} is called, a reference to the + * {@link TraceListener} is stored here so it can be easily removed in a + * later call to {@link //setTrace}{@code (false)}. The listener itself is + * implemented as a parser listener so this field is not directly used by + * other parser methods. + */ + this._tracer = null; + /** + * The list of {@link ParseTreeListener} listeners registered to receive + * events during the parse. + */ + this._parseListeners = null; + /** + * The number of syntax errors reported during parsing. this value is + * incremented each time {@link //notifyErrorListeners} is called. + */ + this._syntaxErrors = 0; + this.setInputStream(input); + } + + // reset the parser's state + reset() { + if (this._input !== null) { + this._input.seek(0); + } + this._errHandler.reset(this); + this._ctx = null; + this._syntaxErrors = 0; + this.setTrace(false); + this._precedenceStack = []; + this._precedenceStack.push(0); + if (this._interp !== null) { + this._interp.reset(); + } + } + + /** + * Match current input symbol against {@code ttype}. If the symbol type + * matches, {@link ANTLRErrorStrategy//reportMatch} and {@link //consume} are + * called to complete the match process. + * + *

          If the symbol type does not match, + * {@link ANTLRErrorStrategy//recoverInline} is called on the current error + * strategy to attempt recovery. If {@link //getBuildParseTree} is + * {@code true} and the token index of the symbol returned by + * {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to + * the parse tree by calling {@link ParserRuleContext//addErrorNode}.

          + * + * @param ttype the token type to match + * @return the matched symbol + * @throws RecognitionException if the current input symbol did not match + * {@code ttype} and the error strategy could not recover from the + * mismatched symbol + */ + match(ttype) { + let t = this.getCurrentToken(); + if (t.type === ttype) { + this._errHandler.reportMatch(this); + this.consume(); + } else { + t = this._errHandler.recoverInline(this); + if (this.buildParseTrees && t.tokenIndex === -1) { + // we must have conjured up a new token during single token + // insertion + // if it's not the current symbol + this._ctx.addErrorNode(t); + } + } + return t; + } + + /** + * Match current input symbol as a wildcard. If the symbol type matches + * (i.e. has a value greater than 0), {@link ANTLRErrorStrategy//reportMatch} + * and {@link //consume} are called to complete the match process. + * + *

          If the symbol type does not match, + * {@link ANTLRErrorStrategy//recoverInline} is called on the current error + * strategy to attempt recovery. If {@link //getBuildParseTree} is + * {@code true} and the token index of the symbol returned by + * {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to + * the parse tree by calling {@link ParserRuleContext//addErrorNode}.

          + * + * @return the matched symbol + * @throws RecognitionException if the current input symbol did not match + * a wildcard and the error strategy could not recover from the mismatched + * symbol + */ + matchWildcard() { + let t = this.getCurrentToken(); + if (t.type > 0) { + this._errHandler.reportMatch(this); + this.consume(); + } else { + t = this._errHandler.recoverInline(this); + if (this._buildParseTrees && t.tokenIndex === -1) { + // we must have conjured up a new token during single token + // insertion + // if it's not the current symbol + this._ctx.addErrorNode(t); + } + } + return t; + } + + getParseListeners() { + return this._parseListeners || []; + } + + /** + * Registers {@code listener} to receive events during the parsing process. + * + *

          To support output-preserving grammar transformations (including but not + * limited to left-recursion removal, automated left-factoring, and + * optimized code generation), calls to listener methods during the parse + * may differ substantially from calls made by + * {@link ParseTreeWalker//DEFAULT} used after the parse is complete. In + * particular, rule entry and exit events may occur in a different order + * during the parse than after the parser. In addition, calls to certain + * rule entry methods may be omitted.

          + * + *

          With the following specific exceptions, calls to listener events are + * deterministic, i.e. for identical input the calls to listener + * methods will be the same.

          + * + *
            + *
          • Alterations to the grammar used to generate code may change the + * behavior of the listener calls.
          • + *
          • Alterations to the command line options passed to ANTLR 4 when + * generating the parser may change the behavior of the listener calls.
          • + *
          • Changing the version of the ANTLR Tool used to generate the parser + * may change the behavior of the listener calls.
          • + *
          + * + * @param listener the listener to add + * + * @throws NullPointerException if {@code} listener is {@code null} + */ + addParseListener(listener) { + if (listener === null) { + throw "listener"; + } + if (this._parseListeners === null) { + this._parseListeners = []; + } + this._parseListeners.push(listener); + } + + /** + * Remove {@code listener} from the list of parse listeners. + * + *

          If {@code listener} is {@code null} or has not been added as a parse + * listener, this method does nothing.

          + * @param listener the listener to remove + */ + removeParseListener(listener) { + if (this._parseListeners !== null) { + const idx = this._parseListeners.indexOf(listener); + if (idx >= 0) { + this._parseListeners.splice(idx, 1); + } + if (this._parseListeners.length === 0) { + this._parseListeners = null; + } + } + } + + // Remove all parse listeners. + removeParseListeners() { + this._parseListeners = null; + } + + // Notify any parse listeners of an enter rule event. + triggerEnterRuleEvent() { + if (this._parseListeners !== null) { + const ctx = this._ctx; + this._parseListeners.forEach(function (listener) { + listener.enterEveryRule(ctx); + ctx.enterRule(listener); + }); + } + } + + /** + * Notify any parse listeners of an exit rule event. + * @see //addParseListener + */ + triggerExitRuleEvent() { + if (this._parseListeners !== null) { + // reverse order walk of listeners + const ctx = this._ctx; + this._parseListeners.slice(0).reverse().forEach(function (listener) { + ctx.exitRule(listener); + listener.exitEveryRule(ctx); + }); + } + } + + getTokenFactory() { + return this._input.tokenSource._factory; + } + + // Tell our token source and error strategy about a new way to create tokens. + setTokenFactory(factory) { + this._input.tokenSource._factory = factory; + } + + /** + * The ATN with bypass alternatives is expensive to create so we create it + * lazily. + * + * @throws UnsupportedOperationException if the current parser does not + * implement the {@link //getSerializedATN()} method. + */ + getATNWithBypassAlts() { + const serializedAtn = this.getSerializedATN(); + if (serializedAtn === null) { + throw "The current parser does not support an ATN with bypass alternatives."; + } + let result = this.bypassAltsAtnCache[serializedAtn]; + if (result === null) { + const deserializationOptions = new ATNDeserializationOptions(); + deserializationOptions.generateRuleBypassTransitions = true; + result = new ATNDeserializer(deserializationOptions) + .deserialize(serializedAtn); + this.bypassAltsAtnCache[serializedAtn] = result; + } + return result; + } + + getInputStream() { + return this.getTokenStream(); + } + + setInputStream(input) { + this.setTokenStream(input); + } + + getTokenStream() { + return this._input; + } + + // Set the token stream and reset the parser. + setTokenStream(input) { + this._input = null; + this.reset(); + this._input = input; + } + + /** + * Match needs to return the current input symbol, which gets put + * into the label for the associated token ref; e.g., x=ID. + */ + getCurrentToken() { + return this._input.LT(1); + } + + notifyErrorListeners(msg, offendingToken, err) { + offendingToken = offendingToken || null; + err = err || null; + if (offendingToken === null) { + offendingToken = this.getCurrentToken(); + } + this._syntaxErrors += 1; + const line = offendingToken.line; + const column = offendingToken.column; + const listener = this.getErrorListenerDispatch(); + listener.syntaxError(this, offendingToken, line, column, msg, err); + } + + /** + * Consume and return the {@linkplain //getCurrentToken current symbol}. + * + *

          E.g., given the following input with {@code A} being the current + * lookahead symbol, this function moves the cursor to {@code B} and returns + * {@code A}.

          + * + *
          +     * A B
          +     * ^
          +     * 
          + * + * If the parser is not in error recovery mode, the consumed symbol is added + * to the parse tree using {@link ParserRuleContext//addChild(Token)}, and + * {@link ParseTreeListener//visitTerminal} is called on any parse listeners. + * If the parser is in error recovery mode, the consumed symbol is + * added to the parse tree using + * {@link ParserRuleContext//addErrorNode(Token)}, and + * {@link ParseTreeListener//visitErrorNode} is called on any parse + * listeners. + */ + consume() { + const o = this.getCurrentToken(); + if (o.type !== Token.EOF) { + this.getInputStream().consume(); + } + const hasListener = this._parseListeners !== null && this._parseListeners.length > 0; + if (this.buildParseTrees || hasListener) { + let node; + if (this._errHandler.inErrorRecoveryMode(this)) { + node = this._ctx.addErrorNode(o); + } else { + node = this._ctx.addTokenNode(o); + } + node.invokingState = this.state; + if (hasListener) { + this._parseListeners.forEach(function (listener) { + if (node instanceof ErrorNode || (node.isErrorNode !== undefined && node.isErrorNode())) { + listener.visitErrorNode(node); + } else if (node instanceof TerminalNode) { + listener.visitTerminal(node); + } + }); + } + } + return o; + } + + addContextToParseTree() { + // add current context to parent if we have a parent + if (this._ctx.parentCtx !== null) { + this._ctx.parentCtx.addChild(this._ctx); + } + } + + /** + * Always called by generated parsers upon entry to a rule. Access field + * {@link //_ctx} get the current context. + */ + enterRule(localctx, state, ruleIndex) { + this.state = state; + this._ctx = localctx; + this._ctx.start = this._input.LT(1); + if (this.buildParseTrees) { + this.addContextToParseTree(); + } + this.triggerEnterRuleEvent(); + } + + exitRule() { + this._ctx.stop = this._input.LT(-1); + // trigger event on _ctx, before it reverts to parent + this.triggerExitRuleEvent(); + this.state = this._ctx.invokingState; + this._ctx = this._ctx.parentCtx; + } + + enterOuterAlt(localctx, altNum) { + localctx.setAltNumber(altNum); + // if we have new localctx, make sure we replace existing ctx + // that is previous child of parse tree + if (this.buildParseTrees && this._ctx !== localctx) { + if (this._ctx.parentCtx !== null) { + this._ctx.parentCtx.removeLastChild(); + this._ctx.parentCtx.addChild(localctx); + } + } + this._ctx = localctx; + } + + /** + * Get the precedence level for the top-most precedence rule. + * + * @return The precedence level for the top-most precedence rule, or -1 if + * the parser context is not nested within a precedence rule. + */ + getPrecedence() { + if (this._precedenceStack.length === 0) { + return -1; + } else { + return this._precedenceStack[this._precedenceStack.length - 1]; + } + } + + enterRecursionRule(localctx, state, ruleIndex, precedence) { + this.state = state; + this._precedenceStack.push(precedence); + this._ctx = localctx; + this._ctx.start = this._input.LT(1); + this.triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules + } + + // Like {@link //enterRule} but for recursive rules. + pushNewRecursionContext(localctx, state, ruleIndex) { + const previous = this._ctx; + previous.parentCtx = localctx; + previous.invokingState = state; + previous.stop = this._input.LT(-1); + + this._ctx = localctx; + this._ctx.start = previous.start; + if (this.buildParseTrees) { + this._ctx.addChild(previous); + } + this.triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules + } + + unrollRecursionContexts(parentCtx) { + this._precedenceStack.pop(); + this._ctx.stop = this._input.LT(-1); + const retCtx = this._ctx; // save current ctx (return value) + // unroll so _ctx is as it was before call to recursive method + const parseListeners = this.getParseListeners(); + if (parseListeners !== null && parseListeners.length > 0) { + while (this._ctx !== parentCtx) { + this.triggerExitRuleEvent(); + this._ctx = this._ctx.parentCtx; + } + } else { + this._ctx = parentCtx; + } + // hook into tree + retCtx.parentCtx = parentCtx; + if (this.buildParseTrees && parentCtx !== null) { + // add return ctx into invoking rule's tree + parentCtx.addChild(retCtx); + } + } + + getInvokingContext(ruleIndex) { + let ctx = this._ctx; + while (ctx !== null) { + if (ctx.ruleIndex === ruleIndex) { + return ctx; + } + ctx = ctx.parentCtx; + } + return null; + } + + precpred(localctx, precedence) { + return precedence >= this._precedenceStack[this._precedenceStack.length - 1]; + } + + inContext(context) { + // TODO: useful in parser? + return false; + } + + /** + * Checks whether or not {@code symbol} can follow the current state in the + * ATN. The behavior of this method is equivalent to the following, but is + * implemented such that the complete context-sensitive follow set does not + * need to be explicitly constructed. + * + *
          +     * return getExpectedTokens().contains(symbol);
          +     * 
          + * + * @param symbol the symbol type to check + * @return {@code true} if {@code symbol} can follow the current state in + * the ATN, otherwise {@code false}. + */ + isExpectedToken(symbol) { + const atn = this._interp.atn; + let ctx = this._ctx; + const s = atn.states[this.state]; + let following = atn.nextTokens(s); + if (following.contains(symbol)) { + return true; + } + if (!following.contains(Token.EPSILON)) { + return false; + } + while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) { + const invokingState = atn.states[ctx.invokingState]; + const rt = invokingState.transitions[0]; + following = atn.nextTokens(rt.followState); + if (following.contains(symbol)) { + return true; + } + ctx = ctx.parentCtx; + } + if (following.contains(Token.EPSILON) && symbol === Token.EOF) { + return true; + } else { + return false; + } + } + + /** + * Computes the set of input symbols which could follow the current parser + * state and context, as given by {@link //getState} and {@link //getContext}, + * respectively. + * + * @see ATN//getExpectedTokens(int, RuleContext) + */ + getExpectedTokens() { + return this._interp.atn.getExpectedTokens(this.state, this._ctx); + } + + getExpectedTokensWithinCurrentRule() { + const atn = this._interp.atn; + const s = atn.states[this.state]; + return atn.nextTokens(s); + } + + // Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found. + getRuleIndex(ruleName) { + const ruleIndex = this.getRuleIndexMap()[ruleName]; + if (ruleIndex !== null) { + return ruleIndex; + } else { + return -1; + } + } + + /** + * Return List<String> of the rule names in your parser instance + * leading up to a call to the current rule. You could override if + * you want more details such as the file/line info of where + * in the ATN a rule is invoked. + * + * this is very useful for error messages. + */ + getRuleInvocationStack(p) { + p = p || null; + if (p === null) { + p = this._ctx; + } + const stack = []; + while (p !== null) { + // compute what follows who invoked us + const ruleIndex = p.ruleIndex; + if (ruleIndex < 0) { + stack.push("n/a"); + } else { + stack.push(this.ruleNames[ruleIndex]); + } + p = p.parentCtx; + } + return stack; + } + + // For debugging and other purposes. + getDFAStrings() { + return this._interp.decisionToDFA.toString(); + } + + // For debugging and other purposes. + dumpDFA() { + let seenOne = false; + for (let i = 0; i < this._interp.decisionToDFA.length; i++) { + const dfa = this._interp.decisionToDFA[i]; + if (dfa.states.length > 0) { + if (seenOne) { + console.log(); + } + this.printer.println("Decision " + dfa.decision + ":"); + this.printer.print(dfa.toString(this.literalNames, this.symbolicNames)); + seenOne = true; + } + } + } + + /* + " printer = function() {\r\n" + + " this.println = function(s) { document.getElementById('output') += s + '\\n'; }\r\n" + + " this.print = function(s) { document.getElementById('output') += s; }\r\n" + + " };\r\n" + + */ + getSourceName() { + return this._input.sourceName; + } + + /** + * During a parse is sometimes useful to listen in on the rule entry and exit + * events as well as token matches. this is for quick and dirty debugging. + */ + setTrace(trace) { + if (!trace) { + this.removeParseListener(this._tracer); + this._tracer = null; + } else { + if (this._tracer !== null) { + this.removeParseListener(this._tracer); + } + this._tracer = new TraceListener(this); + this.addParseListener(this._tracer); + } + } +} + +/** + * this field maps from the serialized ATN string to the deserialized {@link + * ATN} with + * bypass alternatives. + * + * @see ATNDeserializationOptions//isGenerateRuleBypassTransitions() + */ +Parser.bypassAltsAtnCache = {}; + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/atn/PredictionContextCache.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + +/** + * Used to cache {@link PredictionContext} objects. Its used for the shared + * context cash associated with contexts in DFA states. This cache + * can be used for both lexers and parsers. + */ +class PredictionContextCache { + + constructor() { + this.cache = new HashMap_HashMap(); + } + + /** + * Add a context to the cache and return it. If the context already exists, + * return that one instead and do not add a new context to the cache. + * Protect shared cache from unsafe thread access. + */ + add(ctx) { + if (ctx === PredictionContext.EMPTY) { + return PredictionContext.EMPTY; + } + const existing = this.cache.get(ctx) || null; + if (existing !== null) { + return existing; + } + this.cache.set(ctx, ctx); + return ctx; + } + + get(ctx) { + return this.cache.get(ctx) || null; + } + + get length(){ + return this.cache.length; + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/TerminalNodeImpl.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + +class TerminalNodeImpl extends TerminalNode { + constructor(symbol) { + super(); + this.parentCtx = null; + this.symbol = symbol; + } + + getChild(i) { + return null; + } + + getSymbol() { + return this.symbol; + } + + getParent() { + return this.parentCtx; + } + + getPayload() { + return this.symbol; + } + + getSourceInterval() { + if (this.symbol === null) { + return Interval.INVALID_INTERVAL; + } + const tokenIndex = this.symbol.tokenIndex; + return new Interval(tokenIndex, tokenIndex); + } + + getChildCount() { + return 0; + } + + accept(visitor) { + return visitor.visitTerminal(this); + } + + getText() { + return this.symbol.text; + } + + toString() { + if (this.symbol.type === Token.EOF) { + return ""; + } else { + return this.symbol.text; + } + } +} + + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/tree/ErrorNodeImpl.js +/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. + * Use is of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +/** + * Represents a token that was consumed during resynchronization + * rather than during a valid match operation. For example, + * we will create this kind of a node during single token insertion + * and deletion as well as during "consume until error recovery set" + * upon no viable alternative exceptions. + */ + + +class ErrorNodeImpl extends TerminalNodeImpl { + constructor(token) { + super(token); + } + + isErrorNode() { + return true; + } + + accept(visitor) { + return visitor.visitErrorNode(this); + } +} + +;// CONCATENATED MODULE: ../node_modules/antlr4/src/antlr4/context/ParserRuleContext.js +/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + + + + + + + +/** + * A rule invocation record for parsing. + * + * Contains all of the information about the current rule not stored in the + * RuleContext. It handles parse tree children list, Any ATN state + * tracing, and the default values available for rule indications: + * start, stop, rule index, current alt number, current + * ATN state. + * + * Subclasses made for each rule and grammar track the parameters, + * return values, locals, and labels specific to that rule. These + * are the objects that are returned from rules. + * + * Note text is not an actual field of a rule return value; it is computed + * from start and stop using the input stream's toString() method. I + * could add a ctor to this so that we can pass in and store the input + * stream, but I'm not sure we want to do that. It would seem to be undefined + * to get the .text property anyway if the rule matches tokens from multiple + * input streams. + * + * I do not use getters for fields of objects that are used simply to + * group values such as this aggregate. The getters/setters are there to + * satisfy the superclass interface. + */ +class ParserRuleContext extends RuleContext { + constructor(parent, invokingStateNumber) { + parent = parent || null; + invokingStateNumber = invokingStateNumber || null; + super(parent, invokingStateNumber); + this.ruleIndex = -1; + /** + * If we are debugging or building a parse tree for a visitor, + * we need to track all of the tokens and rule invocations associated + * with this rule's context. This is empty for parsing w/o tree constr. + * operation because we don't the need to track the details about + * how we parse this rule. + */ + this.children = null; + this.start = null; + this.stop = null; + /** + * The exception that forced this rule to return. If the rule successfully + * completed, this is {@code null}. + */ + this.exception = null; + } + + // COPY a ctx (I'm deliberately not using copy constructor) + copyFrom(ctx) { + // from RuleContext + this.parentCtx = ctx.parentCtx; + this.invokingState = ctx.invokingState; + this.children = null; + this.start = ctx.start; + this.stop = ctx.stop; + // copy any error nodes to alt label node + if(ctx.children) { + this.children = []; + // reset parent pointer for any error nodes + ctx.children.map(function(child) { + if (child instanceof ErrorNodeImpl) { + this.children.push(child); + child.parentCtx = this; + } + }, this); + } + } + + // Double dispatch methods for listeners + enterRule(listener) { + } + + exitRule(listener) { + } + + // Does not set parent link; other add methods do that + addChild(child) { + if (this.children === null) { + this.children = []; + } + this.children.push(child); + return child; + } + + /** Used by enterOuterAlt to toss out a RuleContext previously added as + * we entered a rule. If we have // label, we will need to remove + * generic ruleContext object. + */ + removeLastChild() { + if (this.children !== null) { + this.children.pop(); + } + } + + addTokenNode(token) { + const node = new TerminalNodeImpl(token); + this.addChild(node); + node.parentCtx = this; + return node; + } + + addErrorNode(badToken) { + const node = new ErrorNodeImpl(badToken); + this.addChild(node); + node.parentCtx = this; + return node; + } + + getChild(i, type) { + type = type || null; + if (this.children === null || i < 0 || i >= this.children.length) { + return null; + } + if (type === null) { + return this.children[i]; + } else { + for(let j=0; j= this.children.length) { + return null; + } + for(let j=0; j new src_antlr4.dfa.DFA(ds, index) ); + +class n3_nodropLexer extends src_antlr4.Lexer { + + static grammarFileName = "n3_nodrop.g4"; + static channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]; + static modeNames = [ "DEFAULT_MODE" ]; + static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", "','", + "'a'", "'has'", "'is'", "'of'", "'='", "'<='", + "'=>'", "'<-'", "'!'", "'^'", "'['", "']'", "'('", + "')'", "'{'", "'}'", "'^^'" ]; + static symbolicNames = [ null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "COMMENT", + "BooleanLiteral", "String", "IRIREF", "PNAME_NS", + "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", + "DECIMAL", "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", + "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", + "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", + "WS", "IPLSTART", "ANON", "QuickVarName", "PN_CHARS_U", + "PN_CHARS_BASE", "PN_CHARS", "BASE", "PREFIX", + "PN_PREFIX", "PN_LOCAL", "PLX", "PERCENT", "HEX", + "PN_LOCAL_ESC" ]; + static ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", + "T__13", "T__14", "T__15", "T__16", "T__17", "T__18", + "T__19", "T__20", "T__21", "COMMENT", "BooleanLiteral", + "String", "IRIREF", "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", + "LANGTAG", "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", + "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", + "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", + "UCHAR", "ECHAR", "WS", "IPLSTART", "ANON", "QuickVarName", + "PN_CHARS_U", "PN_CHARS_BASE", "PN_CHARS", "BASE", + "PREFIX", "PN_PREFIX", "PN_LOCAL", "PLX", "PERCENT", + "HEX", "PN_LOCAL_ESC" ]; + + constructor(input) { + super(input) + this._interp = new src_antlr4.atn.LexerATNSimulator(this, n3_nodropLexer_atn, decisionsToDFA, new src_antlr4.PredictionContextCache()); + } + + get atn() { + return n3_nodropLexer_atn; + } +} + +n3_nodropLexer.EOF = src_antlr4.Token.EOF; +n3_nodropLexer.T__0 = 1; +n3_nodropLexer.T__1 = 2; +n3_nodropLexer.T__2 = 3; +n3_nodropLexer.T__3 = 4; +n3_nodropLexer.T__4 = 5; +n3_nodropLexer.T__5 = 6; +n3_nodropLexer.T__6 = 7; +n3_nodropLexer.T__7 = 8; +n3_nodropLexer.T__8 = 9; +n3_nodropLexer.T__9 = 10; +n3_nodropLexer.T__10 = 11; +n3_nodropLexer.T__11 = 12; +n3_nodropLexer.T__12 = 13; +n3_nodropLexer.T__13 = 14; +n3_nodropLexer.T__14 = 15; +n3_nodropLexer.T__15 = 16; +n3_nodropLexer.T__16 = 17; +n3_nodropLexer.T__17 = 18; +n3_nodropLexer.T__18 = 19; +n3_nodropLexer.T__19 = 20; +n3_nodropLexer.T__20 = 21; +n3_nodropLexer.T__21 = 22; +n3_nodropLexer.COMMENT = 23; +n3_nodropLexer.BooleanLiteral = 24; +n3_nodropLexer.String = 25; +n3_nodropLexer.IRIREF = 26; +n3_nodropLexer.PNAME_NS = 27; +n3_nodropLexer.PNAME_LN = 28; +n3_nodropLexer.BLANK_NODE_LABEL = 29; +n3_nodropLexer.LANGTAG = 30; +n3_nodropLexer.INTEGER = 31; +n3_nodropLexer.DECIMAL = 32; +n3_nodropLexer.DOUBLE = 33; +n3_nodropLexer.EXPONENT = 34; +n3_nodropLexer.STRING_LITERAL_LONG_SINGLE_QUOTE = 35; +n3_nodropLexer.STRING_LITERAL_LONG_QUOTE = 36; +n3_nodropLexer.STRING_LITERAL_QUOTE = 37; +n3_nodropLexer.STRING_LITERAL_SINGLE_QUOTE = 38; +n3_nodropLexer.UCHAR = 39; +n3_nodropLexer.ECHAR = 40; +n3_nodropLexer.WS = 41; +n3_nodropLexer.IPLSTART = 42; +n3_nodropLexer.ANON = 43; +n3_nodropLexer.QuickVarName = 44; +n3_nodropLexer.PN_CHARS_U = 45; +n3_nodropLexer.PN_CHARS_BASE = 46; +n3_nodropLexer.PN_CHARS = 47; +n3_nodropLexer.BASE = 48; +n3_nodropLexer.PREFIX = 49; +n3_nodropLexer.PN_PREFIX = 50; +n3_nodropLexer.PN_LOCAL = 51; +n3_nodropLexer.PLX = 52; +n3_nodropLexer.PERCENT = 53; +n3_nodropLexer.HEX = 54; +n3_nodropLexer.PN_LOCAL_ESC = 55; + + + + +;// CONCATENATED MODULE: ./parser/n3_nodrop/n3_nodropListener.js +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start + + +// This class defines a complete listener for a parse tree produced by n3_nodropParser. +class n3_nodropListener extends src_antlr4.tree.ParseTreeListener { + + // Enter a parse tree produced by n3_nodropParser#n3Doc. + enterN3Doc(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#n3Doc. + exitN3Doc(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#n3Statement. + enterN3Statement(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#n3Statement. + exitN3Statement(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#n3Directive. + enterN3Directive(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#n3Directive. + exitN3Directive(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#sparqlDirective. + enterSparqlDirective(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#sparqlDirective. + exitSparqlDirective(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#sparqlBase. + enterSparqlBase(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#sparqlBase. + exitSparqlBase(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#sparqlPrefix. + enterSparqlPrefix(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#sparqlPrefix. + exitSparqlPrefix(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#prefixID. + enterPrefixID(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#prefixID. + exitPrefixID(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#base. + enterBase(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#base. + exitBase(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#triples. + enterTriples(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#triples. + exitTriples(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#predicateObjectList. + enterPredicateObjectList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#predicateObjectList. + exitPredicateObjectList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#objectList. + enterObjectList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#objectList. + exitObjectList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#verb. + enterVerb(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#verb. + exitVerb(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#subject. + enterSubject(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#subject. + exitSubject(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#predicate. + enterPredicate(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#predicate. + exitPredicate(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#object. + enterObject(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#object. + exitObject(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#expression. + enterExpression(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#expression. + exitExpression(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#path. + enterPath(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#path. + exitPath(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#pathItem. + enterPathItem(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#pathItem. + exitPathItem(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#literal. + enterLiteral(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#literal. + exitLiteral(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#blankNodePropertyList. + enterBlankNodePropertyList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#blankNodePropertyList. + exitBlankNodePropertyList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#iriPropertyList. + enterIriPropertyList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#iriPropertyList. + exitIriPropertyList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#collection. + enterCollection(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#collection. + exitCollection(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#formula. + enterFormula(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#formula. + exitFormula(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#formulaContent. + enterFormulaContent(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#formulaContent. + exitFormulaContent(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#numericLiteral. + enterNumericLiteral(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#numericLiteral. + exitNumericLiteral(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#rdfLiteral. + enterRdfLiteral(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#rdfLiteral. + exitRdfLiteral(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#iri. + enterIri(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#iri. + exitIri(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#prefixedName. + enterPrefixedName(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#prefixedName. + exitPrefixedName(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#blankNode. + enterBlankNode(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#blankNode. + exitBlankNode(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#quickVar. + enterQuickVar(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#quickVar. + exitQuickVar(ctx) { + } + + + +} +;// CONCATENATED MODULE: ./parser/n3_nodrop/n3_nodropVisitor.js +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start + + +// This class defines a complete generic visitor for a parse tree produced by n3_nodropParser. + +class n3_nodropVisitor extends src_antlr4.tree.ParseTreeVisitor { + + // Visit a parse tree produced by n3_nodropParser#n3Doc. + visitN3Doc(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#n3Statement. + visitN3Statement(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#n3Directive. + visitN3Directive(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#sparqlDirective. + visitSparqlDirective(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#sparqlBase. + visitSparqlBase(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#sparqlPrefix. + visitSparqlPrefix(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#prefixID. + visitPrefixID(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#base. + visitBase(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#triples. + visitTriples(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#predicateObjectList. + visitPredicateObjectList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#objectList. + visitObjectList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#verb. + visitVerb(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#subject. + visitSubject(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#predicate. + visitPredicate(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#object. + visitObject(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#expression. + visitExpression(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#path. + visitPath(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#pathItem. + visitPathItem(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#literal. + visitLiteral(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#iriPropertyList. + visitIriPropertyList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#collection. + visitCollection(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#formula. + visitFormula(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#formulaContent. + visitFormulaContent(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#numericLiteral. + visitNumericLiteral(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#rdfLiteral. + visitRdfLiteral(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#iri. + visitIri(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#prefixedName. + visitPrefixedName(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#blankNode. + visitBlankNode(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#quickVar. + visitQuickVar(ctx) { + return this.visitChildren(ctx); + } + + + +} +;// CONCATENATED MODULE: ./parser/n3_nodrop/n3_nodropParser.js +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start + + + + +const n3_nodropParser_serializedATN = [4,1,55,224,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7, +4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12, +2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2, +20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27, +7,27,2,28,7,28,2,29,7,29,1,0,1,0,1,0,1,0,5,0,65,8,0,10,0,12,0,68,9,0,1,0, +1,0,1,1,1,1,3,1,74,8,1,1,2,1,2,3,2,78,8,2,1,3,1,3,3,3,82,8,3,1,4,1,4,1,4, +1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,3,8,100,8,8,1,9,1,9, +1,9,1,9,1,9,1,9,3,9,108,8,9,5,9,110,8,9,10,9,12,9,113,9,9,1,10,1,10,1,10, +5,10,118,8,10,10,10,12,10,121,9,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1, +11,1,11,1,11,1,11,3,11,134,8,11,1,12,1,12,1,13,1,13,1,13,3,13,141,8,13,1, +14,1,14,1,15,1,15,1,16,1,16,1,16,1,16,1,16,3,16,152,8,16,1,17,1,17,1,17, +1,17,1,17,1,17,1,17,1,17,3,17,162,8,17,1,18,1,18,1,18,3,18,167,8,18,1,19, +1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,5,21,180,8,21,10,21,12, +21,183,9,21,1,21,1,21,1,22,1,22,3,22,189,8,22,1,22,1,22,1,23,1,23,1,23,3, +23,196,8,23,3,23,198,8,23,1,23,1,23,3,23,202,8,23,3,23,204,8,23,1,24,1,24, +1,25,1,25,1,25,1,25,3,25,212,8,25,1,26,1,26,3,26,216,8,26,1,27,1,27,1,28, +1,28,1,29,1,29,1,29,0,0,30,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32, +34,36,38,40,42,44,46,48,50,52,54,56,58,0,3,1,0,31,33,1,0,27,28,2,0,29,29, +43,43,229,0,66,1,0,0,0,2,73,1,0,0,0,4,77,1,0,0,0,6,81,1,0,0,0,8,83,1,0,0, +0,10,86,1,0,0,0,12,90,1,0,0,0,14,94,1,0,0,0,16,97,1,0,0,0,18,101,1,0,0,0, +20,114,1,0,0,0,22,133,1,0,0,0,24,135,1,0,0,0,26,140,1,0,0,0,28,142,1,0,0, +0,30,144,1,0,0,0,32,146,1,0,0,0,34,161,1,0,0,0,36,166,1,0,0,0,38,168,1,0, +0,0,40,172,1,0,0,0,42,177,1,0,0,0,44,186,1,0,0,0,46,203,1,0,0,0,48,205,1, +0,0,0,50,207,1,0,0,0,52,215,1,0,0,0,54,217,1,0,0,0,56,219,1,0,0,0,58,221, +1,0,0,0,60,61,3,2,1,0,61,62,5,1,0,0,62,65,1,0,0,0,63,65,3,6,3,0,64,60,1, +0,0,0,64,63,1,0,0,0,65,68,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,69,1,0, +0,0,68,66,1,0,0,0,69,70,5,0,0,1,70,1,1,0,0,0,71,74,3,4,2,0,72,74,3,16,8, +0,73,71,1,0,0,0,73,72,1,0,0,0,74,3,1,0,0,0,75,78,3,12,6,0,76,78,3,14,7,0, +77,75,1,0,0,0,77,76,1,0,0,0,78,5,1,0,0,0,79,82,3,8,4,0,80,82,3,10,5,0,81, +79,1,0,0,0,81,80,1,0,0,0,82,7,1,0,0,0,83,84,5,48,0,0,84,85,5,26,0,0,85,9, +1,0,0,0,86,87,5,49,0,0,87,88,5,27,0,0,88,89,5,26,0,0,89,11,1,0,0,0,90,91, +5,2,0,0,91,92,5,27,0,0,92,93,5,26,0,0,93,13,1,0,0,0,94,95,5,3,0,0,95,96, +5,26,0,0,96,15,1,0,0,0,97,99,3,24,12,0,98,100,3,18,9,0,99,98,1,0,0,0,99, +100,1,0,0,0,100,17,1,0,0,0,101,102,3,22,11,0,102,111,3,20,10,0,103,107,5, +4,0,0,104,105,3,22,11,0,105,106,3,20,10,0,106,108,1,0,0,0,107,104,1,0,0, +0,107,108,1,0,0,0,108,110,1,0,0,0,109,103,1,0,0,0,110,113,1,0,0,0,111,109, +1,0,0,0,111,112,1,0,0,0,112,19,1,0,0,0,113,111,1,0,0,0,114,119,3,28,14,0, +115,116,5,5,0,0,116,118,3,28,14,0,117,115,1,0,0,0,118,121,1,0,0,0,119,117, +1,0,0,0,119,120,1,0,0,0,120,21,1,0,0,0,121,119,1,0,0,0,122,134,3,26,13,0, +123,134,5,6,0,0,124,125,5,7,0,0,125,134,3,30,15,0,126,127,5,8,0,0,127,128, +3,30,15,0,128,129,5,9,0,0,129,134,1,0,0,0,130,134,5,10,0,0,131,134,5,11, +0,0,132,134,5,12,0,0,133,122,1,0,0,0,133,123,1,0,0,0,133,124,1,0,0,0,133, +126,1,0,0,0,133,130,1,0,0,0,133,131,1,0,0,0,133,132,1,0,0,0,134,23,1,0,0, +0,135,136,3,30,15,0,136,25,1,0,0,0,137,141,3,30,15,0,138,139,5,13,0,0,139, +141,3,30,15,0,140,137,1,0,0,0,140,138,1,0,0,0,141,27,1,0,0,0,142,143,3,30, +15,0,143,29,1,0,0,0,144,145,3,32,16,0,145,31,1,0,0,0,146,151,3,34,17,0,147, +148,5,14,0,0,148,152,3,32,16,0,149,150,5,15,0,0,150,152,3,32,16,0,151,147, +1,0,0,0,151,149,1,0,0,0,151,152,1,0,0,0,152,33,1,0,0,0,153,162,3,52,26,0, +154,162,3,56,28,0,155,162,3,58,29,0,156,162,3,42,21,0,157,162,3,38,19,0, +158,162,3,40,20,0,159,162,3,36,18,0,160,162,3,44,22,0,161,153,1,0,0,0,161, +154,1,0,0,0,161,155,1,0,0,0,161,156,1,0,0,0,161,157,1,0,0,0,161,158,1,0, +0,0,161,159,1,0,0,0,161,160,1,0,0,0,162,35,1,0,0,0,163,167,3,50,25,0,164, +167,3,48,24,0,165,167,5,24,0,0,166,163,1,0,0,0,166,164,1,0,0,0,166,165,1, +0,0,0,167,37,1,0,0,0,168,169,5,16,0,0,169,170,3,18,9,0,170,171,5,17,0,0, +171,39,1,0,0,0,172,173,5,42,0,0,173,174,3,52,26,0,174,175,3,18,9,0,175,176, +5,17,0,0,176,41,1,0,0,0,177,181,5,18,0,0,178,180,3,28,14,0,179,178,1,0,0, +0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183,181, +1,0,0,0,184,185,5,19,0,0,185,43,1,0,0,0,186,188,5,20,0,0,187,189,3,46,23, +0,188,187,1,0,0,0,188,189,1,0,0,0,189,190,1,0,0,0,190,191,5,21,0,0,191,45, +1,0,0,0,192,197,3,2,1,0,193,195,5,1,0,0,194,196,3,46,23,0,195,194,1,0,0, +0,195,196,1,0,0,0,196,198,1,0,0,0,197,193,1,0,0,0,197,198,1,0,0,0,198,204, +1,0,0,0,199,201,3,6,3,0,200,202,3,46,23,0,201,200,1,0,0,0,201,202,1,0,0, +0,202,204,1,0,0,0,203,192,1,0,0,0,203,199,1,0,0,0,204,47,1,0,0,0,205,206, +7,0,0,0,206,49,1,0,0,0,207,211,5,25,0,0,208,212,5,30,0,0,209,210,5,22,0, +0,210,212,3,52,26,0,211,208,1,0,0,0,211,209,1,0,0,0,211,212,1,0,0,0,212, +51,1,0,0,0,213,216,5,26,0,0,214,216,3,54,27,0,215,213,1,0,0,0,215,214,1, +0,0,0,216,53,1,0,0,0,217,218,7,1,0,0,218,55,1,0,0,0,219,220,7,2,0,0,220, +57,1,0,0,0,221,222,5,44,0,0,222,59,1,0,0,0,22,64,66,73,77,81,99,107,111, +119,133,140,151,161,166,181,188,195,197,201,203,211,215]; + + +const n3_nodropParser_atn = new src_antlr4.atn.ATNDeserializer().deserialize(n3_nodropParser_serializedATN); + +const n3_nodropParser_decisionsToDFA = n3_nodropParser_atn.decisionToState.map( (ds, index) => new src_antlr4.dfa.DFA(ds, index) ); + +const sharedContextCache = new src_antlr4.PredictionContextCache(); + +class n3_nodropParser extends src_antlr4.Parser { + + static grammarFileName = "n3_nodrop.g4"; + static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", + "','", "'a'", "'has'", "'is'", "'of'", "'='", + "'<='", "'=>'", "'<-'", "'!'", "'^'", "'['", + "']'", "'('", "')'", "'{'", "'}'", "'^^'" ]; + static symbolicNames = [ null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "COMMENT", + "BooleanLiteral", "String", "IRIREF", "PNAME_NS", + "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", + "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", + "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", + "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", + "UCHAR", "ECHAR", "WS", "IPLSTART", "ANON", + "QuickVarName", "PN_CHARS_U", "PN_CHARS_BASE", + "PN_CHARS", "BASE", "PREFIX", "PN_PREFIX", + "PN_LOCAL", "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; + static ruleNames = [ "n3Doc", "n3Statement", "n3Directive", "sparqlDirective", + "sparqlBase", "sparqlPrefix", "prefixID", "base", + "triples", "predicateObjectList", "objectList", + "verb", "subject", "predicate", "object", "expression", + "path", "pathItem", "literal", "blankNodePropertyList", + "iriPropertyList", "collection", "formula", "formulaContent", + "numericLiteral", "rdfLiteral", "iri", "prefixedName", + "blankNode", "quickVar" ]; + + constructor(input) { + super(input); + this._interp = new src_antlr4.atn.ParserATNSimulator(this, n3_nodropParser_atn, n3_nodropParser_decisionsToDFA, sharedContextCache); + this.ruleNames = n3_nodropParser.ruleNames; + this.literalNames = n3_nodropParser.literalNames; + this.symbolicNames = n3_nodropParser.symbolicNames; + } + + get atn() { + return n3_nodropParser_atn; + } + + + + n3Doc() { + let localctx = new N3DocContext(this, this._ctx, this.state); + this.enterRule(localctx, 0, n3_nodropParser.RULE_n3Doc); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 66; + this._errHandler.sync(this); + _la = this._input.LA(1); + while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 64; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + case n3_nodropParser.T__2: + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.state = 60; + this.n3Statement(); + this.state = 61; + this.match(n3_nodropParser.T__0); + break; + case n3_nodropParser.BASE: + case n3_nodropParser.PREFIX: + this.state = 63; + this.sparqlDirective(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + this.state = 68; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 69; + this.match(n3_nodropParser.EOF); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + n3Statement() { + let localctx = new N3StatementContext(this, this._ctx, this.state); + this.enterRule(localctx, 2, n3_nodropParser.RULE_n3Statement); + try { + this.state = 73; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + case n3_nodropParser.T__2: + this.enterOuterAlt(localctx, 1); + this.state = 71; + this.n3Directive(); + break; + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 2); + this.state = 72; + this.triples(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + n3Directive() { + let localctx = new N3DirectiveContext(this, this._ctx, this.state); + this.enterRule(localctx, 4, n3_nodropParser.RULE_n3Directive); + try { + this.state = 77; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + this.enterOuterAlt(localctx, 1); + this.state = 75; + this.prefixID(); + break; + case n3_nodropParser.T__2: + this.enterOuterAlt(localctx, 2); + this.state = 76; + this.base(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlDirective() { + let localctx = new SparqlDirectiveContext(this, this._ctx, this.state); + this.enterRule(localctx, 6, n3_nodropParser.RULE_sparqlDirective); + try { + this.state = 81; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.BASE: + this.enterOuterAlt(localctx, 1); + this.state = 79; + this.sparqlBase(); + break; + case n3_nodropParser.PREFIX: + this.enterOuterAlt(localctx, 2); + this.state = 80; + this.sparqlPrefix(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlBase() { + let localctx = new SparqlBaseContext(this, this._ctx, this.state); + this.enterRule(localctx, 8, n3_nodropParser.RULE_sparqlBase); + try { + this.enterOuterAlt(localctx, 1); + this.state = 83; + this.match(n3_nodropParser.BASE); + this.state = 84; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlPrefix() { + let localctx = new SparqlPrefixContext(this, this._ctx, this.state); + this.enterRule(localctx, 10, n3_nodropParser.RULE_sparqlPrefix); + try { + this.enterOuterAlt(localctx, 1); + this.state = 86; + this.match(n3_nodropParser.PREFIX); + this.state = 87; + this.match(n3_nodropParser.PNAME_NS); + this.state = 88; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + prefixID() { + let localctx = new PrefixIDContext(this, this._ctx, this.state); + this.enterRule(localctx, 12, n3_nodropParser.RULE_prefixID); + try { + this.enterOuterAlt(localctx, 1); + this.state = 90; + this.match(n3_nodropParser.T__1); + this.state = 91; + this.match(n3_nodropParser.PNAME_NS); + this.state = 92; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + base() { + let localctx = new BaseContext(this, this._ctx, this.state); + this.enterRule(localctx, 14, n3_nodropParser.RULE_base); + try { + this.enterOuterAlt(localctx, 1); + this.state = 94; + this.match(n3_nodropParser.T__2); + this.state = 95; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + triples() { + let localctx = new TriplesContext(this, this._ctx, this.state); + this.enterRule(localctx, 16, n3_nodropParser.RULE_triples); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 97; + this.subject(); + this.state = 99; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__5) | (1 << n3_nodropParser.T__6) | (1 << n3_nodropParser.T__7) | (1 << n3_nodropParser.T__9) | (1 << n3_nodropParser.T__10) | (1 << n3_nodropParser.T__11) | (1 << n3_nodropParser.T__12) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)))) !== 0)) { + this.state = 98; + this.predicateObjectList(); + } + + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + predicateObjectList() { + let localctx = new PredicateObjectListContext(this, this._ctx, this.state); + this.enterRule(localctx, 18, n3_nodropParser.RULE_predicateObjectList); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 101; + this.verb(); + this.state = 102; + this.objectList(); + this.state = 111; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(_la===n3_nodropParser.T__3) { + this.state = 103; + this.match(n3_nodropParser.T__3); + this.state = 107; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__5) | (1 << n3_nodropParser.T__6) | (1 << n3_nodropParser.T__7) | (1 << n3_nodropParser.T__9) | (1 << n3_nodropParser.T__10) | (1 << n3_nodropParser.T__11) | (1 << n3_nodropParser.T__12) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)))) !== 0)) { + this.state = 104; + this.verb(); + this.state = 105; + this.objectList(); + } + + this.state = 113; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + objectList() { + let localctx = new ObjectListContext(this, this._ctx, this.state); + this.enterRule(localctx, 20, n3_nodropParser.RULE_objectList); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 114; + this.object(); + this.state = 119; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(_la===n3_nodropParser.T__4) { + this.state = 115; + this.match(n3_nodropParser.T__4); + this.state = 116; + this.object(); + this.state = 121; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + verb() { + let localctx = new VerbContext(this, this._ctx, this.state); + this.enterRule(localctx, 22, n3_nodropParser.RULE_verb); + try { + this.state = 133; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__12: + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 1); + this.state = 122; + this.predicate(); + break; + case n3_nodropParser.T__5: + this.enterOuterAlt(localctx, 2); + this.state = 123; + this.match(n3_nodropParser.T__5); + break; + case n3_nodropParser.T__6: + this.enterOuterAlt(localctx, 3); + this.state = 124; + this.match(n3_nodropParser.T__6); + this.state = 125; + this.expression(); + break; + case n3_nodropParser.T__7: + this.enterOuterAlt(localctx, 4); + this.state = 126; + this.match(n3_nodropParser.T__7); + this.state = 127; + this.expression(); + this.state = 128; + this.match(n3_nodropParser.T__8); + break; + case n3_nodropParser.T__9: + this.enterOuterAlt(localctx, 5); + this.state = 130; + this.match(n3_nodropParser.T__9); + break; + case n3_nodropParser.T__10: + this.enterOuterAlt(localctx, 6); + this.state = 131; + this.match(n3_nodropParser.T__10); + break; + case n3_nodropParser.T__11: + this.enterOuterAlt(localctx, 7); + this.state = 132; + this.match(n3_nodropParser.T__11); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + subject() { + let localctx = new SubjectContext(this, this._ctx, this.state); + this.enterRule(localctx, 24, n3_nodropParser.RULE_subject); + try { + this.enterOuterAlt(localctx, 1); + this.state = 135; + this.expression(); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + predicate() { + let localctx = new PredicateContext(this, this._ctx, this.state); + this.enterRule(localctx, 26, n3_nodropParser.RULE_predicate); + try { + this.enterOuterAlt(localctx, 1); + this.state = 140; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.state = 137; + this.expression(); + break; + case n3_nodropParser.T__12: + this.state = 138; + this.match(n3_nodropParser.T__12); + this.state = 139; + this.expression(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + object() { + let localctx = new ObjectContext(this, this._ctx, this.state); + this.enterRule(localctx, 28, n3_nodropParser.RULE_object); + try { + this.enterOuterAlt(localctx, 1); + this.state = 142; + this.expression(); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + expression() { + let localctx = new ExpressionContext(this, this._ctx, this.state); + this.enterRule(localctx, 30, n3_nodropParser.RULE_expression); + try { + this.enterOuterAlt(localctx, 1); + this.state = 144; + this.path(); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + path() { + let localctx = new PathContext(this, this._ctx, this.state); + this.enterRule(localctx, 32, n3_nodropParser.RULE_path); + try { + this.enterOuterAlt(localctx, 1); + this.state = 146; + this.pathItem(); + this.state = 151; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case n3_nodropParser.T__13: + this.state = 147; + this.match(n3_nodropParser.T__13); + this.state = 148; + this.path(); + break; + case n3_nodropParser.T__14: + this.state = 149; + this.match(n3_nodropParser.T__14); + this.state = 150; + this.path(); + break; + case n3_nodropParser.T__0: + case n3_nodropParser.T__3: + case n3_nodropParser.T__4: + case n3_nodropParser.T__5: + case n3_nodropParser.T__6: + case n3_nodropParser.T__7: + case n3_nodropParser.T__8: + case n3_nodropParser.T__9: + case n3_nodropParser.T__10: + case n3_nodropParser.T__11: + case n3_nodropParser.T__12: + case n3_nodropParser.T__15: + case n3_nodropParser.T__16: + case n3_nodropParser.T__17: + case n3_nodropParser.T__18: + case n3_nodropParser.T__19: + case n3_nodropParser.T__20: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + break; + default: + break; + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + pathItem() { + let localctx = new PathItemContext(this, this._ctx, this.state); + this.enterRule(localctx, 34, n3_nodropParser.RULE_pathItem); + try { + this.state = 161; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + this.enterOuterAlt(localctx, 1); + this.state = 153; + this.iri(); + break; + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.ANON: + this.enterOuterAlt(localctx, 2); + this.state = 154; + this.blankNode(); + break; + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 3); + this.state = 155; + this.quickVar(); + break; + case n3_nodropParser.T__17: + this.enterOuterAlt(localctx, 4); + this.state = 156; + this.collection(); + break; + case n3_nodropParser.T__15: + this.enterOuterAlt(localctx, 5); + this.state = 157; + this.blankNodePropertyList(); + break; + case n3_nodropParser.IPLSTART: + this.enterOuterAlt(localctx, 6); + this.state = 158; + this.iriPropertyList(); + break; + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + this.enterOuterAlt(localctx, 7); + this.state = 159; + this.literal(); + break; + case n3_nodropParser.T__19: + this.enterOuterAlt(localctx, 8); + this.state = 160; + this.formula(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + literal() { + let localctx = new LiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 36, n3_nodropParser.RULE_literal); + try { + this.state = 166; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.String: + this.enterOuterAlt(localctx, 1); + this.state = 163; + this.rdfLiteral(); + break; + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + this.enterOuterAlt(localctx, 2); + this.state = 164; + this.numericLiteral(); + break; + case n3_nodropParser.BooleanLiteral: + this.enterOuterAlt(localctx, 3); + this.state = 165; + this.match(n3_nodropParser.BooleanLiteral); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + blankNodePropertyList() { + let localctx = new BlankNodePropertyListContext(this, this._ctx, this.state); + this.enterRule(localctx, 38, n3_nodropParser.RULE_blankNodePropertyList); + try { + this.enterOuterAlt(localctx, 1); + this.state = 168; + this.match(n3_nodropParser.T__15); + this.state = 169; + this.predicateObjectList(); + this.state = 170; + this.match(n3_nodropParser.T__16); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + iriPropertyList() { + let localctx = new IriPropertyListContext(this, this._ctx, this.state); + this.enterRule(localctx, 40, n3_nodropParser.RULE_iriPropertyList); + try { + this.enterOuterAlt(localctx, 1); + this.state = 172; + this.match(n3_nodropParser.IPLSTART); + this.state = 173; + this.iri(); + this.state = 174; + this.predicateObjectList(); + this.state = 175; + this.match(n3_nodropParser.T__16); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + collection() { + let localctx = new CollectionContext(this, this._ctx, this.state); + this.enterRule(localctx, 42, n3_nodropParser.RULE_collection); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 177; + this.match(n3_nodropParser.T__17); + this.state = 181; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(((((_la - 16)) & ~0x1f) == 0 && ((1 << (_la - 16)) & ((1 << (n3_nodropParser.T__15 - 16)) | (1 << (n3_nodropParser.T__17 - 16)) | (1 << (n3_nodropParser.T__19 - 16)) | (1 << (n3_nodropParser.BooleanLiteral - 16)) | (1 << (n3_nodropParser.String - 16)) | (1 << (n3_nodropParser.IRIREF - 16)) | (1 << (n3_nodropParser.PNAME_NS - 16)) | (1 << (n3_nodropParser.PNAME_LN - 16)) | (1 << (n3_nodropParser.BLANK_NODE_LABEL - 16)) | (1 << (n3_nodropParser.INTEGER - 16)) | (1 << (n3_nodropParser.DECIMAL - 16)) | (1 << (n3_nodropParser.DOUBLE - 16)) | (1 << (n3_nodropParser.IPLSTART - 16)) | (1 << (n3_nodropParser.ANON - 16)) | (1 << (n3_nodropParser.QuickVarName - 16)))) !== 0)) { + this.state = 178; + this.object(); + this.state = 183; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 184; + this.match(n3_nodropParser.T__18); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + formula() { + let localctx = new FormulaContext(this, this._ctx, this.state); + this.enterRule(localctx, 44, n3_nodropParser.RULE_formula); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 186; + this.match(n3_nodropParser.T__19); + this.state = 188; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 187; + this.formulaContent(); + } + + this.state = 190; + this.match(n3_nodropParser.T__20); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + formulaContent() { + let localctx = new FormulaContentContext(this, this._ctx, this.state); + this.enterRule(localctx, 46, n3_nodropParser.RULE_formulaContent); + var _la = 0; // Token type + try { + this.state = 203; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + case n3_nodropParser.T__2: + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 1); + this.state = 192; + this.n3Statement(); + this.state = 197; + this._errHandler.sync(this); + _la = this._input.LA(1); + if(_la===n3_nodropParser.T__0) { + this.state = 193; + this.match(n3_nodropParser.T__0); + this.state = 195; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 194; + this.formulaContent(); + } + + } + + break; + case n3_nodropParser.BASE: + case n3_nodropParser.PREFIX: + this.enterOuterAlt(localctx, 2); + this.state = 199; + this.sparqlDirective(); + this.state = 201; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 200; + this.formulaContent(); + } + + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + numericLiteral() { + let localctx = new NumericLiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 48, n3_nodropParser.RULE_numericLiteral); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 205; + _la = this._input.LA(1); + if(!(((((_la - 31)) & ~0x1f) == 0 && ((1 << (_la - 31)) & ((1 << (n3_nodropParser.INTEGER - 31)) | (1 << (n3_nodropParser.DECIMAL - 31)) | (1 << (n3_nodropParser.DOUBLE - 31)))) !== 0))) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + rdfLiteral() { + let localctx = new RdfLiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 50, n3_nodropParser.RULE_rdfLiteral); + try { + this.enterOuterAlt(localctx, 1); + this.state = 207; + this.match(n3_nodropParser.String); + this.state = 211; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case n3_nodropParser.LANGTAG: + this.state = 208; + this.match(n3_nodropParser.LANGTAG); + break; + case n3_nodropParser.T__21: + this.state = 209; + this.match(n3_nodropParser.T__21); + this.state = 210; + this.iri(); + break; + case n3_nodropParser.T__0: + case n3_nodropParser.T__3: + case n3_nodropParser.T__4: + case n3_nodropParser.T__5: + case n3_nodropParser.T__6: + case n3_nodropParser.T__7: + case n3_nodropParser.T__8: + case n3_nodropParser.T__9: + case n3_nodropParser.T__10: + case n3_nodropParser.T__11: + case n3_nodropParser.T__12: + case n3_nodropParser.T__13: + case n3_nodropParser.T__14: + case n3_nodropParser.T__15: + case n3_nodropParser.T__16: + case n3_nodropParser.T__17: + case n3_nodropParser.T__18: + case n3_nodropParser.T__19: + case n3_nodropParser.T__20: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + break; + default: + break; + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + iri() { + let localctx = new IriContext(this, this._ctx, this.state); + this.enterRule(localctx, 52, n3_nodropParser.RULE_iri); + try { + this.state = 215; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.IRIREF: + this.enterOuterAlt(localctx, 1); + this.state = 213; + this.match(n3_nodropParser.IRIREF); + break; + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + this.enterOuterAlt(localctx, 2); + this.state = 214; + this.prefixedName(); + break; + default: + throw new src_antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + prefixedName() { + let localctx = new PrefixedNameContext(this, this._ctx, this.state); + this.enterRule(localctx, 54, n3_nodropParser.RULE_prefixedName); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 217; + _la = this._input.LA(1); + if(!(_la===n3_nodropParser.PNAME_NS || _la===n3_nodropParser.PNAME_LN)) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + blankNode() { + let localctx = new BlankNodeContext(this, this._ctx, this.state); + this.enterRule(localctx, 56, n3_nodropParser.RULE_blankNode); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 219; + _la = this._input.LA(1); + if(!(_la===n3_nodropParser.BLANK_NODE_LABEL || _la===n3_nodropParser.ANON)) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + quickVar() { + let localctx = new QuickVarContext(this, this._ctx, this.state); + this.enterRule(localctx, 58, n3_nodropParser.RULE_quickVar); + try { + this.enterOuterAlt(localctx, 1); + this.state = 221; + this.match(n3_nodropParser.QuickVarName); + } catch (re) { + if(re instanceof src_antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + +} + +n3_nodropParser.EOF = src_antlr4.Token.EOF; +n3_nodropParser.T__0 = 1; +n3_nodropParser.T__1 = 2; +n3_nodropParser.T__2 = 3; +n3_nodropParser.T__3 = 4; +n3_nodropParser.T__4 = 5; +n3_nodropParser.T__5 = 6; +n3_nodropParser.T__6 = 7; +n3_nodropParser.T__7 = 8; +n3_nodropParser.T__8 = 9; +n3_nodropParser.T__9 = 10; +n3_nodropParser.T__10 = 11; +n3_nodropParser.T__11 = 12; +n3_nodropParser.T__12 = 13; +n3_nodropParser.T__13 = 14; +n3_nodropParser.T__14 = 15; +n3_nodropParser.T__15 = 16; +n3_nodropParser.T__16 = 17; +n3_nodropParser.T__17 = 18; +n3_nodropParser.T__18 = 19; +n3_nodropParser.T__19 = 20; +n3_nodropParser.T__20 = 21; +n3_nodropParser.T__21 = 22; +n3_nodropParser.COMMENT = 23; +n3_nodropParser.BooleanLiteral = 24; +n3_nodropParser.String = 25; +n3_nodropParser.IRIREF = 26; +n3_nodropParser.PNAME_NS = 27; +n3_nodropParser.PNAME_LN = 28; +n3_nodropParser.BLANK_NODE_LABEL = 29; +n3_nodropParser.LANGTAG = 30; +n3_nodropParser.INTEGER = 31; +n3_nodropParser.DECIMAL = 32; +n3_nodropParser.DOUBLE = 33; +n3_nodropParser.EXPONENT = 34; +n3_nodropParser.STRING_LITERAL_LONG_SINGLE_QUOTE = 35; +n3_nodropParser.STRING_LITERAL_LONG_QUOTE = 36; +n3_nodropParser.STRING_LITERAL_QUOTE = 37; +n3_nodropParser.STRING_LITERAL_SINGLE_QUOTE = 38; +n3_nodropParser.UCHAR = 39; +n3_nodropParser.ECHAR = 40; +n3_nodropParser.WS = 41; +n3_nodropParser.IPLSTART = 42; +n3_nodropParser.ANON = 43; +n3_nodropParser.QuickVarName = 44; +n3_nodropParser.PN_CHARS_U = 45; +n3_nodropParser.PN_CHARS_BASE = 46; +n3_nodropParser.PN_CHARS = 47; +n3_nodropParser.BASE = 48; +n3_nodropParser.PREFIX = 49; +n3_nodropParser.PN_PREFIX = 50; +n3_nodropParser.PN_LOCAL = 51; +n3_nodropParser.PLX = 52; +n3_nodropParser.PERCENT = 53; +n3_nodropParser.HEX = 54; +n3_nodropParser.PN_LOCAL_ESC = 55; + +n3_nodropParser.RULE_n3Doc = 0; +n3_nodropParser.RULE_n3Statement = 1; +n3_nodropParser.RULE_n3Directive = 2; +n3_nodropParser.RULE_sparqlDirective = 3; +n3_nodropParser.RULE_sparqlBase = 4; +n3_nodropParser.RULE_sparqlPrefix = 5; +n3_nodropParser.RULE_prefixID = 6; +n3_nodropParser.RULE_base = 7; +n3_nodropParser.RULE_triples = 8; +n3_nodropParser.RULE_predicateObjectList = 9; +n3_nodropParser.RULE_objectList = 10; +n3_nodropParser.RULE_verb = 11; +n3_nodropParser.RULE_subject = 12; +n3_nodropParser.RULE_predicate = 13; +n3_nodropParser.RULE_object = 14; +n3_nodropParser.RULE_expression = 15; +n3_nodropParser.RULE_path = 16; +n3_nodropParser.RULE_pathItem = 17; +n3_nodropParser.RULE_literal = 18; +n3_nodropParser.RULE_blankNodePropertyList = 19; +n3_nodropParser.RULE_iriPropertyList = 20; +n3_nodropParser.RULE_collection = 21; +n3_nodropParser.RULE_formula = 22; +n3_nodropParser.RULE_formulaContent = 23; +n3_nodropParser.RULE_numericLiteral = 24; +n3_nodropParser.RULE_rdfLiteral = 25; +n3_nodropParser.RULE_iri = 26; +n3_nodropParser.RULE_prefixedName = 27; +n3_nodropParser.RULE_blankNode = 28; +n3_nodropParser.RULE_quickVar = 29; + +class N3DocContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_n3Doc; + } + + EOF() { + return this.getToken(n3_nodropParser.EOF, 0); + }; + + n3Statement = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(N3StatementContext); + } else { + return this.getTypedRuleContext(N3StatementContext,i); + } + }; + + sparqlDirective = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(SparqlDirectiveContext); + } else { + return this.getTypedRuleContext(SparqlDirectiveContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterN3Doc(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitN3Doc(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitN3Doc(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class N3StatementContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_n3Statement; + } + + n3Directive() { + return this.getTypedRuleContext(N3DirectiveContext,0); + }; + + triples() { + return this.getTypedRuleContext(TriplesContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterN3Statement(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitN3Statement(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitN3Statement(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class N3DirectiveContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_n3Directive; + } + + prefixID() { + return this.getTypedRuleContext(PrefixIDContext,0); + }; + + base() { + return this.getTypedRuleContext(BaseContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterN3Directive(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitN3Directive(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitN3Directive(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SparqlDirectiveContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_sparqlDirective; + } + + sparqlBase() { + return this.getTypedRuleContext(SparqlBaseContext,0); + }; + + sparqlPrefix() { + return this.getTypedRuleContext(SparqlPrefixContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSparqlDirective(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSparqlDirective(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSparqlDirective(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SparqlBaseContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_sparqlBase; + } + + BASE() { + return this.getToken(n3_nodropParser.BASE, 0); + }; + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSparqlBase(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSparqlBase(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSparqlBase(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SparqlPrefixContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_sparqlPrefix; + } + + PREFIX() { + return this.getToken(n3_nodropParser.PREFIX, 0); + }; + + PNAME_NS() { + return this.getToken(n3_nodropParser.PNAME_NS, 0); + }; + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSparqlPrefix(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSparqlPrefix(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSparqlPrefix(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PrefixIDContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_prefixID; + } + + PNAME_NS() { + return this.getToken(n3_nodropParser.PNAME_NS, 0); + }; + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPrefixID(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPrefixID(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPrefixID(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class BaseContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_base; + } + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterBase(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitBase(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitBase(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class TriplesContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_triples; + } + + subject() { + return this.getTypedRuleContext(SubjectContext,0); + }; + + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterTriples(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitTriples(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitTriples(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PredicateObjectListContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_predicateObjectList; + } + + verb = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(VerbContext); + } else { + return this.getTypedRuleContext(VerbContext,i); + } + }; + + objectList = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectListContext); + } else { + return this.getTypedRuleContext(ObjectListContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPredicateObjectList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPredicateObjectList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPredicateObjectList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class ObjectListContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_objectList; + } + + object = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectContext); + } else { + return this.getTypedRuleContext(ObjectContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterObjectList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitObjectList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitObjectList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class VerbContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_verb; + } + + predicate() { + return this.getTypedRuleContext(PredicateContext,0); + }; + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterVerb(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitVerb(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitVerb(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SubjectContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_subject; + } + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSubject(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSubject(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSubject(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PredicateContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_predicate; + } + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPredicate(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPredicate(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPredicate(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class ObjectContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_object; + } + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterObject(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitObject(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitObject(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class ExpressionContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_expression; + } + + path() { + return this.getTypedRuleContext(PathContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterExpression(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitExpression(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitExpression(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PathContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_path; + } + + pathItem() { + return this.getTypedRuleContext(PathItemContext,0); + }; + + path() { + return this.getTypedRuleContext(PathContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPath(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPath(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPath(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PathItemContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_pathItem; + } + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + blankNode() { + return this.getTypedRuleContext(BlankNodeContext,0); + }; + + quickVar() { + return this.getTypedRuleContext(QuickVarContext,0); + }; + + collection() { + return this.getTypedRuleContext(CollectionContext,0); + }; + + blankNodePropertyList() { + return this.getTypedRuleContext(BlankNodePropertyListContext,0); + }; + + iriPropertyList() { + return this.getTypedRuleContext(IriPropertyListContext,0); + }; + + literal() { + return this.getTypedRuleContext(LiteralContext,0); + }; + + formula() { + return this.getTypedRuleContext(FormulaContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPathItem(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPathItem(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPathItem(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class LiteralContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_literal; + } + + rdfLiteral() { + return this.getTypedRuleContext(RdfLiteralContext,0); + }; + + numericLiteral() { + return this.getTypedRuleContext(NumericLiteralContext,0); + }; + + BooleanLiteral() { + return this.getToken(n3_nodropParser.BooleanLiteral, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterLiteral(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitLiteral(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitLiteral(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class BlankNodePropertyListContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_blankNodePropertyList; + } + + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterBlankNodePropertyList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitBlankNodePropertyList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitBlankNodePropertyList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class IriPropertyListContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_iriPropertyList; + } + + IPLSTART() { + return this.getToken(n3_nodropParser.IPLSTART, 0); + }; + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterIriPropertyList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitIriPropertyList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitIriPropertyList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class CollectionContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_collection; + } + + object = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectContext); + } else { + return this.getTypedRuleContext(ObjectContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterCollection(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitCollection(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitCollection(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class FormulaContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_formula; + } + + formulaContent() { + return this.getTypedRuleContext(FormulaContentContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterFormula(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitFormula(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitFormula(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class FormulaContentContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_formulaContent; + } + + n3Statement() { + return this.getTypedRuleContext(N3StatementContext,0); + }; + + formulaContent() { + return this.getTypedRuleContext(FormulaContentContext,0); + }; + + sparqlDirective() { + return this.getTypedRuleContext(SparqlDirectiveContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterFormulaContent(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitFormulaContent(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitFormulaContent(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class NumericLiteralContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_numericLiteral; + } + + INTEGER() { + return this.getToken(n3_nodropParser.INTEGER, 0); + }; + + DECIMAL() { + return this.getToken(n3_nodropParser.DECIMAL, 0); + }; + + DOUBLE() { + return this.getToken(n3_nodropParser.DOUBLE, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterNumericLiteral(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitNumericLiteral(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitNumericLiteral(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class RdfLiteralContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_rdfLiteral; + } + + String() { + return this.getToken(n3_nodropParser.String, 0); + }; + + LANGTAG() { + return this.getToken(n3_nodropParser.LANGTAG, 0); + }; + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterRdfLiteral(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitRdfLiteral(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitRdfLiteral(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class IriContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_iri; + } + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + prefixedName() { + return this.getTypedRuleContext(PrefixedNameContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterIri(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitIri(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitIri(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PrefixedNameContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_prefixedName; + } + + PNAME_NS() { + return this.getToken(n3_nodropParser.PNAME_NS, 0); + }; + + PNAME_LN() { + return this.getToken(n3_nodropParser.PNAME_LN, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPrefixedName(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPrefixedName(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPrefixedName(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class BlankNodeContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_blankNode; + } + + BLANK_NODE_LABEL() { + return this.getToken(n3_nodropParser.BLANK_NODE_LABEL, 0); + }; + + ANON() { + return this.getToken(n3_nodropParser.ANON, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterBlankNode(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitBlankNode(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitBlankNode(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class QuickVarContext extends src_antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_quickVar; + } + + QuickVarName() { + return this.getToken(n3_nodropParser.QuickVarName, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterQuickVar(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitQuickVar(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitQuickVar(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + + +n3_nodropParser.N3DocContext = N3DocContext; +n3_nodropParser.N3StatementContext = N3StatementContext; +n3_nodropParser.N3DirectiveContext = N3DirectiveContext; +n3_nodropParser.SparqlDirectiveContext = SparqlDirectiveContext; +n3_nodropParser.SparqlBaseContext = SparqlBaseContext; +n3_nodropParser.SparqlPrefixContext = SparqlPrefixContext; +n3_nodropParser.PrefixIDContext = PrefixIDContext; +n3_nodropParser.BaseContext = BaseContext; +n3_nodropParser.TriplesContext = TriplesContext; +n3_nodropParser.PredicateObjectListContext = PredicateObjectListContext; +n3_nodropParser.ObjectListContext = ObjectListContext; +n3_nodropParser.VerbContext = VerbContext; +n3_nodropParser.SubjectContext = SubjectContext; +n3_nodropParser.PredicateContext = PredicateContext; +n3_nodropParser.ObjectContext = ObjectContext; +n3_nodropParser.ExpressionContext = ExpressionContext; +n3_nodropParser.PathContext = PathContext; +n3_nodropParser.PathItemContext = PathItemContext; +n3_nodropParser.LiteralContext = LiteralContext; +n3_nodropParser.BlankNodePropertyListContext = BlankNodePropertyListContext; +n3_nodropParser.IriPropertyListContext = IriPropertyListContext; +n3_nodropParser.CollectionContext = CollectionContext; +n3_nodropParser.FormulaContext = FormulaContext; +n3_nodropParser.FormulaContentContext = FormulaContentContext; +n3_nodropParser.NumericLiteralContext = NumericLiteralContext; +n3_nodropParser.RdfLiteralContext = RdfLiteralContext; +n3_nodropParser.IriContext = IriContext; +n3_nodropParser.PrefixedNameContext = PrefixedNameContext; +n3_nodropParser.BlankNodeContext = BlankNodeContext; +n3_nodropParser.QuickVarContext = QuickVarContext; + +;// CONCATENATED MODULE: ./parser/n3_nodrop/n3_nodropPrefixListener.js + + +class n3_nodropPrefixListener extends n3_nodropListener { + + constructor(listener) { + super(); + + this.listener = listener; + this.prefixes = {}; + } + + // Exit a parse tree produced by n3Parser#sparqlPrefix. + exitSparqlPrefix(ctx) { + this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); + } + + // Exit a parse tree produced by n3Parser#prefixID. + exitPrefixID(ctx) { + this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); + } + + processPrefix(pNameNs, iriRef) { + if (pNameNs == null) + return + + var prefix = pNameNs.getText().trim(); + prefix = prefix.substring(0, prefix.length - 1) + + var uri = this.iri(iriRef); + this.prefixes[prefix] = uri; + } + + // Exit a parse tree produced by n3Parser#prefixedName. + exitPrefixedName(ctx) { + var pNameLn = ctx.PNAME_LN(); + + if (pNameLn != null) { + var pName = pNameLn.getText().trim(); + var prefix = pName.substring(0, pName.indexOf(":")).trim(); + + if (prefix == "") + return; + + if (this.prefixes[prefix] === undefined) { + var line = ctx.start.line + var start = ctx.start.column + var end = start + prefix.length + + this.listener.unknownPrefix(prefix, pName, line, start, end); + } + } + } + + text(node) { + if (node == null) + return null; + + return node.getText().trim(); + } + + iri(node) { + var s = this.text(node); + return s.substring(1, s.length - 1); + } +} +;// CONCATENATED MODULE: ./parser/n3_nodrop/n3_nodropPrintVisitor.js +// var n3Visitor = require('./n3Visitor').n3Visitor +// var n3Parser = require('./n3Parser').n3Parser + + + +class n3_nodropPrintVisitor extends n3_nodropVisitor { + + constructor(listener) { + super(); + + this.listener = listener; + this.lvl = 0 + } + + // Visit a parse tree produced by n3Parser#n3Doc. + visitN3Doc(ctx) { + this.print("N3Doc") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#n3Statement. + visitN3Statement(ctx) { + this.print("N3Statement") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#n3Directive. + visitN3Directive(ctx) { + this.print("N3Directive") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#sparqlDirective. + visitSparqlDirective(ctx) { + this.print("SparqlDirective") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#sparqlBase. + visitSparqlBase(ctx) { + this.print("SparqlBase") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#sparqlPrefix. + visitSparqlPrefix(ctx) { + this.print("SparqlPrefix") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixID. + visitPrefixID(ctx) { + this.print("PrefixID") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#base. + visitBase(ctx) { + this.print("Base") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#triples. + visitTriples(ctx) { + this.print("Triples") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicateObjectList. + visitPredicateObjectList(ctx) { + this.print("PredicateObjectList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#objectList. + visitObjectList(ctx) { + this.print("ObjectList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#verb. + visitVerb(ctx) { + this.print("Verb") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#subject. + visitSubject(ctx) { + this.print("Subject") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicate. + visitPredicate(ctx) { + this.print("Predicate") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#object. + visitObject(ctx) { + this.print("Object") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#expression. + visitExpression(ctx) { + this.print("Expression") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#path. + visitPath(ctx) { + this.print("Path") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#pathItem. + visitPathItem(ctx) { + this.print("PathItem") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#literal. + visitLiteral(ctx) { + this.print("Literal") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + this.print("BlankNodePropertyList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriPropertyList. + visitIriPropertyList(ctx) { + this.print("IriPropertyList") + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#collection. + visitCollection(ctx) { + this.print("Collection") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#formula. + visitFormula(ctx) { + this.print("Formula") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#formulaContent. + visitFormulaContent(ctx) { + this.print("FormulaContent") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#numericLiteral. + visitNumericLiteral(ctx) { + this.print("NumericLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#rdfLiteral. + visitRdfLiteral(ctx) { + this.print("RdfLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iri. + visitIri(ctx) { + this.print("Iri") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriList. + visitIriList(ctx) { + this.print("IriList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixedName. + visitPrefixedName(ctx) { + this.print("PrefixedName") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNode. + visitBlankNode(ctx) { + this.print("BlankNode") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#quickVar. + visitQuickVar(ctx) { + this.print("QuickVar") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#existential. + visitExistential(ctx) { + this.print("Existential") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#universal. + visitUniversal(ctx) { + this.print("Universal") + return this.doVisitChildren(ctx) + } + + + incrLvl() { + this.lvl++; + } + + decrLvl() { + this.lvl--; + } + + print(el) { + var ws = new Array(this.lvl + 1).join(" "); + var out = ws + el + "\n"; + + this.listener.newAstLine(out); + } + + doVisitChildren(ctx) { + this.lvl++; + this.visitChildren(ctx); + this.lvl--; + } + + visitChildren(node) { + var result = null; // this.defaultResult() + var n = node.getChildCount() + for (var i = 0; i < n; i++) { + // if (!this.shouldVisitNextChild(node, result)) { + // break + // } + + var c = node.getChild(i) + if (c.symbol !== undefined) { + var out = "' " + c + " '"; + var type = c.symbol.type + if (type != -1 && n3_nodropParser.symbolicNames[type] !== null) + out += " (" + n3_nodropParser.symbolicNames[type] + ")" + this.print(out) + + } else { + result = c.accept(this); + // result = this.aggregateResult(result, childResult); + } + } + + return result + } +} +;// CONCATENATED MODULE: ./parser/n3_nodrop/n3_nodropFormatVisitor.js + +// import n3_nodropParser from './n3_nodropParser'; + +class n3_nodropFormatVisitor extends n3_nodropVisitor { + + static CHANNEL_WHITESPACE = 1; + static CHANNEL_COMMENT = 2; + + static DIR_LEFT = 1; + static DIR_RIGHT = 2; + + constructor(config, tokens, n3Parser) { + super(); + + this.config = config; + this.tokens = tokens; + this.n3Parser = n3Parser; + + this.str = ""; + this.indent = 0; + + if (config.formatNamespaces) { + this.ns = {}; + this.base = ""; + } + } + + callAccept(child) { + child.accept(this); + } + + // Visit a parse tree produced by n3Parser#n3Doc. + visitN3Doc(ctx) { + this.logVisit("N3Doc"); + + // get comment at start of document, if any + let startCmt = this.leftComment(ctx.children[0]); + + this.doVisitGraphContents(ctx); + + // TODO integrate all these re-assignments into visit checks + // (currently we cannot "stream" output) + + // - drop newlines between "}" and "." + this.str = this.str.replace(/\}\n\s*\./g, "} ."); + + if (this.config.formatNamespaces) + this.printNamespaces(); + + if (startCmt) + this.str = startCmt + this.str; + + return this.str; + } + + printNamespaces() { + let prefixes = Object.keys(this.ns); + prefixes.sort(); + + let preamble = prefixes.map(prefix => + `@prefix ${prefix} ${this.ns[prefix]} .` + ).join("\n"); + + if (this.base) { + if (preamble) + preamble += "\n"; + preamble += `@base ${this.base} .`; + } + + if (preamble == "") + return; + + // not starting with comment + // (in that case, comment is in charge of newlines) + if (!/^\s*#/.test(this.str)) + preamble += "\n\n"; + + this.str = preamble + this.str; + } + + // Visit a parse tree produced by n3Parser#n3Statement. + visitN3Statement(ctx) { + this.logVisit("N3Statement"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#n3Directive. + visitN3Directive(ctx) { + this.logVisit("N3Directive"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlDirective. + visitSparqlDirective(ctx) { + this.logVisit("SparqlDirective"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlBase. + visitSparqlBase(ctx) { + this.logVisit("SparqlBase"); + + this.doVisitBase(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlPrefix. + visitSparqlPrefix(ctx) { + this.logVisit("SparqlPrefix"); + + this.doVisitPrefix(ctx); + } + + + // Visit a parse tree produced by n3Parser#prefixID. + visitPrefixID(ctx) { + this.logVisit("PrefixID"); + + this.doVisitPrefix(ctx); + } + + + // Visit a parse tree produced by n3Parser#base. + visitBase(ctx) { + this.logVisit("Base"); + + this.doVisitBase(ctx); + } + + + doVisitBase(ctx) { + if (this.config.formatNamespaces) + this.base = ctx.children[1].toString(); + else + this.doVisitChildren(ctx, " "); + } + + + doVisitPrefix(ctx) { + if (this.config.formatNamespaces) { + let prefix = ctx.children[1].toString() + let uri = ctx.children[2].toString() + + if (this.ns[prefix]) + console.warn(`overwriting prefix '${prefix}'`); + + this.ns[prefix] = uri; + + } else + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#triples. + visitTriples(ctx) { + this.logVisit("Triples"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#predicateObjectList. + visitPredicateObjectList(ctx) { + this.logVisit("PredicateObjectList"); + + let indented = false; + ctx.children.forEach(child => { + // terminal ";" + if (child.symbol !== undefined) { + // if needed, increment level + if (!indented) { + // indent taken care of by blankNodePropertyList, iriPropertyList + let name = this.ruleName(ctx.parentCtx) + if (name != "blankNodePropertyList" && + name != "iriPropertyList") { + + indented = true; + this.incrIndent(); + } + } + + // newline after ";"; + this.print(child); + this.appendNewline(); + + } else { + // non-terminal (term) + this.callAccept(child); + this.separate(" "); + } + }); + + // after, decrement level again + if (indented) + this.decrIndent(); + } + + + // Visit a parse tree produced by n3Parser#objectList. + visitObjectList(ctx) { + this.logVisit("ObjectList"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#verb. + visitVerb(ctx) { + this.logVisit("Verb") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#subject. + visitSubject(ctx) { + this.logVisit("Subject") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicate. + visitPredicate(ctx) { + this.logVisit("Predicate") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#object. + visitObject(ctx) { + this.logVisit("Object") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#expression. + visitExpression(ctx) { + this.logVisit("Expression") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#path. + visitPath(ctx) { + this.logVisit("Path") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#pathItem. + visitPathItem(ctx) { + this.logVisit("PathItem") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#literal. + visitLiteral(ctx) { + this.logVisit("Literal") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + this.logVisit("BlankNodePropertyList"); + + // "[" + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + for (let i = 1; i < ctx.getChildCount() - 1; i++) { + this.callAccept(ctx.getChild(i)); + } + + this.decrIndent(); + + this.appendNewline(); + // "]" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + } + + + // Visit a parse tree produced by n3Parser#iriPropertyList. + visitIriPropertyList(ctx) { + this.logVisit("IriPropertyList") + + // IPLSTART + this.print(ctx.getChild(0)); + + // id + this.separate(" "); + this.callAccept(ctx.getChild(1)); + + this.incrIndent(1); + this.appendNewline(); + + for (let i = 2; i < ctx.getChildCount() - 1; i++) { + this.callAccept(ctx.getChild(i)); + } + + this.decrIndent(1); + + this.appendNewline(); + // "]" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + } + + + // Visit a parse tree produced by n3Parser#collection. + visitCollection(ctx) { + this.logVisit("Collection"); + + // in case of any formula descendants, + // print list contents like bnode property list + if (this.hasSomeDescendant(ctx, "formula")) { + + // "(" + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + for (let i = 1; i < ctx.getChildCount() - 1; i++) { + if (i > 1) + this.appendNewline(); + + this.callAccept(ctx.getChild(i)); + } + + this.decrIndent(); + this.appendNewline(); + + // ")" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + + } else + this.doVisitChildren(ctx, " "); + } + + // Visit a parse tree produced by n3Parser#formula. + visitFormula(ctx) { + this.logVisit("Formula"); + + // empty formula + if (ctx.getChildCount() == 2) { + this.doVisitChildren(ctx); + return + } + + // terminal "{" + if (this.config.graphOnNewline) { + this.appendNewline(); + } + + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + this.callAccept(ctx.getChild(1)); + + this.decrIndent(); + + // terminal "}" + this.appendNewline(); + this.print(ctx.getChild(2)); + + if (this.config.graphOnNewline) { + this.appendNewline(); + } + } + + + // Visit a parse tree produced by n3Parser#formulaContent. + visitFormulaContent(ctx) { + this.logVisit("FormulaContent"); + + this.doVisitGraphContents(ctx); + } + + + // Visit a parse tree produced by n3Parser#numericLiteral. + visitNumericLiteral(ctx) { + this.logVisit("NumericLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#rdfLiteral. + visitRdfLiteral(ctx) { + this.logVisit("RdfLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iri. + visitIri(ctx) { + this.logVisit("Iri") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriList. + visitIriList(ctx) { + this.logVisit("IriList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixedName. + visitPrefixedName(ctx) { + this.logVisit("PrefixedName") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNode. + visitBlankNode(ctx) { + this.logVisit("BlankNode") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#quickVar. + visitQuickVar(ctx) { + this.logVisit("QuickVar") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#existential. + visitExistential(ctx) { + this.logVisit("Existential") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#universal. + visitUniversal(ctx) { + this.logVisit("Universal") + return this.doVisitChildren(ctx) + } + + + incrIndent(plus) { + this.indent += this.config.tab + (plus ? plus : 0); + } + + decrIndent(minus) { + this.indent -= (this.config.tab + (minus ? minus : 0)); + } + + doVisitGraphContents(ctx) { + let n = ctx.getChildCount(); + + // either: + // pairs of n3Statement "." + // or sparqlDirective + // or + for (let i = 0; i < n; i++) { + let child = ctx.getChild(i); + + // console.log(this.getName(child), "skip?", this.skipNode(child)); + + // either terminating "." or + if (child.symbol !== undefined) { + // don't print terminating "." if prior child did not get printed + if (this.skipNode(ctx.getChild(i - 1))) + continue; + + if (child.toString() == "") + continue; + + this.separate(" "); + this.print(child); + // newline for n3Statements after "." + if (i < n - 1) // don't add after last child + this.appendNewline(); + + } else { + // non-terminal + // (n3Statement or sparqlDirective) + this.callAccept(child); + + // newline after sparqlDirectives + // (don't add newline if directive got skipped) + if (this.ruleName(child) == "sparqlDirective" && !this.skipNode(child)) { + if (i < n - 1) // don't add after last child + this.appendNewline(); + } + } + } + } + + // whether a node will not be printed + skipNode(node) { + if (this.config.formatNamespaces) { + if (this.ruleName(node) == "sparqlDirective") + return true; + + if (node.children && node.children.length == 1) { + if (this.ruleName(node.children[0]) == "n3Directive") + return true; + } + + return false; + } + } + + doVisitChildren(ctx, sep) { + this.visitChildren(ctx, sep); + } + + visitChildren(node, sep) { + for (var i = 0; i < node.getChildCount(); i++) { + var child = node.getChild(i); + // console.log("child", child); + + if (sep && i > 0) + this.separate(sep); + + // terminal + if (child.symbol !== undefined) { + this.print(child); + + } else { + // non-terminal + this.callAccept(child); + } + } + } + + + logVisit(el) { + // console.log(el); + } + + logChildren(ctx) { + let out = ctx.children.map(child => { + if (child.symbol) { + return this.symbolName(child); + + } else { + return this.ruleName(child) + } + }); + + console.log("<-", out.join(" ")); + } + + hasSomeDescendant(ctx, name) { + if (this.ruleName(ctx) == name) + return true; + + if (ctx.children) + return ctx.children.some(child => this.hasSomeDescendant(child, name)); + else + return false; + } + + getName(node) { + let name = this.ruleName(node) + if (name) + return name; + else + return this.symbolName(node) + } + + symbolName(node) { + let type = node.symbol.type + let name = this.n3Parser.symbolicNames[type] + if (!name) + name = this.n3Parser.literalNames[type] + + return name + } + + ruleName(node) { + let rule = node.ruleIndex + return this.n3Parser.ruleNames[rule] + } + + appendNewline() { + // if we already end with newline: + // replace it with our newline (and its possibly updated indents) + let matches = [...this.str.matchAll(/^([\s\S]*)\n\s*$/g)]; + if (matches.length > 0) { + this.str = matches[0][1]; + } + + this.str += "\n" + new Array(this.indent).join(" "); + } + + separate(sep) { + // don't add space separator after a whitespace + // (e.g., when putting newlines around =>) + if (sep == " " && /.*\s+$/g.test(this.str)) + return; + + this.str += sep; + } + + print(node) { + if (typeof node === 'string') { + this.str += node; + + // for every single node we print: + // check whether there's a comment before or after + } else { + this.str += this.leftComment(node); + this.str += node; + this.str += this.rightComment(node); + } + } + + // for left side, print all prior comments & newlines until non-hidden token + leftComment(node) { + // includes all comments & newlines until prior non-hidden token + let tokens = this.nextHiddenTokens(node, n3_nodropFormatVisitor.DIR_LEFT); + // there's a comment in there somewhere + if (tokens && tokens.some(t => t.channel == n3_nodropFormatVisitor.CHANNEL_COMMENT)) { + // console.log("hidden-left", tokens, tokens.map(c => c.text)); + + let text = tokens.map(c => c.text).join(""); + // after the last comment, keep only the newlines + text = text.replace(/[ \t]*$/, ""); + + return text; + } + + return ""; + } + + // for right side, print next comment + newline + rightComment(node) { + // includes all comments & newlines until next non-hidden token + let tokens = this.nextHiddenTokens(node, n3_nodropFormatVisitor.DIR_RIGHT); + + // there's a comment in there somewhere + if (tokens && tokens.some(t => t.channel == n3_nodropFormatVisitor.CHANNEL_COMMENT)) { + // console.log("hidden-right", tokens, tokens.map(c => c.text)); + + this.separate(" "); // add ws after whatever we printed before + + let text = tokens.map(c => c.text).join(""); + // keep all whitespaces before first comment & between comments + text = text.trimEnd(); + + if (text) + return text + "\n"; + } + + return ""; + } + + nextHiddenTokens(node, dir, channelId) { + let symbol; + if (node.symbol) + symbol = node.symbol + else { + if (dir == n3_nodropFormatVisitor.DIR_LEFT) + symbol = node.start; + else + symbol = node.end; + } + + let idx = symbol.tokenIndex; + + let fn = (dir == n3_nodropFormatVisitor.DIR_LEFT ? + this.tokens.getHiddenTokensToLeft : + this.tokens.getHiddenTokensToRight + ); + + let channel = fn.call(this.tokens, idx, channelId); + if (channel != null) { + // make sure to return tokens only once + // (e.g., right-side comment showing up as left-side comment next) + channel = channel.filter(t => !t.consumed); + channel.forEach(t => t.consumed = true); + + return channel; + } + + return false; + } +} +;// CONCATENATED MODULE: ./parser/n3_nodrop/index.js +// - CommonJS +// var antlr4 = require('antlr4'); +// var N3Lexer = require('./n3_nodropLexer').n3Lexer; +// var N3Parser = require('./n3_nodropParser').n3Parser; +// var N3PrefixListener = require('./n3_nodropPrefixListener').n3PrefixListener; +// var N3PrintListener = require('./n3_nodropPrintListener').n3PrintListener; +// var N3PrintVisitor = require('./n3_nodropPrintVisitor').n3PrintVisitor; + +// - ES6 + + + + + + + + +// re-generate n3_nodrop: +// (base) wvw@Williams-MBP n3_nodrop % java -jar ~/git/antlr4/antlr-4.10.1-complete.jar -Dlanguage=JavaScript ~/git/n3/N3/grammar/n3_nodrop.g4 -visitor -o ./ + +function parse(input, listener) { + var chars = new InputStream(input); + + var n3Lexer = new n3_nodropLexer(chars); + n3Lexer.removeErrorListeners(); + n3Lexer.addErrorListener(listener); + + var tokens = new CommonTokenStream(n3Lexer); + + var n3Parser = new n3_nodropParser(tokens); + n3Parser.removeErrorListeners(); + n3Parser.removeParseListeners(); + + if (listener.syntaxError) + // will call listener with any syntax (parser/lexer) error + n3Parser.addErrorListener(listener); + + if (listener.unknownPrefix) + // will call listener with any prefix errors + n3Parser.addParseListener(new n3_nodropPrefixListener(listener)); + + // if (listener.newAstLine) + // // will call listener with individual ast lines + // n3Parser.addParseListener(new N3PrintListener(listener)); + + var ast = n3Parser.n3Doc() + if (listener.newAstLine) + new n3_nodropPrintVisitor(listener).visit(ast) +} + +function format(input, config) { + var chars = new InputStream(input); + + var n3Lexer = new n3_nodropLexer(chars); + var tokens = new CommonTokenStream(n3Lexer); + + var n3Parser = new n3_nodropParser(tokens); + + let ast = n3Parser.n3Doc(); + // return ast; + + var visitor = new n3_nodropFormatVisitor(config, tokens, n3Parser); + return visitor.visitN3Doc(ast); +} + +// exports.parse = parse; +})(); + +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/editor/dist/n3_nodropMain.js b/editor/dist/n3_nodropMain.js new file mode 100644 index 0000000..bd62e8e --- /dev/null +++ b/editor/dist/n3_nodropMain.js @@ -0,0 +1,2 @@ +/*! For license information please see n3_nodropMain.js.LICENSE.txt */ +var n3;(()=>{var t={262:()=>{}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i](r,r.exports,s),r.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";s.r(i),s.d(i,{format:()=>us,parse:()=>cs});class t{constructor(){this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null}getTokenSource(){return this.source[0]}getInputStream(){return this.source[1]}get text(){return this._text}set text(t){this._text=t}}t.INVALID_TYPE=0,t.EPSILON=-2,t.MIN_USER_TOKEN_TYPE=1,t.EOF=-1,t.DEFAULT_CHANNEL=0,t.HIDDEN_CHANNEL=1,String.prototype.codePointAt||function(){var t=function(){let t;try{const e={},s=Object.defineProperty;t=s(e,e,e)&&s}catch(t){}return t}();const e=function(t){if(null==this)throw TypeError();const e=String(this),s=e.length;let i=t?Number(t):0;if(i!=i&&(i=0),i<0||i>=s)return;const n=e.charCodeAt(i);let r;return n>=55296&&n<=56319&&s>i+1&&(r=e.charCodeAt(i+1),r>=56320&&r<=57343)?1024*(n-55296)+r-56320+65536:n};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),String.fromCodePoint||function(){const t=function(){let t;try{const e={},s=Object.defineProperty;t=s(e,e,e)&&s}catch(t){}return t}(),e=String.fromCharCode,s=Math.floor,i=function(t){const i=16384,n=[];let r,o,a=-1;const l=arguments.length;if(!l)return"";let h="";for(;++a1114111||s(t)!==t)throw RangeError("Invalid code point: "+t);t<=65535?n.push(t):(t-=65536,r=55296+(t>>10),o=t%1024+56320,n.push(r,o)),(a+1===l||n.length>i)&&(h+=e.apply(null,n),n.length=0)}return h};t?t(String,"fromCodePoint",{value:i,configurable:!0,writable:!0}):String.fromCodePoint=i}();class e{constructor(t,e){if(this.name="",this.strdata=t,this.decodeToUnicodeCodePoints=e||!1,this._index=0,this.data=[],this.decodeToUnicodeCodePoints)for(let t=0;t=this._size)throw"cannot consume EOF";this._index+=1}LA(e){if(0===e)return 0;e<0&&(e+=1);const s=this._index+e-1;return s<0||s>=this._size?t.EOF:this.data[s]}LT(t){return this.LA(t)}mark(){return-1}release(t){}seek(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)}getText(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){let s="";for(let i=t;i<=e;i++)s+=String.fromCodePoint(this.data[i]);return s}return this.strdata.slice(t,e+1)}toString(){return this.strdata}get index(){return this._index}get size(){return this._size}}class n{syntaxError(t,e,s,i,n,r){}reportAmbiguity(t,e,s,i,n,r,o){}reportAttemptingFullContext(t,e,s,i,n,r){}reportContextSensitivity(t,e,s,i,n,r){}}class r extends n{constructor(){super()}syntaxError(t,e,s,i,n,r){console.error("line "+s+":"+i+" "+n)}}r.INSTANCE=new r;class o extends n{constructor(t){if(super(),null===t)throw"delegates";return this.delegates=t,this}syntaxError(t,e,s,i,n,r){this.delegates.map((o=>o.syntaxError(t,e,s,i,n,r)))}reportAmbiguity(t,e,s,i,n,r,o){this.delegates.map((a=>a.reportAmbiguity(t,e,s,i,n,r,o)))}reportAttemptingFullContext(t,e,s,i,n,r){this.delegates.map((o=>o.reportAttemptingFullContext(t,e,s,i,n,r)))}reportContextSensitivity(t,e,s,i,n,r){this.delegates.map((o=>o.reportContextSensitivity(t,e,s,i,n,r)))}}class a{constructor(){this._listeners=[r.INSTANCE],this._interp=null,this._stateNumber=-1}checkVersion(t){"4.10.1"!==t&&console.log("ANTLR runtime and generated code versions disagree: 4.10.1!="+t)}addErrorListener(t){this._listeners.push(t)}removeErrorListeners(){this._listeners=[]}getLiteralNames(){return Object.getPrototypeOf(this).constructor.literalNames||[]}getSymbolicNames(){return Object.getPrototypeOf(this).constructor.symbolicNames||[]}getTokenNames(){if(!this.tokenNames){const t=this.getLiteralNames(),e=this.getSymbolicNames(),s=t.length>e.length?t.length:e.length;this.tokenNames=[];for(let i=0;i";let s=e.text;return null===s&&(s=e.type===t.EOF?"":"<"+e.type+">"),s=s.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"),"'"+s+"'"}getErrorListenerDispatch(){return new o(this._listeners)}sempred(t,e,s){return!0}precpred(t,e){return!0}get state(){return this._stateNumber}set state(t){this._stateNumber=t}}a.tokenTypeMapCache={},a.ruleIndexMapCache={};class l extends t{constructor(e,s,i,n,r){super(),this.source=void 0!==e?e:l.EMPTY_SOURCE,this.type=void 0!==s?s:null,this.channel=void 0!==i?i:t.DEFAULT_CHANNEL,this.start=void 0!==n?n:-1,this.stop=void 0!==r?r:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=e[0].line,this.column=e[0].column):this.column=-1}clone(){const t=new l(this.source,this.type,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,t.text=this.text,t}toString(){let t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"}get text(){if(null!==this._text)return this._text;const t=this.getInputStream();if(null===t)return null;const e=t.size;return this.start"}set text(t){this._text=t}}l.EMPTY_SOURCE=[null,null];class h extends class{}{constructor(t){super(),this.copyText=void 0!==t&&t}create(t,e,s,i,n,r,o,a){const h=new l(t,e,i,n,r);return h.line=o,h.column=a,null!==s?h.text=s:this.copyText&&null!==t[1]&&(h.text=t[1].getText(n,r)),h}createThin(t,e){const s=new l(null,t);return s.text=e,s}}h.DEFAULT=new h;class c extends Error{constructor(t){super(t.message),Error.captureStackTrace&&Error.captureStackTrace(this,c),this.message=t.message,this.recognizer=t.recognizer,this.input=t.input,this.ctx=t.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}}class u{constructor(t,e){this.start=t,this.stop=e}clone(){return new u(this.start,this.stop)}contains(t){return t>=this.start&&t=0&&this.startIndex":"\n"===e?"\\n":"\t"===e?"\\t":"\r"===e?"\\r":e}getCharErrorDisplay(t){return"'"+this.getErrorDisplayForChar(t)+"'"}recover(e){this._input.LA(1)!==t.EOF&&(e instanceof d?this._interp.consume(this._input):this._input.consume())}get inputStream(){return this._input}set inputStream(t){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=t,this._tokenFactorySourcePair=[this,this._input]}get sourceName(){return this._input.sourceName}get type(){return this._type}set type(t){this._type=t}get line(){return this._interp.line}set line(t){this._interp.line=t}get column(){return this._interp.column}set column(t){this._interp.column=t}get text(){return null!==this._text?this._text:this._interp.getText(this._input)}set text(t){this._text=t}}p.DEFAULT_MODE=0,p.MORE=-2,p.SKIP=-3,p.DEFAULT_TOKEN_CHANNEL=t.DEFAULT_CHANNEL,p.HIDDEN=t.HIDDEN_CHANNEL,p.MIN_CHAR_VALUE=0,p.MAX_CHAR_VALUE=1114111;class _ extends class extends class{}{constructor(t){super(),this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}mark(){return 0}release(t){}reset(){this.seek(0)}seek(t){this.lazyInit(),this.index=this.adjustSeekIndex(t)}get(t){return this.lazyInit(),this.tokens[t]}consume(){let e=!1;if(e=this.index>=0&&(this.fetchedEOF?this.index0)||this.fetch(e)>=e}fetch(e){if(this.fetchedEOF)return 0;for(let s=0;s=this.tokens.length&&(s=this.tokens.length-1);for(let r=e;r=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]}adjustSeekIndex(t){return t}lazyInit(){-1===this.index&&this.setup()}setup(){this.sync(0),this.index=this.adjustSeekIndex(0)}setTokenSource(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}nextTokenOnChannel(e,s){if(this.sync(e),e>=this.tokens.length)return-1;let i=this.tokens[e];for(;i.channel!==this.channel;){if(i.type===t.EOF)return-1;e+=1,this.sync(e),i=this.tokens[e]}return e}previousTokenOnChannel(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t}getHiddenTokensToRight(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const s=this.nextTokenOnChannel(t+1,p.DEFAULT_TOKEN_CHANNEL),i=t+1,n=-1===s?this.tokens.length-1:s;return this.filterForChannel(i,n,e)}getHiddenTokensToLeft(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const s=this.previousTokenOnChannel(t-1,p.DEFAULT_TOKEN_CHANNEL);if(s===t-1)return null;const i=s+1,n=t-1;return this.filterForChannel(i,n,e)}filterForChannel(t,e,s){const i=[];for(let n=t;n=this.tokens.length&&(i=this.tokens.length-1);let n="";for(let e=s;e>>16)*o&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*a+(((s>>>16)*a&65535)<<16)&4294967295,r^=s,r=r<<13|r>>>19,e=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=27492+(65535&e)+((58964+(e>>>16)&65535)<<16);switch(s=0,i){case 3:s^=(255&t.charCodeAt(l+2))<<16;case 2:s^=(255&t.charCodeAt(l+1))<<8;case 1:s^=255&t.charCodeAt(l),s=(65535&s)*o+(((s>>>16)*o&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*a+(((s>>>16)*a&65535)<<16)&4294967295,r^=s}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0};class f{constructor(){this.count=0,this.hash=0}update(){for(let t=0;t>>17,t*=461845907,this.count=this.count+1;let s=this.hash^t;s=s<<13|s>>>19,s=5*s+3864292196,this.hash=s}}}finish(){let t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16,t}static hashStuff(){const t=new f;return t.update.apply(t,arguments),t.finish()}}function x(t){return t?t.hashCode():-1}function T(t,e){return t?t.equals(e):t===e}function E(t){return null===t?"null":t}function N(t){return Array.isArray(t)?"["+t.map(E).join(", ")+"]":"null"}const C="h-";class S{constructor(t,e){this.data={},this.hashFunction=t||x,this.equalsFunction=e||T}add(t){const e=C+this.hashFunction(t);if(e in this.data){const s=this.data[e];for(let e=0;et.startsWith(C))).flatMap((t=>this.data[t]),this)}toString(){return N(this.values())}get length(){return Object.keys(this.data).filter((t=>t.startsWith(C))).map((t=>this.data[t].length),this).reduce(((t,e)=>t+e),0)}}class m{hashCode(){const t=new f;return this.updateHashCode(t),t.finish()}evaluate(t,e){}evalPrecedence(t,e){return this}static andContext(t,e){if(null===t||t===m.NONE)return e;if(null===e||e===m.NONE)return t;const s=new A(t,e);return 1===s.opnds.length?s.opnds[0]:s}static orContext(t,e){if(null===t)return e;if(null===e)return t;if(t===m.NONE||e===m.NONE)return m.NONE;const s=new L(t,e);return 1===s.opnds.length?s.opnds[0]:s}}class A extends m{constructor(t,e){super();const s=new S;t instanceof A?t.opnds.map((function(t){s.add(t)})):s.add(t),e instanceof A?e.opnds.map((function(t){s.add(t)})):s.add(e);const i=R(s);if(i.length>0){let t=null;i.map((function(e){(null===t||e.precedencet.toString()));return(t.length>3?t.slice(3):t).join("&&")}}class L extends m{constructor(t,e){super();const s=new S;t instanceof L?t.opnds.map((function(t){s.add(t)})):s.add(t),e instanceof L?e.opnds.map((function(t){s.add(t)})):s.add(e);const i=R(s);if(i.length>0){const t=i.sort((function(t,e){return t.compareTo(e)})),e=t[t.length-1];s.add(e)}this.opnds=Array.from(s.values())}equals(t){return this===t||t instanceof L&&g(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"OR")}evaluate(t,e){for(let s=0;st.toString()));return(t.length>3?t.slice(3):t).join("||")}}function R(t){const e=[];return t.values().map((function(t){t instanceof m.PrecedencePredicate&&e.push(t)})),e}function I(t,e){if(null===t){const t={state:null,alt:null,context:null,semanticContext:null};return e&&(t.reachesIntoOuterContext=0),t}{const s={};return s.state=t.state||null,s.alt=void 0===t.alt?null:t.alt,s.context=t.context||null,s.semanticContext=t.semanticContext||null,e&&(s.reachesIntoOuterContext=t.reachesIntoOuterContext||0,s.precedenceFilterSuppressed=t.precedenceFilterSuppressed||!1),s}}class v{constructor(t,e){this.checkContext(t,e),t=I(t),e=I(e,!0),this.state=null!==t.state?t.state:e.state,this.alt=null!==t.alt?t.alt:e.alt,this.context=null!==t.context?t.context:e.context,this.semanticContext=null!==t.semanticContext?t.semanticContext:null!==e.semanticContext?e.semanticContext:m.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,this.precedenceFilterSuppressed=e.precedenceFilterSuppressed}checkContext(t,e){null!==t.context&&void 0!==t.context||null!==e&&null!==e.context&&void 0!==e.context||(this.context=null)}hashCode(){const t=new f;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)}equals(t){return this===t||t instanceof v&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&(null===this.context?null===t.context:this.context.equals(t.context))&&this.semanticContext.equals(t.semanticContext)&&this.precedenceFilterSuppressed===t.precedenceFilterSuppressed}hashCodeForConfigSet(){const t=new f;return t.update(this.state.stateNumber,this.alt,this.semanticContext),t.finish()}equalsForConfigSet(t){return this===t||t instanceof v&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&this.semanticContext.equals(t.semanticContext)}toString(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==m.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}class y{constructor(){this.intervals=null,this.readOnly=!1}first(e){return null===this.intervals||0===this.intervals.length?t.INVALID_TYPE:this.intervals[0].start}addOne(t){this.addInterval(new u(t,t+1))}addRange(t,e){this.addInterval(new u(t,e+1))}addInterval(t){if(null===this.intervals)this.intervals=[],this.intervals.push(t.clone());else{for(let e=0;ethis.addInterval(t)),this),this}reduce(t){if(t=s.stop?(this.intervals.splice(t+1,1),this.reduce(t)):e.stop>=s.start&&(this.intervals[t]=new u(e.start,s.stop),this.intervals.splice(t+1,1))}}complement(t,e){const s=new y;return s.addInterval(new u(t,e+1)),null!==this.intervals&&this.intervals.forEach((t=>s.removeRange(t))),s}contains(t){if(null===this.intervals)return!1;for(let e=0;es.start&&t.stop=s.stop?(this.intervals.splice(e,1),e-=1):t.start"):e.push("'"+String.fromCharCode(i.start)+"'"):e.push("'"+String.fromCharCode(i.start)+"'..'"+String.fromCharCode(i.stop-1)+"'")}return e.length>1?"{"+e.join(", ")+"}":e[0]}toIndexString(){const e=[];for(let s=0;s"):e.push(i.start.toString()):e.push(i.start.toString()+".."+(i.stop-1).toString())}return e.length>1?"{"+e.join(", ")+"}":e[0]}toTokenString(t,e){const s=[];for(let i=0;i1?"{"+s.join(", ")+"}":s[0]}elementName(e,s,i){return i===t.EOF?"":i===t.EPSILON?"":e[i]||s[i]}get length(){return this.intervals.map((t=>t.length)).reduce(((t,e)=>t+e))}}class O{constructor(){this.atn=null,this.stateNumber=O.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null}toString(){return this.stateNumber}equals(t){return t instanceof O&&this.stateNumber===t.stateNumber}isNonGreedyExitState(){return!1}addTransition(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)}}O.INVALID_TYPE=0,O.BASIC=1,O.RULE_START=2,O.BLOCK_START=3,O.PLUS_BLOCK_START=4,O.STAR_BLOCK_START=5,O.TOKEN_START=6,O.RULE_STOP=7,O.BLOCK_END=8,O.STAR_LOOP_BACK=9,O.STAR_LOOP_ENTRY=10,O.PLUS_LOOP_BACK=11,O.LOOP_END=12,O.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],O.INVALID_STATE_NUMBER=-1;class P extends O{constructor(){return super(),this.stateType=O.RULE_STOP,this}}class k{constructor(t){if(null==t)throw"target cannot be null.";this.target=t,this.isEpsilon=!1,this.label=null}}k.EPSILON=1,k.RANGE=2,k.RULE=3,k.PREDICATE=4,k.ATOM=5,k.ACTION=6,k.SET=7,k.NOT_SET=8,k.WILDCARD=9,k.PRECEDENCE=10,k.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],k.serializationTypes={EpsilonTransition:k.EPSILON,RangeTransition:k.RANGE,RuleTransition:k.RULE,PredicateTransition:k.PREDICATE,AtomTransition:k.ATOM,ActionTransition:k.ACTION,SetTransition:k.SET,NotSetTransition:k.NOT_SET,WildcardTransition:k.WILDCARD,PrecedencePredicateTransition:k.PRECEDENCE};class b extends k{constructor(t,e,s,i){super(t),this.ruleIndex=e,this.precedence=s,this.followState=i,this.serializationType=k.RULE,this.isEpsilon=!0}matches(t,e,s){return!1}}class D extends k{constructor(e,s){super(e),this.serializationType=k.SET,null!=s?this.label=s:(this.label=new y,this.label.addOne(t.INVALID_TYPE))}matches(t,e,s){return this.label.contains(t)}toString(){return this.label.toString()}}class w extends D{constructor(t,e){super(t,e),this.serializationType=k.NOT_SET}matches(t,e,s){return t>=e&&t<=s&&!super.matches(t,e,s)}toString(){return"~"+super.toString()}}class F extends k{constructor(t){super(t),this.serializationType=k.WILDCARD}matches(t,e,s){return t>=e&&t<=s}toString(){return"."}}class M extends k{constructor(t){super(t)}}class U extends class extends class{}{}{}class B extends U{getRuleContext(){throw new Error("missing interface implementation")}}class V extends U{}class H extends V{}const q={toStringTree:function(t,e,s){e=e||null,null!==(s=s||null)&&(e=s.ruleNames);let i=q.getNodeText(t,e);i=function(t,e){return t=t.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(i);const n=t.getChildCount();if(0===n)return i;let r="("+i+" ";n>0&&(i=q.toStringTree(t.getChild(0),e),r=r.concat(i));for(let s=1;s=0&&e0&&(t+=", "),this.returnStates[e]!==K.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"}}get length(){return this.returnStates.length}}class Y extends K{constructor(t,e){let s=0;const i=new f;null!==t?i.update(t,e):i.update(1),s=i.finish(),super(s),this.parentCtx=t,this.returnState=e}getParent(t){return this.parentCtx}getReturnState(t){return this.returnState}equals(t){return this===t||t instanceof Y&&this.hashCode()===t.hashCode()&&this.returnState===t.returnState&&(null==this.parentCtx?null==t.parentCtx:this.parentCtx.equals(t.parentCtx))}toString(){const t=null===this.parentCtx?"":this.parentCtx.toString();return 0===t.length?this.returnState===K.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+t}get length(){return 1}static create(t,e){return e===K.EMPTY_RETURN_STATE&&null===t?K.EMPTY:new Y(t,e)}}class Q extends Y{constructor(){super(null,K.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(t){return null}getReturnState(t){return this.returnState}equals(t){return this===t}toString(){return"$"}}K.EMPTY=new Q;const X="h-";class W{constructor(t,e){this.data={},this.hashFunction=t||x,this.equalsFunction=e||T}set(t,e){const s=X+this.hashFunction(t);if(s in this.data){const i=this.data[s];for(let s=0;st.startsWith(X))).flatMap((t=>this.data[t]),this)}getKeys(){return this.entries().map((t=>t.key))}getValues(){return this.entries().map((t=>t.value))}toString(){return"["+this.entries().map((t=>"{"+t.key+":"+t.value+"}")).join(", ")+"]"}get length(){return Object.keys(this.data).filter((t=>t.startsWith(X))).map((t=>this.data[t].length),this).reduce(((t,e)=>t+e),0)}}function $(t,e){if(null==e&&(e=j.EMPTY),null===e.parentCtx||e===j.EMPTY)return K.EMPTY;const s=$(t,e.parentCtx),i=t.states[e.invokingState].transitions[0];return Y.create(s,i.followState.stateNumber)}function J(t,e,s){if(t.isEmpty())return t;let i=s.get(t)||null;if(null!==i)return i;if(i=e.get(t),null!==i)return s.set(t,i),i;let n=!1,r=[];for(let i=0;ie.returnState&&(n[0]=e.returnState,n[1]=t.returnState);const r=new z([s,s],n);return null!==i&&i.set(t,e,r),r}const n=[t.returnState,e.returnState];let r=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(n[0]=e.returnState,n[1]=t.returnState,r=[e.parentCtx,t.parentCtx]);const o=new z(r,n);return null!==i&&i.set(t,e,o),o}}(t,e,s,i);if(s){if(t instanceof Q)return t;if(e instanceof Q)return e}return t instanceof Y&&(t=new z([t.getParent()],[t.returnState])),e instanceof Y&&(e=new z([e.getParent()],[e.returnState])),function(t,e,s,i){if(null!==i){let s=i.get(t,e);if(null!==s)return s;if(s=i.get(e,t),null!==s)return s}let n=0,r=0,o=0,a=[],l=[];for(;nthis.add(t)),this)}remove(t){delete this.data[t]}has(t){return!0===this.data[t]}values(){return Object.keys(this.data)}minValue(){return Math.min.apply(null,this.values())}hashCode(){return f.hashStuff(this.values())}equals(t){return t instanceof tt&&g(this.data,t.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.values().length}}class et{constructor(t){this.atn=t}getDecisionLookahead(t){if(null===t)return null;const e=t.transitions.length,s=[];for(let i=0;i=this.states.length)throw"Invalid state number.";const i=this.states[e];let n=this.nextTokens(i);if(!n.contains(t.EPSILON))return n;const r=new y;for(r.addSet(n),r.removeOne(t.EPSILON);null!==s&&s.invokingState>=0&&n.contains(t.EPSILON);){const e=this.states[s.invokingState].transitions[0];n=this.nextTokens(e.followState),r.addSet(n),r.removeOne(t.EPSILON),s=s.parentCtx}return n.contains(t.EPSILON)&&r.addOne(t.EOF),r}}st.INVALID_ALT_NUMBER=0;class it extends O{constructor(){super(),this.stateType=O.BASIC}}class nt extends O{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class rt extends nt{constructor(){return super(),this.endState=null,this}}class ot extends O{constructor(){return super(),this.stateType=O.BLOCK_END,this.startState=null,this}}class at extends O{constructor(){return super(),this.stateType=O.LOOP_END,this.loopBackState=null,this}}class lt extends O{constructor(){return super(),this.stateType=O.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class ht extends nt{constructor(){return super(),this.stateType=O.TOKEN_START,this}}class ct extends nt{constructor(){return super(),this.stateType=O.PLUS_LOOP_BACK,this}}class ut extends O{constructor(){return super(),this.stateType=O.STAR_LOOP_BACK,this}}class dt extends nt{constructor(){return super(),this.stateType=O.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class pt extends rt{constructor(){return super(),this.stateType=O.PLUS_BLOCK_START,this.loopBackState=null,this}}class _t extends rt{constructor(){return super(),this.stateType=O.STAR_BLOCK_START,this}}class gt extends rt{constructor(){return super(),this.stateType=O.BLOCK_START,this}}class ft extends k{constructor(t,e){super(t),this.label_=e,this.label=this.makeLabel(),this.serializationType=k.ATOM}makeLabel(){const t=new y;return t.addOne(this.label_),t}matches(t,e,s){return this.label_===t}toString(){return this.label_}}class xt extends k{constructor(t,e,s){super(t),this.serializationType=k.RANGE,this.start=e,this.stop=s,this.label=this.makeLabel()}makeLabel(){const t=new y;return t.addRange(this.start,this.stop),t}matches(t,e,s){return t>=this.start&&t<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}}class Tt extends k{constructor(t,e,s,i){super(t),this.serializationType=k.ACTION,this.ruleIndex=e,this.actionIndex=void 0===s?-1:s,this.isCtxDependent=void 0!==i&&i,this.isEpsilon=!0}matches(t,e,s){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}}class Et extends k{constructor(t,e){super(t),this.serializationType=k.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e}matches(t,e,s){return!1}toString(){return"epsilon"}}class Nt extends m{constructor(t,e,s){super(),this.ruleIndex=void 0===t?-1:t,this.predIndex=void 0===e?-1:e,this.isCtxDependent=void 0!==s&&s}evaluate(t,e){const s=this.isCtxDependent?e:null;return t.sempred(s,this.ruleIndex,this.predIndex)}updateHashCode(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)}equals(t){return this===t||t instanceof Nt&&this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}m.NONE=new Nt;class Ct extends M{constructor(t,e,s,i){super(t),this.serializationType=k.PREDICATE,this.ruleIndex=e,this.predIndex=s,this.isCtxDependent=i,this.isEpsilon=!0}matches(t,e,s){return!1}getPredicate(){return new Nt(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class St extends m{constructor(t){super(),this.precedence=void 0===t?0:t}evaluate(t,e){return t.precpred(e,this.precedence)}evalPrecedence(t,e){return t.precpred(e,this.precedence)?m.NONE:null}compareTo(t){return this.precedence-t.precedence}updateHashCode(t){t.update(this.precedence)}equals(t){return this===t||t instanceof St&&this.precedence===t.precedence}toString(){return"{"+this.precedence+">=prec}?"}}m.PrecedencePredicate=St;class mt extends M{constructor(t,e){super(t),this.serializationType=k.PRECEDENCE,this.precedence=e,this.isEpsilon=!0}matches(t,e,s){return!1}getPredicate(){return new St(this.precedence)}toString(){return this.precedence+" >= _p"}}class At{constructor(t){void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions}}At.defaultOptions=new At,At.defaultOptions.readOnly=!0;class Lt{constructor(t){this.actionType=t,this.isPositionDependent=!1}hashCode(){const t=new f;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.actionType)}equals(t){return this===t}}class Rt extends Lt{constructor(){super(6)}execute(t){t.skip()}toString(){return"skip"}}Rt.INSTANCE=new Rt;class It extends Lt{constructor(t){super(0),this.channel=t}execute(t){t._channel=this.channel}updateHashCode(t){t.update(this.actionType,this.channel)}equals(t){return this===t||t instanceof It&&this.channel===t.channel}toString(){return"channel("+this.channel+")"}}class vt extends Lt{constructor(t,e){super(1),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0}execute(t){t.action(null,this.ruleIndex,this.actionIndex)}updateHashCode(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)}equals(t){return this===t||t instanceof vt&&this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex}}class yt extends Lt{constructor(){super(3)}execute(t){t.more()}toString(){return"more"}}yt.INSTANCE=new yt;class Ot extends Lt{constructor(t){super(7),this.type=t}execute(t){t.type=this.type}updateHashCode(t){t.update(this.actionType,this.type)}equals(t){return this===t||t instanceof Ot&&this.type===t.type}toString(){return"type("+this.type+")"}}class Pt extends Lt{constructor(t){super(5),this.mode=t}execute(t){t.pushMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof Pt&&this.mode===t.mode}toString(){return"pushMode("+this.mode+")"}}class kt extends Lt{constructor(){super(4)}execute(t){t.popMode()}toString(){return"popMode"}}kt.INSTANCE=new kt;class bt extends Lt{constructor(t){super(2),this.mode=t}execute(t){t.mode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof bt&&this.mode===t.mode}toString(){return"mode("+this.mode+")"}}function Dt(t,e){const s=[];return s[t-1]=e,s.map((function(t){return e}))}class wt{constructor(t){null==t&&(t=At.defaultOptions),this.deserializationOptions=t,this.stateFactories=null,this.actionFactories=null}deserialize(t){const e=this.reset(t);this.checkVersion(e),e&&this.skipUUID();const s=this.readATN();this.readStates(s,e),this.readRules(s,e),this.readModes(s);const i=[];return this.readSets(s,i,this.readInt.bind(this)),e&&this.readSets(s,i,this.readInt32.bind(this)),this.readEdges(s,i),this.readDecisions(s),this.readLexerActions(s,e),this.markPrecedenceDecisions(s),this.verifyATN(s),this.deserializationOptions.generateRuleBypassTransitions&&1===s.grammarType&&(this.generateRuleBypassTransitions(s),this.verifyATN(s)),s}reset(t){if(3===(t.charCodeAt?t.charCodeAt(0):t[0])){const e=function(t){const e=t.charCodeAt(0);return e>1?e-2:e+65534},s=t.split("").map(e);return s[0]=t.charCodeAt(0),this.data=s,this.pos=0,!0}return this.data=t,this.pos=0,!1}skipUUID(){let t=0;for(;t++<8;)this.readInt()}checkVersion(t){const e=this.readInt();if(!t&&4!==e)throw"Could not deserialize ATN with version "+e+" (expected 4)."}readATN(){const t=this.readInt(),e=this.readInt();return new st(t,e)}readStates(t,e){let s,i,n;const r=[],o=[],a=this.readInt();for(let s=0;s0;)n.addTransition(l.transitions[h-1]),l.transitions=l.transitions.slice(-1);t.ruleToStartState[e].addTransition(new Et(n)),r.addTransition(new Et(a));const c=new it;t.addState(c),c.addTransition(new ft(r,t.ruleToTokenType[e])),n.addTransition(new Et(c))}stateIsEndStateFor(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof dt))return null;const s=t.transitions[t.transitions.length-1].target;return s instanceof at&&s.epsilonOnlyTransitions&&s.transitions[0].target instanceof P?t:null}markPrecedenceDecisions(t){for(let e=0;e=0):this.checkCondition(s.transitions.length<=1||s instanceof P)}}checkCondition(t,e){if(!t)throw null==e&&(e="IllegalState"),e}readInt(){return this.data[this.pos++]}readInt32(){return this.readInt()|this.readInt()<<16}edgeFactory(e,s,i,n,r,o,a,l){const h=e.states[n];switch(s){case k.EPSILON:return new Et(h);case k.RANGE:return new xt(h,0!==a?t.EOF:r,o);case k.RULE:return new b(e.states[r],o,a,h);case k.PREDICATE:return new Ct(h,r,o,0!==a);case k.PRECEDENCE:return new mt(h,r);case k.ATOM:return new ft(h,0!==a?t.EOF:r);case k.ACTION:return new Tt(h,r,o,0!==a);case k.SET:return new D(h,l[r]);case k.NOT_SET:return new w(h,l[r]);case k.WILDCARD:return new F(h);default:throw"The specified transition type: "+s+" is not valid."}}stateFactory(t,e){if(null===this.stateFactories){const t=[];t[O.INVALID_TYPE]=null,t[O.BASIC]=()=>new it,t[O.RULE_START]=()=>new lt,t[O.BLOCK_START]=()=>new gt,t[O.PLUS_BLOCK_START]=()=>new pt,t[O.STAR_BLOCK_START]=()=>new _t,t[O.TOKEN_START]=()=>new ht,t[O.RULE_STOP]=()=>new P,t[O.BLOCK_END]=()=>new ot,t[O.STAR_LOOP_BACK]=()=>new ut,t[O.STAR_LOOP_ENTRY]=()=>new dt,t[O.PLUS_LOOP_BACK]=()=>new ct,t[O.LOOP_END]=()=>new at,this.stateFactories=t}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";{const s=this.stateFactories[t]();if(null!==s)return s.ruleIndex=e,s}}lexerActionFactory(t,e,s){if(null===this.actionFactories){const t=[];t[0]=(t,e)=>new It(t),t[1]=(t,e)=>new vt(t,e),t[2]=(t,e)=>new bt(t),t[3]=(t,e)=>yt.INSTANCE,t[4]=(t,e)=>kt.INSTANCE,t[5]=(t,e)=>new Pt(t),t[6]=(t,e)=>Rt.INSTANCE,t[7]=(t,e)=>new Ot(t),this.actionFactories=t}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,s)}}function Ft(t){return t.hashCodeForConfigSet()}function Mt(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}class Ut{constructor(t){this.configLookup=new S(Ft,Mt),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1}add(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==m.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);const s=this.configLookup.add(t);if(s===t)return this.cachedHashCode=-1,this.configs.push(t),!0;const i=!this.fullCtx,n=Z(s.context,t.context,i,e);return s.reachesIntoOuterContext=Math.max(s.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(s.precedenceFilterSuppressed=!0),s.context=n,!0}getStates(){const t=new S;for(let e=0;eYt.MAX_DFA_EDGE)return null;let s=t.edges[e-Yt.MIN_DFA_EDGE];return void 0===s&&(s=null),Yt.debug&&null!==s&&console.log("reuse state "+t.stateNumber+" edge to "+s.stateNumber),s}computeTargetState(t,e,s){const i=new Ht;return this.getReachableConfigSet(t,e.configs,i,s),0===i.items.length?(i.hasSemanticContext||this.addDFAEdge(e,s,Vt.ERROR),Vt.ERROR):this.addDFAEdge(e,s,null,i)}failOrAccept(e,s,i,n){if(null!==this.prevAccept.dfaState){const t=e.dfaState.lexerActionExecutor;return this.accept(s,t,this.startIndex,e.index,e.line,e.column),e.dfaState.prediction}if(n===t.EOF&&s.index===this.startIndex)return t.EOF;throw new d(this.recog,s,this.startIndex,i)}getReachableConfigSet(e,s,i,n){let r=st.INVALID_ALT_NUMBER;for(let o=0;oYt.MAX_DFA_EDGE||(Yt.debug&&console.log("EDGE "+t+" -> "+s+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-Yt.MIN_DFA_EDGE]=s),s}addDFAState(t){const e=new Bt(null,t);let s=null;for(let e=0;et.startsWith("k-"))).map((t=>this.data[t]),this)}}const Wt={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(t,e){if(Wt.allConfigsInRuleStopStates(e))return!0;if(t===Wt.SLL&&e.hasSemanticContext){const t=new Ut;for(let s=0;s1)return!0;return!1},allSubsetsEqual:function(t){let e=null;for(let s=0;s0&&(r=this.getAltThatFinishedDecisionEntryRule(n),r!==st.INVALID_ALT_NUMBER)?r:st.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(t){const e=[];for(let s=0;s0||i.state instanceof P&&i.context.hasEmptyPath())&&e.indexOf(i.alt)<0&&e.push(i.alt)}return 0===e.length?st.INVALID_ALT_NUMBER:Math.min.apply(null,e)}splitAccordingToSemanticValidity(t,e){const s=new Ut(t.fullCtx),i=new Ut(t.fullCtx);for(let n=0;n50))throw"problem";if(t.state instanceof P){if(!t.context.isEmpty()){for(let a=0;a=0&&(i+=1)}this.closureCheckingStopState(u,e,s,c,n,i,o)}}}canDropLoopEntryEdgeInLeftRecursiveRule(t){const e=t.state;if(e.stateType!==O.STAR_LOOP_ENTRY)return!1;if(e.stateType!==O.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;const s=t.context.length;for(let i=0;i=0?this.parser.ruleNames[t]:""}getEpsilonTarget(e,s,i,n,r,o){switch(s.serializationType){case k.RULE:return this.ruleTransition(e,s);case k.PRECEDENCE:return this.precedenceTransition(e,s,i,n,r);case k.PREDICATE:return this.predTransition(e,s,i,n,r);case k.ACTION:return this.actionTransition(e,s);case k.EPSILON:return new v({state:s.target},e);case k.ATOM:case k.RANGE:case k.SET:return o&&s.matches(t.EOF,0,1)?new v({state:s.target},e):null;default:return null}}actionTransition(t,e){if(this.debug){const t=-1===e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+t)}return new v({state:e.target},t)}precedenceTransition(t,e,s,i,n){this.debug&&(console.log("PRED (collectPredicates="+s+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+N(this.parser.getRuleInvocationStack())));let r=null;if(s&&i)if(n){const s=this._input.index;this._input.seek(this._startIndex);const i=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(s),i&&(r=new v({state:e.target},t))}else{const s=m.andContext(t.semanticContext,e.getPredicate());r=new v({state:e.target,semanticContext:s},t)}else r=new v({state:e.target},t);return this.debug&&console.log("config from pred transition="+r),r}predTransition(t,e,s,i,n){this.debug&&(console.log("PRED (collectPredicates="+s+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+N(this.parser.getRuleInvocationStack())));let r=null;if(s&&(e.isCtxDependent&&i||!e.isCtxDependent))if(n){const s=this._input.index;this._input.seek(this._startIndex);const i=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(s),i&&(r=new v({state:e.target},t))}else{const s=m.andContext(t.semanticContext,e.getPredicate());r=new v({state:e.target,semanticContext:s},t)}else r=new v({state:e.target},t);return this.debug&&console.log("config from pred transition="+r),r}ruleTransition(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);const s=e.followState,i=Y.create(t.context,s.stateNumber);return new v({state:e.target,context:i},t)}getConflictingAlts(t){const e=$t.getConflictingAltSubsets(t);return $t.getAlts(e)}getConflictingAltsOrUniqueAlt(t){let e=null;return t.uniqueAlt!==st.INVALID_ALT_NUMBER?(e=new tt,e.add(t.uniqueAlt)):e=t.conflictingAlts,e}getTokenName(e){if(e===t.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(e>=this.parser.literalNames.length&&e>=this.parser.symbolicNames.length))return(this.parser.literalNames[e]||this.parser.symbolicNames[e])+"<"+e+">";console.log(e+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+e}getLookaheadName(t){return this.getTokenName(t.LA(1))}dumpDeadEndConfigs(t){console.log("dead end configs: ");const e=t.getDeadEndConfigs();for(let t=0;t0){const t=s.state.transitions[0];t instanceof ft?i="Atom "+this.getTokenName(t.label):t instanceof D&&(i=(t instanceof w?"~":"")+"Set "+t.set)}console.error(s.toString(this.parser,!0)+":"+i)}}noViableAlt(t,e,s,i){return new Jt(this.parser,t,t.get(i),t.LT(1),s,e)}getUniqueAlt(t){let e=st.INVALID_ALT_NUMBER;for(let s=0;s "+i+" upon "+this.getTokenName(s)),null===i)return null;if(i=this.addDFAState(t,i),null===e||s<-1||s>this.atn.maxTokenType)return i;if(null===e.edges&&(e.edges=[]),e.edges[s+1]=i,this.debug){const e=null===this.parser?null:this.parser.literalNames,s=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(e,s))}return i}addDFAState(t,e){if(e===Vt.ERROR)return e;const s=t.states.get(e);return null!==s?s:(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)}reportAttemptingFullContext(t,e,s,i,n){if(this.debug||this.retry_debug){const e=new u(i,n+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+s+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser,t,i,n,e,s)}reportContextSensitivity(t,e,s,i,n){if(this.debug||this.retry_debug){const e=new u(i,n+1);console.log("reportContextSensitivity decision="+t.decision+":"+s+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser,t,i,n,e,s)}reportAmbiguity(t,e,s,i,n,r,o){if(this.debug||this.retry_debug){const t=new u(s,i+1);console.log("reportAmbiguity "+r+":"+o+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser,t,s,i,n,r,o)}},PredictionMode:$t};class ee{constructor(t,e,s){this.dfa=t,this.literalNames=e||[],this.symbolicNames=s||[]}toString(){if(null===this.dfa.s0)return null;let t="";const e=this.dfa.sortedStates();for(let s=0;s"),t=t.concat(this.getStateString(e)),t=t.concat("\n"))}}}return 0===t.length?null:t}getEdgeLabel(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)}getStateString(t){const e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+N(t.predicates):e+"=>"+t.prediction.toString():e}}class se extends ee{constructor(t){super(t,null)}getEdgeLabel(t){return"'"+String.fromCharCode(t)+"'"}}const ie={DFA:class{constructor(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new S,this.s0=null,this.precedenceDfa=!1,t instanceof dt&&t.isPrecedenceDecision){this.precedenceDfa=!0;const t=new Bt(null,new Ut);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}}getPrecedenceStartState(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null}setPrecedenceStartState(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)}setPrecedenceDfa(t){if(this.precedenceDfa!==t){if(this._states=new S,t){const t=new Bt(null,new Ut);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}else this.s0=null;this.precedenceDfa=t}}sortedStates(){return this._states.values().sort((function(t,e){return t.stateNumber-e.stateNumber}))}toString(t,e){return t=t||null,e=e||null,null===this.s0?"":new ee(this,t,e).toString()}toLexerString(){return null===this.s0?"":new se(this).toString()}get states(){return this._states}},DFASerializer:ee,LexerDFASerializer:se,PredPrediction:Qt};class ne{visitTerminal(t){}visitErrorNode(t){}enterEveryRule(t){}exitEveryRule(t){}}class re{walk(t,e){if(e instanceof H||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof V)t.visitTerminal(e);else{this.enterRule(t,e);for(let s=0;s=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);const s=this.getErrorRecoverySet(t);this.consumeUntil(t,s)}sync(e){if(this.inErrorRecoveryMode(e))return;const s=e._interp.atn.states[e.state],i=e.getTokenStream().LA(1),n=e.atn.nextTokens(s);if(n.contains(i))return this.nextTokensContext=null,void(this.nextTokenState=O.INVALID_STATE_NUMBER);if(n.contains(t.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=e._ctx,this.nextTokensState=e._stateNumber);else switch(s.stateType){case O.BLOCK_START:case O.STAR_BLOCK_START:case O.PLUS_BLOCK_START:case O.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(e))return;throw new ae(e);case O.PLUS_LOOP_BACK:case O.STAR_LOOP_BACK:{this.reportUnwantedToken(e);const t=new y;t.addSet(e.getExpectedTokens());const s=t.addSet(this.getErrorRecoverySet(e));this.consumeUntil(e,s)}}}reportNoViableAlternative(e,s){const i=e.getTokenStream();let n;n=null!==i?s.startToken.type===t.EOF?"":i.getText(new u(s.startToken.tokenIndex,s.offendingToken.tokenIndex)):"";const r="no viable alternative at input "+this.escapeWSAndQuote(n);e.notifyErrorListeners(r,s.offendingToken,s)}reportInputMismatch(t,e){const s="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(s,e.offendingToken,e)}reportFailedPredicate(t,e){const s="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(s,e.offendingToken,e)}reportUnwantedToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),s="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(s,e,null)}reportMissingToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),s="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(s,e,null)}recoverInline(t){const e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new ae(t)}singleTokenInsertion(t){const e=t.getTokenStream().LA(1),s=t._interp.atn,i=s.states[t.state].transitions[0].target;return!!s.nextTokens(i,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)}singleTokenDeletion(t){const e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();const e=t.getCurrentToken();return this.reportMatch(t),e}return null}getMissingSymbol(e){const s=e.getCurrentToken(),i=this.getExpectedTokens(e).first();let n;n=i===t.EOF?"":"";let r=s;const o=e.getTokenStream().LT(-1);return r.type===t.EOF&&null!==o&&(r=o),e.getTokenFactory().create(r.source,i,n,t.DEFAULT_CHANNEL,-1,-1,r.line,r.column)}getExpectedTokens(t){return t.getExpectedTokens()}getTokenErrorDisplay(e){if(null===e)return"";let s=e.text;return null===s&&(s=e.type===t.EOF?"":"<"+e.type+">"),this.escapeWSAndQuote(s)}escapeWSAndQuote(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"}getErrorRecoverySet(e){const s=e._interp.atn;let i=e._ctx;const n=new y;for(;null!==i&&i.invokingState>=0;){const t=s.states[i.invokingState].transitions[0],e=s.nextTokens(t.followState);n.addSet(e),i=i.parentCtx}return n.removeOne(t.EPSILON),n}consumeUntil(e,s){let i=e.getTokenStream().LA(1);for(;i!==t.EOF&&!s.contains(i);)e.consume(),i=e.getTokenStream().LA(1)}}const de={RecognitionException:c,NoViableAltException:Jt,LexerNoViableAltException:d,InputMismatchException:ae,FailedPredicateException:le,DiagnosticErrorListener:class extends n{constructor(t){super(),t=t||!0,this.exactOnly=t}reportAmbiguity(t,e,s,i,n,r,o){if(this.exactOnly&&!n)return;const a="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(r,o)+", input='"+t.getTokenStream().getText(new u(s,i))+"'";t.notifyErrorListeners(a)}reportAttemptingFullContext(t,e,s,i,n,r){const o="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new u(s,i))+"'";t.notifyErrorListeners(o)}reportContextSensitivity(t,e,s,i,n,r){const o="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new u(s,i))+"'";t.notifyErrorListeners(o)}getDecisionDescription(t,e){const s=e.decision,i=e.atnStartState.ruleIndex,n=t.ruleNames;if(i<0||i>=n.length)return""+s;const r=n[i]||null;return null===r||0===r.length?""+s:`${s} (${r})`}getConflictingAlts(t,e){if(null!==t)return t;const s=new tt;for(let t=0;t=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}}removeParseListeners(){this._parseListeners=null}triggerEnterRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.forEach((function(e){e.enterEveryRule(t),t.enterRule(e)}))}}triggerExitRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.slice(0).reverse().forEach((function(e){t.exitRule(e),e.exitEveryRule(t)}))}}getTokenFactory(){return this._input.tokenSource._factory}setTokenFactory(t){this._input.tokenSource._factory=t}getATNWithBypassAlts(){const t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";let e=this.bypassAltsAtnCache[t];if(null===e){const s=new At;s.generateRuleBypassTransitions=!0,e=new wt(s).deserialize(t),this.bypassAltsAtnCache[t]=e}return e}getInputStream(){return this.getTokenStream()}setInputStream(t){this.setTokenStream(t)}getTokenStream(){return this._input}setTokenStream(t){this._input=null,this.reset(),this._input=t}getCurrentToken(){return this._input.LT(1)}notifyErrorListeners(t,e,s){s=s||null,null===(e=e||null)&&(e=this.getCurrentToken()),this._syntaxErrors+=1;const i=e.line,n=e.column;this.getErrorListenerDispatch().syntaxError(this,e,i,n,t,s)}consume(){const e=this.getCurrentToken();e.type!==t.EOF&&this.getInputStream().consume();const s=null!==this._parseListeners&&this._parseListeners.length>0;if(this.buildParseTrees||s){let t;t=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(e):this._ctx.addTokenNode(e),t.invokingState=this.state,s&&this._parseListeners.forEach((function(e){t instanceof H||void 0!==t.isErrorNode&&t.isErrorNode()?e.visitErrorNode(t):t instanceof V&&e.visitTerminal(t)}))}return e}addContextToParseTree(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)}enterRule(t,e,s){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this._ctx.stop=this._input.LT(-1),this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx}enterOuterAlt(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t}getPrecedence(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]}enterRecursionRule(t,e,s,i){this.state=e,this._precedenceStack.push(i),this._ctx=t,this._ctx.start=this._input.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(t,e,s){const i=this._ctx;i.parentCtx=t,i.invokingState=e,i.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=i.start,this.buildParseTrees&&this._ctx.addChild(i),this.triggerEnterRuleEvent()}unrollRecursionContexts(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);const e=this._ctx,s=this.getParseListeners();if(null!==s&&s.length>0)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)}getInvokingContext(t){let e=this._ctx;for(;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null}precpred(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]}inContext(t){return!1}isExpectedToken(e){const s=this._interp.atn;let i=this._ctx;const n=s.states[this.state];let r=s.nextTokens(n);if(r.contains(e))return!0;if(!r.contains(t.EPSILON))return!1;for(;null!==i&&i.invokingState>=0&&r.contains(t.EPSILON);){const t=s.states[i.invokingState].transitions[0];if(r=s.nextTokens(t.followState),r.contains(e))return!0;i=i.parentCtx}return!(!r.contains(t.EPSILON)||e!==t.EOF)}getExpectedTokens(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)}getExpectedTokensWithinCurrentRule(){const t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)}getRuleIndex(t){const e=this.getRuleIndexMap()[t];return null!==e?e:-1}getRuleInvocationStack(t){null===(t=t||null)&&(t=this._ctx);const e=[];for(;null!==t;){const s=t.ruleIndex;s<0?e.push("n/a"):e.push(this.ruleNames[s]),t=t.parentCtx}return e}getDFAStrings(){return this._interp.decisionToDFA.toString()}dumpDFA(){let t=!1;for(let e=0;e0&&(t&&console.log(),this.printer.println("Decision "+s.decision+":"),this.printer.print(s.toString(this.literalNames,this.symbolicNames)),t=!0)}}getSourceName(){return this._input.sourceName}setTrace(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new ge(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}fe.bypassAltsAtnCache={};class xe extends V{constructor(t){super(),this.parentCtx=null,this.symbol=t}getChild(t){return null}getSymbol(){return this.symbol}getParent(){return this.parentCtx}getPayload(){return this.symbol}getSourceInterval(){if(null===this.symbol)return u.INVALID_INTERVAL;const t=this.symbol.tokenIndex;return new u(t,t)}getChildCount(){return 0}accept(t){return t.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===t.EOF?"":this.symbol.text}}class Te extends xe{constructor(t){super(t)}isErrorNode(){return!0}accept(t){return t.visitErrorNode(this)}}class Ee extends j{constructor(t,e){super(t=t||null,e=e||null),this.ruleIndex=-1,this.children=null,this.start=null,this.stop=null,this.exception=null}copyFrom(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map((function(t){t instanceof Te&&(this.children.push(t),t.parentCtx=this)}),this))}enterRule(t){}exitRule(t){}addChild(t){return null===this.children&&(this.children=[]),this.children.push(t),t}removeLastChild(){null!==this.children&&this.children.pop()}addTokenNode(t){const e=new xe(t);return this.addChild(e),e.parentCtx=this,e}addErrorNode(t){const e=new Te(t);return this.addChild(e),e.parentCtx=this,e}getChild(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(let s=0;s=this.children.length)return null;for(let s=0;snew Ce.dfa.DFA(t,e)));class Ae extends Ce.Lexer{static grammarFileName="n3_nodrop.g4";static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static modeNames=["DEFAULT_MODE"];static literalNames=[null,"'.'","'@prefix'","'@base'","';'","','","'a'","'has'","'is'","'of'","'='","'<='","'=>'","'<-'","'!'","'^'","'['","']'","'('","')'","'{'","'}'","'^^'"];static symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"COMMENT","BooleanLiteral","String","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","IPLSTART","ANON","QuickVarName","PN_CHARS_U","PN_CHARS_BASE","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];static ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","T__13","T__14","T__15","T__16","T__17","T__18","T__19","T__20","T__21","COMMENT","BooleanLiteral","String","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","IPLSTART","ANON","QuickVarName","PN_CHARS_U","PN_CHARS_BASE","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];constructor(t){super(t),this._interp=new Ce.atn.LexerATNSimulator(this,Se,me,new Ce.PredictionContextCache)}get atn(){return Se}}Ae.EOF=Ce.Token.EOF,Ae.T__0=1,Ae.T__1=2,Ae.T__2=3,Ae.T__3=4,Ae.T__4=5,Ae.T__5=6,Ae.T__6=7,Ae.T__7=8,Ae.T__8=9,Ae.T__9=10,Ae.T__10=11,Ae.T__11=12,Ae.T__12=13,Ae.T__13=14,Ae.T__14=15,Ae.T__15=16,Ae.T__16=17,Ae.T__17=18,Ae.T__18=19,Ae.T__19=20,Ae.T__20=21,Ae.T__21=22,Ae.COMMENT=23,Ae.BooleanLiteral=24,Ae.String=25,Ae.IRIREF=26,Ae.PNAME_NS=27,Ae.PNAME_LN=28,Ae.BLANK_NODE_LABEL=29,Ae.LANGTAG=30,Ae.INTEGER=31,Ae.DECIMAL=32,Ae.DOUBLE=33,Ae.EXPONENT=34,Ae.STRING_LITERAL_LONG_SINGLE_QUOTE=35,Ae.STRING_LITERAL_LONG_QUOTE=36,Ae.STRING_LITERAL_QUOTE=37,Ae.STRING_LITERAL_SINGLE_QUOTE=38,Ae.UCHAR=39,Ae.ECHAR=40,Ae.WS=41,Ae.IPLSTART=42,Ae.ANON=43,Ae.QuickVarName=44,Ae.PN_CHARS_U=45,Ae.PN_CHARS_BASE=46,Ae.PN_CHARS=47,Ae.BASE=48,Ae.PREFIX=49,Ae.PN_PREFIX=50,Ae.PN_LOCAL=51,Ae.PLX=52,Ae.PERCENT=53,Ae.HEX=54,Ae.PN_LOCAL_ESC=55;class Le extends Ce.tree.ParseTreeListener{enterN3Doc(t){}exitN3Doc(t){}enterN3Statement(t){}exitN3Statement(t){}enterN3Directive(t){}exitN3Directive(t){}enterSparqlDirective(t){}exitSparqlDirective(t){}enterSparqlBase(t){}exitSparqlBase(t){}enterSparqlPrefix(t){}exitSparqlPrefix(t){}enterPrefixID(t){}exitPrefixID(t){}enterBase(t){}exitBase(t){}enterTriples(t){}exitTriples(t){}enterPredicateObjectList(t){}exitPredicateObjectList(t){}enterObjectList(t){}exitObjectList(t){}enterVerb(t){}exitVerb(t){}enterSubject(t){}exitSubject(t){}enterPredicate(t){}exitPredicate(t){}enterObject(t){}exitObject(t){}enterExpression(t){}exitExpression(t){}enterPath(t){}exitPath(t){}enterPathItem(t){}exitPathItem(t){}enterLiteral(t){}exitLiteral(t){}enterBlankNodePropertyList(t){}exitBlankNodePropertyList(t){}enterIriPropertyList(t){}exitIriPropertyList(t){}enterCollection(t){}exitCollection(t){}enterFormula(t){}exitFormula(t){}enterFormulaContent(t){}exitFormulaContent(t){}enterNumericLiteral(t){}exitNumericLiteral(t){}enterRdfLiteral(t){}exitRdfLiteral(t){}enterIri(t){}exitIri(t){}enterPrefixedName(t){}exitPrefixedName(t){}enterBlankNode(t){}exitBlankNode(t){}enterQuickVar(t){}exitQuickVar(t){}}class Re extends Ce.tree.ParseTreeVisitor{visitN3Doc(t){return this.visitChildren(t)}visitN3Statement(t){return this.visitChildren(t)}visitN3Directive(t){return this.visitChildren(t)}visitSparqlDirective(t){return this.visitChildren(t)}visitSparqlBase(t){return this.visitChildren(t)}visitSparqlPrefix(t){return this.visitChildren(t)}visitPrefixID(t){return this.visitChildren(t)}visitBase(t){return this.visitChildren(t)}visitTriples(t){return this.visitChildren(t)}visitPredicateObjectList(t){return this.visitChildren(t)}visitObjectList(t){return this.visitChildren(t)}visitVerb(t){return this.visitChildren(t)}visitSubject(t){return this.visitChildren(t)}visitPredicate(t){return this.visitChildren(t)}visitObject(t){return this.visitChildren(t)}visitExpression(t){return this.visitChildren(t)}visitPath(t){return this.visitChildren(t)}visitPathItem(t){return this.visitChildren(t)}visitLiteral(t){return this.visitChildren(t)}visitBlankNodePropertyList(t){return this.visitChildren(t)}visitIriPropertyList(t){return this.visitChildren(t)}visitCollection(t){return this.visitChildren(t)}visitFormula(t){return this.visitChildren(t)}visitFormulaContent(t){return this.visitChildren(t)}visitNumericLiteral(t){return this.visitChildren(t)}visitRdfLiteral(t){return this.visitChildren(t)}visitIri(t){return this.visitChildren(t)}visitPrefixedName(t){return this.visitChildren(t)}visitBlankNode(t){return this.visitChildren(t)}visitQuickVar(t){return this.visitChildren(t)}}const Ie=(new Ce.atn.ATNDeserializer).deserialize([4,1,55,224,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,1,0,1,0,1,0,1,0,5,0,65,8,0,10,0,12,0,68,9,0,1,0,1,0,1,1,1,1,3,1,74,8,1,1,2,1,2,3,2,78,8,2,1,3,1,3,3,3,82,8,3,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,3,8,100,8,8,1,9,1,9,1,9,1,9,1,9,1,9,3,9,108,8,9,5,9,110,8,9,10,9,12,9,113,9,9,1,10,1,10,1,10,5,10,118,8,10,10,10,12,10,121,9,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,3,11,134,8,11,1,12,1,12,1,13,1,13,1,13,3,13,141,8,13,1,14,1,14,1,15,1,15,1,16,1,16,1,16,1,16,1,16,3,16,152,8,16,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,3,17,162,8,17,1,18,1,18,1,18,3,18,167,8,18,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,5,21,180,8,21,10,21,12,21,183,9,21,1,21,1,21,1,22,1,22,3,22,189,8,22,1,22,1,22,1,23,1,23,1,23,3,23,196,8,23,3,23,198,8,23,1,23,1,23,3,23,202,8,23,3,23,204,8,23,1,24,1,24,1,25,1,25,1,25,1,25,3,25,212,8,25,1,26,1,26,3,26,216,8,26,1,27,1,27,1,28,1,28,1,29,1,29,1,29,0,0,30,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,0,3,1,0,31,33,1,0,27,28,2,0,29,29,43,43,229,0,66,1,0,0,0,2,73,1,0,0,0,4,77,1,0,0,0,6,81,1,0,0,0,8,83,1,0,0,0,10,86,1,0,0,0,12,90,1,0,0,0,14,94,1,0,0,0,16,97,1,0,0,0,18,101,1,0,0,0,20,114,1,0,0,0,22,133,1,0,0,0,24,135,1,0,0,0,26,140,1,0,0,0,28,142,1,0,0,0,30,144,1,0,0,0,32,146,1,0,0,0,34,161,1,0,0,0,36,166,1,0,0,0,38,168,1,0,0,0,40,172,1,0,0,0,42,177,1,0,0,0,44,186,1,0,0,0,46,203,1,0,0,0,48,205,1,0,0,0,50,207,1,0,0,0,52,215,1,0,0,0,54,217,1,0,0,0,56,219,1,0,0,0,58,221,1,0,0,0,60,61,3,2,1,0,61,62,5,1,0,0,62,65,1,0,0,0,63,65,3,6,3,0,64,60,1,0,0,0,64,63,1,0,0,0,65,68,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,69,1,0,0,0,68,66,1,0,0,0,69,70,5,0,0,1,70,1,1,0,0,0,71,74,3,4,2,0,72,74,3,16,8,0,73,71,1,0,0,0,73,72,1,0,0,0,74,3,1,0,0,0,75,78,3,12,6,0,76,78,3,14,7,0,77,75,1,0,0,0,77,76,1,0,0,0,78,5,1,0,0,0,79,82,3,8,4,0,80,82,3,10,5,0,81,79,1,0,0,0,81,80,1,0,0,0,82,7,1,0,0,0,83,84,5,48,0,0,84,85,5,26,0,0,85,9,1,0,0,0,86,87,5,49,0,0,87,88,5,27,0,0,88,89,5,26,0,0,89,11,1,0,0,0,90,91,5,2,0,0,91,92,5,27,0,0,92,93,5,26,0,0,93,13,1,0,0,0,94,95,5,3,0,0,95,96,5,26,0,0,96,15,1,0,0,0,97,99,3,24,12,0,98,100,3,18,9,0,99,98,1,0,0,0,99,100,1,0,0,0,100,17,1,0,0,0,101,102,3,22,11,0,102,111,3,20,10,0,103,107,5,4,0,0,104,105,3,22,11,0,105,106,3,20,10,0,106,108,1,0,0,0,107,104,1,0,0,0,107,108,1,0,0,0,108,110,1,0,0,0,109,103,1,0,0,0,110,113,1,0,0,0,111,109,1,0,0,0,111,112,1,0,0,0,112,19,1,0,0,0,113,111,1,0,0,0,114,119,3,28,14,0,115,116,5,5,0,0,116,118,3,28,14,0,117,115,1,0,0,0,118,121,1,0,0,0,119,117,1,0,0,0,119,120,1,0,0,0,120,21,1,0,0,0,121,119,1,0,0,0,122,134,3,26,13,0,123,134,5,6,0,0,124,125,5,7,0,0,125,134,3,30,15,0,126,127,5,8,0,0,127,128,3,30,15,0,128,129,5,9,0,0,129,134,1,0,0,0,130,134,5,10,0,0,131,134,5,11,0,0,132,134,5,12,0,0,133,122,1,0,0,0,133,123,1,0,0,0,133,124,1,0,0,0,133,126,1,0,0,0,133,130,1,0,0,0,133,131,1,0,0,0,133,132,1,0,0,0,134,23,1,0,0,0,135,136,3,30,15,0,136,25,1,0,0,0,137,141,3,30,15,0,138,139,5,13,0,0,139,141,3,30,15,0,140,137,1,0,0,0,140,138,1,0,0,0,141,27,1,0,0,0,142,143,3,30,15,0,143,29,1,0,0,0,144,145,3,32,16,0,145,31,1,0,0,0,146,151,3,34,17,0,147,148,5,14,0,0,148,152,3,32,16,0,149,150,5,15,0,0,150,152,3,32,16,0,151,147,1,0,0,0,151,149,1,0,0,0,151,152,1,0,0,0,152,33,1,0,0,0,153,162,3,52,26,0,154,162,3,56,28,0,155,162,3,58,29,0,156,162,3,42,21,0,157,162,3,38,19,0,158,162,3,40,20,0,159,162,3,36,18,0,160,162,3,44,22,0,161,153,1,0,0,0,161,154,1,0,0,0,161,155,1,0,0,0,161,156,1,0,0,0,161,157,1,0,0,0,161,158,1,0,0,0,161,159,1,0,0,0,161,160,1,0,0,0,162,35,1,0,0,0,163,167,3,50,25,0,164,167,3,48,24,0,165,167,5,24,0,0,166,163,1,0,0,0,166,164,1,0,0,0,166,165,1,0,0,0,167,37,1,0,0,0,168,169,5,16,0,0,169,170,3,18,9,0,170,171,5,17,0,0,171,39,1,0,0,0,172,173,5,42,0,0,173,174,3,52,26,0,174,175,3,18,9,0,175,176,5,17,0,0,176,41,1,0,0,0,177,181,5,18,0,0,178,180,3,28,14,0,179,178,1,0,0,0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183,181,1,0,0,0,184,185,5,19,0,0,185,43,1,0,0,0,186,188,5,20,0,0,187,189,3,46,23,0,188,187,1,0,0,0,188,189,1,0,0,0,189,190,1,0,0,0,190,191,5,21,0,0,191,45,1,0,0,0,192,197,3,2,1,0,193,195,5,1,0,0,194,196,3,46,23,0,195,194,1,0,0,0,195,196,1,0,0,0,196,198,1,0,0,0,197,193,1,0,0,0,197,198,1,0,0,0,198,204,1,0,0,0,199,201,3,6,3,0,200,202,3,46,23,0,201,200,1,0,0,0,201,202,1,0,0,0,202,204,1,0,0,0,203,192,1,0,0,0,203,199,1,0,0,0,204,47,1,0,0,0,205,206,7,0,0,0,206,49,1,0,0,0,207,211,5,25,0,0,208,212,5,30,0,0,209,210,5,22,0,0,210,212,3,52,26,0,211,208,1,0,0,0,211,209,1,0,0,0,211,212,1,0,0,0,212,51,1,0,0,0,213,216,5,26,0,0,214,216,3,54,27,0,215,213,1,0,0,0,215,214,1,0,0,0,216,53,1,0,0,0,217,218,7,1,0,0,218,55,1,0,0,0,219,220,7,2,0,0,220,57,1,0,0,0,221,222,5,44,0,0,222,59,1,0,0,0,22,64,66,73,77,81,99,107,111,119,133,140,151,161,166,181,188,195,197,201,203,211,215]),ve=Ie.decisionToState.map(((t,e)=>new Ce.dfa.DFA(t,e))),ye=new Ce.PredictionContextCache;class Oe extends Ce.Parser{static grammarFileName="n3_nodrop.g4";static literalNames=[null,"'.'","'@prefix'","'@base'","';'","','","'a'","'has'","'is'","'of'","'='","'<='","'=>'","'<-'","'!'","'^'","'['","']'","'('","')'","'{'","'}'","'^^'"];static symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"COMMENT","BooleanLiteral","String","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","IPLSTART","ANON","QuickVarName","PN_CHARS_U","PN_CHARS_BASE","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];static ruleNames=["n3Doc","n3Statement","n3Directive","sparqlDirective","sparqlBase","sparqlPrefix","prefixID","base","triples","predicateObjectList","objectList","verb","subject","predicate","object","expression","path","pathItem","literal","blankNodePropertyList","iriPropertyList","collection","formula","formulaContent","numericLiteral","rdfLiteral","iri","prefixedName","blankNode","quickVar"];constructor(t){super(t),this._interp=new Ce.atn.ParserATNSimulator(this,Ie,ve,ye),this.ruleNames=Oe.ruleNames,this.literalNames=Oe.literalNames,this.symbolicNames=Oe.symbolicNames}get atn(){return Ie}n3Doc(){let t=new Pe(this,this._ctx,this.state);this.enterRule(t,0,Oe.RULE_n3Doc);var e=0;try{for(this.enterOuterAlt(t,1),this.state=66,this._errHandler.sync(this),e=this._input.LA(1);0==(-32&e)&&0!=(1<`@prefix ${t} ${this.ns[t]} .`)).join("\n");this.base&&(e&&(e+="\n"),e+=`@base ${this.base} .`),""!=e&&(/^\s*#/.test(this.str)||(e+="\n\n"),this.str=e+this.str)}visitN3Statement(t){this.logVisit("N3Statement"),this.doVisitChildren(t)}visitN3Directive(t){this.logVisit("N3Directive"),this.doVisitChildren(t)}visitSparqlDirective(t){this.logVisit("SparqlDirective"),this.doVisitChildren(t)}visitSparqlBase(t){this.logVisit("SparqlBase"),this.doVisitBase(t)}visitSparqlPrefix(t){this.logVisit("SparqlPrefix"),this.doVisitPrefix(t)}visitPrefixID(t){this.logVisit("PrefixID"),this.doVisitPrefix(t)}visitBase(t){this.logVisit("Base"),this.doVisitBase(t)}doVisitBase(t){this.config.formatNamespaces?this.base=t.children[1].toString():this.doVisitChildren(t," ")}doVisitPrefix(t){if(this.config.formatNamespaces){let e=t.children[1].toString(),s=t.children[2].toString();this.ns[e]&&console.warn(`WARNING overwriting prefix '${e}'`),this.ns[e]=s}else this.doVisitChildren(t," ")}visitTriples(t){this.logVisit("Triples"),this.doVisitChildren(t," ")}visitPredicateObjectList(t){this.logVisit("PredicateObjectList");let e=!1;t.children.forEach((s=>{if(void 0!==s.symbol){if(!e){let s=this.ruleName(t.parentCtx);"blankNodePropertyList"!=s&&"iriPropertyList"!=s&&(e=!0,this.incrIndent())}this.print(s),this.appendNewline()}else this.callAccept(s),this.separate(" ")})),e&&this.decrIndent()}visitObjectList(t){this.logVisit("ObjectList"),this.doVisitChildren(t," ")}visitVerb(t){return this.logVisit("Verb"),this.doVisitChildren(t)}visitSubject(t){return this.logVisit("Subject"),this.doVisitChildren(t)}visitPredicate(t){return this.logVisit("Predicate"),this.doVisitChildren(t)}visitObject(t){return this.logVisit("Object"),this.doVisitChildren(t)}visitExpression(t){return this.logVisit("Expression"),this.doVisitChildren(t)}visitPath(t){return this.logVisit("Path"),this.doVisitChildren(t)}visitPathItem(t){return this.logVisit("PathItem"),this.doVisitChildren(t)}visitLiteral(t){return this.logVisit("Literal"),this.doVisitChildren(t)}visitBlankNodePropertyList(t){this.logVisit("BlankNodePropertyList"),this.print(t.getChild(0)),this.incrIndent(),this.appendNewline();for(let e=1;e1&&this.appendNewline(),this.callAccept(t.getChild(e));this.decrIndent(),this.appendNewline(),this.print(t.getChild(t.getChildCount()-1))}else this.doVisitChildren(t," ")}visitFormula(t){this.logVisit("Formula"),2!=t.getChildCount()?(this.config.graphOnNewline&&this.appendNewline(),this.print(t.getChild(0)),this.incrIndent(),this.appendNewline(),this.callAccept(t.getChild(1)),this.decrIndent(),this.appendNewline(),this.print(t.getChild(2)),this.config.graphOnNewline&&this.appendNewline()):this.doVisitChildren(t)}visitFormulaContent(t){this.logVisit("FormulaContent"),this.doVisitGraphContents(t)}visitNumericLiteral(t){return this.logVisit("NumericLiteral"),this.doVisitChildren(t)}visitRdfLiteral(t){return this.logVisit("RdfLiteral"),this.doVisitChildren(t)}visitIri(t){return this.logVisit("Iri"),this.doVisitChildren(t)}visitIriList(t){return this.logVisit("IriList"),this.doVisitChildren(t)}visitPrefixedName(t){return this.logVisit("PrefixedName"),this.doVisitChildren(t)}visitBlankNode(t){return this.logVisit("BlankNode"),this.doVisitChildren(t)}visitQuickVar(t){return this.logVisit("QuickVar"),this.doVisitChildren(t)}visitExistential(t){return this.logVisit("Existential"),this.doVisitChildren(t)}visitUniversal(t){return this.logVisit("Universal"),this.doVisitChildren(t)}incrIndent(t){this.indent+=this.config.tab+(t||0)}decrIndent(t){this.indent-=this.config.tab+(t||0)}doVisitGraphContents(t){let e=t.getChildCount();for(let s=0;s"==i.toString())continue;this.separate(" "),this.print(i),s0&&this.separate(e),void 0!==i.symbol?this.print(i):this.callAccept(i)}}logVisit(t){}logChildren(t){let e=t.children.map((t=>t.symbol?this.symbolName(t):this.ruleName(t)));console.log("<-",e.join(" "))}hasSomeDescendant(t,e){return this.ruleName(t)==e||!!t.children&&t.children.some((t=>this.hasSomeDescendant(t,e)))}getName(t){return this.ruleName(t)||this.symbolName(t)}symbolName(t){let e=t.symbol.type,s=this.n3Parser.symbolicNames[e];return s||(s=this.n3Parser.literalNames[e]),s}ruleName(t){let e=t.ruleIndex;return this.n3Parser.ruleNames[e]}appendNewline(){this.beforeNewNewline(),this.str+="\n"+new Array(this.indent).join(" ")}beforeNewNewline(){let t=[...this.str.matchAll(/^([\s\S]*)\n\s*$/g)];t.length>0&&(this.str=t[0][1])}separate(t){" "==t&&/.*\s+$/g.test(this.str)||(this.str+=t)}print(t){if("string"==typeof t)this.str+=t;else{let e=this.leftComment(t);e.startsWith("\n")&&this.beforeNewNewline(),this.str+=e,this.str+=t,this.str+=this.rightComment(t)}}leftComment(t){let e=this.nextHiddenTokens(t,hs.DIR_LEFT);if(e&&e.some((t=>t.channel==hs.CHANNEL_COMMENT))){let t=e.map((t=>t.text)).join("");return t=t.replace(/[ \t]*$/,""),t}return""}rightComment(t){let e=this.nextHiddenTokens(t,hs.DIR_RIGHT);if(e&&e.some((t=>t.channel==hs.CHANNEL_COMMENT))){this.separate(" ");let t=e.map((t=>t.text)).join("");if(t=t.trimEnd(),t)return t+"\n"}return""}nextHiddenTokens(t,e,s){let i;i=t.symbol?t.symbol:e==hs.DIR_LEFT?t.start:t.end;let n=i.tokenIndex,r=(e==hs.DIR_LEFT?this.tokens.getHiddenTokensToLeft:this.tokens.getHiddenTokensToRight).call(this.tokens,n,s);return null!=r&&(r=r.filter((t=>!t.consumed)),r.forEach((t=>t.consumed=!0)),r)}}function cs(t,s){var i=new e(t),n=new Ae(i);n.removeErrorListeners(),n.addErrorListener(s);var r=new _(n),o=new Oe(r);o.removeErrorListeners(),o.removeParseListeners(),s.syntaxError&&o.addErrorListener(s),s.unknownPrefix&&o.addParseListener(new as(s));var a=o.n3Doc();s.newAstLine&&new ls(s).visit(a)}function us(t,s){var i=new e(t),n=new Ae(i),r=new _(n),o=new Oe(r);let a=o.n3Doc();return new hs(s,r,o).visitN3Doc(a)}})(),n3=i})(); \ No newline at end of file diff --git a/editor/dist/n3_nodropMain.js.LICENSE.txt b/editor/dist/n3_nodropMain.js.LICENSE.txt new file mode 100644 index 0000000..90fe869 --- /dev/null +++ b/editor/dist/n3_nodropMain.js.LICENSE.txt @@ -0,0 +1,3 @@ +/*! https://mths.be/codepointat v0.2.0 by @mathias */ + +/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */ diff --git a/editor/dist/turtlestarMain.js b/editor/dist/turtlestarMain.js index a12a5b5..fc94e70 100644 --- a/editor/dist/turtlestarMain.js +++ b/editor/dist/turtlestarMain.js @@ -1,15938 +1,2 @@ -var turtlestar = -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 34); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -function arrayToString(a) { - return "[" + a.join(", ") + "]"; -} - -String.prototype.seed = String.prototype.seed || Math.round(Math.random() * Math.pow(2, 32)); - -String.prototype.hashCode = function () { - var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i, - key = this.toString(); - - remainder = key.length & 3; // key.length % 4 - bytes = key.length - remainder; - h1 = String.prototype.seed; - c1 = 0xcc9e2d51; - c2 = 0x1b873593; - i = 0; - - while (i < bytes) { - k1 = - ((key.charCodeAt(i) & 0xff)) | - ((key.charCodeAt(++i) & 0xff) << 8) | - ((key.charCodeAt(++i) & 0xff) << 16) | - ((key.charCodeAt(++i) & 0xff) << 24); - ++i; - - k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; - k1 = (k1 << 15) | (k1 >>> 17); - k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; - - h1 ^= k1; - h1 = (h1 << 13) | (h1 >>> 19); - h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; - h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); - } - - k1 = 0; - - switch (remainder) { - case 3: - k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; - case 2: - k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; - case 1: - k1 ^= (key.charCodeAt(i) & 0xff); - - k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; - k1 = (k1 << 15) | (k1 >>> 17); - k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; - h1 ^= k1; - } - - h1 ^= key.length; - - h1 ^= h1 >>> 16; - h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; - h1 ^= h1 >>> 13; - h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; - h1 ^= h1 >>> 16; - - return h1 >>> 0; -}; - -function standardEqualsFunction(a, b) { - return a.equals(b); -} - -function standardHashCodeFunction(a) { - return a.hashCode(); -} - -function Set(hashFunction, equalsFunction) { - this.data = {}; - this.hashFunction = hashFunction || standardHashCodeFunction; - this.equalsFunction = equalsFunction || standardEqualsFunction; - return this; -} - -Object.defineProperty(Set.prototype, "length", { - get: function () { - var l = 0; - for (var key in this.data) { - if (key.indexOf("hash_") === 0) { - l = l + this.data[key].length; - } - } - return l; - } -}); - -Set.prototype.add = function (value) { - var hash = this.hashFunction(value); - var key = "hash_" + hash; - if (key in this.data) { - var values = this.data[key]; - for (var i = 0; i < values.length; i++) { - if (this.equalsFunction(value, values[i])) { - return values[i]; - } - } - values.push(value); - return value; - } else { - this.data[key] = [value]; - return value; - } -}; - -Set.prototype.contains = function (value) { - return this.get(value) != null; -}; - -Set.prototype.get = function (value) { - var hash = this.hashFunction(value); - var key = "hash_" + hash; - if (key in this.data) { - var values = this.data[key]; - for (var i = 0; i < values.length; i++) { - if (this.equalsFunction(value, values[i])) { - return values[i]; - } - } - } - return null; -}; - -Set.prototype.values = function () { - var l = []; - for (var key in this.data) { - if (key.indexOf("hash_") === 0) { - l = l.concat(this.data[key]); - } - } - return l; -}; - -Set.prototype.toString = function () { - return arrayToString(this.values()); -}; - -function BitSet() { - this.data = []; - return this; -} - -BitSet.prototype.add = function (value) { - this.data[value] = true; -}; - -BitSet.prototype.or = function (set) { - var bits = this; - Object.keys(set.data).map(function (alt) { - bits.add(alt); - }); -}; - -BitSet.prototype.remove = function (value) { - delete this.data[value]; -}; - -BitSet.prototype.contains = function (value) { - return this.data[value] === true; -}; - -BitSet.prototype.values = function () { - return Object.keys(this.data); -}; - -BitSet.prototype.minValue = function () { - return Math.min.apply(null, this.values()); -}; - -BitSet.prototype.hashCode = function () { - var hash = new Hash(); - hash.update(this.values()); - return hash.finish(); -}; - -BitSet.prototype.equals = function (other) { - if (!(other instanceof BitSet)) { - return false; - } - return this.hashCode() === other.hashCode(); -}; - -Object.defineProperty(BitSet.prototype, "length", { - get: function () { - return this.values().length; - } -}); - -BitSet.prototype.toString = function () { - return "{" + this.values().join(", ") + "}"; -}; - -function Map(hashFunction, equalsFunction) { - this.data = {}; - this.hashFunction = hashFunction || standardHashCodeFunction; - this.equalsFunction = equalsFunction || standardEqualsFunction; - return this; -} - -Object.defineProperty(Map.prototype, "length", { - get: function () { - var l = 0; - for (var hashKey in this.data) { - if (hashKey.indexOf("hash_") === 0) { - l = l + this.data[hashKey].length; - } - } - return l; - } -}); - -Map.prototype.put = function (key, value) { - var hashKey = "hash_" + this.hashFunction(key); - if (hashKey in this.data) { - var entries = this.data[hashKey]; - for (var i = 0; i < entries.length; i++) { - var entry = entries[i]; - if (this.equalsFunction(key, entry.key)) { - var oldValue = entry.value; - entry.value = value; - return oldValue; - } - } - entries.push({key:key, value:value}); - return value; - } else { - this.data[hashKey] = [{key:key, value:value}]; - return value; - } -}; - -Map.prototype.containsKey = function (key) { - var hashKey = "hash_" + this.hashFunction(key); - if(hashKey in this.data) { - var entries = this.data[hashKey]; - for (var i = 0; i < entries.length; i++) { - var entry = entries[i]; - if (this.equalsFunction(key, entry.key)) - return true; - } - } - return false; -}; - -Map.prototype.get = function (key) { - var hashKey = "hash_" + this.hashFunction(key); - if(hashKey in this.data) { - var entries = this.data[hashKey]; - for (var i = 0; i < entries.length; i++) { - var entry = entries[i]; - if (this.equalsFunction(key, entry.key)) - return entry.value; - } - } - return null; -}; - -Map.prototype.entries = function () { - var l = []; - for (var key in this.data) { - if (key.indexOf("hash_") === 0) { - l = l.concat(this.data[key]); - } - } - return l; -}; - - -Map.prototype.getKeys = function () { - return this.entries().map(function(e) { - return e.key; - }); -}; - - -Map.prototype.getValues = function () { - return this.entries().map(function(e) { - return e.value; - }); -}; - - -Map.prototype.toString = function () { - var ss = this.entries().map(function(entry) { - return '{' + entry.key + ':' + entry.value + '}'; - }); - return '[' + ss.join(", ") + ']'; -}; - - -function AltDict() { - this.data = {}; - return this; -} - - -AltDict.prototype.get = function (key) { - key = "k-" + key; - if (key in this.data) { - return this.data[key]; - } else { - return null; - } -}; - -AltDict.prototype.put = function (key, value) { - key = "k-" + key; - this.data[key] = value; -}; - -AltDict.prototype.values = function () { - var data = this.data; - var keys = Object.keys(this.data); - return keys.map(function (key) { - return data[key]; - }); -}; - -function DoubleDict(defaultMapCtor) { - this.defaultMapCtor = defaultMapCtor || Map; - this.cacheMap = new this.defaultMapCtor(); - return this; -} - -function Hash() { - this.count = 0; - this.hash = 0; - return this; -} - -Hash.prototype.update = function () { - for(var i=0;i>> (32 - 15)); - k = k * 0x1B873593; - this.count = this.count + 1; - var hash = this.hash ^ k; - hash = (hash << 13) | (hash >>> (32 - 13)); - hash = hash * 5 + 0xE6546B64; - this.hash = hash; - } - } -}; - -Hash.prototype.finish = function () { - var hash = this.hash ^ (this.count * 4); - hash = hash ^ (hash >>> 16); - hash = hash * 0x85EBCA6B; - hash = hash ^ (hash >>> 13); - hash = hash * 0xC2B2AE35; - hash = hash ^ (hash >>> 16); - return hash; -}; - -function hashStuff() { - var hash = new Hash(); - hash.update.apply(hash, arguments); - return hash.finish(); -} - -DoubleDict.prototype.get = function (a, b) { - var d = this.cacheMap.get(a) || null; - return d === null ? null : (d.get(b) || null); -}; - -DoubleDict.prototype.set = function (a, b, o) { - var d = this.cacheMap.get(a) || null; - if (d === null) { - d = new this.defaultMapCtor(); - this.cacheMap.put(a, d); - } - d.put(b, o); -}; - - -function escapeWhitespace(s, escapeSpaces) { - s = s.replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r"); - if (escapeSpaces) { - s = s.replace(/ /g, "\u00B7"); - } - return s; -} - -function titleCase(str) { - return str.replace(/\w\S*/g, function (txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1); - }); -}; - -function equalArrays(a, b) -{ - if (!Array.isArray(a) || !Array.isArray(b)) - return false; - if (a == b) - return true; - if (a.length != b.length) - return false; - for (var i = 0; i < a.length; i++) { - if (a[i] == b[i]) - continue; - if (!a[i].equals(b[i])) - return false; - } - return true; -}; - -exports.Hash = Hash; -exports.Set = Set; -exports.Map = Map; -exports.BitSet = BitSet; -exports.AltDict = AltDict; -exports.DoubleDict = DoubleDict; -exports.hashStuff = hashStuff; -exports.escapeWhitespace = escapeWhitespace; -exports.arrayToString = arrayToString; -exports.titleCase = titleCase; -exports.equalArrays = equalArrays; - - -/***/ }), -/* 1 */ -/***/ (function(module, exports) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// A token has properties: text, type, line, character position in the line -// (so we can ignore tabs), token channel, index, and source from which -// we obtained this token. - -function Token() { - this.source = null; - this.type = null; // token type of the token - this.channel = null; // The parser ignores everything not on DEFAULT_CHANNEL - this.start = null; // optional; return -1 if not implemented. - this.stop = null; // optional; return -1 if not implemented. - this.tokenIndex = null; // from 0..n-1 of the token object in the input stream - this.line = null; // line=1..n of the 1st character - this.column = null; // beginning of the line at which it occurs, 0..n-1 - this._text = null; // text of the token. - return this; -} - -Token.INVALID_TYPE = 0; - -// During lookahead operations, this "token" signifies we hit rule end ATN state -// and did not follow it despite needing to. -Token.EPSILON = -2; - -Token.MIN_USER_TOKEN_TYPE = 1; - -Token.EOF = -1; - -// All tokens go to the parser (unless skip() is called in that rule) -// on a particular "channel". The parser tunes to a particular channel -// so that whitespace etc... can go to the parser on a "hidden" channel. - -Token.DEFAULT_CHANNEL = 0; - -// Anything on different channel than DEFAULT_CHANNEL is not parsed -// by parser. - -Token.HIDDEN_CHANNEL = 1; - -// Explicitly set the text for this token. If {code text} is not -// {@code null}, then {@link //getText} will return this value rather than -// extracting the text from the input. -// -// @param text The explicit text of the token, or {@code null} if the text -// should be obtained from the input along with the start and stop indexes -// of the token. - -Object.defineProperty(Token.prototype, "text", { - get : function() { - return this._text; - }, - set : function(text) { - this._text = text; - } -}); - -Token.prototype.getTokenSource = function() { - return this.source[0]; -}; - -Token.prototype.getInputStream = function() { - return this.source[1]; -}; - -function CommonToken(source, type, channel, start, stop) { - Token.call(this); - this.source = source !== undefined ? source : CommonToken.EMPTY_SOURCE; - this.type = type !== undefined ? type : null; - this.channel = channel !== undefined ? channel : Token.DEFAULT_CHANNEL; - this.start = start !== undefined ? start : -1; - this.stop = stop !== undefined ? stop : -1; - this.tokenIndex = -1; - if (this.source[0] !== null) { - this.line = source[0].line; - this.column = source[0].column; - } else { - this.column = -1; - } - return this; -} - -CommonToken.prototype = Object.create(Token.prototype); -CommonToken.prototype.constructor = CommonToken; - -// An empty {@link Pair} which is used as the default value of -// {@link //source} for tokens that do not have a source. -CommonToken.EMPTY_SOURCE = [ null, null ]; - -// Constructs a new {@link CommonToken} as a copy of another {@link Token}. -// -//

          -// If {@code oldToken} is also a {@link CommonToken} instance, the newly -// constructed token will share a reference to the {@link //text} field and -// the {@link Pair} stored in {@link //source}. Otherwise, {@link //text} will -// be assigned the result of calling {@link //getText}, and {@link //source} -// will be constructed from the result of {@link Token//getTokenSource} and -// {@link Token//getInputStream}.

          -// -// @param oldToken The token to copy. -// -CommonToken.prototype.clone = function() { - var t = new CommonToken(this.source, this.type, this.channel, this.start, - this.stop); - t.tokenIndex = this.tokenIndex; - t.line = this.line; - t.column = this.column; - t.text = this.text; - return t; -}; - -Object.defineProperty(CommonToken.prototype, "text", { - get : function() { - if (this._text !== null) { - return this._text; - } - var input = this.getInputStream(); - if (input === null) { - return null; - } - var n = input.size; - if (this.start < n && this.stop < n) { - return input.getText(this.start, this.stop); - } else { - return ""; - } - }, - set : function(text) { - this._text = text; - } -}); - -CommonToken.prototype.toString = function() { - var txt = this.text; - if (txt !== null) { - txt = txt.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t"); - } else { - txt = ""; - } - return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + - txt + "',<" + this.type + ">" + - (this.channel > 0 ? ",channel=" + this.channel : "") + "," + - this.line + ":" + this.column + "]"; -}; - -exports.Token = Token; -exports.CommonToken = CommonToken; - - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -/*jslint smarttabs:true */ - -var Token = __webpack_require__(1).Token; - -/* stop is not included! */ -function Interval(start, stop) { - this.start = start; - this.stop = stop; - return this; -} - -Interval.prototype.contains = function(item) { - return item >= this.start && item < this.stop; -}; - -Interval.prototype.toString = function() { - if(this.start===this.stop-1) { - return this.start.toString(); - } else { - return this.start.toString() + ".." + (this.stop-1).toString(); - } -}; - - -Object.defineProperty(Interval.prototype, "length", { - get : function() { - return this.stop - this.start; - } -}); - -function IntervalSet() { - this.intervals = null; - this.readOnly = false; -} - -IntervalSet.prototype.first = function(v) { - if (this.intervals === null || this.intervals.length===0) { - return Token.INVALID_TYPE; - } else { - return this.intervals[0].start; - } -}; - -IntervalSet.prototype.addOne = function(v) { - this.addInterval(new Interval(v, v + 1)); -}; - -IntervalSet.prototype.addRange = function(l, h) { - this.addInterval(new Interval(l, h + 1)); -}; - -IntervalSet.prototype.addInterval = function(v) { - if (this.intervals === null) { - this.intervals = []; - this.intervals.push(v); - } else { - // find insert pos - for (var k = 0; k < this.intervals.length; k++) { - var i = this.intervals[k]; - // distinct range -> insert - if (v.stop < i.start) { - this.intervals.splice(k, 0, v); - return; - } - // contiguous range -> adjust - else if (v.stop === i.start) { - this.intervals[k].start = v.start; - return; - } - // overlapping range -> adjust and reduce - else if (v.start <= i.stop) { - this.intervals[k] = new Interval(Math.min(i.start, v.start), Math.max(i.stop, v.stop)); - this.reduce(k); - return; - } - } - // greater than any existing - this.intervals.push(v); - } -}; - -IntervalSet.prototype.addSet = function(other) { - if (other.intervals !== null) { - for (var k = 0; k < other.intervals.length; k++) { - var i = other.intervals[k]; - this.addInterval(new Interval(i.start, i.stop)); - } - } - return this; -}; - -IntervalSet.prototype.reduce = function(k) { - // only need to reduce if k is not the last - if (k < this.intervalslength - 1) { - var l = this.intervals[k]; - var r = this.intervals[k + 1]; - // if r contained in l - if (l.stop >= r.stop) { - this.intervals.pop(k + 1); - this.reduce(k); - } else if (l.stop >= r.start) { - this.intervals[k] = new Interval(l.start, r.stop); - this.intervals.pop(k + 1); - } - } -}; - -IntervalSet.prototype.complement = function(start, stop) { - var result = new IntervalSet(); - result.addInterval(new Interval(start,stop+1)); - for(var i=0; ii.start && v.stop=i.stop) { - this.intervals.splice(k, 1); - k = k - 1; // need another pass - } - // check for lower boundary - else if(v.start"); - } else { - names.push("'" + String.fromCharCode(v.start) + "'"); - } - } else { - names.push("'" + String.fromCharCode(v.start) + "'..'" + String.fromCharCode(v.stop-1) + "'"); - } - } - if (names.length > 1) { - return "{" + names.join(", ") + "}"; - } else { - return names[0]; - } -}; - - -IntervalSet.prototype.toIndexString = function() { - var names = []; - for (var i = 0; i < this.intervals.length; i++) { - var v = this.intervals[i]; - if(v.stop===v.start+1) { - if ( v.start===Token.EOF ) { - names.push(""); - } else { - names.push(v.start.toString()); - } - } else { - names.push(v.start.toString() + ".." + (v.stop-1).toString()); - } - } - if (names.length > 1) { - return "{" + names.join(", ") + "}"; - } else { - return names[0]; - } -}; - - -IntervalSet.prototype.toTokenString = function(literalNames, symbolicNames) { - var names = []; - for (var i = 0; i < this.intervals.length; i++) { - var v = this.intervals[i]; - for (var j = v.start; j < v.stop; j++) { - names.push(this.elementName(literalNames, symbolicNames, j)); - } - } - if (names.length > 1) { - return "{" + names.join(", ") + "}"; - } else { - return names[0]; - } -}; - -IntervalSet.prototype.elementName = function(literalNames, symbolicNames, a) { - if (a === Token.EOF) { - return ""; - } else if (a === Token.EPSILON) { - return ""; - } else { - return literalNames[a] || symbolicNames[a]; - } -}; - -exports.Interval = Interval; -exports.IntervalSet = IntervalSet; - - -/***/ }), -/* 3 */ -/***/ (function(module, exports) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// The following images show the relation of states and -// {@link ATNState//transitions} for various grammar constructs. -// -//
            -// -//
          • Solid edges marked with an &//0949; indicate a required -// {@link EpsilonTransition}.
          • -// -//
          • Dashed edges indicate locations where any transition derived from -// {@link Transition} might appear.
          • -// -//
          • Dashed nodes are place holders for either a sequence of linked -// {@link BasicState} states or the inclusion of a block representing a nested -// construct in one of the forms below.
          • -// -//
          • Nodes showing multiple outgoing alternatives with a {@code ...} support -// any number of alternatives (one or more). Nodes without the {@code ...} only -// support the exact number of alternatives shown in the diagram.
          • -// -//
          -// -//

          Basic Blocks

          -// -//

          Rule

          -// -// -// -//

          Block of 1 or more alternatives

          -// -// -// -//

          Greedy Loops

          -// -//

          Greedy Closure: {@code (...)*}

          -// -// -// -//

          Greedy Positive Closure: {@code (...)+}

          -// -// -// -//

          Greedy Optional: {@code (...)?}

          -// -// -// -//

          Non-Greedy Loops

          -// -//

          Non-Greedy Closure: {@code (...)*?}

          -// -// -// -//

          Non-Greedy Positive Closure: {@code (...)+?}

          -// -// -// -//

          Non-Greedy Optional: {@code (...)??}

          -// -// -// - -var INITIAL_NUM_TRANSITIONS = 4; - -function ATNState() { - // Which ATN are we in? - this.atn = null; - this.stateNumber = ATNState.INVALID_STATE_NUMBER; - this.stateType = null; - this.ruleIndex = 0; // at runtime, we don't have Rule objects - this.epsilonOnlyTransitions = false; - // Track the transitions emanating from this ATN state. - this.transitions = []; - // Used to cache lookahead during parsing, not used during construction - this.nextTokenWithinRule = null; - return this; -} - -// constants for serialization -ATNState.INVALID_TYPE = 0; -ATNState.BASIC = 1; -ATNState.RULE_START = 2; -ATNState.BLOCK_START = 3; -ATNState.PLUS_BLOCK_START = 4; -ATNState.STAR_BLOCK_START = 5; -ATNState.TOKEN_START = 6; -ATNState.RULE_STOP = 7; -ATNState.BLOCK_END = 8; -ATNState.STAR_LOOP_BACK = 9; -ATNState.STAR_LOOP_ENTRY = 10; -ATNState.PLUS_LOOP_BACK = 11; -ATNState.LOOP_END = 12; - -ATNState.serializationNames = [ - "INVALID", - "BASIC", - "RULE_START", - "BLOCK_START", - "PLUS_BLOCK_START", - "STAR_BLOCK_START", - "TOKEN_START", - "RULE_STOP", - "BLOCK_END", - "STAR_LOOP_BACK", - "STAR_LOOP_ENTRY", - "PLUS_LOOP_BACK", - "LOOP_END" ]; - -ATNState.INVALID_STATE_NUMBER = -1; - -ATNState.prototype.toString = function() { - return this.stateNumber; -}; - -ATNState.prototype.equals = function(other) { - if (other instanceof ATNState) { - return this.stateNumber===other.stateNumber; - } else { - return false; - } -}; - -ATNState.prototype.isNonGreedyExitState = function() { - return false; -}; - - -ATNState.prototype.addTransition = function(trans, index) { - if(index===undefined) { - index = -1; - } - if (this.transitions.length===0) { - this.epsilonOnlyTransitions = trans.isEpsilon; - } else if(this.epsilonOnlyTransitions !== trans.isEpsilon) { - this.epsilonOnlyTransitions = false; - } - if (index===-1) { - this.transitions.push(trans); - } else { - this.transitions.splice(index, 1, trans); - } -}; - -function BasicState() { - ATNState.call(this); - this.stateType = ATNState.BASIC; - return this; -} - -BasicState.prototype = Object.create(ATNState.prototype); -BasicState.prototype.constructor = BasicState; - - -function DecisionState() { - ATNState.call(this); - this.decision = -1; - this.nonGreedy = false; - return this; -} - -DecisionState.prototype = Object.create(ATNState.prototype); -DecisionState.prototype.constructor = DecisionState; - - -// The start of a regular {@code (...)} block. -function BlockStartState() { - DecisionState.call(this); - this.endState = null; - return this; -} - -BlockStartState.prototype = Object.create(DecisionState.prototype); -BlockStartState.prototype.constructor = BlockStartState; - - -function BasicBlockStartState() { - BlockStartState.call(this); - this.stateType = ATNState.BLOCK_START; - return this; -} - -BasicBlockStartState.prototype = Object.create(BlockStartState.prototype); -BasicBlockStartState.prototype.constructor = BasicBlockStartState; - - -// Terminal node of a simple {@code (a|b|c)} block. -function BlockEndState() { - ATNState.call(this); - this.stateType = ATNState.BLOCK_END; - this.startState = null; - return this; -} - -BlockEndState.prototype = Object.create(ATNState.prototype); -BlockEndState.prototype.constructor = BlockEndState; - - -// The last node in the ATN for a rule, unless that rule is the start symbol. -// In that case, there is one transition to EOF. Later, we might encode -// references to all calls to this rule to compute FOLLOW sets for -// error handling. -// -function RuleStopState() { - ATNState.call(this); - this.stateType = ATNState.RULE_STOP; - return this; -} - -RuleStopState.prototype = Object.create(ATNState.prototype); -RuleStopState.prototype.constructor = RuleStopState; - -function RuleStartState() { - ATNState.call(this); - this.stateType = ATNState.RULE_START; - this.stopState = null; - this.isPrecedenceRule = false; - return this; -} - -RuleStartState.prototype = Object.create(ATNState.prototype); -RuleStartState.prototype.constructor = RuleStartState; - -// Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: -// one to the loop back to start of the block and one to exit. -// -function PlusLoopbackState() { - DecisionState.call(this); - this.stateType = ATNState.PLUS_LOOP_BACK; - return this; -} - -PlusLoopbackState.prototype = Object.create(DecisionState.prototype); -PlusLoopbackState.prototype.constructor = PlusLoopbackState; - - -// Start of {@code (A|B|...)+} loop. Technically a decision state, but -// we don't use for code generation; somebody might need it, so I'm defining -// it for completeness. In reality, the {@link PlusLoopbackState} node is the -// real decision-making note for {@code A+}. -// -function PlusBlockStartState() { - BlockStartState.call(this); - this.stateType = ATNState.PLUS_BLOCK_START; - this.loopBackState = null; - return this; -} - -PlusBlockStartState.prototype = Object.create(BlockStartState.prototype); -PlusBlockStartState.prototype.constructor = PlusBlockStartState; - -// The block that begins a closure loop. -function StarBlockStartState() { - BlockStartState.call(this); - this.stateType = ATNState.STAR_BLOCK_START; - return this; -} - -StarBlockStartState.prototype = Object.create(BlockStartState.prototype); -StarBlockStartState.prototype.constructor = StarBlockStartState; - - -function StarLoopbackState() { - ATNState.call(this); - this.stateType = ATNState.STAR_LOOP_BACK; - return this; -} - -StarLoopbackState.prototype = Object.create(ATNState.prototype); -StarLoopbackState.prototype.constructor = StarLoopbackState; - - -function StarLoopEntryState() { - DecisionState.call(this); - this.stateType = ATNState.STAR_LOOP_ENTRY; - this.loopBackState = null; - // Indicates whether this state can benefit from a precedence DFA during SLL decision making. - this.isPrecedenceDecision = null; - return this; -} - -StarLoopEntryState.prototype = Object.create(DecisionState.prototype); -StarLoopEntryState.prototype.constructor = StarLoopEntryState; - - -// Mark the end of a * or + loop. -function LoopEndState() { - ATNState.call(this); - this.stateType = ATNState.LOOP_END; - this.loopBackState = null; - return this; -} - -LoopEndState.prototype = Object.create(ATNState.prototype); -LoopEndState.prototype.constructor = LoopEndState; - - -// The Tokens rule start state linking to each lexer rule start state */ -function TokensStartState() { - DecisionState.call(this); - this.stateType = ATNState.TOKEN_START; - return this; -} - -TokensStartState.prototype = Object.create(DecisionState.prototype); -TokensStartState.prototype.constructor = TokensStartState; - -exports.ATNState = ATNState; -exports.BasicState = BasicState; -exports.DecisionState = DecisionState; -exports.BlockStartState = BlockStartState; -exports.BlockEndState = BlockEndState; -exports.LoopEndState = LoopEndState; -exports.RuleStartState = RuleStartState; -exports.RuleStopState = RuleStopState; -exports.TokensStartState = TokensStartState; -exports.PlusLoopbackState = PlusLoopbackState; -exports.StarLoopbackState = StarLoopbackState; -exports.StarLoopEntryState = StarLoopEntryState; -exports.PlusBlockStartState = PlusBlockStartState; -exports.StarBlockStartState = StarBlockStartState; -exports.BasicBlockStartState = BasicBlockStartState; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -// The basic notion of a tree has a parent, a payload, and a list of children. -// It is the most abstract interface for all the trees used by ANTLR. -/// - -var Token = __webpack_require__(1).Token; -var Interval = __webpack_require__(2).Interval; -var INVALID_INTERVAL = new Interval(-1, -2); -var Utils = __webpack_require__(0); - - -function Tree() { - return this; -} - -function SyntaxTree() { - Tree.call(this); - return this; -} - -SyntaxTree.prototype = Object.create(Tree.prototype); -SyntaxTree.prototype.constructor = SyntaxTree; - -function ParseTree() { - SyntaxTree.call(this); - return this; -} - -ParseTree.prototype = Object.create(SyntaxTree.prototype); -ParseTree.prototype.constructor = ParseTree; - -function RuleNode() { - ParseTree.call(this); - return this; -} - -RuleNode.prototype = Object.create(ParseTree.prototype); -RuleNode.prototype.constructor = RuleNode; - -function TerminalNode() { - ParseTree.call(this); - return this; -} - -TerminalNode.prototype = Object.create(ParseTree.prototype); -TerminalNode.prototype.constructor = TerminalNode; - -function ErrorNode() { - TerminalNode.call(this); - return this; -} - -ErrorNode.prototype = Object.create(TerminalNode.prototype); -ErrorNode.prototype.constructor = ErrorNode; - -function ParseTreeVisitor() { - return this; -} - -ParseTreeVisitor.prototype.visit = function(ctx) { - if (Array.isArray(ctx)) { - return ctx.map(function(child) { - return child.accept(this); - }, this); - } else { - return ctx.accept(this); - } -}; - -ParseTreeVisitor.prototype.visitChildren = function(ctx) { - if (ctx.children) { - return this.visit(ctx.children); - } else { - return null; - } -} - -ParseTreeVisitor.prototype.visitTerminal = function(node) { -}; - -ParseTreeVisitor.prototype.visitErrorNode = function(node) { -}; - - -function ParseTreeListener() { - return this; -} - -ParseTreeListener.prototype.visitTerminal = function(node) { -}; - -ParseTreeListener.prototype.visitErrorNode = function(node) { -}; - -ParseTreeListener.prototype.enterEveryRule = function(node) { -}; - -ParseTreeListener.prototype.exitEveryRule = function(node) { -}; - -function TerminalNodeImpl(symbol) { - TerminalNode.call(this); - this.parentCtx = null; - this.symbol = symbol; - return this; -} - -TerminalNodeImpl.prototype = Object.create(TerminalNode.prototype); -TerminalNodeImpl.prototype.constructor = TerminalNodeImpl; - -TerminalNodeImpl.prototype.getChild = function(i) { - return null; -}; - -TerminalNodeImpl.prototype.getSymbol = function() { - return this.symbol; -}; - -TerminalNodeImpl.prototype.getParent = function() { - return this.parentCtx; -}; - -TerminalNodeImpl.prototype.getPayload = function() { - return this.symbol; -}; - -TerminalNodeImpl.prototype.getSourceInterval = function() { - if (this.symbol === null) { - return INVALID_INTERVAL; - } - var tokenIndex = this.symbol.tokenIndex; - return new Interval(tokenIndex, tokenIndex); -}; - -TerminalNodeImpl.prototype.getChildCount = function() { - return 0; -}; - -TerminalNodeImpl.prototype.accept = function(visitor) { - return visitor.visitTerminal(this); -}; - -TerminalNodeImpl.prototype.getText = function() { - return this.symbol.text; -}; - -TerminalNodeImpl.prototype.toString = function() { - if (this.symbol.type === Token.EOF) { - return ""; - } else { - return this.symbol.text; - } -}; - -// Represents a token that was consumed during resynchronization -// rather than during a valid match operation. For example, -// we will create this kind of a node during single token insertion -// and deletion as well as during "consume until error recovery set" -// upon no viable alternative exceptions. - -function ErrorNodeImpl(token) { - TerminalNodeImpl.call(this, token); - return this; -} - -ErrorNodeImpl.prototype = Object.create(TerminalNodeImpl.prototype); -ErrorNodeImpl.prototype.constructor = ErrorNodeImpl; - -ErrorNodeImpl.prototype.isErrorNode = function() { - return true; -}; - -ErrorNodeImpl.prototype.accept = function(visitor) { - return visitor.visitErrorNode(this); -}; - -function ParseTreeWalker() { - return this; -} - -ParseTreeWalker.prototype.walk = function(listener, t) { - var errorNode = t instanceof ErrorNode || - (t.isErrorNode !== undefined && t.isErrorNode()); - if (errorNode) { - listener.visitErrorNode(t); - } else if (t instanceof TerminalNode) { - listener.visitTerminal(t); - } else { - this.enterRule(listener, t); - for (var i = 0; i < t.getChildCount(); i++) { - var child = t.getChild(i); - this.walk(listener, child); - } - this.exitRule(listener, t); - } -}; -// -// The discovery of a rule node, involves sending two events: the generic -// {@link ParseTreeListener//enterEveryRule} and a -// {@link RuleContext}-specific event. First we trigger the generic and then -// the rule specific. We to them in reverse order upon finishing the node. -// -ParseTreeWalker.prototype.enterRule = function(listener, r) { - var ctx = r.getRuleContext(); - listener.enterEveryRule(ctx); - ctx.enterRule(listener); -}; - -ParseTreeWalker.prototype.exitRule = function(listener, r) { - var ctx = r.getRuleContext(); - ctx.exitRule(listener); - listener.exitEveryRule(ctx); -}; - -ParseTreeWalker.DEFAULT = new ParseTreeWalker(); - -exports.RuleNode = RuleNode; -exports.ErrorNode = ErrorNode; -exports.TerminalNode = TerminalNode; -exports.ErrorNodeImpl = ErrorNodeImpl; -exports.TerminalNodeImpl = TerminalNodeImpl; -exports.ParseTreeListener = ParseTreeListener; -exports.ParseTreeVisitor = ParseTreeVisitor; -exports.ParseTreeWalker = ParseTreeWalker; -exports.INVALID_INTERVAL = INVALID_INTERVAL; - - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -// The root of the ANTLR exception hierarchy. In general, ANTLR tracks just -// 3 kinds of errors: prediction errors, failed predicate errors, and -// mismatched input errors. In each case, the parser knows where it is -// in the input, where it is in the ATN, the rule invocation stack, -// and what kind of problem occurred. - -var PredicateTransition = __webpack_require__(8).PredicateTransition; - -function RecognitionException(params) { - Error.call(this); - if (!!Error.captureStackTrace) { - Error.captureStackTrace(this, RecognitionException); - } else { - var stack = new Error().stack; - } - this.message = params.message; - this.recognizer = params.recognizer; - this.input = params.input; - this.ctx = params.ctx; - // The current {@link Token} when an error occurred. Since not all streams - // support accessing symbols by index, we have to track the {@link Token} - // instance itself. - this.offendingToken = null; - // Get the ATN state number the parser was in at the time the error - // occurred. For {@link NoViableAltException} and - // {@link LexerNoViableAltException} exceptions, this is the - // {@link DecisionState} number. For others, it is the state whose outgoing - // edge we couldn't match. - this.offendingState = -1; - if (this.recognizer!==null) { - this.offendingState = this.recognizer.state; - } - return this; -} - -RecognitionException.prototype = Object.create(Error.prototype); -RecognitionException.prototype.constructor = RecognitionException; - -//

          If the state number is not known, this method returns -1.

          - -// -// Gets the set of input symbols which could potentially follow the -// previously matched symbol at the time this exception was thrown. -// -//

          If the set of expected tokens is not known and could not be computed, -// this method returns {@code null}.

          -// -// @return The set of token types that could potentially follow the current -// state in the ATN, or {@code null} if the information is not available. -// / -RecognitionException.prototype.getExpectedTokens = function() { - if (this.recognizer!==null) { - return this.recognizer.atn.getExpectedTokens(this.offendingState, this.ctx); - } else { - return null; - } -}; - -RecognitionException.prototype.toString = function() { - return this.message; -}; - -function LexerNoViableAltException(lexer, input, startIndex, deadEndConfigs) { - RecognitionException.call(this, {message:"", recognizer:lexer, input:input, ctx:null}); - this.startIndex = startIndex; - this.deadEndConfigs = deadEndConfigs; - return this; -} - -LexerNoViableAltException.prototype = Object.create(RecognitionException.prototype); -LexerNoViableAltException.prototype.constructor = LexerNoViableAltException; - -LexerNoViableAltException.prototype.toString = function() { - var symbol = ""; - if (this.startIndex >= 0 && this.startIndex < this.input.size) { - symbol = this.input.getText((this.startIndex,this.startIndex)); - } - return "LexerNoViableAltException" + symbol; -}; - -// Indicates that the parser could not decide which of two or more paths -// to take based upon the remaining input. It tracks the starting token -// of the offending input and also knows where the parser was -// in the various paths when the error. Reported by reportNoViableAlternative() -// -function NoViableAltException(recognizer, input, startToken, offendingToken, deadEndConfigs, ctx) { - ctx = ctx || recognizer._ctx; - offendingToken = offendingToken || recognizer.getCurrentToken(); - startToken = startToken || recognizer.getCurrentToken(); - input = input || recognizer.getInputStream(); - RecognitionException.call(this, {message:"", recognizer:recognizer, input:input, ctx:ctx}); - // Which configurations did we try at input.index() that couldn't match - // input.LT(1)?// - this.deadEndConfigs = deadEndConfigs; - // The token object at the start index; the input stream might - // not be buffering tokens so get a reference to it. (At the - // time the error occurred, of course the stream needs to keep a - // buffer all of the tokens but later we might not have access to those.) - this.startToken = startToken; - this.offendingToken = offendingToken; -} - -NoViableAltException.prototype = Object.create(RecognitionException.prototype); -NoViableAltException.prototype.constructor = NoViableAltException; - -// This signifies any kind of mismatched input exceptions such as -// when the current input does not match the expected token. -// -function InputMismatchException(recognizer) { - RecognitionException.call(this, {message:"", recognizer:recognizer, input:recognizer.getInputStream(), ctx:recognizer._ctx}); - this.offendingToken = recognizer.getCurrentToken(); -} - -InputMismatchException.prototype = Object.create(RecognitionException.prototype); -InputMismatchException.prototype.constructor = InputMismatchException; - -// A semantic predicate failed during validation. Validation of predicates -// occurs when normally parsing the alternative just like matching a token. -// Disambiguating predicate evaluation occurs when we test a predicate during -// prediction. - -function FailedPredicateException(recognizer, predicate, message) { - RecognitionException.call(this, {message:this.formatMessage(predicate,message || null), recognizer:recognizer, - input:recognizer.getInputStream(), ctx:recognizer._ctx}); - var s = recognizer._interp.atn.states[recognizer.state]; - var trans = s.transitions[0]; - if (trans instanceof PredicateTransition) { - this.ruleIndex = trans.ruleIndex; - this.predicateIndex = trans.predIndex; - } else { - this.ruleIndex = 0; - this.predicateIndex = 0; - } - this.predicate = predicate; - this.offendingToken = recognizer.getCurrentToken(); - return this; -} - -FailedPredicateException.prototype = Object.create(RecognitionException.prototype); -FailedPredicateException.prototype.constructor = FailedPredicateException; - -FailedPredicateException.prototype.formatMessage = function(predicate, message) { - if (message !==null) { - return message; - } else { - return "failed predicate: {" + predicate + "}?"; - } -}; - -function ParseCancellationException() { - Error.call(this); - Error.captureStackTrace(this, ParseCancellationException); - return this; -} - -ParseCancellationException.prototype = Object.create(Error.prototype); -ParseCancellationException.prototype.constructor = ParseCancellationException; - -exports.RecognitionException = RecognitionException; -exports.NoViableAltException = NoViableAltException; -exports.LexerNoViableAltException = LexerNoViableAltException; -exports.InputMismatchException = InputMismatchException; -exports.FailedPredicateException = FailedPredicateException; -exports.ParseCancellationException = ParseCancellationException; - - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -var RuleContext = __webpack_require__(14).RuleContext; -var Hash = __webpack_require__(0).Hash; -var Map = __webpack_require__(0).Map; - -function PredictionContext(cachedHashCode) { - this.cachedHashCode = cachedHashCode; -} - -// Represents {@code $} in local context prediction, which means wildcard. -// {@code//+x =//}. -// / -PredictionContext.EMPTY = null; - -// Represents {@code $} in an array in full context mode, when {@code $} -// doesn't mean wildcard: {@code $ + x = [$,x]}. Here, -// {@code $} = {@link //EMPTY_RETURN_STATE}. -// / -PredictionContext.EMPTY_RETURN_STATE = 0x7FFFFFFF; - -PredictionContext.globalNodeCount = 1; -PredictionContext.id = PredictionContext.globalNodeCount; - -// Stores the computed hash code of this {@link PredictionContext}. The hash -// code is computed in parts to match the following reference algorithm. -// -//
          -// private int referenceHashCode() {
          -// int hash = {@link MurmurHash//initialize MurmurHash.initialize}({@link
          -// //INITIAL_HASH});
          -//
          -// for (int i = 0; i < {@link //size()}; i++) {
          -// hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link //getParent
          -// getParent}(i));
          -// }
          -//
          -// for (int i = 0; i < {@link //size()}; i++) {
          -// hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link
          -// //getReturnState getReturnState}(i));
          -// }
          -//
          -// hash = {@link MurmurHash//finish MurmurHash.finish}(hash, 2// {@link
          -// //size()});
          -// return hash;
          -// }
          -// 
          -// / - -// This means only the {@link //EMPTY} context is in set. -PredictionContext.prototype.isEmpty = function() { - return this === PredictionContext.EMPTY; -}; - -PredictionContext.prototype.hasEmptyPath = function() { - return this.getReturnState(this.length - 1) === PredictionContext.EMPTY_RETURN_STATE; -}; - -PredictionContext.prototype.hashCode = function() { - return this.cachedHashCode; -}; - - -PredictionContext.prototype.updateHashCode = function(hash) { - hash.update(this.cachedHashCode); -}; -/* -function calculateHashString(parent, returnState) { - return "" + parent + returnState; -} -*/ - -// Used to cache {@link PredictionContext} objects. Its used for the shared -// context cash associated with contexts in DFA states. This cache -// can be used for both lexers and parsers. - -function PredictionContextCache() { - this.cache = new Map(); - return this; -} - -// Add a context to the cache and return it. If the context already exists, -// return that one instead and do not add a new context to the cache. -// Protect shared cache from unsafe thread access. -// -PredictionContextCache.prototype.add = function(ctx) { - if (ctx === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; - } - var existing = this.cache.get(ctx) || null; - if (existing !== null) { - return existing; - } - this.cache.put(ctx, ctx); - return ctx; -}; - -PredictionContextCache.prototype.get = function(ctx) { - return this.cache.get(ctx) || null; -}; - -Object.defineProperty(PredictionContextCache.prototype, "length", { - get : function() { - return this.cache.length; - } -}); - -function SingletonPredictionContext(parent, returnState) { - var hashCode = 0; - var hash = new Hash(); - if(parent !== null) { - hash.update(parent, returnState); - } else { - hash.update(1); - } - hashCode = hash.finish(); - PredictionContext.call(this, hashCode); - this.parentCtx = parent; - this.returnState = returnState; -} - -SingletonPredictionContext.prototype = Object.create(PredictionContext.prototype); -SingletonPredictionContext.prototype.contructor = SingletonPredictionContext; - -SingletonPredictionContext.create = function(parent, returnState) { - if (returnState === PredictionContext.EMPTY_RETURN_STATE && parent === null) { - // someone can pass in the bits of an array ctx that mean $ - return PredictionContext.EMPTY; - } else { - return new SingletonPredictionContext(parent, returnState); - } -}; - -Object.defineProperty(SingletonPredictionContext.prototype, "length", { - get : function() { - return 1; - } -}); - -SingletonPredictionContext.prototype.getParent = function(index) { - return this.parentCtx; -}; - -SingletonPredictionContext.prototype.getReturnState = function(index) { - return this.returnState; -}; - -SingletonPredictionContext.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (!(other instanceof SingletonPredictionContext)) { - return false; - } else if (this.hashCode() !== other.hashCode()) { - return false; // can't be same if hash is different - } else { - if(this.returnState !== other.returnState) - return false; - else if(this.parentCtx==null) - return other.parentCtx==null - else - return this.parentCtx.equals(other.parentCtx); - } -}; - -SingletonPredictionContext.prototype.toString = function() { - var up = this.parentCtx === null ? "" : this.parentCtx.toString(); - if (up.length === 0) { - if (this.returnState === PredictionContext.EMPTY_RETURN_STATE) { - return "$"; - } else { - return "" + this.returnState; - } - } else { - return "" + this.returnState + " " + up; - } -}; - -function EmptyPredictionContext() { - SingletonPredictionContext.call(this, null, PredictionContext.EMPTY_RETURN_STATE); - return this; -} - -EmptyPredictionContext.prototype = Object.create(SingletonPredictionContext.prototype); -EmptyPredictionContext.prototype.constructor = EmptyPredictionContext; - -EmptyPredictionContext.prototype.isEmpty = function() { - return true; -}; - -EmptyPredictionContext.prototype.getParent = function(index) { - return null; -}; - -EmptyPredictionContext.prototype.getReturnState = function(index) { - return this.returnState; -}; - -EmptyPredictionContext.prototype.equals = function(other) { - return this === other; -}; - -EmptyPredictionContext.prototype.toString = function() { - return "$"; -}; - -PredictionContext.EMPTY = new EmptyPredictionContext(); - -function ArrayPredictionContext(parents, returnStates) { - // Parent can be null only if full ctx mode and we make an array - // from {@link //EMPTY} and non-empty. We merge {@link //EMPTY} by using - // null parent and - // returnState == {@link //EMPTY_RETURN_STATE}. - var h = new Hash(); - h.update(parents, returnStates); - var hashCode = h.finish(); - PredictionContext.call(this, hashCode); - this.parents = parents; - this.returnStates = returnStates; - return this; -} - -ArrayPredictionContext.prototype = Object.create(PredictionContext.prototype); -ArrayPredictionContext.prototype.constructor = ArrayPredictionContext; - -ArrayPredictionContext.prototype.isEmpty = function() { - // since EMPTY_RETURN_STATE can only appear in the last position, we - // don't need to verify that size==1 - return this.returnStates[0] === PredictionContext.EMPTY_RETURN_STATE; -}; - -Object.defineProperty(ArrayPredictionContext.prototype, "length", { - get : function() { - return this.returnStates.length; - } -}); - -ArrayPredictionContext.prototype.getParent = function(index) { - return this.parents[index]; -}; - -ArrayPredictionContext.prototype.getReturnState = function(index) { - return this.returnStates[index]; -}; - -ArrayPredictionContext.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (!(other instanceof ArrayPredictionContext)) { - return false; - } else if (this.hashCode() !== other.hashCode()) { - return false; // can't be same if hash is different - } else { - return this.returnStates === other.returnStates && - this.parents === other.parents; - } -}; - -ArrayPredictionContext.prototype.toString = function() { - if (this.isEmpty()) { - return "[]"; - } else { - var s = "["; - for (var i = 0; i < this.returnStates.length; i++) { - if (i > 0) { - s = s + ", "; - } - if (this.returnStates[i] === PredictionContext.EMPTY_RETURN_STATE) { - s = s + "$"; - continue; - } - s = s + this.returnStates[i]; - if (this.parents[i] !== null) { - s = s + " " + this.parents[i]; - } else { - s = s + "null"; - } - } - return s + "]"; - } -}; - -// Convert a {@link RuleContext} tree to a {@link PredictionContext} graph. -// Return {@link //EMPTY} if {@code outerContext} is empty or null. -// / -function predictionContextFromRuleContext(atn, outerContext) { - if (outerContext === undefined || outerContext === null) { - outerContext = RuleContext.EMPTY; - } - // if we are in RuleContext of start rule, s, then PredictionContext - // is EMPTY. Nobody called us. (if we are empty, return empty) - if (outerContext.parentCtx === null || outerContext === RuleContext.EMPTY) { - return PredictionContext.EMPTY; - } - // If we have a parent, convert it to a PredictionContext graph - var parent = predictionContextFromRuleContext(atn, outerContext.parentCtx); - var state = atn.states[outerContext.invokingState]; - var transition = state.transitions[0]; - return SingletonPredictionContext.create(parent, transition.followState.stateNumber); -} -/* -function calculateListsHashString(parents, returnStates) { - var s = ""; - parents.map(function(p) { - s = s + p; - }); - returnStates.map(function(r) { - s = s + r; - }); - return s; -} -*/ -function merge(a, b, rootIsWildcard, mergeCache) { - // share same graph if both same - if (a === b) { - return a; - } - if (a instanceof SingletonPredictionContext && b instanceof SingletonPredictionContext) { - return mergeSingletons(a, b, rootIsWildcard, mergeCache); - } - // At least one of a or b is array - // If one is $ and rootIsWildcard, return $ as// wildcard - if (rootIsWildcard) { - if (a instanceof EmptyPredictionContext) { - return a; - } - if (b instanceof EmptyPredictionContext) { - return b; - } - } - // convert singleton so both are arrays to normalize - if (a instanceof SingletonPredictionContext) { - a = new ArrayPredictionContext([a.getParent()], [a.returnState]); - } - if (b instanceof SingletonPredictionContext) { - b = new ArrayPredictionContext([b.getParent()], [b.returnState]); - } - return mergeArrays(a, b, rootIsWildcard, mergeCache); -} - -// -// Merge two {@link SingletonPredictionContext} instances. -// -//

          Stack tops equal, parents merge is same; return left graph.
          -//

          -// -//

          Same stack top, parents differ; merge parents giving array node, then -// remainders of those graphs. A new root node is created to point to the -// merged parents.
          -//

          -// -//

          Different stack tops pointing to same parent. Make array node for the -// root where both element in the root point to the same (original) -// parent.
          -//

          -// -//

          Different stack tops pointing to different parents. Make array node for -// the root where each element points to the corresponding original -// parent.
          -//

          -// -// @param a the first {@link SingletonPredictionContext} -// @param b the second {@link SingletonPredictionContext} -// @param rootIsWildcard {@code true} if this is a local-context merge, -// otherwise false to indicate a full-context merge -// @param mergeCache -// / -function mergeSingletons(a, b, rootIsWildcard, mergeCache) { - if (mergeCache !== null) { - var previous = mergeCache.get(a, b); - if (previous !== null) { - return previous; - } - previous = mergeCache.get(b, a); - if (previous !== null) { - return previous; - } - } - - var rootMerge = mergeRoot(a, b, rootIsWildcard); - if (rootMerge !== null) { - if (mergeCache !== null) { - mergeCache.set(a, b, rootMerge); - } - return rootMerge; - } - if (a.returnState === b.returnState) { - var parent = merge(a.parentCtx, b.parentCtx, rootIsWildcard, mergeCache); - // if parent is same as existing a or b parent or reduced to a parent, - // return it - if (parent === a.parentCtx) { - return a; // ax + bx = ax, if a=b - } - if (parent === b.parentCtx) { - return b; // ax + bx = bx, if a=b - } - // else: ax + ay = a'[x,y] - // merge parents x and y, giving array node with x,y then remainders - // of those graphs. dup a, a' points at merged array - // new joined parent so create new singleton pointing to it, a' - var spc = SingletonPredictionContext.create(parent, a.returnState); - if (mergeCache !== null) { - mergeCache.set(a, b, spc); - } - return spc; - } else { // a != b payloads differ - // see if we can collapse parents due to $+x parents if local ctx - var singleParent = null; - if (a === b || (a.parentCtx !== null && a.parentCtx === b.parentCtx)) { // ax + - // bx = - // [a,b]x - singleParent = a.parentCtx; - } - if (singleParent !== null) { // parents are same - // sort payloads and use same parent - var payloads = [ a.returnState, b.returnState ]; - if (a.returnState > b.returnState) { - payloads[0] = b.returnState; - payloads[1] = a.returnState; - } - var parents = [ singleParent, singleParent ]; - var apc = new ArrayPredictionContext(parents, payloads); - if (mergeCache !== null) { - mergeCache.set(a, b, apc); - } - return apc; - } - // parents differ and can't merge them. Just pack together - // into array; can't merge. - // ax + by = [ax,by] - var payloads = [ a.returnState, b.returnState ]; - var parents = [ a.parentCtx, b.parentCtx ]; - if (a.returnState > b.returnState) { // sort by payload - payloads[0] = b.returnState; - payloads[1] = a.returnState; - parents = [ b.parentCtx, a.parentCtx ]; - } - var a_ = new ArrayPredictionContext(parents, payloads); - if (mergeCache !== null) { - mergeCache.set(a, b, a_); - } - return a_; - } -} - -// -// Handle case where at least one of {@code a} or {@code b} is -// {@link //EMPTY}. In the following diagrams, the symbol {@code $} is used -// to represent {@link //EMPTY}. -// -//

          Local-Context Merges

          -// -//

          These local-context merge operations are used when {@code rootIsWildcard} -// is true.

          -// -//

          {@link //EMPTY} is superset of any graph; return {@link //EMPTY}.
          -//

          -// -//

          {@link //EMPTY} and anything is {@code //EMPTY}, so merged parent is -// {@code //EMPTY}; return left graph.
          -//

          -// -//

          Special case of last merge if local context.
          -//

          -// -//

          Full-Context Merges

          -// -//

          These full-context merge operations are used when {@code rootIsWildcard} -// is false.

          -// -//

          -// -//

          Must keep all contexts; {@link //EMPTY} in array is a special value (and -// null parent).
          -//

          -// -//

          -// -// @param a the first {@link SingletonPredictionContext} -// @param b the second {@link SingletonPredictionContext} -// @param rootIsWildcard {@code true} if this is a local-context merge, -// otherwise false to indicate a full-context merge -// / -function mergeRoot(a, b, rootIsWildcard) { - if (rootIsWildcard) { - if (a === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; // // + b =// - } - if (b === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; // a +// =// - } - } else { - if (a === PredictionContext.EMPTY && b === PredictionContext.EMPTY) { - return PredictionContext.EMPTY; // $ + $ = $ - } else if (a === PredictionContext.EMPTY) { // $ + x = [$,x] - var payloads = [ b.returnState, - PredictionContext.EMPTY_RETURN_STATE ]; - var parents = [ b.parentCtx, null ]; - return new ArrayPredictionContext(parents, payloads); - } else if (b === PredictionContext.EMPTY) { // x + $ = [$,x] ($ is always first if present) - var payloads = [ a.returnState, PredictionContext.EMPTY_RETURN_STATE ]; - var parents = [ a.parentCtx, null ]; - return new ArrayPredictionContext(parents, payloads); - } - } - return null; -} - -// -// Merge two {@link ArrayPredictionContext} instances. -// -//

          Different tops, different parents.
          -//

          -// -//

          Shared top, same parents.
          -//

          -// -//

          Shared top, different parents.
          -//

          -// -//

          Shared top, all shared parents.
          -//

          -// -//

          Equal tops, merge parents and reduce top to -// {@link SingletonPredictionContext}.
          -//

          -// / -function mergeArrays(a, b, rootIsWildcard, mergeCache) { - if (mergeCache !== null) { - var previous = mergeCache.get(a, b); - if (previous !== null) { - return previous; - } - previous = mergeCache.get(b, a); - if (previous !== null) { - return previous; - } - } - // merge sorted payloads a + b => M - var i = 0; // walks a - var j = 0; // walks b - var k = 0; // walks target M array - - var mergedReturnStates = []; - var mergedParents = []; - // walk and merge to yield mergedParents, mergedReturnStates - while (i < a.returnStates.length && j < b.returnStates.length) { - var a_parent = a.parents[i]; - var b_parent = b.parents[j]; - if (a.returnStates[i] === b.returnStates[j]) { - // same payload (stack tops are equal), must yield merged singleton - var payload = a.returnStates[i]; - // $+$ = $ - var bothDollars = payload === PredictionContext.EMPTY_RETURN_STATE && - a_parent === null && b_parent === null; - var ax_ax = (a_parent !== null && b_parent !== null && a_parent === b_parent); // ax+ax - // -> - // ax - if (bothDollars || ax_ax) { - mergedParents[k] = a_parent; // choose left - mergedReturnStates[k] = payload; - } else { // ax+ay -> a'[x,y] - var mergedParent = merge(a_parent, b_parent, rootIsWildcard, mergeCache); - mergedParents[k] = mergedParent; - mergedReturnStates[k] = payload; - } - i += 1; // hop over left one as usual - j += 1; // but also skip one in right side since we merge - } else if (a.returnStates[i] < b.returnStates[j]) { // copy a[i] to M - mergedParents[k] = a_parent; - mergedReturnStates[k] = a.returnStates[i]; - i += 1; - } else { // b > a, copy b[j] to M - mergedParents[k] = b_parent; - mergedReturnStates[k] = b.returnStates[j]; - j += 1; - } - k += 1; - } - // copy over any payloads remaining in either array - if (i < a.returnStates.length) { - for (var p = i; p < a.returnStates.length; p++) { - mergedParents[k] = a.parents[p]; - mergedReturnStates[k] = a.returnStates[p]; - k += 1; - } - } else { - for (var p = j; p < b.returnStates.length; p++) { - mergedParents[k] = b.parents[p]; - mergedReturnStates[k] = b.returnStates[p]; - k += 1; - } - } - // trim merged if we combined a few that had same stack tops - if (k < mergedParents.length) { // write index < last position; trim - if (k === 1) { // for just one merged element, return singleton top - var a_ = SingletonPredictionContext.create(mergedParents[0], - mergedReturnStates[0]); - if (mergeCache !== null) { - mergeCache.set(a, b, a_); - } - return a_; - } - mergedParents = mergedParents.slice(0, k); - mergedReturnStates = mergedReturnStates.slice(0, k); - } - - var M = new ArrayPredictionContext(mergedParents, mergedReturnStates); - - // if we created same array as a or b, return that instead - // TODO: track whether this is possible above during merge sort for speed - if (M === a) { - if (mergeCache !== null) { - mergeCache.set(a, b, a); - } - return a; - } - if (M === b) { - if (mergeCache !== null) { - mergeCache.set(a, b, b); - } - return b; - } - combineCommonParents(mergedParents); - - if (mergeCache !== null) { - mergeCache.set(a, b, M); - } - return M; -} - -// -// Make pass over all M {@code parents}; merge any {@code equals()} -// ones. -// / -function combineCommonParents(parents) { - var uniqueParents = new Map(); - - for (var p = 0; p < parents.length; p++) { - var parent = parents[p]; - if (!(uniqueParents.containsKey(parent))) { - uniqueParents.put(parent, parent); - } - } - for (var q = 0; q < parents.length; q++) { - parents[q] = uniqueParents.get(parents[q]); - } -} - -function getCachedPredictionContext(context, contextCache, visited) { - if (context.isEmpty()) { - return context; - } - var existing = visited.get(context) || null; - if (existing !== null) { - return existing; - } - existing = contextCache.get(context); - if (existing !== null) { - visited.put(context, existing); - return existing; - } - var changed = false; - var parents = []; - for (var i = 0; i < parents.length; i++) { - var parent = getCachedPredictionContext(context.getParent(i), contextCache, visited); - if (changed || parent !== context.getParent(i)) { - if (!changed) { - parents = []; - for (var j = 0; j < context.length; j++) { - parents[j] = context.getParent(j); - } - changed = true; - } - parents[i] = parent; - } - } - if (!changed) { - contextCache.add(context); - visited.put(context, context); - return context; - } - var updated = null; - if (parents.length === 0) { - updated = PredictionContext.EMPTY; - } else if (parents.length === 1) { - updated = SingletonPredictionContext.create(parents[0], context - .getReturnState(0)); - } else { - updated = new ArrayPredictionContext(parents, context.returnStates); - } - contextCache.add(updated); - visited.put(updated, updated); - visited.put(context, updated); - - return updated; -} - -// ter's recursive version of Sam's getAllNodes() -function getAllContextNodes(context, nodes, visited) { - if (nodes === null) { - nodes = []; - return getAllContextNodes(context, nodes, visited); - } else if (visited === null) { - visited = new Map(); - return getAllContextNodes(context, nodes, visited); - } else { - if (context === null || visited.containsKey(context)) { - return nodes; - } - visited.put(context, context); - nodes.push(context); - for (var i = 0; i < context.length; i++) { - getAllContextNodes(context.getParent(i), nodes, visited); - } - return nodes; - } -} - -exports.merge = merge; -exports.PredictionContext = PredictionContext; -exports.PredictionContextCache = PredictionContextCache; -exports.SingletonPredictionContext = SingletonPredictionContext; -exports.predictionContextFromRuleContext = predictionContextFromRuleContext; -exports.getCachedPredictionContext = getCachedPredictionContext; - - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -var LL1Analyzer = __webpack_require__(36).LL1Analyzer; -var IntervalSet = __webpack_require__(2).IntervalSet; - -function ATN(grammarType , maxTokenType) { - - // Used for runtime deserialization of ATNs from strings/// - // The type of the ATN. - this.grammarType = grammarType; - // The maximum value for any symbol recognized by a transition in the ATN. - this.maxTokenType = maxTokenType; - this.states = []; - // Each subrule/rule is a decision point and we must track them so we - // can go back later and build DFA predictors for them. This includes - // all the rules, subrules, optional blocks, ()+, ()* etc... - this.decisionToState = []; - // Maps from rule index to starting state number. - this.ruleToStartState = []; - // Maps from rule index to stop state number. - this.ruleToStopState = null; - this.modeNameToStartState = {}; - // For lexer ATNs, this maps the rule index to the resulting token type. - // For parser ATNs, this maps the rule index to the generated bypass token - // type if the - // {@link ATNDeserializationOptions//isGenerateRuleBypassTransitions} - // deserialization option was specified; otherwise, this is {@code null}. - this.ruleToTokenType = null; - // For lexer ATNs, this is an array of {@link LexerAction} objects which may - // be referenced by action transitions in the ATN. - this.lexerActions = null; - this.modeToStartState = []; - - return this; -} - -// Compute the set of valid tokens that can occur starting in state {@code s}. -// If {@code ctx} is null, the set of tokens will not include what can follow -// the rule surrounding {@code s}. In other words, the set will be -// restricted to tokens reachable staying within {@code s}'s rule. -ATN.prototype.nextTokensInContext = function(s, ctx) { - var anal = new LL1Analyzer(this); - return anal.LOOK(s, null, ctx); -}; - -// Compute the set of valid tokens that can occur starting in {@code s} and -// staying in same rule. {@link Token//EPSILON} is in set if we reach end of -// rule. -ATN.prototype.nextTokensNoContext = function(s) { - if (s.nextTokenWithinRule !== null ) { - return s.nextTokenWithinRule; - } - s.nextTokenWithinRule = this.nextTokensInContext(s, null); - s.nextTokenWithinRule.readOnly = true; - return s.nextTokenWithinRule; -}; - -ATN.prototype.nextTokens = function(s, ctx) { - if ( ctx===undefined ) { - return this.nextTokensNoContext(s); - } else { - return this.nextTokensInContext(s, ctx); - } -}; - -ATN.prototype.addState = function( state) { - if ( state !== null ) { - state.atn = this; - state.stateNumber = this.states.length; - } - this.states.push(state); -}; - -ATN.prototype.removeState = function( state) { - this.states[state.stateNumber] = null; // just free mem, don't shift states in list -}; - -ATN.prototype.defineDecisionState = function( s) { - this.decisionToState.push(s); - s.decision = this.decisionToState.length-1; - return s.decision; -}; - -ATN.prototype.getDecisionState = function( decision) { - if (this.decisionToState.length===0) { - return null; - } else { - return this.decisionToState[decision]; - } -}; - -// Computes the set of input symbols which could follow ATN state number -// {@code stateNumber} in the specified full {@code context}. This method -// considers the complete parser context, but does not evaluate semantic -// predicates (i.e. all predicates encountered during the calculation are -// assumed true). If a path in the ATN exists from the starting state to the -// {@link RuleStopState} of the outermost context without matching any -// symbols, {@link Token//EOF} is added to the returned set. -// -//

          If {@code context} is {@code null}, it is treated as -// {@link ParserRuleContext//EMPTY}.

          -// -// @param stateNumber the ATN state number -// @param context the full parse context -// @return The set of potentially valid input symbols which could follow the -// specified state in the specified context. -// @throws IllegalArgumentException if the ATN does not contain a state with -// number {@code stateNumber} -var Token = __webpack_require__(1).Token; - -ATN.prototype.getExpectedTokens = function( stateNumber, ctx ) { - if ( stateNumber < 0 || stateNumber >= this.states.length ) { - throw("Invalid state number."); - } - var s = this.states[stateNumber]; - var following = this.nextTokens(s); - if (!following.contains(Token.EPSILON)) { - return following; - } - var expected = new IntervalSet(); - expected.addSet(following); - expected.removeOne(Token.EPSILON); - while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) { - var invokingState = this.states[ctx.invokingState]; - var rt = invokingState.transitions[0]; - following = this.nextTokens(rt.followState); - expected.addSet(following); - expected.removeOne(Token.EPSILON); - ctx = ctx.parentCtx; - } - if (following.contains(Token.EPSILON)) { - expected.addOne(Token.EOF); - } - return expected; -}; - -ATN.INVALID_ALT_NUMBER = 0; - -exports.ATN = ATN; - -/***/ }), -/* 8 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// An ATN transition between any two ATN states. Subclasses define -// atom, set, epsilon, action, predicate, rule transitions. -// -//

          This is a one way link. It emanates from a state (usually via a list of -// transitions) and has a target state.

          -// -//

          Since we never have to change the ATN transitions once we construct it, -// we can fix these transitions as specific classes. The DFA transitions -// on the other hand need to update the labels as it adds transitions to -// the states. We'll use the term Edge for the DFA to distinguish them from -// ATN transitions.

          - -var Token = __webpack_require__(1).Token; -var Interval = __webpack_require__(2).Interval; -var IntervalSet = __webpack_require__(2).IntervalSet; -var Predicate = __webpack_require__(10).Predicate; -var PrecedencePredicate = __webpack_require__(10).PrecedencePredicate; - -function Transition (target) { - // The target of this transition. - if (target===undefined || target===null) { - throw "target cannot be null."; - } - this.target = target; - // Are we epsilon, action, sempred? - this.isEpsilon = false; - this.label = null; - return this; -} - // constants for serialization -Transition.EPSILON = 1; -Transition.RANGE = 2; -Transition.RULE = 3; -Transition.PREDICATE = 4; // e.g., {isType(input.LT(1))}? -Transition.ATOM = 5; -Transition.ACTION = 6; -Transition.SET = 7; // ~(A|B) or ~atom, wildcard, which convert to next 2 -Transition.NOT_SET = 8; -Transition.WILDCARD = 9; -Transition.PRECEDENCE = 10; - -Transition.serializationNames = [ - "INVALID", - "EPSILON", - "RANGE", - "RULE", - "PREDICATE", - "ATOM", - "ACTION", - "SET", - "NOT_SET", - "WILDCARD", - "PRECEDENCE" - ]; - -Transition.serializationTypes = { - EpsilonTransition: Transition.EPSILON, - RangeTransition: Transition.RANGE, - RuleTransition: Transition.RULE, - PredicateTransition: Transition.PREDICATE, - AtomTransition: Transition.ATOM, - ActionTransition: Transition.ACTION, - SetTransition: Transition.SET, - NotSetTransition: Transition.NOT_SET, - WildcardTransition: Transition.WILDCARD, - PrecedencePredicateTransition: Transition.PRECEDENCE - }; - - -// TODO: make all transitions sets? no, should remove set edges -function AtomTransition(target, label) { - Transition.call(this, target); - this.label_ = label; // The token type or character value; or, signifies special label. - this.label = this.makeLabel(); - this.serializationType = Transition.ATOM; - return this; -} - -AtomTransition.prototype = Object.create(Transition.prototype); -AtomTransition.prototype.constructor = AtomTransition; - -AtomTransition.prototype.makeLabel = function() { - var s = new IntervalSet(); - s.addOne(this.label_); - return s; -}; - -AtomTransition.prototype.matches = function( symbol, minVocabSymbol, maxVocabSymbol) { - return this.label_ === symbol; -}; - -AtomTransition.prototype.toString = function() { - return this.label_; -}; - -function RuleTransition(ruleStart, ruleIndex, precedence, followState) { - Transition.call(this, ruleStart); - this.ruleIndex = ruleIndex; // ptr to the rule definition object for this rule ref - this.precedence = precedence; - this.followState = followState; // what node to begin computations following ref to rule - this.serializationType = Transition.RULE; - this.isEpsilon = true; - return this; -} - -RuleTransition.prototype = Object.create(Transition.prototype); -RuleTransition.prototype.constructor = RuleTransition; - -RuleTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return false; -}; - - -function EpsilonTransition(target, outermostPrecedenceReturn) { - Transition.call(this, target); - this.serializationType = Transition.EPSILON; - this.isEpsilon = true; - this.outermostPrecedenceReturn = outermostPrecedenceReturn; - return this; -} - -EpsilonTransition.prototype = Object.create(Transition.prototype); -EpsilonTransition.prototype.constructor = EpsilonTransition; - -EpsilonTransition.prototype.matches = function( symbol, minVocabSymbol, maxVocabSymbol) { - return false; -}; - -EpsilonTransition.prototype.toString = function() { - return "epsilon"; -}; - -function RangeTransition(target, start, stop) { - Transition.call(this, target); - this.serializationType = Transition.RANGE; - this.start = start; - this.stop = stop; - this.label = this.makeLabel(); - return this; -} - -RangeTransition.prototype = Object.create(Transition.prototype); -RangeTransition.prototype.constructor = RangeTransition; - -RangeTransition.prototype.makeLabel = function() { - var s = new IntervalSet(); - s.addRange(this.start, this.stop); - return s; -}; - -RangeTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return symbol >= this.start && symbol <= this.stop; -}; - -RangeTransition.prototype.toString = function() { - return "'" + String.fromCharCode(this.start) + "'..'" + String.fromCharCode(this.stop) + "'"; -}; - -function AbstractPredicateTransition(target) { - Transition.call(this, target); - return this; -} - -AbstractPredicateTransition.prototype = Object.create(Transition.prototype); -AbstractPredicateTransition.prototype.constructor = AbstractPredicateTransition; - -function PredicateTransition(target, ruleIndex, predIndex, isCtxDependent) { - AbstractPredicateTransition.call(this, target); - this.serializationType = Transition.PREDICATE; - this.ruleIndex = ruleIndex; - this.predIndex = predIndex; - this.isCtxDependent = isCtxDependent; // e.g., $i ref in pred - this.isEpsilon = true; - return this; -} - -PredicateTransition.prototype = Object.create(AbstractPredicateTransition.prototype); -PredicateTransition.prototype.constructor = PredicateTransition; - -PredicateTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return false; -}; - -PredicateTransition.prototype.getPredicate = function() { - return new Predicate(this.ruleIndex, this.predIndex, this.isCtxDependent); -}; - -PredicateTransition.prototype.toString = function() { - return "pred_" + this.ruleIndex + ":" + this.predIndex; -}; - -function ActionTransition(target, ruleIndex, actionIndex, isCtxDependent) { - Transition.call(this, target); - this.serializationType = Transition.ACTION; - this.ruleIndex = ruleIndex; - this.actionIndex = actionIndex===undefined ? -1 : actionIndex; - this.isCtxDependent = isCtxDependent===undefined ? false : isCtxDependent; // e.g., $i ref in pred - this.isEpsilon = true; - return this; -} - -ActionTransition.prototype = Object.create(Transition.prototype); -ActionTransition.prototype.constructor = ActionTransition; - - -ActionTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return false; -}; - -ActionTransition.prototype.toString = function() { - return "action_" + this.ruleIndex + ":" + this.actionIndex; -}; - - -// A transition containing a set of values. -function SetTransition(target, set) { - Transition.call(this, target); - this.serializationType = Transition.SET; - if (set !==undefined && set !==null) { - this.label = set; - } else { - this.label = new IntervalSet(); - this.label.addOne(Token.INVALID_TYPE); - } - return this; -} - -SetTransition.prototype = Object.create(Transition.prototype); -SetTransition.prototype.constructor = SetTransition; - -SetTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return this.label.contains(symbol); -}; - - -SetTransition.prototype.toString = function() { - return this.label.toString(); -}; - -function NotSetTransition(target, set) { - SetTransition.call(this, target, set); - this.serializationType = Transition.NOT_SET; - return this; -} - -NotSetTransition.prototype = Object.create(SetTransition.prototype); -NotSetTransition.prototype.constructor = NotSetTransition; - -NotSetTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && - !SetTransition.prototype.matches.call(this, symbol, minVocabSymbol, maxVocabSymbol); -}; - -NotSetTransition.prototype.toString = function() { - return '~' + SetTransition.prototype.toString.call(this); -}; - -function WildcardTransition(target) { - Transition.call(this, target); - this.serializationType = Transition.WILDCARD; - return this; -} - -WildcardTransition.prototype = Object.create(Transition.prototype); -WildcardTransition.prototype.constructor = WildcardTransition; - - -WildcardTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; -}; - -WildcardTransition.prototype.toString = function() { - return "."; -}; - -function PrecedencePredicateTransition(target, precedence) { - AbstractPredicateTransition.call(this, target); - this.serializationType = Transition.PRECEDENCE; - this.precedence = precedence; - this.isEpsilon = true; - return this; -} - -PrecedencePredicateTransition.prototype = Object.create(AbstractPredicateTransition.prototype); -PrecedencePredicateTransition.prototype.constructor = PrecedencePredicateTransition; - -PrecedencePredicateTransition.prototype.matches = function(symbol, minVocabSymbol, maxVocabSymbol) { - return false; -}; - -PrecedencePredicateTransition.prototype.getPredicate = function() { - return new PrecedencePredicate(this.precedence); -}; - -PrecedencePredicateTransition.prototype.toString = function() { - return this.precedence + " >= _p"; -}; - -exports.Transition = Transition; -exports.AtomTransition = AtomTransition; -exports.SetTransition = SetTransition; -exports.NotSetTransition = NotSetTransition; -exports.RuleTransition = RuleTransition; -exports.ActionTransition = ActionTransition; -exports.EpsilonTransition = EpsilonTransition; -exports.RangeTransition = RangeTransition; -exports.WildcardTransition = WildcardTransition; -exports.PredicateTransition = PredicateTransition; -exports.PrecedencePredicateTransition = PrecedencePredicateTransition; -exports.AbstractPredicateTransition = AbstractPredicateTransition; - -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -// -// Specialized {@link Set}{@code <}{@link ATNConfig}{@code >} that can track -// info about the set, with support for combining similar configurations using a -// graph-structured stack. -/// - -var ATN = __webpack_require__(7).ATN; -var Utils = __webpack_require__(0); -var Hash = Utils.Hash; -var Set = Utils.Set; -var SemanticContext = __webpack_require__(10).SemanticContext; -var merge = __webpack_require__(6).merge; - -function hashATNConfig(c) { - return c.hashCodeForConfigSet(); -} - -function equalATNConfigs(a, b) { - if ( a===b ) { - return true; - } else if ( a===null || b===null ) { - return false; - } else - return a.equalsForConfigSet(b); - } - - -function ATNConfigSet(fullCtx) { - // - // The reason that we need this is because we don't want the hash map to use - // the standard hash code and equals. We need all configurations with the - // same - // {@code (s,i,_,semctx)} to be equal. Unfortunately, this key effectively - // doubles - // the number of objects associated with ATNConfigs. The other solution is - // to - // use a hash table that lets us specify the equals/hashcode operation. - // All configs but hashed by (s, i, _, pi) not including context. Wiped out - // when we go readonly as this set becomes a DFA state. - this.configLookup = new Set(hashATNConfig, equalATNConfigs); - // Indicates that this configuration set is part of a full context - // LL prediction. It will be used to determine how to merge $. With SLL - // it's a wildcard whereas it is not for LL context merge. - this.fullCtx = fullCtx === undefined ? true : fullCtx; - // Indicates that the set of configurations is read-only. Do not - // allow any code to manipulate the set; DFA states will point at - // the sets and they must not change. This does not protect the other - // fields; in particular, conflictingAlts is set after - // we've made this readonly. - this.readOnly = false; - // Track the elements as they are added to the set; supports get(i)/// - this.configs = []; - - // TODO: these fields make me pretty uncomfortable but nice to pack up info - // together, saves recomputation - // TODO: can we track conflicts as they are added to save scanning configs - // later? - this.uniqueAlt = 0; - this.conflictingAlts = null; - - // Used in parser and lexer. In lexer, it indicates we hit a pred - // while computing a closure operation. Don't make a DFA state from this. - this.hasSemanticContext = false; - this.dipsIntoOuterContext = false; - - this.cachedHashCode = -1; - - return this; -} - -// Adding a new config means merging contexts with existing configs for -// {@code (s, i, pi, _)}, where {@code s} is the -// {@link ATNConfig//state}, {@code i} is the {@link ATNConfig//alt}, and -// {@code pi} is the {@link ATNConfig//semanticContext}. We use -// {@code (s,i,pi)} as key. -// -//

          This method updates {@link //dipsIntoOuterContext} and -// {@link //hasSemanticContext} when necessary.

          -// / -ATNConfigSet.prototype.add = function(config, mergeCache) { - if (mergeCache === undefined) { - mergeCache = null; - } - if (this.readOnly) { - throw "This set is readonly"; - } - if (config.semanticContext !== SemanticContext.NONE) { - this.hasSemanticContext = true; - } - if (config.reachesIntoOuterContext > 0) { - this.dipsIntoOuterContext = true; - } - var existing = this.configLookup.add(config); - if (existing === config) { - this.cachedHashCode = -1; - this.configs.push(config); // track order here - return true; - } - // a previous (s,i,pi,_), merge with it and save result - var rootIsWildcard = !this.fullCtx; - var merged = merge(existing.context, config.context, rootIsWildcard, mergeCache); - // no need to check for existing.context, config.context in cache - // since only way to create new graphs is "call rule" and here. We - // cache at both places. - existing.reachesIntoOuterContext = Math.max( existing.reachesIntoOuterContext, config.reachesIntoOuterContext); - // make sure to preserve the precedence filter suppression during the merge - if (config.precedenceFilterSuppressed) { - existing.precedenceFilterSuppressed = true; - } - existing.context = merged; // replace context; no need to alt mapping - return true; -}; - -ATNConfigSet.prototype.getStates = function() { - var states = new Set(); - for (var i = 0; i < this.configs.length; i++) { - states.add(this.configs[i].state); - } - return states; -}; - -ATNConfigSet.prototype.getPredicates = function() { - var preds = []; - for (var i = 0; i < this.configs.length; i++) { - var c = this.configs[i].semanticContext; - if (c !== SemanticContext.NONE) { - preds.push(c.semanticContext); - } - } - return preds; -}; - -Object.defineProperty(ATNConfigSet.prototype, "items", { - get : function() { - return this.configs; - } -}); - -ATNConfigSet.prototype.optimizeConfigs = function(interpreter) { - if (this.readOnly) { - throw "This set is readonly"; - } - if (this.configLookup.length === 0) { - return; - } - for (var i = 0; i < this.configs.length; i++) { - var config = this.configs[i]; - config.context = interpreter.getCachedContext(config.context); - } -}; - -ATNConfigSet.prototype.addAll = function(coll) { - for (var i = 0; i < coll.length; i++) { - this.add(coll[i]); - } - return false; -}; - -ATNConfigSet.prototype.equals = function(other) { - return this === other || - (other instanceof ATNConfigSet && - Utils.equalArrays(this.configs, other.configs) && - this.fullCtx === other.fullCtx && - this.uniqueAlt === other.uniqueAlt && - this.conflictingAlts === other.conflictingAlts && - this.hasSemanticContext === other.hasSemanticContext && - this.dipsIntoOuterContext === other.dipsIntoOuterContext); -}; - -ATNConfigSet.prototype.hashCode = function() { - var hash = new Hash(); - hash.update(this.configs); - return hash.finish(); -}; - - -ATNConfigSet.prototype.updateHashCode = function(hash) { - if (this.readOnly) { - if (this.cachedHashCode === -1) { - this.cachedHashCode = this.hashCode(); - } - hash.update(this.cachedHashCode); - } else { - hash.update(this.hashCode()); - } -}; - - -Object.defineProperty(ATNConfigSet.prototype, "length", { - get : function() { - return this.configs.length; - } -}); - -ATNConfigSet.prototype.isEmpty = function() { - return this.configs.length === 0; -}; - -ATNConfigSet.prototype.contains = function(item) { - if (this.configLookup === null) { - throw "This method is not implemented for readonly sets."; - } - return this.configLookup.contains(item); -}; - -ATNConfigSet.prototype.containsFast = function(item) { - if (this.configLookup === null) { - throw "This method is not implemented for readonly sets."; - } - return this.configLookup.containsFast(item); -}; - -ATNConfigSet.prototype.clear = function() { - if (this.readOnly) { - throw "This set is readonly"; - } - this.configs = []; - this.cachedHashCode = -1; - this.configLookup = new Set(); -}; - -ATNConfigSet.prototype.setReadonly = function(readOnly) { - this.readOnly = readOnly; - if (readOnly) { - this.configLookup = null; // can't mod, no need for lookup cache - } -}; - -ATNConfigSet.prototype.toString = function() { - return Utils.arrayToString(this.configs) + - (this.hasSemanticContext ? ",hasSemanticContext=" + this.hasSemanticContext : "") + - (this.uniqueAlt !== ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") + - (this.conflictingAlts !== null ? ",conflictingAlts=" + this.conflictingAlts : "") + - (this.dipsIntoOuterContext ? ",dipsIntoOuterContext" : ""); -}; - -function OrderedATNConfigSet() { - ATNConfigSet.call(this); - this.configLookup = new Set(); - return this; -} - -OrderedATNConfigSet.prototype = Object.create(ATNConfigSet.prototype); -OrderedATNConfigSet.prototype.constructor = OrderedATNConfigSet; - -exports.ATNConfigSet = ATNConfigSet; -exports.OrderedATNConfigSet = OrderedATNConfigSet; - - -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// A tree structure used to record the semantic context in which -// an ATN configuration is valid. It's either a single predicate, -// a conjunction {@code p1&&p2}, or a sum of products {@code p1||p2}. -// -//

          I have scoped the {@link AND}, {@link OR}, and {@link Predicate} subclasses of -// {@link SemanticContext} within the scope of this outer class.

          -// - -var Set = __webpack_require__(0).Set; -var Hash = __webpack_require__(0).Hash; - -function SemanticContext() { - return this; -} - -SemanticContext.prototype.hashCode = function() { - var hash = new Hash(); - this.updateHashCode(hash); - return hash.finish(); -}; - -// For context independent predicates, we evaluate them without a local -// context (i.e., null context). That way, we can evaluate them without -// having to create proper rule-specific context during prediction (as -// opposed to the parser, which creates them naturally). In a practical -// sense, this avoids a cast exception from RuleContext to myruleContext. -// -//

          For context dependent predicates, we must pass in a local context so that -// references such as $arg evaluate properly as _localctx.arg. We only -// capture context dependent predicates in the context in which we begin -// prediction, so we passed in the outer context here in case of context -// dependent predicate evaluation.

          -// -SemanticContext.prototype.evaluate = function(parser, outerContext) { -}; - -// -// Evaluate the precedence predicates for the context and reduce the result. -// -// @param parser The parser instance. -// @param outerContext The current parser context object. -// @return The simplified semantic context after precedence predicates are -// evaluated, which will be one of the following values. -//
            -//
          • {@link //NONE}: if the predicate simplifies to {@code true} after -// precedence predicates are evaluated.
          • -//
          • {@code null}: if the predicate simplifies to {@code false} after -// precedence predicates are evaluated.
          • -//
          • {@code this}: if the semantic context is not changed as a result of -// precedence predicate evaluation.
          • -//
          • A non-{@code null} {@link SemanticContext}: the new simplified -// semantic context after precedence predicates are evaluated.
          • -//
          -// -SemanticContext.prototype.evalPrecedence = function(parser, outerContext) { - return this; -}; - -SemanticContext.andContext = function(a, b) { - if (a === null || a === SemanticContext.NONE) { - return b; - } - if (b === null || b === SemanticContext.NONE) { - return a; - } - var result = new AND(a, b); - if (result.opnds.length === 1) { - return result.opnds[0]; - } else { - return result; - } -}; - -SemanticContext.orContext = function(a, b) { - if (a === null) { - return b; - } - if (b === null) { - return a; - } - if (a === SemanticContext.NONE || b === SemanticContext.NONE) { - return SemanticContext.NONE; - } - var result = new OR(a, b); - if (result.opnds.length === 1) { - return result.opnds[0]; - } else { - return result; - } -}; - -function Predicate(ruleIndex, predIndex, isCtxDependent) { - SemanticContext.call(this); - this.ruleIndex = ruleIndex === undefined ? -1 : ruleIndex; - this.predIndex = predIndex === undefined ? -1 : predIndex; - this.isCtxDependent = isCtxDependent === undefined ? false : isCtxDependent; // e.g., $i ref in pred - return this; -} - -Predicate.prototype = Object.create(SemanticContext.prototype); -Predicate.prototype.constructor = Predicate; - -//The default {@link SemanticContext}, which is semantically equivalent to -//a predicate of the form {@code {true}?}. -// -SemanticContext.NONE = new Predicate(); - - -Predicate.prototype.evaluate = function(parser, outerContext) { - var localctx = this.isCtxDependent ? outerContext : null; - return parser.sempred(localctx, this.ruleIndex, this.predIndex); -}; - -Predicate.prototype.updateHashCode = function(hash) { - hash.update(this.ruleIndex, this.predIndex, this.isCtxDependent); -}; - -Predicate.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (!(other instanceof Predicate)) { - return false; - } else { - return this.ruleIndex === other.ruleIndex && - this.predIndex === other.predIndex && - this.isCtxDependent === other.isCtxDependent; - } -}; - -Predicate.prototype.toString = function() { - return "{" + this.ruleIndex + ":" + this.predIndex + "}?"; -}; - -function PrecedencePredicate(precedence) { - SemanticContext.call(this); - this.precedence = precedence === undefined ? 0 : precedence; -} - -PrecedencePredicate.prototype = Object.create(SemanticContext.prototype); -PrecedencePredicate.prototype.constructor = PrecedencePredicate; - -PrecedencePredicate.prototype.evaluate = function(parser, outerContext) { - return parser.precpred(outerContext, this.precedence); -}; - -PrecedencePredicate.prototype.evalPrecedence = function(parser, outerContext) { - if (parser.precpred(outerContext, this.precedence)) { - return SemanticContext.NONE; - } else { - return null; - } -}; - -PrecedencePredicate.prototype.compareTo = function(other) { - return this.precedence - other.precedence; -}; - -PrecedencePredicate.prototype.updateHashCode = function(hash) { - hash.update(31); -}; - -PrecedencePredicate.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (!(other instanceof PrecedencePredicate)) { - return false; - } else { - return this.precedence === other.precedence; - } -}; - -PrecedencePredicate.prototype.toString = function() { - return "{"+this.precedence+">=prec}?"; -}; - - - -PrecedencePredicate.filterPrecedencePredicates = function(set) { - var result = []; - set.values().map( function(context) { - if (context instanceof PrecedencePredicate) { - result.push(context); - } - }); - return result; -}; - - -// A semantic context which is true whenever none of the contained contexts -// is false. -// -function AND(a, b) { - SemanticContext.call(this); - var operands = new Set(); - if (a instanceof AND) { - a.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(a); - } - if (b instanceof AND) { - b.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(b); - } - var precedencePredicates = PrecedencePredicate.filterPrecedencePredicates(operands); - if (precedencePredicates.length > 0) { - // interested in the transition with the lowest precedence - var reduced = null; - precedencePredicates.map( function(p) { - if(reduced===null || p.precedence -// The evaluation of predicates by this context is short-circuiting, but -// unordered.

          -// -AND.prototype.evaluate = function(parser, outerContext) { - for (var i = 0; i < this.opnds.length; i++) { - if (!this.opnds[i].evaluate(parser, outerContext)) { - return false; - } - } - return true; -}; - -AND.prototype.evalPrecedence = function(parser, outerContext) { - var differs = false; - var operands = []; - for (var i = 0; i < this.opnds.length; i++) { - var context = this.opnds[i]; - var evaluated = context.evalPrecedence(parser, outerContext); - differs |= (evaluated !== context); - if (evaluated === null) { - // The AND context is false if any element is false - return null; - } else if (evaluated !== SemanticContext.NONE) { - // Reduce the result by skipping true elements - operands.push(evaluated); - } - } - if (!differs) { - return this; - } - if (operands.length === 0) { - // all elements were true, so the AND context is true - return SemanticContext.NONE; - } - var result = null; - operands.map(function(o) { - result = result === null ? o : SemanticContext.andContext(result, o); - }); - return result; -}; - -AND.prototype.toString = function() { - var s = ""; - this.opnds.map(function(o) { - s += "&& " + o.toString(); - }); - return s.length > 3 ? s.slice(3) : s; -}; - -// -// A semantic context which is true whenever at least one of the contained -// contexts is true. -// -function OR(a, b) { - SemanticContext.call(this); - var operands = new Set(); - if (a instanceof OR) { - a.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(a); - } - if (b instanceof OR) { - b.opnds.map(function(o) { - operands.add(o); - }); - } else { - operands.add(b); - } - - var precedencePredicates = PrecedencePredicate.filterPrecedencePredicates(operands); - if (precedencePredicates.length > 0) { - // interested in the transition with the highest precedence - var s = precedencePredicates.sort(function(a, b) { - return a.compareTo(b); - }); - var reduced = s[s.length-1]; - operands.add(reduced); - } - this.opnds = operands.values(); - return this; -} - -OR.prototype = Object.create(SemanticContext.prototype); -OR.prototype.constructor = OR; - -OR.prototype.constructor = function(other) { - if (this === other) { - return true; - } else if (!(other instanceof OR)) { - return false; - } else { - return this.opnds === other.opnds; - } -}; - -OR.prototype.updateHashCode = function(hash) { - hash.update(this.opnds, "OR"); -}; - -//

          -// The evaluation of predicates by this context is short-circuiting, but -// unordered.

          -// -OR.prototype.evaluate = function(parser, outerContext) { - for (var i = 0; i < this.opnds.length; i++) { - if (this.opnds[i].evaluate(parser, outerContext)) { - return true; - } - } - return false; -}; - -OR.prototype.evalPrecedence = function(parser, outerContext) { - var differs = false; - var operands = []; - for (var i = 0; i < this.opnds.length; i++) { - var context = this.opnds[i]; - var evaluated = context.evalPrecedence(parser, outerContext); - differs |= (evaluated !== context); - if (evaluated === SemanticContext.NONE) { - // The OR context is true if any element is true - return SemanticContext.NONE; - } else if (evaluated !== null) { - // Reduce the result by skipping false elements - operands.push(evaluated); - } - } - if (!differs) { - return this; - } - if (operands.length === 0) { - // all elements were false, so the OR context is false - return null; - } - var result = null; - operands.map(function(o) { - return result === null ? o : SemanticContext.orContext(result, o); - }); - return result; -}; - -OR.prototype.toString = function() { - var s = ""; - this.opnds.map(function(o) { - s += "|| " + o.toString(); - }); - return s.length > 3 ? s.slice(3) : s; -}; - -exports.SemanticContext = SemanticContext; -exports.PrecedencePredicate = PrecedencePredicate; -exports.Predicate = Predicate; - - -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -var ATNConfigSet = __webpack_require__(9).ATNConfigSet; -var Utils = __webpack_require__(0); -var Hash = Utils.Hash; -var Set = Utils.Set; - -// Map a predicate to a predicted alternative./// - -function PredPrediction(pred, alt) { - this.alt = alt; - this.pred = pred; - return this; -} - -PredPrediction.prototype.toString = function() { - return "(" + this.pred + ", " + this.alt + ")"; -}; - -// A DFA state represents a set of possible ATN configurations. -// As Aho, Sethi, Ullman p. 117 says "The DFA uses its state -// to keep track of all possible states the ATN can be in after -// reading each input symbol. That is to say, after reading -// input a1a2..an, the DFA is in a state that represents the -// subset T of the states of the ATN that are reachable from the -// ATN's start state along some path labeled a1a2..an." -// In conventional NFA→DFA conversion, therefore, the subset T -// would be a bitset representing the set of states the -// ATN could be in. We need to track the alt predicted by each -// state as well, however. More importantly, we need to maintain -// a stack of states, tracking the closure operations as they -// jump from rule to rule, emulating rule invocations (method calls). -// I have to add a stack to simulate the proper lookahead sequences for -// the underlying LL grammar from which the ATN was derived. -// -//

          I use a set of ATNConfig objects not simple states. An ATNConfig -// is both a state (ala normal conversion) and a RuleContext describing -// the chain of rules (if any) followed to arrive at that state.

          -// -//

          A DFA state may have multiple references to a particular state, -// but with different ATN contexts (with same or different alts) -// meaning that state was reached via a different set of rule invocations.

          -// / - -function DFAState(stateNumber, configs) { - if (stateNumber === null) { - stateNumber = -1; - } - if (configs === null) { - configs = new ATNConfigSet(); - } - this.stateNumber = stateNumber; - this.configs = configs; - // {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1) - // {@link Token//EOF} maps to {@code edges[0]}. - this.edges = null; - this.isAcceptState = false; - // if accept state, what ttype do we match or alt do we predict? - // This is set to {@link ATN//INVALID_ALT_NUMBER} when {@link - // //predicates}{@code !=null} or - // {@link //requiresFullContext}. - this.prediction = 0; - this.lexerActionExecutor = null; - // Indicates that this state was created during SLL prediction that - // discovered a conflict between the configurations in the state. Future - // {@link ParserATNSimulator//execATN} invocations immediately jumped doing - // full context prediction if this field is true. - this.requiresFullContext = false; - // During SLL parsing, this is a list of predicates associated with the - // ATN configurations of the DFA state. When we have predicates, - // {@link //requiresFullContext} is {@code false} since full context - // prediction evaluates predicates - // on-the-fly. If this is not null, then {@link //prediction} is - // {@link ATN//INVALID_ALT_NUMBER}. - // - //

          We only use these for non-{@link //requiresFullContext} but - // conflicting states. That - // means we know from the context (it's $ or we don't dip into outer - // context) that it's an ambiguity not a conflict.

          - // - //

          This list is computed by {@link - // ParserATNSimulator//predicateDFAState}.

          - this.predicates = null; - return this; -} - -// Get the set of all alts mentioned by all ATN configurations in this -// DFA state. -DFAState.prototype.getAltSet = function() { - var alts = new Set(); - if (this.configs !== null) { - for (var i = 0; i < this.configs.length; i++) { - var c = this.configs[i]; - alts.add(c.alt); - } - } - if (alts.length === 0) { - return null; - } else { - return alts; - } -}; - -// Two {@link DFAState} instances are equal if their ATN configuration sets -// are the same. This method is used to see if a state already exists. -// -//

          Because the number of alternatives and number of ATN configurations are -// finite, there is a finite number of DFA states that can be processed. -// This is necessary to show that the algorithm terminates.

          -// -//

          Cannot test the DFA state numbers here because in -// {@link ParserATNSimulator//addDFAState} we need to know if any other state -// exists that has this exact set of ATN configurations. The -// {@link //stateNumber} is irrelevant.

          -DFAState.prototype.equals = function(other) { - // compare set of ATN configurations in this set with other - return this === other || - (other instanceof DFAState && - this.configs.equals(other.configs)); -}; - -DFAState.prototype.toString = function() { - var s = "" + this.stateNumber + ":" + this.configs; - if(this.isAcceptState) { - s = s + "=>"; - if (this.predicates !== null) - s = s + this.predicates; - else - s = s + this.prediction; - } - return s; -}; - -DFAState.prototype.hashCode = function() { - var hash = new Hash(); - hash.update(this.configs); - return hash.finish(); -}; - -exports.DFAState = DFAState; -exports.PredPrediction = PredPrediction; - - -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -exports.atn = __webpack_require__(35); -exports.codepointat = __webpack_require__(27); -exports.dfa = __webpack_require__(42); -exports.fromcodepoint = __webpack_require__(28); -exports.tree = __webpack_require__(44); -exports.error = __webpack_require__(45); -exports.Token = __webpack_require__(1).Token; -exports.CharStreams = __webpack_require__(47).CharStreams; -exports.CommonToken = __webpack_require__(1).CommonToken; -exports.InputStream = __webpack_require__(19).InputStream; -exports.FileStream = __webpack_require__(48).FileStream; -exports.CommonTokenStream = __webpack_require__(49).CommonTokenStream; -exports.Lexer = __webpack_require__(15).Lexer; -exports.Parser = __webpack_require__(51).Parser; -var pc = __webpack_require__(6); -exports.PredictionContextCache = pc.PredictionContextCache; -exports.ParserRuleContext = __webpack_require__(18).ParserRuleContext; -exports.Interval = __webpack_require__(2).Interval; -exports.Utils = __webpack_require__(0); - - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -// A tuple: (ATN state, predicted alt, syntactic, semantic context). -// The syntactic context is a graph-structured stack node whose -// path(s) to the root is the rule invocation(s) -// chain used to arrive at the state. The semantic context is -// the tree of semantic predicates encountered before reaching -// an ATN state. -/// - -var DecisionState = __webpack_require__(3).DecisionState; -var SemanticContext = __webpack_require__(10).SemanticContext; -var Hash = __webpack_require__(0).Hash; - - -function checkParams(params, isCfg) { - if(params===null) { - var result = { state:null, alt:null, context:null, semanticContext:null }; - if(isCfg) { - result.reachesIntoOuterContext = 0; - } - return result; - } else { - var props = {}; - props.state = params.state || null; - props.alt = (params.alt === undefined) ? null : params.alt; - props.context = params.context || null; - props.semanticContext = params.semanticContext || null; - if(isCfg) { - props.reachesIntoOuterContext = params.reachesIntoOuterContext || 0; - props.precedenceFilterSuppressed = params.precedenceFilterSuppressed || false; - } - return props; - } -} - -function ATNConfig(params, config) { - this.checkContext(params, config); - params = checkParams(params); - config = checkParams(config, true); - // The ATN state associated with this configuration/// - this.state = params.state!==null ? params.state : config.state; - // What alt (or lexer rule) is predicted by this configuration/// - this.alt = params.alt!==null ? params.alt : config.alt; - // The stack of invoking states leading to the rule/states associated - // with this config. We track only those contexts pushed during - // execution of the ATN simulator. - this.context = params.context!==null ? params.context : config.context; - this.semanticContext = params.semanticContext!==null ? params.semanticContext : - (config.semanticContext!==null ? config.semanticContext : SemanticContext.NONE); - // We cannot execute predicates dependent upon local context unless - // we know for sure we are in the correct context. Because there is - // no way to do this efficiently, we simply cannot evaluate - // dependent predicates unless we are in the rule that initially - // invokes the ATN simulator. - // - // closure() tracks the depth of how far we dip into the - // outer context: depth > 0. Note that it may not be totally - // accurate depth since I don't ever decrement. TODO: make it a boolean then - this.reachesIntoOuterContext = config.reachesIntoOuterContext; - this.precedenceFilterSuppressed = config.precedenceFilterSuppressed; - return this; -} - -ATNConfig.prototype.checkContext = function(params, config) { - if((params.context===null || params.context===undefined) && - (config===null || config.context===null || config.context===undefined)) { - this.context = null; - } -}; - - -ATNConfig.prototype.hashCode = function() { - var hash = new Hash(); - this.updateHashCode(hash); - return hash.finish(); -}; - - -ATNConfig.prototype.updateHashCode = function(hash) { - hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext); -}; - -// An ATN configuration is equal to another if both have -// the same state, they predict the same alternative, and -// syntactic/semantic contexts are the same. - -ATNConfig.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof ATNConfig)) { - return false; - } else { - return this.state.stateNumber===other.state.stateNumber && - this.alt===other.alt && - (this.context===null ? other.context===null : this.context.equals(other.context)) && - this.semanticContext.equals(other.semanticContext) && - this.precedenceFilterSuppressed===other.precedenceFilterSuppressed; - } -}; - - -ATNConfig.prototype.hashCodeForConfigSet = function() { - var hash = new Hash(); - hash.update(this.state.stateNumber, this.alt, this.semanticContext); - return hash.finish(); -}; - - -ATNConfig.prototype.equalsForConfigSet = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof ATNConfig)) { - return false; - } else { - return this.state.stateNumber===other.state.stateNumber && - this.alt===other.alt && - this.semanticContext.equals(other.semanticContext); - } -}; - - -ATNConfig.prototype.toString = function() { - return "(" + this.state + "," + this.alt + - (this.context!==null ? ",[" + this.context.toString() + "]" : "") + - (this.semanticContext !== SemanticContext.NONE ? - ("," + this.semanticContext.toString()) - : "") + - (this.reachesIntoOuterContext>0 ? - (",up=" + this.reachesIntoOuterContext) - : "") + ")"; -}; - - -function LexerATNConfig(params, config) { - ATNConfig.call(this, params, config); - - // This is the backing field for {@link //getLexerActionExecutor}. - var lexerActionExecutor = params.lexerActionExecutor || null; - this.lexerActionExecutor = lexerActionExecutor || (config!==null ? config.lexerActionExecutor : null); - this.passedThroughNonGreedyDecision = config!==null ? this.checkNonGreedyDecision(config, this.state) : false; - return this; -} - -LexerATNConfig.prototype = Object.create(ATNConfig.prototype); -LexerATNConfig.prototype.constructor = LexerATNConfig; - -LexerATNConfig.prototype.updateHashCode = function(hash) { - hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext, this.passedThroughNonGreedyDecision, this.lexerActionExecutor); -}; - -LexerATNConfig.prototype.equals = function(other) { - return this === other || - (other instanceof LexerATNConfig && - this.passedThroughNonGreedyDecision == other.passedThroughNonGreedyDecision && - (this.lexerActionExecutor ? this.lexerActionExecutor.equals(other.lexerActionExecutor) : !other.lexerActionExecutor) && - ATNConfig.prototype.equals.call(this, other)); -}; - -LexerATNConfig.prototype.hashCodeForConfigSet = LexerATNConfig.prototype.hashCode; - -LexerATNConfig.prototype.equalsForConfigSet = LexerATNConfig.prototype.equals; - - -LexerATNConfig.prototype.checkNonGreedyDecision = function(source, target) { - return source.passedThroughNonGreedyDecision || - (target instanceof DecisionState) && target.nonGreedy; -}; - -exports.ATNConfig = ATNConfig; -exports.LexerATNConfig = LexerATNConfig; - -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -// A rule context is a record of a single rule invocation. It knows -// which context invoked it, if any. If there is no parent context, then -// naturally the invoking state is not valid. The parent link -// provides a chain upwards from the current rule invocation to the root -// of the invocation tree, forming a stack. We actually carry no -// information about the rule associated with this context (except -// when parsing). We keep only the state number of the invoking state from -// the ATN submachine that invoked this. Contrast this with the s -// pointer inside ParserRuleContext that tracks the current state -// being "executed" for the current rule. -// -// The parent contexts are useful for computing lookahead sets and -// getting error information. -// -// These objects are used during parsing and prediction. -// For the special case of parsers, we use the subclass -// ParserRuleContext. -// -// @see ParserRuleContext -/// - -var RuleNode = __webpack_require__(4).RuleNode; -var INVALID_INTERVAL = __webpack_require__(4).INVALID_INTERVAL; -var INVALID_ALT_NUMBER = __webpack_require__(7).INVALID_ALT_NUMBER; - -function RuleContext(parent, invokingState) { - RuleNode.call(this); - // What context invoked this rule? - this.parentCtx = parent || null; - // What state invoked the rule associated with this context? - // The "return address" is the followState of invokingState - // If parent is null, this should be -1. - this.invokingState = invokingState || -1; - return this; -} - -RuleContext.prototype = Object.create(RuleNode.prototype); -RuleContext.prototype.constructor = RuleContext; - -RuleContext.prototype.depth = function() { - var n = 0; - var p = this; - while (p !== null) { - p = p.parentCtx; - n += 1; - } - return n; -}; - -// A context is empty if there is no invoking state; meaning nobody call -// current context. -RuleContext.prototype.isEmpty = function() { - return this.invokingState === -1; -}; - -// satisfy the ParseTree / SyntaxTree interface - -RuleContext.prototype.getSourceInterval = function() { - return INVALID_INTERVAL; -}; - -RuleContext.prototype.getRuleContext = function() { - return this; -}; - -RuleContext.prototype.getPayload = function() { - return this; -}; - -// Return the combined text of all child nodes. This method only considers -// tokens which have been added to the parse tree. -//

          -// Since tokens on hidden channels (e.g. whitespace or comments) are not -// added to the parse trees, they will not appear in the output of this -// method. -// / -RuleContext.prototype.getText = function() { - if (this.getChildCount() === 0) { - return ""; - } else { - return this.children.map(function(child) { - return child.getText(); - }).join(""); - } -}; - -// For rule associated with this parse tree internal node, return -// the outer alternative number used to match the input. Default -// implementation does not compute nor store this alt num. Create -// a subclass of ParserRuleContext with backing field and set -// option contextSuperClass. -// to set it. -RuleContext.prototype.getAltNumber = function() { return INVALID_ALT_NUMBER; } - -// Set the outer alternative number for this context node. Default -// implementation does nothing to avoid backing field overhead for -// trees that don't need it. Create -// a subclass of ParserRuleContext with backing field and set -// option contextSuperClass. -RuleContext.prototype.setAltNumber = function(altNumber) { } - -RuleContext.prototype.getChild = function(i) { - return null; -}; - -RuleContext.prototype.getChildCount = function() { - return 0; -}; - -RuleContext.prototype.accept = function(visitor) { - return visitor.visitChildren(this); -}; - -//need to manage circular dependencies, so export now -exports.RuleContext = RuleContext; -var Trees = __webpack_require__(20).Trees; - - -// Print out a whole tree, not just a node, in LISP format -// (root child1 .. childN). Print just a node if this is a leaf. -// - -RuleContext.prototype.toStringTree = function(ruleNames, recog) { - return Trees.toStringTree(this, ruleNames, recog); -}; - -RuleContext.prototype.toString = function(ruleNames, stop) { - ruleNames = ruleNames || null; - stop = stop || null; - var p = this; - var s = "["; - while (p !== null && p !== stop) { - if (ruleNames === null) { - if (!p.isEmpty()) { - s += p.invokingState; - } - } else { - var ri = p.ruleIndex; - var ruleName = (ri >= 0 && ri < ruleNames.length) ? ruleNames[ri] - : "" + ri; - s += ruleName; - } - if (p.parentCtx !== null && (ruleNames !== null || !p.parentCtx.isEmpty())) { - s += " "; - } - p = p.parentCtx; - } - s += "]"; - return s; -}; - - - -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -// A lexer is recognizer that draws input symbols from a character stream. -// lexer grammars result in a subclass of this object. A Lexer object -// uses simplified match() and error recovery mechanisms in the interest of speed. - -var Token = __webpack_require__(1).Token; -var Recognizer = __webpack_require__(24).Recognizer; -var CommonTokenFactory = __webpack_require__(39).CommonTokenFactory; -var RecognitionException = __webpack_require__(5).RecognitionException; -var LexerNoViableAltException = __webpack_require__(5).LexerNoViableAltException; - -function TokenSource() { - return this; -} - -function Lexer(input) { - Recognizer.call(this); - this._input = input; - this._factory = CommonTokenFactory.DEFAULT; - this._tokenFactorySourcePair = [ this, input ]; - - this._interp = null; // child classes must populate this - - // The goal of all lexer rules/methods is to create a token object. - // this is an instance variable as multiple rules may collaborate to - // create a single token. nextToken will return this object after - // matching lexer rule(s). If you subclass to allow multiple token - // emissions, then set this to the last token to be matched or - // something nonnull so that the auto token emit mechanism will not - // emit another token. - this._token = null; - - // What character index in the stream did the current token start at? - // Needed, for example, to get the text for current token. Set at - // the start of nextToken. - this._tokenStartCharIndex = -1; - - // The line on which the first character of the token resides/// - this._tokenStartLine = -1; - - // The character position of first character within the line/// - this._tokenStartColumn = -1; - - // Once we see EOF on char stream, next token will be EOF. - // If you have DONE : EOF ; then you see DONE EOF. - this._hitEOF = false; - - // The channel number for the current token/// - this._channel = Token.DEFAULT_CHANNEL; - - // The token type for the current token/// - this._type = Token.INVALID_TYPE; - - this._modeStack = []; - this._mode = Lexer.DEFAULT_MODE; - - // You can set the text for the current token to override what is in - // the input char buffer. Use setText() or can set this instance var. - // / - this._text = null; - - return this; -} - -Lexer.prototype = Object.create(Recognizer.prototype); -Lexer.prototype.constructor = Lexer; - -Lexer.DEFAULT_MODE = 0; -Lexer.MORE = -2; -Lexer.SKIP = -3; - -Lexer.DEFAULT_TOKEN_CHANNEL = Token.DEFAULT_CHANNEL; -Lexer.HIDDEN = Token.HIDDEN_CHANNEL; -Lexer.MIN_CHAR_VALUE = 0x0000; -Lexer.MAX_CHAR_VALUE = 0x10FFFF; - -Lexer.prototype.reset = function() { - // wack Lexer state variables - if (this._input !== null) { - this._input.seek(0); // rewind the input - } - this._token = null; - this._type = Token.INVALID_TYPE; - this._channel = Token.DEFAULT_CHANNEL; - this._tokenStartCharIndex = -1; - this._tokenStartColumn = -1; - this._tokenStartLine = -1; - this._text = null; - - this._hitEOF = false; - this._mode = Lexer.DEFAULT_MODE; - this._modeStack = []; - - this._interp.reset(); -}; - -// Return a token from this source; i.e., match a token on the char stream. -Lexer.prototype.nextToken = function() { - if (this._input === null) { - throw "nextToken requires a non-null input stream."; - } - - // Mark start location in char stream so unbuffered streams are - // guaranteed at least have text of current token - var tokenStartMarker = this._input.mark(); - try { - while (true) { - if (this._hitEOF) { - this.emitEOF(); - return this._token; - } - this._token = null; - this._channel = Token.DEFAULT_CHANNEL; - this._tokenStartCharIndex = this._input.index; - this._tokenStartColumn = this._interp.column; - this._tokenStartLine = this._interp.line; - this._text = null; - var continueOuter = false; - while (true) { - this._type = Token.INVALID_TYPE; - var ttype = Lexer.SKIP; - try { - ttype = this._interp.match(this._input, this._mode); - } catch (e) { - if(e instanceof RecognitionException) { - this.notifyListeners(e); // report error - this.recover(e); - } else { - console.log(e.stack); - throw e; - } - } - if (this._input.LA(1) === Token.EOF) { - this._hitEOF = true; - } - if (this._type === Token.INVALID_TYPE) { - this._type = ttype; - } - if (this._type === Lexer.SKIP) { - continueOuter = true; - break; - } - if (this._type !== Lexer.MORE) { - break; - } - } - if (continueOuter) { - continue; - } - if (this._token === null) { - this.emit(); - } - return this._token; - } - } finally { - // make sure we release marker after match or - // unbuffered char stream will keep buffering - this._input.release(tokenStartMarker); - } -}; - -// Instruct the lexer to skip creating a token for current lexer rule -// and look for another token. nextToken() knows to keep looking when -// a lexer rule finishes with token set to SKIP_TOKEN. Recall that -// if token==null at end of any token rule, it creates one for you -// and emits it. -// / -Lexer.prototype.skip = function() { - this._type = Lexer.SKIP; -}; - -Lexer.prototype.more = function() { - this._type = Lexer.MORE; -}; - -Lexer.prototype.mode = function(m) { - this._mode = m; -}; - -Lexer.prototype.pushMode = function(m) { - if (this._interp.debug) { - console.log("pushMode " + m); - } - this._modeStack.push(this._mode); - this.mode(m); -}; - -Lexer.prototype.popMode = function() { - if (this._modeStack.length === 0) { - throw "Empty Stack"; - } - if (this._interp.debug) { - console.log("popMode back to " + this._modeStack.slice(0, -1)); - } - this.mode(this._modeStack.pop()); - return this._mode; -}; - -// Set the char stream and reset the lexer -Object.defineProperty(Lexer.prototype, "inputStream", { - get : function() { - return this._input; - }, - set : function(input) { - this._input = null; - this._tokenFactorySourcePair = [ this, this._input ]; - this.reset(); - this._input = input; - this._tokenFactorySourcePair = [ this, this._input ]; - } -}); - -Object.defineProperty(Lexer.prototype, "sourceName", { - get : function sourceName() { - return this._input.sourceName; - } -}); - -// By default does not support multiple emits per nextToken invocation -// for efficiency reasons. Subclass and override this method, nextToken, -// and getToken (to push tokens into a list and pull from that list -// rather than a single variable as this implementation does). -// / -Lexer.prototype.emitToken = function(token) { - this._token = token; -}; - -// The standard method called to automatically emit a token at the -// outermost lexical rule. The token object should point into the -// char buffer start..stop. If there is a text override in 'text', -// use that to set the token's text. Override this method to emit -// custom Token objects or provide a new factory. -// / -Lexer.prototype.emit = function() { - var t = this._factory.create(this._tokenFactorySourcePair, this._type, - this._text, this._channel, this._tokenStartCharIndex, this - .getCharIndex() - 1, this._tokenStartLine, - this._tokenStartColumn); - this.emitToken(t); - return t; -}; - -Lexer.prototype.emitEOF = function() { - var cpos = this.column; - var lpos = this.line; - var eof = this._factory.create(this._tokenFactorySourcePair, Token.EOF, - null, Token.DEFAULT_CHANNEL, this._input.index, - this._input.index - 1, lpos, cpos); - this.emitToken(eof); - return eof; -}; - -Object.defineProperty(Lexer.prototype, "type", { - get : function() { - return this.type; - }, - set : function(type) { - this._type = type; - } -}); - -Object.defineProperty(Lexer.prototype, "line", { - get : function() { - return this._interp.line; - }, - set : function(line) { - this._interp.line = line; - } -}); - -Object.defineProperty(Lexer.prototype, "column", { - get : function() { - return this._interp.column; - }, - set : function(column) { - this._interp.column = column; - } -}); - - -// What is the index of the current character of lookahead?/// -Lexer.prototype.getCharIndex = function() { - return this._input.index; -}; - -// Return the text matched so far for the current token or any text override. -//Set the complete text of this token; it wipes any previous changes to the text. -Object.defineProperty(Lexer.prototype, "text", { - get : function() { - if (this._text !== null) { - return this._text; - } else { - return this._interp.getText(this._input); - } - }, - set : function(text) { - this._text = text; - } -}); -// Return a list of all Token objects in input char stream. -// Forces load of all tokens. Does not include EOF token. -// / -Lexer.prototype.getAllTokens = function() { - var tokens = []; - var t = this.nextToken(); - while (t.type !== Token.EOF) { - tokens.push(t); - t = this.nextToken(); - } - return tokens; -}; - -Lexer.prototype.notifyListeners = function(e) { - var start = this._tokenStartCharIndex; - var stop = this._input.index; - var text = this._input.getText(start, stop); - var msg = "token recognition error at: '" + this.getErrorDisplay(text) + "'"; - var listener = this.getErrorListenerDispatch(); - listener.syntaxError(this, null, this._tokenStartLine, - this._tokenStartColumn, msg, e); -}; - -Lexer.prototype.getErrorDisplay = function(s) { - var d = []; - for (var i = 0; i < s.length; i++) { - d.push(s[i]); - } - return d.join(''); -}; - -Lexer.prototype.getErrorDisplayForChar = function(c) { - if (c.charCodeAt(0) === Token.EOF) { - return ""; - } else if (c === '\n') { - return "\\n"; - } else if (c === '\t') { - return "\\t"; - } else if (c === '\r') { - return "\\r"; - } else { - return c; - } -}; - -Lexer.prototype.getCharErrorDisplay = function(c) { - return "'" + this.getErrorDisplayForChar(c) + "'"; -}; - -// Lexers can normally match any char in it's vocabulary after matching -// a token, so do the easy thing and just kill a character and hope -// it all works out. You can instead use the rule invocation stack -// to do sophisticated error recovery if you are in a fragment rule. -// / -Lexer.prototype.recover = function(re) { - if (this._input.LA(1) !== Token.EOF) { - if (re instanceof LexerNoViableAltException) { - // skip a char and try again - this._interp.consume(this._input); - } else { - // TODO: Do we lose character or line position information? - this._input.consume(); - } - } -}; - -exports.Lexer = Lexer; - - -/***/ }), -/* 16 */ -/***/ (function(module, exports) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -// Provides an empty default implementation of {@link ANTLRErrorListener}. The -// default implementation of each method does nothing, but can be overridden as -// necessary. - -function ErrorListener() { - return this; -} - -ErrorListener.prototype.syntaxError = function(recognizer, offendingSymbol, line, column, msg, e) { -}; - -ErrorListener.prototype.reportAmbiguity = function(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { -}; - -ErrorListener.prototype.reportAttemptingFullContext = function(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { -}; - -ErrorListener.prototype.reportContextSensitivity = function(recognizer, dfa, startIndex, stopIndex, prediction, configs) { -}; - -function ConsoleErrorListener() { - ErrorListener.call(this); - return this; -} - -ConsoleErrorListener.prototype = Object.create(ErrorListener.prototype); -ConsoleErrorListener.prototype.constructor = ConsoleErrorListener; - -// -// Provides a default instance of {@link ConsoleErrorListener}. -// -ConsoleErrorListener.INSTANCE = new ConsoleErrorListener(); - -// -// {@inheritDoc} -// -//

          -// This implementation prints messages to {@link System//err} containing the -// values of {@code line}, {@code charPositionInLine}, and {@code msg} using -// the following format.

          -// -//
          -// line line:charPositionInLine msg
          -// 
          -// -ConsoleErrorListener.prototype.syntaxError = function(recognizer, offendingSymbol, line, column, msg, e) { - console.error("line " + line + ":" + column + " " + msg); -}; - -function ProxyErrorListener(delegates) { - ErrorListener.call(this); - if (delegates===null) { - throw "delegates"; - } - this.delegates = delegates; - return this; -} - -ProxyErrorListener.prototype = Object.create(ErrorListener.prototype); -ProxyErrorListener.prototype.constructor = ProxyErrorListener; - -ProxyErrorListener.prototype.syntaxError = function(recognizer, offendingSymbol, line, column, msg, e) { - this.delegates.map(function(d) { d.syntaxError(recognizer, offendingSymbol, line, column, msg, e); }); -}; - -ProxyErrorListener.prototype.reportAmbiguity = function(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) { - this.delegates.map(function(d) { d.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs); }); -}; - -ProxyErrorListener.prototype.reportAttemptingFullContext = function(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { - this.delegates.map(function(d) { d.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs); }); -}; - -ProxyErrorListener.prototype.reportContextSensitivity = function(recognizer, dfa, startIndex, stopIndex, prediction, configs) { - this.delegates.map(function(d) { d.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs); }); -}; - -exports.ErrorListener = ErrorListener; -exports.ConsoleErrorListener = ConsoleErrorListener; -exports.ProxyErrorListener = ProxyErrorListener; - - - -/***/ }), -/* 17 */ -/***/ (function(module, exports) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -// A DFA walker that knows how to dump them to serialized strings.#/ - - -function DFASerializer(dfa, literalNames, symbolicNames) { - this.dfa = dfa; - this.literalNames = literalNames || []; - this.symbolicNames = symbolicNames || []; - return this; -} - -DFASerializer.prototype.toString = function() { - if(this.dfa.s0 === null) { - return null; - } - var buf = ""; - var states = this.dfa.sortedStates(); - for(var i=0;i"); - buf = buf.concat(this.getStateString(t)); - buf = buf.concat('\n'); - } - } - } - } - return buf.length===0 ? null : buf; -}; - -DFASerializer.prototype.getEdgeLabel = function(i) { - if (i===0) { - return "EOF"; - } else if(this.literalNames !==null || this.symbolicNames!==null) { - return this.literalNames[i-1] || this.symbolicNames[i-1]; - } else { - return String.fromCharCode(i-1); - } -}; - -DFASerializer.prototype.getStateString = function(s) { - var baseStateStr = ( s.isAcceptState ? ":" : "") + "s" + s.stateNumber + ( s.requiresFullContext ? "^" : ""); - if(s.isAcceptState) { - if (s.predicates !== null) { - return baseStateStr + "=>" + s.predicates.toString(); - } else { - return baseStateStr + "=>" + s.prediction.toString(); - } - } else { - return baseStateStr; - } -}; - -function LexerDFASerializer(dfa) { - DFASerializer.call(this, dfa, null); - return this; -} - -LexerDFASerializer.prototype = Object.create(DFASerializer.prototype); -LexerDFASerializer.prototype.constructor = LexerDFASerializer; - -LexerDFASerializer.prototype.getEdgeLabel = function(i) { - return "'" + String.fromCharCode(i) + "'"; -}; - -exports.DFASerializer = DFASerializer; -exports.LexerDFASerializer = LexerDFASerializer; - - - -/***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -//* A rule invocation record for parsing. -// -// Contains all of the information about the current rule not stored in the -// RuleContext. It handles parse tree children list, Any ATN state -// tracing, and the default values available for rule indications: -// start, stop, rule index, current alt number, current -// ATN state. -// -// Subclasses made for each rule and grammar track the parameters, -// return values, locals, and labels specific to that rule. These -// are the objects that are returned from rules. -// -// Note text is not an actual field of a rule return value; it is computed -// from start and stop using the input stream's toString() method. I -// could add a ctor to this so that we can pass in and store the input -// stream, but I'm not sure we want to do that. It would seem to be undefined -// to get the .text property anyway if the rule matches tokens from multiple -// input streams. -// -// I do not use getters for fields of objects that are used simply to -// group values such as this aggregate. The getters/setters are there to -// satisfy the superclass interface. - -var RuleContext = __webpack_require__(14).RuleContext; -var Tree = __webpack_require__(4); -var INVALID_INTERVAL = Tree.INVALID_INTERVAL; -var TerminalNode = Tree.TerminalNode; -var TerminalNodeImpl = Tree.TerminalNodeImpl; -var ErrorNodeImpl = Tree.ErrorNodeImpl; -var Interval = __webpack_require__(2).Interval; - -function ParserRuleContext(parent, invokingStateNumber) { - parent = parent || null; - invokingStateNumber = invokingStateNumber || null; - RuleContext.call(this, parent, invokingStateNumber); - this.ruleIndex = -1; - // * If we are debugging or building a parse tree for a visitor, - // we need to track all of the tokens and rule invocations associated - // with this rule's context. This is empty for parsing w/o tree constr. - // operation because we don't the need to track the details about - // how we parse this rule. - // / - this.children = null; - this.start = null; - this.stop = null; - // The exception that forced this rule to return. If the rule successfully - // completed, this is {@code null}. - this.exception = null; -} - -ParserRuleContext.prototype = Object.create(RuleContext.prototype); -ParserRuleContext.prototype.constructor = ParserRuleContext; - -// * COPY a ctx (I'm deliberately not using copy constructor)/// -ParserRuleContext.prototype.copyFrom = function(ctx) { - // from RuleContext - this.parentCtx = ctx.parentCtx; - this.invokingState = ctx.invokingState; - this.children = null; - this.start = ctx.start; - this.stop = ctx.stop; - // copy any error nodes to alt label node - if(ctx.children) { - this.children = []; - // reset parent pointer for any error nodes - ctx.children.map(function(child) { - if (child instanceof ErrorNodeImpl) { - this.children.push(child); - child.parentCtx = this; - } - }, this); - } -}; - -// Double dispatch methods for listeners -ParserRuleContext.prototype.enterRule = function(listener) { -}; - -ParserRuleContext.prototype.exitRule = function(listener) { -}; - -// * Does not set parent link; other add methods do that/// -ParserRuleContext.prototype.addChild = function(child) { - if (this.children === null) { - this.children = []; - } - this.children.push(child); - return child; -}; - -// * Used by enterOuterAlt to toss out a RuleContext previously added as -// we entered a rule. If we have // label, we will need to remove -// generic ruleContext object. -// / -ParserRuleContext.prototype.removeLastChild = function() { - if (this.children !== null) { - this.children.pop(); - } -}; - -ParserRuleContext.prototype.addTokenNode = function(token) { - var node = new TerminalNodeImpl(token); - this.addChild(node); - node.parentCtx = this; - return node; -}; - -ParserRuleContext.prototype.addErrorNode = function(badToken) { - var node = new ErrorNodeImpl(badToken); - this.addChild(node); - node.parentCtx = this; - return node; -}; - -ParserRuleContext.prototype.getChild = function(i, type) { - type = type || null; - if (this.children === null || i < 0 || i >= this.children.length) { - return null; - } - if (type === null) { - return this.children[i]; - } else { - for(var j=0; j= this.children.length) { - return null; - } - for(var j=0; j= this._size) { - // assert this.LA(1) == Token.EOF - throw ("cannot consume EOF"); - } - this._index += 1; -}; - -InputStream.prototype.LA = function(offset) { - if (offset === 0) { - return 0; // undefined - } - if (offset < 0) { - offset += 1; // e.g., translate LA(-1) to use offset=0 - } - var pos = this._index + offset - 1; - if (pos < 0 || pos >= this._size) { // invalid - return Token.EOF; - } - return this.data[pos]; -}; - -InputStream.prototype.LT = function(offset) { - return this.LA(offset); -}; - -// mark/release do nothing; we have entire buffer -InputStream.prototype.mark = function() { - return -1; -}; - -InputStream.prototype.release = function(marker) { -}; - -// consume() ahead until p==_index; can't just set p=_index as we must -// update line and column. If we seek backwards, just set p -// -InputStream.prototype.seek = function(_index) { - if (_index <= this._index) { - this._index = _index; // just jump; don't update stream state (line, - // ...) - return; - } - // seek forward - this._index = Math.min(_index, this._size); -}; - -InputStream.prototype.getText = function(start, stop) { - if (stop >= this._size) { - stop = this._size - 1; - } - if (start >= this._size) { - return ""; - } else { - if (this.decodeToUnicodeCodePoints) { - var result = ""; - for (var i = start; i <= stop; i++) { - result += String.fromCodePoint(this.data[i]); - } - return result; - } else { - return this.strdata.slice(start, stop + 1); - } - } -}; - -InputStream.prototype.toString = function() { - return this.strdata; -}; - -exports.InputStream = InputStream; - - -/***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -var Utils = __webpack_require__(0); -var Token = __webpack_require__(1).Token; -var RuleNode = __webpack_require__(4).RuleNode; -var ErrorNode = __webpack_require__(4).ErrorNode; -var TerminalNode = __webpack_require__(4).TerminalNode; -var ParserRuleContext = __webpack_require__(18).ParserRuleContext; -var RuleContext = __webpack_require__(14).RuleContext; -var INVALID_ALT_NUMBER = __webpack_require__(7).INVALID_ALT_NUMBER; - - -/** A set of utility routines useful for all kinds of ANTLR trees. */ -function Trees() { -} - -// Print out a whole tree in LISP form. {@link //getNodeText} is used on the -// node payloads to get the text for the nodes. Detect -// parse trees and extract data appropriately. -Trees.toStringTree = function(tree, ruleNames, recog) { - ruleNames = ruleNames || null; - recog = recog || null; - if(recog!==null) { - ruleNames = recog.ruleNames; - } - var s = Trees.getNodeText(tree, ruleNames); - s = Utils.escapeWhitespace(s, false); - var c = tree.getChildCount(); - if(c===0) { - return s; - } - var res = "(" + s + ' '; - if(c>0) { - s = Trees.toStringTree(tree.getChild(0), ruleNames); - res = res.concat(s); - } - for(var i=1;i= idx1; -}; - -ATNDeserializer.prototype.deserialize = function(data) { - this.reset(data); - this.checkVersion(); - this.checkUUID(); - var atn = this.readATN(); - this.readStates(atn); - this.readRules(atn); - this.readModes(atn); - var sets = []; - // First, deserialize sets with 16-bit arguments <= U+FFFF. - this.readSets(atn, sets, this.readInt.bind(this)); - // Next, if the ATN was serialized with the Unicode SMP feature, - // deserialize sets with 32-bit arguments <= U+10FFFF. - if (this.isFeatureSupported(ADDED_UNICODE_SMP, this.uuid)) { - this.readSets(atn, sets, this.readInt32.bind(this)); - } - this.readEdges(atn, sets); - this.readDecisions(atn); - this.readLexerActions(atn); - this.markPrecedenceDecisions(atn); - this.verifyATN(atn); - if (this.deserializationOptions.generateRuleBypassTransitions && atn.grammarType === ATNType.PARSER ) { - this.generateRuleBypassTransitions(atn); - // re-verify after modification - this.verifyATN(atn); - } - return atn; -}; - -ATNDeserializer.prototype.reset = function(data) { - var adjust = function(c) { - var v = c.charCodeAt(0); - return v>1 ? v-2 : v + 65534; - }; - var temp = data.split("").map(adjust); - // don't adjust the first value since that's the version number - temp[0] = data.charCodeAt(0); - this.data = temp; - this.pos = 0; -}; - -ATNDeserializer.prototype.checkVersion = function() { - var version = this.readInt(); - if ( version !== SERIALIZED_VERSION ) { - throw ("Could not deserialize ATN with version " + version + " (expected " + SERIALIZED_VERSION + ")."); - } -}; - -ATNDeserializer.prototype.checkUUID = function() { - var uuid = this.readUUID(); - if (SUPPORTED_UUIDS.indexOf(uuid)<0) { - throw ("Could not deserialize ATN with UUID: " + uuid + - " (expected " + SERIALIZED_UUID + " or a legacy UUID).", uuid, SERIALIZED_UUID); - } - this.uuid = uuid; -}; - -ATNDeserializer.prototype.readATN = function() { - var grammarType = this.readInt(); - var maxTokenType = this.readInt(); - return new ATN(grammarType, maxTokenType); -}; - -ATNDeserializer.prototype.readStates = function(atn) { - var j, pair, stateNumber; - var loopBackStateNumbers = []; - var endStateNumbers = []; - var nstates = this.readInt(); - for(var i=0; i 0) { - bypassStart.addTransition(ruleToStartState.transitions[count-1]); - ruleToStartState.transitions = ruleToStartState.transitions.slice(-1); - } - // link the new states - atn.ruleToStartState[idx].addTransition(new EpsilonTransition(bypassStart)); - bypassStop.addTransition(new EpsilonTransition(endState)); - - var matchState = new BasicState(); - atn.addState(matchState); - matchState.addTransition(new AtomTransition(bypassStop, atn.ruleToTokenType[idx])); - bypassStart.addTransition(new EpsilonTransition(matchState)); -}; - -ATNDeserializer.prototype.stateIsEndStateFor = function(state, idx) { - if ( state.ruleIndex !== idx) { - return null; - } - if (!( state instanceof StarLoopEntryState)) { - return null; - } - var maybeLoopEndState = state.transitions[state.transitions.length - 1].target; - if (!( maybeLoopEndState instanceof LoopEndState)) { - return null; - } - if (maybeLoopEndState.epsilonOnlyTransitions && - (maybeLoopEndState.transitions[0].target instanceof RuleStopState)) { - return state; - } else { - return null; - } -}; - -// -// Analyze the {@link StarLoopEntryState} states in the specified ATN to set -// the {@link StarLoopEntryState//isPrecedenceDecision} field to the -// correct value. -// -// @param atn The ATN. -// -ATNDeserializer.prototype.markPrecedenceDecisions = function(atn) { - for(var i=0; i= 0); - } else { - this.checkCondition(state.transitions.length <= 1 || (state instanceof RuleStopState)); - } - } -}; - -ATNDeserializer.prototype.checkCondition = function(condition, message) { - if (!condition) { - if (message === undefined || message===null) { - message = "IllegalState"; - } - throw (message); - } -}; - -ATNDeserializer.prototype.readInt = function() { - return this.data[this.pos++]; -}; - -ATNDeserializer.prototype.readInt32 = function() { - var low = this.readInt(); - var high = this.readInt(); - return low | (high << 16); -}; - -ATNDeserializer.prototype.readLong = function() { - var low = this.readInt32(); - var high = this.readInt32(); - return (low & 0x00000000FFFFFFFF) | (high << 32); -}; - -function createByteToHex() { - var bth = []; - for (var i = 0; i < 256; i++) { - bth[i] = (i + 0x100).toString(16).substr(1).toUpperCase(); - } - return bth; -} - -var byteToHex = createByteToHex(); - -ATNDeserializer.prototype.readUUID = function() { - var bb = []; - for(var i=7;i>=0;i--) { - var int = this.readInt(); - /* jshint bitwise: false */ - bb[(2*i)+1] = int & 0xFF; - bb[2*i] = (int >> 8) & 0xFF; - } - return byteToHex[bb[0]] + byteToHex[bb[1]] + - byteToHex[bb[2]] + byteToHex[bb[3]] + '-' + - byteToHex[bb[4]] + byteToHex[bb[5]] + '-' + - byteToHex[bb[6]] + byteToHex[bb[7]] + '-' + - byteToHex[bb[8]] + byteToHex[bb[9]] + '-' + - byteToHex[bb[10]] + byteToHex[bb[11]] + - byteToHex[bb[12]] + byteToHex[bb[13]] + - byteToHex[bb[14]] + byteToHex[bb[15]]; -}; - -ATNDeserializer.prototype.edgeFactory = function(atn, type, src, trg, arg1, arg2, arg3, sets) { - var target = atn.states[trg]; - switch(type) { - case Transition.EPSILON: - return new EpsilonTransition(target); - case Transition.RANGE: - return arg3 !== 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2); - case Transition.RULE: - return new RuleTransition(atn.states[arg1], arg2, arg3, target); - case Transition.PREDICATE: - return new PredicateTransition(target, arg1, arg2, arg3 !== 0); - case Transition.PRECEDENCE: - return new PrecedencePredicateTransition(target, arg1); - case Transition.ATOM: - return arg3 !== 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1); - case Transition.ACTION: - return new ActionTransition(target, arg1, arg2, arg3 !== 0); - case Transition.SET: - return new SetTransition(target, sets[arg1]); - case Transition.NOT_SET: - return new NotSetTransition(target, sets[arg1]); - case Transition.WILDCARD: - return new WildcardTransition(target); - default: - throw "The specified transition type: " + type + " is not valid."; - } -}; - -ATNDeserializer.prototype.stateFactory = function(type, ruleIndex) { - if (this.stateFactories === null) { - var sf = []; - sf[ATNState.INVALID_TYPE] = null; - sf[ATNState.BASIC] = function() { return new BasicState(); }; - sf[ATNState.RULE_START] = function() { return new RuleStartState(); }; - sf[ATNState.BLOCK_START] = function() { return new BasicBlockStartState(); }; - sf[ATNState.PLUS_BLOCK_START] = function() { return new PlusBlockStartState(); }; - sf[ATNState.STAR_BLOCK_START] = function() { return new StarBlockStartState(); }; - sf[ATNState.TOKEN_START] = function() { return new TokensStartState(); }; - sf[ATNState.RULE_STOP] = function() { return new RuleStopState(); }; - sf[ATNState.BLOCK_END] = function() { return new BlockEndState(); }; - sf[ATNState.STAR_LOOP_BACK] = function() { return new StarLoopbackState(); }; - sf[ATNState.STAR_LOOP_ENTRY] = function() { return new StarLoopEntryState(); }; - sf[ATNState.PLUS_LOOP_BACK] = function() { return new PlusLoopbackState(); }; - sf[ATNState.LOOP_END] = function() { return new LoopEndState(); }; - this.stateFactories = sf; - } - if (type>this.stateFactories.length || this.stateFactories[type] === null) { - throw("The specified state type " + type + " is not valid."); - } else { - var s = this.stateFactories[type](); - if (s!==null) { - s.ruleIndex = ruleIndex; - return s; - } - } -}; - -ATNDeserializer.prototype.lexerActionFactory = function(type, data1, data2) { - if (this.actionFactories === null) { - var af = []; - af[LexerActionType.CHANNEL] = function(data1, data2) { return new LexerChannelAction(data1); }; - af[LexerActionType.CUSTOM] = function(data1, data2) { return new LexerCustomAction(data1, data2); }; - af[LexerActionType.MODE] = function(data1, data2) { return new LexerModeAction(data1); }; - af[LexerActionType.MORE] = function(data1, data2) { return LexerMoreAction.INSTANCE; }; - af[LexerActionType.POP_MODE] = function(data1, data2) { return LexerPopModeAction.INSTANCE; }; - af[LexerActionType.PUSH_MODE] = function(data1, data2) { return new LexerPushModeAction(data1); }; - af[LexerActionType.SKIP] = function(data1, data2) { return LexerSkipAction.INSTANCE; }; - af[LexerActionType.TYPE] = function(data1, data2) { return new LexerTypeAction(data1); }; - this.actionFactories = af; - } - if (type>this.actionFactories.length || this.actionFactories[type] === null) { - throw("The specified lexer action type " + type + " is not valid."); - } else { - return this.actionFactories[type](data1, data2); - } -}; - - -exports.ATNDeserializer = ATNDeserializer; - -/***/ }), -/* 22 */ -/***/ (function(module, exports) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -function ATNDeserializationOptions(copyFrom) { - if(copyFrom===undefined) { - copyFrom = null; - } - this.readOnly = false; - this.verifyATN = copyFrom===null ? true : copyFrom.verifyATN; - this.generateRuleBypassTransitions = copyFrom===null ? false : copyFrom.generateRuleBypassTransitions; - - return this; -} - -ATNDeserializationOptions.defaultOptions = new ATNDeserializationOptions(); -ATNDeserializationOptions.defaultOptions.readOnly = true; - -// def __setattr__(self, key, value): -// if key!="readOnly" and self.readOnly: -// raise Exception("The object is read only.") -// super(type(self), self).__setattr__(key,value) - -exports.ATNDeserializationOptions = ATNDeserializationOptions; - - -/***/ }), -/* 23 */ -/***/ (function(module, exports) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - // - -function LexerActionType() { -} - -LexerActionType.CHANNEL = 0; //The type of a {@link LexerChannelAction} action. -LexerActionType.CUSTOM = 1; //The type of a {@link LexerCustomAction} action. -LexerActionType.MODE = 2; //The type of a {@link LexerModeAction} action. -LexerActionType.MORE = 3; //The type of a {@link LexerMoreAction} action. -LexerActionType.POP_MODE = 4; //The type of a {@link LexerPopModeAction} action. -LexerActionType.PUSH_MODE = 5; //The type of a {@link LexerPushModeAction} action. -LexerActionType.SKIP = 6; //The type of a {@link LexerSkipAction} action. -LexerActionType.TYPE = 7; //The type of a {@link LexerTypeAction} action. - -function LexerAction(action) { - this.actionType = action; - this.isPositionDependent = false; - return this; -} - -LexerAction.prototype.hashCode = function() { - var hash = new Hash(); - this.updateHashCode(hash); - return hash.finish() -}; - -LexerAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType); -}; - -LexerAction.prototype.equals = function(other) { - return this === other; -}; - - - -// -// Implements the {@code skip} lexer action by calling {@link Lexer//skip}. -// -//

          The {@code skip} command does not have any parameters, so this action is -// implemented as a singleton instance exposed by {@link //INSTANCE}.

          -function LexerSkipAction() { - LexerAction.call(this, LexerActionType.SKIP); - return this; -} - -LexerSkipAction.prototype = Object.create(LexerAction.prototype); -LexerSkipAction.prototype.constructor = LexerSkipAction; - -// Provides a singleton instance of this parameterless lexer action. -LexerSkipAction.INSTANCE = new LexerSkipAction(); - -LexerSkipAction.prototype.execute = function(lexer) { - lexer.skip(); -}; - -LexerSkipAction.prototype.toString = function() { - return "skip"; -}; - -// Implements the {@code type} lexer action by calling {@link Lexer//setType} -// with the assigned type. -function LexerTypeAction(type) { - LexerAction.call(this, LexerActionType.TYPE); - this.type = type; - return this; -} - -LexerTypeAction.prototype = Object.create(LexerAction.prototype); -LexerTypeAction.prototype.constructor = LexerTypeAction; - -LexerTypeAction.prototype.execute = function(lexer) { - lexer.type = this.type; -}; - -LexerTypeAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType, this.type); -}; - - -LexerTypeAction.prototype.equals = function(other) { - if(this === other) { - return true; - } else if (! (other instanceof LexerTypeAction)) { - return false; - } else { - return this.type === other.type; - } -}; - -LexerTypeAction.prototype.toString = function() { - return "type(" + this.type + ")"; -}; - -// Implements the {@code pushMode} lexer action by calling -// {@link Lexer//pushMode} with the assigned mode. -function LexerPushModeAction(mode) { - LexerAction.call(this, LexerActionType.PUSH_MODE); - this.mode = mode; - return this; -} - -LexerPushModeAction.prototype = Object.create(LexerAction.prototype); -LexerPushModeAction.prototype.constructor = LexerPushModeAction; - -//

          This action is implemented by calling {@link Lexer//pushMode} with the -// value provided by {@link //getMode}.

          -LexerPushModeAction.prototype.execute = function(lexer) { - lexer.pushMode(this.mode); -}; - -LexerPushModeAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType, this.mode); -}; - -LexerPushModeAction.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerPushModeAction)) { - return false; - } else { - return this.mode === other.mode; - } -}; - -LexerPushModeAction.prototype.toString = function() { - return "pushMode(" + this.mode + ")"; -}; - - -// Implements the {@code popMode} lexer action by calling {@link Lexer//popMode}. -// -//

          The {@code popMode} command does not have any parameters, so this action is -// implemented as a singleton instance exposed by {@link //INSTANCE}.

          -function LexerPopModeAction() { - LexerAction.call(this,LexerActionType.POP_MODE); - return this; -} - -LexerPopModeAction.prototype = Object.create(LexerAction.prototype); -LexerPopModeAction.prototype.constructor = LexerPopModeAction; - -LexerPopModeAction.INSTANCE = new LexerPopModeAction(); - -//

          This action is implemented by calling {@link Lexer//popMode}.

          -LexerPopModeAction.prototype.execute = function(lexer) { - lexer.popMode(); -}; - -LexerPopModeAction.prototype.toString = function() { - return "popMode"; -}; - -// Implements the {@code more} lexer action by calling {@link Lexer//more}. -// -//

          The {@code more} command does not have any parameters, so this action is -// implemented as a singleton instance exposed by {@link //INSTANCE}.

          -function LexerMoreAction() { - LexerAction.call(this, LexerActionType.MORE); - return this; -} - -LexerMoreAction.prototype = Object.create(LexerAction.prototype); -LexerMoreAction.prototype.constructor = LexerMoreAction; - -LexerMoreAction.INSTANCE = new LexerMoreAction(); - -//

          This action is implemented by calling {@link Lexer//popMode}.

          -LexerMoreAction.prototype.execute = function(lexer) { - lexer.more(); -}; - -LexerMoreAction.prototype.toString = function() { - return "more"; -}; - - -// Implements the {@code mode} lexer action by calling {@link Lexer//mode} with -// the assigned mode. -function LexerModeAction(mode) { - LexerAction.call(this, LexerActionType.MODE); - this.mode = mode; - return this; -} - -LexerModeAction.prototype = Object.create(LexerAction.prototype); -LexerModeAction.prototype.constructor = LexerModeAction; - -//

          This action is implemented by calling {@link Lexer//mode} with the -// value provided by {@link //getMode}.

          -LexerModeAction.prototype.execute = function(lexer) { - lexer.mode(this.mode); -}; - -LexerModeAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType, this.mode); -}; - -LexerModeAction.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerModeAction)) { - return false; - } else { - return this.mode === other.mode; - } -}; - -LexerModeAction.prototype.toString = function() { - return "mode(" + this.mode + ")"; -}; - -// Executes a custom lexer action by calling {@link Recognizer//action} with the -// rule and action indexes assigned to the custom action. The implementation of -// a custom action is added to the generated code for the lexer in an override -// of {@link Recognizer//action} when the grammar is compiled. -// -//

          This class may represent embedded actions created with the {...} -// syntax in ANTLR 4, as well as actions created for lexer commands where the -// command argument could not be evaluated when the grammar was compiled.

          - - - // Constructs a custom lexer action with the specified rule and action - // indexes. - // - // @param ruleIndex The rule index to use for calls to - // {@link Recognizer//action}. - // @param actionIndex The action index to use for calls to - // {@link Recognizer//action}. - -function LexerCustomAction(ruleIndex, actionIndex) { - LexerAction.call(this, LexerActionType.CUSTOM); - this.ruleIndex = ruleIndex; - this.actionIndex = actionIndex; - this.isPositionDependent = true; - return this; -} - -LexerCustomAction.prototype = Object.create(LexerAction.prototype); -LexerCustomAction.prototype.constructor = LexerCustomAction; - -//

          Custom actions are implemented by calling {@link Lexer//action} with the -// appropriate rule and action indexes.

          -LexerCustomAction.prototype.execute = function(lexer) { - lexer.action(null, this.ruleIndex, this.actionIndex); -}; - -LexerCustomAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType, this.ruleIndex, this.actionIndex); -}; - -LexerCustomAction.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerCustomAction)) { - return false; - } else { - return this.ruleIndex === other.ruleIndex && this.actionIndex === other.actionIndex; - } -}; - -// Implements the {@code channel} lexer action by calling -// {@link Lexer//setChannel} with the assigned channel. -// Constructs a new {@code channel} action with the specified channel value. -// @param channel The channel value to pass to {@link Lexer//setChannel}. -function LexerChannelAction(channel) { - LexerAction.call(this, LexerActionType.CHANNEL); - this.channel = channel; - return this; -} - -LexerChannelAction.prototype = Object.create(LexerAction.prototype); -LexerChannelAction.prototype.constructor = LexerChannelAction; - -//

          This action is implemented by calling {@link Lexer//setChannel} with the -// value provided by {@link //getChannel}.

          -LexerChannelAction.prototype.execute = function(lexer) { - lexer._channel = this.channel; -}; - -LexerChannelAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType, this.channel); -}; - -LexerChannelAction.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerChannelAction)) { - return false; - } else { - return this.channel === other.channel; - } -}; - -LexerChannelAction.prototype.toString = function() { - return "channel(" + this.channel + ")"; -}; - -// This implementation of {@link LexerAction} is used for tracking input offsets -// for position-dependent actions within a {@link LexerActionExecutor}. -// -//

          This action is not serialized as part of the ATN, and is only required for -// position-dependent lexer actions which appear at a location other than the -// end of a rule. For more information about DFA optimizations employed for -// lexer actions, see {@link LexerActionExecutor//append} and -// {@link LexerActionExecutor//fixOffsetBeforeMatch}.

          - -// Constructs a new indexed custom action by associating a character offset -// with a {@link LexerAction}. -// -//

          Note: This class is only required for lexer actions for which -// {@link LexerAction//isPositionDependent} returns {@code true}.

          -// -// @param offset The offset into the input {@link CharStream}, relative to -// the token start index, at which the specified lexer action should be -// executed. -// @param action The lexer action to execute at a particular offset in the -// input {@link CharStream}. -function LexerIndexedCustomAction(offset, action) { - LexerAction.call(this, action.actionType); - this.offset = offset; - this.action = action; - this.isPositionDependent = true; - return this; -} - -LexerIndexedCustomAction.prototype = Object.create(LexerAction.prototype); -LexerIndexedCustomAction.prototype.constructor = LexerIndexedCustomAction; - -//

          This method calls {@link //execute} on the result of {@link //getAction} -// using the provided {@code lexer}.

          -LexerIndexedCustomAction.prototype.execute = function(lexer) { - // assume the input stream position was properly set by the calling code - this.action.execute(lexer); -}; - -LexerIndexedCustomAction.prototype.updateHashCode = function(hash) { - hash.update(this.actionType, this.offset, this.action); -}; - -LexerIndexedCustomAction.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (! (other instanceof LexerIndexedCustomAction)) { - return false; - } else { - return this.offset === other.offset && this.action === other.action; - } -}; - - -exports.LexerActionType = LexerActionType; -exports.LexerSkipAction = LexerSkipAction; -exports.LexerChannelAction = LexerChannelAction; -exports.LexerCustomAction = LexerCustomAction; -exports.LexerIndexedCustomAction = LexerIndexedCustomAction; -exports.LexerMoreAction = LexerMoreAction; -exports.LexerTypeAction = LexerTypeAction; -exports.LexerPushModeAction = LexerPushModeAction; -exports.LexerPopModeAction = LexerPopModeAction; -exports.LexerModeAction = LexerModeAction; - -/***/ }), -/* 24 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -var Token = __webpack_require__(1).Token; -var ConsoleErrorListener = __webpack_require__(16).ConsoleErrorListener; -var ProxyErrorListener = __webpack_require__(16).ProxyErrorListener; - -function Recognizer() { - this._listeners = [ ConsoleErrorListener.INSTANCE ]; - this._interp = null; - this._stateNumber = -1; - return this; -} - -Recognizer.tokenTypeMapCache = {}; -Recognizer.ruleIndexMapCache = {}; - - -Recognizer.prototype.checkVersion = function(toolVersion) { - var runtimeVersion = "4.8"; - if (runtimeVersion!==toolVersion) { - console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion); - } -}; - -Recognizer.prototype.addErrorListener = function(listener) { - this._listeners.push(listener); -}; - -Recognizer.prototype.removeErrorListeners = function() { - this._listeners = []; -}; - -Recognizer.prototype.getTokenTypeMap = function() { - var tokenNames = this.getTokenNames(); - if (tokenNames===null) { - throw("The current recognizer does not provide a list of token names."); - } - var result = this.tokenTypeMapCache[tokenNames]; - if(result===undefined) { - result = tokenNames.reduce(function(o, k, i) { o[k] = i; }); - result.EOF = Token.EOF; - this.tokenTypeMapCache[tokenNames] = result; - } - return result; -}; - -// Get a map from rule names to rule indexes. -// -//

          Used for XPath and tree pattern compilation.

          -// -Recognizer.prototype.getRuleIndexMap = function() { - var ruleNames = this.ruleNames; - if (ruleNames===null) { - throw("The current recognizer does not provide a list of rule names."); - } - var result = this.ruleIndexMapCache[ruleNames]; - if(result===undefined) { - result = ruleNames.reduce(function(o, k, i) { o[k] = i; }); - this.ruleIndexMapCache[ruleNames] = result; - } - return result; -}; - -Recognizer.prototype.getTokenType = function(tokenName) { - var ttype = this.getTokenTypeMap()[tokenName]; - if (ttype !==undefined) { - return ttype; - } else { - return Token.INVALID_TYPE; - } -}; - - -// What is the error header, normally line/character position information?// -Recognizer.prototype.getErrorHeader = function(e) { - var line = e.getOffendingToken().line; - var column = e.getOffendingToken().column; - return "line " + line + ":" + column; -}; - - -// How should a token be displayed in an error message? The default -// is to display just the text, but during development you might -// want to have a lot of information spit out. Override in that case -// to use t.toString() (which, for CommonToken, dumps everything about -// the token). This is better than forcing you to override a method in -// your token objects because you don't have to go modify your lexer -// so that it creates a new Java type. -// -// @deprecated This method is not called by the ANTLR 4 Runtime. Specific -// implementations of {@link ANTLRErrorStrategy} may provide a similar -// feature when necessary. For example, see -// {@link DefaultErrorStrategy//getTokenErrorDisplay}. -// -Recognizer.prototype.getTokenErrorDisplay = function(t) { - if (t===null) { - return ""; - } - var s = t.text; - if (s===null) { - if (t.type===Token.EOF) { - s = ""; - } else { - s = "<" + t.type + ">"; - } - } - s = s.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"); - return "'" + s + "'"; -}; - -Recognizer.prototype.getErrorListenerDispatch = function() { - return new ProxyErrorListener(this._listeners); -}; - -// subclass needs to override these if there are sempreds or actions -// that the ATN interp needs to execute -Recognizer.prototype.sempred = function(localctx, ruleIndex, actionIndex) { - return true; -}; - -Recognizer.prototype.precpred = function(localctx , precedence) { - return true; -}; - -//Indicate that the recognizer has changed internal state that is -//consistent with the ATN state passed in. This way we always know -//where we are in the ATN as the parser goes along. The rule -//context objects form a stack that lets us see the stack of -//invoking rules. Combine this and we have complete ATN -//configuration information. - -Object.defineProperty(Recognizer.prototype, "state", { - get : function() { - return this._stateNumber; - }, - set : function(state) { - this._stateNumber = state; - } -}); - - -exports.Recognizer = Recognizer; - - -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -var DFAState = __webpack_require__(11).DFAState; -var ATNConfigSet = __webpack_require__(9).ATNConfigSet; -var getCachedPredictionContext = __webpack_require__(6).getCachedPredictionContext; -var Map = __webpack_require__(0).Map; - -function ATNSimulator(atn, sharedContextCache) { - - // The context cache maps all PredictionContext objects that are == - // to a single cached copy. This cache is shared across all contexts - // in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet - // to use only cached nodes/graphs in addDFAState(). We don't want to - // fill this during closure() since there are lots of contexts that - // pop up but are not used ever again. It also greatly slows down closure(). - // - //

          This cache makes a huge difference in memory and a little bit in speed. - // For the Java grammar on java.*, it dropped the memory requirements - // at the end from 25M to 16M. We don't store any of the full context - // graphs in the DFA because they are limited to local context only, - // but apparently there's a lot of repetition there as well. We optimize - // the config contexts before storing the config set in the DFA states - // by literally rebuilding them with cached subgraphs only.

          - // - //

          I tried a cache for use during closure operations, that was - // whacked after each adaptivePredict(). It cost a little bit - // more time I think and doesn't save on the overall footprint - // so it's not worth the complexity.

          - /// - this.atn = atn; - this.sharedContextCache = sharedContextCache; - return this; -} - -// Must distinguish between missing edge and edge we know leads nowhere/// -ATNSimulator.ERROR = new DFAState(0x7FFFFFFF, new ATNConfigSet()); - - -ATNSimulator.prototype.getCachedContext = function(context) { - if (this.sharedContextCache ===null) { - return context; - } - var visited = new Map(); - return getCachedPredictionContext(context, this.sharedContextCache, visited); -}; - -exports.ATNSimulator = ATNSimulator; - - -/***/ }), -/* 26 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// -// -// This enumeration defines the prediction modes available in ANTLR 4 along with -// utility methods for analyzing configuration sets for conflicts and/or -// ambiguities. - -var Set = __webpack_require__(0).Set; -var Map = __webpack_require__(0).Map; -var BitSet = __webpack_require__(0).BitSet; -var AltDict = __webpack_require__(0).AltDict; -var ATN = __webpack_require__(7).ATN; -var RuleStopState = __webpack_require__(3).RuleStopState; -var ATNConfigSet = __webpack_require__(9).ATNConfigSet; -var ATNConfig = __webpack_require__(13).ATNConfig; -var SemanticContext = __webpack_require__(10).SemanticContext; -var Hash = __webpack_require__(0).Hash; -var hashStuff = __webpack_require__(0).hashStuff; -var equalArrays = __webpack_require__(0).equalArrays; - -function PredictionMode() { - return this; -} - -// -// The SLL(*) prediction mode. This prediction mode ignores the current -// parser context when making predictions. This is the fastest prediction -// mode, and provides correct results for many grammars. This prediction -// mode is more powerful than the prediction mode provided by ANTLR 3, but -// may result in syntax errors for grammar and input combinations which are -// not SLL. -// -//

          -// When using this prediction mode, the parser will either return a correct -// parse tree (i.e. the same parse tree that would be returned with the -// {@link //LL} prediction mode), or it will report a syntax error. If a -// syntax error is encountered when using the {@link //SLL} prediction mode, -// it may be due to either an actual syntax error in the input or indicate -// that the particular combination of grammar and input requires the more -// powerful {@link //LL} prediction abilities to complete successfully.

          -// -//

          -// This prediction mode does not provide any guarantees for prediction -// behavior for syntactically-incorrect inputs.

          -// -PredictionMode.SLL = 0; -// -// The LL(*) prediction mode. This prediction mode allows the current parser -// context to be used for resolving SLL conflicts that occur during -// prediction. This is the fastest prediction mode that guarantees correct -// parse results for all combinations of grammars with syntactically correct -// inputs. -// -//

          -// When using this prediction mode, the parser will make correct decisions -// for all syntactically-correct grammar and input combinations. However, in -// cases where the grammar is truly ambiguous this prediction mode might not -// report a precise answer for exactly which alternatives are -// ambiguous.

          -// -//

          -// This prediction mode does not provide any guarantees for prediction -// behavior for syntactically-incorrect inputs.

          -// -PredictionMode.LL = 1; -// -// The LL(*) prediction mode with exact ambiguity detection. In addition to -// the correctness guarantees provided by the {@link //LL} prediction mode, -// this prediction mode instructs the prediction algorithm to determine the -// complete and exact set of ambiguous alternatives for every ambiguous -// decision encountered while parsing. -// -//

          -// This prediction mode may be used for diagnosing ambiguities during -// grammar development. Due to the performance overhead of calculating sets -// of ambiguous alternatives, this prediction mode should be avoided when -// the exact results are not necessary.

          -// -//

          -// This prediction mode does not provide any guarantees for prediction -// behavior for syntactically-incorrect inputs.

          -// -PredictionMode.LL_EXACT_AMBIG_DETECTION = 2; - - -// -// Computes the SLL prediction termination condition. -// -//

          -// This method computes the SLL prediction termination condition for both of -// the following cases.

          -// -//
            -//
          • The usual SLL+LL fallback upon SLL conflict
          • -//
          • Pure SLL without LL fallback
          • -//
          -// -//

          COMBINED SLL+LL PARSING

          -// -//

          When LL-fallback is enabled upon SLL conflict, correct predictions are -// ensured regardless of how the termination condition is computed by this -// method. Due to the substantially higher cost of LL prediction, the -// prediction should only fall back to LL when the additional lookahead -// cannot lead to a unique SLL prediction.

          -// -//

          Assuming combined SLL+LL parsing, an SLL configuration set with only -// conflicting subsets should fall back to full LL, even if the -// configuration sets don't resolve to the same alternative (e.g. -// {@code {1,2}} and {@code {3,4}}. If there is at least one non-conflicting -// configuration, SLL could continue with the hopes that more lookahead will -// resolve via one of those non-conflicting configurations.

          -// -//

          Here's the prediction termination rule them: SLL (for SLL+LL parsing) -// stops when it sees only conflicting configuration subsets. In contrast, -// full LL keeps going when there is uncertainty.

          -// -//

          HEURISTIC

          -// -//

          As a heuristic, we stop prediction when we see any conflicting subset -// unless we see a state that only has one alternative associated with it. -// The single-alt-state thing lets prediction continue upon rules like -// (otherwise, it would admit defeat too soon):

          -// -//

          {@code [12|1|[], 6|2|[], 12|2|[]]. s : (ID | ID ID?) ';' ;}

          -// -//

          When the ATN simulation reaches the state before {@code ';'}, it has a -// DFA state that looks like: {@code [12|1|[], 6|2|[], 12|2|[]]}. Naturally -// {@code 12|1|[]} and {@code 12|2|[]} conflict, but we cannot stop -// processing this node because alternative to has another way to continue, -// via {@code [6|2|[]]}.

          -// -//

          It also let's us continue for this rule:

          -// -//

          {@code [1|1|[], 1|2|[], 8|3|[]] a : A | A | A B ;}

          -// -//

          After matching input A, we reach the stop state for rule A, state 1. -// State 8 is the state right before B. Clearly alternatives 1 and 2 -// conflict and no amount of further lookahead will separate the two. -// However, alternative 3 will be able to continue and so we do not stop -// working on this state. In the previous example, we're concerned with -// states associated with the conflicting alternatives. Here alt 3 is not -// associated with the conflicting configs, but since we can continue -// looking for input reasonably, don't declare the state done.

          -// -//

          PURE SLL PARSING

          -// -//

          To handle pure SLL parsing, all we have to do is make sure that we -// combine stack contexts for configurations that differ only by semantic -// predicate. From there, we can do the usual SLL termination heuristic.

          -// -//

          PREDICATES IN SLL+LL PARSING

          -// -//

          SLL decisions don't evaluate predicates until after they reach DFA stop -// states because they need to create the DFA cache that works in all -// semantic situations. In contrast, full LL evaluates predicates collected -// during start state computation so it can ignore predicates thereafter. -// This means that SLL termination detection can totally ignore semantic -// predicates.

          -// -//

          Implementation-wise, {@link ATNConfigSet} combines stack contexts but not -// semantic predicate contexts so we might see two configurations like the -// following.

          -// -//

          {@code (s, 1, x, {}), (s, 1, x', {p})}

          -// -//

          Before testing these configurations against others, we have to merge -// {@code x} and {@code x'} (without modifying the existing configurations). -// For example, we test {@code (x+x')==x''} when looking for conflicts in -// the following configurations.

          -// -//

          {@code (s, 1, x, {}), (s, 1, x', {p}), (s, 2, x'', {})}

          -// -//

          If the configuration set has predicates (as indicated by -// {@link ATNConfigSet//hasSemanticContext}), this algorithm makes a copy of -// the configurations to strip out all of the predicates so that a standard -// {@link ATNConfigSet} will merge everything ignoring predicates.

          -// -PredictionMode.hasSLLConflictTerminatingPrediction = function( mode, configs) { - // Configs in rule stop states indicate reaching the end of the decision - // rule (local context) or end of start rule (full context). If all - // configs meet this condition, then none of the configurations is able - // to match additional input so we terminate prediction. - // - if (PredictionMode.allConfigsInRuleStopStates(configs)) { - return true; - } - // pure SLL mode parsing - if (mode === PredictionMode.SLL) { - // Don't bother with combining configs from different semantic - // contexts if we can fail over to full LL; costs more time - // since we'll often fail over anyway. - if (configs.hasSemanticContext) { - // dup configs, tossing out semantic predicates - var dup = new ATNConfigSet(); - for(var i=0;iCan we stop looking ahead during ATN simulation or is there some -// uncertainty as to which alternative we will ultimately pick, after -// consuming more input? Even if there are partial conflicts, we might know -// that everything is going to resolve to the same minimum alternative. That -// means we can stop since no more lookahead will change that fact. On the -// other hand, there might be multiple conflicts that resolve to different -// minimums. That means we need more look ahead to decide which of those -// alternatives we should predict.

          -// -//

          The basic idea is to split the set of configurations {@code C}, into -// conflicting subsets {@code (s, _, ctx, _)} and singleton subsets with -// non-conflicting configurations. Two configurations conflict if they have -// identical {@link ATNConfig//state} and {@link ATNConfig//context} values -// but different {@link ATNConfig//alt} value, e.g. {@code (s, i, ctx, _)} -// and {@code (s, j, ctx, _)} for {@code i!=j}.

          -// -//

          Reduce these configuration subsets to the set of possible alternatives. -// You can compute the alternative subsets in one pass as follows:

          -// -//

          {@code A_s,ctx = {i | (s, i, ctx, _)}} for each configuration in -// {@code C} holding {@code s} and {@code ctx} fixed.

          -// -//

          Or in pseudo-code, for each configuration {@code c} in {@code C}:

          -// -//
          -// map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not
          -// alt and not pred
          -// 
          -// -//

          The values in {@code map} are the set of {@code A_s,ctx} sets.

          -// -//

          If {@code |A_s,ctx|=1} then there is no conflict associated with -// {@code s} and {@code ctx}.

          -// -//

          Reduce the subsets to singletons by choosing a minimum of each subset. If -// the union of these alternative subsets is a singleton, then no amount of -// more lookahead will help us. We will always pick that alternative. If, -// however, there is more than one alternative, then we are uncertain which -// alternative to predict and must continue looking for resolution. We may -// or may not discover an ambiguity in the future, even if there are no -// conflicting subsets this round.

          -// -//

          The biggest sin is to terminate early because it means we've made a -// decision but were uncertain as to the eventual outcome. We haven't used -// enough lookahead. On the other hand, announcing a conflict too late is no -// big deal; you will still have the conflict. It's just inefficient. It -// might even look until the end of file.

          -// -//

          No special consideration for semantic predicates is required because -// predicates are evaluated on-the-fly for full LL prediction, ensuring that -// no configuration contains a semantic context during the termination -// check.

          -// -//

          CONFLICTING CONFIGS

          -// -//

          Two configurations {@code (s, i, x)} and {@code (s, j, x')}, conflict -// when {@code i!=j} but {@code x=x'}. Because we merge all -// {@code (s, i, _)} configurations together, that means that there are at -// most {@code n} configurations associated with state {@code s} for -// {@code n} possible alternatives in the decision. The merged stacks -// complicate the comparison of configuration contexts {@code x} and -// {@code x'}. Sam checks to see if one is a subset of the other by calling -// merge and checking to see if the merged result is either {@code x} or -// {@code x'}. If the {@code x} associated with lowest alternative {@code i} -// is the superset, then {@code i} is the only possible prediction since the -// others resolve to {@code min(i)} as well. However, if {@code x} is -// associated with {@code j>i} then at least one stack configuration for -// {@code j} is not in conflict with alternative {@code i}. The algorithm -// should keep going, looking for more lookahead due to the uncertainty.

          -// -//

          For simplicity, I'm doing a equality check between {@code x} and -// {@code x'} that lets the algorithm continue to consume lookahead longer -// than necessary. The reason I like the equality is of course the -// simplicity but also because that is the test you need to detect the -// alternatives that are actually in conflict.

          -// -//

          CONTINUE/STOP RULE

          -// -//

          Continue if union of resolved alternative sets from non-conflicting and -// conflicting alternative subsets has more than one alternative. We are -// uncertain about which alternative to predict.

          -// -//

          The complete set of alternatives, {@code [i for (_,i,_)]}, tells us which -// alternatives are still in the running for the amount of input we've -// consumed at this point. The conflicting sets let us to strip away -// configurations that won't lead to more states because we resolve -// conflicts to the configuration with a minimum alternate for the -// conflicting set.

          -// -//

          CASES

          -// -//
            -// -//
          • no conflicts and more than 1 alternative in set => continue
          • -// -//
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s, 3, z)}, -// {@code (s', 1, y)}, {@code (s', 2, y)} yields non-conflicting set -// {@code {3}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} = -// {@code {1,3}} => continue -//
          • -// -//
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)}, -// {@code (s', 2, y)}, {@code (s'', 1, z)} yields non-conflicting set -// {@code {1}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} = -// {@code {1}} => stop and predict 1
          • -// -//
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)}, -// {@code (s', 2, y)} yields conflicting, reduced sets {@code {1}} U -// {@code {1}} = {@code {1}} => stop and predict 1, can announce -// ambiguity {@code {1,2}}
          • -// -//
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 2, y)}, -// {@code (s', 3, y)} yields conflicting, reduced sets {@code {1}} U -// {@code {2}} = {@code {1,2}} => continue
          • -// -//
          • {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 3, y)}, -// {@code (s', 4, y)} yields conflicting, reduced sets {@code {1}} U -// {@code {3}} = {@code {1,3}} => continue
          • -// -//
          -// -//

          EXACT AMBIGUITY DETECTION

          -// -//

          If all states report the same conflicting set of alternatives, then we -// know we have the exact ambiguity set.

          -// -//

          |A_i|>1 and -// A_i = A_j for all i, j.

          -// -//

          In other words, we continue examining lookahead until all {@code A_i} -// have more than one alternative and all {@code A_i} are the same. If -// {@code A={{1,2}, {1,3}}}, then regular LL prediction would terminate -// because the resolved set is {@code {1}}. To determine what the real -// ambiguity is, we have to know whether the ambiguity is between one and -// two or one and three so we keep going. We can only stop prediction when -// we need exact ambiguity detection when the sets look like -// {@code A={{1,2}}} or {@code {{1,2},{1,2}}}, etc...

          -// -PredictionMode.resolvesToJustOneViableAlt = function(altsets) { - return PredictionMode.getSingleViableAlt(altsets); -}; - -// -// Determines if every alternative subset in {@code altsets} contains more -// than one alternative. -// -// @param altsets a collection of alternative subsets -// @return {@code true} if every {@link BitSet} in {@code altsets} has -// {@link BitSet//cardinality cardinality} > 1, otherwise {@code false} -// -PredictionMode.allSubsetsConflict = function(altsets) { - return ! PredictionMode.hasNonConflictingAltSet(altsets); -}; -// -// Determines if any single alternative subset in {@code altsets} contains -// exactly one alternative. -// -// @param altsets a collection of alternative subsets -// @return {@code true} if {@code altsets} contains a {@link BitSet} with -// {@link BitSet//cardinality cardinality} 1, otherwise {@code false} -// -PredictionMode.hasNonConflictingAltSet = function(altsets) { - for(var i=0;i1) { - return true; - } - } - return false; -}; - -// -// Determines if every alternative subset in {@code altsets} is equivalent. -// -// @param altsets a collection of alternative subsets -// @return {@code true} if every member of {@code altsets} is equal to the -// others, otherwise {@code false} -// -PredictionMode.allSubsetsEqual = function(altsets) { - var first = null; - for(var i=0;i -// map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not -// alt and not pred -// - -PredictionMode.getConflictingAltSubsets = function(configs) { - var configToAlts = new Map(); - configToAlts.hashFunction = function(cfg) { hashStuff(cfg.state.stateNumber, cfg.context); }; - configToAlts.equalsFunction = function(c1, c2) { return c1.state.stateNumber==c2.state.stateNumber && c1.context.equals(c2.context);} - configs.items.map(function(cfg) { - var alts = configToAlts.get(cfg); - if (alts === null) { - alts = new BitSet(); - configToAlts.put(cfg, alts); - } - alts.add(cfg.alt); - }); - return configToAlts.getValues(); -}; - -// -// Get a map from state to alt subset from a configuration set. For each -// configuration {@code c} in {@code configs}: -// -//
          -// map[c.{@link ATNConfig//state state}] U= c.{@link ATNConfig//alt alt}
          -// 
          -// -PredictionMode.getStateToAltMap = function(configs) { - var m = new AltDict(); - configs.items.map(function(c) { - var alts = m.get(c.state); - if (alts === null) { - alts = new BitSet(); - m.put(c.state, alts); - } - alts.add(c.alt); - }); - return m; -}; - -PredictionMode.hasStateAssociatedWithOneAlt = function(configs) { - var values = PredictionMode.getStateToAltMap(configs).values(); - for(var i=0;i= size) { - return undefined; - } - // Get the first code unit - var first = string.charCodeAt(index); - var second; - if ( // check if it’s the start of a surrogate pair - first >= 0xD800 && first <= 0xDBFF && // high surrogate - size > index + 1 // there is a next code unit - ) { - second = string.charCodeAt(index + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - return first; - }; - if (defineProperty) { - defineProperty(String.prototype, 'codePointAt', { - 'value': codePointAt, - 'configurable': true, - 'writable': true - }); - } else { - String.prototype.codePointAt = codePointAt; - } - }()); -} - - -/***/ }), -/* 28 */ -/***/ (function(module, exports) { - -/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */ -if (!String.fromCodePoint) { - (function() { - var defineProperty = (function() { - // IE 8 only supports `Object.defineProperty` on DOM elements - try { - var object = {}; - var $defineProperty = Object.defineProperty; - var result = $defineProperty(object, object, object) && $defineProperty; - } catch(error) {} - return result; - }()); - var stringFromCharCode = String.fromCharCode; - var floor = Math.floor; - var fromCodePoint = function(_) { - var MAX_SIZE = 0x4000; - var codeUnits = []; - var highSurrogate; - var lowSurrogate; - var index = -1; - var length = arguments.length; - if (!length) { - return ''; - } - var result = ''; - while (++index < length) { - var codePoint = Number(arguments[index]); - if ( - !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` - codePoint < 0 || // not a valid Unicode code point - codePoint > 0x10FFFF || // not a valid Unicode code point - floor(codePoint) != codePoint // not an integer - ) { - throw RangeError('Invalid code point: ' + codePoint); - } - if (codePoint <= 0xFFFF) { // BMP code point - codeUnits.push(codePoint); - } else { // Astral code point; split in surrogate halves - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - codePoint -= 0x10000; - highSurrogate = (codePoint >> 10) + 0xD800; - lowSurrogate = (codePoint % 0x400) + 0xDC00; - codeUnits.push(highSurrogate, lowSurrogate); - } - if (index + 1 == length || codeUnits.length > MAX_SIZE) { - result += stringFromCharCode.apply(null, codeUnits); - codeUnits.length = 0; - } - } - return result; - }; - if (defineProperty) { - defineProperty(String, 'fromCodePoint', { - 'value': fromCodePoint, - 'configurable': true, - 'writable': true - }); - } else { - String.fromCodePoint = fromCodePoint; - } - }()); -} - - -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -var Token = __webpack_require__(1).Token; -var Errors = __webpack_require__(5); -var NoViableAltException = Errors.NoViableAltException; -var InputMismatchException = Errors.InputMismatchException; -var FailedPredicateException = Errors.FailedPredicateException; -var ParseCancellationException = Errors.ParseCancellationException; -var ATNState = __webpack_require__(3).ATNState; -var Interval = __webpack_require__(2).Interval; -var IntervalSet = __webpack_require__(2).IntervalSet; - -function ErrorStrategy() { - -} - -ErrorStrategy.prototype.reset = function(recognizer){ -}; - -ErrorStrategy.prototype.recoverInline = function(recognizer){ -}; - -ErrorStrategy.prototype.recover = function(recognizer, e){ -}; - -ErrorStrategy.prototype.sync = function(recognizer){ -}; - -ErrorStrategy.prototype.inErrorRecoveryMode = function(recognizer){ -}; - -ErrorStrategy.prototype.reportError = function(recognizer){ -}; - - - -// This is the default implementation of {@link ANTLRErrorStrategy} used for -// error reporting and recovery in ANTLR parsers. -// -function DefaultErrorStrategy() { - ErrorStrategy.call(this); - // Indicates whether the error strategy is currently "recovering from an - // error". This is used to suppress reporting multiple error messages while - // attempting to recover from a detected syntax error. - // - // @see //inErrorRecoveryMode - // - this.errorRecoveryMode = false; - - // The index into the input stream where the last error occurred. - // This is used to prevent infinite loops where an error is found - // but no token is consumed during recovery...another error is found, - // ad nauseum. This is a failsafe mechanism to guarantee that at least - // one token/tree node is consumed for two errors. - // - this.lastErrorIndex = -1; - this.lastErrorStates = null; - return this; -} - -DefaultErrorStrategy.prototype = Object.create(ErrorStrategy.prototype); -DefaultErrorStrategy.prototype.constructor = DefaultErrorStrategy; - -//

          The default implementation simply calls {@link //endErrorCondition} to -// ensure that the handler is not in error recovery mode.

          -DefaultErrorStrategy.prototype.reset = function(recognizer) { - this.endErrorCondition(recognizer); -}; - -// -// This method is called to enter error recovery mode when a recognition -// exception is reported. -// -// @param recognizer the parser instance -// -DefaultErrorStrategy.prototype.beginErrorCondition = function(recognizer) { - this.errorRecoveryMode = true; -}; - -DefaultErrorStrategy.prototype.inErrorRecoveryMode = function(recognizer) { - return this.errorRecoveryMode; -}; - -// -// This method is called to leave error recovery mode after recovering from -// a recognition exception. -// -// @param recognizer -// -DefaultErrorStrategy.prototype.endErrorCondition = function(recognizer) { - this.errorRecoveryMode = false; - this.lastErrorStates = null; - this.lastErrorIndex = -1; -}; - -// -// {@inheritDoc} -// -//

          The default implementation simply calls {@link //endErrorCondition}.

          -// -DefaultErrorStrategy.prototype.reportMatch = function(recognizer) { - this.endErrorCondition(recognizer); -}; - -// -// {@inheritDoc} -// -//

          The default implementation returns immediately if the handler is already -// in error recovery mode. Otherwise, it calls {@link //beginErrorCondition} -// and dispatches the reporting task based on the runtime type of {@code e} -// according to the following table.

          -// -//
            -//
          • {@link NoViableAltException}: Dispatches the call to -// {@link //reportNoViableAlternative}
          • -//
          • {@link InputMismatchException}: Dispatches the call to -// {@link //reportInputMismatch}
          • -//
          • {@link FailedPredicateException}: Dispatches the call to -// {@link //reportFailedPredicate}
          • -//
          • All other types: calls {@link Parser//notifyErrorListeners} to report -// the exception
          • -//
          -// -DefaultErrorStrategy.prototype.reportError = function(recognizer, e) { - // if we've already reported an error and have not matched a token - // yet successfully, don't report any errors. - if(this.inErrorRecoveryMode(recognizer)) { - return; // don't report spurious errors - } - this.beginErrorCondition(recognizer); - if ( e instanceof NoViableAltException ) { - this.reportNoViableAlternative(recognizer, e); - } else if ( e instanceof InputMismatchException ) { - this.reportInputMismatch(recognizer, e); - } else if ( e instanceof FailedPredicateException ) { - this.reportFailedPredicate(recognizer, e); - } else { - console.log("unknown recognition error type: " + e.constructor.name); - console.log(e.stack); - recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e); - } -}; -// -// {@inheritDoc} -// -//

          The default implementation resynchronizes the parser by consuming tokens -// until we find one in the resynchronization set--loosely the set of tokens -// that can follow the current rule.

          -// -DefaultErrorStrategy.prototype.recover = function(recognizer, e) { - if (this.lastErrorIndex===recognizer.getInputStream().index && - this.lastErrorStates !== null && this.lastErrorStates.indexOf(recognizer.state)>=0) { - // uh oh, another error at same token index and previously-visited - // state in ATN; must be a case where LT(1) is in the recovery - // token set so nothing got consumed. Consume a single token - // at least to prevent an infinite loop; this is a failsafe. - recognizer.consume(); - } - this.lastErrorIndex = recognizer._input.index; - if (this.lastErrorStates === null) { - this.lastErrorStates = []; - } - this.lastErrorStates.push(recognizer.state); - var followSet = this.getErrorRecoverySet(recognizer); - this.consumeUntil(recognizer, followSet); -}; - -// The default implementation of {@link ANTLRErrorStrategy//sync} makes sure -// that the current lookahead symbol is consistent with what were expecting -// at this point in the ATN. You can call this anytime but ANTLR only -// generates code to check before subrules/loops and each iteration. -// -//

          Implements Jim Idle's magic sync mechanism in closures and optional -// subrules. E.g.,

          -// -//
          -// a : sync ( stuff sync )* ;
          -// sync : {consume to what can follow sync} ;
          -// 
          -// -// At the start of a sub rule upon error, {@link //sync} performs single -// token deletion, if possible. If it can't do that, it bails on the current -// rule and uses the default error recovery, which consumes until the -// resynchronization set of the current rule. -// -//

          If the sub rule is optional ({@code (...)?}, {@code (...)*}, or block -// with an empty alternative), then the expected set includes what follows -// the subrule.

          -// -//

          During loop iteration, it consumes until it sees a token that can start a -// sub rule or what follows loop. Yes, that is pretty aggressive. We opt to -// stay in the loop as long as possible.

          -// -//

          ORIGINS

          -// -//

          Previous versions of ANTLR did a poor job of their recovery within loops. -// A single mismatch token or missing token would force the parser to bail -// out of the entire rules surrounding the loop. So, for rule

          -// -//
          -// classDef : 'class' ID '{' member* '}'
          -// 
          -// -// input with an extra token between members would force the parser to -// consume until it found the next class definition rather than the next -// member definition of the current class. -// -//

          This functionality cost a little bit of effort because the parser has to -// compare token set at the start of the loop and at each iteration. If for -// some reason speed is suffering for you, you can turn off this -// functionality by simply overriding this method as a blank { }.

          -// -DefaultErrorStrategy.prototype.sync = function(recognizer) { - // If already recovering, don't try to sync - if (this.inErrorRecoveryMode(recognizer)) { - return; - } - var s = recognizer._interp.atn.states[recognizer.state]; - var la = recognizer.getTokenStream().LA(1); - // try cheaper subset first; might get lucky. seems to shave a wee bit off - var nextTokens = recognizer.atn.nextTokens(s); - if (nextTokens.contains(Token.EPSILON) || nextTokens.contains(la)) { - return; - } - switch (s.stateType) { - case ATNState.BLOCK_START: - case ATNState.STAR_BLOCK_START: - case ATNState.PLUS_BLOCK_START: - case ATNState.STAR_LOOP_ENTRY: - // report error and recover if possible - if( this.singleTokenDeletion(recognizer) !== null) { - return; - } else { - throw new InputMismatchException(recognizer); - } - break; - case ATNState.PLUS_LOOP_BACK: - case ATNState.STAR_LOOP_BACK: - this.reportUnwantedToken(recognizer); - var expecting = new IntervalSet(); - expecting.addSet(recognizer.getExpectedTokens()); - var whatFollowsLoopIterationOrRule = expecting.addSet(this.getErrorRecoverySet(recognizer)); - this.consumeUntil(recognizer, whatFollowsLoopIterationOrRule); - break; - default: - // do nothing if we can't identify the exact kind of ATN state - } -}; - -// This is called by {@link //reportError} when the exception is a -// {@link NoViableAltException}. -// -// @see //reportError -// -// @param recognizer the parser instance -// @param e the recognition exception -// -DefaultErrorStrategy.prototype.reportNoViableAlternative = function(recognizer, e) { - var tokens = recognizer.getTokenStream(); - var input; - if(tokens !== null) { - if (e.startToken.type===Token.EOF) { - input = ""; - } else { - input = tokens.getText(new Interval(e.startToken.tokenIndex, e.offendingToken.tokenIndex)); - } - } else { - input = ""; - } - var msg = "no viable alternative at input " + this.escapeWSAndQuote(input); - recognizer.notifyErrorListeners(msg, e.offendingToken, e); -}; - -// -// This is called by {@link //reportError} when the exception is an -// {@link InputMismatchException}. -// -// @see //reportError -// -// @param recognizer the parser instance -// @param e the recognition exception -// -DefaultErrorStrategy.prototype.reportInputMismatch = function(recognizer, e) { - var msg = "mismatched input " + this.getTokenErrorDisplay(e.offendingToken) + - " expecting " + e.getExpectedTokens().toString(recognizer.literalNames, recognizer.symbolicNames); - recognizer.notifyErrorListeners(msg, e.offendingToken, e); -}; - -// -// This is called by {@link //reportError} when the exception is a -// {@link FailedPredicateException}. -// -// @see //reportError -// -// @param recognizer the parser instance -// @param e the recognition exception -// -DefaultErrorStrategy.prototype.reportFailedPredicate = function(recognizer, e) { - var ruleName = recognizer.ruleNames[recognizer._ctx.ruleIndex]; - var msg = "rule " + ruleName + " " + e.message; - recognizer.notifyErrorListeners(msg, e.offendingToken, e); -}; - -// This method is called to report a syntax error which requires the removal -// of a token from the input stream. At the time this method is called, the -// erroneous symbol is current {@code LT(1)} symbol and has not yet been -// removed from the input stream. When this method returns, -// {@code recognizer} is in error recovery mode. -// -//

          This method is called when {@link //singleTokenDeletion} identifies -// single-token deletion as a viable recovery strategy for a mismatched -// input error.

          -// -//

          The default implementation simply returns if the handler is already in -// error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to -// enter error recovery mode, followed by calling -// {@link Parser//notifyErrorListeners}.

          -// -// @param recognizer the parser instance -// -DefaultErrorStrategy.prototype.reportUnwantedToken = function(recognizer) { - if (this.inErrorRecoveryMode(recognizer)) { - return; - } - this.beginErrorCondition(recognizer); - var t = recognizer.getCurrentToken(); - var tokenName = this.getTokenErrorDisplay(t); - var expecting = this.getExpectedTokens(recognizer); - var msg = "extraneous input " + tokenName + " expecting " + - expecting.toString(recognizer.literalNames, recognizer.symbolicNames); - recognizer.notifyErrorListeners(msg, t, null); -}; -// This method is called to report a syntax error which requires the -// insertion of a missing token into the input stream. At the time this -// method is called, the missing token has not yet been inserted. When this -// method returns, {@code recognizer} is in error recovery mode. -// -//

          This method is called when {@link //singleTokenInsertion} identifies -// single-token insertion as a viable recovery strategy for a mismatched -// input error.

          -// -//

          The default implementation simply returns if the handler is already in -// error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to -// enter error recovery mode, followed by calling -// {@link Parser//notifyErrorListeners}.

          -// -// @param recognizer the parser instance -// -DefaultErrorStrategy.prototype.reportMissingToken = function(recognizer) { - if ( this.inErrorRecoveryMode(recognizer)) { - return; - } - this.beginErrorCondition(recognizer); - var t = recognizer.getCurrentToken(); - var expecting = this.getExpectedTokens(recognizer); - var msg = "missing " + expecting.toString(recognizer.literalNames, recognizer.symbolicNames) + - " at " + this.getTokenErrorDisplay(t); - recognizer.notifyErrorListeners(msg, t, null); -}; - -//

          The default implementation attempts to recover from the mismatched input -// by using single token insertion and deletion as described below. If the -// recovery attempt fails, this method throws an -// {@link InputMismatchException}.

          -// -//

          EXTRA TOKEN (single token deletion)

          -// -//

          {@code LA(1)} is not what we are looking for. If {@code LA(2)} has the -// right token, however, then assume {@code LA(1)} is some extra spurious -// token and delete it. Then consume and return the next token (which was -// the {@code LA(2)} token) as the successful result of the match operation.

          -// -//

          This recovery strategy is implemented by {@link -// //singleTokenDeletion}.

          -// -//

          MISSING TOKEN (single token insertion)

          -// -//

          If current token (at {@code LA(1)}) is consistent with what could come -// after the expected {@code LA(1)} token, then assume the token is missing -// and use the parser's {@link TokenFactory} to create it on the fly. The -// "insertion" is performed by returning the created token as the successful -// result of the match operation.

          -// -//

          This recovery strategy is implemented by {@link -// //singleTokenInsertion}.

          -// -//

          EXAMPLE

          -// -//

          For example, Input {@code i=(3;} is clearly missing the {@code ')'}. When -// the parser returns from the nested call to {@code expr}, it will have -// call chain:

          -// -//
          -// stat → expr → atom
          -// 
          -// -// and it will be trying to match the {@code ')'} at this point in the -// derivation: -// -//
          -// => ID '=' '(' INT ')' ('+' atom)* ';'
          -// ^
          -// 
          -// -// The attempt to match {@code ')'} will fail when it sees {@code ';'} and -// call {@link //recoverInline}. To recover, it sees that {@code LA(1)==';'} -// is in the set of tokens that can follow the {@code ')'} token reference -// in rule {@code atom}. It can assume that you forgot the {@code ')'}. -// -DefaultErrorStrategy.prototype.recoverInline = function(recognizer) { - // SINGLE TOKEN DELETION - var matchedSymbol = this.singleTokenDeletion(recognizer); - if (matchedSymbol !== null) { - // we have deleted the extra token. - // now, move past ttype token as if all were ok - recognizer.consume(); - return matchedSymbol; - } - // SINGLE TOKEN INSERTION - if (this.singleTokenInsertion(recognizer)) { - return this.getMissingSymbol(recognizer); - } - // even that didn't work; must throw the exception - throw new InputMismatchException(recognizer); -}; - -// -// This method implements the single-token insertion inline error recovery -// strategy. It is called by {@link //recoverInline} if the single-token -// deletion strategy fails to recover from the mismatched input. If this -// method returns {@code true}, {@code recognizer} will be in error recovery -// mode. -// -//

          This method determines whether or not single-token insertion is viable by -// checking if the {@code LA(1)} input symbol could be successfully matched -// if it were instead the {@code LA(2)} symbol. If this method returns -// {@code true}, the caller is responsible for creating and inserting a -// token with the correct type to produce this behavior.

          -// -// @param recognizer the parser instance -// @return {@code true} if single-token insertion is a viable recovery -// strategy for the current mismatched input, otherwise {@code false} -// -DefaultErrorStrategy.prototype.singleTokenInsertion = function(recognizer) { - var currentSymbolType = recognizer.getTokenStream().LA(1); - // if current token is consistent with what could come after current - // ATN state, then we know we're missing a token; error recovery - // is free to conjure up and insert the missing token - var atn = recognizer._interp.atn; - var currentState = atn.states[recognizer.state]; - var next = currentState.transitions[0].target; - var expectingAtLL2 = atn.nextTokens(next, recognizer._ctx); - if (expectingAtLL2.contains(currentSymbolType) ){ - this.reportMissingToken(recognizer); - return true; - } else { - return false; - } -}; - -// This method implements the single-token deletion inline error recovery -// strategy. It is called by {@link //recoverInline} to attempt to recover -// from mismatched input. If this method returns null, the parser and error -// handler state will not have changed. If this method returns non-null, -// {@code recognizer} will not be in error recovery mode since the -// returned token was a successful match. -// -//

          If the single-token deletion is successful, this method calls -// {@link //reportUnwantedToken} to report the error, followed by -// {@link Parser//consume} to actually "delete" the extraneous token. Then, -// before returning {@link //reportMatch} is called to signal a successful -// match.

          -// -// @param recognizer the parser instance -// @return the successfully matched {@link Token} instance if single-token -// deletion successfully recovers from the mismatched input, otherwise -// {@code null} -// -DefaultErrorStrategy.prototype.singleTokenDeletion = function(recognizer) { - var nextTokenType = recognizer.getTokenStream().LA(2); - var expecting = this.getExpectedTokens(recognizer); - if (expecting.contains(nextTokenType)) { - this.reportUnwantedToken(recognizer); - // print("recoverFromMismatchedToken deleting " \ - // + str(recognizer.getTokenStream().LT(1)) \ - // + " since " + str(recognizer.getTokenStream().LT(2)) \ - // + " is what we want", file=sys.stderr) - recognizer.consume(); // simply delete extra token - // we want to return the token we're actually matching - var matchedSymbol = recognizer.getCurrentToken(); - this.reportMatch(recognizer); // we know current token is correct - return matchedSymbol; - } else { - return null; - } -}; - -// Conjure up a missing token during error recovery. -// -// The recognizer attempts to recover from single missing -// symbols. But, actions might refer to that missing symbol. -// For example, x=ID {f($x);}. The action clearly assumes -// that there has been an identifier matched previously and that -// $x points at that token. If that token is missing, but -// the next token in the stream is what we want we assume that -// this token is missing and we keep going. Because we -// have to return some token to replace the missing token, -// we have to conjure one up. This method gives the user control -// over the tokens returned for missing tokens. Mostly, -// you will want to create something special for identifier -// tokens. For literals such as '{' and ',', the default -// action in the parser or tree parser works. It simply creates -// a CommonToken of the appropriate type. The text will be the token. -// If you change what tokens must be created by the lexer, -// override this method to create the appropriate tokens. -// -DefaultErrorStrategy.prototype.getMissingSymbol = function(recognizer) { - var currentSymbol = recognizer.getCurrentToken(); - var expecting = this.getExpectedTokens(recognizer); - var expectedTokenType = expecting.first(); // get any element - var tokenText; - if (expectedTokenType===Token.EOF) { - tokenText = ""; - } else { - tokenText = ""; - } - var current = currentSymbol; - var lookback = recognizer.getTokenStream().LT(-1); - if (current.type===Token.EOF && lookback !== null) { - current = lookback; - } - return recognizer.getTokenFactory().create(current.source, - expectedTokenType, tokenText, Token.DEFAULT_CHANNEL, - -1, -1, current.line, current.column); -}; - -DefaultErrorStrategy.prototype.getExpectedTokens = function(recognizer) { - return recognizer.getExpectedTokens(); -}; - -// How should a token be displayed in an error message? The default -// is to display just the text, but during development you might -// want to have a lot of information spit out. Override in that case -// to use t.toString() (which, for CommonToken, dumps everything about -// the token). This is better than forcing you to override a method in -// your token objects because you don't have to go modify your lexer -// so that it creates a new Java type. -// -DefaultErrorStrategy.prototype.getTokenErrorDisplay = function(t) { - if (t === null) { - return ""; - } - var s = t.text; - if (s === null) { - if (t.type===Token.EOF) { - s = ""; - } else { - s = "<" + t.type + ">"; - } - } - return this.escapeWSAndQuote(s); -}; - -DefaultErrorStrategy.prototype.escapeWSAndQuote = function(s) { - s = s.replace(/\n/g,"\\n"); - s = s.replace(/\r/g,"\\r"); - s = s.replace(/\t/g,"\\t"); - return "'" + s + "'"; -}; - -// Compute the error recovery set for the current rule. During -// rule invocation, the parser pushes the set of tokens that can -// follow that rule reference on the stack; this amounts to -// computing FIRST of what follows the rule reference in the -// enclosing rule. See LinearApproximator.FIRST(). -// This local follow set only includes tokens -// from within the rule; i.e., the FIRST computation done by -// ANTLR stops at the end of a rule. -// -// EXAMPLE -// -// When you find a "no viable alt exception", the input is not -// consistent with any of the alternatives for rule r. The best -// thing to do is to consume tokens until you see something that -// can legally follow a call to r//or* any rule that called r. -// You don't want the exact set of viable next tokens because the -// input might just be missing a token--you might consume the -// rest of the input looking for one of the missing tokens. -// -// Consider grammar: -// -// a : '[' b ']' -// | '(' b ')' -// ; -// b : c '^' INT ; -// c : ID -// | INT -// ; -// -// At each rule invocation, the set of tokens that could follow -// that rule is pushed on a stack. Here are the various -// context-sensitive follow sets: -// -// FOLLOW(b1_in_a) = FIRST(']') = ']' -// FOLLOW(b2_in_a) = FIRST(')') = ')' -// FOLLOW(c_in_b) = FIRST('^') = '^' -// -// Upon erroneous input "[]", the call chain is -// -// a -> b -> c -// -// and, hence, the follow context stack is: -// -// depth follow set start of rule execution -// 0 a (from main()) -// 1 ']' b -// 2 '^' c -// -// Notice that ')' is not included, because b would have to have -// been called from a different context in rule a for ')' to be -// included. -// -// For error recovery, we cannot consider FOLLOW(c) -// (context-sensitive or otherwise). We need the combined set of -// all context-sensitive FOLLOW sets--the set of all tokens that -// could follow any reference in the call chain. We need to -// resync to one of those tokens. Note that FOLLOW(c)='^' and if -// we resync'd to that token, we'd consume until EOF. We need to -// sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}. -// In this case, for input "[]", LA(1) is ']' and in the set, so we would -// not consume anything. After printing an error, rule c would -// return normally. Rule b would not find the required '^' though. -// At this point, it gets a mismatched token error and throws an -// exception (since LA(1) is not in the viable following token -// set). The rule exception handler tries to recover, but finds -// the same recovery set and doesn't consume anything. Rule b -// exits normally returning to rule a. Now it finds the ']' (and -// with the successful match exits errorRecovery mode). -// -// So, you can see that the parser walks up the call chain looking -// for the token that was a member of the recovery set. -// -// Errors are not generated in errorRecovery mode. -// -// ANTLR's error recovery mechanism is based upon original ideas: -// -// "Algorithms + Data Structures = Programs" by Niklaus Wirth -// -// and -// -// "A note on error recovery in recursive descent parsers": -// http://portal.acm.org/citation.cfm?id=947902.947905 -// -// Later, Josef Grosch had some good ideas: -// -// "Efficient and Comfortable Error Recovery in Recursive Descent -// Parsers": -// ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip -// -// Like Grosch I implement context-sensitive FOLLOW sets that are combined -// at run-time upon error to avoid overhead during parsing. -// -DefaultErrorStrategy.prototype.getErrorRecoverySet = function(recognizer) { - var atn = recognizer._interp.atn; - var ctx = recognizer._ctx; - var recoverSet = new IntervalSet(); - while (ctx !== null && ctx.invokingState>=0) { - // compute what follows who invoked us - var invokingState = atn.states[ctx.invokingState]; - var rt = invokingState.transitions[0]; - var follow = atn.nextTokens(rt.followState); - recoverSet.addSet(follow); - ctx = ctx.parentCtx; - } - recoverSet.removeOne(Token.EPSILON); - return recoverSet; -}; - -// Consume tokens until one matches the given token set.// -DefaultErrorStrategy.prototype.consumeUntil = function(recognizer, set) { - var ttype = recognizer.getTokenStream().LA(1); - while( ttype !== Token.EOF && !set.contains(ttype)) { - recognizer.consume(); - ttype = recognizer.getTokenStream().LA(1); - } -}; - -// -// This implementation of {@link ANTLRErrorStrategy} responds to syntax errors -// by immediately canceling the parse operation with a -// {@link ParseCancellationException}. The implementation ensures that the -// {@link ParserRuleContext//exception} field is set for all parse tree nodes -// that were not completed prior to encountering the error. -// -//

          -// This error strategy is useful in the following scenarios.

          -// -//
            -//
          • Two-stage parsing: This error strategy allows the first -// stage of two-stage parsing to immediately terminate if an error is -// encountered, and immediately fall back to the second stage. In addition to -// avoiding wasted work by attempting to recover from errors here, the empty -// implementation of {@link BailErrorStrategy//sync} improves the performance of -// the first stage.
          • -//
          • Silent validation: When syntax errors are not being -// reported or logged, and the parse result is simply ignored if errors occur, -// the {@link BailErrorStrategy} avoids wasting work on recovering from errors -// when the result will be ignored either way.
          • -//
          -// -//

          -// {@code myparser.setErrorHandler(new BailErrorStrategy());}

          -// -// @see Parser//setErrorHandler(ANTLRErrorStrategy) -// -function BailErrorStrategy() { - DefaultErrorStrategy.call(this); - return this; -} - -BailErrorStrategy.prototype = Object.create(DefaultErrorStrategy.prototype); -BailErrorStrategy.prototype.constructor = BailErrorStrategy; - -// Instead of recovering from exception {@code e}, re-throw it wrapped -// in a {@link ParseCancellationException} so it is not caught by the -// rule function catches. Use {@link Exception//getCause()} to get the -// original {@link RecognitionException}. -// -BailErrorStrategy.prototype.recover = function(recognizer, e) { - var context = recognizer._ctx; - while (context !== null) { - context.exception = e; - context = context.parentCtx; - } - throw new ParseCancellationException(e); -}; - -// Make sure we don't attempt to recover inline; if the parser -// successfully recovers, it won't throw an exception. -// -BailErrorStrategy.prototype.recoverInline = function(recognizer) { - this.recover(recognizer, new InputMismatchException(recognizer)); -}; - -// Make sure we don't attempt to recover from problems in subrules.// -BailErrorStrategy.prototype.sync = function(recognizer) { - // pass -}; - -exports.BailErrorStrategy = BailErrorStrategy; -exports.DefaultErrorStrategy = DefaultErrorStrategy; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports) { - - - -/***/ }), -/* 31 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 -// jshint ignore: start -var antlr4 = __webpack_require__(12); -var turtlestarListener = __webpack_require__(32).turtlestarListener; -var turtlestarVisitor = __webpack_require__(33).turtlestarVisitor; - -var grammarFileName = "turtlestar.g4"; - -var serializedATN = ["\u0003\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd", - "\u00030\u00b6\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004\u0004\t", - "\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t\u0007\u0004", - "\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004\f\t\f\u0004", - "\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010\t\u0010\u0004", - "\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013\u0004\u0014\t", - "\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017\t\u0017\u0004", - "\u0018\t\u0018\u0003\u0002\u0007\u00022\n\u0002\f\u0002\u000e\u0002", - "5\u000b\u0002\u0003\u0002\u0003\u0002\u0003\u0003\u0003\u0003\u0003", - "\u0003\u0003\u0003\u0005\u0003=\n\u0003\u0003\u0004\u0003\u0004\u0003", - "\u0004\u0003\u0004\u0005\u0004C\n\u0004\u0003\u0005\u0003\u0005\u0003", - "\u0005\u0003\u0005\u0003\u0005\u0003\u0006\u0003\u0006\u0003\u0006\u0003", - "\u0006\u0003\u0007\u0003\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003", - "\b\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0005\tZ\n\t\u0005\t\\\n", - "\t\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0005\nd\n\n\u0007", - "\nf\n\n\f\n\u000e\ni\u000b\n\u0003\u000b\u0003\u000b\u0003\u000b\u0007", - "\u000bn\n\u000b\f\u000b\u000e\u000bq\u000b\u000b\u0003\f\u0003\f\u0005", - "\fu\n\f\u0003\r\u0003\r\u0003\r\u0003\r\u0005\r{\n\r\u0003\u000e\u0003", - "\u000e\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003", - "\u000f\u0005\u000f\u0085\n\u000f\u0003\u0010\u0003\u0010\u0003\u0010", - "\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0011\u0003\u0011\u0003\u0011", - "\u0005\u0011\u0090\n\u0011\u0003\u0012\u0003\u0012\u0003\u0012\u0003", - "\u0012\u0005\u0012\u0096\n\u0012\u0003\u0013\u0003\u0013\u0003\u0013", - "\u0005\u0013\u009b\n\u0013\u0003\u0014\u0003\u0014\u0003\u0014\u0003", - "\u0014\u0003\u0015\u0003\u0015\u0007\u0015\u00a3\n\u0015\f\u0015\u000e", - "\u0015\u00a6\u000b\u0015\u0003\u0015\u0003\u0015\u0003\u0016\u0003\u0016", - "\u0003\u0016\u0003\u0016\u0005\u0016\u00ae\n\u0016\u0003\u0017\u0003", - "\u0017\u0005\u0017\u00b2\n\u0017\u0003\u0018\u0003\u0018\u0003\u0018", - "\u0002\u0002\u0019\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016", - "\u0018\u001a\u001c\u001e \"$&(*,.\u0002\u0003\u0003\u0002\u0016\u0017", - "\u00bc\u00023\u0003\u0002\u0002\u0002\u0004<\u0003\u0002\u0002\u0002", - "\u0006B\u0003\u0002\u0002\u0002\bD\u0003\u0002\u0002\u0002\nI\u0003", - "\u0002\u0002\u0002\fM\u0003\u0002\u0002\u0002\u000eP\u0003\u0002\u0002", - "\u0002\u0010[\u0003\u0002\u0002\u0002\u0012]\u0003\u0002\u0002\u0002", - "\u0014j\u0003\u0002\u0002\u0002\u0016t\u0003\u0002\u0002\u0002\u0018", - "z\u0003\u0002\u0002\u0002\u001a|\u0003\u0002\u0002\u0002\u001c\u0084", - "\u0003\u0002\u0002\u0002\u001e\u0086\u0003\u0002\u0002\u0002 \u008f", - "\u0003\u0002\u0002\u0002\"\u0095\u0003\u0002\u0002\u0002$\u009a\u0003", - "\u0002\u0002\u0002&\u009c\u0003\u0002\u0002\u0002(\u00a0\u0003\u0002", - "\u0002\u0002*\u00a9\u0003\u0002\u0002\u0002,\u00b1\u0003\u0002\u0002", - "\u0002.\u00b3\u0003\u0002\u0002\u000202\u0005\u0004\u0003\u000210\u0003", - "\u0002\u0002\u000225\u0003\u0002\u0002\u000231\u0003\u0002\u0002\u0002", - "34\u0003\u0002\u0002\u000246\u0003\u0002\u0002\u000253\u0003\u0002\u0002", - "\u000267\u0007\u0002\u0002\u00037\u0003\u0003\u0002\u0002\u00028=\u0005", - "\u0006\u0004\u00029:\u0005\u0010\t\u0002:;\u0007\u0003\u0002\u0002;", - "=\u0003\u0002\u0002\u0002<8\u0003\u0002\u0002\u0002<9\u0003\u0002\u0002", - "\u0002=\u0005\u0003\u0002\u0002\u0002>C\u0005\b\u0005\u0002?C\u0005", - "\n\u0006\u0002@C\u0005\u000e\b\u0002AC\u0005\f\u0007\u0002B>\u0003\u0002", - "\u0002\u0002B?\u0003\u0002\u0002\u0002B@\u0003\u0002\u0002\u0002BA\u0003", - "\u0002\u0002\u0002C\u0007\u0003\u0002\u0002\u0002DE\u0007\u0004\u0002", - "\u0002EF\u0007\u0016\u0002\u0002FG\u0007\u0015\u0002\u0002GH\u0007\u0003", - "\u0002\u0002H\t\u0003\u0002\u0002\u0002IJ\u0007\u0005\u0002\u0002JK", - "\u0007\u0015\u0002\u0002KL\u0007\u0003\u0002\u0002L\u000b\u0003\u0002", - "\u0002\u0002MN\u0007)\u0002\u0002NO\u0007\u0015\u0002\u0002O\r\u0003", - "\u0002\u0002\u0002PQ\u0007*\u0002\u0002QR\u0007\u0016\u0002\u0002RS", - "\u0007\u0015\u0002\u0002S\u000f\u0003\u0002\u0002\u0002TU\u0005\u0018", - "\r\u0002UV\u0005\u0012\n\u0002V\\\u0003\u0002\u0002\u0002WY\u0005&\u0014", - "\u0002XZ\u0005\u0012\n\u0002YX\u0003\u0002\u0002\u0002YZ\u0003\u0002", - "\u0002\u0002Z\\\u0003\u0002\u0002\u0002[T\u0003\u0002\u0002\u0002[W", - "\u0003\u0002\u0002\u0002\\\u0011\u0003\u0002\u0002\u0002]^\u0005\u0016", - "\f\u0002^g\u0005\u0014\u000b\u0002_c\u0007\u0006\u0002\u0002`a\u0005", - "\u0016\f\u0002ab\u0005\u0014\u000b\u0002bd\u0003\u0002\u0002\u0002c", - "`\u0003\u0002\u0002\u0002cd\u0003\u0002\u0002\u0002df\u0003\u0002\u0002", - "\u0002e_\u0003\u0002\u0002\u0002fi\u0003\u0002\u0002\u0002ge\u0003\u0002", - "\u0002\u0002gh\u0003\u0002\u0002\u0002h\u0013\u0003\u0002\u0002\u0002", - "ig\u0003\u0002\u0002\u0002jo\u0005\u001c\u000f\u0002kl\u0007\u0007\u0002", - "\u0002ln\u0005\u001c\u000f\u0002mk\u0003\u0002\u0002\u0002nq\u0003\u0002", - "\u0002\u0002om\u0003\u0002\u0002\u0002op\u0003\u0002\u0002\u0002p\u0015", - "\u0003\u0002\u0002\u0002qo\u0003\u0002\u0002\u0002ru\u0005\u001a\u000e", - "\u0002su\u0007\b\u0002\u0002tr\u0003\u0002\u0002\u0002ts\u0003\u0002", - "\u0002\u0002u\u0017\u0003\u0002\u0002\u0002v{\u0005,\u0017\u0002w{\u0007", - "\u0014\u0002\u0002x{\u0005(\u0015\u0002y{\u0005\u001e\u0010\u0002zv", - "\u0003\u0002\u0002\u0002zw\u0003\u0002\u0002\u0002zx\u0003\u0002\u0002", - "\u0002zy\u0003\u0002\u0002\u0002{\u0019\u0003\u0002\u0002\u0002|}\u0005", - ",\u0017\u0002}\u001b\u0003\u0002\u0002\u0002~\u0085\u0005,\u0017\u0002", - "\u007f\u0085\u0007\u0014\u0002\u0002\u0080\u0085\u0005$\u0013\u0002", - "\u0081\u0085\u0005(\u0015\u0002\u0082\u0085\u0005&\u0014\u0002\u0083", - "\u0085\u0005\u001e\u0010\u0002\u0084~\u0003\u0002\u0002\u0002\u0084", - "\u007f\u0003\u0002\u0002\u0002\u0084\u0080\u0003\u0002\u0002\u0002\u0084", - "\u0081\u0003\u0002\u0002\u0002\u0084\u0082\u0003\u0002\u0002\u0002\u0084", - "\u0083\u0003\u0002\u0002\u0002\u0085\u001d\u0003\u0002\u0002\u0002\u0086", - "\u0087\u0007\t\u0002\u0002\u0087\u0088\u0005 \u0011\u0002\u0088\u0089", - "\u0005\u001a\u000e\u0002\u0089\u008a\u0005\"\u0012\u0002\u008a\u008b", - "\u0007\n\u0002\u0002\u008b\u001f\u0003\u0002\u0002\u0002\u008c\u0090", - "\u0005,\u0017\u0002\u008d\u0090\u0007\u0014\u0002\u0002\u008e\u0090", - "\u0005\u001e\u0010\u0002\u008f\u008c\u0003\u0002\u0002\u0002\u008f\u008d", - "\u0003\u0002\u0002\u0002\u008f\u008e\u0003\u0002\u0002\u0002\u0090!", - "\u0003\u0002\u0002\u0002\u0091\u0096\u0005,\u0017\u0002\u0092\u0096", - "\u0007\u0014\u0002\u0002\u0093\u0096\u0005$\u0013\u0002\u0094\u0096", - "\u0005\u001e\u0010\u0002\u0095\u0091\u0003\u0002\u0002\u0002\u0095\u0092", - "\u0003\u0002\u0002\u0002\u0095\u0093\u0003\u0002\u0002\u0002\u0095\u0094", - "\u0003\u0002\u0002\u0002\u0096#\u0003\u0002\u0002\u0002\u0097\u009b", - "\u0005*\u0016\u0002\u0098\u009b\u0007\u0011\u0002\u0002\u0099\u009b", - "\u0007\u0012\u0002\u0002\u009a\u0097\u0003\u0002\u0002\u0002\u009a\u0098", - "\u0003\u0002\u0002\u0002\u009a\u0099\u0003\u0002\u0002\u0002\u009b%", - "\u0003\u0002\u0002\u0002\u009c\u009d\u0007\u000b\u0002\u0002\u009d\u009e", - "\u0005\u0012\n\u0002\u009e\u009f\u0007\f\u0002\u0002\u009f\'\u0003\u0002", - "\u0002\u0002\u00a0\u00a4\u0007\r\u0002\u0002\u00a1\u00a3\u0005\u001c", - "\u000f\u0002\u00a2\u00a1\u0003\u0002\u0002\u0002\u00a3\u00a6\u0003\u0002", - "\u0002\u0002\u00a4\u00a2\u0003\u0002\u0002\u0002\u00a4\u00a5\u0003\u0002", - "\u0002\u0002\u00a5\u00a7\u0003\u0002\u0002\u0002\u00a6\u00a4\u0003\u0002", - "\u0002\u0002\u00a7\u00a8\u0007\u000e\u0002\u0002\u00a8)\u0003\u0002", - "\u0002\u0002\u00a9\u00ad\u0007\u0013\u0002\u0002\u00aa\u00ae\u0007\u0019", - "\u0002\u0002\u00ab\u00ac\u0007\u000f\u0002\u0002\u00ac\u00ae\u0005,", - "\u0017\u0002\u00ad\u00aa\u0003\u0002\u0002\u0002\u00ad\u00ab\u0003\u0002", - "\u0002\u0002\u00ad\u00ae\u0003\u0002\u0002\u0002\u00ae+\u0003\u0002", - "\u0002\u0002\u00af\u00b2\u0007\u0015\u0002\u0002\u00b0\u00b2\u0005.", - "\u0018\u0002\u00b1\u00af\u0003\u0002\u0002\u0002\u00b1\u00b0\u0003\u0002", - "\u0002\u0002\u00b2-\u0003\u0002\u0002\u0002\u00b3\u00b4\t\u0002\u0002", - "\u0002\u00b4/\u0003\u0002\u0002\u0002\u00133>'", "'['", "']'", "'('", "')'", - "'^^'" ]; - -var symbolicNames = [ null, null, null, null, null, null, null, null, null, - null, null, null, null, null, "COMMENT", "NumericLiteral", - "BooleanLiteral", "String", "BlankNode", "IRIREF", - "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", - "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", - "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", "WS", - "ANON", "PN_CHARS_BASE", "PN_CHARS_U", "PN_CHARS", - "BASE", "PREFIX", "PN_PREFIX", "PN_LOCAL", "PLX", - "PERCENT", "HEX", "PN_LOCAL_ESC" ]; -turtlestarParser.symbolicNames = symbolicNames; - -var ruleNames = [ "turtleStarDoc", "statement", "directive", "prefixID", - "base", "sparqlBase", "sparqlPrefix", "triples", "predicateObjectList", - "objectList", "verb", "subject", "predicate", "object", - "tripleX", "subjectX", "objectX", "literal", "blankNodePropertyList", - "collection", "rdfLiteral", "iri", "prefixedName" ]; - -function turtlestarParser (input) { - antlr4.Parser.call(this, input); - this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache); - this.ruleNames = ruleNames; - this.literalNames = literalNames; - this.symbolicNames = symbolicNames; - return this; -} - -turtlestarParser.prototype = Object.create(antlr4.Parser.prototype); -turtlestarParser.prototype.constructor = turtlestarParser; - -Object.defineProperty(turtlestarParser.prototype, "atn", { - get : function() { - return atn; - } -}); - -turtlestarParser.EOF = antlr4.Token.EOF; -turtlestarParser.T__0 = 1; -turtlestarParser.T__1 = 2; -turtlestarParser.T__2 = 3; -turtlestarParser.T__3 = 4; -turtlestarParser.T__4 = 5; -turtlestarParser.T__5 = 6; -turtlestarParser.T__6 = 7; -turtlestarParser.T__7 = 8; -turtlestarParser.T__8 = 9; -turtlestarParser.T__9 = 10; -turtlestarParser.T__10 = 11; -turtlestarParser.T__11 = 12; -turtlestarParser.T__12 = 13; -turtlestarParser.COMMENT = 14; -turtlestarParser.NumericLiteral = 15; -turtlestarParser.BooleanLiteral = 16; -turtlestarParser.String = 17; -turtlestarParser.BlankNode = 18; -turtlestarParser.IRIREF = 19; -turtlestarParser.PNAME_NS = 20; -turtlestarParser.PNAME_LN = 21; -turtlestarParser.BLANK_NODE_LABEL = 22; -turtlestarParser.LANGTAG = 23; -turtlestarParser.INTEGER = 24; -turtlestarParser.DECIMAL = 25; -turtlestarParser.DOUBLE = 26; -turtlestarParser.EXPONENT = 27; -turtlestarParser.STRING_LITERAL_LONG_SINGLE_QUOTE = 28; -turtlestarParser.STRING_LITERAL_LONG_QUOTE = 29; -turtlestarParser.STRING_LITERAL_QUOTE = 30; -turtlestarParser.STRING_LITERAL_SINGLE_QUOTE = 31; -turtlestarParser.UCHAR = 32; -turtlestarParser.ECHAR = 33; -turtlestarParser.WS = 34; -turtlestarParser.ANON = 35; -turtlestarParser.PN_CHARS_BASE = 36; -turtlestarParser.PN_CHARS_U = 37; -turtlestarParser.PN_CHARS = 38; -turtlestarParser.BASE = 39; -turtlestarParser.PREFIX = 40; -turtlestarParser.PN_PREFIX = 41; -turtlestarParser.PN_LOCAL = 42; -turtlestarParser.PLX = 43; -turtlestarParser.PERCENT = 44; -turtlestarParser.HEX = 45; -turtlestarParser.PN_LOCAL_ESC = 46; - -turtlestarParser.RULE_turtleStarDoc = 0; -turtlestarParser.RULE_statement = 1; -turtlestarParser.RULE_directive = 2; -turtlestarParser.RULE_prefixID = 3; -turtlestarParser.RULE_base = 4; -turtlestarParser.RULE_sparqlBase = 5; -turtlestarParser.RULE_sparqlPrefix = 6; -turtlestarParser.RULE_triples = 7; -turtlestarParser.RULE_predicateObjectList = 8; -turtlestarParser.RULE_objectList = 9; -turtlestarParser.RULE_verb = 10; -turtlestarParser.RULE_subject = 11; -turtlestarParser.RULE_predicate = 12; -turtlestarParser.RULE_object = 13; -turtlestarParser.RULE_tripleX = 14; -turtlestarParser.RULE_subjectX = 15; -turtlestarParser.RULE_objectX = 16; -turtlestarParser.RULE_literal = 17; -turtlestarParser.RULE_blankNodePropertyList = 18; -turtlestarParser.RULE_collection = 19; -turtlestarParser.RULE_rdfLiteral = 20; -turtlestarParser.RULE_iri = 21; -turtlestarParser.RULE_prefixedName = 22; - -function TurtleStarDocContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_turtleStarDoc; - return this; -} - -TurtleStarDocContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -TurtleStarDocContext.prototype.constructor = TurtleStarDocContext; - -TurtleStarDocContext.prototype.EOF = function() { - return this.getToken(turtlestarParser.EOF, 0); -}; - -TurtleStarDocContext.prototype.statement = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(StatementContext); - } else { - return this.getTypedRuleContext(StatementContext,i); - } -}; - -TurtleStarDocContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterTurtleStarDoc(this); - } -}; - -TurtleStarDocContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitTurtleStarDoc(this); - } -}; - -TurtleStarDocContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitTurtleStarDoc(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.TurtleStarDocContext = TurtleStarDocContext; - -turtlestarParser.prototype.turtleStarDoc = function() { - - var localctx = new TurtleStarDocContext(this, this._ctx, this.state); - this.enterRule(localctx, 0, turtlestarParser.RULE_turtleStarDoc); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 49; - this._errHandler.sync(this); - _la = this._input.LA(1); - while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__1) | (1 << turtlestarParser.T__2) | (1 << turtlestarParser.T__6) | (1 << turtlestarParser.T__8) | (1 << turtlestarParser.T__10) | (1 << turtlestarParser.BlankNode) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0) || _la===turtlestarParser.BASE || _la===turtlestarParser.PREFIX) { - this.state = 46; - this.statement(); - this.state = 51; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 52; - this.match(turtlestarParser.EOF); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function StatementContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_statement; - return this; -} - -StatementContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -StatementContext.prototype.constructor = StatementContext; - -StatementContext.prototype.directive = function() { - return this.getTypedRuleContext(DirectiveContext,0); -}; - -StatementContext.prototype.triples = function() { - return this.getTypedRuleContext(TriplesContext,0); -}; - -StatementContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterStatement(this); - } -}; - -StatementContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitStatement(this); - } -}; - -StatementContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitStatement(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.StatementContext = StatementContext; - -turtlestarParser.prototype.statement = function() { - - var localctx = new StatementContext(this, this._ctx, this.state); - this.enterRule(localctx, 2, turtlestarParser.RULE_statement); - try { - this.state = 58; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.T__1: - case turtlestarParser.T__2: - case turtlestarParser.BASE: - case turtlestarParser.PREFIX: - this.enterOuterAlt(localctx, 1); - this.state = 54; - this.directive(); - break; - case turtlestarParser.T__6: - case turtlestarParser.T__8: - case turtlestarParser.T__10: - case turtlestarParser.BlankNode: - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 2); - this.state = 55; - this.triples(); - this.state = 56; - this.match(turtlestarParser.T__0); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function DirectiveContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_directive; - return this; -} - -DirectiveContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -DirectiveContext.prototype.constructor = DirectiveContext; - -DirectiveContext.prototype.prefixID = function() { - return this.getTypedRuleContext(PrefixIDContext,0); -}; - -DirectiveContext.prototype.base = function() { - return this.getTypedRuleContext(BaseContext,0); -}; - -DirectiveContext.prototype.sparqlPrefix = function() { - return this.getTypedRuleContext(SparqlPrefixContext,0); -}; - -DirectiveContext.prototype.sparqlBase = function() { - return this.getTypedRuleContext(SparqlBaseContext,0); -}; - -DirectiveContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterDirective(this); - } -}; - -DirectiveContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitDirective(this); - } -}; - -DirectiveContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitDirective(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.DirectiveContext = DirectiveContext; - -turtlestarParser.prototype.directive = function() { - - var localctx = new DirectiveContext(this, this._ctx, this.state); - this.enterRule(localctx, 4, turtlestarParser.RULE_directive); - try { - this.state = 64; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.T__1: - this.enterOuterAlt(localctx, 1); - this.state = 60; - this.prefixID(); - break; - case turtlestarParser.T__2: - this.enterOuterAlt(localctx, 2); - this.state = 61; - this.base(); - break; - case turtlestarParser.PREFIX: - this.enterOuterAlt(localctx, 3); - this.state = 62; - this.sparqlPrefix(); - break; - case turtlestarParser.BASE: - this.enterOuterAlt(localctx, 4); - this.state = 63; - this.sparqlBase(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PrefixIDContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_prefixID; - return this; -} - -PrefixIDContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PrefixIDContext.prototype.constructor = PrefixIDContext; - -PrefixIDContext.prototype.PNAME_NS = function() { - return this.getToken(turtlestarParser.PNAME_NS, 0); -}; - -PrefixIDContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; - -PrefixIDContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPrefixID(this); - } -}; - -PrefixIDContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPrefixID(this); - } -}; - -PrefixIDContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPrefixID(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.PrefixIDContext = PrefixIDContext; - -turtlestarParser.prototype.prefixID = function() { - - var localctx = new PrefixIDContext(this, this._ctx, this.state); - this.enterRule(localctx, 6, turtlestarParser.RULE_prefixID); - try { - this.enterOuterAlt(localctx, 1); - this.state = 66; - this.match(turtlestarParser.T__1); - this.state = 67; - this.match(turtlestarParser.PNAME_NS); - this.state = 68; - this.match(turtlestarParser.IRIREF); - this.state = 69; - this.match(turtlestarParser.T__0); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function BaseContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_base; - return this; -} - -BaseContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -BaseContext.prototype.constructor = BaseContext; - -BaseContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; - -BaseContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterBase(this); - } -}; - -BaseContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitBase(this); - } -}; - -BaseContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitBase(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.BaseContext = BaseContext; - -turtlestarParser.prototype.base = function() { - - var localctx = new BaseContext(this, this._ctx, this.state); - this.enterRule(localctx, 8, turtlestarParser.RULE_base); - try { - this.enterOuterAlt(localctx, 1); - this.state = 71; - this.match(turtlestarParser.T__2); - this.state = 72; - this.match(turtlestarParser.IRIREF); - this.state = 73; - this.match(turtlestarParser.T__0); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SparqlBaseContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_sparqlBase; - return this; -} - -SparqlBaseContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SparqlBaseContext.prototype.constructor = SparqlBaseContext; - -SparqlBaseContext.prototype.BASE = function() { - return this.getToken(turtlestarParser.BASE, 0); -}; - -SparqlBaseContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; - -SparqlBaseContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSparqlBase(this); - } -}; - -SparqlBaseContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSparqlBase(this); - } -}; - -SparqlBaseContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSparqlBase(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.SparqlBaseContext = SparqlBaseContext; - -turtlestarParser.prototype.sparqlBase = function() { - - var localctx = new SparqlBaseContext(this, this._ctx, this.state); - this.enterRule(localctx, 10, turtlestarParser.RULE_sparqlBase); - try { - this.enterOuterAlt(localctx, 1); - this.state = 75; - this.match(turtlestarParser.BASE); - this.state = 76; - this.match(turtlestarParser.IRIREF); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SparqlPrefixContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_sparqlPrefix; - return this; -} - -SparqlPrefixContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SparqlPrefixContext.prototype.constructor = SparqlPrefixContext; - -SparqlPrefixContext.prototype.PREFIX = function() { - return this.getToken(turtlestarParser.PREFIX, 0); -}; - -SparqlPrefixContext.prototype.PNAME_NS = function() { - return this.getToken(turtlestarParser.PNAME_NS, 0); -}; - -SparqlPrefixContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; - -SparqlPrefixContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSparqlPrefix(this); - } -}; - -SparqlPrefixContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSparqlPrefix(this); - } -}; - -SparqlPrefixContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSparqlPrefix(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.SparqlPrefixContext = SparqlPrefixContext; - -turtlestarParser.prototype.sparqlPrefix = function() { - - var localctx = new SparqlPrefixContext(this, this._ctx, this.state); - this.enterRule(localctx, 12, turtlestarParser.RULE_sparqlPrefix); - try { - this.enterOuterAlt(localctx, 1); - this.state = 78; - this.match(turtlestarParser.PREFIX); - this.state = 79; - this.match(turtlestarParser.PNAME_NS); - this.state = 80; - this.match(turtlestarParser.IRIREF); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function TriplesContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_triples; - return this; -} - -TriplesContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -TriplesContext.prototype.constructor = TriplesContext; - -TriplesContext.prototype.subject = function() { - return this.getTypedRuleContext(SubjectContext,0); -}; - -TriplesContext.prototype.predicateObjectList = function() { - return this.getTypedRuleContext(PredicateObjectListContext,0); -}; - -TriplesContext.prototype.blankNodePropertyList = function() { - return this.getTypedRuleContext(BlankNodePropertyListContext,0); -}; - -TriplesContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterTriples(this); - } -}; - -TriplesContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitTriples(this); - } -}; - -TriplesContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitTriples(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.TriplesContext = TriplesContext; - -turtlestarParser.prototype.triples = function() { - - var localctx = new TriplesContext(this, this._ctx, this.state); - this.enterRule(localctx, 14, turtlestarParser.RULE_triples); - var _la = 0; // Token type - try { - this.state = 89; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.T__6: - case turtlestarParser.T__10: - case turtlestarParser.BlankNode: - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 82; - this.subject(); - this.state = 83; - this.predicateObjectList(); - break; - case turtlestarParser.T__8: - this.enterOuterAlt(localctx, 2); - this.state = 85; - this.blankNodePropertyList(); - this.state = 87; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__5) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0)) { - this.state = 86; - this.predicateObjectList(); - } - - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PredicateObjectListContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_predicateObjectList; - return this; -} - -PredicateObjectListContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PredicateObjectListContext.prototype.constructor = PredicateObjectListContext; - -PredicateObjectListContext.prototype.verb = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(VerbContext); - } else { - return this.getTypedRuleContext(VerbContext,i); - } -}; - -PredicateObjectListContext.prototype.objectList = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectListContext); - } else { - return this.getTypedRuleContext(ObjectListContext,i); - } -}; - -PredicateObjectListContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPredicateObjectList(this); - } -}; - -PredicateObjectListContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPredicateObjectList(this); - } -}; - -PredicateObjectListContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPredicateObjectList(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.PredicateObjectListContext = PredicateObjectListContext; - -turtlestarParser.prototype.predicateObjectList = function() { - - var localctx = new PredicateObjectListContext(this, this._ctx, this.state); - this.enterRule(localctx, 16, turtlestarParser.RULE_predicateObjectList); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 91; - this.verb(); - this.state = 92; - this.objectList(); - this.state = 101; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(_la===turtlestarParser.T__3) { - this.state = 93; - this.match(turtlestarParser.T__3); - this.state = 97; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__5) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0)) { - this.state = 94; - this.verb(); - this.state = 95; - this.objectList(); - } - - this.state = 103; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function ObjectListContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_objectList; - return this; -} - -ObjectListContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -ObjectListContext.prototype.constructor = ObjectListContext; - -ObjectListContext.prototype.object = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectContext); - } else { - return this.getTypedRuleContext(ObjectContext,i); - } -}; - -ObjectListContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterObjectList(this); - } -}; - -ObjectListContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitObjectList(this); - } -}; - -ObjectListContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitObjectList(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.ObjectListContext = ObjectListContext; - -turtlestarParser.prototype.objectList = function() { - - var localctx = new ObjectListContext(this, this._ctx, this.state); - this.enterRule(localctx, 18, turtlestarParser.RULE_objectList); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 104; - this.object(); - this.state = 109; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(_la===turtlestarParser.T__4) { - this.state = 105; - this.match(turtlestarParser.T__4); - this.state = 106; - this.object(); - this.state = 111; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function VerbContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_verb; - return this; -} - -VerbContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -VerbContext.prototype.constructor = VerbContext; - -VerbContext.prototype.predicate = function() { - return this.getTypedRuleContext(PredicateContext,0); -}; - -VerbContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterVerb(this); - } -}; - -VerbContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitVerb(this); - } -}; - -VerbContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitVerb(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.VerbContext = VerbContext; - -turtlestarParser.prototype.verb = function() { - - var localctx = new VerbContext(this, this._ctx, this.state); - this.enterRule(localctx, 20, turtlestarParser.RULE_verb); - try { - this.state = 114; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 112; - this.predicate(); - break; - case turtlestarParser.T__5: - this.enterOuterAlt(localctx, 2); - this.state = 113; - this.match(turtlestarParser.T__5); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SubjectContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_subject; - return this; -} - -SubjectContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SubjectContext.prototype.constructor = SubjectContext; - -SubjectContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; - -SubjectContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; - -SubjectContext.prototype.collection = function() { - return this.getTypedRuleContext(CollectionContext,0); -}; - -SubjectContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; - -SubjectContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSubject(this); - } -}; - -SubjectContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSubject(this); - } -}; - -SubjectContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSubject(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.SubjectContext = SubjectContext; - -turtlestarParser.prototype.subject = function() { - - var localctx = new SubjectContext(this, this._ctx, this.state); - this.enterRule(localctx, 22, turtlestarParser.RULE_subject); - try { - this.state = 120; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 116; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 117; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.T__10: - this.enterOuterAlt(localctx, 3); - this.state = 118; - this.collection(); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 4); - this.state = 119; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PredicateContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_predicate; - return this; -} - -PredicateContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PredicateContext.prototype.constructor = PredicateContext; - -PredicateContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; - -PredicateContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPredicate(this); - } -}; - -PredicateContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPredicate(this); - } -}; - -PredicateContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPredicate(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.PredicateContext = PredicateContext; - -turtlestarParser.prototype.predicate = function() { - - var localctx = new PredicateContext(this, this._ctx, this.state); - this.enterRule(localctx, 24, turtlestarParser.RULE_predicate); - try { - this.enterOuterAlt(localctx, 1); - this.state = 122; - this.iri(); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function ObjectContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_object; - return this; -} - -ObjectContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -ObjectContext.prototype.constructor = ObjectContext; - -ObjectContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; - -ObjectContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; - -ObjectContext.prototype.literal = function() { - return this.getTypedRuleContext(LiteralContext,0); -}; - -ObjectContext.prototype.collection = function() { - return this.getTypedRuleContext(CollectionContext,0); -}; - -ObjectContext.prototype.blankNodePropertyList = function() { - return this.getTypedRuleContext(BlankNodePropertyListContext,0); -}; - -ObjectContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; - -ObjectContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterObject(this); - } -}; - -ObjectContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitObject(this); - } -}; - -ObjectContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitObject(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.ObjectContext = ObjectContext; - -turtlestarParser.prototype.object = function() { - - var localctx = new ObjectContext(this, this._ctx, this.state); - this.enterRule(localctx, 26, turtlestarParser.RULE_object); - try { - this.state = 130; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 124; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 125; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.NumericLiteral: - case turtlestarParser.BooleanLiteral: - case turtlestarParser.String: - this.enterOuterAlt(localctx, 3); - this.state = 126; - this.literal(); - break; - case turtlestarParser.T__10: - this.enterOuterAlt(localctx, 4); - this.state = 127; - this.collection(); - break; - case turtlestarParser.T__8: - this.enterOuterAlt(localctx, 5); - this.state = 128; - this.blankNodePropertyList(); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 6); - this.state = 129; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function TripleXContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_tripleX; - return this; -} - -TripleXContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -TripleXContext.prototype.constructor = TripleXContext; - -TripleXContext.prototype.subjectX = function() { - return this.getTypedRuleContext(SubjectXContext,0); -}; - -TripleXContext.prototype.predicate = function() { - return this.getTypedRuleContext(PredicateContext,0); -}; - -TripleXContext.prototype.objectX = function() { - return this.getTypedRuleContext(ObjectXContext,0); -}; - -TripleXContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterTripleX(this); - } -}; - -TripleXContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitTripleX(this); - } -}; - -TripleXContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitTripleX(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.TripleXContext = TripleXContext; - -turtlestarParser.prototype.tripleX = function() { - - var localctx = new TripleXContext(this, this._ctx, this.state); - this.enterRule(localctx, 28, turtlestarParser.RULE_tripleX); - try { - this.enterOuterAlt(localctx, 1); - this.state = 132; - this.match(turtlestarParser.T__6); - this.state = 133; - this.subjectX(); - this.state = 134; - this.predicate(); - this.state = 135; - this.objectX(); - this.state = 136; - this.match(turtlestarParser.T__7); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SubjectXContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_subjectX; - return this; -} - -SubjectXContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SubjectXContext.prototype.constructor = SubjectXContext; - -SubjectXContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; - -SubjectXContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; - -SubjectXContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; - -SubjectXContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSubjectX(this); - } -}; - -SubjectXContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSubjectX(this); - } -}; - -SubjectXContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSubjectX(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.SubjectXContext = SubjectXContext; - -turtlestarParser.prototype.subjectX = function() { - - var localctx = new SubjectXContext(this, this._ctx, this.state); - this.enterRule(localctx, 30, turtlestarParser.RULE_subjectX); - try { - this.state = 141; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 138; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 139; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 3); - this.state = 140; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function ObjectXContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_objectX; - return this; -} - -ObjectXContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -ObjectXContext.prototype.constructor = ObjectXContext; - -ObjectXContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; - -ObjectXContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; - -ObjectXContext.prototype.literal = function() { - return this.getTypedRuleContext(LiteralContext,0); -}; - -ObjectXContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; - -ObjectXContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterObjectX(this); - } -}; - -ObjectXContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitObjectX(this); - } -}; - -ObjectXContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitObjectX(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.ObjectXContext = ObjectXContext; - -turtlestarParser.prototype.objectX = function() { - - var localctx = new ObjectXContext(this, this._ctx, this.state); - this.enterRule(localctx, 32, turtlestarParser.RULE_objectX); - try { - this.state = 147; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 143; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 144; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.NumericLiteral: - case turtlestarParser.BooleanLiteral: - case turtlestarParser.String: - this.enterOuterAlt(localctx, 3); - this.state = 145; - this.literal(); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 4); - this.state = 146; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function LiteralContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_literal; - return this; -} - -LiteralContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -LiteralContext.prototype.constructor = LiteralContext; - -LiteralContext.prototype.rdfLiteral = function() { - return this.getTypedRuleContext(RdfLiteralContext,0); -}; - -LiteralContext.prototype.NumericLiteral = function() { - return this.getToken(turtlestarParser.NumericLiteral, 0); -}; - -LiteralContext.prototype.BooleanLiteral = function() { - return this.getToken(turtlestarParser.BooleanLiteral, 0); -}; - -LiteralContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterLiteral(this); - } -}; - -LiteralContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitLiteral(this); - } -}; - -LiteralContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitLiteral(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.LiteralContext = LiteralContext; - -turtlestarParser.prototype.literal = function() { - - var localctx = new LiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 34, turtlestarParser.RULE_literal); - try { - this.state = 152; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.String: - this.enterOuterAlt(localctx, 1); - this.state = 149; - this.rdfLiteral(); - break; - case turtlestarParser.NumericLiteral: - this.enterOuterAlt(localctx, 2); - this.state = 150; - this.match(turtlestarParser.NumericLiteral); - break; - case turtlestarParser.BooleanLiteral: - this.enterOuterAlt(localctx, 3); - this.state = 151; - this.match(turtlestarParser.BooleanLiteral); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function BlankNodePropertyListContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_blankNodePropertyList; - return this; -} - -BlankNodePropertyListContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -BlankNodePropertyListContext.prototype.constructor = BlankNodePropertyListContext; - -BlankNodePropertyListContext.prototype.predicateObjectList = function() { - return this.getTypedRuleContext(PredicateObjectListContext,0); -}; - -BlankNodePropertyListContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterBlankNodePropertyList(this); - } -}; - -BlankNodePropertyListContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitBlankNodePropertyList(this); - } -}; - -BlankNodePropertyListContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitBlankNodePropertyList(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.BlankNodePropertyListContext = BlankNodePropertyListContext; - -turtlestarParser.prototype.blankNodePropertyList = function() { - - var localctx = new BlankNodePropertyListContext(this, this._ctx, this.state); - this.enterRule(localctx, 36, turtlestarParser.RULE_blankNodePropertyList); - try { - this.enterOuterAlt(localctx, 1); - this.state = 154; - this.match(turtlestarParser.T__8); - this.state = 155; - this.predicateObjectList(); - this.state = 156; - this.match(turtlestarParser.T__9); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function CollectionContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_collection; - return this; -} - -CollectionContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -CollectionContext.prototype.constructor = CollectionContext; - -CollectionContext.prototype.object = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectContext); - } else { - return this.getTypedRuleContext(ObjectContext,i); - } -}; - -CollectionContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterCollection(this); - } -}; - -CollectionContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitCollection(this); - } -}; - -CollectionContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitCollection(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.CollectionContext = CollectionContext; - -turtlestarParser.prototype.collection = function() { - - var localctx = new CollectionContext(this, this._ctx, this.state); - this.enterRule(localctx, 38, turtlestarParser.RULE_collection); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 158; - this.match(turtlestarParser.T__10); - this.state = 162; - this._errHandler.sync(this); - _la = this._input.LA(1); - while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__6) | (1 << turtlestarParser.T__8) | (1 << turtlestarParser.T__10) | (1 << turtlestarParser.NumericLiteral) | (1 << turtlestarParser.BooleanLiteral) | (1 << turtlestarParser.String) | (1 << turtlestarParser.BlankNode) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0)) { - this.state = 159; - this.object(); - this.state = 164; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 165; - this.match(turtlestarParser.T__11); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function RdfLiteralContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_rdfLiteral; - return this; -} - -RdfLiteralContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -RdfLiteralContext.prototype.constructor = RdfLiteralContext; - -RdfLiteralContext.prototype.String = function() { - return this.getToken(turtlestarParser.String, 0); -}; - -RdfLiteralContext.prototype.LANGTAG = function() { - return this.getToken(turtlestarParser.LANGTAG, 0); -}; - -RdfLiteralContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; - -RdfLiteralContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterRdfLiteral(this); - } -}; - -RdfLiteralContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitRdfLiteral(this); - } -}; - -RdfLiteralContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitRdfLiteral(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.RdfLiteralContext = RdfLiteralContext; - -turtlestarParser.prototype.rdfLiteral = function() { - - var localctx = new RdfLiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 40, turtlestarParser.RULE_rdfLiteral); - try { - this.enterOuterAlt(localctx, 1); - this.state = 167; - this.match(turtlestarParser.String); - this.state = 171; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case turtlestarParser.LANGTAG: - this.state = 168; - this.match(turtlestarParser.LANGTAG); - break; - case turtlestarParser.T__12: - this.state = 169; - this.match(turtlestarParser.T__12); - this.state = 170; - this.iri(); - break; - case turtlestarParser.T__0: - case turtlestarParser.T__3: - case turtlestarParser.T__4: - case turtlestarParser.T__6: - case turtlestarParser.T__7: - case turtlestarParser.T__8: - case turtlestarParser.T__9: - case turtlestarParser.T__10: - case turtlestarParser.T__11: - case turtlestarParser.NumericLiteral: - case turtlestarParser.BooleanLiteral: - case turtlestarParser.String: - case turtlestarParser.BlankNode: - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function IriContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_iri; - return this; -} - -IriContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -IriContext.prototype.constructor = IriContext; - -IriContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; - -IriContext.prototype.prefixedName = function() { - return this.getTypedRuleContext(PrefixedNameContext,0); -}; - -IriContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterIri(this); - } -}; - -IriContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitIri(this); - } -}; - -IriContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitIri(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.IriContext = IriContext; - -turtlestarParser.prototype.iri = function() { - - var localctx = new IriContext(this, this._ctx, this.state); - this.enterRule(localctx, 42, turtlestarParser.RULE_iri); - try { - this.state = 175; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - this.enterOuterAlt(localctx, 1); - this.state = 173; - this.match(turtlestarParser.IRIREF); - break; - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 2); - this.state = 174; - this.prefixedName(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PrefixedNameContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_prefixedName; - return this; -} - -PrefixedNameContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PrefixedNameContext.prototype.constructor = PrefixedNameContext; - -PrefixedNameContext.prototype.PNAME_NS = function() { - return this.getToken(turtlestarParser.PNAME_NS, 0); -}; - -PrefixedNameContext.prototype.PNAME_LN = function() { - return this.getToken(turtlestarParser.PNAME_LN, 0); -}; - -PrefixedNameContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPrefixedName(this); - } -}; - -PrefixedNameContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPrefixedName(this); - } -}; - -PrefixedNameContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPrefixedName(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.PrefixedNameContext = PrefixedNameContext; - -turtlestarParser.prototype.prefixedName = function() { - - var localctx = new PrefixedNameContext(this, this._ctx, this.state); - this.enterRule(localctx, 44, turtlestarParser.RULE_prefixedName); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 177; - _la = this._input.LA(1); - if(!(_la===turtlestarParser.PNAME_NS || _la===turtlestarParser.PNAME_LN)) { - this._errHandler.recoverInline(this); - } - else { - this._errHandler.reportMatch(this); - this.consume(); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; - - -exports.turtlestarParser = turtlestarParser; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 -// jshint ignore: start -var antlr4 = __webpack_require__(12); - -// This class defines a complete listener for a parse tree produced by turtlestarParser. -function turtlestarListener() { - antlr4.tree.ParseTreeListener.call(this); - return this; -} - -turtlestarListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype); -turtlestarListener.prototype.constructor = turtlestarListener; - -// Enter a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarListener.prototype.enterTurtleStarDoc = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarListener.prototype.exitTurtleStarDoc = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#statement. -turtlestarListener.prototype.enterStatement = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#statement. -turtlestarListener.prototype.exitStatement = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#directive. -turtlestarListener.prototype.enterDirective = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#directive. -turtlestarListener.prototype.exitDirective = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#prefixID. -turtlestarListener.prototype.enterPrefixID = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#prefixID. -turtlestarListener.prototype.exitPrefixID = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#base. -turtlestarListener.prototype.enterBase = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#base. -turtlestarListener.prototype.exitBase = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#sparqlBase. -turtlestarListener.prototype.enterSparqlBase = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#sparqlBase. -turtlestarListener.prototype.exitSparqlBase = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarListener.prototype.enterSparqlPrefix = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarListener.prototype.exitSparqlPrefix = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#triples. -turtlestarListener.prototype.enterTriples = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#triples. -turtlestarListener.prototype.exitTriples = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarListener.prototype.enterPredicateObjectList = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarListener.prototype.exitPredicateObjectList = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#objectList. -turtlestarListener.prototype.enterObjectList = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#objectList. -turtlestarListener.prototype.exitObjectList = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#verb. -turtlestarListener.prototype.enterVerb = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#verb. -turtlestarListener.prototype.exitVerb = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#subject. -turtlestarListener.prototype.enterSubject = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#subject. -turtlestarListener.prototype.exitSubject = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#predicate. -turtlestarListener.prototype.enterPredicate = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#predicate. -turtlestarListener.prototype.exitPredicate = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#object. -turtlestarListener.prototype.enterObject = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#object. -turtlestarListener.prototype.exitObject = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#tripleX. -turtlestarListener.prototype.enterTripleX = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#tripleX. -turtlestarListener.prototype.exitTripleX = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#subjectX. -turtlestarListener.prototype.enterSubjectX = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#subjectX. -turtlestarListener.prototype.exitSubjectX = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#objectX. -turtlestarListener.prototype.enterObjectX = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#objectX. -turtlestarListener.prototype.exitObjectX = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#literal. -turtlestarListener.prototype.enterLiteral = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#literal. -turtlestarListener.prototype.exitLiteral = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarListener.prototype.enterBlankNodePropertyList = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarListener.prototype.exitBlankNodePropertyList = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#collection. -turtlestarListener.prototype.enterCollection = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#collection. -turtlestarListener.prototype.exitCollection = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarListener.prototype.enterRdfLiteral = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarListener.prototype.exitRdfLiteral = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#iri. -turtlestarListener.prototype.enterIri = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#iri. -turtlestarListener.prototype.exitIri = function(ctx) { -}; - - -// Enter a parse tree produced by turtlestarParser#prefixedName. -turtlestarListener.prototype.enterPrefixedName = function(ctx) { -}; - -// Exit a parse tree produced by turtlestarParser#prefixedName. -turtlestarListener.prototype.exitPrefixedName = function(ctx) { -}; - - - -exports.turtlestarListener = turtlestarListener; - -/***/ }), -/* 33 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 -// jshint ignore: start -var antlr4 = __webpack_require__(12); - -// This class defines a complete generic visitor for a parse tree produced by turtlestarParser. - -function turtlestarVisitor() { - antlr4.tree.ParseTreeVisitor.call(this); - return this; -} - -turtlestarVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype); -turtlestarVisitor.prototype.constructor = turtlestarVisitor; - -// Visit a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarVisitor.prototype.visitTurtleStarDoc = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#statement. -turtlestarVisitor.prototype.visitStatement = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#directive. -turtlestarVisitor.prototype.visitDirective = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#prefixID. -turtlestarVisitor.prototype.visitPrefixID = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#base. -turtlestarVisitor.prototype.visitBase = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#sparqlBase. -turtlestarVisitor.prototype.visitSparqlBase = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarVisitor.prototype.visitSparqlPrefix = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#triples. -turtlestarVisitor.prototype.visitTriples = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarVisitor.prototype.visitPredicateObjectList = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#objectList. -turtlestarVisitor.prototype.visitObjectList = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#verb. -turtlestarVisitor.prototype.visitVerb = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#subject. -turtlestarVisitor.prototype.visitSubject = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#predicate. -turtlestarVisitor.prototype.visitPredicate = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#object. -turtlestarVisitor.prototype.visitObject = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#tripleX. -turtlestarVisitor.prototype.visitTripleX = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#subjectX. -turtlestarVisitor.prototype.visitSubjectX = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#objectX. -turtlestarVisitor.prototype.visitObjectX = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#literal. -turtlestarVisitor.prototype.visitLiteral = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarVisitor.prototype.visitBlankNodePropertyList = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#collection. -turtlestarVisitor.prototype.visitCollection = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarVisitor.prototype.visitRdfLiteral = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#iri. -turtlestarVisitor.prototype.visitIri = function(ctx) { - return this.visitChildren(ctx); -}; - - -// Visit a parse tree produced by turtlestarParser#prefixedName. -turtlestarVisitor.prototype.visitPrefixedName = function(ctx) { - return this.visitChildren(ctx); -}; - - - -exports.turtlestarVisitor = turtlestarVisitor; - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -var antlr4 = __webpack_require__(12); -var TurtleStarLexer = __webpack_require__(52).turtlestarLexer; -var TurtleStarParser = __webpack_require__(31).turtlestarParser; -var TurtleStarPrefixListener = __webpack_require__(53).turtlestarPrefixListener; -// var TurtleStarPrintListener = require('./turtlestarPrintListener').turtlestarPrintListener; -var TurtleStarPrintVisitor = __webpack_require__(54).turtlestarPrintVisitor; - -function parse(input, listener) { - var chars = new antlr4.InputStream(input); - - var turtlestarLexer = new TurtleStarLexer(chars); - turtlestarLexer.removeErrorListeners(); - turtlestarLexer.addErrorListener(listener); - - var tokens = new antlr4.CommonTokenStream(turtlestarLexer); - - var turtlestarParser = new TurtleStarParser(tokens); - turtlestarParser.removeErrorListeners(); - turtlestarParser.removeParseListeners(); - - if (listener.syntaxError) - // will call listener with any syntax (parser/lexer) error - turtlestarParser.addErrorListener(listener); - - if (listener.unknownPrefix) - // will call listener with any prefix errors - turtlestarParser.addParseListener(new TurtleStarPrefixListener(listener)); - - // if (listener.newAstLine) - // will call listener with individual ast lines - // turtlestarParser.addParseListener(new TurtleStarPrintListener(listener)); - - var ast = turtlestarParser.turtleStarDoc() - if (listener.newAstLine) - new TurtleStarPrintVisitor(listener).visit(ast) -} - -exports.parse = parse; - -/***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -exports.ATN = __webpack_require__(7).ATN; -exports.ATNDeserializer = __webpack_require__(21).ATNDeserializer; -exports.LexerATNSimulator = __webpack_require__(38).LexerATNSimulator; -exports.ParserATNSimulator = __webpack_require__(41).ParserATNSimulator; -exports.PredictionMode = __webpack_require__(26).PredictionMode; - - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -var Set = __webpack_require__(0).Set; -var BitSet = __webpack_require__(0).BitSet; -var Token = __webpack_require__(1).Token; -var ATNConfig = __webpack_require__(13).ATNConfig; -var Interval = __webpack_require__(2).Interval; -var IntervalSet = __webpack_require__(2).IntervalSet; -var RuleStopState = __webpack_require__(3).RuleStopState; -var RuleTransition = __webpack_require__(8).RuleTransition; -var NotSetTransition = __webpack_require__(8).NotSetTransition; -var WildcardTransition = __webpack_require__(8).WildcardTransition; -var AbstractPredicateTransition = __webpack_require__(8).AbstractPredicateTransition; - -var pc = __webpack_require__(6); -var predictionContextFromRuleContext = pc.predictionContextFromRuleContext; -var PredictionContext = pc.PredictionContext; -var SingletonPredictionContext = pc.SingletonPredictionContext; - -function LL1Analyzer (atn) { - this.atn = atn; -} - -//* Special value added to the lookahead sets to indicate that we hit -// a predicate during analysis if {@code seeThruPreds==false}. -/// -LL1Analyzer.HIT_PRED = Token.INVALID_TYPE; - - -//* -// Calculates the SLL(1) expected lookahead set for each outgoing transition -// of an {@link ATNState}. The returned array has one element for each -// outgoing transition in {@code s}. If the closure from transition -// i leads to a semantic predicate before matching a symbol, the -// element at index i of the result will be {@code null}. -// -// @param s the ATN state -// @return the expected symbols for each outgoing transition of {@code s}. -/// -LL1Analyzer.prototype.getDecisionLookahead = function(s) { - if (s === null) { - return null; - } - var count = s.transitions.length; - var look = []; - for(var alt=0; alt< count; alt++) { - look[alt] = new IntervalSet(); - var lookBusy = new Set(); - var seeThruPreds = false; // fail to get lookahead upon pred - this._LOOK(s.transition(alt).target, null, PredictionContext.EMPTY, - look[alt], lookBusy, new BitSet(), seeThruPreds, false); - // Wipe out lookahead for this alternative if we found nothing - // or we had a predicate when we !seeThruPreds - if (look[alt].length===0 || look[alt].contains(LL1Analyzer.HIT_PRED)) { - look[alt] = null; - } - } - return look; -}; - -//* -// Compute set of tokens that can follow {@code s} in the ATN in the -// specified {@code ctx}. -// -//

          If {@code ctx} is {@code null} and the end of the rule containing -// {@code s} is reached, {@link Token//EPSILON} is added to the result set. -// If {@code ctx} is not {@code null} and the end of the outermost rule is -// reached, {@link Token//EOF} is added to the result set.

          -// -// @param s the ATN state -// @param stopState the ATN state to stop at. This can be a -// {@link BlockEndState} to detect epsilon paths through a closure. -// @param ctx the complete parser context, or {@code null} if the context -// should be ignored -// -// @return The set of tokens that can follow {@code s} in the ATN in the -// specified {@code ctx}. -/// -LL1Analyzer.prototype.LOOK = function(s, stopState, ctx) { - var r = new IntervalSet(); - var seeThruPreds = true; // ignore preds; get all lookahead - ctx = ctx || null; - var lookContext = ctx!==null ? predictionContextFromRuleContext(s.atn, ctx) : null; - this._LOOK(s, stopState, lookContext, r, new Set(), new BitSet(), seeThruPreds, true); - return r; -}; - -//* -// Compute set of tokens that can follow {@code s} in the ATN in the -// specified {@code ctx}. -// -//

          If {@code ctx} is {@code null} and {@code stopState} or the end of the -// rule containing {@code s} is reached, {@link Token//EPSILON} is added to -// the result set. If {@code ctx} is not {@code null} and {@code addEOF} is -// {@code true} and {@code stopState} or the end of the outermost rule is -// reached, {@link Token//EOF} is added to the result set.

          -// -// @param s the ATN state. -// @param stopState the ATN state to stop at. This can be a -// {@link BlockEndState} to detect epsilon paths through a closure. -// @param ctx The outer context, or {@code null} if the outer context should -// not be used. -// @param look The result lookahead set. -// @param lookBusy A set used for preventing epsilon closures in the ATN -// from causing a stack overflow. Outside code should pass -// {@code new Set} for this argument. -// @param calledRuleStack A set used for preventing left recursion in the -// ATN from causing a stack overflow. Outside code should pass -// {@code new BitSet()} for this argument. -// @param seeThruPreds {@code true} to true semantic predicates as -// implicitly {@code true} and "see through them", otherwise {@code false} -// to treat semantic predicates as opaque and add {@link //HIT_PRED} to the -// result if one is encountered. -// @param addEOF Add {@link Token//EOF} to the result if the end of the -// outermost context is reached. This parameter has no effect if {@code ctx} -// is {@code null}. -/// -LL1Analyzer.prototype._LOOK = function(s, stopState , ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) { - var c = new ATNConfig({state:s, alt:0, context: ctx}, null); - if (lookBusy.contains(c)) { - return; - } - lookBusy.add(c); - if (s === stopState) { - if (ctx ===null) { - look.addOne(Token.EPSILON); - return; - } else if (ctx.isEmpty() && addEOF) { - look.addOne(Token.EOF); - return; - } - } - if (s instanceof RuleStopState ) { - if (ctx ===null) { - look.addOne(Token.EPSILON); - return; - } else if (ctx.isEmpty() && addEOF) { - look.addOne(Token.EOF); - return; - } - if (ctx !== PredictionContext.EMPTY) { - // run thru all possible stack tops in ctx - for(var i=0; iWe track these variables separately for the DFA and ATN simulation -// because the DFA simulation often has to fail over to the ATN -// simulation. If the ATN simulation fails, we need the DFA to fall -// back to its previously accepted state, if any. If the ATN succeeds, -// then the ATN does the accept and the DFA simulator that invoked it -// can simply return the predicted token type.

          -/// - -var Token = __webpack_require__(1).Token; -var Lexer = __webpack_require__(15).Lexer; -var ATN = __webpack_require__(7).ATN; -var ATNSimulator = __webpack_require__(25).ATNSimulator; -var DFAState = __webpack_require__(11).DFAState; -var ATNConfigSet = __webpack_require__(9).ATNConfigSet; -var OrderedATNConfigSet = __webpack_require__(9).OrderedATNConfigSet; -var PredictionContext = __webpack_require__(6).PredictionContext; -var SingletonPredictionContext = __webpack_require__(6).SingletonPredictionContext; -var RuleStopState = __webpack_require__(3).RuleStopState; -var LexerATNConfig = __webpack_require__(13).LexerATNConfig; -var Transition = __webpack_require__(8).Transition; -var LexerActionExecutor = __webpack_require__(40).LexerActionExecutor; -var LexerNoViableAltException = __webpack_require__(5).LexerNoViableAltException; - -function resetSimState(sim) { - sim.index = -1; - sim.line = 0; - sim.column = -1; - sim.dfaState = null; -} - -function SimState() { - resetSimState(this); - return this; -} - -SimState.prototype.reset = function() { - resetSimState(this); -}; - -function LexerATNSimulator(recog, atn, decisionToDFA, sharedContextCache) { - ATNSimulator.call(this, atn, sharedContextCache); - this.decisionToDFA = decisionToDFA; - this.recog = recog; - // The current token's starting index into the character stream. - // Shared across DFA to ATN simulation in case the ATN fails and the - // DFA did not have a previous accept state. In this case, we use the - // ATN-generated exception object. - this.startIndex = -1; - // line number 1..n within the input/// - this.line = 1; - // The index of the character relative to the beginning of the line - // 0..n-1/// - this.column = 0; - this.mode = Lexer.DEFAULT_MODE; - // Used during DFA/ATN exec to record the most recent accept configuration - // info - this.prevAccept = new SimState(); - // done - return this; -} - -LexerATNSimulator.prototype = Object.create(ATNSimulator.prototype); -LexerATNSimulator.prototype.constructor = LexerATNSimulator; - -LexerATNSimulator.debug = false; -LexerATNSimulator.dfa_debug = false; - -LexerATNSimulator.MIN_DFA_EDGE = 0; -LexerATNSimulator.MAX_DFA_EDGE = 127; // forces unicode to stay in ATN - -LexerATNSimulator.match_calls = 0; - -LexerATNSimulator.prototype.copyState = function(simulator) { - this.column = simulator.column; - this.line = simulator.line; - this.mode = simulator.mode; - this.startIndex = simulator.startIndex; -}; - -LexerATNSimulator.prototype.match = function(input, mode) { - this.match_calls += 1; - this.mode = mode; - var mark = input.mark(); - try { - this.startIndex = input.index; - this.prevAccept.reset(); - var dfa = this.decisionToDFA[mode]; - if (dfa.s0 === null) { - return this.matchATN(input); - } else { - return this.execATN(input, dfa.s0); - } - } finally { - input.release(mark); - } -}; - -LexerATNSimulator.prototype.reset = function() { - this.prevAccept.reset(); - this.startIndex = -1; - this.line = 1; - this.column = 0; - this.mode = Lexer.DEFAULT_MODE; -}; - -LexerATNSimulator.prototype.matchATN = function(input) { - var startState = this.atn.modeToStartState[this.mode]; - - if (LexerATNSimulator.debug) { - console.log("matchATN mode " + this.mode + " start: " + startState); - } - var old_mode = this.mode; - var s0_closure = this.computeStartState(input, startState); - var suppressEdge = s0_closure.hasSemanticContext; - s0_closure.hasSemanticContext = false; - - var next = this.addDFAState(s0_closure); - if (!suppressEdge) { - this.decisionToDFA[this.mode].s0 = next; - } - - var predict = this.execATN(input, next); - - if (LexerATNSimulator.debug) { - console.log("DFA after matchATN: " + this.decisionToDFA[old_mode].toLexerString()); - } - return predict; -}; - -LexerATNSimulator.prototype.execATN = function(input, ds0) { - if (LexerATNSimulator.debug) { - console.log("start state closure=" + ds0.configs); - } - if (ds0.isAcceptState) { - // allow zero-length tokens - this.captureSimState(this.prevAccept, input, ds0); - } - var t = input.LA(1); - var s = ds0; // s is current/from DFA state - - while (true) { // while more work - if (LexerATNSimulator.debug) { - console.log("execATN loop starting closure: " + s.configs); - } - - // As we move src->trg, src->trg, we keep track of the previous trg to - // avoid looking up the DFA state again, which is expensive. - // If the previous target was already part of the DFA, we might - // be able to avoid doing a reach operation upon t. If s!=null, - // it means that semantic predicates didn't prevent us from - // creating a DFA state. Once we know s!=null, we check to see if - // the DFA state has an edge already for t. If so, we can just reuse - // it's configuration set; there's no point in re-computing it. - // This is kind of like doing DFA simulation within the ATN - // simulation because DFA simulation is really just a way to avoid - // computing reach/closure sets. Technically, once we know that - // we have a previously added DFA state, we could jump over to - // the DFA simulator. But, that would mean popping back and forth - // a lot and making things more complicated algorithmically. - // This optimization makes a lot of sense for loops within DFA. - // A character will take us back to an existing DFA state - // that already has lots of edges out of it. e.g., .* in comments. - // print("Target for:" + str(s) + " and:" + str(t)) - var target = this.getExistingTargetState(s, t); - // print("Existing:" + str(target)) - if (target === null) { - target = this.computeTargetState(input, s, t); - // print("Computed:" + str(target)) - } - if (target === ATNSimulator.ERROR) { - break; - } - // If this is a consumable input element, make sure to consume before - // capturing the accept state so the input index, line, and char - // position accurately reflect the state of the interpreter at the - // end of the token. - if (t !== Token.EOF) { - this.consume(input); - } - if (target.isAcceptState) { - this.captureSimState(this.prevAccept, input, target); - if (t === Token.EOF) { - break; - } - } - t = input.LA(1); - s = target; // flip; current DFA target becomes new src/from state - } - return this.failOrAccept(this.prevAccept, input, s.configs, t); -}; - -// Get an existing target state for an edge in the DFA. If the target state -// for the edge has not yet been computed or is otherwise not available, -// this method returns {@code null}. -// -// @param s The current DFA state -// @param t The next input symbol -// @return The existing target DFA state for the given input symbol -// {@code t}, or {@code null} if the target state for this edge is not -// already cached -LexerATNSimulator.prototype.getExistingTargetState = function(s, t) { - if (s.edges === null || t < LexerATNSimulator.MIN_DFA_EDGE || t > LexerATNSimulator.MAX_DFA_EDGE) { - return null; - } - - var target = s.edges[t - LexerATNSimulator.MIN_DFA_EDGE]; - if(target===undefined) { - target = null; - } - if (LexerATNSimulator.debug && target !== null) { - console.log("reuse state " + s.stateNumber + " edge to " + target.stateNumber); - } - return target; -}; - -// Compute a target state for an edge in the DFA, and attempt to add the -// computed state and corresponding edge to the DFA. -// -// @param input The input stream -// @param s The current DFA state -// @param t The next input symbol -// -// @return The computed target DFA state for the given input symbol -// {@code t}. If {@code t} does not lead to a valid DFA state, this method -// returns {@link //ERROR}. -LexerATNSimulator.prototype.computeTargetState = function(input, s, t) { - var reach = new OrderedATNConfigSet(); - // if we don't find an existing DFA state - // Fill reach starting from closure, following t transitions - this.getReachableConfigSet(input, s.configs, reach, t); - - if (reach.items.length === 0) { // we got nowhere on t from s - if (!reach.hasSemanticContext) { - // we got nowhere on t, don't throw out this knowledge; it'd - // cause a failover from DFA later. - this.addDFAEdge(s, t, ATNSimulator.ERROR); - } - // stop when we can't match any more char - return ATNSimulator.ERROR; - } - // Add an edge from s to target DFA found/created for reach - return this.addDFAEdge(s, t, null, reach); -}; - -LexerATNSimulator.prototype.failOrAccept = function(prevAccept, input, reach, t) { - if (this.prevAccept.dfaState !== null) { - var lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor; - this.accept(input, lexerActionExecutor, this.startIndex, - prevAccept.index, prevAccept.line, prevAccept.column); - return prevAccept.dfaState.prediction; - } else { - // if no accept and EOF is first char, return EOF - if (t === Token.EOF && input.index === this.startIndex) { - return Token.EOF; - } - throw new LexerNoViableAltException(this.recog, input, this.startIndex, reach); - } -}; - -// Given a starting configuration set, figure out all ATN configurations -// we can reach upon input {@code t}. Parameter {@code reach} is a return -// parameter. -LexerATNSimulator.prototype.getReachableConfigSet = function(input, closure, - reach, t) { - // this is used to skip processing for configs which have a lower priority - // than a config that already reached an accept state for the same rule - var skipAlt = ATN.INVALID_ALT_NUMBER; - for (var i = 0; i < closure.items.length; i++) { - var cfg = closure.items[i]; - var currentAltReachedAcceptState = (cfg.alt === skipAlt); - if (currentAltReachedAcceptState && cfg.passedThroughNonGreedyDecision) { - continue; - } - if (LexerATNSimulator.debug) { - console.log("testing %s at %s\n", this.getTokenName(t), cfg - .toString(this.recog, true)); - } - for (var j = 0; j < cfg.state.transitions.length; j++) { - var trans = cfg.state.transitions[j]; // for each transition - var target = this.getReachableTarget(trans, t); - if (target !== null) { - var lexerActionExecutor = cfg.lexerActionExecutor; - if (lexerActionExecutor !== null) { - lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index - this.startIndex); - } - var treatEofAsEpsilon = (t === Token.EOF); - var config = new LexerATNConfig({state:target, lexerActionExecutor:lexerActionExecutor}, cfg); - if (this.closure(input, config, reach, - currentAltReachedAcceptState, true, treatEofAsEpsilon)) { - // any remaining configs for this alt have a lower priority - // than the one that just reached an accept state. - skipAlt = cfg.alt; - } - } - } - } -}; - -LexerATNSimulator.prototype.accept = function(input, lexerActionExecutor, - startIndex, index, line, charPos) { - if (LexerATNSimulator.debug) { - console.log("ACTION %s\n", lexerActionExecutor); - } - // seek to after last char in token - input.seek(index); - this.line = line; - this.column = charPos; - if (lexerActionExecutor !== null && this.recog !== null) { - lexerActionExecutor.execute(this.recog, input, startIndex); - } -}; - -LexerATNSimulator.prototype.getReachableTarget = function(trans, t) { - if (trans.matches(t, 0, Lexer.MAX_CHAR_VALUE)) { - return trans.target; - } else { - return null; - } -}; - -LexerATNSimulator.prototype.computeStartState = function(input, p) { - var initialContext = PredictionContext.EMPTY; - var configs = new OrderedATNConfigSet(); - for (var i = 0; i < p.transitions.length; i++) { - var target = p.transitions[i].target; - var cfg = new LexerATNConfig({state:target, alt:i+1, context:initialContext}, null); - this.closure(input, cfg, configs, false, false, false); - } - return configs; -}; - -// Since the alternatives within any lexer decision are ordered by -// preference, this method stops pursuing the closure as soon as an accept -// state is reached. After the first accept state is reached by depth-first -// search from {@code config}, all other (potentially reachable) states for -// this rule would have a lower priority. -// -// @return {@code true} if an accept state is reached, otherwise -// {@code false}. -LexerATNSimulator.prototype.closure = function(input, config, configs, - currentAltReachedAcceptState, speculative, treatEofAsEpsilon) { - var cfg = null; - if (LexerATNSimulator.debug) { - console.log("closure(" + config.toString(this.recog, true) + ")"); - } - if (config.state instanceof RuleStopState) { - if (LexerATNSimulator.debug) { - if (this.recog !== null) { - console.log("closure at %s rule stop %s\n", this.recog.ruleNames[config.state.ruleIndex], config); - } else { - console.log("closure at rule stop %s\n", config); - } - } - if (config.context === null || config.context.hasEmptyPath()) { - if (config.context === null || config.context.isEmpty()) { - configs.add(config); - return true; - } else { - configs.add(new LexerATNConfig({ state:config.state, context:PredictionContext.EMPTY}, config)); - currentAltReachedAcceptState = true; - } - } - if (config.context !== null && !config.context.isEmpty()) { - for (var i = 0; i < config.context.length; i++) { - if (config.context.getReturnState(i) !== PredictionContext.EMPTY_RETURN_STATE) { - var newContext = config.context.getParent(i); // "pop" return state - var returnState = this.atn.states[config.context.getReturnState(i)]; - cfg = new LexerATNConfig({ state:returnState, context:newContext }, config); - currentAltReachedAcceptState = this.closure(input, cfg, - configs, currentAltReachedAcceptState, speculative, - treatEofAsEpsilon); - } - } - } - return currentAltReachedAcceptState; - } - // optimization - if (!config.state.epsilonOnlyTransitions) { - if (!currentAltReachedAcceptState || !config.passedThroughNonGreedyDecision) { - configs.add(config); - } - } - for (var j = 0; j < config.state.transitions.length; j++) { - var trans = config.state.transitions[j]; - cfg = this.getEpsilonTarget(input, config, trans, configs, speculative, treatEofAsEpsilon); - if (cfg !== null) { - currentAltReachedAcceptState = this.closure(input, cfg, configs, - currentAltReachedAcceptState, speculative, treatEofAsEpsilon); - } - } - return currentAltReachedAcceptState; -}; - -// side-effect: can alter configs.hasSemanticContext -LexerATNSimulator.prototype.getEpsilonTarget = function(input, config, trans, - configs, speculative, treatEofAsEpsilon) { - var cfg = null; - if (trans.serializationType === Transition.RULE) { - var newContext = SingletonPredictionContext.create(config.context, trans.followState.stateNumber); - cfg = new LexerATNConfig( { state:trans.target, context:newContext}, config); - } else if (trans.serializationType === Transition.PRECEDENCE) { - throw "Precedence predicates are not supported in lexers."; - } else if (trans.serializationType === Transition.PREDICATE) { - // Track traversing semantic predicates. If we traverse, - // we cannot add a DFA state for this "reach" computation - // because the DFA would not test the predicate again in the - // future. Rather than creating collections of semantic predicates - // like v3 and testing them on prediction, v4 will test them on the - // fly all the time using the ATN not the DFA. This is slower but - // semantically it's not used that often. One of the key elements to - // this predicate mechanism is not adding DFA states that see - // predicates immediately afterwards in the ATN. For example, - - // a : ID {p1}? | ID {p2}? ; - - // should create the start state for rule 'a' (to save start state - // competition), but should not create target of ID state. The - // collection of ATN states the following ID references includes - // states reached by traversing predicates. Since this is when we - // test them, we cannot cash the DFA state target of ID. - - if (LexerATNSimulator.debug) { - console.log("EVAL rule " + trans.ruleIndex + ":" + trans.predIndex); - } - configs.hasSemanticContext = true; - if (this.evaluatePredicate(input, trans.ruleIndex, trans.predIndex, speculative)) { - cfg = new LexerATNConfig({ state:trans.target}, config); - } - } else if (trans.serializationType === Transition.ACTION) { - if (config.context === null || config.context.hasEmptyPath()) { - // execute actions anywhere in the start rule for a token. - // - // TODO: if the entry rule is invoked recursively, some - // actions may be executed during the recursive call. The - // problem can appear when hasEmptyPath() is true but - // isEmpty() is false. In this case, the config needs to be - // split into two contexts - one with just the empty path - // and another with everything but the empty path. - // Unfortunately, the current algorithm does not allow - // getEpsilonTarget to return two configurations, so - // additional modifications are needed before we can support - // the split operation. - var lexerActionExecutor = LexerActionExecutor.append(config.lexerActionExecutor, - this.atn.lexerActions[trans.actionIndex]); - cfg = new LexerATNConfig({ state:trans.target, lexerActionExecutor:lexerActionExecutor }, config); - } else { - // ignore actions in referenced rules - cfg = new LexerATNConfig( { state:trans.target}, config); - } - } else if (trans.serializationType === Transition.EPSILON) { - cfg = new LexerATNConfig({ state:trans.target}, config); - } else if (trans.serializationType === Transition.ATOM || - trans.serializationType === Transition.RANGE || - trans.serializationType === Transition.SET) { - if (treatEofAsEpsilon) { - if (trans.matches(Token.EOF, 0, Lexer.MAX_CHAR_VALUE)) { - cfg = new LexerATNConfig( { state:trans.target }, config); - } - } - } - return cfg; -}; - -// Evaluate a predicate specified in the lexer. -// -//

          If {@code speculative} is {@code true}, this method was called before -// {@link //consume} for the matched character. This method should call -// {@link //consume} before evaluating the predicate to ensure position -// sensitive values, including {@link Lexer//getText}, {@link Lexer//getLine}, -// and {@link Lexer//getcolumn}, properly reflect the current -// lexer state. This method should restore {@code input} and the simulator -// to the original state before returning (i.e. undo the actions made by the -// call to {@link //consume}.

          -// -// @param input The input stream. -// @param ruleIndex The rule containing the predicate. -// @param predIndex The index of the predicate within the rule. -// @param speculative {@code true} if the current index in {@code input} is -// one character before the predicate's location. -// -// @return {@code true} if the specified predicate evaluates to -// {@code true}. -// / -LexerATNSimulator.prototype.evaluatePredicate = function(input, ruleIndex, - predIndex, speculative) { - // assume true if no recognizer was provided - if (this.recog === null) { - return true; - } - if (!speculative) { - return this.recog.sempred(null, ruleIndex, predIndex); - } - var savedcolumn = this.column; - var savedLine = this.line; - var index = input.index; - var marker = input.mark(); - try { - this.consume(input); - return this.recog.sempred(null, ruleIndex, predIndex); - } finally { - this.column = savedcolumn; - this.line = savedLine; - input.seek(index); - input.release(marker); - } -}; - -LexerATNSimulator.prototype.captureSimState = function(settings, input, dfaState) { - settings.index = input.index; - settings.line = this.line; - settings.column = this.column; - settings.dfaState = dfaState; -}; - -LexerATNSimulator.prototype.addDFAEdge = function(from_, tk, to, cfgs) { - if (to === undefined) { - to = null; - } - if (cfgs === undefined) { - cfgs = null; - } - if (to === null && cfgs !== null) { - // leading to this call, ATNConfigSet.hasSemanticContext is used as a - // marker indicating dynamic predicate evaluation makes this edge - // dependent on the specific input sequence, so the static edge in the - // DFA should be omitted. The target DFAState is still created since - // execATN has the ability to resynchronize with the DFA state cache - // following the predicate evaluation step. - // - // TJP notes: next time through the DFA, we see a pred again and eval. - // If that gets us to a previously created (but dangling) DFA - // state, we can continue in pure DFA mode from there. - // / - var suppressEdge = cfgs.hasSemanticContext; - cfgs.hasSemanticContext = false; - - to = this.addDFAState(cfgs); - - if (suppressEdge) { - return to; - } - } - // add the edge - if (tk < LexerATNSimulator.MIN_DFA_EDGE || tk > LexerATNSimulator.MAX_DFA_EDGE) { - // Only track edges within the DFA bounds - return to; - } - if (LexerATNSimulator.debug) { - console.log("EDGE " + from_ + " -> " + to + " upon " + tk); - } - if (from_.edges === null) { - // make room for tokens 1..n and -1 masquerading as index 0 - from_.edges = []; - } - from_.edges[tk - LexerATNSimulator.MIN_DFA_EDGE] = to; // connect - - return to; -}; - -// Add a new DFA state if there isn't one with this set of -// configurations already. This method also detects the first -// configuration containing an ATN rule stop state. Later, when -// traversing the DFA, we will know which rule to accept. -LexerATNSimulator.prototype.addDFAState = function(configs) { - var proposed = new DFAState(null, configs); - var firstConfigWithRuleStopState = null; - for (var i = 0; i < configs.items.length; i++) { - var cfg = configs.items[i]; - if (cfg.state instanceof RuleStopState) { - firstConfigWithRuleStopState = cfg; - break; - } - } - if (firstConfigWithRuleStopState !== null) { - proposed.isAcceptState = true; - proposed.lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor; - proposed.prediction = this.atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex]; - } - var dfa = this.decisionToDFA[this.mode]; - var existing = dfa.states.get(proposed); - if (existing!==null) { - return existing; - } - var newState = proposed; - newState.stateNumber = dfa.states.length; - configs.setReadonly(true); - newState.configs = configs; - dfa.states.add(newState); - return newState; -}; - -LexerATNSimulator.prototype.getDFA = function(mode) { - return this.decisionToDFA[mode]; -}; - -// Get the text matched so far for the current token. -LexerATNSimulator.prototype.getText = function(input) { - // index is first lookahead char, don't include. - return input.getText(this.startIndex, input.index - 1); -}; - -LexerATNSimulator.prototype.consume = function(input) { - var curChar = input.LA(1); - if (curChar === "\n".charCodeAt(0)) { - this.line += 1; - this.column = 0; - } else { - this.column += 1; - } - input.consume(); -}; - -LexerATNSimulator.prototype.getTokenName = function(tt) { - if (tt === -1) { - return "EOF"; - } else { - return "'" + String.fromCharCode(tt) + "'"; - } -}; - -exports.LexerATNSimulator = LexerATNSimulator; - - -/***/ }), -/* 39 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// -// This default implementation of {@link TokenFactory} creates -// {@link CommonToken} objects. -// - -var CommonToken = __webpack_require__(1).CommonToken; - -function TokenFactory() { - return this; -} - -function CommonTokenFactory(copyText) { - TokenFactory.call(this); - // Indicates whether {@link CommonToken//setText} should be called after - // constructing tokens to explicitly set the text. This is useful for cases - // where the input stream might not be able to provide arbitrary substrings - // of text from the input after the lexer creates a token (e.g. the - // implementation of {@link CharStream//getText} in - // {@link UnbufferedCharStream} throws an - // {@link UnsupportedOperationException}). Explicitly setting the token text - // allows {@link Token//getText} to be called at any time regardless of the - // input stream implementation. - // - //

          - // The default value is {@code false} to avoid the performance and memory - // overhead of copying text for every token unless explicitly requested.

          - // - this.copyText = copyText===undefined ? false : copyText; - return this; -} - -CommonTokenFactory.prototype = Object.create(TokenFactory.prototype); -CommonTokenFactory.prototype.constructor = CommonTokenFactory; - -// -// The default {@link CommonTokenFactory} instance. -// -//

          -// This token factory does not explicitly copy token text when constructing -// tokens.

          -// -CommonTokenFactory.DEFAULT = new CommonTokenFactory(); - -CommonTokenFactory.prototype.create = function(source, type, text, channel, start, stop, line, column) { - var t = new CommonToken(source, type, channel, start, stop); - t.line = line; - t.column = column; - if (text !==null) { - t.text = text; - } else if (this.copyText && source[1] !==null) { - t.text = source[1].getText(start,stop); - } - return t; -}; - -CommonTokenFactory.prototype.createThin = function(type, text) { - var t = new CommonToken(null, type); - t.text = text; - return t; -}; - -exports.CommonTokenFactory = CommonTokenFactory; - - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -// Represents an executor for a sequence of lexer actions which traversed during -// the matching operation of a lexer rule (token). -// -//

          The executor tracks position information for position-dependent lexer actions -// efficiently, ensuring that actions appearing only at the end of the rule do -// not cause bloating of the {@link DFA} created for the lexer.

          - -var hashStuff = __webpack_require__(0).hashStuff; -var LexerIndexedCustomAction = __webpack_require__(23).LexerIndexedCustomAction; - -function LexerActionExecutor(lexerActions) { - this.lexerActions = lexerActions === null ? [] : lexerActions; - // Caches the result of {@link //hashCode} since the hash code is an element - // of the performance-critical {@link LexerATNConfig//hashCode} operation. - this.cachedHashCode = hashStuff(lexerActions); // "".join([str(la) for la in - // lexerActions])) - return this; -} - -// Creates a {@link LexerActionExecutor} which executes the actions for -// the input {@code lexerActionExecutor} followed by a specified -// {@code lexerAction}. -// -// @param lexerActionExecutor The executor for actions already traversed by -// the lexer while matching a token within a particular -// {@link LexerATNConfig}. If this is {@code null}, the method behaves as -// though it were an empty executor. -// @param lexerAction The lexer action to execute after the actions -// specified in {@code lexerActionExecutor}. -// -// @return A {@link LexerActionExecutor} for executing the combine actions -// of {@code lexerActionExecutor} and {@code lexerAction}. -LexerActionExecutor.append = function(lexerActionExecutor, lexerAction) { - if (lexerActionExecutor === null) { - return new LexerActionExecutor([ lexerAction ]); - } - var lexerActions = lexerActionExecutor.lexerActions.concat([ lexerAction ]); - return new LexerActionExecutor(lexerActions); -}; - -// Creates a {@link LexerActionExecutor} which encodes the current offset -// for position-dependent lexer actions. -// -//

          Normally, when the executor encounters lexer actions where -// {@link LexerAction//isPositionDependent} returns {@code true}, it calls -// {@link IntStream//seek} on the input {@link CharStream} to set the input -// position to the end of the current token. This behavior provides -// for efficient DFA representation of lexer actions which appear at the end -// of a lexer rule, even when the lexer rule matches a variable number of -// characters.

          -// -//

          Prior to traversing a match transition in the ATN, the current offset -// from the token start index is assigned to all position-dependent lexer -// actions which have not already been assigned a fixed offset. By storing -// the offsets relative to the token start index, the DFA representation of -// lexer actions which appear in the middle of tokens remains efficient due -// to sharing among tokens of the same length, regardless of their absolute -// position in the input stream.

          -// -//

          If the current executor already has offsets assigned to all -// position-dependent lexer actions, the method returns {@code this}.

          -// -// @param offset The current offset to assign to all position-dependent -// lexer actions which do not already have offsets assigned. -// -// @return A {@link LexerActionExecutor} which stores input stream offsets -// for all position-dependent lexer actions. -// / -LexerActionExecutor.prototype.fixOffsetBeforeMatch = function(offset) { - var updatedLexerActions = null; - for (var i = 0; i < this.lexerActions.length; i++) { - if (this.lexerActions[i].isPositionDependent && - !(this.lexerActions[i] instanceof LexerIndexedCustomAction)) { - if (updatedLexerActions === null) { - updatedLexerActions = this.lexerActions.concat([]); - } - updatedLexerActions[i] = new LexerIndexedCustomAction(offset, - this.lexerActions[i]); - } - } - if (updatedLexerActions === null) { - return this; - } else { - return new LexerActionExecutor(updatedLexerActions); - } -}; - -// Execute the actions encapsulated by this executor within the context of a -// particular {@link Lexer}. -// -//

          This method calls {@link IntStream//seek} to set the position of the -// {@code input} {@link CharStream} prior to calling -// {@link LexerAction//execute} on a position-dependent action. Before the -// method returns, the input position will be restored to the same position -// it was in when the method was invoked.

          -// -// @param lexer The lexer instance. -// @param input The input stream which is the source for the current token. -// When this method is called, the current {@link IntStream//index} for -// {@code input} should be the start of the following token, i.e. 1 -// character past the end of the current token. -// @param startIndex The token start index. This value may be passed to -// {@link IntStream//seek} to set the {@code input} position to the beginning -// of the token. -// / -LexerActionExecutor.prototype.execute = function(lexer, input, startIndex) { - var requiresSeek = false; - var stopIndex = input.index; - try { - for (var i = 0; i < this.lexerActions.length; i++) { - var lexerAction = this.lexerActions[i]; - if (lexerAction instanceof LexerIndexedCustomAction) { - var offset = lexerAction.offset; - input.seek(startIndex + offset); - lexerAction = lexerAction.action; - requiresSeek = (startIndex + offset) !== stopIndex; - } else if (lexerAction.isPositionDependent) { - input.seek(stopIndex); - requiresSeek = false; - } - lexerAction.execute(lexer); - } - } finally { - if (requiresSeek) { - input.seek(stopIndex); - } - } -}; - -LexerActionExecutor.prototype.hashCode = function() { - return this.cachedHashCode; -}; - -LexerActionExecutor.prototype.updateHashCode = function(hash) { - hash.update(this.cachedHashCode); -}; - - -LexerActionExecutor.prototype.equals = function(other) { - if (this === other) { - return true; - } else if (!(other instanceof LexerActionExecutor)) { - return false; - } else if (this.cachedHashCode != other.cachedHashCode) { - return false; - } else if (this.lexerActions.length != other.lexerActions.length) { - return false; - } else { - var numActions = this.lexerActions.length - for (var idx = 0; idx < numActions; ++idx) { - if (!this.lexerActions[idx].equals(other.lexerActions[idx])) { - return false; - } - } - return true; - } -}; - -exports.LexerActionExecutor = LexerActionExecutor; - - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// -// The embodiment of the adaptive LL(*), ALL(*), parsing strategy. -// -//

          -// The basic complexity of the adaptive strategy makes it harder to understand. -// We begin with ATN simulation to build paths in a DFA. Subsequent prediction -// requests go through the DFA first. If they reach a state without an edge for -// the current symbol, the algorithm fails over to the ATN simulation to -// complete the DFA path for the current input (until it finds a conflict state -// or uniquely predicting state).

          -// -//

          -// All of that is done without using the outer context because we want to create -// a DFA that is not dependent upon the rule invocation stack when we do a -// prediction. One DFA works in all contexts. We avoid using context not -// necessarily because it's slower, although it can be, but because of the DFA -// caching problem. The closure routine only considers the rule invocation stack -// created during prediction beginning in the decision rule. For example, if -// prediction occurs without invoking another rule's ATN, there are no context -// stacks in the configurations. When lack of context leads to a conflict, we -// don't know if it's an ambiguity or a weakness in the strong LL(*) parsing -// strategy (versus full LL(*)).

          -// -//

          -// When SLL yields a configuration set with conflict, we rewind the input and -// retry the ATN simulation, this time using full outer context without adding -// to the DFA. Configuration context stacks will be the full invocation stacks -// from the start rule. If we get a conflict using full context, then we can -// definitively say we have a true ambiguity for that input sequence. If we -// don't get a conflict, it implies that the decision is sensitive to the outer -// context. (It is not context-sensitive in the sense of context-sensitive -// grammars.)

          -// -//

          -// The next time we reach this DFA state with an SLL conflict, through DFA -// simulation, we will again retry the ATN simulation using full context mode. -// This is slow because we can't save the results and have to "interpret" the -// ATN each time we get that input.

          -// -//

          -// CACHING FULL CONTEXT PREDICTIONS

          -// -//

          -// We could cache results from full context to predicted alternative easily and -// that saves a lot of time but doesn't work in presence of predicates. The set -// of visible predicates from the ATN start state changes depending on the -// context, because closure can fall off the end of a rule. I tried to cache -// tuples (stack context, semantic context, predicted alt) but it was slower -// than interpreting and much more complicated. Also required a huge amount of -// memory. The goal is not to create the world's fastest parser anyway. I'd like -// to keep this algorithm simple. By launching multiple threads, we can improve -// the speed of parsing across a large number of files.

          -// -//

          -// There is no strict ordering between the amount of input used by SLL vs LL, -// which makes it really hard to build a cache for full context. Let's say that -// we have input A B C that leads to an SLL conflict with full context X. That -// implies that using X we might only use A B but we could also use A B C D to -// resolve conflict. Input A B C D could predict alternative 1 in one position -// in the input and A B C E could predict alternative 2 in another position in -// input. The conflicting SLL configurations could still be non-unique in the -// full context prediction, which would lead us to requiring more input than the -// original A B C. To make a prediction cache work, we have to track the exact -// input used during the previous prediction. That amounts to a cache that maps -// X to a specific DFA for that context.

          -// -//

          -// Something should be done for left-recursive expression predictions. They are -// likely LL(1) + pred eval. Easier to do the whole SLL unless error and retry -// with full LL thing Sam does.

          -// -//

          -// AVOIDING FULL CONTEXT PREDICTION

          -// -//

          -// We avoid doing full context retry when the outer context is empty, we did not -// dip into the outer context by falling off the end of the decision state rule, -// or when we force SLL mode.

          -// -//

          -// As an example of the not dip into outer context case, consider as super -// constructor calls versus function calls. One grammar might look like -// this:

          -// -//
          -// ctorBody
          -//   : '{' superCall? stat* '}'
          -//   ;
          -// 
          -// -//

          -// Or, you might see something like

          -// -//
          -// stat
          -//   : superCall ';'
          -//   | expression ';'
          -//   | ...
          -//   ;
          -// 
          -// -//

          -// In both cases I believe that no closure operations will dip into the outer -// context. In the first case ctorBody in the worst case will stop at the '}'. -// In the 2nd case it should stop at the ';'. Both cases should stay within the -// entry rule and not dip into the outer context.

          -// -//

          -// PREDICATES

          -// -//

          -// Predicates are always evaluated if present in either SLL or LL both. SLL and -// LL simulation deals with predicates differently. SLL collects predicates as -// it performs closure operations like ANTLR v3 did. It delays predicate -// evaluation until it reaches and accept state. This allows us to cache the SLL -// ATN simulation whereas, if we had evaluated predicates on-the-fly during -// closure, the DFA state configuration sets would be different and we couldn't -// build up a suitable DFA.

          -// -//

          -// When building a DFA accept state during ATN simulation, we evaluate any -// predicates and return the sole semantically valid alternative. If there is -// more than 1 alternative, we report an ambiguity. If there are 0 alternatives, -// we throw an exception. Alternatives without predicates act like they have -// true predicates. The simple way to think about it is to strip away all -// alternatives with false predicates and choose the minimum alternative that -// remains.

          -// -//

          -// When we start in the DFA and reach an accept state that's predicated, we test -// those and return the minimum semantically viable alternative. If no -// alternatives are viable, we throw an exception.

          -// -//

          -// During full LL ATN simulation, closure always evaluates predicates and -// on-the-fly. This is crucial to reducing the configuration set size during -// closure. It hits a landmine when parsing with the Java grammar, for example, -// without this on-the-fly evaluation.

          -// -//

          -// SHARING DFA

          -// -//

          -// All instances of the same parser share the same decision DFAs through a -// static field. Each instance gets its own ATN simulator but they share the -// same {@link //decisionToDFA} field. They also share a -// {@link PredictionContextCache} object that makes sure that all -// {@link PredictionContext} objects are shared among the DFA states. This makes -// a big size difference.

          -// -//

          -// THREAD SAFETY

          -// -//

          -// The {@link ParserATNSimulator} locks on the {@link //decisionToDFA} field when -// it adds a new DFA object to that array. {@link //addDFAEdge} -// locks on the DFA for the current decision when setting the -// {@link DFAState//edges} field. {@link //addDFAState} locks on -// the DFA for the current decision when looking up a DFA state to see if it -// already exists. We must make sure that all requests to add DFA states that -// are equivalent result in the same shared DFA object. This is because lots of -// threads will be trying to update the DFA at once. The -// {@link //addDFAState} method also locks inside the DFA lock -// but this time on the shared context cache when it rebuilds the -// configurations' {@link PredictionContext} objects using cached -// subgraphs/nodes. No other locking occurs, even during DFA simulation. This is -// safe as long as we can guarantee that all threads referencing -// {@code s.edge[t]} get the same physical target {@link DFAState}, or -// {@code null}. Once into the DFA, the DFA simulation does not reference the -// {@link DFA//states} map. It follows the {@link DFAState//edges} field to new -// targets. The DFA simulator will either find {@link DFAState//edges} to be -// {@code null}, to be non-{@code null} and {@code dfa.edges[t]} null, or -// {@code dfa.edges[t]} to be non-null. The -// {@link //addDFAEdge} method could be racing to set the field -// but in either case the DFA simulator works; if {@code null}, and requests ATN -// simulation. It could also race trying to get {@code dfa.edges[t]}, but either -// way it will work because it's not doing a test and set operation.

          -// -//

          -// Starting with SLL then failing to combined SLL/LL (Two-Stage -// Parsing)

          -// -//

          -// Sam pointed out that if SLL does not give a syntax error, then there is no -// point in doing full LL, which is slower. We only have to try LL if we get a -// syntax error. For maximum speed, Sam starts the parser set to pure SLL -// mode with the {@link BailErrorStrategy}:

          -// -//
          -// parser.{@link Parser//getInterpreter() getInterpreter()}.{@link //setPredictionMode setPredictionMode}{@code (}{@link PredictionMode//SLL}{@code )};
          -// parser.{@link Parser//setErrorHandler setErrorHandler}(new {@link BailErrorStrategy}());
          -// 
          -// -//

          -// If it does not get a syntax error, then we're done. If it does get a syntax -// error, we need to retry with the combined SLL/LL strategy.

          -// -//

          -// The reason this works is as follows. If there are no SLL conflicts, then the -// grammar is SLL (at least for that input set). If there is an SLL conflict, -// the full LL analysis must yield a set of viable alternatives which is a -// subset of the alternatives reported by SLL. If the LL set is a singleton, -// then the grammar is LL but not SLL. If the LL set is the same size as the SLL -// set, the decision is SLL. If the LL set has size > 1, then that decision -// is truly ambiguous on the current input. If the LL set is smaller, then the -// SLL conflict resolution might choose an alternative that the full LL would -// rule out as a possibility based upon better context information. If that's -// the case, then the SLL parse will definitely get an error because the full LL -// analysis says it's not viable. If SLL conflict resolution chooses an -// alternative within the LL set, them both SLL and LL would choose the same -// alternative because they both choose the minimum of multiple conflicting -// alternatives.

          -// -//

          -// Let's say we have a set of SLL conflicting alternatives {@code {1, 2, 3}} and -// a smaller LL set called s. If s is {@code {2, 3}}, then SLL -// parsing will get an error because SLL will pursue alternative 1. If -// s is {@code {1, 2}} or {@code {1, 3}} then both SLL and LL will -// choose the same alternative because alternative one is the minimum of either -// set. If s is {@code {2}} or {@code {3}} then SLL will get a syntax -// error. If s is {@code {1}} then SLL will succeed.

          -// -//

          -// Of course, if the input is invalid, then we will get an error for sure in -// both SLL and LL parsing. Erroneous input will therefore require 2 passes over -// the input.

          -// - -var Utils = __webpack_require__(0); -var Set = Utils.Set; -var BitSet = Utils.BitSet; -var DoubleDict = Utils.DoubleDict; -var ATN = __webpack_require__(7).ATN; -var ATNState = __webpack_require__(3).ATNState; -var ATNConfig = __webpack_require__(13).ATNConfig; -var ATNConfigSet = __webpack_require__(9).ATNConfigSet; -var Token = __webpack_require__(1).Token; -var DFAState = __webpack_require__(11).DFAState; -var PredPrediction = __webpack_require__(11).PredPrediction; -var ATNSimulator = __webpack_require__(25).ATNSimulator; -var PredictionMode = __webpack_require__(26).PredictionMode; -var RuleContext = __webpack_require__(14).RuleContext; -var ParserRuleContext = __webpack_require__(18).ParserRuleContext; -var SemanticContext = __webpack_require__(10).SemanticContext; -var StarLoopEntryState = __webpack_require__(3).StarLoopEntryState; -var RuleStopState = __webpack_require__(3).RuleStopState; -var PredictionContext = __webpack_require__(6).PredictionContext; -var Interval = __webpack_require__(2).Interval; -var Transitions = __webpack_require__(8); -var Transition = Transitions.Transition; -var SetTransition = Transitions.SetTransition; -var NotSetTransition = Transitions.NotSetTransition; -var RuleTransition = Transitions.RuleTransition; -var ActionTransition = Transitions.ActionTransition; -var NoViableAltException = __webpack_require__(5).NoViableAltException; - -var SingletonPredictionContext = __webpack_require__(6).SingletonPredictionContext; -var predictionContextFromRuleContext = __webpack_require__(6).predictionContextFromRuleContext; - -function ParserATNSimulator(parser, atn, decisionToDFA, sharedContextCache) { - ATNSimulator.call(this, atn, sharedContextCache); - this.parser = parser; - this.decisionToDFA = decisionToDFA; - // SLL, LL, or LL + exact ambig detection?// - this.predictionMode = PredictionMode.LL; - // LAME globals to avoid parameters!!!!! I need these down deep in predTransition - this._input = null; - this._startIndex = 0; - this._outerContext = null; - this._dfa = null; - // Each prediction operation uses a cache for merge of prediction contexts. - // Don't keep around as it wastes huge amounts of memory. DoubleKeyMap - // isn't synchronized but we're ok since two threads shouldn't reuse same - // parser/atnsim object because it can only handle one input at a time. - // This maps graphs a and b to merged result c. (a,b)→c. We can avoid - // the merge if we ever see a and b again. Note that (b,a)→c should - // also be examined during cache lookup. - // - this.mergeCache = null; - return this; -} - -ParserATNSimulator.prototype = Object.create(ATNSimulator.prototype); -ParserATNSimulator.prototype.constructor = ParserATNSimulator; - -ParserATNSimulator.prototype.debug = false; -ParserATNSimulator.prototype.debug_closure = false; -ParserATNSimulator.prototype.debug_add = false; -ParserATNSimulator.prototype.debug_list_atn_decisions = false; -ParserATNSimulator.prototype.dfa_debug = false; -ParserATNSimulator.prototype.retry_debug = false; - - -ParserATNSimulator.prototype.reset = function() { -}; - -ParserATNSimulator.prototype.adaptivePredict = function(input, decision, outerContext) { - if (this.debug || this.debug_list_atn_decisions) { - console.log("adaptivePredict decision " + decision + - " exec LA(1)==" + this.getLookaheadName(input) + - " line " + input.LT(1).line + ":" + - input.LT(1).column); - } - this._input = input; - this._startIndex = input.index; - this._outerContext = outerContext; - - var dfa = this.decisionToDFA[decision]; - this._dfa = dfa; - var m = input.mark(); - var index = input.index; - - // Now we are certain to have a specific decision's DFA - // But, do we still need an initial state? - try { - var s0; - if (dfa.precedenceDfa) { - // the start state for a precedence DFA depends on the current - // parser precedence, and is provided by a DFA method. - s0 = dfa.getPrecedenceStartState(this.parser.getPrecedence()); - } else { - // the start state for a "regular" DFA is just s0 - s0 = dfa.s0; - } - if (s0===null) { - if (outerContext===null) { - outerContext = RuleContext.EMPTY; - } - if (this.debug || this.debug_list_atn_decisions) { - console.log("predictATN decision " + dfa.decision + - " exec LA(1)==" + this.getLookaheadName(input) + - ", outerContext=" + outerContext.toString(this.parser.ruleNames)); - } - - var fullCtx = false; - var s0_closure = this.computeStartState(dfa.atnStartState, RuleContext.EMPTY, fullCtx); - - if( dfa.precedenceDfa) { - // If this is a precedence DFA, we use applyPrecedenceFilter - // to convert the computed start state to a precedence start - // state. We then use DFA.setPrecedenceStartState to set the - // appropriate start state for the precedence level rather - // than simply setting DFA.s0. - // - dfa.s0.configs = s0_closure; // not used for prediction but useful to know start configs anyway - s0_closure = this.applyPrecedenceFilter(s0_closure); - s0 = this.addDFAState(dfa, new DFAState(null, s0_closure)); - dfa.setPrecedenceStartState(this.parser.getPrecedence(), s0); - } else { - s0 = this.addDFAState(dfa, new DFAState(null, s0_closure)); - dfa.s0 = s0; - } - } - var alt = this.execATN(dfa, s0, input, index, outerContext); - if (this.debug) { - console.log("DFA after predictATN: " + dfa.toString(this.parser.literalNames)); - } - return alt; - } finally { - this._dfa = null; - this.mergeCache = null; // wack cache after each prediction - input.seek(index); - input.release(m); - } -}; -// Performs ATN simulation to compute a predicted alternative based -// upon the remaining input, but also updates the DFA cache to avoid -// having to traverse the ATN again for the same input sequence. - -// There are some key conditions we're looking for after computing a new -// set of ATN configs (proposed DFA state): - // if the set is empty, there is no viable alternative for current symbol - // does the state uniquely predict an alternative? - // does the state have a conflict that would prevent us from - // putting it on the work list? - -// We also have some key operations to do: - // add an edge from previous DFA state to potentially new DFA state, D, - // upon current symbol but only if adding to work list, which means in all - // cases except no viable alternative (and possibly non-greedy decisions?) - // collecting predicates and adding semantic context to DFA accept states - // adding rule context to context-sensitive DFA accept states - // consuming an input symbol - // reporting a conflict - // reporting an ambiguity - // reporting a context sensitivity - // reporting insufficient predicates - -// cover these cases: -// dead end -// single alt -// single alt + preds -// conflict -// conflict + preds -// -ParserATNSimulator.prototype.execATN = function(dfa, s0, input, startIndex, outerContext ) { - if (this.debug || this.debug_list_atn_decisions) { - console.log("execATN decision " + dfa.decision + - " exec LA(1)==" + this.getLookaheadName(input) + - " line " + input.LT(1).line + ":" + input.LT(1).column); - } - var alt; - var previousD = s0; - - if (this.debug) { - console.log("s0 = " + s0); - } - var t = input.LA(1); - while(true) { // while more work - var D = this.getExistingTargetState(previousD, t); - if(D===null) { - D = this.computeTargetState(dfa, previousD, t); - } - if(D===ATNSimulator.ERROR) { - // if any configs in previous dipped into outer context, that - // means that input up to t actually finished entry rule - // at least for SLL decision. Full LL doesn't dip into outer - // so don't need special case. - // We will get an error no matter what so delay until after - // decision; better error message. Also, no reachable target - // ATN states in SLL implies LL will also get nowhere. - // If conflict in states that dip out, choose min since we - // will get error no matter what. - var e = this.noViableAlt(input, outerContext, previousD.configs, startIndex); - input.seek(startIndex); - alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD.configs, outerContext); - if(alt!==ATN.INVALID_ALT_NUMBER) { - return alt; - } else { - throw e; - } - } - if(D.requiresFullContext && this.predictionMode !== PredictionMode.SLL) { - // IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error) - var conflictingAlts = null; - if (D.predicates!==null) { - if (this.debug) { - console.log("DFA state has preds in DFA sim LL failover"); - } - var conflictIndex = input.index; - if(conflictIndex !== startIndex) { - input.seek(startIndex); - } - conflictingAlts = this.evalSemanticContext(D.predicates, outerContext, true); - if (conflictingAlts.length===1) { - if(this.debug) { - console.log("Full LL avoided"); - } - return conflictingAlts.minValue(); - } - if (conflictIndex !== startIndex) { - // restore the index so reporting the fallback to full - // context occurs with the index at the correct spot - input.seek(conflictIndex); - } - } - if (this.dfa_debug) { - console.log("ctx sensitive state " + outerContext +" in " + D); - } - var fullCtx = true; - var s0_closure = this.computeStartState(dfa.atnStartState, outerContext, fullCtx); - this.reportAttemptingFullContext(dfa, conflictingAlts, D.configs, startIndex, input.index); - alt = this.execATNWithFullContext(dfa, D, s0_closure, input, startIndex, outerContext); - return alt; - } - if (D.isAcceptState) { - if (D.predicates===null) { - return D.prediction; - } - var stopIndex = input.index; - input.seek(startIndex); - var alts = this.evalSemanticContext(D.predicates, outerContext, true); - if (alts.length===0) { - throw this.noViableAlt(input, outerContext, D.configs, startIndex); - } else if (alts.length===1) { - return alts.minValue(); - } else { - // report ambiguity after predicate evaluation to make sure the correct set of ambig alts is reported. - this.reportAmbiguity(dfa, D, startIndex, stopIndex, false, alts, D.configs); - return alts.minValue(); - } - } - previousD = D; - - if (t !== Token.EOF) { - input.consume(); - t = input.LA(1); - } - } -}; -// -// Get an existing target state for an edge in the DFA. If the target state -// for the edge has not yet been computed or is otherwise not available, -// this method returns {@code null}. -// -// @param previousD The current DFA state -// @param t The next input symbol -// @return The existing target DFA state for the given input symbol -// {@code t}, or {@code null} if the target state for this edge is not -// already cached -// -ParserATNSimulator.prototype.getExistingTargetState = function(previousD, t) { - var edges = previousD.edges; - if (edges===null) { - return null; - } else { - return edges[t + 1] || null; - } -}; -// -// Compute a target state for an edge in the DFA, and attempt to add the -// computed state and corresponding edge to the DFA. -// -// @param dfa The DFA -// @param previousD The current DFA state -// @param t The next input symbol -// -// @return The computed target DFA state for the given input symbol -// {@code t}. If {@code t} does not lead to a valid DFA state, this method -// returns {@link //ERROR}. -// -ParserATNSimulator.prototype.computeTargetState = function(dfa, previousD, t) { - var reach = this.computeReachSet(previousD.configs, t, false); - if(reach===null) { - this.addDFAEdge(dfa, previousD, t, ATNSimulator.ERROR); - return ATNSimulator.ERROR; - } - // create new target state; we'll add to DFA after it's complete - var D = new DFAState(null, reach); - - var predictedAlt = this.getUniqueAlt(reach); - - if (this.debug) { - var altSubSets = PredictionMode.getConflictingAltSubsets(reach); - console.log("SLL altSubSets=" + Utils.arrayToString(altSubSets) + - ", previous=" + previousD.configs + - ", configs=" + reach + - ", predict=" + predictedAlt + - ", allSubsetsConflict=" + - PredictionMode.allSubsetsConflict(altSubSets) + ", conflictingAlts=" + - this.getConflictingAlts(reach)); - } - if (predictedAlt!==ATN.INVALID_ALT_NUMBER) { - // NO CONFLICT, UNIQUELY PREDICTED ALT - D.isAcceptState = true; - D.configs.uniqueAlt = predictedAlt; - D.prediction = predictedAlt; - } else if (PredictionMode.hasSLLConflictTerminatingPrediction(this.predictionMode, reach)) { - // MORE THAN ONE VIABLE ALTERNATIVE - D.configs.conflictingAlts = this.getConflictingAlts(reach); - D.requiresFullContext = true; - // in SLL-only mode, we will stop at this state and return the minimum alt - D.isAcceptState = true; - D.prediction = D.configs.conflictingAlts.minValue(); - } - if (D.isAcceptState && D.configs.hasSemanticContext) { - this.predicateDFAState(D, this.atn.getDecisionState(dfa.decision)); - if( D.predicates!==null) { - D.prediction = ATN.INVALID_ALT_NUMBER; - } - } - // all adds to dfa are done after we've created full D state - D = this.addDFAEdge(dfa, previousD, t, D); - return D; -}; - -ParserATNSimulator.prototype.predicateDFAState = function(dfaState, decisionState) { - // We need to test all predicates, even in DFA states that - // uniquely predict alternative. - var nalts = decisionState.transitions.length; - // Update DFA so reach becomes accept state with (predicate,alt) - // pairs if preds found for conflicting alts - var altsToCollectPredsFrom = this.getConflictingAltsOrUniqueAlt(dfaState.configs); - var altToPred = this.getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts); - if (altToPred!==null) { - dfaState.predicates = this.getPredicatePredictions(altsToCollectPredsFrom, altToPred); - dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds - } else { - // There are preds in configs but they might go away - // when OR'd together like {p}? || NONE == NONE. If neither - // alt has preds, resolve to min alt - dfaState.prediction = altsToCollectPredsFrom.minValue(); - } -}; - -// comes back with reach.uniqueAlt set to a valid alt -ParserATNSimulator.prototype.execATNWithFullContext = function(dfa, D, // how far we got before failing over - s0, - input, - startIndex, - outerContext) { - if (this.debug || this.debug_list_atn_decisions) { - console.log("execATNWithFullContext "+s0); - } - var fullCtx = true; - var foundExactAmbig = false; - var reach = null; - var previous = s0; - input.seek(startIndex); - var t = input.LA(1); - var predictedAlt = -1; - while (true) { // while more work - reach = this.computeReachSet(previous, t, fullCtx); - if (reach===null) { - // if any configs in previous dipped into outer context, that - // means that input up to t actually finished entry rule - // at least for LL decision. Full LL doesn't dip into outer - // so don't need special case. - // We will get an error no matter what so delay until after - // decision; better error message. Also, no reachable target - // ATN states in SLL implies LL will also get nowhere. - // If conflict in states that dip out, choose min since we - // will get error no matter what. - var e = this.noViableAlt(input, outerContext, previous, startIndex); - input.seek(startIndex); - var alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext); - if(alt!==ATN.INVALID_ALT_NUMBER) { - return alt; - } else { - throw e; - } - } - var altSubSets = PredictionMode.getConflictingAltSubsets(reach); - if(this.debug) { - console.log("LL altSubSets=" + altSubSets + ", predict=" + - PredictionMode.getUniqueAlt(altSubSets) + ", resolvesToJustOneViableAlt=" + - PredictionMode.resolvesToJustOneViableAlt(altSubSets)); - } - reach.uniqueAlt = this.getUniqueAlt(reach); - // unique prediction? - if(reach.uniqueAlt!==ATN.INVALID_ALT_NUMBER) { - predictedAlt = reach.uniqueAlt; - break; - } else if (this.predictionMode !== PredictionMode.LL_EXACT_AMBIG_DETECTION) { - predictedAlt = PredictionMode.resolvesToJustOneViableAlt(altSubSets); - if(predictedAlt !== ATN.INVALID_ALT_NUMBER) { - break; - } - } else { - // In exact ambiguity mode, we never try to terminate early. - // Just keeps scarfing until we know what the conflict is - if (PredictionMode.allSubsetsConflict(altSubSets) && PredictionMode.allSubsetsEqual(altSubSets)) { - foundExactAmbig = true; - predictedAlt = PredictionMode.getSingleViableAlt(altSubSets); - break; - } - // else there are multiple non-conflicting subsets or - // we're not sure what the ambiguity is yet. - // So, keep going. - } - previous = reach; - if( t !== Token.EOF) { - input.consume(); - t = input.LA(1); - } - } - // If the configuration set uniquely predicts an alternative, - // without conflict, then we know that it's a full LL decision - // not SLL. - if (reach.uniqueAlt !== ATN.INVALID_ALT_NUMBER ) { - this.reportContextSensitivity(dfa, predictedAlt, reach, startIndex, input.index); - return predictedAlt; - } - // We do not check predicates here because we have checked them - // on-the-fly when doing full context prediction. - - // - // In non-exact ambiguity detection mode, we might actually be able to - // detect an exact ambiguity, but I'm not going to spend the cycles - // needed to check. We only emit ambiguity warnings in exact ambiguity - // mode. - // - // For example, we might know that we have conflicting configurations. - // But, that does not mean that there is no way forward without a - // conflict. It's possible to have nonconflicting alt subsets as in: - - // altSubSets=[{1, 2}, {1, 2}, {1}, {1, 2}] - - // from - // - // [(17,1,[5 $]), (13,1,[5 10 $]), (21,1,[5 10 $]), (11,1,[$]), - // (13,2,[5 10 $]), (21,2,[5 10 $]), (11,2,[$])] - // - // In this case, (17,1,[5 $]) indicates there is some next sequence that - // would resolve this without conflict to alternative 1. Any other viable - // next sequence, however, is associated with a conflict. We stop - // looking for input because no amount of further lookahead will alter - // the fact that we should predict alternative 1. We just can't say for - // sure that there is an ambiguity without looking further. - - this.reportAmbiguity(dfa, D, startIndex, input.index, foundExactAmbig, null, reach); - - return predictedAlt; -}; - -ParserATNSimulator.prototype.computeReachSet = function(closure, t, fullCtx) { - if (this.debug) { - console.log("in computeReachSet, starting closure: " + closure); - } - if( this.mergeCache===null) { - this.mergeCache = new DoubleDict(); - } - var intermediate = new ATNConfigSet(fullCtx); - - // Configurations already in a rule stop state indicate reaching the end - // of the decision rule (local context) or end of the start rule (full - // context). Once reached, these configurations are never updated by a - // closure operation, so they are handled separately for the performance - // advantage of having a smaller intermediate set when calling closure. - // - // For full-context reach operations, separate handling is required to - // ensure that the alternative matching the longest overall sequence is - // chosen when multiple such configurations can match the input. - - var skippedStopStates = null; - - // First figure out where we can reach on input t - for (var i=0; iWhen {@code lookToEndOfRule} is true, this method uses -// {@link ATN//nextTokens} for each configuration in {@code configs} which is -// not already in a rule stop state to see if a rule stop state is reachable -// from the configuration via epsilon-only transitions.

          -// -// @param configs the configuration set to update -// @param lookToEndOfRule when true, this method checks for rule stop states -// reachable by epsilon-only transitions from each configuration in -// {@code configs}. -// -// @return {@code configs} if all configurations in {@code configs} are in a -// rule stop state, otherwise return a new configuration set containing only -// the configurations from {@code configs} which are in a rule stop state -// -ParserATNSimulator.prototype.removeAllConfigsNotInRuleStopState = function(configs, lookToEndOfRule) { - if (PredictionMode.allConfigsInRuleStopStates(configs)) { - return configs; - } - var result = new ATNConfigSet(configs.fullCtx); - for(var i=0; i -//
        • Evaluate the precedence predicates for each configuration using -// {@link SemanticContext//evalPrecedence}.
        • -//
        • Remove all configurations which predict an alternative greater than -// 1, for which another configuration that predicts alternative 1 is in the -// same ATN state with the same prediction context. This transformation is -// valid for the following reasons: -//
            -//
          • The closure block cannot contain any epsilon transitions which bypass -// the body of the closure, so all states reachable via alternative 1 are -// part of the precedence alternatives of the transformed left-recursive -// rule.
          • -//
          • The "primary" portion of a left recursive rule cannot contain an -// epsilon transition, so the only way an alternative other than 1 can exist -// in a state that is also reachable via alternative 1 is by nesting calls -// to the left-recursive rule, with the outer calls not being at the -// preferred precedence level.
          • -//
          -//
        • -// -// -//

          -// The prediction context must be considered by this filter to address -// situations like the following. -//

          -// -//
          -// grammar TA;
          -// prog: statement* EOF;
          -// statement: letterA | statement letterA 'b' ;
          -// letterA: 'a';
          -// 
          -//
          -//

          -// If the above grammar, the ATN state immediately before the token -// reference {@code 'a'} in {@code letterA} is reachable from the left edge -// of both the primary and closure blocks of the left-recursive rule -// {@code statement}. The prediction context associated with each of these -// configurations distinguishes between them, and prevents the alternative -// which stepped out to {@code prog} (and then back in to {@code statement} -// from being eliminated by the filter. -//

          -// -// @param configs The configuration set computed by -// {@link //computeStartState} as the start state for the DFA. -// @return The transformed configuration set representing the start state -// for a precedence DFA at a particular precedence level (determined by -// calling {@link Parser//getPrecedence}). -// -ParserATNSimulator.prototype.applyPrecedenceFilter = function(configs) { - var config; - var statesFromAlt1 = []; - var configSet = new ATNConfigSet(configs.fullCtx); - for(var i=0; i1 - // (basically a graph subtraction algorithm). - if (!config.precedenceFilterSuppressed) { - var context = statesFromAlt1[config.state.stateNumber] || null; - if (context!==null && context.equals(config.context)) { - // eliminated - continue; - } - } - configSet.add(config, this.mergeCache); - } - return configSet; -}; - -ParserATNSimulator.prototype.getReachableTarget = function(trans, ttype) { - if (trans.matches(ttype, 0, this.atn.maxTokenType)) { - return trans.target; - } else { - return null; - } -}; - -ParserATNSimulator.prototype.getPredsForAmbigAlts = function(ambigAlts, configs, nalts) { - // REACH=[1|1|[]|0:0, 1|2|[]|0:1] - // altToPred starts as an array of all null contexts. The entry at index i - // corresponds to alternative i. altToPred[i] may have one of three values: - // 1. null: no ATNConfig c is found such that c.alt==i - // 2. SemanticContext.NONE: At least one ATNConfig c exists such that - // c.alt==i and c.semanticContext==SemanticContext.NONE. In other words, - // alt i has at least one unpredicated config. - // 3. Non-NONE Semantic Context: There exists at least one, and for all - // ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE. - // - // From this, it is clear that NONE||anything==NONE. - // - var altToPred = []; - for(var i=0;i -// The default implementation of this method uses the following -// algorithm to identify an ATN configuration which successfully parsed the -// decision entry rule. Choosing such an alternative ensures that the -// {@link ParserRuleContext} returned by the calling rule will be complete -// and valid, and the syntax error will be reported later at a more -// localized location.

          -// -//
            -//
          • If a syntactically valid path or paths reach the end of the decision rule and -// they are semantically valid if predicated, return the min associated alt.
          • -//
          • Else, if a semantically invalid but syntactically valid path exist -// or paths exist, return the minimum associated alt. -//
          • -//
          • Otherwise, return {@link ATN//INVALID_ALT_NUMBER}.
          • -//
          -// -//

          -// In some scenarios, the algorithm described above could predict an -// alternative which will result in a {@link FailedPredicateException} in -// the parser. Specifically, this could occur if the only configuration -// capable of successfully parsing to the end of the decision rule is -// blocked by a semantic predicate. By choosing this alternative within -// {@link //adaptivePredict} instead of throwing a -// {@link NoViableAltException}, the resulting -// {@link FailedPredicateException} in the parser will identify the specific -// predicate which is preventing the parser from successfully parsing the -// decision rule, which helps developers identify and correct logic errors -// in semantic predicates. -//

          -// -// @param configs The ATN configurations which were valid immediately before -// the {@link //ERROR} state was reached -// @param outerContext The is the \gamma_0 initial parser context from the paper -// or the parser stack at the instant before prediction commences. -// -// @return The value to return from {@link //adaptivePredict}, or -// {@link ATN//INVALID_ALT_NUMBER} if a suitable alternative was not -// identified and {@link //adaptivePredict} should report an error instead. -// -ParserATNSimulator.prototype.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule = function(configs, outerContext) { - var cfgs = this.splitAccordingToSemanticValidity(configs, outerContext); - var semValidConfigs = cfgs[0]; - var semInvalidConfigs = cfgs[1]; - var alt = this.getAltThatFinishedDecisionEntryRule(semValidConfigs); - if (alt!==ATN.INVALID_ALT_NUMBER) { // semantically/syntactically viable path exists - return alt; - } - // Is there a syntactically valid path with a failed pred? - if (semInvalidConfigs.items.length>0) { - alt = this.getAltThatFinishedDecisionEntryRule(semInvalidConfigs); - if (alt!==ATN.INVALID_ALT_NUMBER) { // syntactically viable path exists - return alt; - } - } - return ATN.INVALID_ALT_NUMBER; -}; - -ParserATNSimulator.prototype.getAltThatFinishedDecisionEntryRule = function(configs) { - var alts = []; - for(var i=0;i0 || ((c.state instanceof RuleStopState) && c.context.hasEmptyPath())) { - if(alts.indexOf(c.alt)<0) { - alts.push(c.alt); - } - } - } - if (alts.length===0) { - return ATN.INVALID_ALT_NUMBER; - } else { - return Math.min.apply(null, alts); - } -}; -// Walk the list of configurations and split them according to -// those that have preds evaluating to true/false. If no pred, assume -// true pred and include in succeeded set. Returns Pair of sets. -// -// Create a new set so as not to alter the incoming parameter. -// -// Assumption: the input stream has been restored to the starting point -// prediction, which is where predicates need to evaluate. -// -ParserATNSimulator.prototype.splitAccordingToSemanticValidity = function( configs, outerContext) { - var succeeded = new ATNConfigSet(configs.fullCtx); - var failed = new ATNConfigSet(configs.fullCtx); - for(var i=0;i50) { - throw "problem"; - } - } - if (config.state instanceof RuleStopState) { - // We hit rule end. If we have context info, use it - // run thru all possible stack tops in ctx - if (! config.context.isEmpty()) { - for ( var i =0; i 0. - if (this._dfa !== null && this._dfa.precedenceDfa) { - if (t.outermostPrecedenceReturn === this._dfa.atnStartState.ruleIndex) { - c.precedenceFilterSuppressed = true; - } - } - - c.reachesIntoOuterContext += 1; - if (closureBusy.add(c)!==c) { - // avoid infinite recursion for right-recursive rules - continue; - } - configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method - newDepth -= 1; - if (this.debug) { - console.log("dips into outer ctx: " + c); - } - } else { - if (!t.isEpsilon && closureBusy.add(c)!==c){ - // avoid infinite recursion for EOF* and EOF+ - continue; - } - if (t instanceof RuleTransition) { - // latch when newDepth goes negative - once we step out of the entry context we can't return - if (newDepth >= 0) { - newDepth += 1; - } - } - } - this.closureCheckingStopState(c, configs, closureBusy, continueCollecting, fullCtx, newDepth, treatEofAsEpsilon); - } - } -}; - - -ParserATNSimulator.prototype.canDropLoopEntryEdgeInLeftRecursiveRule = function(config) { - // return False - var p = config.state; - // First check to see if we are in StarLoopEntryState generated during - // left-recursion elimination. For efficiency, also check if - // the context has an empty stack case. If so, it would mean - // global FOLLOW so we can't perform optimization - // Are we the special loop entry/exit state? or SLL wildcard - if(p.stateType != ATNState.STAR_LOOP_ENTRY) - return false; - if(p.stateType != ATNState.STAR_LOOP_ENTRY || !p.isPrecedenceDecision || - config.context.isEmpty() || config.context.hasEmptyPath()) - return false; - - // Require all return states to return back to the same rule that p is in. - var numCtxs = config.context.length; - for(var i=0; i=0) { - return this.parser.ruleNames[index]; - } else { - return ""; - } -}; - -ParserATNSimulator.prototype.getEpsilonTarget = function(config, t, collectPredicates, inContext, fullCtx, treatEofAsEpsilon) { - switch(t.serializationType) { - case Transition.RULE: - return this.ruleTransition(config, t); - case Transition.PRECEDENCE: - return this.precedenceTransition(config, t, collectPredicates, inContext, fullCtx); - case Transition.PREDICATE: - return this.predTransition(config, t, collectPredicates, inContext, fullCtx); - case Transition.ACTION: - return this.actionTransition(config, t); - case Transition.EPSILON: - return new ATNConfig({state:t.target}, config); - case Transition.ATOM: - case Transition.RANGE: - case Transition.SET: - // EOF transitions act like epsilon transitions after the first EOF - // transition is traversed - if (treatEofAsEpsilon) { - if (t.matches(Token.EOF, 0, 1)) { - return new ATNConfig({state: t.target}, config); - } - } - return null; - default: - return null; - } -}; - -ParserATNSimulator.prototype.actionTransition = function(config, t) { - if (this.debug) { - var index = t.actionIndex==-1 ? 65535 : t.actionIndex; - console.log("ACTION edge " + t.ruleIndex + ":" + index); - } - return new ATNConfig({state:t.target}, config); -}; - -ParserATNSimulator.prototype.precedenceTransition = function(config, pt, collectPredicates, inContext, fullCtx) { - if (this.debug) { - console.log("PRED (collectPredicates=" + collectPredicates + ") " + - pt.precedence + ">=_p, ctx dependent=true"); - if (this.parser!==null) { - console.log("context surrounding pred is " + Utils.arrayToString(this.parser.getRuleInvocationStack())); - } - } - var c = null; - if (collectPredicates && inContext) { - if (fullCtx) { - // In full context mode, we can evaluate predicates on-the-fly - // during closure, which dramatically reduces the size of - // the config sets. It also obviates the need to test predicates - // later during conflict resolution. - var currentPosition = this._input.index; - this._input.seek(this._startIndex); - var predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext); - this._input.seek(currentPosition); - if (predSucceeds) { - c = new ATNConfig({state:pt.target}, config); // no pred context - } - } else { - var newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate()); - c = new ATNConfig({state:pt.target, semanticContext:newSemCtx}, config); - } - } else { - c = new ATNConfig({state:pt.target}, config); - } - if (this.debug) { - console.log("config from pred transition=" + c); - } - return c; -}; - -ParserATNSimulator.prototype.predTransition = function(config, pt, collectPredicates, inContext, fullCtx) { - if (this.debug) { - console.log("PRED (collectPredicates=" + collectPredicates + ") " + pt.ruleIndex + - ":" + pt.predIndex + ", ctx dependent=" + pt.isCtxDependent); - if (this.parser!==null) { - console.log("context surrounding pred is " + Utils.arrayToString(this.parser.getRuleInvocationStack())); - } - } - var c = null; - if (collectPredicates && ((pt.isCtxDependent && inContext) || ! pt.isCtxDependent)) { - if (fullCtx) { - // In full context mode, we can evaluate predicates on-the-fly - // during closure, which dramatically reduces the size of - // the config sets. It also obviates the need to test predicates - // later during conflict resolution. - var currentPosition = this._input.index; - this._input.seek(this._startIndex); - var predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext); - this._input.seek(currentPosition); - if (predSucceeds) { - c = new ATNConfig({state:pt.target}, config); // no pred context - } - } else { - var newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate()); - c = new ATNConfig({state:pt.target, semanticContext:newSemCtx}, config); - } - } else { - c = new ATNConfig({state:pt.target}, config); - } - if (this.debug) { - console.log("config from pred transition=" + c); - } - return c; -}; - -ParserATNSimulator.prototype.ruleTransition = function(config, t) { - if (this.debug) { - console.log("CALL rule " + this.getRuleName(t.target.ruleIndex) + ", ctx=" + config.context); - } - var returnState = t.followState; - var newContext = SingletonPredictionContext.create(config.context, returnState.stateNumber); - return new ATNConfig({state:t.target, context:newContext}, config ); -}; - -ParserATNSimulator.prototype.getConflictingAlts = function(configs) { - var altsets = PredictionMode.getConflictingAltSubsets(configs); - return PredictionMode.getAlts(altsets); -}; - - // Sam pointed out a problem with the previous definition, v3, of - // ambiguous states. If we have another state associated with conflicting - // alternatives, we should keep going. For example, the following grammar - // - // s : (ID | ID ID?) ';' ; - // - // When the ATN simulation reaches the state before ';', it has a DFA - // state that looks like: [12|1|[], 6|2|[], 12|2|[]]. Naturally - // 12|1|[] and 12|2|[] conflict, but we cannot stop processing this node - // because alternative to has another way to continue, via [6|2|[]]. - // The key is that we have a single state that has config's only associated - // with a single alternative, 2, and crucially the state transitions - // among the configurations are all non-epsilon transitions. That means - // we don't consider any conflicts that include alternative 2. So, we - // ignore the conflict between alts 1 and 2. We ignore a set of - // conflicting alts when there is an intersection with an alternative - // associated with a single alt state in the state→config-list map. - // - // It's also the case that we might have two conflicting configurations but - // also a 3rd nonconflicting configuration for a different alternative: - // [1|1|[], 1|2|[], 8|3|[]]. This can come about from grammar: - // - // a : A | A | A B ; - // - // After matching input A, we reach the stop state for rule A, state 1. - // State 8 is the state right before B. Clearly alternatives 1 and 2 - // conflict and no amount of further lookahead will separate the two. - // However, alternative 3 will be able to continue and so we do not - // stop working on this state. In the previous example, we're concerned - // with states associated with the conflicting alternatives. Here alt - // 3 is not associated with the conflicting configs, but since we can continue - // looking for input reasonably, I don't declare the state done. We - // ignore a set of conflicting alts when we have an alternative - // that we still need to pursue. -// - -ParserATNSimulator.prototype.getConflictingAltsOrUniqueAlt = function(configs) { - var conflictingAlts = null; - if (configs.uniqueAlt!== ATN.INVALID_ALT_NUMBER) { - conflictingAlts = new BitSet(); - conflictingAlts.add(configs.uniqueAlt); - } else { - conflictingAlts = configs.conflictingAlts; - } - return conflictingAlts; -}; - -ParserATNSimulator.prototype.getTokenName = function( t) { - if (t===Token.EOF) { - return "EOF"; - } - if( this.parser!==null && this.parser.literalNames!==null) { - if (t >= this.parser.literalNames.length && t >= this.parser.symbolicNames.length) { - console.log("" + t + " ttype out of range: " + this.parser.literalNames); - console.log("" + this.parser.getInputStream().getTokens()); - } else { - var name = this.parser.literalNames[t] || this.parser.symbolicNames[t]; - return name + "<" + t + ">"; - } - } - return "" + t; -}; - -ParserATNSimulator.prototype.getLookaheadName = function(input) { - return this.getTokenName(input.LA(1)); -}; - -// Used for debugging in adaptivePredict around execATN but I cut -// it out for clarity now that alg. works well. We can leave this -// "dead" code for a bit. -// -ParserATNSimulator.prototype.dumpDeadEndConfigs = function(nvae) { - console.log("dead end configs: "); - var decs = nvae.getDeadEndConfigs(); - for(var i=0; i0) { - var t = c.state.transitions[0]; - if (t instanceof AtomTransition) { - trans = "Atom "+ this.getTokenName(t.label); - } else if (t instanceof SetTransition) { - var neg = (t instanceof NotSetTransition); - trans = (neg ? "~" : "") + "Set " + t.set; - } - } - console.error(c.toString(this.parser, true) + ":" + trans); - } -}; - -ParserATNSimulator.prototype.noViableAlt = function(input, outerContext, configs, startIndex) { - return new NoViableAltException(this.parser, input, input.get(startIndex), input.LT(1), configs, outerContext); -}; - -ParserATNSimulator.prototype.getUniqueAlt = function(configs) { - var alt = ATN.INVALID_ALT_NUMBER; - for(var i=0;iIf {@code to} is {@code null}, this method returns {@code null}. -// Otherwise, this method returns the {@link DFAState} returned by calling -// {@link //addDFAState} for the {@code to} state.

          -// -// @param dfa The DFA -// @param from The source state for the edge -// @param t The input symbol -// @param to The target state for the edge -// -// @return If {@code to} is {@code null}, this method returns {@code null}; -// otherwise this method returns the result of calling {@link //addDFAState} -// on {@code to} -// -ParserATNSimulator.prototype.addDFAEdge = function(dfa, from_, t, to) { - if( this.debug) { - console.log("EDGE " + from_ + " -> " + to + " upon " + this.getTokenName(t)); - } - if (to===null) { - return null; - } - to = this.addDFAState(dfa, to); // used existing if possible not incoming - if (from_===null || t < -1 || t > this.atn.maxTokenType) { - return to; - } - if (from_.edges===null) { - from_.edges = []; - } - from_.edges[t+1] = to; // connect - - if (this.debug) { - var literalNames = this.parser===null ? null : this.parser.literalNames; - var symbolicNames = this.parser===null ? null : this.parser.symbolicNames; - console.log("DFA=\n" + dfa.toString(literalNames, symbolicNames)); - } - return to; -}; -// -// Add state {@code D} to the DFA if it is not already present, and return -// the actual instance stored in the DFA. If a state equivalent to {@code D} -// is already in the DFA, the existing state is returned. Otherwise this -// method returns {@code D} after adding it to the DFA. -// -//

          If {@code D} is {@link //ERROR}, this method returns {@link //ERROR} and -// does not change the DFA.

          -// -// @param dfa The dfa -// @param D The DFA state to add -// @return The state stored in the DFA. This will be either the existing -// state if {@code D} is already in the DFA, or {@code D} itself if the -// state was not already present. -// -ParserATNSimulator.prototype.addDFAState = function(dfa, D) { - if (D == ATNSimulator.ERROR) { - return D; - } - var existing = dfa.states.get(D); - if(existing!==null) { - return existing; - } - D.stateNumber = dfa.states.length; - if (! D.configs.readOnly) { - D.configs.optimizeConfigs(this); - D.configs.setReadonly(true); - } - dfa.states.add(D); - if (this.debug) { - console.log("adding new DFA state: " + D); - } - return D; -}; - -ParserATNSimulator.prototype.reportAttemptingFullContext = function(dfa, conflictingAlts, configs, startIndex, stopIndex) { - if (this.debug || this.retry_debug) { - var interval = new Interval(startIndex, stopIndex + 1); - console.log("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs + - ", input=" + this.parser.getTokenStream().getText(interval)); - } - if (this.parser!==null) { - this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs); - } -}; - -ParserATNSimulator.prototype.reportContextSensitivity = function(dfa, prediction, configs, startIndex, stopIndex) { - if (this.debug || this.retry_debug) { - var interval = new Interval(startIndex, stopIndex + 1); - console.log("reportContextSensitivity decision=" + dfa.decision + ":" + configs + - ", input=" + this.parser.getTokenStream().getText(interval)); - } - if (this.parser!==null) { - this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs); - } -}; - -// If context sensitive parsing, we know it's ambiguity not conflict// -ParserATNSimulator.prototype.reportAmbiguity = function(dfa, D, startIndex, stopIndex, - exact, ambigAlts, configs ) { - if (this.debug || this.retry_debug) { - var interval = new Interval(startIndex, stopIndex + 1); - console.log("reportAmbiguity " + ambigAlts + ":" + configs + - ", input=" + this.parser.getTokenStream().getText(interval)); - } - if (this.parser!==null) { - this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs); - } -}; - -exports.ParserATNSimulator = ParserATNSimulator; - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -exports.DFA = __webpack_require__(43).DFA; -exports.DFASerializer = __webpack_require__(17).DFASerializer; -exports.LexerDFASerializer = __webpack_require__(17).LexerDFASerializer; -exports.PredPrediction = __webpack_require__(11).PredPrediction; - - -/***/ }), -/* 43 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -var Set = __webpack_require__(0).Set; -var DFAState = __webpack_require__(11).DFAState; -var StarLoopEntryState = __webpack_require__(3).StarLoopEntryState; -var ATNConfigSet = __webpack_require__(9).ATNConfigSet; -var DFASerializer = __webpack_require__(17).DFASerializer; -var LexerDFASerializer = __webpack_require__(17).LexerDFASerializer; - - - -function DFA(atnStartState, decision) { - if (decision === undefined) { - decision = 0; - } - // From which ATN state did we create this DFA? - this.atnStartState = atnStartState; - this.decision = decision; - // A set of all DFA states. Use {@link Map} so we can get old state back - // ({@link Set} only allows you to see if it's there). - this._states = new Set(); - this.s0 = null; - // {@code true} if this DFA is for a precedence decision; otherwise, - // {@code false}. This is the backing field for {@link //isPrecedenceDfa}, - // {@link //setPrecedenceDfa}. - this.precedenceDfa = false; - if (atnStartState instanceof StarLoopEntryState) - { - if (atnStartState.isPrecedenceDecision) { - this.precedenceDfa = true; - var precedenceState = new DFAState(null, new ATNConfigSet()); - precedenceState.edges = []; - precedenceState.isAcceptState = false; - precedenceState.requiresFullContext = false; - this.s0 = precedenceState; - } - } - return this; -} - -// Get the start state for a specific precedence value. -// -// @param precedence The current precedence. -// @return The start state corresponding to the specified precedence, or -// {@code null} if no start state exists for the specified precedence. -// -// @throws IllegalStateException if this is not a precedence DFA. -// @see //isPrecedenceDfa() - -DFA.prototype.getPrecedenceStartState = function(precedence) { - if (!(this.precedenceDfa)) { - throw ("Only precedence DFAs may contain a precedence start state."); - } - // s0.edges is never null for a precedence DFA - if (precedence < 0 || precedence >= this.s0.edges.length) { - return null; - } - return this.s0.edges[precedence] || null; -}; - -// Set the start state for a specific precedence value. -// -// @param precedence The current precedence. -// @param startState The start state corresponding to the specified -// precedence. -// -// @throws IllegalStateException if this is not a precedence DFA. -// @see //isPrecedenceDfa() -// -DFA.prototype.setPrecedenceStartState = function(precedence, startState) { - if (!(this.precedenceDfa)) { - throw ("Only precedence DFAs may contain a precedence start state."); - } - if (precedence < 0) { - return; - } - - // synchronization on s0 here is ok. when the DFA is turned into a - // precedence DFA, s0 will be initialized once and not updated again - // s0.edges is never null for a precedence DFA - this.s0.edges[precedence] = startState; -}; - -// -// Sets whether this is a precedence DFA. If the specified value differs -// from the current DFA configuration, the following actions are taken; -// otherwise no changes are made to the current DFA. -// -//
            -//
          • The {@link //states} map is cleared
          • -//
          • If {@code precedenceDfa} is {@code false}, the initial state -// {@link //s0} is set to {@code null}; otherwise, it is initialized to a new -// {@link DFAState} with an empty outgoing {@link DFAState//edges} array to -// store the start states for individual precedence values.
          • -//
          • The {@link //precedenceDfa} field is updated
          • -//
          -// -// @param precedenceDfa {@code true} if this is a precedence DFA; otherwise, -// {@code false} - -DFA.prototype.setPrecedenceDfa = function(precedenceDfa) { - if (this.precedenceDfa!==precedenceDfa) { - this._states = new DFAStatesSet(); - if (precedenceDfa) { - var precedenceState = new DFAState(null, new ATNConfigSet()); - precedenceState.edges = []; - precedenceState.isAcceptState = false; - precedenceState.requiresFullContext = false; - this.s0 = precedenceState; - } else { - this.s0 = null; - } - this.precedenceDfa = precedenceDfa; - } -}; - -Object.defineProperty(DFA.prototype, "states", { - get : function() { - return this._states; - } -}); - -// Return a list of all states in this DFA, ordered by state number. -DFA.prototype.sortedStates = function() { - var list = this._states.values(); - return list.sort(function(a, b) { - return a.stateNumber - b.stateNumber; - }); -}; - -DFA.prototype.toString = function(literalNames, symbolicNames) { - literalNames = literalNames || null; - symbolicNames = symbolicNames || null; - if (this.s0 === null) { - return ""; - } - var serializer = new DFASerializer(this, literalNames, symbolicNames); - return serializer.toString(); -}; - -DFA.prototype.toLexerString = function() { - if (this.s0 === null) { - return ""; - } - var serializer = new LexerDFASerializer(this); - return serializer.toString(); -}; - -exports.DFA = DFA; - - -/***/ }), -/* 44 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -var Tree = __webpack_require__(4); -exports.Trees = __webpack_require__(20).Trees; -exports.RuleNode = Tree.RuleNode; -exports.ParseTreeListener = Tree.ParseTreeListener; -exports.ParseTreeVisitor = Tree.ParseTreeVisitor; -exports.ParseTreeWalker = Tree.ParseTreeWalker; - - -/***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -exports.RecognitionException = __webpack_require__(5).RecognitionException; -exports.NoViableAltException = __webpack_require__(5).NoViableAltException; -exports.LexerNoViableAltException = __webpack_require__(5).LexerNoViableAltException; -exports.InputMismatchException = __webpack_require__(5).InputMismatchException; -exports.FailedPredicateException = __webpack_require__(5).FailedPredicateException; -exports.DiagnosticErrorListener = __webpack_require__(46).DiagnosticErrorListener; -exports.BailErrorStrategy = __webpack_require__(29).BailErrorStrategy; -exports.ErrorListener = __webpack_require__(16).ErrorListener; - - -/***/ }), -/* 46 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// -// This implementation of {@link ANTLRErrorListener} can be used to identify -// certain potential correctness and performance problems in grammars. "Reports" -// are made by calling {@link Parser//notifyErrorListeners} with the appropriate -// message. -// -//
            -//
          • Ambiguities: These are cases where more than one path through the -// grammar can match the input.
          • -//
          • Weak context sensitivity: These are cases where full-context -// prediction resolved an SLL conflict to a unique alternative which equaled the -// minimum alternative of the SLL conflict.
          • -//
          • Strong (forced) context sensitivity: These are cases where the -// full-context prediction resolved an SLL conflict to a unique alternative, -// and the minimum alternative of the SLL conflict was found to not be -// a truly viable alternative. Two-stage parsing cannot be used for inputs where -// this situation occurs.
          • -//
          - -var BitSet = __webpack_require__(0).BitSet; -var ErrorListener = __webpack_require__(16).ErrorListener; -var Interval = __webpack_require__(2).Interval; - -function DiagnosticErrorListener(exactOnly) { - ErrorListener.call(this); - exactOnly = exactOnly || true; - // whether all ambiguities or only exact ambiguities are reported. - this.exactOnly = exactOnly; - return this; -} - -DiagnosticErrorListener.prototype = Object.create(ErrorListener.prototype); -DiagnosticErrorListener.prototype.constructor = DiagnosticErrorListener; - -DiagnosticErrorListener.prototype.reportAmbiguity = function(recognizer, dfa, - startIndex, stopIndex, exact, ambigAlts, configs) { - if (this.exactOnly && !exact) { - return; - } - var msg = "reportAmbiguity d=" + - this.getDecisionDescription(recognizer, dfa) + - ": ambigAlts=" + - this.getConflictingAlts(ambigAlts, configs) + - ", input='" + - recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'"; - recognizer.notifyErrorListeners(msg); -}; - -DiagnosticErrorListener.prototype.reportAttemptingFullContext = function( - recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) { - var msg = "reportAttemptingFullContext d=" + - this.getDecisionDescription(recognizer, dfa) + - ", input='" + - recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'"; - recognizer.notifyErrorListeners(msg); -}; - -DiagnosticErrorListener.prototype.reportContextSensitivity = function( - recognizer, dfa, startIndex, stopIndex, prediction, configs) { - var msg = "reportContextSensitivity d=" + - this.getDecisionDescription(recognizer, dfa) + - ", input='" + - recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'"; - recognizer.notifyErrorListeners(msg); -}; - -DiagnosticErrorListener.prototype.getDecisionDescription = function(recognizer, dfa) { - var decision = dfa.decision; - var ruleIndex = dfa.atnStartState.ruleIndex; - - var ruleNames = recognizer.ruleNames; - if (ruleIndex < 0 || ruleIndex >= ruleNames.length) { - return "" + decision; - } - var ruleName = ruleNames[ruleIndex] || null; - if (ruleName === null || ruleName.length === 0) { - return "" + decision; - } - return "" + decision + " (" + ruleName + ")"; -}; - -// -// Computes the set of conflicting or ambiguous alternatives from a -// configuration set, if that information was not already provided by the -// parser. -// -// @param reportedAlts The set of conflicting or ambiguous alternatives, as -// reported by the parser. -// @param configs The conflicting or ambiguous configuration set. -// @return Returns {@code reportedAlts} if it is not {@code null}, otherwise -// returns the set of alternatives represented in {@code configs}. -// -DiagnosticErrorListener.prototype.getConflictingAlts = function(reportedAlts, configs) { - if (reportedAlts !== null) { - return reportedAlts; - } - var result = new BitSet(); - for (var i = 0; i < configs.items.length; i++) { - result.add(configs.items[i].alt); - } - return "{" + result.values().join(", ") + "}"; -}; - -exports.DiagnosticErrorListener = DiagnosticErrorListener; - -/***/ }), -/* 47 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -var InputStream = __webpack_require__(19).InputStream; - -var isNodeJs = typeof window === 'undefined' && typeof importScripts === 'undefined'; -var fs = isNodeJs ? __webpack_require__(30) : null; - -// Utility functions to create InputStreams from various sources. -// -// All returned InputStreams support the full range of Unicode -// up to U+10FFFF (the default behavior of InputStream only supports -// code points up to U+FFFF). -var CharStreams = { - // Creates an InputStream from a string. - fromString: function(str) { - return new InputStream(str, true); - }, - - // Asynchronously creates an InputStream from a blob given the - // encoding of the bytes in that blob (defaults to 'utf8' if - // encoding is null). - // - // Invokes onLoad(result) on success, onError(error) on - // failure. - fromBlob: function(blob, encoding, onLoad, onError) { - var reader = FileReader(); - reader.onload = function(e) { - var is = new InputStream(e.target.result, true); - onLoad(is); - }; - reader.onerror = onError; - reader.readAsText(blob, encoding); - }, - - // Creates an InputStream from a Buffer given the - // encoding of the bytes in that buffer (defaults to 'utf8' if - // encoding is null). - fromBuffer: function(buffer, encoding) { - return new InputStream(buffer.toString(encoding), true); - }, - - // Asynchronously creates an InputStream from a file on disk given - // the encoding of the bytes in that file (defaults to 'utf8' if - // encoding is null). - // - // Invokes callback(error, result) on completion. - fromPath: function(path, encoding, callback) { - fs.readFile(path, encoding, function(err, data) { - var is = null; - if (data !== null) { - is = new InputStream(data, true); - } - callback(err, is); - }); - }, - - // Synchronously creates an InputStream given a path to a file - // on disk and the encoding of the bytes in that file (defaults to - // 'utf8' if encoding is null). - fromPathSync: function(path, encoding) { - var data = fs.readFileSync(path, encoding); - return new InputStream(data, true); - } -}; - -exports.CharStreams = CharStreams; - - -/***/ }), -/* 48 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -// - -// -// This is an InputStream that is loaded from a file all at once -// when you construct the object. -// -var InputStream = __webpack_require__(19).InputStream; -var isNodeJs = typeof window === 'undefined' && typeof importScripts === 'undefined'; -var fs = isNodeJs ? __webpack_require__(30) : null; - -function FileStream(fileName, decodeToUnicodeCodePoints) { - var data = fs.readFileSync(fileName, "utf8"); - InputStream.call(this, data, decodeToUnicodeCodePoints); - this.fileName = fileName; - return this; -} - -FileStream.prototype = Object.create(InputStream.prototype); -FileStream.prototype.constructor = FileStream; - -exports.FileStream = FileStream; - - -/***/ }), -/* 49 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ -/// - -// -// This class extends {@link BufferedTokenStream} with functionality to filter -// token streams to tokens on a particular channel (tokens where -// {@link Token//getChannel} returns a particular value). -// -//

          -// This token stream provides access to all tokens by index or when calling -// methods like {@link //getText}. The channel filtering is only used for code -// accessing tokens via the lookahead methods {@link //LA}, {@link //LT}, and -// {@link //LB}.

          -// -//

          -// By default, tokens are placed on the default channel -// ({@link Token//DEFAULT_CHANNEL}), but may be reassigned by using the -// {@code ->channel(HIDDEN)} lexer command, or by using an embedded action to -// call {@link Lexer//setChannel}. -//

          -// -//

          -// Note: lexer rules which use the {@code ->skip} lexer command or call -// {@link Lexer//skip} do not produce tokens at all, so input text matched by -// such a rule will not be available as part of the token stream, regardless of -// channel.

          -/// - -var Token = __webpack_require__(1).Token; -var BufferedTokenStream = __webpack_require__(50).BufferedTokenStream; - -function CommonTokenStream(lexer, channel) { - BufferedTokenStream.call(this, lexer); - this.channel = channel===undefined ? Token.DEFAULT_CHANNEL : channel; - return this; -} - -CommonTokenStream.prototype = Object.create(BufferedTokenStream.prototype); -CommonTokenStream.prototype.constructor = CommonTokenStream; - -CommonTokenStream.prototype.adjustSeekIndex = function(i) { - return this.nextTokenOnChannel(i, this.channel); -}; - -CommonTokenStream.prototype.LB = function(k) { - if (k===0 || this.index-k<0) { - return null; - } - var i = this.index; - var n = 1; - // find k good tokens looking backwards - while (n <= k) { - // skip off-channel tokens - i = this.previousTokenOnChannel(i - 1, this.channel); - n += 1; - } - if (i < 0) { - return null; - } - return this.tokens[i]; -}; - -CommonTokenStream.prototype.LT = function(k) { - this.lazyInit(); - if (k === 0) { - return null; - } - if (k < 0) { - return this.LB(-k); - } - var i = this.index; - var n = 1; // we know tokens[pos] is a good one - // find k good tokens - while (n < k) { - // skip off-channel tokens, but make sure to not look past EOF - if (this.sync(i + 1)) { - i = this.nextTokenOnChannel(i + 1, this.channel); - } - n += 1; - } - return this.tokens[i]; -}; - -// Count EOF just once./// -CommonTokenStream.prototype.getNumberOfOnChannelTokens = function() { - var n = 0; - this.fill(); - for (var i =0; i< this.tokens.length;i++) { - var t = this.tokens[i]; - if( t.channel===this.channel) { - n += 1; - } - if( t.type===Token.EOF) { - break; - } - } - return n; -}; - -exports.CommonTokenStream = CommonTokenStream; - -/***/ }), -/* 50 */ -/***/ (function(module, exports, __webpack_require__) { - -// -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -// This implementation of {@link TokenStream} loads tokens from a -// {@link TokenSource} on-demand, and places the tokens in a buffer to provide -// access to any previous token by index. -// -//

          -// This token stream ignores the value of {@link Token//getChannel}. If your -// parser requires the token stream filter tokens to only those on a particular -// channel, such as {@link Token//DEFAULT_CHANNEL} or -// {@link Token//HIDDEN_CHANNEL}, use a filtering token stream such a -// {@link CommonTokenStream}.

          - -var Token = __webpack_require__(1).Token; -var Lexer = __webpack_require__(15).Lexer; -var Interval = __webpack_require__(2).Interval; - -// this is just to keep meaningful parameter types to Parser -function TokenStream() { - return this; -} - -function BufferedTokenStream(tokenSource) { - - TokenStream.call(this); - // The {@link TokenSource} from which tokens for this stream are fetched. - this.tokenSource = tokenSource; - - // A collection of all tokens fetched from the token source. The list is - // considered a complete view of the input once {@link //fetchedEOF} is set - // to {@code true}. - this.tokens = []; - - // The index into {@link //tokens} of the current token (next token to - // {@link //consume}). {@link //tokens}{@code [}{@link //p}{@code ]} should - // be - // {@link //LT LT(1)}. - // - //

          This field is set to -1 when the stream is first constructed or when - // {@link //setTokenSource} is called, indicating that the first token has - // not yet been fetched from the token source. For additional information, - // see the documentation of {@link IntStream} for a description of - // Initializing Methods.

          - this.index = -1; - - // Indicates whether the {@link Token//EOF} token has been fetched from - // {@link //tokenSource} and added to {@link //tokens}. This field improves - // performance for the following cases: - // - //
            - //
          • {@link //consume}: The lookahead check in {@link //consume} to - // prevent - // consuming the EOF symbol is optimized by checking the values of - // {@link //fetchedEOF} and {@link //p} instead of calling {@link - // //LA}.
          • - //
          • {@link //fetch}: The check to prevent adding multiple EOF symbols - // into - // {@link //tokens} is trivial with this field.
          • - //
              - this.fetchedEOF = false; - return this; -} - -BufferedTokenStream.prototype = Object.create(TokenStream.prototype); -BufferedTokenStream.prototype.constructor = BufferedTokenStream; - -BufferedTokenStream.prototype.mark = function() { - return 0; -}; - -BufferedTokenStream.prototype.release = function(marker) { - // no resources to release -}; - -BufferedTokenStream.prototype.reset = function() { - this.seek(0); -}; - -BufferedTokenStream.prototype.seek = function(index) { - this.lazyInit(); - this.index = this.adjustSeekIndex(index); -}; - -BufferedTokenStream.prototype.get = function(index) { - this.lazyInit(); - return this.tokens[index]; -}; - -BufferedTokenStream.prototype.consume = function() { - var skipEofCheck = false; - if (this.index >= 0) { - if (this.fetchedEOF) { - // the last token in tokens is EOF. skip check if p indexes any - // fetched token except the last. - skipEofCheck = this.index < this.tokens.length - 1; - } else { - // no EOF token in tokens. skip check if p indexes a fetched token. - skipEofCheck = this.index < this.tokens.length; - } - } else { - // not yet initialized - skipEofCheck = false; - } - if (!skipEofCheck && this.LA(1) === Token.EOF) { - throw "cannot consume EOF"; - } - if (this.sync(this.index + 1)) { - this.index = this.adjustSeekIndex(this.index + 1); - } -}; - -// Make sure index {@code i} in tokens has a token. -// -// @return {@code true} if a token is located at index {@code i}, otherwise -// {@code false}. -// @see //get(int i) -// / -BufferedTokenStream.prototype.sync = function(i) { - var n = i - this.tokens.length + 1; // how many more elements we need? - if (n > 0) { - var fetched = this.fetch(n); - return fetched >= n; - } - return true; -}; - -// Add {@code n} elements to buffer. -// -// @return The actual number of elements added to the buffer. -// / -BufferedTokenStream.prototype.fetch = function(n) { - if (this.fetchedEOF) { - return 0; - } - for (var i = 0; i < n; i++) { - var t = this.tokenSource.nextToken(); - t.tokenIndex = this.tokens.length; - this.tokens.push(t); - if (t.type === Token.EOF) { - this.fetchedEOF = true; - return i + 1; - } - } - return n; -}; - -// Get all tokens from start..stop inclusively/// -BufferedTokenStream.prototype.getTokens = function(start, stop, types) { - if (types === undefined) { - types = null; - } - if (start < 0 || stop < 0) { - return null; - } - this.lazyInit(); - var subset = []; - if (stop >= this.tokens.length) { - stop = this.tokens.length - 1; - } - for (var i = start; i < stop; i++) { - var t = this.tokens[i]; - if (t.type === Token.EOF) { - break; - } - if (types === null || types.contains(t.type)) { - subset.push(t); - } - } - return subset; -}; - -BufferedTokenStream.prototype.LA = function(i) { - return this.LT(i).type; -}; - -BufferedTokenStream.prototype.LB = function(k) { - if (this.index - k < 0) { - return null; - } - return this.tokens[this.index - k]; -}; - -BufferedTokenStream.prototype.LT = function(k) { - this.lazyInit(); - if (k === 0) { - return null; - } - if (k < 0) { - return this.LB(-k); - } - var i = this.index + k - 1; - this.sync(i); - if (i >= this.tokens.length) { // return EOF token - // EOF must be last token - return this.tokens[this.tokens.length - 1]; - } - return this.tokens[i]; -}; - -// Allowed derived classes to modify the behavior of operations which change -// the current stream position by adjusting the target token index of a seek -// operation. The default implementation simply returns {@code i}. If an -// exception is thrown in this method, the current stream index should not be -// changed. -// -//

              For example, {@link CommonTokenStream} overrides this method to ensure -// that -// the seek target is always an on-channel token.

              -// -// @param i The target token index. -// @return The adjusted target token index. - -BufferedTokenStream.prototype.adjustSeekIndex = function(i) { - return i; -}; - -BufferedTokenStream.prototype.lazyInit = function() { - if (this.index === -1) { - this.setup(); - } -}; - -BufferedTokenStream.prototype.setup = function() { - this.sync(0); - this.index = this.adjustSeekIndex(0); -}; - -// Reset this token stream by setting its token source./// -BufferedTokenStream.prototype.setTokenSource = function(tokenSource) { - this.tokenSource = tokenSource; - this.tokens = []; - this.index = -1; - this.fetchedEOF = false; -}; - - -// Given a starting index, return the index of the next token on channel. -// Return i if tokens[i] is on channel. Return -1 if there are no tokens -// on channel between i and EOF. -// / -BufferedTokenStream.prototype.nextTokenOnChannel = function(i, channel) { - this.sync(i); - if (i >= this.tokens.length) { - return -1; - } - var token = this.tokens[i]; - while (token.channel !== this.channel) { - if (token.type === Token.EOF) { - return -1; - } - i += 1; - this.sync(i); - token = this.tokens[i]; - } - return i; -}; - -// Given a starting index, return the index of the previous token on channel. -// Return i if tokens[i] is on channel. Return -1 if there are no tokens -// on channel between i and 0. -BufferedTokenStream.prototype.previousTokenOnChannel = function(i, channel) { - while (i >= 0 && this.tokens[i].channel !== channel) { - i -= 1; - } - return i; -}; - -// Collect all tokens on specified channel to the right of -// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or -// EOF. If channel is -1, find any non default channel token. -BufferedTokenStream.prototype.getHiddenTokensToRight = function(tokenIndex, - channel) { - if (channel === undefined) { - channel = -1; - } - this.lazyInit(); - if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { - throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; - } - var nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL); - var from_ = tokenIndex + 1; - // if none onchannel to right, nextOnChannel=-1 so set to = last token - var to = nextOnChannel === -1 ? this.tokens.length - 1 : nextOnChannel; - return this.filterForChannel(from_, to, channel); -}; - -// Collect all tokens on specified channel to the left of -// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL. -// If channel is -1, find any non default channel token. -BufferedTokenStream.prototype.getHiddenTokensToLeft = function(tokenIndex, - channel) { - if (channel === undefined) { - channel = -1; - } - this.lazyInit(); - if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { - throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; - } - var prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL); - if (prevOnChannel === tokenIndex - 1) { - return null; - } - // if none on channel to left, prevOnChannel=-1 then from=0 - var from_ = prevOnChannel + 1; - var to = tokenIndex - 1; - return this.filterForChannel(from_, to, channel); -}; - -BufferedTokenStream.prototype.filterForChannel = function(left, right, channel) { - var hidden = []; - for (var i = left; i < right + 1; i++) { - var t = this.tokens[i]; - if (channel === -1) { - if (t.channel !== Lexer.DEFAULT_TOKEN_CHANNEL) { - hidden.push(t); - } - } else if (t.channel === channel) { - hidden.push(t); - } - } - if (hidden.length === 0) { - return null; - } - return hidden; -}; - -BufferedTokenStream.prototype.getSourceName = function() { - return this.tokenSource.getSourceName(); -}; - -// Get the text of all tokens in this buffer./// -BufferedTokenStream.prototype.getText = function(interval) { - this.lazyInit(); - this.fill(); - if (interval === undefined || interval === null) { - interval = new Interval(0, this.tokens.length - 1); - } - var start = interval.start; - if (start instanceof Token) { - start = start.tokenIndex; - } - var stop = interval.stop; - if (stop instanceof Token) { - stop = stop.tokenIndex; - } - if (start === null || stop === null || start < 0 || stop < 0) { - return ""; - } - if (stop >= this.tokens.length) { - stop = this.tokens.length - 1; - } - var s = ""; - for (var i = start; i < stop + 1; i++) { - var t = this.tokens[i]; - if (t.type === Token.EOF) { - break; - } - s = s + t.text; - } - return s; -}; - -// Get all tokens from lexer until EOF/// -BufferedTokenStream.prototype.fill = function() { - this.lazyInit(); - while (this.fetch(1000) === 1000) { - continue; - } -}; - -exports.BufferedTokenStream = BufferedTokenStream; - - -/***/ }), -/* 51 */ -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -var Token = __webpack_require__(1).Token; -var ParseTreeListener = __webpack_require__(4).ParseTreeListener; -var Recognizer = __webpack_require__(24).Recognizer; -var DefaultErrorStrategy = __webpack_require__(29).DefaultErrorStrategy; -var ATNDeserializer = __webpack_require__(21).ATNDeserializer; -var ATNDeserializationOptions = __webpack_require__(22).ATNDeserializationOptions; -var TerminalNode = __webpack_require__(4).TerminalNode; -var ErrorNode = __webpack_require__(4).ErrorNode; - -function TraceListener(parser) { - ParseTreeListener.call(this); - this.parser = parser; - return this; -} - -TraceListener.prototype = Object.create(ParseTreeListener.prototype); -TraceListener.prototype.constructor = TraceListener; - -TraceListener.prototype.enterEveryRule = function(ctx) { - console.log("enter " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text); -}; - -TraceListener.prototype.visitTerminal = function( node) { - console.log("consume " + node.symbol + " rule " + this.parser.ruleNames[this.parser._ctx.ruleIndex]); -}; - -TraceListener.prototype.exitEveryRule = function(ctx) { - console.log("exit " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text); -}; - -// this is all the parsing support code essentially; most of it is error -// recovery stuff.// -function Parser(input) { - Recognizer.call(this); - // The input stream. - this._input = null; - // The error handling strategy for the parser. The default value is a new - // instance of {@link DefaultErrorStrategy}. - this._errHandler = new DefaultErrorStrategy(); - this._precedenceStack = []; - this._precedenceStack.push(0); - // The {@link ParserRuleContext} object for the currently executing rule. - // this is always non-null during the parsing process. - this._ctx = null; - // Specifies whether or not the parser should construct a parse tree during - // the parsing process. The default value is {@code true}. - this.buildParseTrees = true; - // When {@link //setTrace}{@code (true)} is called, a reference to the - // {@link TraceListener} is stored here so it can be easily removed in a - // later call to {@link //setTrace}{@code (false)}. The listener itself is - // implemented as a parser listener so this field is not directly used by - // other parser methods. - this._tracer = null; - // The list of {@link ParseTreeListener} listeners registered to receive - // events during the parse. - this._parseListeners = null; - // The number of syntax errors reported during parsing. this value is - // incremented each time {@link //notifyErrorListeners} is called. - this._syntaxErrors = 0; - this.setInputStream(input); - return this; -} - -Parser.prototype = Object.create(Recognizer.prototype); -Parser.prototype.contructor = Parser; - -// this field maps from the serialized ATN string to the deserialized {@link -// ATN} with -// bypass alternatives. -// -// @see ATNDeserializationOptions//isGenerateRuleBypassTransitions() -// -Parser.bypassAltsAtnCache = {}; - -// reset the parser's state// -Parser.prototype.reset = function() { - if (this._input !== null) { - this._input.seek(0); - } - this._errHandler.reset(this); - this._ctx = null; - this._syntaxErrors = 0; - this.setTrace(false); - this._precedenceStack = []; - this._precedenceStack.push(0); - if (this._interp !== null) { - this._interp.reset(); - } -}; - -// Match current input symbol against {@code ttype}. If the symbol type -// matches, {@link ANTLRErrorStrategy//reportMatch} and {@link //consume} are -// called to complete the match process. -// -//

              If the symbol type does not match, -// {@link ANTLRErrorStrategy//recoverInline} is called on the current error -// strategy to attempt recovery. If {@link //getBuildParseTree} is -// {@code true} and the token index of the symbol returned by -// {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to -// the parse tree by calling {@link ParserRuleContext//addErrorNode}.

              -// -// @param ttype the token type to match -// @return the matched symbol -// @throws RecognitionException if the current input symbol did not match -// {@code ttype} and the error strategy could not recover from the -// mismatched symbol - -Parser.prototype.match = function(ttype) { - var t = this.getCurrentToken(); - if (t.type === ttype) { - this._errHandler.reportMatch(this); - this.consume(); - } else { - t = this._errHandler.recoverInline(this); - if (this.buildParseTrees && t.tokenIndex === -1) { - // we must have conjured up a new token during single token - // insertion - // if it's not the current symbol - this._ctx.addErrorNode(t); - } - } - return t; -}; -// Match current input symbol as a wildcard. If the symbol type matches -// (i.e. has a value greater than 0), {@link ANTLRErrorStrategy//reportMatch} -// and {@link //consume} are called to complete the match process. -// -//

              If the symbol type does not match, -// {@link ANTLRErrorStrategy//recoverInline} is called on the current error -// strategy to attempt recovery. If {@link //getBuildParseTree} is -// {@code true} and the token index of the symbol returned by -// {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to -// the parse tree by calling {@link ParserRuleContext//addErrorNode}.

              -// -// @return the matched symbol -// @throws RecognitionException if the current input symbol did not match -// a wildcard and the error strategy could not recover from the mismatched -// symbol - -Parser.prototype.matchWildcard = function() { - var t = this.getCurrentToken(); - if (t.type > 0) { - this._errHandler.reportMatch(this); - this.consume(); - } else { - t = this._errHandler.recoverInline(this); - if (this._buildParseTrees && t.tokenIndex === -1) { - // we must have conjured up a new token during single token - // insertion - // if it's not the current symbol - this._ctx.addErrorNode(t); - } - } - return t; -}; - -Parser.prototype.getParseListeners = function() { - return this._parseListeners || []; -}; - -// Registers {@code listener} to receive events during the parsing process. -// -//

              To support output-preserving grammar transformations (including but not -// limited to left-recursion removal, automated left-factoring, and -// optimized code generation), calls to listener methods during the parse -// may differ substantially from calls made by -// {@link ParseTreeWalker//DEFAULT} used after the parse is complete. In -// particular, rule entry and exit events may occur in a different order -// during the parse than after the parser. In addition, calls to certain -// rule entry methods may be omitted.

              -// -//

              With the following specific exceptions, calls to listener events are -// deterministic, i.e. for identical input the calls to listener -// methods will be the same.

              -// -//
                -//
              • Alterations to the grammar used to generate code may change the -// behavior of the listener calls.
              • -//
              • Alterations to the command line options passed to ANTLR 4 when -// generating the parser may change the behavior of the listener calls.
              • -//
              • Changing the version of the ANTLR Tool used to generate the parser -// may change the behavior of the listener calls.
              • -//
              -// -// @param listener the listener to add -// -// @throws NullPointerException if {@code} listener is {@code null} -// -Parser.prototype.addParseListener = function(listener) { - if (listener === null) { - throw "listener"; - } - if (this._parseListeners === null) { - this._parseListeners = []; - } - this._parseListeners.push(listener); -}; - -// -// Remove {@code listener} from the list of parse listeners. -// -//

              If {@code listener} is {@code null} or has not been added as a parse -// listener, this method does nothing.

              -// @param listener the listener to remove -// -Parser.prototype.removeParseListener = function(listener) { - if (this._parseListeners !== null) { - var idx = this._parseListeners.indexOf(listener); - if (idx >= 0) { - this._parseListeners.splice(idx, 1); - } - if (this._parseListeners.length === 0) { - this._parseListeners = null; - } - } -}; - -// Remove all parse listeners. -Parser.prototype.removeParseListeners = function() { - this._parseListeners = null; -}; - -// Notify any parse listeners of an enter rule event. -Parser.prototype.triggerEnterRuleEvent = function() { - if (this._parseListeners !== null) { - var ctx = this._ctx; - this._parseListeners.map(function(listener) { - listener.enterEveryRule(ctx); - ctx.enterRule(listener); - }); - } -}; - -// -// Notify any parse listeners of an exit rule event. -// -// @see //addParseListener -// -Parser.prototype.triggerExitRuleEvent = function() { - if (this._parseListeners !== null) { - // reverse order walk of listeners - var ctx = this._ctx; - this._parseListeners.slice(0).reverse().map(function(listener) { - ctx.exitRule(listener); - listener.exitEveryRule(ctx); - }); - } -}; - -Parser.prototype.getTokenFactory = function() { - return this._input.tokenSource._factory; -}; - -// Tell our token source and error strategy about a new way to create tokens.// -Parser.prototype.setTokenFactory = function(factory) { - this._input.tokenSource._factory = factory; -}; - -// The ATN with bypass alternatives is expensive to create so we create it -// lazily. -// -// @throws UnsupportedOperationException if the current parser does not -// implement the {@link //getSerializedATN()} method. -// -Parser.prototype.getATNWithBypassAlts = function() { - var serializedAtn = this.getSerializedATN(); - if (serializedAtn === null) { - throw "The current parser does not support an ATN with bypass alternatives."; - } - var result = this.bypassAltsAtnCache[serializedAtn]; - if (result === null) { - var deserializationOptions = new ATNDeserializationOptions(); - deserializationOptions.generateRuleBypassTransitions = true; - result = new ATNDeserializer(deserializationOptions) - .deserialize(serializedAtn); - this.bypassAltsAtnCache[serializedAtn] = result; - } - return result; -}; - -// The preferred method of getting a tree pattern. For example, here's a -// sample use: -// -//
              -// ParseTree t = parser.expr();
              -// ParseTreePattern p = parser.compileParseTreePattern("<ID>+0",
              -// MyParser.RULE_expr);
              -// ParseTreeMatch m = p.match(t);
              -// String id = m.get("ID");
              -// 
              - -var Lexer = __webpack_require__(15).Lexer; - -Parser.prototype.compileParseTreePattern = function(pattern, patternRuleIndex, lexer) { - lexer = lexer || null; - if (lexer === null) { - if (this.getTokenStream() !== null) { - var tokenSource = this.getTokenStream().tokenSource; - if (tokenSource instanceof Lexer) { - lexer = tokenSource; - } - } - } - if (lexer === null) { - throw "Parser can't discover a lexer to use"; - } - var m = new ParseTreePatternMatcher(lexer, this); - return m.compile(pattern, patternRuleIndex); -}; - -Parser.prototype.getInputStream = function() { - return this.getTokenStream(); -}; - -Parser.prototype.setInputStream = function(input) { - this.setTokenStream(input); -}; - -Parser.prototype.getTokenStream = function() { - return this._input; -}; - -// Set the token stream and reset the parser.// -Parser.prototype.setTokenStream = function(input) { - this._input = null; - this.reset(); - this._input = input; -}; - -// Match needs to return the current input symbol, which gets put -// into the label for the associated token ref; e.g., x=ID. -// -Parser.prototype.getCurrentToken = function() { - return this._input.LT(1); -}; - -Parser.prototype.notifyErrorListeners = function(msg, offendingToken, err) { - offendingToken = offendingToken || null; - err = err || null; - if (offendingToken === null) { - offendingToken = this.getCurrentToken(); - } - this._syntaxErrors += 1; - var line = offendingToken.line; - var column = offendingToken.column; - var listener = this.getErrorListenerDispatch(); - listener.syntaxError(this, offendingToken, line, column, msg, err); -}; - -// -// Consume and return the {@linkplain //getCurrentToken current symbol}. -// -//

              E.g., given the following input with {@code A} being the current -// lookahead symbol, this function moves the cursor to {@code B} and returns -// {@code A}.

              -// -//
              -// A B
              -// ^
              -// 
              -// -// If the parser is not in error recovery mode, the consumed symbol is added -// to the parse tree using {@link ParserRuleContext//addChild(Token)}, and -// {@link ParseTreeListener//visitTerminal} is called on any parse listeners. -// If the parser is in error recovery mode, the consumed symbol is -// added to the parse tree using -// {@link ParserRuleContext//addErrorNode(Token)}, and -// {@link ParseTreeListener//visitErrorNode} is called on any parse -// listeners. -// -Parser.prototype.consume = function() { - var o = this.getCurrentToken(); - if (o.type !== Token.EOF) { - this.getInputStream().consume(); - } - var hasListener = this._parseListeners !== null && this._parseListeners.length > 0; - if (this.buildParseTrees || hasListener) { - var node; - if (this._errHandler.inErrorRecoveryMode(this)) { - node = this._ctx.addErrorNode(o); - } else { - node = this._ctx.addTokenNode(o); - } - node.invokingState = this.state; - if (hasListener) { - this._parseListeners.map(function(listener) { - if (node instanceof ErrorNode || (node.isErrorNode !== undefined && node.isErrorNode())) { - listener.visitErrorNode(node); - } else if (node instanceof TerminalNode) { - listener.visitTerminal(node); - } - }); - } - } - return o; -}; - -Parser.prototype.addContextToParseTree = function() { - // add current context to parent if we have a parent - if (this._ctx.parentCtx !== null) { - this._ctx.parentCtx.addChild(this._ctx); - } -}; - -// Always called by generated parsers upon entry to a rule. Access field -// {@link //_ctx} get the current context. - -Parser.prototype.enterRule = function(localctx, state, ruleIndex) { - this.state = state; - this._ctx = localctx; - this._ctx.start = this._input.LT(1); - if (this.buildParseTrees) { - this.addContextToParseTree(); - } - if (this._parseListeners !== null) { - this.triggerEnterRuleEvent(); - } -}; - -Parser.prototype.exitRule = function() { - this._ctx.stop = this._input.LT(-1); - // trigger event on _ctx, before it reverts to parent - if (this._parseListeners !== null) { - this.triggerExitRuleEvent(); - } - this.state = this._ctx.invokingState; - this._ctx = this._ctx.parentCtx; -}; - -Parser.prototype.enterOuterAlt = function(localctx, altNum) { - localctx.setAltNumber(altNum); - // if we have new localctx, make sure we replace existing ctx - // that is previous child of parse tree - if (this.buildParseTrees && this._ctx !== localctx) { - if (this._ctx.parentCtx !== null) { - this._ctx.parentCtx.removeLastChild(); - this._ctx.parentCtx.addChild(localctx); - } - } - this._ctx = localctx; -}; - -// Get the precedence level for the top-most precedence rule. -// -// @return The precedence level for the top-most precedence rule, or -1 if -// the parser context is not nested within a precedence rule. - -Parser.prototype.getPrecedence = function() { - if (this._precedenceStack.length === 0) { - return -1; - } else { - return this._precedenceStack[this._precedenceStack.length-1]; - } -}; - -Parser.prototype.enterRecursionRule = function(localctx, state, ruleIndex, - precedence) { - this.state = state; - this._precedenceStack.push(precedence); - this._ctx = localctx; - this._ctx.start = this._input.LT(1); - if (this._parseListeners !== null) { - this.triggerEnterRuleEvent(); // simulates rule entry for - // left-recursive rules - } -}; - -// -// Like {@link //enterRule} but for recursive rules. - -Parser.prototype.pushNewRecursionContext = function(localctx, state, ruleIndex) { - var previous = this._ctx; - previous.parentCtx = localctx; - previous.invokingState = state; - previous.stop = this._input.LT(-1); - - this._ctx = localctx; - this._ctx.start = previous.start; - if (this.buildParseTrees) { - this._ctx.addChild(previous); - } - if (this._parseListeners !== null) { - this.triggerEnterRuleEvent(); // simulates rule entry for - // left-recursive rules - } -}; - -Parser.prototype.unrollRecursionContexts = function(parentCtx) { - this._precedenceStack.pop(); - this._ctx.stop = this._input.LT(-1); - var retCtx = this._ctx; // save current ctx (return value) - // unroll so _ctx is as it was before call to recursive method - if (this._parseListeners !== null) { - while (this._ctx !== parentCtx) { - this.triggerExitRuleEvent(); - this._ctx = this._ctx.parentCtx; - } - } else { - this._ctx = parentCtx; - } - // hook into tree - retCtx.parentCtx = parentCtx; - if (this.buildParseTrees && parentCtx !== null) { - // add return ctx into invoking rule's tree - parentCtx.addChild(retCtx); - } -}; - -Parser.prototype.getInvokingContext = function(ruleIndex) { - var ctx = this._ctx; - while (ctx !== null) { - if (ctx.ruleIndex === ruleIndex) { - return ctx; - } - ctx = ctx.parentCtx; - } - return null; -}; - -Parser.prototype.precpred = function(localctx, precedence) { - return precedence >= this._precedenceStack[this._precedenceStack.length-1]; -}; - -Parser.prototype.inContext = function(context) { - // TODO: useful in parser? - return false; -}; - -// -// Checks whether or not {@code symbol} can follow the current state in the -// ATN. The behavior of this method is equivalent to the following, but is -// implemented such that the complete context-sensitive follow set does not -// need to be explicitly constructed. -// -//
              -// return getExpectedTokens().contains(symbol);
              -// 
              -// -// @param symbol the symbol type to check -// @return {@code true} if {@code symbol} can follow the current state in -// the ATN, otherwise {@code false}. - -Parser.prototype.isExpectedToken = function(symbol) { - var atn = this._interp.atn; - var ctx = this._ctx; - var s = atn.states[this.state]; - var following = atn.nextTokens(s); - if (following.contains(symbol)) { - return true; - } - if (!following.contains(Token.EPSILON)) { - return false; - } - while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) { - var invokingState = atn.states[ctx.invokingState]; - var rt = invokingState.transitions[0]; - following = atn.nextTokens(rt.followState); - if (following.contains(symbol)) { - return true; - } - ctx = ctx.parentCtx; - } - if (following.contains(Token.EPSILON) && symbol === Token.EOF) { - return true; - } else { - return false; - } -}; - -// Computes the set of input symbols which could follow the current parser -// state and context, as given by {@link //getState} and {@link //getContext}, -// respectively. -// -// @see ATN//getExpectedTokens(int, RuleContext) -// -Parser.prototype.getExpectedTokens = function() { - return this._interp.atn.getExpectedTokens(this.state, this._ctx); -}; - -Parser.prototype.getExpectedTokensWithinCurrentRule = function() { - var atn = this._interp.atn; - var s = atn.states[this.state]; - return atn.nextTokens(s); -}; - -// Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found.// -Parser.prototype.getRuleIndex = function(ruleName) { - var ruleIndex = this.getRuleIndexMap()[ruleName]; - if (ruleIndex !== null) { - return ruleIndex; - } else { - return -1; - } -}; - -// Return List<String> of the rule names in your parser instance -// leading up to a call to the current rule. You could override if -// you want more details such as the file/line info of where -// in the ATN a rule is invoked. -// -// this is very useful for error messages. -// -Parser.prototype.getRuleInvocationStack = function(p) { - p = p || null; - if (p === null) { - p = this._ctx; - } - var stack = []; - while (p !== null) { - // compute what follows who invoked us - var ruleIndex = p.ruleIndex; - if (ruleIndex < 0) { - stack.push("n/a"); - } else { - stack.push(this.ruleNames[ruleIndex]); - } - p = p.parentCtx; - } - return stack; -}; - -// For debugging and other purposes.// -Parser.prototype.getDFAStrings = function() { - return this._interp.decisionToDFA.toString(); -}; -// For debugging and other purposes.// -Parser.prototype.dumpDFA = function() { - var seenOne = false; - for (var i = 0; i < this._interp.decisionToDFA.length; i++) { - var dfa = this._interp.decisionToDFA[i]; - if (dfa.states.length > 0) { - if (seenOne) { - console.log(); - } - this.printer.println("Decision " + dfa.decision + ":"); - this.printer.print(dfa.toString(this.literalNames, this.symbolicNames)); - seenOne = true; - } - } -}; - -/* -" printer = function() {\r\n" + -" this.println = function(s) { document.getElementById('output') += s + '\\n'; }\r\n" + -" this.print = function(s) { document.getElementById('output') += s; }\r\n" + -" };\r\n" + -*/ - -Parser.prototype.getSourceName = function() { - return this._input.sourceName; -}; - -// During a parse is sometimes useful to listen in on the rule entry and exit -// events as well as token matches. this is for quick and dirty debugging. -// -Parser.prototype.setTrace = function(trace) { - if (!trace) { - this.removeParseListener(this._tracer); - this._tracer = null; - } else { - if (this._tracer !== null) { - this.removeParseListener(this._tracer); - } - this._tracer = new TraceListener(this); - this.addParseListener(this._tracer); - } -}; - -exports.Parser = Parser; - -/***/ }), -/* 52 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 -// jshint ignore: start -var antlr4 = __webpack_require__(12); - - -var serializedATN = ["\u0003\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd", - "\u00020\u01ca\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004", - "\u0004\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t", - "\u0007\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004", - "\f\t\f\u0004\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010", - "\t\u0010\u0004\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013", - "\u0004\u0014\t\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017", - "\t\u0017\u0004\u0018\t\u0018\u0004\u0019\t\u0019\u0004\u001a\t\u001a", - "\u0004\u001b\t\u001b\u0004\u001c\t\u001c\u0004\u001d\t\u001d\u0004\u001e", - "\t\u001e\u0004\u001f\t\u001f\u0004 \t \u0004!\t!\u0004\"\t\"\u0004#", - "\t#\u0004$\t$\u0004%\t%\u0004&\t&\u0004\'\t\'\u0004(\t(\u0004)\t)\u0004", - "*\t*\u0004+\t+\u0004,\t,\u0004-\t-\u0004.\t.\u0004/\t/\u0003\u0002\u0003", - "\u0002\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003", - "\u0003\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004\u0003\u0004\u0003", - "\u0004\u0003\u0004\u0003\u0004\u0003\u0005\u0003\u0005\u0003\u0006\u0003", - "\u0006\u0003\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003\t\u0003", - "\t\u0003\t\u0003\n\u0003\n\u0003\u000b\u0003\u000b\u0003\f\u0003\f\u0003", - "\r\u0003\r\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000f\u0003\u000f", - "\u0007\u000f\u0089\n\u000f\f\u000f\u000e\u000f\u008c\u000b\u000f\u0003", - "\u000f\u0003\u000f\u0003\u0010\u0003\u0010\u0003\u0010\u0005\u0010\u0093", - "\n\u0010\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011", - "\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0005\u0011\u009e\n", - "\u0011\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0005\u0012\u00a4", - "\n\u0012\u0003\u0013\u0003\u0013\u0005\u0013\u00a8\n\u0013\u0003\u0014", - "\u0003\u0014\u0003\u0014\u0007\u0014\u00ad\n\u0014\f\u0014\u000e\u0014", - "\u00b0\u000b\u0014\u0003\u0014\u0003\u0014\u0003\u0015\u0005\u0015\u00b5", - "\n\u0015\u0003\u0015\u0003\u0015\u0003\u0016\u0003\u0016\u0003\u0016", - "\u0003\u0017\u0003\u0017\u0003\u0017\u0003\u0017\u0003\u0017\u0005\u0017", - "\u00c1\n\u0017\u0003\u0017\u0003\u0017\u0007\u0017\u00c5\n\u0017\f\u0017", - "\u000e\u0017\u00c8\u000b\u0017\u0003\u0017\u0005\u0017\u00cb\n\u0017", - "\u0003\u0018\u0003\u0018\u0006\u0018\u00cf\n\u0018\r\u0018\u000e\u0018", - "\u00d0\u0003\u0018\u0003\u0018\u0006\u0018\u00d5\n\u0018\r\u0018\u000e", - "\u0018\u00d6\u0007\u0018\u00d9\n\u0018\f\u0018\u000e\u0018\u00dc\u000b", - "\u0018\u0003\u0019\u0005\u0019\u00df\n\u0019\u0003\u0019\u0006\u0019", - "\u00e2\n\u0019\r\u0019\u000e\u0019\u00e3\u0003\u001a\u0005\u001a\u00e7", - "\n\u001a\u0003\u001a\u0007\u001a\u00ea\n\u001a\f\u001a\u000e\u001a\u00ed", - "\u000b\u001a\u0003\u001a\u0003\u001a\u0006\u001a\u00f1\n\u001a\r\u001a", - "\u000e\u001a\u00f2\u0003\u001b\u0005\u001b\u00f6\n\u001b\u0003\u001b", - "\u0006\u001b\u00f9\n\u001b\r\u001b\u000e\u001b\u00fa\u0003\u001b\u0003", - "\u001b\u0007\u001b\u00ff\n\u001b\f\u001b\u000e\u001b\u0102\u000b\u001b", - "\u0003\u001b\u0003\u001b\u0003\u001b\u0006\u001b\u0107\n\u001b\r\u001b", - "\u000e\u001b\u0108\u0003\u001b\u0003\u001b\u0006\u001b\u010d\n\u001b", - "\r\u001b\u000e\u001b\u010e\u0003\u001b\u0005\u001b\u0112\n\u001b\u0003", - "\u001c\u0003\u001c\u0005\u001c\u0116\n\u001c\u0003\u001c\u0006\u001c", - "\u0119\n\u001c\r\u001c\u000e\u001c\u011a\u0003\u001d\u0003\u001d\u0003", - "\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0005\u001d\u0124", - "\n\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0005\u001d\u0129\n\u001d", - "\u0007\u001d\u012b\n\u001d\f\u001d\u000e\u001d\u012e\u000b\u001d\u0003", - "\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001e\u0003\u001e\u0003", - "\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0005\u001e\u013b", - "\n\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0005\u001e\u0140\n\u001e", - "\u0007\u001e\u0142\n\u001e\f\u001e\u000e\u001e\u0145\u000b\u001e\u0003", - "\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0003\u001f\u0003\u001f\u0003", - "\u001f\u0003\u001f\u0007\u001f\u014f\n\u001f\f\u001f\u000e\u001f\u0152", - "\u000b\u001f\u0003\u001f\u0003\u001f\u0003 \u0003 \u0003 \u0003 \u0007", - " \u015a\n \f \u000e \u015d\u000b \u0003 \u0003 \u0003!\u0003!\u0003", - "!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003", - "!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0005!\u0175\n!\u0003", - "\"\u0003\"\u0003\"\u0003#\u0003#\u0003#\u0003#\u0003$\u0003$\u0007$", - "\u0180\n$\f$\u000e$\u0183\u000b$\u0003$\u0003$\u0003%\u0005%\u0188\n", - "%\u0003&\u0003&\u0005&\u018c\n&\u0003\'\u0003\'\u0005\'\u0190\n\'\u0003", - "(\u0003(\u0003(\u0003(\u0003(\u0003)\u0003)\u0003)\u0003)\u0003)\u0003", - ")\u0003)\u0003*\u0003*\u0003*\u0007*\u01a1\n*\f*\u000e*\u01a4\u000b", - "*\u0003*\u0005*\u01a7\n*\u0003+\u0003+\u0003+\u0005+\u01ac\n+\u0003", - "+\u0003+\u0003+\u0007+\u01b1\n+\f+\u000e+\u01b4\u000b+\u0003+\u0003", - "+\u0003+\u0005+\u01b9\n+\u0005+\u01bb\n+\u0003,\u0003,\u0005,\u01bf", - "\n,\u0003-\u0003-\u0003-\u0003-\u0003.\u0005.\u01c6\n.\u0003/\u0003", - "/\u0003/\u0002\u00020\u0003\u0003\u0005\u0004\u0007\u0005\t\u0006\u000b", - "\u0007\r\b\u000f\t\u0011\n\u0013\u000b\u0015\f\u0017\r\u0019\u000e\u001b", - "\u000f\u001d\u0010\u001f\u0011!\u0012#\u0013%\u0014\'\u0015)\u0016+", - "\u0017-\u0018/\u00191\u001a3\u001b5\u001c7\u001d9\u001e;\u001f= ?!A", - "\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]0\u0003\u0002\u001c\u0004\u0002\f\f\u000f", - "\u000f\n\u0002\u0002\"$$>>@@^^``bb}\u007f\u0003\u00022;\u0004\u0002", - "C\\c|\u0005\u00022;C\\c|\u0004\u0002--//\u0004\u0002GGgg\u0004\u0002", - "))^^\u0004\u0002$$^^\u0006\u0002\f\f\u000f\u000f$$^^\u0006\u0002\f\f", - "\u000f\u000f))^^\n\u0002$$))^^ddhhppttvv\u0005\u0002\u000b\f\u000f\u000f", - "\"\"\u000f\u0002C\\c|\u00c2\u00d8\u00da\u00f8\u00fa\u0301\u0372\u037f", - "\u0381\u2001\u200e\u200f\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1", - "\ufdf2\uffff\u0007\u0002//2;\u00b9\u00b9\u0302\u0371\u2041\u2042\u0004", - "\u0002DDdd\u0004\u0002CCcc\u0004\u0002UUuu\u0004\u0002RRrr\u0004\u0002", - "TTtt\u0004\u0002HHhh\u0004\u0002KKkk\u0004\u0002ZZzz\u0004\u000200<", - "<\u0005\u00022;CHch\t\u0002##%1==??ABaa\u0080\u0080\u0209\u0002\u0003", - "\u0003\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002\u0002\u0007", - "\u0003\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002\u0002\u000b", - "\u0003\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002\u0002\u000f", - "\u0003\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002\u0002\u0013", - "\u0003\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002\u0002\u0017", - "\u0003\u0002\u0002\u0002\u0002\u0019\u0003\u0002\u0002\u0002\u0002\u001b", - "\u0003\u0002\u0002\u0002\u0002\u001d\u0003\u0002\u0002\u0002\u0002\u001f", - "\u0003\u0002\u0002\u0002\u0002!\u0003\u0002\u0002\u0002\u0002#\u0003", - "\u0002\u0002\u0002\u0002%\u0003\u0002\u0002\u0002\u0002\'\u0003\u0002", - "\u0002\u0002\u0002)\u0003\u0002\u0002\u0002\u0002+\u0003\u0002\u0002", - "\u0002\u0002-\u0003\u0002\u0002\u0002\u0002/\u0003\u0002\u0002\u0002", - "\u00021\u0003\u0002\u0002\u0002\u00023\u0003\u0002\u0002\u0002\u0002", - "5\u0003\u0002\u0002\u0002\u00027\u0003\u0002\u0002\u0002\u00029\u0003", - "\u0002\u0002\u0002\u0002;\u0003\u0002\u0002\u0002\u0002=\u0003\u0002", - "\u0002\u0002\u0002?\u0003\u0002\u0002\u0002\u0002A\u0003\u0002\u0002", - "\u0002\u0002C\u0003\u0002\u0002\u0002\u0002E\u0003\u0002\u0002\u0002", - "\u0002G\u0003\u0002\u0002\u0002\u0002I\u0003\u0002\u0002\u0002\u0002", - "K\u0003\u0002\u0002\u0002\u0002M\u0003\u0002\u0002\u0002\u0002O\u0003", - "\u0002\u0002\u0002\u0002Q\u0003\u0002\u0002\u0002\u0002S\u0003\u0002", - "\u0002\u0002\u0002U\u0003\u0002\u0002\u0002\u0002W\u0003\u0002\u0002", - "\u0002\u0002Y\u0003\u0002\u0002\u0002\u0002[\u0003\u0002\u0002\u0002", - "\u0002]\u0003\u0002\u0002\u0002\u0003_\u0003\u0002\u0002\u0002\u0005", - "a\u0003\u0002\u0002\u0002\u0007i\u0003\u0002\u0002\u0002\to\u0003\u0002", - "\u0002\u0002\u000bq\u0003\u0002\u0002\u0002\rs\u0003\u0002\u0002\u0002", - "\u000fu\u0003\u0002\u0002\u0002\u0011x\u0003\u0002\u0002\u0002\u0013", - "{\u0003\u0002\u0002\u0002\u0015}\u0003\u0002\u0002\u0002\u0017\u007f", - "\u0003\u0002\u0002\u0002\u0019\u0081\u0003\u0002\u0002\u0002\u001b\u0083", - "\u0003\u0002\u0002\u0002\u001d\u0086\u0003\u0002\u0002\u0002\u001f\u0092", - "\u0003\u0002\u0002\u0002!\u009d\u0003\u0002\u0002\u0002#\u00a3\u0003", - "\u0002\u0002\u0002%\u00a7\u0003\u0002\u0002\u0002\'\u00a9\u0003\u0002", - "\u0002\u0002)\u00b4\u0003\u0002\u0002\u0002+\u00b8\u0003\u0002\u0002", - "\u0002-\u00bb\u0003\u0002\u0002\u0002/\u00cc\u0003\u0002\u0002\u0002", - "1\u00de\u0003\u0002\u0002\u00023\u00e6\u0003\u0002\u0002\u00025\u00f5", - "\u0003\u0002\u0002\u00027\u0113\u0003\u0002\u0002\u00029\u011c\u0003", - "\u0002\u0002\u0002;\u0133\u0003\u0002\u0002\u0002=\u014a\u0003\u0002", - "\u0002\u0002?\u0155\u0003\u0002\u0002\u0002A\u0174\u0003\u0002\u0002", - "\u0002C\u0176\u0003\u0002\u0002\u0002E\u0179\u0003\u0002\u0002\u0002", - "G\u017d\u0003\u0002\u0002\u0002I\u0187\u0003\u0002\u0002\u0002K\u018b", - "\u0003\u0002\u0002\u0002M\u018f\u0003\u0002\u0002\u0002O\u0191\u0003", - "\u0002\u0002\u0002Q\u0196\u0003\u0002\u0002\u0002S\u019d\u0003\u0002", - "\u0002\u0002U\u01ab\u0003\u0002\u0002\u0002W\u01be\u0003\u0002\u0002", - "\u0002Y\u01c0\u0003\u0002\u0002\u0002[\u01c5\u0003\u0002\u0002\u0002", - "]\u01c7\u0003\u0002\u0002\u0002_`\u00070\u0002\u0002`\u0004\u0003\u0002", - "\u0002\u0002ab\u0007B\u0002\u0002bc\u0007r\u0002\u0002cd\u0007t\u0002", - "\u0002de\u0007g\u0002\u0002ef\u0007h\u0002\u0002fg\u0007k\u0002\u0002", - "gh\u0007z\u0002\u0002h\u0006\u0003\u0002\u0002\u0002ij\u0007B\u0002", - "\u0002jk\u0007d\u0002\u0002kl\u0007c\u0002\u0002lm\u0007u\u0002\u0002", - "mn\u0007g\u0002\u0002n\b\u0003\u0002\u0002\u0002op\u0007=\u0002\u0002", - "p\n\u0003\u0002\u0002\u0002qr\u0007.\u0002\u0002r\f\u0003\u0002\u0002", - "\u0002st\u0007c\u0002\u0002t\u000e\u0003\u0002\u0002\u0002uv\u0007>", - "\u0002\u0002vw\u0007>\u0002\u0002w\u0010\u0003\u0002\u0002\u0002xy\u0007", - "@\u0002\u0002yz\u0007@\u0002\u0002z\u0012\u0003\u0002\u0002\u0002{|", - "\u0007]\u0002\u0002|\u0014\u0003\u0002\u0002\u0002}~\u0007_\u0002\u0002", - "~\u0016\u0003\u0002\u0002\u0002\u007f\u0080\u0007*\u0002\u0002\u0080", - "\u0018\u0003\u0002\u0002\u0002\u0081\u0082\u0007+\u0002\u0002\u0082", - "\u001a\u0003\u0002\u0002\u0002\u0083\u0084\u0007`\u0002\u0002\u0084", - "\u0085\u0007`\u0002\u0002\u0085\u001c\u0003\u0002\u0002\u0002\u0086", - "\u008a\u0007%\u0002\u0002\u0087\u0089\n\u0002\u0002\u0002\u0088\u0087", - "\u0003\u0002\u0002\u0002\u0089\u008c\u0003\u0002\u0002\u0002\u008a\u0088", - "\u0003\u0002\u0002\u0002\u008a\u008b\u0003\u0002\u0002\u0002\u008b\u008d", - "\u0003\u0002\u0002\u0002\u008c\u008a\u0003\u0002\u0002\u0002\u008d\u008e", - "\b\u000f\u0002\u0002\u008e\u001e\u0003\u0002\u0002\u0002\u008f\u0093", - "\u00051\u0019\u0002\u0090\u0093\u00053\u001a\u0002\u0091\u0093\u0005", - "5\u001b\u0002\u0092\u008f\u0003\u0002\u0002\u0002\u0092\u0090\u0003", - "\u0002\u0002\u0002\u0092\u0091\u0003\u0002\u0002\u0002\u0093 \u0003", - "\u0002\u0002\u0002\u0094\u0095\u0007v\u0002\u0002\u0095\u0096\u0007", - "t\u0002\u0002\u0096\u0097\u0007w\u0002\u0002\u0097\u009e\u0007g\u0002", - "\u0002\u0098\u0099\u0007h\u0002\u0002\u0099\u009a\u0007c\u0002\u0002", - "\u009a\u009b\u0007n\u0002\u0002\u009b\u009c\u0007u\u0002\u0002\u009c", - "\u009e\u0007g\u0002\u0002\u009d\u0094\u0003\u0002\u0002\u0002\u009d", - "\u0098\u0003\u0002\u0002\u0002\u009e\"\u0003\u0002\u0002\u0002\u009f", - "\u00a4\u0005=\u001f\u0002\u00a0\u00a4\u0005? \u0002\u00a1\u00a4\u0005", - "9\u001d\u0002\u00a2\u00a4\u0005;\u001e\u0002\u00a3\u009f\u0003\u0002", - "\u0002\u0002\u00a3\u00a0\u0003\u0002\u0002\u0002\u00a3\u00a1\u0003\u0002", - "\u0002\u0002\u00a3\u00a2\u0003\u0002\u0002\u0002\u00a4$\u0003\u0002", - "\u0002\u0002\u00a5\u00a8\u0005-\u0017\u0002\u00a6\u00a8\u0005G$\u0002", - "\u00a7\u00a5\u0003\u0002\u0002\u0002\u00a7\u00a6\u0003\u0002\u0002\u0002", - "\u00a8&\u0003\u0002\u0002\u0002\u00a9\u00ae\u0007>\u0002\u0002\u00aa", - "\u00ad\n\u0003\u0002\u0002\u00ab\u00ad\u0005A!\u0002\u00ac\u00aa\u0003", - "\u0002\u0002\u0002\u00ac\u00ab\u0003\u0002\u0002\u0002\u00ad\u00b0\u0003", - "\u0002\u0002\u0002\u00ae\u00ac\u0003\u0002\u0002\u0002\u00ae\u00af\u0003", - "\u0002\u0002\u0002\u00af\u00b1\u0003\u0002\u0002\u0002\u00b0\u00ae\u0003", - "\u0002\u0002\u0002\u00b1\u00b2\u0007@\u0002\u0002\u00b2(\u0003\u0002", - "\u0002\u0002\u00b3\u00b5\u0005S*\u0002\u00b4\u00b3\u0003\u0002\u0002", - "\u0002\u00b4\u00b5\u0003\u0002\u0002\u0002\u00b5\u00b6\u0003\u0002\u0002", - "\u0002\u00b6\u00b7\u0007<\u0002\u0002\u00b7*\u0003\u0002\u0002\u0002", - "\u00b8\u00b9\u0005)\u0015\u0002\u00b9\u00ba\u0005U+\u0002\u00ba,\u0003", - "\u0002\u0002\u0002\u00bb\u00bc\u0007a\u0002\u0002\u00bc\u00bd\u0007", - "<\u0002\u0002\u00bd\u00c0\u0003\u0002\u0002\u0002\u00be\u00c1\u0005", - "K&\u0002\u00bf\u00c1\t\u0004\u0002\u0002\u00c0\u00be\u0003\u0002\u0002", - "\u0002\u00c0\u00bf\u0003\u0002\u0002\u0002\u00c1\u00ca\u0003\u0002\u0002", - "\u0002\u00c2\u00c5\u0005M\'\u0002\u00c3\u00c5\u00070\u0002\u0002\u00c4", - "\u00c2\u0003\u0002\u0002\u0002\u00c4\u00c3\u0003\u0002\u0002\u0002\u00c5", - "\u00c8\u0003\u0002\u0002\u0002\u00c6\u00c4\u0003\u0002\u0002\u0002\u00c6", - "\u00c7\u0003\u0002\u0002\u0002\u00c7\u00c9\u0003\u0002\u0002\u0002\u00c8", - "\u00c6\u0003\u0002\u0002\u0002\u00c9\u00cb\u0005M\'\u0002\u00ca\u00c6", - "\u0003\u0002\u0002\u0002\u00ca\u00cb\u0003\u0002\u0002\u0002\u00cb.", - "\u0003\u0002\u0002\u0002\u00cc\u00ce\u0007B\u0002\u0002\u00cd\u00cf", - "\t\u0005\u0002\u0002\u00ce\u00cd\u0003\u0002\u0002\u0002\u00cf\u00d0", - "\u0003\u0002\u0002\u0002\u00d0\u00ce\u0003\u0002\u0002\u0002\u00d0\u00d1", - "\u0003\u0002\u0002\u0002\u00d1\u00da\u0003\u0002\u0002\u0002\u00d2\u00d4", - "\u0007/\u0002\u0002\u00d3\u00d5\t\u0006\u0002\u0002\u00d4\u00d3\u0003", - "\u0002\u0002\u0002\u00d5\u00d6\u0003\u0002\u0002\u0002\u00d6\u00d4\u0003", - "\u0002\u0002\u0002\u00d6\u00d7\u0003\u0002\u0002\u0002\u00d7\u00d9\u0003", - "\u0002\u0002\u0002\u00d8\u00d2\u0003\u0002\u0002\u0002\u00d9\u00dc\u0003", - "\u0002\u0002\u0002\u00da\u00d8\u0003\u0002\u0002\u0002\u00da\u00db\u0003", - "\u0002\u0002\u0002\u00db0\u0003\u0002\u0002\u0002\u00dc\u00da\u0003", - "\u0002\u0002\u0002\u00dd\u00df\t\u0007\u0002\u0002\u00de\u00dd\u0003", - "\u0002\u0002\u0002\u00de\u00df\u0003\u0002\u0002\u0002\u00df\u00e1\u0003", - "\u0002\u0002\u0002\u00e0\u00e2\t\u0004\u0002\u0002\u00e1\u00e0\u0003", - "\u0002\u0002\u0002\u00e2\u00e3\u0003\u0002\u0002\u0002\u00e3\u00e1\u0003", - "\u0002\u0002\u0002\u00e3\u00e4\u0003\u0002\u0002\u0002\u00e42\u0003", - "\u0002\u0002\u0002\u00e5\u00e7\t\u0007\u0002\u0002\u00e6\u00e5\u0003", - "\u0002\u0002\u0002\u00e6\u00e7\u0003\u0002\u0002\u0002\u00e7\u00eb\u0003", - "\u0002\u0002\u0002\u00e8\u00ea\t\u0004\u0002\u0002\u00e9\u00e8\u0003", - "\u0002\u0002\u0002\u00ea\u00ed\u0003\u0002\u0002\u0002\u00eb\u00e9\u0003", - "\u0002\u0002\u0002\u00eb\u00ec\u0003\u0002\u0002\u0002\u00ec\u00ee\u0003", - "\u0002\u0002\u0002\u00ed\u00eb\u0003\u0002\u0002\u0002\u00ee\u00f0\u0007", - "0\u0002\u0002\u00ef\u00f1\t\u0004\u0002\u0002\u00f0\u00ef\u0003\u0002", - "\u0002\u0002\u00f1\u00f2\u0003\u0002\u0002\u0002\u00f2\u00f0\u0003\u0002", - "\u0002\u0002\u00f2\u00f3\u0003\u0002\u0002\u0002\u00f34\u0003\u0002", - "\u0002\u0002\u00f4\u00f6\t\u0007\u0002\u0002\u00f5\u00f4\u0003\u0002", - "\u0002\u0002\u00f5\u00f6\u0003\u0002\u0002\u0002\u00f6\u0111\u0003\u0002", - "\u0002\u0002\u00f7\u00f9\t\u0004\u0002\u0002\u00f8\u00f7\u0003\u0002", - "\u0002\u0002\u00f9\u00fa\u0003\u0002\u0002\u0002\u00fa\u00f8\u0003\u0002", - "\u0002\u0002\u00fa\u00fb\u0003\u0002\u0002\u0002\u00fb\u00fc\u0003\u0002", - "\u0002\u0002\u00fc\u0100\u00070\u0002\u0002\u00fd\u00ff\t\u0004\u0002", - "\u0002\u00fe\u00fd\u0003\u0002\u0002\u0002\u00ff\u0102\u0003\u0002\u0002", - "\u0002\u0100\u00fe\u0003\u0002\u0002\u0002\u0100\u0101\u0003\u0002\u0002", - "\u0002\u0101\u0103\u0003\u0002\u0002\u0002\u0102\u0100\u0003\u0002\u0002", - "\u0002\u0103\u0112\u00057\u001c\u0002\u0104\u0106\u00070\u0002\u0002", - "\u0105\u0107\t\u0004\u0002\u0002\u0106\u0105\u0003\u0002\u0002\u0002", - "\u0107\u0108\u0003\u0002\u0002\u0002\u0108\u0106\u0003\u0002\u0002\u0002", - "\u0108\u0109\u0003\u0002\u0002\u0002\u0109\u010a\u0003\u0002\u0002\u0002", - "\u010a\u0112\u00057\u001c\u0002\u010b\u010d\t\u0004\u0002\u0002\u010c", - "\u010b\u0003\u0002\u0002\u0002\u010d\u010e\u0003\u0002\u0002\u0002\u010e", - "\u010c\u0003\u0002\u0002\u0002\u010e\u010f\u0003\u0002\u0002\u0002\u010f", - "\u0110\u0003\u0002\u0002\u0002\u0110\u0112\u00057\u001c\u0002\u0111", - "\u00f8\u0003\u0002\u0002\u0002\u0111\u0104\u0003\u0002\u0002\u0002\u0111", - "\u010c\u0003\u0002\u0002\u0002\u01126\u0003\u0002\u0002\u0002\u0113", - "\u0115\t\b\u0002\u0002\u0114\u0116\t\u0007\u0002\u0002\u0115\u0114\u0003", - "\u0002\u0002\u0002\u0115\u0116\u0003\u0002\u0002\u0002\u0116\u0118\u0003", - "\u0002\u0002\u0002\u0117\u0119\t\u0004\u0002\u0002\u0118\u0117\u0003", - "\u0002\u0002\u0002\u0119\u011a\u0003\u0002\u0002\u0002\u011a\u0118\u0003", - "\u0002\u0002\u0002\u011a\u011b\u0003\u0002\u0002\u0002\u011b8\u0003", - "\u0002\u0002\u0002\u011c\u011d\u0007)\u0002\u0002\u011d\u011e\u0007", - ")\u0002\u0002\u011e\u011f\u0007)\u0002\u0002\u011f\u012c\u0003\u0002", - "\u0002\u0002\u0120\u0124\u0007)\u0002\u0002\u0121\u0122\u0007)\u0002", - "\u0002\u0122\u0124\u0007)\u0002\u0002\u0123\u0120\u0003\u0002\u0002", - "\u0002\u0123\u0121\u0003\u0002\u0002\u0002\u0123\u0124\u0003\u0002\u0002", - "\u0002\u0124\u0128\u0003\u0002\u0002\u0002\u0125\u0129\n\t\u0002\u0002", - "\u0126\u0129\u0005C\"\u0002\u0127\u0129\u0005A!\u0002\u0128\u0125\u0003", - "\u0002\u0002\u0002\u0128\u0126\u0003\u0002\u0002\u0002\u0128\u0127\u0003", - "\u0002\u0002\u0002\u0129\u012b\u0003\u0002\u0002\u0002\u012a\u0123\u0003", - "\u0002\u0002\u0002\u012b\u012e\u0003\u0002\u0002\u0002\u012c\u012a\u0003", - "\u0002\u0002\u0002\u012c\u012d\u0003\u0002\u0002\u0002\u012d\u012f\u0003", - "\u0002\u0002\u0002\u012e\u012c\u0003\u0002\u0002\u0002\u012f\u0130\u0007", - ")\u0002\u0002\u0130\u0131\u0007)\u0002\u0002\u0131\u0132\u0007)\u0002", - "\u0002\u0132:\u0003\u0002\u0002\u0002\u0133\u0134\u0007$\u0002\u0002", - "\u0134\u0135\u0007$\u0002\u0002\u0135\u0136\u0007$\u0002\u0002\u0136", - "\u0143\u0003\u0002\u0002\u0002\u0137\u013b\u0007$\u0002\u0002\u0138", - "\u0139\u0007$\u0002\u0002\u0139\u013b\u0007$\u0002\u0002\u013a\u0137", - "\u0003\u0002\u0002\u0002\u013a\u0138\u0003\u0002\u0002\u0002\u013a\u013b", - "\u0003\u0002\u0002\u0002\u013b\u013f\u0003\u0002\u0002\u0002\u013c\u0140", - "\n\n\u0002\u0002\u013d\u0140\u0005C\"\u0002\u013e\u0140\u0005A!\u0002", - "\u013f\u013c\u0003\u0002\u0002\u0002\u013f\u013d\u0003\u0002\u0002\u0002", - "\u013f\u013e\u0003\u0002\u0002\u0002\u0140\u0142\u0003\u0002\u0002\u0002", - "\u0141\u013a\u0003\u0002\u0002\u0002\u0142\u0145\u0003\u0002\u0002\u0002", - "\u0143\u0141\u0003\u0002\u0002\u0002\u0143\u0144\u0003\u0002\u0002\u0002", - "\u0144\u0146\u0003\u0002\u0002\u0002\u0145\u0143\u0003\u0002\u0002\u0002", - "\u0146\u0147\u0007$\u0002\u0002\u0147\u0148\u0007$\u0002\u0002\u0148", - "\u0149\u0007$\u0002\u0002\u0149<\u0003\u0002\u0002\u0002\u014a\u0150", - "\u0007$\u0002\u0002\u014b\u014f\n\u000b\u0002\u0002\u014c\u014f\u0005", - "C\"\u0002\u014d\u014f\u0005A!\u0002\u014e\u014b\u0003\u0002\u0002\u0002", - "\u014e\u014c\u0003\u0002\u0002\u0002\u014e\u014d\u0003\u0002\u0002\u0002", - "\u014f\u0152\u0003\u0002\u0002\u0002\u0150\u014e\u0003\u0002\u0002\u0002", - "\u0150\u0151\u0003\u0002\u0002\u0002\u0151\u0153\u0003\u0002\u0002\u0002", - "\u0152\u0150\u0003\u0002\u0002\u0002\u0153\u0154\u0007$\u0002\u0002", - "\u0154>\u0003\u0002\u0002\u0002\u0155\u015b\u0007)\u0002\u0002\u0156", - "\u015a\n\f\u0002\u0002\u0157\u015a\u0005C\"\u0002\u0158\u015a\u0005", - "A!\u0002\u0159\u0156\u0003\u0002\u0002\u0002\u0159\u0157\u0003\u0002", - "\u0002\u0002\u0159\u0158\u0003\u0002\u0002\u0002\u015a\u015d\u0003\u0002", - "\u0002\u0002\u015b\u0159\u0003\u0002\u0002\u0002\u015b\u015c\u0003\u0002", - "\u0002\u0002\u015c\u015e\u0003\u0002\u0002\u0002\u015d\u015b\u0003\u0002", - "\u0002\u0002\u015e\u015f\u0007)\u0002\u0002\u015f@\u0003\u0002\u0002", - "\u0002\u0160\u0161\u0007^\u0002\u0002\u0161\u0162\u0007w\u0002\u0002", - "\u0162\u0163\u0003\u0002\u0002\u0002\u0163\u0164\u0005[.\u0002\u0164", - "\u0165\u0005[.\u0002\u0165\u0166\u0005[.\u0002\u0166\u0167\u0005[.\u0002", - "\u0167\u0175\u0003\u0002\u0002\u0002\u0168\u0169\u0007^\u0002\u0002", - "\u0169\u016a\u0007W\u0002\u0002\u016a\u016b\u0003\u0002\u0002\u0002", - "\u016b\u016c\u0005[.\u0002\u016c\u016d\u0005[.\u0002\u016d\u016e\u0005", - "[.\u0002\u016e\u016f\u0005[.\u0002\u016f\u0170\u0005[.\u0002\u0170\u0171", - "\u0005[.\u0002\u0171\u0172\u0005[.\u0002\u0172\u0173\u0005[.\u0002\u0173", - "\u0175\u0003\u0002\u0002\u0002\u0174\u0160\u0003\u0002\u0002\u0002\u0174", - "\u0168\u0003\u0002\u0002\u0002\u0175B\u0003\u0002\u0002\u0002\u0176", - "\u0177\u0007^\u0002\u0002\u0177\u0178\t\r\u0002\u0002\u0178D\u0003\u0002", - "\u0002\u0002\u0179\u017a\t\u000e\u0002\u0002\u017a\u017b\u0003\u0002", - "\u0002\u0002\u017b\u017c\b#\u0002\u0002\u017cF\u0003\u0002\u0002\u0002", - "\u017d\u0181\u0007]\u0002\u0002\u017e\u0180\u0005E#\u0002\u017f\u017e", - "\u0003\u0002\u0002\u0002\u0180\u0183\u0003\u0002\u0002\u0002\u0181\u017f", - "\u0003\u0002\u0002\u0002\u0181\u0182\u0003\u0002\u0002\u0002\u0182\u0184", - "\u0003\u0002\u0002\u0002\u0183\u0181\u0003\u0002\u0002\u0002\u0184\u0185", - "\u0007_\u0002\u0002\u0185H\u0003\u0002\u0002\u0002\u0186\u0188\t\u000f", - "\u0002\u0002\u0187\u0186\u0003\u0002\u0002\u0002\u0188J\u0003\u0002", - "\u0002\u0002\u0189\u018c\u0005I%\u0002\u018a\u018c\u0007a\u0002\u0002", - "\u018b\u0189\u0003\u0002\u0002\u0002\u018b\u018a\u0003\u0002\u0002\u0002", - "\u018cL\u0003\u0002\u0002\u0002\u018d\u0190\u0005K&\u0002\u018e\u0190", - "\t\u0010\u0002\u0002\u018f\u018d\u0003\u0002\u0002\u0002\u018f\u018e", - "\u0003\u0002\u0002\u0002\u0190N\u0003\u0002\u0002\u0002\u0191\u0192", - "\t\u0011\u0002\u0002\u0192\u0193\t\u0012\u0002\u0002\u0193\u0194\t\u0013", - "\u0002\u0002\u0194\u0195\t\b\u0002\u0002\u0195P\u0003\u0002\u0002\u0002", - "\u0196\u0197\t\u0014\u0002\u0002\u0197\u0198\t\u0015\u0002\u0002\u0198", - "\u0199\t\b\u0002\u0002\u0199\u019a\t\u0016\u0002\u0002\u019a\u019b\t", - "\u0017\u0002\u0002\u019b\u019c\t\u0018\u0002\u0002\u019cR\u0003\u0002", - "\u0002\u0002\u019d\u01a6\u0005I%\u0002\u019e\u01a1\u0005M\'\u0002\u019f", - "\u01a1\u00070\u0002\u0002\u01a0\u019e\u0003\u0002\u0002\u0002\u01a0", - "\u019f\u0003\u0002\u0002\u0002\u01a1\u01a4\u0003\u0002\u0002\u0002\u01a2", - "\u01a0\u0003\u0002\u0002\u0002\u01a2\u01a3\u0003\u0002\u0002\u0002\u01a3", - "\u01a5\u0003\u0002\u0002\u0002\u01a4\u01a2\u0003\u0002\u0002\u0002\u01a5", - "\u01a7\u0005M\'\u0002\u01a6\u01a2\u0003\u0002\u0002\u0002\u01a6\u01a7", - "\u0003\u0002\u0002\u0002\u01a7T\u0003\u0002\u0002\u0002\u01a8\u01ac", - "\u0005K&\u0002\u01a9\u01ac\u00042<\u0002\u01aa\u01ac\u0005W,\u0002\u01ab", - "\u01a8\u0003\u0002\u0002\u0002\u01ab\u01a9\u0003\u0002\u0002\u0002\u01ab", - "\u01aa\u0003\u0002\u0002\u0002\u01ac\u01ba\u0003\u0002\u0002\u0002\u01ad", - "\u01b1\u0005M\'\u0002\u01ae\u01b1\t\u0019\u0002\u0002\u01af\u01b1\u0005", - "W,\u0002\u01b0\u01ad\u0003\u0002\u0002\u0002\u01b0\u01ae\u0003\u0002", - "\u0002\u0002\u01b0\u01af\u0003\u0002\u0002\u0002\u01b1\u01b4\u0003\u0002", - "\u0002\u0002\u01b2\u01b0\u0003\u0002\u0002\u0002\u01b2\u01b3\u0003\u0002", - "\u0002\u0002\u01b3\u01b8\u0003\u0002\u0002\u0002\u01b4\u01b2\u0003\u0002", - "\u0002\u0002\u01b5\u01b9\u0005M\'\u0002\u01b6\u01b9\u0007<\u0002\u0002", - "\u01b7\u01b9\u0005W,\u0002\u01b8\u01b5\u0003\u0002\u0002\u0002\u01b8", - "\u01b6\u0003\u0002\u0002\u0002\u01b8\u01b7\u0003\u0002\u0002\u0002\u01b9", - "\u01bb\u0003\u0002\u0002\u0002\u01ba\u01b2\u0003\u0002\u0002\u0002\u01ba", - "\u01bb\u0003\u0002\u0002\u0002\u01bbV\u0003\u0002\u0002\u0002\u01bc", - "\u01bf\u0005Y-\u0002\u01bd\u01bf\u0005]/\u0002\u01be\u01bc\u0003\u0002", - "\u0002\u0002\u01be\u01bd\u0003\u0002\u0002\u0002\u01bfX\u0003\u0002", - "\u0002\u0002\u01c0\u01c1\u0007\'\u0002\u0002\u01c1\u01c2\u0005[.\u0002", - "\u01c2\u01c3\u0005[.\u0002\u01c3Z\u0003\u0002\u0002\u0002\u01c4\u01c6", - "\t\u001a\u0002\u0002\u01c5\u01c4\u0003\u0002\u0002\u0002\u01c6\\\u0003", - "\u0002\u0002\u0002\u01c7\u01c8\u0007^\u0002\u0002\u01c8\u01c9\t\u001b", - "\u0002\u0002\u01c9^\u0003\u0002\u0002\u00028\u0002\u008a\u0092\u009d", - "\u00a3\u00a7\u00ac\u00ae\u00b4\u00c0\u00c4\u00c6\u00ca\u00d0\u00d6\u00da", - "\u00de\u00e3\u00e6\u00eb\u00f2\u00f5\u00fa\u0100\u0108\u010e\u0111\u0115", - "\u011a\u0123\u0128\u012c\u013a\u013f\u0143\u014e\u0150\u0159\u015b\u0174", - "\u0181\u0187\u018b\u018f\u01a0\u01a2\u01a6\u01ab\u01b0\u01b2\u01b8\u01ba", - "\u01be\u01c5\u0003\b\u0002\u0002"].join(""); - - -var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); - -var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); }); - -function turtlestarLexer(input) { - antlr4.Lexer.call(this, input); - this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache()); - return this; -} - -turtlestarLexer.prototype = Object.create(antlr4.Lexer.prototype); -turtlestarLexer.prototype.constructor = turtlestarLexer; - -turtlestarLexer.EOF = antlr4.Token.EOF; -turtlestarLexer.T__0 = 1; -turtlestarLexer.T__1 = 2; -turtlestarLexer.T__2 = 3; -turtlestarLexer.T__3 = 4; -turtlestarLexer.T__4 = 5; -turtlestarLexer.T__5 = 6; -turtlestarLexer.T__6 = 7; -turtlestarLexer.T__7 = 8; -turtlestarLexer.T__8 = 9; -turtlestarLexer.T__9 = 10; -turtlestarLexer.T__10 = 11; -turtlestarLexer.T__11 = 12; -turtlestarLexer.T__12 = 13; -turtlestarLexer.COMMENT = 14; -turtlestarLexer.NumericLiteral = 15; -turtlestarLexer.BooleanLiteral = 16; -turtlestarLexer.String = 17; -turtlestarLexer.BlankNode = 18; -turtlestarLexer.IRIREF = 19; -turtlestarLexer.PNAME_NS = 20; -turtlestarLexer.PNAME_LN = 21; -turtlestarLexer.BLANK_NODE_LABEL = 22; -turtlestarLexer.LANGTAG = 23; -turtlestarLexer.INTEGER = 24; -turtlestarLexer.DECIMAL = 25; -turtlestarLexer.DOUBLE = 26; -turtlestarLexer.EXPONENT = 27; -turtlestarLexer.STRING_LITERAL_LONG_SINGLE_QUOTE = 28; -turtlestarLexer.STRING_LITERAL_LONG_QUOTE = 29; -turtlestarLexer.STRING_LITERAL_QUOTE = 30; -turtlestarLexer.STRING_LITERAL_SINGLE_QUOTE = 31; -turtlestarLexer.UCHAR = 32; -turtlestarLexer.ECHAR = 33; -turtlestarLexer.WS = 34; -turtlestarLexer.ANON = 35; -turtlestarLexer.PN_CHARS_BASE = 36; -turtlestarLexer.PN_CHARS_U = 37; -turtlestarLexer.PN_CHARS = 38; -turtlestarLexer.BASE = 39; -turtlestarLexer.PREFIX = 40; -turtlestarLexer.PN_PREFIX = 41; -turtlestarLexer.PN_LOCAL = 42; -turtlestarLexer.PLX = 43; -turtlestarLexer.PERCENT = 44; -turtlestarLexer.HEX = 45; -turtlestarLexer.PN_LOCAL_ESC = 46; - - -turtlestarLexer.prototype.modeNames = [ "DEFAULT_MODE" ]; - -turtlestarLexer.prototype.literalNames = [ null, "'.'", "'@prefix'", "'@base'", - "';'", "','", "'a'", "'<<'", - "'>>'", "'['", "']'", "'('", - "')'", "'^^'" ]; - -turtlestarLexer.prototype.symbolicNames = [ null, null, null, null, null, - null, null, null, null, null, - null, null, null, null, "COMMENT", - "NumericLiteral", "BooleanLiteral", - "String", "BlankNode", "IRIREF", - "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", - "LANGTAG", "INTEGER", "DECIMAL", - "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", - "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", - "UCHAR", "ECHAR", "WS", "ANON", - "PN_CHARS_BASE", "PN_CHARS_U", - "PN_CHARS", "BASE", "PREFIX", - "PN_PREFIX", "PN_LOCAL", "PLX", - "PERCENT", "HEX", "PN_LOCAL_ESC" ]; - -turtlestarLexer.prototype.ruleNames = [ "T__0", "T__1", "T__2", "T__3", - "T__4", "T__5", "T__6", "T__7", - "T__8", "T__9", "T__10", "T__11", - "T__12", "COMMENT", "NumericLiteral", - "BooleanLiteral", "String", "BlankNode", - "IRIREF", "PNAME_NS", "PNAME_LN", - "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", - "DECIMAL", "DOUBLE", "EXPONENT", - "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", - "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", - "ECHAR", "WS", "ANON", "PN_CHARS_BASE", - "PN_CHARS_U", "PN_CHARS", "BASE", - "PREFIX", "PN_PREFIX", "PN_LOCAL", - "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; - -turtlestarLexer.prototype.grammarFileName = "turtlestar.g4"; - - - -exports.turtlestarLexer = turtlestarLexer; - - - -/***/ }), -/* 53 */ -/***/ (function(module, exports, __webpack_require__) { - -var turtlestarListener = __webpack_require__(32).turtlestarListener; - -function turtlestarPrefixListener(listener) { - turtlestarListener.call(this); - this.listener = listener; - this.prefixes = {}; - - return this; -} - -turtlestarPrefixListener.prototype = Object.create(turtlestarListener.prototype); -turtlestarPrefixListener.prototype.constructor = turtlestarPrefixListener; - -// Exit a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarPrefixListener.prototype.exitSparqlPrefix = function(ctx) { - this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); -}; - -// Exit a parse tree produced by turtlestarParser#prefixID. -turtlestarPrefixListener.prototype.exitPrefixID = function(ctx) { - this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); -}; - -turtlestarPrefixListener.prototype.processPrefix = function(pNameNs, iriRef) { - if (pNameNs == null) - return - - var prefix = pNameNs.getText().trim(); - prefix = prefix.substring(0, prefix.length - 1) - - var uri = this.iri(iriRef); - this.prefixes[prefix] = uri; -} - -// Exit a parse tree produced by turtlestarParser#prefixedName. -turtlestarPrefixListener.prototype.exitPrefixedName = function(ctx) { - var pNameLn = ctx.PNAME_LN(); - - if (pNameLn != null) { - var pName = pNameLn.getText().trim(); - var prefix = pName.substring(0, pName.indexOf(":")).trim(); - - if (prefix == "") - return; - - if (this.prefixes[prefix] === undefined) { - var line = ctx.start.line - var start = ctx.start.column - var end = start + prefix.length - - this.listener.unknownPrefix(prefix, pName, line, start, end); - } - } -}; - -turtlestarPrefixListener.prototype.text = function(node) { - if (node == null) - return null; - - return node.getText().trim(); -} - -turtlestarPrefixListener.prototype.iri = function(node) { - var s = this.text(node); - return s.substring(1, s.length - 1); -} - -exports.turtlestarPrefixListener = turtlestarPrefixListener; - -/***/ }), -/* 54 */ -/***/ (function(module, exports, __webpack_require__) { - -var turtlestarVisitor = __webpack_require__(33).turtlestarVisitor -var turtlestarParser = __webpack_require__(31).turtlestarParser - -function turtlestarPrintVisitor(listener) { - turtlestarVisitor.call(this); - this.listener = listener; - - this.lvl = 0 - - return this; -} - -turtlestarPrintVisitor.prototype = Object.create(turtlestarVisitor.prototype); -turtlestarPrintVisitor.prototype.constructor = turtlestarPrintVisitor; - - -// Visit a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarVisitor.prototype.visitTurtleStarDoc = function(ctx) { - this.print("TurtleStarDoc"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#directive. -turtlestarVisitor.prototype.visitDirective = function(ctx) { - this.print("Directive"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#prefixID. -turtlestarVisitor.prototype.visitPrefixID = function(ctx) { - this.print("PrefixID"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#base. -turtlestarVisitor.prototype.visitBase = function(ctx) { - this.print("Base"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#sparqlBase. -turtlestarVisitor.prototype.visitSparqlBase = function(ctx) { - this.print("SparqlBase"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarVisitor.prototype.visitSparqlPrefix = function(ctx) { - this.print("SparqlPrefix"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#triples. -turtlestarVisitor.prototype.visitTriples = function(ctx) { - this.print("Triples"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarVisitor.prototype.visitPredicateObjectList = function(ctx) { - this.print("PredicateObjectList"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#objectList. -turtlestarVisitor.prototype.visitObjectList = function(ctx) { - this.print("ObjectList"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#verb. -turtlestarVisitor.prototype.visitVerb = function(ctx) { - this.print("Verb"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#subject. -turtlestarVisitor.prototype.visitSubject = function(ctx) { - this.print("Subject"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#predicate. -turtlestarVisitor.prototype.visitPredicate = function(ctx) { - this.print("Predicate"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#object. -turtlestarVisitor.prototype.visitObject = function(ctx) { - this.print("Object"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#tripleX. -turtlestarVisitor.prototype.visitTripleX = function(ctx) { - this.print("TripleX"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#subjectX. -turtlestarVisitor.prototype.visitSubjectX = function(ctx) { - this.print("SubjectX"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#objectX. -turtlestarVisitor.prototype.visitObjectX = function(ctx) { - this.print("ObjectX"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#literal. -turtlestarVisitor.prototype.visitLiteral = function(ctx) { - this.print("Literal"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarVisitor.prototype.visitBlankNodePropertyList = function(ctx) { - this.print("BlankNodePropertyList"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#collection. -turtlestarVisitor.prototype.visitCollection = function(ctx) { - this.print("Collection"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarVisitor.prototype.visitRdfLiteral = function(ctx) { - this.print("RdfLiteral"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#iri. -turtlestarVisitor.prototype.visitIri = function(ctx) { - this.print("Iri"); - return this.doVisitChildren(ctx); -} - - -// Visit a parse tree produced by turtlestarParser#prefixedName. -turtlestarVisitor.prototype.visitPrefixedName = function(ctx) { - this.print("PrefixedName"); - return this.doVisitChildren(ctx); -} - - -turtlestarPrintVisitor.prototype.incrLvl = function() { - this.lvl++; -} - -turtlestarPrintVisitor.prototype.decrLvl = function() { - this.lvl--; -} - -turtlestarPrintVisitor.prototype.print = function(el) { - var ws = new Array(this.lvl + 1).join(" "); - var out = ws + el + "\n"; - - this.listener.newAstLine(out); -} - -turtlestarPrintVisitor.prototype.doVisitChildren = function(ctx) { - this.lvl++; - this.visitChildren(ctx); - this.lvl--; -} - -turtlestarPrintVisitor.prototype.visitChildren = function(node) { - var result = null; // this.defaultResult() - var n = node.getChildCount() - for (var i = 0; i < n; i++) { - // if (!this.shouldVisitNextChild(node, result)) { - // break - // } - - var c = node.getChild(i) - if (c.symbol !== undefined) { - var out = "' " + c + " '"; - var type = c.symbol.type - if (type != -1 && turtlestarParser.symbolicNames[type] !== null) - out += " (" + turtlestarParser.symbolicNames[type] + ")" - this.print(out) - - } else { - result = c.accept(this); - // result = this.aggregateResult(result, childResult); - } - } - - return result -} - -exports.turtlestarPrintVisitor = turtlestarPrintVisitor; - -/***/ }) -/******/ ]); \ No newline at end of file +/*! For license information please see turtlestarMain.js.LICENSE.txt */ +var turtlestar;(()=>{var t={330:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});var s=n(470);class i extends s.Z.tree.ParseTreeListener{enterTurtleStarDoc(t){}exitTurtleStarDoc(t){}enterStatement(t){}exitStatement(t){}enterDirective(t){}exitDirective(t){}enterPrefixID(t){}exitPrefixID(t){}enterBase(t){}exitBase(t){}enterSparqlBase(t){}exitSparqlBase(t){}enterSparqlPrefix(t){}exitSparqlPrefix(t){}enterTriples(t){}exitTriples(t){}enterPredicateObjectList(t){}exitPredicateObjectList(t){}enterObjectList(t){}exitObjectList(t){}enterVerb(t){}exitVerb(t){}enterSubject(t){}exitSubject(t){}enterPredicate(t){}exitPredicate(t){}enterObject(t){}exitObject(t){}enterTripleX(t){}exitTripleX(t){}enterSubjectX(t){}exitSubjectX(t){}enterObjectX(t){}exitObjectX(t){}enterLiteral(t){}exitLiteral(t){}enterBlankNodePropertyList(t){}exitBlankNodePropertyList(t){}enterCollection(t){}exitCollection(t){}enterRdfLiteral(t){}exitRdfLiteral(t){}enterIri(t){}exitIri(t){}enterPrefixedName(t){}exitPrefixedName(t){}}},577:(t,e,n)=>{"use strict";n.d(e,{Z:()=>h});var s=n(470),i=n(330),r=n(516);const o=(new s.Z.atn.ATNDeserializer).deserialize([4,1,46,180,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,1,0,5,0,48,8,0,10,0,12,0,51,9,0,1,0,1,0,1,1,1,1,1,1,1,1,3,1,59,8,1,1,2,1,2,1,2,1,2,3,2,65,8,2,1,3,1,3,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,3,7,88,8,7,3,7,90,8,7,1,8,1,8,1,8,1,8,1,8,1,8,3,8,98,8,8,5,8,100,8,8,10,8,12,8,103,9,8,1,9,1,9,1,9,5,9,108,8,9,10,9,12,9,111,9,9,1,10,1,10,3,10,115,8,10,1,11,1,11,1,11,1,11,3,11,121,8,11,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,3,13,131,8,13,1,14,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,3,15,142,8,15,1,16,1,16,1,16,1,16,3,16,148,8,16,1,17,1,17,1,17,3,17,153,8,17,1,18,1,18,1,18,1,18,1,19,1,19,5,19,161,8,19,10,19,12,19,164,9,19,1,19,1,19,1,20,1,20,1,20,1,20,3,20,172,8,20,1,21,1,21,3,21,176,8,21,1,22,1,22,1,22,0,0,23,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,0,1,1,0,20,21,186,0,49,1,0,0,0,2,58,1,0,0,0,4,64,1,0,0,0,6,66,1,0,0,0,8,71,1,0,0,0,10,75,1,0,0,0,12,78,1,0,0,0,14,89,1,0,0,0,16,91,1,0,0,0,18,104,1,0,0,0,20,114,1,0,0,0,22,120,1,0,0,0,24,122,1,0,0,0,26,130,1,0,0,0,28,132,1,0,0,0,30,141,1,0,0,0,32,147,1,0,0,0,34,152,1,0,0,0,36,154,1,0,0,0,38,158,1,0,0,0,40,167,1,0,0,0,42,175,1,0,0,0,44,177,1,0,0,0,46,48,3,2,1,0,47,46,1,0,0,0,48,51,1,0,0,0,49,47,1,0,0,0,49,50,1,0,0,0,50,52,1,0,0,0,51,49,1,0,0,0,52,53,5,0,0,1,53,1,1,0,0,0,54,59,3,4,2,0,55,56,3,14,7,0,56,57,5,1,0,0,57,59,1,0,0,0,58,54,1,0,0,0,58,55,1,0,0,0,59,3,1,0,0,0,60,65,3,6,3,0,61,65,3,8,4,0,62,65,3,12,6,0,63,65,3,10,5,0,64,60,1,0,0,0,64,61,1,0,0,0,64,62,1,0,0,0,64,63,1,0,0,0,65,5,1,0,0,0,66,67,5,2,0,0,67,68,5,20,0,0,68,69,5,19,0,0,69,70,5,1,0,0,70,7,1,0,0,0,71,72,5,3,0,0,72,73,5,19,0,0,73,74,5,1,0,0,74,9,1,0,0,0,75,76,5,39,0,0,76,77,5,19,0,0,77,11,1,0,0,0,78,79,5,40,0,0,79,80,5,20,0,0,80,81,5,19,0,0,81,13,1,0,0,0,82,83,3,22,11,0,83,84,3,16,8,0,84,90,1,0,0,0,85,87,3,36,18,0,86,88,3,16,8,0,87,86,1,0,0,0,87,88,1,0,0,0,88,90,1,0,0,0,89,82,1,0,0,0,89,85,1,0,0,0,90,15,1,0,0,0,91,92,3,20,10,0,92,101,3,18,9,0,93,97,5,4,0,0,94,95,3,20,10,0,95,96,3,18,9,0,96,98,1,0,0,0,97,94,1,0,0,0,97,98,1,0,0,0,98,100,1,0,0,0,99,93,1,0,0,0,100,103,1,0,0,0,101,99,1,0,0,0,101,102,1,0,0,0,102,17,1,0,0,0,103,101,1,0,0,0,104,109,3,26,13,0,105,106,5,5,0,0,106,108,3,26,13,0,107,105,1,0,0,0,108,111,1,0,0,0,109,107,1,0,0,0,109,110,1,0,0,0,110,19,1,0,0,0,111,109,1,0,0,0,112,115,3,24,12,0,113,115,5,6,0,0,114,112,1,0,0,0,114,113,1,0,0,0,115,21,1,0,0,0,116,121,3,42,21,0,117,121,5,18,0,0,118,121,3,38,19,0,119,121,3,28,14,0,120,116,1,0,0,0,120,117,1,0,0,0,120,118,1,0,0,0,120,119,1,0,0,0,121,23,1,0,0,0,122,123,3,42,21,0,123,25,1,0,0,0,124,131,3,42,21,0,125,131,5,18,0,0,126,131,3,34,17,0,127,131,3,38,19,0,128,131,3,36,18,0,129,131,3,28,14,0,130,124,1,0,0,0,130,125,1,0,0,0,130,126,1,0,0,0,130,127,1,0,0,0,130,128,1,0,0,0,130,129,1,0,0,0,131,27,1,0,0,0,132,133,5,7,0,0,133,134,3,30,15,0,134,135,3,24,12,0,135,136,3,32,16,0,136,137,5,8,0,0,137,29,1,0,0,0,138,142,3,42,21,0,139,142,5,18,0,0,140,142,3,28,14,0,141,138,1,0,0,0,141,139,1,0,0,0,141,140,1,0,0,0,142,31,1,0,0,0,143,148,3,42,21,0,144,148,5,18,0,0,145,148,3,34,17,0,146,148,3,28,14,0,147,143,1,0,0,0,147,144,1,0,0,0,147,145,1,0,0,0,147,146,1,0,0,0,148,33,1,0,0,0,149,153,3,40,20,0,150,153,5,15,0,0,151,153,5,16,0,0,152,149,1,0,0,0,152,150,1,0,0,0,152,151,1,0,0,0,153,35,1,0,0,0,154,155,5,9,0,0,155,156,3,16,8,0,156,157,5,10,0,0,157,37,1,0,0,0,158,162,5,11,0,0,159,161,3,26,13,0,160,159,1,0,0,0,161,164,1,0,0,0,162,160,1,0,0,0,162,163,1,0,0,0,163,165,1,0,0,0,164,162,1,0,0,0,165,166,5,12,0,0,166,39,1,0,0,0,167,171,5,17,0,0,168,172,5,23,0,0,169,170,5,13,0,0,170,172,3,42,21,0,171,168,1,0,0,0,171,169,1,0,0,0,171,172,1,0,0,0,172,41,1,0,0,0,173,176,5,19,0,0,174,176,3,44,22,0,175,173,1,0,0,0,175,174,1,0,0,0,176,43,1,0,0,0,177,178,7,0,0,0,178,45,1,0,0,0,17,49,58,64,87,89,97,101,109,114,120,130,141,147,152,162,171,175]),l=o.decisionToState.map(((t,e)=>new s.Z.dfa.DFA(t,e))),a=new s.Z.PredictionContextCache;class h extends s.Z.Parser{static grammarFileName="java-escape";static literalNames=[null,"'.'","'@prefix'","'@base'","';'","','","'a'","'<<'","'>>'","'['","']'","'('","')'","'^^'"];static symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"COMMENT","NumericLiteral","BooleanLiteral","String","BlankNode","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","ANON","PN_CHARS_BASE","PN_CHARS_U","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];static ruleNames=["turtleStarDoc","statement","directive","prefixID","base","sparqlBase","sparqlPrefix","triples","predicateObjectList","objectList","verb","subject","predicate","object","tripleX","subjectX","objectX","literal","blankNodePropertyList","collection","rdfLiteral","iri","prefixedName"];constructor(t){super(t),this._interp=new s.Z.atn.ParserATNSimulator(this,o,l,a),this.ruleNames=h.ruleNames,this.literalNames=h.literalNames,this.symbolicNames=h.symbolicNames}get atn(){return o}turtleStarDoc(){let t=new c(this,this._ctx,this.state);this.enterRule(t,0,h.RULE_turtleStarDoc);var e=0;try{for(this.enterOuterAlt(t,1),this.state=49,this._errHandler.sync(this),e=this._input.LA(1);0==(-32&e)&&0!=(1<{var s=n(330).turtlestarListener;function i(t){return s.call(this),this.listener=t,this.lvl=0,this}i.prototype=Object.create(s.prototype),i.prototype.constructor=i,i.prototype.enterTurtleStarDoc=function(t){this.print("TurtleStarDoc"),this.incrLvl()},i.prototype.exitTurtleStarDoc=function(t){this.decrLvl()},i.prototype.enterStatement=function(t){this.print("Statement"),this.incrLvl()},i.prototype.exitStatement=function(t){this.decrLvl()},i.prototype.enterDirective=function(t){this.print("Directive"),this.incrLvl()},i.prototype.exitDirective=function(t){this.decrLvl()},i.prototype.enterPrefixID=function(t){this.print("PrefixID"),this.incrLvl()},i.prototype.exitPrefixID=function(t){this.decrLvl()},i.prototype.enterBase=function(t){this.print("Base"),this.incrLvl()},i.prototype.exitBase=function(t){this.decrLvl()},i.prototype.enterSparqlBase=function(t){this.print("SparqlBase"),this.incrLvl()},i.prototype.exitSparqlBase=function(t){this.decrLvl()},i.prototype.enterSparqlPrefix=function(t){this.print("SparqlPrefix"),this.incrLvl()},i.prototype.exitSparqlPrefix=function(t){this.decrLvl()},i.prototype.enterTriples=function(t){this.print("Triples"),this.incrLvl()},i.prototype.exitTriples=function(t){this.decrLvl()},i.prototype.enterPredicateObjectList=function(t){this.print("PredicateObjectList"),this.incrLvl()},i.prototype.exitPredicateObjectList=function(t){this.decrLvl()},i.prototype.enterObjectList=function(t){this.print("ObjectList"),this.incrLvl()},i.prototype.exitObjectList=function(t){this.decrLvl()},i.prototype.enterVerb=function(t){this.print("Verb"),this.incrLvl()},i.prototype.exitVerb=function(t){this.decrLvl()},i.prototype.enterSubject=function(t){this.print("Subject"),this.incrLvl()},i.prototype.exitSubject=function(t){this.decrLvl()},i.prototype.enterPredicate=function(t){this.print("Predicate"),this.incrLvl()},i.prototype.exitPredicate=function(t){this.decrLvl()},i.prototype.enterObject=function(t){this.print("Object"),this.incrLvl()},i.prototype.exitObject=function(t){this.decrLvl()},i.prototype.enterTripleX=function(t){this.print("TripleX"),this.incrLvl()},i.prototype.exitTripleX=function(t){this.decrLvl()},i.prototype.enterSubjectX=function(t){this.print("SubjectX"),this.incrLvl()},i.prototype.exitSubjectX=function(t){this.decrLvl()},i.prototype.enterObjectX=function(t){this.print("ObjectX"),this.incrLvl()},i.prototype.exitObjectX=function(t){this.decrLvl()},i.prototype.enterLiteral=function(t){this.print("Literal"),this.incrLvl()},i.prototype.exitLiteral=function(t){this.decrLvl()},i.prototype.enterBlankNodePropertyList=function(t){this.print("BlankNodePropertyList"),this.incrLvl()},i.prototype.exitBlankNodePropertyList=function(t){this.decrLvl()},i.prototype.enterCollection=function(t){this.print("Collection"),this.incrLvl()},i.prototype.exitCollection=function(t){this.decrLvl()},i.prototype.enterRdfLiteral=function(t){this.print("RdfLiteral"),this.incrLvl()},i.prototype.exitRdfLiteral=function(t){this.decrLvl()},i.prototype.enterIri=function(t){this.print("Iri"),this.incrLvl()},i.prototype.exitIri=function(t){this.decrLvl()},i.prototype.enterPrefixedName=function(t){this.print("PrefixedName"),this.incrLvl()},i.prototype.exitPrefixedName=function(t){this.decrLvl()},i.prototype.incrLvl=function(){this.lvl++},i.prototype.decrLvl=function(){this.lvl--},i.prototype.print=function(t){console.log("el? "+t);var e=new Array(this.lvl+1).join(" ")+t+"\n";this.listener.newAstLine(e)}},26:(t,e,n)=>{var s=n(516).turtlestarVisitor,i=n(577).turtlestarParser;function r(t){return s.call(this),this.listener=t,this.lvl=0,this}r.prototype=Object.create(s.prototype),r.prototype.constructor=r,s.prototype.visitTurtleStarDoc=function(t){return this.print("TurtleStarDoc"),this.doVisitChildren(t)},s.prototype.visitDirective=function(t){return this.print("Directive"),this.doVisitChildren(t)},s.prototype.visitPrefixID=function(t){return this.print("PrefixID"),this.doVisitChildren(t)},s.prototype.visitBase=function(t){return this.print("Base"),this.doVisitChildren(t)},s.prototype.visitSparqlBase=function(t){return this.print("SparqlBase"),this.doVisitChildren(t)},s.prototype.visitSparqlPrefix=function(t){return this.print("SparqlPrefix"),this.doVisitChildren(t)},s.prototype.visitTriples=function(t){return this.print("Triples"),this.doVisitChildren(t)},s.prototype.visitPredicateObjectList=function(t){return this.print("PredicateObjectList"),this.doVisitChildren(t)},s.prototype.visitObjectList=function(t){return this.print("ObjectList"),this.doVisitChildren(t)},s.prototype.visitVerb=function(t){return this.print("Verb"),this.doVisitChildren(t)},s.prototype.visitSubject=function(t){return this.print("Subject"),this.doVisitChildren(t)},s.prototype.visitPredicate=function(t){return this.print("Predicate"),this.doVisitChildren(t)},s.prototype.visitObject=function(t){return this.print("Object"),this.doVisitChildren(t)},s.prototype.visitTripleX=function(t){return this.print("TripleX"),this.doVisitChildren(t)},s.prototype.visitSubjectX=function(t){return this.print("SubjectX"),this.doVisitChildren(t)},s.prototype.visitObjectX=function(t){return this.print("ObjectX"),this.doVisitChildren(t)},s.prototype.visitLiteral=function(t){return this.print("Literal"),this.doVisitChildren(t)},s.prototype.visitBlankNodePropertyList=function(t){return this.print("BlankNodePropertyList"),this.doVisitChildren(t)},s.prototype.visitCollection=function(t){return this.print("Collection"),this.doVisitChildren(t)},s.prototype.visitRdfLiteral=function(t){return this.print("RdfLiteral"),this.doVisitChildren(t)},s.prototype.visitIri=function(t){return this.print("Iri"),this.doVisitChildren(t)},s.prototype.visitPrefixedName=function(t){return this.print("PrefixedName"),this.doVisitChildren(t)},r.prototype.incrLvl=function(){this.lvl++},r.prototype.decrLvl=function(){this.lvl--},r.prototype.print=function(t){var e=new Array(this.lvl+1).join(" ")+t+"\n";this.listener.newAstLine(e)},r.prototype.doVisitChildren=function(t){this.lvl++,this.visitChildren(t),this.lvl--},r.prototype.visitChildren=function(t){for(var e=null,n=t.getChildCount(),s=0;s{"use strict";n.d(e,{Z:()=>i});var s=n(470);class i extends s.Z.tree.ParseTreeVisitor{visitTurtleStarDoc(t){return this.visitChildren(t)}visitStatement(t){return this.visitChildren(t)}visitDirective(t){return this.visitChildren(t)}visitPrefixID(t){return this.visitChildren(t)}visitBase(t){return this.visitChildren(t)}visitSparqlBase(t){return this.visitChildren(t)}visitSparqlPrefix(t){return this.visitChildren(t)}visitTriples(t){return this.visitChildren(t)}visitPredicateObjectList(t){return this.visitChildren(t)}visitObjectList(t){return this.visitChildren(t)}visitVerb(t){return this.visitChildren(t)}visitSubject(t){return this.visitChildren(t)}visitPredicate(t){return this.visitChildren(t)}visitObject(t){return this.visitChildren(t)}visitTripleX(t){return this.visitChildren(t)}visitSubjectX(t){return this.visitChildren(t)}visitObjectX(t){return this.visitChildren(t)}visitLiteral(t){return this.visitChildren(t)}visitBlankNodePropertyList(t){return this.visitChildren(t)}visitCollection(t){return this.visitChildren(t)}visitRdfLiteral(t){return this.visitChildren(t)}visitIri(t){return this.visitChildren(t)}visitPrefixedName(t){return this.visitChildren(t)}}},262:()=>{},790:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});var s=n(12);class i extends s.Z{constructor(t,e,n,r,o){super(),this.source=void 0!==t?t:i.EMPTY_SOURCE,this.type=void 0!==e?e:null,this.channel=void 0!==n?n:s.Z.DEFAULT_CHANNEL,this.start=void 0!==r?r:-1,this.stop=void 0!==o?o:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=t[0].line,this.column=t[0].column):this.column=-1}clone(){const t=new i(this.source,this.type,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,t.text=this.text,t}toString(){let t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"}get text(){if(null!==this._text)return this._text;const t=this.getInputStream();if(null===t)return null;const e=t.size;return this.start"}set text(t){this._text=t}}i.EMPTY_SOURCE=[null,null]},477:(t,e,n)=>{"use strict";n.d(e,{Z:()=>o});var s=n(12),i=n(517),r=n(393);class o extends class extends class{}{constructor(t){super(),this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}mark(){return 0}release(t){}reset(){this.seek(0)}seek(t){this.lazyInit(),this.index=this.adjustSeekIndex(t)}get(t){return this.lazyInit(),this.tokens[t]}consume(){let t=!1;if(t=this.index>=0&&(this.fetchedEOF?this.index0)||this.fetch(e)>=e}fetch(t){if(this.fetchedEOF)return 0;for(let e=0;e=this.tokens.length&&(e=this.tokens.length-1);for(let r=t;r=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]}adjustSeekIndex(t){return t}lazyInit(){-1===this.index&&this.setup()}setup(){this.sync(0),this.index=this.adjustSeekIndex(0)}setTokenSource(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}nextTokenOnChannel(t,e){if(this.sync(t),t>=this.tokens.length)return-1;let n=this.tokens[t];for(;n.channel!==this.channel;){if(n.type===s.Z.EOF)return-1;t+=1,this.sync(t),n=this.tokens[t]}return t}previousTokenOnChannel(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t}getHiddenTokensToRight(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const n=this.nextTokenOnChannel(t+1,i.Z.DEFAULT_TOKEN_CHANNEL),s=t+1,r=-1===n?this.tokens.length-1:n;return this.filterForChannel(s,r,e)}getHiddenTokensToLeft(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const n=this.previousTokenOnChannel(t-1,i.Z.DEFAULT_TOKEN_CHANNEL);if(n===t-1)return null;const s=n+1,r=t-1;return this.filterForChannel(s,r,e)}filterForChannel(t,e,n){const s=[];for(let r=t;r=this.tokens.length&&(n=this.tokens.length-1);let i="";for(let t=e;t{"use strict";n.d(e,{Z:()=>i});var s=n(12);n(408),n(545);class i{constructor(t,e){if(this.name="",this.strdata=t,this.decodeToUnicodeCodePoints=e||!1,this._index=0,this.data=[],this.decodeToUnicodeCodePoints)for(let t=0;t=this._size)throw"cannot consume EOF";this._index+=1}LA(t){if(0===t)return 0;t<0&&(t+=1);const e=this._index+t-1;return e<0||e>=this._size?s.Z.EOF:this.data[e]}LT(t){return this.LA(t)}mark(){return-1}release(t){}seek(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)}getText(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){let n="";for(let s=t;s<=e;s++)n+=String.fromCodePoint(this.data[s]);return n}return this.strdata.slice(t,e+1)}toString(){return this.strdata}get index(){return this._index}get size(){return this._size}}},517:(t,e,n)=>{"use strict";n.d(e,{Z:()=>h});var s=n(12),i=n(597),r=n(790);class o extends class{}{constructor(t){super(),this.copyText=void 0!==t&&t}create(t,e,n,s,i,o,l,a){const h=new r.Z(t,e,s,i,o);return h.line=l,h.column=a,null!==n?h.text=n:this.copyText&&null!==t[1]&&(h.text=t[1].getText(i,o)),h}createThin(t,e){const n=new r.Z(null,t);return n.text=e,n}}o.DEFAULT=new o;var l=n(774),a=n(81);class h extends i.Z{constructor(t){super(),this._input=t,this._factory=o.DEFAULT,this._tokenFactorySourcePair=[this,t],this._interp=null,this._token=null,this._tokenStartCharIndex=-1,this._tokenStartLine=-1,this._tokenStartColumn=-1,this._hitEOF=!1,this._channel=s.Z.DEFAULT_CHANNEL,this._type=s.Z.INVALID_TYPE,this._modeStack=[],this._mode=h.DEFAULT_MODE,this._text=null}reset(){null!==this._input&&this._input.seek(0),this._token=null,this._type=s.Z.INVALID_TYPE,this._channel=s.Z.DEFAULT_CHANNEL,this._tokenStartCharIndex=-1,this._tokenStartColumn=-1,this._tokenStartLine=-1,this._text=null,this._hitEOF=!1,this._mode=h.DEFAULT_MODE,this._modeStack=[],this._interp.reset()}nextToken(){if(null===this._input)throw"nextToken requires a non-null input stream.";const t=this._input.mark();try{for(;;){if(this._hitEOF)return this.emitEOF(),this._token;this._token=null,this._channel=s.Z.DEFAULT_CHANNEL,this._tokenStartCharIndex=this._input.index,this._tokenStartColumn=this._interp.column,this._tokenStartLine=this._interp.line,this._text=null;let t=!1;for(;;){this._type=s.Z.INVALID_TYPE;let e=h.SKIP;try{e=this._interp.match(this._input,this._mode)}catch(t){if(!(t instanceof l.Z))throw console.log(t.stack),t;this.notifyListeners(t),this.recover(t)}if(this._input.LA(1)===s.Z.EOF&&(this._hitEOF=!0),this._type===s.Z.INVALID_TYPE&&(this._type=e),this._type===h.SKIP){t=!0;break}if(this._type!==h.MORE)break}if(!t)return null===this._token&&this.emit(),this._token}}finally{this._input.release(t)}}skip(){this._type=h.SKIP}more(){this._type=h.MORE}mode(t){this._mode=t}pushMode(t){this._interp.debug&&console.log("pushMode "+t),this._modeStack.push(this._mode),this.mode(t)}popMode(){if(0===this._modeStack.length)throw"Empty Stack";return this._interp.debug&&console.log("popMode back to "+this._modeStack.slice(0,-1)),this.mode(this._modeStack.pop()),this._mode}emitToken(t){this._token=t}emit(){const t=this._factory.create(this._tokenFactorySourcePair,this._type,this._text,this._channel,this._tokenStartCharIndex,this.getCharIndex()-1,this._tokenStartLine,this._tokenStartColumn);return this.emitToken(t),t}emitEOF(){const t=this.column,e=this.line,n=this._factory.create(this._tokenFactorySourcePair,s.Z.EOF,null,s.Z.DEFAULT_CHANNEL,this._input.index,this._input.index-1,e,t);return this.emitToken(n),n}getCharIndex(){return this._input.index}getAllTokens(){const t=[];let e=this.nextToken();for(;e.type!==s.Z.EOF;)t.push(e),e=this.nextToken();return t}notifyListeners(t){const e=this._tokenStartCharIndex,n=this._input.index,s=this._input.getText(e,n),i="token recognition error at: '"+this.getErrorDisplay(s)+"'";this.getErrorListenerDispatch().syntaxError(this,null,this._tokenStartLine,this._tokenStartColumn,i,t)}getErrorDisplay(t){const e=[];for(let n=0;n":"\n"===t?"\\n":"\t"===t?"\\t":"\r"===t?"\\r":t}getCharErrorDisplay(t){return"'"+this.getErrorDisplayForChar(t)+"'"}recover(t){this._input.LA(1)!==s.Z.EOF&&(t instanceof a.Z?this._interp.consume(this._input):this._input.consume())}get inputStream(){return this._input}set inputStream(t){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=t,this._tokenFactorySourcePair=[this,this._input]}get sourceName(){return this._input.sourceName}get type(){return this._type}set type(t){this._type=t}get line(){return this._interp.line}set line(t){this._interp.line=t}get column(){return this._interp.column}set column(t){this._interp.column=t}get text(){return null!==this._text?this._text:this._interp.getText(this._input)}set text(t){this._text=t}}h.DEFAULT_MODE=0,h.MORE=-2,h.SKIP=-3,h.DEFAULT_TOKEN_CHANNEL=s.Z.DEFAULT_CHANNEL,h.HIDDEN=s.Z.HIDDEN_CHANNEL,h.MIN_CHAR_VALUE=0,h.MAX_CHAR_VALUE=1114111},597:(t,e,n)=>{"use strict";n.d(e,{Z:()=>l});var s=n(12),i=n(765);class r extends i.Z{constructor(){super()}syntaxError(t,e,n,s,i,r){console.error("line "+n+":"+s+" "+i)}}r.INSTANCE=new r;class o extends i.Z{constructor(t){if(super(),null===t)throw"delegates";return this.delegates=t,this}syntaxError(t,e,n,s,i,r){this.delegates.map((o=>o.syntaxError(t,e,n,s,i,r)))}reportAmbiguity(t,e,n,s,i,r,o){this.delegates.map((l=>l.reportAmbiguity(t,e,n,s,i,r,o)))}reportAttemptingFullContext(t,e,n,s,i,r){this.delegates.map((o=>o.reportAttemptingFullContext(t,e,n,s,i,r)))}reportContextSensitivity(t,e,n,s,i,r){this.delegates.map((o=>o.reportContextSensitivity(t,e,n,s,i,r)))}}class l{constructor(){this._listeners=[r.INSTANCE],this._interp=null,this._stateNumber=-1}checkVersion(t){"4.10.1"!==t&&console.log("ANTLR runtime and generated code versions disagree: 4.10.1!="+t)}addErrorListener(t){this._listeners.push(t)}removeErrorListeners(){this._listeners=[]}getLiteralNames(){return Object.getPrototypeOf(this).constructor.literalNames||[]}getSymbolicNames(){return Object.getPrototypeOf(this).constructor.symbolicNames||[]}getTokenNames(){if(!this.tokenNames){const t=this.getLiteralNames(),e=this.getSymbolicNames(),n=t.length>e.length?t.length:e.length;this.tokenNames=[];for(let s=0;s";let e=t.text;return null===e&&(e=t.type===s.Z.EOF?"":"<"+t.type+">"),e=e.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"),"'"+e+"'"}getErrorListenerDispatch(){return new o(this._listeners)}sempred(t,e,n){return!0}precpred(t,e){return!0}get state(){return this._stateNumber}set state(t){this._stateNumber=t}}l.tokenTypeMapCache={},l.ruleIndexMapCache={}},12:(t,e,n)=>{"use strict";n.d(e,{Z:()=>s});class s{constructor(){this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null}getTokenSource(){return this.source[0]}getInputStream(){return this.source[1]}get text(){return this._text}set text(t){this._text=t}}s.INVALID_TYPE=0,s.EPSILON=-2,s.MIN_USER_TOKEN_TYPE=1,s.EOF=-1,s.DEFAULT_CHANNEL=0,s.HIDDEN_CHANNEL=1},765:(t,e,n)=>{"use strict";n.d(e,{Z:()=>s});class s{syntaxError(t,e,n,s,i,r){}reportAmbiguity(t,e,n,s,i,r,o){}reportAttemptingFullContext(t,e,n,s,i,r){}reportContextSensitivity(t,e,n,s,i,r){}}},81:(t,e,n)=>{"use strict";n.d(e,{Z:()=>r});var s=n(393),i=n(774);class r extends i.Z{constructor(t,e,n,s){super({message:"",recognizer:t,input:e,ctx:null}),this.startIndex=n,this.deadEndConfigs=s}toString(){let t="";return this.startIndex>=0&&this.startIndex{"use strict";n.d(e,{Z:()=>s});class s extends Error{constructor(t){super(t.message),Error.captureStackTrace&&Error.captureStackTrace(this,s),this.message=t.message,this.recognizer=t.recognizer,this.input=t.input,this.ctx=t.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}}},470:(t,e,n)=>{"use strict";n.d(e,{Z:()=>Ce}),String.prototype.seed=String.prototype.seed||Math.round(Math.random()*Math.pow(2,32)),String.prototype.hashCode=function(){const t=this.toString();let e,n;const s=3&t.length,i=t.length-s;let r=String.prototype.seed;const o=3432918353,l=461845907;let a=0;for(;a>>16)*o&65535)<<16)&4294967295,n=n<<15|n>>>17,n=(65535&n)*l+(((n>>>16)*l&65535)<<16)&4294967295,r^=n,r=r<<13|r>>>19,e=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=27492+(65535&e)+((58964+(e>>>16)&65535)<<16);switch(n=0,s){case 3:n^=(255&t.charCodeAt(a+2))<<16;case 2:n^=(255&t.charCodeAt(a+1))<<8;case 1:n^=255&t.charCodeAt(a),n=(65535&n)*o+(((n>>>16)*o&65535)<<16)&4294967295,n=n<<15|n>>>17,n=(65535&n)*l+(((n>>>16)*l&65535)<<16)&4294967295,r^=n}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0},n(408),n(545);var s=n(12);function i(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n>>17,t*=461845907,this.count=this.count+1;let n=this.hash^t;n=n<<13|n>>>19,n=5*n+3864292196,this.hash=n}}}finish(){let t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16,t}static hashStuff(){const t=new r;return t.update.apply(t,arguments),t.finish()}}function o(t){return t?t.hashCode():-1}function l(t,e){return t?t.equals(e):t===e}function a(t){return null===t?"null":t}function h(t){return Array.isArray(t)?"["+t.map(a).join(", ")+"]":"null"}const c="h-";class u{constructor(t,e){this.data={},this.hashFunction=t||o,this.equalsFunction=e||l}add(t){const e=c+this.hashFunction(t);if(e in this.data){const n=this.data[e];for(let e=0;et.startsWith(c))).flatMap((t=>this.data[t]),this)}toString(){return h(this.values())}get length(){return Object.keys(this.data).filter((t=>t.startsWith(c))).map((t=>this.data[t].length),this).reduce(((t,e)=>t+e),0)}}class d{hashCode(){const t=new r;return this.updateHashCode(t),t.finish()}evaluate(t,e){}evalPrecedence(t,e){return this}static andContext(t,e){if(null===t||t===d.NONE)return e;if(null===e||e===d.NONE)return t;const n=new p(t,e);return 1===n.opnds.length?n.opnds[0]:n}static orContext(t,e){if(null===t)return e;if(null===e)return t;if(t===d.NONE||e===d.NONE)return d.NONE;const n=new f(t,e);return 1===n.opnds.length?n.opnds[0]:n}}class p extends d{constructor(t,e){super();const n=new u;t instanceof p?t.opnds.map((function(t){n.add(t)})):n.add(t),e instanceof p?e.opnds.map((function(t){n.add(t)})):n.add(e);const s=g(n);if(s.length>0){let t=null;s.map((function(e){(null===t||e.precedencet.toString()));return(t.length>3?t.slice(3):t).join("&&")}}class f extends d{constructor(t,e){super();const n=new u;t instanceof f?t.opnds.map((function(t){n.add(t)})):n.add(t),e instanceof f?e.opnds.map((function(t){n.add(t)})):n.add(e);const s=g(n);if(s.length>0){const t=s.sort((function(t,e){return t.compareTo(e)})),e=t[t.length-1];n.add(e)}this.opnds=Array.from(n.values())}equals(t){return this===t||t instanceof f&&i(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"OR")}evaluate(t,e){for(let n=0;nt.toString()));return(t.length>3?t.slice(3):t).join("||")}}function g(t){const e=[];return t.values().map((function(t){t instanceof d.PrecedencePredicate&&e.push(t)})),e}function x(t,e){if(null===t){const t={state:null,alt:null,context:null,semanticContext:null};return e&&(t.reachesIntoOuterContext=0),t}{const n={};return n.state=t.state||null,n.alt=void 0===t.alt?null:t.alt,n.context=t.context||null,n.semanticContext=t.semanticContext||null,e&&(n.reachesIntoOuterContext=t.reachesIntoOuterContext||0,n.precedenceFilterSuppressed=t.precedenceFilterSuppressed||!1),n}}class T{constructor(t,e){this.checkContext(t,e),t=x(t),e=x(e,!0),this.state=null!==t.state?t.state:e.state,this.alt=null!==t.alt?t.alt:e.alt,this.context=null!==t.context?t.context:e.context,this.semanticContext=null!==t.semanticContext?t.semanticContext:null!==e.semanticContext?e.semanticContext:d.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,this.precedenceFilterSuppressed=e.precedenceFilterSuppressed}checkContext(t,e){null!==t.context&&void 0!==t.context||null!==e&&null!==e.context&&void 0!==e.context||(this.context=null)}hashCode(){const t=new r;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)}equals(t){return this===t||t instanceof T&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&(null===this.context?null===t.context:this.context.equals(t.context))&&this.semanticContext.equals(t.semanticContext)&&this.precedenceFilterSuppressed===t.precedenceFilterSuppressed}hashCodeForConfigSet(){const t=new r;return t.update(this.state.stateNumber,this.alt,this.semanticContext),t.finish()}equalsForConfigSet(t){return this===t||t instanceof T&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&this.semanticContext.equals(t.semanticContext)}toString(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==d.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}var _=n(393);class E{constructor(){this.intervals=null,this.readOnly=!1}first(t){return null===this.intervals||0===this.intervals.length?s.Z.INVALID_TYPE:this.intervals[0].start}addOne(t){this.addInterval(new _.Z(t,t+1))}addRange(t,e){this.addInterval(new _.Z(t,e+1))}addInterval(t){if(null===this.intervals)this.intervals=[],this.intervals.push(t.clone());else{for(let e=0;ethis.addInterval(t)),this),this}reduce(t){if(t=n.stop?(this.intervals.splice(t+1,1),this.reduce(t)):e.stop>=n.start&&(this.intervals[t]=new _.Z(e.start,n.stop),this.intervals.splice(t+1,1))}}complement(t,e){const n=new E;return n.addInterval(new _.Z(t,e+1)),null!==this.intervals&&this.intervals.forEach((t=>n.removeRange(t))),n}contains(t){if(null===this.intervals)return!1;for(let e=0;en.start&&t.stop=n.stop?(this.intervals.splice(e,1),e-=1):t.start"):t.push("'"+String.fromCharCode(n.start)+"'"):t.push("'"+String.fromCharCode(n.start)+"'..'"+String.fromCharCode(n.stop-1)+"'")}return t.length>1?"{"+t.join(", ")+"}":t[0]}toIndexString(){const t=[];for(let e=0;e"):t.push(n.start.toString()):t.push(n.start.toString()+".."+(n.stop-1).toString())}return t.length>1?"{"+t.join(", ")+"}":t[0]}toTokenString(t,e){const n=[];for(let s=0;s1?"{"+n.join(", ")+"}":n[0]}elementName(t,e,n){return n===s.Z.EOF?"":n===s.Z.EPSILON?"":t[n]||e[n]}get length(){return this.intervals.map((t=>t.length)).reduce(((t,e)=>t+e))}}class S{constructor(){this.atn=null,this.stateNumber=S.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null}toString(){return this.stateNumber}equals(t){return t instanceof S&&this.stateNumber===t.stateNumber}isNonGreedyExitState(){return!1}addTransition(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)}}S.INVALID_TYPE=0,S.BASIC=1,S.RULE_START=2,S.BLOCK_START=3,S.PLUS_BLOCK_START=4,S.STAR_BLOCK_START=5,S.TOKEN_START=6,S.RULE_STOP=7,S.BLOCK_END=8,S.STAR_LOOP_BACK=9,S.STAR_LOOP_ENTRY=10,S.PLUS_LOOP_BACK=11,S.LOOP_END=12,S.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],S.INVALID_STATE_NUMBER=-1;class C extends S{constructor(){return super(),this.stateType=S.RULE_STOP,this}}class m{constructor(t){if(null==t)throw"target cannot be null.";this.target=t,this.isEpsilon=!1,this.label=null}}m.EPSILON=1,m.RANGE=2,m.RULE=3,m.PREDICATE=4,m.ATOM=5,m.ACTION=6,m.SET=7,m.NOT_SET=8,m.WILDCARD=9,m.PRECEDENCE=10,m.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],m.serializationTypes={EpsilonTransition:m.EPSILON,RangeTransition:m.RANGE,RuleTransition:m.RULE,PredicateTransition:m.PREDICATE,AtomTransition:m.ATOM,ActionTransition:m.ACTION,SetTransition:m.SET,NotSetTransition:m.NOT_SET,WildcardTransition:m.WILDCARD,PrecedencePredicateTransition:m.PRECEDENCE};class A extends m{constructor(t,e,n,s){super(t),this.ruleIndex=e,this.precedence=n,this.followState=s,this.serializationType=m.RULE,this.isEpsilon=!0}matches(t,e,n){return!1}}class L extends m{constructor(t,e){super(t),this.serializationType=m.SET,null!=e?this.label=e:(this.label=new E,this.label.addOne(s.Z.INVALID_TYPE))}matches(t,e,n){return this.label.contains(t)}toString(){return this.label.toString()}}class N extends L{constructor(t,e){super(t,e),this.serializationType=m.NOT_SET}matches(t,e,n){return t>=e&&t<=n&&!super.matches(t,e,n)}toString(){return"~"+super.toString()}}class R extends m{constructor(t){super(t),this.serializationType=m.WILDCARD}matches(t,e,n){return t>=e&&t<=n}toString(){return"."}}class y extends m{constructor(t){super(t)}}class I extends class extends class{}{}{}class v extends I{getRuleContext(){throw new Error("missing interface implementation")}}class O extends I{}class k extends O{}const b={toStringTree:function(t,e,n){e=e||null,null!==(n=n||null)&&(e=n.ruleNames);let s=b.getNodeText(t,e);s=function(t,e){return t=t.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(s);const i=t.getChildCount();if(0===i)return s;let r="("+s+" ";i>0&&(s=b.toStringTree(t.getChild(0),e),r=r.concat(s));for(let n=1;n=0&&e0&&(t+=", "),this.returnStates[e]!==D.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"}}get length(){return this.returnStates.length}}class F extends D{constructor(t,e){let n=0;const s=new r;null!==t?s.update(t,e):s.update(1),n=s.finish(),super(n),this.parentCtx=t,this.returnState=e}getParent(t){return this.parentCtx}getReturnState(t){return this.returnState}equals(t){return this===t||t instanceof F&&this.hashCode()===t.hashCode()&&this.returnState===t.returnState&&(null==this.parentCtx?null==t.parentCtx:this.parentCtx.equals(t.parentCtx))}toString(){const t=null===this.parentCtx?"":this.parentCtx.toString();return 0===t.length?this.returnState===D.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+t}get length(){return 1}static create(t,e){return e===D.EMPTY_RETURN_STATE&&null===t?D.EMPTY:new F(t,e)}}class U extends F{constructor(){super(null,D.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(t){return null}getReturnState(t){return this.returnState}equals(t){return this===t}toString(){return"$"}}D.EMPTY=new U;const M="h-";class B{constructor(t,e){this.data={},this.hashFunction=t||o,this.equalsFunction=e||l}set(t,e){const n=M+this.hashFunction(t);if(n in this.data){const s=this.data[n];for(let n=0;nt.startsWith(M))).flatMap((t=>this.data[t]),this)}getKeys(){return this.entries().map((t=>t.key))}getValues(){return this.entries().map((t=>t.value))}toString(){return"["+this.entries().map((t=>"{"+t.key+":"+t.value+"}")).join(", ")+"]"}get length(){return Object.keys(this.data).filter((t=>t.startsWith(M))).map((t=>this.data[t].length),this).reduce(((t,e)=>t+e),0)}}function H(t,e){if(null==e&&(e=w.EMPTY),null===e.parentCtx||e===w.EMPTY)return D.EMPTY;const n=H(t,e.parentCtx),s=t.states[e.invokingState].transitions[0];return F.create(n,s.followState.stateNumber)}function j(t,e,n){if(t.isEmpty())return t;let s=n.get(t)||null;if(null!==s)return s;if(s=e.get(t),null!==s)return n.set(t,s),s;let i=!1,r=[];for(let s=0;se.returnState&&(i[0]=e.returnState,i[1]=t.returnState);const r=new Z([n,n],i);return null!==s&&s.set(t,e,r),r}const i=[t.returnState,e.returnState];let r=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(i[0]=e.returnState,i[1]=t.returnState,r=[e.parentCtx,t.parentCtx]);const o=new Z(r,i);return null!==s&&s.set(t,e,o),o}}(t,e,n,s);if(n){if(t instanceof U)return t;if(e instanceof U)return e}return t instanceof F&&(t=new Z([t.getParent()],[t.returnState])),e instanceof F&&(e=new Z([e.getParent()],[e.returnState])),function(t,e,n,s){if(null!==s){let n=s.get(t,e);if(null!==n)return n;if(n=s.get(e,t),null!==n)return n}let i=0,r=0,o=0,l=[],a=[];for(;ithis.add(t)),this)}remove(t){delete this.data[t]}has(t){return!0===this.data[t]}values(){return Object.keys(this.data)}minValue(){return Math.min.apply(null,this.values())}hashCode(){return r.hashStuff(this.values())}equals(t){return t instanceof q&&i(this.data,t.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.values().length}}class X{constructor(t){this.atn=t}getDecisionLookahead(t){if(null===t)return null;const e=t.transitions.length,n=[];for(let s=0;s=this.states.length)throw"Invalid state number.";const n=this.states[t];let i=this.nextTokens(n);if(!i.contains(s.Z.EPSILON))return i;const r=new E;for(r.addSet(i),r.removeOne(s.Z.EPSILON);null!==e&&e.invokingState>=0&&i.contains(s.Z.EPSILON);){const t=this.states[e.invokingState].transitions[0];i=this.nextTokens(t.followState),r.addSet(i),r.removeOne(s.Z.EPSILON),e=e.parentCtx}return i.contains(s.Z.EPSILON)&&r.addOne(s.Z.EOF),r}}G.INVALID_ALT_NUMBER=0;class z extends S{constructor(){super(),this.stateType=S.BASIC}}class K extends S{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class Y extends K{constructor(){return super(),this.endState=null,this}}class W extends S{constructor(){return super(),this.stateType=S.BLOCK_END,this.startState=null,this}}class Q extends S{constructor(){return super(),this.stateType=S.LOOP_END,this.loopBackState=null,this}}class $ extends S{constructor(){return super(),this.stateType=S.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class J extends K{constructor(){return super(),this.stateType=S.TOKEN_START,this}}class tt extends K{constructor(){return super(),this.stateType=S.PLUS_LOOP_BACK,this}}class et extends S{constructor(){return super(),this.stateType=S.STAR_LOOP_BACK,this}}class nt extends K{constructor(){return super(),this.stateType=S.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class st extends Y{constructor(){return super(),this.stateType=S.PLUS_BLOCK_START,this.loopBackState=null,this}}class it extends Y{constructor(){return super(),this.stateType=S.STAR_BLOCK_START,this}}class rt extends Y{constructor(){return super(),this.stateType=S.BLOCK_START,this}}class ot extends m{constructor(t,e){super(t),this.label_=e,this.label=this.makeLabel(),this.serializationType=m.ATOM}makeLabel(){const t=new E;return t.addOne(this.label_),t}matches(t,e,n){return this.label_===t}toString(){return this.label_}}class lt extends m{constructor(t,e,n){super(t),this.serializationType=m.RANGE,this.start=e,this.stop=n,this.label=this.makeLabel()}makeLabel(){const t=new E;return t.addRange(this.start,this.stop),t}matches(t,e,n){return t>=this.start&&t<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}}class at extends m{constructor(t,e,n,s){super(t),this.serializationType=m.ACTION,this.ruleIndex=e,this.actionIndex=void 0===n?-1:n,this.isCtxDependent=void 0!==s&&s,this.isEpsilon=!0}matches(t,e,n){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}}class ht extends m{constructor(t,e){super(t),this.serializationType=m.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e}matches(t,e,n){return!1}toString(){return"epsilon"}}class ct extends d{constructor(t,e,n){super(),this.ruleIndex=void 0===t?-1:t,this.predIndex=void 0===e?-1:e,this.isCtxDependent=void 0!==n&&n}evaluate(t,e){const n=this.isCtxDependent?e:null;return t.sempred(n,this.ruleIndex,this.predIndex)}updateHashCode(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)}equals(t){return this===t||t instanceof ct&&this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}d.NONE=new ct;class ut extends y{constructor(t,e,n,s){super(t),this.serializationType=m.PREDICATE,this.ruleIndex=e,this.predIndex=n,this.isCtxDependent=s,this.isEpsilon=!0}matches(t,e,n){return!1}getPredicate(){return new ct(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class dt extends d{constructor(t){super(),this.precedence=void 0===t?0:t}evaluate(t,e){return t.precpred(e,this.precedence)}evalPrecedence(t,e){return t.precpred(e,this.precedence)?d.NONE:null}compareTo(t){return this.precedence-t.precedence}updateHashCode(t){t.update(this.precedence)}equals(t){return this===t||t instanceof dt&&this.precedence===t.precedence}toString(){return"{"+this.precedence+">=prec}?"}}d.PrecedencePredicate=dt;class pt extends y{constructor(t,e){super(t),this.serializationType=m.PRECEDENCE,this.precedence=e,this.isEpsilon=!0}matches(t,e,n){return!1}getPredicate(){return new dt(this.precedence)}toString(){return this.precedence+" >= _p"}}class ft{constructor(t){void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions}}ft.defaultOptions=new ft,ft.defaultOptions.readOnly=!0;class gt{constructor(t){this.actionType=t,this.isPositionDependent=!1}hashCode(){const t=new r;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.actionType)}equals(t){return this===t}}class xt extends gt{constructor(){super(6)}execute(t){t.skip()}toString(){return"skip"}}xt.INSTANCE=new xt;class Tt extends gt{constructor(t){super(0),this.channel=t}execute(t){t._channel=this.channel}updateHashCode(t){t.update(this.actionType,this.channel)}equals(t){return this===t||t instanceof Tt&&this.channel===t.channel}toString(){return"channel("+this.channel+")"}}class _t extends gt{constructor(t,e){super(1),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0}execute(t){t.action(null,this.ruleIndex,this.actionIndex)}updateHashCode(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)}equals(t){return this===t||t instanceof _t&&this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex}}class Et extends gt{constructor(){super(3)}execute(t){t.more()}toString(){return"more"}}Et.INSTANCE=new Et;class St extends gt{constructor(t){super(7),this.type=t}execute(t){t.type=this.type}updateHashCode(t){t.update(this.actionType,this.type)}equals(t){return this===t||t instanceof St&&this.type===t.type}toString(){return"type("+this.type+")"}}class Ct extends gt{constructor(t){super(5),this.mode=t}execute(t){t.pushMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof Ct&&this.mode===t.mode}toString(){return"pushMode("+this.mode+")"}}class mt extends gt{constructor(){super(4)}execute(t){t.popMode()}toString(){return"popMode"}}mt.INSTANCE=new mt;class At extends gt{constructor(t){super(2),this.mode=t}execute(t){t.mode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof At&&this.mode===t.mode}toString(){return"mode("+this.mode+")"}}function Lt(t,e){const n=[];return n[t-1]=e,n.map((function(t){return e}))}class Nt{constructor(t){null==t&&(t=ft.defaultOptions),this.deserializationOptions=t,this.stateFactories=null,this.actionFactories=null}deserialize(t){const e=this.reset(t);this.checkVersion(e),e&&this.skipUUID();const n=this.readATN();this.readStates(n,e),this.readRules(n,e),this.readModes(n);const s=[];return this.readSets(n,s,this.readInt.bind(this)),e&&this.readSets(n,s,this.readInt32.bind(this)),this.readEdges(n,s),this.readDecisions(n),this.readLexerActions(n,e),this.markPrecedenceDecisions(n),this.verifyATN(n),this.deserializationOptions.generateRuleBypassTransitions&&1===n.grammarType&&(this.generateRuleBypassTransitions(n),this.verifyATN(n)),n}reset(t){if(3===(t.charCodeAt?t.charCodeAt(0):t[0])){const e=function(t){const e=t.charCodeAt(0);return e>1?e-2:e+65534},n=t.split("").map(e);return n[0]=t.charCodeAt(0),this.data=n,this.pos=0,!0}return this.data=t,this.pos=0,!1}skipUUID(){let t=0;for(;t++<8;)this.readInt()}checkVersion(t){const e=this.readInt();if(!t&&4!==e)throw"Could not deserialize ATN with version "+e+" (expected 4)."}readATN(){const t=this.readInt(),e=this.readInt();return new G(t,e)}readStates(t,e){let n,s,i;const r=[],o=[],l=this.readInt();for(let n=0;n0;)i.addTransition(a.transitions[h-1]),a.transitions=a.transitions.slice(-1);t.ruleToStartState[e].addTransition(new ht(i)),r.addTransition(new ht(l));const c=new z;t.addState(c),c.addTransition(new ot(r,t.ruleToTokenType[e])),i.addTransition(new ht(c))}stateIsEndStateFor(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof nt))return null;const n=t.transitions[t.transitions.length-1].target;return n instanceof Q&&n.epsilonOnlyTransitions&&n.transitions[0].target instanceof C?t:null}markPrecedenceDecisions(t){for(let e=0;e=0):this.checkCondition(n.transitions.length<=1||n instanceof C)}}checkCondition(t,e){if(!t)throw null==e&&(e="IllegalState"),e}readInt(){return this.data[this.pos++]}readInt32(){return this.readInt()|this.readInt()<<16}edgeFactory(t,e,n,i,r,o,l,a){const h=t.states[i];switch(e){case m.EPSILON:return new ht(h);case m.RANGE:return new lt(h,0!==l?s.Z.EOF:r,o);case m.RULE:return new A(t.states[r],o,l,h);case m.PREDICATE:return new ut(h,r,o,0!==l);case m.PRECEDENCE:return new pt(h,r);case m.ATOM:return new ot(h,0!==l?s.Z.EOF:r);case m.ACTION:return new at(h,r,o,0!==l);case m.SET:return new L(h,a[r]);case m.NOT_SET:return new N(h,a[r]);case m.WILDCARD:return new R(h);default:throw"The specified transition type: "+e+" is not valid."}}stateFactory(t,e){if(null===this.stateFactories){const t=[];t[S.INVALID_TYPE]=null,t[S.BASIC]=()=>new z,t[S.RULE_START]=()=>new $,t[S.BLOCK_START]=()=>new rt,t[S.PLUS_BLOCK_START]=()=>new st,t[S.STAR_BLOCK_START]=()=>new it,t[S.TOKEN_START]=()=>new J,t[S.RULE_STOP]=()=>new C,t[S.BLOCK_END]=()=>new W,t[S.STAR_LOOP_BACK]=()=>new et,t[S.STAR_LOOP_ENTRY]=()=>new nt,t[S.PLUS_LOOP_BACK]=()=>new tt,t[S.LOOP_END]=()=>new Q,this.stateFactories=t}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";{const n=this.stateFactories[t]();if(null!==n)return n.ruleIndex=e,n}}lexerActionFactory(t,e,n){if(null===this.actionFactories){const t=[];t[0]=(t,e)=>new Tt(t),t[1]=(t,e)=>new _t(t,e),t[2]=(t,e)=>new At(t),t[3]=(t,e)=>Et.INSTANCE,t[4]=(t,e)=>mt.INSTANCE,t[5]=(t,e)=>new Ct(t),t[6]=(t,e)=>xt.INSTANCE,t[7]=(t,e)=>new St(t),this.actionFactories=t}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,n)}}var Rt=n(517);function yt(t){return t.hashCodeForConfigSet()}function It(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}class vt{constructor(t){this.configLookup=new u(yt,It),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1}add(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==d.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);const n=this.configLookup.add(t);if(n===t)return this.cachedHashCode=-1,this.configs.push(t),!0;const s=!this.fullCtx,i=V(n.context,t.context,s,e);return n.reachesIntoOuterContext=Math.max(n.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(n.precedenceFilterSuppressed=!0),n.context=i,!0}getStates(){const t=new u;for(let e=0;eMt.MAX_DFA_EDGE)return null;let n=t.edges[e-Mt.MIN_DFA_EDGE];return void 0===n&&(n=null),Mt.debug&&null!==n&&console.log("reuse state "+t.stateNumber+" edge to "+n.stateNumber),n}computeTargetState(t,e,n){const s=new bt;return this.getReachableConfigSet(t,e.configs,s,n),0===s.items.length?(s.hasSemanticContext||this.addDFAEdge(e,n,kt.ERROR),kt.ERROR):this.addDFAEdge(e,n,null,s)}failOrAccept(t,e,n,i){if(null!==this.prevAccept.dfaState){const n=t.dfaState.lexerActionExecutor;return this.accept(e,n,this.startIndex,t.index,t.line,t.column),t.dfaState.prediction}if(i===s.Z.EOF&&e.index===this.startIndex)return s.Z.EOF;throw new Zt.Z(this.recog,e,this.startIndex,n)}getReachableConfigSet(t,e,n,i){let r=G.INVALID_ALT_NUMBER;for(let o=0;oMt.MAX_DFA_EDGE||(Mt.debug&&console.log("EDGE "+t+" -> "+n+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-Mt.MIN_DFA_EDGE]=n),n}addDFAState(t){const e=new Ot(null,t);let n=null;for(let e=0;et.startsWith("k-"))).map((t=>this.data[t]),this)}}const jt={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(t,e){if(jt.allConfigsInRuleStopStates(e))return!0;if(t===jt.SLL&&e.hasSemanticContext){const t=new vt;for(let n=0;n1)return!0;return!1},allSubsetsEqual:function(t){let e=null;for(let n=0;n0&&(r=this.getAltThatFinishedDecisionEntryRule(i),r!==G.INVALID_ALT_NUMBER)?r:G.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(t){const e=[];for(let n=0;n0||s.state instanceof C&&s.context.hasEmptyPath())&&e.indexOf(s.alt)<0&&e.push(s.alt)}return 0===e.length?G.INVALID_ALT_NUMBER:Math.min.apply(null,e)}splitAccordingToSemanticValidity(t,e){const n=new vt(t.fullCtx),s=new vt(t.fullCtx);for(let i=0;i50))throw"problem";if(t.state instanceof C){if(!t.context.isEmpty()){for(let l=0;l=0&&(s+=1)}this.closureCheckingStopState(u,e,n,c,i,s,o)}}}canDropLoopEntryEdgeInLeftRecursiveRule(t){const e=t.state;if(e.stateType!==S.STAR_LOOP_ENTRY)return!1;if(e.stateType!==S.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;const n=t.context.length;for(let s=0;s=0?this.parser.ruleNames[t]:""}getEpsilonTarget(t,e,n,i,r,o){switch(e.serializationType){case m.RULE:return this.ruleTransition(t,e);case m.PRECEDENCE:return this.precedenceTransition(t,e,n,i,r);case m.PREDICATE:return this.predTransition(t,e,n,i,r);case m.ACTION:return this.actionTransition(t,e);case m.EPSILON:return new T({state:e.target},t);case m.ATOM:case m.RANGE:case m.SET:return o&&e.matches(s.Z.EOF,0,1)?new T({state:e.target},t):null;default:return null}}actionTransition(t,e){if(this.debug){const t=-1===e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+t)}return new T({state:e.target},t)}precedenceTransition(t,e,n,s,i){this.debug&&(console.log("PRED (collectPredicates="+n+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+h(this.parser.getRuleInvocationStack())));let r=null;if(n&&s)if(i){const n=this._input.index;this._input.seek(this._startIndex);const s=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(n),s&&(r=new T({state:e.target},t))}else{const n=d.andContext(t.semanticContext,e.getPredicate());r=new T({state:e.target,semanticContext:n},t)}else r=new T({state:e.target},t);return this.debug&&console.log("config from pred transition="+r),r}predTransition(t,e,n,s,i){this.debug&&(console.log("PRED (collectPredicates="+n+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+h(this.parser.getRuleInvocationStack())));let r=null;if(n&&(e.isCtxDependent&&s||!e.isCtxDependent))if(i){const n=this._input.index;this._input.seek(this._startIndex);const s=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(n),s&&(r=new T({state:e.target},t))}else{const n=d.andContext(t.semanticContext,e.getPredicate());r=new T({state:e.target,semanticContext:n},t)}else r=new T({state:e.target},t);return this.debug&&console.log("config from pred transition="+r),r}ruleTransition(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);const n=e.followState,s=F.create(t.context,n.stateNumber);return new T({state:e.target,context:s},t)}getConflictingAlts(t){const e=Vt.getConflictingAltSubsets(t);return Vt.getAlts(e)}getConflictingAltsOrUniqueAlt(t){let e=null;return t.uniqueAlt!==G.INVALID_ALT_NUMBER?(e=new q,e.add(t.uniqueAlt)):e=t.conflictingAlts,e}getTokenName(t){if(t===s.Z.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(t>=this.parser.literalNames.length&&t>=this.parser.symbolicNames.length))return(this.parser.literalNames[t]||this.parser.symbolicNames[t])+"<"+t+">";console.log(t+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+t}getLookaheadName(t){return this.getTokenName(t.LA(1))}dumpDeadEndConfigs(t){console.log("dead end configs: ");const e=t.getDeadEndConfigs();for(let t=0;t0){const t=n.state.transitions[0];t instanceof ot?s="Atom "+this.getTokenName(t.label):t instanceof L&&(s=(t instanceof N?"~":"")+"Set "+t.set)}console.error(n.toString(this.parser,!0)+":"+s)}}noViableAlt(t,e,n,s){return new Xt(this.parser,t,t.get(s),t.LT(1),n,e)}getUniqueAlt(t){let e=G.INVALID_ALT_NUMBER;for(let n=0;n "+s+" upon "+this.getTokenName(n)),null===s)return null;if(s=this.addDFAState(t,s),null===e||n<-1||n>this.atn.maxTokenType)return s;if(null===e.edges&&(e.edges=[]),e.edges[n+1]=s,this.debug){const e=null===this.parser?null:this.parser.literalNames,n=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(e,n))}return s}addDFAState(t,e){if(e===kt.ERROR)return e;const n=t.states.get(e);return null!==n?n:(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)}reportAttemptingFullContext(t,e,n,s,i){if(this.debug||this.retry_debug){const e=new _.Z(s,i+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+n+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser,t,s,i,e,n)}reportContextSensitivity(t,e,n,s,i){if(this.debug||this.retry_debug){const e=new _.Z(s,i+1);console.log("reportContextSensitivity decision="+t.decision+":"+n+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser,t,s,i,e,n)}reportAmbiguity(t,e,n,s,i,r,o){if(this.debug||this.retry_debug){const t=new _.Z(n,s+1);console.log("reportAmbiguity "+r+":"+o+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser,t,n,s,i,r,o)}},PredictionMode:Vt};class Kt{constructor(t,e,n){this.dfa=t,this.literalNames=e||[],this.symbolicNames=n||[]}toString(){if(null===this.dfa.s0)return null;let t="";const e=this.dfa.sortedStates();for(let n=0;n"),t=t.concat(this.getStateString(e)),t=t.concat("\n"))}}}return 0===t.length?null:t}getEdgeLabel(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)}getStateString(t){const e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+h(t.predicates):e+"=>"+t.prediction.toString():e}}class Yt extends Kt{constructor(t){super(t,null)}getEdgeLabel(t){return"'"+String.fromCharCode(t)+"'"}}const Wt={DFA:class{constructor(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new u,this.s0=null,this.precedenceDfa=!1,t instanceof nt&&t.isPrecedenceDecision){this.precedenceDfa=!0;const t=new Ot(null,new vt);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}}getPrecedenceStartState(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null}setPrecedenceStartState(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)}setPrecedenceDfa(t){if(this.precedenceDfa!==t){if(this._states=new u,t){const t=new Ot(null,new vt);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}else this.s0=null;this.precedenceDfa=t}}sortedStates(){return this._states.values().sort((function(t,e){return t.stateNumber-e.stateNumber}))}toString(t,e){return t=t||null,e=e||null,null===this.s0?"":new Kt(this,t,e).toString()}toLexerString(){return null===this.s0?"":new Yt(this).toString()}get states(){return this._states}},DFASerializer:Kt,LexerDFASerializer:Yt,PredPrediction:Bt};class Qt{visitTerminal(t){}visitErrorNode(t){}enterEveryRule(t){}exitEveryRule(t){}}class $t{walk(t,e){if(e instanceof k||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof O)t.visitTerminal(e);else{this.enterRule(t,e);for(let n=0;n=i.length)return""+n;const r=i[s]||null;return null===r||0===r.length?""+n:`${n} (${r})`}getConflictingAlts(t,e){if(null!==t)return t;const n=new q;for(let t=0;t=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);const n=this.getErrorRecoverySet(t);this.consumeUntil(t,n)}sync(t){if(this.inErrorRecoveryMode(t))return;const e=t._interp.atn.states[t.state],n=t.getTokenStream().LA(1),i=t.atn.nextTokens(e);if(i.contains(n))return this.nextTokensContext=null,void(this.nextTokenState=S.INVALID_STATE_NUMBER);if(i.contains(s.Z.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=t._ctx,this.nextTokensState=t._stateNumber);else switch(e.stateType){case S.BLOCK_START:case S.STAR_BLOCK_START:case S.PLUS_BLOCK_START:case S.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(t))return;throw new te(t);case S.PLUS_LOOP_BACK:case S.STAR_LOOP_BACK:{this.reportUnwantedToken(t);const e=new E;e.addSet(t.getExpectedTokens());const n=e.addSet(this.getErrorRecoverySet(t));this.consumeUntil(t,n)}}}reportNoViableAlternative(t,e){const n=t.getTokenStream();let i;i=null!==n?e.startToken.type===s.Z.EOF?"":n.getText(new _.Z(e.startToken.tokenIndex,e.offendingToken.tokenIndex)):"";const r="no viable alternative at input "+this.escapeWSAndQuote(i);t.notifyErrorListeners(r,e.offendingToken,e)}reportInputMismatch(t,e){const n="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(n,e.offendingToken,e)}reportFailedPredicate(t,e){const n="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(n,e.offendingToken,e)}reportUnwantedToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),n="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(n,e,null)}reportMissingToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),n="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(n,e,null)}recoverInline(t){const e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new te(t)}singleTokenInsertion(t){const e=t.getTokenStream().LA(1),n=t._interp.atn,s=n.states[t.state].transitions[0].target;return!!n.nextTokens(s,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)}singleTokenDeletion(t){const e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();const e=t.getCurrentToken();return this.reportMatch(t),e}return null}getMissingSymbol(t){const e=t.getCurrentToken(),n=this.getExpectedTokens(t).first();let i;i=n===s.Z.EOF?"":"";let r=e;const o=t.getTokenStream().LT(-1);return r.type===s.Z.EOF&&null!==o&&(r=o),t.getTokenFactory().create(r.source,n,i,s.Z.DEFAULT_CHANNEL,-1,-1,r.line,r.column)}getExpectedTokens(t){return t.getExpectedTokens()}getTokenErrorDisplay(t){if(null===t)return"";let e=t.text;return null===e&&(e=t.type===s.Z.EOF?"":"<"+t.type+">"),this.escapeWSAndQuote(e)}escapeWSAndQuote(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"}getErrorRecoverySet(t){const e=t._interp.atn;let n=t._ctx;const i=new E;for(;null!==n&&n.invokingState>=0;){const t=e.states[n.invokingState].transitions[0],s=e.nextTokens(t.followState);i.addSet(s),n=n.parentCtx}return i.removeOne(s.Z.EPSILON),i}consumeUntil(t,e){let n=t.getTokenStream().LA(1);for(;n!==s.Z.EOF&&!e.contains(n);)t.consume(),n=t.getTokenStream().LA(1)}}const le={RecognitionException:qt.Z,NoViableAltException:Xt,LexerNoViableAltException:Zt.Z,InputMismatchException:te,FailedPredicateException:ee,DiagnosticErrorListener:ie,BailErrorStrategy:class extends oe{constructor(){super()}recover(t,e){let n=t._ctx;for(;null!==n;)n.exception=e,n=n.parentCtx;throw new re(e)}recoverInline(t){this.recover(t,new te(t))}sync(t){}},DefaultErrorStrategy:oe,ErrorListener:se.Z};var ae=n(790),he=n(166),ce=n(262);const ue={fromString:function(t){return new he.Z(t,!0)},fromBlob:function(t,e,n,s){const i=new window.FileReader;i.onload=function(t){const e=new he.Z(t.target.result,!0);n(e)},i.onerror=s,i.readAsText(t,e)},fromBuffer:function(t,e){return new he.Z(t.toString(e),!0)},fromPath:function(t,e,n){ce.readFile(t,e,(function(t,e){let s=null;null!==e&&(s=new he.Z(e,!0)),n(t,s)}))},fromPathSync:function(t,e){const n=ce.readFileSync(t,e);return new he.Z(n,!0)}};class de extends he.Z{constructor(t,e){super(ce.readFileSync(t,"utf8"),e),this.fileName=t}}var pe=n(477),fe=n(597);class ge extends Qt{constructor(t){super(),this.parser=t}enterEveryRule(t){console.log("enter "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}visitTerminal(t){console.log("consume "+t.symbol+" rule "+this.parser.ruleNames[this.parser._ctx.ruleIndex])}exitEveryRule(t){console.log("exit "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}}class xe extends fe.Z{constructor(t){super(),this._input=null,this._errHandler=new oe,this._precedenceStack=[],this._precedenceStack.push(0),this._ctx=null,this.buildParseTrees=!0,this._tracer=null,this._parseListeners=null,this._syntaxErrors=0,this.setInputStream(t)}reset(){null!==this._input&&this._input.seek(0),this._errHandler.reset(this),this._ctx=null,this._syntaxErrors=0,this.setTrace(!1),this._precedenceStack=[],this._precedenceStack.push(0),null!==this._interp&&this._interp.reset()}match(t){let e=this.getCurrentToken();return e.type===t?(this._errHandler.reportMatch(this),this.consume()):(e=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===e.tokenIndex&&this._ctx.addErrorNode(e)),e}matchWildcard(){let t=this.getCurrentToken();return t.type>0?(this._errHandler.reportMatch(this),this.consume()):(t=this._errHandler.recoverInline(this),this._buildParseTrees&&-1===t.tokenIndex&&this._ctx.addErrorNode(t)),t}getParseListeners(){return this._parseListeners||[]}addParseListener(t){if(null===t)throw"listener";null===this._parseListeners&&(this._parseListeners=[]),this._parseListeners.push(t)}removeParseListener(t){if(null!==this._parseListeners){const e=this._parseListeners.indexOf(t);e>=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}}removeParseListeners(){this._parseListeners=null}triggerEnterRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.forEach((function(e){e.enterEveryRule(t),t.enterRule(e)}))}}triggerExitRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.slice(0).reverse().forEach((function(e){t.exitRule(e),e.exitEveryRule(t)}))}}getTokenFactory(){return this._input.tokenSource._factory}setTokenFactory(t){this._input.tokenSource._factory=t}getATNWithBypassAlts(){const t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";let e=this.bypassAltsAtnCache[t];if(null===e){const n=new ft;n.generateRuleBypassTransitions=!0,e=new Nt(n).deserialize(t),this.bypassAltsAtnCache[t]=e}return e}getInputStream(){return this.getTokenStream()}setInputStream(t){this.setTokenStream(t)}getTokenStream(){return this._input}setTokenStream(t){this._input=null,this.reset(),this._input=t}getCurrentToken(){return this._input.LT(1)}notifyErrorListeners(t,e,n){n=n||null,null===(e=e||null)&&(e=this.getCurrentToken()),this._syntaxErrors+=1;const s=e.line,i=e.column;this.getErrorListenerDispatch().syntaxError(this,e,s,i,t,n)}consume(){const t=this.getCurrentToken();t.type!==s.Z.EOF&&this.getInputStream().consume();const e=null!==this._parseListeners&&this._parseListeners.length>0;if(this.buildParseTrees||e){let n;n=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(t):this._ctx.addTokenNode(t),n.invokingState=this.state,e&&this._parseListeners.forEach((function(t){n instanceof k||void 0!==n.isErrorNode&&n.isErrorNode()?t.visitErrorNode(n):n instanceof O&&t.visitTerminal(n)}))}return t}addContextToParseTree(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)}enterRule(t,e,n){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this._ctx.stop=this._input.LT(-1),this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx}enterOuterAlt(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t}getPrecedence(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]}enterRecursionRule(t,e,n,s){this.state=e,this._precedenceStack.push(s),this._ctx=t,this._ctx.start=this._input.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(t,e,n){const s=this._ctx;s.parentCtx=t,s.invokingState=e,s.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=s.start,this.buildParseTrees&&this._ctx.addChild(s),this.triggerEnterRuleEvent()}unrollRecursionContexts(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);const e=this._ctx,n=this.getParseListeners();if(null!==n&&n.length>0)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)}getInvokingContext(t){let e=this._ctx;for(;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null}precpred(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]}inContext(t){return!1}isExpectedToken(t){const e=this._interp.atn;let n=this._ctx;const i=e.states[this.state];let r=e.nextTokens(i);if(r.contains(t))return!0;if(!r.contains(s.Z.EPSILON))return!1;for(;null!==n&&n.invokingState>=0&&r.contains(s.Z.EPSILON);){const s=e.states[n.invokingState].transitions[0];if(r=e.nextTokens(s.followState),r.contains(t))return!0;n=n.parentCtx}return!(!r.contains(s.Z.EPSILON)||t!==s.Z.EOF)}getExpectedTokens(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)}getExpectedTokensWithinCurrentRule(){const t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)}getRuleIndex(t){const e=this.getRuleIndexMap()[t];return null!==e?e:-1}getRuleInvocationStack(t){null===(t=t||null)&&(t=this._ctx);const e=[];for(;null!==t;){const n=t.ruleIndex;n<0?e.push("n/a"):e.push(this.ruleNames[n]),t=t.parentCtx}return e}getDFAStrings(){return this._interp.decisionToDFA.toString()}dumpDFA(){let t=!1;for(let e=0;e0&&(t&&console.log(),this.printer.println("Decision "+n.decision+":"),this.printer.print(n.toString(this.literalNames,this.symbolicNames)),t=!0)}}getSourceName(){return this._input.sourceName}setTrace(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new ge(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}xe.bypassAltsAtnCache={};class Te extends O{constructor(t){super(),this.parentCtx=null,this.symbol=t}getChild(t){return null}getSymbol(){return this.symbol}getParent(){return this.parentCtx}getPayload(){return this.symbol}getSourceInterval(){if(null===this.symbol)return _.Z.INVALID_INTERVAL;const t=this.symbol.tokenIndex;return new _.Z(t,t)}getChildCount(){return 0}accept(t){return t.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===s.Z.EOF?"":this.symbol.text}}class _e extends Te{constructor(t){super(t)}isErrorNode(){return!0}accept(t){return t.visitErrorNode(this)}}class Ee extends w{constructor(t,e){super(t=t||null,e=e||null),this.ruleIndex=-1,this.children=null,this.start=null,this.stop=null,this.exception=null}copyFrom(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map((function(t){t instanceof _e&&(this.children.push(t),t.parentCtx=this)}),this))}enterRule(t){}exitRule(t){}addChild(t){return null===this.children&&(this.children=[]),this.children.push(t),t}removeLastChild(){null!==this.children&&this.children.pop()}addTokenNode(t){const e=new Te(t);return this.addChild(e),e.parentCtx=this,e}addErrorNode(t){const e=new _e(t);return this.addChild(e),e.parentCtx=this,e}getChild(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(let n=0;n=this.children.length)return null;for(let n=0;n{"use strict";n.d(e,{Z:()=>s});class s{constructor(t,e){this.start=t,this.stop=e}clone(){return new s(this.start,this.stop)}contains(t){return t>=this.start&&t{"use strict";String.prototype.codePointAt||function(){var t=function(){let t;try{const e={},n=Object.defineProperty;t=n(e,e,e)&&n}catch(t){}return t}();const e=function(t){if(null==this)throw TypeError();const e=String(this),n=e.length;let s=t?Number(t):0;if(s!=s&&(s=0),s<0||s>=n)return;const i=e.charCodeAt(s);let r;return i>=55296&&i<=56319&&n>s+1&&(r=e.charCodeAt(s+1),r>=56320&&r<=57343)?1024*(i-55296)+r-56320+65536:i};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}()},545:()=>{"use strict";String.fromCodePoint||function(){const t=function(){let t;try{const e={},n=Object.defineProperty;t=n(e,e,e)&&n}catch(t){}return t}(),e=String.fromCharCode,n=Math.floor,s=function(t){const s=16384,i=[];let r,o,l=-1;const a=arguments.length;if(!a)return"";let h="";for(;++l1114111||n(t)!==t)throw RangeError("Invalid code point: "+t);t<=65535?i.push(t):(t-=65536,r=55296+(t>>10),o=t%1024+56320,i.push(r,o)),(l+1===a||i.length>s)&&(h+=e.apply(null,i),i.length=0)}return h};t?t(String,"fromCodePoint",{value:s,configurable:!0,writable:!0}):String.fromCodePoint=s}()}},e={};function n(s){var i=e[s];if(void 0!==i)return i.exports;var r=e[s]={exports:{}};return t[s](r,r.exports,n),r.exports}n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{"use strict";n.r(s);var t=n(166),e=n(477),i=n(470);const r=(new i.Z.atn.ATNDeserializer).deserialize([4,0,46,456,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,12,1,13,1,13,5,13,135,8,13,10,13,12,13,138,9,13,1,13,1,13,1,14,1,14,1,14,3,14,145,8,14,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,3,15,156,8,15,1,16,1,16,1,16,1,16,3,16,162,8,16,1,17,1,17,3,17,166,8,17,1,18,1,18,1,18,5,18,171,8,18,10,18,12,18,174,9,18,1,18,1,18,1,19,3,19,179,8,19,1,19,1,19,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,3,21,191,8,21,1,21,1,21,5,21,195,8,21,10,21,12,21,198,9,21,1,21,3,21,201,8,21,1,22,1,22,4,22,205,8,22,11,22,12,22,206,1,22,1,22,4,22,211,8,22,11,22,12,22,212,5,22,215,8,22,10,22,12,22,218,9,22,1,23,3,23,221,8,23,1,23,4,23,224,8,23,11,23,12,23,225,1,24,3,24,229,8,24,1,24,5,24,232,8,24,10,24,12,24,235,9,24,1,24,1,24,4,24,239,8,24,11,24,12,24,240,1,25,3,25,244,8,25,1,25,4,25,247,8,25,11,25,12,25,248,1,25,1,25,5,25,253,8,25,10,25,12,25,256,9,25,1,25,1,25,1,25,4,25,261,8,25,11,25,12,25,262,1,25,1,25,4,25,267,8,25,11,25,12,25,268,1,25,3,25,272,8,25,1,26,1,26,3,26,276,8,26,1,26,4,26,279,8,26,11,26,12,26,280,1,27,1,27,1,27,1,27,1,27,1,27,1,27,3,27,290,8,27,1,27,1,27,1,27,3,27,295,8,27,5,27,297,8,27,10,27,12,27,300,9,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,3,28,313,8,28,1,28,1,28,1,28,3,28,318,8,28,5,28,320,8,28,10,28,12,28,323,9,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,5,29,333,8,29,10,29,12,29,336,9,29,1,29,1,29,1,30,1,30,1,30,1,30,5,30,344,8,30,10,30,12,30,347,9,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,3,31,371,8,31,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,34,1,34,5,34,382,8,34,10,34,12,34,385,9,34,1,34,1,34,1,35,3,35,390,8,35,1,36,1,36,3,36,394,8,36,1,37,1,37,3,37,398,8,37,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40,5,40,415,8,40,10,40,12,40,418,9,40,1,40,3,40,421,8,40,1,41,1,41,1,41,3,41,426,8,41,1,41,1,41,1,41,5,41,431,8,41,10,41,12,41,434,9,41,1,41,1,41,1,41,3,41,439,8,41,3,41,441,8,41,1,42,1,42,3,42,445,8,42,1,43,1,43,1,43,1,43,1,44,3,44,452,8,44,1,45,1,45,1,45,0,0,46,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,1,0,26,2,0,10,10,13,13,8,0,0,32,34,34,60,60,62,62,92,92,94,94,96,96,123,125,1,0,48,57,2,0,65,90,97,122,3,0,48,57,65,90,97,122,2,0,43,43,45,45,2,0,69,69,101,101,2,0,39,39,92,92,2,0,34,34,92,92,4,0,10,10,13,13,34,34,92,92,4,0,10,10,13,13,39,39,92,92,8,0,34,34,39,39,92,92,98,98,102,102,110,110,114,114,116,116,3,0,9,10,13,13,32,32,13,0,65,90,97,122,192,214,216,246,248,767,880,893,895,8191,8204,8205,8304,8591,11264,12271,12289,55295,63744,64975,65008,65533,5,0,45,45,48,57,183,183,768,879,8255,8256,2,0,66,66,98,98,2,0,65,65,97,97,2,0,83,83,115,115,2,0,80,80,112,112,2,0,82,82,114,114,2,0,70,70,102,102,2,0,73,73,105,105,2,0,88,88,120,120,2,0,46,46,58,58,3,0,48,57,65,70,97,102,7,0,33,33,35,47,59,59,61,61,63,64,95,95,126,126,519,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,1,93,1,0,0,0,3,95,1,0,0,0,5,103,1,0,0,0,7,109,1,0,0,0,9,111,1,0,0,0,11,113,1,0,0,0,13,115,1,0,0,0,15,118,1,0,0,0,17,121,1,0,0,0,19,123,1,0,0,0,21,125,1,0,0,0,23,127,1,0,0,0,25,129,1,0,0,0,27,132,1,0,0,0,29,144,1,0,0,0,31,155,1,0,0,0,33,161,1,0,0,0,35,165,1,0,0,0,37,167,1,0,0,0,39,178,1,0,0,0,41,182,1,0,0,0,43,185,1,0,0,0,45,202,1,0,0,0,47,220,1,0,0,0,49,228,1,0,0,0,51,243,1,0,0,0,53,273,1,0,0,0,55,282,1,0,0,0,57,305,1,0,0,0,59,328,1,0,0,0,61,339,1,0,0,0,63,370,1,0,0,0,65,372,1,0,0,0,67,375,1,0,0,0,69,379,1,0,0,0,71,389,1,0,0,0,73,393,1,0,0,0,75,397,1,0,0,0,77,399,1,0,0,0,79,404,1,0,0,0,81,411,1,0,0,0,83,425,1,0,0,0,85,444,1,0,0,0,87,446,1,0,0,0,89,451,1,0,0,0,91,453,1,0,0,0,93,94,5,46,0,0,94,2,1,0,0,0,95,96,5,64,0,0,96,97,5,112,0,0,97,98,5,114,0,0,98,99,5,101,0,0,99,100,5,102,0,0,100,101,5,105,0,0,101,102,5,120,0,0,102,4,1,0,0,0,103,104,5,64,0,0,104,105,5,98,0,0,105,106,5,97,0,0,106,107,5,115,0,0,107,108,5,101,0,0,108,6,1,0,0,0,109,110,5,59,0,0,110,8,1,0,0,0,111,112,5,44,0,0,112,10,1,0,0,0,113,114,5,97,0,0,114,12,1,0,0,0,115,116,5,60,0,0,116,117,5,60,0,0,117,14,1,0,0,0,118,119,5,62,0,0,119,120,5,62,0,0,120,16,1,0,0,0,121,122,5,91,0,0,122,18,1,0,0,0,123,124,5,93,0,0,124,20,1,0,0,0,125,126,5,40,0,0,126,22,1,0,0,0,127,128,5,41,0,0,128,24,1,0,0,0,129,130,5,94,0,0,130,131,5,94,0,0,131,26,1,0,0,0,132,136,5,35,0,0,133,135,8,0,0,0,134,133,1,0,0,0,135,138,1,0,0,0,136,134,1,0,0,0,136,137,1,0,0,0,137,139,1,0,0,0,138,136,1,0,0,0,139,140,6,13,0,0,140,28,1,0,0,0,141,145,3,47,23,0,142,145,3,49,24,0,143,145,3,51,25,0,144,141,1,0,0,0,144,142,1,0,0,0,144,143,1,0,0,0,145,30,1,0,0,0,146,147,5,116,0,0,147,148,5,114,0,0,148,149,5,117,0,0,149,156,5,101,0,0,150,151,5,102,0,0,151,152,5,97,0,0,152,153,5,108,0,0,153,154,5,115,0,0,154,156,5,101,0,0,155,146,1,0,0,0,155,150,1,0,0,0,156,32,1,0,0,0,157,162,3,59,29,0,158,162,3,61,30,0,159,162,3,55,27,0,160,162,3,57,28,0,161,157,1,0,0,0,161,158,1,0,0,0,161,159,1,0,0,0,161,160,1,0,0,0,162,34,1,0,0,0,163,166,3,43,21,0,164,166,3,69,34,0,165,163,1,0,0,0,165,164,1,0,0,0,166,36,1,0,0,0,167,172,5,60,0,0,168,171,8,1,0,0,169,171,3,63,31,0,170,168,1,0,0,0,170,169,1,0,0,0,171,174,1,0,0,0,172,170,1,0,0,0,172,173,1,0,0,0,173,175,1,0,0,0,174,172,1,0,0,0,175,176,5,62,0,0,176,38,1,0,0,0,177,179,3,81,40,0,178,177,1,0,0,0,178,179,1,0,0,0,179,180,1,0,0,0,180,181,5,58,0,0,181,40,1,0,0,0,182,183,3,39,19,0,183,184,3,83,41,0,184,42,1,0,0,0,185,186,5,95,0,0,186,187,5,58,0,0,187,190,1,0,0,0,188,191,3,73,36,0,189,191,7,2,0,0,190,188,1,0,0,0,190,189,1,0,0,0,191,200,1,0,0,0,192,195,3,75,37,0,193,195,5,46,0,0,194,192,1,0,0,0,194,193,1,0,0,0,195,198,1,0,0,0,196,194,1,0,0,0,196,197,1,0,0,0,197,199,1,0,0,0,198,196,1,0,0,0,199,201,3,75,37,0,200,196,1,0,0,0,200,201,1,0,0,0,201,44,1,0,0,0,202,204,5,64,0,0,203,205,7,3,0,0,204,203,1,0,0,0,205,206,1,0,0,0,206,204,1,0,0,0,206,207,1,0,0,0,207,216,1,0,0,0,208,210,5,45,0,0,209,211,7,4,0,0,210,209,1,0,0,0,211,212,1,0,0,0,212,210,1,0,0,0,212,213,1,0,0,0,213,215,1,0,0,0,214,208,1,0,0,0,215,218,1,0,0,0,216,214,1,0,0,0,216,217,1,0,0,0,217,46,1,0,0,0,218,216,1,0,0,0,219,221,7,5,0,0,220,219,1,0,0,0,220,221,1,0,0,0,221,223,1,0,0,0,222,224,7,2,0,0,223,222,1,0,0,0,224,225,1,0,0,0,225,223,1,0,0,0,225,226,1,0,0,0,226,48,1,0,0,0,227,229,7,5,0,0,228,227,1,0,0,0,228,229,1,0,0,0,229,233,1,0,0,0,230,232,7,2,0,0,231,230,1,0,0,0,232,235,1,0,0,0,233,231,1,0,0,0,233,234,1,0,0,0,234,236,1,0,0,0,235,233,1,0,0,0,236,238,5,46,0,0,237,239,7,2,0,0,238,237,1,0,0,0,239,240,1,0,0,0,240,238,1,0,0,0,240,241,1,0,0,0,241,50,1,0,0,0,242,244,7,5,0,0,243,242,1,0,0,0,243,244,1,0,0,0,244,271,1,0,0,0,245,247,7,2,0,0,246,245,1,0,0,0,247,248,1,0,0,0,248,246,1,0,0,0,248,249,1,0,0,0,249,250,1,0,0,0,250,254,5,46,0,0,251,253,7,2,0,0,252,251,1,0,0,0,253,256,1,0,0,0,254,252,1,0,0,0,254,255,1,0,0,0,255,257,1,0,0,0,256,254,1,0,0,0,257,272,3,53,26,0,258,260,5,46,0,0,259,261,7,2,0,0,260,259,1,0,0,0,261,262,1,0,0,0,262,260,1,0,0,0,262,263,1,0,0,0,263,264,1,0,0,0,264,272,3,53,26,0,265,267,7,2,0,0,266,265,1,0,0,0,267,268,1,0,0,0,268,266,1,0,0,0,268,269,1,0,0,0,269,270,1,0,0,0,270,272,3,53,26,0,271,246,1,0,0,0,271,258,1,0,0,0,271,266,1,0,0,0,272,52,1,0,0,0,273,275,7,6,0,0,274,276,7,5,0,0,275,274,1,0,0,0,275,276,1,0,0,0,276,278,1,0,0,0,277,279,7,2,0,0,278,277,1,0,0,0,279,280,1,0,0,0,280,278,1,0,0,0,280,281,1,0,0,0,281,54,1,0,0,0,282,283,5,39,0,0,283,284,5,39,0,0,284,285,5,39,0,0,285,298,1,0,0,0,286,290,5,39,0,0,287,288,5,39,0,0,288,290,5,39,0,0,289,286,1,0,0,0,289,287,1,0,0,0,289,290,1,0,0,0,290,294,1,0,0,0,291,295,8,7,0,0,292,295,3,65,32,0,293,295,3,63,31,0,294,291,1,0,0,0,294,292,1,0,0,0,294,293,1,0,0,0,295,297,1,0,0,0,296,289,1,0,0,0,297,300,1,0,0,0,298,296,1,0,0,0,298,299,1,0,0,0,299,301,1,0,0,0,300,298,1,0,0,0,301,302,5,39,0,0,302,303,5,39,0,0,303,304,5,39,0,0,304,56,1,0,0,0,305,306,5,34,0,0,306,307,5,34,0,0,307,308,5,34,0,0,308,321,1,0,0,0,309,313,5,34,0,0,310,311,5,34,0,0,311,313,5,34,0,0,312,309,1,0,0,0,312,310,1,0,0,0,312,313,1,0,0,0,313,317,1,0,0,0,314,318,8,8,0,0,315,318,3,65,32,0,316,318,3,63,31,0,317,314,1,0,0,0,317,315,1,0,0,0,317,316,1,0,0,0,318,320,1,0,0,0,319,312,1,0,0,0,320,323,1,0,0,0,321,319,1,0,0,0,321,322,1,0,0,0,322,324,1,0,0,0,323,321,1,0,0,0,324,325,5,34,0,0,325,326,5,34,0,0,326,327,5,34,0,0,327,58,1,0,0,0,328,334,5,34,0,0,329,333,8,9,0,0,330,333,3,65,32,0,331,333,3,63,31,0,332,329,1,0,0,0,332,330,1,0,0,0,332,331,1,0,0,0,333,336,1,0,0,0,334,332,1,0,0,0,334,335,1,0,0,0,335,337,1,0,0,0,336,334,1,0,0,0,337,338,5,34,0,0,338,60,1,0,0,0,339,345,5,39,0,0,340,344,8,10,0,0,341,344,3,65,32,0,342,344,3,63,31,0,343,340,1,0,0,0,343,341,1,0,0,0,343,342,1,0,0,0,344,347,1,0,0,0,345,343,1,0,0,0,345,346,1,0,0,0,346,348,1,0,0,0,347,345,1,0,0,0,348,349,5,39,0,0,349,62,1,0,0,0,350,351,5,92,0,0,351,352,5,117,0,0,352,353,1,0,0,0,353,354,3,89,44,0,354,355,3,89,44,0,355,356,3,89,44,0,356,357,3,89,44,0,357,371,1,0,0,0,358,359,5,92,0,0,359,360,5,85,0,0,360,361,1,0,0,0,361,362,3,89,44,0,362,363,3,89,44,0,363,364,3,89,44,0,364,365,3,89,44,0,365,366,3,89,44,0,366,367,3,89,44,0,367,368,3,89,44,0,368,369,3,89,44,0,369,371,1,0,0,0,370,350,1,0,0,0,370,358,1,0,0,0,371,64,1,0,0,0,372,373,5,92,0,0,373,374,7,11,0,0,374,66,1,0,0,0,375,376,7,12,0,0,376,377,1,0,0,0,377,378,6,33,0,0,378,68,1,0,0,0,379,383,5,91,0,0,380,382,3,67,33,0,381,380,1,0,0,0,382,385,1,0,0,0,383,381,1,0,0,0,383,384,1,0,0,0,384,386,1,0,0,0,385,383,1,0,0,0,386,387,5,93,0,0,387,70,1,0,0,0,388,390,7,13,0,0,389,388,1,0,0,0,390,72,1,0,0,0,391,394,3,71,35,0,392,394,5,95,0,0,393,391,1,0,0,0,393,392,1,0,0,0,394,74,1,0,0,0,395,398,3,73,36,0,396,398,7,14,0,0,397,395,1,0,0,0,397,396,1,0,0,0,398,76,1,0,0,0,399,400,7,15,0,0,400,401,7,16,0,0,401,402,7,17,0,0,402,403,7,6,0,0,403,78,1,0,0,0,404,405,7,18,0,0,405,406,7,19,0,0,406,407,7,6,0,0,407,408,7,20,0,0,408,409,7,21,0,0,409,410,7,22,0,0,410,80,1,0,0,0,411,420,3,71,35,0,412,415,3,75,37,0,413,415,5,46,0,0,414,412,1,0,0,0,414,413,1,0,0,0,415,418,1,0,0,0,416,414,1,0,0,0,416,417,1,0,0,0,417,419,1,0,0,0,418,416,1,0,0,0,419,421,3,75,37,0,420,416,1,0,0,0,420,421,1,0,0,0,421,82,1,0,0,0,422,426,3,73,36,0,423,426,2,48,58,0,424,426,3,85,42,0,425,422,1,0,0,0,425,423,1,0,0,0,425,424,1,0,0,0,426,440,1,0,0,0,427,431,3,75,37,0,428,431,7,23,0,0,429,431,3,85,42,0,430,427,1,0,0,0,430,428,1,0,0,0,430,429,1,0,0,0,431,434,1,0,0,0,432,430,1,0,0,0,432,433,1,0,0,0,433,438,1,0,0,0,434,432,1,0,0,0,435,439,3,75,37,0,436,439,5,58,0,0,437,439,3,85,42,0,438,435,1,0,0,0,438,436,1,0,0,0,438,437,1,0,0,0,439,441,1,0,0,0,440,432,1,0,0,0,440,441,1,0,0,0,441,84,1,0,0,0,442,445,3,87,43,0,443,445,3,91,45,0,444,442,1,0,0,0,444,443,1,0,0,0,445,86,1,0,0,0,446,447,5,37,0,0,447,448,3,89,44,0,448,449,3,89,44,0,449,88,1,0,0,0,450,452,7,24,0,0,451,450,1,0,0,0,452,90,1,0,0,0,453,454,5,92,0,0,454,455,7,25,0,0,455,92,1,0,0,0,54,0,136,144,155,161,165,170,172,178,190,194,196,200,206,212,216,220,225,228,233,240,243,248,254,262,268,271,275,280,289,294,298,312,317,321,332,334,343,345,370,383,389,393,397,414,416,420,425,430,432,438,440,444,451,1,6,0,0]),o=r.decisionToState.map(((t,e)=>new i.Z.dfa.DFA(t,e)));class l extends i.Z.Lexer{static grammarFileName="turtlestar.g4";static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static modeNames=["DEFAULT_MODE"];static literalNames=[null,"'.'","'@prefix'","'@base'","';'","','","'a'","'<<'","'>>'","'['","']'","'('","')'","'^^'"];static symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"COMMENT","NumericLiteral","BooleanLiteral","String","BlankNode","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","ANON","PN_CHARS_BASE","PN_CHARS_U","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];static ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","COMMENT","NumericLiteral","BooleanLiteral","String","BlankNode","IRIREF","PNAME_NS","PNAME_LN","BLANK_NODE_LABEL","LANGTAG","INTEGER","DECIMAL","DOUBLE","EXPONENT","STRING_LITERAL_LONG_SINGLE_QUOTE","STRING_LITERAL_LONG_QUOTE","STRING_LITERAL_QUOTE","STRING_LITERAL_SINGLE_QUOTE","UCHAR","ECHAR","WS","ANON","PN_CHARS_BASE","PN_CHARS_U","PN_CHARS","BASE","PREFIX","PN_PREFIX","PN_LOCAL","PLX","PERCENT","HEX","PN_LOCAL_ESC"];constructor(t){super(t),this._interp=new i.Z.atn.LexerATNSimulator(this,r,o,new i.Z.PredictionContextCache)}get atn(){return r}}l.EOF=i.Z.Token.EOF,l.T__0=1,l.T__1=2,l.T__2=3,l.T__3=4,l.T__4=5,l.T__5=6,l.T__6=7,l.T__7=8,l.T__8=9,l.T__9=10,l.T__10=11,l.T__11=12,l.T__12=13,l.COMMENT=14,l.NumericLiteral=15,l.BooleanLiteral=16,l.String=17,l.BlankNode=18,l.IRIREF=19,l.PNAME_NS=20,l.PNAME_LN=21,l.BLANK_NODE_LABEL=22,l.LANGTAG=23,l.INTEGER=24,l.DECIMAL=25,l.DOUBLE=26,l.EXPONENT=27,l.STRING_LITERAL_LONG_SINGLE_QUOTE=28,l.STRING_LITERAL_LONG_QUOTE=29,l.STRING_LITERAL_QUOTE=30,l.STRING_LITERAL_SINGLE_QUOTE=31,l.UCHAR=32,l.ECHAR=33,l.WS=34,l.ANON=35,l.PN_CHARS_BASE=36,l.PN_CHARS_U=37,l.PN_CHARS=38,l.BASE=39,l.PREFIX=40,l.PN_PREFIX=41,l.PN_LOCAL=42,l.PLX=43,l.PERCENT=44,l.HEX=45,l.PN_LOCAL_ESC=46;var a=n(577),h=(n(254),n(26));exports.parse=function(n,s){var i=new t.Z(n),r=new l(i);r.removeErrorListeners(),r.addErrorListener(s);var o=new e.Z(r),c=new a.Z(o);c.removeErrorListeners(),c.removeParseListeners(),s.syntaxError&&c.addErrorListener(s),s.unknownPrefix&&c.addParseListener(new TurtleStarPrefixListener(s));var u=c.turtleStarDoc();s.newAstLine&&new h(s).visit(u)}})(),turtlestar=s})(); \ No newline at end of file diff --git a/editor/dist/turtlestarMain.js.LICENSE.txt b/editor/dist/turtlestarMain.js.LICENSE.txt new file mode 100644 index 0000000..90fe869 --- /dev/null +++ b/editor/dist/turtlestarMain.js.LICENSE.txt @@ -0,0 +1,3 @@ +/*! https://mths.be/codepointat v0.2.0 by @mathias */ + +/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */ diff --git a/editor/index.html b/editor/index.html index c120aba..c005b62 100644 --- a/editor/index.html +++ b/editor/index.html @@ -15,28 +15,28 @@ - - + + - - + + + @@ -414,49 +432,7 @@

              Notation3 Editor

              Experimental auto-suggestion of namespaces. A specific namespace will only be suggested once (so just remove it if it's wrong!). - + Create link to formula @@ -476,9 +452,9 @@

              Notation3 Editor



              @@ -488,6 +464,9 @@

              Notation3 Editor

              +
              + +
              - +

              diff --git a/editor/lib/ast.js b/editor/lib/ast.js index a18bfc7..360856a 100644 --- a/editor/lib/ast.js +++ b/editor/lib/ast.js @@ -39,8 +39,4 @@ function doAst(formula, onAstLine, onError, lib) { n3.ast = function(formula, onAstLine, onError) { doAst(formula, onAstLine, onError, n3); -} - -turtlestar.ast = function(formula, onAstLine, onError) { - doAst(formula, onAstLine, onError, turtlestar); } \ No newline at end of file diff --git a/editor/lib/codemirror-5.54.0/lint.js b/editor/lib/codemirror-5.54.0/lint.js index 8873f0a..b8e05fd 100644 --- a/editor/lib/codemirror-5.54.0/lint.js +++ b/editor/lib/codemirror-5.54.0/lint.js @@ -104,12 +104,6 @@ n3.lint = function(onSuggestion) { } } -turtlestar.lint = function(onSuggestion) { - return function(text, options, editor) { - return doLint(text, options, editor, onSuggestion, turtlestar) - } -} - // doesn't seem to work for me // tried adding it to codemirror addon folder (copying setup from other // lints); re-installing codemirror (npm install), .. diff --git a/editor/lib/codemirror-5.54.0/n3-mode.js b/editor/lib/codemirror-5.54.0/n3-mode.js index d34c958..e9da404 100644 --- a/editor/lib/codemirror-5.54.0/n3-mode.js +++ b/editor/lib/codemirror-5.54.0/n3-mode.js @@ -33,16 +33,31 @@ // will consume anything matching the regex stream.match(/^[^\s\u00a0>]*>?/); return "atom"; + } else if (ch == "?") { + stream.match(/^[^\s\u00a0>]*>?/); + return "variable-2"; + } else if (ch == "_" && stream.match(/^:/, false)) { + stream.match(/^:[^\s\u00a0>]*>?/); + return "variable-2"; } else if (ch == "\"" || ch == "'") { // eat all tokens until (non-esc) closing quote state.tokenize = tokenLiteral(ch); return state.tokenize(stream, state); + } else if (/\d/.test(ch)) { + stream.match(/\d+(\.\d*)?/); + return "number"; + } else if (ch == "t" && stream.match(/^rue/, false)) { + stream.match(/^rue/); + return "number" + } else if (ch == "f" && stream.match(/^alse/, false)) { + stream.match(/^alse/); + return "number" // allows keeping separate state per nested element } else if (/[{}\(\),\.;\[\]]/.test(ch)) { curPunc = ch; return null; - // eat entire comment } else if (ch == "#") { + // eat entire comment stream.skipToEnd(); return "comment"; // eat all operator chars diff --git a/editor/lib/default.css b/editor/lib/default.css index 21f0491..71885c5 100644 --- a/editor/lib/default.css +++ b/editor/lib/default.css @@ -67,7 +67,7 @@ h1::before { .functions { display: grid; - grid-template-columns: 1fr 1fr 1fr 1fr 0.5fr; + grid-template-columns: 1fr 1fr 1fr 1fr 1fr; } .function { diff --git a/editor/lib/load_eyebrow.js b/editor/lib/load_eyebrow.js deleted file mode 100644 index 594e0e0..0000000 --- a/editor/lib/load_eyebrow.js +++ /dev/null @@ -1,4 +0,0 @@ -import { eyebrow } from "../../lib/eyebrow/eyebrow.js"; - -window.eyebrow = eyebrow; -loadedEyebrow(); \ No newline at end of file diff --git a/editor/lib/service.js b/editor/lib/service.js index 941a778..3641423 100644 --- a/editor/lib/service.js +++ b/editor/lib/service.js @@ -1,46 +1,32 @@ -// import { eyebrow } from "../../lib/eyebrow/eyebrow.js"; - -const serviceUrl = `${config.http.hostname}:${config.http.port}/n3`; - -window.loadedEyebrow = function() { - doneLoading(); - - window.eyebrowCtu(); -} - -window.eyebrowCtu = function() { - let [ options, onSuccess, onError ] = window.eyebrowParams; - - window.eyebrow(options, options.formula, (output) => { - if (output.success !== undefined) - onSuccess(output.success); - else - onError(output.error); - }); -} +const serviceUrl = (config.http.port !== undefined ? + `${config.http.hostname}:${config.http.port}/n3` : + `${config.http.hostname}/n3`); function exec(options, onSuccess, onError) { switch (options.system) { - case 'eyebrow': - window.eyebrowParams = [ options, onSuccess, onError ]; - // TODO instead of this mess, - // do this properly with requirejs - if (!window.eyebrow) { - startLoading(); + case 'eyejs': + let task = options.task; + switch (options.task) { - var load_eyebrow = document.createElement('script'); - load_eyebrow.setAttribute('type', 'module'); - load_eyebrow.setAttribute('src', 'lib/load_eyebrow.js'); + case 'derivations': + break; - document.head.appendChild(load_eyebrow); + case 'deductive_closure': + task = "deductive_closure_plus_rules"; + break; + } - } else - window.eyebrowCtu(); + eyereasoner.n3reasoner( + options.formula, + undefined, + { output: task } + ).then(onSuccess).catch(onError); break; default: + // console.log("serviceUrl? ", serviceUrl); $.post(serviceUrl, options, (output, status) => { // console.log(status, output) @@ -54,11 +40,11 @@ function exec(options, onSuccess, onError) { break default: - onError("Error reaching N3 service.") + onError("Error reaching N3 service: ", status) break } }).fail((response) => { - onError("Error reaching N3 service.") + onError("Error reaching N3 service:", response) }) break; } diff --git a/editor/lib/spin3.css b/editor/lib/spin3.css new file mode 100644 index 0000000..4545178 --- /dev/null +++ b/editor/lib/spin3.css @@ -0,0 +1,264 @@ +body { + font-family: sans-serif; + padding-left: 15px; + max-width: 1400px; + margin: auto; +} + +.content { + padding-top: 15px; +} + +.content table td { + width: 50%; + vertical-align: top; +} + +.header table td { + vertical-align: middle; +} + +.logo { + display: block; +} + +button { + padding: 8px 25px; + border-radius: 5px; + color: #fff; + border: 0; + font-size: 17px; + margin-left: 15px; +} + +button:hover { + cursor: pointer; +} + +button#execute { + background-color: #e68103; +} + +button#execute:hover { + background-color: #8a25b1; +} + +button#link { + background-color: rgb(177, 177, 177); +} + +button#link:hover { + background-color: rgb(139, 139, 139); +} + +.content h1+p { + margin-bottom: 15px; + line-height: 1.5; +} + +.content input[type=radio] { + margin-bottom: 10px +} + +.content textarea#input { + overflow: scroll !important; + width: 100%; + height: 200px; +} + +h1 { + font-size: 32px; +} + +h1::before { + content: ''; + display: block; + background-color: #8a25b1; + width: 60px; + height: 5px; + border-radius: 2px; + margin-bottom: 10px; +} + +.functions { +} + +.function { + float: left; +} + +.function button { +} + +.loading { + float: left; + display: none; + margin-left: 15px; + padding-top: 10px; +} + +.output { + display: none; + position: relative; +} + +#links { + margin-top: 15px; + display: none; +} + +#times { + margin-top: 15px; + display: none; +} + +#num_constructs { + display: none; + font-size: 14px; +} + +.hint { + font-size: 14px; +} + +#links div { + display: inline +} + +#links a { + color: #fff; + background-color: rgb(139, 139, 139); + text-decoration: none; + padding: 5px 10px; + border-radius: 5px; + } + +.box { + white-space: pre-wrap; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); + padding: 15px; + padding-left: 25px; + width: auto; + background: #fcfaee; + padding: .5em; + border-left-width: .5em; + border-left-style: solid; + border-color: #e68103; + width: 75%; + margin-top: 20px; +} + +#error>.box { + border-color: #e00000; + background: #ffa8a8; +} + +.system { + display: inline +} + +div.CodeMirror { + border: 1px solid #ddd; +} + +td.separator { + padding: 25px; +} + +td.separator div { + width: 1px; + height: 50px; + background: black; +} + +h3 { + margin-bottom: 5px +} + +.note1 { + float: left; + margin-bottom: 15px +} + +.note2 { + float: right; + margin-bottom: 15px +} + +/* tooltips */ +/* https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip_arrow_bottom */ + +.tooltip { + position: relative; + display: inline-block; + border-bottom: 1px dotted black; +} + +.tooltip .tooltiptext { + visibility: hidden; + width: 200px; + margin-left: -150px; + background-color: black; + color: #fff; + text-align: center; + border-radius: 6px; + padding: 5px 0; + position: absolute; + z-index: 1; + bottom: 150%; + left: 50%; + padding: 10px; + font-size: 14px; +} + +.tooltip .tooltiptext::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: black transparent transparent transparent; +} + +.tooltip:hover .tooltiptext { + visibility: visible; +} + +.CodeMirror { + resize: vertical; +} + +.copy { + position: absolute; + top: 55px; + right: 215px; + width: 25px; + height: 25px; + background-image: url("../img/copy.svg"); + background-size: contain; + background-repeat: no-repeat; + cursor: pointer; + border-bottom: none; +} + +.copy .tooltiptext { + width: 140px; + bottom: 150%; + left: 50%; + margin-left: -75px; + } + + .copy .tooltiptext::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; + } + +.CodeMirror pre.CodeMirror-placeholder { color: grey ; } \ No newline at end of file diff --git a/editor/logo-small.png b/editor/logo-small.png new file mode 100644 index 0000000..bf6fed7 Binary files /dev/null and b/editor/logo-small.png differ diff --git a/editor/parser/n3/index.js b/editor/parser/n3/index.js index b7a55e8..fa3b814 100644 --- a/editor/parser/n3/index.js +++ b/editor/parser/n3/index.js @@ -13,6 +13,7 @@ import N3Lexer from './n3Lexer'; import N3Parser from './n3Parser'; import N3PrefixListener from './n3PrefixListener'; import N3PrintVisitor from './n3PrintVisitor'; +import N3FormatVisitor from './n3FormatVisitor'; export function parse(input, listener) { @@ -45,4 +46,19 @@ export function parse(input, listener) { new N3PrintVisitor(listener).visit(ast) } +export function format(input, config) { + var chars = new InputStream(input); + + var n3Lexer = new N3Lexer(chars); + var tokens = new CommonTokenStream(n3Lexer); + + var n3Parser = new N3Parser(tokens); + + let ast = n3Parser.n3Doc(); + // return ast; + + var visitor = new N3FormatVisitor(config); + return visitor.visitN3Doc(ast); +} + // exports.parse = parse; \ No newline at end of file diff --git a/editor/parser/n3/n3FormatVisitor.js b/editor/parser/n3/n3FormatVisitor.js new file mode 100644 index 0000000..609fc99 --- /dev/null +++ b/editor/parser/n3/n3FormatVisitor.js @@ -0,0 +1,468 @@ +import n3Visitor from './n3Visitor'; +// import n3Parser from './n3Parser'; + +export default class n3FormatVisitor extends n3Visitor { + + constructor(config) { + super(); + + this.config = config; + + this.str = ""; + this.indent = 0; + } + + // Visit a parse tree produced by n3Parser#n3Doc. + visitN3Doc(ctx) { + this.logVisit("N3Doc"); + + this.visitGraphContents(ctx); + + // TODO integrate all these re-assignments into visit checks + // (currently we cannot "stream" output) + + // - drop newlines between "}" and "." + this.str = this.str.replace(/\}\n\s*\./g, "} ."); + + return this.str; + } + + // Visit a parse tree produced by n3Parser#n3Statement. + visitN3Statement(ctx) { + this.logVisit("N3Statement"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#n3Directive. + visitN3Directive(ctx) { + this.logVisit("N3Directive"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlDirective. + visitSparqlDirective(ctx) { + this.logVisit("SparqlDirective"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlBase. + visitSparqlBase(ctx) { + this.logVisit("SparqlBase"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#sparqlPrefix. + visitSparqlPrefix(ctx) { + this.logVisit("SparqlPrefix"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#prefixID. + visitPrefixID(ctx) { + this.logVisit("PrefixID"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#base. + visitBase(ctx) { + this.logVisit("Base"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#triples. + visitTriples(ctx) { + this.logVisit("Triples"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#predicateObjectList. + visitPredicateObjectList(ctx) { + this.logVisit("PredicateObjectList"); + + let indented = false; + ctx.children.forEach(child => { + // terminal ";" + if (child.symbol !== undefined) { + // if needed, increment level + if (!indented) { + // indent taken care of by blankNodePropertyList, iriPropertyList + if (ctx.parentCtx.ruleIndex != 19 && + ctx.parentCtx.ruleIndex != 20) { + + indented = true; + this.incrIndent(); + } + } + + // newline after ";"; + this.print(child); + this.appendNewline(); + + } else { + // non-terminal (term) + child.accept(this); + this.separate(" "); + } + }); + + // after, decrement level again + if (indented) + this.decrIndent(); + } + + + // Visit a parse tree produced by n3Parser#objectList. + visitObjectList(ctx) { + this.logVisit("ObjectList"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#verb. + visitVerb(ctx) { + this.logVisit("Verb") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#subject. + visitSubject(ctx) { + this.logVisit("Subject") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicate. + visitPredicate(ctx) { + this.logVisit("Predicate") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#object. + visitObject(ctx) { + this.logVisit("Object") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#expression. + visitExpression(ctx) { + this.logVisit("Expression") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#path. + visitPath(ctx) { + this.logVisit("Path") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#pathItem. + visitPathItem(ctx) { + this.logVisit("PathItem") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#literal. + visitLiteral(ctx) { + this.logVisit("Literal") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + this.logVisit("BlankNodePropertyList"); + + // "[" + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + for (let i = 1; i < ctx.getChildCount() - 1; i++) { + ctx.getChild(i).accept(this); + } + + this.decrIndent(); + + this.appendNewline(); + // "]" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + } + + + // Visit a parse tree produced by n3Parser#iriPropertyList. + visitIriPropertyList(ctx) { + this.logVisit("IriPropertyList") + + // IPLSTART + this.print(ctx.getChild(0)); + + // id + this.separate(" "); + ctx.getChild(1).accept(this) + + this.incrIndent(1); + this.appendNewline(); + + for (let i = 2; i < ctx.getChildCount() - 1; i++) { + ctx.getChild(i).accept(this); + } + + this.decrIndent(1); + + this.appendNewline(); + // "]" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + } + + + // Visit a parse tree produced by n3Parser#collection. + visitCollection(ctx) { + this.logVisit("Collection"); + + // in case of any formula descendants, + // print list contents like bnode property list + // (22: rule index of formula) + if (this.hasSomeDescendant(ctx, 22)) { + + // "(" + this.print(ctx.getChild(0)); + + this.incrIndent(); + + for (let i = 1; i < ctx.getChildCount() - 1; i++) { + if (i > 1) + this.appendNewline(); + + ctx.getChild(i).accept(this); + } + + this.decrIndent(); + + this.appendNewline(); + // ")" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + + } else + this.doVisitChildren(ctx, " "); + } + + hasSomeDescendant(ctx, ruleIndex) { + if (ctx.ruleIndex == ruleIndex) + return true; + + if (ctx.children) + return ctx.children.some(child => this.hasSomeDescendant(child, ruleIndex)); + else + return false; + } + + // Visit a parse tree produced by n3Parser#formula. + visitFormula(ctx) { + this.logVisit("Formula"); + + // empty formula + if (ctx.getChildCount() == 2) { + this.doVisitChildren(ctx); + return + } + + // terminal "{" + if (this.config.graphOnNewline) { + this.appendNewline(); + } + + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + ctx.getChild(1).accept(this); + + this.decrIndent(); + + // terminal "}" + this.appendNewline(); + this.print(ctx.getChild(2)); + + if (this.config.graphOnNewline) { + this.appendNewline(); + } + } + + + // Visit a parse tree produced by n3Parser#formulaContent. + visitFormulaContent(ctx) { + this.logVisit("FormulaContent"); + + this.visitGraphContents(ctx); + } + + + // Visit a parse tree produced by n3Parser#numericLiteral. + visitNumericLiteral(ctx) { + this.logVisit("NumericLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#rdfLiteral. + visitRdfLiteral(ctx) { + this.logVisit("RdfLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iri. + visitIri(ctx) { + this.logVisit("Iri") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriList. + visitIriList(ctx) { + this.logVisit("IriList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixedName. + visitPrefixedName(ctx) { + this.logVisit("PrefixedName") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNode. + visitBlankNode(ctx) { + this.logVisit("BlankNode") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#quickVar. + visitQuickVar(ctx) { + this.logVisit("QuickVar") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#existential. + visitExistential(ctx) { + this.logVisit("Existential") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#universal. + visitUniversal(ctx) { + this.logVisit("Universal") + return this.doVisitChildren(ctx) + } + + + incrIndent(plus) { + this.indent += this.config.tab + (plus ? plus : 0); + } + + decrIndent(minus) { + this.indent -= (this.config.tab + (minus ? minus : 0)); + } + + visitGraphContents(ctx) { + let n = ctx.getChildCount(); + for (let i = 0; i < n; i++) { + let child = ctx.getChild(i); + + // terminating "." + if (child.symbol !== undefined) { + this.separate(" "); + this.print(child); + // newline for N3Statements after "." + if (i < n - 1) // not last child + this.appendNewline(); + + } else { + // non-terminal + child.accept(this); + if (child.ruleIndex == 3) { // SparqlDirective + if (i < n - 1) // not last child + this.appendNewline(); // newline afterwards + } + } + } + } + + doVisitChildren(ctx, sep) { + this.visitChildren(ctx, sep); + } + + visitChildren(node, sep) { + for (var i = 0; i < node.getChildCount(); i++) { + var child = node.getChild(i); + // console.log("child", child); + + if (sep && i > 0) + this.separate(sep); + + // terminal + if (child.symbol !== undefined) { + let out = child.toString(); + // console.log("out", out); + + this.print(out); + + // (get type of symbol for debugging) + // var type = c.symbol.type; + // if (type != -1 && n3Parser.symbolicNames[type] !== null) + // out += " (" + n3Parser.symbolicNames[type] + ")"; + + } else { + // non-terminal + child.accept(this); + } + } + } + + logVisit(el) { + // console.log(el); + } + + appendNewline() { + // if we already end with newline: + // drop that one (and its subsequent indent) + if (/.*\n\s*$/g.test(this.str)) + this.str = this.str.trim(); + + this.print("\n" + new Array(this.indent).join(" ")); + } + + separate(sep) { + // let's not add space separator after a whitespace + // (e.g., when putting newlines around =>) + if (sep == " " && /.*\s+$/g.test(this.str)) + return; + + this.print(sep); + } + + print(str) { + if (str != "") + this.str += str; + } +} \ No newline at end of file diff --git a/editor/parser/n3/n3Lexer.js b/editor/parser/n3/n3Lexer.js index fa64eed..719425d 100644 --- a/editor/parser/n3/n3Lexer.js +++ b/editor/parser/n3/n3Lexer.js @@ -1,8 +1,7 @@ -// Generated from n3.g4 by ANTLR 4.10.1 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start import antlr4 from 'antlr4'; - const serializedATN = [4,0,55,506,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2, 4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7, 12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19, diff --git a/editor/parser/n3/n3Listener.js b/editor/parser/n3/n3Listener.js index 3d297b8..a6952a2 100644 --- a/editor/parser/n3/n3Listener.js +++ b/editor/parser/n3/n3Listener.js @@ -1,4 +1,4 @@ -// Generated from n3.g4 by ANTLR 4.10.1 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start import antlr4 from 'antlr4'; diff --git a/editor/parser/n3/n3Parser.js b/editor/parser/n3/n3Parser.js index f64640c..8aa32db 100644 --- a/editor/parser/n3/n3Parser.js +++ b/editor/parser/n3/n3Parser.js @@ -1,4 +1,4 @@ -// Generated from n3.g4 by ANTLR 4.10.1 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start import antlr4 from 'antlr4'; import n3Listener from './n3Listener.js'; @@ -83,7 +83,7 @@ const sharedContextCache = new antlr4.PredictionContextCache(); export default class n3Parser extends antlr4.Parser { - static grammarFileName = "n3.g4"; + static grammarFileName = "java-escape"; static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", "','", "'a'", "'has'", "'is'", "'of'", "'='", "'<='", "'=>'", "'<-'", "'!'", "'^'", "'['", @@ -132,34 +132,34 @@ export default class n3Parser extends antlr4.Parser { this.state = 66; this._errHandler.sync(this); _la = this._input.LA(1); - while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser.T__1) | (1 << n3Parser.T__2) | (1 << n3Parser.T__15) | (1 << n3Parser.T__17) | (1 << n3Parser.T__19) | (1 << n3Parser.BooleanLiteral) | (1 << n3Parser.String) | (1 << n3Parser.IRIREF) | (1 << n3Parser.PNAME_NS) | (1 << n3Parser.PNAME_LN) | (1 << n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser.DECIMAL - 32)) | (1 << (n3Parser.DOUBLE - 32)) | (1 << (n3Parser.IPLSTART - 32)) | (1 << (n3Parser.ANON - 32)) | (1 << (n3Parser.QuickVarName - 32)) | (1 << (n3Parser.BASE - 32)) | (1 << (n3Parser.PREFIX - 32)))) !== 0)) { + while((((_la) & ~0x1f) == 0 && ((1 << _la) & 3205824524) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & 203779) !== 0)) { this.state = 64; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.T__1: - case n3Parser.T__2: - case n3Parser.T__15: - case n3Parser.T__17: - case n3Parser.T__19: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 2: + case 3: + case 16: + case 18: + case 20: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: this.state = 60; this.n3Statement(); this.state = 61; this.match(n3Parser.T__0); break; - case n3Parser.BASE: - case n3Parser.PREFIX: + case 48: + case 49: this.state = 63; this.sparqlDirective(); break; @@ -195,27 +195,27 @@ export default class n3Parser extends antlr4.Parser { this.state = 73; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.T__1: - case n3Parser.T__2: + case 2: + case 3: this.enterOuterAlt(localctx, 1); this.state = 71; this.n3Directive(); break; - case n3Parser.T__15: - case n3Parser.T__17: - case n3Parser.T__19: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 16: + case 18: + case 20: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: this.enterOuterAlt(localctx, 2); this.state = 72; this.triples(); @@ -246,12 +246,12 @@ export default class n3Parser extends antlr4.Parser { this.state = 77; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.T__1: + case 2: this.enterOuterAlt(localctx, 1); this.state = 75; this.prefixID(); break; - case n3Parser.T__2: + case 3: this.enterOuterAlt(localctx, 2); this.state = 76; this.base(); @@ -282,12 +282,12 @@ export default class n3Parser extends antlr4.Parser { this.state = 81; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.BASE: + case 48: this.enterOuterAlt(localctx, 1); this.state = 79; this.sparqlBase(); break; - case n3Parser.PREFIX: + case 49: this.enterOuterAlt(localctx, 2); this.state = 80; this.sparqlPrefix(); @@ -426,7 +426,7 @@ export default class n3Parser extends antlr4.Parser { this.state = 99; this._errHandler.sync(this); _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser.T__5) | (1 << n3Parser.T__6) | (1 << n3Parser.T__7) | (1 << n3Parser.T__9) | (1 << n3Parser.T__10) | (1 << n3Parser.T__11) | (1 << n3Parser.T__12) | (1 << n3Parser.T__15) | (1 << n3Parser.T__17) | (1 << n3Parser.T__19) | (1 << n3Parser.BooleanLiteral) | (1 << n3Parser.String) | (1 << n3Parser.IRIREF) | (1 << n3Parser.PNAME_NS) | (1 << n3Parser.PNAME_LN) | (1 << n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser.DECIMAL - 32)) | (1 << (n3Parser.DOUBLE - 32)) | (1 << (n3Parser.IPLSTART - 32)) | (1 << (n3Parser.ANON - 32)) | (1 << (n3Parser.QuickVarName - 32)))) !== 0)) { + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3205840320) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & 7171) !== 0)) { this.state = 98; this.predicateObjectList(); } @@ -460,13 +460,13 @@ export default class n3Parser extends antlr4.Parser { this.state = 111; this._errHandler.sync(this); _la = this._input.LA(1); - while(_la===n3Parser.T__3) { + while(_la===4) { this.state = 103; this.match(n3Parser.T__3); this.state = 107; this._errHandler.sync(this); _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser.T__5) | (1 << n3Parser.T__6) | (1 << n3Parser.T__7) | (1 << n3Parser.T__9) | (1 << n3Parser.T__10) | (1 << n3Parser.T__11) | (1 << n3Parser.T__12) | (1 << n3Parser.T__15) | (1 << n3Parser.T__17) | (1 << n3Parser.T__19) | (1 << n3Parser.BooleanLiteral) | (1 << n3Parser.String) | (1 << n3Parser.IRIREF) | (1 << n3Parser.PNAME_NS) | (1 << n3Parser.PNAME_LN) | (1 << n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser.DECIMAL - 32)) | (1 << (n3Parser.DOUBLE - 32)) | (1 << (n3Parser.IPLSTART - 32)) | (1 << (n3Parser.ANON - 32)) | (1 << (n3Parser.QuickVarName - 32)))) !== 0)) { + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3205840320) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & 7171) !== 0)) { this.state = 104; this.verb(); this.state = 105; @@ -504,7 +504,7 @@ export default class n3Parser extends antlr4.Parser { this.state = 119; this._errHandler.sync(this); _la = this._input.LA(1); - while(_la===n3Parser.T__4) { + while(_la===5) { this.state = 115; this.match(n3Parser.T__4); this.state = 116; @@ -536,39 +536,39 @@ export default class n3Parser extends antlr4.Parser { this.state = 133; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.T__12: - case n3Parser.T__15: - case n3Parser.T__17: - case n3Parser.T__19: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 13: + case 16: + case 18: + case 20: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: this.enterOuterAlt(localctx, 1); this.state = 122; this.predicate(); break; - case n3Parser.T__5: + case 6: this.enterOuterAlt(localctx, 2); this.state = 123; this.match(n3Parser.T__5); break; - case n3Parser.T__6: + case 7: this.enterOuterAlt(localctx, 3); this.state = 124; this.match(n3Parser.T__6); this.state = 125; this.expression(); break; - case n3Parser.T__7: + case 8: this.enterOuterAlt(localctx, 4); this.state = 126; this.match(n3Parser.T__7); @@ -577,17 +577,17 @@ export default class n3Parser extends antlr4.Parser { this.state = 128; this.match(n3Parser.T__8); break; - case n3Parser.T__9: + case 10: this.enterOuterAlt(localctx, 5); this.state = 130; this.match(n3Parser.T__9); break; - case n3Parser.T__10: + case 11: this.enterOuterAlt(localctx, 6); this.state = 131; this.match(n3Parser.T__10); break; - case n3Parser.T__11: + case 12: this.enterOuterAlt(localctx, 7); this.state = 132; this.match(n3Parser.T__11); @@ -642,25 +642,25 @@ export default class n3Parser extends antlr4.Parser { this.state = 140; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.T__15: - case n3Parser.T__17: - case n3Parser.T__19: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 16: + case 18: + case 20: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: this.state = 137; this.expression(); break; - case n3Parser.T__12: + case 13: this.state = 138; this.match(n3Parser.T__12); this.state = 139; @@ -741,47 +741,47 @@ export default class n3Parser extends antlr4.Parser { this.state = 151; this._errHandler.sync(this); switch (this._input.LA(1)) { - case n3Parser.T__13: + case 14: this.state = 147; this.match(n3Parser.T__13); this.state = 148; this.path(); break; - case n3Parser.T__14: + case 15: this.state = 149; this.match(n3Parser.T__14); this.state = 150; this.path(); break; - case n3Parser.T__0: - case n3Parser.T__3: - case n3Parser.T__4: - case n3Parser.T__5: - case n3Parser.T__6: - case n3Parser.T__7: - case n3Parser.T__8: - case n3Parser.T__9: - case n3Parser.T__10: - case n3Parser.T__11: - case n3Parser.T__12: - case n3Parser.T__15: - case n3Parser.T__16: - case n3Parser.T__17: - case n3Parser.T__18: - case n3Parser.T__19: - case n3Parser.T__20: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 1: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: break; default: break; @@ -809,49 +809,49 @@ export default class n3Parser extends antlr4.Parser { this.state = 161; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: + case 26: + case 27: + case 28: this.enterOuterAlt(localctx, 1); this.state = 153; this.iri(); break; - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.ANON: + case 29: + case 43: this.enterOuterAlt(localctx, 2); this.state = 154; this.blankNode(); break; - case n3Parser.QuickVarName: + case 44: this.enterOuterAlt(localctx, 3); this.state = 155; this.quickVar(); break; - case n3Parser.T__17: + case 18: this.enterOuterAlt(localctx, 4); this.state = 156; this.collection(); break; - case n3Parser.T__15: + case 16: this.enterOuterAlt(localctx, 5); this.state = 157; this.blankNodePropertyList(); break; - case n3Parser.IPLSTART: + case 42: this.enterOuterAlt(localctx, 6); this.state = 158; this.iriPropertyList(); break; - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: + case 24: + case 25: + case 31: + case 32: + case 33: this.enterOuterAlt(localctx, 7); this.state = 159; this.literal(); break; - case n3Parser.T__19: + case 20: this.enterOuterAlt(localctx, 8); this.state = 160; this.formula(); @@ -882,19 +882,19 @@ export default class n3Parser extends antlr4.Parser { this.state = 166; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.String: + case 25: this.enterOuterAlt(localctx, 1); this.state = 163; this.rdfLiteral(); break; - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: + case 31: + case 32: + case 33: this.enterOuterAlt(localctx, 2); this.state = 164; this.numericLiteral(); break; - case n3Parser.BooleanLiteral: + case 24: this.enterOuterAlt(localctx, 3); this.state = 165; this.match(n3Parser.BooleanLiteral); @@ -985,7 +985,7 @@ export default class n3Parser extends antlr4.Parser { this.state = 181; this._errHandler.sync(this); _la = this._input.LA(1); - while(((((_la - 16)) & ~0x1f) == 0 && ((1 << (_la - 16)) & ((1 << (n3Parser.T__15 - 16)) | (1 << (n3Parser.T__17 - 16)) | (1 << (n3Parser.T__19 - 16)) | (1 << (n3Parser.BooleanLiteral - 16)) | (1 << (n3Parser.String - 16)) | (1 << (n3Parser.IRIREF - 16)) | (1 << (n3Parser.PNAME_NS - 16)) | (1 << (n3Parser.PNAME_LN - 16)) | (1 << (n3Parser.BLANK_NODE_LABEL - 16)) | (1 << (n3Parser.INTEGER - 16)) | (1 << (n3Parser.DECIMAL - 16)) | (1 << (n3Parser.DOUBLE - 16)) | (1 << (n3Parser.IPLSTART - 16)) | (1 << (n3Parser.ANON - 16)) | (1 << (n3Parser.QuickVarName - 16)))) !== 0)) { + while(((((_la - 16)) & ~0x1f) == 0 && ((1 << (_la - 16)) & 470007573) !== 0)) { this.state = 178; this.object(); this.state = 183; @@ -1021,7 +1021,7 @@ export default class n3Parser extends antlr4.Parser { this.state = 188; this._errHandler.sync(this); _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser.T__1) | (1 << n3Parser.T__2) | (1 << n3Parser.T__15) | (1 << n3Parser.T__17) | (1 << n3Parser.T__19) | (1 << n3Parser.BooleanLiteral) | (1 << n3Parser.String) | (1 << n3Parser.IRIREF) | (1 << n3Parser.PNAME_NS) | (1 << n3Parser.PNAME_LN) | (1 << n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser.DECIMAL - 32)) | (1 << (n3Parser.DOUBLE - 32)) | (1 << (n3Parser.IPLSTART - 32)) | (1 << (n3Parser.ANON - 32)) | (1 << (n3Parser.QuickVarName - 32)) | (1 << (n3Parser.BASE - 32)) | (1 << (n3Parser.PREFIX - 32)))) !== 0)) { + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3205824524) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & 203779) !== 0)) { this.state = 187; this.formulaContent(); } @@ -1052,36 +1052,36 @@ export default class n3Parser extends antlr4.Parser { this.state = 203; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.T__1: - case n3Parser.T__2: - case n3Parser.T__15: - case n3Parser.T__17: - case n3Parser.T__19: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 2: + case 3: + case 16: + case 18: + case 20: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: this.enterOuterAlt(localctx, 1); this.state = 192; this.n3Statement(); this.state = 197; this._errHandler.sync(this); _la = this._input.LA(1); - if(_la===n3Parser.T__0) { + if(_la===1) { this.state = 193; this.match(n3Parser.T__0); this.state = 195; this._errHandler.sync(this); _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser.T__1) | (1 << n3Parser.T__2) | (1 << n3Parser.T__15) | (1 << n3Parser.T__17) | (1 << n3Parser.T__19) | (1 << n3Parser.BooleanLiteral) | (1 << n3Parser.String) | (1 << n3Parser.IRIREF) | (1 << n3Parser.PNAME_NS) | (1 << n3Parser.PNAME_LN) | (1 << n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser.DECIMAL - 32)) | (1 << (n3Parser.DOUBLE - 32)) | (1 << (n3Parser.IPLSTART - 32)) | (1 << (n3Parser.ANON - 32)) | (1 << (n3Parser.QuickVarName - 32)) | (1 << (n3Parser.BASE - 32)) | (1 << (n3Parser.PREFIX - 32)))) !== 0)) { + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3205824524) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & 203779) !== 0)) { this.state = 194; this.formulaContent(); } @@ -1089,15 +1089,15 @@ export default class n3Parser extends antlr4.Parser { } break; - case n3Parser.BASE: - case n3Parser.PREFIX: + case 48: + case 49: this.enterOuterAlt(localctx, 2); this.state = 199; this.sparqlDirective(); this.state = 201; this._errHandler.sync(this); _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3Parser.T__1) | (1 << n3Parser.T__2) | (1 << n3Parser.T__15) | (1 << n3Parser.T__17) | (1 << n3Parser.T__19) | (1 << n3Parser.BooleanLiteral) | (1 << n3Parser.String) | (1 << n3Parser.IRIREF) | (1 << n3Parser.PNAME_NS) | (1 << n3Parser.PNAME_LN) | (1 << n3Parser.BLANK_NODE_LABEL) | (1 << n3Parser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3Parser.DECIMAL - 32)) | (1 << (n3Parser.DOUBLE - 32)) | (1 << (n3Parser.IPLSTART - 32)) | (1 << (n3Parser.ANON - 32)) | (1 << (n3Parser.QuickVarName - 32)) | (1 << (n3Parser.BASE - 32)) | (1 << (n3Parser.PREFIX - 32)))) !== 0)) { + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3205824524) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & 203779) !== 0)) { this.state = 200; this.formulaContent(); } @@ -1130,7 +1130,7 @@ export default class n3Parser extends antlr4.Parser { this.enterOuterAlt(localctx, 1); this.state = 205; _la = this._input.LA(1); - if(!(((((_la - 31)) & ~0x1f) == 0 && ((1 << (_la - 31)) & ((1 << (n3Parser.INTEGER - 31)) | (1 << (n3Parser.DECIMAL - 31)) | (1 << (n3Parser.DOUBLE - 31)))) !== 0))) { + if(!(((((_la - 31)) & ~0x1f) == 0 && ((1 << (_la - 31)) & 7) !== 0))) { this._errHandler.recoverInline(this); } else { @@ -1163,47 +1163,47 @@ export default class n3Parser extends antlr4.Parser { this.state = 211; this._errHandler.sync(this); switch (this._input.LA(1)) { - case n3Parser.LANGTAG: + case 30: this.state = 208; this.match(n3Parser.LANGTAG); break; - case n3Parser.T__21: + case 22: this.state = 209; this.match(n3Parser.T__21); this.state = 210; this.iri(); break; - case n3Parser.T__0: - case n3Parser.T__3: - case n3Parser.T__4: - case n3Parser.T__5: - case n3Parser.T__6: - case n3Parser.T__7: - case n3Parser.T__8: - case n3Parser.T__9: - case n3Parser.T__10: - case n3Parser.T__11: - case n3Parser.T__12: - case n3Parser.T__13: - case n3Parser.T__14: - case n3Parser.T__15: - case n3Parser.T__16: - case n3Parser.T__17: - case n3Parser.T__18: - case n3Parser.T__19: - case n3Parser.T__20: - case n3Parser.BooleanLiteral: - case n3Parser.String: - case n3Parser.IRIREF: - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: - case n3Parser.BLANK_NODE_LABEL: - case n3Parser.INTEGER: - case n3Parser.DECIMAL: - case n3Parser.DOUBLE: - case n3Parser.IPLSTART: - case n3Parser.ANON: - case n3Parser.QuickVarName: + case 1: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 31: + case 32: + case 33: + case 42: + case 43: + case 44: break; default: break; @@ -1231,13 +1231,13 @@ export default class n3Parser extends antlr4.Parser { this.state = 215; this._errHandler.sync(this); switch(this._input.LA(1)) { - case n3Parser.IRIREF: + case 26: this.enterOuterAlt(localctx, 1); this.state = 213; this.match(n3Parser.IRIREF); break; - case n3Parser.PNAME_NS: - case n3Parser.PNAME_LN: + case 27: + case 28: this.enterOuterAlt(localctx, 2); this.state = 214; this.prefixedName(); @@ -1269,7 +1269,7 @@ export default class n3Parser extends antlr4.Parser { this.enterOuterAlt(localctx, 1); this.state = 217; _la = this._input.LA(1); - if(!(_la===n3Parser.PNAME_NS || _la===n3Parser.PNAME_LN)) { + if(!(_la===27 || _la===28)) { this._errHandler.recoverInline(this); } else { @@ -1300,7 +1300,7 @@ export default class n3Parser extends antlr4.Parser { this.enterOuterAlt(localctx, 1); this.state = 219; _la = this._input.LA(1); - if(!(_la===n3Parser.BLANK_NODE_LABEL || _la===n3Parser.ANON)) { + if(!(_la===29 || _la===43)) { this._errHandler.recoverInline(this); } else { diff --git a/editor/parser/n3/n3PrintVisitor.js b/editor/parser/n3/n3PrintVisitor.js index be93657..d6c207f 100644 --- a/editor/parser/n3/n3PrintVisitor.js +++ b/editor/parser/n3/n3PrintVisitor.js @@ -5,280 +5,287 @@ import n3Parser from './n3Parser'; export default class n3PrintVisitor extends n3Visitor { - constructor(listener) { - super(); + constructor(listener) { + super(); - this.listener = listener; - this.lvl = 0 - } - - // Visit a parse tree produced by n3Parser#n3Doc. - visitN3Doc(ctx) { - this.print("N3Doc") - return this.doVisitChildren(ctx) - } + this.listener = listener; + this.lvl = 0 + } + // Visit a parse tree produced by n3Parser#n3Doc. + visitN3Doc(ctx) { + this.print("N3Doc") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#n3Statement. - visitN3Statement(ctx) { - this.print("N3Statement") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#n3Statement. + visitN3Statement(ctx) { + this.print("N3Statement") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#n3Directive. - visitN3Directive(ctx) { - this.print("N3Directive") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#n3Directive. + visitN3Directive(ctx) { + this.print("N3Directive") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#sparqlDirective. - visitSparqlDirective(ctx) { - this.print("SparqlDirective") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#sparqlDirective. + visitSparqlDirective(ctx) { + this.print("SparqlDirective") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#sparqlBase. - visitSparqlBase(ctx) { - this.print("SparqlBase") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#sparqlBase. + visitSparqlBase(ctx) { + this.print("SparqlBase") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#sparqlPrefix. - visitSparqlPrefix(ctx) { - this.print("SparqlPrefix") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#sparqlPrefix. + visitSparqlPrefix(ctx) { + this.print("SparqlPrefix") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#prefixID. - visitPrefixID(ctx) { - this.print("PrefixID") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#prefixID. + visitPrefixID(ctx) { + this.print("PrefixID") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#base. - visitBase(ctx) { - this.print("Base") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#base. + visitBase(ctx) { + this.print("Base") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#triples. - visitTriples(ctx) { - this.print("Triples") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#triples. + visitTriples(ctx) { + this.print("Triples") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#predicateObjectList. - visitPredicateObjectList(ctx) { - this.print("PredicateObjectList") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#predicateObjectList. + visitPredicateObjectList(ctx) { + this.print("PredicateObjectList") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#objectList. - visitObjectList(ctx) { - this.print("ObjectList") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#objectList. + visitObjectList(ctx) { + this.print("ObjectList") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#verb. - visitVerb(ctx) { - this.print("Verb") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#verb. + visitVerb(ctx) { + this.print("Verb") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#subject. - visitSubject(ctx) { - this.print("Subject") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#subject. + visitSubject(ctx) { + this.print("Subject") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#predicate. - visitPredicate(ctx) { - this.print("Predicate") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#predicate. + visitPredicate(ctx) { + this.print("Predicate") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#object. - visitObject(ctx) { - this.print("Object") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#object. + visitObject(ctx) { + this.print("Object") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#expression. - visitExpression(ctx) { - this.print("Expression") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#expression. + visitExpression(ctx) { + this.print("Expression") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#path. - visitPath(ctx) { - this.print("Path") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#path. + visitPath(ctx) { + this.print("Path") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#pathItem. - visitPathItem(ctx) { - this.print("PathItem") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#pathItem. + visitPathItem(ctx) { + this.print("PathItem") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#literal. - visitLiteral(ctx) { - this.print("Literal") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#literal. + visitLiteral(ctx) { + this.print("Literal") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#blankNodePropertyList. - visitBlankNodePropertyList(ctx) { - this.print("BlankNodePropertyList") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + this.print("BlankNodePropertyList") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#collection. - visitCollection(ctx) { - this.print("Collection") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#iriPropertyList. + visitIriPropertyList(ctx) { + this.print("IriPropertyList") + return this.visitChildren(ctx); + } - // Visit a parse tree produced by n3Parser#formula. - visitFormula(ctx) { - this.print("Formula") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#collection. + visitCollection(ctx) { + this.print("Collection") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#formulaContent. - visitFormulaContent(ctx) { - this.print("FormulaContent") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#formula. + visitFormula(ctx) { + this.print("Formula") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#numericLiteral. - visitNumericLiteral(ctx) { - this.print("NumericLiteral") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#formulaContent. + visitFormulaContent(ctx) { + this.print("FormulaContent") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#rdfLiteral. - visitRdfLiteral(ctx) { - this.print("RdfLiteral") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#numericLiteral. + visitNumericLiteral(ctx) { + this.print("NumericLiteral") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#iri. - visitIri(ctx) { - this.print("Iri") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#rdfLiteral. + visitRdfLiteral(ctx) { + this.print("RdfLiteral") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#iriList. - visitIriList(ctx) { - this.print("IriList") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#iri. + visitIri(ctx) { + this.print("Iri") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#prefixedName. - visitPrefixedName(ctx) { - this.print("PrefixedName") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#iriList. + visitIriList(ctx) { + this.print("IriList") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#blankNode. - visitBlankNode(ctx) { - this.print("BlankNode") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#prefixedName. + visitPrefixedName(ctx) { + this.print("PrefixedName") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#quickVar. - visitQuickVar(ctx) { - this.print("QuickVar") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#blankNode. + visitBlankNode(ctx) { + this.print("BlankNode") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#existential. - visitExistential(ctx) { - this.print("Existential") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#quickVar. + visitQuickVar(ctx) { + this.print("QuickVar") + return this.doVisitChildren(ctx) + } - // Visit a parse tree produced by n3Parser#universal. - visitUniversal(ctx) { - this.print("Universal") - return this.doVisitChildren(ctx) - } + // Visit a parse tree produced by n3Parser#existential. + visitExistential(ctx) { + this.print("Existential") + return this.doVisitChildren(ctx) + } - incrLvl() { - this.lvl++; - } - decrLvl() { - this.lvl--; - } + // Visit a parse tree produced by n3Parser#universal. + visitUniversal(ctx) { + this.print("Universal") + return this.doVisitChildren(ctx) + } - print(el) { - var ws = new Array(this.lvl + 1).join(" "); - var out = ws + el + "\n"; - this.listener.newAstLine(out); - } + incrLvl() { + this.lvl++; + } - doVisitChildren(ctx) { - this.lvl++; - this.visitChildren(ctx); - this.lvl--; - } + decrLvl() { + this.lvl--; + } - visitChildren(node) { - var result = null; // this.defaultResult() - var n = node.getChildCount() - for (var i = 0; i < n; i++) { - // if (!this.shouldVisitNextChild(node, result)) { - // break - // } + print(el) { + var ws = new Array(this.lvl + 1).join(" "); + var out = ws + el + "\n"; - var c = node.getChild(i) - if (c.symbol !== undefined) { - var out = "' " + c + " '"; - var type = c.symbol.type - if (type != -1 && n3Parser.symbolicNames[type] !== null) - out += " (" + n3Parser.symbolicNames[type] + ")" - this.print(out) + this.listener.newAstLine(out); + } - } else { - result = c.accept(this); - // result = this.aggregateResult(result, childResult); - } + doVisitChildren(ctx) { + this.lvl++; + this.visitChildren(ctx); + this.lvl--; } - return result - } + visitChildren(node) { + var result = null; // this.defaultResult() + var n = node.getChildCount() + for (var i = 0; i < n; i++) { + // if (!this.shouldVisitNextChild(node, result)) { + // break + // } + + var c = node.getChild(i) + if (c.symbol !== undefined) { + var out = "' " + c + " '"; + var type = c.symbol.type + if (type != -1 && n3Parser.symbolicNames[type] !== null) + out += " (" + n3Parser.symbolicNames[type] + ")" + this.print(out) + + } else { + result = c.accept(this); + // result = this.aggregateResult(result, childResult); + } + } + + return result + } } \ No newline at end of file diff --git a/editor/parser/n3/n3Visitor.js b/editor/parser/n3/n3Visitor.js index f658fda..724274d 100644 --- a/editor/parser/n3/n3Visitor.js +++ b/editor/parser/n3/n3Visitor.js @@ -1,4 +1,4 @@ -// Generated from n3.g4 by ANTLR 4.10.1 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start import antlr4 from 'antlr4'; diff --git a/editor/parser/n3_nodrop/index.js b/editor/parser/n3_nodrop/index.js new file mode 100644 index 0000000..acfe75a --- /dev/null +++ b/editor/parser/n3_nodrop/index.js @@ -0,0 +1,66 @@ +// - CommonJS +// var antlr4 = require('antlr4'); +// var N3Lexer = require('./n3_nodropLexer').n3Lexer; +// var N3Parser = require('./n3_nodropParser').n3Parser; +// var N3PrefixListener = require('./n3_nodropPrefixListener').n3PrefixListener; +// var N3PrintListener = require('./n3_nodropPrintListener').n3PrintListener; +// var N3PrintVisitor = require('./n3_nodropPrintVisitor').n3PrintVisitor; + +// - ES6 +import InputStream from 'antlr4/src/antlr4/InputStream'; +import CommonTokenStream from 'antlr4/src/antlr4/CommonTokenStream'; +import N3Lexer from './n3_nodropLexer'; +import N3Parser from './n3_nodropParser'; +import N3PrefixListener from './n3_nodropPrefixListener'; +import N3PrintVisitor from './n3_nodropPrintVisitor'; +import N3FormatVisitor from './n3_nodropFormatVisitor'; + +// re-generate n3_nodrop: +// (base) wvw@Williams-MBP n3_nodrop % java -jar ~/git/antlr4/antlr-4.10.1-complete.jar -Dlanguage=JavaScript ~/git/n3/N3/grammar/n3_nodrop.g4 -visitor -o ./ + +export function parse(input, listener) { + var chars = new InputStream(input); + + var n3Lexer = new N3Lexer(chars); + n3Lexer.removeErrorListeners(); + n3Lexer.addErrorListener(listener); + + var tokens = new CommonTokenStream(n3Lexer); + + var n3Parser = new N3Parser(tokens); + n3Parser.removeErrorListeners(); + n3Parser.removeParseListeners(); + + if (listener.syntaxError) + // will call listener with any syntax (parser/lexer) error + n3Parser.addErrorListener(listener); + + if (listener.unknownPrefix) + // will call listener with any prefix errors + n3Parser.addParseListener(new N3PrefixListener(listener)); + + // if (listener.newAstLine) + // // will call listener with individual ast lines + // n3Parser.addParseListener(new N3PrintListener(listener)); + + var ast = n3Parser.n3Doc() + if (listener.newAstLine) + new N3PrintVisitor(listener).visit(ast) +} + +export function format(input, config) { + var chars = new InputStream(input); + + var n3Lexer = new N3Lexer(chars); + var tokens = new CommonTokenStream(n3Lexer); + + var n3Parser = new N3Parser(tokens); + + let ast = n3Parser.n3Doc(); + // return ast; + + var visitor = new N3FormatVisitor(config, tokens, n3Parser); + return visitor.visitN3Doc(ast); +} + +// exports.parse = parse; \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodrop.interp b/editor/parser/n3_nodrop/n3_nodrop.interp new file mode 100644 index 0000000..06712de --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodrop.interp @@ -0,0 +1,151 @@ +token literal names: +null +'.' +'@prefix' +'@base' +';' +',' +'a' +'has' +'is' +'of' +'=' +'<=' +'=>' +'<-' +'!' +'^' +'[' +']' +'(' +')' +'{' +'}' +'^^' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +COMMENT +BooleanLiteral +String +IRIREF +PNAME_NS +PNAME_LN +BLANK_NODE_LABEL +LANGTAG +INTEGER +DECIMAL +DOUBLE +EXPONENT +STRING_LITERAL_LONG_SINGLE_QUOTE +STRING_LITERAL_LONG_QUOTE +STRING_LITERAL_QUOTE +STRING_LITERAL_SINGLE_QUOTE +UCHAR +ECHAR +WS +IPLSTART +ANON +QuickVarName +PN_CHARS_U +PN_CHARS_BASE +PN_CHARS +BASE +PREFIX +PN_PREFIX +PN_LOCAL +PLX +PERCENT +HEX +PN_LOCAL_ESC + +rule names: +n3Doc +n3Statement +n3Directive +sparqlDirective +sparqlBase +sparqlPrefix +prefixID +base +triples +predicateObjectList +objectList +verb +subject +predicate +object +expression +path +pathItem +literal +blankNodePropertyList +iriPropertyList +collection +formula +formulaContent +numericLiteral +rdfLiteral +iri +prefixedName +blankNode +quickVar + + +atn: +[4, 1, 55, 224, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 65, 8, 0, 10, 0, 12, 0, 68, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 74, 8, 1, 1, 2, 1, 2, 3, 2, 78, 8, 2, 1, 3, 1, 3, 3, 3, 82, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 3, 8, 100, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 108, 8, 9, 5, 9, 110, 8, 9, 10, 9, 12, 9, 113, 9, 9, 1, 10, 1, 10, 1, 10, 5, 10, 118, 8, 10, 10, 10, 12, 10, 121, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 134, 8, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 3, 13, 141, 8, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 152, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 162, 8, 17, 1, 18, 1, 18, 1, 18, 3, 18, 167, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 5, 21, 180, 8, 21, 10, 21, 12, 21, 183, 9, 21, 1, 21, 1, 21, 1, 22, 1, 22, 3, 22, 189, 8, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 3, 23, 196, 8, 23, 3, 23, 198, 8, 23, 1, 23, 1, 23, 3, 23, 202, 8, 23, 3, 23, 204, 8, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 212, 8, 25, 1, 26, 1, 26, 3, 26, 216, 8, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 0, 0, 30, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 0, 3, 1, 0, 31, 33, 1, 0, 27, 28, 2, 0, 29, 29, 43, 43, 229, 0, 66, 1, 0, 0, 0, 2, 73, 1, 0, 0, 0, 4, 77, 1, 0, 0, 0, 6, 81, 1, 0, 0, 0, 8, 83, 1, 0, 0, 0, 10, 86, 1, 0, 0, 0, 12, 90, 1, 0, 0, 0, 14, 94, 1, 0, 0, 0, 16, 97, 1, 0, 0, 0, 18, 101, 1, 0, 0, 0, 20, 114, 1, 0, 0, 0, 22, 133, 1, 0, 0, 0, 24, 135, 1, 0, 0, 0, 26, 140, 1, 0, 0, 0, 28, 142, 1, 0, 0, 0, 30, 144, 1, 0, 0, 0, 32, 146, 1, 0, 0, 0, 34, 161, 1, 0, 0, 0, 36, 166, 1, 0, 0, 0, 38, 168, 1, 0, 0, 0, 40, 172, 1, 0, 0, 0, 42, 177, 1, 0, 0, 0, 44, 186, 1, 0, 0, 0, 46, 203, 1, 0, 0, 0, 48, 205, 1, 0, 0, 0, 50, 207, 1, 0, 0, 0, 52, 215, 1, 0, 0, 0, 54, 217, 1, 0, 0, 0, 56, 219, 1, 0, 0, 0, 58, 221, 1, 0, 0, 0, 60, 61, 3, 2, 1, 0, 61, 62, 5, 1, 0, 0, 62, 65, 1, 0, 0, 0, 63, 65, 3, 6, 3, 0, 64, 60, 1, 0, 0, 0, 64, 63, 1, 0, 0, 0, 65, 68, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 69, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 69, 70, 5, 0, 0, 1, 70, 1, 1, 0, 0, 0, 71, 74, 3, 4, 2, 0, 72, 74, 3, 16, 8, 0, 73, 71, 1, 0, 0, 0, 73, 72, 1, 0, 0, 0, 74, 3, 1, 0, 0, 0, 75, 78, 3, 12, 6, 0, 76, 78, 3, 14, 7, 0, 77, 75, 1, 0, 0, 0, 77, 76, 1, 0, 0, 0, 78, 5, 1, 0, 0, 0, 79, 82, 3, 8, 4, 0, 80, 82, 3, 10, 5, 0, 81, 79, 1, 0, 0, 0, 81, 80, 1, 0, 0, 0, 82, 7, 1, 0, 0, 0, 83, 84, 5, 48, 0, 0, 84, 85, 5, 26, 0, 0, 85, 9, 1, 0, 0, 0, 86, 87, 5, 49, 0, 0, 87, 88, 5, 27, 0, 0, 88, 89, 5, 26, 0, 0, 89, 11, 1, 0, 0, 0, 90, 91, 5, 2, 0, 0, 91, 92, 5, 27, 0, 0, 92, 93, 5, 26, 0, 0, 93, 13, 1, 0, 0, 0, 94, 95, 5, 3, 0, 0, 95, 96, 5, 26, 0, 0, 96, 15, 1, 0, 0, 0, 97, 99, 3, 24, 12, 0, 98, 100, 3, 18, 9, 0, 99, 98, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 17, 1, 0, 0, 0, 101, 102, 3, 22, 11, 0, 102, 111, 3, 20, 10, 0, 103, 107, 5, 4, 0, 0, 104, 105, 3, 22, 11, 0, 105, 106, 3, 20, 10, 0, 106, 108, 1, 0, 0, 0, 107, 104, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 110, 1, 0, 0, 0, 109, 103, 1, 0, 0, 0, 110, 113, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 19, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 114, 119, 3, 28, 14, 0, 115, 116, 5, 5, 0, 0, 116, 118, 3, 28, 14, 0, 117, 115, 1, 0, 0, 0, 118, 121, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 21, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 122, 134, 3, 26, 13, 0, 123, 134, 5, 6, 0, 0, 124, 125, 5, 7, 0, 0, 125, 134, 3, 30, 15, 0, 126, 127, 5, 8, 0, 0, 127, 128, 3, 30, 15, 0, 128, 129, 5, 9, 0, 0, 129, 134, 1, 0, 0, 0, 130, 134, 5, 10, 0, 0, 131, 134, 5, 11, 0, 0, 132, 134, 5, 12, 0, 0, 133, 122, 1, 0, 0, 0, 133, 123, 1, 0, 0, 0, 133, 124, 1, 0, 0, 0, 133, 126, 1, 0, 0, 0, 133, 130, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 133, 132, 1, 0, 0, 0, 134, 23, 1, 0, 0, 0, 135, 136, 3, 30, 15, 0, 136, 25, 1, 0, 0, 0, 137, 141, 3, 30, 15, 0, 138, 139, 5, 13, 0, 0, 139, 141, 3, 30, 15, 0, 140, 137, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 141, 27, 1, 0, 0, 0, 142, 143, 3, 30, 15, 0, 143, 29, 1, 0, 0, 0, 144, 145, 3, 32, 16, 0, 145, 31, 1, 0, 0, 0, 146, 151, 3, 34, 17, 0, 147, 148, 5, 14, 0, 0, 148, 152, 3, 32, 16, 0, 149, 150, 5, 15, 0, 0, 150, 152, 3, 32, 16, 0, 151, 147, 1, 0, 0, 0, 151, 149, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 33, 1, 0, 0, 0, 153, 162, 3, 52, 26, 0, 154, 162, 3, 56, 28, 0, 155, 162, 3, 58, 29, 0, 156, 162, 3, 42, 21, 0, 157, 162, 3, 38, 19, 0, 158, 162, 3, 40, 20, 0, 159, 162, 3, 36, 18, 0, 160, 162, 3, 44, 22, 0, 161, 153, 1, 0, 0, 0, 161, 154, 1, 0, 0, 0, 161, 155, 1, 0, 0, 0, 161, 156, 1, 0, 0, 0, 161, 157, 1, 0, 0, 0, 161, 158, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 161, 160, 1, 0, 0, 0, 162, 35, 1, 0, 0, 0, 163, 167, 3, 50, 25, 0, 164, 167, 3, 48, 24, 0, 165, 167, 5, 24, 0, 0, 166, 163, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 165, 1, 0, 0, 0, 167, 37, 1, 0, 0, 0, 168, 169, 5, 16, 0, 0, 169, 170, 3, 18, 9, 0, 170, 171, 5, 17, 0, 0, 171, 39, 1, 0, 0, 0, 172, 173, 5, 42, 0, 0, 173, 174, 3, 52, 26, 0, 174, 175, 3, 18, 9, 0, 175, 176, 5, 17, 0, 0, 176, 41, 1, 0, 0, 0, 177, 181, 5, 18, 0, 0, 178, 180, 3, 28, 14, 0, 179, 178, 1, 0, 0, 0, 180, 183, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 184, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 185, 5, 19, 0, 0, 185, 43, 1, 0, 0, 0, 186, 188, 5, 20, 0, 0, 187, 189, 3, 46, 23, 0, 188, 187, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 190, 1, 0, 0, 0, 190, 191, 5, 21, 0, 0, 191, 45, 1, 0, 0, 0, 192, 197, 3, 2, 1, 0, 193, 195, 5, 1, 0, 0, 194, 196, 3, 46, 23, 0, 195, 194, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 198, 1, 0, 0, 0, 197, 193, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 204, 1, 0, 0, 0, 199, 201, 3, 6, 3, 0, 200, 202, 3, 46, 23, 0, 201, 200, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 204, 1, 0, 0, 0, 203, 192, 1, 0, 0, 0, 203, 199, 1, 0, 0, 0, 204, 47, 1, 0, 0, 0, 205, 206, 7, 0, 0, 0, 206, 49, 1, 0, 0, 0, 207, 211, 5, 25, 0, 0, 208, 212, 5, 30, 0, 0, 209, 210, 5, 22, 0, 0, 210, 212, 3, 52, 26, 0, 211, 208, 1, 0, 0, 0, 211, 209, 1, 0, 0, 0, 211, 212, 1, 0, 0, 0, 212, 51, 1, 0, 0, 0, 213, 216, 5, 26, 0, 0, 214, 216, 3, 54, 27, 0, 215, 213, 1, 0, 0, 0, 215, 214, 1, 0, 0, 0, 216, 53, 1, 0, 0, 0, 217, 218, 7, 1, 0, 0, 218, 55, 1, 0, 0, 0, 219, 220, 7, 2, 0, 0, 220, 57, 1, 0, 0, 0, 221, 222, 5, 44, 0, 0, 222, 59, 1, 0, 0, 0, 22, 64, 66, 73, 77, 81, 99, 107, 111, 119, 133, 140, 151, 161, 166, 181, 188, 195, 197, 201, 203, 211, 215] \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodrop.tokens b/editor/parser/n3_nodrop/n3_nodrop.tokens new file mode 100644 index 0000000..6857ac6 --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodrop.tokens @@ -0,0 +1,77 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +T__9=10 +T__10=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +COMMENT=23 +BooleanLiteral=24 +String=25 +IRIREF=26 +PNAME_NS=27 +PNAME_LN=28 +BLANK_NODE_LABEL=29 +LANGTAG=30 +INTEGER=31 +DECIMAL=32 +DOUBLE=33 +EXPONENT=34 +STRING_LITERAL_LONG_SINGLE_QUOTE=35 +STRING_LITERAL_LONG_QUOTE=36 +STRING_LITERAL_QUOTE=37 +STRING_LITERAL_SINGLE_QUOTE=38 +UCHAR=39 +ECHAR=40 +WS=41 +IPLSTART=42 +ANON=43 +QuickVarName=44 +PN_CHARS_U=45 +PN_CHARS_BASE=46 +PN_CHARS=47 +BASE=48 +PREFIX=49 +PN_PREFIX=50 +PN_LOCAL=51 +PLX=52 +PERCENT=53 +HEX=54 +PN_LOCAL_ESC=55 +'.'=1 +'@prefix'=2 +'@base'=3 +';'=4 +','=5 +'a'=6 +'has'=7 +'is'=8 +'of'=9 +'='=10 +'<='=11 +'=>'=12 +'<-'=13 +'!'=14 +'^'=15 +'['=16 +']'=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'^^'=22 diff --git a/editor/parser/n3_nodrop/n3_nodropFormatVisitor.js b/editor/parser/n3_nodrop/n3_nodropFormatVisitor.js new file mode 100644 index 0000000..a4e8270 --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropFormatVisitor.js @@ -0,0 +1,704 @@ +import n3_nodropVisitor from './n3_nodropVisitor'; +// import n3_nodropParser from './n3_nodropParser'; + +export default class n3_nodropFormatVisitor extends n3_nodropVisitor { + + static CHANNEL_WHITESPACE = 1; + static CHANNEL_COMMENT = 2; + + static DIR_LEFT = 1; + static DIR_RIGHT = 2; + + constructor(config, tokens, n3Parser) { + super(); + + this.config = config; + this.tokens = tokens; + this.n3Parser = n3Parser; + + this.str = ""; + this.indent = 0; + + if (config.formatNamespaces) { + this.ns = {}; + this.base = ""; + } + } + + callAccept(child) { + child.accept(this); + } + + // Visit a parse tree produced by n3Parser#n3Doc. + visitN3Doc(ctx) { + this.logVisit("N3Doc"); + + // get comment at start of document, if any + let startCmt = this.leftComment(ctx.children[0]); + + this.doVisitGraphContents(ctx); + + // TODO integrate all these re-assignments into visit checks + // (currently we cannot "stream" output) + + // - drop newlines between "}" and "." + this.str = this.str.replace(/\}\n\s*\./g, "} ."); + + if (this.config.formatNamespaces) + this.printNamespaces(); + + if (startCmt) + this.str = startCmt + this.str; + + return this.str; + } + + printNamespaces() { + let prefixes = Object.keys(this.ns); + prefixes.sort(); + + let preamble = prefixes.map(prefix => + `@prefix ${prefix} ${this.ns[prefix]} .` + ).join("\n"); + + if (this.base) { + if (preamble) + preamble += "\n"; + preamble += `@base ${this.base} .`; + } + + if (preamble == "") + return; + + // not starting with comment + // (in that case, comment is in charge of newlines) + if (!/^\s*#/.test(this.str)) + preamble += "\n\n"; + + this.str = preamble + this.str; + } + + // Visit a parse tree produced by n3Parser#n3Statement. + visitN3Statement(ctx) { + this.logVisit("N3Statement"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#n3Directive. + visitN3Directive(ctx) { + this.logVisit("N3Directive"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlDirective. + visitSparqlDirective(ctx) { + this.logVisit("SparqlDirective"); + this.doVisitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlBase. + visitSparqlBase(ctx) { + this.logVisit("SparqlBase"); + + this.doVisitBase(ctx); + } + + + // Visit a parse tree produced by n3Parser#sparqlPrefix. + visitSparqlPrefix(ctx) { + this.logVisit("SparqlPrefix"); + + this.doVisitPrefix(ctx); + } + + + // Visit a parse tree produced by n3Parser#prefixID. + visitPrefixID(ctx) { + this.logVisit("PrefixID"); + + this.doVisitPrefix(ctx); + } + + + // Visit a parse tree produced by n3Parser#base. + visitBase(ctx) { + this.logVisit("Base"); + + this.doVisitBase(ctx); + } + + + doVisitBase(ctx) { + if (this.config.formatNamespaces) + this.base = ctx.children[1].toString(); + else + this.doVisitChildren(ctx, " "); + } + + + doVisitPrefix(ctx) { + if (this.config.formatNamespaces) { + let prefix = ctx.children[1].toString() + let uri = ctx.children[2].toString() + + if (this.ns[prefix]) + console.warn(`WARNING overwriting prefix '${prefix}'`); + + this.ns[prefix] = uri; + + } else + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#triples. + visitTriples(ctx) { + this.logVisit("Triples"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#predicateObjectList. + visitPredicateObjectList(ctx) { + this.logVisit("PredicateObjectList"); + + let indented = false; + ctx.children.forEach(child => { + // terminal ";" + if (child.symbol !== undefined) { + // if needed, increment level + if (!indented) { + // indent taken care of by blankNodePropertyList, iriPropertyList + let name = this.ruleName(ctx.parentCtx) + if (name != "blankNodePropertyList" && + name != "iriPropertyList") { + + indented = true; + this.incrIndent(); + } + } + + // newline after ";"; + this.print(child); + this.appendNewline(); + + } else { + // non-terminal (term) + this.callAccept(child); + this.separate(" "); + } + }); + + // after, decrement level again + if (indented) + this.decrIndent(); + } + + + // Visit a parse tree produced by n3Parser#objectList. + visitObjectList(ctx) { + this.logVisit("ObjectList"); + this.doVisitChildren(ctx, " "); + } + + + // Visit a parse tree produced by n3Parser#verb. + visitVerb(ctx) { + this.logVisit("Verb") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#subject. + visitSubject(ctx) { + this.logVisit("Subject") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicate. + visitPredicate(ctx) { + this.logVisit("Predicate") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#object. + visitObject(ctx) { + this.logVisit("Object") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#expression. + visitExpression(ctx) { + this.logVisit("Expression") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#path. + visitPath(ctx) { + this.logVisit("Path") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#pathItem. + visitPathItem(ctx) { + this.logVisit("PathItem") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#literal. + visitLiteral(ctx) { + this.logVisit("Literal") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + this.logVisit("BlankNodePropertyList"); + + // "[" + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + for (let i = 1; i < ctx.getChildCount() - 1; i++) { + this.callAccept(ctx.getChild(i)); + } + + this.decrIndent(); + + this.appendNewline(); + // "]" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + } + + + // Visit a parse tree produced by n3Parser#iriPropertyList. + visitIriPropertyList(ctx) { + this.logVisit("IriPropertyList") + + // IPLSTART + this.print(ctx.getChild(0)); + + // id + this.separate(" "); + this.callAccept(ctx.getChild(1)); + + this.incrIndent(1); + this.appendNewline(); + + for (let i = 2; i < ctx.getChildCount() - 1; i++) { + this.callAccept(ctx.getChild(i)); + } + + this.decrIndent(1); + + this.appendNewline(); + // "]" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + } + + + // Visit a parse tree produced by n3Parser#collection. + visitCollection(ctx) { + this.logVisit("Collection"); + + // in case of any formula descendants, + // print list contents like bnode property list + if (this.hasSomeDescendant(ctx, "formula")) { + + // "(" + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + for (let i = 1; i < ctx.getChildCount() - 1; i++) { + if (i > 1) + this.appendNewline(); + + this.callAccept(ctx.getChild(i)); + } + + this.decrIndent(); + this.appendNewline(); + + // ")" + this.print(ctx.getChild(ctx.getChildCount() - 1)); + + } else + this.doVisitChildren(ctx, " "); + } + + // Visit a parse tree produced by n3Parser#formula. + visitFormula(ctx) { + this.logVisit("Formula"); + + // empty formula + if (ctx.getChildCount() == 2) { + this.doVisitChildren(ctx); + return + } + + // terminal "{" + if (this.config.graphOnNewline) { + this.appendNewline(); + } + + this.print(ctx.getChild(0)); + + this.incrIndent(); + this.appendNewline(); + + this.callAccept(ctx.getChild(1)); + + this.decrIndent(); + + // terminal "}" + this.appendNewline(); + this.print(ctx.getChild(2)); + + if (this.config.graphOnNewline) { + this.appendNewline(); + } + } + + + // Visit a parse tree produced by n3Parser#formulaContent. + visitFormulaContent(ctx) { + this.logVisit("FormulaContent"); + + this.doVisitGraphContents(ctx); + } + + + // Visit a parse tree produced by n3Parser#numericLiteral. + visitNumericLiteral(ctx) { + this.logVisit("NumericLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#rdfLiteral. + visitRdfLiteral(ctx) { + this.logVisit("RdfLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iri. + visitIri(ctx) { + this.logVisit("Iri") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriList. + visitIriList(ctx) { + this.logVisit("IriList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixedName. + visitPrefixedName(ctx) { + this.logVisit("PrefixedName") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNode. + visitBlankNode(ctx) { + this.logVisit("BlankNode") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#quickVar. + visitQuickVar(ctx) { + this.logVisit("QuickVar") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#existential. + visitExistential(ctx) { + this.logVisit("Existential") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#universal. + visitUniversal(ctx) { + this.logVisit("Universal") + return this.doVisitChildren(ctx) + } + + + incrIndent(plus) { + this.indent += this.config.tab + (plus ? plus : 0); + } + + decrIndent(minus) { + this.indent -= (this.config.tab + (minus ? minus : 0)); + } + + doVisitGraphContents(ctx) { + let n = ctx.getChildCount(); + + // either: + // pairs of n3Statement "." + // or sparqlDirective + // or + for (let i = 0; i < n; i++) { + let child = ctx.getChild(i); + + // console.log(this.getName(child), "skip?", this.skipNode(child)); + + // either terminating "." or + if (child.symbol !== undefined) { + // don't print terminating "." if prior child did not get printed + if (this.skipNode(ctx.getChild(i - 1))) + continue; + + if (child.toString() == "") + continue; + + this.separate(" "); + this.print(child); + // newline for n3Statements after "." + if (i < n - 1) // don't add after last child + this.appendNewline(); + + } else { + // non-terminal + // (n3Statement or sparqlDirective) + this.callAccept(child); + + // newline after sparqlDirectives + // (don't add newline if directive got skipped) + if (this.ruleName(child) == "sparqlDirective" && !this.skipNode(child)) { + if (i < n - 1) // don't add after last child + this.appendNewline(); + } + } + } + } + + // whether a node will not be printed + skipNode(node) { + if (this.config.formatNamespaces) { + if (this.ruleName(node) == "sparqlDirective") + return true; + + if (node.children && node.children.length == 1) { + if (this.ruleName(node.children[0]) == "n3Directive") + return true; + } + + return false; + } + } + + doVisitChildren(ctx, sep) { + this.visitChildren(ctx, sep); + } + + visitChildren(node, sep) { + for (var i = 0; i < node.getChildCount(); i++) { + var child = node.getChild(i); + // console.log("child", child); + + if (sep && i > 0) + this.separate(sep); + + // terminal + if (child.symbol !== undefined) { + this.print(child); + + } else { + // non-terminal + this.callAccept(child); + } + } + } + + + logVisit(el) { + // console.log(el); + } + + logChildren(ctx) { + let out = ctx.children.map(child => { + if (child.symbol) { + return this.symbolName(child); + + } else { + return this.ruleName(child) + } + }); + + console.log("<-", out.join(" ")); + } + + hasSomeDescendant(ctx, name) { + if (this.ruleName(ctx) == name) + return true; + + if (ctx.children) + return ctx.children.some(child => this.hasSomeDescendant(child, name)); + else + return false; + } + + getName(node) { + let name = this.ruleName(node) + if (name) + return name; + else + return this.symbolName(node) + } + + symbolName(node) { + let type = node.symbol.type + let name = this.n3Parser.symbolicNames[type] + if (!name) + name = this.n3Parser.literalNames[type] + + return name + } + + ruleName(node) { + let rule = node.ruleIndex + return this.n3Parser.ruleNames[rule] + } + + appendNewline() { + this.beforeNewNewline(); + + this.str += "\n" + new Array(this.indent).join(" "); + } + + // called whenever a new newline is being added + // (e.g., appendNewline, add left comment) + beforeNewNewline() { + // possible we already end with newline that we ourselves added before + // (e.g., adding newline after closing "}") + // we don't want to add double newlines, so, remove it & its indent + let matches = [...this.str.matchAll(/^([\s\S]*)\n\s*$/g)]; + + if (matches.length > 0) { + this.str = matches[0][1]; + } + } + + separate(sep) { + // don't add space separator after a whitespace + // (e.g., when putting newlines around =>) + if (sep == " " && /.*\s+$/g.test(this.str)) + return; + + this.str += sep; + } + + print(node) { + if (typeof node === 'string') { + this.str += node; + + // for every node we print: + // print comments that come before or after + } else { + let lc = this.leftComment(node); + if (lc.startsWith("\n")) + this.beforeNewNewline(); + this.str += lc; + + this.str += node; + + this.str += this.rightComment(node); + } + } + + // for left side, print all prior comments & newlines until non-hidden token + leftComment(node) { + // includes all comments & newlines until prior non-hidden token + let tokens = this.nextHiddenTokens(node, n3_nodropFormatVisitor.DIR_LEFT); + // there's a comment in there somewhere + if (tokens && tokens.some(t => t.channel == n3_nodropFormatVisitor.CHANNEL_COMMENT)) { + // console.log("hidden-left", tokens, tokens.map(c => c.text)); + + let text = tokens.map(c => c.text).join(""); + // after the last comment, keep only the newlines + // (avoid cases like "#blah\n :a") + text = text.replace(/[ \t]*$/, ""); + + return text; + } + + return ""; + } + + // for right side, print next comment + newline + rightComment(node) { + // includes all comments & newlines until next non-hidden token + let tokens = this.nextHiddenTokens(node, n3_nodropFormatVisitor.DIR_RIGHT); + + // there's a comment in there somewhere + if (tokens && tokens.some(t => t.channel == n3_nodropFormatVisitor.CHANNEL_COMMENT)) { + // console.log("hidden-right", tokens, tokens.map(c => c.text)); + + this.separate(" "); // add ws after whatever we printed before + + let text = tokens.map(c => c.text).join(""); + // keep all whitespaces before first comment & between comments + // (avoid cases like ":c #blah\n :a") + text = text.trimEnd(); + + if (text) + return text + "\n"; + } + + return ""; + } + + nextHiddenTokens(node, dir, channelId) { + let symbol; + if (node.symbol) + symbol = node.symbol + else { + if (dir == n3_nodropFormatVisitor.DIR_LEFT) + symbol = node.start; + else + symbol = node.end; + } + + let idx = symbol.tokenIndex; + + let fn = (dir == n3_nodropFormatVisitor.DIR_LEFT ? + this.tokens.getHiddenTokensToLeft : + this.tokens.getHiddenTokensToRight + ); + + let channel = fn.call(this.tokens, idx, channelId); + if (channel != null) { + // make sure to return tokens only once + // (e.g., right-side comment showing up as left-side comment next) + channel = channel.filter(t => !t.consumed); + channel.forEach(t => t.consumed = true); + + return channel; + } + + return false; + } +} \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodropLexer.interp b/editor/parser/n3_nodrop/n3_nodropLexer.interp new file mode 100644 index 0000000..1932606 --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropLexer.interp @@ -0,0 +1,182 @@ +token literal names: +null +'.' +'@prefix' +'@base' +';' +',' +'a' +'has' +'is' +'of' +'=' +'<=' +'=>' +'<-' +'!' +'^' +'[' +']' +'(' +')' +'{' +'}' +'^^' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +COMMENT +BooleanLiteral +String +IRIREF +PNAME_NS +PNAME_LN +BLANK_NODE_LABEL +LANGTAG +INTEGER +DECIMAL +DOUBLE +EXPONENT +STRING_LITERAL_LONG_SINGLE_QUOTE +STRING_LITERAL_LONG_QUOTE +STRING_LITERAL_QUOTE +STRING_LITERAL_SINGLE_QUOTE +UCHAR +ECHAR +WS +IPLSTART +ANON +QuickVarName +PN_CHARS_U +PN_CHARS_BASE +PN_CHARS +BASE +PREFIX +PN_PREFIX +PN_LOCAL +PLX +PERCENT +HEX +PN_LOCAL_ESC + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +T__9 +T__10 +T__11 +T__12 +T__13 +T__14 +T__15 +T__16 +T__17 +T__18 +T__19 +T__20 +T__21 +COMMENT +BooleanLiteral +String +IRIREF +PNAME_NS +PNAME_LN +BLANK_NODE_LABEL +LANGTAG +INTEGER +DECIMAL +DOUBLE +EXPONENT +STRING_LITERAL_LONG_SINGLE_QUOTE +STRING_LITERAL_LONG_QUOTE +STRING_LITERAL_QUOTE +STRING_LITERAL_SINGLE_QUOTE +UCHAR +ECHAR +WS +IPLSTART +ANON +QuickVarName +PN_CHARS_U +PN_CHARS_BASE +PN_CHARS +BASE +PREFIX +PN_PREFIX +PN_LOCAL +PLX +PERCENT +HEX +PN_LOCAL_ESC + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 55, 506, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 5, 22, 176, 8, 22, 10, 22, 12, 22, 179, 9, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 192, 8, 23, 1, 24, 1, 24, 1, 24, 1, 24, 3, 24, 198, 8, 24, 1, 25, 1, 25, 1, 25, 5, 25, 203, 8, 25, 10, 25, 12, 25, 206, 9, 25, 1, 25, 1, 25, 1, 26, 3, 26, 211, 8, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 223, 8, 28, 1, 28, 1, 28, 5, 28, 227, 8, 28, 10, 28, 12, 28, 230, 9, 28, 1, 28, 3, 28, 233, 8, 28, 1, 29, 1, 29, 4, 29, 237, 8, 29, 11, 29, 12, 29, 238, 1, 29, 1, 29, 4, 29, 243, 8, 29, 11, 29, 12, 29, 244, 5, 29, 247, 8, 29, 10, 29, 12, 29, 250, 9, 29, 1, 30, 3, 30, 253, 8, 30, 1, 30, 4, 30, 256, 8, 30, 11, 30, 12, 30, 257, 1, 31, 3, 31, 261, 8, 31, 1, 31, 5, 31, 264, 8, 31, 10, 31, 12, 31, 267, 9, 31, 1, 31, 1, 31, 4, 31, 271, 8, 31, 11, 31, 12, 31, 272, 1, 32, 3, 32, 276, 8, 32, 1, 32, 4, 32, 279, 8, 32, 11, 32, 12, 32, 280, 1, 32, 1, 32, 5, 32, 285, 8, 32, 10, 32, 12, 32, 288, 9, 32, 1, 32, 1, 32, 1, 32, 4, 32, 293, 8, 32, 11, 32, 12, 32, 294, 1, 32, 1, 32, 4, 32, 299, 8, 32, 11, 32, 12, 32, 300, 1, 32, 3, 32, 304, 8, 32, 1, 33, 1, 33, 3, 33, 308, 8, 33, 1, 33, 4, 33, 311, 8, 33, 11, 33, 12, 33, 312, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 322, 8, 34, 1, 34, 1, 34, 1, 34, 3, 34, 327, 8, 34, 5, 34, 329, 8, 34, 10, 34, 12, 34, 332, 9, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 3, 35, 345, 8, 35, 1, 35, 1, 35, 1, 35, 3, 35, 350, 8, 35, 5, 35, 352, 8, 35, 10, 35, 12, 35, 355, 9, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 365, 8, 36, 10, 36, 12, 36, 368, 9, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 5, 37, 376, 8, 37, 10, 37, 12, 37, 379, 9, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 403, 8, 38, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 5, 41, 414, 8, 41, 10, 41, 12, 41, 417, 9, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 5, 42, 424, 8, 42, 10, 42, 12, 42, 427, 9, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 5, 43, 434, 8, 43, 10, 43, 12, 43, 437, 9, 43, 1, 44, 1, 44, 3, 44, 441, 8, 44, 1, 45, 3, 45, 444, 8, 45, 1, 46, 1, 46, 3, 46, 448, 8, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 5, 49, 465, 8, 49, 10, 49, 12, 49, 468, 9, 49, 1, 49, 3, 49, 471, 8, 49, 1, 50, 1, 50, 1, 50, 3, 50, 476, 8, 50, 1, 50, 1, 50, 1, 50, 5, 50, 481, 8, 50, 10, 50, 12, 50, 484, 9, 50, 1, 50, 1, 50, 1, 50, 3, 50, 489, 8, 50, 3, 50, 491, 8, 50, 1, 51, 1, 51, 3, 51, 495, 8, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 53, 3, 53, 502, 8, 53, 1, 54, 1, 54, 1, 54, 0, 0, 55, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 47, 95, 48, 97, 49, 99, 50, 101, 51, 103, 52, 105, 53, 107, 54, 109, 55, 1, 0, 26, 2, 0, 10, 10, 12, 13, 8, 0, 0, 32, 34, 34, 60, 60, 62, 62, 92, 92, 94, 94, 96, 96, 123, 125, 1, 0, 48, 57, 2, 0, 65, 90, 97, 122, 3, 0, 48, 57, 65, 90, 97, 122, 2, 0, 43, 43, 45, 45, 2, 0, 69, 69, 101, 101, 2, 0, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 4, 0, 10, 10, 13, 13, 34, 34, 92, 92, 4, 0, 10, 10, 13, 13, 39, 39, 92, 92, 8, 0, 34, 34, 39, 39, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 9, 10, 13, 13, 32, 32, 13, 0, 65, 90, 97, 122, 192, 214, 216, 246, 248, 767, 880, 893, 895, 8191, 8204, 8205, 8304, 8591, 11264, 12271, 12289, 55295, 63744, 64975, 65008, 65533, 5, 0, 45, 45, 48, 57, 183, 183, 768, 879, 8255, 8256, 2, 0, 66, 66, 98, 98, 2, 0, 65, 65, 97, 97, 2, 0, 83, 83, 115, 115, 2, 0, 80, 80, 112, 112, 2, 0, 82, 82, 114, 114, 2, 0, 70, 70, 102, 102, 2, 0, 73, 73, 105, 105, 2, 0, 88, 88, 120, 120, 2, 0, 46, 46, 58, 58, 3, 0, 48, 57, 65, 70, 97, 102, 7, 0, 33, 33, 35, 47, 59, 59, 61, 61, 63, 64, 95, 95, 126, 126, 568, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 0, 97, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 0, 107, 1, 0, 0, 0, 0, 109, 1, 0, 0, 0, 1, 111, 1, 0, 0, 0, 3, 113, 1, 0, 0, 0, 5, 121, 1, 0, 0, 0, 7, 127, 1, 0, 0, 0, 9, 129, 1, 0, 0, 0, 11, 131, 1, 0, 0, 0, 13, 133, 1, 0, 0, 0, 15, 137, 1, 0, 0, 0, 17, 140, 1, 0, 0, 0, 19, 143, 1, 0, 0, 0, 21, 145, 1, 0, 0, 0, 23, 148, 1, 0, 0, 0, 25, 151, 1, 0, 0, 0, 27, 154, 1, 0, 0, 0, 29, 156, 1, 0, 0, 0, 31, 158, 1, 0, 0, 0, 33, 160, 1, 0, 0, 0, 35, 162, 1, 0, 0, 0, 37, 164, 1, 0, 0, 0, 39, 166, 1, 0, 0, 0, 41, 168, 1, 0, 0, 0, 43, 170, 1, 0, 0, 0, 45, 173, 1, 0, 0, 0, 47, 191, 1, 0, 0, 0, 49, 197, 1, 0, 0, 0, 51, 199, 1, 0, 0, 0, 53, 210, 1, 0, 0, 0, 55, 214, 1, 0, 0, 0, 57, 217, 1, 0, 0, 0, 59, 234, 1, 0, 0, 0, 61, 252, 1, 0, 0, 0, 63, 260, 1, 0, 0, 0, 65, 275, 1, 0, 0, 0, 67, 305, 1, 0, 0, 0, 69, 314, 1, 0, 0, 0, 71, 337, 1, 0, 0, 0, 73, 360, 1, 0, 0, 0, 75, 371, 1, 0, 0, 0, 77, 402, 1, 0, 0, 0, 79, 404, 1, 0, 0, 0, 81, 407, 1, 0, 0, 0, 83, 411, 1, 0, 0, 0, 85, 421, 1, 0, 0, 0, 87, 430, 1, 0, 0, 0, 89, 440, 1, 0, 0, 0, 91, 443, 1, 0, 0, 0, 93, 447, 1, 0, 0, 0, 95, 449, 1, 0, 0, 0, 97, 454, 1, 0, 0, 0, 99, 461, 1, 0, 0, 0, 101, 475, 1, 0, 0, 0, 103, 494, 1, 0, 0, 0, 105, 496, 1, 0, 0, 0, 107, 501, 1, 0, 0, 0, 109, 503, 1, 0, 0, 0, 111, 112, 5, 46, 0, 0, 112, 2, 1, 0, 0, 0, 113, 114, 5, 64, 0, 0, 114, 115, 5, 112, 0, 0, 115, 116, 5, 114, 0, 0, 116, 117, 5, 101, 0, 0, 117, 118, 5, 102, 0, 0, 118, 119, 5, 105, 0, 0, 119, 120, 5, 120, 0, 0, 120, 4, 1, 0, 0, 0, 121, 122, 5, 64, 0, 0, 122, 123, 5, 98, 0, 0, 123, 124, 5, 97, 0, 0, 124, 125, 5, 115, 0, 0, 125, 126, 5, 101, 0, 0, 126, 6, 1, 0, 0, 0, 127, 128, 5, 59, 0, 0, 128, 8, 1, 0, 0, 0, 129, 130, 5, 44, 0, 0, 130, 10, 1, 0, 0, 0, 131, 132, 5, 97, 0, 0, 132, 12, 1, 0, 0, 0, 133, 134, 5, 104, 0, 0, 134, 135, 5, 97, 0, 0, 135, 136, 5, 115, 0, 0, 136, 14, 1, 0, 0, 0, 137, 138, 5, 105, 0, 0, 138, 139, 5, 115, 0, 0, 139, 16, 1, 0, 0, 0, 140, 141, 5, 111, 0, 0, 141, 142, 5, 102, 0, 0, 142, 18, 1, 0, 0, 0, 143, 144, 5, 61, 0, 0, 144, 20, 1, 0, 0, 0, 145, 146, 5, 60, 0, 0, 146, 147, 5, 61, 0, 0, 147, 22, 1, 0, 0, 0, 148, 149, 5, 61, 0, 0, 149, 150, 5, 62, 0, 0, 150, 24, 1, 0, 0, 0, 151, 152, 5, 60, 0, 0, 152, 153, 5, 45, 0, 0, 153, 26, 1, 0, 0, 0, 154, 155, 5, 33, 0, 0, 155, 28, 1, 0, 0, 0, 156, 157, 5, 94, 0, 0, 157, 30, 1, 0, 0, 0, 158, 159, 5, 91, 0, 0, 159, 32, 1, 0, 0, 0, 160, 161, 5, 93, 0, 0, 161, 34, 1, 0, 0, 0, 162, 163, 5, 40, 0, 0, 163, 36, 1, 0, 0, 0, 164, 165, 5, 41, 0, 0, 165, 38, 1, 0, 0, 0, 166, 167, 5, 123, 0, 0, 167, 40, 1, 0, 0, 0, 168, 169, 5, 125, 0, 0, 169, 42, 1, 0, 0, 0, 170, 171, 5, 94, 0, 0, 171, 172, 5, 94, 0, 0, 172, 44, 1, 0, 0, 0, 173, 177, 5, 35, 0, 0, 174, 176, 8, 0, 0, 0, 175, 174, 1, 0, 0, 0, 176, 179, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 180, 1, 0, 0, 0, 179, 177, 1, 0, 0, 0, 180, 181, 6, 22, 0, 0, 181, 46, 1, 0, 0, 0, 182, 183, 5, 116, 0, 0, 183, 184, 5, 114, 0, 0, 184, 185, 5, 117, 0, 0, 185, 192, 5, 101, 0, 0, 186, 187, 5, 102, 0, 0, 187, 188, 5, 97, 0, 0, 188, 189, 5, 108, 0, 0, 189, 190, 5, 115, 0, 0, 190, 192, 5, 101, 0, 0, 191, 182, 1, 0, 0, 0, 191, 186, 1, 0, 0, 0, 192, 48, 1, 0, 0, 0, 193, 198, 3, 73, 36, 0, 194, 198, 3, 75, 37, 0, 195, 198, 3, 69, 34, 0, 196, 198, 3, 71, 35, 0, 197, 193, 1, 0, 0, 0, 197, 194, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 197, 196, 1, 0, 0, 0, 198, 50, 1, 0, 0, 0, 199, 204, 5, 60, 0, 0, 200, 203, 8, 1, 0, 0, 201, 203, 3, 77, 38, 0, 202, 200, 1, 0, 0, 0, 202, 201, 1, 0, 0, 0, 203, 206, 1, 0, 0, 0, 204, 202, 1, 0, 0, 0, 204, 205, 1, 0, 0, 0, 205, 207, 1, 0, 0, 0, 206, 204, 1, 0, 0, 0, 207, 208, 5, 62, 0, 0, 208, 52, 1, 0, 0, 0, 209, 211, 3, 99, 49, 0, 210, 209, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 212, 1, 0, 0, 0, 212, 213, 5, 58, 0, 0, 213, 54, 1, 0, 0, 0, 214, 215, 3, 53, 26, 0, 215, 216, 3, 101, 50, 0, 216, 56, 1, 0, 0, 0, 217, 218, 5, 95, 0, 0, 218, 219, 5, 58, 0, 0, 219, 222, 1, 0, 0, 0, 220, 223, 3, 89, 44, 0, 221, 223, 7, 2, 0, 0, 222, 220, 1, 0, 0, 0, 222, 221, 1, 0, 0, 0, 223, 232, 1, 0, 0, 0, 224, 227, 3, 93, 46, 0, 225, 227, 5, 46, 0, 0, 226, 224, 1, 0, 0, 0, 226, 225, 1, 0, 0, 0, 227, 230, 1, 0, 0, 0, 228, 226, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 231, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 231, 233, 3, 93, 46, 0, 232, 228, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 58, 1, 0, 0, 0, 234, 236, 5, 64, 0, 0, 235, 237, 7, 3, 0, 0, 236, 235, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 236, 1, 0, 0, 0, 238, 239, 1, 0, 0, 0, 239, 248, 1, 0, 0, 0, 240, 242, 5, 45, 0, 0, 241, 243, 7, 4, 0, 0, 242, 241, 1, 0, 0, 0, 243, 244, 1, 0, 0, 0, 244, 242, 1, 0, 0, 0, 244, 245, 1, 0, 0, 0, 245, 247, 1, 0, 0, 0, 246, 240, 1, 0, 0, 0, 247, 250, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 60, 1, 0, 0, 0, 250, 248, 1, 0, 0, 0, 251, 253, 7, 5, 0, 0, 252, 251, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, 253, 255, 1, 0, 0, 0, 254, 256, 7, 2, 0, 0, 255, 254, 1, 0, 0, 0, 256, 257, 1, 0, 0, 0, 257, 255, 1, 0, 0, 0, 257, 258, 1, 0, 0, 0, 258, 62, 1, 0, 0, 0, 259, 261, 7, 5, 0, 0, 260, 259, 1, 0, 0, 0, 260, 261, 1, 0, 0, 0, 261, 265, 1, 0, 0, 0, 262, 264, 7, 2, 0, 0, 263, 262, 1, 0, 0, 0, 264, 267, 1, 0, 0, 0, 265, 263, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 268, 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 268, 270, 5, 46, 0, 0, 269, 271, 7, 2, 0, 0, 270, 269, 1, 0, 0, 0, 271, 272, 1, 0, 0, 0, 272, 270, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 273, 64, 1, 0, 0, 0, 274, 276, 7, 5, 0, 0, 275, 274, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 303, 1, 0, 0, 0, 277, 279, 7, 2, 0, 0, 278, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 278, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 282, 1, 0, 0, 0, 282, 286, 5, 46, 0, 0, 283, 285, 7, 2, 0, 0, 284, 283, 1, 0, 0, 0, 285, 288, 1, 0, 0, 0, 286, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 289, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 289, 304, 3, 67, 33, 0, 290, 292, 5, 46, 0, 0, 291, 293, 7, 2, 0, 0, 292, 291, 1, 0, 0, 0, 293, 294, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 304, 3, 67, 33, 0, 297, 299, 7, 2, 0, 0, 298, 297, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 300, 301, 1, 0, 0, 0, 301, 302, 1, 0, 0, 0, 302, 304, 3, 67, 33, 0, 303, 278, 1, 0, 0, 0, 303, 290, 1, 0, 0, 0, 303, 298, 1, 0, 0, 0, 304, 66, 1, 0, 0, 0, 305, 307, 7, 6, 0, 0, 306, 308, 7, 5, 0, 0, 307, 306, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 310, 1, 0, 0, 0, 309, 311, 7, 2, 0, 0, 310, 309, 1, 0, 0, 0, 311, 312, 1, 0, 0, 0, 312, 310, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 68, 1, 0, 0, 0, 314, 315, 5, 39, 0, 0, 315, 316, 5, 39, 0, 0, 316, 317, 5, 39, 0, 0, 317, 330, 1, 0, 0, 0, 318, 322, 5, 39, 0, 0, 319, 320, 5, 39, 0, 0, 320, 322, 5, 39, 0, 0, 321, 318, 1, 0, 0, 0, 321, 319, 1, 0, 0, 0, 321, 322, 1, 0, 0, 0, 322, 326, 1, 0, 0, 0, 323, 327, 8, 7, 0, 0, 324, 327, 3, 79, 39, 0, 325, 327, 3, 77, 38, 0, 326, 323, 1, 0, 0, 0, 326, 324, 1, 0, 0, 0, 326, 325, 1, 0, 0, 0, 327, 329, 1, 0, 0, 0, 328, 321, 1, 0, 0, 0, 329, 332, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 333, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 334, 5, 39, 0, 0, 334, 335, 5, 39, 0, 0, 335, 336, 5, 39, 0, 0, 336, 70, 1, 0, 0, 0, 337, 338, 5, 34, 0, 0, 338, 339, 5, 34, 0, 0, 339, 340, 5, 34, 0, 0, 340, 353, 1, 0, 0, 0, 341, 345, 5, 34, 0, 0, 342, 343, 5, 34, 0, 0, 343, 345, 5, 34, 0, 0, 344, 341, 1, 0, 0, 0, 344, 342, 1, 0, 0, 0, 344, 345, 1, 0, 0, 0, 345, 349, 1, 0, 0, 0, 346, 350, 8, 8, 0, 0, 347, 350, 3, 79, 39, 0, 348, 350, 3, 77, 38, 0, 349, 346, 1, 0, 0, 0, 349, 347, 1, 0, 0, 0, 349, 348, 1, 0, 0, 0, 350, 352, 1, 0, 0, 0, 351, 344, 1, 0, 0, 0, 352, 355, 1, 0, 0, 0, 353, 351, 1, 0, 0, 0, 353, 354, 1, 0, 0, 0, 354, 356, 1, 0, 0, 0, 355, 353, 1, 0, 0, 0, 356, 357, 5, 34, 0, 0, 357, 358, 5, 34, 0, 0, 358, 359, 5, 34, 0, 0, 359, 72, 1, 0, 0, 0, 360, 366, 5, 34, 0, 0, 361, 365, 8, 9, 0, 0, 362, 365, 3, 79, 39, 0, 363, 365, 3, 77, 38, 0, 364, 361, 1, 0, 0, 0, 364, 362, 1, 0, 0, 0, 364, 363, 1, 0, 0, 0, 365, 368, 1, 0, 0, 0, 366, 364, 1, 0, 0, 0, 366, 367, 1, 0, 0, 0, 367, 369, 1, 0, 0, 0, 368, 366, 1, 0, 0, 0, 369, 370, 5, 34, 0, 0, 370, 74, 1, 0, 0, 0, 371, 377, 5, 39, 0, 0, 372, 376, 8, 10, 0, 0, 373, 376, 3, 79, 39, 0, 374, 376, 3, 77, 38, 0, 375, 372, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 374, 1, 0, 0, 0, 376, 379, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 380, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 380, 381, 5, 39, 0, 0, 381, 76, 1, 0, 0, 0, 382, 383, 5, 92, 0, 0, 383, 384, 5, 117, 0, 0, 384, 385, 1, 0, 0, 0, 385, 386, 3, 107, 53, 0, 386, 387, 3, 107, 53, 0, 387, 388, 3, 107, 53, 0, 388, 389, 3, 107, 53, 0, 389, 403, 1, 0, 0, 0, 390, 391, 5, 92, 0, 0, 391, 392, 5, 85, 0, 0, 392, 393, 1, 0, 0, 0, 393, 394, 3, 107, 53, 0, 394, 395, 3, 107, 53, 0, 395, 396, 3, 107, 53, 0, 396, 397, 3, 107, 53, 0, 397, 398, 3, 107, 53, 0, 398, 399, 3, 107, 53, 0, 399, 400, 3, 107, 53, 0, 400, 401, 3, 107, 53, 0, 401, 403, 1, 0, 0, 0, 402, 382, 1, 0, 0, 0, 402, 390, 1, 0, 0, 0, 403, 78, 1, 0, 0, 0, 404, 405, 5, 92, 0, 0, 405, 406, 7, 11, 0, 0, 406, 80, 1, 0, 0, 0, 407, 408, 7, 12, 0, 0, 408, 409, 1, 0, 0, 0, 409, 410, 6, 40, 1, 0, 410, 82, 1, 0, 0, 0, 411, 415, 5, 91, 0, 0, 412, 414, 3, 81, 40, 0, 413, 412, 1, 0, 0, 0, 414, 417, 1, 0, 0, 0, 415, 413, 1, 0, 0, 0, 415, 416, 1, 0, 0, 0, 416, 418, 1, 0, 0, 0, 417, 415, 1, 0, 0, 0, 418, 419, 5, 105, 0, 0, 419, 420, 5, 100, 0, 0, 420, 84, 1, 0, 0, 0, 421, 425, 5, 91, 0, 0, 422, 424, 3, 81, 40, 0, 423, 422, 1, 0, 0, 0, 424, 427, 1, 0, 0, 0, 425, 423, 1, 0, 0, 0, 425, 426, 1, 0, 0, 0, 426, 428, 1, 0, 0, 0, 427, 425, 1, 0, 0, 0, 428, 429, 5, 93, 0, 0, 429, 86, 1, 0, 0, 0, 430, 431, 5, 63, 0, 0, 431, 435, 3, 89, 44, 0, 432, 434, 3, 93, 46, 0, 433, 432, 1, 0, 0, 0, 434, 437, 1, 0, 0, 0, 435, 433, 1, 0, 0, 0, 435, 436, 1, 0, 0, 0, 436, 88, 1, 0, 0, 0, 437, 435, 1, 0, 0, 0, 438, 441, 3, 91, 45, 0, 439, 441, 5, 95, 0, 0, 440, 438, 1, 0, 0, 0, 440, 439, 1, 0, 0, 0, 441, 90, 1, 0, 0, 0, 442, 444, 7, 13, 0, 0, 443, 442, 1, 0, 0, 0, 444, 92, 1, 0, 0, 0, 445, 448, 3, 89, 44, 0, 446, 448, 7, 14, 0, 0, 447, 445, 1, 0, 0, 0, 447, 446, 1, 0, 0, 0, 448, 94, 1, 0, 0, 0, 449, 450, 7, 15, 0, 0, 450, 451, 7, 16, 0, 0, 451, 452, 7, 17, 0, 0, 452, 453, 7, 6, 0, 0, 453, 96, 1, 0, 0, 0, 454, 455, 7, 18, 0, 0, 455, 456, 7, 19, 0, 0, 456, 457, 7, 6, 0, 0, 457, 458, 7, 20, 0, 0, 458, 459, 7, 21, 0, 0, 459, 460, 7, 22, 0, 0, 460, 98, 1, 0, 0, 0, 461, 470, 3, 91, 45, 0, 462, 465, 3, 93, 46, 0, 463, 465, 5, 46, 0, 0, 464, 462, 1, 0, 0, 0, 464, 463, 1, 0, 0, 0, 465, 468, 1, 0, 0, 0, 466, 464, 1, 0, 0, 0, 466, 467, 1, 0, 0, 0, 467, 469, 1, 0, 0, 0, 468, 466, 1, 0, 0, 0, 469, 471, 3, 93, 46, 0, 470, 466, 1, 0, 0, 0, 470, 471, 1, 0, 0, 0, 471, 100, 1, 0, 0, 0, 472, 476, 3, 89, 44, 0, 473, 476, 2, 48, 58, 0, 474, 476, 3, 103, 51, 0, 475, 472, 1, 0, 0, 0, 475, 473, 1, 0, 0, 0, 475, 474, 1, 0, 0, 0, 476, 490, 1, 0, 0, 0, 477, 481, 3, 93, 46, 0, 478, 481, 7, 23, 0, 0, 479, 481, 3, 103, 51, 0, 480, 477, 1, 0, 0, 0, 480, 478, 1, 0, 0, 0, 480, 479, 1, 0, 0, 0, 481, 484, 1, 0, 0, 0, 482, 480, 1, 0, 0, 0, 482, 483, 1, 0, 0, 0, 483, 488, 1, 0, 0, 0, 484, 482, 1, 0, 0, 0, 485, 489, 3, 93, 46, 0, 486, 489, 5, 58, 0, 0, 487, 489, 3, 103, 51, 0, 488, 485, 1, 0, 0, 0, 488, 486, 1, 0, 0, 0, 488, 487, 1, 0, 0, 0, 489, 491, 1, 0, 0, 0, 490, 482, 1, 0, 0, 0, 490, 491, 1, 0, 0, 0, 491, 102, 1, 0, 0, 0, 492, 495, 3, 105, 52, 0, 493, 495, 3, 109, 54, 0, 494, 492, 1, 0, 0, 0, 494, 493, 1, 0, 0, 0, 495, 104, 1, 0, 0, 0, 496, 497, 5, 37, 0, 0, 497, 498, 3, 107, 53, 0, 498, 499, 3, 107, 53, 0, 499, 106, 1, 0, 0, 0, 500, 502, 7, 24, 0, 0, 501, 500, 1, 0, 0, 0, 502, 108, 1, 0, 0, 0, 503, 504, 5, 92, 0, 0, 504, 505, 7, 25, 0, 0, 505, 110, 1, 0, 0, 0, 54, 0, 177, 191, 197, 202, 204, 210, 222, 226, 228, 232, 238, 244, 248, 252, 257, 260, 265, 272, 275, 280, 286, 294, 300, 303, 307, 312, 321, 326, 330, 344, 349, 353, 364, 366, 375, 377, 402, 415, 425, 435, 440, 443, 447, 464, 466, 470, 475, 480, 482, 488, 490, 494, 501, 2, 0, 2, 0, 0, 1, 0] \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodropLexer.js b/editor/parser/n3_nodrop/n3_nodropLexer.js new file mode 100644 index 0000000..2d0364a --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropLexer.js @@ -0,0 +1,296 @@ +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start +import antlr4 from 'antlr4'; + + +const serializedATN = [4,0,55,506,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2, +4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7, +12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19, +2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2, +27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34, +7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7, +41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48, +2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,1,0,1,0,1,1, +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,4,1,4,1,5, +1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1,11, +1,11,1,11,1,12,1,12,1,12,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1, +17,1,18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,21,1,22,1,22,5,22,176,8,22, +10,22,12,22,179,9,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1, +23,3,23,192,8,23,1,24,1,24,1,24,1,24,3,24,198,8,24,1,25,1,25,1,25,5,25,203, +8,25,10,25,12,25,206,9,25,1,25,1,25,1,26,3,26,211,8,26,1,26,1,26,1,27,1, +27,1,27,1,28,1,28,1,28,1,28,1,28,3,28,223,8,28,1,28,1,28,5,28,227,8,28,10, +28,12,28,230,9,28,1,28,3,28,233,8,28,1,29,1,29,4,29,237,8,29,11,29,12,29, +238,1,29,1,29,4,29,243,8,29,11,29,12,29,244,5,29,247,8,29,10,29,12,29,250, +9,29,1,30,3,30,253,8,30,1,30,4,30,256,8,30,11,30,12,30,257,1,31,3,31,261, +8,31,1,31,5,31,264,8,31,10,31,12,31,267,9,31,1,31,1,31,4,31,271,8,31,11, +31,12,31,272,1,32,3,32,276,8,32,1,32,4,32,279,8,32,11,32,12,32,280,1,32, +1,32,5,32,285,8,32,10,32,12,32,288,9,32,1,32,1,32,1,32,4,32,293,8,32,11, +32,12,32,294,1,32,1,32,4,32,299,8,32,11,32,12,32,300,1,32,3,32,304,8,32, +1,33,1,33,3,33,308,8,33,1,33,4,33,311,8,33,11,33,12,33,312,1,34,1,34,1,34, +1,34,1,34,1,34,1,34,3,34,322,8,34,1,34,1,34,1,34,3,34,327,8,34,5,34,329, +8,34,10,34,12,34,332,9,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1, +35,1,35,3,35,345,8,35,1,35,1,35,1,35,3,35,350,8,35,5,35,352,8,35,10,35,12, +35,355,9,35,1,35,1,35,1,35,1,35,1,36,1,36,1,36,1,36,5,36,365,8,36,10,36, +12,36,368,9,36,1,36,1,36,1,37,1,37,1,37,1,37,5,37,376,8,37,10,37,12,37,379, +9,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, +38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,403,8,38,1,39,1,39,1,39, +1,40,1,40,1,40,1,40,1,41,1,41,5,41,414,8,41,10,41,12,41,417,9,41,1,41,1, +41,1,41,1,42,1,42,5,42,424,8,42,10,42,12,42,427,9,42,1,42,1,42,1,43,1,43, +1,43,5,43,434,8,43,10,43,12,43,437,9,43,1,44,1,44,3,44,441,8,44,1,45,3,45, +444,8,45,1,46,1,46,3,46,448,8,46,1,47,1,47,1,47,1,47,1,47,1,48,1,48,1,48, +1,48,1,48,1,48,1,48,1,49,1,49,1,49,5,49,465,8,49,10,49,12,49,468,9,49,1, +49,3,49,471,8,49,1,50,1,50,1,50,3,50,476,8,50,1,50,1,50,1,50,5,50,481,8, +50,10,50,12,50,484,9,50,1,50,1,50,1,50,3,50,489,8,50,3,50,491,8,50,1,51, +1,51,3,51,495,8,51,1,52,1,52,1,52,1,52,1,53,3,53,502,8,53,1,54,1,54,1,54, +0,0,55,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27, +14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51, +26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75, +38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,95,48,97,49,99, +50,101,51,103,52,105,53,107,54,109,55,1,0,26,2,0,10,10,12,13,8,0,0,32,34, +34,60,60,62,62,92,92,94,94,96,96,123,125,1,0,48,57,2,0,65,90,97,122,3,0, +48,57,65,90,97,122,2,0,43,43,45,45,2,0,69,69,101,101,2,0,39,39,92,92,2,0, +34,34,92,92,4,0,10,10,13,13,34,34,92,92,4,0,10,10,13,13,39,39,92,92,8,0, +34,34,39,39,92,92,98,98,102,102,110,110,114,114,116,116,3,0,9,10,13,13,32, +32,13,0,65,90,97,122,192,214,216,246,248,767,880,893,895,8191,8204,8205, +8304,8591,11264,12271,12289,55295,63744,64975,65008,65533,5,0,45,45,48,57, +183,183,768,879,8255,8256,2,0,66,66,98,98,2,0,65,65,97,97,2,0,83,83,115, +115,2,0,80,80,112,112,2,0,82,82,114,114,2,0,70,70,102,102,2,0,73,73,105, +105,2,0,88,88,120,120,2,0,46,46,58,58,3,0,48,57,65,70,97,102,7,0,33,33,35, +47,59,59,61,61,63,64,95,95,126,126,568,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0, +0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1, +0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0, +29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0, +0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51, +1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0, +0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1, +0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0, +85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0, +0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0, +0,107,1,0,0,0,0,109,1,0,0,0,1,111,1,0,0,0,3,113,1,0,0,0,5,121,1,0,0,0,7, +127,1,0,0,0,9,129,1,0,0,0,11,131,1,0,0,0,13,133,1,0,0,0,15,137,1,0,0,0,17, +140,1,0,0,0,19,143,1,0,0,0,21,145,1,0,0,0,23,148,1,0,0,0,25,151,1,0,0,0, +27,154,1,0,0,0,29,156,1,0,0,0,31,158,1,0,0,0,33,160,1,0,0,0,35,162,1,0,0, +0,37,164,1,0,0,0,39,166,1,0,0,0,41,168,1,0,0,0,43,170,1,0,0,0,45,173,1,0, +0,0,47,191,1,0,0,0,49,197,1,0,0,0,51,199,1,0,0,0,53,210,1,0,0,0,55,214,1, +0,0,0,57,217,1,0,0,0,59,234,1,0,0,0,61,252,1,0,0,0,63,260,1,0,0,0,65,275, +1,0,0,0,67,305,1,0,0,0,69,314,1,0,0,0,71,337,1,0,0,0,73,360,1,0,0,0,75,371, +1,0,0,0,77,402,1,0,0,0,79,404,1,0,0,0,81,407,1,0,0,0,83,411,1,0,0,0,85,421, +1,0,0,0,87,430,1,0,0,0,89,440,1,0,0,0,91,443,1,0,0,0,93,447,1,0,0,0,95,449, +1,0,0,0,97,454,1,0,0,0,99,461,1,0,0,0,101,475,1,0,0,0,103,494,1,0,0,0,105, +496,1,0,0,0,107,501,1,0,0,0,109,503,1,0,0,0,111,112,5,46,0,0,112,2,1,0,0, +0,113,114,5,64,0,0,114,115,5,112,0,0,115,116,5,114,0,0,116,117,5,101,0,0, +117,118,5,102,0,0,118,119,5,105,0,0,119,120,5,120,0,0,120,4,1,0,0,0,121, +122,5,64,0,0,122,123,5,98,0,0,123,124,5,97,0,0,124,125,5,115,0,0,125,126, +5,101,0,0,126,6,1,0,0,0,127,128,5,59,0,0,128,8,1,0,0,0,129,130,5,44,0,0, +130,10,1,0,0,0,131,132,5,97,0,0,132,12,1,0,0,0,133,134,5,104,0,0,134,135, +5,97,0,0,135,136,5,115,0,0,136,14,1,0,0,0,137,138,5,105,0,0,138,139,5,115, +0,0,139,16,1,0,0,0,140,141,5,111,0,0,141,142,5,102,0,0,142,18,1,0,0,0,143, +144,5,61,0,0,144,20,1,0,0,0,145,146,5,60,0,0,146,147,5,61,0,0,147,22,1,0, +0,0,148,149,5,61,0,0,149,150,5,62,0,0,150,24,1,0,0,0,151,152,5,60,0,0,152, +153,5,45,0,0,153,26,1,0,0,0,154,155,5,33,0,0,155,28,1,0,0,0,156,157,5,94, +0,0,157,30,1,0,0,0,158,159,5,91,0,0,159,32,1,0,0,0,160,161,5,93,0,0,161, +34,1,0,0,0,162,163,5,40,0,0,163,36,1,0,0,0,164,165,5,41,0,0,165,38,1,0,0, +0,166,167,5,123,0,0,167,40,1,0,0,0,168,169,5,125,0,0,169,42,1,0,0,0,170, +171,5,94,0,0,171,172,5,94,0,0,172,44,1,0,0,0,173,177,5,35,0,0,174,176,8, +0,0,0,175,174,1,0,0,0,176,179,1,0,0,0,177,175,1,0,0,0,177,178,1,0,0,0,178, +180,1,0,0,0,179,177,1,0,0,0,180,181,6,22,0,0,181,46,1,0,0,0,182,183,5,116, +0,0,183,184,5,114,0,0,184,185,5,117,0,0,185,192,5,101,0,0,186,187,5,102, +0,0,187,188,5,97,0,0,188,189,5,108,0,0,189,190,5,115,0,0,190,192,5,101,0, +0,191,182,1,0,0,0,191,186,1,0,0,0,192,48,1,0,0,0,193,198,3,73,36,0,194,198, +3,75,37,0,195,198,3,69,34,0,196,198,3,71,35,0,197,193,1,0,0,0,197,194,1, +0,0,0,197,195,1,0,0,0,197,196,1,0,0,0,198,50,1,0,0,0,199,204,5,60,0,0,200, +203,8,1,0,0,201,203,3,77,38,0,202,200,1,0,0,0,202,201,1,0,0,0,203,206,1, +0,0,0,204,202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1,0,0,0,207, +208,5,62,0,0,208,52,1,0,0,0,209,211,3,99,49,0,210,209,1,0,0,0,210,211,1, +0,0,0,211,212,1,0,0,0,212,213,5,58,0,0,213,54,1,0,0,0,214,215,3,53,26,0, +215,216,3,101,50,0,216,56,1,0,0,0,217,218,5,95,0,0,218,219,5,58,0,0,219, +222,1,0,0,0,220,223,3,89,44,0,221,223,7,2,0,0,222,220,1,0,0,0,222,221,1, +0,0,0,223,232,1,0,0,0,224,227,3,93,46,0,225,227,5,46,0,0,226,224,1,0,0,0, +226,225,1,0,0,0,227,230,1,0,0,0,228,226,1,0,0,0,228,229,1,0,0,0,229,231, +1,0,0,0,230,228,1,0,0,0,231,233,3,93,46,0,232,228,1,0,0,0,232,233,1,0,0, +0,233,58,1,0,0,0,234,236,5,64,0,0,235,237,7,3,0,0,236,235,1,0,0,0,237,238, +1,0,0,0,238,236,1,0,0,0,238,239,1,0,0,0,239,248,1,0,0,0,240,242,5,45,0,0, +241,243,7,4,0,0,242,241,1,0,0,0,243,244,1,0,0,0,244,242,1,0,0,0,244,245, +1,0,0,0,245,247,1,0,0,0,246,240,1,0,0,0,247,250,1,0,0,0,248,246,1,0,0,0, +248,249,1,0,0,0,249,60,1,0,0,0,250,248,1,0,0,0,251,253,7,5,0,0,252,251,1, +0,0,0,252,253,1,0,0,0,253,255,1,0,0,0,254,256,7,2,0,0,255,254,1,0,0,0,256, +257,1,0,0,0,257,255,1,0,0,0,257,258,1,0,0,0,258,62,1,0,0,0,259,261,7,5,0, +0,260,259,1,0,0,0,260,261,1,0,0,0,261,265,1,0,0,0,262,264,7,2,0,0,263,262, +1,0,0,0,264,267,1,0,0,0,265,263,1,0,0,0,265,266,1,0,0,0,266,268,1,0,0,0, +267,265,1,0,0,0,268,270,5,46,0,0,269,271,7,2,0,0,270,269,1,0,0,0,271,272, +1,0,0,0,272,270,1,0,0,0,272,273,1,0,0,0,273,64,1,0,0,0,274,276,7,5,0,0,275, +274,1,0,0,0,275,276,1,0,0,0,276,303,1,0,0,0,277,279,7,2,0,0,278,277,1,0, +0,0,279,280,1,0,0,0,280,278,1,0,0,0,280,281,1,0,0,0,281,282,1,0,0,0,282, +286,5,46,0,0,283,285,7,2,0,0,284,283,1,0,0,0,285,288,1,0,0,0,286,284,1,0, +0,0,286,287,1,0,0,0,287,289,1,0,0,0,288,286,1,0,0,0,289,304,3,67,33,0,290, +292,5,46,0,0,291,293,7,2,0,0,292,291,1,0,0,0,293,294,1,0,0,0,294,292,1,0, +0,0,294,295,1,0,0,0,295,296,1,0,0,0,296,304,3,67,33,0,297,299,7,2,0,0,298, +297,1,0,0,0,299,300,1,0,0,0,300,298,1,0,0,0,300,301,1,0,0,0,301,302,1,0, +0,0,302,304,3,67,33,0,303,278,1,0,0,0,303,290,1,0,0,0,303,298,1,0,0,0,304, +66,1,0,0,0,305,307,7,6,0,0,306,308,7,5,0,0,307,306,1,0,0,0,307,308,1,0,0, +0,308,310,1,0,0,0,309,311,7,2,0,0,310,309,1,0,0,0,311,312,1,0,0,0,312,310, +1,0,0,0,312,313,1,0,0,0,313,68,1,0,0,0,314,315,5,39,0,0,315,316,5,39,0,0, +316,317,5,39,0,0,317,330,1,0,0,0,318,322,5,39,0,0,319,320,5,39,0,0,320,322, +5,39,0,0,321,318,1,0,0,0,321,319,1,0,0,0,321,322,1,0,0,0,322,326,1,0,0,0, +323,327,8,7,0,0,324,327,3,79,39,0,325,327,3,77,38,0,326,323,1,0,0,0,326, +324,1,0,0,0,326,325,1,0,0,0,327,329,1,0,0,0,328,321,1,0,0,0,329,332,1,0, +0,0,330,328,1,0,0,0,330,331,1,0,0,0,331,333,1,0,0,0,332,330,1,0,0,0,333, +334,5,39,0,0,334,335,5,39,0,0,335,336,5,39,0,0,336,70,1,0,0,0,337,338,5, +34,0,0,338,339,5,34,0,0,339,340,5,34,0,0,340,353,1,0,0,0,341,345,5,34,0, +0,342,343,5,34,0,0,343,345,5,34,0,0,344,341,1,0,0,0,344,342,1,0,0,0,344, +345,1,0,0,0,345,349,1,0,0,0,346,350,8,8,0,0,347,350,3,79,39,0,348,350,3, +77,38,0,349,346,1,0,0,0,349,347,1,0,0,0,349,348,1,0,0,0,350,352,1,0,0,0, +351,344,1,0,0,0,352,355,1,0,0,0,353,351,1,0,0,0,353,354,1,0,0,0,354,356, +1,0,0,0,355,353,1,0,0,0,356,357,5,34,0,0,357,358,5,34,0,0,358,359,5,34,0, +0,359,72,1,0,0,0,360,366,5,34,0,0,361,365,8,9,0,0,362,365,3,79,39,0,363, +365,3,77,38,0,364,361,1,0,0,0,364,362,1,0,0,0,364,363,1,0,0,0,365,368,1, +0,0,0,366,364,1,0,0,0,366,367,1,0,0,0,367,369,1,0,0,0,368,366,1,0,0,0,369, +370,5,34,0,0,370,74,1,0,0,0,371,377,5,39,0,0,372,376,8,10,0,0,373,376,3, +79,39,0,374,376,3,77,38,0,375,372,1,0,0,0,375,373,1,0,0,0,375,374,1,0,0, +0,376,379,1,0,0,0,377,375,1,0,0,0,377,378,1,0,0,0,378,380,1,0,0,0,379,377, +1,0,0,0,380,381,5,39,0,0,381,76,1,0,0,0,382,383,5,92,0,0,383,384,5,117,0, +0,384,385,1,0,0,0,385,386,3,107,53,0,386,387,3,107,53,0,387,388,3,107,53, +0,388,389,3,107,53,0,389,403,1,0,0,0,390,391,5,92,0,0,391,392,5,85,0,0,392, +393,1,0,0,0,393,394,3,107,53,0,394,395,3,107,53,0,395,396,3,107,53,0,396, +397,3,107,53,0,397,398,3,107,53,0,398,399,3,107,53,0,399,400,3,107,53,0, +400,401,3,107,53,0,401,403,1,0,0,0,402,382,1,0,0,0,402,390,1,0,0,0,403,78, +1,0,0,0,404,405,5,92,0,0,405,406,7,11,0,0,406,80,1,0,0,0,407,408,7,12,0, +0,408,409,1,0,0,0,409,410,6,40,1,0,410,82,1,0,0,0,411,415,5,91,0,0,412,414, +3,81,40,0,413,412,1,0,0,0,414,417,1,0,0,0,415,413,1,0,0,0,415,416,1,0,0, +0,416,418,1,0,0,0,417,415,1,0,0,0,418,419,5,105,0,0,419,420,5,100,0,0,420, +84,1,0,0,0,421,425,5,91,0,0,422,424,3,81,40,0,423,422,1,0,0,0,424,427,1, +0,0,0,425,423,1,0,0,0,425,426,1,0,0,0,426,428,1,0,0,0,427,425,1,0,0,0,428, +429,5,93,0,0,429,86,1,0,0,0,430,431,5,63,0,0,431,435,3,89,44,0,432,434,3, +93,46,0,433,432,1,0,0,0,434,437,1,0,0,0,435,433,1,0,0,0,435,436,1,0,0,0, +436,88,1,0,0,0,437,435,1,0,0,0,438,441,3,91,45,0,439,441,5,95,0,0,440,438, +1,0,0,0,440,439,1,0,0,0,441,90,1,0,0,0,442,444,7,13,0,0,443,442,1,0,0,0, +444,92,1,0,0,0,445,448,3,89,44,0,446,448,7,14,0,0,447,445,1,0,0,0,447,446, +1,0,0,0,448,94,1,0,0,0,449,450,7,15,0,0,450,451,7,16,0,0,451,452,7,17,0, +0,452,453,7,6,0,0,453,96,1,0,0,0,454,455,7,18,0,0,455,456,7,19,0,0,456,457, +7,6,0,0,457,458,7,20,0,0,458,459,7,21,0,0,459,460,7,22,0,0,460,98,1,0,0, +0,461,470,3,91,45,0,462,465,3,93,46,0,463,465,5,46,0,0,464,462,1,0,0,0,464, +463,1,0,0,0,465,468,1,0,0,0,466,464,1,0,0,0,466,467,1,0,0,0,467,469,1,0, +0,0,468,466,1,0,0,0,469,471,3,93,46,0,470,466,1,0,0,0,470,471,1,0,0,0,471, +100,1,0,0,0,472,476,3,89,44,0,473,476,2,48,58,0,474,476,3,103,51,0,475,472, +1,0,0,0,475,473,1,0,0,0,475,474,1,0,0,0,476,490,1,0,0,0,477,481,3,93,46, +0,478,481,7,23,0,0,479,481,3,103,51,0,480,477,1,0,0,0,480,478,1,0,0,0,480, +479,1,0,0,0,481,484,1,0,0,0,482,480,1,0,0,0,482,483,1,0,0,0,483,488,1,0, +0,0,484,482,1,0,0,0,485,489,3,93,46,0,486,489,5,58,0,0,487,489,3,103,51, +0,488,485,1,0,0,0,488,486,1,0,0,0,488,487,1,0,0,0,489,491,1,0,0,0,490,482, +1,0,0,0,490,491,1,0,0,0,491,102,1,0,0,0,492,495,3,105,52,0,493,495,3,109, +54,0,494,492,1,0,0,0,494,493,1,0,0,0,495,104,1,0,0,0,496,497,5,37,0,0,497, +498,3,107,53,0,498,499,3,107,53,0,499,106,1,0,0,0,500,502,7,24,0,0,501,500, +1,0,0,0,502,108,1,0,0,0,503,504,5,92,0,0,504,505,7,25,0,0,505,110,1,0,0, +0,54,0,177,191,197,202,204,210,222,226,228,232,238,244,248,252,257,260,265, +272,275,280,286,294,300,303,307,312,321,326,330,344,349,353,364,366,375, +377,402,415,425,435,440,443,447,464,466,470,475,480,482,488,490,494,501, +2,0,2,0,0,1,0]; + + +const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); + +const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) ); + +export default class n3_nodropLexer extends antlr4.Lexer { + + static grammarFileName = "n3_nodrop.g4"; + static channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]; + static modeNames = [ "DEFAULT_MODE" ]; + static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", "','", + "'a'", "'has'", "'is'", "'of'", "'='", "'<='", + "'=>'", "'<-'", "'!'", "'^'", "'['", "']'", "'('", + "')'", "'{'", "'}'", "'^^'" ]; + static symbolicNames = [ null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "COMMENT", + "BooleanLiteral", "String", "IRIREF", "PNAME_NS", + "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", + "DECIMAL", "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", + "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", + "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", + "WS", "IPLSTART", "ANON", "QuickVarName", "PN_CHARS_U", + "PN_CHARS_BASE", "PN_CHARS", "BASE", "PREFIX", + "PN_PREFIX", "PN_LOCAL", "PLX", "PERCENT", "HEX", + "PN_LOCAL_ESC" ]; + static ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", + "T__13", "T__14", "T__15", "T__16", "T__17", "T__18", + "T__19", "T__20", "T__21", "COMMENT", "BooleanLiteral", + "String", "IRIREF", "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", + "LANGTAG", "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", + "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", + "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", + "UCHAR", "ECHAR", "WS", "IPLSTART", "ANON", "QuickVarName", + "PN_CHARS_U", "PN_CHARS_BASE", "PN_CHARS", "BASE", + "PREFIX", "PN_PREFIX", "PN_LOCAL", "PLX", "PERCENT", + "HEX", "PN_LOCAL_ESC" ]; + + constructor(input) { + super(input) + this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache()); + } + + get atn() { + return atn; + } +} + +n3_nodropLexer.EOF = antlr4.Token.EOF; +n3_nodropLexer.T__0 = 1; +n3_nodropLexer.T__1 = 2; +n3_nodropLexer.T__2 = 3; +n3_nodropLexer.T__3 = 4; +n3_nodropLexer.T__4 = 5; +n3_nodropLexer.T__5 = 6; +n3_nodropLexer.T__6 = 7; +n3_nodropLexer.T__7 = 8; +n3_nodropLexer.T__8 = 9; +n3_nodropLexer.T__9 = 10; +n3_nodropLexer.T__10 = 11; +n3_nodropLexer.T__11 = 12; +n3_nodropLexer.T__12 = 13; +n3_nodropLexer.T__13 = 14; +n3_nodropLexer.T__14 = 15; +n3_nodropLexer.T__15 = 16; +n3_nodropLexer.T__16 = 17; +n3_nodropLexer.T__17 = 18; +n3_nodropLexer.T__18 = 19; +n3_nodropLexer.T__19 = 20; +n3_nodropLexer.T__20 = 21; +n3_nodropLexer.T__21 = 22; +n3_nodropLexer.COMMENT = 23; +n3_nodropLexer.BooleanLiteral = 24; +n3_nodropLexer.String = 25; +n3_nodropLexer.IRIREF = 26; +n3_nodropLexer.PNAME_NS = 27; +n3_nodropLexer.PNAME_LN = 28; +n3_nodropLexer.BLANK_NODE_LABEL = 29; +n3_nodropLexer.LANGTAG = 30; +n3_nodropLexer.INTEGER = 31; +n3_nodropLexer.DECIMAL = 32; +n3_nodropLexer.DOUBLE = 33; +n3_nodropLexer.EXPONENT = 34; +n3_nodropLexer.STRING_LITERAL_LONG_SINGLE_QUOTE = 35; +n3_nodropLexer.STRING_LITERAL_LONG_QUOTE = 36; +n3_nodropLexer.STRING_LITERAL_QUOTE = 37; +n3_nodropLexer.STRING_LITERAL_SINGLE_QUOTE = 38; +n3_nodropLexer.UCHAR = 39; +n3_nodropLexer.ECHAR = 40; +n3_nodropLexer.WS = 41; +n3_nodropLexer.IPLSTART = 42; +n3_nodropLexer.ANON = 43; +n3_nodropLexer.QuickVarName = 44; +n3_nodropLexer.PN_CHARS_U = 45; +n3_nodropLexer.PN_CHARS_BASE = 46; +n3_nodropLexer.PN_CHARS = 47; +n3_nodropLexer.BASE = 48; +n3_nodropLexer.PREFIX = 49; +n3_nodropLexer.PN_PREFIX = 50; +n3_nodropLexer.PN_LOCAL = 51; +n3_nodropLexer.PLX = 52; +n3_nodropLexer.PERCENT = 53; +n3_nodropLexer.HEX = 54; +n3_nodropLexer.PN_LOCAL_ESC = 55; + + + diff --git a/editor/parser/n3_nodrop/n3_nodropLexer.tokens b/editor/parser/n3_nodrop/n3_nodropLexer.tokens new file mode 100644 index 0000000..6857ac6 --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropLexer.tokens @@ -0,0 +1,77 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +T__9=10 +T__10=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +COMMENT=23 +BooleanLiteral=24 +String=25 +IRIREF=26 +PNAME_NS=27 +PNAME_LN=28 +BLANK_NODE_LABEL=29 +LANGTAG=30 +INTEGER=31 +DECIMAL=32 +DOUBLE=33 +EXPONENT=34 +STRING_LITERAL_LONG_SINGLE_QUOTE=35 +STRING_LITERAL_LONG_QUOTE=36 +STRING_LITERAL_QUOTE=37 +STRING_LITERAL_SINGLE_QUOTE=38 +UCHAR=39 +ECHAR=40 +WS=41 +IPLSTART=42 +ANON=43 +QuickVarName=44 +PN_CHARS_U=45 +PN_CHARS_BASE=46 +PN_CHARS=47 +BASE=48 +PREFIX=49 +PN_PREFIX=50 +PN_LOCAL=51 +PLX=52 +PERCENT=53 +HEX=54 +PN_LOCAL_ESC=55 +'.'=1 +'@prefix'=2 +'@base'=3 +';'=4 +','=5 +'a'=6 +'has'=7 +'is'=8 +'of'=9 +'='=10 +'<='=11 +'=>'=12 +'<-'=13 +'!'=14 +'^'=15 +'['=16 +']'=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'^^'=22 diff --git a/editor/parser/n3_nodrop/n3_nodropListener.js b/editor/parser/n3_nodrop/n3_nodropListener.js new file mode 100644 index 0000000..d1f493c --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropListener.js @@ -0,0 +1,279 @@ +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start +import antlr4 from 'antlr4'; + +// This class defines a complete listener for a parse tree produced by n3_nodropParser. +export default class n3_nodropListener extends antlr4.tree.ParseTreeListener { + + // Enter a parse tree produced by n3_nodropParser#n3Doc. + enterN3Doc(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#n3Doc. + exitN3Doc(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#n3Statement. + enterN3Statement(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#n3Statement. + exitN3Statement(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#n3Directive. + enterN3Directive(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#n3Directive. + exitN3Directive(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#sparqlDirective. + enterSparqlDirective(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#sparqlDirective. + exitSparqlDirective(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#sparqlBase. + enterSparqlBase(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#sparqlBase. + exitSparqlBase(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#sparqlPrefix. + enterSparqlPrefix(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#sparqlPrefix. + exitSparqlPrefix(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#prefixID. + enterPrefixID(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#prefixID. + exitPrefixID(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#base. + enterBase(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#base. + exitBase(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#triples. + enterTriples(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#triples. + exitTriples(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#predicateObjectList. + enterPredicateObjectList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#predicateObjectList. + exitPredicateObjectList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#objectList. + enterObjectList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#objectList. + exitObjectList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#verb. + enterVerb(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#verb. + exitVerb(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#subject. + enterSubject(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#subject. + exitSubject(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#predicate. + enterPredicate(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#predicate. + exitPredicate(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#object. + enterObject(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#object. + exitObject(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#expression. + enterExpression(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#expression. + exitExpression(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#path. + enterPath(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#path. + exitPath(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#pathItem. + enterPathItem(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#pathItem. + exitPathItem(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#literal. + enterLiteral(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#literal. + exitLiteral(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#blankNodePropertyList. + enterBlankNodePropertyList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#blankNodePropertyList. + exitBlankNodePropertyList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#iriPropertyList. + enterIriPropertyList(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#iriPropertyList. + exitIriPropertyList(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#collection. + enterCollection(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#collection. + exitCollection(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#formula. + enterFormula(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#formula. + exitFormula(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#formulaContent. + enterFormulaContent(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#formulaContent. + exitFormulaContent(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#numericLiteral. + enterNumericLiteral(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#numericLiteral. + exitNumericLiteral(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#rdfLiteral. + enterRdfLiteral(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#rdfLiteral. + exitRdfLiteral(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#iri. + enterIri(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#iri. + exitIri(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#prefixedName. + enterPrefixedName(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#prefixedName. + exitPrefixedName(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#blankNode. + enterBlankNode(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#blankNode. + exitBlankNode(ctx) { + } + + + // Enter a parse tree produced by n3_nodropParser#quickVar. + enterQuickVar(ctx) { + } + + // Exit a parse tree produced by n3_nodropParser#quickVar. + exitQuickVar(ctx) { + } + + + +} \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodropParser.js b/editor/parser/n3_nodrop/n3_nodropParser.js new file mode 100644 index 0000000..a344c5e --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropParser.js @@ -0,0 +1,2932 @@ +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start +import antlr4 from 'antlr4'; +import n3_nodropListener from './n3_nodropListener.js'; +import n3_nodropVisitor from './n3_nodropVisitor.js'; + +const serializedATN = [4,1,55,224,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7, +4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12, +2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2, +20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27, +7,27,2,28,7,28,2,29,7,29,1,0,1,0,1,0,1,0,5,0,65,8,0,10,0,12,0,68,9,0,1,0, +1,0,1,1,1,1,3,1,74,8,1,1,2,1,2,3,2,78,8,2,1,3,1,3,3,3,82,8,3,1,4,1,4,1,4, +1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,3,8,100,8,8,1,9,1,9, +1,9,1,9,1,9,1,9,3,9,108,8,9,5,9,110,8,9,10,9,12,9,113,9,9,1,10,1,10,1,10, +5,10,118,8,10,10,10,12,10,121,9,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1, +11,1,11,1,11,1,11,3,11,134,8,11,1,12,1,12,1,13,1,13,1,13,3,13,141,8,13,1, +14,1,14,1,15,1,15,1,16,1,16,1,16,1,16,1,16,3,16,152,8,16,1,17,1,17,1,17, +1,17,1,17,1,17,1,17,1,17,3,17,162,8,17,1,18,1,18,1,18,3,18,167,8,18,1,19, +1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,5,21,180,8,21,10,21,12, +21,183,9,21,1,21,1,21,1,22,1,22,3,22,189,8,22,1,22,1,22,1,23,1,23,1,23,3, +23,196,8,23,3,23,198,8,23,1,23,1,23,3,23,202,8,23,3,23,204,8,23,1,24,1,24, +1,25,1,25,1,25,1,25,3,25,212,8,25,1,26,1,26,3,26,216,8,26,1,27,1,27,1,28, +1,28,1,29,1,29,1,29,0,0,30,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32, +34,36,38,40,42,44,46,48,50,52,54,56,58,0,3,1,0,31,33,1,0,27,28,2,0,29,29, +43,43,229,0,66,1,0,0,0,2,73,1,0,0,0,4,77,1,0,0,0,6,81,1,0,0,0,8,83,1,0,0, +0,10,86,1,0,0,0,12,90,1,0,0,0,14,94,1,0,0,0,16,97,1,0,0,0,18,101,1,0,0,0, +20,114,1,0,0,0,22,133,1,0,0,0,24,135,1,0,0,0,26,140,1,0,0,0,28,142,1,0,0, +0,30,144,1,0,0,0,32,146,1,0,0,0,34,161,1,0,0,0,36,166,1,0,0,0,38,168,1,0, +0,0,40,172,1,0,0,0,42,177,1,0,0,0,44,186,1,0,0,0,46,203,1,0,0,0,48,205,1, +0,0,0,50,207,1,0,0,0,52,215,1,0,0,0,54,217,1,0,0,0,56,219,1,0,0,0,58,221, +1,0,0,0,60,61,3,2,1,0,61,62,5,1,0,0,62,65,1,0,0,0,63,65,3,6,3,0,64,60,1, +0,0,0,64,63,1,0,0,0,65,68,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,69,1,0, +0,0,68,66,1,0,0,0,69,70,5,0,0,1,70,1,1,0,0,0,71,74,3,4,2,0,72,74,3,16,8, +0,73,71,1,0,0,0,73,72,1,0,0,0,74,3,1,0,0,0,75,78,3,12,6,0,76,78,3,14,7,0, +77,75,1,0,0,0,77,76,1,0,0,0,78,5,1,0,0,0,79,82,3,8,4,0,80,82,3,10,5,0,81, +79,1,0,0,0,81,80,1,0,0,0,82,7,1,0,0,0,83,84,5,48,0,0,84,85,5,26,0,0,85,9, +1,0,0,0,86,87,5,49,0,0,87,88,5,27,0,0,88,89,5,26,0,0,89,11,1,0,0,0,90,91, +5,2,0,0,91,92,5,27,0,0,92,93,5,26,0,0,93,13,1,0,0,0,94,95,5,3,0,0,95,96, +5,26,0,0,96,15,1,0,0,0,97,99,3,24,12,0,98,100,3,18,9,0,99,98,1,0,0,0,99, +100,1,0,0,0,100,17,1,0,0,0,101,102,3,22,11,0,102,111,3,20,10,0,103,107,5, +4,0,0,104,105,3,22,11,0,105,106,3,20,10,0,106,108,1,0,0,0,107,104,1,0,0, +0,107,108,1,0,0,0,108,110,1,0,0,0,109,103,1,0,0,0,110,113,1,0,0,0,111,109, +1,0,0,0,111,112,1,0,0,0,112,19,1,0,0,0,113,111,1,0,0,0,114,119,3,28,14,0, +115,116,5,5,0,0,116,118,3,28,14,0,117,115,1,0,0,0,118,121,1,0,0,0,119,117, +1,0,0,0,119,120,1,0,0,0,120,21,1,0,0,0,121,119,1,0,0,0,122,134,3,26,13,0, +123,134,5,6,0,0,124,125,5,7,0,0,125,134,3,30,15,0,126,127,5,8,0,0,127,128, +3,30,15,0,128,129,5,9,0,0,129,134,1,0,0,0,130,134,5,10,0,0,131,134,5,11, +0,0,132,134,5,12,0,0,133,122,1,0,0,0,133,123,1,0,0,0,133,124,1,0,0,0,133, +126,1,0,0,0,133,130,1,0,0,0,133,131,1,0,0,0,133,132,1,0,0,0,134,23,1,0,0, +0,135,136,3,30,15,0,136,25,1,0,0,0,137,141,3,30,15,0,138,139,5,13,0,0,139, +141,3,30,15,0,140,137,1,0,0,0,140,138,1,0,0,0,141,27,1,0,0,0,142,143,3,30, +15,0,143,29,1,0,0,0,144,145,3,32,16,0,145,31,1,0,0,0,146,151,3,34,17,0,147, +148,5,14,0,0,148,152,3,32,16,0,149,150,5,15,0,0,150,152,3,32,16,0,151,147, +1,0,0,0,151,149,1,0,0,0,151,152,1,0,0,0,152,33,1,0,0,0,153,162,3,52,26,0, +154,162,3,56,28,0,155,162,3,58,29,0,156,162,3,42,21,0,157,162,3,38,19,0, +158,162,3,40,20,0,159,162,3,36,18,0,160,162,3,44,22,0,161,153,1,0,0,0,161, +154,1,0,0,0,161,155,1,0,0,0,161,156,1,0,0,0,161,157,1,0,0,0,161,158,1,0, +0,0,161,159,1,0,0,0,161,160,1,0,0,0,162,35,1,0,0,0,163,167,3,50,25,0,164, +167,3,48,24,0,165,167,5,24,0,0,166,163,1,0,0,0,166,164,1,0,0,0,166,165,1, +0,0,0,167,37,1,0,0,0,168,169,5,16,0,0,169,170,3,18,9,0,170,171,5,17,0,0, +171,39,1,0,0,0,172,173,5,42,0,0,173,174,3,52,26,0,174,175,3,18,9,0,175,176, +5,17,0,0,176,41,1,0,0,0,177,181,5,18,0,0,178,180,3,28,14,0,179,178,1,0,0, +0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183,181, +1,0,0,0,184,185,5,19,0,0,185,43,1,0,0,0,186,188,5,20,0,0,187,189,3,46,23, +0,188,187,1,0,0,0,188,189,1,0,0,0,189,190,1,0,0,0,190,191,5,21,0,0,191,45, +1,0,0,0,192,197,3,2,1,0,193,195,5,1,0,0,194,196,3,46,23,0,195,194,1,0,0, +0,195,196,1,0,0,0,196,198,1,0,0,0,197,193,1,0,0,0,197,198,1,0,0,0,198,204, +1,0,0,0,199,201,3,6,3,0,200,202,3,46,23,0,201,200,1,0,0,0,201,202,1,0,0, +0,202,204,1,0,0,0,203,192,1,0,0,0,203,199,1,0,0,0,204,47,1,0,0,0,205,206, +7,0,0,0,206,49,1,0,0,0,207,211,5,25,0,0,208,212,5,30,0,0,209,210,5,22,0, +0,210,212,3,52,26,0,211,208,1,0,0,0,211,209,1,0,0,0,211,212,1,0,0,0,212, +51,1,0,0,0,213,216,5,26,0,0,214,216,3,54,27,0,215,213,1,0,0,0,215,214,1, +0,0,0,216,53,1,0,0,0,217,218,7,1,0,0,218,55,1,0,0,0,219,220,7,2,0,0,220, +57,1,0,0,0,221,222,5,44,0,0,222,59,1,0,0,0,22,64,66,73,77,81,99,107,111, +119,133,140,151,161,166,181,188,195,197,201,203,211,215]; + + +const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); + +const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) ); + +const sharedContextCache = new antlr4.PredictionContextCache(); + +export default class n3_nodropParser extends antlr4.Parser { + + static grammarFileName = "n3_nodrop.g4"; + static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", + "','", "'a'", "'has'", "'is'", "'of'", "'='", + "'<='", "'=>'", "'<-'", "'!'", "'^'", "'['", + "']'", "'('", "')'", "'{'", "'}'", "'^^'" ]; + static symbolicNames = [ null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "COMMENT", + "BooleanLiteral", "String", "IRIREF", "PNAME_NS", + "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", + "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", + "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", + "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", + "UCHAR", "ECHAR", "WS", "IPLSTART", "ANON", + "QuickVarName", "PN_CHARS_U", "PN_CHARS_BASE", + "PN_CHARS", "BASE", "PREFIX", "PN_PREFIX", + "PN_LOCAL", "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; + static ruleNames = [ "n3Doc", "n3Statement", "n3Directive", "sparqlDirective", + "sparqlBase", "sparqlPrefix", "prefixID", "base", + "triples", "predicateObjectList", "objectList", + "verb", "subject", "predicate", "object", "expression", + "path", "pathItem", "literal", "blankNodePropertyList", + "iriPropertyList", "collection", "formula", "formulaContent", + "numericLiteral", "rdfLiteral", "iri", "prefixedName", + "blankNode", "quickVar" ]; + + constructor(input) { + super(input); + this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache); + this.ruleNames = n3_nodropParser.ruleNames; + this.literalNames = n3_nodropParser.literalNames; + this.symbolicNames = n3_nodropParser.symbolicNames; + } + + get atn() { + return atn; + } + + + + n3Doc() { + let localctx = new N3DocContext(this, this._ctx, this.state); + this.enterRule(localctx, 0, n3_nodropParser.RULE_n3Doc); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 66; + this._errHandler.sync(this); + _la = this._input.LA(1); + while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 64; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + case n3_nodropParser.T__2: + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.state = 60; + this.n3Statement(); + this.state = 61; + this.match(n3_nodropParser.T__0); + break; + case n3_nodropParser.BASE: + case n3_nodropParser.PREFIX: + this.state = 63; + this.sparqlDirective(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + this.state = 68; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 69; + this.match(n3_nodropParser.EOF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + n3Statement() { + let localctx = new N3StatementContext(this, this._ctx, this.state); + this.enterRule(localctx, 2, n3_nodropParser.RULE_n3Statement); + try { + this.state = 73; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + case n3_nodropParser.T__2: + this.enterOuterAlt(localctx, 1); + this.state = 71; + this.n3Directive(); + break; + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 2); + this.state = 72; + this.triples(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + n3Directive() { + let localctx = new N3DirectiveContext(this, this._ctx, this.state); + this.enterRule(localctx, 4, n3_nodropParser.RULE_n3Directive); + try { + this.state = 77; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + this.enterOuterAlt(localctx, 1); + this.state = 75; + this.prefixID(); + break; + case n3_nodropParser.T__2: + this.enterOuterAlt(localctx, 2); + this.state = 76; + this.base(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlDirective() { + let localctx = new SparqlDirectiveContext(this, this._ctx, this.state); + this.enterRule(localctx, 6, n3_nodropParser.RULE_sparqlDirective); + try { + this.state = 81; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.BASE: + this.enterOuterAlt(localctx, 1); + this.state = 79; + this.sparqlBase(); + break; + case n3_nodropParser.PREFIX: + this.enterOuterAlt(localctx, 2); + this.state = 80; + this.sparqlPrefix(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlBase() { + let localctx = new SparqlBaseContext(this, this._ctx, this.state); + this.enterRule(localctx, 8, n3_nodropParser.RULE_sparqlBase); + try { + this.enterOuterAlt(localctx, 1); + this.state = 83; + this.match(n3_nodropParser.BASE); + this.state = 84; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlPrefix() { + let localctx = new SparqlPrefixContext(this, this._ctx, this.state); + this.enterRule(localctx, 10, n3_nodropParser.RULE_sparqlPrefix); + try { + this.enterOuterAlt(localctx, 1); + this.state = 86; + this.match(n3_nodropParser.PREFIX); + this.state = 87; + this.match(n3_nodropParser.PNAME_NS); + this.state = 88; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + prefixID() { + let localctx = new PrefixIDContext(this, this._ctx, this.state); + this.enterRule(localctx, 12, n3_nodropParser.RULE_prefixID); + try { + this.enterOuterAlt(localctx, 1); + this.state = 90; + this.match(n3_nodropParser.T__1); + this.state = 91; + this.match(n3_nodropParser.PNAME_NS); + this.state = 92; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + base() { + let localctx = new BaseContext(this, this._ctx, this.state); + this.enterRule(localctx, 14, n3_nodropParser.RULE_base); + try { + this.enterOuterAlt(localctx, 1); + this.state = 94; + this.match(n3_nodropParser.T__2); + this.state = 95; + this.match(n3_nodropParser.IRIREF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + triples() { + let localctx = new TriplesContext(this, this._ctx, this.state); + this.enterRule(localctx, 16, n3_nodropParser.RULE_triples); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 97; + this.subject(); + this.state = 99; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__5) | (1 << n3_nodropParser.T__6) | (1 << n3_nodropParser.T__7) | (1 << n3_nodropParser.T__9) | (1 << n3_nodropParser.T__10) | (1 << n3_nodropParser.T__11) | (1 << n3_nodropParser.T__12) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)))) !== 0)) { + this.state = 98; + this.predicateObjectList(); + } + + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + predicateObjectList() { + let localctx = new PredicateObjectListContext(this, this._ctx, this.state); + this.enterRule(localctx, 18, n3_nodropParser.RULE_predicateObjectList); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 101; + this.verb(); + this.state = 102; + this.objectList(); + this.state = 111; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(_la===n3_nodropParser.T__3) { + this.state = 103; + this.match(n3_nodropParser.T__3); + this.state = 107; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__5) | (1 << n3_nodropParser.T__6) | (1 << n3_nodropParser.T__7) | (1 << n3_nodropParser.T__9) | (1 << n3_nodropParser.T__10) | (1 << n3_nodropParser.T__11) | (1 << n3_nodropParser.T__12) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)))) !== 0)) { + this.state = 104; + this.verb(); + this.state = 105; + this.objectList(); + } + + this.state = 113; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + objectList() { + let localctx = new ObjectListContext(this, this._ctx, this.state); + this.enterRule(localctx, 20, n3_nodropParser.RULE_objectList); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 114; + this.object(); + this.state = 119; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(_la===n3_nodropParser.T__4) { + this.state = 115; + this.match(n3_nodropParser.T__4); + this.state = 116; + this.object(); + this.state = 121; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + verb() { + let localctx = new VerbContext(this, this._ctx, this.state); + this.enterRule(localctx, 22, n3_nodropParser.RULE_verb); + try { + this.state = 133; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__12: + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 1); + this.state = 122; + this.predicate(); + break; + case n3_nodropParser.T__5: + this.enterOuterAlt(localctx, 2); + this.state = 123; + this.match(n3_nodropParser.T__5); + break; + case n3_nodropParser.T__6: + this.enterOuterAlt(localctx, 3); + this.state = 124; + this.match(n3_nodropParser.T__6); + this.state = 125; + this.expression(); + break; + case n3_nodropParser.T__7: + this.enterOuterAlt(localctx, 4); + this.state = 126; + this.match(n3_nodropParser.T__7); + this.state = 127; + this.expression(); + this.state = 128; + this.match(n3_nodropParser.T__8); + break; + case n3_nodropParser.T__9: + this.enterOuterAlt(localctx, 5); + this.state = 130; + this.match(n3_nodropParser.T__9); + break; + case n3_nodropParser.T__10: + this.enterOuterAlt(localctx, 6); + this.state = 131; + this.match(n3_nodropParser.T__10); + break; + case n3_nodropParser.T__11: + this.enterOuterAlt(localctx, 7); + this.state = 132; + this.match(n3_nodropParser.T__11); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + subject() { + let localctx = new SubjectContext(this, this._ctx, this.state); + this.enterRule(localctx, 24, n3_nodropParser.RULE_subject); + try { + this.enterOuterAlt(localctx, 1); + this.state = 135; + this.expression(); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + predicate() { + let localctx = new PredicateContext(this, this._ctx, this.state); + this.enterRule(localctx, 26, n3_nodropParser.RULE_predicate); + try { + this.enterOuterAlt(localctx, 1); + this.state = 140; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.state = 137; + this.expression(); + break; + case n3_nodropParser.T__12: + this.state = 138; + this.match(n3_nodropParser.T__12); + this.state = 139; + this.expression(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + object() { + let localctx = new ObjectContext(this, this._ctx, this.state); + this.enterRule(localctx, 28, n3_nodropParser.RULE_object); + try { + this.enterOuterAlt(localctx, 1); + this.state = 142; + this.expression(); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + expression() { + let localctx = new ExpressionContext(this, this._ctx, this.state); + this.enterRule(localctx, 30, n3_nodropParser.RULE_expression); + try { + this.enterOuterAlt(localctx, 1); + this.state = 144; + this.path(); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + path() { + let localctx = new PathContext(this, this._ctx, this.state); + this.enterRule(localctx, 32, n3_nodropParser.RULE_path); + try { + this.enterOuterAlt(localctx, 1); + this.state = 146; + this.pathItem(); + this.state = 151; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case n3_nodropParser.T__13: + this.state = 147; + this.match(n3_nodropParser.T__13); + this.state = 148; + this.path(); + break; + case n3_nodropParser.T__14: + this.state = 149; + this.match(n3_nodropParser.T__14); + this.state = 150; + this.path(); + break; + case n3_nodropParser.T__0: + case n3_nodropParser.T__3: + case n3_nodropParser.T__4: + case n3_nodropParser.T__5: + case n3_nodropParser.T__6: + case n3_nodropParser.T__7: + case n3_nodropParser.T__8: + case n3_nodropParser.T__9: + case n3_nodropParser.T__10: + case n3_nodropParser.T__11: + case n3_nodropParser.T__12: + case n3_nodropParser.T__15: + case n3_nodropParser.T__16: + case n3_nodropParser.T__17: + case n3_nodropParser.T__18: + case n3_nodropParser.T__19: + case n3_nodropParser.T__20: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + break; + default: + break; + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + pathItem() { + let localctx = new PathItemContext(this, this._ctx, this.state); + this.enterRule(localctx, 34, n3_nodropParser.RULE_pathItem); + try { + this.state = 161; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + this.enterOuterAlt(localctx, 1); + this.state = 153; + this.iri(); + break; + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.ANON: + this.enterOuterAlt(localctx, 2); + this.state = 154; + this.blankNode(); + break; + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 3); + this.state = 155; + this.quickVar(); + break; + case n3_nodropParser.T__17: + this.enterOuterAlt(localctx, 4); + this.state = 156; + this.collection(); + break; + case n3_nodropParser.T__15: + this.enterOuterAlt(localctx, 5); + this.state = 157; + this.blankNodePropertyList(); + break; + case n3_nodropParser.IPLSTART: + this.enterOuterAlt(localctx, 6); + this.state = 158; + this.iriPropertyList(); + break; + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + this.enterOuterAlt(localctx, 7); + this.state = 159; + this.literal(); + break; + case n3_nodropParser.T__19: + this.enterOuterAlt(localctx, 8); + this.state = 160; + this.formula(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + literal() { + let localctx = new LiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 36, n3_nodropParser.RULE_literal); + try { + this.state = 166; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.String: + this.enterOuterAlt(localctx, 1); + this.state = 163; + this.rdfLiteral(); + break; + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + this.enterOuterAlt(localctx, 2); + this.state = 164; + this.numericLiteral(); + break; + case n3_nodropParser.BooleanLiteral: + this.enterOuterAlt(localctx, 3); + this.state = 165; + this.match(n3_nodropParser.BooleanLiteral); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + blankNodePropertyList() { + let localctx = new BlankNodePropertyListContext(this, this._ctx, this.state); + this.enterRule(localctx, 38, n3_nodropParser.RULE_blankNodePropertyList); + try { + this.enterOuterAlt(localctx, 1); + this.state = 168; + this.match(n3_nodropParser.T__15); + this.state = 169; + this.predicateObjectList(); + this.state = 170; + this.match(n3_nodropParser.T__16); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + iriPropertyList() { + let localctx = new IriPropertyListContext(this, this._ctx, this.state); + this.enterRule(localctx, 40, n3_nodropParser.RULE_iriPropertyList); + try { + this.enterOuterAlt(localctx, 1); + this.state = 172; + this.match(n3_nodropParser.IPLSTART); + this.state = 173; + this.iri(); + this.state = 174; + this.predicateObjectList(); + this.state = 175; + this.match(n3_nodropParser.T__16); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + collection() { + let localctx = new CollectionContext(this, this._ctx, this.state); + this.enterRule(localctx, 42, n3_nodropParser.RULE_collection); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 177; + this.match(n3_nodropParser.T__17); + this.state = 181; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(((((_la - 16)) & ~0x1f) == 0 && ((1 << (_la - 16)) & ((1 << (n3_nodropParser.T__15 - 16)) | (1 << (n3_nodropParser.T__17 - 16)) | (1 << (n3_nodropParser.T__19 - 16)) | (1 << (n3_nodropParser.BooleanLiteral - 16)) | (1 << (n3_nodropParser.String - 16)) | (1 << (n3_nodropParser.IRIREF - 16)) | (1 << (n3_nodropParser.PNAME_NS - 16)) | (1 << (n3_nodropParser.PNAME_LN - 16)) | (1 << (n3_nodropParser.BLANK_NODE_LABEL - 16)) | (1 << (n3_nodropParser.INTEGER - 16)) | (1 << (n3_nodropParser.DECIMAL - 16)) | (1 << (n3_nodropParser.DOUBLE - 16)) | (1 << (n3_nodropParser.IPLSTART - 16)) | (1 << (n3_nodropParser.ANON - 16)) | (1 << (n3_nodropParser.QuickVarName - 16)))) !== 0)) { + this.state = 178; + this.object(); + this.state = 183; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 184; + this.match(n3_nodropParser.T__18); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + formula() { + let localctx = new FormulaContext(this, this._ctx, this.state); + this.enterRule(localctx, 44, n3_nodropParser.RULE_formula); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 186; + this.match(n3_nodropParser.T__19); + this.state = 188; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 187; + this.formulaContent(); + } + + this.state = 190; + this.match(n3_nodropParser.T__20); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + formulaContent() { + let localctx = new FormulaContentContext(this, this._ctx, this.state); + this.enterRule(localctx, 46, n3_nodropParser.RULE_formulaContent); + var _la = 0; // Token type + try { + this.state = 203; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.T__1: + case n3_nodropParser.T__2: + case n3_nodropParser.T__15: + case n3_nodropParser.T__17: + case n3_nodropParser.T__19: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + this.enterOuterAlt(localctx, 1); + this.state = 192; + this.n3Statement(); + this.state = 197; + this._errHandler.sync(this); + _la = this._input.LA(1); + if(_la===n3_nodropParser.T__0) { + this.state = 193; + this.match(n3_nodropParser.T__0); + this.state = 195; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 194; + this.formulaContent(); + } + + } + + break; + case n3_nodropParser.BASE: + case n3_nodropParser.PREFIX: + this.enterOuterAlt(localctx, 2); + this.state = 199; + this.sparqlDirective(); + this.state = 201; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << n3_nodropParser.T__1) | (1 << n3_nodropParser.T__2) | (1 << n3_nodropParser.T__15) | (1 << n3_nodropParser.T__17) | (1 << n3_nodropParser.T__19) | (1 << n3_nodropParser.BooleanLiteral) | (1 << n3_nodropParser.String) | (1 << n3_nodropParser.IRIREF) | (1 << n3_nodropParser.PNAME_NS) | (1 << n3_nodropParser.PNAME_LN) | (1 << n3_nodropParser.BLANK_NODE_LABEL) | (1 << n3_nodropParser.INTEGER))) !== 0) || ((((_la - 32)) & ~0x1f) == 0 && ((1 << (_la - 32)) & ((1 << (n3_nodropParser.DECIMAL - 32)) | (1 << (n3_nodropParser.DOUBLE - 32)) | (1 << (n3_nodropParser.IPLSTART - 32)) | (1 << (n3_nodropParser.ANON - 32)) | (1 << (n3_nodropParser.QuickVarName - 32)) | (1 << (n3_nodropParser.BASE - 32)) | (1 << (n3_nodropParser.PREFIX - 32)))) !== 0)) { + this.state = 200; + this.formulaContent(); + } + + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + numericLiteral() { + let localctx = new NumericLiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 48, n3_nodropParser.RULE_numericLiteral); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 205; + _la = this._input.LA(1); + if(!(((((_la - 31)) & ~0x1f) == 0 && ((1 << (_la - 31)) & ((1 << (n3_nodropParser.INTEGER - 31)) | (1 << (n3_nodropParser.DECIMAL - 31)) | (1 << (n3_nodropParser.DOUBLE - 31)))) !== 0))) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + rdfLiteral() { + let localctx = new RdfLiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 50, n3_nodropParser.RULE_rdfLiteral); + try { + this.enterOuterAlt(localctx, 1); + this.state = 207; + this.match(n3_nodropParser.String); + this.state = 211; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case n3_nodropParser.LANGTAG: + this.state = 208; + this.match(n3_nodropParser.LANGTAG); + break; + case n3_nodropParser.T__21: + this.state = 209; + this.match(n3_nodropParser.T__21); + this.state = 210; + this.iri(); + break; + case n3_nodropParser.T__0: + case n3_nodropParser.T__3: + case n3_nodropParser.T__4: + case n3_nodropParser.T__5: + case n3_nodropParser.T__6: + case n3_nodropParser.T__7: + case n3_nodropParser.T__8: + case n3_nodropParser.T__9: + case n3_nodropParser.T__10: + case n3_nodropParser.T__11: + case n3_nodropParser.T__12: + case n3_nodropParser.T__13: + case n3_nodropParser.T__14: + case n3_nodropParser.T__15: + case n3_nodropParser.T__16: + case n3_nodropParser.T__17: + case n3_nodropParser.T__18: + case n3_nodropParser.T__19: + case n3_nodropParser.T__20: + case n3_nodropParser.BooleanLiteral: + case n3_nodropParser.String: + case n3_nodropParser.IRIREF: + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + case n3_nodropParser.BLANK_NODE_LABEL: + case n3_nodropParser.INTEGER: + case n3_nodropParser.DECIMAL: + case n3_nodropParser.DOUBLE: + case n3_nodropParser.IPLSTART: + case n3_nodropParser.ANON: + case n3_nodropParser.QuickVarName: + break; + default: + break; + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + iri() { + let localctx = new IriContext(this, this._ctx, this.state); + this.enterRule(localctx, 52, n3_nodropParser.RULE_iri); + try { + this.state = 215; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case n3_nodropParser.IRIREF: + this.enterOuterAlt(localctx, 1); + this.state = 213; + this.match(n3_nodropParser.IRIREF); + break; + case n3_nodropParser.PNAME_NS: + case n3_nodropParser.PNAME_LN: + this.enterOuterAlt(localctx, 2); + this.state = 214; + this.prefixedName(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + prefixedName() { + let localctx = new PrefixedNameContext(this, this._ctx, this.state); + this.enterRule(localctx, 54, n3_nodropParser.RULE_prefixedName); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 217; + _la = this._input.LA(1); + if(!(_la===n3_nodropParser.PNAME_NS || _la===n3_nodropParser.PNAME_LN)) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + blankNode() { + let localctx = new BlankNodeContext(this, this._ctx, this.state); + this.enterRule(localctx, 56, n3_nodropParser.RULE_blankNode); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 219; + _la = this._input.LA(1); + if(!(_la===n3_nodropParser.BLANK_NODE_LABEL || _la===n3_nodropParser.ANON)) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + quickVar() { + let localctx = new QuickVarContext(this, this._ctx, this.state); + this.enterRule(localctx, 58, n3_nodropParser.RULE_quickVar); + try { + this.enterOuterAlt(localctx, 1); + this.state = 221; + this.match(n3_nodropParser.QuickVarName); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + +} + +n3_nodropParser.EOF = antlr4.Token.EOF; +n3_nodropParser.T__0 = 1; +n3_nodropParser.T__1 = 2; +n3_nodropParser.T__2 = 3; +n3_nodropParser.T__3 = 4; +n3_nodropParser.T__4 = 5; +n3_nodropParser.T__5 = 6; +n3_nodropParser.T__6 = 7; +n3_nodropParser.T__7 = 8; +n3_nodropParser.T__8 = 9; +n3_nodropParser.T__9 = 10; +n3_nodropParser.T__10 = 11; +n3_nodropParser.T__11 = 12; +n3_nodropParser.T__12 = 13; +n3_nodropParser.T__13 = 14; +n3_nodropParser.T__14 = 15; +n3_nodropParser.T__15 = 16; +n3_nodropParser.T__16 = 17; +n3_nodropParser.T__17 = 18; +n3_nodropParser.T__18 = 19; +n3_nodropParser.T__19 = 20; +n3_nodropParser.T__20 = 21; +n3_nodropParser.T__21 = 22; +n3_nodropParser.COMMENT = 23; +n3_nodropParser.BooleanLiteral = 24; +n3_nodropParser.String = 25; +n3_nodropParser.IRIREF = 26; +n3_nodropParser.PNAME_NS = 27; +n3_nodropParser.PNAME_LN = 28; +n3_nodropParser.BLANK_NODE_LABEL = 29; +n3_nodropParser.LANGTAG = 30; +n3_nodropParser.INTEGER = 31; +n3_nodropParser.DECIMAL = 32; +n3_nodropParser.DOUBLE = 33; +n3_nodropParser.EXPONENT = 34; +n3_nodropParser.STRING_LITERAL_LONG_SINGLE_QUOTE = 35; +n3_nodropParser.STRING_LITERAL_LONG_QUOTE = 36; +n3_nodropParser.STRING_LITERAL_QUOTE = 37; +n3_nodropParser.STRING_LITERAL_SINGLE_QUOTE = 38; +n3_nodropParser.UCHAR = 39; +n3_nodropParser.ECHAR = 40; +n3_nodropParser.WS = 41; +n3_nodropParser.IPLSTART = 42; +n3_nodropParser.ANON = 43; +n3_nodropParser.QuickVarName = 44; +n3_nodropParser.PN_CHARS_U = 45; +n3_nodropParser.PN_CHARS_BASE = 46; +n3_nodropParser.PN_CHARS = 47; +n3_nodropParser.BASE = 48; +n3_nodropParser.PREFIX = 49; +n3_nodropParser.PN_PREFIX = 50; +n3_nodropParser.PN_LOCAL = 51; +n3_nodropParser.PLX = 52; +n3_nodropParser.PERCENT = 53; +n3_nodropParser.HEX = 54; +n3_nodropParser.PN_LOCAL_ESC = 55; + +n3_nodropParser.RULE_n3Doc = 0; +n3_nodropParser.RULE_n3Statement = 1; +n3_nodropParser.RULE_n3Directive = 2; +n3_nodropParser.RULE_sparqlDirective = 3; +n3_nodropParser.RULE_sparqlBase = 4; +n3_nodropParser.RULE_sparqlPrefix = 5; +n3_nodropParser.RULE_prefixID = 6; +n3_nodropParser.RULE_base = 7; +n3_nodropParser.RULE_triples = 8; +n3_nodropParser.RULE_predicateObjectList = 9; +n3_nodropParser.RULE_objectList = 10; +n3_nodropParser.RULE_verb = 11; +n3_nodropParser.RULE_subject = 12; +n3_nodropParser.RULE_predicate = 13; +n3_nodropParser.RULE_object = 14; +n3_nodropParser.RULE_expression = 15; +n3_nodropParser.RULE_path = 16; +n3_nodropParser.RULE_pathItem = 17; +n3_nodropParser.RULE_literal = 18; +n3_nodropParser.RULE_blankNodePropertyList = 19; +n3_nodropParser.RULE_iriPropertyList = 20; +n3_nodropParser.RULE_collection = 21; +n3_nodropParser.RULE_formula = 22; +n3_nodropParser.RULE_formulaContent = 23; +n3_nodropParser.RULE_numericLiteral = 24; +n3_nodropParser.RULE_rdfLiteral = 25; +n3_nodropParser.RULE_iri = 26; +n3_nodropParser.RULE_prefixedName = 27; +n3_nodropParser.RULE_blankNode = 28; +n3_nodropParser.RULE_quickVar = 29; + +class N3DocContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_n3Doc; + } + + EOF() { + return this.getToken(n3_nodropParser.EOF, 0); + }; + + n3Statement = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(N3StatementContext); + } else { + return this.getTypedRuleContext(N3StatementContext,i); + } + }; + + sparqlDirective = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(SparqlDirectiveContext); + } else { + return this.getTypedRuleContext(SparqlDirectiveContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterN3Doc(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitN3Doc(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitN3Doc(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class N3StatementContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_n3Statement; + } + + n3Directive() { + return this.getTypedRuleContext(N3DirectiveContext,0); + }; + + triples() { + return this.getTypedRuleContext(TriplesContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterN3Statement(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitN3Statement(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitN3Statement(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class N3DirectiveContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_n3Directive; + } + + prefixID() { + return this.getTypedRuleContext(PrefixIDContext,0); + }; + + base() { + return this.getTypedRuleContext(BaseContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterN3Directive(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitN3Directive(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitN3Directive(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SparqlDirectiveContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_sparqlDirective; + } + + sparqlBase() { + return this.getTypedRuleContext(SparqlBaseContext,0); + }; + + sparqlPrefix() { + return this.getTypedRuleContext(SparqlPrefixContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSparqlDirective(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSparqlDirective(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSparqlDirective(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SparqlBaseContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_sparqlBase; + } + + BASE() { + return this.getToken(n3_nodropParser.BASE, 0); + }; + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSparqlBase(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSparqlBase(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSparqlBase(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SparqlPrefixContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_sparqlPrefix; + } + + PREFIX() { + return this.getToken(n3_nodropParser.PREFIX, 0); + }; + + PNAME_NS() { + return this.getToken(n3_nodropParser.PNAME_NS, 0); + }; + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSparqlPrefix(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSparqlPrefix(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSparqlPrefix(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PrefixIDContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_prefixID; + } + + PNAME_NS() { + return this.getToken(n3_nodropParser.PNAME_NS, 0); + }; + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPrefixID(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPrefixID(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPrefixID(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class BaseContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_base; + } + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterBase(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitBase(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitBase(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class TriplesContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_triples; + } + + subject() { + return this.getTypedRuleContext(SubjectContext,0); + }; + + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterTriples(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitTriples(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitTriples(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PredicateObjectListContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_predicateObjectList; + } + + verb = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(VerbContext); + } else { + return this.getTypedRuleContext(VerbContext,i); + } + }; + + objectList = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectListContext); + } else { + return this.getTypedRuleContext(ObjectListContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPredicateObjectList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPredicateObjectList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPredicateObjectList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class ObjectListContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_objectList; + } + + object = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectContext); + } else { + return this.getTypedRuleContext(ObjectContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterObjectList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitObjectList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitObjectList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class VerbContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_verb; + } + + predicate() { + return this.getTypedRuleContext(PredicateContext,0); + }; + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterVerb(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitVerb(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitVerb(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class SubjectContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_subject; + } + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterSubject(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitSubject(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitSubject(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PredicateContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_predicate; + } + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPredicate(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPredicate(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPredicate(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class ObjectContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_object; + } + + expression() { + return this.getTypedRuleContext(ExpressionContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterObject(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitObject(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitObject(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class ExpressionContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_expression; + } + + path() { + return this.getTypedRuleContext(PathContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterExpression(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitExpression(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitExpression(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PathContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_path; + } + + pathItem() { + return this.getTypedRuleContext(PathItemContext,0); + }; + + path() { + return this.getTypedRuleContext(PathContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPath(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPath(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPath(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PathItemContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_pathItem; + } + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + blankNode() { + return this.getTypedRuleContext(BlankNodeContext,0); + }; + + quickVar() { + return this.getTypedRuleContext(QuickVarContext,0); + }; + + collection() { + return this.getTypedRuleContext(CollectionContext,0); + }; + + blankNodePropertyList() { + return this.getTypedRuleContext(BlankNodePropertyListContext,0); + }; + + iriPropertyList() { + return this.getTypedRuleContext(IriPropertyListContext,0); + }; + + literal() { + return this.getTypedRuleContext(LiteralContext,0); + }; + + formula() { + return this.getTypedRuleContext(FormulaContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPathItem(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPathItem(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPathItem(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class LiteralContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_literal; + } + + rdfLiteral() { + return this.getTypedRuleContext(RdfLiteralContext,0); + }; + + numericLiteral() { + return this.getTypedRuleContext(NumericLiteralContext,0); + }; + + BooleanLiteral() { + return this.getToken(n3_nodropParser.BooleanLiteral, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterLiteral(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitLiteral(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitLiteral(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class BlankNodePropertyListContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_blankNodePropertyList; + } + + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterBlankNodePropertyList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitBlankNodePropertyList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitBlankNodePropertyList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class IriPropertyListContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_iriPropertyList; + } + + IPLSTART() { + return this.getToken(n3_nodropParser.IPLSTART, 0); + }; + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterIriPropertyList(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitIriPropertyList(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitIriPropertyList(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class CollectionContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_collection; + } + + object = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectContext); + } else { + return this.getTypedRuleContext(ObjectContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterCollection(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitCollection(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitCollection(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class FormulaContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_formula; + } + + formulaContent() { + return this.getTypedRuleContext(FormulaContentContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterFormula(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitFormula(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitFormula(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class FormulaContentContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_formulaContent; + } + + n3Statement() { + return this.getTypedRuleContext(N3StatementContext,0); + }; + + formulaContent() { + return this.getTypedRuleContext(FormulaContentContext,0); + }; + + sparqlDirective() { + return this.getTypedRuleContext(SparqlDirectiveContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterFormulaContent(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitFormulaContent(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitFormulaContent(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class NumericLiteralContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_numericLiteral; + } + + INTEGER() { + return this.getToken(n3_nodropParser.INTEGER, 0); + }; + + DECIMAL() { + return this.getToken(n3_nodropParser.DECIMAL, 0); + }; + + DOUBLE() { + return this.getToken(n3_nodropParser.DOUBLE, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterNumericLiteral(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitNumericLiteral(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitNumericLiteral(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class RdfLiteralContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_rdfLiteral; + } + + String() { + return this.getToken(n3_nodropParser.String, 0); + }; + + LANGTAG() { + return this.getToken(n3_nodropParser.LANGTAG, 0); + }; + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterRdfLiteral(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitRdfLiteral(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitRdfLiteral(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class IriContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_iri; + } + + IRIREF() { + return this.getToken(n3_nodropParser.IRIREF, 0); + }; + + prefixedName() { + return this.getTypedRuleContext(PrefixedNameContext,0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterIri(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitIri(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitIri(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class PrefixedNameContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_prefixedName; + } + + PNAME_NS() { + return this.getToken(n3_nodropParser.PNAME_NS, 0); + }; + + PNAME_LN() { + return this.getToken(n3_nodropParser.PNAME_LN, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterPrefixedName(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitPrefixedName(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitPrefixedName(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class BlankNodeContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_blankNode; + } + + BLANK_NODE_LABEL() { + return this.getToken(n3_nodropParser.BLANK_NODE_LABEL, 0); + }; + + ANON() { + return this.getToken(n3_nodropParser.ANON, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterBlankNode(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitBlankNode(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitBlankNode(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + +class QuickVarContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = n3_nodropParser.RULE_quickVar; + } + + QuickVarName() { + return this.getToken(n3_nodropParser.QuickVarName, 0); + }; + + enterRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.enterQuickVar(this); + } + } + + exitRule(listener) { + if(listener instanceof n3_nodropListener ) { + listener.exitQuickVar(this); + } + } + + accept(visitor) { + if ( visitor instanceof n3_nodropVisitor ) { + return visitor.visitQuickVar(this); + } else { + return visitor.visitChildren(this); + } + } + + +} + + + + +n3_nodropParser.N3DocContext = N3DocContext; +n3_nodropParser.N3StatementContext = N3StatementContext; +n3_nodropParser.N3DirectiveContext = N3DirectiveContext; +n3_nodropParser.SparqlDirectiveContext = SparqlDirectiveContext; +n3_nodropParser.SparqlBaseContext = SparqlBaseContext; +n3_nodropParser.SparqlPrefixContext = SparqlPrefixContext; +n3_nodropParser.PrefixIDContext = PrefixIDContext; +n3_nodropParser.BaseContext = BaseContext; +n3_nodropParser.TriplesContext = TriplesContext; +n3_nodropParser.PredicateObjectListContext = PredicateObjectListContext; +n3_nodropParser.ObjectListContext = ObjectListContext; +n3_nodropParser.VerbContext = VerbContext; +n3_nodropParser.SubjectContext = SubjectContext; +n3_nodropParser.PredicateContext = PredicateContext; +n3_nodropParser.ObjectContext = ObjectContext; +n3_nodropParser.ExpressionContext = ExpressionContext; +n3_nodropParser.PathContext = PathContext; +n3_nodropParser.PathItemContext = PathItemContext; +n3_nodropParser.LiteralContext = LiteralContext; +n3_nodropParser.BlankNodePropertyListContext = BlankNodePropertyListContext; +n3_nodropParser.IriPropertyListContext = IriPropertyListContext; +n3_nodropParser.CollectionContext = CollectionContext; +n3_nodropParser.FormulaContext = FormulaContext; +n3_nodropParser.FormulaContentContext = FormulaContentContext; +n3_nodropParser.NumericLiteralContext = NumericLiteralContext; +n3_nodropParser.RdfLiteralContext = RdfLiteralContext; +n3_nodropParser.IriContext = IriContext; +n3_nodropParser.PrefixedNameContext = PrefixedNameContext; +n3_nodropParser.BlankNodeContext = BlankNodeContext; +n3_nodropParser.QuickVarContext = QuickVarContext; diff --git a/editor/parser/n3_nodrop/n3_nodropPrefixListener.js b/editor/parser/n3_nodrop/n3_nodropPrefixListener.js new file mode 100644 index 0000000..9d6f2bb --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropPrefixListener.js @@ -0,0 +1,65 @@ +import n3_nodropListener from './n3_nodropListener'; + +export default class n3_nodropPrefixListener extends n3_nodropListener { + + constructor(listener) { + super(); + + this.listener = listener; + this.prefixes = {}; + } + + // Exit a parse tree produced by n3Parser#sparqlPrefix. + exitSparqlPrefix(ctx) { + this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); + } + + // Exit a parse tree produced by n3Parser#prefixID. + exitPrefixID(ctx) { + this.processPrefix(ctx.PNAME_NS(), ctx.IRIREF()); + } + + processPrefix(pNameNs, iriRef) { + if (pNameNs == null) + return + + var prefix = pNameNs.getText().trim(); + prefix = prefix.substring(0, prefix.length - 1) + + var uri = this.iri(iriRef); + this.prefixes[prefix] = uri; + } + + // Exit a parse tree produced by n3Parser#prefixedName. + exitPrefixedName(ctx) { + var pNameLn = ctx.PNAME_LN(); + + if (pNameLn != null) { + var pName = pNameLn.getText().trim(); + var prefix = pName.substring(0, pName.indexOf(":")).trim(); + + if (prefix == "") + return; + + if (this.prefixes[prefix] === undefined) { + var line = ctx.start.line + var start = ctx.start.column + var end = start + prefix.length + + this.listener.unknownPrefix(prefix, pName, line, start, end); + } + } + } + + text(node) { + if (node == null) + return null; + + return node.getText().trim(); + } + + iri(node) { + var s = this.text(node); + return s.substring(1, s.length - 1); + } +} \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodropPrintVisitor.js b/editor/parser/n3_nodrop/n3_nodropPrintVisitor.js new file mode 100644 index 0000000..6d333e9 --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropPrintVisitor.js @@ -0,0 +1,291 @@ +// var n3Visitor = require('./n3Visitor').n3Visitor +// var n3Parser = require('./n3Parser').n3Parser +import n3_nodropVisitor from './n3_nodropVisitor'; +import n3_nodropParser from './n3_nodropParser'; + +export default class n3_nodropPrintVisitor extends n3_nodropVisitor { + + constructor(listener) { + super(); + + this.listener = listener; + this.lvl = 0 + } + + // Visit a parse tree produced by n3Parser#n3Doc. + visitN3Doc(ctx) { + this.print("N3Doc") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#n3Statement. + visitN3Statement(ctx) { + this.print("N3Statement") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#n3Directive. + visitN3Directive(ctx) { + this.print("N3Directive") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#sparqlDirective. + visitSparqlDirective(ctx) { + this.print("SparqlDirective") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#sparqlBase. + visitSparqlBase(ctx) { + this.print("SparqlBase") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#sparqlPrefix. + visitSparqlPrefix(ctx) { + this.print("SparqlPrefix") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixID. + visitPrefixID(ctx) { + this.print("PrefixID") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#base. + visitBase(ctx) { + this.print("Base") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#triples. + visitTriples(ctx) { + this.print("Triples") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicateObjectList. + visitPredicateObjectList(ctx) { + this.print("PredicateObjectList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#objectList. + visitObjectList(ctx) { + this.print("ObjectList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#verb. + visitVerb(ctx) { + this.print("Verb") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#subject. + visitSubject(ctx) { + this.print("Subject") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#predicate. + visitPredicate(ctx) { + this.print("Predicate") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#object. + visitObject(ctx) { + this.print("Object") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#expression. + visitExpression(ctx) { + this.print("Expression") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#path. + visitPath(ctx) { + this.print("Path") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#pathItem. + visitPathItem(ctx) { + this.print("PathItem") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#literal. + visitLiteral(ctx) { + this.print("Literal") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + this.print("BlankNodePropertyList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriPropertyList. + visitIriPropertyList(ctx) { + this.print("IriPropertyList") + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3Parser#collection. + visitCollection(ctx) { + this.print("Collection") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#formula. + visitFormula(ctx) { + this.print("Formula") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#formulaContent. + visitFormulaContent(ctx) { + this.print("FormulaContent") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#numericLiteral. + visitNumericLiteral(ctx) { + this.print("NumericLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#rdfLiteral. + visitRdfLiteral(ctx) { + this.print("RdfLiteral") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iri. + visitIri(ctx) { + this.print("Iri") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#iriList. + visitIriList(ctx) { + this.print("IriList") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#prefixedName. + visitPrefixedName(ctx) { + this.print("PrefixedName") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#blankNode. + visitBlankNode(ctx) { + this.print("BlankNode") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#quickVar. + visitQuickVar(ctx) { + this.print("QuickVar") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#existential. + visitExistential(ctx) { + this.print("Existential") + return this.doVisitChildren(ctx) + } + + + // Visit a parse tree produced by n3Parser#universal. + visitUniversal(ctx) { + this.print("Universal") + return this.doVisitChildren(ctx) + } + + + incrLvl() { + this.lvl++; + } + + decrLvl() { + this.lvl--; + } + + print(el) { + var ws = new Array(this.lvl + 1).join(" "); + var out = ws + el + "\n"; + + this.listener.newAstLine(out); + } + + doVisitChildren(ctx) { + this.lvl++; + this.visitChildren(ctx); + this.lvl--; + } + + visitChildren(node) { + var result = null; // this.defaultResult() + var n = node.getChildCount() + for (var i = 0; i < n; i++) { + // if (!this.shouldVisitNextChild(node, result)) { + // break + // } + + var c = node.getChild(i) + if (c.symbol !== undefined) { + var out = "' " + c + " '"; + var type = c.symbol.type + if (type != -1 && n3_nodropParser.symbolicNames[type] !== null) + out += " (" + n3_nodropParser.symbolicNames[type] + ")" + this.print(out) + + } else { + result = c.accept(this); + // result = this.aggregateResult(result, childResult); + } + } + + return result + } +} \ No newline at end of file diff --git a/editor/parser/n3_nodrop/n3_nodropVisitor.js b/editor/parser/n3_nodrop/n3_nodropVisitor.js new file mode 100644 index 0000000..5fbc492 --- /dev/null +++ b/editor/parser/n3_nodrop/n3_nodropVisitor.js @@ -0,0 +1,190 @@ +// Generated from /Users/wvw/git/n3/N3/grammar/n3_nodrop.g4 by ANTLR 4.10.1 +// jshint ignore: start +import antlr4 from 'antlr4'; + +// This class defines a complete generic visitor for a parse tree produced by n3_nodropParser. + +export default class n3_nodropVisitor extends antlr4.tree.ParseTreeVisitor { + + // Visit a parse tree produced by n3_nodropParser#n3Doc. + visitN3Doc(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#n3Statement. + visitN3Statement(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#n3Directive. + visitN3Directive(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#sparqlDirective. + visitSparqlDirective(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#sparqlBase. + visitSparqlBase(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#sparqlPrefix. + visitSparqlPrefix(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#prefixID. + visitPrefixID(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#base. + visitBase(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#triples. + visitTriples(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#predicateObjectList. + visitPredicateObjectList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#objectList. + visitObjectList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#verb. + visitVerb(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#subject. + visitSubject(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#predicate. + visitPredicate(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#object. + visitObject(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#expression. + visitExpression(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#path. + visitPath(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#pathItem. + visitPathItem(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#literal. + visitLiteral(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#iriPropertyList. + visitIriPropertyList(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#collection. + visitCollection(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#formula. + visitFormula(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#formulaContent. + visitFormulaContent(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#numericLiteral. + visitNumericLiteral(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#rdfLiteral. + visitRdfLiteral(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#iri. + visitIri(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#prefixedName. + visitPrefixedName(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#blankNode. + visitBlankNode(ctx) { + return this.visitChildren(ctx); + } + + + // Visit a parse tree produced by n3_nodropParser#quickVar. + visitQuickVar(ctx) { + return this.visitChildren(ctx); + } + + + +} \ No newline at end of file diff --git a/editor/parser/turtlestar/index.js b/editor/parser/turtlestar/index.js index 414d7af..cbf7bbe 100644 --- a/editor/parser/turtlestar/index.js +++ b/editor/parser/turtlestar/index.js @@ -1,18 +1,27 @@ -var antlr4 = require('antlr4'); -var TurtleStarLexer = require('./turtlestarLexer').turtlestarLexer; -var TurtleStarParser = require('./turtlestarParser').turtlestarParser; -var TurtleStarPrefixListener = require('./turtlestarPrefixListener').turtlestarPrefixListener; -// var TurtleStarPrintListener = require('./turtlestarPrintListener').turtlestarPrintListener; -var TurtleStarPrintVisitor = require('./turtlestarPrintVisitor').turtlestarPrintVisitor; +// - CommonJS +// var antlr4 = require('antlr4'); +// var TurtleStarLexer = require('./turtlestarLexer').turtlestarLexer; +// var TurtleStarParser = require('./turtlestarParser').turtlestarParser; +// var TurtleStarPrefixListener = require('./turtlestarPrefixListener').turtlestarPrefixListener; +// // var TurtleStarPrintListener = require('./turtlestarPrintListener').turtlestarPrintListener; +// var TurtleStarPrintVisitor = require('./turtlestarPrintVisitor').turtlestarPrintVisitor; + +// - ES6 +import InputStream from 'antlr4/src/antlr4/InputStream'; +import CommonTokenStream from 'antlr4/src/antlr4/CommonTokenStream'; +import TurtleStarLexer from './turtlestarLexer'; +import TurtleStarParser from './turtlestarParser'; +import TurtleStarPrintListener from './turtlestarPrintListener'; +import TurtleStarPrintVisitor from './turtlestarPrintVisitor'; function parse(input, listener) { - var chars = new antlr4.InputStream(input); + var chars = new InputStream(input); var turtlestarLexer = new TurtleStarLexer(chars); turtlestarLexer.removeErrorListeners(); turtlestarLexer.addErrorListener(listener); - var tokens = new antlr4.CommonTokenStream(turtlestarLexer); + var tokens = new CommonTokenStream(turtlestarLexer); var turtlestarParser = new TurtleStarParser(tokens); turtlestarParser.removeErrorListeners(); diff --git a/editor/parser/turtlestar/turtlestar.interp b/editor/parser/turtlestar/turtlestar.interp new file mode 100644 index 0000000..811c596 --- /dev/null +++ b/editor/parser/turtlestar/turtlestar.interp @@ -0,0 +1,126 @@ +token literal names: +null +'.' +'@prefix' +'@base' +';' +',' +'a' +'<<' +'>>' +'[' +']' +'(' +')' +'^^' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +COMMENT +NumericLiteral +BooleanLiteral +String +BlankNode +IRIREF +PNAME_NS +PNAME_LN +BLANK_NODE_LABEL +LANGTAG +INTEGER +DECIMAL +DOUBLE +EXPONENT +STRING_LITERAL_LONG_SINGLE_QUOTE +STRING_LITERAL_LONG_QUOTE +STRING_LITERAL_QUOTE +STRING_LITERAL_SINGLE_QUOTE +UCHAR +ECHAR +WS +ANON +PN_CHARS_BASE +PN_CHARS_U +PN_CHARS +BASE +PREFIX +PN_PREFIX +PN_LOCAL +PLX +PERCENT +HEX +PN_LOCAL_ESC + +rule names: +turtleStarDoc +statement +directive +prefixID +base +sparqlBase +sparqlPrefix +triples +predicateObjectList +objectList +verb +subject +predicate +object +tripleX +subjectX +objectX +literal +blankNodePropertyList +collection +rdfLiteral +iri +prefixedName + + +atn: +[4, 1, 46, 180, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 1, 0, 5, 0, 48, 8, 0, 10, 0, 12, 0, 51, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 59, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 65, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 88, 8, 7, 3, 7, 90, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 98, 8, 8, 5, 8, 100, 8, 8, 10, 8, 12, 8, 103, 9, 8, 1, 9, 1, 9, 1, 9, 5, 9, 108, 8, 9, 10, 9, 12, 9, 111, 9, 9, 1, 10, 1, 10, 3, 10, 115, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 121, 8, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 131, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 3, 15, 142, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 148, 8, 16, 1, 17, 1, 17, 1, 17, 3, 17, 153, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 5, 19, 161, 8, 19, 10, 19, 12, 19, 164, 9, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 172, 8, 20, 1, 21, 1, 21, 3, 21, 176, 8, 21, 1, 22, 1, 22, 1, 22, 0, 0, 23, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 0, 1, 1, 0, 20, 21, 186, 0, 49, 1, 0, 0, 0, 2, 58, 1, 0, 0, 0, 4, 64, 1, 0, 0, 0, 6, 66, 1, 0, 0, 0, 8, 71, 1, 0, 0, 0, 10, 75, 1, 0, 0, 0, 12, 78, 1, 0, 0, 0, 14, 89, 1, 0, 0, 0, 16, 91, 1, 0, 0, 0, 18, 104, 1, 0, 0, 0, 20, 114, 1, 0, 0, 0, 22, 120, 1, 0, 0, 0, 24, 122, 1, 0, 0, 0, 26, 130, 1, 0, 0, 0, 28, 132, 1, 0, 0, 0, 30, 141, 1, 0, 0, 0, 32, 147, 1, 0, 0, 0, 34, 152, 1, 0, 0, 0, 36, 154, 1, 0, 0, 0, 38, 158, 1, 0, 0, 0, 40, 167, 1, 0, 0, 0, 42, 175, 1, 0, 0, 0, 44, 177, 1, 0, 0, 0, 46, 48, 3, 2, 1, 0, 47, 46, 1, 0, 0, 0, 48, 51, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 52, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 52, 53, 5, 0, 0, 1, 53, 1, 1, 0, 0, 0, 54, 59, 3, 4, 2, 0, 55, 56, 3, 14, 7, 0, 56, 57, 5, 1, 0, 0, 57, 59, 1, 0, 0, 0, 58, 54, 1, 0, 0, 0, 58, 55, 1, 0, 0, 0, 59, 3, 1, 0, 0, 0, 60, 65, 3, 6, 3, 0, 61, 65, 3, 8, 4, 0, 62, 65, 3, 12, 6, 0, 63, 65, 3, 10, 5, 0, 64, 60, 1, 0, 0, 0, 64, 61, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 63, 1, 0, 0, 0, 65, 5, 1, 0, 0, 0, 66, 67, 5, 2, 0, 0, 67, 68, 5, 20, 0, 0, 68, 69, 5, 19, 0, 0, 69, 70, 5, 1, 0, 0, 70, 7, 1, 0, 0, 0, 71, 72, 5, 3, 0, 0, 72, 73, 5, 19, 0, 0, 73, 74, 5, 1, 0, 0, 74, 9, 1, 0, 0, 0, 75, 76, 5, 39, 0, 0, 76, 77, 5, 19, 0, 0, 77, 11, 1, 0, 0, 0, 78, 79, 5, 40, 0, 0, 79, 80, 5, 20, 0, 0, 80, 81, 5, 19, 0, 0, 81, 13, 1, 0, 0, 0, 82, 83, 3, 22, 11, 0, 83, 84, 3, 16, 8, 0, 84, 90, 1, 0, 0, 0, 85, 87, 3, 36, 18, 0, 86, 88, 3, 16, 8, 0, 87, 86, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 90, 1, 0, 0, 0, 89, 82, 1, 0, 0, 0, 89, 85, 1, 0, 0, 0, 90, 15, 1, 0, 0, 0, 91, 92, 3, 20, 10, 0, 92, 101, 3, 18, 9, 0, 93, 97, 5, 4, 0, 0, 94, 95, 3, 20, 10, 0, 95, 96, 3, 18, 9, 0, 96, 98, 1, 0, 0, 0, 97, 94, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 1, 0, 0, 0, 99, 93, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 17, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 109, 3, 26, 13, 0, 105, 106, 5, 5, 0, 0, 106, 108, 3, 26, 13, 0, 107, 105, 1, 0, 0, 0, 108, 111, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 109, 110, 1, 0, 0, 0, 110, 19, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 112, 115, 3, 24, 12, 0, 113, 115, 5, 6, 0, 0, 114, 112, 1, 0, 0, 0, 114, 113, 1, 0, 0, 0, 115, 21, 1, 0, 0, 0, 116, 121, 3, 42, 21, 0, 117, 121, 5, 18, 0, 0, 118, 121, 3, 38, 19, 0, 119, 121, 3, 28, 14, 0, 120, 116, 1, 0, 0, 0, 120, 117, 1, 0, 0, 0, 120, 118, 1, 0, 0, 0, 120, 119, 1, 0, 0, 0, 121, 23, 1, 0, 0, 0, 122, 123, 3, 42, 21, 0, 123, 25, 1, 0, 0, 0, 124, 131, 3, 42, 21, 0, 125, 131, 5, 18, 0, 0, 126, 131, 3, 34, 17, 0, 127, 131, 3, 38, 19, 0, 128, 131, 3, 36, 18, 0, 129, 131, 3, 28, 14, 0, 130, 124, 1, 0, 0, 0, 130, 125, 1, 0, 0, 0, 130, 126, 1, 0, 0, 0, 130, 127, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 130, 129, 1, 0, 0, 0, 131, 27, 1, 0, 0, 0, 132, 133, 5, 7, 0, 0, 133, 134, 3, 30, 15, 0, 134, 135, 3, 24, 12, 0, 135, 136, 3, 32, 16, 0, 136, 137, 5, 8, 0, 0, 137, 29, 1, 0, 0, 0, 138, 142, 3, 42, 21, 0, 139, 142, 5, 18, 0, 0, 140, 142, 3, 28, 14, 0, 141, 138, 1, 0, 0, 0, 141, 139, 1, 0, 0, 0, 141, 140, 1, 0, 0, 0, 142, 31, 1, 0, 0, 0, 143, 148, 3, 42, 21, 0, 144, 148, 5, 18, 0, 0, 145, 148, 3, 34, 17, 0, 146, 148, 3, 28, 14, 0, 147, 143, 1, 0, 0, 0, 147, 144, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 147, 146, 1, 0, 0, 0, 148, 33, 1, 0, 0, 0, 149, 153, 3, 40, 20, 0, 150, 153, 5, 15, 0, 0, 151, 153, 5, 16, 0, 0, 152, 149, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 152, 151, 1, 0, 0, 0, 153, 35, 1, 0, 0, 0, 154, 155, 5, 9, 0, 0, 155, 156, 3, 16, 8, 0, 156, 157, 5, 10, 0, 0, 157, 37, 1, 0, 0, 0, 158, 162, 5, 11, 0, 0, 159, 161, 3, 26, 13, 0, 160, 159, 1, 0, 0, 0, 161, 164, 1, 0, 0, 0, 162, 160, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 165, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 165, 166, 5, 12, 0, 0, 166, 39, 1, 0, 0, 0, 167, 171, 5, 17, 0, 0, 168, 172, 5, 23, 0, 0, 169, 170, 5, 13, 0, 0, 170, 172, 3, 42, 21, 0, 171, 168, 1, 0, 0, 0, 171, 169, 1, 0, 0, 0, 171, 172, 1, 0, 0, 0, 172, 41, 1, 0, 0, 0, 173, 176, 5, 19, 0, 0, 174, 176, 3, 44, 22, 0, 175, 173, 1, 0, 0, 0, 175, 174, 1, 0, 0, 0, 176, 43, 1, 0, 0, 0, 177, 178, 7, 0, 0, 0, 178, 45, 1, 0, 0, 0, 17, 49, 58, 64, 87, 89, 97, 101, 109, 114, 120, 130, 141, 147, 152, 162, 171, 175] \ No newline at end of file diff --git a/editor/parser/turtlestar/turtlestarLexer.interp b/editor/parser/turtlestar/turtlestarLexer.interp new file mode 100644 index 0000000..7db6205 --- /dev/null +++ b/editor/parser/turtlestar/turtlestarLexer.interp @@ -0,0 +1,155 @@ +token literal names: +null +'.' +'@prefix' +'@base' +';' +',' +'a' +'<<' +'>>' +'[' +']' +'(' +')' +'^^' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +COMMENT +NumericLiteral +BooleanLiteral +String +BlankNode +IRIREF +PNAME_NS +PNAME_LN +BLANK_NODE_LABEL +LANGTAG +INTEGER +DECIMAL +DOUBLE +EXPONENT +STRING_LITERAL_LONG_SINGLE_QUOTE +STRING_LITERAL_LONG_QUOTE +STRING_LITERAL_QUOTE +STRING_LITERAL_SINGLE_QUOTE +UCHAR +ECHAR +WS +ANON +PN_CHARS_BASE +PN_CHARS_U +PN_CHARS +BASE +PREFIX +PN_PREFIX +PN_LOCAL +PLX +PERCENT +HEX +PN_LOCAL_ESC + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +T__9 +T__10 +T__11 +T__12 +COMMENT +NumericLiteral +BooleanLiteral +String +BlankNode +IRIREF +PNAME_NS +PNAME_LN +BLANK_NODE_LABEL +LANGTAG +INTEGER +DECIMAL +DOUBLE +EXPONENT +STRING_LITERAL_LONG_SINGLE_QUOTE +STRING_LITERAL_LONG_QUOTE +STRING_LITERAL_QUOTE +STRING_LITERAL_SINGLE_QUOTE +UCHAR +ECHAR +WS +ANON +PN_CHARS_BASE +PN_CHARS_U +PN_CHARS +BASE +PREFIX +PN_PREFIX +PN_LOCAL +PLX +PERCENT +HEX +PN_LOCAL_ESC + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 46, 456, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 5, 13, 135, 8, 13, 10, 13, 12, 13, 138, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 3, 14, 145, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 156, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 162, 8, 16, 1, 17, 1, 17, 3, 17, 166, 8, 17, 1, 18, 1, 18, 1, 18, 5, 18, 171, 8, 18, 10, 18, 12, 18, 174, 9, 18, 1, 18, 1, 18, 1, 19, 3, 19, 179, 8, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 191, 8, 21, 1, 21, 1, 21, 5, 21, 195, 8, 21, 10, 21, 12, 21, 198, 9, 21, 1, 21, 3, 21, 201, 8, 21, 1, 22, 1, 22, 4, 22, 205, 8, 22, 11, 22, 12, 22, 206, 1, 22, 1, 22, 4, 22, 211, 8, 22, 11, 22, 12, 22, 212, 5, 22, 215, 8, 22, 10, 22, 12, 22, 218, 9, 22, 1, 23, 3, 23, 221, 8, 23, 1, 23, 4, 23, 224, 8, 23, 11, 23, 12, 23, 225, 1, 24, 3, 24, 229, 8, 24, 1, 24, 5, 24, 232, 8, 24, 10, 24, 12, 24, 235, 9, 24, 1, 24, 1, 24, 4, 24, 239, 8, 24, 11, 24, 12, 24, 240, 1, 25, 3, 25, 244, 8, 25, 1, 25, 4, 25, 247, 8, 25, 11, 25, 12, 25, 248, 1, 25, 1, 25, 5, 25, 253, 8, 25, 10, 25, 12, 25, 256, 9, 25, 1, 25, 1, 25, 1, 25, 4, 25, 261, 8, 25, 11, 25, 12, 25, 262, 1, 25, 1, 25, 4, 25, 267, 8, 25, 11, 25, 12, 25, 268, 1, 25, 3, 25, 272, 8, 25, 1, 26, 1, 26, 3, 26, 276, 8, 26, 1, 26, 4, 26, 279, 8, 26, 11, 26, 12, 26, 280, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 3, 27, 290, 8, 27, 1, 27, 1, 27, 1, 27, 3, 27, 295, 8, 27, 5, 27, 297, 8, 27, 10, 27, 12, 27, 300, 9, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 313, 8, 28, 1, 28, 1, 28, 1, 28, 3, 28, 318, 8, 28, 5, 28, 320, 8, 28, 10, 28, 12, 28, 323, 9, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 5, 29, 333, 8, 29, 10, 29, 12, 29, 336, 9, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 344, 8, 30, 10, 30, 12, 30, 347, 9, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 3, 31, 371, 8, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 5, 34, 382, 8, 34, 10, 34, 12, 34, 385, 9, 34, 1, 34, 1, 34, 1, 35, 3, 35, 390, 8, 35, 1, 36, 1, 36, 3, 36, 394, 8, 36, 1, 37, 1, 37, 3, 37, 398, 8, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 5, 40, 415, 8, 40, 10, 40, 12, 40, 418, 9, 40, 1, 40, 3, 40, 421, 8, 40, 1, 41, 1, 41, 1, 41, 3, 41, 426, 8, 41, 1, 41, 1, 41, 1, 41, 5, 41, 431, 8, 41, 10, 41, 12, 41, 434, 9, 41, 1, 41, 1, 41, 1, 41, 3, 41, 439, 8, 41, 3, 41, 441, 8, 41, 1, 42, 1, 42, 3, 42, 445, 8, 42, 1, 43, 1, 43, 1, 43, 1, 43, 1, 44, 3, 44, 452, 8, 44, 1, 45, 1, 45, 1, 45, 0, 0, 46, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 1, 0, 26, 2, 0, 10, 10, 13, 13, 8, 0, 0, 32, 34, 34, 60, 60, 62, 62, 92, 92, 94, 94, 96, 96, 123, 125, 1, 0, 48, 57, 2, 0, 65, 90, 97, 122, 3, 0, 48, 57, 65, 90, 97, 122, 2, 0, 43, 43, 45, 45, 2, 0, 69, 69, 101, 101, 2, 0, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 4, 0, 10, 10, 13, 13, 34, 34, 92, 92, 4, 0, 10, 10, 13, 13, 39, 39, 92, 92, 8, 0, 34, 34, 39, 39, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 9, 10, 13, 13, 32, 32, 13, 0, 65, 90, 97, 122, 192, 214, 216, 246, 248, 767, 880, 893, 895, 8191, 8204, 8205, 8304, 8591, 11264, 12271, 12289, 55295, 63744, 64975, 65008, 65533, 5, 0, 45, 45, 48, 57, 183, 183, 768, 879, 8255, 8256, 2, 0, 66, 66, 98, 98, 2, 0, 65, 65, 97, 97, 2, 0, 83, 83, 115, 115, 2, 0, 80, 80, 112, 112, 2, 0, 82, 82, 114, 114, 2, 0, 70, 70, 102, 102, 2, 0, 73, 73, 105, 105, 2, 0, 88, 88, 120, 120, 2, 0, 46, 46, 58, 58, 3, 0, 48, 57, 65, 70, 97, 102, 7, 0, 33, 33, 35, 47, 59, 59, 61, 61, 63, 64, 95, 95, 126, 126, 519, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 1, 93, 1, 0, 0, 0, 3, 95, 1, 0, 0, 0, 5, 103, 1, 0, 0, 0, 7, 109, 1, 0, 0, 0, 9, 111, 1, 0, 0, 0, 11, 113, 1, 0, 0, 0, 13, 115, 1, 0, 0, 0, 15, 118, 1, 0, 0, 0, 17, 121, 1, 0, 0, 0, 19, 123, 1, 0, 0, 0, 21, 125, 1, 0, 0, 0, 23, 127, 1, 0, 0, 0, 25, 129, 1, 0, 0, 0, 27, 132, 1, 0, 0, 0, 29, 144, 1, 0, 0, 0, 31, 155, 1, 0, 0, 0, 33, 161, 1, 0, 0, 0, 35, 165, 1, 0, 0, 0, 37, 167, 1, 0, 0, 0, 39, 178, 1, 0, 0, 0, 41, 182, 1, 0, 0, 0, 43, 185, 1, 0, 0, 0, 45, 202, 1, 0, 0, 0, 47, 220, 1, 0, 0, 0, 49, 228, 1, 0, 0, 0, 51, 243, 1, 0, 0, 0, 53, 273, 1, 0, 0, 0, 55, 282, 1, 0, 0, 0, 57, 305, 1, 0, 0, 0, 59, 328, 1, 0, 0, 0, 61, 339, 1, 0, 0, 0, 63, 370, 1, 0, 0, 0, 65, 372, 1, 0, 0, 0, 67, 375, 1, 0, 0, 0, 69, 379, 1, 0, 0, 0, 71, 389, 1, 0, 0, 0, 73, 393, 1, 0, 0, 0, 75, 397, 1, 0, 0, 0, 77, 399, 1, 0, 0, 0, 79, 404, 1, 0, 0, 0, 81, 411, 1, 0, 0, 0, 83, 425, 1, 0, 0, 0, 85, 444, 1, 0, 0, 0, 87, 446, 1, 0, 0, 0, 89, 451, 1, 0, 0, 0, 91, 453, 1, 0, 0, 0, 93, 94, 5, 46, 0, 0, 94, 2, 1, 0, 0, 0, 95, 96, 5, 64, 0, 0, 96, 97, 5, 112, 0, 0, 97, 98, 5, 114, 0, 0, 98, 99, 5, 101, 0, 0, 99, 100, 5, 102, 0, 0, 100, 101, 5, 105, 0, 0, 101, 102, 5, 120, 0, 0, 102, 4, 1, 0, 0, 0, 103, 104, 5, 64, 0, 0, 104, 105, 5, 98, 0, 0, 105, 106, 5, 97, 0, 0, 106, 107, 5, 115, 0, 0, 107, 108, 5, 101, 0, 0, 108, 6, 1, 0, 0, 0, 109, 110, 5, 59, 0, 0, 110, 8, 1, 0, 0, 0, 111, 112, 5, 44, 0, 0, 112, 10, 1, 0, 0, 0, 113, 114, 5, 97, 0, 0, 114, 12, 1, 0, 0, 0, 115, 116, 5, 60, 0, 0, 116, 117, 5, 60, 0, 0, 117, 14, 1, 0, 0, 0, 118, 119, 5, 62, 0, 0, 119, 120, 5, 62, 0, 0, 120, 16, 1, 0, 0, 0, 121, 122, 5, 91, 0, 0, 122, 18, 1, 0, 0, 0, 123, 124, 5, 93, 0, 0, 124, 20, 1, 0, 0, 0, 125, 126, 5, 40, 0, 0, 126, 22, 1, 0, 0, 0, 127, 128, 5, 41, 0, 0, 128, 24, 1, 0, 0, 0, 129, 130, 5, 94, 0, 0, 130, 131, 5, 94, 0, 0, 131, 26, 1, 0, 0, 0, 132, 136, 5, 35, 0, 0, 133, 135, 8, 0, 0, 0, 134, 133, 1, 0, 0, 0, 135, 138, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 139, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 139, 140, 6, 13, 0, 0, 140, 28, 1, 0, 0, 0, 141, 145, 3, 47, 23, 0, 142, 145, 3, 49, 24, 0, 143, 145, 3, 51, 25, 0, 144, 141, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 143, 1, 0, 0, 0, 145, 30, 1, 0, 0, 0, 146, 147, 5, 116, 0, 0, 147, 148, 5, 114, 0, 0, 148, 149, 5, 117, 0, 0, 149, 156, 5, 101, 0, 0, 150, 151, 5, 102, 0, 0, 151, 152, 5, 97, 0, 0, 152, 153, 5, 108, 0, 0, 153, 154, 5, 115, 0, 0, 154, 156, 5, 101, 0, 0, 155, 146, 1, 0, 0, 0, 155, 150, 1, 0, 0, 0, 156, 32, 1, 0, 0, 0, 157, 162, 3, 59, 29, 0, 158, 162, 3, 61, 30, 0, 159, 162, 3, 55, 27, 0, 160, 162, 3, 57, 28, 0, 161, 157, 1, 0, 0, 0, 161, 158, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 161, 160, 1, 0, 0, 0, 162, 34, 1, 0, 0, 0, 163, 166, 3, 43, 21, 0, 164, 166, 3, 69, 34, 0, 165, 163, 1, 0, 0, 0, 165, 164, 1, 0, 0, 0, 166, 36, 1, 0, 0, 0, 167, 172, 5, 60, 0, 0, 168, 171, 8, 1, 0, 0, 169, 171, 3, 63, 31, 0, 170, 168, 1, 0, 0, 0, 170, 169, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 175, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 176, 5, 62, 0, 0, 176, 38, 1, 0, 0, 0, 177, 179, 3, 81, 40, 0, 178, 177, 1, 0, 0, 0, 178, 179, 1, 0, 0, 0, 179, 180, 1, 0, 0, 0, 180, 181, 5, 58, 0, 0, 181, 40, 1, 0, 0, 0, 182, 183, 3, 39, 19, 0, 183, 184, 3, 83, 41, 0, 184, 42, 1, 0, 0, 0, 185, 186, 5, 95, 0, 0, 186, 187, 5, 58, 0, 0, 187, 190, 1, 0, 0, 0, 188, 191, 3, 73, 36, 0, 189, 191, 7, 2, 0, 0, 190, 188, 1, 0, 0, 0, 190, 189, 1, 0, 0, 0, 191, 200, 1, 0, 0, 0, 192, 195, 3, 75, 37, 0, 193, 195, 5, 46, 0, 0, 194, 192, 1, 0, 0, 0, 194, 193, 1, 0, 0, 0, 195, 198, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 199, 1, 0, 0, 0, 198, 196, 1, 0, 0, 0, 199, 201, 3, 75, 37, 0, 200, 196, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 44, 1, 0, 0, 0, 202, 204, 5, 64, 0, 0, 203, 205, 7, 3, 0, 0, 204, 203, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 204, 1, 0, 0, 0, 206, 207, 1, 0, 0, 0, 207, 216, 1, 0, 0, 0, 208, 210, 5, 45, 0, 0, 209, 211, 7, 4, 0, 0, 210, 209, 1, 0, 0, 0, 211, 212, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, 212, 213, 1, 0, 0, 0, 213, 215, 1, 0, 0, 0, 214, 208, 1, 0, 0, 0, 215, 218, 1, 0, 0, 0, 216, 214, 1, 0, 0, 0, 216, 217, 1, 0, 0, 0, 217, 46, 1, 0, 0, 0, 218, 216, 1, 0, 0, 0, 219, 221, 7, 5, 0, 0, 220, 219, 1, 0, 0, 0, 220, 221, 1, 0, 0, 0, 221, 223, 1, 0, 0, 0, 222, 224, 7, 2, 0, 0, 223, 222, 1, 0, 0, 0, 224, 225, 1, 0, 0, 0, 225, 223, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 48, 1, 0, 0, 0, 227, 229, 7, 5, 0, 0, 228, 227, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 233, 1, 0, 0, 0, 230, 232, 7, 2, 0, 0, 231, 230, 1, 0, 0, 0, 232, 235, 1, 0, 0, 0, 233, 231, 1, 0, 0, 0, 233, 234, 1, 0, 0, 0, 234, 236, 1, 0, 0, 0, 235, 233, 1, 0, 0, 0, 236, 238, 5, 46, 0, 0, 237, 239, 7, 2, 0, 0, 238, 237, 1, 0, 0, 0, 239, 240, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 50, 1, 0, 0, 0, 242, 244, 7, 5, 0, 0, 243, 242, 1, 0, 0, 0, 243, 244, 1, 0, 0, 0, 244, 271, 1, 0, 0, 0, 245, 247, 7, 2, 0, 0, 246, 245, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 250, 1, 0, 0, 0, 250, 254, 5, 46, 0, 0, 251, 253, 7, 2, 0, 0, 252, 251, 1, 0, 0, 0, 253, 256, 1, 0, 0, 0, 254, 252, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 257, 1, 0, 0, 0, 256, 254, 1, 0, 0, 0, 257, 272, 3, 53, 26, 0, 258, 260, 5, 46, 0, 0, 259, 261, 7, 2, 0, 0, 260, 259, 1, 0, 0, 0, 261, 262, 1, 0, 0, 0, 262, 260, 1, 0, 0, 0, 262, 263, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 272, 3, 53, 26, 0, 265, 267, 7, 2, 0, 0, 266, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 272, 3, 53, 26, 0, 271, 246, 1, 0, 0, 0, 271, 258, 1, 0, 0, 0, 271, 266, 1, 0, 0, 0, 272, 52, 1, 0, 0, 0, 273, 275, 7, 6, 0, 0, 274, 276, 7, 5, 0, 0, 275, 274, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 278, 1, 0, 0, 0, 277, 279, 7, 2, 0, 0, 278, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 278, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 54, 1, 0, 0, 0, 282, 283, 5, 39, 0, 0, 283, 284, 5, 39, 0, 0, 284, 285, 5, 39, 0, 0, 285, 298, 1, 0, 0, 0, 286, 290, 5, 39, 0, 0, 287, 288, 5, 39, 0, 0, 288, 290, 5, 39, 0, 0, 289, 286, 1, 0, 0, 0, 289, 287, 1, 0, 0, 0, 289, 290, 1, 0, 0, 0, 290, 294, 1, 0, 0, 0, 291, 295, 8, 7, 0, 0, 292, 295, 3, 65, 32, 0, 293, 295, 3, 63, 31, 0, 294, 291, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 294, 293, 1, 0, 0, 0, 295, 297, 1, 0, 0, 0, 296, 289, 1, 0, 0, 0, 297, 300, 1, 0, 0, 0, 298, 296, 1, 0, 0, 0, 298, 299, 1, 0, 0, 0, 299, 301, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 301, 302, 5, 39, 0, 0, 302, 303, 5, 39, 0, 0, 303, 304, 5, 39, 0, 0, 304, 56, 1, 0, 0, 0, 305, 306, 5, 34, 0, 0, 306, 307, 5, 34, 0, 0, 307, 308, 5, 34, 0, 0, 308, 321, 1, 0, 0, 0, 309, 313, 5, 34, 0, 0, 310, 311, 5, 34, 0, 0, 311, 313, 5, 34, 0, 0, 312, 309, 1, 0, 0, 0, 312, 310, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 317, 1, 0, 0, 0, 314, 318, 8, 8, 0, 0, 315, 318, 3, 65, 32, 0, 316, 318, 3, 63, 31, 0, 317, 314, 1, 0, 0, 0, 317, 315, 1, 0, 0, 0, 317, 316, 1, 0, 0, 0, 318, 320, 1, 0, 0, 0, 319, 312, 1, 0, 0, 0, 320, 323, 1, 0, 0, 0, 321, 319, 1, 0, 0, 0, 321, 322, 1, 0, 0, 0, 322, 324, 1, 0, 0, 0, 323, 321, 1, 0, 0, 0, 324, 325, 5, 34, 0, 0, 325, 326, 5, 34, 0, 0, 326, 327, 5, 34, 0, 0, 327, 58, 1, 0, 0, 0, 328, 334, 5, 34, 0, 0, 329, 333, 8, 9, 0, 0, 330, 333, 3, 65, 32, 0, 331, 333, 3, 63, 31, 0, 332, 329, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 332, 331, 1, 0, 0, 0, 333, 336, 1, 0, 0, 0, 334, 332, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 337, 1, 0, 0, 0, 336, 334, 1, 0, 0, 0, 337, 338, 5, 34, 0, 0, 338, 60, 1, 0, 0, 0, 339, 345, 5, 39, 0, 0, 340, 344, 8, 10, 0, 0, 341, 344, 3, 65, 32, 0, 342, 344, 3, 63, 31, 0, 343, 340, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 342, 1, 0, 0, 0, 344, 347, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 345, 346, 1, 0, 0, 0, 346, 348, 1, 0, 0, 0, 347, 345, 1, 0, 0, 0, 348, 349, 5, 39, 0, 0, 349, 62, 1, 0, 0, 0, 350, 351, 5, 92, 0, 0, 351, 352, 5, 117, 0, 0, 352, 353, 1, 0, 0, 0, 353, 354, 3, 89, 44, 0, 354, 355, 3, 89, 44, 0, 355, 356, 3, 89, 44, 0, 356, 357, 3, 89, 44, 0, 357, 371, 1, 0, 0, 0, 358, 359, 5, 92, 0, 0, 359, 360, 5, 85, 0, 0, 360, 361, 1, 0, 0, 0, 361, 362, 3, 89, 44, 0, 362, 363, 3, 89, 44, 0, 363, 364, 3, 89, 44, 0, 364, 365, 3, 89, 44, 0, 365, 366, 3, 89, 44, 0, 366, 367, 3, 89, 44, 0, 367, 368, 3, 89, 44, 0, 368, 369, 3, 89, 44, 0, 369, 371, 1, 0, 0, 0, 370, 350, 1, 0, 0, 0, 370, 358, 1, 0, 0, 0, 371, 64, 1, 0, 0, 0, 372, 373, 5, 92, 0, 0, 373, 374, 7, 11, 0, 0, 374, 66, 1, 0, 0, 0, 375, 376, 7, 12, 0, 0, 376, 377, 1, 0, 0, 0, 377, 378, 6, 33, 0, 0, 378, 68, 1, 0, 0, 0, 379, 383, 5, 91, 0, 0, 380, 382, 3, 67, 33, 0, 381, 380, 1, 0, 0, 0, 382, 385, 1, 0, 0, 0, 383, 381, 1, 0, 0, 0, 383, 384, 1, 0, 0, 0, 384, 386, 1, 0, 0, 0, 385, 383, 1, 0, 0, 0, 386, 387, 5, 93, 0, 0, 387, 70, 1, 0, 0, 0, 388, 390, 7, 13, 0, 0, 389, 388, 1, 0, 0, 0, 390, 72, 1, 0, 0, 0, 391, 394, 3, 71, 35, 0, 392, 394, 5, 95, 0, 0, 393, 391, 1, 0, 0, 0, 393, 392, 1, 0, 0, 0, 394, 74, 1, 0, 0, 0, 395, 398, 3, 73, 36, 0, 396, 398, 7, 14, 0, 0, 397, 395, 1, 0, 0, 0, 397, 396, 1, 0, 0, 0, 398, 76, 1, 0, 0, 0, 399, 400, 7, 15, 0, 0, 400, 401, 7, 16, 0, 0, 401, 402, 7, 17, 0, 0, 402, 403, 7, 6, 0, 0, 403, 78, 1, 0, 0, 0, 404, 405, 7, 18, 0, 0, 405, 406, 7, 19, 0, 0, 406, 407, 7, 6, 0, 0, 407, 408, 7, 20, 0, 0, 408, 409, 7, 21, 0, 0, 409, 410, 7, 22, 0, 0, 410, 80, 1, 0, 0, 0, 411, 420, 3, 71, 35, 0, 412, 415, 3, 75, 37, 0, 413, 415, 5, 46, 0, 0, 414, 412, 1, 0, 0, 0, 414, 413, 1, 0, 0, 0, 415, 418, 1, 0, 0, 0, 416, 414, 1, 0, 0, 0, 416, 417, 1, 0, 0, 0, 417, 419, 1, 0, 0, 0, 418, 416, 1, 0, 0, 0, 419, 421, 3, 75, 37, 0, 420, 416, 1, 0, 0, 0, 420, 421, 1, 0, 0, 0, 421, 82, 1, 0, 0, 0, 422, 426, 3, 73, 36, 0, 423, 426, 2, 48, 58, 0, 424, 426, 3, 85, 42, 0, 425, 422, 1, 0, 0, 0, 425, 423, 1, 0, 0, 0, 425, 424, 1, 0, 0, 0, 426, 440, 1, 0, 0, 0, 427, 431, 3, 75, 37, 0, 428, 431, 7, 23, 0, 0, 429, 431, 3, 85, 42, 0, 430, 427, 1, 0, 0, 0, 430, 428, 1, 0, 0, 0, 430, 429, 1, 0, 0, 0, 431, 434, 1, 0, 0, 0, 432, 430, 1, 0, 0, 0, 432, 433, 1, 0, 0, 0, 433, 438, 1, 0, 0, 0, 434, 432, 1, 0, 0, 0, 435, 439, 3, 75, 37, 0, 436, 439, 5, 58, 0, 0, 437, 439, 3, 85, 42, 0, 438, 435, 1, 0, 0, 0, 438, 436, 1, 0, 0, 0, 438, 437, 1, 0, 0, 0, 439, 441, 1, 0, 0, 0, 440, 432, 1, 0, 0, 0, 440, 441, 1, 0, 0, 0, 441, 84, 1, 0, 0, 0, 442, 445, 3, 87, 43, 0, 443, 445, 3, 91, 45, 0, 444, 442, 1, 0, 0, 0, 444, 443, 1, 0, 0, 0, 445, 86, 1, 0, 0, 0, 446, 447, 5, 37, 0, 0, 447, 448, 3, 89, 44, 0, 448, 449, 3, 89, 44, 0, 449, 88, 1, 0, 0, 0, 450, 452, 7, 24, 0, 0, 451, 450, 1, 0, 0, 0, 452, 90, 1, 0, 0, 0, 453, 454, 5, 92, 0, 0, 454, 455, 7, 25, 0, 0, 455, 92, 1, 0, 0, 0, 54, 0, 136, 144, 155, 161, 165, 170, 172, 178, 190, 194, 196, 200, 206, 212, 216, 220, 225, 228, 233, 240, 243, 248, 254, 262, 268, 271, 275, 280, 289, 294, 298, 312, 317, 321, 332, 334, 343, 345, 370, 383, 389, 393, 397, 414, 416, 420, 425, 430, 432, 438, 440, 444, 451, 1, 6, 0, 0] \ No newline at end of file diff --git a/editor/parser/turtlestar/turtlestarLexer.js b/editor/parser/turtlestar/turtlestarLexer.js index a0d31bb..e2e3cdb 100644 --- a/editor/parser/turtlestar/turtlestarLexer.js +++ b/editor/parser/turtlestar/turtlestarLexer.js @@ -1,350 +1,219 @@ -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start -var antlr4 = require('antlr4/index'); +import antlr4 from 'antlr4'; -var serializedATN = ["\u0003\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd", - "\u00020\u01ca\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004", - "\u0004\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t", - "\u0007\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004", - "\f\t\f\u0004\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010", - "\t\u0010\u0004\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013", - "\u0004\u0014\t\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017", - "\t\u0017\u0004\u0018\t\u0018\u0004\u0019\t\u0019\u0004\u001a\t\u001a", - "\u0004\u001b\t\u001b\u0004\u001c\t\u001c\u0004\u001d\t\u001d\u0004\u001e", - "\t\u001e\u0004\u001f\t\u001f\u0004 \t \u0004!\t!\u0004\"\t\"\u0004#", - "\t#\u0004$\t$\u0004%\t%\u0004&\t&\u0004\'\t\'\u0004(\t(\u0004)\t)\u0004", - "*\t*\u0004+\t+\u0004,\t,\u0004-\t-\u0004.\t.\u0004/\t/\u0003\u0002\u0003", - "\u0002\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003", - "\u0003\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004\u0003\u0004\u0003", - "\u0004\u0003\u0004\u0003\u0004\u0003\u0005\u0003\u0005\u0003\u0006\u0003", - "\u0006\u0003\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003\t\u0003", - "\t\u0003\t\u0003\n\u0003\n\u0003\u000b\u0003\u000b\u0003\f\u0003\f\u0003", - "\r\u0003\r\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000f\u0003\u000f", - "\u0007\u000f\u0089\n\u000f\f\u000f\u000e\u000f\u008c\u000b\u000f\u0003", - "\u000f\u0003\u000f\u0003\u0010\u0003\u0010\u0003\u0010\u0005\u0010\u0093", - "\n\u0010\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011", - "\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0005\u0011\u009e\n", - "\u0011\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0005\u0012\u00a4", - "\n\u0012\u0003\u0013\u0003\u0013\u0005\u0013\u00a8\n\u0013\u0003\u0014", - "\u0003\u0014\u0003\u0014\u0007\u0014\u00ad\n\u0014\f\u0014\u000e\u0014", - "\u00b0\u000b\u0014\u0003\u0014\u0003\u0014\u0003\u0015\u0005\u0015\u00b5", - "\n\u0015\u0003\u0015\u0003\u0015\u0003\u0016\u0003\u0016\u0003\u0016", - "\u0003\u0017\u0003\u0017\u0003\u0017\u0003\u0017\u0003\u0017\u0005\u0017", - "\u00c1\n\u0017\u0003\u0017\u0003\u0017\u0007\u0017\u00c5\n\u0017\f\u0017", - "\u000e\u0017\u00c8\u000b\u0017\u0003\u0017\u0005\u0017\u00cb\n\u0017", - "\u0003\u0018\u0003\u0018\u0006\u0018\u00cf\n\u0018\r\u0018\u000e\u0018", - "\u00d0\u0003\u0018\u0003\u0018\u0006\u0018\u00d5\n\u0018\r\u0018\u000e", - "\u0018\u00d6\u0007\u0018\u00d9\n\u0018\f\u0018\u000e\u0018\u00dc\u000b", - "\u0018\u0003\u0019\u0005\u0019\u00df\n\u0019\u0003\u0019\u0006\u0019", - "\u00e2\n\u0019\r\u0019\u000e\u0019\u00e3\u0003\u001a\u0005\u001a\u00e7", - "\n\u001a\u0003\u001a\u0007\u001a\u00ea\n\u001a\f\u001a\u000e\u001a\u00ed", - "\u000b\u001a\u0003\u001a\u0003\u001a\u0006\u001a\u00f1\n\u001a\r\u001a", - "\u000e\u001a\u00f2\u0003\u001b\u0005\u001b\u00f6\n\u001b\u0003\u001b", - "\u0006\u001b\u00f9\n\u001b\r\u001b\u000e\u001b\u00fa\u0003\u001b\u0003", - "\u001b\u0007\u001b\u00ff\n\u001b\f\u001b\u000e\u001b\u0102\u000b\u001b", - "\u0003\u001b\u0003\u001b\u0003\u001b\u0006\u001b\u0107\n\u001b\r\u001b", - "\u000e\u001b\u0108\u0003\u001b\u0003\u001b\u0006\u001b\u010d\n\u001b", - "\r\u001b\u000e\u001b\u010e\u0003\u001b\u0005\u001b\u0112\n\u001b\u0003", - "\u001c\u0003\u001c\u0005\u001c\u0116\n\u001c\u0003\u001c\u0006\u001c", - "\u0119\n\u001c\r\u001c\u000e\u001c\u011a\u0003\u001d\u0003\u001d\u0003", - "\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0005\u001d\u0124", - "\n\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0005\u001d\u0129\n\u001d", - "\u0007\u001d\u012b\n\u001d\f\u001d\u000e\u001d\u012e\u000b\u001d\u0003", - "\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001e\u0003\u001e\u0003", - "\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0005\u001e\u013b", - "\n\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0005\u001e\u0140\n\u001e", - "\u0007\u001e\u0142\n\u001e\f\u001e\u000e\u001e\u0145\u000b\u001e\u0003", - "\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0003\u001f\u0003\u001f\u0003", - "\u001f\u0003\u001f\u0007\u001f\u014f\n\u001f\f\u001f\u000e\u001f\u0152", - "\u000b\u001f\u0003\u001f\u0003\u001f\u0003 \u0003 \u0003 \u0003 \u0007", - " \u015a\n \f \u000e \u015d\u000b \u0003 \u0003 \u0003!\u0003!\u0003", - "!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003", - "!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0003!\u0005!\u0175\n!\u0003", - "\"\u0003\"\u0003\"\u0003#\u0003#\u0003#\u0003#\u0003$\u0003$\u0007$", - "\u0180\n$\f$\u000e$\u0183\u000b$\u0003$\u0003$\u0003%\u0005%\u0188\n", - "%\u0003&\u0003&\u0005&\u018c\n&\u0003\'\u0003\'\u0005\'\u0190\n\'\u0003", - "(\u0003(\u0003(\u0003(\u0003(\u0003)\u0003)\u0003)\u0003)\u0003)\u0003", - ")\u0003)\u0003*\u0003*\u0003*\u0007*\u01a1\n*\f*\u000e*\u01a4\u000b", - "*\u0003*\u0005*\u01a7\n*\u0003+\u0003+\u0003+\u0005+\u01ac\n+\u0003", - "+\u0003+\u0003+\u0007+\u01b1\n+\f+\u000e+\u01b4\u000b+\u0003+\u0003", - "+\u0003+\u0005+\u01b9\n+\u0005+\u01bb\n+\u0003,\u0003,\u0005,\u01bf", - "\n,\u0003-\u0003-\u0003-\u0003-\u0003.\u0005.\u01c6\n.\u0003/\u0003", - "/\u0003/\u0002\u00020\u0003\u0003\u0005\u0004\u0007\u0005\t\u0006\u000b", - "\u0007\r\b\u000f\t\u0011\n\u0013\u000b\u0015\f\u0017\r\u0019\u000e\u001b", - "\u000f\u001d\u0010\u001f\u0011!\u0012#\u0013%\u0014\'\u0015)\u0016+", - "\u0017-\u0018/\u00191\u001a3\u001b5\u001c7\u001d9\u001e;\u001f= ?!A", - "\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]0\u0003\u0002\u001c\u0004\u0002\f\f\u000f", - "\u000f\n\u0002\u0002\"$$>>@@^^``bb}\u007f\u0003\u00022;\u0004\u0002", - "C\\c|\u0005\u00022;C\\c|\u0004\u0002--//\u0004\u0002GGgg\u0004\u0002", - "))^^\u0004\u0002$$^^\u0006\u0002\f\f\u000f\u000f$$^^\u0006\u0002\f\f", - "\u000f\u000f))^^\n\u0002$$))^^ddhhppttvv\u0005\u0002\u000b\f\u000f\u000f", - "\"\"\u000f\u0002C\\c|\u00c2\u00d8\u00da\u00f8\u00fa\u0301\u0372\u037f", - "\u0381\u2001\u200e\u200f\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1", - "\ufdf2\uffff\u0007\u0002//2;\u00b9\u00b9\u0302\u0371\u2041\u2042\u0004", - "\u0002DDdd\u0004\u0002CCcc\u0004\u0002UUuu\u0004\u0002RRrr\u0004\u0002", - "TTtt\u0004\u0002HHhh\u0004\u0002KKkk\u0004\u0002ZZzz\u0004\u000200<", - "<\u0005\u00022;CHch\t\u0002##%1==??ABaa\u0080\u0080\u0209\u0002\u0003", - "\u0003\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002\u0002\u0007", - "\u0003\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002\u0002\u000b", - "\u0003\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002\u0002\u000f", - "\u0003\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002\u0002\u0013", - "\u0003\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002\u0002\u0017", - "\u0003\u0002\u0002\u0002\u0002\u0019\u0003\u0002\u0002\u0002\u0002\u001b", - "\u0003\u0002\u0002\u0002\u0002\u001d\u0003\u0002\u0002\u0002\u0002\u001f", - "\u0003\u0002\u0002\u0002\u0002!\u0003\u0002\u0002\u0002\u0002#\u0003", - "\u0002\u0002\u0002\u0002%\u0003\u0002\u0002\u0002\u0002\'\u0003\u0002", - "\u0002\u0002\u0002)\u0003\u0002\u0002\u0002\u0002+\u0003\u0002\u0002", - "\u0002\u0002-\u0003\u0002\u0002\u0002\u0002/\u0003\u0002\u0002\u0002", - "\u00021\u0003\u0002\u0002\u0002\u00023\u0003\u0002\u0002\u0002\u0002", - "5\u0003\u0002\u0002\u0002\u00027\u0003\u0002\u0002\u0002\u00029\u0003", - "\u0002\u0002\u0002\u0002;\u0003\u0002\u0002\u0002\u0002=\u0003\u0002", - "\u0002\u0002\u0002?\u0003\u0002\u0002\u0002\u0002A\u0003\u0002\u0002", - "\u0002\u0002C\u0003\u0002\u0002\u0002\u0002E\u0003\u0002\u0002\u0002", - "\u0002G\u0003\u0002\u0002\u0002\u0002I\u0003\u0002\u0002\u0002\u0002", - "K\u0003\u0002\u0002\u0002\u0002M\u0003\u0002\u0002\u0002\u0002O\u0003", - "\u0002\u0002\u0002\u0002Q\u0003\u0002\u0002\u0002\u0002S\u0003\u0002", - "\u0002\u0002\u0002U\u0003\u0002\u0002\u0002\u0002W\u0003\u0002\u0002", - "\u0002\u0002Y\u0003\u0002\u0002\u0002\u0002[\u0003\u0002\u0002\u0002", - "\u0002]\u0003\u0002\u0002\u0002\u0003_\u0003\u0002\u0002\u0002\u0005", - "a\u0003\u0002\u0002\u0002\u0007i\u0003\u0002\u0002\u0002\to\u0003\u0002", - "\u0002\u0002\u000bq\u0003\u0002\u0002\u0002\rs\u0003\u0002\u0002\u0002", - "\u000fu\u0003\u0002\u0002\u0002\u0011x\u0003\u0002\u0002\u0002\u0013", - "{\u0003\u0002\u0002\u0002\u0015}\u0003\u0002\u0002\u0002\u0017\u007f", - "\u0003\u0002\u0002\u0002\u0019\u0081\u0003\u0002\u0002\u0002\u001b\u0083", - "\u0003\u0002\u0002\u0002\u001d\u0086\u0003\u0002\u0002\u0002\u001f\u0092", - "\u0003\u0002\u0002\u0002!\u009d\u0003\u0002\u0002\u0002#\u00a3\u0003", - "\u0002\u0002\u0002%\u00a7\u0003\u0002\u0002\u0002\'\u00a9\u0003\u0002", - "\u0002\u0002)\u00b4\u0003\u0002\u0002\u0002+\u00b8\u0003\u0002\u0002", - "\u0002-\u00bb\u0003\u0002\u0002\u0002/\u00cc\u0003\u0002\u0002\u0002", - "1\u00de\u0003\u0002\u0002\u00023\u00e6\u0003\u0002\u0002\u00025\u00f5", - "\u0003\u0002\u0002\u00027\u0113\u0003\u0002\u0002\u00029\u011c\u0003", - "\u0002\u0002\u0002;\u0133\u0003\u0002\u0002\u0002=\u014a\u0003\u0002", - "\u0002\u0002?\u0155\u0003\u0002\u0002\u0002A\u0174\u0003\u0002\u0002", - "\u0002C\u0176\u0003\u0002\u0002\u0002E\u0179\u0003\u0002\u0002\u0002", - "G\u017d\u0003\u0002\u0002\u0002I\u0187\u0003\u0002\u0002\u0002K\u018b", - "\u0003\u0002\u0002\u0002M\u018f\u0003\u0002\u0002\u0002O\u0191\u0003", - "\u0002\u0002\u0002Q\u0196\u0003\u0002\u0002\u0002S\u019d\u0003\u0002", - "\u0002\u0002U\u01ab\u0003\u0002\u0002\u0002W\u01be\u0003\u0002\u0002", - "\u0002Y\u01c0\u0003\u0002\u0002\u0002[\u01c5\u0003\u0002\u0002\u0002", - "]\u01c7\u0003\u0002\u0002\u0002_`\u00070\u0002\u0002`\u0004\u0003\u0002", - "\u0002\u0002ab\u0007B\u0002\u0002bc\u0007r\u0002\u0002cd\u0007t\u0002", - "\u0002de\u0007g\u0002\u0002ef\u0007h\u0002\u0002fg\u0007k\u0002\u0002", - "gh\u0007z\u0002\u0002h\u0006\u0003\u0002\u0002\u0002ij\u0007B\u0002", - "\u0002jk\u0007d\u0002\u0002kl\u0007c\u0002\u0002lm\u0007u\u0002\u0002", - "mn\u0007g\u0002\u0002n\b\u0003\u0002\u0002\u0002op\u0007=\u0002\u0002", - "p\n\u0003\u0002\u0002\u0002qr\u0007.\u0002\u0002r\f\u0003\u0002\u0002", - "\u0002st\u0007c\u0002\u0002t\u000e\u0003\u0002\u0002\u0002uv\u0007>", - "\u0002\u0002vw\u0007>\u0002\u0002w\u0010\u0003\u0002\u0002\u0002xy\u0007", - "@\u0002\u0002yz\u0007@\u0002\u0002z\u0012\u0003\u0002\u0002\u0002{|", - "\u0007]\u0002\u0002|\u0014\u0003\u0002\u0002\u0002}~\u0007_\u0002\u0002", - "~\u0016\u0003\u0002\u0002\u0002\u007f\u0080\u0007*\u0002\u0002\u0080", - "\u0018\u0003\u0002\u0002\u0002\u0081\u0082\u0007+\u0002\u0002\u0082", - "\u001a\u0003\u0002\u0002\u0002\u0083\u0084\u0007`\u0002\u0002\u0084", - "\u0085\u0007`\u0002\u0002\u0085\u001c\u0003\u0002\u0002\u0002\u0086", - "\u008a\u0007%\u0002\u0002\u0087\u0089\n\u0002\u0002\u0002\u0088\u0087", - "\u0003\u0002\u0002\u0002\u0089\u008c\u0003\u0002\u0002\u0002\u008a\u0088", - "\u0003\u0002\u0002\u0002\u008a\u008b\u0003\u0002\u0002\u0002\u008b\u008d", - "\u0003\u0002\u0002\u0002\u008c\u008a\u0003\u0002\u0002\u0002\u008d\u008e", - "\b\u000f\u0002\u0002\u008e\u001e\u0003\u0002\u0002\u0002\u008f\u0093", - "\u00051\u0019\u0002\u0090\u0093\u00053\u001a\u0002\u0091\u0093\u0005", - "5\u001b\u0002\u0092\u008f\u0003\u0002\u0002\u0002\u0092\u0090\u0003", - "\u0002\u0002\u0002\u0092\u0091\u0003\u0002\u0002\u0002\u0093 \u0003", - "\u0002\u0002\u0002\u0094\u0095\u0007v\u0002\u0002\u0095\u0096\u0007", - "t\u0002\u0002\u0096\u0097\u0007w\u0002\u0002\u0097\u009e\u0007g\u0002", - "\u0002\u0098\u0099\u0007h\u0002\u0002\u0099\u009a\u0007c\u0002\u0002", - "\u009a\u009b\u0007n\u0002\u0002\u009b\u009c\u0007u\u0002\u0002\u009c", - "\u009e\u0007g\u0002\u0002\u009d\u0094\u0003\u0002\u0002\u0002\u009d", - "\u0098\u0003\u0002\u0002\u0002\u009e\"\u0003\u0002\u0002\u0002\u009f", - "\u00a4\u0005=\u001f\u0002\u00a0\u00a4\u0005? \u0002\u00a1\u00a4\u0005", - "9\u001d\u0002\u00a2\u00a4\u0005;\u001e\u0002\u00a3\u009f\u0003\u0002", - "\u0002\u0002\u00a3\u00a0\u0003\u0002\u0002\u0002\u00a3\u00a1\u0003\u0002", - "\u0002\u0002\u00a3\u00a2\u0003\u0002\u0002\u0002\u00a4$\u0003\u0002", - "\u0002\u0002\u00a5\u00a8\u0005-\u0017\u0002\u00a6\u00a8\u0005G$\u0002", - "\u00a7\u00a5\u0003\u0002\u0002\u0002\u00a7\u00a6\u0003\u0002\u0002\u0002", - "\u00a8&\u0003\u0002\u0002\u0002\u00a9\u00ae\u0007>\u0002\u0002\u00aa", - "\u00ad\n\u0003\u0002\u0002\u00ab\u00ad\u0005A!\u0002\u00ac\u00aa\u0003", - "\u0002\u0002\u0002\u00ac\u00ab\u0003\u0002\u0002\u0002\u00ad\u00b0\u0003", - "\u0002\u0002\u0002\u00ae\u00ac\u0003\u0002\u0002\u0002\u00ae\u00af\u0003", - "\u0002\u0002\u0002\u00af\u00b1\u0003\u0002\u0002\u0002\u00b0\u00ae\u0003", - "\u0002\u0002\u0002\u00b1\u00b2\u0007@\u0002\u0002\u00b2(\u0003\u0002", - "\u0002\u0002\u00b3\u00b5\u0005S*\u0002\u00b4\u00b3\u0003\u0002\u0002", - "\u0002\u00b4\u00b5\u0003\u0002\u0002\u0002\u00b5\u00b6\u0003\u0002\u0002", - "\u0002\u00b6\u00b7\u0007<\u0002\u0002\u00b7*\u0003\u0002\u0002\u0002", - "\u00b8\u00b9\u0005)\u0015\u0002\u00b9\u00ba\u0005U+\u0002\u00ba,\u0003", - "\u0002\u0002\u0002\u00bb\u00bc\u0007a\u0002\u0002\u00bc\u00bd\u0007", - "<\u0002\u0002\u00bd\u00c0\u0003\u0002\u0002\u0002\u00be\u00c1\u0005", - "K&\u0002\u00bf\u00c1\t\u0004\u0002\u0002\u00c0\u00be\u0003\u0002\u0002", - "\u0002\u00c0\u00bf\u0003\u0002\u0002\u0002\u00c1\u00ca\u0003\u0002\u0002", - "\u0002\u00c2\u00c5\u0005M\'\u0002\u00c3\u00c5\u00070\u0002\u0002\u00c4", - "\u00c2\u0003\u0002\u0002\u0002\u00c4\u00c3\u0003\u0002\u0002\u0002\u00c5", - "\u00c8\u0003\u0002\u0002\u0002\u00c6\u00c4\u0003\u0002\u0002\u0002\u00c6", - "\u00c7\u0003\u0002\u0002\u0002\u00c7\u00c9\u0003\u0002\u0002\u0002\u00c8", - "\u00c6\u0003\u0002\u0002\u0002\u00c9\u00cb\u0005M\'\u0002\u00ca\u00c6", - "\u0003\u0002\u0002\u0002\u00ca\u00cb\u0003\u0002\u0002\u0002\u00cb.", - "\u0003\u0002\u0002\u0002\u00cc\u00ce\u0007B\u0002\u0002\u00cd\u00cf", - "\t\u0005\u0002\u0002\u00ce\u00cd\u0003\u0002\u0002\u0002\u00cf\u00d0", - "\u0003\u0002\u0002\u0002\u00d0\u00ce\u0003\u0002\u0002\u0002\u00d0\u00d1", - "\u0003\u0002\u0002\u0002\u00d1\u00da\u0003\u0002\u0002\u0002\u00d2\u00d4", - "\u0007/\u0002\u0002\u00d3\u00d5\t\u0006\u0002\u0002\u00d4\u00d3\u0003", - "\u0002\u0002\u0002\u00d5\u00d6\u0003\u0002\u0002\u0002\u00d6\u00d4\u0003", - "\u0002\u0002\u0002\u00d6\u00d7\u0003\u0002\u0002\u0002\u00d7\u00d9\u0003", - "\u0002\u0002\u0002\u00d8\u00d2\u0003\u0002\u0002\u0002\u00d9\u00dc\u0003", - "\u0002\u0002\u0002\u00da\u00d8\u0003\u0002\u0002\u0002\u00da\u00db\u0003", - "\u0002\u0002\u0002\u00db0\u0003\u0002\u0002\u0002\u00dc\u00da\u0003", - "\u0002\u0002\u0002\u00dd\u00df\t\u0007\u0002\u0002\u00de\u00dd\u0003", - "\u0002\u0002\u0002\u00de\u00df\u0003\u0002\u0002\u0002\u00df\u00e1\u0003", - "\u0002\u0002\u0002\u00e0\u00e2\t\u0004\u0002\u0002\u00e1\u00e0\u0003", - "\u0002\u0002\u0002\u00e2\u00e3\u0003\u0002\u0002\u0002\u00e3\u00e1\u0003", - "\u0002\u0002\u0002\u00e3\u00e4\u0003\u0002\u0002\u0002\u00e42\u0003", - "\u0002\u0002\u0002\u00e5\u00e7\t\u0007\u0002\u0002\u00e6\u00e5\u0003", - "\u0002\u0002\u0002\u00e6\u00e7\u0003\u0002\u0002\u0002\u00e7\u00eb\u0003", - "\u0002\u0002\u0002\u00e8\u00ea\t\u0004\u0002\u0002\u00e9\u00e8\u0003", - "\u0002\u0002\u0002\u00ea\u00ed\u0003\u0002\u0002\u0002\u00eb\u00e9\u0003", - "\u0002\u0002\u0002\u00eb\u00ec\u0003\u0002\u0002\u0002\u00ec\u00ee\u0003", - "\u0002\u0002\u0002\u00ed\u00eb\u0003\u0002\u0002\u0002\u00ee\u00f0\u0007", - "0\u0002\u0002\u00ef\u00f1\t\u0004\u0002\u0002\u00f0\u00ef\u0003\u0002", - "\u0002\u0002\u00f1\u00f2\u0003\u0002\u0002\u0002\u00f2\u00f0\u0003\u0002", - "\u0002\u0002\u00f2\u00f3\u0003\u0002\u0002\u0002\u00f34\u0003\u0002", - "\u0002\u0002\u00f4\u00f6\t\u0007\u0002\u0002\u00f5\u00f4\u0003\u0002", - "\u0002\u0002\u00f5\u00f6\u0003\u0002\u0002\u0002\u00f6\u0111\u0003\u0002", - "\u0002\u0002\u00f7\u00f9\t\u0004\u0002\u0002\u00f8\u00f7\u0003\u0002", - "\u0002\u0002\u00f9\u00fa\u0003\u0002\u0002\u0002\u00fa\u00f8\u0003\u0002", - "\u0002\u0002\u00fa\u00fb\u0003\u0002\u0002\u0002\u00fb\u00fc\u0003\u0002", - "\u0002\u0002\u00fc\u0100\u00070\u0002\u0002\u00fd\u00ff\t\u0004\u0002", - "\u0002\u00fe\u00fd\u0003\u0002\u0002\u0002\u00ff\u0102\u0003\u0002\u0002", - "\u0002\u0100\u00fe\u0003\u0002\u0002\u0002\u0100\u0101\u0003\u0002\u0002", - "\u0002\u0101\u0103\u0003\u0002\u0002\u0002\u0102\u0100\u0003\u0002\u0002", - "\u0002\u0103\u0112\u00057\u001c\u0002\u0104\u0106\u00070\u0002\u0002", - "\u0105\u0107\t\u0004\u0002\u0002\u0106\u0105\u0003\u0002\u0002\u0002", - "\u0107\u0108\u0003\u0002\u0002\u0002\u0108\u0106\u0003\u0002\u0002\u0002", - "\u0108\u0109\u0003\u0002\u0002\u0002\u0109\u010a\u0003\u0002\u0002\u0002", - "\u010a\u0112\u00057\u001c\u0002\u010b\u010d\t\u0004\u0002\u0002\u010c", - "\u010b\u0003\u0002\u0002\u0002\u010d\u010e\u0003\u0002\u0002\u0002\u010e", - "\u010c\u0003\u0002\u0002\u0002\u010e\u010f\u0003\u0002\u0002\u0002\u010f", - "\u0110\u0003\u0002\u0002\u0002\u0110\u0112\u00057\u001c\u0002\u0111", - "\u00f8\u0003\u0002\u0002\u0002\u0111\u0104\u0003\u0002\u0002\u0002\u0111", - "\u010c\u0003\u0002\u0002\u0002\u01126\u0003\u0002\u0002\u0002\u0113", - "\u0115\t\b\u0002\u0002\u0114\u0116\t\u0007\u0002\u0002\u0115\u0114\u0003", - "\u0002\u0002\u0002\u0115\u0116\u0003\u0002\u0002\u0002\u0116\u0118\u0003", - "\u0002\u0002\u0002\u0117\u0119\t\u0004\u0002\u0002\u0118\u0117\u0003", - "\u0002\u0002\u0002\u0119\u011a\u0003\u0002\u0002\u0002\u011a\u0118\u0003", - "\u0002\u0002\u0002\u011a\u011b\u0003\u0002\u0002\u0002\u011b8\u0003", - "\u0002\u0002\u0002\u011c\u011d\u0007)\u0002\u0002\u011d\u011e\u0007", - ")\u0002\u0002\u011e\u011f\u0007)\u0002\u0002\u011f\u012c\u0003\u0002", - "\u0002\u0002\u0120\u0124\u0007)\u0002\u0002\u0121\u0122\u0007)\u0002", - "\u0002\u0122\u0124\u0007)\u0002\u0002\u0123\u0120\u0003\u0002\u0002", - "\u0002\u0123\u0121\u0003\u0002\u0002\u0002\u0123\u0124\u0003\u0002\u0002", - "\u0002\u0124\u0128\u0003\u0002\u0002\u0002\u0125\u0129\n\t\u0002\u0002", - "\u0126\u0129\u0005C\"\u0002\u0127\u0129\u0005A!\u0002\u0128\u0125\u0003", - "\u0002\u0002\u0002\u0128\u0126\u0003\u0002\u0002\u0002\u0128\u0127\u0003", - "\u0002\u0002\u0002\u0129\u012b\u0003\u0002\u0002\u0002\u012a\u0123\u0003", - "\u0002\u0002\u0002\u012b\u012e\u0003\u0002\u0002\u0002\u012c\u012a\u0003", - "\u0002\u0002\u0002\u012c\u012d\u0003\u0002\u0002\u0002\u012d\u012f\u0003", - "\u0002\u0002\u0002\u012e\u012c\u0003\u0002\u0002\u0002\u012f\u0130\u0007", - ")\u0002\u0002\u0130\u0131\u0007)\u0002\u0002\u0131\u0132\u0007)\u0002", - "\u0002\u0132:\u0003\u0002\u0002\u0002\u0133\u0134\u0007$\u0002\u0002", - "\u0134\u0135\u0007$\u0002\u0002\u0135\u0136\u0007$\u0002\u0002\u0136", - "\u0143\u0003\u0002\u0002\u0002\u0137\u013b\u0007$\u0002\u0002\u0138", - "\u0139\u0007$\u0002\u0002\u0139\u013b\u0007$\u0002\u0002\u013a\u0137", - "\u0003\u0002\u0002\u0002\u013a\u0138\u0003\u0002\u0002\u0002\u013a\u013b", - "\u0003\u0002\u0002\u0002\u013b\u013f\u0003\u0002\u0002\u0002\u013c\u0140", - "\n\n\u0002\u0002\u013d\u0140\u0005C\"\u0002\u013e\u0140\u0005A!\u0002", - "\u013f\u013c\u0003\u0002\u0002\u0002\u013f\u013d\u0003\u0002\u0002\u0002", - "\u013f\u013e\u0003\u0002\u0002\u0002\u0140\u0142\u0003\u0002\u0002\u0002", - "\u0141\u013a\u0003\u0002\u0002\u0002\u0142\u0145\u0003\u0002\u0002\u0002", - "\u0143\u0141\u0003\u0002\u0002\u0002\u0143\u0144\u0003\u0002\u0002\u0002", - "\u0144\u0146\u0003\u0002\u0002\u0002\u0145\u0143\u0003\u0002\u0002\u0002", - "\u0146\u0147\u0007$\u0002\u0002\u0147\u0148\u0007$\u0002\u0002\u0148", - "\u0149\u0007$\u0002\u0002\u0149<\u0003\u0002\u0002\u0002\u014a\u0150", - "\u0007$\u0002\u0002\u014b\u014f\n\u000b\u0002\u0002\u014c\u014f\u0005", - "C\"\u0002\u014d\u014f\u0005A!\u0002\u014e\u014b\u0003\u0002\u0002\u0002", - "\u014e\u014c\u0003\u0002\u0002\u0002\u014e\u014d\u0003\u0002\u0002\u0002", - "\u014f\u0152\u0003\u0002\u0002\u0002\u0150\u014e\u0003\u0002\u0002\u0002", - "\u0150\u0151\u0003\u0002\u0002\u0002\u0151\u0153\u0003\u0002\u0002\u0002", - "\u0152\u0150\u0003\u0002\u0002\u0002\u0153\u0154\u0007$\u0002\u0002", - "\u0154>\u0003\u0002\u0002\u0002\u0155\u015b\u0007)\u0002\u0002\u0156", - "\u015a\n\f\u0002\u0002\u0157\u015a\u0005C\"\u0002\u0158\u015a\u0005", - "A!\u0002\u0159\u0156\u0003\u0002\u0002\u0002\u0159\u0157\u0003\u0002", - "\u0002\u0002\u0159\u0158\u0003\u0002\u0002\u0002\u015a\u015d\u0003\u0002", - "\u0002\u0002\u015b\u0159\u0003\u0002\u0002\u0002\u015b\u015c\u0003\u0002", - "\u0002\u0002\u015c\u015e\u0003\u0002\u0002\u0002\u015d\u015b\u0003\u0002", - "\u0002\u0002\u015e\u015f\u0007)\u0002\u0002\u015f@\u0003\u0002\u0002", - "\u0002\u0160\u0161\u0007^\u0002\u0002\u0161\u0162\u0007w\u0002\u0002", - "\u0162\u0163\u0003\u0002\u0002\u0002\u0163\u0164\u0005[.\u0002\u0164", - "\u0165\u0005[.\u0002\u0165\u0166\u0005[.\u0002\u0166\u0167\u0005[.\u0002", - "\u0167\u0175\u0003\u0002\u0002\u0002\u0168\u0169\u0007^\u0002\u0002", - "\u0169\u016a\u0007W\u0002\u0002\u016a\u016b\u0003\u0002\u0002\u0002", - "\u016b\u016c\u0005[.\u0002\u016c\u016d\u0005[.\u0002\u016d\u016e\u0005", - "[.\u0002\u016e\u016f\u0005[.\u0002\u016f\u0170\u0005[.\u0002\u0170\u0171", - "\u0005[.\u0002\u0171\u0172\u0005[.\u0002\u0172\u0173\u0005[.\u0002\u0173", - "\u0175\u0003\u0002\u0002\u0002\u0174\u0160\u0003\u0002\u0002\u0002\u0174", - "\u0168\u0003\u0002\u0002\u0002\u0175B\u0003\u0002\u0002\u0002\u0176", - "\u0177\u0007^\u0002\u0002\u0177\u0178\t\r\u0002\u0002\u0178D\u0003\u0002", - "\u0002\u0002\u0179\u017a\t\u000e\u0002\u0002\u017a\u017b\u0003\u0002", - "\u0002\u0002\u017b\u017c\b#\u0002\u0002\u017cF\u0003\u0002\u0002\u0002", - "\u017d\u0181\u0007]\u0002\u0002\u017e\u0180\u0005E#\u0002\u017f\u017e", - "\u0003\u0002\u0002\u0002\u0180\u0183\u0003\u0002\u0002\u0002\u0181\u017f", - "\u0003\u0002\u0002\u0002\u0181\u0182\u0003\u0002\u0002\u0002\u0182\u0184", - "\u0003\u0002\u0002\u0002\u0183\u0181\u0003\u0002\u0002\u0002\u0184\u0185", - "\u0007_\u0002\u0002\u0185H\u0003\u0002\u0002\u0002\u0186\u0188\t\u000f", - "\u0002\u0002\u0187\u0186\u0003\u0002\u0002\u0002\u0188J\u0003\u0002", - "\u0002\u0002\u0189\u018c\u0005I%\u0002\u018a\u018c\u0007a\u0002\u0002", - "\u018b\u0189\u0003\u0002\u0002\u0002\u018b\u018a\u0003\u0002\u0002\u0002", - "\u018cL\u0003\u0002\u0002\u0002\u018d\u0190\u0005K&\u0002\u018e\u0190", - "\t\u0010\u0002\u0002\u018f\u018d\u0003\u0002\u0002\u0002\u018f\u018e", - "\u0003\u0002\u0002\u0002\u0190N\u0003\u0002\u0002\u0002\u0191\u0192", - "\t\u0011\u0002\u0002\u0192\u0193\t\u0012\u0002\u0002\u0193\u0194\t\u0013", - "\u0002\u0002\u0194\u0195\t\b\u0002\u0002\u0195P\u0003\u0002\u0002\u0002", - "\u0196\u0197\t\u0014\u0002\u0002\u0197\u0198\t\u0015\u0002\u0002\u0198", - "\u0199\t\b\u0002\u0002\u0199\u019a\t\u0016\u0002\u0002\u019a\u019b\t", - "\u0017\u0002\u0002\u019b\u019c\t\u0018\u0002\u0002\u019cR\u0003\u0002", - "\u0002\u0002\u019d\u01a6\u0005I%\u0002\u019e\u01a1\u0005M\'\u0002\u019f", - "\u01a1\u00070\u0002\u0002\u01a0\u019e\u0003\u0002\u0002\u0002\u01a0", - "\u019f\u0003\u0002\u0002\u0002\u01a1\u01a4\u0003\u0002\u0002\u0002\u01a2", - "\u01a0\u0003\u0002\u0002\u0002\u01a2\u01a3\u0003\u0002\u0002\u0002\u01a3", - "\u01a5\u0003\u0002\u0002\u0002\u01a4\u01a2\u0003\u0002\u0002\u0002\u01a5", - "\u01a7\u0005M\'\u0002\u01a6\u01a2\u0003\u0002\u0002\u0002\u01a6\u01a7", - "\u0003\u0002\u0002\u0002\u01a7T\u0003\u0002\u0002\u0002\u01a8\u01ac", - "\u0005K&\u0002\u01a9\u01ac\u00042<\u0002\u01aa\u01ac\u0005W,\u0002\u01ab", - "\u01a8\u0003\u0002\u0002\u0002\u01ab\u01a9\u0003\u0002\u0002\u0002\u01ab", - "\u01aa\u0003\u0002\u0002\u0002\u01ac\u01ba\u0003\u0002\u0002\u0002\u01ad", - "\u01b1\u0005M\'\u0002\u01ae\u01b1\t\u0019\u0002\u0002\u01af\u01b1\u0005", - "W,\u0002\u01b0\u01ad\u0003\u0002\u0002\u0002\u01b0\u01ae\u0003\u0002", - "\u0002\u0002\u01b0\u01af\u0003\u0002\u0002\u0002\u01b1\u01b4\u0003\u0002", - "\u0002\u0002\u01b2\u01b0\u0003\u0002\u0002\u0002\u01b2\u01b3\u0003\u0002", - "\u0002\u0002\u01b3\u01b8\u0003\u0002\u0002\u0002\u01b4\u01b2\u0003\u0002", - "\u0002\u0002\u01b5\u01b9\u0005M\'\u0002\u01b6\u01b9\u0007<\u0002\u0002", - "\u01b7\u01b9\u0005W,\u0002\u01b8\u01b5\u0003\u0002\u0002\u0002\u01b8", - "\u01b6\u0003\u0002\u0002\u0002\u01b8\u01b7\u0003\u0002\u0002\u0002\u01b9", - "\u01bb\u0003\u0002\u0002\u0002\u01ba\u01b2\u0003\u0002\u0002\u0002\u01ba", - "\u01bb\u0003\u0002\u0002\u0002\u01bbV\u0003\u0002\u0002\u0002\u01bc", - "\u01bf\u0005Y-\u0002\u01bd\u01bf\u0005]/\u0002\u01be\u01bc\u0003\u0002", - "\u0002\u0002\u01be\u01bd\u0003\u0002\u0002\u0002\u01bfX\u0003\u0002", - "\u0002\u0002\u01c0\u01c1\u0007\'\u0002\u0002\u01c1\u01c2\u0005[.\u0002", - "\u01c2\u01c3\u0005[.\u0002\u01c3Z\u0003\u0002\u0002\u0002\u01c4\u01c6", - "\t\u001a\u0002\u0002\u01c5\u01c4\u0003\u0002\u0002\u0002\u01c6\\\u0003", - "\u0002\u0002\u0002\u01c7\u01c8\u0007^\u0002\u0002\u01c8\u01c9\t\u001b", - "\u0002\u0002\u01c9^\u0003\u0002\u0002\u00028\u0002\u008a\u0092\u009d", - "\u00a3\u00a7\u00ac\u00ae\u00b4\u00c0\u00c4\u00c6\u00ca\u00d0\u00d6\u00da", - "\u00de\u00e3\u00e6\u00eb\u00f2\u00f5\u00fa\u0100\u0108\u010e\u0111\u0115", - "\u011a\u0123\u0128\u012c\u013a\u013f\u0143\u014e\u0150\u0159\u015b\u0174", - "\u0181\u0187\u018b\u018f\u01a0\u01a2\u01a6\u01ab\u01b0\u01b2\u01b8\u01ba", - "\u01be\u01c5\u0003\b\u0002\u0002"].join(""); +const serializedATN = [4,0,46,456,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2, +4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7, +12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19, +2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2, +27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34, +7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7, +41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1, +1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,6,1, +7,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,12,1,13,1,13,5, +13,135,8,13,10,13,12,13,138,9,13,1,13,1,13,1,14,1,14,1,14,3,14,145,8,14, +1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,3,15,156,8,15,1,16,1,16,1,16, +1,16,3,16,162,8,16,1,17,1,17,3,17,166,8,17,1,18,1,18,1,18,5,18,171,8,18, +10,18,12,18,174,9,18,1,18,1,18,1,19,3,19,179,8,19,1,19,1,19,1,20,1,20,1, +20,1,21,1,21,1,21,1,21,1,21,3,21,191,8,21,1,21,1,21,5,21,195,8,21,10,21, +12,21,198,9,21,1,21,3,21,201,8,21,1,22,1,22,4,22,205,8,22,11,22,12,22,206, +1,22,1,22,4,22,211,8,22,11,22,12,22,212,5,22,215,8,22,10,22,12,22,218,9, +22,1,23,3,23,221,8,23,1,23,4,23,224,8,23,11,23,12,23,225,1,24,3,24,229,8, +24,1,24,5,24,232,8,24,10,24,12,24,235,9,24,1,24,1,24,4,24,239,8,24,11,24, +12,24,240,1,25,3,25,244,8,25,1,25,4,25,247,8,25,11,25,12,25,248,1,25,1,25, +5,25,253,8,25,10,25,12,25,256,9,25,1,25,1,25,1,25,4,25,261,8,25,11,25,12, +25,262,1,25,1,25,4,25,267,8,25,11,25,12,25,268,1,25,3,25,272,8,25,1,26,1, +26,3,26,276,8,26,1,26,4,26,279,8,26,11,26,12,26,280,1,27,1,27,1,27,1,27, +1,27,1,27,1,27,3,27,290,8,27,1,27,1,27,1,27,3,27,295,8,27,5,27,297,8,27, +10,27,12,27,300,9,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1, +28,3,28,313,8,28,1,28,1,28,1,28,3,28,318,8,28,5,28,320,8,28,10,28,12,28, +323,9,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,5,29,333,8,29,10,29,12, +29,336,9,29,1,29,1,29,1,30,1,30,1,30,1,30,5,30,344,8,30,10,30,12,30,347, +9,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1, +31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,3,31,371,8,31,1,32,1,32,1,32, +1,33,1,33,1,33,1,33,1,34,1,34,5,34,382,8,34,10,34,12,34,385,9,34,1,34,1, +34,1,35,3,35,390,8,35,1,36,1,36,3,36,394,8,36,1,37,1,37,3,37,398,8,37,1, +38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40, +5,40,415,8,40,10,40,12,40,418,9,40,1,40,3,40,421,8,40,1,41,1,41,1,41,3,41, +426,8,41,1,41,1,41,1,41,5,41,431,8,41,10,41,12,41,434,9,41,1,41,1,41,1,41, +3,41,439,8,41,3,41,441,8,41,1,42,1,42,3,42,445,8,42,1,43,1,43,1,43,1,43, +1,44,3,44,452,8,44,1,45,1,45,1,45,0,0,46,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15, +8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20, +41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32, +65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44, +89,45,91,46,1,0,26,2,0,10,10,13,13,8,0,0,32,34,34,60,60,62,62,92,92,94,94, +96,96,123,125,1,0,48,57,2,0,65,90,97,122,3,0,48,57,65,90,97,122,2,0,43,43, +45,45,2,0,69,69,101,101,2,0,39,39,92,92,2,0,34,34,92,92,4,0,10,10,13,13, +34,34,92,92,4,0,10,10,13,13,39,39,92,92,8,0,34,34,39,39,92,92,98,98,102, +102,110,110,114,114,116,116,3,0,9,10,13,13,32,32,13,0,65,90,97,122,192,214, +216,246,248,767,880,893,895,8191,8204,8205,8304,8591,11264,12271,12289,55295, +63744,64975,65008,65533,5,0,45,45,48,57,183,183,768,879,8255,8256,2,0,66, +66,98,98,2,0,65,65,97,97,2,0,83,83,115,115,2,0,80,80,112,112,2,0,82,82,114, +114,2,0,70,70,102,102,2,0,73,73,105,105,2,0,88,88,120,120,2,0,46,46,58,58, +3,0,48,57,65,70,97,102,7,0,33,33,35,47,59,59,61,61,63,64,95,95,126,126,519, +0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0, +0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1, +0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0, +35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0, +0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57, +1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0, +0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1, +0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0, +91,1,0,0,0,1,93,1,0,0,0,3,95,1,0,0,0,5,103,1,0,0,0,7,109,1,0,0,0,9,111,1, +0,0,0,11,113,1,0,0,0,13,115,1,0,0,0,15,118,1,0,0,0,17,121,1,0,0,0,19,123, +1,0,0,0,21,125,1,0,0,0,23,127,1,0,0,0,25,129,1,0,0,0,27,132,1,0,0,0,29,144, +1,0,0,0,31,155,1,0,0,0,33,161,1,0,0,0,35,165,1,0,0,0,37,167,1,0,0,0,39,178, +1,0,0,0,41,182,1,0,0,0,43,185,1,0,0,0,45,202,1,0,0,0,47,220,1,0,0,0,49,228, +1,0,0,0,51,243,1,0,0,0,53,273,1,0,0,0,55,282,1,0,0,0,57,305,1,0,0,0,59,328, +1,0,0,0,61,339,1,0,0,0,63,370,1,0,0,0,65,372,1,0,0,0,67,375,1,0,0,0,69,379, +1,0,0,0,71,389,1,0,0,0,73,393,1,0,0,0,75,397,1,0,0,0,77,399,1,0,0,0,79,404, +1,0,0,0,81,411,1,0,0,0,83,425,1,0,0,0,85,444,1,0,0,0,87,446,1,0,0,0,89,451, +1,0,0,0,91,453,1,0,0,0,93,94,5,46,0,0,94,2,1,0,0,0,95,96,5,64,0,0,96,97, +5,112,0,0,97,98,5,114,0,0,98,99,5,101,0,0,99,100,5,102,0,0,100,101,5,105, +0,0,101,102,5,120,0,0,102,4,1,0,0,0,103,104,5,64,0,0,104,105,5,98,0,0,105, +106,5,97,0,0,106,107,5,115,0,0,107,108,5,101,0,0,108,6,1,0,0,0,109,110,5, +59,0,0,110,8,1,0,0,0,111,112,5,44,0,0,112,10,1,0,0,0,113,114,5,97,0,0,114, +12,1,0,0,0,115,116,5,60,0,0,116,117,5,60,0,0,117,14,1,0,0,0,118,119,5,62, +0,0,119,120,5,62,0,0,120,16,1,0,0,0,121,122,5,91,0,0,122,18,1,0,0,0,123, +124,5,93,0,0,124,20,1,0,0,0,125,126,5,40,0,0,126,22,1,0,0,0,127,128,5,41, +0,0,128,24,1,0,0,0,129,130,5,94,0,0,130,131,5,94,0,0,131,26,1,0,0,0,132, +136,5,35,0,0,133,135,8,0,0,0,134,133,1,0,0,0,135,138,1,0,0,0,136,134,1,0, +0,0,136,137,1,0,0,0,137,139,1,0,0,0,138,136,1,0,0,0,139,140,6,13,0,0,140, +28,1,0,0,0,141,145,3,47,23,0,142,145,3,49,24,0,143,145,3,51,25,0,144,141, +1,0,0,0,144,142,1,0,0,0,144,143,1,0,0,0,145,30,1,0,0,0,146,147,5,116,0,0, +147,148,5,114,0,0,148,149,5,117,0,0,149,156,5,101,0,0,150,151,5,102,0,0, +151,152,5,97,0,0,152,153,5,108,0,0,153,154,5,115,0,0,154,156,5,101,0,0,155, +146,1,0,0,0,155,150,1,0,0,0,156,32,1,0,0,0,157,162,3,59,29,0,158,162,3,61, +30,0,159,162,3,55,27,0,160,162,3,57,28,0,161,157,1,0,0,0,161,158,1,0,0,0, +161,159,1,0,0,0,161,160,1,0,0,0,162,34,1,0,0,0,163,166,3,43,21,0,164,166, +3,69,34,0,165,163,1,0,0,0,165,164,1,0,0,0,166,36,1,0,0,0,167,172,5,60,0, +0,168,171,8,1,0,0,169,171,3,63,31,0,170,168,1,0,0,0,170,169,1,0,0,0,171, +174,1,0,0,0,172,170,1,0,0,0,172,173,1,0,0,0,173,175,1,0,0,0,174,172,1,0, +0,0,175,176,5,62,0,0,176,38,1,0,0,0,177,179,3,81,40,0,178,177,1,0,0,0,178, +179,1,0,0,0,179,180,1,0,0,0,180,181,5,58,0,0,181,40,1,0,0,0,182,183,3,39, +19,0,183,184,3,83,41,0,184,42,1,0,0,0,185,186,5,95,0,0,186,187,5,58,0,0, +187,190,1,0,0,0,188,191,3,73,36,0,189,191,7,2,0,0,190,188,1,0,0,0,190,189, +1,0,0,0,191,200,1,0,0,0,192,195,3,75,37,0,193,195,5,46,0,0,194,192,1,0,0, +0,194,193,1,0,0,0,195,198,1,0,0,0,196,194,1,0,0,0,196,197,1,0,0,0,197,199, +1,0,0,0,198,196,1,0,0,0,199,201,3,75,37,0,200,196,1,0,0,0,200,201,1,0,0, +0,201,44,1,0,0,0,202,204,5,64,0,0,203,205,7,3,0,0,204,203,1,0,0,0,205,206, +1,0,0,0,206,204,1,0,0,0,206,207,1,0,0,0,207,216,1,0,0,0,208,210,5,45,0,0, +209,211,7,4,0,0,210,209,1,0,0,0,211,212,1,0,0,0,212,210,1,0,0,0,212,213, +1,0,0,0,213,215,1,0,0,0,214,208,1,0,0,0,215,218,1,0,0,0,216,214,1,0,0,0, +216,217,1,0,0,0,217,46,1,0,0,0,218,216,1,0,0,0,219,221,7,5,0,0,220,219,1, +0,0,0,220,221,1,0,0,0,221,223,1,0,0,0,222,224,7,2,0,0,223,222,1,0,0,0,224, +225,1,0,0,0,225,223,1,0,0,0,225,226,1,0,0,0,226,48,1,0,0,0,227,229,7,5,0, +0,228,227,1,0,0,0,228,229,1,0,0,0,229,233,1,0,0,0,230,232,7,2,0,0,231,230, +1,0,0,0,232,235,1,0,0,0,233,231,1,0,0,0,233,234,1,0,0,0,234,236,1,0,0,0, +235,233,1,0,0,0,236,238,5,46,0,0,237,239,7,2,0,0,238,237,1,0,0,0,239,240, +1,0,0,0,240,238,1,0,0,0,240,241,1,0,0,0,241,50,1,0,0,0,242,244,7,5,0,0,243, +242,1,0,0,0,243,244,1,0,0,0,244,271,1,0,0,0,245,247,7,2,0,0,246,245,1,0, +0,0,247,248,1,0,0,0,248,246,1,0,0,0,248,249,1,0,0,0,249,250,1,0,0,0,250, +254,5,46,0,0,251,253,7,2,0,0,252,251,1,0,0,0,253,256,1,0,0,0,254,252,1,0, +0,0,254,255,1,0,0,0,255,257,1,0,0,0,256,254,1,0,0,0,257,272,3,53,26,0,258, +260,5,46,0,0,259,261,7,2,0,0,260,259,1,0,0,0,261,262,1,0,0,0,262,260,1,0, +0,0,262,263,1,0,0,0,263,264,1,0,0,0,264,272,3,53,26,0,265,267,7,2,0,0,266, +265,1,0,0,0,267,268,1,0,0,0,268,266,1,0,0,0,268,269,1,0,0,0,269,270,1,0, +0,0,270,272,3,53,26,0,271,246,1,0,0,0,271,258,1,0,0,0,271,266,1,0,0,0,272, +52,1,0,0,0,273,275,7,6,0,0,274,276,7,5,0,0,275,274,1,0,0,0,275,276,1,0,0, +0,276,278,1,0,0,0,277,279,7,2,0,0,278,277,1,0,0,0,279,280,1,0,0,0,280,278, +1,0,0,0,280,281,1,0,0,0,281,54,1,0,0,0,282,283,5,39,0,0,283,284,5,39,0,0, +284,285,5,39,0,0,285,298,1,0,0,0,286,290,5,39,0,0,287,288,5,39,0,0,288,290, +5,39,0,0,289,286,1,0,0,0,289,287,1,0,0,0,289,290,1,0,0,0,290,294,1,0,0,0, +291,295,8,7,0,0,292,295,3,65,32,0,293,295,3,63,31,0,294,291,1,0,0,0,294, +292,1,0,0,0,294,293,1,0,0,0,295,297,1,0,0,0,296,289,1,0,0,0,297,300,1,0, +0,0,298,296,1,0,0,0,298,299,1,0,0,0,299,301,1,0,0,0,300,298,1,0,0,0,301, +302,5,39,0,0,302,303,5,39,0,0,303,304,5,39,0,0,304,56,1,0,0,0,305,306,5, +34,0,0,306,307,5,34,0,0,307,308,5,34,0,0,308,321,1,0,0,0,309,313,5,34,0, +0,310,311,5,34,0,0,311,313,5,34,0,0,312,309,1,0,0,0,312,310,1,0,0,0,312, +313,1,0,0,0,313,317,1,0,0,0,314,318,8,8,0,0,315,318,3,65,32,0,316,318,3, +63,31,0,317,314,1,0,0,0,317,315,1,0,0,0,317,316,1,0,0,0,318,320,1,0,0,0, +319,312,1,0,0,0,320,323,1,0,0,0,321,319,1,0,0,0,321,322,1,0,0,0,322,324, +1,0,0,0,323,321,1,0,0,0,324,325,5,34,0,0,325,326,5,34,0,0,326,327,5,34,0, +0,327,58,1,0,0,0,328,334,5,34,0,0,329,333,8,9,0,0,330,333,3,65,32,0,331, +333,3,63,31,0,332,329,1,0,0,0,332,330,1,0,0,0,332,331,1,0,0,0,333,336,1, +0,0,0,334,332,1,0,0,0,334,335,1,0,0,0,335,337,1,0,0,0,336,334,1,0,0,0,337, +338,5,34,0,0,338,60,1,0,0,0,339,345,5,39,0,0,340,344,8,10,0,0,341,344,3, +65,32,0,342,344,3,63,31,0,343,340,1,0,0,0,343,341,1,0,0,0,343,342,1,0,0, +0,344,347,1,0,0,0,345,343,1,0,0,0,345,346,1,0,0,0,346,348,1,0,0,0,347,345, +1,0,0,0,348,349,5,39,0,0,349,62,1,0,0,0,350,351,5,92,0,0,351,352,5,117,0, +0,352,353,1,0,0,0,353,354,3,89,44,0,354,355,3,89,44,0,355,356,3,89,44,0, +356,357,3,89,44,0,357,371,1,0,0,0,358,359,5,92,0,0,359,360,5,85,0,0,360, +361,1,0,0,0,361,362,3,89,44,0,362,363,3,89,44,0,363,364,3,89,44,0,364,365, +3,89,44,0,365,366,3,89,44,0,366,367,3,89,44,0,367,368,3,89,44,0,368,369, +3,89,44,0,369,371,1,0,0,0,370,350,1,0,0,0,370,358,1,0,0,0,371,64,1,0,0,0, +372,373,5,92,0,0,373,374,7,11,0,0,374,66,1,0,0,0,375,376,7,12,0,0,376,377, +1,0,0,0,377,378,6,33,0,0,378,68,1,0,0,0,379,383,5,91,0,0,380,382,3,67,33, +0,381,380,1,0,0,0,382,385,1,0,0,0,383,381,1,0,0,0,383,384,1,0,0,0,384,386, +1,0,0,0,385,383,1,0,0,0,386,387,5,93,0,0,387,70,1,0,0,0,388,390,7,13,0,0, +389,388,1,0,0,0,390,72,1,0,0,0,391,394,3,71,35,0,392,394,5,95,0,0,393,391, +1,0,0,0,393,392,1,0,0,0,394,74,1,0,0,0,395,398,3,73,36,0,396,398,7,14,0, +0,397,395,1,0,0,0,397,396,1,0,0,0,398,76,1,0,0,0,399,400,7,15,0,0,400,401, +7,16,0,0,401,402,7,17,0,0,402,403,7,6,0,0,403,78,1,0,0,0,404,405,7,18,0, +0,405,406,7,19,0,0,406,407,7,6,0,0,407,408,7,20,0,0,408,409,7,21,0,0,409, +410,7,22,0,0,410,80,1,0,0,0,411,420,3,71,35,0,412,415,3,75,37,0,413,415, +5,46,0,0,414,412,1,0,0,0,414,413,1,0,0,0,415,418,1,0,0,0,416,414,1,0,0,0, +416,417,1,0,0,0,417,419,1,0,0,0,418,416,1,0,0,0,419,421,3,75,37,0,420,416, +1,0,0,0,420,421,1,0,0,0,421,82,1,0,0,0,422,426,3,73,36,0,423,426,2,48,58, +0,424,426,3,85,42,0,425,422,1,0,0,0,425,423,1,0,0,0,425,424,1,0,0,0,426, +440,1,0,0,0,427,431,3,75,37,0,428,431,7,23,0,0,429,431,3,85,42,0,430,427, +1,0,0,0,430,428,1,0,0,0,430,429,1,0,0,0,431,434,1,0,0,0,432,430,1,0,0,0, +432,433,1,0,0,0,433,438,1,0,0,0,434,432,1,0,0,0,435,439,3,75,37,0,436,439, +5,58,0,0,437,439,3,85,42,0,438,435,1,0,0,0,438,436,1,0,0,0,438,437,1,0,0, +0,439,441,1,0,0,0,440,432,1,0,0,0,440,441,1,0,0,0,441,84,1,0,0,0,442,445, +3,87,43,0,443,445,3,91,45,0,444,442,1,0,0,0,444,443,1,0,0,0,445,86,1,0,0, +0,446,447,5,37,0,0,447,448,3,89,44,0,448,449,3,89,44,0,449,88,1,0,0,0,450, +452,7,24,0,0,451,450,1,0,0,0,452,90,1,0,0,0,453,454,5,92,0,0,454,455,7,25, +0,0,455,92,1,0,0,0,54,0,136,144,155,161,165,170,172,178,190,194,196,200, +206,212,216,220,225,228,233,240,243,248,254,262,268,271,275,280,289,294, +298,312,317,321,332,334,343,345,370,383,389,393,397,414,416,420,425,430, +432,438,440,444,451,1,6,0,0]; -var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); +const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); -var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); }); +const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) ); -function turtlestarLexer(input) { - antlr4.Lexer.call(this, input); - this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache()); - return this; -} +export default class turtlestarLexer extends antlr4.Lexer { + + static grammarFileName = "turtlestar.g4"; + static channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]; + static modeNames = [ "DEFAULT_MODE" ]; + static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", "','", + "'a'", "'<<'", "'>>'", "'['", "']'", "'('", "')'", + "'^^'" ]; + static symbolicNames = [ null, null, null, null, null, null, null, null, + null, null, null, null, null, null, "COMMENT", + "NumericLiteral", "BooleanLiteral", "String", + "BlankNode", "IRIREF", "PNAME_NS", "PNAME_LN", + "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", "DECIMAL", + "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", + "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", + "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", + "WS", "ANON", "PN_CHARS_BASE", "PN_CHARS_U", "PN_CHARS", + "BASE", "PREFIX", "PN_PREFIX", "PN_LOCAL", "PLX", + "PERCENT", "HEX", "PN_LOCAL_ESC" ]; + static ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", + "COMMENT", "NumericLiteral", "BooleanLiteral", "String", + "BlankNode", "IRIREF", "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", + "LANGTAG", "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", + "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", + "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", + "UCHAR", "ECHAR", "WS", "ANON", "PN_CHARS_BASE", "PN_CHARS_U", + "PN_CHARS", "BASE", "PREFIX", "PN_PREFIX", "PN_LOCAL", + "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; + + constructor(input) { + super(input) + this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache()); + } -turtlestarLexer.prototype = Object.create(antlr4.Lexer.prototype); -turtlestarLexer.prototype.constructor = turtlestarLexer; + get atn() { + return atn; + } +} turtlestarLexer.EOF = antlr4.Token.EOF; turtlestarLexer.T__0 = 1; @@ -395,48 +264,4 @@ turtlestarLexer.HEX = 45; turtlestarLexer.PN_LOCAL_ESC = 46; -turtlestarLexer.prototype.modeNames = [ "DEFAULT_MODE" ]; - -turtlestarLexer.prototype.literalNames = [ null, "'.'", "'@prefix'", "'@base'", - "';'", "','", "'a'", "'<<'", - "'>>'", "'['", "']'", "'('", - "')'", "'^^'" ]; - -turtlestarLexer.prototype.symbolicNames = [ null, null, null, null, null, - null, null, null, null, null, - null, null, null, null, "COMMENT", - "NumericLiteral", "BooleanLiteral", - "String", "BlankNode", "IRIREF", - "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", - "LANGTAG", "INTEGER", "DECIMAL", - "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", - "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", - "UCHAR", "ECHAR", "WS", "ANON", - "PN_CHARS_BASE", "PN_CHARS_U", - "PN_CHARS", "BASE", "PREFIX", - "PN_PREFIX", "PN_LOCAL", "PLX", - "PERCENT", "HEX", "PN_LOCAL_ESC" ]; - -turtlestarLexer.prototype.ruleNames = [ "T__0", "T__1", "T__2", "T__3", - "T__4", "T__5", "T__6", "T__7", - "T__8", "T__9", "T__10", "T__11", - "T__12", "COMMENT", "NumericLiteral", - "BooleanLiteral", "String", "BlankNode", - "IRIREF", "PNAME_NS", "PNAME_LN", - "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", - "DECIMAL", "DOUBLE", "EXPONENT", - "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", - "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", - "ECHAR", "WS", "ANON", "PN_CHARS_BASE", - "PN_CHARS_U", "PN_CHARS", "BASE", - "PREFIX", "PN_PREFIX", "PN_LOCAL", - "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; - -turtlestarLexer.prototype.grammarFileName = "turtlestar.g4"; - - - -exports.turtlestarLexer = turtlestarLexer; diff --git a/editor/parser/turtlestar/turtlestarListener.js b/editor/parser/turtlestar/turtlestarListener.js index ef0a7c2..4fc08cc 100644 --- a/editor/parser/turtlestar/turtlestarListener.js +++ b/editor/parser/turtlestar/turtlestarListener.js @@ -1,222 +1,216 @@ -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start -var antlr4 = require('antlr4/index'); +import antlr4 from 'antlr4'; // This class defines a complete listener for a parse tree produced by turtlestarParser. -function turtlestarListener() { - antlr4.tree.ParseTreeListener.call(this); - return this; -} +export default class turtlestarListener extends antlr4.tree.ParseTreeListener { -turtlestarListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype); -turtlestarListener.prototype.constructor = turtlestarListener; + // Enter a parse tree produced by turtlestarParser#turtleStarDoc. + enterTurtleStarDoc(ctx) { + } -// Enter a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarListener.prototype.enterTurtleStarDoc = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#turtleStarDoc. + exitTurtleStarDoc(ctx) { + } -// Exit a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarListener.prototype.exitTurtleStarDoc = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#statement. + enterStatement(ctx) { + } -// Enter a parse tree produced by turtlestarParser#statement. -turtlestarListener.prototype.enterStatement = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#statement. + exitStatement(ctx) { + } -// Exit a parse tree produced by turtlestarParser#statement. -turtlestarListener.prototype.exitStatement = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#directive. + enterDirective(ctx) { + } -// Enter a parse tree produced by turtlestarParser#directive. -turtlestarListener.prototype.enterDirective = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#directive. + exitDirective(ctx) { + } -// Exit a parse tree produced by turtlestarParser#directive. -turtlestarListener.prototype.exitDirective = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#prefixID. + enterPrefixID(ctx) { + } -// Enter a parse tree produced by turtlestarParser#prefixID. -turtlestarListener.prototype.enterPrefixID = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#prefixID. + exitPrefixID(ctx) { + } -// Exit a parse tree produced by turtlestarParser#prefixID. -turtlestarListener.prototype.exitPrefixID = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#base. + enterBase(ctx) { + } -// Enter a parse tree produced by turtlestarParser#base. -turtlestarListener.prototype.enterBase = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#base. + exitBase(ctx) { + } -// Exit a parse tree produced by turtlestarParser#base. -turtlestarListener.prototype.exitBase = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#sparqlBase. + enterSparqlBase(ctx) { + } -// Enter a parse tree produced by turtlestarParser#sparqlBase. -turtlestarListener.prototype.enterSparqlBase = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#sparqlBase. + exitSparqlBase(ctx) { + } -// Exit a parse tree produced by turtlestarParser#sparqlBase. -turtlestarListener.prototype.exitSparqlBase = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#sparqlPrefix. + enterSparqlPrefix(ctx) { + } -// Enter a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarListener.prototype.enterSparqlPrefix = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#sparqlPrefix. + exitSparqlPrefix(ctx) { + } -// Exit a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarListener.prototype.exitSparqlPrefix = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#triples. + enterTriples(ctx) { + } -// Enter a parse tree produced by turtlestarParser#triples. -turtlestarListener.prototype.enterTriples = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#triples. + exitTriples(ctx) { + } -// Exit a parse tree produced by turtlestarParser#triples. -turtlestarListener.prototype.exitTriples = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#predicateObjectList. + enterPredicateObjectList(ctx) { + } -// Enter a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarListener.prototype.enterPredicateObjectList = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#predicateObjectList. + exitPredicateObjectList(ctx) { + } -// Exit a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarListener.prototype.exitPredicateObjectList = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#objectList. + enterObjectList(ctx) { + } -// Enter a parse tree produced by turtlestarParser#objectList. -turtlestarListener.prototype.enterObjectList = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#objectList. + exitObjectList(ctx) { + } -// Exit a parse tree produced by turtlestarParser#objectList. -turtlestarListener.prototype.exitObjectList = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#verb. + enterVerb(ctx) { + } -// Enter a parse tree produced by turtlestarParser#verb. -turtlestarListener.prototype.enterVerb = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#verb. + exitVerb(ctx) { + } -// Exit a parse tree produced by turtlestarParser#verb. -turtlestarListener.prototype.exitVerb = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#subject. + enterSubject(ctx) { + } -// Enter a parse tree produced by turtlestarParser#subject. -turtlestarListener.prototype.enterSubject = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#subject. + exitSubject(ctx) { + } -// Exit a parse tree produced by turtlestarParser#subject. -turtlestarListener.prototype.exitSubject = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#predicate. + enterPredicate(ctx) { + } -// Enter a parse tree produced by turtlestarParser#predicate. -turtlestarListener.prototype.enterPredicate = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#predicate. + exitPredicate(ctx) { + } -// Exit a parse tree produced by turtlestarParser#predicate. -turtlestarListener.prototype.exitPredicate = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#object. + enterObject(ctx) { + } -// Enter a parse tree produced by turtlestarParser#object. -turtlestarListener.prototype.enterObject = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#object. + exitObject(ctx) { + } -// Exit a parse tree produced by turtlestarParser#object. -turtlestarListener.prototype.exitObject = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#tripleX. + enterTripleX(ctx) { + } -// Enter a parse tree produced by turtlestarParser#tripleX. -turtlestarListener.prototype.enterTripleX = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#tripleX. + exitTripleX(ctx) { + } -// Exit a parse tree produced by turtlestarParser#tripleX. -turtlestarListener.prototype.exitTripleX = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#subjectX. + enterSubjectX(ctx) { + } -// Enter a parse tree produced by turtlestarParser#subjectX. -turtlestarListener.prototype.enterSubjectX = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#subjectX. + exitSubjectX(ctx) { + } -// Exit a parse tree produced by turtlestarParser#subjectX. -turtlestarListener.prototype.exitSubjectX = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#objectX. + enterObjectX(ctx) { + } -// Enter a parse tree produced by turtlestarParser#objectX. -turtlestarListener.prototype.enterObjectX = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#objectX. + exitObjectX(ctx) { + } -// Exit a parse tree produced by turtlestarParser#objectX. -turtlestarListener.prototype.exitObjectX = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#literal. + enterLiteral(ctx) { + } -// Enter a parse tree produced by turtlestarParser#literal. -turtlestarListener.prototype.enterLiteral = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#literal. + exitLiteral(ctx) { + } -// Exit a parse tree produced by turtlestarParser#literal. -turtlestarListener.prototype.exitLiteral = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#blankNodePropertyList. + enterBlankNodePropertyList(ctx) { + } -// Enter a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarListener.prototype.enterBlankNodePropertyList = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#blankNodePropertyList. + exitBlankNodePropertyList(ctx) { + } -// Exit a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarListener.prototype.exitBlankNodePropertyList = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#collection. + enterCollection(ctx) { + } -// Enter a parse tree produced by turtlestarParser#collection. -turtlestarListener.prototype.enterCollection = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#collection. + exitCollection(ctx) { + } -// Exit a parse tree produced by turtlestarParser#collection. -turtlestarListener.prototype.exitCollection = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#rdfLiteral. + enterRdfLiteral(ctx) { + } -// Enter a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarListener.prototype.enterRdfLiteral = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#rdfLiteral. + exitRdfLiteral(ctx) { + } -// Exit a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarListener.prototype.exitRdfLiteral = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#iri. + enterIri(ctx) { + } -// Enter a parse tree produced by turtlestarParser#iri. -turtlestarListener.prototype.enterIri = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#iri. + exitIri(ctx) { + } -// Exit a parse tree produced by turtlestarParser#iri. -turtlestarListener.prototype.exitIri = function(ctx) { -}; + // Enter a parse tree produced by turtlestarParser#prefixedName. + enterPrefixedName(ctx) { + } -// Enter a parse tree produced by turtlestarParser#prefixedName. -turtlestarListener.prototype.enterPrefixedName = function(ctx) { -}; + // Exit a parse tree produced by turtlestarParser#prefixedName. + exitPrefixedName(ctx) { + } -// Exit a parse tree produced by turtlestarParser#prefixedName. -turtlestarListener.prototype.exitPrefixedName = function(ctx) { -}; - -exports.turtlestarListener = turtlestarListener; \ No newline at end of file +} \ No newline at end of file diff --git a/editor/parser/turtlestar/turtlestarParser.js b/editor/parser/turtlestar/turtlestarParser.js index e9a8d48..8eed6d9 100644 --- a/editor/parser/turtlestar/turtlestarParser.js +++ b/editor/parser/turtlestar/turtlestarParser.js @@ -1,169 +1,1001 @@ -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start -var antlr4 = require('antlr4/index'); -var turtlestarListener = require('./turtlestarListener').turtlestarListener; -var turtlestarVisitor = require('./turtlestarVisitor').turtlestarVisitor; - -var grammarFileName = "turtlestar.g4"; - -var serializedATN = ["\u0003\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd", - "\u00030\u00b6\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004\u0004\t", - "\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t\u0007\u0004", - "\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004\f\t\f\u0004", - "\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010\t\u0010\u0004", - "\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013\u0004\u0014\t", - "\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017\t\u0017\u0004", - "\u0018\t\u0018\u0003\u0002\u0007\u00022\n\u0002\f\u0002\u000e\u0002", - "5\u000b\u0002\u0003\u0002\u0003\u0002\u0003\u0003\u0003\u0003\u0003", - "\u0003\u0003\u0003\u0005\u0003=\n\u0003\u0003\u0004\u0003\u0004\u0003", - "\u0004\u0003\u0004\u0005\u0004C\n\u0004\u0003\u0005\u0003\u0005\u0003", - "\u0005\u0003\u0005\u0003\u0005\u0003\u0006\u0003\u0006\u0003\u0006\u0003", - "\u0006\u0003\u0007\u0003\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003", - "\b\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0005\tZ\n\t\u0005\t\\\n", - "\t\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0005\nd\n\n\u0007", - "\nf\n\n\f\n\u000e\ni\u000b\n\u0003\u000b\u0003\u000b\u0003\u000b\u0007", - "\u000bn\n\u000b\f\u000b\u000e\u000bq\u000b\u000b\u0003\f\u0003\f\u0005", - "\fu\n\f\u0003\r\u0003\r\u0003\r\u0003\r\u0005\r{\n\r\u0003\u000e\u0003", - "\u000e\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003", - "\u000f\u0005\u000f\u0085\n\u000f\u0003\u0010\u0003\u0010\u0003\u0010", - "\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0011\u0003\u0011\u0003\u0011", - "\u0005\u0011\u0090\n\u0011\u0003\u0012\u0003\u0012\u0003\u0012\u0003", - "\u0012\u0005\u0012\u0096\n\u0012\u0003\u0013\u0003\u0013\u0003\u0013", - "\u0005\u0013\u009b\n\u0013\u0003\u0014\u0003\u0014\u0003\u0014\u0003", - "\u0014\u0003\u0015\u0003\u0015\u0007\u0015\u00a3\n\u0015\f\u0015\u000e", - "\u0015\u00a6\u000b\u0015\u0003\u0015\u0003\u0015\u0003\u0016\u0003\u0016", - "\u0003\u0016\u0003\u0016\u0005\u0016\u00ae\n\u0016\u0003\u0017\u0003", - "\u0017\u0005\u0017\u00b2\n\u0017\u0003\u0018\u0003\u0018\u0003\u0018", - "\u0002\u0002\u0019\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016", - "\u0018\u001a\u001c\u001e \"$&(*,.\u0002\u0003\u0003\u0002\u0016\u0017", - "\u00bc\u00023\u0003\u0002\u0002\u0002\u0004<\u0003\u0002\u0002\u0002", - "\u0006B\u0003\u0002\u0002\u0002\bD\u0003\u0002\u0002\u0002\nI\u0003", - "\u0002\u0002\u0002\fM\u0003\u0002\u0002\u0002\u000eP\u0003\u0002\u0002", - "\u0002\u0010[\u0003\u0002\u0002\u0002\u0012]\u0003\u0002\u0002\u0002", - "\u0014j\u0003\u0002\u0002\u0002\u0016t\u0003\u0002\u0002\u0002\u0018", - "z\u0003\u0002\u0002\u0002\u001a|\u0003\u0002\u0002\u0002\u001c\u0084", - "\u0003\u0002\u0002\u0002\u001e\u0086\u0003\u0002\u0002\u0002 \u008f", - "\u0003\u0002\u0002\u0002\"\u0095\u0003\u0002\u0002\u0002$\u009a\u0003", - "\u0002\u0002\u0002&\u009c\u0003\u0002\u0002\u0002(\u00a0\u0003\u0002", - "\u0002\u0002*\u00a9\u0003\u0002\u0002\u0002,\u00b1\u0003\u0002\u0002", - "\u0002.\u00b3\u0003\u0002\u0002\u000202\u0005\u0004\u0003\u000210\u0003", - "\u0002\u0002\u000225\u0003\u0002\u0002\u000231\u0003\u0002\u0002\u0002", - "34\u0003\u0002\u0002\u000246\u0003\u0002\u0002\u000253\u0003\u0002\u0002", - "\u000267\u0007\u0002\u0002\u00037\u0003\u0003\u0002\u0002\u00028=\u0005", - "\u0006\u0004\u00029:\u0005\u0010\t\u0002:;\u0007\u0003\u0002\u0002;", - "=\u0003\u0002\u0002\u0002<8\u0003\u0002\u0002\u0002<9\u0003\u0002\u0002", - "\u0002=\u0005\u0003\u0002\u0002\u0002>C\u0005\b\u0005\u0002?C\u0005", - "\n\u0006\u0002@C\u0005\u000e\b\u0002AC\u0005\f\u0007\u0002B>\u0003\u0002", - "\u0002\u0002B?\u0003\u0002\u0002\u0002B@\u0003\u0002\u0002\u0002BA\u0003", - "\u0002\u0002\u0002C\u0007\u0003\u0002\u0002\u0002DE\u0007\u0004\u0002", - "\u0002EF\u0007\u0016\u0002\u0002FG\u0007\u0015\u0002\u0002GH\u0007\u0003", - "\u0002\u0002H\t\u0003\u0002\u0002\u0002IJ\u0007\u0005\u0002\u0002JK", - "\u0007\u0015\u0002\u0002KL\u0007\u0003\u0002\u0002L\u000b\u0003\u0002", - "\u0002\u0002MN\u0007)\u0002\u0002NO\u0007\u0015\u0002\u0002O\r\u0003", - "\u0002\u0002\u0002PQ\u0007*\u0002\u0002QR\u0007\u0016\u0002\u0002RS", - "\u0007\u0015\u0002\u0002S\u000f\u0003\u0002\u0002\u0002TU\u0005\u0018", - "\r\u0002UV\u0005\u0012\n\u0002V\\\u0003\u0002\u0002\u0002WY\u0005&\u0014", - "\u0002XZ\u0005\u0012\n\u0002YX\u0003\u0002\u0002\u0002YZ\u0003\u0002", - "\u0002\u0002Z\\\u0003\u0002\u0002\u0002[T\u0003\u0002\u0002\u0002[W", - "\u0003\u0002\u0002\u0002\\\u0011\u0003\u0002\u0002\u0002]^\u0005\u0016", - "\f\u0002^g\u0005\u0014\u000b\u0002_c\u0007\u0006\u0002\u0002`a\u0005", - "\u0016\f\u0002ab\u0005\u0014\u000b\u0002bd\u0003\u0002\u0002\u0002c", - "`\u0003\u0002\u0002\u0002cd\u0003\u0002\u0002\u0002df\u0003\u0002\u0002", - "\u0002e_\u0003\u0002\u0002\u0002fi\u0003\u0002\u0002\u0002ge\u0003\u0002", - "\u0002\u0002gh\u0003\u0002\u0002\u0002h\u0013\u0003\u0002\u0002\u0002", - "ig\u0003\u0002\u0002\u0002jo\u0005\u001c\u000f\u0002kl\u0007\u0007\u0002", - "\u0002ln\u0005\u001c\u000f\u0002mk\u0003\u0002\u0002\u0002nq\u0003\u0002", - "\u0002\u0002om\u0003\u0002\u0002\u0002op\u0003\u0002\u0002\u0002p\u0015", - "\u0003\u0002\u0002\u0002qo\u0003\u0002\u0002\u0002ru\u0005\u001a\u000e", - "\u0002su\u0007\b\u0002\u0002tr\u0003\u0002\u0002\u0002ts\u0003\u0002", - "\u0002\u0002u\u0017\u0003\u0002\u0002\u0002v{\u0005,\u0017\u0002w{\u0007", - "\u0014\u0002\u0002x{\u0005(\u0015\u0002y{\u0005\u001e\u0010\u0002zv", - "\u0003\u0002\u0002\u0002zw\u0003\u0002\u0002\u0002zx\u0003\u0002\u0002", - "\u0002zy\u0003\u0002\u0002\u0002{\u0019\u0003\u0002\u0002\u0002|}\u0005", - ",\u0017\u0002}\u001b\u0003\u0002\u0002\u0002~\u0085\u0005,\u0017\u0002", - "\u007f\u0085\u0007\u0014\u0002\u0002\u0080\u0085\u0005$\u0013\u0002", - "\u0081\u0085\u0005(\u0015\u0002\u0082\u0085\u0005&\u0014\u0002\u0083", - "\u0085\u0005\u001e\u0010\u0002\u0084~\u0003\u0002\u0002\u0002\u0084", - "\u007f\u0003\u0002\u0002\u0002\u0084\u0080\u0003\u0002\u0002\u0002\u0084", - "\u0081\u0003\u0002\u0002\u0002\u0084\u0082\u0003\u0002\u0002\u0002\u0084", - "\u0083\u0003\u0002\u0002\u0002\u0085\u001d\u0003\u0002\u0002\u0002\u0086", - "\u0087\u0007\t\u0002\u0002\u0087\u0088\u0005 \u0011\u0002\u0088\u0089", - "\u0005\u001a\u000e\u0002\u0089\u008a\u0005\"\u0012\u0002\u008a\u008b", - "\u0007\n\u0002\u0002\u008b\u001f\u0003\u0002\u0002\u0002\u008c\u0090", - "\u0005,\u0017\u0002\u008d\u0090\u0007\u0014\u0002\u0002\u008e\u0090", - "\u0005\u001e\u0010\u0002\u008f\u008c\u0003\u0002\u0002\u0002\u008f\u008d", - "\u0003\u0002\u0002\u0002\u008f\u008e\u0003\u0002\u0002\u0002\u0090!", - "\u0003\u0002\u0002\u0002\u0091\u0096\u0005,\u0017\u0002\u0092\u0096", - "\u0007\u0014\u0002\u0002\u0093\u0096\u0005$\u0013\u0002\u0094\u0096", - "\u0005\u001e\u0010\u0002\u0095\u0091\u0003\u0002\u0002\u0002\u0095\u0092", - "\u0003\u0002\u0002\u0002\u0095\u0093\u0003\u0002\u0002\u0002\u0095\u0094", - "\u0003\u0002\u0002\u0002\u0096#\u0003\u0002\u0002\u0002\u0097\u009b", - "\u0005*\u0016\u0002\u0098\u009b\u0007\u0011\u0002\u0002\u0099\u009b", - "\u0007\u0012\u0002\u0002\u009a\u0097\u0003\u0002\u0002\u0002\u009a\u0098", - "\u0003\u0002\u0002\u0002\u009a\u0099\u0003\u0002\u0002\u0002\u009b%", - "\u0003\u0002\u0002\u0002\u009c\u009d\u0007\u000b\u0002\u0002\u009d\u009e", - "\u0005\u0012\n\u0002\u009e\u009f\u0007\f\u0002\u0002\u009f\'\u0003\u0002", - "\u0002\u0002\u00a0\u00a4\u0007\r\u0002\u0002\u00a1\u00a3\u0005\u001c", - "\u000f\u0002\u00a2\u00a1\u0003\u0002\u0002\u0002\u00a3\u00a6\u0003\u0002", - "\u0002\u0002\u00a4\u00a2\u0003\u0002\u0002\u0002\u00a4\u00a5\u0003\u0002", - "\u0002\u0002\u00a5\u00a7\u0003\u0002\u0002\u0002\u00a6\u00a4\u0003\u0002", - "\u0002\u0002\u00a7\u00a8\u0007\u000e\u0002\u0002\u00a8)\u0003\u0002", - "\u0002\u0002\u00a9\u00ad\u0007\u0013\u0002\u0002\u00aa\u00ae\u0007\u0019", - "\u0002\u0002\u00ab\u00ac\u0007\u000f\u0002\u0002\u00ac\u00ae\u0005,", - "\u0017\u0002\u00ad\u00aa\u0003\u0002\u0002\u0002\u00ad\u00ab\u0003\u0002", - "\u0002\u0002\u00ad\u00ae\u0003\u0002\u0002\u0002\u00ae+\u0003\u0002", - "\u0002\u0002\u00af\u00b2\u0007\u0015\u0002\u0002\u00b0\u00b2\u0005.", - "\u0018\u0002\u00b1\u00af\u0003\u0002\u0002\u0002\u00b1\u00b0\u0003\u0002", - "\u0002\u0002\u00b2-\u0003\u0002\u0002\u0002\u00b3\u00b4\t\u0002\u0002", - "\u0002\u00b4/\u0003\u0002\u0002\u0002\u00133>'", "'['", "']'", "'('", "')'", - "'^^'" ]; - -var symbolicNames = [ null, null, null, null, null, null, null, null, null, - null, null, null, null, null, "COMMENT", "NumericLiteral", - "BooleanLiteral", "String", "BlankNode", "IRIREF", - "PNAME_NS", "PNAME_LN", "BLANK_NODE_LABEL", "LANGTAG", - "INTEGER", "DECIMAL", "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", - "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", - "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", "WS", - "ANON", "PN_CHARS_BASE", "PN_CHARS_U", "PN_CHARS", - "BASE", "PREFIX", "PN_PREFIX", "PN_LOCAL", "PLX", - "PERCENT", "HEX", "PN_LOCAL_ESC" ]; -turtlestarParser.symbolicNames = symbolicNames; - -var ruleNames = [ "turtleStarDoc", "statement", "directive", "prefixID", - "base", "sparqlBase", "sparqlPrefix", "triples", "predicateObjectList", - "objectList", "verb", "subject", "predicate", "object", - "tripleX", "subjectX", "objectX", "literal", "blankNodePropertyList", - "collection", "rdfLiteral", "iri", "prefixedName" ]; - -function turtlestarParser (input) { - antlr4.Parser.call(this, input); - this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache); - this.ruleNames = ruleNames; - this.literalNames = literalNames; - this.symbolicNames = symbolicNames; - return this; -} +import antlr4 from 'antlr4'; +import turtlestarListener from './turtlestarListener.js'; +import turtlestarVisitor from './turtlestarVisitor.js'; + + +const serializedATN = [4,1,46,180,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7, +4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12, +2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2, +20,7,20,2,21,7,21,2,22,7,22,1,0,5,0,48,8,0,10,0,12,0,51,9,0,1,0,1,0,1,1, +1,1,1,1,1,1,3,1,59,8,1,1,2,1,2,1,2,1,2,3,2,65,8,2,1,3,1,3,1,3,1,3,1,3,1, +4,1,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,3,7,88,8,7, +3,7,90,8,7,1,8,1,8,1,8,1,8,1,8,1,8,3,8,98,8,8,5,8,100,8,8,10,8,12,8,103, +9,8,1,9,1,9,1,9,5,9,108,8,9,10,9,12,9,111,9,9,1,10,1,10,3,10,115,8,10,1, +11,1,11,1,11,1,11,3,11,121,8,11,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13, +3,13,131,8,13,1,14,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,3,15,142,8,15, +1,16,1,16,1,16,1,16,3,16,148,8,16,1,17,1,17,1,17,3,17,153,8,17,1,18,1,18, +1,18,1,18,1,19,1,19,5,19,161,8,19,10,19,12,19,164,9,19,1,19,1,19,1,20,1, +20,1,20,1,20,3,20,172,8,20,1,21,1,21,3,21,176,8,21,1,22,1,22,1,22,0,0,23, +0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,0,1,1,0, +20,21,186,0,49,1,0,0,0,2,58,1,0,0,0,4,64,1,0,0,0,6,66,1,0,0,0,8,71,1,0,0, +0,10,75,1,0,0,0,12,78,1,0,0,0,14,89,1,0,0,0,16,91,1,0,0,0,18,104,1,0,0,0, +20,114,1,0,0,0,22,120,1,0,0,0,24,122,1,0,0,0,26,130,1,0,0,0,28,132,1,0,0, +0,30,141,1,0,0,0,32,147,1,0,0,0,34,152,1,0,0,0,36,154,1,0,0,0,38,158,1,0, +0,0,40,167,1,0,0,0,42,175,1,0,0,0,44,177,1,0,0,0,46,48,3,2,1,0,47,46,1,0, +0,0,48,51,1,0,0,0,49,47,1,0,0,0,49,50,1,0,0,0,50,52,1,0,0,0,51,49,1,0,0, +0,52,53,5,0,0,1,53,1,1,0,0,0,54,59,3,4,2,0,55,56,3,14,7,0,56,57,5,1,0,0, +57,59,1,0,0,0,58,54,1,0,0,0,58,55,1,0,0,0,59,3,1,0,0,0,60,65,3,6,3,0,61, +65,3,8,4,0,62,65,3,12,6,0,63,65,3,10,5,0,64,60,1,0,0,0,64,61,1,0,0,0,64, +62,1,0,0,0,64,63,1,0,0,0,65,5,1,0,0,0,66,67,5,2,0,0,67,68,5,20,0,0,68,69, +5,19,0,0,69,70,5,1,0,0,70,7,1,0,0,0,71,72,5,3,0,0,72,73,5,19,0,0,73,74,5, +1,0,0,74,9,1,0,0,0,75,76,5,39,0,0,76,77,5,19,0,0,77,11,1,0,0,0,78,79,5,40, +0,0,79,80,5,20,0,0,80,81,5,19,0,0,81,13,1,0,0,0,82,83,3,22,11,0,83,84,3, +16,8,0,84,90,1,0,0,0,85,87,3,36,18,0,86,88,3,16,8,0,87,86,1,0,0,0,87,88, +1,0,0,0,88,90,1,0,0,0,89,82,1,0,0,0,89,85,1,0,0,0,90,15,1,0,0,0,91,92,3, +20,10,0,92,101,3,18,9,0,93,97,5,4,0,0,94,95,3,20,10,0,95,96,3,18,9,0,96, +98,1,0,0,0,97,94,1,0,0,0,97,98,1,0,0,0,98,100,1,0,0,0,99,93,1,0,0,0,100, +103,1,0,0,0,101,99,1,0,0,0,101,102,1,0,0,0,102,17,1,0,0,0,103,101,1,0,0, +0,104,109,3,26,13,0,105,106,5,5,0,0,106,108,3,26,13,0,107,105,1,0,0,0,108, +111,1,0,0,0,109,107,1,0,0,0,109,110,1,0,0,0,110,19,1,0,0,0,111,109,1,0,0, +0,112,115,3,24,12,0,113,115,5,6,0,0,114,112,1,0,0,0,114,113,1,0,0,0,115, +21,1,0,0,0,116,121,3,42,21,0,117,121,5,18,0,0,118,121,3,38,19,0,119,121, +3,28,14,0,120,116,1,0,0,0,120,117,1,0,0,0,120,118,1,0,0,0,120,119,1,0,0, +0,121,23,1,0,0,0,122,123,3,42,21,0,123,25,1,0,0,0,124,131,3,42,21,0,125, +131,5,18,0,0,126,131,3,34,17,0,127,131,3,38,19,0,128,131,3,36,18,0,129,131, +3,28,14,0,130,124,1,0,0,0,130,125,1,0,0,0,130,126,1,0,0,0,130,127,1,0,0, +0,130,128,1,0,0,0,130,129,1,0,0,0,131,27,1,0,0,0,132,133,5,7,0,0,133,134, +3,30,15,0,134,135,3,24,12,0,135,136,3,32,16,0,136,137,5,8,0,0,137,29,1,0, +0,0,138,142,3,42,21,0,139,142,5,18,0,0,140,142,3,28,14,0,141,138,1,0,0,0, +141,139,1,0,0,0,141,140,1,0,0,0,142,31,1,0,0,0,143,148,3,42,21,0,144,148, +5,18,0,0,145,148,3,34,17,0,146,148,3,28,14,0,147,143,1,0,0,0,147,144,1,0, +0,0,147,145,1,0,0,0,147,146,1,0,0,0,148,33,1,0,0,0,149,153,3,40,20,0,150, +153,5,15,0,0,151,153,5,16,0,0,152,149,1,0,0,0,152,150,1,0,0,0,152,151,1, +0,0,0,153,35,1,0,0,0,154,155,5,9,0,0,155,156,3,16,8,0,156,157,5,10,0,0,157, +37,1,0,0,0,158,162,5,11,0,0,159,161,3,26,13,0,160,159,1,0,0,0,161,164,1, +0,0,0,162,160,1,0,0,0,162,163,1,0,0,0,163,165,1,0,0,0,164,162,1,0,0,0,165, +166,5,12,0,0,166,39,1,0,0,0,167,171,5,17,0,0,168,172,5,23,0,0,169,170,5, +13,0,0,170,172,3,42,21,0,171,168,1,0,0,0,171,169,1,0,0,0,171,172,1,0,0,0, +172,41,1,0,0,0,173,176,5,19,0,0,174,176,3,44,22,0,175,173,1,0,0,0,175,174, +1,0,0,0,176,43,1,0,0,0,177,178,7,0,0,0,178,45,1,0,0,0,17,49,58,64,87,89, +97,101,109,114,120,130,141,147,152,162,171,175]; + + +const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); + +const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) ); + +const sharedContextCache = new antlr4.PredictionContextCache(); + +export default class turtlestarParser extends antlr4.Parser { + + static grammarFileName = "java-escape"; + static literalNames = [ null, "'.'", "'@prefix'", "'@base'", "';'", + "','", "'a'", "'<<'", "'>>'", "'['", "']'", + "'('", "')'", "'^^'" ]; + static symbolicNames = [ null, null, null, null, null, null, null, null, + null, null, null, null, null, null, "COMMENT", + "NumericLiteral", "BooleanLiteral", "String", + "BlankNode", "IRIREF", "PNAME_NS", "PNAME_LN", + "BLANK_NODE_LABEL", "LANGTAG", "INTEGER", "DECIMAL", + "DOUBLE", "EXPONENT", "STRING_LITERAL_LONG_SINGLE_QUOTE", + "STRING_LITERAL_LONG_QUOTE", "STRING_LITERAL_QUOTE", + "STRING_LITERAL_SINGLE_QUOTE", "UCHAR", "ECHAR", + "WS", "ANON", "PN_CHARS_BASE", "PN_CHARS_U", + "PN_CHARS", "BASE", "PREFIX", "PN_PREFIX", + "PN_LOCAL", "PLX", "PERCENT", "HEX", "PN_LOCAL_ESC" ]; + static ruleNames = [ "turtleStarDoc", "statement", "directive", "prefixID", + "base", "sparqlBase", "sparqlPrefix", "triples", + "predicateObjectList", "objectList", "verb", "subject", + "predicate", "object", "tripleX", "subjectX", "objectX", + "literal", "blankNodePropertyList", "collection", + "rdfLiteral", "iri", "prefixedName" ]; + + constructor(input) { + super(input); + this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache); + this.ruleNames = turtlestarParser.ruleNames; + this.literalNames = turtlestarParser.literalNames; + this.symbolicNames = turtlestarParser.symbolicNames; + } + + get atn() { + return atn; + } + -turtlestarParser.prototype = Object.create(antlr4.Parser.prototype); -turtlestarParser.prototype.constructor = turtlestarParser; -Object.defineProperty(turtlestarParser.prototype, "atn", { - get : function() { - return atn; + turtleStarDoc() { + let localctx = new TurtleStarDocContext(this, this._ctx, this.state); + this.enterRule(localctx, 0, turtlestarParser.RULE_turtleStarDoc); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 49; + this._errHandler.sync(this); + _la = this._input.LA(1); + while((((_la) & ~0x1f) == 0 && ((1 << _la) & 3934860) !== 0) || _la===39 || _la===40) { + this.state = 46; + this.statement(); + this.state = 51; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 52; + this.match(turtlestarParser.EOF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + statement() { + let localctx = new StatementContext(this, this._ctx, this.state); + this.enterRule(localctx, 2, turtlestarParser.RULE_statement); + try { + this.state = 58; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 2: + case 3: + case 39: + case 40: + this.enterOuterAlt(localctx, 1); + this.state = 54; + this.directive(); + break; + case 7: + case 9: + case 11: + case 18: + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 2); + this.state = 55; + this.triples(); + this.state = 56; + this.match(turtlestarParser.T__0); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + directive() { + let localctx = new DirectiveContext(this, this._ctx, this.state); + this.enterRule(localctx, 4, turtlestarParser.RULE_directive); + try { + this.state = 64; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 2: + this.enterOuterAlt(localctx, 1); + this.state = 60; + this.prefixID(); + break; + case 3: + this.enterOuterAlt(localctx, 2); + this.state = 61; + this.base(); + break; + case 40: + this.enterOuterAlt(localctx, 3); + this.state = 62; + this.sparqlPrefix(); + break; + case 39: + this.enterOuterAlt(localctx, 4); + this.state = 63; + this.sparqlBase(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + prefixID() { + let localctx = new PrefixIDContext(this, this._ctx, this.state); + this.enterRule(localctx, 6, turtlestarParser.RULE_prefixID); + try { + this.enterOuterAlt(localctx, 1); + this.state = 66; + this.match(turtlestarParser.T__1); + this.state = 67; + this.match(turtlestarParser.PNAME_NS); + this.state = 68; + this.match(turtlestarParser.IRIREF); + this.state = 69; + this.match(turtlestarParser.T__0); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + base() { + let localctx = new BaseContext(this, this._ctx, this.state); + this.enterRule(localctx, 8, turtlestarParser.RULE_base); + try { + this.enterOuterAlt(localctx, 1); + this.state = 71; + this.match(turtlestarParser.T__2); + this.state = 72; + this.match(turtlestarParser.IRIREF); + this.state = 73; + this.match(turtlestarParser.T__0); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlBase() { + let localctx = new SparqlBaseContext(this, this._ctx, this.state); + this.enterRule(localctx, 10, turtlestarParser.RULE_sparqlBase); + try { + this.enterOuterAlt(localctx, 1); + this.state = 75; + this.match(turtlestarParser.BASE); + this.state = 76; + this.match(turtlestarParser.IRIREF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + sparqlPrefix() { + let localctx = new SparqlPrefixContext(this, this._ctx, this.state); + this.enterRule(localctx, 12, turtlestarParser.RULE_sparqlPrefix); + try { + this.enterOuterAlt(localctx, 1); + this.state = 78; + this.match(turtlestarParser.PREFIX); + this.state = 79; + this.match(turtlestarParser.PNAME_NS); + this.state = 80; + this.match(turtlestarParser.IRIREF); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + triples() { + let localctx = new TriplesContext(this, this._ctx, this.state); + this.enterRule(localctx, 14, turtlestarParser.RULE_triples); + var _la = 0; // Token type + try { + this.state = 89; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 7: + case 11: + case 18: + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 1); + this.state = 82; + this.subject(); + this.state = 83; + this.predicateObjectList(); + break; + case 9: + this.enterOuterAlt(localctx, 2); + this.state = 85; + this.blankNodePropertyList(); + this.state = 87; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3670080) !== 0)) { + this.state = 86; + this.predicateObjectList(); + } + + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + predicateObjectList() { + let localctx = new PredicateObjectListContext(this, this._ctx, this.state); + this.enterRule(localctx, 16, turtlestarParser.RULE_predicateObjectList); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 91; + this.verb(); + this.state = 92; + this.objectList(); + this.state = 101; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(_la===4) { + this.state = 93; + this.match(turtlestarParser.T__3); + this.state = 97; + this._errHandler.sync(this); + _la = this._input.LA(1); + if((((_la) & ~0x1f) == 0 && ((1 << _la) & 3670080) !== 0)) { + this.state = 94; + this.verb(); + this.state = 95; + this.objectList(); + } + + this.state = 103; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + objectList() { + let localctx = new ObjectListContext(this, this._ctx, this.state); + this.enterRule(localctx, 18, turtlestarParser.RULE_objectList); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 104; + this.object(); + this.state = 109; + this._errHandler.sync(this); + _la = this._input.LA(1); + while(_la===5) { + this.state = 105; + this.match(turtlestarParser.T__4); + this.state = 106; + this.object(); + this.state = 111; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + verb() { + let localctx = new VerbContext(this, this._ctx, this.state); + this.enterRule(localctx, 20, turtlestarParser.RULE_verb); + try { + this.state = 114; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 1); + this.state = 112; + this.predicate(); + break; + case 6: + this.enterOuterAlt(localctx, 2); + this.state = 113; + this.match(turtlestarParser.T__5); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + subject() { + let localctx = new SubjectContext(this, this._ctx, this.state); + this.enterRule(localctx, 22, turtlestarParser.RULE_subject); + try { + this.state = 120; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 1); + this.state = 116; + this.iri(); + break; + case 18: + this.enterOuterAlt(localctx, 2); + this.state = 117; + this.match(turtlestarParser.BlankNode); + break; + case 11: + this.enterOuterAlt(localctx, 3); + this.state = 118; + this.collection(); + break; + case 7: + this.enterOuterAlt(localctx, 4); + this.state = 119; + this.tripleX(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + predicate() { + let localctx = new PredicateContext(this, this._ctx, this.state); + this.enterRule(localctx, 24, turtlestarParser.RULE_predicate); + try { + this.enterOuterAlt(localctx, 1); + this.state = 122; + this.iri(); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + object() { + let localctx = new ObjectContext(this, this._ctx, this.state); + this.enterRule(localctx, 26, turtlestarParser.RULE_object); + try { + this.state = 130; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 1); + this.state = 124; + this.iri(); + break; + case 18: + this.enterOuterAlt(localctx, 2); + this.state = 125; + this.match(turtlestarParser.BlankNode); + break; + case 15: + case 16: + case 17: + this.enterOuterAlt(localctx, 3); + this.state = 126; + this.literal(); + break; + case 11: + this.enterOuterAlt(localctx, 4); + this.state = 127; + this.collection(); + break; + case 9: + this.enterOuterAlt(localctx, 5); + this.state = 128; + this.blankNodePropertyList(); + break; + case 7: + this.enterOuterAlt(localctx, 6); + this.state = 129; + this.tripleX(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + tripleX() { + let localctx = new TripleXContext(this, this._ctx, this.state); + this.enterRule(localctx, 28, turtlestarParser.RULE_tripleX); + try { + this.enterOuterAlt(localctx, 1); + this.state = 132; + this.match(turtlestarParser.T__6); + this.state = 133; + this.subjectX(); + this.state = 134; + this.predicate(); + this.state = 135; + this.objectX(); + this.state = 136; + this.match(turtlestarParser.T__7); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + subjectX() { + let localctx = new SubjectXContext(this, this._ctx, this.state); + this.enterRule(localctx, 30, turtlestarParser.RULE_subjectX); + try { + this.state = 141; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 1); + this.state = 138; + this.iri(); + break; + case 18: + this.enterOuterAlt(localctx, 2); + this.state = 139; + this.match(turtlestarParser.BlankNode); + break; + case 7: + this.enterOuterAlt(localctx, 3); + this.state = 140; + this.tripleX(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + objectX() { + let localctx = new ObjectXContext(this, this._ctx, this.state); + this.enterRule(localctx, 32, turtlestarParser.RULE_objectX); + try { + this.state = 147; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 19: + case 20: + case 21: + this.enterOuterAlt(localctx, 1); + this.state = 143; + this.iri(); + break; + case 18: + this.enterOuterAlt(localctx, 2); + this.state = 144; + this.match(turtlestarParser.BlankNode); + break; + case 15: + case 16: + case 17: + this.enterOuterAlt(localctx, 3); + this.state = 145; + this.literal(); + break; + case 7: + this.enterOuterAlt(localctx, 4); + this.state = 146; + this.tripleX(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + literal() { + let localctx = new LiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 34, turtlestarParser.RULE_literal); + try { + this.state = 152; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 17: + this.enterOuterAlt(localctx, 1); + this.state = 149; + this.rdfLiteral(); + break; + case 15: + this.enterOuterAlt(localctx, 2); + this.state = 150; + this.match(turtlestarParser.NumericLiteral); + break; + case 16: + this.enterOuterAlt(localctx, 3); + this.state = 151; + this.match(turtlestarParser.BooleanLiteral); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + blankNodePropertyList() { + let localctx = new BlankNodePropertyListContext(this, this._ctx, this.state); + this.enterRule(localctx, 36, turtlestarParser.RULE_blankNodePropertyList); + try { + this.enterOuterAlt(localctx, 1); + this.state = 154; + this.match(turtlestarParser.T__8); + this.state = 155; + this.predicateObjectList(); + this.state = 156; + this.match(turtlestarParser.T__9); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + collection() { + let localctx = new CollectionContext(this, this._ctx, this.state); + this.enterRule(localctx, 38, turtlestarParser.RULE_collection); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 158; + this.match(turtlestarParser.T__10); + this.state = 162; + this._errHandler.sync(this); + _la = this._input.LA(1); + while((((_la) & ~0x1f) == 0 && ((1 << _la) & 4164224) !== 0)) { + this.state = 159; + this.object(); + this.state = 164; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 165; + this.match(turtlestarParser.T__11); + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + rdfLiteral() { + let localctx = new RdfLiteralContext(this, this._ctx, this.state); + this.enterRule(localctx, 40, turtlestarParser.RULE_rdfLiteral); + try { + this.enterOuterAlt(localctx, 1); + this.state = 167; + this.match(turtlestarParser.String); + this.state = 171; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case 23: + this.state = 168; + this.match(turtlestarParser.LANGTAG); + break; + case 13: + this.state = 169; + this.match(turtlestarParser.T__12); + this.state = 170; + this.iri(); + break; + case 1: + case 4: + case 5: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + break; + default: + break; + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + iri() { + let localctx = new IriContext(this, this._ctx, this.state); + this.enterRule(localctx, 42, turtlestarParser.RULE_iri); + try { + this.state = 175; + this._errHandler.sync(this); + switch(this._input.LA(1)) { + case 19: + this.enterOuterAlt(localctx, 1); + this.state = 173; + this.match(turtlestarParser.IRIREF); + break; + case 20: + case 21: + this.enterOuterAlt(localctx, 2); + this.state = 174; + this.prefixedName(); + break; + default: + throw new antlr4.error.NoViableAltException(this); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + + + + prefixedName() { + let localctx = new PrefixedNameContext(this, this._ctx, this.state); + this.enterRule(localctx, 44, turtlestarParser.RULE_prefixedName); + var _la = 0; // Token type + try { + this.enterOuterAlt(localctx, 1); + this.state = 177; + _la = this._input.LA(1); + if(!(_la===20 || _la===21)) { + this._errHandler.recoverInline(this); + } + else { + this._errHandler.reportMatch(this); + this.consume(); + } + } catch (re) { + if(re instanceof antlr4.error.RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; } -}); + + +} turtlestarParser.EOF = antlr4.Token.EOF; turtlestarParser.T__0 = 1; @@ -237,2074 +1069,1183 @@ turtlestarParser.RULE_rdfLiteral = 20; turtlestarParser.RULE_iri = 21; turtlestarParser.RULE_prefixedName = 22; -function TurtleStarDocContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; +class TurtleStarDocContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_turtleStarDoc; + } + + EOF() { + return this.getToken(turtlestarParser.EOF, 0); + }; + + statement = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(StatementContext); + } else { + return this.getTypedRuleContext(StatementContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterTurtleStarDoc(this); + } + } + + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitTurtleStarDoc(this); + } } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; + + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitTurtleStarDoc(this); + } else { + return visitor.visitChildren(this); + } } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_turtleStarDoc; - return this; + + } -TurtleStarDocContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -TurtleStarDocContext.prototype.constructor = TurtleStarDocContext; -TurtleStarDocContext.prototype.EOF = function() { - return this.getToken(turtlestarParser.EOF, 0); -}; -TurtleStarDocContext.prototype.statement = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(StatementContext); - } else { - return this.getTypedRuleContext(StatementContext,i); +class StatementContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_statement; } -}; -TurtleStarDocContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterTurtleStarDoc(this); + directive() { + return this.getTypedRuleContext(DirectiveContext,0); + }; + + triples() { + return this.getTypedRuleContext(TriplesContext,0); + }; + + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterStatement(this); + } } -}; -TurtleStarDocContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitTurtleStarDoc(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitStatement(this); + } } -}; -TurtleStarDocContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitTurtleStarDoc(this); - } else { - return visitor.visitChildren(this); - } -}; + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitStatement(this); + } else { + return visitor.visitChildren(this); + } + } +} -turtlestarParser.TurtleStarDocContext = TurtleStarDocContext; -turtlestarParser.prototype.turtleStarDoc = function() { +class DirectiveContext extends antlr4.ParserRuleContext { - var localctx = new TurtleStarDocContext(this, this._ctx, this.state); - this.enterRule(localctx, 0, turtlestarParser.RULE_turtleStarDoc); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 49; - this._errHandler.sync(this); - _la = this._input.LA(1); - while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__1) | (1 << turtlestarParser.T__2) | (1 << turtlestarParser.T__6) | (1 << turtlestarParser.T__8) | (1 << turtlestarParser.T__10) | (1 << turtlestarParser.BlankNode) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0) || _la===turtlestarParser.BASE || _la===turtlestarParser.PREFIX) { - this.state = 46; - this.statement(); - this.state = 51; - this._errHandler.sync(this); - _la = this._input.LA(1); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; } - this.state = 52; - this.match(turtlestarParser.EOF); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_directive; } - return localctx; -}; -function StatementContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_statement; - return this; -} + prefixID() { + return this.getTypedRuleContext(PrefixIDContext,0); + }; -StatementContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -StatementContext.prototype.constructor = StatementContext; + base() { + return this.getTypedRuleContext(BaseContext,0); + }; -StatementContext.prototype.directive = function() { - return this.getTypedRuleContext(DirectiveContext,0); -}; + sparqlPrefix() { + return this.getTypedRuleContext(SparqlPrefixContext,0); + }; -StatementContext.prototype.triples = function() { - return this.getTypedRuleContext(TriplesContext,0); -}; + sparqlBase() { + return this.getTypedRuleContext(SparqlBaseContext,0); + }; -StatementContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterStatement(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterDirective(this); + } } -}; -StatementContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitStatement(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitDirective(this); + } } -}; -StatementContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitStatement(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.StatementContext = StatementContext; - -turtlestarParser.prototype.statement = function() { - - var localctx = new StatementContext(this, this._ctx, this.state); - this.enterRule(localctx, 2, turtlestarParser.RULE_statement); - try { - this.state = 58; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.T__1: - case turtlestarParser.T__2: - case turtlestarParser.BASE: - case turtlestarParser.PREFIX: - this.enterOuterAlt(localctx, 1); - this.state = 54; - this.directive(); - break; - case turtlestarParser.T__6: - case turtlestarParser.T__8: - case turtlestarParser.T__10: - case turtlestarParser.BlankNode: - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 2); - this.state = 55; - this.triples(); - this.state = 56; - this.match(turtlestarParser.T__0); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitDirective(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function DirectiveContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_directive; - return this; + + } -DirectiveContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -DirectiveContext.prototype.constructor = DirectiveContext; -DirectiveContext.prototype.prefixID = function() { - return this.getTypedRuleContext(PrefixIDContext,0); -}; -DirectiveContext.prototype.base = function() { - return this.getTypedRuleContext(BaseContext,0); -}; +class PrefixIDContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_prefixID; + } -DirectiveContext.prototype.sparqlPrefix = function() { - return this.getTypedRuleContext(SparqlPrefixContext,0); -}; + PNAME_NS() { + return this.getToken(turtlestarParser.PNAME_NS, 0); + }; -DirectiveContext.prototype.sparqlBase = function() { - return this.getTypedRuleContext(SparqlBaseContext,0); -}; + IRIREF() { + return this.getToken(turtlestarParser.IRIREF, 0); + }; -DirectiveContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterDirective(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterPrefixID(this); + } } -}; -DirectiveContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitDirective(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitPrefixID(this); + } } -}; -DirectiveContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitDirective(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.DirectiveContext = DirectiveContext; - -turtlestarParser.prototype.directive = function() { - - var localctx = new DirectiveContext(this, this._ctx, this.state); - this.enterRule(localctx, 4, turtlestarParser.RULE_directive); - try { - this.state = 64; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.T__1: - this.enterOuterAlt(localctx, 1); - this.state = 60; - this.prefixID(); - break; - case turtlestarParser.T__2: - this.enterOuterAlt(localctx, 2); - this.state = 61; - this.base(); - break; - case turtlestarParser.PREFIX: - this.enterOuterAlt(localctx, 3); - this.state = 62; - this.sparqlPrefix(); - break; - case turtlestarParser.BASE: - this.enterOuterAlt(localctx, 4); - this.state = 63; - this.sparqlBase(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitPrefixID(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PrefixIDContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_prefixID; - return this; -} -PrefixIDContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PrefixIDContext.prototype.constructor = PrefixIDContext; -PrefixIDContext.prototype.PNAME_NS = function() { - return this.getToken(turtlestarParser.PNAME_NS, 0); -}; +} -PrefixIDContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; -PrefixIDContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPrefixID(this); - } -}; -PrefixIDContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPrefixID(this); - } -}; +class BaseContext extends antlr4.ParserRuleContext { -PrefixIDContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPrefixID(this); - } else { - return visitor.visitChildren(this); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_base; } -}; - - + IRIREF() { + return this.getToken(turtlestarParser.IRIREF, 0); + }; -turtlestarParser.PrefixIDContext = PrefixIDContext; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterBase(this); + } + } -turtlestarParser.prototype.prefixID = function() { + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitBase(this); + } + } - var localctx = new PrefixIDContext(this, this._ctx, this.state); - this.enterRule(localctx, 6, turtlestarParser.RULE_prefixID); - try { - this.enterOuterAlt(localctx, 1); - this.state = 66; - this.match(turtlestarParser.T__1); - this.state = 67; - this.match(turtlestarParser.PNAME_NS); - this.state = 68; - this.match(turtlestarParser.IRIREF); - this.state = 69; - this.match(turtlestarParser.T__0); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitBase(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function BaseContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_base; - return this; -} -BaseContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -BaseContext.prototype.constructor = BaseContext; -BaseContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; +} -BaseContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterBase(this); - } -}; -BaseContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitBase(this); - } -}; -BaseContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitBase(this); - } else { - return visitor.visitChildren(this); - } -}; +class SparqlBaseContext extends antlr4.ParserRuleContext { + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_sparqlBase; + } + BASE() { + return this.getToken(turtlestarParser.BASE, 0); + }; + IRIREF() { + return this.getToken(turtlestarParser.IRIREF, 0); + }; -turtlestarParser.BaseContext = BaseContext; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterSparqlBase(this); + } + } -turtlestarParser.prototype.base = function() { + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitSparqlBase(this); + } + } - var localctx = new BaseContext(this, this._ctx, this.state); - this.enterRule(localctx, 8, turtlestarParser.RULE_base); - try { - this.enterOuterAlt(localctx, 1); - this.state = 71; - this.match(turtlestarParser.T__2); - this.state = 72; - this.match(turtlestarParser.IRIREF); - this.state = 73; - this.match(turtlestarParser.T__0); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitSparqlBase(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SparqlBaseContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_sparqlBase; - return this; -} -SparqlBaseContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SparqlBaseContext.prototype.constructor = SparqlBaseContext; -SparqlBaseContext.prototype.BASE = function() { - return this.getToken(turtlestarParser.BASE, 0); -}; +} -SparqlBaseContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; -SparqlBaseContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSparqlBase(this); - } -}; -SparqlBaseContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSparqlBase(this); - } -}; +class SparqlPrefixContext extends antlr4.ParserRuleContext { -SparqlBaseContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSparqlBase(this); - } else { - return visitor.visitChildren(this); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_sparqlPrefix; } -}; + PREFIX() { + return this.getToken(turtlestarParser.PREFIX, 0); + }; + PNAME_NS() { + return this.getToken(turtlestarParser.PNAME_NS, 0); + }; + IRIREF() { + return this.getToken(turtlestarParser.IRIREF, 0); + }; -turtlestarParser.SparqlBaseContext = SparqlBaseContext; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterSparqlPrefix(this); + } + } -turtlestarParser.prototype.sparqlBase = function() { + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitSparqlPrefix(this); + } + } - var localctx = new SparqlBaseContext(this, this._ctx, this.state); - this.enterRule(localctx, 10, turtlestarParser.RULE_sparqlBase); - try { - this.enterOuterAlt(localctx, 1); - this.state = 75; - this.match(turtlestarParser.BASE); - this.state = 76; - this.match(turtlestarParser.IRIREF); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitSparqlPrefix(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SparqlPrefixContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_sparqlPrefix; - return this; -} -SparqlPrefixContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SparqlPrefixContext.prototype.constructor = SparqlPrefixContext; -SparqlPrefixContext.prototype.PREFIX = function() { - return this.getToken(turtlestarParser.PREFIX, 0); -}; +} -SparqlPrefixContext.prototype.PNAME_NS = function() { - return this.getToken(turtlestarParser.PNAME_NS, 0); -}; -SparqlPrefixContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; -SparqlPrefixContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSparqlPrefix(this); - } -}; +class TriplesContext extends antlr4.ParserRuleContext { -SparqlPrefixContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSparqlPrefix(this); - } -}; - -SparqlPrefixContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSparqlPrefix(this); - } else { - return visitor.visitChildren(this); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_triples; } -}; + subject() { + return this.getTypedRuleContext(SubjectContext,0); + }; + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; + blankNodePropertyList() { + return this.getTypedRuleContext(BlankNodePropertyListContext,0); + }; -turtlestarParser.SparqlPrefixContext = SparqlPrefixContext; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterTriples(this); + } + } -turtlestarParser.prototype.sparqlPrefix = function() { + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitTriples(this); + } + } - var localctx = new SparqlPrefixContext(this, this._ctx, this.state); - this.enterRule(localctx, 12, turtlestarParser.RULE_sparqlPrefix); - try { - this.enterOuterAlt(localctx, 1); - this.state = 78; - this.match(turtlestarParser.PREFIX); - this.state = 79; - this.match(turtlestarParser.PNAME_NS); - this.state = 80; - this.match(turtlestarParser.IRIREF); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitTriples(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function TriplesContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_triples; - return this; + + } -TriplesContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -TriplesContext.prototype.constructor = TriplesContext; -TriplesContext.prototype.subject = function() { - return this.getTypedRuleContext(SubjectContext,0); -}; -TriplesContext.prototype.predicateObjectList = function() { - return this.getTypedRuleContext(PredicateObjectListContext,0); -}; +class PredicateObjectListContext extends antlr4.ParserRuleContext { -TriplesContext.prototype.blankNodePropertyList = function() { - return this.getTypedRuleContext(BlankNodePropertyListContext,0); -}; + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_predicateObjectList; + } -TriplesContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterTriples(this); + verb = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(VerbContext); + } else { + return this.getTypedRuleContext(VerbContext,i); + } + }; + + objectList = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectListContext); + } else { + return this.getTypedRuleContext(ObjectListContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterPredicateObjectList(this); + } } -}; -TriplesContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitTriples(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitPredicateObjectList(this); + } } -}; -TriplesContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitTriples(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.TriplesContext = TriplesContext; - -turtlestarParser.prototype.triples = function() { - - var localctx = new TriplesContext(this, this._ctx, this.state); - this.enterRule(localctx, 14, turtlestarParser.RULE_triples); - var _la = 0; // Token type - try { - this.state = 89; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.T__6: - case turtlestarParser.T__10: - case turtlestarParser.BlankNode: - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 82; - this.subject(); - this.state = 83; - this.predicateObjectList(); - break; - case turtlestarParser.T__8: - this.enterOuterAlt(localctx, 2); - this.state = 85; - this.blankNodePropertyList(); - this.state = 87; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__5) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0)) { - this.state = 86; - this.predicateObjectList(); - } - - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitPredicateObjectList(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PredicateObjectListContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_predicateObjectList; - return this; + + } -PredicateObjectListContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PredicateObjectListContext.prototype.constructor = PredicateObjectListContext; -PredicateObjectListContext.prototype.verb = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(VerbContext); - } else { - return this.getTypedRuleContext(VerbContext,i); - } -}; -PredicateObjectListContext.prototype.objectList = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectListContext); - } else { - return this.getTypedRuleContext(ObjectListContext,i); +class ObjectListContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_objectList; } -}; -PredicateObjectListContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPredicateObjectList(this); + object = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectContext); + } else { + return this.getTypedRuleContext(ObjectContext,i); + } + }; + + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterObjectList(this); + } } -}; -PredicateObjectListContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPredicateObjectList(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitObjectList(this); + } } -}; -PredicateObjectListContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPredicateObjectList(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.PredicateObjectListContext = PredicateObjectListContext; - -turtlestarParser.prototype.predicateObjectList = function() { - - var localctx = new PredicateObjectListContext(this, this._ctx, this.state); - this.enterRule(localctx, 16, turtlestarParser.RULE_predicateObjectList); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 91; - this.verb(); - this.state = 92; - this.objectList(); - this.state = 101; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(_la===turtlestarParser.T__3) { - this.state = 93; - this.match(turtlestarParser.T__3); - this.state = 97; - this._errHandler.sync(this); - _la = this._input.LA(1); - if((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__5) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0)) { - this.state = 94; - this.verb(); - this.state = 95; - this.objectList(); - } - - this.state = 103; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitObjectList(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function ObjectListContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_objectList; - return this; + + } -ObjectListContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -ObjectListContext.prototype.constructor = ObjectListContext; -ObjectListContext.prototype.object = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectContext); - } else { - return this.getTypedRuleContext(ObjectContext,i); + +class VerbContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_verb; } -}; -ObjectListContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterObjectList(this); + predicate() { + return this.getTypedRuleContext(PredicateContext,0); + }; + + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterVerb(this); + } } -}; -ObjectListContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitObjectList(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitVerb(this); + } } -}; -ObjectListContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitObjectList(this); - } else { - return visitor.visitChildren(this); - } -}; + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitVerb(this); + } else { + return visitor.visitChildren(this); + } + } +} -turtlestarParser.ObjectListContext = ObjectListContext; -turtlestarParser.prototype.objectList = function() { +class SubjectContext extends antlr4.ParserRuleContext { - var localctx = new ObjectListContext(this, this._ctx, this.state); - this.enterRule(localctx, 18, turtlestarParser.RULE_objectList); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 104; - this.object(); - this.state = 109; - this._errHandler.sync(this); - _la = this._input.LA(1); - while(_la===turtlestarParser.T__4) { - this.state = 105; - this.match(turtlestarParser.T__4); - this.state = 106; - this.object(); - this.state = 111; - this._errHandler.sync(this); - _la = this._input.LA(1); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_subject; } - return localctx; -}; -function VerbContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_verb; - return this; -} + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + BlankNode() { + return this.getToken(turtlestarParser.BlankNode, 0); + }; -VerbContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -VerbContext.prototype.constructor = VerbContext; + collection() { + return this.getTypedRuleContext(CollectionContext,0); + }; -VerbContext.prototype.predicate = function() { - return this.getTypedRuleContext(PredicateContext,0); -}; + tripleX() { + return this.getTypedRuleContext(TripleXContext,0); + }; -VerbContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterVerb(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterSubject(this); + } } -}; -VerbContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitVerb(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitSubject(this); + } } -}; -VerbContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitVerb(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.VerbContext = VerbContext; - -turtlestarParser.prototype.verb = function() { - - var localctx = new VerbContext(this, this._ctx, this.state); - this.enterRule(localctx, 20, turtlestarParser.RULE_verb); - try { - this.state = 114; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 112; - this.predicate(); - break; - case turtlestarParser.T__5: - this.enterOuterAlt(localctx, 2); - this.state = 113; - this.match(turtlestarParser.T__5); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitSubject(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SubjectContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_subject; - return this; + + } -SubjectContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SubjectContext.prototype.constructor = SubjectContext; -SubjectContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; -SubjectContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; +class PredicateContext extends antlr4.ParserRuleContext { -SubjectContext.prototype.collection = function() { - return this.getTypedRuleContext(CollectionContext,0); -}; + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_predicate; + } -SubjectContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; + iri() { + return this.getTypedRuleContext(IriContext,0); + }; -SubjectContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSubject(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterPredicate(this); + } } -}; -SubjectContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSubject(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitPredicate(this); + } } -}; -SubjectContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSubject(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.SubjectContext = SubjectContext; - -turtlestarParser.prototype.subject = function() { - - var localctx = new SubjectContext(this, this._ctx, this.state); - this.enterRule(localctx, 22, turtlestarParser.RULE_subject); - try { - this.state = 120; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 116; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 117; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.T__10: - this.enterOuterAlt(localctx, 3); - this.state = 118; - this.collection(); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 4); - this.state = 119; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitPredicate(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PredicateContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_predicate; - return this; -} -PredicateContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PredicateContext.prototype.constructor = PredicateContext; -PredicateContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; +} -PredicateContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPredicate(this); - } -}; -PredicateContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPredicate(this); - } -}; -PredicateContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPredicate(this); - } else { - return visitor.visitChildren(this); +class ObjectContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_object; } -}; + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + BlankNode() { + return this.getToken(turtlestarParser.BlankNode, 0); + }; + literal() { + return this.getTypedRuleContext(LiteralContext,0); + }; -turtlestarParser.PredicateContext = PredicateContext; + collection() { + return this.getTypedRuleContext(CollectionContext,0); + }; -turtlestarParser.prototype.predicate = function() { + blankNodePropertyList() { + return this.getTypedRuleContext(BlankNodePropertyListContext,0); + }; - var localctx = new PredicateContext(this, this._ctx, this.state); - this.enterRule(localctx, 24, turtlestarParser.RULE_predicate); - try { - this.enterOuterAlt(localctx, 1); - this.state = 122; - this.iri(); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); - } - return localctx; -}; + tripleX() { + return this.getTypedRuleContext(TripleXContext,0); + }; -function ObjectContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterObject(this); + } } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; + + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitObject(this); + } } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_object; - return this; + + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitObject(this); + } else { + return visitor.visitChildren(this); + } + } + + } -ObjectContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -ObjectContext.prototype.constructor = ObjectContext; -ObjectContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; -ObjectContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; +class TripleXContext extends antlr4.ParserRuleContext { -ObjectContext.prototype.literal = function() { - return this.getTypedRuleContext(LiteralContext,0); -}; + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_tripleX; + } -ObjectContext.prototype.collection = function() { - return this.getTypedRuleContext(CollectionContext,0); -}; + subjectX() { + return this.getTypedRuleContext(SubjectXContext,0); + }; -ObjectContext.prototype.blankNodePropertyList = function() { - return this.getTypedRuleContext(BlankNodePropertyListContext,0); -}; + predicate() { + return this.getTypedRuleContext(PredicateContext,0); + }; -ObjectContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; + objectX() { + return this.getTypedRuleContext(ObjectXContext,0); + }; -ObjectContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterObject(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterTripleX(this); + } } -}; -ObjectContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitObject(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitTripleX(this); + } } -}; -ObjectContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitObject(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.ObjectContext = ObjectContext; - -turtlestarParser.prototype.object = function() { - - var localctx = new ObjectContext(this, this._ctx, this.state); - this.enterRule(localctx, 26, turtlestarParser.RULE_object); - try { - this.state = 130; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 124; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 125; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.NumericLiteral: - case turtlestarParser.BooleanLiteral: - case turtlestarParser.String: - this.enterOuterAlt(localctx, 3); - this.state = 126; - this.literal(); - break; - case turtlestarParser.T__10: - this.enterOuterAlt(localctx, 4); - this.state = 127; - this.collection(); - break; - case turtlestarParser.T__8: - this.enterOuterAlt(localctx, 5); - this.state = 128; - this.blankNodePropertyList(); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 6); - this.state = 129; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitTripleX(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function TripleXContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_tripleX; - return this; + + } -TripleXContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -TripleXContext.prototype.constructor = TripleXContext; -TripleXContext.prototype.subjectX = function() { - return this.getTypedRuleContext(SubjectXContext,0); -}; -TripleXContext.prototype.predicate = function() { - return this.getTypedRuleContext(PredicateContext,0); -}; +class SubjectXContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_subjectX; + } + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + BlankNode() { + return this.getToken(turtlestarParser.BlankNode, 0); + }; -TripleXContext.prototype.objectX = function() { - return this.getTypedRuleContext(ObjectXContext,0); -}; + tripleX() { + return this.getTypedRuleContext(TripleXContext,0); + }; -TripleXContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterTripleX(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterSubjectX(this); + } } -}; -TripleXContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitTripleX(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitSubjectX(this); + } } -}; -TripleXContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitTripleX(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.TripleXContext = TripleXContext; - -turtlestarParser.prototype.tripleX = function() { - - var localctx = new TripleXContext(this, this._ctx, this.state); - this.enterRule(localctx, 28, turtlestarParser.RULE_tripleX); - try { - this.enterOuterAlt(localctx, 1); - this.state = 132; - this.match(turtlestarParser.T__6); - this.state = 133; - this.subjectX(); - this.state = 134; - this.predicate(); - this.state = 135; - this.objectX(); - this.state = 136; - this.match(turtlestarParser.T__7); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitSubjectX(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function SubjectXContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_subjectX; - return this; + + } -SubjectXContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -SubjectXContext.prototype.constructor = SubjectXContext; -SubjectXContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; -SubjectXContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; +class ObjectXContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_objectX; + } + + iri() { + return this.getTypedRuleContext(IriContext,0); + }; + + BlankNode() { + return this.getToken(turtlestarParser.BlankNode, 0); + }; + + literal() { + return this.getTypedRuleContext(LiteralContext,0); + }; -SubjectXContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; + tripleX() { + return this.getTypedRuleContext(TripleXContext,0); + }; -SubjectXContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterSubjectX(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterObjectX(this); + } } -}; -SubjectXContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitSubjectX(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitObjectX(this); + } } -}; -SubjectXContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitSubjectX(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.SubjectXContext = SubjectXContext; - -turtlestarParser.prototype.subjectX = function() { - - var localctx = new SubjectXContext(this, this._ctx, this.state); - this.enterRule(localctx, 30, turtlestarParser.RULE_subjectX); - try { - this.state = 141; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 138; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 139; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 3); - this.state = 140; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitObjectX(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function ObjectXContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_objectX; - return this; + + } -ObjectXContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -ObjectXContext.prototype.constructor = ObjectXContext; -ObjectXContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; -ObjectXContext.prototype.BlankNode = function() { - return this.getToken(turtlestarParser.BlankNode, 0); -}; +class LiteralContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_literal; + } + + rdfLiteral() { + return this.getTypedRuleContext(RdfLiteralContext,0); + }; -ObjectXContext.prototype.literal = function() { - return this.getTypedRuleContext(LiteralContext,0); -}; + NumericLiteral() { + return this.getToken(turtlestarParser.NumericLiteral, 0); + }; -ObjectXContext.prototype.tripleX = function() { - return this.getTypedRuleContext(TripleXContext,0); -}; + BooleanLiteral() { + return this.getToken(turtlestarParser.BooleanLiteral, 0); + }; -ObjectXContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterObjectX(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterLiteral(this); + } } -}; -ObjectXContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitObjectX(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitLiteral(this); + } } -}; -ObjectXContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitObjectX(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.ObjectXContext = ObjectXContext; - -turtlestarParser.prototype.objectX = function() { - - var localctx = new ObjectXContext(this, this._ctx, this.state); - this.enterRule(localctx, 32, turtlestarParser.RULE_objectX); - try { - this.state = 147; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 1); - this.state = 143; - this.iri(); - break; - case turtlestarParser.BlankNode: - this.enterOuterAlt(localctx, 2); - this.state = 144; - this.match(turtlestarParser.BlankNode); - break; - case turtlestarParser.NumericLiteral: - case turtlestarParser.BooleanLiteral: - case turtlestarParser.String: - this.enterOuterAlt(localctx, 3); - this.state = 145; - this.literal(); - break; - case turtlestarParser.T__6: - this.enterOuterAlt(localctx, 4); - this.state = 146; - this.tripleX(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitLiteral(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function LiteralContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_literal; - return this; -} - -LiteralContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -LiteralContext.prototype.constructor = LiteralContext; -LiteralContext.prototype.rdfLiteral = function() { - return this.getTypedRuleContext(RdfLiteralContext,0); -}; -LiteralContext.prototype.NumericLiteral = function() { - return this.getToken(turtlestarParser.NumericLiteral, 0); -}; +} -LiteralContext.prototype.BooleanLiteral = function() { - return this.getToken(turtlestarParser.BooleanLiteral, 0); -}; -LiteralContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterLiteral(this); - } -}; -LiteralContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitLiteral(this); - } -}; +class BlankNodePropertyListContext extends antlr4.ParserRuleContext { -LiteralContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitLiteral(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.LiteralContext = LiteralContext; - -turtlestarParser.prototype.literal = function() { - - var localctx = new LiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 34, turtlestarParser.RULE_literal); - try { - this.state = 152; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.String: - this.enterOuterAlt(localctx, 1); - this.state = 149; - this.rdfLiteral(); - break; - case turtlestarParser.NumericLiteral: - this.enterOuterAlt(localctx, 2); - this.state = 150; - this.match(turtlestarParser.NumericLiteral); - break; - case turtlestarParser.BooleanLiteral: - this.enterOuterAlt(localctx, 3); - this.state = 151; - this.match(turtlestarParser.BooleanLiteral); - break; - default: - throw new antlr4.error.NoViableAltException(this); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_blankNodePropertyList; } - return localctx; -}; -function BlankNodePropertyListContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_blankNodePropertyList; - return this; -} - -BlankNodePropertyListContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -BlankNodePropertyListContext.prototype.constructor = BlankNodePropertyListContext; + predicateObjectList() { + return this.getTypedRuleContext(PredicateObjectListContext,0); + }; -BlankNodePropertyListContext.prototype.predicateObjectList = function() { - return this.getTypedRuleContext(PredicateObjectListContext,0); -}; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterBlankNodePropertyList(this); + } + } -BlankNodePropertyListContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterBlankNodePropertyList(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitBlankNodePropertyList(this); + } } -}; -BlankNodePropertyListContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitBlankNodePropertyList(this); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitBlankNodePropertyList(this); + } else { + return visitor.visitChildren(this); + } } -}; -BlankNodePropertyListContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitBlankNodePropertyList(this); - } else { - return visitor.visitChildren(this); - } -}; +} -turtlestarParser.BlankNodePropertyListContext = BlankNodePropertyListContext; +class CollectionContext extends antlr4.ParserRuleContext { -turtlestarParser.prototype.blankNodePropertyList = function() { + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_collection; + } - var localctx = new BlankNodePropertyListContext(this, this._ctx, this.state); - this.enterRule(localctx, 36, turtlestarParser.RULE_blankNodePropertyList); - try { - this.enterOuterAlt(localctx, 1); - this.state = 154; - this.match(turtlestarParser.T__8); - this.state = 155; - this.predicateObjectList(); - this.state = 156; - this.match(turtlestarParser.T__9); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + object = function(i) { + if(i===undefined) { + i = null; + } + if(i===null) { + return this.getTypedRuleContexts(ObjectContext); } else { - throw re; + return this.getTypedRuleContext(ObjectContext,i); } - } finally { - this.exitRule(); - } - return localctx; -}; + }; -function CollectionContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterCollection(this); + } } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_collection; - return this; -} - -CollectionContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -CollectionContext.prototype.constructor = CollectionContext; -CollectionContext.prototype.object = function(i) { - if(i===undefined) { - i = null; - } - if(i===null) { - return this.getTypedRuleContexts(ObjectContext); - } else { - return this.getTypedRuleContext(ObjectContext,i); - } -}; - -CollectionContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterCollection(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitCollection(this); + } } -}; -CollectionContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitCollection(this); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitCollection(this); + } else { + return visitor.visitChildren(this); + } } -}; - -CollectionContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitCollection(this); - } else { - return visitor.visitChildren(this); - } -}; +} -turtlestarParser.CollectionContext = CollectionContext; -turtlestarParser.prototype.collection = function() { +class RdfLiteralContext extends antlr4.ParserRuleContext { - var localctx = new CollectionContext(this, this._ctx, this.state); - this.enterRule(localctx, 38, turtlestarParser.RULE_collection); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 158; - this.match(turtlestarParser.T__10); - this.state = 162; - this._errHandler.sync(this); - _la = this._input.LA(1); - while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << turtlestarParser.T__6) | (1 << turtlestarParser.T__8) | (1 << turtlestarParser.T__10) | (1 << turtlestarParser.NumericLiteral) | (1 << turtlestarParser.BooleanLiteral) | (1 << turtlestarParser.String) | (1 << turtlestarParser.BlankNode) | (1 << turtlestarParser.IRIREF) | (1 << turtlestarParser.PNAME_NS) | (1 << turtlestarParser.PNAME_LN))) !== 0)) { - this.state = 159; - this.object(); - this.state = 164; - this._errHandler.sync(this); - _la = this._input.LA(1); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; } - this.state = 165; - this.match(turtlestarParser.T__11); - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } finally { - this.exitRule(); + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_rdfLiteral; } - return localctx; -}; - -function RdfLiteralContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; - } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_rdfLiteral; - return this; -} - -RdfLiteralContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -RdfLiteralContext.prototype.constructor = RdfLiteralContext; -RdfLiteralContext.prototype.String = function() { - return this.getToken(turtlestarParser.String, 0); -}; + String() { + return this.getToken(turtlestarParser.String, 0); + }; -RdfLiteralContext.prototype.LANGTAG = function() { - return this.getToken(turtlestarParser.LANGTAG, 0); -}; + LANGTAG() { + return this.getToken(turtlestarParser.LANGTAG, 0); + }; -RdfLiteralContext.prototype.iri = function() { - return this.getTypedRuleContext(IriContext,0); -}; + iri() { + return this.getTypedRuleContext(IriContext,0); + }; -RdfLiteralContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterRdfLiteral(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterRdfLiteral(this); + } } -}; -RdfLiteralContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitRdfLiteral(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitRdfLiteral(this); + } } -}; -RdfLiteralContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitRdfLiteral(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.RdfLiteralContext = RdfLiteralContext; - -turtlestarParser.prototype.rdfLiteral = function() { - - var localctx = new RdfLiteralContext(this, this._ctx, this.state); - this.enterRule(localctx, 40, turtlestarParser.RULE_rdfLiteral); - try { - this.enterOuterAlt(localctx, 1); - this.state = 167; - this.match(turtlestarParser.String); - this.state = 171; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case turtlestarParser.LANGTAG: - this.state = 168; - this.match(turtlestarParser.LANGTAG); - break; - case turtlestarParser.T__12: - this.state = 169; - this.match(turtlestarParser.T__12); - this.state = 170; - this.iri(); - break; - case turtlestarParser.T__0: - case turtlestarParser.T__3: - case turtlestarParser.T__4: - case turtlestarParser.T__6: - case turtlestarParser.T__7: - case turtlestarParser.T__8: - case turtlestarParser.T__9: - case turtlestarParser.T__10: - case turtlestarParser.T__11: - case turtlestarParser.NumericLiteral: - case turtlestarParser.BooleanLiteral: - case turtlestarParser.String: - case turtlestarParser.BlankNode: - case turtlestarParser.IRIREF: - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitRdfLiteral(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function IriContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_iri; - return this; + + } -IriContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -IriContext.prototype.constructor = IriContext; -IriContext.prototype.IRIREF = function() { - return this.getToken(turtlestarParser.IRIREF, 0); -}; -IriContext.prototype.prefixedName = function() { - return this.getTypedRuleContext(PrefixedNameContext,0); -}; +class IriContext extends antlr4.ParserRuleContext { + + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_iri; + } + + IRIREF() { + return this.getToken(turtlestarParser.IRIREF, 0); + }; + + prefixedName() { + return this.getTypedRuleContext(PrefixedNameContext,0); + }; -IriContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterIri(this); + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterIri(this); + } } -}; -IriContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitIri(this); + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitIri(this); + } } -}; -IriContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitIri(this); - } else { - return visitor.visitChildren(this); - } -}; - - - - -turtlestarParser.IriContext = IriContext; - -turtlestarParser.prototype.iri = function() { - - var localctx = new IriContext(this, this._ctx, this.state); - this.enterRule(localctx, 42, turtlestarParser.RULE_iri); - try { - this.state = 175; - this._errHandler.sync(this); - switch(this._input.LA(1)) { - case turtlestarParser.IRIREF: - this.enterOuterAlt(localctx, 1); - this.state = 173; - this.match(turtlestarParser.IRIREF); - break; - case turtlestarParser.PNAME_NS: - case turtlestarParser.PNAME_LN: - this.enterOuterAlt(localctx, 2); - this.state = 174; - this.prefixedName(); - break; - default: - throw new antlr4.error.NoViableAltException(this); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitIri(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; - -function PrefixedNameContext(parser, parent, invokingState) { - if(parent===undefined) { - parent = null; - } - if(invokingState===undefined || invokingState===null) { - invokingState = -1; } - antlr4.ParserRuleContext.call(this, parent, invokingState); - this.parser = parser; - this.ruleIndex = turtlestarParser.RULE_prefixedName; - return this; -} -PrefixedNameContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); -PrefixedNameContext.prototype.constructor = PrefixedNameContext; -PrefixedNameContext.prototype.PNAME_NS = function() { - return this.getToken(turtlestarParser.PNAME_NS, 0); -}; +} -PrefixedNameContext.prototype.PNAME_LN = function() { - return this.getToken(turtlestarParser.PNAME_LN, 0); -}; -PrefixedNameContext.prototype.enterRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.enterPrefixedName(this); - } -}; -PrefixedNameContext.prototype.exitRule = function(listener) { - if(listener instanceof turtlestarListener ) { - listener.exitPrefixedName(this); - } -}; +class PrefixedNameContext extends antlr4.ParserRuleContext { -PrefixedNameContext.prototype.accept = function(visitor) { - if ( visitor instanceof turtlestarVisitor ) { - return visitor.visitPrefixedName(this); - } else { - return visitor.visitChildren(this); + constructor(parser, parent, invokingState) { + if(parent===undefined) { + parent = null; + } + if(invokingState===undefined || invokingState===null) { + invokingState = -1; + } + super(parent, invokingState); + this.parser = parser; + this.ruleIndex = turtlestarParser.RULE_prefixedName; } -}; + PNAME_NS() { + return this.getToken(turtlestarParser.PNAME_NS, 0); + }; + PNAME_LN() { + return this.getToken(turtlestarParser.PNAME_LN, 0); + }; + enterRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.enterPrefixedName(this); + } + } -turtlestarParser.PrefixedNameContext = PrefixedNameContext; - -turtlestarParser.prototype.prefixedName = function() { + exitRule(listener) { + if(listener instanceof turtlestarListener ) { + listener.exitPrefixedName(this); + } + } - var localctx = new PrefixedNameContext(this, this._ctx, this.state); - this.enterRule(localctx, 44, turtlestarParser.RULE_prefixedName); - var _la = 0; // Token type - try { - this.enterOuterAlt(localctx, 1); - this.state = 177; - _la = this._input.LA(1); - if(!(_la===turtlestarParser.PNAME_NS || _la===turtlestarParser.PNAME_LN)) { - this._errHandler.recoverInline(this); - } - else { - this._errHandler.reportMatch(this); - this.consume(); - } - } catch (re) { - if(re instanceof antlr4.error.RecognitionException) { - localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); + accept(visitor) { + if ( visitor instanceof turtlestarVisitor ) { + return visitor.visitPrefixedName(this); } else { - throw re; + return visitor.visitChildren(this); } - } finally { - this.exitRule(); - } - return localctx; -}; + } + + +} + + -exports.turtlestarParser = turtlestarParser; +turtlestarParser.TurtleStarDocContext = TurtleStarDocContext; +turtlestarParser.StatementContext = StatementContext; +turtlestarParser.DirectiveContext = DirectiveContext; +turtlestarParser.PrefixIDContext = PrefixIDContext; +turtlestarParser.BaseContext = BaseContext; +turtlestarParser.SparqlBaseContext = SparqlBaseContext; +turtlestarParser.SparqlPrefixContext = SparqlPrefixContext; +turtlestarParser.TriplesContext = TriplesContext; +turtlestarParser.PredicateObjectListContext = PredicateObjectListContext; +turtlestarParser.ObjectListContext = ObjectListContext; +turtlestarParser.VerbContext = VerbContext; +turtlestarParser.SubjectContext = SubjectContext; +turtlestarParser.PredicateContext = PredicateContext; +turtlestarParser.ObjectContext = ObjectContext; +turtlestarParser.TripleXContext = TripleXContext; +turtlestarParser.SubjectXContext = SubjectXContext; +turtlestarParser.ObjectXContext = ObjectXContext; +turtlestarParser.LiteralContext = LiteralContext; +turtlestarParser.BlankNodePropertyListContext = BlankNodePropertyListContext; +turtlestarParser.CollectionContext = CollectionContext; +turtlestarParser.RdfLiteralContext = RdfLiteralContext; +turtlestarParser.IriContext = IriContext; +turtlestarParser.PrefixedNameContext = PrefixedNameContext; diff --git a/editor/parser/turtlestar/turtlestarVisitor.js b/editor/parser/turtlestar/turtlestarVisitor.js index 43066f6..8795213 100644 --- a/editor/parser/turtlestar/turtlestarVisitor.js +++ b/editor/parser/turtlestar/turtlestarVisitor.js @@ -1,154 +1,148 @@ -// Generated from D:\git\n3dev\N3\grammar\turtlestar.g4 by ANTLR 4.6 +// Generated from java-escape by ANTLR 4.11.1 // jshint ignore: start -var antlr4 = require('antlr4/index'); +import antlr4 from 'antlr4'; // This class defines a complete generic visitor for a parse tree produced by turtlestarParser. -function turtlestarVisitor() { - antlr4.tree.ParseTreeVisitor.call(this); - return this; -} +export default class turtlestarVisitor extends antlr4.tree.ParseTreeVisitor { -turtlestarVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype); -turtlestarVisitor.prototype.constructor = turtlestarVisitor; + // Visit a parse tree produced by turtlestarParser#turtleStarDoc. + visitTurtleStarDoc(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#turtleStarDoc. -turtlestarVisitor.prototype.visitTurtleStarDoc = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#statement. + visitStatement(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#statement. -turtlestarVisitor.prototype.visitStatement = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#directive. + visitDirective(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#directive. -turtlestarVisitor.prototype.visitDirective = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#prefixID. + visitPrefixID(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#prefixID. -turtlestarVisitor.prototype.visitPrefixID = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#base. + visitBase(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#base. -turtlestarVisitor.prototype.visitBase = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#sparqlBase. + visitSparqlBase(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#sparqlBase. -turtlestarVisitor.prototype.visitSparqlBase = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#sparqlPrefix. + visitSparqlPrefix(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#sparqlPrefix. -turtlestarVisitor.prototype.visitSparqlPrefix = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#triples. + visitTriples(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#triples. -turtlestarVisitor.prototype.visitTriples = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#predicateObjectList. + visitPredicateObjectList(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#predicateObjectList. -turtlestarVisitor.prototype.visitPredicateObjectList = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#objectList. + visitObjectList(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#objectList. -turtlestarVisitor.prototype.visitObjectList = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#verb. + visitVerb(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#verb. -turtlestarVisitor.prototype.visitVerb = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#subject. + visitSubject(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#subject. -turtlestarVisitor.prototype.visitSubject = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#predicate. + visitPredicate(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#predicate. -turtlestarVisitor.prototype.visitPredicate = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#object. + visitObject(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#object. -turtlestarVisitor.prototype.visitObject = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#tripleX. + visitTripleX(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#tripleX. -turtlestarVisitor.prototype.visitTripleX = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#subjectX. + visitSubjectX(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#subjectX. -turtlestarVisitor.prototype.visitSubjectX = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#objectX. + visitObjectX(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#objectX. -turtlestarVisitor.prototype.visitObjectX = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#literal. + visitLiteral(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#literal. -turtlestarVisitor.prototype.visitLiteral = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#blankNodePropertyList. + visitBlankNodePropertyList(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#blankNodePropertyList. -turtlestarVisitor.prototype.visitBlankNodePropertyList = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#collection. + visitCollection(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#collection. -turtlestarVisitor.prototype.visitCollection = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#rdfLiteral. + visitRdfLiteral(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#rdfLiteral. -turtlestarVisitor.prototype.visitRdfLiteral = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#iri. + visitIri(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#iri. -turtlestarVisitor.prototype.visitIri = function(ctx) { - return this.visitChildren(ctx); -}; + // Visit a parse tree produced by turtlestarParser#prefixedName. + visitPrefixedName(ctx) { + return this.visitChildren(ctx); + } -// Visit a parse tree produced by turtlestarParser#prefixedName. -turtlestarVisitor.prototype.visitPrefixedName = function(ctx) { - return this.visitChildren(ctx); -}; - -exports.turtlestarVisitor = turtlestarVisitor; \ No newline at end of file +} \ No newline at end of file diff --git a/editor/sparql.html b/editor/sparql.html new file mode 100644 index 0000000..e04c66c --- /dev/null +++ b/editor/sparql.html @@ -0,0 +1,324 @@ + + + + + + SPARQL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              + + + + +
              +
              + +
              +
              + + Auto-suggest namespaces.
              + Experimental auto-suggestion of namespaces. A specific namespace will only be suggested once (so just + remove it if it's wrong!). +
              +
              +
              + +
              + loader +
              +
              + +
              + + + Create link for case + + + + + Please submit bugs or feature requests on GitHub. + + +
              + +
              +

              Error:

              +
              +
              + +
              +

              Results:

              +
              +
              +
              +
              + + + + + \ No newline at end of file diff --git a/editor/spin3.html b/editor/spin3.html new file mode 100644 index 0000000..4626d09 --- /dev/null +++ b/editor/spin3.html @@ -0,0 +1,358 @@ + + + + + + SPiN3: SPARQL in N3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              +
              + + + + + +
              + + + + +
              +
              + + +
              +
              + + +
              +
              + loader +
              +
              +
              +
              + +
              +
              Hint: each CONSTRUCT query should be separated with a period (".") followed by at least 1 newline.
              + + + + + +
              + + + +
              + + + Please submit bugs or feature requests on GitHub. + +
              + +
              +

              Error:

              +
              +
              + +
              +
              +

              Results:

              + +
              +
              +
              +
              +
              +
              + + + + + \ No newline at end of file diff --git a/editor/webpack.config.js b/editor/webpack.config.js index b8c1ffe..1af221c 100644 --- a/editor/webpack.config.js +++ b/editor/webpack.config.js @@ -3,24 +3,47 @@ const path = require('path'); // - N3 // -- script + +// (default n3) +// module.exports = { +// // exclude node.js-only modules +// // node: { module: "empty", net: "empty", fs: "empty" }, // older versions of webpack +// resolve: { fallback: { fs: false } }, // webpack v5 + +// entry: './parser/n3/index.js', +// output: { +// filename: 'n3Main.js', +// libraryTarget: 'var', +// library: 'n3', +// path: path.resolve(__dirname, 'dist'), +// }, +// optimization: { +// minimize: true +// } +// }; + +// (n3_nodrop) module.exports = { // exclude node.js-only modules // node: { module: "empty", net: "empty", fs: "empty" }, // older versions of webpack resolve: { fallback: { fs: false } }, // webpack v5 - entry: './parser/n3/index.js', + entry: './parser/n3_nodrop/index.js', output: { - filename: 'n3Main.js', + filename: 'n3_nodropMain.js', libraryTarget: 'var', library: 'n3', path: path.resolve(__dirname, 'dist'), }, optimization: { - minimize: false + minimize: true } }; + // -- requires + +// (default n3) // module.exports = { // // exclude node.js-only modules // // node: { module: "empty", net: "empty", fs: "empty" }, // older versions of webpack @@ -41,6 +64,28 @@ module.exports = { // } // }; +// (n3_nodrop) +// module.exports = { +// // exclude node.js-only modules +// // node: { module: "empty", net: "empty", fs: "empty" }, // older versions of webpack +// resolve: { fallback: { fs: false } }, // webpack v5 + +// entry: './parser/n3_nodrop/index.js', +// output: { +// filename: 'n3Main_nodrop_umd.js', +// path: path.resolve(__dirname, 'dist'), +// globalObject: 'this', +// library: { +// name: 'n3Main', +// type: 'umd', +// }, +// }, +// optimization: { +// minimize: false +// } +// }; + + // - TurtleStar /*module.exports = { diff --git a/lib/check_builtin_input.js b/lib/check_builtin_input.js index a22eb7e..3a27069 100644 --- a/lib/check_builtin_input.js +++ b/lib/check_builtin_input.js @@ -1,23 +1,20 @@ const { config } = require('../config.js') -var exec = require('child_process').exec, child; +let { promiseExec } = require('./cmd_util.js') -exports.checkBuiltinInput = function(defFile, testFile, ctu) { - var cmd = `java -jar ${config.path}/lib/checkBuiltinInput.jar -definitions ${defFile} -test ${testFile}` +exports.checkBuiltinInput = async function(defFile, testFile) { + const cmd = `java -jar ${config.path}/lib/checkBuiltinInput.jar -definitions ${defFile} -test ${testFile}` //var cmd = "java -jar D:/git/n3dev/n3-editor-js/lib/checkBuiltinInput.jar -definitions D:/git/n3dev/jena-core/src/main/resources/etc/builtins/builtins.n3 -test D:/git/n3dev/jena-core/testing/N3/builtin_input0.n3" // console.log(cmd) - child = exec(cmd, - function (error, stdout, stderr) { - //console.log('error', error) - //console.log('stdout', stdout) - //console.log('stderr', stderr) - - if (error) - ctu({ error: error + "" }) - else if (stderr) - ctu({ error: stderr + "" }) - else { - const out = JSON.parse(stdout) - ctu({ success: out }) - } - }); -} + + const [ stdout, stderr ] = await promiseExec(cmd) + //console.log('error', error) + //console.log('stdout', stdout) + //console.log('stderr', stderr) + + if (stderr) + throw stderr + else { + const out = JSON.parse(stdout) + return out + } +} \ No newline at end of file diff --git a/lib/cmd_util.js b/lib/cmd_util.js new file mode 100644 index 0000000..ee10de5 --- /dev/null +++ b/lib/cmd_util.js @@ -0,0 +1,12 @@ +var { exec } = require('child_process') + +exports.promiseExec = function(cmd) { + return new Promise((resolve, reject) => { + exec(cmd, (err, stdout, stderr) => { + if (err) + reject(err) + else + resolve([ stdout, stderr ]) + }) + }); +} \ No newline at end of file diff --git a/lib/cwm/cwm.js b/lib/cwm/cwm.js deleted file mode 100644 index dd0bc9e..0000000 --- a/lib/cwm/cwm.js +++ /dev/null @@ -1,53 +0,0 @@ -var { exec } = require('child_process') -var prefix = require('../prefix_map.js') -var { config } = require('../../config.js') - -const pythonCmd = config.reasoners.cwm.pythonCmd -const cwmExec = config.reasoners.cwm.exec; - -exports.exec = function(options, file, callback) { - var cmd = `${pythonCmd} ${cwmExec} --n3 ${file}` - switch (options.task) { - case 'derivations': - cmd += ` --filter=${file}`; - break; - case 'deductive_closure': - cmd += " --think"; - break; - } - console.log(cmd); - - exec(cmd, (err, stdout, stderr) => { - // if (err) { throw err } - - var ret = null - if (err) { - // console.log("stderr", stderr) - var error = null; - - var dl = stderr.lastIndexOf("swap.notation3.BadSyntax") - if (dl == -1) - dl = stderr.lastIndexOf("ValueError") - - if (dl != -1) - error = stderr.substring(dl).trim() - else - error = stderr - - // console.log("error:", error) - callback({ error: error }) - - } else { - // console.log("stdout", stdout) - - var dl = stdout.indexOf("\n", stdout.indexOf("Base was:")) + 1 - var dl2 = stdout.indexOf("#ENDS") - 1 - var output = stdout.substring(dl, dl2).trim() - - output = prefix.collapse(output, file) - - // console.log("output:", output) - callback({ success: output }) - } - }) -} diff --git a/lib/eye/eye.js b/lib/eye/eye.js index e971438..4ce5941 100644 --- a/lib/eye/eye.js +++ b/lib/eye/eye.js @@ -1,12 +1,12 @@ -var { exec } = require('child_process') +let { promiseExec } = require('../cmd_util.js') var prefix = require('../prefix_map.js') var { config } = require('../../config.js') -const eyeExec = config.reasoners.eye.exec -const eyeFolder = config.reasoners.eye.folder +const eyeExec = config.tools.eye.exec +const eyeFolder = config.tools.eye.folder -exports.exec = function (options, file, callback) { - var cmd = null +exports.exec = async function (options, file) { + let cmd = null switch (options.task) { case 'explain': @@ -14,7 +14,7 @@ exports.exec = function (options, file, callback) { break default: - cmd = `${eyeExec} --n3 ${file} --nope` + cmd = `${eyeExec} ${file} --quantify http://eyereasoner.github.io/.well-known/genid/ --nope` switch (options.task) { case 'derivations': cmd += " --pass-only-new" @@ -26,39 +26,39 @@ exports.exec = function (options, file, callback) { break } - exec(cmd, (err, stdout, stderr) => { - // if (err) { throw err } + // console.log("cmd", cmd); + const [ stdout, stderr ] = await promiseExec(cmd) - if (err) { - var error = stderr - if (stderr.includes("**")) { - var dl = stderr.lastIndexOf("**") + 2 - error = stderr.substring(dl).trim() - } - - // console.log("error:", error) - callback({ error: error }) + if (stderr) { + if (stderr.includes("**")) { + const dl = stderr.lastIndexOf("**") + 2 + error = stderr.substring(dl).trim() - } else { - // console.log("stdout", stdout) - var output = stdout - switch (options.task) { + throw error + } + } - case 'explain': - break + // console.log("stdout", stdout) + let output = stdout + switch (options.task) { + case 'explain': + break - default: - var dl = output.indexOf("\n", output.indexOf("#eye")) - var dl2 = output.lastIndexOf("\n", output.indexOf("#ENDS") - 2) - output = output.substring(dl, dl2).trim() + default: + output = clean(output, file) + break + } - output = prefix.collapse(output, file) - break + // console.log("output:", output) + return output +} - } +function clean(output, file) { + var dl = output.indexOf("\n", output.indexOf("# eye")) + var dl2 = output.lastIndexOf("\n", output.indexOf("# ENDS") - 2) + output = output.substring(dl, dl2).trim() - // console.log("output:", output) - callback({ success: output }) - } - }) + return prefix.collapse(output, file) } + +exports.clean = clean \ No newline at end of file diff --git a/lib/eyebrow/eye.pl b/lib/eyebrow/eye.pl deleted file mode 100644 index e927bd7..0000000 --- a/lib/eyebrow/eye.pl +++ /dev/null @@ -1,11793 +0,0 @@ -% -------------------------------------------- -% Euler Yet another proof Engine -- Jos De Roo -% -------------------------------------------- -% -% See http://github.com/josd/eye -% - -:- use_module(library(lists)). -:- use_module(library(gensym)). -:- use_module(library(system)). -:- use_module(library(terms)). -:- use_module(library(url)). -:- use_module(library(charsio)). -:- use_module(library(qsave)). -:- use_module(library(base64)). -:- use_module(library(date)). -:- use_module(library(prolog_jiti)). -:- use_module(library(sha)). -:- use_module(library(semweb/turtle)). -:- catch(use_module(library(http/http_open)), _, true). - -version_info('EYE v22.1111.1734 josd'). - -license_info('MIT License - -Copyright (c) 2006-2022 Jos De Roo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.'). - -help_info('Usage: eye * * * -eye - swipl -g main eye.pl -- - - --blogic support RDF surfaces - --csv-separator CSV separator such as , or ; - --debug output debug info on stderr - --debug-cnt output debug info about counters on stderr - --debug-djiti output debug info about DJITI on stderr - --debug-pvm output debug info about PVM code on stderr - --help show help info - --hmac-key HMAC key used in e:hmac-sha built-in - --ignore-inference-fuse do not halt in case of inference fuse - --image output all and all code to - --intermediate output all to - --license show license info - --max-inferences halt after maximum number of inferences - --multi-query go into query answer loop - --no-distinct-input no distinct triples in the input - --no-distinct-output no distinct answers in the output - --no-erase no erase functionality for blogic - --no-numerals no numerals in the output - --no-qnames no qnames in the output - --no-qvars no qvars in the output - --no-ucall no extended unifier for forward rules - --nope no proof explanation - --output output reasoner output to - --profile output profile info on stderr - --quantify quantify uris with in the output - --quiet quiet mode - --random-seed create random seed for e:random built-in - --restricted restricting to core built-ins - --rule-histogram output rule histogram info on stderr - --skolem-genid use in Skolem IRIs - --source read command line arguments from - --statistics output statistics info on stderr - --strings output log:outputString objects on stdout - --tactic limited-answer give only a limited number of answers - --tactic linear-select select each rule only once - --version show version info - --warn output warning info on stderr - --wcache to tell that is cached as - - [--n3] N3 triples and rules - --n3p N3P intermediate - --proof N3 proof lemmas - --turtle Turtle triples - - --entail output true if RDF graph is entailed - --not-entail output true if RDF graph is not entailed - --pass output deductive closure - --pass-all output deductive closure plus rules - --pass-all-ground ground the rules and run --pass-all - --pass-only-new output only new derived triples - --query output filtered with filter rules'). - -:- dynamic(answer/3). % answer(Predicate, Subject, Object) -:- dynamic(argi/1). -:- dynamic(base_uri/1). -:- dynamic(bcnd/2). -:- dynamic(bgot/3). -:- dynamic(brake/0). -:- dynamic(bref/2). -:- dynamic(bvar/1). -:- dynamic(cc/1). -:- dynamic(cpred/1). -:- dynamic(data_fuse/0). -:- dynamic(evar/3). -:- dynamic(exopred/3). % exopred(Predicate, Subject, Object) -:- dynamic(fact/1). -:- dynamic(flag/1). -:- dynamic(flag/2). -:- dynamic(fpred/1). -:- dynamic(got_dq/0). -:- dynamic(got_head/0). -:- dynamic(got_labelvars/3). -:- dynamic(got_pi/0). -:- dynamic(got_random/3). -:- dynamic(got_sq/0). -:- dynamic(got_unique/2). -:- dynamic(got_wi/5). % got_wi(Source, Premise, Premise_index, Conclusion, Rule) -:- dynamic(got_uuid/1). -:- dynamic(graph/2). -:- dynamic(hash_value/2). -:- dynamic(implies/3). % implies(Premise, Conclusion, Source) -:- dynamic(input_statements/1). -:- dynamic(intern/1). -:- dynamic(keep_skolem/1). -:- dynamic(lemma/6). % lemma(Count, Source, Premise, Conclusion, Premise-Conclusion_index, Rule) -:- dynamic(mtime/2). -:- dynamic(n3s/2). -:- dynamic(ncllit/0). -:- dynamic(ns/2). -:- dynamic(pass_only_new/1). -:- dynamic(pfx/2). -:- dynamic(pred/1). -:- dynamic(prfstep/7). % prfstep(Conclusion_triple, Premise, Premise_index, Conclusion, Rule, Chaining, Source) -:- dynamic(qevar/3). -:- dynamic(query/2). -:- dynamic(quvar/3). -:- dynamic(retwist/3). -:- dynamic(rule_uvar/1). -:- dynamic(scope/1). -:- dynamic(scount/1). -:- dynamic(semantics/2). -:- dynamic(span/1). -:- dynamic(tabl/3). -:- dynamic(tmpfile/1). -:- dynamic(tuple/2). -:- dynamic(tuple/3). -:- dynamic(tuple/4). -:- dynamic(tuple/5). -:- dynamic(tuple/6). -:- dynamic(tuple/7). -:- dynamic(tuple/8). -:- dynamic(wcache/2). -:- dynamic(wpfx/1). -:- dynamic(wtcache/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). - -% -% Main goal -% - -main(Argv) :- - set_prolog_flag(argv, Argv), - catch(run, Exc, - ( Exc = halt(_) - -> true - ; throw(Exc) - ) - ). - -main :- - catch(run, Exc, - ( Exc = halt(EC) - -> halt(EC) - ; throw(Exc) - ) - ). - -run :- - current_prolog_flag(version_data, swi(SV, _, _, _)), - ( SV < 8 - -> format(user_error, '** ERROR ** EYE requires at least swipl version 8 **~n', []), - flush_output(user_error), - throw(halt(1)) - ; true - ), - catch(set_stream(user_output, encoding(utf8)), _, true), - current_prolog_flag(argv, Argv), - ( append(_, ['--'|Argvp], Argv) - -> true - ; Argvp = Argv - ), - ( Argvp = ['--source', File] - -> ( File = '-' - -> read_line_to_codes(user_input, Codes) - ; read_file_to_codes(File, Codes, []) - ), - atom_codes(Atom, Codes), - atomic_list_concat(Argvs, ' ', Atom) - ; Argvs = Argvp - ), - argv(Argvs, Argus), - findall(Argij, - ( argi(Argij) - ), - Argil - ), - append(Argil, Argi), - format(user_error, 'eye~@~@~n', [w0(Argi), w1(Argus)]), - flush_output(user_error), - version_info(Version), - format(user_error, '~w~n', [Version]), - flush_output(user_error), - ( current_prolog_flag(version_git, PVersion) - -> true - ; current_prolog_flag(version_data, swi(Major, Minor, Patch, Options)), - ( memberchk(tag(Tag), Options) - -> atomic_list_concat([Major, '.', Minor, '.', Patch, '-', Tag], PVersion) - ; atomic_list_concat([Major, '.', Minor, '.', Patch], PVersion) - ) - ), - format(user_error, 'SWI-Prolog version ~w~n', [PVersion]), - flush_output(user_error), - ( retract(prolog_file_type(qlf, qlf)) - -> assertz(prolog_file_type(pvm, qlf)) - ; true - ), - ( Argv = ['--n3', _] - -> retractall(flag('parse-only')), - assertz(flag('parse-only')) - ; true - ), - catch(gre(Argus), Exc, - ( Exc = halt(0) - -> true - ; ( flag('parse-only') - -> true - ; format(user_error, '** ERROR ** gre ** ~w~n', [Exc]), - flush_output(user_error), - nb_setval(exit_code, 3) - ) - ) - ), - ( flag(statistics) - -> statistics - ; true - ), - ( flag('debug-pvm') - -> tell(user_error), - ignore(vm_list(_)), - told, - ( flag('output', Output) - -> tell(Output) - ; true - ) - ; true - ), - ( flag('debug-djiti') - -> tell(user_error), - jiti_list, - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ) - ; true - ), - nb_getval(exit_code, EC), - flush_output, - throw(halt(EC)). - -argv([], []) :- - !. -argv([Arg|Argvs], [U, V|Argus]) :- - sub_atom(Arg, B, 1, E, '='), - sub_atom(Arg, 0, B, _, U), - memberchk(U, ['--csv-separator', '--hmac-key', '--image', '--max-inferences', '--n3', '--n3p', '--proof', '--quantify', '--query', '--output', '--skolem-genid', '--tactic', '--turtle']), - !, - sub_atom(Arg, _, E, 0, V), - argv(Argvs, Argus). -argv([Arg|Argvs], [Arg|Argus]) :- - argv(Argvs, Argus). - - -% ------------------------------ -% GRE (Generic Reasoning Engine) -% ------------------------------ - -gre(Argus) :- - statistics(runtime, [T0, _]), - statistics(walltime, [T1, _]), - format(user_error, 'starting ~w [msec cputime] ~w [msec walltime]~n', [T0, T1]), - flush_output(user_error), - nb_setval(entail_mode, false), - nb_setval(exit_code, 0), - nb_setval(indentation, 0), - nb_setval(limit, -1), - nb_setval(bnet, not_done), - nb_setval(fnet, not_done), - nb_setval(tabl, -1), - nb_setval(tuple, -1), - nb_setval(fdepth, 0), - nb_setval(pdepth, 0), - nb_setval(cdepth, 0), - ( input_statements(Ist) - -> nb_setval(input_statements, Ist) - ; nb_setval(input_statements, 0) - ), - nb_setval(output_statements, 0), - nb_setval(current_scope, '<>'), - nb_setval(wn, 0), - opts(Argus, Args), - ( \+flag('multi-query'), - Args = [] - -> opts(['--help'], _) - ; true - ), - ( flag('skolem-genid', Genid) - -> true - ; A is random(2^62), - atom_number(Genid, A) - ), - atomic_list_concat(['http://josd.github.io/.well-known/genid/', Genid, '#'], Sns), - nb_setval(var_ns, Sns), - ( ( flag(strings) - ; flag(image, _) - ) - -> true - ; version_info(Version), - ( flag(quiet) - -> true - ; format('#Processed by ~w~n', [Version]) - ), - findall(Argij, - ( argi(Argij) - ), - Argil - ), - append(Argil, Argi), - ( flag(quiet) - -> true - ; format('#eye~@~@~n~n', [w0(Argi), w1(Argus)]), - flush_output - ) - ), - ( ( flag('no-qvars') - ; flag('pass-all-ground') - ) - -> retractall(pfx('var:', _)), - assertz(pfx('var:', '')) - ; true - ), - ( flag('intermediate', Out) - -> format(Out, 'flag(\'quantify\', \'~w\').~n', [Sns]) - ; true - ), - args(Args), - ( implies(_, Conc, _), - ( var(Conc) - ; Conc \= answer(_, _, _), - Conc \= (answer(_, _, _), _) - ) - -> true - ; ( \+flag(image, _), - \+flag(tactic, 'linear-select') - -> assertz(flag(tactic, 'linear-select')) - ; true - ) - ), - findall(Sc, - ( scope(Sc) - ), - Scope - ), - nb_setval(scope, Scope), - statistics(runtime, [_, T2]), - statistics(walltime, [_, T3]), - format(user_error, 'networking ~w [msec cputime] ~w [msec walltime]~n', [T2, T3]), - flush_output(user_error), - nb_getval(input_statements, SC), - ( flag(image, File) - -> assertz(argi(Argus)), - retractall(flag(image, _)), - assertz(flag('quantify', Sns)), - retractall(input_statements(_)), - assertz(input_statements(SC)), - reset_gensym, - ( current_predicate(qsave:qsave_program/1) - -> qsave_program(File) - ; save_program(File) - ), - throw(halt(0)) - ; true - ), - ( flag('intermediate', Out) - -> ( SC =\= 0 - -> write(Out, scount(SC)), - writeln(Out, '.') - ; true - ), - writeln(Out, 'end_of_file.'), - close(Out) - ; true - ), - ( \+implies(_, answer(_, _, _), _), - \+implies(_, (answer(_, _, _), _), _), - \+query(_, _), - \+flag('pass-only-new'), - \+flag('multi-query'), - \+flag(strings) - -> throw(halt(0)) - ; true - ), - ( flag(nope) - -> true - ; ( pfx('r:', _) - -> true - ; assertz(pfx('r:', '')) - ), - ( pfx('var:', _) - -> true - ; assertz(pfx('var:', '')) - ), - ( pfx('skolem:', _) - -> true - ; nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, '>'], B), - assertz(pfx('skolem:', B)) - ), - ( pfx('n3:', _) - -> true - ; assertz(pfx('n3:', '')) - ) - ), - nb_setval(tr, 0), - nb_setval(tc, 0), - nb_setval(tp, 0), - nb_setval(rn, 0), - nb_setval(lemma_count, 0), - nb_setval(lemma_cursor, 0), - nb_setval(answer_count, 0), - ( flag('multi-query') - -> nb_setval(mq, 0), - repeat, - catch((read_line_to_codes(user_input, Fc), atom_codes(Fa, Fc)), _, Fa = end_of_file), - ( atomic_list_concat([Fi, Fo], ', ', Fa) - -> open(Fo, write, Fos, [encoding(utf8)]) - ; Fi = Fa, - ( flag('output', Output) - -> Fos = Output - ; Fos = user_output - ) - ), - tell(Fos), - ( Fi = end_of_file - -> true - ; statistics(walltime, [_, _]), - nb_getval(output_statements, Outb), - statistics(inferences, Infb), - ( flag(blogic) - -> Amq = ['--n3', Fi] - ; Amq = ['--query', Fi] - ), - catch(args(Amq), Exc1, - ( format(user_error, '** ERROR ** args ** ~w~n', [Exc1]), - flush_output(user_error), - nb_setval(exit_code, 3) - ) - ), - catch(eam(0), Exc2, - ( ( Exc2 = halt(0) - -> true - ; format(user_error, '** ERROR ** eam ** ~w~n', [Exc2]), - flush_output(user_error), - ( Exc2 = inference_fuse(_) - -> nb_setval(exit_code, 2) - ; nb_setval(exit_code, 3) - ) - ) - ) - ), - ( flag(strings) - -> wst - ; true - ), - forall( - ( answer(A1, A2, A3), - nonvar(A1) - ), - retract(answer(A1, A2, A3)) - ), - retractall(implies(_, answer(_, _, _), _)), - retractall(implies(_, (answer(_, _, _), _), _)), - retractall(query(_, _)), - retractall(''(_, _)), - retractall(cc(_)), - retractall(brake), - retractall(prfstep(answer(_, _, _), _, _, _, _, _, _)), - retractall(lemma(_, _, _, _, _, _)), - retractall(got_wi(_, _, _, _, _)), - retractall(wpfx(_)), - retractall(''(_, _)), - retractall(''(_, _)), - nb_setval(csv_header, []), - cnt(mq), - nb_getval(mq, Cnt), - ( Cnt mod 10000 =:= 0 - -> garbage_collect_atoms - ; true - ), - statistics(runtime, [_, Ti4]), - statistics(walltime, [_, Ti5]), - format(user_error, 'reasoning ~w [msec cputime] ~w [msec walltime]~n', [Ti4, Ti5]), - flush_output(user_error), - nb_getval(output_statements, Oute), - Outd is Oute-Outb, - catch(Outs is round(Outd/Ti5*1000), _, Outs = ''), - ( ( flag(strings) - ; flag(quiet) - ) - -> nl - ; format('#DONE ~3d [sec] mq=~w out=~d out/sec=~w~n~n', [Ti5, Cnt, Outd, Outs]) - ), - timestamp(Stmp), - statistics(inferences, Infe), - Infd is Infe-Infb, - catch(Infs is round(Infd/Ti5*1000), _, Infs = ''), - format(user_error, '~w mq=~w out=~d inf=~w sec=~3d out/sec=~w inf/sec=~w~n~n', [Stmp, Cnt, Outd, Infd, Ti5, Outs, Infs]), - flush_output(user_error), - fail - ), - told - ; ( flag(profile) - -> asserta(pce_profile:pce_show_profile :- fail), - profiler(_, cputime) - ; true - ), - catch(eam(0), Exc3, - ( ( Exc3 = halt(0) - -> true - ; format(user_error, '** ERROR ** eam ** ~w~n', [Exc3]), - flush_output(user_error), - ( Exc3 = inference_fuse(_) - -> nb_setval(exit_code, 2) - ; nb_setval(exit_code, 3) - ) - ) - ) - ), - ( flag('pass-only-new') - -> wh, - forall( - pass_only_new(Zn), - ( indent, - relabel(Zn, Zr), - wt(Zr), - ws(Zr), - write('.'), - nl, - cnt(output_statements) - ) - ), - nl - ; true - ), - ( flag(profile) - -> profiler(_, false), - tell(user_error), - show_profile([]), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ) - ; true - ) - ), - ( flag(strings) - -> wst - ; true - ), - nb_getval(tc, TC), - nb_getval(tp, TP), - statistics(runtime, [_, T4]), - statistics(walltime, [_, T5]), - ( \+flag('multi-query') - -> format(user_error, 'reasoning ~w [msec cputime] ~w [msec walltime]~n', [T4, T5]), - flush_output(user_error) - ; true - ), - nb_getval(input_statements, Inp), - nb_getval(output_statements, Outp), - timestamp(Stamp), - Ent is TC, - Step is TP, - statistics(runtime, [Cpu, _]), - nb_getval(tr, TR), - Brake is TR, - ( statistics(inferences, Inf) - -> true - ; Inf = '' - ), - catch(Speed is round(Inf/Cpu*1000), _, Speed = ''), - ( ( flag(strings) - ; flag(quiet) - ) - -> true - ; format('#~w in=~d out=~d ent=~d step=~w brake=~w inf=~w sec=~3d inf/sec=~w~n#ENDS~n~n', [Stamp, Inp, Outp, Ent, Step, Brake, Inf, Cpu, Speed]) - ), - format(user_error, '~w in=~d out=~d ent=~d step=~w brake=~w inf=~w sec=~3d inf/sec=~w~n~n', [Stamp, Inp, Outp, Ent, Step, Brake, Inf, Cpu, Speed]), - flush_output(user_error), - ( flag('rule-histogram') - -> findall([RTC, RTP, R], - ( tabl(ETP, tp, Rule), - nb_getval(ETP, RTP), - ( tabl(ETC, tc, Rule) - -> nb_getval(ETC, RTC) - ; RTC = 0 - ), - with_output_to(atom(R), wt(Rule)) - ), - CntRl - ), - sort(CntRl, CntRs), - reverse(CntRs, CntRr), - format(user_error, '>>> rule histogram TR=~w <<<~n', [TR]), - forall( - member(RCnt, CntRr), - ( ( last(RCnt, ''(X, Y)), - conj_append(X, pstep(_), Z), - catch(clause(Y, Z), _, fail) - -> format(user_error, 'TC=~w TP=~w for component ~w~n', RCnt) - ; format(user_error, 'TC=~w TP=~w for rule ~w~n', RCnt) - ) - ) - ), - format(user_error, '~n', []), - flush_output(user_error) - ; true - ). - -% -% command line options -% - -opts([], []) :- - !. -opts(['--blogic'|Argus], Args) :- - !, - retractall(flag(blogic)), - assertz(flag(blogic)), - assertz(implies(''(_, G), G, '<>')), - assertz(implies((''(V, G), - makevars(G, H, beta(V)), - call(H) - ), false, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(W, H), L, K), - conj_list(C, K), - conj_list(H, M), - select(''(W, C), M, _) - ), ''(W, C), '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(_, H), L, K), - conj_list(C, K), - makevars(''(C, H), B, beta(V)) - ), B, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(W, H), L, K), - dsplit(K, M, J), - J \= [], - conj_list(R, M), - conj_list(T, J), - ( H = ''(W, A) - -> D = A - ; D = ''(W, H) - ), - ( T = ''(W, F) - -> E = F - ; E = ''(W, T) - ), - makevars(''((D, R), E), B, beta(V)) - ), B, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(W, H), L, K), - conj_list(R, K), - ( H = ''(W, A) - -> D = A - ; D = ''(W, H) - ), - makevars(''(R, D), B, beta(V)) - ), B, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - findall(M, - ( member(M, L), - M \= ''(_, _) - ), - J - ), - conj_list(C, J), - length(L, N), - length(J, K), - I is N-K, - I > 1, - makevars([C,L], [D,E], beta(V)), - call(D), - implies(_, H, _), - findall(F, - ( member(''(_, S), E), - implies(S, F, _) - ), - Q - ), - length(Q, I), - sort(Q, [H]) - ), H, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(_, H), L, K), - conj_list(R, K), - makevars(':-'(H, R), C, beta(V)), - copy_term_nat(C, CC), - labelvars(CC, 0, _, avar), - ( \+cc(CC) - -> assertz(cc(CC)), - assertz(C) - ; true - )), true, '<>')), - assertz(implies((''(V, G), - djiti_answer(answer(G), H), - makevars(implies(G, H, '<>'), C, beta(V)), - copy_term_nat(C, CC), - labelvars(CC, 0, _, avar), - ( \+cc(CC) - -> assertz(cc(CC)), - assertz(C), - retractall(brake) - ; true - )), true, '<>')), - opts(Argus, Args). -opts(['--csv-separator',Separator|Argus], Args) :- - !, - retractall(flag('csv-separator')), - assertz(flag('csv-separator', Separator)), - opts(Argus, Args). -opts(['--debug'|Argus], Args) :- - !, - retractall(flag(debug)), - assertz(flag(debug)), - opts(Argus, Args). -opts(['--debug-cnt'|Argus], Args) :- - !, - retractall(flag('debug-cnt')), - assertz(flag('debug-cnt')), - opts(Argus, Args). -opts(['--debug-djiti'|Argus], Args) :- - !, - retractall(flag('debug-djiti')), - assertz(flag('debug-djiti')), - opts(Argus, Args). -opts(['--debug-pvm'|Argus], Args) :- - !, - retractall(flag('debug-pvm')), - assertz(flag('debug-pvm')), - opts(Argus, Args). -opts(['--help'|_], _) :- - \+flag(image, _), - \+flag('debug-pvm'), - !, - help_info(Help), - format(user_error, '~w~n', [Help]), - flush_output(user_error), - throw(halt(0)). -opts(['--hmac-key',Key|Argus], Args) :- - !, - retractall(flag('hmac-key', _)), - assertz(flag('hmac-key', Key)), - opts(Argus, Args). -opts(['--ignore-inference-fuse'|Argus], Args) :- - !, - retractall(flag('ignore-inference-fuse')), - assertz(flag('ignore-inference-fuse')), - opts(Argus, Args). -opts(['--image',File|Argus], Args) :- - !, - retractall(flag(image, _)), - assertz(flag(image, File)), - opts(Argus, Args). -opts(['--license'|_], _) :- - !, - license_info(License), - format(user_error, '~w~n', [License]), - flush_output(user_error), - throw(halt(0)). -opts(['--max-inferences',Lim|Argus], Args) :- - !, - ( number(Lim) - -> Limit = Lim - ; catch(atom_number(Lim, Limit), Exc, - ( format(user_error, '** ERROR ** max-inferences ** ~w~n', [Exc]), - flush_output(user_error), - flush_output, - throw(halt(1)) - ) - ) - ), - retractall(flag('max-inferences', _)), - assertz(flag('max-inferences', Limit)), - opts(Argus, Args). -opts(['--multi-query'|Argus], Args) :- - !, - retractall(flag('multi-query')), - assertz(flag('multi-query')), - opts(Argus, Args). -opts(['--no-distinct-input'|Argus], Args) :- - !, - retractall(flag('no-distinct-input')), - assertz(flag('no-distinct-input')), - opts(Argus, Args). -opts(['--no-distinct-output'|Argus], Args) :- - !, - retractall(flag('no-distinct-output')), - assertz(flag('no-distinct-output')), - opts(Argus, Args). -opts(['--no-erase'|Argus], Args) :- - !, - retractall(flag('no-erase')), - assertz(flag('no-erase')), - opts(Argus, Args). -opts(['--no-numerals'|Argus], Args) :- - !, - retractall(flag('no-numerals')), - assertz(flag('no-numerals')), - opts(Argus, Args). -opts(['--no-qnames'|Argus], Args) :- - !, - retractall(flag('no-qnames')), - assertz(flag('no-qnames')), - opts(Argus, Args). -opts(['--no-qvars'|Argus], Args) :- - !, - retractall(flag('no-qvars')), - assertz(flag('no-qvars')), - opts(Argus, Args). -opts(['--no-ucall'|Argus], Args) :- - !, - retractall(flag('no-ucall')), - assertz(flag('no-ucall')), - opts(Argus, Args). -opts(['--nope'|Argus], Args) :- - !, - retractall(flag(nope)), - assertz(flag(nope)), - opts(Argus, Args). -opts(['--output',File|Argus], Args) :- - !, - retractall(flag('output', _)), - open(File, write, Out, [encoding(utf8)]), - tell(Out), - assertz(flag('output', Out)), - opts(Argus, Args). -opts(['--pass-all-ground'|Argus], Args) :- - !, - retractall(flag('pass-all-ground')), - assertz(flag('pass-all-ground')), - opts(['--pass-all'|Argus], Args). -opts(['--pass-only-new'|Argus], Args) :- - !, - retractall(flag('pass-only-new')), - assertz(flag('pass-only-new')), - opts(Argus, Args). -opts(['--intermediate',File|Argus], Args) :- - !, - retractall(flag('intermediate', _)), - open(File, write, Out, [encoding(utf8)]), - assertz(flag('intermediate', Out)), - opts(Argus, Args). -opts(['--profile'|Argus], Args) :- - !, - retractall(flag(profile)), - assertz(flag(profile)), - opts(Argus, Args). -opts(['--quantify',Prefix|Argus], Args) :- - !, - assertz(flag('quantify', Prefix)), - opts(Argus, Args). -opts(['--quiet'|Argus], Args) :- - !, - retractall(flag(quiet)), - assertz(flag(quiet)), - opts(Argus, Args). -opts(['--random-seed'|Argus], Args) :- - !, - N is random(2^120), - nb_setval(random, N), - opts(Argus, Args). -opts(['--restricted'|Argus], Args) :- - !, - retractall(flag(restricted)), - assertz(flag(restricted)), - opts(Argus, Args). -opts(['--rule-histogram'|Argus], Args) :- - !, - retractall(flag('rule-histogram')), - assertz(flag('rule-histogram')), - opts(Argus, Args). -opts(['--skolem-genid',Genid|Argus], Args) :- - !, - retractall(flag('skolem-genid', _)), - assertz(flag('skolem-genid', Genid)), - opts(Argus, Args). -opts(['--statistics'|Argus], Args) :- - !, - retractall(flag(statistics)), - assertz(flag(statistics)), - opts(Argus, Args). -opts(['--strings'|Argus], Args) :- - !, - retractall(flag(strings)), - assertz(flag(strings)), - opts(Argus, Args). -opts(['--tactic','limited-answer',Lim|Argus], Args) :- - !, - ( number(Lim) - -> Limit = Lim - ; catch(atom_number(Lim, Limit), Exc, - ( format(user_error, '** ERROR ** limited-answer ** ~w~n', [Exc]), - flush_output(user_error), - flush_output, - throw(halt(1)) - ) - ) - ), - retractall(flag('limited-answer', _)), - assertz(flag('limited-answer', Limit)), - opts(Argus, Args). -opts(['--tactic','linear-select'|Argus], Args) :- - !, - retractall(flag(tactic, 'linear-select')), - assertz(flag(tactic, 'linear-select')), - opts(Argus, Args). -opts(['--tactic',Tactic|_], _) :- - !, - throw(not_supported_tactic(Tactic)). -opts(['--version'|_], _) :- - !, - throw(halt(0)). -opts(['--warn'|Argus], Args) :- - !, - retractall(flag(warn)), - assertz(flag(warn)), - opts(Argus, Args). -opts(['--wcache',Argument,File|Argus], Args) :- - !, - absolute_uri(Argument, Arg), - retractall(wcache(Arg, _)), - assertz(wcache(Arg, File)), - opts(Argus, Args). -opts([Arg|_], _) :- - \+memberchk(Arg, ['--entail', '--help', '--n3', '--n3p', '--not-entail', '--pass', '--pass-all', '--proof', '--query', '--turtle']), - sub_atom(Arg, 0, 2, _, '--'), - !, - throw(not_supported_option(Arg)). -opts([Arg|Argus], [Arg|Args]) :- - opts(Argus, Args). - -args([]) :- - !. -args(['--entail',Arg|Args]) :- - !, - nb_setval(entail_mode, true), - n3_n3p(Arg, entail), - nb_setval(entail_mode, false), - args(Args). -args(['--not-entail',Arg|Args]) :- - !, - nb_setval(entail_mode, true), - n3_n3p(Arg, 'not-entail'), - nb_setval(entail_mode, false), - args(Args). -args(['--n3',Arg|Args]) :- - !, - absolute_uri(Arg, A), - atomic_list_concat(['<', A, '>'], R), - assertz(scope(R)), - ( flag('intermediate', Out) - -> portray_clause(Out, scope(R)) - ; true - ), - n3_n3p(Arg, data), - nb_setval(fdepth, 0), - nb_setval(pdepth, 0), - nb_setval(cdepth, 0), - args(Args). -args(['--n3p',Argument|Args]) :- - !, - absolute_uri(Argument, Arg), - ( wcacher(Arg, File) - -> format(user_error, 'GET ~w FROM ~w ', [Arg, File]), - flush_output(user_error), - open(File, read, In, [encoding(utf8)]) - ; format(user_error, 'GET ~w ', [Arg]), - flush_output(user_error), - ( ( sub_atom(Arg, 0, 5, _, 'http:') - -> true - ; sub_atom(Arg, 0, 6, _, 'https:') - ) - -> http_open(Arg, In, []), - set_stream(In, encoding(utf8)) - ; ( sub_atom(Arg, 0, 5, _, 'file:') - -> ( parse_url(Arg, Parts) - -> memberchk(path(File), Parts) - ; sub_atom(Arg, 7, _, 0, File) - ) - ; File = Arg - ), - ( File = '-' - -> In = user_input - ; open(File, read, In, [encoding(utf8)]) - ) - ) - ), - repeat, - read_term(In, Rt, []), - ( Rt = end_of_file - -> catch(read_term(In, _, []), _, true) - ; n3pin(Rt, In, File, data), - fail - ), - !, - ( File = '-' - -> true - ; close(In) - ), - ( retract(tmpfile(File)) - -> delete_file(File) - ; true - ), - findall(SCnt, - ( retract(scount(SCnt)) - ), - SCnts - ), - sum(SCnts, SC), - nb_getval(input_statements, IN), - Inp is SC+IN, - nb_setval(input_statements, Inp), - ( SC =\= 0 - -> format(user_error, 'SC=~w~n', [SC]) - ; format(user_error, '~n', []) - ), - flush_output(user_error), - args(Args). -args(['--pass'|Args]) :- - !, - ( flag(nope), - \+flag('limited-answer', _), - ( flag('no-distinct-input') - -> flag('no-distinct-output') - ; true - ), - \+implies(_, answer(_, _, _), _), - \+implies(_, (answer(_, _, _), _), _) - -> assertz(query(exopred(P, S, O), exopred(P, S, O))) - ; assertz(implies(exopred(P, S, O), answer(P, S, O), '')) - ), - ( flag('intermediate', Out) - -> portray_clause(Out, implies(exopred(P, S, O), answer(P, S, O), '')) - ; true - ), - args(Args). -args(['--pass-all'|Args]) :- - !, - assertz(implies((exopred(P, S, O), ''(P, '')), - answer(P, S, O), '')), - assertz(implies((''(A, C), ''(A, true)), - answer('', A, C), '')), - assertz(implies(':-'(C, A), - answer(':-', C, A), '')), - ( flag('intermediate', Out) - -> portray_clause(Out, implies((exopred(P, S, O), ''(P, '')), - answer(P, S, O), '')), - portray_clause(user_error, implies((''(A, C), ''(A, true)), - answer('', A, C), '')), - portray_clause(user_error, implies((':-'(C, A), ''(A, true)), - answer(':-', C, A), '')) - ; true - ), - args(Args). -args(['--proof',Arg|Args]) :- - !, - absolute_uri(Arg, A), - atomic_list_concat(['<', A, '>'], R), - assertz(scope(R)), - ( flag('intermediate', Out) - -> portray_clause(Out, scope(R)) - ; true - ), - n3_n3p(Arg, data), - ( got_pi - -> true - ; assertz(implies((''(LEMMA, ''), - ''(LEMMA, GRAPH), - ''(GRAPH, exopred(P, S, O))), - exopred(P, S, O), '')), - assertz(implies((''(LEMMA, ''), - ''(LEMMA, GRAPH), - ''(GRAPH, exopred(P, S, O))), - exopred(P, S, O), '')), - assertz(got_pi) - ), - args(Args). -args(['--query',Arg|Args]) :- - !, - n3_n3p(Arg, query), - args(Args). -args(['--turtle',Argument|Args]) :- - !, - absolute_uri(Argument, Arg), - atomic_list_concat(['<', Arg, '>'], R), - assertz(scope(R)), - ( flag('intermediate', Out) - -> portray_clause(Out, scope(R)) - ; true - ), - ( wcacher(Arg, File) - -> format(user_error, 'GET ~w FROM ~w ', [Arg, File]), - flush_output(user_error), - open(File, read, In, [encoding(utf8)]) - ; format(user_error, 'GET ~w ', [Arg]), - flush_output(user_error), - ( ( sub_atom(Arg, 0, 5, _, 'http:') - -> true - ; sub_atom(Arg, 0, 6, _, 'https:') - ) - -> http_open(Arg, In, []), - set_stream(In, encoding(utf8)) - ; ( sub_atom(Arg, 0, 5, _, 'file:') - -> ( parse_url(Arg, Parts) - -> memberchk(path(File), Parts) - ; sub_atom(Arg, 7, _, 0, File) - ) - ; File = Arg - ), - ( File = '-' - -> In = user_input - ; open(File, read, In, [encoding(utf8)]) - ) - ) - ), - retractall(base_uri(_)), - ( Arg = '-' - -> absolute_uri('', Abu), - assertz(base_uri(Abu)) - ; assertz(base_uri(Arg)) - ), - retractall(ns(_, _)), - ( Arg = '-' - -> D = '#' - ; atomic_list_concat([Arg, '#'], D) - ), - assertz(ns('', D)), - nb_setval(sc, 0), - rdf_read_turtle(stream(In), Triples, []), - close(In), - forall( - member(rdf(S, P, O), Triples), - ( ttl_n3p(S, Subject), - ttl_n3p(P, Predicate), - ttl_n3p(O, Object), - Triple =.. [Predicate, Subject, Object], - djiti_assertz(Triple), - ( flag('intermediate', Out) - -> format(Out, '~q.~n', [Triple]) - ; true - ), - ( flag(nope) - -> true - ; assertz(prfstep(Triple, true, _, Triple, _, forward, R)) - ) - ) - ), - length(Triples, SC), - nb_getval(input_statements, IN), - Inp is SC+IN, - nb_setval(input_statements, Inp), - format(user_error, 'SC=~w~n', [SC]), - flush_output(user_error), - args(Args). -args([Arg|Args]) :- - args(['--n3', Arg|Args]). - -n3pin(Rt, In, File, Mode) :- - ( Rt = ':-'(Rg) - -> ( flag('parse-only') - -> true - ; call(Rg) - ), - ( flag('intermediate', Out) - -> format(Out, '~q.~n', [Rt]) - ; true - ) - ; dynify(Rt), - ( ( Rt = ':-'(Rh, _) - -> predicate_property(Rh, dynamic) - ; predicate_property(Rt, dynamic) - ) - -> true - ; ( File = '-' - -> true - ; close(In) - ), - ( retract(tmpfile(File)) - -> delete_file(File) - ; true - ), - throw(builtin_redefinition(Rt)) - ), - ( Rt = pfx(Pfx, _) - -> retractall(pfx(Pfx, _)) - ; true - ), - ( Rt = scope(Scope) - -> nb_setval(current_scope, Scope) - ; true - ), - ( Rt = ':-'(Ci, Px), - conjify(Px, Pi) - -> ( Ci = true - -> ( flag('parse-only') - -> true - ; call(Pi) - ) - ; nb_getval(current_scope, Si), - copy_term_nat(''(Pi, Ci), Ri), - ( flag(nope) - -> Ph = Pi - ; ( Pi = when(Ai, Bi) - -> conj_append(Bi, istep(Si, Pi, Ci, Ri), Bh), - Ph = when(Ai, Bh) - ; conj_append(Pi, istep(Si, Pi, Ci, Ri), Ph) - ) - ), - ( flag('rule-histogram') - -> ( Ph = when(Ak, Bk) - -> conj_append(Bk, pstep(Ri), Bj), - Pj = when(Ak, Bj) - ; conj_append(Ph, pstep(Ri), Pj) - ) - ; Pj = Ph - ), - functor(Ci, CPi, _), - ( flag('intermediate', Out) - -> ( \+cpred(CPi) - -> portray_clause(Out, cpred(CPi)) - ; true - ), - portray_clause(Out, ':-'(Ci, Pi)) - ; true - ), - ( \+cpred(CPi) - -> assertz(cpred(CPi)) - ; true - ), - assertz(':-'(Ci, Pj)) - ) - ; ( Rt \= implies(_, _, _), - Rt \= scount(_), - \+flag('no-distinct-input'), - call(Rt) - -> true - ; ( Rt \= pred(''), - \+ (Rt = scope(_), Mode = query) - -> djiti_assertz(Rt), - ( flag('intermediate', Out), - Rt \= scount(_) - -> format(Out, '~q.~n', [Rt]) - ; true - ), - ( Rt \= flag(_, _), - Rt \= scope(_), - Rt \= pfx(_, _), - Rt \= pred(_), - Rt \= cpred(_), - Rt \= scount(_) - -> ( flag(nope) - -> true - ; term_index(true, Pnd), - nb_getval(current_scope, Src), - assertz(prfstep(Rt, true, Pnd, Rt, _, forward, Src)) - ) - ; true - ) - ; true - ) - ) - ) - ). - -% N3 to N3P compiler - -n3_n3p(Argument, Mode) :- - absolute_uri(Argument, Arg), - tmp_file(Tmp), - ( wcacher(Arg, File) - -> format(user_error, 'GET ~w FROM ~w ', [Arg, File]), - flush_output(user_error), - open(File, read, In, [encoding(utf8)]) - ; format(user_error, 'GET ~w ', [Arg]), - flush_output(user_error), - ( ( sub_atom(Arg, 0, 5, _, 'http:') - -> true - ; sub_atom(Arg, 0, 6, _, 'https:') - ) - -> http_open(Arg, In, []), - set_stream(In, encoding(utf8)) - ; ( sub_atom(Arg, 0, 5, _, 'file:') - -> ( parse_url(Arg, Parts) - -> memberchk(path(File), Parts) - ; sub_atom(Arg, 7, _, 0, File) - ) - ; File = Arg - ), - ( File = '-' - -> In = user_input - ; open(File, read, In, [encoding(utf8)]) - ) - ) - ), - retractall(base_uri(_)), - ( Arg = '-' - -> absolute_uri('', Abu), - assertz(base_uri(Abu)) - ; assertz(base_uri(Arg)) - ), - retractall(ns(_, _)), - ( Arg = '-' - -> D = '#' - ; atomic_list_concat([Arg, '#'], D) - ), - assertz(ns('', D)), - retractall(quvar(_, _, _)), - retractall(qevar(_, _, _)), - retractall(evar(_, _, _)), - nb_setval(line_number, 1), - nb_setval(sc, 0), - nb_setval(semantics, []), - atomic_list_concat(['\'<', Arg, '>\''], Src), - atomic_list_concat([Tmp, '_p'], Tmp_p), - assertz(tmpfile(Tmp_p)), - open(Tmp_p, write, Ws, [encoding(utf8)]), - tell(Ws), - catch( - ( repeat, - tokens(In, Tokens), - phrase(document(Triples), Tokens, Rest), - ( Rest = [] - -> true - ; nb_getval(line_number, Ln), - throw(invalid_document(after_line(Ln))) - ), - ( Mode = semantics - -> nb_getval(semantics, TriplesPrev), - append(TriplesPrev, Triples, TriplesNext), - findall(Tr, - ( member(Triple, TriplesNext), - ( Triple = ':-'(Head, Body) - -> Tr = '\'\''(Body, Head) - ; Tr = Triple - ) - ), - TriplesNext2 - ), - nb_setval(semantics, TriplesNext2) - ; tr_n3p(Triples, Src, Mode) - ), - Tokens = [] - ), - Exc2, - ( ( Mode = semantics - -> told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - throw(Exc2) - ; true - ), - ( wcacher(Arg, File) - -> format(user_error, '** ERROR ** ~w FROM ~w ** ~w~n', [Arg, File, Exc2]) - ; format(user_error, '** ERROR ** ~w ** ~w~n', [Arg, Exc2]) - ), - flush_output(user_error), - nb_setval(exit_code, 1), - ( ( \+data_fuse, - Mode == 'not-entail' - ; data_fuse, - Mode == entail - ) - -> write(query(true, true)), - writeln('.') - ; true - ), - assertz(data_fuse) - ) - ), - ( Mode = semantics - -> nb_getval(semantics, List), - write(semantics(Src, List)), - writeln('.') - ; true - ), - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - ( File = '-' - -> true - ; close(In) - ), - ( retract(tmpfile(Tmp)) - -> delete_file(Tmp) - ; true - ), - ( flag('intermediate', Out) - -> forall( - ( pfx(Pp, Pu), - \+wpfx(Pp) - ), - ( portray_clause(Out, pfx(Pp, Pu)), - assertz(wpfx(Pp)) - ) - ) - ; true - ), - open(Tmp_p, read, Rs, [encoding(utf8)]), - ( Mode = semantics - -> repeat, - read(Rs, Rt), - ( Rt = end_of_file - -> true - ; djiti_assertz(Rt), - ( Rt = semantics(_, L) - -> length(L, N), - nb_setval(sc, N) - ; Rt \= semantics(_, []), - nb_setval(sc, 1) - ), - fail - ) - ; repeat, - read(Rs, Rt), - ( Rt = end_of_file - -> true - ; dynify(Rt), - ( ground(Rt), - Rt \= ':-'(_, _) - -> ( predicate_property(Rt, dynamic) - -> true - ; close(Rs), - ( retract(tmpfile(Tmp_p)) - -> delete_file(Tmp_p) - ; true - ), - throw(builtin_redefinition(Rt)) - ), - ( Rt \= implies(_, _, _), - \+flag('no-distinct-input'), - call(Rt) - -> true - ; djiti_assertz(Rt), - cnt(sc), - ( flag('intermediate', Out) - -> portray_clause(Out, Rt) - ; true - ) - ) - ; ( Rt = prfstep(Ct, Pt, _, Qt, It, Mt, St) - -> term_index(Pt, Pnd), - ( nonvar(It) - -> copy_term_nat(It, Ic) - ; Ic = It - ), - ( \+prfstep(Ct, Pt, Pnd, Qt, Ic, Mt, St) - -> assertz(prfstep(Ct, Pt, Pnd, Qt, Ic, Mt, St)) - ; true - ) - ; ( Rt = ':-'(Ci, Px), - ( Px = true - -> functor(Ci, Cf, _), - ( \+pred(Cf), - \+cpred(Cf) - -> assertz(pred(Cf)) - ; true - ) - ; true - ), - conjify(Px, Pi) - -> ( Ci = true - -> ( flag('intermediate', Out) - -> portray_clause(Out, ':-'(Pi)) - ; true - ), - ( flag('parse-only') - -> true - ; call(Pi) - ) - ; atomic_list_concat(['<', Arg, '>'], Si), - copy_term_nat(''(Pi, Ci), Ri), - ( flag(nope) - -> Ph = Pi - ; ( Pi = when(Ai, Bi) - -> conj_append(Bi, istep(Si, Pi, Ci, Ri), Bh), - Ph = when(Ai, Bh) - ; conj_append(Pi, istep(Si, Pi, Ci, Ri), Ph) - ) - ), - ( flag('rule-histogram') - -> ( Ph = when(Ak, Bk) - -> conj_append(Bk, pstep(Ri), Bj), - Pj = when(Ak, Bj) - ; conj_append(Ph, pstep(Ri), Pj) - ) - ; Pj = Ph - ), - cnt(sc), - functor(Ci, CPi, _), - ( flag('intermediate', Out) - -> ( \+cpred(CPi) - -> portray_clause(Out, cpred(CPi)) - ; true - ), - portray_clause(Out, ':-'(Ci, Pi)) - ; true - ), - ( \+cpred(CPi) - -> assertz(cpred(CPi)) - ; true - ), - assertz(':-'(Ci, Pj)) - ) - ; djiti_assertz(Rt), - cnt(sc), - ( flag('intermediate', Out) - -> portray_clause(Out, Rt) - ; true - ) - ) - ) - ), - fail - ) - ), - close(Rs), - ( retract(tmpfile(Tmp_p)) - -> delete_file(Tmp_p) - ; true - ), - nb_getval(sc, SC), - nb_getval(input_statements, IN), - Inp is SC+IN, - nb_setval(input_statements, Inp), - format(user_error, 'SC=~w~n', [SC]), - flush_output(user_error), - !. - -tr_n3p([], _, _) :- - !. -tr_n3p(X, _, entail) :- - !, - conj_list(Y, X), - write(query(Y, true)), - writeln('.'). -tr_n3p(X, _, 'not-entail') :- - !, - conj_list(Y, X), - write(query(\+Y, true)), - writeln('.'). -tr_n3p(['\'\''(X, Y)|Z], Src, query) :- - !, - ( Y = '\'\''(_, T) - -> ( is_list(T) - -> H = T - ; findvars(X, U, epsilon), - distinct(U, H) - ), - nb_setval(csv_header, H), - V = '\'\''(_, H) - ; V = Y - ), - ( \+flag('limited-answer', _), - flag(nope), - ( flag('no-distinct-output') - ; V = '\'\''(_, _) - ) - -> write(query(X, V)), - writeln('.') - ; djiti_answer(answer(V), A), - write(implies(X, A, Src)), - writeln('.') - ), - tr_n3p(Z, Src, query). -tr_n3p([':-'(Y, X)|Z], Src, query) :- - !, - ( Y = '\'\''(_, T) - -> ( is_list(T) - -> H = T - ; findvars(X, U, epsilon), - distinct(U, H) - ), - nb_setval(csv_header, H), - V = '\'\''(_, H) - ; V = Y - ), - ( ( \+flag('limited-answer', _) - ; V = '\'\''(_, _), - flag(strings) - ), - flag(nope) - -> write(query(X, V)), - writeln('.') - ; djiti_answer(answer(V), A), - write(implies(X, A, Src)), - writeln('.') - ), - tr_n3p(Z, Src, query). -tr_n3p(['\'\''(X, Y)|Z], Src, Mode) :- - !, - ( flag(tactic, 'linear-select') - -> write(implies(X, '\'\''(X, Y), Src)), - writeln('.'), - write(implies('\'\''(X, Y), Y, Src)), - writeln('.') - ; write(implies(X, Y, Src)), - writeln('.') - ), - tr_n3p(Z, Src, Mode). -tr_n3p([':-'(Y, X)|Z], Src, Mode) :- - !, - tr_tr(Y, U), - write(':-'(U, X)), - writeln('.'), - tr_n3p(Z, Src, Mode). -tr_n3p(['\'\''(X, Y)|Z], Src, Mode) :- - !, - write('\'\''(X, Y)), - writeln('.'), - tr_n3p(Z, Src, Mode). -tr_n3p([X|Z], Src, Mode) :- - ( X \= '\'\''(_, _) - -> tr_tr(X, Y) - ; Y = X - ), - ( findvars(Y, U, epsilon), - U = [] - -> ( Y =.. [A, B, (C, D)] - -> format('~w(~w, (~w', [A, B, C]), - wcn(D), - format(')).~n') - ; write(Y), - writeln('.') - ), - ( flag(nope) - -> true - ; write(prfstep(Y, true, _, Y, _, forward, Src)), - writeln('.') - ) - ; write(':-'(Y, true)), - writeln('.') - ), - tr_n3p(Z, Src, Mode). - -tr_tr([], []) :- - !. -tr_tr([A|B], [C|D]) :- - !, - tr_tr(A, C), - tr_tr(B, D). -tr_tr(A, B) :- - atom(A), - !, - ( atom_concat('_', C, A), - ( sub_atom(C, 0, _, _, 'bn_') - ; sub_atom(C, 0, _, _, 'e_') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, C, '>\''], B) - ; B = A - ). -tr_tr(A, A) :- - number(A), - !. -tr_tr(A, B) :- - A =.. [C|D], - tr_tr(D, E), - B =.. [C|E]. - -tr_split([], [], []) :- - !. -tr_split([A|B], C, [A|D]) :- - functor(A, '\'\'', _), - !, - tr_split(B, C, D). -tr_split([A|B], C, D) :- - functor(A, '\'\'', _), - !, - tr_split(B, C, D). -tr_split([A|B], [A|C], D) :- - tr_split(B, C, D). - -ttl_n3p(literal(type(A, B)), literal(B, type(A))) :- - !. -ttl_n3p(literal(lang(A, B)), literal(B, lang(A))) :- - !. -ttl_n3p(literal(A), literal(A, type(''))) :- - !. -ttl_n3p(node(A), B) :- - !, - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'node_', A, '>'], B). -ttl_n3p(A, B) :- - atomic_list_concat(['<', A, '>'], B). - -% -% N3 parser -% -% according to http://www.w3.org/2000/10/swap/grammar/n3-ietf.txt -% inspired by http://code.google.com/p/km-rdf/wiki/Henry -% - -annotation(Triple, Triples) --> - [lb_pipe], - !, - propertylist(Triple, Triples), - { ( Triples \= [] - -> true - ; nb_getval(line_number, Ln), - throw('empty_triple_annotation'(after_line(Ln))) - ) - }, - [pipe_rb]. -annotation(_, []) --> - []. - -barename(BareName) --> - [name(BareName)]. - -barename_csl([BareName|Tail]) --> - barename(BareName), - !, - barename_csl_tail(Tail). -barename_csl([]) --> - []. - -barename_csl_tail([BareName|Tail]) --> - [','], - !, - barename(BareName), - barename_csl_tail(Tail). -barename_csl_tail([]) --> - []. - -boolean(true) --> - [name('true')], - !. -boolean(false) --> - [name('false')], - !. -boolean(Boolean) --> - literal(Atom, type(T)), - { T = '\'\'', - ( memberchk([Boolean, Atom], [[true, '\'true\''], [true, true], [true, '\'1\''], [false, '\'false\''], [false, false], [false, '\'0\'']]) - -> true - ; ( flag('parse-only') - -> true - ; nb_getval(line_number, Ln), - throw(invalid_boolean_literal(Atom, after_line(Ln))) - ) - ) - }. - -declaration --> - [atname(base)], - !, - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(base_uri(_)), - assertz(base_uri(URI)) - }. -declaration --> - [name(Name)], - { downcase_atom(Name, 'base') - }, - !, - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(base_uri(_)), - assertz(base_uri(URI)) - }, - withoutdot. -declaration --> - [atname(prefix)], - !, - prefix(Prefix), - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(ns(Prefix, _)), - assertz(ns(Prefix, URI)), - put_pfx(Prefix, URI) - }. -declaration --> - [name(Name)], - { downcase_atom(Name, 'prefix') - }, - prefix(Prefix), - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(ns(Prefix, _)), - assertz(ns(Prefix, URI)), - put_pfx(Prefix, URI) - }, - withoutdot. - -document(Triples) --> - statements_optional(Triples). - -dtlang(lang(Langcode)) --> - [atname(Name)], - { Name \= 'is', - Name \= 'has' - }, - !, - { downcase_atom(Name, N), - atomic_list_concat(['\'', N, '\''], Langcode) - }. -dtlang(type(Datatype)) --> - [caret_caret], - !, - uri(Datatype). -dtlang(type(T)) --> - { T = '\'\'' - }, - []. - -existential --> - [atname(forSome)], - !, - symbol_csl(Symbols), - { nb_getval(fdepth, D), - forall( - member(S, Symbols), - ( gensym('qe_', Q), - asserta(qevar(S, Q, D)) - ) - ) - }. - -explicituri(ExplicitURI) --> - [relative_uri(ExplicitURI)]. - -expression(Node, T) --> - pathitem(N1, T1), - pathtail(N1, Node, T2), - { append(T1, T2, T) - }. - -formulacontent(Formula) --> - statementlist(List), - { conj_list(Formula, List) - }. - -literal(Atom, DtLang) --> - string(Codes), - dtlang(DtLang), - { escape_string(Codes, B), - escape_string(B, C), - atom_codes(A, C), - ( sub_atom(A, _, 1, _, '\'') - -> escape_squote(C, D), - atom_codes(E, D) - ; E = A - ), - atomic_list_concat(['\'', E, '\''], Atom) - }. - -numericliteral(Number) --> - [numeric(_, NumB)], - { numeral(NumB, NumC), - number_codes(Number, NumC) - }. - -object(Node, Triples) --> - expression(Node, Triples). - -objecttail(Subject, Verb, [Triple|Triples]) --> - [','], - !, - object(Object, Triples1), - { ( Verb = isof(Vrb) - -> Trpl = triple(Object, Vrb, Subject) - ; Trpl = triple(Subject, Verb, Object) - ) - }, - annotation(Trpl, Triples2), - objecttail(Subject, Verb, Triples3), - { append([Triples1, Triples2, Triples3], Triples), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, Object, Subject] - ; Triple = exopred(V, Object, Subject) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, Subject, Object] - ; Triple = exopred(Verb, Subject, Object) - ) - ) - }. -objecttail(_, _, []) --> - []. - -pathitem(Name, []) --> - symbol(S), - !, - { ( qevar(S, N, D), - \+quvar(S, _, _) - -> ( D = 1, - nb_getval(fdepth, FD), - FD >= D, - \+flag('pass-all-ground') - -> atom_concat('_', N, Name) - ; atomic_list_concat(['\'\''], Name), - ( pfx('var:', _) - -> true - ; assertz(pfx('var:', '')) - ) - ) - ; ( quvar(S, N, D) - -> ( nb_getval(fdepth, FD), - FD >= D, - \+flag('pass-all-ground') - -> atom_concat('_', N, Name) - ; atomic_list_concat(['\'\''], Name), - ( pfx('var:', _) - -> true - ; assertz(pfx('var:', '')) - ) - ) - ; Name = S - ) - ) - }. -pathitem(VarID, []) --> - [uvar(Var)], - !, - { atom_codes(Var, VarCodes), - subst([[[0'-], [0'_, 0'M, 0'I, 0'N, 0'U, 0'S, 0'_]], [[0'.], [0'_, 0'D, 0'O, 0'T, 0'_]]], VarCodes, VarTidy), - atom_codes(VarAtom, [0'_|VarTidy]), - ( flag('pass-all-ground') - -> nb_getval(var_ns, Sns), - atom_codes(VarFrag, VarTidy), - atomic_list_concat(['\'<', Sns, VarFrag, '>\''], VarID) - ; VarID = VarAtom - ) - }. -pathitem(Number, []) --> - numericliteral(Number), - !. -pathitem(Boolean, []) --> - boolean(Boolean), - !. -pathitem(Atom, []) --> - literal(A, type(T)), - { T = '\'\'' - }, - !, - { atom_codes(A, B), - escape_string(C, B), - atom_codes(Atom, C) - }. -pathitem(Number, [], L1, L2) :- - literal(Atom, type(Type), L1, L2), - nb_getval(fdepth, 0), - memberchk(Type, ['\'\'', '\'\'', '\'\'', '\'\'']), - sub_atom(Atom, 1, _, 1, A), - atom_codes(A, NumB), - numeral(NumB, NumC), - number_codes(Number, NumC), - !. -pathitem(literal(Atom, DtLang), []) --> - literal(Atom, DtLang), - !. -pathitem(Subject, Triples) --> - ['[',name(id)], - !, - expression(Subject, T1), - propertylist(Subject, T2), - { append(T1, T2, Triples) - }, - [']']. -pathitem(Node, Triples) --> - ['['], - !, - { gensym('bn_', S), - ( ( nb_getval(entail_mode, false), - nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, S, '>\''], BN) - ; atom_concat('_', S, BN) - ) - }, - propertylist(BN, T), - { ( memberchk('\'\''(X, Head), T), - memberchk('\'\''(X, Tail), T), - del(T, '\'\''(X, '\'\''), U), - del(U, '\'\''(X, Head), V), - del(V, '\'\''(X, Tail), W) - -> Node = [Head|Tail], - Triples = W - ; Node = BN, - Triples = T - ) - }, - [']']. -pathitem(set(Distinct), Triples) --> - ['(', '$'], - !, - pathlist(List, Triples), - { sort(List, Distinct) - }, - ['$', ')']. -pathitem(List, Triples) --> - ['('], - !, - pathlist(List, Triples), - [')']. -pathitem(triple(S, P, O), Triples) --> - [lt_lt], - !, - pathlist(List, Triples), - { ( List = [S, P, O], - Triples = [] - -> true - ; nb_getval(line_number, Ln), - throw('invalid_n3_star_triple'(List, after_line(Ln))) - ) - }, - [gt_gt]. -pathitem(Node, []) --> - ['{'], - { nb_getval(fdepth, I), - J is I+1, - nb_setval(fdepth, J) - }, - formulacontent(Node), - { retractall(quvar(_, _, J)), - retractall(qevar(_, _, J)), - retractall(evar(_, _, J)), - nb_setval(fdepth, I), - ( nb_getval(entail_mode, true) - -> nb_getval(line_number, Ln), - throw(non_rdf_entailment(Node, after_line(Ln))) - ; true - ) - }, - ['}']. - -pathlist([Node|Rest], Triples) --> - expression(Node, T), - !, - pathlist(Rest, Tail), - { append(T, Tail, Triples) - }. -pathlist([], []) --> - []. - -pathtail(Node, PNode, [Triple|Triples]) --> - ['!'], - !, - pathitem(Item, Triples2), - { prolog_verb(Item, Verb), - gensym('bn_', S), - ( ( nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, S, '>\''], BNode) - ; atom_concat('_', S, BNode) - ), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, BNode, Node] - ; Triple = exopred(V, BNode, Node) - ) - ; ( Verb = prolog:Pred - -> ( BNode = true - -> Triple =.. [Pred|Node] - ; ( BNode = false - -> T =.. [Pred|Node], - Triple = \+(T) - ; ( prolog_sym(_, Pred, func) - -> T =.. [Pred|Node], - Triple = is(BNode, T) - ; Triple =.. [Pred, Node, BNode] - ) - ) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, Node, BNode] - ; Triple = exopred(Verb, Node, BNode) - ) - ) - ) - }, - pathtail(BNode, PNode, Tail), - { append(Triples2, Tail, Triples) - }. -pathtail(Node, PNode, [Triple|Triples]) --> - ['^'], - !, - pathitem(Item, Triples2), - { prolog_verb(Item, Verb), - gensym('bn_', S), - ( ( nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, S, '>\''], BNode) - ; atom_concat('_', S, BNode) - ), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, Node, BNode] - ; Triple = exopred(V, Node, BNode) - ) - ; ( Verb = prolog:Pred - -> ( Node = true - -> Triple =.. [Pred|BNode] - ; ( Node = false - -> T =.. [Pred|BNode], - Triple = \+(T) - ; ( prolog_sym(_, Pred, func) - -> T =.. [Pred|BNode], - Triple = is(Node, T) - ; Triple =.. [Pred, BNode, Node] - ) - ) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, BNode, Node] - ; Triple = exopred(Verb, BNode, Node) - ) - ) - ) - }, - pathtail(BNode, PNode, Tail), - { append(Triples2, Tail, Triples) - }. -pathtail(Node, Node, []) --> - []. - -prefix(Prefix) --> - [Prefix:'']. - -propertylist(Subject, [Triple|Triples]) --> - verb(Item, Triples1), - { prolog_verb(Item, Verb) - }, - !, - object(Object, Triples2), - { ( Verb = isof(Vrb) - -> Trpl = triple(Object, Vrb, Subject) - ; Trpl = triple(Subject, Verb, Object) - ) - }, - annotation(Trpl, Triples3), - objecttail(Subject, Verb, Triples4), - propertylisttail(Subject, Triples5), - { append([Triples1, Triples2, Triples3, Triples4, Triples5], Triples), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, Object, Subject] - ; Triple = exopred(V, Object, Subject) - ) - ; ( Verb = prolog:Pred - -> ( Object = true - -> Triple =.. [Pred|Subject] - ; ( Object = false - -> T =.. [Pred|Subject], - Triple = \+(T) - ; ( prolog_sym(_, Pred, func) - -> T =.. [Pred|Subject], - Triple = is(Object, T) - ; Triple =.. [Pred, Subject, Object] - ) - ) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, Subject, Object] - ; Triple = exopred(Verb, Subject, Object) - ) - ) - ) - }. -propertylist(_, []) --> - []. - -propertylisttail(Subject, Triples) --> - [';'], - !, - propertylisttailsemis, - propertylist(Subject, Triples). -propertylisttail(_, []) --> - []. - -propertylisttailsemis --> - [';'], - !, - propertylisttailsemis. -propertylisttailsemis --> - []. - -qname(URI) --> - [NS:Name], - { ( ns(NS, Base) - -> atomic_list_concat([Base, Name], Name1), - ( sub_atom(Name1, _, 1, _, '\'') - -> atom_codes(Name1, Codes1), - escape_squote(Codes1, Codes2), - atom_codes(Name2, Codes2) - ; Name2 = Name1 - ), - atomic_list_concat(['\'<', Name2, '>\''], URI) - ; nb_getval(line_number, Ln), - throw(no_prefix_directive(NS, after_line(Ln))) - ) - }, - !. - -simpleStatement(Triples) --> - subject(Subject, Triples1), - ( { Subject = (D1;D2) - } - -> { Triples = [(D1;D2)] - } - ; propertylist(Subject, Triples2), - { append(Triples1, Triples2, Triples) - } - ). - -statement([]) --> - declaration, - !. -statement([]) --> - universal, - !. -statement([]) --> - existential, - !. -statement(Statement) --> - simpleStatement(Statement). - -statementlist(Triples) --> - statement(Tr), - !, - statementtail(T), - { append(Tr, T, Triples) - }. -statementlist([]) --> - []. - -statements_optional(Triples) --> - statement(Tr), - [dot(Ln)], - !, - { nb_setval(line_number, Ln) - }, - statements_optional(T), - { append(Tr, T, Triples) - }. -statements_optional([]) --> - []. - -statementtail(T) --> - [dot(Ln)], - !, - { nb_setval(line_number, Ln) - }, - statementlist(T). -statementtail([]) --> - []. - -string(Codes) --> - [literal(Codes)]. - -subject(Node, Triples) --> - expression(Node, Triples). - -symbol(Name) --> - uri(Name), - !. -symbol(Name) --> - [name(N)], - !, - { ( memberchk(N, [true, false]) - -> Name = N - ; nb_getval(line_number, Ln), - throw(invalid_keyword(N, after_line(Ln))) - ) - }. -symbol(Name) --> - [bnode(Label)], - { ( flag(blogic) - -> D = 0 - ; nb_getval(fdepth, D) - ), - ( evar(Label, S, D) - -> true - ; atom_concat(Label, '_', M), - gensym(M, S), - assertz(evar(Label, S, D)) - ), - ( ( nb_getval(entail_mode, false), - nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - ( flag('pass-all-ground') - -> atomic_list_concat(['\'<', Sns, Label, '>\''], Name) - ; atomic_list_concat(['\'<', Sns, 'e_', S, '>\''], Name) - ) - ; atom_concat('_e_', S, Name) - ) - }. - -symbol_csl([Symbol|Tail]) --> - symbol(Symbol), - !, - symbol_csl_tail(Tail). -symbol_csl([]) --> - []. - -symbol_csl_tail([Symbol|T]) --> - [','], - !, - symbol(Symbol), - symbol_csl_tail(T). -symbol_csl_tail([]) --> - []. - -universal --> - [atname(forAll)], - !, - symbol_csl(Symbols), - { nb_getval(fdepth, D), - forall( - member(S, Symbols), - ( gensym('qu_', Q), - asserta(quvar(S, Q, D)) - ) - ) - }. - -uri(Name) --> - explicituri(U), - !, - { base_uri(V), - resolve_uri(U, V, W), - ( sub_atom(W, _, 1, _, '\'') - -> atom_codes(W, X), - escape_squote(X, Y), - atom_codes(Z, Y) - ; Z = W - ), - atomic_list_concat(['\'<', Z, '>\''], Name) - }. -uri(Name) --> - qname(Name). - -verb('\'\'', []) --> - ['=', '>'], - !. -verb('\'\'', []) --> - ['='], - !. -verb(':-', []) --> - [lt_eq], - !. -verb('\'\'', []) --> - [name(a)], - !. -verb(Node, Triples) --> - [name(has)], - !, - expression(Node, Triples). -verb(isof(Node), Triples) --> - [name(is)], - !, - expression(Node, Triples), - [name(of)]. -verb(isof(Node), Triples) --> - [lt_dash], - !, - expression(Node, Triples). -verb(Node, Triples) --> - expression(Node, Triples). - -withoutdot, [dot(Ln)] --> - [dot(Ln)], - !, - { throw(unexpected_dot(after_line(Ln))) - }. -withoutdot, [dot(Ln)] --> - [], - { nb_getval(line_number, Ln) - }. - -% -% N3 tokenizer -% - -tokens(In, List) :- - get_code(In, C0), - ( token(C0, In, C1, Tok1) - -> true - ; nb_getval(line_number, Ln), - char_code(Char, C0), - throw(illegal_token(char_code(Char, C0), line(Ln))) - ), - ( Tok1 == end_of_file - -> List = [] - ; List = [Tok1|Tokens], - tokens(C1, In, Tokens) - ). - -tokens(C0, In, List) :- - ( token(C0, In, C1, H) - -> true - ; nb_getval(line_number, Ln), - char_code(Char, C0), - throw(illegal_token(char_code(Char, C0), line(Ln))) - ), - ( H == end_of_file - -> List = [] - ; List = [H|T], - tokens(C1, In, T) - ). - -token(-1, _, -1, end_of_file) :- - !. -token(0'., In, C, Token) :- - ( peek_code(In, C0), - ( e(C0) - -> T1 = [0'0|T2], - get_code(In, CN1) - ; 0'0 =< C0, - C0 =< 0'9, - get_code(In, C1), - integer_codes(C1, In, CN1, T1, T2) - ) - -> ( exponent(CN1, In, C, T2) - -> Type = double - ; C = CN1, - T2 = [], - Type = decimal - ), - Token = numeric(Type, [0'0, 0'.|T1]) - ; nb_getval(line_number, Ln), - get_code(In, C), - !, - Token = dot(Ln) - ). -token(0'#, In, C, Token) :- - !, - get_code(In, C1), - skip_line(C1, In, C2), - token(C2, In, C, Token). -token(C0, In, C, Token) :- - white_space(C0), - !, - get_code(In, C1), - token(C1, In, C, Token). -token(C0, In, C, Number) :- - 0'0 =< C0, - C0 =< 0'9, - !, - number_n(C0, In, C, Number). -token(0'-, In, C, Number) :- - !, - number_n(0'-, In, C, Number). -token(0'+, In, C, Number) :- - !, - number_n(0'+, In, C, Number). -token(0'", In, C, literal(Codes)) :- - !, - ( peek_code(In, 0'") - -> get_code(In, 0'"), - ( peek_code(In, 0'") - -> get_code(In, 0'"), - get_code(In, C1), - dq_string(C1, In, C, Codes) - ; get_code(In, C), - Codes = [] - ) - ; get_code(In, C1), - string_dq(C1, In, C, Codes) - ). -token(0'', In, C, literal(Codes)) :- - !, - ( peek_code(In, 0'') - -> get_code(In, 0''), - ( peek_code(In, 0'') - -> get_code(In, 0''), - get_code(In, C1), - sq_string(C1, In, C, Codes) - ; get_code(In, C), - Codes = [] - ) - ; get_code(In, C1), - string_sq(C1, In, C, Codes) - ). -token(0'?, In, C, uvar(Name)) :- - !, - get_code(In, C0), - ( name(C0, In, C, Name) - -> true - ; C = C0, - nb_getval(line_number, Ln), - throw(empty_quickvar_name(line(Ln))) - ). -token(0'_, In, C, bnode(Name)) :- - peek_code(In, 0':), - !, - get_code(In, _), - get_code(In, C0), - ( name(C0, In, C, Name) - -> true - ; C = C0, - Name = '' - ). -token(0'<, In, C, lt_lt) :- - peek_code(In, 0'<), - !, - get_code(In, _), - get_code(In, C). -token(0'<, In, C, lt_eq) :- - peek_string(In, 2, D), - string_codes(D, [0'=, E]), - ( white_space(E) - ; punctuation(E, _) - ), - !, - get_code(In, _), - get_code(In, C). -token(0'<, In, C, lt_dash) :- - peek_code(In, 0'-), - !, - get_code(In, _), - get_code(In, C). -token(0'<, In, C, relative_uri(URI)) :- - peek_code(In, C1), - !, - get_code(In, C1), - iri_chars(C1, In, C, Codes), - D = Codes, - atom_codes(URI, D). -token(0'>, In, C, gt_gt) :- - peek_code(In, 0'>), - !, - get_code(In, _), - get_code(In, C). -token(0'{, In, C, lb_pipe) :- - peek_code(In, 0'|), - !, - get_code(In, _), - get_code(In, C). -token(0'|, In, C, pipe_rb) :- - peek_code(In, 0'}), - !, - get_code(In, _), - get_code(In, C). -token(0':, In, C, Token) :- - !, - get_code(In, C0), - ( local_name(C0, In, C, Name) - -> Token = '':Name - ; Token = '':'', - C = C0 - ). -token(0'@, In, C, atname(Name)) :- - get_code(In, C0), - token(C0, In, C, name(Name)), - !. -token(0'^, In, C, caret_caret) :- - peek_code(In, 0'^), - !, - get_code(In, _), - get_code(In, C). -token(C0, In, C, Token) :- - name(C0, In, C1, Name), - !, - ( C1 == 0': - -> get_code(In, C2), - ( local_name(C2, In, C, Name2) - -> Token = (Name:Name2) - ; Token = (Name:''), - C = C2 - ) - ; Token = name(Name), - C = C1 - ). -token(C0, In, C, P) :- - punctuation(C0, P), - !, - get_code(In, C). - -number_n(0'-, In, CN, numeric(T, [0'-|Codes])) :- - !, - get_code(In, C0), - number_nn(C0, In, CN, numeric(T, Codes)). -number_n(0'+, In, CN, numeric(T, [0'+|Codes])) :- - !, - get_code(In, C0), - number_nn(C0, In, CN, numeric(T, Codes)). -number_n(C0, In, CN, Value) :- - number_nn(C0, In, CN, Value). - -number_nn(C, In, CN, numeric(Type, Codes)) :- - integer_codes(C, In, CN0, Codes, T0), - ( CN0 == 0'., - peek_code(In, C0), - ( e(C0) - -> T1 = [0'0|T2], - get_code(In, CN1) - ; 0'0 =< C0, - C0 =< 0'9, - get_code(In, C1), - integer_codes(C1, In, CN1, T1, T2) - ), - T0 = [0'.|T1] - -> ( exponent(CN1, In, CN, T2) - -> Type = double - ; CN = CN1, - T2 = [], - Type = decimal - ) - ; ( exponent(CN0, In, CN, T0) - -> Type = double - ; T0 = [], - CN = CN0, - Type = integer - ) - ). - -integer_codes(C0, In, CN, [C0|T0], T) :- - 0'0 =< C0, - C0 =< 0'9, - !, - get_code(In, C1), - integer_codes(C1, In, CN, T0, T). -integer_codes(CN, _, CN, T, T). - -exponent(C0, In, CN, [C0|T0]) :- - e(C0), - !, - get_code(In, C1), - optional_sign(C1, In, CN0, T0, T1), - integer_codes(CN0, In, CN, T1, []), - ( T1 = [] - -> nb_getval(line_number, Ln), - throw(invalid_exponent(line(Ln))) - ; true - ). - -optional_sign(C0, In, CN, [C0|T], T) :- - sign(C0), - !, - get_code(In, CN). -optional_sign(CN, _, CN, T, T). - -e(0'e). -e(0'E). - -sign(0'-). -sign(0'+). - -dq_string(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -dq_string(0'", In, C, []) :- - ( retract(got_dq) - -> true - ; peek_code(In, 0'"), - get_code(In, _) - ), - ( retract(got_dq) - -> assertz(got_dq) - ; assertz(got_dq), - peek_code(In, 0'"), - get_code(In, _), - assertz(got_dq) - ), - !, - ( peek_code(In, 0'") - -> nb_getval(line_number, Ln), - throw(unexpected_double_quote(line(Ln))) - ; true - ), - retractall(got_dq), - get_code(In, C). -dq_string(0'", In, C, [0'"|T]) :- - !, - ( retract(got_dq) - -> C1 = 0'" - ; get_code(In, C1) - ), - dq_string(C1, In, C, T). -dq_string(0'\\, In, C, [H|T]) :- - ( retract(got_dq) - -> C1 = 0'" - ; get_code(In, C1) - ), - !, - string_escape(C1, In, C2, H), - dq_string(C2, In, C, T). -dq_string(C0, In, C, [C0|T]) :- - ( retract(got_dq) - -> C1 = 0'" - ; get_code(In, C1) - ), - dq_string(C1, In, C, T). - -sq_string(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -sq_string(0'', In, C, []) :- - ( retract(got_sq) - -> true - ; peek_code(In, 0''), - get_code(In, _) - ), - ( retract(got_sq) - -> assertz(got_sq) - ; assertz(got_sq), - peek_code(In, 0''), - get_code(In, _), - assertz(got_sq) - ), - !, - ( peek_code(In, 0'') - -> nb_getval(line_number, Ln), - throw(unexpected_single_quote(line(Ln))) - ; true - ), - retractall(got_sq), - get_code(In, C). -sq_string(0'', In, C, [0''|T]) :- - !, - ( retract(got_sq) - -> C1 = 0'' - ; get_code(In, C1) - ), - sq_string(C1, In, C, T). -sq_string(0'\\, In, C, [H|T]) :- - ( retract(got_sq) - -> C1 = 0'' - ; get_code(In, C1) - ), - !, - string_escape(C1, In, C2, H), - sq_string(C2, In, C, T). -sq_string(C0, In, C, [C0|T]) :- - ( retract(got_sq) - -> C1 = 0'' - ; get_code(In, C1) - ), - sq_string(C1, In, C, T). - -string_dq(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -string_dq(0'\n, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_line(line(Ln))). -string_dq(0'", In, C, []) :- - !, - get_code(In, C). -string_dq(0'\\, In, C, D) :- - get_code(In, C1), - !, - string_escape(C1, In, C2, H), - ( current_prolog_flag(windows, true), - H > 0xFFFF - -> E is (H-0x10000)>>10+0xD800, - F is (H-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [H|T] - ), - string_dq(C2, In, C, T). -string_dq(C0, In, C, D) :- - ( current_prolog_flag(windows, true), - C0 > 0xFFFF - -> E is (C0-0x10000)>>10+0xD800, - F is (C0-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [C0|T] - ), - get_code(In, C1), - string_dq(C1, In, C, T). - -string_sq(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -string_sq(0'', In, C, []) :- - !, - get_code(In, C). -string_sq(0'\\, In, C, D) :- - get_code(In, C1), - !, - string_escape(C1, In, C2, H), - ( current_prolog_flag(windows, true), - H > 0xFFFF - -> E is (H-0x10000)>>10+0xD800, - F is (H-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [H|T] - ), - string_sq(C2, In, C, T). -string_sq(C0, In, C, D) :- - ( current_prolog_flag(windows, true), - C0 > 0xFFFF - -> E is (C0-0x10000)>>10+0xD800, - F is (C0-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [C0|T] - ), - get_code(In, C1), - string_sq(C1, In, C, T). - -string_escape(0't, In, C, 0'\t) :- - !, - get_code(In, C). -string_escape(0'b, In, C, 0'\b) :- - !, - get_code(In, C). -string_escape(0'n, In, C, 0'\n) :- - !, - get_code(In, C). -string_escape(0'r, In, C, 0'\r) :- - !, - get_code(In, C). -string_escape(0'f, In, C, 0'\f) :- - !, - get_code(In, C). -string_escape(0'", In, C, 0'") :- - !, - get_code(In, C). -string_escape(0'', In, C, 0'') :- - !, - get_code(In, C). -string_escape(0'\\, In, C, 0'\\) :- - !, - get_code(In, C). -string_escape(0'u, In, C, Code) :- - !, - get_hhhh(In, A), - ( 0xD800 =< A, - A =< 0xDBFF - -> get_code(In, 0'\\), - get_code(In, 0'u), - get_hhhh(In, B), - Code is 0x10000+(A-0xD800)*0x400+(B-0xDC00) - ; Code is A - ), - get_code(In, C). -string_escape(0'U, In, C, Code) :- - !, - get_hhhh(In, Code0), - get_hhhh(In, Code1), - Code is Code0 << 16 + Code1, - get_code(In, C). -string_escape(C, _, _, _) :- - nb_getval(line_number, Ln), - atom_codes(A, [0'\\, C]), - throw(illegal_string_escape_sequence(A, line(Ln))). - -get_hhhh(In, Code) :- - get_code(In, C1), - code_type(C1, xdigit(D1)), - get_code(In, C2), - code_type(C2, xdigit(D2)), - get_code(In, C3), - code_type(C3, xdigit(D3)), - get_code(In, C4), - code_type(C4, xdigit(D4)), - Code is D1<<12+D2<<8+D3<<4+D4. - -language(C0, In, C, [C0|Codes]) :- - code_type(C0, lower), - get_code(In, C1), - lwr_word(C1, In, C2, Codes, Tail), - sub_langs(C2, In, C, Tail, []). - -lwr_word(C0, In, C, [C0|T0], T) :- - code_type(C0, lower), - !, - get_code(In, C1), - lwr_word(C1, In, C, T0, T). -lwr_word(C, _, C, T, T). - -sub_langs(0'-, In, C, [0'-, C1|Codes], T) :- - get_code(In, C1), - lwrdig(C1), - !, - get_code(In, C2), - lwrdigs(C2, In, C3, Codes, Tail), - sub_langs(C3, In, C, Tail, T). -sub_langs(C, _, C, T, T). - -lwrdig(C) :- - code_type(C, lower), - !. -lwrdig(C) :- - code_type(C, digit). - -lwrdigs(C0, In, C, [C0|T0], T) :- - lwrdig(C0), - !, - get_code(In, C1), - lwr_word(C1, In, C, T0, T). -lwrdigs(C, _, C, T, T). - -iri_chars(0'>, In, C, []) :- - !, - get_code(In, C). -iri_chars(0'\\, In, C, D) :- - !, - get_code(In, C1), - iri_escape(C1, In, C2, H), - \+non_iri_char(H), - ( current_prolog_flag(windows, true), - H > 0xFFFF - -> E is (H-0x10000)>>10+0xD800, - F is (H-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [H|T] - ), - iri_chars(C2, In, C, T). -iri_chars(0'%, In, C, [0'%, C1, C2|T]) :- - !, - get_code(In, C1), - code_type(C1, xdigit(_)), - get_code(In, C2), - code_type(C2, xdigit(_)), - get_code(In, C3), - iri_chars(C3, In, C, T). -iri_chars(-1, _, _, _) :- - !, - fail. -iri_chars(C0, In, C, D) :- - \+non_iri_char(C0), - ( current_prolog_flag(windows, true), - C0 > 0xFFFF - -> E is (C0-0x10000)>>10+0xD800, - F is (C0-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [C0|T] - ), - get_code(In, C1), - iri_chars(C1, In, C, T). - -iri_escape(0'u, In, C, Code) :- - !, - get_hhhh(In, A), - ( 0xD800 =< A, - A =< 0xDBFF - -> get_code(In, 0'\\), - get_code(In, 0'u), - get_hhhh(In, B), - Code is 0x10000+(A-0xD800)*0x400+(B-0xDC00) - ; Code is A - ), - get_code(In, C). -iri_escape(0'U, In, C, Code) :- - !, - get_hhhh(In, Code0), - get_hhhh(In, Code1), - Code is Code0 << 16 + Code1, - get_code(In, C). -iri_escape(C, _, _, _) :- - nb_getval(line_number, Ln), - atom_codes(A, [0'\\, C]), - throw(illegal_iri_escape_sequence(A, line(Ln))). - -non_iri_char(C) :- - 0x00 =< C, - C =< 0x20, - !. -non_iri_char(0'<). -non_iri_char(0'>). -non_iri_char(0'"). -non_iri_char(0'{). -non_iri_char(0'}). -non_iri_char(0'|). -non_iri_char(0'^). -non_iri_char(0'`). -non_iri_char(0'\\). - -name(C0, In, C, Atom) :- - name_start_char(C0), - get_code(In, C1), - name_chars(C1, In, C, T), - atom_codes(Atom, [C0|T]). - -name_start_char(C) :- - pn_chars_base(C), - !. -name_start_char(0'_). -name_start_char(C) :- - code_type(C, digit). - -name_chars(0'., In, C, [0'.|T]) :- - peek_code(In, C1), - pn_chars(C1), - !, - get_code(In, C1), - name_chars(C1, In, C, T). -name_chars(C0, In, C, [C0|T]) :- - pn_chars(C0), - !, - get_code(In, C1), - name_chars(C1, In, C, T). -name_chars(C, _, C, []). - -pn_chars_base(C) :- - code_type(C, alpha), - !. -pn_chars_base(C) :- - 0xC0 =< C, - C =< 0xD6, - !. -pn_chars_base(C) :- - 0xD8 =< C, - C =< 0xF6, - !. -pn_chars_base(C) :- - 0xF8 =< C, - C =< 0x2FF, - !. -pn_chars_base(C) :- - 0x370 =< C, - C =< 0x37D, - !. -pn_chars_base(C) :- - 0x37F =< C, - C =< 0x1FFF, - !. -pn_chars_base(C) :- - 0x200C =< C, - C =< 0x200D, - !. -pn_chars_base(C) :- - 0x2070 =< C, - C =< 0x218F, - !. -pn_chars_base(C) :- - 0x2C00 =< C, - C =< 0x2FEF, - !. -pn_chars_base(C) :- - 0x3001 =< C, - C =< 0xD7FF, - !. -pn_chars_base(C) :- - 0xF900 =< C, - C =< 0xFDCF, - !. -pn_chars_base(C) :- - 0xFDF0 =< C, - C =< 0xFFFD, - !. -pn_chars_base(C) :- - 0x10000 =< C, - C =< 0xEFFFF. - -pn_chars(C) :- - code_type(C, csym), - !. -pn_chars(C) :- - pn_chars_base(C), - !. -pn_chars(0'-) :- - !. -pn_chars(0xB7) :- - !. -pn_chars(C) :- - 0x0300 =< C, - C =< 0x036F, - !. -pn_chars(C) :- - 0x203F =< C, - C =< 0x2040. - -local_name(0'\\, In, C, Atom) :- - !, - get_code(In, C0), - reserved_char_escapes(C0), - get_code(In, C1), - local_name_chars(C1, In, C, T), - atom_codes(Atom, [C0|T]). -local_name(0'%, In, C, Atom) :- - !, - get_code(In, C0), - code_type(C0, xdigit(_)), - get_code(In, C1), - code_type(C1, xdigit(_)), - get_code(In, C2), - local_name_chars(C2, In, C, T), - atom_codes(Atom, [0'%, C0, C1|T]). -local_name(C0, In, C, Atom) :- - local_name_start_char(C0), - get_code(In, C1), - local_name_chars(C1, In, C, T), - atom_codes(Atom, [C0|T]). - -local_name_chars(0'\\, In, C, [C0|T]) :- - !, - get_code(In, C0), - reserved_char_escapes(C0), - get_code(In, C1), - local_name_chars(C1, In, C, T). -local_name_chars(0'%, In, C, [0'%, C0, C1|T]) :- - !, - get_code(In, C0), - code_type(C0, xdigit(_)), - get_code(In, C1), - code_type(C1, xdigit(_)), - get_code(In, C2), - local_name_chars(C2, In, C, T). -local_name_chars(0'., In, C, [0'.|T]) :- - peek_code(In, C1), - ( local_name_char(C1) - ; C1 = 0'. - ), - !, - get_code(In, C1), - local_name_chars(C1, In, C, T). -local_name_chars(C0, In, C, [C0|T]) :- - local_name_char(C0), - !, - get_code(In, C1), - local_name_chars(C1, In, C, T). -local_name_chars(C, _, C, []). - -local_name_start_char(C) :- - name_start_char(C), - !. -local_name_start_char(0':). -local_name_start_char(0'%). -local_name_start_char(0'\\). - -local_name_char(C) :- - pn_chars(C), - !. -local_name_char(0':). -local_name_char(0'%). -local_name_char(0'\\). - -reserved_char_escapes(0'~). -reserved_char_escapes(0'.). -reserved_char_escapes(0'-). -reserved_char_escapes(0'!). -reserved_char_escapes(0'$). -reserved_char_escapes(0'&). -reserved_char_escapes(0''). -reserved_char_escapes(0'(). -reserved_char_escapes(0')). -reserved_char_escapes(0'*). -reserved_char_escapes(0'+). -reserved_char_escapes(0',). -reserved_char_escapes(0';). -reserved_char_escapes(0'=). -reserved_char_escapes(0'/). -reserved_char_escapes(0'?). -reserved_char_escapes(0'#). -reserved_char_escapes(0'@). -reserved_char_escapes(0'%). -reserved_char_escapes(0'_). - -punctuation(0'(, '('). -punctuation(0'), ')'). -punctuation(0'[, '['). -punctuation(0'], ']'). -punctuation(0',, ','). -punctuation(0':, ':'). -punctuation(0';, ';'). -punctuation(0'{, '{'). -punctuation(0'}, '}'). -punctuation(0'?, '?'). -punctuation(0'!, '!'). -punctuation(0'^, '^'). -punctuation(0'=, '='). -punctuation(0'<, '<'). -punctuation(0'>, '>'). -punctuation(0'$, '$'). - -skip_line(-1, _, -1) :- - !. -skip_line(0xA, In, C) :- - !, - cnt(line_number), - get_code(In, C). -skip_line(0xD, In, C) :- - !, - get_code(In, C). -skip_line(_, In, C) :- - get_code(In, C1), - skip_line(C1, In, C). - -white_space(0x9). -white_space(0xA) :- - cnt(line_number). -white_space(0xD). -white_space(0x20). - -% -% Reasoning output -% - -w0([]) :- - !. -w0(['--image', _|A]) :- - !, - w0(A). -w0([A|B]) :- - ( \+sub_atom(A, 1, _, _, '"'), - sub_atom(A, _, 1, _, ' '), - \+sub_atom(A, _, _, 1, '"') - -> format(' "~w"', [A]) - ; format(' ~w', [A]) - ), - w0(B). - -w1([]) :- - !. -w1([A|B]) :- - ( \+sub_atom(A, 1, _, _, '"'), - sub_atom(A, _, 1, _, ' '), - \+sub_atom(A, _, _, 1, '"') - -> format(' "~w"', [A]) - ; format(' ~w', [A]) - ), - w1(B). - -wh :- - ( keep_skolem(_) - -> nb_getval(var_ns, Sns), - put_pfx('var', Sns) - ; true - ), - ( flag('no-qnames') - -> true - ; nb_setval(wpfx, false), - forall( - ( pfx(A, B), - \+wpfx(A) - ), - ( format('@prefix ~w ~w.~n',[A,B]), - assertz(wpfx(A)), - nb_setval(wpfx, true) - ) - ), - ( \+flag('pass-only-new'), - nb_getval(wpfx, true) - -> nl - ; true - ) - ). - -w3 :- - wh, - nb_setval(fdepth, 0), - nb_setval(pdepth, 0), - nb_setval(cdepth, 0), - flag(nope), - !, - ( query(Q, A), - ( Q = \+(R) - -> \+catch(call(R), _, fail) - ; catch(call(Q), _, fail) - ), - nb_getval(wn, W), - labelvars(A, W, N, some), - nb_setval(wn, N), - relabel(A, B), - indent, - wt(B), - ws(B), - write('.'), - nl, - ( A = (_, _), - conj_list(A, L) - -> length(L, I), - cnt(output_statements, I) - ; cnt(output_statements) - ), - fail - ; true - ), - ( answer(B1, B2, B3), - relabel([B1, B2, B3], [C1, C2, C3]), - djiti_answer(answer(C), answer(C1, C2, C3)), - indent, - wt(C), - ws(C), - write('.'), - nl, - cnt(output_statements), - fail - ; nl - ). -w3 :- - ( prfstep(answer(_, _, _), _, _, _, _, _, _), - !, - nb_setval(empty_gives, false), - indent, - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'proof', '>'], Sk), - wp(Sk), - write(' '), - wp(''), - write(' '), - wp(''), - write(', '), - wp(''), - write(';'), - indentation(2), - nl, - indent, - ( prfstep(answer(_, _, _), B, Pnd, Cn, R, _, A), - R =.. [P, S, O1], - djiti_answer(answer(O), O1), - Rule =.. [P, S, O], - djiti_answer(answer(C), Cn), - nb_setval(empty_gives, C), - \+got_wi(A, B, Pnd, C, Rule), - assertz(got_wi(A, B, Pnd, C, Rule)), - wp(''), - write(' '), - wi(A, B, C, Rule), - write(';'), - nl, - indent, - fail - ; retractall(got_wi(_, _, _, _, _)) - ), - wp(''), - ( nb_getval(empty_gives, true) - -> write(' true.') - ; write(' {'), - indentation(2), - ( prfstep(answer(B1, B2, B3), _, _, _, _, _, _), - relabel([B1, B2, B3], [C1, C2, C3]), - djiti_answer(answer(C), answer(C1, C2, C3)), - nl, - indent, - getvars(C, D), - ( C = ''(_, _) - -> Q = allv - ; Q = some - ), - wq(D, Q), - wt(C), - ws(C), - write('.'), - cnt(output_statements), - fail - ; true - ), - indentation(-2), - nl, - indent, - write('}.') - ), - indentation(-2), - nl, - nl - ; true - ), - ( nb_getval(lemma_count, Lco), - nb_getval(lemma_cursor, Lcu), - Lcu < Lco - -> repeat, - cnt(lemma_cursor), - nb_getval(lemma_cursor, Cursor), - lemma(Cursor, Ai, Bi, Ci, _, Di), - indent, - wj(Cursor, Ai, Bi, Ci, Di), - nl, - nl, - nb_getval(lemma_count, Cnt), - Cursor = Cnt, - ! - ; true - ). - -wi('<>', _, rule(_, _, A), _) :- % wi(Source, Premise, Conclusion, Rule) - !, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' '), - wg(A), - write(']'). -wi(A, B, C, Rule) :- - term_index(B-C, Ind), - ( lemma(Cnt, A, B, C, Ind, Rule) - -> true - ; cnt(lemma_count), - nb_getval(lemma_count, Cnt), - assertz(lemma(Cnt, A, B, C, Ind, Rule)) - ), - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'lemma', Cnt, '>'], Sk), - wp(Sk). - -wj(Cnt, A, true, C, Rule) :- % wj(Count, Source, Premise, Conclusion, Rule) - var(Rule), - C \= ''(_, _), - !, - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'lemma', Cnt, '>'], Sk), - wp(Sk), - write(' '), - wp(''), - write(' '), - wp(''), - writeln(';'), - indentation(2), - indent, - wp(''), - ( C = true - -> write(' true;') - ; write(' {'), - nl, - indentation(2), - indent, - ( C = rule(PVars, EVars, Rule) - -> wq(PVars, allv), - wq(EVars, some), - wt(Rule) - ; labelvars([A, C], 0, _, avar), - getvars(C, D), - wq(D, some), - wt(C) - ), - ws(C), - write('.'), - nl, - indentation(-2), - indent, - write('};') - ), - nl, - indent, - wp(''), - write(' [ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' '), - ( C = rule(_, _, Rl), - Rl =.. [P, S, O], - ''(triple(S, P, O), Src) - -> wt(Src) - ; ( C =.. [P, S, O], - ''(triple(S, P, O), Src) - -> wt(Src) - ; wt(A) - ) - ), - write('].'), - indentation(-2). -wj(Cnt, A, B, C, Rule) :- - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'lemma', Cnt, '>'], Sk), - wp(Sk), - write(' '), - wp(''), - write(' '), - wp(''), - writeln(';'), - indentation(2), - indent, - wp(''), - ( C = true - -> write(' true;') - ; write(' {'), - nl, - Rule = ''(Prem, Conc), - unifiable(Prem, B, Bs), - ( unifiable(Conc, C, Cs) - -> true - ; Cs = [] - ), - append(Bs, Cs, Ds), - sort(Ds, Bindings), - term_variables(Prem, PVars), - term_variables(Conc, CVars), - nb_getval(wn, W), - labelvars([A, B, C], W, N, some), - nb_setval(wn, N), - labelvars([Rule, PVars, CVars], 0, _, avar), - findall(V, - ( member(V, CVars), - \+member(V, PVars) - ), - EVars - ), - getvars(C, D), - ( C = ''(_, _) - -> Q = allv - ; Q = some - ), - indentation(2), - indent, - wq(D, Q), - wt(C), - ws(C), - write('.'), - nl, - indentation(-2), - indent, - write('};') - ), - nl, - indent, - wp(''), - write(' ('), - indentation(2), - wr(B), - indentation(-2), - nl, - indent, - write(');'), - retractall(got_wi(_, _, _, _, _)), - nl, - indent, - wb(Bindings), - wp(''), - write(' '), - wi(A, true, rule(PVars, EVars, Rule), _), - write('.'), - indentation(-2). - -wr(exopred(P, S, O)) :- - atom(P), - !, - U =.. [P, S, O], - wr(U). -wr((X, Y)) :- - !, - wr(X), - wr(Y). -wr(Z) :- - prfstep(Z, Y, _, Q, Rule, _, X), - !, - nl, - indent, - wi(X, Y, Q, Rule). -wr(Y) :- - nl, - indent, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' '), - ( Y = true - -> wt(Y) - ; write('{'), - labelvars(Y, 0, _, avar), - getvars(Y, Z), - wq(Z, some), - X = Y, - wt(X), - write('}') - ), - write(']'). - -wt(X) :- - var(X), - !, - write('?'), - write(X). -wt(X) :- - functor(X, _, A), - ( A = 0, - !, - wt0(X) - ; A = 1, - !, - wt1(X) - ; A = 2, - !, - wt2(X) - ; wtn(X) - ). - -wt0(!) :- - !, - write('("!") '), - wp(''), - write(' true'). -wt0(fail) :- - !, - write('("fail") '), - wp(''), - write(' true'). -wt0([]) :- - !, - write('()'). -wt0(X) :- - number(X), - !, - ( flag('no-numerals') - -> dtlit([U, V], X), - dtlit([U, V], W), - wt(W) - ; write(X) - ). -wt0(X) :- - atom(X), - atom_concat(some, Y, X), - !, - ( \+flag('no-qvars') - -> ( rule_uvar(L), - ( ncllit - -> ( memberchk(X, L) - -> true - ; retract(rule_uvar(L)), - assertz(rule_uvar([X|L])) - ) - ; memberchk(X, L) - ) - -> write('?U_') - ; write('_:sk_') - ), - write(Y) - ; atomic_list_concat([''], Z), - wt0(Z) - ). -wt0(X) :- - atom(X), - atom_concat(allv, Y, X), - !, - ( \+flag('no-qvars'), - \+flag('pass-all-ground') - -> write('?U_'), - write(Y) - ; atomic_list_concat([''], Z), - wt0(Z) - ). -wt0(X) :- - atom(X), - atom_concat(avar, Y, X), - !, - atomic_list_concat([''], Z), - wt0(Z). -wt0(X) :- - flag(nope), - \+flag('pass-all-ground'), - \+keep_skolem(X), - nb_getval(var_ns, Sns), - atom(X), - sub_atom(X, 1, I, _, Sns), - J is I+1, - sub_atom(X, J, _, 1, Y), - ( getlist(X, M) - -> wt(M) - ; ( rule_uvar(L), - ( ncllit - -> ( memberchk(Y, L) - -> true - ; retract(rule_uvar(L)), - assertz(rule_uvar([Y|L])) - ) - ; memberchk(Y, L) - ) - -> ( ( sub_atom(Y, 0, 2, _, 'e_') - ; sub_atom(Y, 0, 3, _, 'bn_') - ) - -> write('_:') - ; sub_atom(Y, 0, 2, _, Z), - memberchk(Z, ['x_', 't_']), - write('?') - ) - ; ( \+flag('no-qvars') - -> true - ; flag('quantify', Prefix), - sub_atom(X, 1, _, _, Prefix) - ), - write('_:') - ), - write(Y), - ( sub_atom(Y, 0, 2, _, 'x_') - -> write('_'), - nb_getval(rn, N), - write(N) - ; true - ) - ), - !. -wt0(X) :- - flag('quantify', Prefix), - flag(nope), - atom(X), - sub_atom(X, 1, _, _, Prefix), - !, - ( getlist(X, M) - -> wt(M) - ; ''(Y, ['quantify', Prefix, X]), - wt0(Y) - ). -wt0(X) :- - ( wtcache(X, W) - -> true - ; ( \+flag('no-qnames'), - atom(X), - ( sub_atom(X, I, 1, J, '#') - -> J > 1, - sub_atom(X, 0, I, _, C), - atom_concat(C, '#>', D) - ; ( sub_atom_last(X, I, 1, J, '/') - -> J > 1, - sub_atom(X, 0, I, _, C), - atom_concat(C, '/>', D) - ; J = 1, - D = X - ) - ), - pfx(E, D), - K is J-1, - sub_atom(X, _, K, 1, F) - -> atom_concat(E, F, W), - assertz(wtcache(X, W)) - ; ( \+flag(strings), - atom(X), - \+ (sub_atom(X, 0, 1, _, '<'), sub_atom(X, _, 1, 0, '>')), - X \= true, - X \= false - -> W = literal(X, type('')) - ; W = X - ) - ) - ), - ( W = literal(X, type('')) - -> wt2(W) - ; ( current_prolog_flag(windows, true) - -> atom_codes(W, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = W - ), - ( atom(Z) - -> write(Z) - ; ''(A, [blob, Z]), - wt(A) - ) - ). - -wt1(set(X)) :- - !, - write('($'), - wl(X), - write(' $)'). -wt1('$VAR'(X)) :- - !, - write('?V'), - write(X). -wt1(X) :- - X =.. [B|C], - ( atom(B), - \+ (sub_atom(B, 0, 1, _, '<'), sub_atom(B, _, 1, 0, '>')) - -> write('"'), - writeq(X), - write('"') - ; wt(C), - write(' '), - wp(B), - write(' true') - ). - -wt2((X, Y)) :- - !, - ( atomic(X), - X \= '!' - -> wt2([X, Y]), - write(' '), - wt0(''), - write(' true') - ; wt(X), - ws(X), - write('.'), - ( ( flag(strings) - ; flag(nope) - ) - -> write(' ') - ; nl, - indent - ), - wt(Y) - ). -wt2([X|Y]) :- - !, - ( \+last_tail([X|Y], []) - -> write('[ '), - wt0(''), - write(' '), - wg(X), - write('; '), - wt0(''), - write(' '), - wt(Y), - write(']') - ; write('('), - wg(X), - wl(Y), - write(')') - ). -wt2(literal(X, lang(Y))) :- - !, - write('"'), - ( current_prolog_flag(windows, true) - -> atom_codes(X, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = X - ), - write(Z), - write('"@'), - write(Y). -wt2(literal(X, type(''))) :- - !, - ( sub_atom(X, _, 2, _, '\\n') - -> write('"""'), - atom_codes(X, C), - escape_string(D, C), - atom_codes(Y, D), - ( current_prolog_flag(windows, true) - -> atom_codes(Y, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = Y - ), - write(Z), - write('"""') - ; write('"'), - ( current_prolog_flag(windows, true) - -> atom_codes(X, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = X - ), - write(Z), - write('"') - ). -wt2(literal(X, type(Y))) :- - !, - write('"'), - ( current_prolog_flag(windows, true) - -> atom_codes(X, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = X - ), - write(Z), - write('"^^'), - wt(Y). -wt2(rdiv(X, Y)) :- - number_codes(Y, [0'1|Z]), - lzero(Z, Z), - !, - ( Z = [] - -> F = '~d.0' - ; length(Z, N), - number_codes(X, U), - ( length(U, N) - -> F = '0.~d' - ; atomic_list_concat(['~', N, 'd'], F) - ) - ), - ( flag('no-numerals') - -> write('"') - ; true - ), - format(F, [X]), - ( flag('no-numerals') - -> write('"^^'), - wt0('') - ; true - ). -wt2(rdiv(X, Y)) :- - !, - ( flag('no-numerals') - -> write('"') - ; true - ), - format('~g', [rdiv(X, Y)]), - ( flag('no-numerals') - -> write('"^^'), - wt0('') - ; true - ). -wt2(''([X|Y], Z)) :- - flag(nope), - !, - ''(Y, U), - write('{'), - wt(U), - write('. _: '), - wp(''), - write(' '), - wt(Z), - write('} '), - wp(''), - write(' {'), - wt(X), - write('}'). -wt2(''([X|Y], Z)) :- - flag(nope), - !, - ''(Y, U), - write('{'), - wt(U), - write('. _: '), - wp(''), - write(' '), - wt(Z), - write('} '), - wp(''), - write(' {'), - wt(X), - write('}'). -wt2(''(X, Y)) :- - ( flag(nope) - -> U = X - ; ( X = when(A, B) - -> conj_append(B, istep(_, _, _, _), C), - U = when(A, C) - ; conj_append(X, istep(_, _, _, _), U) - ) - ), - ( flag('rule-histogram') - -> ( U = when(D, E) - -> conj_append(E, pstep(_), F), - Z = when(D, F) - ; conj_append(U, pstep(_), Z) - ) - ; Z = U - ), - ( rule_uvar(R) - -> true - ; R = [], - cnt(rn) - ), - ( nb_getval(pdepth, 0), - nb_getval(cdepth, 0) - -> assertz(rule_uvar(R)) - ; true - ), - ( catch(clause(Y, Z), _, fail) - -> ( nb_getval(fdepth, 0) - -> assertz(ncllit) - ; true - ), - wg(Y), - write(' <= '), - wg(X), - ( nb_getval(fdepth, 0) - -> retract(ncllit) - ; true - ) - ; ( clause(''(X, Y, _, _, _, _), true) - -> wg(X), - write(' => '), - wg(Y) - ; ( nb_getval(fdepth, 0) - -> assertz(ncllit) - ; true - ), - ( \+atom(X) - -> nb_getval(pdepth, PD), - PD1 is PD+1, - nb_setval(pdepth, PD1) - ; true - ), - wg(X), - ( \+atom(X) - -> nb_setval(pdepth, PD) - ; true - ), - ( nb_getval(fdepth, 0) - -> retract(ncllit) - ; true - ), - write(' => '), - ( \+atom(Y) - -> nb_getval(cdepth, CD), - CD1 is CD+1, - nb_setval(cdepth, CD1) - ; true - ), - wg(Y), - ( \+atom(Y) - -> nb_setval(cdepth, CD) - ; true - ) - ) - ), - ( nb_getval(pdepth, 0), - nb_getval(cdepth, 0) - -> retract(rule_uvar(_)) - ; true - ), - !. -wt2(':-'(X, Y)) :- - ( rule_uvar(R) - -> true - ; R = [], - cnt(rn) - ), - ( nb_getval(fdepth, 0) - -> assertz(ncllit) - ; true - ), - assertz(rule_uvar(R)), - ( Y = true - -> wt(X) - ; wg(X), - write(' <= '), - wg(Y), - retract(rule_uvar(U)), - ( U \= [], - retract(rule_uvar(V)), - append(U, V, W) - -> assertz(rule_uvar(W)) - ; true - ) - ), - ( nb_getval(fdepth, 0) - -> retract(ncllit) - ; true - ), - !. -wt2(is(O, T)) :- - !, - ( number(T), - T < 0 - -> P = -, - Q is -T, - S = [Q] - ; T =.. [P|S] - ), - wg(S), - write(' '), - wp(P), - write(' '), - wg(O). -wt2(prolog:X) :- - !, - ( X = '\';\'' - -> Y = disjunction - ; prolog_sym(Y, X, _) - ), - atomic_list_concat([''], Z), - wt0(Z). -wt2(X) :- - X =.. [P, S, O], - ( atom(P), - \+ (sub_atom(P, 0, 1, _, '<'), sub_atom(P, _, 1, 0, '>')), - \+sub_atom(P, 0, _, _, avar), - \+sub_atom(P, 0, _, _, some) - -> write('"'), - writeq(X), - write('"') - ; wg(S), - write(' '), - wp(P), - write(' '), - wg(O) - ). - -wtn(exopred(P, S, O)) :- - !, - ( atom(P) - -> X =.. [P, S, O], - wt2(X) - ; wg(S), - write(' '), - wg(P), - write(' '), - wg(O) - ). -wtn(triple(S, P, O)) :- - !, - write('<<'), - wg(S), - write(' '), - wp(P), - write(' '), - wg(O), - write('>>'). -wtn(X) :- - X =.. [B|C], - ( atom(B), - \+ (sub_atom(B, 0, 1, _, '<'), sub_atom(B, _, 1, 0, '>')) - -> write('"'), - writeq(X), - write('"') - ; wt(C), - write(' '), - wp(B), - write(' true') - ). - -wg(X) :- - var(X), - !, - write('?'), - write(X). -wg(X) :- - functor(X, F, A), - ( ( F = exopred, - ! - ; prolog_sym(_, F, _), - F \= true, - F \= false, - F \= '-', - F \= /, - ! - ; A = 2, - F \= '.', - F \= '[|]', - F \= ':', - F \= literal, - F \= rdiv, - ( sub_atom(F, 0, 1, _, '<'), - sub_atom(F, _, 1, 0, '>') - ; F = ':-' - ) - ) - -> write('{'), - indentation(1), - nb_getval(fdepth, D), - E is D+1, - nb_setval(fdepth, E), - wt(X), - nb_setval(fdepth, D), - indentation(-1), - write('}') - ; wt(X) - ). - -wp('') :- - \+flag('no-qnames'), - !, - write('a'). -wp('') :- - \+flag('no-qnames'), - !, - write('=>'). -wp(':-') :- - \+flag('no-qnames'), - !, - write('<='). -wp(X) :- - ( prolog_sym(Y, X, _), - X \= true, - X \= false - -> atomic_list_concat([''], Z), - wt(Z) - ; wg(X) - ). - -wk([]) :- - !. -wk([X|Y]) :- - write(', '), - wt(X), - wk(Y). - -wl([]) :- - !. -wl([X|Y]) :- - write(' '), - wg(X), - wl(Y). - -wq([],_) :- - !. -wq([X|Y],allv) :- - !, - write('@forAll '), - wt(X), - wk(Y), - write('. '). -wq([X|Y],some) :- - ( \+flag('no-qvars') - -> write('@forSome '), - wt(X), - wk(Y), - write('. ') - ; true - ). - -wb([]) :- - !. -wb([X = Y|Z]) :- - wp(''), - write(' [ '), - wp(''), - write(' '), - wv(X), - write('; '), - wp(''), - write(' '), - wv(Y), - write('];'), - nl, - indent, - wb(Z). - -wv(X) :- - atom(X), - atom_concat(avar, Y, X), - !, - write('[ '), - wp(''), - write(' "http://josd.github.io/var#x_'), - write(Y), - write('"]'). -wv(X) :- - atom(X), - atom_concat(some, Y, X), - !, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' "_:sk_'), - write(Y), - write('"]'). -wv(X) :- - atom(X), - nb_getval(var_ns, Sns), - sub_atom(X, 1, I, _, Sns), - !, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' "'), - write(Sns), - J is I+1, - sub_atom(X, J, _, 1, Q), - write(Q), - write('"]'). -wv(X) :- - atom(X), - sub_atom(X, 1, _, 1, U), - atomic_list_concat(['<', U, '>'], X), - !, - write('[ '), - wp(''), - write(' "'), - write(U), - write('"]'). -wv(X) :- - wg(X). - -ws((X, Y)) :- - !, - conj_list((X, Y), Z), - last(Z, U), - ws(U). -ws(X) :- - X =.. Y, - last(Y, Z), - ( \+number(Z), - Z \= rdiv(_, _) - -> true - ; write(' ') - ). - -wst :- - findall([Key, Str], - ( ''(Key, Str) - ; answer(A1, A2, A3), - djiti_answer(answer(''(Key, Str)), answer(A1, A2, A3)) - ), - KS - ), - sort(KS, KT), - forall( - ( member([_, MT], KT), - getcodes(MT, LT) - ), - ( escape_string(NT, LT), - atom_codes(ST, NT), - wt(ST) - ) - ), - ( catch(nb_getval(csv_header, Header), _, Header = []), - wct(Header, Header), - length(Header, Headerl), - query(Where, ''(_, Select)), - catch(call(Where), _, fail), - write('\r\n'), - wct(Select, Header), - cnt(output_statements, Headerl), - cnt(answer_count), - nb_getval(answer_count, AnswerCount), - ( flag('limited-answer', AnswerLimit), - AnswerCount >= AnswerLimit - -> true - ; fail - ) - ; true - ). - -wct([], []) :- - !. -wct([A], [C]) :- - !, - wcf(A, C). -wct([A|B], [C|D]) :- - wcf(A, C), - ( flag('csv-separator', S) - -> true - ; S = ',' - ), - write(S), - wct(B, D). - -wcf(A, _) :- - var(A), - !. -wcf(rdiv(X, Y), _) :- - number_codes(Y, [0'1|Z]), - lzero(Z, Z), - !, - ( Z = [] - -> F = '~d.0' - ; length(Z, N), - number_codes(X, U), - ( length(U, N) - -> F = '0.~d' - ; atomic_list_concat(['~', N, 'd'], F) - ) - ), - format(F, [X]). -wcf(literal(A, B), _) :- - !, - atom_codes(A, C), - subst([[[0'\\, 0'"], [0'", 0'"]]], C, E), - atom_codes(F, E), - ( B \= type(''), - B \= type(''), - B \= type(''), - B \= type(''), - B \= type(''), - B \= type('') - -> write('"'), - write(F), - write('"') - ; write(F) - ). -wcf(A, _) :- - atom(A), - nb_getval(var_ns, Sns), - sub_atom(A, 1, I, _, Sns), - !, - J is I+1, - sub_atom(A, J, _, 1, B), - write('_:'), - write(B). -wcf(A, _) :- - atom(A), - flag('quantify', Prefix), - sub_atom(A, 1, _, _, Prefix), - !, - ''(B, ['quantify', Prefix, A]), - wt0(B). -wcf(A, B) :- - atom(A), - relabel(A, C), - sub_atom(C, 0, 1, _, '<'), - sub_atom(C, _, 1, 0, '>'), - !, - sub_atom(C, 1, _, 1, D), - ( sub_atom(B, _, 2, 0, 'ID') - -> ( flag('hmac-key', Key) - -> hmac_sha(Key, D, E, [algorithm(sha1)]) - ; sha_hash(D, E, [algorithm(sha1)]) - ), - atom_codes(F, E), - base64xml(F, G), - write(G) - ; write(D) - ). -wcf(A, _) :- - atom(A), - sub_atom(A, 0, 1, _, '_'), - !, - sub_atom(A, 1, _, 0, B), - write(B). -wcf(A, _) :- - with_output_to(atom(B), wg(A)), - write(B). - -wcn((A, B)) :- - !, - format(', ~w', [A]), - wcn(B). -wcn(A) :- - format(', ~w', [A]). - -indent:- - nb_getval(indentation, A), - tab(A). - -indentation(C) :- - nb_getval(indentation, A), - B is A+C, - nb_setval(indentation, B). - - -% ---------------------------- -% EAM (Euler Abstract Machine) -% ---------------------------- -% -% In a nutshell: -% -% 1/ Select rule P => C -% 2/ Prove P & NOT(C) (backward chaining) and if it fails backtrack to 1/ -% 3/ If P & NOT(C) assert C (forward chaining) and remove brake -% 4/ If C = answer(A) and tactic limited-answer stop, else backtrack to 2/ -% 5/ If brake or tactic linear-select stop, else start again at 1/ -% - -eam(Span) :- - ( cnt(tr), - ( flag(debug) - -> format(user_error, 'eam/1 entering span ~w~n', [Span]), - flush_output(user_error) - ; true - ), - ( flag('max-inferences', MaxInf), - statistics(inferences, Inf), - Inf > MaxInf - -> throw(max_inferences_exceeded(MaxInf)) - ; true - ), - implies(Prem, Conc, Src), - ignore(Prem = true), - ( flag(nope), - \+flag('rule-histogram') - -> true - ; copy_term_nat(''(Prem, Conc), Rule) - ), - ( flag(debug) - -> format(user_error, '. eam/1 selecting rule ~q~n', [implies(Prem, Conc, Src)]), - flush_output(user_error) - ; true - ), - ( flag('no-ucall') - -> catch(call_residue_vars(call(Prem), []), Exc, - ( Exc = error(existence_error(procedure, _), _) - -> fail - ; throw(Exc) - ) - ) - ; catch(call_residue_vars(ucall(Prem), []), Exc, - ( Exc = error(existence_error(procedure, _), _) - -> fail - ; throw(Exc) - ) - ) - ), - ( ( Conc = false - ; Conc = answer(false, void, void) - ) - -> with_output_to(atom(PN3), wt(''(Prem, false))), - ( flag('ignore-inference-fuse') - -> format(user_error, '** ERROR ** eam ** ~w~n', [inference_fuse(PN3)]), - fail - ; throw(inference_fuse(PN3)) - ) - ; true - ), - \+atom(Conc), - ( flag('rule-histogram'), - copy_term_nat(Rule, RuleL) - -> lookup(RTP, tp, RuleL), - catch(cnt(RTP), _, nb_setval(RTP, 0)) - ; true - ), - cnt(tp), - djiti_conc(Conc, Concd), - ( Concd = ':-'(Head, Body) - -> \+clause(Head, Body) - ; ( Concd = ''(_, _) - -> copy_term_nat(Concd, Concc), - labelvars(Concc, 0, _, avar), - \+cc(Concc), - assertz(cc(Concc)) - ; ( flag('no-ucall') - -> \+catch(call(Concd), _, fail) - ; \+catch(ucall(Concd), _, fail) - ) - ) - ), - ( flag('rule-histogram') - -> lookup(RTC, tc, RuleL), - catch(cnt(RTC), _, nb_setval(RTC, 0)) - ; true - ), - ( Concd = (_, _), - conj_list(Concd, Cl) - -> length(Cl, Ci), - cnt(tc, Ci) - ; cnt(tc) - ), - ( Concd \= ''(_, _), - Concd \= ':-'(_, _) - -> nb_getval(wn, W), - labelvars(Prem-Concd, W, N), % failing when Prem contains attributed variables - nb_setval(wn, N) - ; true - ), - ( flag(debug) - -> format(user_error, '... eam/1 assert step ~q~n', [Concd]), - flush_output(user_error) - ; true - ), - conj_list(Concd, La), - couple(La, La, Lc), - findall([D, F], - ( member([D, D], Lc), - unify(D, F), - ( F = ''(_, _) - -> true - ; catch(\+F, _, true) - ) - ), - Ld - ), - couple(Ls, Le, Ld), - conj_list(Concs, Ls), - conj_list(Conce, Le), - astep(Src, Prem, Concd, Conce, Rule), - ( ( Concs = answer(_, _, _) - ; Concs = (answer(_, _, _), _) - ) - -> cnt(answer_count) - ; true - ), - nb_getval(answer_count, AnswerCount), - ( flag('limited-answer', AnswerLimit), - AnswerCount >= AnswerLimit - -> ( flag(strings) - -> true - ; w3 - ) - ; retract(brake), - fail - ) - ; ( brake - ; flag(tactic, 'linear-select') - ), - ( S is Span+1, - ( \+span(S) - -> assertz(span(S)) - ; true - ), - nb_getval(limit, Limit), - Span < Limit, - eam(S) - ; ( flag(strings) - -> true - ; w3 - ) - ; true - ), - ! - ; assertz(brake), - exogen, - eam(Span) - ). - -astep(A, B, Cd, Cn, Rule) :- % astep(Source, Premise, Conclusion, Conclusion_unique, Rule) - ( Cn = (Dn, En) - -> functor(Dn, P, N), - ( \+pred(P), - P \= '', - P \= '', - P \= '', - P \= '', - P \= '', - N = 2 - -> assertz(pred(P)) - ; true - ), - ( Dn \= ''(_, _), - catch(call(Dn), _, fail) - -> true - ; djiti_assertz(Dn), - ( flag('pass-only-new'), - Dn \= answer(_, _, _), - \+pass_only_new(Dn) - -> assertz(pass_only_new(Dn)) - ; true - ), - ( flag(nope) - -> true - ; ( B = ''(P1, Q1), - Rule = ''(Q6, R6), - prfstep(''(P1, Q1), Q3, Q4, _, - ''(P6, Q6), forward, A) - -> assertz(prfstep(Dn, Q3, Q4, Cd, ''(P6, R6), forward, A)) - ; term_index(B, Pnd), - assertz(prfstep(Dn, B, Pnd, Cd, Rule, forward, A)) - ) - ) - ), - astep(A, B, Cd, En, Rule) - ; ( Cn = true - -> true - ; functor(Cn, P, N), - ( \+pred(P), - P \= '', - P \= '', - P \= '', - P \= '', - P \= '', - N = 2 - -> assertz(pred(P)) - ; true - ), - ( Cn \= ''(_, _), - catch(call(Cn), _, fail) - -> true - ; djiti_assertz(Cn), - ( flag('pass-only-new'), - Cn \= answer(_, _, _), - \+pass_only_new(Cn) - -> assertz(pass_only_new(Cn)) - ; true - ), - ( flag(nope) - -> true - ; ( B = ''(P1, Q1), - Rule = ''(Q6, R6), - prfstep(''(P1, Q1), Q3, Q4, _, - ''(P6, Q6), forward, A) - -> assertz(prfstep(Cn, Q3, Q4, Cd, ''(P6, R6), forward, A)) - ; term_index(B, Pnd), - assertz(prfstep(Cn, B, Pnd, Cd, Rule, forward, A)) - ) - ) - ) - ) - ). - -istep(Src, Prem, Conc, Rule) :- % istep(Source, Premise, Conclusion, Rule) - copy_term_nat(Prem, Prec), - labelvars(Prec, 0, _), - term_index(Prec, Pnd), - ( \+prfstep(Conc, Prec, Pnd, Conc, Rule, backward, Src) - -> assertz(prfstep(Conc, Prec, Pnd, Conc, Rule, backward, Src)) - ; true - ). - -pstep(Rule) :- - copy_term_nat(Rule, RuleL), - lookup(RTC, tc, RuleL), - catch(cnt(RTC), _, nb_setval(RTC, 0)), - lookup(RTP, tp, RuleL), - catch(cnt(RTP), _, nb_setval(RTP, 0)). - -hstep(A, B) :- - ( nonvar(A), - A = exopred(P, S, O) - -> pred(P), - U =.. [P, S, O], - qstep(U, B) - ; qstep(A, B) - ). - -qstep(A, B) :- - prfstep(A, B, _, _, _, _, _). -qstep(A, true) :- - ( nonvar(A) - -> ( A =.. [P, [S1, S2|S3], O] - -> B =.. [P, S1, S2, S3, O] - ; ( A =.. [P, S, literal(O1, O2)] - -> B =.. [P, S, O1, O2] - ; B = A - ) - ) - ; pred(P), - A =.. [P, _, _], - B = A - ), - catch(clause(B, true), _, fail), - \+prfstep(A, _, _, _, _, _, _). - -% -% DJITI (Deep Just In Time Indexing) -% - -djiti_answer(answer((A, B)), (C, D)) :- - !, - djiti_answer(answer(A), C), - djiti_answer(answer(B), D). -djiti_answer(answer(A), answer(P, S, O)) :- - ( nonvar(A) - ; atom(P), - S \= void - ), - A =.. [P, S, O], - !. -djiti_answer(answer(exopred(P, S, O)), answer(P, S, O)) :- - ( var(S) - ; S \= void - ), - !. -djiti_answer(answer(A), answer(A, void, void)) :- - !. -djiti_answer(A, A). - -djiti_conc(':-'(exopred(P, S, O), B), ':-'(A, B)) :- - !, - A =.. [P, S, O]. -djiti_conc(answer((A, B), void, void), (answer(A, void, void), D)) :- - !, - djiti_conc(answer(B, void, void), D). -djiti_conc(A, A). - -djiti_fact(answer(P, S, O), answer(P, S, O)) :- - atomic(P), - !, - ( P \= '', - P \= '', - \+pred(P) - -> assertz(pred(P)) - ; true - ). -djiti_fact(implies(A, B, C), implies(A, B, C)) :- - nonvar(B), - conj_list(B, D), - forall( - member(E, D), - ( unify(E, F), - F =.. [P, _, _], - ( \+fpred(P) - -> assertz(fpred(P)) - ; true - ) - ) - ), - !. -djiti_fact(''(A, B), C) :- - nonvar(B), - ( conj_list(B, D) - -> true - ; D = B - ), - forall( - member(E, D), - ( unify(E, F), - F =.. [P, _, _], - ( \+fpred(P) - -> assertz(fpred(P)) - ; true - ) - ) - ), - !, - ( retwist(A, B, Z) - -> true - ; Z = '<>' - ), - makevars(implies(A, B, Z), C, zeta). -djiti_fact(':-'(A, B), ':-'(C, D)) :- - !, - makevars((A, B), (C, E), eta), - copy_term_nat(''(E, C), F), - ( flag(nope) - -> D = E - ; retwist(E, C, G), - ( E = when(H, I) - -> conj_append(I, istep(G, E, C, F), J), - D = when(H, J) - ; conj_append(E, istep(G, E, C, F), D) - ) - ). -djiti_fact(''(A, B), ':-'(''(A, B), true)) :- - !. -djiti_fact(A, A) :- - ground(A), - A =.. [P, _, _], - ( P \= '', - P \= '', - P \= '', - P \= query, - P \= pfx, - P \= flag, - P \= semantics, - \+pred(P) - -> assertz(pred(P)) - ; true - ), - !. -djiti_fact(A, A). - -djiti_assertz(A) :- - djiti_fact(A, B), - assertz(B). - -% -% Built-ins -% - -''(A, B) :- - \+flag(restricted), - avg(A, B). - -''(A, B) :- - \+flag(restricted), - catch(call(A), _, fail), - A \= B, - unify(A, C), - conj_list(C, D), - forall( - member(E, D), - ( ( E = ''(Prem, Conc) - -> retract(implies(Prem, Conc, Src)), - assertz(retwist(Prem, Conc, Src)) - ; ( E = ':-'(Ci, Pi), - Pi \= true - -> ( flag(nope) - -> Ph = Pi - ; ( Pi = when(Ai, Bi) - -> conj_append(Bi, istep(Si, Pi, Ci, _), Bh), - Ph = when(Ai, Bh) - ; conj_append(Pi, istep(Si, Pi, Ci, _), Ph) - ), - ':-'(Ci, Ph), - assertz(retwist(Pi, Ci, Si)) - ), - retract(':-'(Ci, Ph)) - ; E \= ':-'(_, true), - retract(E) - ) - ), - djiti_answer(answer(E), Z), - retractall(Z), - ( flag('pass-only-new'), - pass_only_new(E) - -> retract(pass_only_new(E)) - ; true - ) - ) - ), - nb_getval(wn, W), - labelvars(B, W, N), - nb_setval(wn, N), - unify(B, F), - conj_list(F, G), - forall( - member(H, G), - ( djiti_assertz(H), - ( flag('pass-only-new'), - \+pass_only_new(H) - -> assertz(pass_only_new(H)) - ; true - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - A, - B. - -''([''(A, B)|C], D) :- - \+flag(restricted), - within_scope(_), - ( nb_getval(bnet, done) - -> true - ; bnet, - nb_setval(bnet, done) - ), - bvar(A), - bval(B), - bcon([''(A, B)], C, D). - -''(A, B) :- - \+flag(restricted), - getnumber(A, C), - ( C =:= 0.0 - -> B is 0.0 - ; ( C =:= 1.0 - -> B is 0.0 - ; B is -(C*log(C)+(1-C)*log(1-C))/log(2) - ) - ). - -''([literal(A, type(''))|B], C) :- - \+flag(restricted), - findall(U, - ( member(V, B), - getnumber(V, U) - ), - W - ), - read_term_from_atom(A, D, [variables(W)]), - catch(C is D, _, fail). - -''(A, B) :- - \+flag(restricted), - nonvar(A), - A \= [_,_], - !, - when( - ( nonvar(B) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - open(Tmp2, write, Ws2, [encoding(utf8)]), - tell(Ws2), - ( flag('no-qnames') - -> true - ; forall( - pfx(E, F), - format('@prefix ~w ~w.~n', [E, F]) - ), - nl - ), - labelvars(B, 0, _), - write('{'), - wt(B), - write('} => {'), - wt(B), - write('}.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp3), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--query', Tmp2, '>', Tmp3]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp3, semantics), - absolute_uri(Tmp3, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - L \= [] - ; delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - fail - ) - ) - ). -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - nonvar(A), - conjify(A, B), - catch(call(B), _, fail), - ( flag(nope) - -> true - ; copy_term_nat(''(B, ''(Sc, B)), C), - istep('<>', B, ''(Sc, B), C) - ). - -''(A, B) :- - \+flag(restricted), - findall(C, - ( cartesian(A, C) - ), - B - ). - -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - hstep(A, _). - -''([literal(A, type(''))|B], C) :- - \+flag(restricted), - atomify(B, D), - read_term_from_atom(A, C, [variables(D)]). - -''(A, B) :- - \+flag(restricted), - cov(A, B). - -''(A, B) :- - \+flag(restricted), - atomify(A, C), - D =.. C, - ( B = true - -> catch(call(D), _, fail) - ; \+catch(call(D), _, fail) - ). - -''(literal(A, type('')), B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( exec(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - nonvar(A), - A \= [_,_], - !, - when( - ( nonvar(B) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - open(Tmp2, write, Ws2, [encoding(utf8)]), - tell(Ws2), - ( flag('no-qnames') - -> true - ; forall( - pfx(E, F), - format('@prefix ~w ~w.~n', [E, F]) - ), - nl - ), - labelvars(B, 0, _), - write('{'), - wt(B), - write('} => {'), - wt(B), - write('}.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp3), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--query', Tmp2, '>', Tmp3]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp3, semantics), - absolute_uri(Tmp3, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - L = [] - ; delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - fail - ) - ) - ). -''(A, B) :- - \+flag(restricted), - within_scope(A), - \+catch(call(B), _, fail). - -''(literal(A, type('')), literal(B, type(''))) :- - \+flag(restricted), - read_file_to_string(A, C, []), - ( string_concat(D, "\n", C) - -> true - ; D = C - ), - atom_string(B, D). - -''(A, B) :- - \+flag(restricted), - call_cleanup(A, B), - ( flag(nope) - -> true - ; conj_append(A, B, C), - copy_term_nat(''(C, ''(A, B)), D), - istep('<>', C, ''(A, B), D) - ). - -''(A, B) :- - \+flag(restricted), - nonvar(A), - A \= [_,_], - !, - when( - ( nonvar(B) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - open(Tmp2, write, Ws2, [encoding(utf8)]), - tell(Ws2), - ( flag('no-qnames') - -> true - ; forall( - pfx(E, F), - format('@prefix ~w ~w.~n', [E, F]) - ), - nl - ), - write('{'), - wt(''(_, B)), - write('} => {'), - wt(''(_, B)), - write('}.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp3), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--query', Tmp2, '>', Tmp3]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp3, semantics), - absolute_uri(Tmp3, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - conj_list(K, L), - labelvars(K, 0, _), - B = [_, _, M], - K = ''(_, [_, _, M]), - delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3) - ; delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - fail - ) - ) - ). -''(Sc, [A, B, C]) :- - \+flag(restricted), - within_scope(Sc), - nonvar(B), - \+is_list(B), - catch(findall(A, B, E), _, E = []), - ( flag(warn) - -> copy_term_nat([A, B, E], [Ac, Bc, Ec]), - labelvars([Ac, Bc, Ec], 0, _), - ( fact(''(Sc, [Ac, Bc, G])) - -> ( E \= G - -> format(user_error, '** WARNING ** conflicting_findall_answers ~w VERSUS ~w~n', [[A, B, G], [A, B, E]]), - flush_output(user_error) - ; true - ) - ; assertz(fact(''(Sc, [Ac, Bc, Ec]))) - ) - ; true - ), - E = C. - -''([A|B], [A, B]) :- - \+flag(restricted). - -''([literal(A, type(''))|B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, D), - preformat(B, E), - format_to_chars(D, E, F), - atom_codes(C, F) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( ''(A, C), - conj_list(C, L), - sort(L, M), - conj_list(K, M), - unify(K, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( makevars(A, C, delta), - difference(C, D), - unify(D, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( intersect(A, M), - unify(M, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( unify(A, C), - conj_list(C, D), - ( nonvar(B) - -> cflat(B, E), - ( ground(E) - -> distinct(E, D) - ; D = E - ) - ; ( ground(D) - -> distinct(D, B) - ; B = D - ) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( conj_list(A, C), - member(D, C), - unify(D, B) - ) - ). - -''((A, B), [A, B]) :- - \+flag(restricted). - -''(literal(A, type('')), literal(B, type(''))) :- - \+flag(restricted), - flag('hmac-key', Key), - hmac_sha(Key, A, C, [algorithm(sha1)]), - atom_codes(D, C), - base64xml(D, B). - -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - nonvar(A), - ( catch(call(A), _, fail) - -> ( flag(nope) - -> true - ; copy_term_nat(''(A, ''(Sc, A)), R), - istep('<>', A, ''(Sc, A), R) - ) - ; true - ). - -''(A, literal(B, type(''))) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( atom(A), - ( sub_atom(A, _, 19, _, '/.well-known/genid/') - -> ( sub_atom(A, I, 1, _, '#') - -> J is I+1, - sub_atom(A, J, _, 1, B) - ; B = '' - ) - ; atom_concat(some, C, A), - atomic_list_concat(['sk_', C], B) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - copy_term_nat(A, C), - labelvars(C, 0, _), - term_index(C, D), - ( got_labelvars(C, D, B) - -> true - ; copy_term_nat(A, B), - labelvars(B, 0, _, avar), - assertz(got_labelvars(C, D, B)) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( ( getlist(A, C) - -> true - ; conj_list(A, D), - ( ground(D) - -> distinct(D, C) - ; C = D - ) - ), - length(C, B) - ) - ). - -''(_, B) :- - \+flag(restricted), - \+ \+catch(call(B), _, fail). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( bmax(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( bmin(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A), - nonvar(B) - ), - ( sort(0, @=<, A, C), - sort(0, @=<, B, C) - ) - ). - -''(A, B) :- - \+flag(restricted), - \+''(A, B). - -''(A, B) :- - \+flag(restricted), - \+''(A, B). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( getnumber(A, B) - ) - ). - -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - nonvar(A), - ( \+catch(call(A), _, fail) - -> true - ; catch(call(A), _, fail), - ( flag(nope) - -> true - ; copy_term_nat(''(A, ''(Sc, A)), R), - istep('<>', A, ''(Sc, A), R) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - pcc([A, B], C). - -''(Sc, literal(A, type(''))) :- - \+flag(restricted), - within_scope(Sc), - with_output_to_codes(wh, C), - atom_codes(A, C), - retractall(wpfx(_)). - -''([A], [B, C]) :- - \+flag(restricted), - !, - D =.. [A, B, C], - catch(call(D), _, fail). -''([A|B], [C, D]) :- - \+flag(restricted), - E =.. [A, C, F], - catch(call(E), _, fail), - ''(B, [F, D]). - -''([A|B], C) :- - \+flag(restricted), - term_index([A|B], I), - ( B \= [], - got_random([A|B], I, C) - -> true - ; catch(nb_getval(random, D), _, D = 16127), - E is mod(1046527*D+16769023, 1073676287), - nb_setval(random, E), - C is mod(E, A), - ( B \= [] - -> assertz(got_random([A|B], I, C)) - ; true - ) - ). - -''(A, B) :- - \+flag(restricted), - reverse(A, B). - -''(A, B) :- - \+flag(restricted), - rms(A, B). - -''(St, [Sen, Asp]) :- - \+flag(restricted), - getnumber(St, K), - ( getnumber(Sen, S) - -> Asp is 1-(1-exp(-K*(S-1)))*(1+exp(K))/(1+exp(-K*(S-1)))/(1-exp(K)) - ; getnumber(Asp, A), - Sen is (1-exp(-K*A))*(1+exp(-K))/(1+exp(-K*A))/(1-exp(-K)) - ). - -''(literal(A, type('')), literal(B, type(''))) :- - \+flag(restricted), - sha_hash(A, C, [algorithm(sha1)]), - atom_codes(D, C), - base64xml(D, B). - -''(A, B) :- - \+flag(restricted), - getnumber(A, C), - B is 1/(1+exp(-C)). - -''(X, Y) :- - \+flag(restricted), - ''(Y, X), - ( \+keep_skolem(Y) - -> assertz(keep_skolem(Y)) - ; true - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( sort(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - std(A, B). - -''(literal(X, Y), literal(Z, Y)) :- - \+flag(restricted), - when( - ( ground(X) - ), - ( atom_codes(X, U), - escape_string(U, V), - atom_codes(Z, V) - ) - ). - -''(literal(X, Y), literal(Z, Y)) :- - \+flag(restricted), - when( - ( ground(X) - ), - ( atom_codes(X, U), - reverse(U, V), - atom_codes(Z, V) - ) - ). - -''([literal(X, type('')), literal(Y, type(''))], - Z) :- - \+flag(restricted), - when( - ( ground([X, Y]) - ), - ( atom_codes(X, U), - atom_codes(Y, C), - ( C = [] - -> findall(literal(A, type('')), - ( member(B, U), - atom_codes(A, [B]) - ), - Z - ) - ; escape_string(V, C), - esplit_string(U, V, [], W), - findall(literal(A, type('')), - ( member(B, W), - atom_codes(A, B) - ), - Z - ) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( sub_list(A, B) - ) - ). - -''(X, Y) :- - \+flag(restricted), - tell(user_error), - write('TRACE '), - ( ( var(X) - ; findvar(X, beta) - ) - -> copy_term_nat(Y, Z), - wg(Z) - ; writeq(Y) - ), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( e_transpose(A, B) - ) - ). - -''(A, [B, C, D]) :- - \+flag(restricted), - A =.. [C, B, D]. - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ; ground(Y) - ), - ( ( is_list(Y), - length(Y, I), - I < 8 - -> Z =.. [tuple, X|Y] - ; Z = tuple(X, Y) - ), - ( call(Z) - -> true - ; var(X), - nb_getval(tuple, M), - N is M+1, - nb_setval(tuple, N), - atom_number(A, N), - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 't_', A, '>'], X), - assertz(Z) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - ( got_unique(A, B) - -> fail - ; assertz(got_unique(A, B)) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( findvars(A, C, delta), - C \= [] - -> true - ; catch(call(B), _, A = B) - ) - ). - -''(X, literal(Y, type(''))) :- - \+flag(restricted), - when( - ( ground(X) - ; ground(Y) - ), - ( ( ground(X) - -> ( number(X) - -> atom_number(T, X) - ; X = literal(T, _) - ), - www_form_encode(T, Z), - atom_codes(Z, U), - subst([[[0'%, 0'2, 0'0], [0'+]]], U, V), - atom_codes(Y, V) - ; www_form_encode(X, Y) - ) - ) - ). - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [Y|Z], - nonvar(Z) - ) - ), - !. - -''(X, []) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [_] - ) - ), - !. -''(X, '') :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [_] - ) - ), - !. -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [_|Y] - ) - ), - !. - -''(literal(A, type('')), literal(B, type(''))) :- - md5_hash(A, B, []). - -''(literal(A, type('')), literal(B, type(''))) :- - sha_hash(A, C, [algorithm(sha1)]), - hash_atom(C, B). - -''(literal(A, type('')), literal(B, type(''))) :- - sha_hash(A, C, [algorithm(sha256)]), - hash_atom(C, B). - -''(literal(A, type('')), literal(B, type(''))) :- - sha_hash(A, C, [algorithm(sha512)]), - hash_atom(C, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( makevars(A, C, delta), - difference(C, D), - unify(D, B) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( conj_list(A, D), - ( ground(D) - -> distinct(D, C) - ; C = D - ), - length(C, B) - ) - ). - -''(A, B) :- - conj_list(A, B). - -''(A, B) :- - ''(A, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - ( member(D, C), - var(D), - var(B) - -> true - ; append(C, B) - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - C = [B|D], - nonvar(D) - ) - ). - -''([A|B], [A, B]). - -''(A, B) :- - when( - ( nonvar(B) - ), - ( getlist(B, C), - member(A, C) - ) - ). - -''(A, [B, C]) :- - when( - ( nonvar(A) - ), - ( nth0(B, A, C) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - last(C, B) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( ( getlist(A, C) - -> true - ; conj_list(A, D), - ( ground(D) - -> distinct(D, C) - ; C = D - ) - ), - length(C, B) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A), - nonvar(B) - ), - ( getlist(A, D), - findall(E, - ( member(F, D), - G =.. [B, F, E], - G - ), - C - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - member(B, C) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A) - ), - ( nth0(B, A, C) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A), - nonvar(B) - ), - ( findall(I, - ( member(I, A), - I \= B - ), - C - ) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A) - ), - ( nth0(B, A, D), - findall(I, - ( member(I, A), - I \= D - ), - C - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - list_to_set(C, B) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - C = [_|B] - ) - ). - -''(A, B) :- - when( - ( nonvar(A), - nonvar(B) - ), - ( getlist(A, C), - getlist(B, D), - sort(C, E), - sort(D, E) - ) - ). - -''(A, B) :- - \+''(A, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( sort(A, B) - ) - ). - -''(A, B) :- - ''(A, B). - -''(X, Y) :- - ( nonvar(X) - -> Y = true - ; Y = false - ). - -''(A, B) :- - call_cleanup(A, B), - ( flag(nope) - -> true - ; conj_append(A, B, C), - copy_term_nat(''(C, ''(A, B)), D), - istep('<>', C, ''(A, B), D) - ). - -''([A, B, C], Sc) :- - within_scope(Sc), - nonvar(B), - \+is_list(B), - catch(findall(A, B, E), _, E = []), - ( flag(warn) - -> copy_term_nat([A, B, E], [Ac, Bc, Ec]), - labelvars([Ac, Bc, Ec], 0, _), - ( fact(''(Sc, [Ac, Bc, G])) - -> ( E \= G - -> format(user_error, '** WARNING ** conflicting_collectAllIn_answers ~w VERSUS ~w~n', [[A, B, G], [A, B, E]]), - flush_output(user_error) - ; true - ) - ; assertz(fact(''(Sc, [Ac, Bc, Ec]))) - ) - ; true - ), - E = C. - -''(A, B) :- - when( - ( nonvar(A) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--pass-all', '>', Tmp2]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp2, semantics), - absolute_uri(Tmp2, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - conj_list(B, L), - labelvars(B, 0, _), - delete_file(Tmp1), - delete_file(Tmp2) - ; delete_file(Tmp1), - delete_file(Tmp2), - fail - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( conjoin(A, M), - unify(M, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - ''(A, C), - ''(C, B). - -''([A, B], C) :- - when( - ( ground(A) - ; nonvar(C) - ), - ( ground(A), - ( var(B) - -> ( member(B, ['', '', - '', '', '', - '', '', '']), - dtlit([A, B], C), - getnumber(C, D), - dtlit([_, B], D) - -> true - ; ( dtlit([A, ''], C), - getbool(C, _), - B = '' - -> true - ; B = '', - C = A - ) - ) - ; A = literal(E, _), - ( B = prolog:atom - -> C = E - ; C = literal(E, type(B)) - ), - ! - ) - ; nonvar(C), - dtlit([A, B], C) - ) - ). - -''(X, Y) :- - unify(X, Y). - -''([A, B], Sc) :- - within_scope(Sc), - when( - ( nonvar(A), - nonvar(B) - ), - ( forall(A, B) - ) - ). - -''(X, Y) :- - implies(U, V, _), - unify(U, X), - unify(V, Y), - ( commonvars(X, Y, []) - -> labelvars(Y, 0, _, avar) - ; true - ), - ( var(Y) - -> true - ; Y \= answer(_, _, _), - Y \= (answer(_, _, _), _) - ). - -''(X, Y) :- - within_scope(X), - !, - when( - ( nonvar(Y) - ), - ( Y - ) - ). -''(X, Y) :- - when( - ( nonvar(X), - nonvar(Y) - ), - ( conj_list(X, A), - conj_list(Y, B), - includes(A, B) - ) - ). - -''(X, Y) :- - within_scope(X), - !, - when( - ( nonvar(Y) - ), - ( \+ \+call(Y) - ) - ). -''(X, Y) :- - when( - ( nonvar(X), - nonvar(Y) - ), - ( conj_list(X, A), - conj_list(Y, B), - \+ \+includes(A, B) - ) - ). - -''(A, B) :- - ''(A, C), - ( nonvar(B) - -> ''([B,C], B) - ; B = C - ). - -''([literal(A, type('')), literal(B, type(''))], literal(A, lang(B))). - -''(A, literal(B, type(''))) :- - term_variables(A, V), - labelvars([A, V], 0, _, avar), - with_output_to_chars((wq(V, allv), wt(A)), E), - escape_string(E, F), - atom_codes(B, F). - -''(A, literal(B, type(''))) :- - when( - ( nonvar(A) - ), - ( sub_atom(A, 1, _, 1, C), - sub_atom_last(C, _, 1, N, '/'), - sub_atom(C, _, N, 0, B) - ) - ). - -''(A, literal(B, type(''))) :- - ( n3s(A, literal(B, type(''))) - -> true - ; retractall(wpfx(_)), - with_output_to_chars(wh, C1), - \+ (C1 = [], \+flag('no-qnames')), - numbervars(A), - with_output_to_chars(wt(A), C2), - append(C1, C2, C), - escape_string(C, D), - atom_codes(B, D), - assertz(n3s(A, literal(B, type('')))) - ). - -''(A, literal(B, type(''))) :- - when( - ( nonvar(A) - ), - ( sub_atom(A, 1, _, 1, C), - sub_atom_last(C, N, 1, _, '/'), - M is N+1, - sub_atom(C, 0, M, _, B) - ) - ). - -''(X, Y) :- - \+''(X, Y). - -''(X, Y) :- - ignore(within_scope(X)), - \+''(X, Y). - -''(literal(A, _), B) :- - atom_codes(A, C), - escape_string(D, C), - atom_codes(E, D), - tmp_file(Tmp), - open(Tmp, write, Ws, [encoding(utf8)]), - tell(Ws), - writef(E, []), - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - atomic_list_concat([''], F), - ''(F, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( sub_atom(A, 1, _, 1, C), - sub_atom(C, N, 1, _, '#'), - sub_atom(C, 0, N, _, D), - atomic_list_concat(['<', D, '>'], B) - ) - ). - -''(A, B) :- - nonvar(A), - raw_type(A, C), - C = B. - -''(A, B) :- - C is A-1, - between(0, C, B). - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( ( semantics(X, L) - -> conj_list(Y, L) - ; sub_atom(X, 0, 1, _, '<'), - sub_atom(X, _, 1, 0, '>'), - sub_atom(X, 1, _, 1, Z), - catch( - n3_n3p(Z, semantics), - Exc, - ( format(user_error, '** ERROR ** ~w **~n', [Exc]), - flush_output(user_error), - fail - ) - ), - semantics(X, L), - conj_list(Y, L) - ) - ) - ). - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( ( semantics(X, L) - -> conj_list(Y, L) - ; sub_atom(X, 0, 1, _, '<'), - sub_atom(X, _, 1, 0, '>'), - sub_atom(X, 1, _, 1, Z), - catch( - n3_n3p(Z, semantics), - Exc, - assertz(semantics(X, [literal(Exc, type(''))])) - ), - semantics(X, L), - conj_list(Y, L) - ) - ) - ). - -''(X, Y) :- - ''(Y, X), - ( \+keep_skolem(Y) - -> assertz(keep_skolem(Y)) - ; true - ). - -''(A, B) :- - ''(A, B). - -''(X, Y) :- - when( - ( nonvar(X) - ; nonvar(Y) - ), - ( atomic(X), - ( atom_concat(some, V, X) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'sk_', V, '>'], U) - ; ( atom_concat(avar, V, X) - -> atomic_list_concat([''], U) - ; U = X - ) - ), - sub_atom(U, 1, _, 1, Z), - atomic_list_concat(['<', Z, '>'], U), - Y = literal(Z, type('')), - ! - ; nonvar(Y), - Y = literal(Z, type('')), - atomic_list_concat(['<', Z, '>'], X) - ) - ). - -''(X, literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( ''(X, literal(U, type(''))), - ( \+got_uuid(U) - -> uuid(Y, [uri(U)]), - assertz(got_uuid(U)) - ; true - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, U), - Y is abs(U) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is acos(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is acosh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is asin(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is asinh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is atan(W) - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - Z is atan(U/V) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is atanh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( - getnumber(X, U), - Y is ceiling(U) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is cos(U), - ! - ; getnumber(Y, W), - X is acos(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is cosh(U), - ! - ; getnumber(Y, W), - X is acosh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is U*180/pi, - ! - ; getnumber(Y, W), - X is W*pi/180 - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - Z is U-V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U =:= V - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ; ground([X, Z]) - ), - ( getnumber(X, U), - ( getnumber(Y, V), - Z is U**V, - ! - ; getnumber(Z, W), - W =\= 0, - U =\= 0, - Y is log(W)/log(U) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( - getnumber(X, U), - Y is floor(U) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U > V - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - ( V =\= 0 - -> Z is round(floor(U/V)) - ; throw(zero_division(''([X, Y], Z))) - ) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U < V - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ; ground([X, Z]) - ), - ( getnumber(X, U), - ( getnumber(Y, V), - V =\= 0, - U =\= 0, - Z is log(U)/log(V), - ! - ; getnumber(Z, W), - Y is U**(1/W) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( max_list(X, Y) - ) - ). - -''(X, Y) :- - when( - ( nonvar(X) - ), - ( ( getlist(X, Z) - -> true - ; conj_list(X, U), - ( ground(U) - -> distinct(U, Z) - ; Z = U - ) - ), - length(Z, Y) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( min_list(X, Y) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is -U, - ! - ; getnumber(Y, W), - X is -W - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U =\= V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U =< V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U >= V - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( product(X, Y) - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - ( V =\= 0 - -> Z is U/V - ; throw(zero_division(''([X, Y], Z))) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is U*pi/180, - ! - ; getnumber(Y, W), - X is W*180/pi - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - ( V =\= 0 - -> Z is U-V*round(floor(U/V)) - ; throw(zero_division(''([X, Y], Z))) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, U), - Y is round(round(U)) - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - F is 10**floor(V), - Z is round(round(U*F))/F - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is sin(U), - ! - ; getnumber(Y, W), - X is asin(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is sinh(U), - ! - ; getnumber(Y, W), - X is asinh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( sum(X, Y) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is tan(U), - ! - ; getnumber(Y, W), - X is atan(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is tanh(U), - ! - ; getnumber(Y, W), - X is atanh(W) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground(X) - ), - ( sub_atom(X, 0, 1, _, A), - upcase_atom(A, B), - sub_atom(X, 1, _, 0, C), - downcase_atom(C, D), - atom_concat(B, D, Y) - ) - ). - -''(X, Y) :- - when( - ( nonvar(X) - ), - ( getlist(X, C), - labelvars(C, 0, _, avar), - ( member(D, C), - var(D), - var(Y) - -> true - ; findall(S, - ( member(A, X), - getcodes(A, S) - ), - Z - ), - flatten(Z, E), - atom_codes(F, E), - Y = literal(F, type('')) - ) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground([X, Y]) - ), - ( sub_atom(X, _, _, _, Y) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground([X, Y]) - ), - ( downcase_atom(X, U), - downcase_atom(Y, V), - sub_atom(U, _, _, _, V) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground([X, Y]) - ), - ( downcase_atom(X, R), - downcase_atom(Y, S), - normalize_space(atom(U), R), - normalize_space(atom(V), S), - sub_atom(U, _, _, _, V) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( sub_atom(X, _, _, 0, Y) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( downcase_atom(X, U), - downcase_atom(Y, U) - ) - ). - -''([literal(A, _)|B], literal(C, type(''))) :- - when( - ( ground([A, B]) - ), - ( atom_codes(A, D), - subst([[[0'%, 0's], [0'~, 0'w]]], D, E), - preformat(B, F), - format_to_chars(E, F, G), - atom_codes(C, G) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @> V - ) - ). - -''([X,Y], Z) :- - when( - ( nonvar(X) - ), - ( getlist(X, C), - getcodes(Y, D), - labelvars(C, 0, _, avar), - ( member(E, C), - var(E), - var(Z) - -> true - ; findall([D,S], - ( member(A, X), - getcodes(A, S) - ), - U - ), - flatten(U, V), - ( V = [] - -> F = V - ; append(D, F, V) - ), - atom_codes(G, F), - Z = literal(G, type('')) - ) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @< V - ) - ). - -''(literal(A, _), B) :- - when( - ( ground(A) - ), - ( sub_atom(A, 0, B, 0, _) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground(X) - ), - ( downcase_atom(X, Y) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( regex(Y, X, _) - ) - ). - -''(X, Y) :- - \+''(X, Y). - -''(X, Y) :- - \+''(X, Y). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @=< V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @>= V - ) - ). - -''(X, Y) :- - \+''(X, Y). - -''([literal(X, _),literal(Search, _),literal(Replace, _)], literal(Y, type(''))) :- - when( - ( ground([X,Search,Replace]) - ), - ( ( regex(Search, X, [S|_]) - -> atom_codes(X, XC), - string_codes(S, SC), - atom_codes(Replace, RC), - subst([[[0'$,0'1],SC]], RC, TC), - subst([[SC,TC]], XC, YC), - atom_codes(Y, YC) - ; Y = X - ) - ) - ). - -''([literal(X, _),SearchList,ReplaceList], literal(Y, type(''))) :- - when( - ( ground([X,SearchList,ReplaceList]) - ), - ( preformat(SearchList, SearchList2), - preformat(ReplaceList, ReplaceList2), - replace(SearchList2, ReplaceList2, X, Z), - atom_string(Y, Z) - ) - ). - -''([literal(X, _),literal(Y, _)], literal(Z, type(''))) :- - when( - ( ground([X,Y]) - ), - ( regex(Y, X, [W|_]), - atom_string(Z, W) - ) - ). - -''([literal(X, _),literal(Y, _)], Z) :- - when( - ( ground([X,Y]) - ), - ( scrape(X, Y, V), - preformat(Z, V) - ) - ). - -''([literal(X, _),literal(Y, _)], Z) :- - when( - ( ground([X, Y]) - ), - ( regex(Y, X, L), - findall(literal(A, type('')), - ( member(M, L), - atom_string(A, M) - ), - Z - ) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( sub_atom(X, 0, _, _, Y) - ) - ). - -''([literal(A, _), B, C], literal(D, type(''))) :- - !, - when( - ( ground([A, B, C]) - ), - ( getint(B, I), - getint(C, J), - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = '' - ; sub_atom(A, G, H, _, D) - ) - ) - ). -''([literal(A, _), B], literal(D, type(''))) :- - when( - ( ground([A, B]) - ), - ( getint(B, I), - sub_atom(A, 0, E, 0, _), - J is E-I+1, - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = [] - ; sub_atom(A, G, H, _, D) - ) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground(X) - ), - ( upcase_atom(X, Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( sub_atom(X, 8, 2, _, Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( timestamp(Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( sub_atom(X, 5, 2, _, Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( sub_atom(X, 0, 4, _, Y) - ) - ). - -% RIF built-ins according to RIF Datatypes and Built-Ins 1.0 -- http://www.w3.org/TR/rif-dtb/ - -% 4.1.1.1 pred:literal-not-identical - -''([literal(A, B), literal(C, B)], D) :- - \+flag(restricted), - when( - ( ground([A, B, C]) - ), - ( A \== C - -> D = true - ; D = false - ) - ). - -% 4.4.4 pred:iri-string - -''([A, literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( nonvar(A) - ; nonvar(B) - ), - ( atom(A), - sub_atom(A, 1, _, 1, U), - atomic_list_concat(['<', U, '>'], A), - !, - ( U = B - -> C = true - ; C = false - ) - ; nonvar(B), - ( atomic_list_concat(['<', B, '>'], A) - -> C = true - ; C = false - ) - ) - ). - -% 4.5.1 Numeric Functions - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sum([A, B], C) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - C is U-V - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - C is U*V - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( V =\= 0 - -> C is U/V - ; throw(zero_division(''([A, B], C))) - ) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( V =\= 0 - -> C is integer(floor(U/V)) - ; throw(zero_division(''([A, B], C))) - ) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( V =\= 0 - -> C is U-V*integer(floor(U/V)) - ; throw(zero_division(''([A, B], C))) - ) - ) - ). - -% 4.5.2.1 pred:numeric-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U =:= V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.2 pred:numeric-less-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U < V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.3 pred:numeric-greater-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U > V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.4 pred:numeric-not-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U =\= V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.5 pred:numeric-less-than-or-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U =< V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.6 pred:numeric-greater-than-or-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U >= V - -> C = true - ; C = false - ) - ) - ). - -% 4.6.1.1 func:not - -''([A], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( getbool(A, U), - ( ground(B) - -> getbool(B, V) - ; V = B - ), - inv(U, V) - ) - ). - -% 4.6.2.1 pred:boolean-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getbool(A, U), - getbool(B, U) - -> C = true - ; C = false - ) - ). - -% 4.6.2.2 pred:boolean-less-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getbool(A, false), - getbool(B, true) - -> C = true - ; C = false - ) - ). - -% 4.6.2.3 pred:boolean-greater-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getbool(A, true), - getbool(B, false) - -> C = true - ; C = false - ) - ). - -% 4.7.1.1 func:compare @@partial implementation: no collation - -''([literal(A, B), literal(C, B)], D) :- - \+flag(restricted), - !, - ( A @< C - -> D = -1 - ; ( A == C - -> D = 0 - ; ( A @> C - -> D = 1 - ) - ) - ). - -% 4.7.1.2 func:concat - -''(A, literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( findall(F, - ( member(literal(S, type('')), A), - atom_codes(S, F) - ), - C - ), - flatten(C, D), - atom_codes(B, D) - ) - ). - -% 4.7.1.3 func:string-join - -''([A, literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(B, D), - findall([D, E], - ( member(literal(F, type('')), A), - atom_codes(F, E) - ), - G - ), - ( G = [[_, H]|I] - -> flatten([H|I], J), - atom_codes(C, J) - ; C = '' - ) - ) - ). - -% 4.7.1.4 func:substring - -''([literal(A, _), B, C], literal(D, type(''))) :- - \+flag(restricted), - !, - when( - ( ground([A, B, C]) - ), - ( getint(B, I), - getint(C, J), - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = '' - ; sub_atom(A, G, H, _, D) - ) - ) - ). -''([literal(A, _), B], literal(D, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getint(B, I), - sub_atom(A, 0, E, 0, _), - J is E-I+1, - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = [] - ; sub_atom(A, G, H, _, D) - ) - ) - ). - -% 4.7.1.5 func:string-length - -''([literal(A, _)], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( sub_atom(A, 0, B, 0, _) - ) - ). - -% 4.7.1.6 func:upper-case - -''([literal(A, B)], literal(C, B)) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( upcase_atom(A, C) - ) - ). - -% 4.7.1.7 func:lower-case - -''([literal(A, B)], literal(C, B)) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( downcase_atom(A, C) - ) - ). - -% 4.7.1.8 func:encode-for-uri - -''([literal(A, B)], literal(C, B)) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( www_form_encode(A, C) - ) - ). - -% 4.7.1.11 func:substring-before @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, W, _, _, B), - sub_atom(A, 0, W, _, C) - ) - ). - -% 4.7.1.12 func:substring-after @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, _, _, W, B), - sub_atom(A, _, W, 0, C) - ) - ). - -% 4.7.2.1 pred:contains @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(B, 0, D, 0, _), - sub_atom(A, _, D, _, B) - -> C = true - ; C = false - ) - ). - -% 4.7.2.2 pred:starts-with @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, 0, _, _, B) - -> C = true - ; C = false - ) - ). - -% 4.7.2.3 pred:ends-with @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, _, _, 0, B) - -> C = true - ; C = false - ) - ). - -% 4.7.2.4 pred:matches @@partial implementation: no flags - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( regex(B, A, _) - -> C = true - ; C = false - ) - ). - -% 4.8.1.1 func:year-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(C, _, _, _, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.2 func:month-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, C, _, _, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.3 func:day-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, C, _, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.4 func:hours-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, C, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.5 func:minutes-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, _, C, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.6 func:seconds-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, _, _, C, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.7 func:year-from-date - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(C, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.8 func:month-from-date - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(_, C, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.9 func:day-from-date - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(_, _, C, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.10 func:hours-from-time - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(C, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.11 func:minutes-from-time - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(_, C, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.12 func:seconds-from-time - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(_, _, C, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.13 func:years-from-duration - -''([literal(_, type(''))], 0) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - yearmonthduration(C, U, []), - D is C//12, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.14 func:months-from-duration - -''([literal(_, type(''))], 0) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - yearmonthduration(C, U, []), - D is C-(C//12)*12, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.15 func:days-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is integer(C)//86400, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.16 func:hours-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is (integer(C)-(integer(C)//86400)*86400)//3600, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.17 func:minutes-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is (integer(C)-(integer(C)//3600)*3600)//60, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.18 func:seconds-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is C-(integer(C)//60)*60, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.19 func:timezone-from-dateTime - -''([literal(A, type(''))], literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, _, _, _, C, U, []), - ( ground(B) - -> atom_codes(B, V), - daytimeduration(D, V, []), - D =:= C - ; daytimeduration(C, E), - atom_codes(B, E) - ) - ) - ). - -% 4.8.1.20 func:timezone-from-date - -''([literal(A, type(''))], literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(_, _, _, C, U, []), - ( ground(B) - -> atom_codes(B, V), - daytimeduration(D, V, []), - D =:= C - ; daytimeduration(C, E), - atom_codes(B, E) - ) - ) - ). - -% 4.8.1.21 func:timezone-from-time - -''([literal(A, type(''))], literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(_, _, _, C, U, []), - ( ground(B) - -> atom_codes(B, V), - daytimeduration(D, V, []), - D =:= C - ; daytimeduration(C, E), - atom_codes(B, E) - ) - ) - ). - -% 4.8.1.22 func:subtract-dateTimes - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.23 func:subtract-dates - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.24 func:subtract-times - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.25 func:add-yearMonthDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - F is D+E, - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.26 func:subtract-yearMonthDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.27 func:multiply-yearMonthDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - yearmonthduration(D, U, []), - getnumber(B, E), - F is integer(round(D*E-1)+1), - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.28 func:divide-yearMonthDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - yearmonthduration(D, U, []), - getnumber(B, E), - F is integer(round(D/E-1)+1), - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.29 func:divide-yearMonthDuration-by-yearMonthDuration - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - F is D/E, - ( ground(C) - -> C =:= F - ; C = F - ) - ) - ). - -% 4.8.1.30 func:add-dayTimeDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - F is D+E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.31 func:subtract-dayTimeDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.32 func:multiply-dayTimeDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - daytimeduration(D, U, []), - getnumber(B, E), - F is integer(round(D*E-1)+1), - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.33 func:divide-dayTimeDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - daytimeduration(D, U, []), - getnumber(B, E), - F is integer(round(D/E-1)+1), - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.34 func:divide-dayTimeDuration-by-dayTimeDuration - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - F is D/E, - ( ground(C) - -> C =:= F - ; C = F - ) - ) - ). - -% 4.8.1.35 func:add-yearMonthDuration-to-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - yearmonthduration(K, V, []), - L is E+K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+I+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.36 func:add-yearMonthDuration-to-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - yearmonthduration(K, V, []), - L is E+K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+31536000-N-G))//60)*60, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.37 func:add-dayTimeDuration-to-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - daytimeduration(K, V, []), - L is I+K, - memotime(datime(D, E, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+L+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.38 func:add-dayTimeDuration-to-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is integer(K), - memotime(datime(D, E, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+L+31536000-N))//86400)*86400-G, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.39 func:add-dayTimeDuration-to-time - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is F+K, - memotime(datime(1972, 12, 31, D, E, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - Z is M+L+31536000-N-G, - O is Z-86400*integer(floor(Z/86400)), - ( ground(C) - -> atom_codes(C, W), - time(P, W, []), - O =:= P-86400*integer(floor(P/86400)) - ; Offset is -G, - stamp_date_time(O, date(_, _, _, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - time(Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.40 func:subtract-yearMonthDuration-from-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - yearmonthduration(K, V, []), - L is E-K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+I+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.41 func:subtract-yearMonthDuration-from-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - yearmonthduration(K, V, []), - L is E-K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+31536000-N-G))//60)*60, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.42 func:subtract-dayTimeDuration-from-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - daytimeduration(K, V, []), - L is I-integer(K), - memotime(datime(D, E, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+L+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.43 func:subtract-dayTimeDuration-from-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is -integer(K), - memotime(datime(D, E, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+L+31536000-N))//86400)*86400-G, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.44 func:subtract-dayTimeDuration-from-time - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is F-K, - memotime(datime(1972, 12, 31, D, E, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - Z is M+L+31536000-N-G, - O is Z-86400*integer(floor(Z/86400)), - ( ground(C) - -> atom_codes(C, W), - time(P, W, []), - O =:= P-86400*integer(floor(P/86400)) - ; Offset is -G, - stamp_date_time(O, date(_, _, _, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - time(Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.2.1 pred:dateTime-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.2 pred:dateTime-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.3 pred:dateTime-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.4 pred:date-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.5 pred:date-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.6 pred:date-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.7 pred:time-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.8 pred:time-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.9 pred:time-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.10 pred:duration-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - duration(D, U, []), - duration(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.11 pred:dayTimeDuration-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.12 pred:dayTimeDuration-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.13 pred:yearMonthDuration-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.14 pred:yearMonthDuration-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.15 pred:dateTime-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.16 pred:dateTime-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.17 pred:dateTime-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.18 pred:date-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.19 pred:date-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.20 pred:date-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.21 pred:time-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.22 pred:time-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.23 pred:time-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.24 pred:duration-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - duration(D, U, []), - duration(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.25 pred:dayTimeDuration-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.26 pred:dayTimeDuration-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.27 pred:yearMonthDuration-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.28 pred:yearMonthDuration-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.10.1.1 func:PlainLiteral-from-string-lang - -''([literal(A, type(''))], literal(A, type(''))) :- - \+flag(restricted), - !. -''([literal(A, type('')), literal(B, type(''))], literal(A, lang(C))) :- - \+flag(restricted), - downcase_atom(B, C). - -% 4.10.1.2 func:string-from-PlainLiteral - -''([literal(A, type(''))], literal(A, type(''))) :- - \+flag(restricted), - !. -''([literal(A, lang(_))], literal(A, type(''))) :- - \+flag(restricted). - -% 4.10.1.3 func:lang-from-PlainLiteral - -''([literal(_, type(''))], literal('', type(''))) :- - \+flag(restricted), - !. -''([literal(_, lang(A))], literal(A, type(''))) :- - \+flag(restricted). - -% 4.10.1.4 func:PlainLiteral-compare @@partial implementation: no collation - -''([literal(A, type('')), literal(C, type(''))], D) :- - \+flag(restricted), - !, - ( A @< C - -> D = -1 - ; ( A == C - -> D = 0 - ; ( A @> C - -> D = 1 - ) - ) - ). -''([literal(A, lang(B)), literal(C, lang(B))], D) :- - \+flag(restricted), - ( A @< C - -> D = -1 - ; ( A == C - -> D = 0 - ; ( A @> C - -> D = 1 - ) - ) - ). - -% 4.10.1.5 func:PlainLiteral-length - -''([literal(A, type(''))], C) :- - \+flag(restricted), - !, - sub_atom(A, 0, C, 0, _). -''([literal(A, lang(_))], C) :- - \+flag(restricted), - sub_atom(A, 0, C, 0, _). - -% 4.10.2.1 pred:matches-language-range @@partial implementation: no false results - -''([literal(A, lang(B)), literal(C, type(''))], true) :- - \+flag(restricted), - A \= '', - atom_codes(C, U), - regexp_wildcard(U, V), - atom_codes(E, V), - atomic_list_concat(['^', E], F), - downcase_atom(F, G), - downcase_atom(B, H), - regex(G, H, _). - -% 4.11.3.1 pred:is-list - -''([A], B) :- - \+flag(restricted), - ( is_list(A) - -> B = true - ; B = false - ). - -% 4.11.3.2 pred:list-contains - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( member(B, A) - -> C = true - ; C = false - ) - ). - -% 4.11.4.1 func:make-list - -''(A, A) :- - \+flag(restricted). - -% 4.11.4.2 func:count - -''([A], B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( length(A, B) - ) - ). - -% 4.11.4.3 func:get - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( getnumber(B, U), - nth0(U, A, C) - ) - ). - -% 4.11.4.4 func:sublist - -''([A, B, C], D) :- - \+flag(restricted), - !, - when( - ( nonvar(A), - ground([B, C]) - ), - ( getint(B, U), - getint(C, V), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - ( V < 0 - -> J is W+V - ; J is V - ), - append(E, F, A), - length(E, I), - append(D, G, F), - K is J-I, - ( length(D, K) - -> true - ; G = [] - ), - ! - ) - ). -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( getint(B, U), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - append(E, C, A), - length(E, I), - ! - ) - ). - -% 4.11.4.5 func:append - -''([A|B], C) :- - \+flag(restricted), - append(A, B, C). - -% 4.11.4.6 func:concatenate - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( append(A, B) - ) - ). - -% 4.11.4.7 func:insert-before - -''([A, B, C], D) :- - \+flag(restricted), - when( - ( nonvar(A), - ground([B, C]) - ), - ( getint(B, U), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - append(G, H, A), - length(G, I), - append([G, [C], H], D) - ) - ). - -% 4.11.4.8 func:remove - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( getint(B, U), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - append(G, [_|T], A), - length(G, I), - append(G, T, C) - ) - ). - -% 4.11.4.9 func:reverse - -''([A], B) :- - \+flag(restricted), - reverse(A, B). - -% 4.11.4.10 func:index-of - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( findall(I, - ( nth0(I, A, B) - ), - C - ) - ) - ). - -% 4.11.4.11 func:union - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( append(A, C), - distinct(C, B) - ) - ). - -% 4.11.4.12 func:distinct-values - -''([A], B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( distinct(A, B) - ) - ). - -% 4.11.4.13 func:intersect - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground(A), - ground(B) - ), - ( findall(I, - ( member(I, A), - member(I, B) - ), - C - ) - ) - ). - -% 4.11.4.14 func:except - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground(A), - ground(B) - ), - ( findall(I, - ( member(I, A), - \+member(I, B) - ), - C - ) - ) - ). - -% Prolog built-ins - -prolog_sym(abolish, abolish, rel). -prolog_sym(abort, abort, rel). -prolog_sym(abs, abs, func). -prolog_sym(absolute_file_name, absolute_file_name, rel). -prolog_sym(acos, acos, func). -prolog_sym(acosh, acosh, func). -prolog_sym(acyclic_term, acyclic_term, rel). -prolog_sym(alarm, alarm, rel). -prolog_sym(append, append, rel). -prolog_sym(arg, arg, rel). -prolog_sym(arithmetic_equal, =:=, rel). -prolog_sym(arithmetic_greater_than, >, rel). -prolog_sym(arithmetic_greater_than_or_equal, >=, rel). -prolog_sym(arithmetic_less_than, <, rel). -prolog_sym(arithmetic_less_than_or_equal, =<, rel). -prolog_sym(arithmetic_not_equal, =\=, rel). -prolog_sym(asin, asin, func). -prolog_sym(asinh, asinh, func). -prolog_sym(assert, assert, rel). -prolog_sym(asserta, asserta, rel). -prolog_sym(assertz, assertz, rel). -prolog_sym(at_end_of_stream, at_end_of_stream, rel). -prolog_sym(atan, atan, func). -prolog_sym(atan2, atan2, func). -prolog_sym(atanh, atanh, func). -prolog_sym(atom, atom, rel). -prolog_sym(atom_chars, atom_chars, rel). -prolog_sym(atom_codes, atom_codes, rel). -prolog_sym(atom_concat, atom_concat, rel). -prolog_sym(atom_length, atom_length, rel). -prolog_sym(atom_number, atom_number, rel). -prolog_sym(atomic, atomic, rel). -prolog_sym(atomic_concat, atomic_concat, rel). -prolog_sym(atomic_list_concat, atomic_list_concat, rel). -prolog_sym(b_getval, b_getval, rel). -prolog_sym(b_setval, b_setval, rel). -prolog_sym(bagof, bagof, rel). -prolog_sym(between, between, rel). -prolog_sym(break, break, rel). -prolog_sym(call, call, rel). -prolog_sym(call_residue_vars, call_residue_vars, rel). -prolog_sym(callable, callable, rel). -prolog_sym(catch, catch, rel). -prolog_sym(ceiling, ceiling, func). -prolog_sym(char_code, char_code, rel). -prolog_sym(char_conversion, char_conversion, rel). -prolog_sym(char_type, char_type, rel). -prolog_sym(character_count, character_count, rel). -prolog_sym(clause, clause, rel). -prolog_sym(close, close, rel). -prolog_sym(code_type, code_type, rel). -prolog_sym(compare, compare, rel). -prolog_sym(compound, compound, rel). -prolog_sym(conjunction, ',', rel). -prolog_sym(consult, consult, rel). -prolog_sym(copy_term, copy_term, rel). -prolog_sym(copy_term_nat, copy_term_nat, rel). -prolog_sym(cos, cos, func). -prolog_sym(cosh, cosh, func). -prolog_sym(cputime, cputime, func). -prolog_sym(create_mutable, create_mutable, rel). -prolog_sym(create_prolog_flag, create_prolog_flag, rel). -prolog_sym(current_atom, current_atom, rel). -prolog_sym(current_char_conversion, current_char_conversion, rel). -prolog_sym(current_input, current_input, rel). -prolog_sym(current_key, current_key, rel). -prolog_sym(current_module, current_module, rel). -prolog_sym(current_op, current_op, rel). -prolog_sym(current_output, current_output, rel). -prolog_sym(current_predicate, current_predicate, rel). -prolog_sym(current_prolog_flag, current_prolog_flag, rel). -prolog_sym(cut, !, rel). -prolog_sym(cyclic_term, cyclic_term, rel). -prolog_sym(date_time_stamp, date_time_stamp, rel). -prolog_sym(date_time_value, date_time_value, rel). -prolog_sym(day_of_the_week, day_of_the_week, rel). -prolog_sym(delete, delete, rel). -prolog_sym(dif, dif, rel). -prolog_sym(discontiguous, discontiguous, rel). -prolog_sym(disjunction, ;, rel). -prolog_sym(display, display, rel). -prolog_sym(div, div, func). -prolog_sym(duplicate_term, duplicate_term, rel). -prolog_sym(dynamic, dynamic, rel). -prolog_sym(e, e, func). -prolog_sym(ensure_loaded, ensure_loaded, rel). -prolog_sym(environ, environ, rel). -prolog_sym(epsilon, epsilon, func). -prolog_sym(erase, erase, rel). -prolog_sym(erf, erf, func). -prolog_sym(erfc, erfc, func). -prolog_sym(exception, exception, rel). -prolog_sym(exists, exists, rel). -prolog_sym(exp, exp, func). -prolog_sym(fail, fail, rel). -prolog_sym(false, false, rel). -prolog_sym(file_base_name, file_base_name, rel). -prolog_sym(file_name_extension, file_name_extension, rel). -prolog_sym(findall, findall, rel). -prolog_sym(flatten, flatten, rel). -prolog_sym(float, float, rel). -prolog_sym(float_fractional_part, float_fractional_part, func). -prolog_sym(float_function, float, func). -prolog_sym(float_integer_part, float_integer_part, func). -prolog_sym(floor, floor, func). -prolog_sym(flush_output, flush_output, rel). -prolog_sym(forall, forall, rel). -prolog_sym(format, format, rel). -prolog_sym(format_time, format_time, rel). -prolog_sym(freeze, freeze, rel). -prolog_sym(frozen, frozen, rel). -prolog_sym(functor, functor, rel). -prolog_sym(garbage_collect, garbage_collect, rel). -prolog_sym(garbage_collect_atoms, garbage_collect_atoms, rel). -prolog_sym(gc, gc, rel). -prolog_sym(gcd, gcd, func). -prolog_sym(get, get, rel). -prolog_sym(get_byte, get_byte, rel). -prolog_sym(get_char, get_char, rel). -prolog_sym(get_code, get_code, rel). -prolog_sym(get_mutable, get_mutable, rel). -prolog_sym(get_time, get_time, rel). -prolog_sym(get0, get0, rel). -prolog_sym(getcwd, getcwd, rel). -prolog_sym(ground, ground, rel). -prolog_sym(halt, halt, rel). -prolog_sym(if, soft_cut, rel). -prolog_sym(if_then, ->, rel). -prolog_sym(if_then_else, if_then_else, rel). -prolog_sym(ignore, ignore, rel). -prolog_sym(include, include, rel). -prolog_sym(initialization, initialization, rel). -prolog_sym(instance, instance, rel). -prolog_sym(integer, integer, rel). -prolog_sym(integer_conjunction, /\, func). -prolog_sym(integer_disjunction, \/, func). -prolog_sym(integer_exclusive_disjunction, xor, func). -prolog_sym(integer_function, integer, func). -prolog_sym(integer_left_logical_shift, <<, func). -prolog_sym(integer_negation, \, func). -prolog_sym(integer_power, ^, func). -prolog_sym(integer_quotient, //, func). -prolog_sym(integer_right_logical_shift, >>, func). -prolog_sym(is, is, rel). -prolog_sym(is_list, is_list, rel). -prolog_sym(is_stream, is_stream, rel). -prolog_sym(keysort, keysort, rel). -prolog_sym(last, last, rel). -prolog_sym(length, length, rel). -prolog_sym(lgamma, lgamma, func). -prolog_sym(line_count, line_count, rel). -prolog_sym(line_position, line_position, rel). -prolog_sym(listing, listing, rel). -prolog_sym(log, log, func). -prolog_sym(log10, log10, func). -prolog_sym(lsb, lsb, func). -prolog_sym(max, max, func). -prolog_sym(max_list, max_list, rel). -prolog_sym(member, member, rel). -prolog_sym(memberchk, memberchk, rel). -prolog_sym(message_to_string, message_to_string, rel). -prolog_sym(min, min, func). -prolog_sym(min_list, min_list, rel). -prolog_sym(minus, -, func). -prolog_sym(mod, mod, func). -prolog_sym(msb, msb, func). -prolog_sym(multifile, multifile, rel). -prolog_sym(name, name, rel). -prolog_sym(nb_current, nb_current, rel). -prolog_sym(nb_delete, nb_delete, rel). -prolog_sym(nb_getval, nb_getval, rel). -prolog_sym(nb_linkarg, nb_linkarg, rel). -prolog_sym(nb_linkval, nb_linkval, rel). -prolog_sym(nb_setarg, nb_setarg, rel). -prolog_sym(nb_setval, nb_setval, rel). -prolog_sym(nl, nl, rel). -prolog_sym(nonvar, nonvar, rel). -prolog_sym(not_provable, \+, rel). -prolog_sym(not_unifiable, \=, rel). -prolog_sym(nth, nth, rel). -prolog_sym(nth_clause, nth_clause, rel). -prolog_sym(nth0, nth0, rel). -prolog_sym(nth1, nth1, rel). -prolog_sym(number, number, rel). -prolog_sym(number_chars, number_chars, rel). -prolog_sym(number_codes, number_codes, rel). -prolog_sym(numbervars, numbervars, rel). -prolog_sym(numlist, numlist, rel). -prolog_sym(on_signal, on_signal, rel). -prolog_sym(once, once, rel). -prolog_sym(op, op, rel). -prolog_sym(open, open, rel). -prolog_sym(parse_time, parse_time, rel). -prolog_sym(peek_byte, peek_byte, rel). -prolog_sym(peek_char, peek_char, rel). -prolog_sym(peek_code, peek_code, rel). -prolog_sym(permutation, permutation, rel). -prolog_sym(pi, pi, func). -prolog_sym(plus, +, rel). -prolog_sym(plus_function, +, func). -prolog_sym(popcount, popcount, func). -prolog_sym(portray_clause, portray_clause, rel). -prolog_sym(power, **, func). -prolog_sym(predicate_property, predicate_property, rel). -prolog_sym(predsort, predsort, rel). -prolog_sym(print, print, rel). -prolog_sym(print_message, print_message, rel). -prolog_sym(print_message_lines, print_message_lines, rel). -prolog_sym(product, *, func). -prolog_sym(prolog_flag, prolog_flag, rel). -prolog_sym(prolog_load_context, prolog_load_context, rel). -prolog_sym(prompt, prompt, rel). -prolog_sym(put, put, rel). -prolog_sym(put_byte, put_byte, rel). -prolog_sym(put_char, put_char, rel). -prolog_sym(put_code, put_code, rel). -prolog_sym(quotient, /, func). -prolog_sym(random, random, func). -prolog_sym(random_float, random_float, func). -prolog_sym(rational, rational, rel). -prolog_sym(rational_function, rational, func). -prolog_sym(rationalize, rationalize, func). -prolog_sym(read, read, rel). -prolog_sym(read_term, read_term, rel). -prolog_sym(recorda, recorda, rel). -prolog_sym(recorded, recorded, rel). -prolog_sym(recordz, recordz, rel). -prolog_sym(rem, rem, func). -prolog_sym(rename_file, rename_file, rel). -prolog_sym(repeat, repeat, rel). -prolog_sym(retract, retract, rel). -prolog_sym(retractall, retractall, rel). -prolog_sym(reverse, reverse, rel). -prolog_sym(round, round, func). -prolog_sym(same_length, same_length, rel). -prolog_sym(see, see, rel). -prolog_sym(seeing, seeing, rel). -prolog_sym(seen, seen, rel). -prolog_sym(select, select, rel). -prolog_sym(selectchk, selectchk, rel). -prolog_sym(set_input, set_input, rel). -prolog_sym(set_output, set_output, rel). -prolog_sym(set_prolog_flag, set_prolog_flag, rel). -prolog_sym(set_stream_position, set_stream_position, rel). -prolog_sym(setarg, setarg, rel). -prolog_sym(setof, setof, rel). -prolog_sym(set_random, set_random, rel). -prolog_sym(shell, shell, rel). -prolog_sym(sign, sign, func). -prolog_sym(simple, simple, rel). -prolog_sym(sin, sin, func). -prolog_sym(sinh, sinh, func). -prolog_sym(skip, skip, rel). -prolog_sym(sort, sort, rel). -prolog_sym(source_file, source_file, rel). -prolog_sym(source_location, source_location, rel). -prolog_sym(sqrt, sqrt, func). -prolog_sym(stamp_date_time, stamp_date_time, rel). -prolog_sym(statistics, statistics, rel). -prolog_sym(stream_position, stream_position, rel). -prolog_sym(stream_position_data, stream_position_data, rel). -prolog_sym(stream_property, stream_property, rel). -prolog_sym(sub_atom, sub_atom, rel). -prolog_sym(sublist, sublist, rel). -prolog_sym(subsumes_term, subsumes_term, rel). -prolog_sym(succ, succ, rel). -prolog_sym(sum_list, sum_list, rel). -prolog_sym(tab, tab, rel). -prolog_sym(tan, tan, func). -prolog_sym(tanh, tanh, func). -prolog_sym(tell, tell, rel). -prolog_sym(telling, telling, rel). -prolog_sym(term_greater_than, @>, rel). -prolog_sym(term_greater_than_or_equal, @>=, rel). -prolog_sym(term_hash, term_index, rel). -prolog_sym(term_identical, ==, rel). -prolog_sym(term_less_than, @<, rel). -prolog_sym(term_less_than_or_equal, @=<, rel). -prolog_sym(term_not_identical, \==, rel). -prolog_sym(term_to_atom, term_to_atom, rel). -prolog_sym(term_variables, term_variables, rel). -prolog_sym(throw, throw, rel). -prolog_sym(time, time, rel). -prolog_sym(time_file, time_file, rel). -prolog_sym(told, told, rel). -prolog_sym(true, true, rel). -prolog_sym(truncate, truncate, func). -prolog_sym(unifiable, unifiable, rel). -prolog_sym(unify, =, rel). -prolog_sym(unify_with_occurs_check, unify_with_occurs_check, rel). -prolog_sym(univ, =.., rel). -prolog_sym(unknown, unknown, rel). -prolog_sym(update_mutable, update_mutable, rel). -prolog_sym(use_module, use_module, rel). -prolog_sym(var, var, rel). -prolog_sym(variant, variant, rel). -prolog_sym(version, version, rel). -prolog_sym(when, when, rel). -prolog_sym(with_output_to, with_output_to, rel). -prolog_sym(write, write, rel). -prolog_sym(write_canonical, write_canonical, rel). -prolog_sym(write_term, write_term, rel). -prolog_sym(writeln, writeln, rel). -prolog_sym(writeq, writeq, rel). - -% -% Support -% - -def_pfx('math:', ''). -def_pfx('e:', ''). -def_pfx('list:', ''). -def_pfx('xsd:', ''). -def_pfx('log:', ''). -def_pfx('r:', ''). -def_pfx('rdfs:', ''). -def_pfx('time:', ''). -def_pfx('rdf:', ''). -def_pfx('string:', ''). -def_pfx('owl:', ''). -def_pfx('n3:', ''). - -put_pfx(_, URI) :- - atomic_list_concat(['<', URI, '>'], U), - pfx(_, U), - !. -put_pfx(_, URI) :- - atomic_list_concat(['<', URI, '>'], U), - def_pfx(Pf, U), - \+pfx(Pf, _), - !, - assertz(pfx(Pf, U)). -put_pfx(Pf, URI) :- - atomic_list_concat(['<', URI, '>'], U), - fresh_pf(Pf, Pff), - assertz(pfx(Pff, U)). - -fresh_pf(Pf, Pfx) :- - atom_concat(Pf, ':', Pfx), - \+pfx(Pfx, _), - !. -fresh_pf(_, Pfx) :- - gensym(ns, Pfn), - fresh_pf(Pfn, Pfx). - -cnt(A) :- - nb_getval(A, B), - C is B+1, - nb_setval(A, C), - ( flag('debug-cnt'), - C mod 10000 =:= 0 - -> format(user_error, '~w = ~w~n', [A, C]), - flush_output(user_error) - ; true - ). - -cnt(A, I) :- - nb_getval(A, B), - C is B+I, - nb_setval(A, C), - ( flag('debug-cnt'), - C mod 10000 =:= 0 - -> format(user_error, '~w = ~w~n', [A, C]), - flush_output(user_error) - ; true - ). - -within_scope([A, B]) :- - ( var(B) - -> B = 1 - ; true - ), - ( B = 0 - -> brake - ; nb_getval(limit, C), - ( C < B - -> nb_setval(limit, B) - ; true - ), - span(B) - ), - nb_getval(scope, A). - -exopred(P, S, O) :- - ( var(P), - var(S), - var(O) - -> pred(P), - H =.. [P, S, O], - clause(H, true) - ; ( var(P) - -> pred(P) - ; atom(P), - current_predicate(P/2) - ), - call(P, S, O) - ). - -exogen :- - forall( - ( clause(exopred(P, S, O), Body), - ( nonvar(S) - ; nonvar(O) - ) - ), - ( ( var(P) - -> pred(P) - ; atom(P), - current_predicate(P/2) - ), - Head =.. [P, S, O], - ( \+clause(Head, Body) - -> assertz(Head :- Body) - ; true - ) - ) - ). -exogen :- - \+flag('multi-query'). - -ucall(A) :- - ( A = (B, C) - -> vcall(B), - ucall(C) - ; vcall(A) - ). - -vcall(A) :- - ( ( A =.. [_, V, W] - ; A = exopred(_, V, W) - ), - ( is_gl(V) - ; is_gl(W) - ) - -> unify(A, B) - ; B = A - ), - ( B =.. [C, D, E], - pred(C), - ( is_gl(D) - ; is_gl(E) - ) - -> G =.. [C, H, I], - call(G), - unify(H, D), - unify(I, E) - ; call(B) - ). - -is_gl(A) :- - nonvar(A), - \+is_list(A), - ( A = (_, _), - ! - ; A =.. [F, _, _], - F \= literal, - F \= rdiv, - ! - ; A = exopred(_, _, _) - ). - -unify(A, true) :- - \+flag('no-erase'), - nonvar(A), - A = ''(X, Y), - nonvar(Y), - labelvars(X, 0, _), - call(Y). -unify(A, B) :- - \+flag('no-erase'), - nonvar(A), - A = ''(X, Y), - conj_list(Y, C), - length(C, D), - D > 1, - ndsplit(C, E, F), - E \= [], - F \= [], - conj_list(G, F), - ( call(G) - -> conj_list(H, E), - B = ''(X, H) - ; ( G = ''(_, I) - -> call(I) - ; ''(_, G) - ), - B = true - ). -unify(A, B) :- - nonvar(A), - A = exopred(P, S, O), - ( ( nonvar(B) - ; nonvar(P) - ) - -> ( nonvar(P) - -> atom(P) - ; true - ), - B =.. [P, T, R], - atom(P), - unify(S, T), - unify(O, R) - ; B = exopred(P, T, R), - unify(S, T), - unify(O, R) - ), - !. -unify(A, B) :- - nonvar(B), - B = exopred(P, S, O), - ( ( nonvar(A) - ; nonvar(P) - ) - -> ( nonvar(P) - -> atom(P) - ; true - ), - A =.. [P, T, R], - atom(P), - unify(S, T), - unify(O, R) - ; A = exopred(P, T, R), - unify(S, T), - unify(O, R) - ), - !. -unify(A, B) :- - is_list(A), - !, - getlist(B, C), - C = A. -unify(A, B) :- - is_list(B), - !, - getlist(A, C), - C = B. -unify(A, B) :- - nonvar(A), - nonvar(B), - ( A = (_, _) - ; B = (_, _) - ), - !, - conj_list(A, C), - conj_list(B, D), - includes(C, D), - includes(D, C). -unify(A, B) :- - nonvar(A), - nonvar(B), - A =.. [P, S, O], - B =.. [P, T, R], - !, - unify(S, T), - unify(O, R). -unify(A, A). - -conj_list(true, []) :- - !. -conj_list(A, [A]) :- - A \= (_, _), - A \= false, - !. -conj_list((A, B), [A|C]) :- - conj_list(B, C). - -conj_append(A, true, A) :- - !. -conj_append((A, B), C, (A, D)) :- - conj_append(B, C, D), - !. -conj_append(A, B, (A, B)). - -cflat([], []). -cflat([A|B], C) :- - cflat(B, D), - copy_term_nat(A, E), - ( E = (_, _), - conj_list(E, F) - -> append(F, D, C) - ; ( E = true - -> C = D - ; C = [E|D] - ) - ). - -couple([], [], []). -couple([A|B], [C|D], [[A, C]|E]) :- - couple(B, D, E). - -includes(_, []) :- - !. -includes(X, [Y|Z]) :- - member(U, X), - unify(U, Y), - includes(X, Z). - -conjoin([X], X) :- - !. -conjoin([true|Y], Z) :- - conjoin(Y, Z), - !. -conjoin([X|Y], Z) :- - conjoin(Y, U), - conj_append(X, U, V), - ( ground(V) - -> conj_list(V, A), - sort(A, B), - conj_list(Z, B) - ; Z = V - ). - -difference([true, _], true) :- - !. -difference([X, true], X) :- - !. -difference([X, Y], Z) :- - conj_list(X, U), - conj_list(Y, V), - difference(U, V, W), - distinct(W, J), - conj_list(Z, J). - -difference([], _, []) :- - !. -difference([X|Y], U, V) :- - member(Z, U), - unify(X, Z), - !, - difference(Y, U, V). -difference([X|Y], U, [X|V]) :- - difference(Y, U, V). - -intersect([X], X) :- - !. -intersect([true|_], true) :- - !. -intersect([X|Y], Z) :- - intersect(Y, I), - conj_list(X, U), - conj_list(I, V), - intersect(U, V, W), - distinct(W, J), - conj_list(Z, J). - -intersect([], _, []) :- - !. -intersect([X|Y], U, V) :- - member(Z, U), - unify(X, Z), - V = [X|W], - intersect(Y, U, W). -intersect([_|Y], U, V) :- - intersect(Y, U, V). - -cartesian([], []). -cartesian([A|B], [C|D]) :- - member(C, A), - cartesian(B, D). - -distinct(A, B) :- - ( ground(A) - -> distinct_hash(A, B) - ; distinct_value(A, B) - ). - -distinct_hash([], []) :- - ( retract(hash_value(_, _)), - fail - ; true - ), - !. -distinct_hash([A|B], C) :- - term_index(A, D), - ( hash_value(D, E) - -> ( unify(A, E) - -> C = F - ; C = [A|F] - ) - ; assertz(hash_value(D, A)), - C = [A|F] - ), - distinct_hash(B, F). - -distinct_value([], []). -distinct_value([A|B], [A|D]) :- - nonvar(A), - !, - del(B, A, E), - distinct_value(E, D). -distinct_value([_|A], B) :- - distinct_value(A, B). - -del([], _, []). -del([A|B], C, D) :- - copy_term_nat(A, Ac), - copy_term_nat(C, Cc), - unify(Ac, Cc), - !, - del(B, C, D). -del([A|B], C, [A|D]) :- - del(B, C, D). - -subst(_, [], []). -subst(A, B, C) :- - member([D, E], A), - append(D, F, B), - !, - append(E, G, C), - subst(A, F, G). -subst(A, [B|C], [B|D]) :- - subst(A, C, D). - -replace([], [], X, X) :- - !. -replace([Search|SearchRest], [Replace|ReplaceRest], X, Y) :- - atomic_list_concat(['(', Search, ')'], Scap), - scrape(X, Scap, Scrape), - atom_codes(Replace, RC), - srlist(Scrape, RC, Subst), - atom_codes(X, XC), - subst(Subst, XC, ZC), - atom_codes(Z, ZC), - replace(SearchRest, ReplaceRest, Z, Y). - -scrape(X, Y, [V|Z]) :- - regex(Y, X, [W|_]), - !, - atom_string(V, W), - sub_atom(X, _, _, I, V), - sub_atom(X, _, I, 0, U), - scrape(U, Y, Z). -scrape(_, _, []). - -srlist([], _, []). -srlist([A|B], C, [[E,C]|D]) :- - string_codes(A, E), - srlist(B, C, D). - -quicksort([], []). -quicksort([A|B], C) :- - split(A, B, D, E), - quicksort(D, F), - quicksort(E, G), - append(F, [A|G], C). - -split(_, [], [], []). -split(A, [B|C], [B|D], E) :- - sort([A, B], [B, A]), - !, - split(A, C, D, E). -split(A, [B|C], D, [B|E]) :- - split(A, C, D, E). - -dsplit([], [], []). -dsplit([A|B], [A|C], D):- - dsplit(B, C, D). -dsplit([A|B], C, [A|D]):- - predicate_property(A, dynamic), - dsplit(B, C, D). - -ndsplit([], [], []). -ndsplit([A|B], [A|C], D):- - ndsplit(B, C, D). -ndsplit([A|B], C, [A|D]):- - ndsplit(B, C, D). - -last_tail([], []) :- - !. -last_tail([_|B], B) :- - \+is_list(B), - !. -last_tail([_|B], C) :- - last_tail(B, C). - -sub_list(A, A) :- - !. -sub_list([A|B], C) :- - sub_list(B, A, C). - -sub_list(A, _, A) :- - !. -sub_list([A|B], C, [C|D]) :- - !, - sub_list(B, A, D). -sub_list([A|B], _, C) :- - sub_list(B, A, C). - -e_transpose([], []). -e_transpose([A|B], C) :- - e_transpose(A, [A|B], C). - -e_transpose([], _, []). -e_transpose([_|A], B, [C|D]) :- - lists_fr(B, C, E), - e_transpose(A, E, D). - -lists_fr([], [], []). -lists_fr([[A|B]|C], [A|D], [B|E]) :- - lists_fr(C, D, E). - -sum([], 0) :- - !. -sum([A|B], C) :- - getnumber(A, X), - sum(B, D), - C is X+D. - -product([], 1) :- - !. -product([A|B], C) :- - getnumber(A, X), - product(B, D), - C is X*D. - -avg(A, B) :- - sum(A, As), - length(A, An), - B is As/An. - -cov([A, B], C) :- - avg(A, Am), - avg(B, Bm), - cov1(A, B, Am, Bm, Cp), - length(A, An), - C is Cp/(An-1). - -cov1([], [], _, _, 0). -cov1([A|B], [C|D], E, F, G) :- - cov1(B, D, E, F, H), - getnumber(A, I), - getnumber(C, J), - G is (I-E)*(J-F)+H. - -pcc([A, B], C) :- - avg(A, Am), - avg(B, Bm), - cov1(A, B, Am, Bm, Cp), - std1(A, Am, Ap), - std1(B, Bm, Bp), - C is Cp/sqrt(Ap*Bp). - -rms(A, B) :- - rms1(A, Ar), - length(A, An), - B is sqrt(Ar/An). - -rms1([], 0). -rms1([A|B], C) :- - rms1(B, D), - getnumber(A, E), - C is E^2+D. - -std(A, B) :- - avg(A, Am), - std1(A, Am, As), - length(A, An), - B is sqrt(As/(An-1)). - -std1([], _, 0). -std1([A|B], C, D) :- - std1(B, C, E), - getnumber(A, F), - D is (F-C)^2+E. - -bmax([A|B], C) :- - bmax(B, A, C). - -bmax([], A, A). -bmax([A|B], C, D) :- - getnumber(A, X), - getnumber(C, Y), - ( X > Y - -> bmax(B, A, D) - ; bmax(B, C, D) - ). - -bmin([A|B], C) :- - bmin(B, A, C). - -bmin([], A, A). -bmin([A|B], C, D) :- - getnumber(A, X), - getnumber(C, Y), - ( X < Y - -> bmin(B, A, D) - ; bmin(B, C, D) - ). - -inconsistent([''(A, '')|B]) :- - memberchk(''(A, ''), B), - !. -inconsistent([''(A, '')|B]) :- - memberchk(''(A, ''), B), - !. -inconsistent([_|B]) :- - inconsistent(B). - -inverse(''(A, ''), - ''(A, '')) :- - !. -inverse(''(A, ''), - ''(A, '')). - -bnet :- - ( ''([A|B], _), - sort(B, C), - findall(Y, - ( ''([A|X], Y), - sort(X, C) - ), - L - ), - sum(L, S), - length(L, N), - Z is S/N, - \+bcnd([A|B], _), - assertz(bcnd([A|B], Z)), - inverse(A, D), - \+bcnd([D|B], _), - E is 1-Z, - assertz(bcnd([D|B], E)), - fail - ; bcnd([''(A, _)|B], _), - ( \+bvar(A), - assertz(bvar(A)) - ; true - ), - member(''(C, _), B), - \+bref(C, A), - assertz(bref(C, A)), - \+bvar(C), - assertz(bvar(C)), - fail - ; true - ). - -bval(''). -bval(''). - -brel(''(A, _), ''(B, _)) :- - bref(A, B), - !. -brel(A, ''(B, _)) :- - bref(C, B), - brel(A, ''(C, _)). - -bpar([], []) :- - !. -bpar([''(A, _)|B], [A|C]) :- - bpar(B, C). - -bget(A, B, 1.0) :- - memberchk(A, B), - !. -bget(''(A, ''), B, 0.0) :- - memberchk(''(A, ''), B), - !. -bget(''(A, ''), B, C) :- - ( memberchk(''(A, ''), B), - !, - C is 0.0 - ; - !, - bget(''(A, ''), B, D), - C is 1-D - ). -bget(A, B, C) :- - ( bgot(A, B, C) - -> true - ; ( member(X, B), - brel(A, X), - member(G, B), - findall(_, - ( member(Z, [A|B]), - brel(G, Z) - ), - [] - ), - del(B, G, H), - !, - bget(G, [A|H], U), - bget(A, H, V), - bget(G, H, W), - ( W < 1e-15 - -> C is 0.5 - ; E is U*V/W, - bmin([E, 1.0], C) - ) - ; findall([Z, Y], - ( bcnd([A|O], P), - bcon(O, B, Q), - Z is P*Q, - bpar(O, Y) - ), - L - ), - findall(Z, - ( member([_, Z], L) - ), - N - ), - distinct(N, I), - findall(Z, - ( member(Y, I), - findall(P, - ( member([P, Y], L) - ), - Q - ), - sum(Q, R), - length(Q, S), - length(Y, T), - ( Q = [] - -> Z is 0.0 - ; D is 2**(T-ceiling(log(S)/log(2))), - ( D < 1 - -> Z is R*D - ; Z is R - ) - ) - ), - J - ), - ( J = [] - -> C is 0.0 - ; bmax(J, C) - ) - ), - assertz(bgot(A, B, C)) - ). - -bcon([], _, 1.0) :- - !. -bcon(_, B, 0.5) :- - inconsistent(B), - !. -bcon([A|B], C, D) :- - bget(A, C, E), - bcon(B, [A|C], F), - D is E*F. - -tmp_file(A) :- - ( current_prolog_flag(dialect, swi), - current_prolog_flag(windows, true), - current_prolog_flag(pid, B) - -> atomic_list_concat(['pl_eye_', B, '_'], C) - ; C = 'eye' - ), - tmp_file(C, A). - -exec(A, B) :- - shell(A, B), - ( B =:= 0 - -> true - ; throw(exec_error(A)) - ). - -getcwd(A) :- - working_directory(A, A). - -% -% Modified Base64 for XML identifiers -% - -base64xml(A, B) :- - base64(A, C), - atom_codes(C, D), - subst([[[0'+], [0'_]], [[0'/], [0':]], [[0'=], []]], D, E), - atom_codes(B, E). - -term_index(A, B) :- - term_hash(A, B). - -if_then_else(A, B, C) :- - ( catch(call(A), _, fail) - -> catch(call(B), _, fail) - ; catch(call(C), _, fail) - ). - -soft_cut(A, B, C) :- - ( catch(call(A), _, fail) - *-> catch(call(B), _, fail) - ; catch(call(C), _, fail) - ). - -inv(false, true). -inv(true, false). - -+(A, B, C) :- - plus(A, B, C). - -':-'(A, B) :- - ( var(A) - -> cpred(C), - A =.. [C, _, _] - ; true - ), - ( A = exopred(P, S, O) - -> Ax =.. [P, S, O] - ; Ax = A - ), - clause(Ax, D), - ( \+flag(nope), - ( D = when(H, I) - -> conj_append(J, istep(Src, _, _, _), I), - B = when(H, J) - ; conj_append(B, istep(Src, _, _, _), D) - ) - -> term_index(true, Pnd), - ( \+prfstep(':-'(Ax, B), true, Pnd, ':-'(Ax, B), _, forward, Src) - -> assertz(prfstep(':-'(Ax, B), true, Pnd, ':-'(Ax, B), _, forward, Src)) - ; true - ) - ; D = B - ). - -sub_atom_last(A, B, C, D, E) :- - sub_atom(A, B, C, D, E), - F is B+1, - sub_atom(A, F, _, 0, G), - ( sub_atom(G, _, C, _, E) - -> sub_atom_last(G, B, C, D, E) - ; true - ). - -lookup(A, B, C) :- - tabl(A, B, C), - !. -lookup(A, B, C) :- - var(A), - nb_getval(tabl, M), - N is M+1, - nb_setval(tabl, N), - atom_number(I, N), - atomic_list_concat([B, '_tabl_entry_', I], A), - assertz(tabl(A, B, C)). - -escape_string([], []) :- - !. -escape_string([0'\t|A], [0'\\, 0't|B]) :- - !, - escape_string(A, B). -escape_string([0'\b|A], [0'\\, 0'b|B]) :- - !, - escape_string(A, B). -escape_string([0'\n|A], [0'\\, 0'n|B]) :- - !, - escape_string(A, B). -escape_string([0'\r|A], [0'\\, 0'r|B]) :- - !, - escape_string(A, B). -escape_string([0'\f|A], [0'\\, 0'f|B]) :- - !, - escape_string(A, B). -escape_string([0'"|A], [0'\\, 0'"|B]) :- - !, - escape_string(A, B). -escape_string([0'\\|A], [0'\\, 0'\\|B]) :- - !, - escape_string(A, B). -escape_string([A|B], [A|C]) :- - escape_string(B, C). - -escape_squote([], []) :- - !. -escape_squote([0''|A], [0'\\, 0''|B]) :- - !, - escape_squote(A, B). -escape_squote([A|B], [A|C]) :- - escape_squote(B, C). - -escape_unicode([], []) :- - !. -escape_unicode([A, B|C], D) :- - 0xD800 =< A, - A =< 0xDBFF, - 0xDC00 =< B, - B =< 0xDFFF, - E is 0x10000+(A-0xD800)*0x400+(B-0xDC00), - ( 0x100000 =< E - -> with_output_to(codes(F), format('\\U00~16R', [E])) - ; with_output_to(codes(F), format('\\U000~16R', [E])) - ), - append(F, G, D), - !, - escape_unicode(C, G). -escape_unicode([A|B], [A|C]) :- - escape_unicode(B, C). - -esplit_string([], _, [], []) :- - !. -esplit_string([], _, A, [A]) :- - !. -esplit_string([A|B], C, [], D) :- - memberchk(A, C), - !, - esplit_string(B, C, [], D). -esplit_string([A|B], C, D, [D|E]) :- - memberchk(A, C), - !, - esplit_string(B, C, [], E). -esplit_string([A|B], C, D, E) :- - append(D, [A], F), - esplit_string(B, C, F, E). - -quant(A, some) :- - var(A), - !. -quant(''(_, _), allv) :- - !. -quant(':-'(_, _), allv) :- - !. -quant(answer('', _, _), allv) :- - !. -quant(answer(':-', _, _), allv) :- - !. -quant(answer('', _, _), allv) :- - !. -quant(_, some). - -labelvars(A, B, C) :- - quant(A, Q), - labelvars(A, B, C, Q). - -labelvars(A, B, C, D) :- - var(A), - !, - atom_number(E, B), - atomic_list_concat([D, E], A), % failing when A is an attributed variable - C is B+1. -labelvars(A, B, B, _) :- - atomic(A), - !. -labelvars(''(A, B), C, C, D) :- - D \= avar, - nonvar(A), - nonvar(B), - !. -labelvars((A, B), C, D, Q) :- - !, - labelvars(A, C, E, Q), - labelvars(B, E, D, Q). -labelvars([A|B], C, D, Q) :- - !, - labelvars(A, C, E, Q), - labelvars(B, E, D, Q). -labelvars(A, B, C, Q) :- - nonvar(A), - functor(A, _, D), - labelvars(0, D, A, B, C, Q). - -labelvars(A, A, _, B, B, _) :- - !. -labelvars(A, B, C, D, E, Q) :- - F is A+1, - arg(F, C, G), - labelvars(G, D, H, Q), - labelvars(F, B, C, H, E, Q). - -relabel(A, A) :- - var(A), - !, - nb_getval(wn, W), - labelvars(A, W, N, allv), - nb_setval(wn, N). -relabel([], []) :- - !. -relabel([A|B], [C|D]) :- - !, - relabel(A, C), - relabel(B, D). -relabel(A, B) :- - atom(A), - !, - ( ''(A, B) - -> labelvars(B, 0, _) - ; B = A - ). -relabel(A, A) :- - number(A), - !. -relabel(A, B) :- - A =.. [C|D], - relabel(C, E), - relabel(D, F), - B =.. [E|F]. - -dynify(A) :- - var(A), - !. -dynify((A, B)) :- - !, - dynify(A), - dynify(B). -dynify(implies(A, B, _)) :- - !, - dynify(A), - dynify(B). -dynify(':-'(A, B)) :- - !, - dynify(A), - dynify(B). -dynify(answer(A, _, _)) :- - nonvar(A), - !, - ( current_predicate(A/2) - -> true - ; dynamic(A/2) - ). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(A) :- - functor(A, F, N), - ( current_predicate(F/N) - -> true - ; dynamic(F/N) - ). - -conjify((A, B), (C, D)) :- - !, - conjify(A, C), - conjify(B, D). -conjify(''([literal(when, type('')), - ''([literal(A, type(''))|B], true), C], true), when(D, C)) :- - !, - D =.. [A|B]. -conjify(''([], true), !) :- - !. -conjify(''([literal(!, type(''))], true), !) :- - !. -conjify(A, A). - -atomify(A, A) :- - var(A), - !. -atomify([A|B], [C|D]) :- - !, - atomify(A, C), - atomify(B, D). -atomify(literal(A, type('')), A) :- - atom(A), - !. -atomify(A, A). - -commonvars(''(A, _), B, C) :- - !, - commonvars(A, B, C). -commonvars(A, B, C) :- - term_variables(A, D), - term_variables(B, E), - copy_term_nat([D, E], [F, G]), - labelvars([F, G], 0, _), - findall(H, - ( member(H, F), - member(H, G) - ), - C - ). - -getvars(A, B) :- - findvars(A, C, alpha), - distinct(C, B). - -makevars(A, B, beta(C)) :- - !, - distinct(C, D), - length(D, E), - length(F, E), - makevars(A, B, D, F). -makevars(A, B, Z) :- - findvars(A, C, Z), - distinct(C, D), - length(D, E), - length(F, E), - makevars(A, B, D, F). - -makevars(A, B, C, D) :- - atomic(A), - !, - ( atom(A), - nth0(E, C, A) - -> nth0(E, D, B) - ; B = A - ). -makevars(A, A, _, _) :- - var(A), - !. -makevars([], [], _, _) :- - !. -makevars([A|B], [C|D], E, F) :- - makevars(A, C, E, F), - makevars(B, D, E, F), - !. -makevars(A, B, E, F) :- - A =.. C, - makevars(C, D, E, F), - B =.. D. - -findvars(A, B, Z) :- - atomic(A), - !, - ( atom(A), - findvar(A, Z) - -> B = [A] - ; B = [] - ). -findvars(A, [], _) :- - var(A), - !. -findvars([], [], _) :- - !. -findvars([A|B], C, Z) :- - findvars(A, D, Z), - findvars(B, E, Z), - append(D, E, C), - !. -findvars(A, B, Z) :- - A =.. C, - findvars(C, B, Z). - -shallowvars(A, B, Z) :- - atomic(A), - !, - ( atom(A), - findvar(A, Z) - -> B = [A] - ; B = [] - ). -shallowvars(A, [], _) :- - var(A), - !. -shallowvars([], [], _) :- - !. -shallowvars([A|B], C, Z) :- - shallowvars(A, D, Z), - shallowvars(B, E, Z), - append(D, E, C), - !. -shallowvars(_, [], _). - -findvar(A, alpha) :- - !, - atom_concat('') :- - is_list(A), - !. -raw_type(A, '') :- - number(A), - !. -raw_type(A, '') :- - atom(A), - \+ sub_atom(A, 0, _, _, some), - \+ sub_atom(A, 0, _, _, avar), - \+ (sub_atom(A, 0, 1, _, '<'), sub_atom(A, _, 1, 0, '>')), - !. -raw_type(literal(_, _), '') :- - !. -raw_type(rdiv(_, _), '') :- - !. -raw_type('', '') :- - !. -raw_type((_, _), '') :- - !. -raw_type(set(_), '') :- - !. -raw_type(A, '') :- - functor(A, B, C), - B \= ':', - C >= 2, - !. -raw_type(_, ''). - -getnumber(rdiv(A, B), C) :- - nonvar(A), - !, - C is A/B. -getnumber(A, A) :- - number(A), - !. -getnumber(A, epsilon) :- - nonvar(A), - A = '', - !. -getnumber(A, A) :- - nonvar(A), - memberchk(A, [inf, -inf, nan]), - !. -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - datetime(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - date(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - time(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - duration(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - yearmonthduration(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - daytimeduration(B, C, []). -getnumber(literal(A, _), B) :- - ground(A), - atom_codes(A, C), - numeral(C, D), - catch(number_codes(B, D), _, fail). - -getint(A, B) :- - getnumber(A, C), - B is integer(round(C)). - -getbool(literal(false, type('')), false). -getbool(literal(true, type('')), true). -getbool(literal('0', type('')), false). -getbool(literal('1', type('')), true). -getbool(false, false). -getbool(true, true). - -getlist(A, A) :- - var(A), - !. -getlist(set(A), A) :- - !. -getlist('', []) :- - !. -getlist([], []) :- - !. -getlist([A|B], [C|D]) :- - getlist(A, C), - !, - getlist(B, D). -getlist([A|B], [A|D]) :- - !, - getlist(B, D). -getlist(A, [B|C]) :- - ''(A, B), - ''(A, D), - getlist(D, C). - -getstring(A, B) :- - ''(A, B), - !. -getstring(A, A). - -getcodes(literal(A, _), B) :- - nonvar(A), - !, - atom_codes(A, B). -getcodes(A, B) :- - nonvar(A), - with_output_to_chars(wg(A), B). - -preformat([], []) :- - !. -preformat([literal(A, type(''))|B], [A|D]) :- - !, - preformat(B, D). -preformat([A|B], [A|D]) :- - preformat(B, D). - -numeral([0'-, 0'.|A], [0'-, 0'0, 0'.|A]) :- - !. -numeral([0'+, 0'.|A], [0'+, 0'0, 0'.|A]) :- - !. -numeral([0'.|A], [0'0, 0'.|A]) :- - !. -numeral(A, B) :- - append([C, [0'., 0'e], D], A), - append([C, [0'., 0'0, 0'e], D], B), - !. -numeral(A, B) :- - append([C, [0'., 0'E], D], A), - append([C, [0'., 0'0, 0'E], D], B), - !. -numeral(A, B) :- - last(A, 0'.), - append(A, [0'0], B), - !. -numeral(A, A). - -rdiv_codes(rdiv(A, B), C) :- - append(D, [0'.|E], C), - append(D, E, F), - number_codes(A, F), - lzero(E, G), - number_codes(B, [0'1|G]), - !. -rdiv_codes(rdiv(A, 1), C) :- - number_codes(A, C). - -lzero([], []) :- - !. -lzero([_|A], [0'0|B]) :- - lzero(A, B). - -dtlit([literal(A, type('')), C], B) :- - nonvar(C), - ''(C, ''), - integer(B), - !, - atom_number(A, B). -dtlit([literal(A, type('')), ''], B) :- - integer(B), - !, - atom_number(A, B). -dtlit([literal(A, type('')), ''], B) :- - float(B), - !, - atom_number(A, B). -dtlit([literal(A, type('')), ''], B) :- - ( number(B) - -> datetime(B, C) - ; nonvar(B), - B = date(Year, Month, Day, Hour, Minute, Second, Offset, _, _), - datetime(Year, Month, Day, Hour, Minute, Second, Offset, C) - ), - !, - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - ( number(B) - -> date(B, C) - ; nonvar(B), - B = date(Year, Month, Day, _, _, _, Offset, _, _), - date(Year, Month, Day, Offset, C) - ), - !, - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - ( number(B) - -> time(B, C) - ; nonvar(B), - B = date(_, _, _, Hour, Minute, Second, Offset, _, _), - time(Hour, Minute, Second, Offset, C) - ), - !, - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - number(B), - !, - daytimeduration(B, C), - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - number(B), - !, - yearmonthduration(B, C), - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - number(B), - !, - daytimeduration(B, C), - atom_codes(A, C). -dtlit([literal(A, type('')), ''], A) :- - atomic(A), - getbool(A, A), - !. -dtlit([literal(A, type('')), prolog:atom], A) :- - atomic(A), - \+ (sub_atom(A, 0, 1, _, '<'), sub_atom(A, _, 1, 0, '>')), - !. -dtlit([literal(A, type('')), ''], literal(A, lang(_))) :- - !. -dtlit([literal(A, type('')), B], literal(A, type(B))). - -hash_to_ascii([], L1, L1). -hash_to_ascii([A|B], [C, D|L3], L4) :- - E is A>>4 /\ 15, - F is A /\ 15, - code_type(C, xdigit(E)), - code_type(D, xdigit(F)), - hash_to_ascii(B, L3, L4). - -memotime(datime(A, B, C, D, E, F), G) :- - ( mtime(datime(A, B, C, D, E, F), G) - -> true - ; catch(date_time_stamp(date(A, B, C, D, E, F, 0, -, -), H), _, fail), - fmsec(F, H, G), - assertz(mtime(datime(A, B, C, D, E, F), G)) - ). - -datetime(A, L1, L13) :- - int(B, L1, [0'-|L3]), - int(C, L3, [0'-|L5]), - int(D, L5, [0'T|L7]), - int(E, L7, [0':|L9]), - int(F, L9, [0':|L11]), - decimal(G, L11, L12), - timezone(H, L12, L13), - I is -H, - catch(date_time_stamp(date(B, C, D, E, F, G, I, -, -), J), _, fail), - fmsec(G, J, A). - -datetime(A, B, C, D, E, F, G, L1, L13) :- - int(A, L1, [0'-|L3]), - int(B, L3, [0'-|L5]), - int(C, L5, [0'T|L7]), - int(D, L7, [0':|L9]), - int(E, L9, [0':|L11]), - decimal(F, L11, L12), - timezone(G, L12, L13). - -date(A, L1, L7) :- - int(B, L1, [0'-|L3]), - int(C, L3, [0'-|L5]), - int(D, L5, L6), - timezone(H, L6, L7), - I is -H, - catch(date_time_stamp(date(B, C, D, 0, 0, 0, I, -, -), E), _, fail), - fmsec(0, E, A). - -date(A, B, C, D, L1, L7) :- - int(A, L1, [0'-|L3]), - int(B, L3, [0'-|L5]), - int(C, L5, L6), - timezone(D, L6, L7). - -time(A, L1, L7) :- - int(B, L1, [0':|L3]), - int(C, L3, [0':|L5]), - decimal(D, L5, L6), - timezone(E, L6, L7), - ( B = 24 - -> A is C*60+D-E - ; A is B*3600+C*60+D-E - ). - -time(A, B, C, D, L1, L7) :- - int(A, L1, [0':|L3]), - int(B, L3, [0':|L5]), - decimal(C, L5, L6), - timezone(D, L6, L7). - -duration(A, L1, L7) :- - dsign(B, L1, [0'P|L3]), - years(C, L3, L4), - months(D, L4, L5), - days(E, L5, L6), - dtime(F, L6, L7), - A is B*(C*31556952+D*2629746+E*86400.0+F). - -yearmonthduration(A, L1, L5) :- - dsign(B, L1, [0'P|L3]), - years(C, L3, L4), - months(D, L4, L5), - A is B*(C*12+D). - -daytimeduration(A, L1, L5) :- - dsign(B, L1, [0'P|L3]), - days(C, L3, L4), - dtime(D, L4, L5), - A is B*(C*86400.0+D). - -timezone(A, L1, L4) :- - int(B, L1, [0':|L3]), - !, - int(C, L3, L4), - A is B*3600+C*60. -timezone(0, [0'Z|L2], L2) :- - !. -timezone(0, L1, L1). - -dsign(1, [0'+|L2], L2). -dsign(-1, [0'-|L2], L2). -dsign(1, L1, L1). - -dtime(A, [0'T|L2], L5) :- - !, - hours(B, L2, L3), - minutes(C, L3, L4), - seconds(D, L4, L5), - A is B*3600+C*60+D. -dtime(0, L1, L1). - -years(A, L1, L3) :- - int(A, L1, [0'Y|L3]). -years(0, L1, L1). - -months(A, L1, L3) :- - int(A, L1, [0'M|L3]). -months(0, L1, L1) . - -days(A, L1, L3) :- - int(A, L1, [0'D|L3]). -days(0, L1, L1). - -hours(A, L1, L3) :- - int(A, L1, [0'H|L3]). -hours(0, L1, L1). - -minutes(A, L1, L3) :- - int(A, L1, [0'M|L3]). -minutes(0, L1, L1). - -seconds(A, L1, L3) :- - decimal(A, L1, [0'S|L3]). -seconds(0, L1, L1). - -int(A, L1, L4) :- - sgn(B, L1, L2), - digit(C, L2, L3), - digits(D, L3, L4), - number_codes(A, [B, C|D]). - -decimal(A, L1, L5) :- - sgn(B, L1, L2), - digit(C, L2, L3), - digits(D, L3, L4), - fraction(E, L4, L5), - append([B, C|D], E, F), - number_codes(A, F). - -sgn(0'+, [0'+|L2], L2). -sgn(0'-, [0'-|L2], L2). -sgn(0'+, L1, L1). - -fraction([0'., A|B], [0'.|L2], L4) :- - !, - digit(A, L2, L3), - digits(B, L3, L4). -fraction([], L1, L1). - -digits([A|B], L1, L3) :- - digit(A, L1, L2), - digits(B, L2, L3). -digits([], L1, L1). - -digit(A, [A|L2], L2) :- - code_type(A, digit). - -fmsec(A, B, C) :- - integer(A), - !, - C is floor(B). -fmsec(_, B, B). - -datetime(A, B) :- - stamp_date_time(A, date(Year, Month, Day, Hour, Minute, Second, _, _, _), 0), - fmsec(A, Second, Sec), - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Sec, H), - append([C, [0'-], D, [0'-], E, [0'T], F, [0':], G, [0':], H, [0'Z]], B). - -datetime(Year, Month, Day, Hour, Minute, Second, Offset, B) :- - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Second, H), - ( Offset =:= 0 - -> append([C, [0'-], D, [0'-], E, [0'T], F, [0':], G, [0':], H, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([C, [0'-], D, [0'-], E, [0'T], F, [0':], G, [0':], H, I, J, [0':], K], B) - ). - -date(A, B) :- - N is A+3600*12, - stamp_date_time(N, date(Year, Month, Day, _, _, _, _, _, _), 0), - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - Offset is (round(floor(N)) mod 86400) - 3600*12, - ( Offset =:= 0 - -> append([C, [0'-], D, [0'-], E, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([C, [0'-], D, [0'-], E, I, J, [0':], K], B) - ). - -date(Year, Month, Day, Offset, B) :- - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - ( Offset =:= 0 - -> append([C, [0'-], D, [0'-], E, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([C, [0'-], D, [0'-], E, I, J, [0':], K], B) - ). - -time(A, B) :- - stamp_date_time(A, date(_, _, _, Hour, Minute, Second, _, _, _), 0), - fmsec(A, Second, Sec), - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Sec, H), - append([F, [0':], G, [0':], H, [0'Z]], B). - -time(Hour, Minute, Second, Offset, B) :- - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Second, H), - ( Offset =:= 0 - -> append([F, [0':], G, [0':], H, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([F, [0':], G, [0':], H, I, J, [0':], K], B) - ). - -yearmonthduration(A, B) :- - ( A < 0 - -> C = [0'-] - ; C = [] - ), - D is abs(A), - E is D//12, - number_codes(E, Years), - F is D-(D//12)*12, - number_codes(F, Months), - append([C, [0'P], Years, [0'Y], Months, [0'M]], B). - -daytimeduration(A, B) :- - AInt is round(floor(A)), - AFrac is A-AInt, - ( AInt < 0 - -> C = [0'-] - ; C = [] - ), - D is abs(AInt), - E is D//86400, - number_codes(E, Days), - F is (D-(D//86400)*86400)//3600, - number_codes(F, Hours), - G is (D-(D//3600)*3600)//60, - number_codes(G, Minutes), - H is D-(D//60)*60+AFrac, - number_codes(H, Seconds), - append([C, [0'P| Days], [0'D, 0'T| Hours], [0'H| Minutes], [0'M| Seconds], [0'S]], B). - -ncodes(A, B) :- - number_codes(A, D), - ( A < 10 - -> B = [0'0| D] - ; B = D - ). - -ycodes(A, B) :- - C is abs(A), - number_codes(C, D), - ( C < 10 - -> E = [0'0, 0'0, 0'0| D] - ; ( C < 100 - -> E = [0'0, 0'0| D] - ; ( C < 1000 - -> E = [0'0| D] - ; E = D - ) - ) - ), - ( A >= 0 - -> B = E - ; B = [0'-|E] - ). - -absolute_uri('-', '-') :- - !. -absolute_uri(A, B) :- - ( is_absolute_url(A) - -> B = A - ; absolute_file_name(A, C), - prolog_to_os_filename(D, C), - atom_codes(D, E), - subst([[[0x20], [0'%, 0'2, 0'0]]], E, F), - atom_codes(G, F), - ( current_prolog_flag(windows, true) - -> atomic_list_concat(['file:///', G], B) - ; atomic_list_concat(['file://', G], B) - ) - ). - -resolve_uri(A, _, A) :- - sub_atom(A, _, 1, _, ':'), - !. -resolve_uri('', A, A) :- - !. -resolve_uri('#', A, B) :- - !, - atomic_list_concat([A, '#'], B). -resolve_uri(A, B, A) :- - \+sub_atom(B, _, 1, _, ':'), - !. -resolve_uri(A, B, C) :- - so_uri(U), - atom_length(U, V), - sub_atom(A, 0, 1, _, '#'), - sub_atom(B, 0, V, _, U), - !, - atomic_list_concat([B, A], C). -resolve_uri(A, B, C) :- - sub_atom(A, 0, 2, _, './'), - !, - sub_atom(A, 2, _, 0, R), - resolve_uri(R, B, C). -resolve_uri(A, B, C) :- - sub_atom(A, 0, 3, _, '../'), - !, - sub_atom(A, 3, _, 0, R), - so_uri(U), - atom_length(U, V), - sub_atom(B, 0, V, D, U), - sub_atom(B, V, D, _, E), - ( sub_atom(E, F, 1, G, '/'), - sub_atom(E, _, G, 0, H), - \+sub_atom(H, _, _, _, '/'), - K is V+F - -> sub_atom(B, 0, K, _, S) - ; S = B - ), - resolve_uri(R, S, C). -resolve_uri(A, B, C) :- - so_uri(U), - atom_length(U, V), - sub_atom(A, 0, 1, _, '/'), - sub_atom(B, 0, V, D, U), - sub_atom(B, V, D, _, E), - ( sub_atom(E, F, 1, _, '/') - -> sub_atom(E, 0, F, _, G) - ; G = E - ), - !, - atomic_list_concat([U, G, A], C). -resolve_uri(A, B, C) :- - so_uri(U), - atom_length(U, V), - sub_atom(B, 0, V, D, U), - sub_atom(B, V, D, _, E), - ( sub_atom(E, F, 1, G, '/'), - sub_atom(E, _, G, 0, H), - \+sub_atom(H, _, _, _, '/') - -> sub_atom(E, 0, F, _, I) - ; I = E - ), - !, - atomic_list_concat([U, I, '/', A], C). -resolve_uri(A, _, _) :- - nb_getval(line_number, Ln), - throw(unresolvable_relative_uri(A, after_line(Ln))). - -so_uri('http://'). -so_uri('https://'). -so_uri('ftp://'). -so_uri('file://'). - -wcacher(A, B) :- - wcache(A, B), - !. -wcacher(A, B) :- - wcache(C, D), - sub_atom(A, 0, I, _, C), - sub_atom(A, I, _, 0, E), - atomic_list_concat([D, E], B). - -prolog_verb(S, Name) :- - ( atom(S), - atom_concat('\'\'', A) - -> ( B = conjunction - -> Pred = '\', \'' - ; ( B = disjunction - -> Pred = '\';\'' - ; ( prolog_sym(B, Pred, _) - -> true - ; nb_getval(line_number, Ln), - throw(invalid_prolog_builtin(B, after_line(Ln))) - ) - ) - ), - Name = prolog:Pred - ; Name = S - ). - -timestamp(Stamp) :- - get_time(StampN), - datetime(StampN, StampC), - atom_codes(StampA, StampC), - ( sub_atom(StampA, I, 1, 0, 'Z'), - I > 23 - -> sub_atom(StampA, 0, 23, _, StampB), - atomic_list_concat([StampB, 'Z'], Stamp) - ; Stamp = StampA - ). - -% -% Regular expressions -% - -% Regular Expressions inspired by http://www.cs.sfu.ca/~cameron/Teaching/384/99-3/regexp-plg.html -regex(RE_esc_atom, Input_esc_atom, Output_esc_atoms) :- - atom_codes(RE_esc_atom, RE_esc), - atom_codes(Input_esc_atom, Input_esc), - escape_string(RE, RE_esc), - re(Parsed_RE, RE, []), - ( RE = [0'^|_] - -> Bos = true - ; Bos = false - ), - escape_string(Input, Input_esc), - tokenize2(Parsed_RE, Input, Outputs, Bos), - findall(Output_esc_atom, - ( member(Output, Outputs), - escape_string(Output, Output_esc), - atom_codes(Output_esc_atom, Output_esc) - ), - Output_esc_atoms - ), - !. - -tokenize2(_P_RE, [], [], true). -tokenize2(P_RE, Input, Output, Bos) :- - ( rematch1(P_RE, Input, _, Output) - -> true - ; Bos = false, - Input = [_|Inp], - tokenize2(P_RE, Inp, Output, Bos) - ). - -rematch1(union(RE1, _RE2), S, U, Selected) :- - rematch1(RE1, S, U, Selected). -rematch1(union(_RE1, RE2), S, U, Selected) :- - rematch1(RE2, S, U, Selected). -rematch1(conc(RE1, RE2), S, U, Selected) :- - rematch1(RE1, S, U1, Sel1), - rematch1(RE2, U1, U, Sel2), - append(Sel1, Sel2, Selected). -rematch1(star(RE), S, U, Selected) :- - rematch1(RE, S, U1, Sel1), - rematch1(star(RE), U1, U, Sel2), - append(Sel1, Sel2, Selected). -rematch1(star(_RE), S, S, []). -rematch1(qm(RE), S, U, Selected) :- - rematch1(RE, S, U, Selected). -rematch1(qm(_RE), S, S, []). -rematch1(plus(RE), S, U, Selected) :- - rematch1(RE, S, U1, Sel1), - rematch1(star(RE), U1, U, Sel2), - append(Sel1, Sel2, Selected). -rematch1(group(RE), S, U, Selected) :- - rematch1(RE, S, U, Sel1), - append(P, U, S), - append(Sel1, [P], Selected). -rematch1(any, [_C1|U], U, []). -rematch1(char(C), [C|U], U, []). -rematch1(bos, S, S, []). -rematch1(eos, [], [], []). -rematch1(negSet(Set), [C|U], U, []) :- - \+charSetMember(C, Set). -rematch1(posSet(Set), [C|U], U, []) :- - charSetMember(C, Set). - -charSetMember(C, [char(C)|_]). -charSetMember(C, [range(C1, C2)|_]) :- - C1 =< C, - C =< C2. -charSetMember(C, [negSet(Set)|_]) :- - \+charSetMember(C, Set). -charSetMember(C, [posSet(Set)|_]) :- - charSetMember(C, Set). -charSetMember(C, [_|T]) :- - charSetMember(C, T). - -re(Z, L1, L3) :- - basicRE(W, L1, L2), - reTail(W, Z, L2, L3). - -reTail(W, Z, [0'||L2], L4) :- - basicRE(X, L2, L3), - reTail(union(W, X), Z, L3, L4). -reTail(W, W, L1, L1). - -basicRE(Z, L1, L3) :- - simpleRE(W, L1, L2), - basicREtail(W, Z, L2, L3). - -basicREtail(W, Z, L1, L3) :- - simpleRE(X, L1, L2), - basicREtail(conc(W, X), Z, L2, L3). -basicREtail(W, W, L1, L1). - -simpleRE(Z, L1, L3) :- - elementalRE(W, L1, L2), - simpleREtail(W, Z, L2, L3). - -simpleREtail(W, star(W), [0'*|L2], L2). -simpleREtail(W, qm(W), [0'?|L2], L2). -simpleREtail(W, plus(W), [0'+|L2], L2). -simpleREtail(W, W, L1, L1). - -elementalRE(any, [0'.|L2], L2). -elementalRE(group(X), [0'(|L2], L4) :- - re(X, L2, [0')|L4]). -elementalRE(bos, [0'^|L2], L2). -elementalRE(eos, [0'$|L2], L2). -elementalRE(posSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'w|L2], L2). -elementalRE(negSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'W|L2], L2). -elementalRE(posSet([range(0'0, 0'9)]), [0'\\, 0'd|L2], L2). -elementalRE(negSet([range(0'0, 0'9)]), [0'\\, 0'D|L2], L2). -elementalRE(posSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0's|L2], L2). -elementalRE(negSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0'S|L2], L2). -elementalRE(char(C), [0'\\, C|L2], L2) :- - re_metachar([C]). -elementalRE(char(C), [C|L2], L2) :- - \+re_metachar([C]). -elementalRE(negSet(X), [0'[, 0'^|L2], L4) :- - !, - setItems(X, L2, [0']|L4]). -elementalRE(posSet(X), [0'[|L2], L4) :- - setItems(X, L2, [0']|L4]). - -re_metachar([0'\\]). -re_metachar([0'|]). -re_metachar([0'*]). -re_metachar([0'?]). -re_metachar([0'+]). -re_metachar([0'.]). -re_metachar([0'[]). -re_metachar([0'$]). -re_metachar([0'(]). -re_metachar([0')]). - -setItems([Item1|MoreItems], L1, L3) :- - setItem(Item1, L1, L2), - setItems(MoreItems, L2, L3). -setItems([Item1], L1, L2) :- - setItem(Item1, L1, L2). - -setItem(posSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'w|L2], L2). -setItem(negSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'W|L2], L2). -setItem(posSet([range(0'0, 0'9)]), [0'\\, 0'd|L2], L2). -setItem(negSet([range(0'0, 0'9)]), [0'\\, 0'D|L2], L2). -setItem(posSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0's|L2], L2). -setItem(negSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0'S|L2], L2). -setItem(char(C), [0'\\, C|L2], L2) :- - set_metachar([C]). -setItem(char(C), [C|L2], L2) :- - \+set_metachar([C]). -setItem(range(A, B), L1, L4) :- - setItem(char(A), L1, [0'-|L3]), - setItem(char(B), L3, L4). - -set_metachar([0'\\]). -set_metachar([0']]). -set_metachar([0'-]). - -regexp_wildcard([], []) :- - !. -regexp_wildcard([0'*|A], [0'., 0'*|B]) :- - !, - regexp_wildcard(A, B). -regexp_wildcard([A|B], [A|C]) :- - regexp_wildcard(B, C). - -fm(A) :- - format(user_error, '~n*** ~q~n', [A]), - flush_output(user_error). - -mf(A) :- - forall( - catch(A, _, fail), - format(user_error, '~n*** ~q~n', [A]) - ), - flush_output(user_error). diff --git a/lib/eyebrow/eyebrow.js b/lib/eyebrow/eyebrow.js deleted file mode 100644 index 9627dda..0000000 --- a/lib/eyebrow/eyebrow.js +++ /dev/null @@ -1,74 +0,0 @@ -import { Output } from './output.js'; -import { SWIPL } from '/n3/lib/eyebrow/swipl-web-module.js'; - -const output = new Output(); - -var Module = { - noInitialRun: true, - arguments: [], - locateFile: function (file) { - return './' + file; - }, - preRun: [() => { - Module.FS.init(undefined, (c) => output.write("stdout", c), (c) => output.write("stderr", c)) - }] -}; - -function exec(query) { - Module.prolog.call(query); - - return output.flushAll(); -} - -function derivations(file) { - return exec(`main(['--n3', '${file}', '--nope', '--pass-only-new']).`); -} - -function deduc_closure(file) { - return exec(`main(['--n3', '${file}', '--nope', '--pass-all']).`); -} - -async function retrieve(link, file) { - const response = await fetch(link); - await Module.FS.writeFile(file, await response.text()); -} - -// initialize -var start = performance.now(); - -const module = await SWIPL(Module); -module.prolog.call("set_prolog_flag(tty_control, true)"); -module.prolog.call("set_prolog_flag(debug_on_error, false)"); - -var end = performance.now(); -console.log("[eyebrow] loading SWIPL:", (end - start)); - -start = performance.now(); - -await retrieve('/n3/lib/eyebrow/eye.pl', 'eye.pl'); -var msg = await exec("consult('./eye.pl')"); - -end = performance.now(); -console.log("[eyebrow] loading eye.pl:", (end - start)); - -if (msg.error) - console.error("eyebrow", msg.error); - -const _exec = async function (options, input, callback) { - // await retrieve(file, 'input.n3'); - Module.FS.writeFile('input.n3', input); - switch (options.task) { - - case 'derivations': - msg = await derivations('./input.n3'); - break; - - case 'deductive_closure': - msg = await deduc_closure('./input.n3'); - break; - } - - callback(msg); -}; - -export { _exec as eyebrow }; \ No newline at end of file diff --git a/lib/eyebrow/output.js b/lib/eyebrow/output.js deleted file mode 100644 index 316b369..0000000 --- a/lib/eyebrow/output.js +++ /dev/null @@ -1,54 +0,0 @@ -class _Output { - - constructor() { - this.buffers = { - stdout: [], - stderr: [] - }; - - this.output = document.getElementById('output'); - } - - write(to, c) { - if (c) - this.buffers[to].push(c); - - // console.log(c); - // if (c == 10 || c == null) - // this.flush(to); - } - - flushAll() { - return new Promise((resolve, reject) => { - let stderr = this.flush("stderr"); - if (stderr) { - if (stderr.includes("**")) { - let dl = stderr.lastIndexOf("**") + 2 - let error = stderr.substring(dl).trim() - - // console.log("error:", error) - resolve({ error: error }); - return; - } - } - - let output = this.flush("stdout"); - // console.log(output); - let dl = output.indexOf("\n", output.indexOf("#eye")) - let dl2 = output.lastIndexOf("\n", output.indexOf("#ENDS") - 2) - output = output.substring(dl, dl2).trim() - - // console.log("output:", output); - resolve({ success: output }); - }); - } - - flush(to) { - let str = String.fromCharCode.apply(null, this.buffers[to]); - this.buffers[to] = []; - - return str; - } -}; - -export { _Output as Output }; \ No newline at end of file diff --git a/lib/eyebrow/run.html b/lib/eyebrow/run.html deleted file mode 100644 index 4a8ed35..0000000 --- a/lib/eyebrow/run.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - đŸ¤¨ - - - \ No newline at end of file diff --git a/lib/eyebrow/swipl-web-module.js b/lib/eyebrow/swipl-web-module.js deleted file mode 100644 index 3a3170e..0000000 --- a/lib/eyebrow/swipl-web-module.js +++ /dev/null @@ -1,37 +0,0 @@ - -var _SWIPL = (() => { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(SWIPL) { - SWIPL = SWIPL || {}; - -var Module=typeof SWIPL!="undefined"?SWIPL:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0}Module.expectedDataFileDownloads++;(function(){if(Module["ENVIRONMENT_IS_PTHREAD"])return;var loadPackage=function(metadata){var PACKAGE_PATH="";if(typeof window==="object"){PACKAGE_PATH=window["encodeURIComponent"](window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/")}else if(typeof process==="undefined"&&typeof location!=="undefined"){PACKAGE_PATH=encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/")}var PACKAGE_NAME="src/swipl-web.data"; -var REMOTE_PACKAGE_BASE="/n3/lib/eyebrow/swipl-web.data"; -if(typeof Module["locateFilePackage"]==="function"&&!Module["locateFile"]){Module["locateFile"]=Module["locateFilePackage"];err("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)")} -// EDIT wvw -var REMOTE_PACKAGE_NAME=REMOTE_PACKAGE_BASE -// var REMOTE_PACKAGE_NAME=Module["locateFile"] ? -// Module["locateFile"](REMOTE_PACKAGE_BASE,"") : -// REMOTE_PACKAGE_BASE; -var REMOTE_PACKAGE_SIZE=metadata["remote_package_size"];function fetchRemotePackage(packageName,packageSize,callback,errback){if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){require("fs").readFile(packageName,function(err,contents){if(err){errback(err)}else{callback(contents.buffer)}});return}var xhr=new XMLHttpRequest;xhr.open("GET",packageName,true);xhr.responseType="arraybuffer";xhr.onprogress=function(event){var url=packageName;var size=packageSize;if(event.total)size=event.total;if(event.loaded){if(!xhr.addedTotal){xhr.addedTotal=true;if(!Module.dataFileDownloads)Module.dataFileDownloads={};Module.dataFileDownloads[url]={loaded:event.loaded,total:size}}else{Module.dataFileDownloads[url].loaded=event.loaded}var total=0;var loaded=0;var num=0;for(var download in Module.dataFileDownloads){var data=Module.dataFileDownloads[download];total+=data.total;loaded+=data.loaded;num++}total=Math.ceil(total*Module.expectedDataFileDownloads/num);if(Module["setStatus"])Module["setStatus"]("Downloading data... ("+loaded+"/"+total+")")}else if(!Module.dataFileDownloads){if(Module["setStatus"])Module["setStatus"]("Downloading data...")}};xhr.onerror=function(event){throw new Error("NetworkError for: "+packageName)};xhr.onload=function(event){if(xhr.status==200||xhr.status==304||xhr.status==206||xhr.status==0&&xhr.response){var packageData=xhr.response;callback(packageData)}else{throw new Error(xhr.statusText+" : "+xhr.responseURL)}};xhr.send(null)}function handleError(error){console.error("package error:",error)}var fetchedCallback=null;var fetched=Module["getPreloadedPackage"]?Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE):null;if(!fetched)fetchRemotePackage(REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE,function(data){if(fetchedCallback){fetchedCallback(data);fetchedCallback=null}else{fetched=data}},handleError);function runWithFS(){function assert(check,msg){if(!check)throw msg+(new Error).stack}Module["FS_createPath"]("/","swipl",true,true);Module["FS_createPath"]("/swipl","library",true,true);Module["FS_createPath"]("/swipl/library","iri_scheme",true,true);Module["FS_createPath"]("/swipl/library","http",true,true);Module["FS_createPath"]("/swipl/library","chr",true,true);Module["FS_createPath"]("/swipl/library","theme",true,true);Module["FS_createPath"]("/swipl/library","DTD",true,true);Module["FS_createPath"]("/swipl/library","lynx",true,true);Module["FS_createPath"]("/swipl/library","clp",true,true);Module["FS_createPath"]("/swipl/library/clp","clpqr",true,true);Module["FS_createPath"]("/swipl/library/clp","clpq",true,true);Module["FS_createPath"]("/swipl/library/clp","clpr",true,true);Module["FS_createPath"]("/swipl/library","dcg",true,true);Module["FS_createPath"]("/swipl/library","unicode",true,true);Module["FS_createPath"]("/swipl/library","build",true,true);Module["FS_createPath"]("/swipl/library","dialect",true,true);Module["FS_createPath"]("/swipl/library/dialect","swi",true,true);Module["FS_createPath"]("/swipl/library/dialect","xsb",true,true);Module["FS_createPath"]("/swipl/library/dialect","sicstus4",true,true);Module["FS_createPath"]("/swipl/library/dialect","eclipse",true,true);Module["FS_createPath"]("/swipl/library/dialect","yap",true,true);Module["FS_createPath"]("/swipl/library/dialect","sicstus",true,true);Module["FS_createPath"]("/swipl/library/dialect","hprolog",true,true);Module["FS_createPath"]("/swipl/library/dialect","iso",true,true);Module["FS_createPath"]("/swipl/library","semweb",true,true);function DataRequest(start,end,audio){this.start=start;this.end=end;this.audio=audio}DataRequest.prototype={requests:{},open:function(mode,name){this.name=name;this.requests[name]=this;Module["addRunDependency"]("fp "+this.name)},send:function(){},onload:function(){var byteArray=this.byteArray.subarray(this.start,this.end);this.finish(byteArray)},finish:function(byteArray){var that=this;Module["FS_createDataFile"](this.name,null,byteArray,true,true,true);Module["removeRunDependency"]("fp "+that.name);this.requests[this.name]=null}};var files=metadata["files"];for(var i=0;i{s+=a});Module.on_output(s,stream)}else{console.log.apply(null,args)}}function bind_std_streams(){decoder=new TextDecoder("utf-8");Module.FS.init(undefined,c=>write("stdout",c),c=>write("stderr",c))}if(Module.on_output){Module.preRun.push(bind_std_streams)}var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory=""; -function locateFile(path){ - if(Module["locateFile"]){ - return Module["locateFile"](path,scriptDirectory) - }return scriptDirectory+path -} -var read_,readAsync,readBinary,setWindowTitle;function logExceptionOnExit(e){if(e instanceof ExitStatus)return;let toLog=e;err("exiting due to exception: "+toLog)}var fs;var nodePath;var requireNodeFS;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}requireNodeFS=()=>{if(!nodePath){fs=require("fs");nodePath=require("path")}};read_=function shell_read(filename,binary){requireNodeFS();filename=nodePath["normalize"](filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror)=>{requireNodeFS();filename=nodePath["normalize"](filename);fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer)})};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",function(reason){throw reason});quit_=(status,toThrow)=>{if(keepRuntimeAlive()){process["exitCode"]=status;throw toThrow}logExceptionOnExit(toThrow);process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=value=>{tempRet0=value};var getTempRet0=()=>tempRet0;var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||false;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf);Module["HEAP64"]=HEAP64=new BigInt64Array(buf);Module["HEAPU64"]=HEAPU64=new BigUint64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;var runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function exitRuntime(){___funcs_on_exit();callRuntimeCallbacks(__ATEXIT__);FS.quit();TTY.shutdown();runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){{if(Module["onAbort"]){Module["onAbort"](what)}}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")} -// EDIT wvw -var wasmBinaryFile;wasmBinaryFile="/n3/lib/eyebrow/swipl-web.wasm"; -// if(!isDataURI(wasmBinaryFile)){ -// wasmBinaryFile=locateFile(wasmBinaryFile) -// console.log(wasmBinaryFile) -// } -function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["na"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Gb"];addOnInit(Module["asm"]["oa"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync().catch(readyPromiseReject);return{}}var ASM_CONSTS={270120:$0=>{release_registered_object($0)},270155:$0=>{const s=prolog_js_obj_class_name($0);const len=lengthBytesUTF8(s)+1;const mem=_malloc(len);stringToUTF8(s,mem,len);return mem},270298:($0,$1)=>{return prolog_js_call($0,$1)}};function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort("invalid type for getValue: "+type)}return null}function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort("invalid type for setValue: "+type)}}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}var wasmTableMirror=[];function getWasmTableEntry(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func}function ___call_sighandler(fp,sig){getWasmTableEntry(fp)(sig)}var PATH={isAbs:path=>path.charAt(0)==="/",splitPath:filename=>{var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(p=>!!p),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:path=>{if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:(l,r)=>{return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto=="object"&&typeof crypto["getRandomValues"]=="function"){var randomBuffer=new Uint8Array(1);return()=>{crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else if(ENVIRONMENT_IS_NODE){try{var crypto_module=require("crypto");return()=>crypto_module["randomBytes"](1)[0]}catch(e){}}return()=>abort("randomDevice")}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(p=>!!p),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:(from,to)=>{from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var TTY={ttys:[],init:function(){},shutdown:function(){},register:function(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open:function(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close:function(stream){stream.tty.ops.flush(stream.tty)},flush:function(stream){stream.tty.ops.flush(stream.tty)},read:function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function zeroMemory(address,size){HEAPU8.fill(0,address,address+size)}function alignMemory(size,alignment){return Math.ceil(size/alignment)*alignment}function mmapAlloc(size){size=alignMemory(size,65536);var ptr=_emscripten_builtin_memalign(65536,size);if(!ptr)return 0;zeroMemory(ptr,size);return ptr}var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray:function(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage:function(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).');onload(new Uint8Array(arrayBuffer));if(dep)removeRunDependency(dep)},event=>{if(onerror){onerror()}else{throw'Loading data file "'+url+'" failed.'}});if(dep)addRunDependency(dep)}var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(path,opts={})=>{path=PATH_FS.resolve(FS.cwd(),path);if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};opts=Object.assign(defaults,opts);if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=PATH.normalizeArray(path.split("/").filter(p=>!!p),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:node=>{var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:(parentid,name)=>{var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:node=>{var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:node=>{var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:(parent,name)=>{var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:(parent,name,mode,rdev)=>{var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:node=>{FS.hashRemoveNode(node)},isRoot:node=>{return node===node.parent},isMountpoint:node=>{return!!node.mounted},isFile:mode=>{return(mode&61440)===32768},isDir:mode=>{return(mode&61440)===16384},isLink:mode=>{return(mode&61440)===40960},isChrdev:mode=>{return(mode&61440)===8192},isBlkdev:mode=>{return(mode&61440)===24576},isFIFO:mode=>{return(mode&61440)===4096},isSocket:mode=>{return(mode&49152)===49152},flagModes:{"r":0,"r+":2,"w":577,"w+":578,"a":1089,"a+":1090},modeStringToFlags:str=>{var flags=FS.flagModes[str];if(typeof flags=="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:flag=>{var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:(node,perms)=>{if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup:dir=>{var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:(dir,name)=>{try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:(dir,name,isdir)=>{var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:(node,flags)=>{if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:(fd_start=0,fd_end=FS.MAX_OPEN_FDS)=>{for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:fd=>FS.streams[fd],createStream:(stream,fd_start,fd_end)=>{if(!FS.FSStream){FS.FSStream=function(){this.shared={}};FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(val){this.shared.flags=val}},position:{get:function(){return this.shared.position},set:function(val){this.shared.position=val}}})}stream=Object.assign(new FS.FSStream,stream);var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:fd=>{FS.streams[fd]=null},chrdev_stream_ops:{open:stream=>{var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:()=>{throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice:(dev,ops)=>{FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts:mount=>{var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:(populate,callback)=>{if(typeof populate=="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:(type,opts,mountpoint)=>{var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:mountpoint=>{var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:(parent,name)=>{return parent.node_ops.lookup(parent,name)},mknod:(path,mode,dev)=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:(path,mode)=>{mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:(path,mode)=>{mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:(path,mode)=>{var dirs=path.split("/");var d="";for(var i=0;i{if(typeof dev=="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink:(oldpath,newpath)=>{if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename:(old_path,new_path)=>{var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,"w");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir:path=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(54)}return node.node_ops.readdir(node)},unlink:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink:path=>{var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return PATH_FS.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))},stat:(path,dontFollow)=>{var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(44)}if(!node.node_ops.getattr){throw new FS.ErrnoError(63)}return node.node_ops.getattr(node)},lstat:path=>{return FS.stat(path,true)},chmod:(path,mode,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})},lchmod:(path,mode)=>{FS.chmod(path,mode,true)},fchmod:(fd,mode)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chmod(stream.node,mode)},chown:(path,uid,gid,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{timestamp:Date.now()})},lchown:(path,uid,gid)=>{FS.chown(path,uid,gid,true)},fchown:(fd,uid,gid)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chown(stream.node,uid,gid)},truncate:(path,len)=>{if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,"w");if(errCode){throw new FS.ErrnoError(errCode)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate:(fd,len)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.truncate(stream.node,len)},utime:(path,atime,mtime)=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open:(path,flags,mode)=>{if(path===""){throw new FS.ErrnoError(44)}flags=typeof flags=="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode=="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path=="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close:stream=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed:stream=>{return stream.fd===null},llseek:(stream,offset,whence)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read:(stream,buffer,offset,length,position)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write:(stream,buffer,offset,length,position,canOwn)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},allocate:(stream,offset,length)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(offset<0||length<=0){throw new FS.ErrnoError(28)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(stream.node.mode)){throw new FS.ErrnoError(43)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(138)}stream.stream_ops.allocate(stream,offset,length)},mmap:(stream,length,position,prot,flags)=>{if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync:(stream,buffer,offset,length,mmapFlags)=>{if(!stream||!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},munmap:stream=>0,ioctl:(stream,cmd,arg)=>{if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile:(path,opts={})=>{opts.flags=opts.flags||0;opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret},writeFile:(path,data,opts={})=>{opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data=="string"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,undefined,opts.canOwn)}else if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error("Unsupported data type")}FS.close(stream)},cwd:()=>FS.currentPath,chdir:path=>{var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,"x");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories:()=>{FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices:()=>{FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device=getRandomDevice();FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{FS.mkdir("/proc");var proc_self=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:()=>{var node=FS.createNode(proc_self,"fd",16384|511,73);node.node_ops={lookup:(parent,name)=>{var fd=+name;var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>stream.path}};ret.parent=ret;return ret}};return node}},{},"/proc/self/fd")},createStandardStreams:()=>{if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin",0);var stdout=FS.open("/dev/stdout",1);var stderr=FS.open("/dev/stderr",1)},ensureErrnoError:()=>{if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.node=node;this.setErrno=function(errno){this.errno=errno};this.setErrno(errno);this.message="FS error"};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[44].forEach(code=>{FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack=""})},staticInit:()=>{FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={"MEMFS":MEMFS}},init:(input,output,error)=>{FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()},quit:()=>{FS.init.initialized=false;_fflush(0);for(var i=0;i{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode},findObject:(path,dontResolveLastLink)=>{var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath:(path,dontResolveLastLink)=>{try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path==="/"}catch(e){ret.error=e.errno}return ret},createPath:(parent,path,canRead,canWrite)=>{parent=typeof parent=="string"?parent:FS.getPath(parent);var parts=path.split("/").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){}parent=current}return current},createFile:(parent,name,properties,canRead,canWrite)=>{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile:(parent,name,data,canRead,canWrite,canOwn)=>{var path=name;if(parent){parent=typeof parent=="string"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS.getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data=="string"){var arr=new Array(data.length);for(var i=0,len=data.length;i{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(!!input,!!output);if(!FS.createDevice.major)FS.createDevice.major=64;var dev=FS.makedev(FS.createDevice.major++,0);FS.registerDevice(dev,{open:stream=>{stream.seekable=false},close:stream=>{if(output&&output.buffer&&output.buffer.length){output(10)}},read:(stream,buffer,offset,length,pos)=>{var bytesRead=0;for(var i=0;i{for(var i=0;i{if(obj.isDevice||obj.isFolder||obj.link||obj.contents)return true;if(typeof XMLHttpRequest!="undefined"){throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")}else if(read_){try{obj.contents=intArrayFromString(read_(obj.url),true);obj.usedBytes=obj.contents.length}catch(e){throw new FS.ErrnoError(29)}}else{throw new Error("Cannot load without read() or XMLHttpRequest.")}},createLazyFile:(parent,name,url,canRead,canWrite)=>{function LazyUint8Array(){this.lengthKnown=false;this.chunks=[]}LazyUint8Array.prototype.get=function LazyUint8Array_get(idx){if(idx>this.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||"",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]=="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]=="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr:ptr,allocated:true}};node.stream_ops=stream_ops;return node},createPreloadedFile:(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency("cp "+fullname);function processData(byteArray){function finish(byteArray){if(preFinish)preFinish();if(!dontCreateFile){FS.createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}if(onload)onload();removeRunDependency(dep)}if(Browser.handledByPreloadPlugin(byteArray,fullname,finish,()=>{if(onerror)onerror();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url=="string"){asyncLoad(url,byteArray=>processData(byteArray),onerror)}else{processData(url)}},indexedDB:()=>{return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:()=>{return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=()=>{out("creating db");var db=openRequest.result;db.createObjectStore(FS.DB_STORE_NAME)};openRequest.onsuccess=()=>{var db=openRequest.result;var transaction=db.transaction([FS.DB_STORE_NAME],"readwrite");var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var putRequest=files.put(FS.analyzePath(path).object.contents,path);putRequest.onsuccess=()=>{ok++;if(ok+fail==total)finish()};putRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror},loadFilesFromDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=onerror;openRequest.onsuccess=()=>{var db=openRequest.result;try{var transaction=db.transaction([FS.DB_STORE_NAME],"readonly")}catch(e){onerror(e);return}var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var getRequest=files.get(path);getRequest.onsuccess=()=>{if(FS.analyzePath(path).exists){FS.unlink(path)}FS.createDataFile(PATH.dirname(path),PATH.basename(path),getRequest.result,true,true,true);ok++;if(ok+fail==total)finish()};getRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror}};var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=FS.getStream(dirfd);if(!dirstream)throw new FS.ErrnoError(8);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return PATH.join2(dir,path)},doStat:function(func,path,buf){try{var stat=func(path)}catch(e){if(e&&e.node&&PATH.normalize(path)!==PATH.normalize(FS.getPath(e.node))){return-54}throw e}HEAP32[buf>>2]=stat.dev;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP64[buf+40>>3]=BigInt(stat.size);HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;HEAP64[buf+56>>3]=BigInt(Math.floor(stat.atime.getTime()/1e3));HEAP32[buf+64>>2]=0;HEAP64[buf+72>>3]=BigInt(Math.floor(stat.mtime.getTime()/1e3));HEAP32[buf+80>>2]=0;HEAP64[buf+88>>3]=BigInt(Math.floor(stat.ctime.getTime()/1e3));HEAP32[buf+96>>2]=0;HEAP64[buf+104>>3]=BigInt(stat.ino);return 0},doMsync:function(addr,stream,len,flags,offset){var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream}};function ___syscall_chdir(path){try{path=SYSCALLS.getStr(path);FS.chdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_chmod(path,mode){try{path=SYSCALLS.getStr(path);FS.chmod(path,mode);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_dup3(fd,suggestFD,flags){try{var old=SYSCALLS.getStreamFromFD(fd);if(old.fd===suggestFD)return-28;var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.createStream(old,suggestFD,suggestFD+1).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_faccessat(dirfd,path,amode,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(amode&~7){return-28}var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.createStream(stream,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 5:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}var MAX_INT53=9007199254740992;var MIN_INT53=-9007199254740992;function bigintToI53Checked(num){return numMAX_INT53?NaN:Number(num)}function ___syscall_ftruncate64(fd,length){try{length=bigintToI53Checked(length);if(isNaN(length))return-61;FS.ftruncate(fd,length);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(size>3]=BigInt(id);HEAP64[dirp+pos+8>>3]=BigInt((idx+1)*struct_size);HEAP16[dirp+pos+16>>1]=280;HEAP8[dirp+pos+18>>0]=type;stringToUTF8(name,dirp+pos+19,256);pos+=struct_size;idx+=1}FS.llseek(stream,idx*struct_size,0);return pos}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(op){case 21509:case 21505:{if(!stream.tty)return-59;return 0}case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:{if(!stream.tty)return-59;return 0}case 21519:{if(!stream.tty)return-59;var argp=SYSCALLS.get();HEAP32[argp>>2]=0;return 0}case 21520:{if(!stream.tty)return-59;return-28}case 21531:{var argp=SYSCALLS.get();return FS.ioctl(stream,op,argp)}case 21523:{if(!stream.tty)return-59;return 0}case 21524:{if(!stream.tty)return-59;return 0}default:return-28}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_lstat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.lstat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_mkdirat(dirfd,path,mode){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_newfstatat(dirfd,path,buf,flags){try{path=SYSCALLS.getStr(path);var nofollow=flags&256;var allowEmpty=flags&4096;flags=flags&~4352;path=SYSCALLS.calculateAt(dirfd,path,allowEmpty);return SYSCALLS.doStat(nofollow?FS.lstat:FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs;try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);var mode=varargs?SYSCALLS.get():0;return FS.open(path,flags,mode).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_poll(fds,nfds,timeout){try{var nonzero=0;for(var i=0;i>2];var events=HEAP16[pollfd+4>>1];var mask=32;var stream=FS.getStream(fd);if(stream){mask=SYSCALLS.DEFAULT_POLLMASK;if(stream.stream_ops.poll){mask=stream.stream_ops.poll(stream)}}mask&=events|8|16;if(mask)nonzero++;HEAP16[pollfd+6>>1]=mask}return nonzero}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_readlinkat(dirfd,path,buf,bufsize){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_renameat(olddirfd,oldpath,newdirfd,newpath){try{oldpath=SYSCALLS.getStr(oldpath);newpath=SYSCALLS.getStr(newpath);oldpath=SYSCALLS.calculateAt(olddirfd,oldpath);newpath=SYSCALLS.calculateAt(newdirfd,newpath);FS.rename(oldpath,newpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_rmdir(path){try{path=SYSCALLS.getStr(path);FS.rmdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_stat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_symlink(target,linkpath){try{target=SYSCALLS.getStr(target);linkpath=SYSCALLS.getStr(linkpath);FS.symlink(target,linkpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_unlinkat(dirfd,path,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(flags===0){FS.unlink(path)}else if(flags===512){FS.rmdir(path)}else{abort("Invalid flags passed to unlinkat")}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function readI53FromI64(ptr){return HEAPU32[ptr>>2]+HEAP32[ptr+4>>2]*4294967296}function ___syscall_utimensat(dirfd,path,times,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path,true);if(!times){var atime=Date.now();var mtime=atime}else{var seconds=readI53FromI64(times);var nanoseconds=HEAP32[times+8>>2];atime=seconds*1e3+nanoseconds/(1e3*1e3);times+=16;seconds=readI53FromI64(times);nanoseconds=HEAP32[times+8>>2];mtime=seconds*1e3+nanoseconds/(1e3*1e3)}FS.utime(path,atime,mtime);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function __emscripten_date_now(){return Date.now()}var nowIsMonotonic=true;function __emscripten_get_now_is_monotonic(){return nowIsMonotonic}function __emscripten_throw_longjmp(){throw Infinity}function __localtime_js(time,tmPtr){var date=new Date(readI53FromI64(time)*1e3);HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getDay();var start=new Date(date.getFullYear(),0,1);var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>2]=dst}function __mktime_js(tmPtr){var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();return date.getTime()/1e3|0}function __munmap_js(addr,len,prot,flags,fd,offset){try{var stream=FS.getStream(fd);if(stream){if(prot&2){SYSCALLS.doMsync(addr,stream,len,flags,offset)}FS.munmap(stream)}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function _tzset_impl(timezone,daylight,tzname){var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAP32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAPU32[tzname+4>>2]=summerNamePtr}else{HEAPU32[tzname>>2]=summerNamePtr;HEAPU32[tzname+4>>2]=winterNamePtr}}function __tzset_js(timezone,daylight,tzname){if(__tzset_js.called)return;__tzset_js.called=true;_tzset_impl(timezone,daylight,tzname)}function _abort(){abort("")}var readAsmConstArgsArray=[];function readAsmConstArgs(sigPtr,buf){readAsmConstArgsArray.length=0;var ch;buf>>=2;while(ch=HEAPU8[sigPtr++]){buf+=ch!=105&buf;readAsmConstArgsArray.push(ch==105?HEAP32[buf]:(ch==106?HEAP64:HEAPF64)[buf++>>1]);++buf}return readAsmConstArgsArray}function _emscripten_asm_const_int(code,sigPtr,argbuf){var args=readAsmConstArgs(sigPtr,argbuf);return ASM_CONSTS[code].apply(null,args)}var _emscripten_asm_const_ptr=_emscripten_asm_const_int;function getHeapMax(){return 2147483648}function _emscripten_get_heap_max(){return getHeapMax()}var _emscripten_get_now;if(ENVIRONMENT_IS_NODE){_emscripten_get_now=()=>{var t=process["hrtime"]();return t[0]*1e3+t[1]/1e6}}else _emscripten_get_now=()=>performance.now();function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function _emscripten_run_script(ptr){eval(UTF8ToString(ptr))}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAPU32[penviron_buf_size>>2]=bufSize;return 0}function _proc_exit(code){EXITSTATUS=code;if(!keepRuntimeAlive()){if(Module["onExit"])Module["onExit"](code);ABORT=true}quit_(code,new ExitStatus(code))}function exitJS(status,implicit){EXITSTATUS=status;if(!keepRuntimeAlive()){exitRuntime()}_proc_exit(status)}var _exit=exitJS;function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_fdstat_get(fd,pbuf){try{var stream=SYSCALLS.getStreamFromFD(fd);var type=stream.tty?2:FS.isDir(stream.mode)?3:FS.isLink(stream.mode)?7:4;HEAP8[pbuf>>0]=type;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doReadv(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_seek(fd,offset,whence,newOffset){try{offset=bigintToI53Checked(offset);if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);HEAP64[newOffset>>3]=BigInt(stream.position);if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doWritev(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=doWritev(stream,iov,iovcnt);HEAPU32[pnum>>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _getTempRet0(){return getTempRet0()}function _setTempRet0(val){setTempRet0(val)}function __isLeapYear(year){return year%4===0&&(year%100!==0||year%400===0)}function __arraySum(array,index){var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date,days){var newDate=new Date(date.getTime());while(days>0){var leap=__isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate}function _strftime(s,maxsize,format,tm){var tm_zone=HEAP32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value=="number"?value.toString():value||"";while(str.length0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}return thisDate.getFullYear()}return thisDate.getFullYear()-1}var EXPANSION_RULES_2={"%a":function(date){return WEEKDAYS[date.tm_wday].substring(0,3)},"%A":function(date){return WEEKDAYS[date.tm_wday]},"%b":function(date){return MONTHS[date.tm_mon].substring(0,3)},"%B":function(date){return MONTHS[date.tm_mon]},"%C":function(date){var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":function(date){return leadingNulls(date.tm_mday,2)},"%e":function(date){return leadingSomething(date.tm_mday,2," ")},"%g":function(date){return getWeekBasedYear(date).toString().substring(2)},"%G":function(date){return getWeekBasedYear(date)},"%H":function(date){return leadingNulls(date.tm_hour,2)},"%I":function(date){var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":function(date){return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,date.tm_mon-1),3)},"%m":function(date){return leadingNulls(date.tm_mon+1,2)},"%M":function(date){return leadingNulls(date.tm_min,2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}return"PM"},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var days=date.tm_yday+7-date.tm_wday;return leadingNulls(Math.floor(days/7),2)},"%V":function(date){var val=Math.floor((date.tm_yday+7-(date.tm_wday+6)%7)/7);if((date.tm_wday+371-date.tm_yday-2)%7<=2){val++}if(!val){val=52;var dec31=(date.tm_wday+7-date.tm_yday-1)%7;if(dec31==4||dec31==5&&__isLeapYear(date.tm_year%400-1)){val++}}else if(val==53){var jan1=(date.tm_wday+371-date.tm_yday)%7;if(jan1!=4&&(jan1!=3||!__isLeapYear(date.tm_year)))val=1}return leadingNulls(val,2)},"%w":function(date){return date.tm_wday},"%W":function(date){var days=date.tm_yday+7-(date.tm_wday+6)%7;return leadingNulls(Math.floor(days/7),2)},"%y":function(date){return(date.tm_year+1900).toString().substring(2)},"%Y":function(date){return date.tm_year+1900},"%z":function(date){var off=date.tm_gmtoff;var ahead=off>=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};pattern=pattern.replace(/%%/g,"\0\0");for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}pattern=pattern.replace(/\0\0/g,"%");var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1}var ALLOC_NORMAL=0;var ALLOC_STACK=1;function allocate(slab,allocator){var ret;if(allocator==ALLOC_STACK){ret=stackAlloc(slab.length)}else{ret=_malloc(slab.length)}if(!slab.subarray&&!slab.slice){slab=new Uint8Array(slab)}HEAPU8.set(slab,ret);return ret}function getCFunc(ident){var func=Module["_"+ident];return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;itype==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_unlink"]=FS.unlink;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;var asmLibraryArg={"P":___call_sighandler,"fa":___syscall_chdir,"ea":___syscall_chmod,"da":___syscall_dup3,"ga":___syscall_faccessat,"n":___syscall_fcntl64,"Z":___syscall_fstat64,"V":___syscall_ftruncate64,"U":___syscall_getcwd,"O":___syscall_getdents64,"w":___syscall_ioctl,"W":___syscall_lstat64,"S":___syscall_mkdirat,"X":___syscall_newfstatat,"x":___syscall_openat,"Q":___syscall_poll,"N":___syscall_readlinkat,"L":___syscall_renameat,"t":___syscall_rmdir,"Y":___syscall_stat64,"K":___syscall_symlink,"M":___syscall_unlinkat,"I":___syscall_utimensat,"z":__emscripten_date_now,"_":__emscripten_get_now_is_monotonic,"G":__emscripten_throw_longjmp,"$":__localtime_js,"aa":__mktime_js,"R":__munmap_js,"ba":__tzset_js,"m":_abort,"A":_emscripten_asm_const_int,"ja":_emscripten_asm_const_ptr,"J":_emscripten_get_heap_max,"y":_emscripten_get_now,"ca":_emscripten_memcpy_big,"H":_emscripten_resize_heap,"ka":_emscripten_run_script,"ha":_environ_get,"ia":_environ_sizes_get,"i":_exit,"p":_fd_close,"u":_fd_fdstat_get,"v":_fd_read,"T":_fd_seek,"q":_fd_write,"a":_getTempRet0,"h":invoke_i,"d":invoke_ii,"c":invoke_iii,"f":invoke_iiii,"k":invoke_iiiii,"j":invoke_iiiiii,"C":invoke_iiiiiii,"s":invoke_iiiiiiii,"D":invoke_iiiiiiiii,"E":invoke_iiiiiiiiii,"F":invoke_iiiiiiiiiii,"ma":invoke_iiiiiiiiiiii,"r":invoke_iiji,"B":invoke_ij,"l":invoke_v,"e":invoke_vi,"g":invoke_vii,"o":invoke_viii,"b":_setTempRet0,"la":_strftime};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["oa"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["pa"]).apply(null,arguments)};var _PL_initialise=Module["_PL_initialise"]=function(){return(_PL_initialise=Module["_PL_initialise"]=Module["asm"]["qa"]).apply(null,arguments)};var _PL_halt=Module["_PL_halt"]=function(){return(_PL_halt=Module["_PL_halt"]=Module["asm"]["ra"]).apply(null,arguments)};var _PL_toplevel=Module["_PL_toplevel"]=function(){return(_PL_toplevel=Module["_PL_toplevel"]=Module["asm"]["sa"]).apply(null,arguments)};var _PL_unregister_blob_type=Module["_PL_unregister_blob_type"]=function(){return(_PL_unregister_blob_type=Module["_PL_unregister_blob_type"]=Module["asm"]["ta"]).apply(null,arguments)};var _PL_unregister_atom=Module["_PL_unregister_atom"]=function(){return(_PL_unregister_atom=Module["_PL_unregister_atom"]=Module["asm"]["ua"]).apply(null,arguments)};var _PL_agc_hook=Module["_PL_agc_hook"]=function(){return(_PL_agc_hook=Module["_PL_agc_hook"]=Module["asm"]["va"]).apply(null,arguments)};var _PL_register_atom=Module["_PL_register_atom"]=function(){return(_PL_register_atom=Module["_PL_register_atom"]=Module["asm"]["wa"]).apply(null,arguments)};var _PL_open_foreign_frame=Module["_PL_open_foreign_frame"]=function(){return(_PL_open_foreign_frame=Module["_PL_open_foreign_frame"]=Module["asm"]["xa"]).apply(null,arguments)};var _PL_close_foreign_frame=Module["_PL_close_foreign_frame"]=function(){return(_PL_close_foreign_frame=Module["_PL_close_foreign_frame"]=Module["asm"]["ya"]).apply(null,arguments)};var _PL_rewind_foreign_frame=Module["_PL_rewind_foreign_frame"]=function(){return(_PL_rewind_foreign_frame=Module["_PL_rewind_foreign_frame"]=Module["asm"]["za"]).apply(null,arguments)};var _PL_discard_foreign_frame=Module["_PL_discard_foreign_frame"]=function(){return(_PL_discard_foreign_frame=Module["_PL_discard_foreign_frame"]=Module["asm"]["Aa"]).apply(null,arguments)};var _PL_open_query=Module["_PL_open_query"]=function(){return(_PL_open_query=Module["_PL_open_query"]=Module["asm"]["Ba"]).apply(null,arguments)};var _PL_exception=Module["_PL_exception"]=function(){return(_PL_exception=Module["_PL_exception"]=Module["asm"]["Ca"]).apply(null,arguments)};var _PL_cut_query=Module["_PL_cut_query"]=function(){return(_PL_cut_query=Module["_PL_cut_query"]=Module["asm"]["Da"]).apply(null,arguments)};var _PL_close_query=Module["_PL_close_query"]=function(){return(_PL_close_query=Module["_PL_close_query"]=Module["asm"]["Ea"]).apply(null,arguments)};var _PL_current_query=Module["_PL_current_query"]=function(){return(_PL_current_query=Module["_PL_current_query"]=Module["asm"]["Fa"]).apply(null,arguments)};var _PL_next_solution=Module["_PL_next_solution"]=function(){return(_PL_next_solution=Module["_PL_next_solution"]=Module["asm"]["Ga"]).apply(null,arguments)};var _PL_instantiation_error=Module["_PL_instantiation_error"]=function(){return(_PL_instantiation_error=Module["_PL_instantiation_error"]=Module["asm"]["Ha"]).apply(null,arguments)};var _PL_uninstantiation_error=Module["_PL_uninstantiation_error"]=function(){return(_PL_uninstantiation_error=Module["_PL_uninstantiation_error"]=Module["asm"]["Ia"]).apply(null,arguments)};var _PL_representation_error=Module["_PL_representation_error"]=function(){return(_PL_representation_error=Module["_PL_representation_error"]=Module["asm"]["Ja"]).apply(null,arguments)};var _PL_type_error=Module["_PL_type_error"]=function(){return(_PL_type_error=Module["_PL_type_error"]=Module["asm"]["Ka"]).apply(null,arguments)};var _PL_domain_error=Module["_PL_domain_error"]=function(){return(_PL_domain_error=Module["_PL_domain_error"]=Module["asm"]["La"]).apply(null,arguments)};var _PL_existence_error=Module["_PL_existence_error"]=function(){return(_PL_existence_error=Module["_PL_existence_error"]=Module["asm"]["Ma"]).apply(null,arguments)};var _PL_permission_error=Module["_PL_permission_error"]=function(){return(_PL_permission_error=Module["_PL_permission_error"]=Module["asm"]["Na"]).apply(null,arguments)};var _PL_resource_error=Module["_PL_resource_error"]=function(){return(_PL_resource_error=Module["_PL_resource_error"]=Module["asm"]["Oa"]).apply(null,arguments)};var _PL_syntax_error=Module["_PL_syntax_error"]=function(){return(_PL_syntax_error=Module["_PL_syntax_error"]=Module["asm"]["Pa"]).apply(null,arguments)};var _PL_get_atom_ex=Module["_PL_get_atom_ex"]=function(){return(_PL_get_atom_ex=Module["_PL_get_atom_ex"]=Module["asm"]["Qa"]).apply(null,arguments)};var _PL_get_integer_ex=Module["_PL_get_integer_ex"]=function(){return(_PL_get_integer_ex=Module["_PL_get_integer_ex"]=Module["asm"]["Ra"]).apply(null,arguments)};var _PL_get_long_ex=Module["_PL_get_long_ex"]=function(){return(_PL_get_long_ex=Module["_PL_get_long_ex"]=Module["asm"]["Sa"]).apply(null,arguments)};var _PL_get_int64_ex=Module["_PL_get_int64_ex"]=function(){return(_PL_get_int64_ex=Module["_PL_get_int64_ex"]=Module["asm"]["Ta"]).apply(null,arguments)};var _PL_get_intptr_ex=Module["_PL_get_intptr_ex"]=function(){return(_PL_get_intptr_ex=Module["_PL_get_intptr_ex"]=Module["asm"]["Ua"]).apply(null,arguments)};var _PL_get_size_ex=Module["_PL_get_size_ex"]=function(){return(_PL_get_size_ex=Module["_PL_get_size_ex"]=Module["asm"]["Va"]).apply(null,arguments)};var _PL_get_bool_ex=Module["_PL_get_bool_ex"]=function(){return(_PL_get_bool_ex=Module["_PL_get_bool_ex"]=Module["asm"]["Wa"]).apply(null,arguments)};var _PL_get_float_ex=Module["_PL_get_float_ex"]=function(){return(_PL_get_float_ex=Module["_PL_get_float_ex"]=Module["asm"]["Xa"]).apply(null,arguments)};var _PL_get_char_ex=Module["_PL_get_char_ex"]=function(){return(_PL_get_char_ex=Module["_PL_get_char_ex"]=Module["asm"]["Ya"]).apply(null,arguments)};var _PL_get_pointer_ex=Module["_PL_get_pointer_ex"]=function(){return(_PL_get_pointer_ex=Module["_PL_get_pointer_ex"]=Module["asm"]["Za"]).apply(null,arguments)};var _PL_unify_list_ex=Module["_PL_unify_list_ex"]=function(){return(_PL_unify_list_ex=Module["_PL_unify_list_ex"]=Module["asm"]["_a"]).apply(null,arguments)};var _PL_unify_nil_ex=Module["_PL_unify_nil_ex"]=function(){return(_PL_unify_nil_ex=Module["_PL_unify_nil_ex"]=Module["asm"]["$a"]).apply(null,arguments)};var _PL_get_list_ex=Module["_PL_get_list_ex"]=function(){return(_PL_get_list_ex=Module["_PL_get_list_ex"]=Module["asm"]["ab"]).apply(null,arguments)};var _PL_get_nil_ex=Module["_PL_get_nil_ex"]=function(){return(_PL_get_nil_ex=Module["_PL_get_nil_ex"]=Module["asm"]["bb"]).apply(null,arguments)};var _PL_unify_bool_ex=Module["_PL_unify_bool_ex"]=function(){return(_PL_unify_bool_ex=Module["_PL_unify_bool_ex"]=Module["asm"]["cb"]).apply(null,arguments)};var _PL_is_ground=Module["_PL_is_ground"]=function(){return(_PL_is_ground=Module["_PL_is_ground"]=Module["asm"]["db"]).apply(null,arguments)};var _PL_is_acyclic=Module["_PL_is_acyclic"]=function(){return(_PL_is_acyclic=Module["_PL_is_acyclic"]=Module["asm"]["eb"]).apply(null,arguments)};var _PL_put_term_from_chars=Module["_PL_put_term_from_chars"]=function(){return(_PL_put_term_from_chars=Module["_PL_put_term_from_chars"]=Module["asm"]["fb"]).apply(null,arguments)};var _PL_chars_to_term=Module["_PL_chars_to_term"]=function(){return(_PL_chars_to_term=Module["_PL_chars_to_term"]=Module["asm"]["gb"]).apply(null,arguments)};var _PL_wchars_to_term=Module["_PL_wchars_to_term"]=function(){return(_PL_wchars_to_term=Module["_PL_wchars_to_term"]=Module["asm"]["hb"]).apply(null,arguments)};var _PL_record_external=Module["_PL_record_external"]=function(){return(_PL_record_external=Module["_PL_record_external"]=Module["asm"]["ib"]).apply(null,arguments)};var _PL_recorded_external=Module["_PL_recorded_external"]=function(){return(_PL_recorded_external=Module["_PL_recorded_external"]=Module["asm"]["jb"]).apply(null,arguments)};var _PL_erase_external=Module["_PL_erase_external"]=function(){return(_PL_erase_external=Module["_PL_erase_external"]=Module["asm"]["kb"]).apply(null,arguments)};var _PL_sigaction=Module["_PL_sigaction"]=function(){return(_PL_sigaction=Module["_PL_sigaction"]=Module["asm"]["lb"]).apply(null,arguments)};var _PL_get_signum_ex=Module["_PL_get_signum_ex"]=function(){return(_PL_get_signum_ex=Module["_PL_get_signum_ex"]=Module["asm"]["mb"]).apply(null,arguments)};var _PL_signal=Module["_PL_signal"]=function(){return(_PL_signal=Module["_PL_signal"]=Module["asm"]["nb"]).apply(null,arguments)};var _PL_handle_signals=Module["_PL_handle_signals"]=function(){return(_PL_handle_signals=Module["_PL_handle_signals"]=Module["asm"]["ob"]).apply(null,arguments)};var _PL_write_term=Module["_PL_write_term"]=function(){return(_PL_write_term=Module["_PL_write_term"]=Module["asm"]["pb"]).apply(null,arguments)};var _PL_cleanup_fork=Module["_PL_cleanup_fork"]=function(){return(_PL_cleanup_fork=Module["_PL_cleanup_fork"]=Module["asm"]["qb"]).apply(null,arguments)};var _PL_is_initialised=Module["_PL_is_initialised"]=function(){return(_PL_is_initialised=Module["_PL_is_initialised"]=Module["asm"]["rb"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["sb"]).apply(null,arguments)};var _PL_raise=Module["_PL_raise"]=function(){return(_PL_raise=Module["_PL_raise"]=Module["asm"]["tb"]).apply(null,arguments)};var _PL_new_atom=Module["_PL_new_atom"]=function(){return(_PL_new_atom=Module["_PL_new_atom"]=Module["asm"]["ub"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["vb"]).apply(null,arguments)};var _PL_put_atom_chars=Module["_PL_put_atom_chars"]=function(){return(_PL_put_atom_chars=Module["_PL_put_atom_chars"]=Module["asm"]["wb"]).apply(null,arguments)};var _PL_throw=Module["_PL_throw"]=function(){return(_PL_throw=Module["_PL_throw"]=Module["asm"]["xb"]).apply(null,arguments)};var _PL_raise_exception=Module["_PL_raise_exception"]=function(){return(_PL_raise_exception=Module["_PL_raise_exception"]=Module["asm"]["yb"]).apply(null,arguments)};var _PL_clear_exception=Module["_PL_clear_exception"]=function(){return(_PL_clear_exception=Module["_PL_clear_exception"]=Module["asm"]["zb"]).apply(null,arguments)};var _PL_put_nil=Module["_PL_put_nil"]=function(){return(_PL_put_nil=Module["_PL_put_nil"]=Module["asm"]["Ab"]).apply(null,arguments)};var _PL_atom_nchars=Module["_PL_atom_nchars"]=function(){return(_PL_atom_nchars=Module["_PL_atom_nchars"]=Module["asm"]["Bb"]).apply(null,arguments)};var _PL_atom_wchars=Module["_PL_atom_wchars"]=function(){return(_PL_atom_wchars=Module["_PL_atom_wchars"]=Module["asm"]["Cb"]).apply(null,arguments)};var _PL_is_integer=Module["_PL_is_integer"]=function(){return(_PL_is_integer=Module["_PL_is_integer"]=Module["asm"]["Db"]).apply(null,arguments)};var _PL_unify_uint64=Module["_PL_unify_uint64"]=function(){return(_PL_unify_uint64=Module["_PL_unify_uint64"]=Module["asm"]["Eb"]).apply(null,arguments)};var _PL_unify_float=Module["_PL_unify_float"]=function(){return(_PL_unify_float=Module["_PL_unify_float"]=Module["asm"]["Fb"]).apply(null,arguments)};var _PL_unify_nil=Module["_PL_unify_nil"]=function(){return(_PL_unify_nil=Module["_PL_unify_nil"]=Module["asm"]["Hb"]).apply(null,arguments)};var _PL_cons_functor_v=Module["_PL_cons_functor_v"]=function(){return(_PL_cons_functor_v=Module["_PL_cons_functor_v"]=Module["asm"]["Ib"]).apply(null,arguments)};var _PL_get_nil=Module["_PL_get_nil"]=function(){return(_PL_get_nil=Module["_PL_get_nil"]=Module["asm"]["Jb"]).apply(null,arguments)};var _PL_atom_chars=Module["_PL_atom_chars"]=function(){return(_PL_atom_chars=Module["_PL_atom_chars"]=Module["asm"]["Kb"]).apply(null,arguments)};var _PL_is_list=Module["_PL_is_list"]=function(){return(_PL_is_list=Module["_PL_is_list"]=Module["asm"]["Lb"]).apply(null,arguments)};var _PL_cons_functor=Module["_PL_cons_functor"]=function(){return(_PL_cons_functor=Module["_PL_cons_functor"]=Module["asm"]["Mb"]).apply(null,arguments)};var _PL_warning=Module["_PL_warning"]=function(){return(_PL_warning=Module["_PL_warning"]=Module["asm"]["Nb"]).apply(null,arguments)};var _PL_unify_chars=Module["_PL_unify_chars"]=function(){return(_PL_unify_chars=Module["_PL_unify_chars"]=Module["asm"]["Ob"]).apply(null,arguments)};var _PL_get_nchars=Module["_PL_get_nchars"]=function(){return(_PL_get_nchars=Module["_PL_get_nchars"]=Module["asm"]["Pb"]).apply(null,arguments)};var _PL_get_wchars=Module["_PL_get_wchars"]=function(){return(_PL_get_wchars=Module["_PL_get_wchars"]=Module["asm"]["Qb"]).apply(null,arguments)};var _PL_call_predicate=Module["_PL_call_predicate"]=function(){return(_PL_call_predicate=Module["_PL_call_predicate"]=Module["asm"]["Rb"]).apply(null,arguments)};var _PL_is_number=Module["_PL_is_number"]=function(){return(_PL_is_number=Module["_PL_is_number"]=Module["asm"]["Sb"]).apply(null,arguments)};var _PL_is_string=Module["_PL_is_string"]=function(){return(_PL_is_string=Module["_PL_is_string"]=Module["asm"]["Tb"]).apply(null,arguments)};var _PL_is_pair=Module["_PL_is_pair"]=function(){return(_PL_is_pair=Module["_PL_is_pair"]=Module["asm"]["Ub"]).apply(null,arguments)};var _PL_predicate=Module["_PL_predicate"]=function(){return(_PL_predicate=Module["_PL_predicate"]=Module["asm"]["Vb"]).apply(null,arguments)};var _PL_is_float=Module["_PL_is_float"]=function(){return(_PL_is_float=Module["_PL_is_float"]=Module["asm"]["Wb"]).apply(null,arguments)};var _PL_is_compound=Module["_PL_is_compound"]=function(){return(_PL_is_compound=Module["_PL_is_compound"]=Module["asm"]["Xb"]).apply(null,arguments)};var _PL_is_callable=Module["_PL_is_callable"]=function(){return(_PL_is_callable=Module["_PL_is_callable"]=Module["asm"]["Yb"]).apply(null,arguments)};var _PL_unify_compound=Module["_PL_unify_compound"]=function(){return(_PL_unify_compound=Module["_PL_unify_compound"]=Module["asm"]["Zb"]).apply(null,arguments)};var _PL_compare=Module["_PL_compare"]=function(){return(_PL_compare=Module["_PL_compare"]=Module["asm"]["_b"]).apply(null,arguments)};var _PL_unify_atom_nchars=Module["_PL_unify_atom_nchars"]=function(){return(_PL_unify_atom_nchars=Module["_PL_unify_atom_nchars"]=Module["asm"]["$b"]).apply(null,arguments)};var _PL_unify_wchars=Module["_PL_unify_wchars"]=function(){return(_PL_unify_wchars=Module["_PL_unify_wchars"]=Module["asm"]["ac"]).apply(null,arguments)};var _PL_get_atom_chars=Module["_PL_get_atom_chars"]=function(){return(_PL_get_atom_chars=Module["_PL_get_atom_chars"]=Module["asm"]["bc"]).apply(null,arguments)};var _PL_unify_bool=Module["_PL_unify_bool"]=function(){return(_PL_unify_bool=Module["_PL_unify_bool"]=Module["asm"]["cc"]).apply(null,arguments)};var _PL_get_chars=Module["_PL_get_chars"]=function(){return(_PL_get_chars=Module["_PL_get_chars"]=Module["asm"]["dc"]).apply(null,arguments)};var _PL_skip_list=Module["_PL_skip_list"]=function(){return(_PL_skip_list=Module["_PL_skip_list"]=Module["asm"]["ec"]).apply(null,arguments)};var _PL_is_atom=Module["_PL_is_atom"]=function(){return(_PL_is_atom=Module["_PL_is_atom"]=Module["asm"]["fc"]).apply(null,arguments)};var _PL_is_variable=Module["_PL_is_variable"]=function(){return(_PL_is_variable=Module["_PL_is_variable"]=Module["asm"]["gc"]).apply(null,arguments)};var _PL_unify_atom=Module["_PL_unify_atom"]=function(){return(_PL_unify_atom=Module["_PL_unify_atom"]=Module["asm"]["hc"]).apply(null,arguments)};var _PL_new_term_refs=Module["_PL_new_term_refs"]=function(){return(_PL_new_term_refs=Module["_PL_new_term_refs"]=Module["asm"]["ic"]).apply(null,arguments)};var _PL_put_atom=Module["_PL_put_atom"]=function(){return(_PL_put_atom=Module["_PL_put_atom"]=Module["asm"]["jc"]).apply(null,arguments)};var _PL_new_term_ref=Module["_PL_new_term_ref"]=function(){return(_PL_new_term_ref=Module["_PL_new_term_ref"]=Module["asm"]["kc"]).apply(null,arguments)};var _PL_unify=Module["_PL_unify"]=function(){return(_PL_unify=Module["_PL_unify"]=Module["asm"]["lc"]).apply(null,arguments)};var _PL_get_bool=Module["_PL_get_bool"]=function(){return(_PL_get_bool=Module["_PL_get_bool"]=Module["asm"]["mc"]).apply(null,arguments)};var _PL_get_float=Module["_PL_get_float"]=function(){return(_PL_get_float=Module["_PL_get_float"]=Module["asm"]["nc"]).apply(null,arguments)};var _PL_get_module=Module["_PL_get_module"]=function(){return(_PL_get_module=Module["_PL_get_module"]=Module["asm"]["oc"]).apply(null,arguments)};var _PL_erase=Module["_PL_erase"]=function(){return(_PL_erase=Module["_PL_erase"]=Module["asm"]["pc"]).apply(null,arguments)};var _PL_unify_string_nchars=Module["_PL_unify_string_nchars"]=function(){return(_PL_unify_string_nchars=Module["_PL_unify_string_nchars"]=Module["asm"]["qc"]).apply(null,arguments)};var _PL_get_intptr=Module["_PL_get_intptr"]=function(){return(_PL_get_intptr=Module["_PL_get_intptr"]=Module["asm"]["rc"]).apply(null,arguments)};var _PL_pred=Module["_PL_pred"]=function(){return(_PL_pred=Module["_PL_pred"]=Module["asm"]["sc"]).apply(null,arguments)};var _PL_is_blob=Module["_PL_is_blob"]=function(){return(_PL_is_blob=Module["_PL_is_blob"]=Module["asm"]["tc"]).apply(null,arguments)};var _PL_put_bool=Module["_PL_put_bool"]=function(){return(_PL_put_bool=Module["_PL_put_bool"]=Module["asm"]["uc"]).apply(null,arguments)};var _PL_unify_atom_chars=Module["_PL_unify_atom_chars"]=function(){return(_PL_unify_atom_chars=Module["_PL_unify_atom_chars"]=Module["asm"]["vc"]).apply(null,arguments)};var _PL_put_float=Module["_PL_put_float"]=function(){return(_PL_put_float=Module["_PL_put_float"]=Module["asm"]["wc"]).apply(null,arguments)};var _PL_put_pointer=Module["_PL_put_pointer"]=function(){return(_PL_put_pointer=Module["_PL_put_pointer"]=Module["asm"]["xc"]).apply(null,arguments)};var _PL_unify_int64=Module["_PL_unify_int64"]=function(){return(_PL_unify_int64=Module["_PL_unify_int64"]=Module["asm"]["yc"]).apply(null,arguments)};var _PL_get_atom=Module["_PL_get_atom"]=function(){return(_PL_get_atom=Module["_PL_get_atom"]=Module["asm"]["zc"]).apply(null,arguments)};var _PL_copy_term_ref=Module["_PL_copy_term_ref"]=function(){return(_PL_copy_term_ref=Module["_PL_copy_term_ref"]=Module["asm"]["Ac"]).apply(null,arguments)};var _PL_unify_integer=Module["_PL_unify_integer"]=function(){return(_PL_unify_integer=Module["_PL_unify_integer"]=Module["asm"]["Bc"]).apply(null,arguments)};var _PL_put_int64=Module["_PL_put_int64"]=function(){return(_PL_put_int64=Module["_PL_put_int64"]=Module["asm"]["Cc"]).apply(null,arguments)};var _PL_set_prolog_flag=Module["_PL_set_prolog_flag"]=function(){return(_PL_set_prolog_flag=Module["_PL_set_prolog_flag"]=Module["asm"]["Dc"]).apply(null,arguments)};var _PL_get_file_name=Module["_PL_get_file_name"]=function(){return(_PL_get_file_name=Module["_PL_get_file_name"]=Module["asm"]["Ec"]).apply(null,arguments)};var _PL_unify_blob=Module["_PL_unify_blob"]=function(){return(_PL_unify_blob=Module["_PL_unify_blob"]=Module["asm"]["Fc"]).apply(null,arguments)};var _PL_get_blob=Module["_PL_get_blob"]=function(){return(_PL_get_blob=Module["_PL_get_blob"]=Module["asm"]["Gc"]).apply(null,arguments)};var _PL_blob_data=Module["_PL_blob_data"]=function(){return(_PL_blob_data=Module["_PL_blob_data"]=Module["asm"]["Hc"]).apply(null,arguments)};var _PL_new_module=Module["_PL_new_module"]=function(){return(_PL_new_module=Module["_PL_new_module"]=Module["asm"]["Ic"]).apply(null,arguments)};var _PL_put_string_chars=Module["_PL_put_string_chars"]=function(){return(_PL_put_string_chars=Module["_PL_put_string_chars"]=Module["asm"]["Jc"]).apply(null,arguments)};var _PL_set_resource_db_mem=Module["_PL_set_resource_db_mem"]=function(){return(_PL_set_resource_db_mem=Module["_PL_set_resource_db_mem"]=Module["asm"]["Kc"]).apply(null,arguments)};var _PL_on_halt=Module["_PL_on_halt"]=function(){return(_PL_on_halt=Module["_PL_on_halt"]=Module["asm"]["Lc"]).apply(null,arguments)};var _PL_exit_hook=Module["_PL_exit_hook"]=function(){return(_PL_exit_hook=Module["_PL_exit_hook"]=Module["asm"]["Mc"]).apply(null,arguments)};var _PL_cleanup=Module["_PL_cleanup"]=function(){return(_PL_cleanup=Module["_PL_cleanup"]=Module["asm"]["Nc"]).apply(null,arguments)};var _PL_unify_string_chars=Module["_PL_unify_string_chars"]=function(){return(_PL_unify_string_chars=Module["_PL_unify_string_chars"]=Module["asm"]["Oc"]).apply(null,arguments)};var _PL_put_variable=Module["_PL_put_variable"]=function(){return(_PL_put_variable=Module["_PL_put_variable"]=Module["asm"]["Pc"]).apply(null,arguments)};var _PL_is_atomic=Module["_PL_is_atomic"]=function(){return(_PL_is_atomic=Module["_PL_is_atomic"]=Module["asm"]["Qc"]).apply(null,arguments)};var _PL_recorded=Module["_PL_recorded"]=function(){return(_PL_recorded=Module["_PL_recorded"]=Module["asm"]["Rc"]).apply(null,arguments)};var _PL_record=Module["_PL_record"]=function(){return(_PL_record=Module["_PL_record"]=Module["asm"]["Sc"]).apply(null,arguments)};var _PL_put_functor=Module["_PL_put_functor"]=function(){return(_PL_put_functor=Module["_PL_put_functor"]=Module["asm"]["Tc"]).apply(null,arguments)};var _PL_strip_module=Module["_PL_strip_module"]=function(){return(_PL_strip_module=Module["_PL_strip_module"]=Module["asm"]["Uc"]).apply(null,arguments)};var _PL_unify_list=Module["_PL_unify_list"]=function(){return(_PL_unify_list=Module["_PL_unify_list"]=Module["asm"]["Vc"]).apply(null,arguments)};var _PL_register_foreign_in_module=Module["_PL_register_foreign_in_module"]=function(){return(_PL_register_foreign_in_module=Module["_PL_register_foreign_in_module"]=Module["asm"]["Wc"]).apply(null,arguments)};var _PL_foreign_control=Module["_PL_foreign_control"]=function(){return(_PL_foreign_control=Module["_PL_foreign_control"]=Module["asm"]["Xc"]).apply(null,arguments)};var _PL_foreign_context_address=Module["_PL_foreign_context_address"]=function(){return(_PL_foreign_context_address=Module["_PL_foreign_context_address"]=Module["asm"]["Yc"]).apply(null,arguments)};var _PL_reset_term_refs=Module["_PL_reset_term_refs"]=function(){return(_PL_reset_term_refs=Module["_PL_reset_term_refs"]=Module["asm"]["Zc"]).apply(null,arguments)};var _PL_new_atom_nchars=Module["_PL_new_atom_nchars"]=function(){return(_PL_new_atom_nchars=Module["_PL_new_atom_nchars"]=Module["asm"]["_c"]).apply(null,arguments)};var _PL_new_atom_mbchars=Module["_PL_new_atom_mbchars"]=function(){return(_PL_new_atom_mbchars=Module["_PL_new_atom_mbchars"]=Module["asm"]["$c"]).apply(null,arguments)};var _PL_new_functor=Module["_PL_new_functor"]=function(){return(_PL_new_functor=Module["_PL_new_functor"]=Module["asm"]["ad"]).apply(null,arguments)};var _PL_functor_name=Module["_PL_functor_name"]=function(){return(_PL_functor_name=Module["_PL_functor_name"]=Module["asm"]["bd"]).apply(null,arguments)};var _PL_functor_arity=Module["_PL_functor_arity"]=function(){return(_PL_functor_arity=Module["_PL_functor_arity"]=Module["asm"]["cd"]).apply(null,arguments)};var _PL_new_atom_wchars=Module["_PL_new_atom_wchars"]=function(){return(_PL_new_atom_wchars=Module["_PL_new_atom_wchars"]=Module["asm"]["dd"]).apply(null,arguments)};var _PL_unify_wchars_diff=Module["_PL_unify_wchars_diff"]=function(){return(_PL_unify_wchars_diff=Module["_PL_unify_wchars_diff"]=Module["asm"]["ed"]).apply(null,arguments)};var _PL_same_compound=Module["_PL_same_compound"]=function(){return(_PL_same_compound=Module["_PL_same_compound"]=Module["asm"]["fd"]).apply(null,arguments)};var _PL_cons_list=Module["_PL_cons_list"]=function(){return(_PL_cons_list=Module["_PL_cons_list"]=Module["asm"]["gd"]).apply(null,arguments)};var _PL_get_atom_nchars=Module["_PL_get_atom_nchars"]=function(){return(_PL_get_atom_nchars=Module["_PL_get_atom_nchars"]=Module["asm"]["hd"]).apply(null,arguments)};var _PL_get_list_nchars=Module["_PL_get_list_nchars"]=function(){return(_PL_get_list_nchars=Module["_PL_get_list_nchars"]=Module["asm"]["id"]).apply(null,arguments)};var _PL_get_list_chars=Module["_PL_get_list_chars"]=function(){return(_PL_get_list_chars=Module["_PL_get_list_chars"]=Module["asm"]["jd"]).apply(null,arguments)};var _PL_quote=Module["_PL_quote"]=function(){return(_PL_quote=Module["_PL_quote"]=Module["asm"]["kd"]).apply(null,arguments)};var _PL_get_integer=Module["_PL_get_integer"]=function(){return(_PL_get_integer=Module["_PL_get_integer"]=Module["asm"]["ld"]).apply(null,arguments)};var _PL_get_long=Module["_PL_get_long"]=function(){return(_PL_get_long=Module["_PL_get_long"]=Module["asm"]["md"]).apply(null,arguments)};var _PL_get_int64=Module["_PL_get_int64"]=function(){return(_PL_get_int64=Module["_PL_get_int64"]=Module["asm"]["nd"]).apply(null,arguments)};var _PL_get_pointer=Module["_PL_get_pointer"]=function(){return(_PL_get_pointer=Module["_PL_get_pointer"]=Module["asm"]["od"]).apply(null,arguments)};var _PL_get_name_arity=Module["_PL_get_name_arity"]=function(){return(_PL_get_name_arity=Module["_PL_get_name_arity"]=Module["asm"]["pd"]).apply(null,arguments)};var _PL_get_compound_name_arity=Module["_PL_get_compound_name_arity"]=function(){return(_PL_get_compound_name_arity=Module["_PL_get_compound_name_arity"]=Module["asm"]["qd"]).apply(null,arguments)};var _PL_get_functor=Module["_PL_get_functor"]=function(){return(_PL_get_functor=Module["_PL_get_functor"]=Module["asm"]["rd"]).apply(null,arguments)};var _PL_get_arg=Module["_PL_get_arg"]=function(){return(_PL_get_arg=Module["_PL_get_arg"]=Module["asm"]["sd"]).apply(null,arguments)};var _PL_get_list=Module["_PL_get_list"]=function(){return(_PL_get_list=Module["_PL_get_list"]=Module["asm"]["td"]).apply(null,arguments)};var _PL_get_head=Module["_PL_get_head"]=function(){return(_PL_get_head=Module["_PL_get_head"]=Module["asm"]["ud"]).apply(null,arguments)};var _PL_get_tail=Module["_PL_get_tail"]=function(){return(_PL_get_tail=Module["_PL_get_tail"]=Module["asm"]["vd"]).apply(null,arguments)};var _PL_is_functor=Module["_PL_is_functor"]=function(){return(_PL_is_functor=Module["_PL_is_functor"]=Module["asm"]["wd"]).apply(null,arguments)};var _PL_put_atom_nchars=Module["_PL_put_atom_nchars"]=function(){return(_PL_put_atom_nchars=Module["_PL_put_atom_nchars"]=Module["asm"]["xd"]).apply(null,arguments)};var _PL_put_string_nchars=Module["_PL_put_string_nchars"]=function(){return(_PL_put_string_nchars=Module["_PL_put_string_nchars"]=Module["asm"]["yd"]).apply(null,arguments)};var _PL_put_chars=Module["_PL_put_chars"]=function(){return(_PL_put_chars=Module["_PL_put_chars"]=Module["asm"]["zd"]).apply(null,arguments)};var _PL_put_list_ncodes=Module["_PL_put_list_ncodes"]=function(){return(_PL_put_list_ncodes=Module["_PL_put_list_ncodes"]=Module["asm"]["Ad"]).apply(null,arguments)};var _PL_put_list_nchars=Module["_PL_put_list_nchars"]=function(){return(_PL_put_list_nchars=Module["_PL_put_list_nchars"]=Module["asm"]["Bd"]).apply(null,arguments)};var _PL_put_list_chars=Module["_PL_put_list_chars"]=function(){return(_PL_put_list_chars=Module["_PL_put_list_chars"]=Module["asm"]["Cd"]).apply(null,arguments)};var _PL_put_integer=Module["_PL_put_integer"]=function(){return(_PL_put_integer=Module["_PL_put_integer"]=Module["asm"]["Dd"]).apply(null,arguments)};var _PL_put_list=Module["_PL_put_list"]=function(){return(_PL_put_list=Module["_PL_put_list"]=Module["asm"]["Ed"]).apply(null,arguments)};var _PL_put_term=Module["_PL_put_term"]=function(){return(_PL_put_term=Module["_PL_put_term"]=Module["asm"]["Fd"]).apply(null,arguments)};var _PL_unify_functor=Module["_PL_unify_functor"]=function(){return(_PL_unify_functor=Module["_PL_unify_functor"]=Module["asm"]["Gd"]).apply(null,arguments)};var _PL_unify_list_ncodes=Module["_PL_unify_list_ncodes"]=function(){return(_PL_unify_list_ncodes=Module["_PL_unify_list_ncodes"]=Module["asm"]["Hd"]).apply(null,arguments)};var _PL_unify_list_nchars=Module["_PL_unify_list_nchars"]=function(){return(_PL_unify_list_nchars=Module["_PL_unify_list_nchars"]=Module["asm"]["Id"]).apply(null,arguments)};var _PL_unify_list_chars=Module["_PL_unify_list_chars"]=function(){return(_PL_unify_list_chars=Module["_PL_unify_list_chars"]=Module["asm"]["Jd"]).apply(null,arguments)};var _PL_unify_pointer=Module["_PL_unify_pointer"]=function(){return(_PL_unify_pointer=Module["_PL_unify_pointer"]=Module["asm"]["Kd"]).apply(null,arguments)};var _PL_unify_arg=Module["_PL_unify_arg"]=function(){return(_PL_unify_arg=Module["_PL_unify_arg"]=Module["asm"]["Ld"]).apply(null,arguments)};var _PL_unify_term=Module["_PL_unify_term"]=function(){return(_PL_unify_term=Module["_PL_unify_term"]=Module["asm"]["Md"]).apply(null,arguments)};var _PL_put_blob=Module["_PL_put_blob"]=function(){return(_PL_put_blob=Module["_PL_put_blob"]=Module["asm"]["Nd"]).apply(null,arguments)};var _PL_put_dict=Module["_PL_put_dict"]=function(){return(_PL_put_dict=Module["_PL_put_dict"]=Module["asm"]["Od"]).apply(null,arguments)};var _PL_term_type=Module["_PL_term_type"]=function(){return(_PL_term_type=Module["_PL_term_type"]=Module["asm"]["Pd"]).apply(null,arguments)};var _PL_context=Module["_PL_context"]=function(){return(_PL_context=Module["_PL_context"]=Module["asm"]["Qd"]).apply(null,arguments)};var _PL_module_name=Module["_PL_module_name"]=function(){return(_PL_module_name=Module["_PL_module_name"]=Module["asm"]["Rd"]).apply(null,arguments)};var _PL_predicate_info=Module["_PL_predicate_info"]=function(){return(_PL_predicate_info=Module["_PL_predicate_info"]=Module["asm"]["Sd"]).apply(null,arguments)};var _PL_call=Module["_PL_call"]=function(){return(_PL_call=Module["_PL_call"]=Module["asm"]["Td"]).apply(null,arguments)};var _PL_foreign_context=Module["_PL_foreign_context"]=function(){return(_PL_foreign_context=Module["_PL_foreign_context"]=Module["asm"]["Ud"]).apply(null,arguments)};var _PL_foreign_context_predicate=Module["_PL_foreign_context_predicate"]=function(){return(_PL_foreign_context_predicate=Module["_PL_foreign_context_predicate"]=Module["asm"]["Vd"]).apply(null,arguments)};var _PL_register_extensions_in_module=Module["_PL_register_extensions_in_module"]=function(){return(_PL_register_extensions_in_module=Module["_PL_register_extensions_in_module"]=Module["asm"]["Wd"]).apply(null,arguments)};var _PL_register_extensions=Module["_PL_register_extensions"]=function(){return(_PL_register_extensions=Module["_PL_register_extensions"]=Module["asm"]["Xd"]).apply(null,arguments)};var _PL_register_foreign=Module["_PL_register_foreign"]=function(){return(_PL_register_foreign=Module["_PL_register_foreign"]=Module["asm"]["Yd"]).apply(null,arguments)};var _PL_abort_hook=Module["_PL_abort_hook"]=function(){return(_PL_abort_hook=Module["_PL_abort_hook"]=Module["asm"]["Zd"]).apply(null,arguments)};var _PL_abort_unhook=Module["_PL_abort_unhook"]=function(){return(_PL_abort_unhook=Module["_PL_abort_unhook"]=Module["asm"]["_d"]).apply(null,arguments)};var _PL_dispatch_hook=Module["_PL_dispatch_hook"]=function(){return(_PL_dispatch_hook=Module["_PL_dispatch_hook"]=Module["asm"]["$d"]).apply(null,arguments)};var _PL_duplicate_record=Module["_PL_duplicate_record"]=function(){return(_PL_duplicate_record=Module["_PL_duplicate_record"]=Module["asm"]["ae"]).apply(null,arguments)};var _PL_action=Module["_PL_action"]=function(){return(_PL_action=Module["_PL_action"]=Module["asm"]["be"]).apply(null,arguments)};var _PL_query=Module["_PL_query"]=function(){return(_PL_query=Module["_PL_query"]=Module["asm"]["ce"]).apply(null,arguments)};var __PL_streams=Module["__PL_streams"]=function(){return(__PL_streams=Module["__PL_streams"]=Module["asm"]["de"]).apply(null,arguments)};var _PL_get_file_nameW=Module["_PL_get_file_nameW"]=function(){return(_PL_get_file_nameW=Module["_PL_get_file_nameW"]=Module["asm"]["ee"]).apply(null,arguments)};var _WASM_ttymode=Module["_WASM_ttymode"]=function(){return(_WASM_ttymode=Module["_WASM_ttymode"]=Module["asm"]["fe"]).apply(null,arguments)};var _WASM_variable_id=Module["_WASM_variable_id"]=function(){return(_WASM_variable_id=Module["_WASM_variable_id"]=Module["asm"]["ge"]).apply(null,arguments)};var _WASM_yield_request=Module["_WASM_yield_request"]=function(){return(_WASM_yield_request=Module["_WASM_yield_request"]=Module["asm"]["he"]).apply(null,arguments)};var _WASM_set_yield_result=Module["_WASM_set_yield_result"]=function(){return(_WASM_set_yield_result=Module["_WASM_set_yield_result"]=Module["asm"]["ie"]).apply(null,arguments)};var _js_unify_obj=Module["_js_unify_obj"]=function(){return(_js_unify_obj=Module["_js_unify_obj"]=Module["asm"]["je"]).apply(null,arguments)};var _js_get_obj=Module["_js_get_obj"]=function(){return(_js_get_obj=Module["_js_get_obj"]=Module["asm"]["ke"]).apply(null,arguments)};var ___funcs_on_exit=Module["___funcs_on_exit"]=function(){return(___funcs_on_exit=Module["___funcs_on_exit"]=Module["asm"]["le"]).apply(null,arguments)};var _fflush=Module["_fflush"]=function(){return(_fflush=Module["_fflush"]=Module["asm"]["me"]).apply(null,arguments)};var _emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=function(){return(_emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=Module["asm"]["ne"]).apply(null,arguments)};var _setThrew=Module["_setThrew"]=function(){return(_setThrew=Module["_setThrew"]=Module["asm"]["oe"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["pe"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["qe"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["re"]).apply(null,arguments)};function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiji(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ij(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;Module["addRunDependency"]=addRunDependency;Module["removeRunDependency"]=removeRunDependency;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;Module["cwrap"]=cwrap;Module["setValue"]=setValue;Module["getValue"]=getValue;Module["intArrayFromString"]=intArrayFromString;Module["FS"]=FS;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["allocate"]=allocate;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();const class_var=class PrologVar{constructor(id){this.$t="v";if(id!==undefined)this.v=id}};const class_string=class PrologString{constructor(string){this.$t="s";this.v=string}toString(){return this.v}toJSON(){return this.v}};const class_rational=class PrologRational{constructor(n,d){this.$t="r";this.n=n;this.d=d}toNumber(){return Number(this.d)/Number(this.n)}toString(){return this.d+"r"+this.n}toJSON(){return this.toString()}};const class_compound=class PrologCompound{constructor(name,args){this.$t="t";this.functor=name;this[name]=args}arguments(){return this[this.functor]}arg(n){return this.arguments[n]}arity(){return this.arguments.length}toJSON(){const obj={$t:"t"};obj[this.functor]=this.arguments();return obj}};const class_list=class PrologList{constructor(array,tail){this.$t="l";this.v=array;if(tail!==undefined)this.t=tail}};const class_blob=class PrologBlob{constructor(){this.$t="b"}};const class_abortable_promise=class AbortablePromise extends Promise{constructor(executer){super(executer);this.executer=executer}abort(){if(this.executer.abort)return this.executer.abort();else console.log("Cannot abort promise");return false}};class Prolog{constructor(module,args){this.module=module;this.args=args;this.lastyieldat=0;this.functor_arg_names_={};this.objects={};this.object_ids=new WeakMap;this.next_object_id=0;this.open_queries=[];this.__set_foreign_constants();this.__bind_foreign_functions();this.__export_classes();this.__initialize()}__initialize(){let argv0=this.args||[];argv0.unshift("swipl");let argv=argv0.map(function(arg){return this.module.allocate(this.module.intArrayFromString(arg),"i8",this.module.ALLOC_NORMAL)},this);var ptr=this.module._malloc(argv.length*4);argv.forEach(function(arg,i){this.module.setValue(ptr+i*4,arg,"*")},this);if(!this.bindings.PL_initialise(argv.length,ptr)){throw new Error("SWI-Prolog initialisation failed.")}this.MODULE_user=this.new_module("user");this.call("set_prolog_flag(color_term, false).");this.call("set_prolog_flag(debug_on_error, false)");this.call("use_module(library(wasm))")}__export_classes(){this.Var=class_var;this.String=class_string;this.Rational=class_rational;this.Compound=class_compound;this.List=class_list;this.Blob=class_blob;this.Promise=class_abortable_promise}__set_foreign_constants(){this.PL_VARIABLE=1;this.PL_ATOM=2;this.PL_INTEGER=3;this.PL_RATIONAL=4;this.PL_FLOAT=5;this.PL_STRING=6;this.PL_TERM=7;this.PL_NIL=8;this.PL_BLOB=9;this.PL_LIST_PAIR=10;this.PL_FUNCTOR=11;this.PL_LIST=12;this.PL_CHARS=13;this.PL_POINTER=14;this.PL_CODE_LIST=15;this.PL_CHAR_LIST=16;this.PL_BOOL=17;this.PL_FUNCTOR_CHARS=18;this._PL_PREDICATE_INDICATOR=19;this.PL_SHORT=20;this.PL_INT=21;this.PL_LONG=22;this.PL_DOUBLE=23;this.PL_NCHARS=24;this.PL_UTF8_CHARS=25;this.PL_UTF8_STRING=26;this.PL_INT64=27;this.PL_NUTF8_CHARS=28;this.PL_NUTF8_CODES=29;this.PL_NUTF8_STRING=30;this.PL_NWCHARS=31;this.PL_NWCODES=32;this.PL_NWSTRING=33;this.PL_MBCHARS=34;this.PL_MBCODES=35;this.PL_MBSTRING=36;this.PL_INTPTR=37;this.PL_CHAR=38;this.PL_CODE=39;this.PL_BYTE=40;this.PL_PARTIAL_LIST=41;this.PL_CYCLIC_TERM=42;this.PL_NOT_A_LIST=43;this.PL_DICT=44;this.REP_ISO_LATIN_1=0;this.REP_UTF8=1048576;this.REP_MB=2097152;this.REP_FN=this.REP_UTF8;this.CVT_ATOM=1;this.CVT_STRING=2;this.CVT_LIST=4;this.CVT_INTEGER=8;this.CVT_RATIONAL=16;this.CVT_FLOAT=32;this.CVT_VARIABLE=64;this.CVT_NUMBER=this.CVT_INTEGER|this.CVT_RATIONAL|this.CVT_FLOAT;this.CVT_ATOMIC=this.CVT_NUMBER|this.CVT_ATOM|this.CVT_STRING;this.CVT_WRITE=128;this.CVT_WRITE_CANONICAL=256;this.CVT_WRITEQ=512;this.CVT_ALL=this.CVT_ATOMIC|this.CVT_LIST;this.CVT_MASK=4095;this.CVT_EXCEPTION=4096;this.CVT_VARNOFAIL=8192;this.BUF_DISCARDABLE=0;this.BUF_STACK=65536;this.BUF_MALLOC=131072;this.BUF_ALLOW_STACK=262144;this.PL_Q_NORMAL=2;this.PL_Q_NODEBUG=4;this.PL_Q_CATCH_EXCEPTION=8;this.PL_Q_PASS_EXCEPTION=16;this.PL_Q_ALLOW_YIELD=32;this.PL_Q_EXT_STATUS=64;this.PL_S_EXCEPTION=-1;this.PL_S_FALSE=0;this.PL_S_TRUE=1;this.PL_S_LAST=2;this.PL_S_YIELD=255;this.PL_WRT_QUOTED=1;this.PL_WRT_NEWLINE=8192}__bind_foreign_functions(){this.bindings={_PL_streams:this.module.cwrap("_PL_streams","number",[]),PL_functor_arity:this.module.cwrap("PL_functor_arity","number",["number"]),PL_functor_name:this.module.cwrap("PL_functor_name","number",["number"]),PL_get_functor:this.module.cwrap("PL_get_functor","number",["number","number"]),PL_get_chars:this.module.cwrap("PL_get_chars","number",["number","number","number"]),PL_get_arg:this.module.cwrap("PL_get_arg","number",["number","number","number"]),PL_get_int64:this.module.cwrap("PL_get_int64","number",["number","number"]),PL_get_float:this.module.cwrap("PL_get_float","number",["number","number"]),PL_put_chars:this.module.cwrap("PL_put_chars","number",["number","number","number","number"]),put_bytes:this.module.cwrap("PL_put_chars","number",["number","number","number","array"]),PL_put_atom:this.module.cwrap("PL_put_atom","number",["number"]),PL_put_variable:this.module.cwrap("PL_put_variable","number",["number"]),PL_unify:this.module.cwrap("PL_unify","number",["number","number"]),PL_is_string:this.module.cwrap("PL_is_string","number",["number"]),PL_is_variable:this.module.cwrap("PL_is_variable","number",["number"]),PL_term_type:this.module.cwrap("PL_term_type","number",["number"]),PL_get_list:this.module.cwrap("PL_get_list","number",["number","number","number"]),PL_get_nil:this.module.cwrap("PL_get_nil","number",["number"]),PL_initialise:this.module.cwrap("PL_initialise","number",["number","number"]),PL_new_atom:this.module.cwrap("PL_new_atom","number",["string"]),PL_register_atom:this.module.cwrap("PL_register_atom",null,["number"]),PL_unregister_atom:this.module.cwrap("PL_unregister_atom",null,["number"]),PL_new_module:this.module.cwrap("PL_new_module","number",["number"]),PL_new_functor:this.module.cwrap("PL_new_functor","number",["number","number"]),PL_new_term_ref:this.module.cwrap("PL_new_term_ref","number",[]),PL_new_term_refs:this.module.cwrap("PL_new_term_refs","number",["number"]),PL_copy_term_ref:this.module.cwrap("PL_copy_term_ref","number",["number"]),PL_reset_term_refs:this.module.cwrap("PL_reset_term_refs",null,["number"]),PL_put_functor:this.module.cwrap("PL_put_functor","number",["number","number"]),PL_put_integer:this.module.cwrap("PL_put_integer","number",["number","number"]),PL_put_float:this.module.cwrap("PL_put_float","number",["number","number"]),PL_put_nil:this.module.cwrap("PL_put_nil","number",[]),PL_cons_functor_v:this.module.cwrap("PL_cons_functor_v","number",["number","number","number"]),PL_cons_list:this.module.cwrap("PL_cons_list","number",["number","number","number"]),PL_put_dict:this.module.cwrap("PL_put_dict","number",["number","number","number","number","number"]),PL_put_term_from_chars:this.module.cwrap("PL_put_term_from_chars","number",["number","number","number","string"]),PL_put_term:this.module.cwrap("PL_put_term","number",["number","number"]),PL_write_term:this.module.cwrap("PL_write_term","number",["number","number","number","number"]),PL_call:this.module.cwrap("PL_call","number",["number","number"]),PL_open_foreign_frame:this.module.cwrap("PL_open_foreign_frame","number",[]),PL_close_foreign_frame:this.module.cwrap("PL_close_foreign_frame","number",["number"]),PL_discard_foreign_frame:this.module.cwrap("PL_close_foreign_frame","number",["number"]),PL_predicate:this.module.cwrap("PL_predicate","number",["number","number","number"]),PL_open_query:this.module.cwrap("PL_open_query","number",["number","number","number","number"]),PL_next_solution:this.module.cwrap("PL_next_solution","number",["number"]),PL_close_query:this.module.cwrap("PL_close_query","number",["number"]),PL_cut_query:this.module.cwrap("PL_cut_query","number",["number"]),PL_exception:this.module.cwrap("PL_exception","number",["number"]),PL_raise_exception:this.module.cwrap("PL_raise_exception","number",["number"]),WASM_ttymode:this.module.cwrap("WASM_ttymode","number",[]),WASM_yield_request:this.module.cwrap("WASM_yield_request","number",[]),WASM_set_yield_result:this.module.cwrap("WASM_set_yield_result","number",["number"]),WASM_variable_id:this.module.cwrap("WASM_variable_id","number",["number"]),js_unify_obj:this.module.cwrap("js_unify_obj","number",["number","number"]),js_get_obj:this.module.cwrap("js_get_obj","number",["number"])}}call(goal,opts){opts=opts||{};if(typeof goal==="string"){if(opts.async){return this.__call_yieldable(goal,opts)}else{return this.with_frame(function(){const term=this.new_term_ref();if(!this.chars_to_term(goal,term))throw new Error("Query has a syntax error: "+query);const module=opts.module?this.new_module(opts.module):this.MODULE_user;return!!this.bindings.PL_call(term,module)})}}}with_frame(f,persist){const fid=this.bindings.PL_open_foreign_frame();if(fid){const rc=f.call(this);if(persist===false)this.bindings.PL_discard_foreign_frame(fid);else this.bindings.PL_close_foreign_frame(fid);return rc}return false}__string_to_c(string){const len=this.module.lengthBytesUTF8(string);const ptr=this.module._malloc(len+1);this.module.stringToUTF8(string,ptr,len+1);return{ptr:ptr,length:len}}predicate(name,arity,module){if(arity===undefined){let ar=/^([^:]+):(.*)\/([0-9]+)$/.exec(name);if(ar){module=ar[1];name=ar[2];arity=parseInt(ar[3])}else{ar=/(.*)\/([0-9]+)$/.exec(name);if(ar){name=ar[1];arity=parseInt(ar[2])}}if(arity===undefined)throw`Prolog.predicate: illegal specification: ${name}`}const c_name=allocateUTF8(name);const c_module=allocateUTF8(module||"user");const pred=this.bindings.PL_predicate(c_name,arity,c_module);this.module._free(c_name);this.module._free(c_module);return pred}new_module(name){const c_atom=this.new_atom(name);const module=this.bindings.PL_new_module(c_atom);this.unregister_atom(c_atom);return module}consult(...args){return this.forEach("load_files(user:Files)",{Files:args})}load_string(s,id){if(!id){this.__script_id=this.__script_id+1||1;id="/string/"+this.__script_id}return this.forEach("setup_call_cleanup("+"open_string(S, _In),"+"load_files(user:Id, [stream(_In)]),"+"close(_In))",{S:new this.String(s),Id:id})}async load_scripts(){const prolog=this;const scripts=document.querySelectorAll("script[type='text/prolog']");const loaded=[];for(let i=0;i{prolog.query(goal,{Event__:ev}).once()})}fetch(url,opts,type){return fetch(url,opts).then(response=>response[type]())}url_properties(url){return fetch(url,{method:"HEAD"}).then(r=>{if(r.status==200){const size=parseInt(r.headers.get("content-length"));const mods=r.headers.get("last-modified");const time=Date.parse(mods)||0;if(!size instanceof Number)size=-1;return{url:r.url,status:r.status,size:size,last_modified:time/1e3}}else{return{url:url,status:r.status}}})}message_to_string(term){return this.with_frame(()=>{const av=this.new_term_ref(2);this.bindings.PL_put_term(av+0,term);const flags=this.PL_Q_NORMAL;const pred=this.predicate("message_to_string/2");const qid=this.bindings.PL_open_query(0,flags,pred,av);let msg;if(this.bindings.PL_next_solution(qid))msg=this.get_chars(av+1);else msg="Unknown Prolog exception";this.bindings.PL_close_query(qid);return msg},false)}flush_output(stream){if(stream==undefined){flush("stderr");flush("stdout")}else{flush(stream)}}log(...args){log_output("stdout",args)}query(module,flags,pred,argv,map,fid){if(typeof argv==="number"){return new Query(this,module,flags,pred,argv,map)}else if(typeof module==="string"&&pred===undefined){const goal=module;const fid=this.bindings.PL_open_foreign_frame();const av=this.new_term_ref(3);const input=flags||{};this.frame=fid;this.put_chars(av+0,goal);this.toProlog(input,av+1);const q=new Query(this,0,this.PL_Q_CATCH_EXCEPTION,"wasm_call_string/3",av,a=>this.toJSON(a+2));q.from_text=true;return q}}forEach(goal,...args){const prolog=this;const fid=this.bindings.PL_open_foreign_frame();const av=this.new_term_ref(3);let callback;let input;if(typeof args[0]==="object"){input=args[0];callback=args[1]}else{input={};callback=args[0]}if(callback!==undefined&&typeof callback!=="function")throw TypeError("callback must be a function");this.frame=fid;this.put_chars(av+0,goal);this.toProlog(input,av+1);const q=new Query(this,this.MODULE_user,this.PL_Q_ALLOW_YIELD|this.PL_Q_CATCH_EXCEPTION,"wasm_call_string_with_heartbeat/3",av,a=>this.toJSON(a+2));return new Promise(function(resolve,reject){let answers=callback?0:[];function next_foreach(rc){while(true){if(rc.yield!==undefined){switch(rc.yield){case"beat":return setTimeout(()=>next_foreach(rc.resume("true")),0);case"builtin":return rc.resume(rc=>next_foreach(rc));default:throw rc}}else if(rc.value){if(callback){answers++;callback.call(prolog,rc.value)}else{answers.push(rc.value)}if(rc.done==false){rc=q.next_yieldable();continue}}q.close();if(rc.error)return reject(rc.message);if(rc.done)return resolve(answers)}}return next_foreach(q.next_yieldable())})}abort(){this.abort_request=true}promise_sleep(time){const f=function(resolve,reject){f.reject=reject;f.timer=setTimeout(()=>{f.timer=undefined;resolve(true)},time*1e3)};f.abort=function(){if(f.timer){clearTimeout(f.timer);f.timer=undefined;f.reject("abort")}};return new this.Promise(f)}stream(name){const iob=this.bindings._PL_streams();let offset=undefined;switch(name){case"user_input":offset=0;break;case"user_output":offset=1;break;case"user_error":offset=2;break;default:throw`Unknown stream ${name}`}return this.module.getValue(iob+offset*4,"i32")}write(term,opts){opts=opts||{};const precedence=opts.precedence||1200;const flags=opts.flags==undefined?this.PL_WRT_QUOTED|this.PL_WRT_NEWLINE:flags;let s=undefined;if(opts.stream){if(typeof stream==="string")s=this.stream(opts.stream)}else{s=this.stream("user_output")}return this.bindings.PL_write_term(s,term,precedence,flags)}functor_arity(functor){return this.bindings.PL_functor_arity(functor)}functor_name(functor){return this.bindings.PL_functor_name(functor)}get_functor(term){const ptr=this.module._malloc(4);let result;if(this.bindings.PL_get_functor(term,ptr))result=this.module.getValue(ptr,"i32");else result=null;this.module._free(ptr);return result}get_integer(term){const ptr=this.module._malloc(8);let rc;if(this.bindings.PL_get_int64(term,ptr)){rc=this.module.getValue(ptr,"i64");if(rc>=Number.MIN_SAFE_INTEGER&&rc<=Number.MAX_SAFE_INTEGER)rc=Number(rc)}else{const s=this.get_chars(term,this.CVT_INTEGER);rc=BigInt(s)}this.module._free(ptr);return rc}get_float(term){const ptr=this.module._malloc(8);let rc;if(this.bindings.PL_get_float(term,ptr)){rc=this.module.getValue(ptr,"double")}else{rc=null}this.module._free(ptr);return rc}put_chars(term,string,flags){flags=flags||this.PL_STRING;flags|=this.REP_UTF8;const c=this.__string_to_c(string);const ret=!!this.bindings.PL_put_chars(term,flags,c.length,c.ptr);this.module._free(c.ptr);return ret}put_bytes(term,array_buffer){const content=new Uint8Array(array_buffer);return!!this.bindings.put_bytes(term,this.PL_STRING|this.REP_ISO_LATIN_1,content.length,content)}put_bigint(term,value){const s=value.toString();return this.bindings.PL_put_term_from_chars(term,this.REP_UTF8,-1,s)}unify(term1,term2){return!!this.bindings.PL_unify(term1,term2)}is_string(term){return!!this.bindings.PL_is_string(term)}is_variable(term){return!!this.bindings.PL_is_variable(term)}atom_chars(atom){const t=this.new_term_ref();this.bindings.PL_put_atom(t,atom);const str=this.get_chars(t,this.CVT_ATOM);this.bindings.PL_reset_term_refs(t);return str}ttymode(){return this.module.UTF8ToString(this.bindings.WASM_ttymode())}yield_request(){const tref=this.bindings.WASM_yield_request();return this.toJSON(tref)}set_yield_result(obj){this.with_frame(()=>{const term=this.toProlog(obj,undefined,{string:"string"});if(!term){console.log("Could not convert",obj);throw"Could not convert JavaScript data to Prolog"}this.bindings.WASM_set_yield_result(term)},true)}__call_yieldable(goal,module){var pred_call1;const flags=this.PL_Q_NORMAL|this.PL_Q_ALLOW_YIELD;if(!pred_call1)pred_call1=this.predicate("call",1,"system");const fid=this.bindings.PL_open_foreign_frame();const term=this.new_term_ref();if(!this.chars_to_term(goal,term))throw new Error("Query has a syntax error: "+query);const q=this.query(module,flags,pred_call1,term,fid);return q.next_yieldable()}set_arg_names(name,args){if(!this.functor_arg_names_[name])this.functor_arg_names_[name]={};this.functor_arg_names_[name][args.length]=args}arg_names(name,arity){if(this.functor_arg_names_[name])return this.functor_arg_names_[name][arity]}toJSON(term,options){options=options||{};function toJSON(prolog,term,options){switch(prolog.bindings.PL_term_type(term)){case prolog.PL_VARIABLE:return new prolog.Var(prolog.bindings.WASM_variable_id(term));case prolog.PL_STRING:if(options.string!=="string")return new prolog.String(prolog.get_chars(term));case prolog.PL_ATOM:return prolog.get_chars(term);case prolog.PL_NIL:return[];case prolog.PL_BLOB:{const id=prolog.bindings.js_get_obj(term);if(id!=-1)return prolog.objects[id];return new prolog.Blob}case prolog.PL_INTEGER:return prolog.get_integer(term);case prolog.PL_RATIONAL:{let s=prolog.get_chars(term,prolog.CVT_RATIONAL);let a=s.split("r");function toInt(s){const bi=BigInt(s);if(bi>=Number.MIN_SAFE_INTEGER&&bi<=Number.MAX_SAFE_INTEGER)return Number(bi);return bi}return new prolog.Rational(toInt(a[0]),toInt(a[1]))}case prolog.PL_FLOAT:return prolog.get_float(term);case prolog.PL_TERM:{const f=prolog.get_functor(term);const name=prolog.atom_chars(prolog.functor_name(f));const arity=prolog.functor_arity(f);const map=prolog.arg_names(name,arity);const a=prolog.new_term_ref();if(map){let result={$tag:name};for(var i=0;i=0&&rc;i--){rc=toProlog(prolog,data[i],h,ctx)&&prolog.bindings.PL_cons_list(term,h,term)}return rc}switch(typeof data){case"number":if(Number.isInteger(data))rc=prolog.bindings.PL_put_integer(term,data);else rc=prolog.bindings.PL_put_float(term,data);break;case"bigint":rc=prolog.put_bigint(term,data);break;case"string":{const flags=ctx.string==="string"?prolog.PL_STRING:prolog.PL_ATOM;rc=prolog.put_chars(term,data,flags);break}case"boolean":rc=prolog.put_chars(term,data?"true":"false",prolog.PL_ATOM);break;case"undefined":rc=prolog.put_chars(term,"undefined",prolog.PL_ATOM);break;case"object":if(data===null){rc=prolog.put_chars(term,"null",prolog.PL_ATOM)}else if(Array.isArray(data)){rc=toList(term,data)}else if(data.$t){switch(data.$t){case"s":rc=prolog.put_chars(term,data.v,prolog.PL_STRING);break;case"r":{const s=data.n+"r"+data.d;rc=prolog.bindings.PL_put_term_from_chars(term,prolog.REP_UTF8,-1,s);break}case"t":{const keys=Object.keys(data);let args;let name;for(var i=0;i{prolog.set_yield_result(value);return this.next()}}}}}next_yieldable(){function next(query){const prolog=query.prolog;while(true){let rc=query.next();if(rc.yield!==undefined){let request=rc.yield;if(prolog.abort_request){prolog.abort_request=undefined;prolog.set_yield_result("abort");continue}if(request==="beat"){const now=Date.now();const passed=now-prolog.lastyieldat;if(passed<20){prolog.set_yield_result("true");continue}prolog.lastyieldat=now}else if(request instanceof Promise){let result={yield:"builtin",request:request,query:query,resume:cont=>{if(typeof cont==="string"){prolog.set_yield_result(cont);return next(query)}else{result.cont=cont;request.then(value=>{prolog.set_yield_result(value);cont.call(prolog,next(query))}).catch(error=>{prolog.set_yield_result({$error:error});cont.call(prolog,next(query))})}},abort:()=>{if(!(request.abort&&request.abort())){console.log("Cannot abort",request);prolog.abort_request=true}}};return result}rc.resume=value=>{prolog.set_yield_result(value);return next(query)}}else if(rc.done===false){rc.resume=()=>next(query)}return rc}}return next(this)}once(){const rc=this.next();this.close();if(this.from_text){delete rc.done;if(rc.value){rc.value.success=true;return rc.value}else{if(!rc.error)rc.success=false;return rc}}else{return rc.value?rc.value:rc}}close(){if(this.open){const prolog=this.prolog;if(this!=prolog.open_queries.at(-1))console.log("Attempt for Query.close() on not innermost query");prolog.open_queries.pop();this.prolog.bindings.PL_cut_query(this.qid);if(this.frame)this.prolog.bindings.PL_discard_foreign_frame(this.frame);this.open=false}}}Module.onRuntimeInitialized=function(){Module.prolog=new Prolog(Module,Module.arguments)};function prolog_js_call(request,result){const prolog=Module.prolog;function eval_chain(ar,obj){obj=obj||window;function eval_one(obj,fname,args){if(args.length==0){switch(fname){case"instanceof":return obj.constructor.name}}else if(args.length==1){switch(fname){case"-":return-args[0];case"!":return!args[0];case"instanceof":return obj instanceof args[0]}}else if(args.length==2){switch(fname){case"+":return args[0]+args[1];case"-":return args[0]-args[1];case"*":return args[0]*args[1];case"/":return args[0]/args[1];case"&":return args[0]&args[1];case"|":return args[0]|args[1];case"&&":return args[0]&&args[1];case"||":return args[0]||args[1]}}const func=obj[fname];if(typeof func==="function")return func.apply(obj,args);else console.log("ERROR: Function",fname,"is not defined on",obj)}for(let i=0;ieval_chain(v));obj=eval_one(obj,next.f,args)}}return obj}try{return prolog.with_frame(()=>{const ar=prolog.toJSON(request,{string:"string"});let obj;if(ar.setter){const target=eval_chain(ar.target);const value=eval_chain(ar.value);target[ar.setter]=value;obj=true}else{obj=eval_chain(ar)}return prolog.unify(result,prolog.toProlog(obj))},false)}catch(e){return prolog.bindings.PL_raise_exception(prolog.toProlog(new prolog.Compound("error",[new prolog.Compound("js_error",[e.toString()]),new prolog.Var])))}}function prolog_js_obj_class_name(id){const prolog=Module.prolog;const obj=prolog.objects[id];return obj.constructor.name}function release_registered_object(id){const prolog=Module.prolog;const obj=prolog.objects[id];prolog.object_ids.delete(obj);delete prolog.objects[id]}if(BigInt.prototype.toJSON===undefined){BigInt.prototype.toJSON=function(){return this.toString()}}if(typeof HTMLCollection==="object"){HTMLCollection.prototype.toList=function(){const ar=[];for(let i=0;i { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(SWIPL) { - SWIPL = SWIPL || {}; - -var Module=typeof SWIPL!="undefined"?SWIPL:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0}Module.expectedDataFileDownloads++;(function(){if(Module["ENVIRONMENT_IS_PTHREAD"])return;var loadPackage=function(metadata){var PACKAGE_PATH="";if(typeof window==="object"){PACKAGE_PATH=window["encodeURIComponent"](window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/")}else if(typeof process==="undefined"&&typeof location!=="undefined"){PACKAGE_PATH=encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/")}var PACKAGE_NAME="src/swipl-web.data";var REMOTE_PACKAGE_BASE="swipl-web.data";if(typeof Module["locateFilePackage"]==="function"&&!Module["locateFile"]){Module["locateFile"]=Module["locateFilePackage"];err("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)")}var REMOTE_PACKAGE_NAME=Module["locateFile"]?Module["locateFile"](REMOTE_PACKAGE_BASE,""):REMOTE_PACKAGE_BASE;var REMOTE_PACKAGE_SIZE=metadata["remote_package_size"];function fetchRemotePackage(packageName,packageSize,callback,errback){if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){require("fs").readFile(packageName,function(err,contents){if(err){errback(err)}else{callback(contents.buffer)}});return}var xhr=new XMLHttpRequest;xhr.open("GET",packageName,true);xhr.responseType="arraybuffer";xhr.onprogress=function(event){var url=packageName;var size=packageSize;if(event.total)size=event.total;if(event.loaded){if(!xhr.addedTotal){xhr.addedTotal=true;if(!Module.dataFileDownloads)Module.dataFileDownloads={};Module.dataFileDownloads[url]={loaded:event.loaded,total:size}}else{Module.dataFileDownloads[url].loaded=event.loaded}var total=0;var loaded=0;var num=0;for(var download in Module.dataFileDownloads){var data=Module.dataFileDownloads[download];total+=data.total;loaded+=data.loaded;num++}total=Math.ceil(total*Module.expectedDataFileDownloads/num);if(Module["setStatus"])Module["setStatus"]("Downloading data... ("+loaded+"/"+total+")")}else if(!Module.dataFileDownloads){if(Module["setStatus"])Module["setStatus"]("Downloading data...")}};xhr.onerror=function(event){throw new Error("NetworkError for: "+packageName)};xhr.onload=function(event){if(xhr.status==200||xhr.status==304||xhr.status==206||xhr.status==0&&xhr.response){var packageData=xhr.response;callback(packageData)}else{throw new Error(xhr.statusText+" : "+xhr.responseURL)}};xhr.send(null)}function handleError(error){console.error("package error:",error)}var fetchedCallback=null;var fetched=Module["getPreloadedPackage"]?Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE):null;if(!fetched)fetchRemotePackage(REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE,function(data){if(fetchedCallback){fetchedCallback(data);fetchedCallback=null}else{fetched=data}},handleError);function runWithFS(){function assert(check,msg){if(!check)throw msg+(new Error).stack}Module["FS_createPath"]("/","swipl",true,true);Module["FS_createPath"]("/swipl","library",true,true);Module["FS_createPath"]("/swipl/library","iri_scheme",true,true);Module["FS_createPath"]("/swipl/library","http",true,true);Module["FS_createPath"]("/swipl/library","chr",true,true);Module["FS_createPath"]("/swipl/library","theme",true,true);Module["FS_createPath"]("/swipl/library","DTD",true,true);Module["FS_createPath"]("/swipl/library","lynx",true,true);Module["FS_createPath"]("/swipl/library","clp",true,true);Module["FS_createPath"]("/swipl/library/clp","clpqr",true,true);Module["FS_createPath"]("/swipl/library/clp","clpq",true,true);Module["FS_createPath"]("/swipl/library/clp","clpr",true,true);Module["FS_createPath"]("/swipl/library","dcg",true,true);Module["FS_createPath"]("/swipl/library","unicode",true,true);Module["FS_createPath"]("/swipl/library","build",true,true);Module["FS_createPath"]("/swipl/library","dialect",true,true);Module["FS_createPath"]("/swipl/library/dialect","swi",true,true);Module["FS_createPath"]("/swipl/library/dialect","xsb",true,true);Module["FS_createPath"]("/swipl/library/dialect","sicstus4",true,true);Module["FS_createPath"]("/swipl/library/dialect","eclipse",true,true);Module["FS_createPath"]("/swipl/library/dialect","yap",true,true);Module["FS_createPath"]("/swipl/library/dialect","sicstus",true,true);Module["FS_createPath"]("/swipl/library/dialect","hprolog",true,true);Module["FS_createPath"]("/swipl/library/dialect","iso",true,true);Module["FS_createPath"]("/swipl/library","semweb",true,true);function DataRequest(start,end,audio){this.start=start;this.end=end;this.audio=audio}DataRequest.prototype={requests:{},open:function(mode,name){this.name=name;this.requests[name]=this;Module["addRunDependency"]("fp "+this.name)},send:function(){},onload:function(){var byteArray=this.byteArray.subarray(this.start,this.end);this.finish(byteArray)},finish:function(byteArray){var that=this;Module["FS_createDataFile"](this.name,null,byteArray,true,true,true);Module["removeRunDependency"]("fp "+that.name);this.requests[this.name]=null}};var files=metadata["files"];for(var i=0;i{s+=a});Module.on_output(s,stream)}else{console.log.apply(null,args)}}function bind_std_streams(){decoder=new TextDecoder("utf-8");Module.FS.init(undefined,c=>write("stdout",c),c=>write("stderr",c))}if(Module.on_output){Module.preRun.push(bind_std_streams)}var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;function logExceptionOnExit(e){if(e instanceof ExitStatus)return;let toLog=e;err("exiting due to exception: "+toLog)}var fs;var nodePath;var requireNodeFS;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}requireNodeFS=()=>{if(!nodePath){fs=require("fs");nodePath=require("path")}};read_=function shell_read(filename,binary){requireNodeFS();filename=nodePath["normalize"](filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror)=>{requireNodeFS();filename=nodePath["normalize"](filename);fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer)})};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",function(reason){throw reason});quit_=(status,toThrow)=>{if(keepRuntimeAlive()){process["exitCode"]=status;throw toThrow}logExceptionOnExit(toThrow);process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=value=>{tempRet0=value};var getTempRet0=()=>tempRet0;var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||false;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf);Module["HEAP64"]=HEAP64=new BigInt64Array(buf);Module["HEAPU64"]=HEAPU64=new BigUint64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;var runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function exitRuntime(){___funcs_on_exit();callRuntimeCallbacks(__ATEXIT__);FS.quit();TTY.shutdown();runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){{if(Module["onAbort"]){Module["onAbort"](what)}}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="swipl-web.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["na"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Gb"];addOnInit(Module["asm"]["oa"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync().catch(readyPromiseReject);return{}}var ASM_CONSTS={270120:$0=>{release_registered_object($0)},270155:$0=>{const s=prolog_js_obj_class_name($0);const len=lengthBytesUTF8(s)+1;const mem=_malloc(len);stringToUTF8(s,mem,len);return mem},270298:($0,$1)=>{return prolog_js_call($0,$1)}};function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort("invalid type for getValue: "+type)}return null}function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort("invalid type for setValue: "+type)}}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}var wasmTableMirror=[];function getWasmTableEntry(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func}function ___call_sighandler(fp,sig){getWasmTableEntry(fp)(sig)}var PATH={isAbs:path=>path.charAt(0)==="/",splitPath:filename=>{var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(p=>!!p),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:path=>{if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:(l,r)=>{return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto=="object"&&typeof crypto["getRandomValues"]=="function"){var randomBuffer=new Uint8Array(1);return()=>{crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else if(ENVIRONMENT_IS_NODE){try{var crypto_module=require("crypto");return()=>crypto_module["randomBytes"](1)[0]}catch(e){}}return()=>abort("randomDevice")}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(p=>!!p),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:(from,to)=>{from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var TTY={ttys:[],init:function(){},shutdown:function(){},register:function(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open:function(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close:function(stream){stream.tty.ops.flush(stream.tty)},flush:function(stream){stream.tty.ops.flush(stream.tty)},read:function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function zeroMemory(address,size){HEAPU8.fill(0,address,address+size)}function alignMemory(size,alignment){return Math.ceil(size/alignment)*alignment}function mmapAlloc(size){size=alignMemory(size,65536);var ptr=_emscripten_builtin_memalign(65536,size);if(!ptr)return 0;zeroMemory(ptr,size);return ptr}var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray:function(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage:function(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).');onload(new Uint8Array(arrayBuffer));if(dep)removeRunDependency(dep)},event=>{if(onerror){onerror()}else{throw'Loading data file "'+url+'" failed.'}});if(dep)addRunDependency(dep)}var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(path,opts={})=>{path=PATH_FS.resolve(FS.cwd(),path);if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};opts=Object.assign(defaults,opts);if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=PATH.normalizeArray(path.split("/").filter(p=>!!p),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:node=>{var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:(parentid,name)=>{var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:node=>{var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:node=>{var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:(parent,name)=>{var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:(parent,name,mode,rdev)=>{var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:node=>{FS.hashRemoveNode(node)},isRoot:node=>{return node===node.parent},isMountpoint:node=>{return!!node.mounted},isFile:mode=>{return(mode&61440)===32768},isDir:mode=>{return(mode&61440)===16384},isLink:mode=>{return(mode&61440)===40960},isChrdev:mode=>{return(mode&61440)===8192},isBlkdev:mode=>{return(mode&61440)===24576},isFIFO:mode=>{return(mode&61440)===4096},isSocket:mode=>{return(mode&49152)===49152},flagModes:{"r":0,"r+":2,"w":577,"w+":578,"a":1089,"a+":1090},modeStringToFlags:str=>{var flags=FS.flagModes[str];if(typeof flags=="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:flag=>{var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:(node,perms)=>{if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup:dir=>{var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:(dir,name)=>{try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:(dir,name,isdir)=>{var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:(node,flags)=>{if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:(fd_start=0,fd_end=FS.MAX_OPEN_FDS)=>{for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:fd=>FS.streams[fd],createStream:(stream,fd_start,fd_end)=>{if(!FS.FSStream){FS.FSStream=function(){this.shared={}};FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(val){this.shared.flags=val}},position:{get:function(){return this.shared.position},set:function(val){this.shared.position=val}}})}stream=Object.assign(new FS.FSStream,stream);var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:fd=>{FS.streams[fd]=null},chrdev_stream_ops:{open:stream=>{var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:()=>{throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice:(dev,ops)=>{FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts:mount=>{var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:(populate,callback)=>{if(typeof populate=="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:(type,opts,mountpoint)=>{var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:mountpoint=>{var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:(parent,name)=>{return parent.node_ops.lookup(parent,name)},mknod:(path,mode,dev)=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:(path,mode)=>{mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:(path,mode)=>{mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:(path,mode)=>{var dirs=path.split("/");var d="";for(var i=0;i{if(typeof dev=="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink:(oldpath,newpath)=>{if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename:(old_path,new_path)=>{var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,"w");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir:path=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(54)}return node.node_ops.readdir(node)},unlink:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink:path=>{var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return PATH_FS.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))},stat:(path,dontFollow)=>{var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(44)}if(!node.node_ops.getattr){throw new FS.ErrnoError(63)}return node.node_ops.getattr(node)},lstat:path=>{return FS.stat(path,true)},chmod:(path,mode,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})},lchmod:(path,mode)=>{FS.chmod(path,mode,true)},fchmod:(fd,mode)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chmod(stream.node,mode)},chown:(path,uid,gid,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{timestamp:Date.now()})},lchown:(path,uid,gid)=>{FS.chown(path,uid,gid,true)},fchown:(fd,uid,gid)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chown(stream.node,uid,gid)},truncate:(path,len)=>{if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,"w");if(errCode){throw new FS.ErrnoError(errCode)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate:(fd,len)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.truncate(stream.node,len)},utime:(path,atime,mtime)=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open:(path,flags,mode)=>{if(path===""){throw new FS.ErrnoError(44)}flags=typeof flags=="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode=="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path=="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close:stream=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed:stream=>{return stream.fd===null},llseek:(stream,offset,whence)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read:(stream,buffer,offset,length,position)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write:(stream,buffer,offset,length,position,canOwn)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},allocate:(stream,offset,length)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(offset<0||length<=0){throw new FS.ErrnoError(28)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(stream.node.mode)){throw new FS.ErrnoError(43)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(138)}stream.stream_ops.allocate(stream,offset,length)},mmap:(stream,length,position,prot,flags)=>{if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync:(stream,buffer,offset,length,mmapFlags)=>{if(!stream||!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},munmap:stream=>0,ioctl:(stream,cmd,arg)=>{if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile:(path,opts={})=>{opts.flags=opts.flags||0;opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret},writeFile:(path,data,opts={})=>{opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data=="string"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,undefined,opts.canOwn)}else if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error("Unsupported data type")}FS.close(stream)},cwd:()=>FS.currentPath,chdir:path=>{var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,"x");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories:()=>{FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices:()=>{FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device=getRandomDevice();FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{FS.mkdir("/proc");var proc_self=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:()=>{var node=FS.createNode(proc_self,"fd",16384|511,73);node.node_ops={lookup:(parent,name)=>{var fd=+name;var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>stream.path}};ret.parent=ret;return ret}};return node}},{},"/proc/self/fd")},createStandardStreams:()=>{if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin",0);var stdout=FS.open("/dev/stdout",1);var stderr=FS.open("/dev/stderr",1)},ensureErrnoError:()=>{if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.node=node;this.setErrno=function(errno){this.errno=errno};this.setErrno(errno);this.message="FS error"};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[44].forEach(code=>{FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack=""})},staticInit:()=>{FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={"MEMFS":MEMFS}},init:(input,output,error)=>{FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()},quit:()=>{FS.init.initialized=false;_fflush(0);for(var i=0;i{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode},findObject:(path,dontResolveLastLink)=>{var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath:(path,dontResolveLastLink)=>{try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path==="/"}catch(e){ret.error=e.errno}return ret},createPath:(parent,path,canRead,canWrite)=>{parent=typeof parent=="string"?parent:FS.getPath(parent);var parts=path.split("/").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){}parent=current}return current},createFile:(parent,name,properties,canRead,canWrite)=>{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile:(parent,name,data,canRead,canWrite,canOwn)=>{var path=name;if(parent){parent=typeof parent=="string"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS.getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data=="string"){var arr=new Array(data.length);for(var i=0,len=data.length;i{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(!!input,!!output);if(!FS.createDevice.major)FS.createDevice.major=64;var dev=FS.makedev(FS.createDevice.major++,0);FS.registerDevice(dev,{open:stream=>{stream.seekable=false},close:stream=>{if(output&&output.buffer&&output.buffer.length){output(10)}},read:(stream,buffer,offset,length,pos)=>{var bytesRead=0;for(var i=0;i{for(var i=0;i{if(obj.isDevice||obj.isFolder||obj.link||obj.contents)return true;if(typeof XMLHttpRequest!="undefined"){throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")}else if(read_){try{obj.contents=intArrayFromString(read_(obj.url),true);obj.usedBytes=obj.contents.length}catch(e){throw new FS.ErrnoError(29)}}else{throw new Error("Cannot load without read() or XMLHttpRequest.")}},createLazyFile:(parent,name,url,canRead,canWrite)=>{function LazyUint8Array(){this.lengthKnown=false;this.chunks=[]}LazyUint8Array.prototype.get=function LazyUint8Array_get(idx){if(idx>this.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||"",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]=="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]=="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr:ptr,allocated:true}};node.stream_ops=stream_ops;return node},createPreloadedFile:(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency("cp "+fullname);function processData(byteArray){function finish(byteArray){if(preFinish)preFinish();if(!dontCreateFile){FS.createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}if(onload)onload();removeRunDependency(dep)}if(Browser.handledByPreloadPlugin(byteArray,fullname,finish,()=>{if(onerror)onerror();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url=="string"){asyncLoad(url,byteArray=>processData(byteArray),onerror)}else{processData(url)}},indexedDB:()=>{return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:()=>{return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=()=>{out("creating db");var db=openRequest.result;db.createObjectStore(FS.DB_STORE_NAME)};openRequest.onsuccess=()=>{var db=openRequest.result;var transaction=db.transaction([FS.DB_STORE_NAME],"readwrite");var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var putRequest=files.put(FS.analyzePath(path).object.contents,path);putRequest.onsuccess=()=>{ok++;if(ok+fail==total)finish()};putRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror},loadFilesFromDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=onerror;openRequest.onsuccess=()=>{var db=openRequest.result;try{var transaction=db.transaction([FS.DB_STORE_NAME],"readonly")}catch(e){onerror(e);return}var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var getRequest=files.get(path);getRequest.onsuccess=()=>{if(FS.analyzePath(path).exists){FS.unlink(path)}FS.createDataFile(PATH.dirname(path),PATH.basename(path),getRequest.result,true,true,true);ok++;if(ok+fail==total)finish()};getRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror}};var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=FS.getStream(dirfd);if(!dirstream)throw new FS.ErrnoError(8);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return PATH.join2(dir,path)},doStat:function(func,path,buf){try{var stat=func(path)}catch(e){if(e&&e.node&&PATH.normalize(path)!==PATH.normalize(FS.getPath(e.node))){return-54}throw e}HEAP32[buf>>2]=stat.dev;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP64[buf+40>>3]=BigInt(stat.size);HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;HEAP64[buf+56>>3]=BigInt(Math.floor(stat.atime.getTime()/1e3));HEAP32[buf+64>>2]=0;HEAP64[buf+72>>3]=BigInt(Math.floor(stat.mtime.getTime()/1e3));HEAP32[buf+80>>2]=0;HEAP64[buf+88>>3]=BigInt(Math.floor(stat.ctime.getTime()/1e3));HEAP32[buf+96>>2]=0;HEAP64[buf+104>>3]=BigInt(stat.ino);return 0},doMsync:function(addr,stream,len,flags,offset){var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream}};function ___syscall_chdir(path){try{path=SYSCALLS.getStr(path);FS.chdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_chmod(path,mode){try{path=SYSCALLS.getStr(path);FS.chmod(path,mode);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_dup3(fd,suggestFD,flags){try{var old=SYSCALLS.getStreamFromFD(fd);if(old.fd===suggestFD)return-28;var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.createStream(old,suggestFD,suggestFD+1).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_faccessat(dirfd,path,amode,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(amode&~7){return-28}var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.createStream(stream,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 5:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}var MAX_INT53=9007199254740992;var MIN_INT53=-9007199254740992;function bigintToI53Checked(num){return numMAX_INT53?NaN:Number(num)}function ___syscall_ftruncate64(fd,length){try{length=bigintToI53Checked(length);if(isNaN(length))return-61;FS.ftruncate(fd,length);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(size>3]=BigInt(id);HEAP64[dirp+pos+8>>3]=BigInt((idx+1)*struct_size);HEAP16[dirp+pos+16>>1]=280;HEAP8[dirp+pos+18>>0]=type;stringToUTF8(name,dirp+pos+19,256);pos+=struct_size;idx+=1}FS.llseek(stream,idx*struct_size,0);return pos}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(op){case 21509:case 21505:{if(!stream.tty)return-59;return 0}case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:{if(!stream.tty)return-59;return 0}case 21519:{if(!stream.tty)return-59;var argp=SYSCALLS.get();HEAP32[argp>>2]=0;return 0}case 21520:{if(!stream.tty)return-59;return-28}case 21531:{var argp=SYSCALLS.get();return FS.ioctl(stream,op,argp)}case 21523:{if(!stream.tty)return-59;return 0}case 21524:{if(!stream.tty)return-59;return 0}default:return-28}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_lstat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.lstat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_mkdirat(dirfd,path,mode){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_newfstatat(dirfd,path,buf,flags){try{path=SYSCALLS.getStr(path);var nofollow=flags&256;var allowEmpty=flags&4096;flags=flags&~4352;path=SYSCALLS.calculateAt(dirfd,path,allowEmpty);return SYSCALLS.doStat(nofollow?FS.lstat:FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs;try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);var mode=varargs?SYSCALLS.get():0;return FS.open(path,flags,mode).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_poll(fds,nfds,timeout){try{var nonzero=0;for(var i=0;i>2];var events=HEAP16[pollfd+4>>1];var mask=32;var stream=FS.getStream(fd);if(stream){mask=SYSCALLS.DEFAULT_POLLMASK;if(stream.stream_ops.poll){mask=stream.stream_ops.poll(stream)}}mask&=events|8|16;if(mask)nonzero++;HEAP16[pollfd+6>>1]=mask}return nonzero}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_readlinkat(dirfd,path,buf,bufsize){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_renameat(olddirfd,oldpath,newdirfd,newpath){try{oldpath=SYSCALLS.getStr(oldpath);newpath=SYSCALLS.getStr(newpath);oldpath=SYSCALLS.calculateAt(olddirfd,oldpath);newpath=SYSCALLS.calculateAt(newdirfd,newpath);FS.rename(oldpath,newpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_rmdir(path){try{path=SYSCALLS.getStr(path);FS.rmdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_stat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_symlink(target,linkpath){try{target=SYSCALLS.getStr(target);linkpath=SYSCALLS.getStr(linkpath);FS.symlink(target,linkpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_unlinkat(dirfd,path,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(flags===0){FS.unlink(path)}else if(flags===512){FS.rmdir(path)}else{abort("Invalid flags passed to unlinkat")}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function readI53FromI64(ptr){return HEAPU32[ptr>>2]+HEAP32[ptr+4>>2]*4294967296}function ___syscall_utimensat(dirfd,path,times,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path,true);if(!times){var atime=Date.now();var mtime=atime}else{var seconds=readI53FromI64(times);var nanoseconds=HEAP32[times+8>>2];atime=seconds*1e3+nanoseconds/(1e3*1e3);times+=16;seconds=readI53FromI64(times);nanoseconds=HEAP32[times+8>>2];mtime=seconds*1e3+nanoseconds/(1e3*1e3)}FS.utime(path,atime,mtime);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function __emscripten_date_now(){return Date.now()}var nowIsMonotonic=true;function __emscripten_get_now_is_monotonic(){return nowIsMonotonic}function __emscripten_throw_longjmp(){throw Infinity}function __localtime_js(time,tmPtr){var date=new Date(readI53FromI64(time)*1e3);HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getDay();var start=new Date(date.getFullYear(),0,1);var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>2]=dst}function __mktime_js(tmPtr){var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();return date.getTime()/1e3|0}function __munmap_js(addr,len,prot,flags,fd,offset){try{var stream=FS.getStream(fd);if(stream){if(prot&2){SYSCALLS.doMsync(addr,stream,len,flags,offset)}FS.munmap(stream)}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function _tzset_impl(timezone,daylight,tzname){var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAP32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAPU32[tzname+4>>2]=summerNamePtr}else{HEAPU32[tzname>>2]=summerNamePtr;HEAPU32[tzname+4>>2]=winterNamePtr}}function __tzset_js(timezone,daylight,tzname){if(__tzset_js.called)return;__tzset_js.called=true;_tzset_impl(timezone,daylight,tzname)}function _abort(){abort("")}var readAsmConstArgsArray=[];function readAsmConstArgs(sigPtr,buf){readAsmConstArgsArray.length=0;var ch;buf>>=2;while(ch=HEAPU8[sigPtr++]){buf+=ch!=105&buf;readAsmConstArgsArray.push(ch==105?HEAP32[buf]:(ch==106?HEAP64:HEAPF64)[buf++>>1]);++buf}return readAsmConstArgsArray}function _emscripten_asm_const_int(code,sigPtr,argbuf){var args=readAsmConstArgs(sigPtr,argbuf);return ASM_CONSTS[code].apply(null,args)}var _emscripten_asm_const_ptr=_emscripten_asm_const_int;function getHeapMax(){return 2147483648}function _emscripten_get_heap_max(){return getHeapMax()}var _emscripten_get_now;if(ENVIRONMENT_IS_NODE){_emscripten_get_now=()=>{var t=process["hrtime"]();return t[0]*1e3+t[1]/1e6}}else _emscripten_get_now=()=>performance.now();function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function _emscripten_run_script(ptr){eval(UTF8ToString(ptr))}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAPU32[penviron_buf_size>>2]=bufSize;return 0}function _proc_exit(code){EXITSTATUS=code;if(!keepRuntimeAlive()){if(Module["onExit"])Module["onExit"](code);ABORT=true}quit_(code,new ExitStatus(code))}function exitJS(status,implicit){EXITSTATUS=status;if(!keepRuntimeAlive()){exitRuntime()}_proc_exit(status)}var _exit=exitJS;function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_fdstat_get(fd,pbuf){try{var stream=SYSCALLS.getStreamFromFD(fd);var type=stream.tty?2:FS.isDir(stream.mode)?3:FS.isLink(stream.mode)?7:4;HEAP8[pbuf>>0]=type;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doReadv(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_seek(fd,offset,whence,newOffset){try{offset=bigintToI53Checked(offset);if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);HEAP64[newOffset>>3]=BigInt(stream.position);if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doWritev(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=doWritev(stream,iov,iovcnt);HEAPU32[pnum>>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _getTempRet0(){return getTempRet0()}function _setTempRet0(val){setTempRet0(val)}function __isLeapYear(year){return year%4===0&&(year%100!==0||year%400===0)}function __arraySum(array,index){var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date,days){var newDate=new Date(date.getTime());while(days>0){var leap=__isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate}function _strftime(s,maxsize,format,tm){var tm_zone=HEAP32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value=="number"?value.toString():value||"";while(str.length0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}return thisDate.getFullYear()}return thisDate.getFullYear()-1}var EXPANSION_RULES_2={"%a":function(date){return WEEKDAYS[date.tm_wday].substring(0,3)},"%A":function(date){return WEEKDAYS[date.tm_wday]},"%b":function(date){return MONTHS[date.tm_mon].substring(0,3)},"%B":function(date){return MONTHS[date.tm_mon]},"%C":function(date){var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":function(date){return leadingNulls(date.tm_mday,2)},"%e":function(date){return leadingSomething(date.tm_mday,2," ")},"%g":function(date){return getWeekBasedYear(date).toString().substring(2)},"%G":function(date){return getWeekBasedYear(date)},"%H":function(date){return leadingNulls(date.tm_hour,2)},"%I":function(date){var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":function(date){return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,date.tm_mon-1),3)},"%m":function(date){return leadingNulls(date.tm_mon+1,2)},"%M":function(date){return leadingNulls(date.tm_min,2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}return"PM"},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var days=date.tm_yday+7-date.tm_wday;return leadingNulls(Math.floor(days/7),2)},"%V":function(date){var val=Math.floor((date.tm_yday+7-(date.tm_wday+6)%7)/7);if((date.tm_wday+371-date.tm_yday-2)%7<=2){val++}if(!val){val=52;var dec31=(date.tm_wday+7-date.tm_yday-1)%7;if(dec31==4||dec31==5&&__isLeapYear(date.tm_year%400-1)){val++}}else if(val==53){var jan1=(date.tm_wday+371-date.tm_yday)%7;if(jan1!=4&&(jan1!=3||!__isLeapYear(date.tm_year)))val=1}return leadingNulls(val,2)},"%w":function(date){return date.tm_wday},"%W":function(date){var days=date.tm_yday+7-(date.tm_wday+6)%7;return leadingNulls(Math.floor(days/7),2)},"%y":function(date){return(date.tm_year+1900).toString().substring(2)},"%Y":function(date){return date.tm_year+1900},"%z":function(date){var off=date.tm_gmtoff;var ahead=off>=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};pattern=pattern.replace(/%%/g,"\0\0");for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}pattern=pattern.replace(/\0\0/g,"%");var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1}var ALLOC_NORMAL=0;var ALLOC_STACK=1;function allocate(slab,allocator){var ret;if(allocator==ALLOC_STACK){ret=stackAlloc(slab.length)}else{ret=_malloc(slab.length)}if(!slab.subarray&&!slab.slice){slab=new Uint8Array(slab)}HEAPU8.set(slab,ret);return ret}function getCFunc(ident){var func=Module["_"+ident];return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;itype==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_unlink"]=FS.unlink;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;var asmLibraryArg={"P":___call_sighandler,"fa":___syscall_chdir,"ea":___syscall_chmod,"da":___syscall_dup3,"ga":___syscall_faccessat,"n":___syscall_fcntl64,"Z":___syscall_fstat64,"V":___syscall_ftruncate64,"U":___syscall_getcwd,"O":___syscall_getdents64,"w":___syscall_ioctl,"W":___syscall_lstat64,"S":___syscall_mkdirat,"X":___syscall_newfstatat,"x":___syscall_openat,"Q":___syscall_poll,"N":___syscall_readlinkat,"L":___syscall_renameat,"t":___syscall_rmdir,"Y":___syscall_stat64,"K":___syscall_symlink,"M":___syscall_unlinkat,"I":___syscall_utimensat,"z":__emscripten_date_now,"_":__emscripten_get_now_is_monotonic,"G":__emscripten_throw_longjmp,"$":__localtime_js,"aa":__mktime_js,"R":__munmap_js,"ba":__tzset_js,"m":_abort,"A":_emscripten_asm_const_int,"ja":_emscripten_asm_const_ptr,"J":_emscripten_get_heap_max,"y":_emscripten_get_now,"ca":_emscripten_memcpy_big,"H":_emscripten_resize_heap,"ka":_emscripten_run_script,"ha":_environ_get,"ia":_environ_sizes_get,"i":_exit,"p":_fd_close,"u":_fd_fdstat_get,"v":_fd_read,"T":_fd_seek,"q":_fd_write,"a":_getTempRet0,"h":invoke_i,"d":invoke_ii,"c":invoke_iii,"f":invoke_iiii,"k":invoke_iiiii,"j":invoke_iiiiii,"C":invoke_iiiiiii,"s":invoke_iiiiiiii,"D":invoke_iiiiiiiii,"E":invoke_iiiiiiiiii,"F":invoke_iiiiiiiiiii,"ma":invoke_iiiiiiiiiiii,"r":invoke_iiji,"B":invoke_ij,"l":invoke_v,"e":invoke_vi,"g":invoke_vii,"o":invoke_viii,"b":_setTempRet0,"la":_strftime};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["oa"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["pa"]).apply(null,arguments)};var _PL_initialise=Module["_PL_initialise"]=function(){return(_PL_initialise=Module["_PL_initialise"]=Module["asm"]["qa"]).apply(null,arguments)};var _PL_halt=Module["_PL_halt"]=function(){return(_PL_halt=Module["_PL_halt"]=Module["asm"]["ra"]).apply(null,arguments)};var _PL_toplevel=Module["_PL_toplevel"]=function(){return(_PL_toplevel=Module["_PL_toplevel"]=Module["asm"]["sa"]).apply(null,arguments)};var _PL_unregister_blob_type=Module["_PL_unregister_blob_type"]=function(){return(_PL_unregister_blob_type=Module["_PL_unregister_blob_type"]=Module["asm"]["ta"]).apply(null,arguments)};var _PL_unregister_atom=Module["_PL_unregister_atom"]=function(){return(_PL_unregister_atom=Module["_PL_unregister_atom"]=Module["asm"]["ua"]).apply(null,arguments)};var _PL_agc_hook=Module["_PL_agc_hook"]=function(){return(_PL_agc_hook=Module["_PL_agc_hook"]=Module["asm"]["va"]).apply(null,arguments)};var _PL_register_atom=Module["_PL_register_atom"]=function(){return(_PL_register_atom=Module["_PL_register_atom"]=Module["asm"]["wa"]).apply(null,arguments)};var _PL_open_foreign_frame=Module["_PL_open_foreign_frame"]=function(){return(_PL_open_foreign_frame=Module["_PL_open_foreign_frame"]=Module["asm"]["xa"]).apply(null,arguments)};var _PL_close_foreign_frame=Module["_PL_close_foreign_frame"]=function(){return(_PL_close_foreign_frame=Module["_PL_close_foreign_frame"]=Module["asm"]["ya"]).apply(null,arguments)};var _PL_rewind_foreign_frame=Module["_PL_rewind_foreign_frame"]=function(){return(_PL_rewind_foreign_frame=Module["_PL_rewind_foreign_frame"]=Module["asm"]["za"]).apply(null,arguments)};var _PL_discard_foreign_frame=Module["_PL_discard_foreign_frame"]=function(){return(_PL_discard_foreign_frame=Module["_PL_discard_foreign_frame"]=Module["asm"]["Aa"]).apply(null,arguments)};var _PL_open_query=Module["_PL_open_query"]=function(){return(_PL_open_query=Module["_PL_open_query"]=Module["asm"]["Ba"]).apply(null,arguments)};var _PL_exception=Module["_PL_exception"]=function(){return(_PL_exception=Module["_PL_exception"]=Module["asm"]["Ca"]).apply(null,arguments)};var _PL_cut_query=Module["_PL_cut_query"]=function(){return(_PL_cut_query=Module["_PL_cut_query"]=Module["asm"]["Da"]).apply(null,arguments)};var _PL_close_query=Module["_PL_close_query"]=function(){return(_PL_close_query=Module["_PL_close_query"]=Module["asm"]["Ea"]).apply(null,arguments)};var _PL_current_query=Module["_PL_current_query"]=function(){return(_PL_current_query=Module["_PL_current_query"]=Module["asm"]["Fa"]).apply(null,arguments)};var _PL_next_solution=Module["_PL_next_solution"]=function(){return(_PL_next_solution=Module["_PL_next_solution"]=Module["asm"]["Ga"]).apply(null,arguments)};var _PL_instantiation_error=Module["_PL_instantiation_error"]=function(){return(_PL_instantiation_error=Module["_PL_instantiation_error"]=Module["asm"]["Ha"]).apply(null,arguments)};var _PL_uninstantiation_error=Module["_PL_uninstantiation_error"]=function(){return(_PL_uninstantiation_error=Module["_PL_uninstantiation_error"]=Module["asm"]["Ia"]).apply(null,arguments)};var _PL_representation_error=Module["_PL_representation_error"]=function(){return(_PL_representation_error=Module["_PL_representation_error"]=Module["asm"]["Ja"]).apply(null,arguments)};var _PL_type_error=Module["_PL_type_error"]=function(){return(_PL_type_error=Module["_PL_type_error"]=Module["asm"]["Ka"]).apply(null,arguments)};var _PL_domain_error=Module["_PL_domain_error"]=function(){return(_PL_domain_error=Module["_PL_domain_error"]=Module["asm"]["La"]).apply(null,arguments)};var _PL_existence_error=Module["_PL_existence_error"]=function(){return(_PL_existence_error=Module["_PL_existence_error"]=Module["asm"]["Ma"]).apply(null,arguments)};var _PL_permission_error=Module["_PL_permission_error"]=function(){return(_PL_permission_error=Module["_PL_permission_error"]=Module["asm"]["Na"]).apply(null,arguments)};var _PL_resource_error=Module["_PL_resource_error"]=function(){return(_PL_resource_error=Module["_PL_resource_error"]=Module["asm"]["Oa"]).apply(null,arguments)};var _PL_syntax_error=Module["_PL_syntax_error"]=function(){return(_PL_syntax_error=Module["_PL_syntax_error"]=Module["asm"]["Pa"]).apply(null,arguments)};var _PL_get_atom_ex=Module["_PL_get_atom_ex"]=function(){return(_PL_get_atom_ex=Module["_PL_get_atom_ex"]=Module["asm"]["Qa"]).apply(null,arguments)};var _PL_get_integer_ex=Module["_PL_get_integer_ex"]=function(){return(_PL_get_integer_ex=Module["_PL_get_integer_ex"]=Module["asm"]["Ra"]).apply(null,arguments)};var _PL_get_long_ex=Module["_PL_get_long_ex"]=function(){return(_PL_get_long_ex=Module["_PL_get_long_ex"]=Module["asm"]["Sa"]).apply(null,arguments)};var _PL_get_int64_ex=Module["_PL_get_int64_ex"]=function(){return(_PL_get_int64_ex=Module["_PL_get_int64_ex"]=Module["asm"]["Ta"]).apply(null,arguments)};var _PL_get_intptr_ex=Module["_PL_get_intptr_ex"]=function(){return(_PL_get_intptr_ex=Module["_PL_get_intptr_ex"]=Module["asm"]["Ua"]).apply(null,arguments)};var _PL_get_size_ex=Module["_PL_get_size_ex"]=function(){return(_PL_get_size_ex=Module["_PL_get_size_ex"]=Module["asm"]["Va"]).apply(null,arguments)};var _PL_get_bool_ex=Module["_PL_get_bool_ex"]=function(){return(_PL_get_bool_ex=Module["_PL_get_bool_ex"]=Module["asm"]["Wa"]).apply(null,arguments)};var _PL_get_float_ex=Module["_PL_get_float_ex"]=function(){return(_PL_get_float_ex=Module["_PL_get_float_ex"]=Module["asm"]["Xa"]).apply(null,arguments)};var _PL_get_char_ex=Module["_PL_get_char_ex"]=function(){return(_PL_get_char_ex=Module["_PL_get_char_ex"]=Module["asm"]["Ya"]).apply(null,arguments)};var _PL_get_pointer_ex=Module["_PL_get_pointer_ex"]=function(){return(_PL_get_pointer_ex=Module["_PL_get_pointer_ex"]=Module["asm"]["Za"]).apply(null,arguments)};var _PL_unify_list_ex=Module["_PL_unify_list_ex"]=function(){return(_PL_unify_list_ex=Module["_PL_unify_list_ex"]=Module["asm"]["_a"]).apply(null,arguments)};var _PL_unify_nil_ex=Module["_PL_unify_nil_ex"]=function(){return(_PL_unify_nil_ex=Module["_PL_unify_nil_ex"]=Module["asm"]["$a"]).apply(null,arguments)};var _PL_get_list_ex=Module["_PL_get_list_ex"]=function(){return(_PL_get_list_ex=Module["_PL_get_list_ex"]=Module["asm"]["ab"]).apply(null,arguments)};var _PL_get_nil_ex=Module["_PL_get_nil_ex"]=function(){return(_PL_get_nil_ex=Module["_PL_get_nil_ex"]=Module["asm"]["bb"]).apply(null,arguments)};var _PL_unify_bool_ex=Module["_PL_unify_bool_ex"]=function(){return(_PL_unify_bool_ex=Module["_PL_unify_bool_ex"]=Module["asm"]["cb"]).apply(null,arguments)};var _PL_is_ground=Module["_PL_is_ground"]=function(){return(_PL_is_ground=Module["_PL_is_ground"]=Module["asm"]["db"]).apply(null,arguments)};var _PL_is_acyclic=Module["_PL_is_acyclic"]=function(){return(_PL_is_acyclic=Module["_PL_is_acyclic"]=Module["asm"]["eb"]).apply(null,arguments)};var _PL_put_term_from_chars=Module["_PL_put_term_from_chars"]=function(){return(_PL_put_term_from_chars=Module["_PL_put_term_from_chars"]=Module["asm"]["fb"]).apply(null,arguments)};var _PL_chars_to_term=Module["_PL_chars_to_term"]=function(){return(_PL_chars_to_term=Module["_PL_chars_to_term"]=Module["asm"]["gb"]).apply(null,arguments)};var _PL_wchars_to_term=Module["_PL_wchars_to_term"]=function(){return(_PL_wchars_to_term=Module["_PL_wchars_to_term"]=Module["asm"]["hb"]).apply(null,arguments)};var _PL_record_external=Module["_PL_record_external"]=function(){return(_PL_record_external=Module["_PL_record_external"]=Module["asm"]["ib"]).apply(null,arguments)};var _PL_recorded_external=Module["_PL_recorded_external"]=function(){return(_PL_recorded_external=Module["_PL_recorded_external"]=Module["asm"]["jb"]).apply(null,arguments)};var _PL_erase_external=Module["_PL_erase_external"]=function(){return(_PL_erase_external=Module["_PL_erase_external"]=Module["asm"]["kb"]).apply(null,arguments)};var _PL_sigaction=Module["_PL_sigaction"]=function(){return(_PL_sigaction=Module["_PL_sigaction"]=Module["asm"]["lb"]).apply(null,arguments)};var _PL_get_signum_ex=Module["_PL_get_signum_ex"]=function(){return(_PL_get_signum_ex=Module["_PL_get_signum_ex"]=Module["asm"]["mb"]).apply(null,arguments)};var _PL_signal=Module["_PL_signal"]=function(){return(_PL_signal=Module["_PL_signal"]=Module["asm"]["nb"]).apply(null,arguments)};var _PL_handle_signals=Module["_PL_handle_signals"]=function(){return(_PL_handle_signals=Module["_PL_handle_signals"]=Module["asm"]["ob"]).apply(null,arguments)};var _PL_write_term=Module["_PL_write_term"]=function(){return(_PL_write_term=Module["_PL_write_term"]=Module["asm"]["pb"]).apply(null,arguments)};var _PL_cleanup_fork=Module["_PL_cleanup_fork"]=function(){return(_PL_cleanup_fork=Module["_PL_cleanup_fork"]=Module["asm"]["qb"]).apply(null,arguments)};var _PL_is_initialised=Module["_PL_is_initialised"]=function(){return(_PL_is_initialised=Module["_PL_is_initialised"]=Module["asm"]["rb"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["sb"]).apply(null,arguments)};var _PL_raise=Module["_PL_raise"]=function(){return(_PL_raise=Module["_PL_raise"]=Module["asm"]["tb"]).apply(null,arguments)};var _PL_new_atom=Module["_PL_new_atom"]=function(){return(_PL_new_atom=Module["_PL_new_atom"]=Module["asm"]["ub"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["vb"]).apply(null,arguments)};var _PL_put_atom_chars=Module["_PL_put_atom_chars"]=function(){return(_PL_put_atom_chars=Module["_PL_put_atom_chars"]=Module["asm"]["wb"]).apply(null,arguments)};var _PL_throw=Module["_PL_throw"]=function(){return(_PL_throw=Module["_PL_throw"]=Module["asm"]["xb"]).apply(null,arguments)};var _PL_raise_exception=Module["_PL_raise_exception"]=function(){return(_PL_raise_exception=Module["_PL_raise_exception"]=Module["asm"]["yb"]).apply(null,arguments)};var _PL_clear_exception=Module["_PL_clear_exception"]=function(){return(_PL_clear_exception=Module["_PL_clear_exception"]=Module["asm"]["zb"]).apply(null,arguments)};var _PL_put_nil=Module["_PL_put_nil"]=function(){return(_PL_put_nil=Module["_PL_put_nil"]=Module["asm"]["Ab"]).apply(null,arguments)};var _PL_atom_nchars=Module["_PL_atom_nchars"]=function(){return(_PL_atom_nchars=Module["_PL_atom_nchars"]=Module["asm"]["Bb"]).apply(null,arguments)};var _PL_atom_wchars=Module["_PL_atom_wchars"]=function(){return(_PL_atom_wchars=Module["_PL_atom_wchars"]=Module["asm"]["Cb"]).apply(null,arguments)};var _PL_is_integer=Module["_PL_is_integer"]=function(){return(_PL_is_integer=Module["_PL_is_integer"]=Module["asm"]["Db"]).apply(null,arguments)};var _PL_unify_uint64=Module["_PL_unify_uint64"]=function(){return(_PL_unify_uint64=Module["_PL_unify_uint64"]=Module["asm"]["Eb"]).apply(null,arguments)};var _PL_unify_float=Module["_PL_unify_float"]=function(){return(_PL_unify_float=Module["_PL_unify_float"]=Module["asm"]["Fb"]).apply(null,arguments)};var _PL_unify_nil=Module["_PL_unify_nil"]=function(){return(_PL_unify_nil=Module["_PL_unify_nil"]=Module["asm"]["Hb"]).apply(null,arguments)};var _PL_cons_functor_v=Module["_PL_cons_functor_v"]=function(){return(_PL_cons_functor_v=Module["_PL_cons_functor_v"]=Module["asm"]["Ib"]).apply(null,arguments)};var _PL_get_nil=Module["_PL_get_nil"]=function(){return(_PL_get_nil=Module["_PL_get_nil"]=Module["asm"]["Jb"]).apply(null,arguments)};var _PL_atom_chars=Module["_PL_atom_chars"]=function(){return(_PL_atom_chars=Module["_PL_atom_chars"]=Module["asm"]["Kb"]).apply(null,arguments)};var _PL_is_list=Module["_PL_is_list"]=function(){return(_PL_is_list=Module["_PL_is_list"]=Module["asm"]["Lb"]).apply(null,arguments)};var _PL_cons_functor=Module["_PL_cons_functor"]=function(){return(_PL_cons_functor=Module["_PL_cons_functor"]=Module["asm"]["Mb"]).apply(null,arguments)};var _PL_warning=Module["_PL_warning"]=function(){return(_PL_warning=Module["_PL_warning"]=Module["asm"]["Nb"]).apply(null,arguments)};var _PL_unify_chars=Module["_PL_unify_chars"]=function(){return(_PL_unify_chars=Module["_PL_unify_chars"]=Module["asm"]["Ob"]).apply(null,arguments)};var _PL_get_nchars=Module["_PL_get_nchars"]=function(){return(_PL_get_nchars=Module["_PL_get_nchars"]=Module["asm"]["Pb"]).apply(null,arguments)};var _PL_get_wchars=Module["_PL_get_wchars"]=function(){return(_PL_get_wchars=Module["_PL_get_wchars"]=Module["asm"]["Qb"]).apply(null,arguments)};var _PL_call_predicate=Module["_PL_call_predicate"]=function(){return(_PL_call_predicate=Module["_PL_call_predicate"]=Module["asm"]["Rb"]).apply(null,arguments)};var _PL_is_number=Module["_PL_is_number"]=function(){return(_PL_is_number=Module["_PL_is_number"]=Module["asm"]["Sb"]).apply(null,arguments)};var _PL_is_string=Module["_PL_is_string"]=function(){return(_PL_is_string=Module["_PL_is_string"]=Module["asm"]["Tb"]).apply(null,arguments)};var _PL_is_pair=Module["_PL_is_pair"]=function(){return(_PL_is_pair=Module["_PL_is_pair"]=Module["asm"]["Ub"]).apply(null,arguments)};var _PL_predicate=Module["_PL_predicate"]=function(){return(_PL_predicate=Module["_PL_predicate"]=Module["asm"]["Vb"]).apply(null,arguments)};var _PL_is_float=Module["_PL_is_float"]=function(){return(_PL_is_float=Module["_PL_is_float"]=Module["asm"]["Wb"]).apply(null,arguments)};var _PL_is_compound=Module["_PL_is_compound"]=function(){return(_PL_is_compound=Module["_PL_is_compound"]=Module["asm"]["Xb"]).apply(null,arguments)};var _PL_is_callable=Module["_PL_is_callable"]=function(){return(_PL_is_callable=Module["_PL_is_callable"]=Module["asm"]["Yb"]).apply(null,arguments)};var _PL_unify_compound=Module["_PL_unify_compound"]=function(){return(_PL_unify_compound=Module["_PL_unify_compound"]=Module["asm"]["Zb"]).apply(null,arguments)};var _PL_compare=Module["_PL_compare"]=function(){return(_PL_compare=Module["_PL_compare"]=Module["asm"]["_b"]).apply(null,arguments)};var _PL_unify_atom_nchars=Module["_PL_unify_atom_nchars"]=function(){return(_PL_unify_atom_nchars=Module["_PL_unify_atom_nchars"]=Module["asm"]["$b"]).apply(null,arguments)};var _PL_unify_wchars=Module["_PL_unify_wchars"]=function(){return(_PL_unify_wchars=Module["_PL_unify_wchars"]=Module["asm"]["ac"]).apply(null,arguments)};var _PL_get_atom_chars=Module["_PL_get_atom_chars"]=function(){return(_PL_get_atom_chars=Module["_PL_get_atom_chars"]=Module["asm"]["bc"]).apply(null,arguments)};var _PL_unify_bool=Module["_PL_unify_bool"]=function(){return(_PL_unify_bool=Module["_PL_unify_bool"]=Module["asm"]["cc"]).apply(null,arguments)};var _PL_get_chars=Module["_PL_get_chars"]=function(){return(_PL_get_chars=Module["_PL_get_chars"]=Module["asm"]["dc"]).apply(null,arguments)};var _PL_skip_list=Module["_PL_skip_list"]=function(){return(_PL_skip_list=Module["_PL_skip_list"]=Module["asm"]["ec"]).apply(null,arguments)};var _PL_is_atom=Module["_PL_is_atom"]=function(){return(_PL_is_atom=Module["_PL_is_atom"]=Module["asm"]["fc"]).apply(null,arguments)};var _PL_is_variable=Module["_PL_is_variable"]=function(){return(_PL_is_variable=Module["_PL_is_variable"]=Module["asm"]["gc"]).apply(null,arguments)};var _PL_unify_atom=Module["_PL_unify_atom"]=function(){return(_PL_unify_atom=Module["_PL_unify_atom"]=Module["asm"]["hc"]).apply(null,arguments)};var _PL_new_term_refs=Module["_PL_new_term_refs"]=function(){return(_PL_new_term_refs=Module["_PL_new_term_refs"]=Module["asm"]["ic"]).apply(null,arguments)};var _PL_put_atom=Module["_PL_put_atom"]=function(){return(_PL_put_atom=Module["_PL_put_atom"]=Module["asm"]["jc"]).apply(null,arguments)};var _PL_new_term_ref=Module["_PL_new_term_ref"]=function(){return(_PL_new_term_ref=Module["_PL_new_term_ref"]=Module["asm"]["kc"]).apply(null,arguments)};var _PL_unify=Module["_PL_unify"]=function(){return(_PL_unify=Module["_PL_unify"]=Module["asm"]["lc"]).apply(null,arguments)};var _PL_get_bool=Module["_PL_get_bool"]=function(){return(_PL_get_bool=Module["_PL_get_bool"]=Module["asm"]["mc"]).apply(null,arguments)};var _PL_get_float=Module["_PL_get_float"]=function(){return(_PL_get_float=Module["_PL_get_float"]=Module["asm"]["nc"]).apply(null,arguments)};var _PL_get_module=Module["_PL_get_module"]=function(){return(_PL_get_module=Module["_PL_get_module"]=Module["asm"]["oc"]).apply(null,arguments)};var _PL_erase=Module["_PL_erase"]=function(){return(_PL_erase=Module["_PL_erase"]=Module["asm"]["pc"]).apply(null,arguments)};var _PL_unify_string_nchars=Module["_PL_unify_string_nchars"]=function(){return(_PL_unify_string_nchars=Module["_PL_unify_string_nchars"]=Module["asm"]["qc"]).apply(null,arguments)};var _PL_get_intptr=Module["_PL_get_intptr"]=function(){return(_PL_get_intptr=Module["_PL_get_intptr"]=Module["asm"]["rc"]).apply(null,arguments)};var _PL_pred=Module["_PL_pred"]=function(){return(_PL_pred=Module["_PL_pred"]=Module["asm"]["sc"]).apply(null,arguments)};var _PL_is_blob=Module["_PL_is_blob"]=function(){return(_PL_is_blob=Module["_PL_is_blob"]=Module["asm"]["tc"]).apply(null,arguments)};var _PL_put_bool=Module["_PL_put_bool"]=function(){return(_PL_put_bool=Module["_PL_put_bool"]=Module["asm"]["uc"]).apply(null,arguments)};var _PL_unify_atom_chars=Module["_PL_unify_atom_chars"]=function(){return(_PL_unify_atom_chars=Module["_PL_unify_atom_chars"]=Module["asm"]["vc"]).apply(null,arguments)};var _PL_put_float=Module["_PL_put_float"]=function(){return(_PL_put_float=Module["_PL_put_float"]=Module["asm"]["wc"]).apply(null,arguments)};var _PL_put_pointer=Module["_PL_put_pointer"]=function(){return(_PL_put_pointer=Module["_PL_put_pointer"]=Module["asm"]["xc"]).apply(null,arguments)};var _PL_unify_int64=Module["_PL_unify_int64"]=function(){return(_PL_unify_int64=Module["_PL_unify_int64"]=Module["asm"]["yc"]).apply(null,arguments)};var _PL_get_atom=Module["_PL_get_atom"]=function(){return(_PL_get_atom=Module["_PL_get_atom"]=Module["asm"]["zc"]).apply(null,arguments)};var _PL_copy_term_ref=Module["_PL_copy_term_ref"]=function(){return(_PL_copy_term_ref=Module["_PL_copy_term_ref"]=Module["asm"]["Ac"]).apply(null,arguments)};var _PL_unify_integer=Module["_PL_unify_integer"]=function(){return(_PL_unify_integer=Module["_PL_unify_integer"]=Module["asm"]["Bc"]).apply(null,arguments)};var _PL_put_int64=Module["_PL_put_int64"]=function(){return(_PL_put_int64=Module["_PL_put_int64"]=Module["asm"]["Cc"]).apply(null,arguments)};var _PL_set_prolog_flag=Module["_PL_set_prolog_flag"]=function(){return(_PL_set_prolog_flag=Module["_PL_set_prolog_flag"]=Module["asm"]["Dc"]).apply(null,arguments)};var _PL_get_file_name=Module["_PL_get_file_name"]=function(){return(_PL_get_file_name=Module["_PL_get_file_name"]=Module["asm"]["Ec"]).apply(null,arguments)};var _PL_unify_blob=Module["_PL_unify_blob"]=function(){return(_PL_unify_blob=Module["_PL_unify_blob"]=Module["asm"]["Fc"]).apply(null,arguments)};var _PL_get_blob=Module["_PL_get_blob"]=function(){return(_PL_get_blob=Module["_PL_get_blob"]=Module["asm"]["Gc"]).apply(null,arguments)};var _PL_blob_data=Module["_PL_blob_data"]=function(){return(_PL_blob_data=Module["_PL_blob_data"]=Module["asm"]["Hc"]).apply(null,arguments)};var _PL_new_module=Module["_PL_new_module"]=function(){return(_PL_new_module=Module["_PL_new_module"]=Module["asm"]["Ic"]).apply(null,arguments)};var _PL_put_string_chars=Module["_PL_put_string_chars"]=function(){return(_PL_put_string_chars=Module["_PL_put_string_chars"]=Module["asm"]["Jc"]).apply(null,arguments)};var _PL_set_resource_db_mem=Module["_PL_set_resource_db_mem"]=function(){return(_PL_set_resource_db_mem=Module["_PL_set_resource_db_mem"]=Module["asm"]["Kc"]).apply(null,arguments)};var _PL_on_halt=Module["_PL_on_halt"]=function(){return(_PL_on_halt=Module["_PL_on_halt"]=Module["asm"]["Lc"]).apply(null,arguments)};var _PL_exit_hook=Module["_PL_exit_hook"]=function(){return(_PL_exit_hook=Module["_PL_exit_hook"]=Module["asm"]["Mc"]).apply(null,arguments)};var _PL_cleanup=Module["_PL_cleanup"]=function(){return(_PL_cleanup=Module["_PL_cleanup"]=Module["asm"]["Nc"]).apply(null,arguments)};var _PL_unify_string_chars=Module["_PL_unify_string_chars"]=function(){return(_PL_unify_string_chars=Module["_PL_unify_string_chars"]=Module["asm"]["Oc"]).apply(null,arguments)};var _PL_put_variable=Module["_PL_put_variable"]=function(){return(_PL_put_variable=Module["_PL_put_variable"]=Module["asm"]["Pc"]).apply(null,arguments)};var _PL_is_atomic=Module["_PL_is_atomic"]=function(){return(_PL_is_atomic=Module["_PL_is_atomic"]=Module["asm"]["Qc"]).apply(null,arguments)};var _PL_recorded=Module["_PL_recorded"]=function(){return(_PL_recorded=Module["_PL_recorded"]=Module["asm"]["Rc"]).apply(null,arguments)};var _PL_record=Module["_PL_record"]=function(){return(_PL_record=Module["_PL_record"]=Module["asm"]["Sc"]).apply(null,arguments)};var _PL_put_functor=Module["_PL_put_functor"]=function(){return(_PL_put_functor=Module["_PL_put_functor"]=Module["asm"]["Tc"]).apply(null,arguments)};var _PL_strip_module=Module["_PL_strip_module"]=function(){return(_PL_strip_module=Module["_PL_strip_module"]=Module["asm"]["Uc"]).apply(null,arguments)};var _PL_unify_list=Module["_PL_unify_list"]=function(){return(_PL_unify_list=Module["_PL_unify_list"]=Module["asm"]["Vc"]).apply(null,arguments)};var _PL_register_foreign_in_module=Module["_PL_register_foreign_in_module"]=function(){return(_PL_register_foreign_in_module=Module["_PL_register_foreign_in_module"]=Module["asm"]["Wc"]).apply(null,arguments)};var _PL_foreign_control=Module["_PL_foreign_control"]=function(){return(_PL_foreign_control=Module["_PL_foreign_control"]=Module["asm"]["Xc"]).apply(null,arguments)};var _PL_foreign_context_address=Module["_PL_foreign_context_address"]=function(){return(_PL_foreign_context_address=Module["_PL_foreign_context_address"]=Module["asm"]["Yc"]).apply(null,arguments)};var _PL_reset_term_refs=Module["_PL_reset_term_refs"]=function(){return(_PL_reset_term_refs=Module["_PL_reset_term_refs"]=Module["asm"]["Zc"]).apply(null,arguments)};var _PL_new_atom_nchars=Module["_PL_new_atom_nchars"]=function(){return(_PL_new_atom_nchars=Module["_PL_new_atom_nchars"]=Module["asm"]["_c"]).apply(null,arguments)};var _PL_new_atom_mbchars=Module["_PL_new_atom_mbchars"]=function(){return(_PL_new_atom_mbchars=Module["_PL_new_atom_mbchars"]=Module["asm"]["$c"]).apply(null,arguments)};var _PL_new_functor=Module["_PL_new_functor"]=function(){return(_PL_new_functor=Module["_PL_new_functor"]=Module["asm"]["ad"]).apply(null,arguments)};var _PL_functor_name=Module["_PL_functor_name"]=function(){return(_PL_functor_name=Module["_PL_functor_name"]=Module["asm"]["bd"]).apply(null,arguments)};var _PL_functor_arity=Module["_PL_functor_arity"]=function(){return(_PL_functor_arity=Module["_PL_functor_arity"]=Module["asm"]["cd"]).apply(null,arguments)};var _PL_new_atom_wchars=Module["_PL_new_atom_wchars"]=function(){return(_PL_new_atom_wchars=Module["_PL_new_atom_wchars"]=Module["asm"]["dd"]).apply(null,arguments)};var _PL_unify_wchars_diff=Module["_PL_unify_wchars_diff"]=function(){return(_PL_unify_wchars_diff=Module["_PL_unify_wchars_diff"]=Module["asm"]["ed"]).apply(null,arguments)};var _PL_same_compound=Module["_PL_same_compound"]=function(){return(_PL_same_compound=Module["_PL_same_compound"]=Module["asm"]["fd"]).apply(null,arguments)};var _PL_cons_list=Module["_PL_cons_list"]=function(){return(_PL_cons_list=Module["_PL_cons_list"]=Module["asm"]["gd"]).apply(null,arguments)};var _PL_get_atom_nchars=Module["_PL_get_atom_nchars"]=function(){return(_PL_get_atom_nchars=Module["_PL_get_atom_nchars"]=Module["asm"]["hd"]).apply(null,arguments)};var _PL_get_list_nchars=Module["_PL_get_list_nchars"]=function(){return(_PL_get_list_nchars=Module["_PL_get_list_nchars"]=Module["asm"]["id"]).apply(null,arguments)};var _PL_get_list_chars=Module["_PL_get_list_chars"]=function(){return(_PL_get_list_chars=Module["_PL_get_list_chars"]=Module["asm"]["jd"]).apply(null,arguments)};var _PL_quote=Module["_PL_quote"]=function(){return(_PL_quote=Module["_PL_quote"]=Module["asm"]["kd"]).apply(null,arguments)};var _PL_get_integer=Module["_PL_get_integer"]=function(){return(_PL_get_integer=Module["_PL_get_integer"]=Module["asm"]["ld"]).apply(null,arguments)};var _PL_get_long=Module["_PL_get_long"]=function(){return(_PL_get_long=Module["_PL_get_long"]=Module["asm"]["md"]).apply(null,arguments)};var _PL_get_int64=Module["_PL_get_int64"]=function(){return(_PL_get_int64=Module["_PL_get_int64"]=Module["asm"]["nd"]).apply(null,arguments)};var _PL_get_pointer=Module["_PL_get_pointer"]=function(){return(_PL_get_pointer=Module["_PL_get_pointer"]=Module["asm"]["od"]).apply(null,arguments)};var _PL_get_name_arity=Module["_PL_get_name_arity"]=function(){return(_PL_get_name_arity=Module["_PL_get_name_arity"]=Module["asm"]["pd"]).apply(null,arguments)};var _PL_get_compound_name_arity=Module["_PL_get_compound_name_arity"]=function(){return(_PL_get_compound_name_arity=Module["_PL_get_compound_name_arity"]=Module["asm"]["qd"]).apply(null,arguments)};var _PL_get_functor=Module["_PL_get_functor"]=function(){return(_PL_get_functor=Module["_PL_get_functor"]=Module["asm"]["rd"]).apply(null,arguments)};var _PL_get_arg=Module["_PL_get_arg"]=function(){return(_PL_get_arg=Module["_PL_get_arg"]=Module["asm"]["sd"]).apply(null,arguments)};var _PL_get_list=Module["_PL_get_list"]=function(){return(_PL_get_list=Module["_PL_get_list"]=Module["asm"]["td"]).apply(null,arguments)};var _PL_get_head=Module["_PL_get_head"]=function(){return(_PL_get_head=Module["_PL_get_head"]=Module["asm"]["ud"]).apply(null,arguments)};var _PL_get_tail=Module["_PL_get_tail"]=function(){return(_PL_get_tail=Module["_PL_get_tail"]=Module["asm"]["vd"]).apply(null,arguments)};var _PL_is_functor=Module["_PL_is_functor"]=function(){return(_PL_is_functor=Module["_PL_is_functor"]=Module["asm"]["wd"]).apply(null,arguments)};var _PL_put_atom_nchars=Module["_PL_put_atom_nchars"]=function(){return(_PL_put_atom_nchars=Module["_PL_put_atom_nchars"]=Module["asm"]["xd"]).apply(null,arguments)};var _PL_put_string_nchars=Module["_PL_put_string_nchars"]=function(){return(_PL_put_string_nchars=Module["_PL_put_string_nchars"]=Module["asm"]["yd"]).apply(null,arguments)};var _PL_put_chars=Module["_PL_put_chars"]=function(){return(_PL_put_chars=Module["_PL_put_chars"]=Module["asm"]["zd"]).apply(null,arguments)};var _PL_put_list_ncodes=Module["_PL_put_list_ncodes"]=function(){return(_PL_put_list_ncodes=Module["_PL_put_list_ncodes"]=Module["asm"]["Ad"]).apply(null,arguments)};var _PL_put_list_nchars=Module["_PL_put_list_nchars"]=function(){return(_PL_put_list_nchars=Module["_PL_put_list_nchars"]=Module["asm"]["Bd"]).apply(null,arguments)};var _PL_put_list_chars=Module["_PL_put_list_chars"]=function(){return(_PL_put_list_chars=Module["_PL_put_list_chars"]=Module["asm"]["Cd"]).apply(null,arguments)};var _PL_put_integer=Module["_PL_put_integer"]=function(){return(_PL_put_integer=Module["_PL_put_integer"]=Module["asm"]["Dd"]).apply(null,arguments)};var _PL_put_list=Module["_PL_put_list"]=function(){return(_PL_put_list=Module["_PL_put_list"]=Module["asm"]["Ed"]).apply(null,arguments)};var _PL_put_term=Module["_PL_put_term"]=function(){return(_PL_put_term=Module["_PL_put_term"]=Module["asm"]["Fd"]).apply(null,arguments)};var _PL_unify_functor=Module["_PL_unify_functor"]=function(){return(_PL_unify_functor=Module["_PL_unify_functor"]=Module["asm"]["Gd"]).apply(null,arguments)};var _PL_unify_list_ncodes=Module["_PL_unify_list_ncodes"]=function(){return(_PL_unify_list_ncodes=Module["_PL_unify_list_ncodes"]=Module["asm"]["Hd"]).apply(null,arguments)};var _PL_unify_list_nchars=Module["_PL_unify_list_nchars"]=function(){return(_PL_unify_list_nchars=Module["_PL_unify_list_nchars"]=Module["asm"]["Id"]).apply(null,arguments)};var _PL_unify_list_chars=Module["_PL_unify_list_chars"]=function(){return(_PL_unify_list_chars=Module["_PL_unify_list_chars"]=Module["asm"]["Jd"]).apply(null,arguments)};var _PL_unify_pointer=Module["_PL_unify_pointer"]=function(){return(_PL_unify_pointer=Module["_PL_unify_pointer"]=Module["asm"]["Kd"]).apply(null,arguments)};var _PL_unify_arg=Module["_PL_unify_arg"]=function(){return(_PL_unify_arg=Module["_PL_unify_arg"]=Module["asm"]["Ld"]).apply(null,arguments)};var _PL_unify_term=Module["_PL_unify_term"]=function(){return(_PL_unify_term=Module["_PL_unify_term"]=Module["asm"]["Md"]).apply(null,arguments)};var _PL_put_blob=Module["_PL_put_blob"]=function(){return(_PL_put_blob=Module["_PL_put_blob"]=Module["asm"]["Nd"]).apply(null,arguments)};var _PL_put_dict=Module["_PL_put_dict"]=function(){return(_PL_put_dict=Module["_PL_put_dict"]=Module["asm"]["Od"]).apply(null,arguments)};var _PL_term_type=Module["_PL_term_type"]=function(){return(_PL_term_type=Module["_PL_term_type"]=Module["asm"]["Pd"]).apply(null,arguments)};var _PL_context=Module["_PL_context"]=function(){return(_PL_context=Module["_PL_context"]=Module["asm"]["Qd"]).apply(null,arguments)};var _PL_module_name=Module["_PL_module_name"]=function(){return(_PL_module_name=Module["_PL_module_name"]=Module["asm"]["Rd"]).apply(null,arguments)};var _PL_predicate_info=Module["_PL_predicate_info"]=function(){return(_PL_predicate_info=Module["_PL_predicate_info"]=Module["asm"]["Sd"]).apply(null,arguments)};var _PL_call=Module["_PL_call"]=function(){return(_PL_call=Module["_PL_call"]=Module["asm"]["Td"]).apply(null,arguments)};var _PL_foreign_context=Module["_PL_foreign_context"]=function(){return(_PL_foreign_context=Module["_PL_foreign_context"]=Module["asm"]["Ud"]).apply(null,arguments)};var _PL_foreign_context_predicate=Module["_PL_foreign_context_predicate"]=function(){return(_PL_foreign_context_predicate=Module["_PL_foreign_context_predicate"]=Module["asm"]["Vd"]).apply(null,arguments)};var _PL_register_extensions_in_module=Module["_PL_register_extensions_in_module"]=function(){return(_PL_register_extensions_in_module=Module["_PL_register_extensions_in_module"]=Module["asm"]["Wd"]).apply(null,arguments)};var _PL_register_extensions=Module["_PL_register_extensions"]=function(){return(_PL_register_extensions=Module["_PL_register_extensions"]=Module["asm"]["Xd"]).apply(null,arguments)};var _PL_register_foreign=Module["_PL_register_foreign"]=function(){return(_PL_register_foreign=Module["_PL_register_foreign"]=Module["asm"]["Yd"]).apply(null,arguments)};var _PL_abort_hook=Module["_PL_abort_hook"]=function(){return(_PL_abort_hook=Module["_PL_abort_hook"]=Module["asm"]["Zd"]).apply(null,arguments)};var _PL_abort_unhook=Module["_PL_abort_unhook"]=function(){return(_PL_abort_unhook=Module["_PL_abort_unhook"]=Module["asm"]["_d"]).apply(null,arguments)};var _PL_dispatch_hook=Module["_PL_dispatch_hook"]=function(){return(_PL_dispatch_hook=Module["_PL_dispatch_hook"]=Module["asm"]["$d"]).apply(null,arguments)};var _PL_duplicate_record=Module["_PL_duplicate_record"]=function(){return(_PL_duplicate_record=Module["_PL_duplicate_record"]=Module["asm"]["ae"]).apply(null,arguments)};var _PL_action=Module["_PL_action"]=function(){return(_PL_action=Module["_PL_action"]=Module["asm"]["be"]).apply(null,arguments)};var _PL_query=Module["_PL_query"]=function(){return(_PL_query=Module["_PL_query"]=Module["asm"]["ce"]).apply(null,arguments)};var __PL_streams=Module["__PL_streams"]=function(){return(__PL_streams=Module["__PL_streams"]=Module["asm"]["de"]).apply(null,arguments)};var _PL_get_file_nameW=Module["_PL_get_file_nameW"]=function(){return(_PL_get_file_nameW=Module["_PL_get_file_nameW"]=Module["asm"]["ee"]).apply(null,arguments)};var _WASM_ttymode=Module["_WASM_ttymode"]=function(){return(_WASM_ttymode=Module["_WASM_ttymode"]=Module["asm"]["fe"]).apply(null,arguments)};var _WASM_variable_id=Module["_WASM_variable_id"]=function(){return(_WASM_variable_id=Module["_WASM_variable_id"]=Module["asm"]["ge"]).apply(null,arguments)};var _WASM_yield_request=Module["_WASM_yield_request"]=function(){return(_WASM_yield_request=Module["_WASM_yield_request"]=Module["asm"]["he"]).apply(null,arguments)};var _WASM_set_yield_result=Module["_WASM_set_yield_result"]=function(){return(_WASM_set_yield_result=Module["_WASM_set_yield_result"]=Module["asm"]["ie"]).apply(null,arguments)};var _js_unify_obj=Module["_js_unify_obj"]=function(){return(_js_unify_obj=Module["_js_unify_obj"]=Module["asm"]["je"]).apply(null,arguments)};var _js_get_obj=Module["_js_get_obj"]=function(){return(_js_get_obj=Module["_js_get_obj"]=Module["asm"]["ke"]).apply(null,arguments)};var ___funcs_on_exit=Module["___funcs_on_exit"]=function(){return(___funcs_on_exit=Module["___funcs_on_exit"]=Module["asm"]["le"]).apply(null,arguments)};var _fflush=Module["_fflush"]=function(){return(_fflush=Module["_fflush"]=Module["asm"]["me"]).apply(null,arguments)};var _emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=function(){return(_emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=Module["asm"]["ne"]).apply(null,arguments)};var _setThrew=Module["_setThrew"]=function(){return(_setThrew=Module["_setThrew"]=Module["asm"]["oe"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["pe"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["qe"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["re"]).apply(null,arguments)};function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiji(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ij(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;Module["addRunDependency"]=addRunDependency;Module["removeRunDependency"]=removeRunDependency;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;Module["cwrap"]=cwrap;Module["setValue"]=setValue;Module["getValue"]=getValue;Module["intArrayFromString"]=intArrayFromString;Module["FS"]=FS;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["allocate"]=allocate;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();const class_var=class PrologVar{constructor(id){this.$t="v";if(id!==undefined)this.v=id}};const class_string=class PrologString{constructor(string){this.$t="s";this.v=string}toString(){return this.v}toJSON(){return this.v}};const class_rational=class PrologRational{constructor(n,d){this.$t="r";this.n=n;this.d=d}toNumber(){return Number(this.d)/Number(this.n)}toString(){return this.d+"r"+this.n}toJSON(){return this.toString()}};const class_compound=class PrologCompound{constructor(name,args){this.$t="t";this.functor=name;this[name]=args}arguments(){return this[this.functor]}arg(n){return this.arguments[n]}arity(){return this.arguments.length}toJSON(){const obj={$t:"t"};obj[this.functor]=this.arguments();return obj}};const class_list=class PrologList{constructor(array,tail){this.$t="l";this.v=array;if(tail!==undefined)this.t=tail}};const class_blob=class PrologBlob{constructor(){this.$t="b"}};const class_abortable_promise=class AbortablePromise extends Promise{constructor(executer){super(executer);this.executer=executer}abort(){if(this.executer.abort)return this.executer.abort();else console.log("Cannot abort promise");return false}};class Prolog{constructor(module,args){this.module=module;this.args=args;this.lastyieldat=0;this.functor_arg_names_={};this.objects={};this.object_ids=new WeakMap;this.next_object_id=0;this.open_queries=[];this.__set_foreign_constants();this.__bind_foreign_functions();this.__export_classes();this.__initialize()}__initialize(){let argv0=this.args||[];argv0.unshift("swipl");let argv=argv0.map(function(arg){return this.module.allocate(this.module.intArrayFromString(arg),"i8",this.module.ALLOC_NORMAL)},this);var ptr=this.module._malloc(argv.length*4);argv.forEach(function(arg,i){this.module.setValue(ptr+i*4,arg,"*")},this);if(!this.bindings.PL_initialise(argv.length,ptr)){throw new Error("SWI-Prolog initialisation failed.")}this.MODULE_user=this.new_module("user");this.call("set_prolog_flag(color_term, false).");this.call("set_prolog_flag(debug_on_error, false)");this.call("use_module(library(wasm))")}__export_classes(){this.Var=class_var;this.String=class_string;this.Rational=class_rational;this.Compound=class_compound;this.List=class_list;this.Blob=class_blob;this.Promise=class_abortable_promise}__set_foreign_constants(){this.PL_VARIABLE=1;this.PL_ATOM=2;this.PL_INTEGER=3;this.PL_RATIONAL=4;this.PL_FLOAT=5;this.PL_STRING=6;this.PL_TERM=7;this.PL_NIL=8;this.PL_BLOB=9;this.PL_LIST_PAIR=10;this.PL_FUNCTOR=11;this.PL_LIST=12;this.PL_CHARS=13;this.PL_POINTER=14;this.PL_CODE_LIST=15;this.PL_CHAR_LIST=16;this.PL_BOOL=17;this.PL_FUNCTOR_CHARS=18;this._PL_PREDICATE_INDICATOR=19;this.PL_SHORT=20;this.PL_INT=21;this.PL_LONG=22;this.PL_DOUBLE=23;this.PL_NCHARS=24;this.PL_UTF8_CHARS=25;this.PL_UTF8_STRING=26;this.PL_INT64=27;this.PL_NUTF8_CHARS=28;this.PL_NUTF8_CODES=29;this.PL_NUTF8_STRING=30;this.PL_NWCHARS=31;this.PL_NWCODES=32;this.PL_NWSTRING=33;this.PL_MBCHARS=34;this.PL_MBCODES=35;this.PL_MBSTRING=36;this.PL_INTPTR=37;this.PL_CHAR=38;this.PL_CODE=39;this.PL_BYTE=40;this.PL_PARTIAL_LIST=41;this.PL_CYCLIC_TERM=42;this.PL_NOT_A_LIST=43;this.PL_DICT=44;this.REP_ISO_LATIN_1=0;this.REP_UTF8=1048576;this.REP_MB=2097152;this.REP_FN=this.REP_UTF8;this.CVT_ATOM=1;this.CVT_STRING=2;this.CVT_LIST=4;this.CVT_INTEGER=8;this.CVT_RATIONAL=16;this.CVT_FLOAT=32;this.CVT_VARIABLE=64;this.CVT_NUMBER=this.CVT_INTEGER|this.CVT_RATIONAL|this.CVT_FLOAT;this.CVT_ATOMIC=this.CVT_NUMBER|this.CVT_ATOM|this.CVT_STRING;this.CVT_WRITE=128;this.CVT_WRITE_CANONICAL=256;this.CVT_WRITEQ=512;this.CVT_ALL=this.CVT_ATOMIC|this.CVT_LIST;this.CVT_MASK=4095;this.CVT_EXCEPTION=4096;this.CVT_VARNOFAIL=8192;this.BUF_DISCARDABLE=0;this.BUF_STACK=65536;this.BUF_MALLOC=131072;this.BUF_ALLOW_STACK=262144;this.PL_Q_NORMAL=2;this.PL_Q_NODEBUG=4;this.PL_Q_CATCH_EXCEPTION=8;this.PL_Q_PASS_EXCEPTION=16;this.PL_Q_ALLOW_YIELD=32;this.PL_Q_EXT_STATUS=64;this.PL_S_EXCEPTION=-1;this.PL_S_FALSE=0;this.PL_S_TRUE=1;this.PL_S_LAST=2;this.PL_S_YIELD=255;this.PL_WRT_QUOTED=1;this.PL_WRT_NEWLINE=8192}__bind_foreign_functions(){this.bindings={_PL_streams:this.module.cwrap("_PL_streams","number",[]),PL_functor_arity:this.module.cwrap("PL_functor_arity","number",["number"]),PL_functor_name:this.module.cwrap("PL_functor_name","number",["number"]),PL_get_functor:this.module.cwrap("PL_get_functor","number",["number","number"]),PL_get_chars:this.module.cwrap("PL_get_chars","number",["number","number","number"]),PL_get_arg:this.module.cwrap("PL_get_arg","number",["number","number","number"]),PL_get_int64:this.module.cwrap("PL_get_int64","number",["number","number"]),PL_get_float:this.module.cwrap("PL_get_float","number",["number","number"]),PL_put_chars:this.module.cwrap("PL_put_chars","number",["number","number","number","number"]),put_bytes:this.module.cwrap("PL_put_chars","number",["number","number","number","array"]),PL_put_atom:this.module.cwrap("PL_put_atom","number",["number"]),PL_put_variable:this.module.cwrap("PL_put_variable","number",["number"]),PL_unify:this.module.cwrap("PL_unify","number",["number","number"]),PL_is_string:this.module.cwrap("PL_is_string","number",["number"]),PL_is_variable:this.module.cwrap("PL_is_variable","number",["number"]),PL_term_type:this.module.cwrap("PL_term_type","number",["number"]),PL_get_list:this.module.cwrap("PL_get_list","number",["number","number","number"]),PL_get_nil:this.module.cwrap("PL_get_nil","number",["number"]),PL_initialise:this.module.cwrap("PL_initialise","number",["number","number"]),PL_new_atom:this.module.cwrap("PL_new_atom","number",["string"]),PL_register_atom:this.module.cwrap("PL_register_atom",null,["number"]),PL_unregister_atom:this.module.cwrap("PL_unregister_atom",null,["number"]),PL_new_module:this.module.cwrap("PL_new_module","number",["number"]),PL_new_functor:this.module.cwrap("PL_new_functor","number",["number","number"]),PL_new_term_ref:this.module.cwrap("PL_new_term_ref","number",[]),PL_new_term_refs:this.module.cwrap("PL_new_term_refs","number",["number"]),PL_copy_term_ref:this.module.cwrap("PL_copy_term_ref","number",["number"]),PL_reset_term_refs:this.module.cwrap("PL_reset_term_refs",null,["number"]),PL_put_functor:this.module.cwrap("PL_put_functor","number",["number","number"]),PL_put_integer:this.module.cwrap("PL_put_integer","number",["number","number"]),PL_put_float:this.module.cwrap("PL_put_float","number",["number","number"]),PL_put_nil:this.module.cwrap("PL_put_nil","number",[]),PL_cons_functor_v:this.module.cwrap("PL_cons_functor_v","number",["number","number","number"]),PL_cons_list:this.module.cwrap("PL_cons_list","number",["number","number","number"]),PL_put_dict:this.module.cwrap("PL_put_dict","number",["number","number","number","number","number"]),PL_put_term_from_chars:this.module.cwrap("PL_put_term_from_chars","number",["number","number","number","string"]),PL_put_term:this.module.cwrap("PL_put_term","number",["number","number"]),PL_write_term:this.module.cwrap("PL_write_term","number",["number","number","number","number"]),PL_call:this.module.cwrap("PL_call","number",["number","number"]),PL_open_foreign_frame:this.module.cwrap("PL_open_foreign_frame","number",[]),PL_close_foreign_frame:this.module.cwrap("PL_close_foreign_frame","number",["number"]),PL_discard_foreign_frame:this.module.cwrap("PL_close_foreign_frame","number",["number"]),PL_predicate:this.module.cwrap("PL_predicate","number",["number","number","number"]),PL_open_query:this.module.cwrap("PL_open_query","number",["number","number","number","number"]),PL_next_solution:this.module.cwrap("PL_next_solution","number",["number"]),PL_close_query:this.module.cwrap("PL_close_query","number",["number"]),PL_cut_query:this.module.cwrap("PL_cut_query","number",["number"]),PL_exception:this.module.cwrap("PL_exception","number",["number"]),PL_raise_exception:this.module.cwrap("PL_raise_exception","number",["number"]),WASM_ttymode:this.module.cwrap("WASM_ttymode","number",[]),WASM_yield_request:this.module.cwrap("WASM_yield_request","number",[]),WASM_set_yield_result:this.module.cwrap("WASM_set_yield_result","number",["number"]),WASM_variable_id:this.module.cwrap("WASM_variable_id","number",["number"]),js_unify_obj:this.module.cwrap("js_unify_obj","number",["number","number"]),js_get_obj:this.module.cwrap("js_get_obj","number",["number"])}}call(goal,opts){opts=opts||{};if(typeof goal==="string"){if(opts.async){return this.__call_yieldable(goal,opts)}else{return this.with_frame(function(){const term=this.new_term_ref();if(!this.chars_to_term(goal,term))throw new Error("Query has a syntax error: "+query);const module=opts.module?this.new_module(opts.module):this.MODULE_user;return!!this.bindings.PL_call(term,module)})}}}with_frame(f,persist){const fid=this.bindings.PL_open_foreign_frame();if(fid){const rc=f.call(this);if(persist===false)this.bindings.PL_discard_foreign_frame(fid);else this.bindings.PL_close_foreign_frame(fid);return rc}return false}__string_to_c(string){const len=this.module.lengthBytesUTF8(string);const ptr=this.module._malloc(len+1);this.module.stringToUTF8(string,ptr,len+1);return{ptr:ptr,length:len}}predicate(name,arity,module){if(arity===undefined){let ar=/^([^:]+):(.*)\/([0-9]+)$/.exec(name);if(ar){module=ar[1];name=ar[2];arity=parseInt(ar[3])}else{ar=/(.*)\/([0-9]+)$/.exec(name);if(ar){name=ar[1];arity=parseInt(ar[2])}}if(arity===undefined)throw`Prolog.predicate: illegal specification: ${name}`}const c_name=allocateUTF8(name);const c_module=allocateUTF8(module||"user");const pred=this.bindings.PL_predicate(c_name,arity,c_module);this.module._free(c_name);this.module._free(c_module);return pred}new_module(name){const c_atom=this.new_atom(name);const module=this.bindings.PL_new_module(c_atom);this.unregister_atom(c_atom);return module}consult(...args){return this.forEach("load_files(user:Files)",{Files:args})}load_string(s,id){if(!id){this.__script_id=this.__script_id+1||1;id="/string/"+this.__script_id}return this.forEach("setup_call_cleanup("+"open_string(S, _In),"+"load_files(user:Id, [stream(_In)]),"+"close(_In))",{S:new this.String(s),Id:id})}async load_scripts(){const prolog=this;const scripts=document.querySelectorAll("script[type='text/prolog']");const loaded=[];for(let i=0;i{prolog.query(goal,{Event__:ev}).once()})}fetch(url,opts,type){return fetch(url,opts).then(response=>response[type]())}url_properties(url){return fetch(url,{method:"HEAD"}).then(r=>{if(r.status==200){const size=parseInt(r.headers.get("content-length"));const mods=r.headers.get("last-modified");const time=Date.parse(mods)||0;if(!size instanceof Number)size=-1;return{url:r.url,status:r.status,size:size,last_modified:time/1e3}}else{return{url:url,status:r.status}}})}message_to_string(term){return this.with_frame(()=>{const av=this.new_term_ref(2);this.bindings.PL_put_term(av+0,term);const flags=this.PL_Q_NORMAL;const pred=this.predicate("message_to_string/2");const qid=this.bindings.PL_open_query(0,flags,pred,av);let msg;if(this.bindings.PL_next_solution(qid))msg=this.get_chars(av+1);else msg="Unknown Prolog exception";this.bindings.PL_close_query(qid);return msg},false)}flush_output(stream){if(stream==undefined){flush("stderr");flush("stdout")}else{flush(stream)}}log(...args){log_output("stdout",args)}query(module,flags,pred,argv,map,fid){if(typeof argv==="number"){return new Query(this,module,flags,pred,argv,map)}else if(typeof module==="string"&&pred===undefined){const goal=module;const fid=this.bindings.PL_open_foreign_frame();const av=this.new_term_ref(3);const input=flags||{};this.frame=fid;this.put_chars(av+0,goal);this.toProlog(input,av+1);const q=new Query(this,0,this.PL_Q_CATCH_EXCEPTION,"wasm_call_string/3",av,a=>this.toJSON(a+2));q.from_text=true;return q}}forEach(goal,...args){const prolog=this;const fid=this.bindings.PL_open_foreign_frame();const av=this.new_term_ref(3);let callback;let input;if(typeof args[0]==="object"){input=args[0];callback=args[1]}else{input={};callback=args[0]}if(callback!==undefined&&typeof callback!=="function")throw TypeError("callback must be a function");this.frame=fid;this.put_chars(av+0,goal);this.toProlog(input,av+1);const q=new Query(this,this.MODULE_user,this.PL_Q_ALLOW_YIELD|this.PL_Q_CATCH_EXCEPTION,"wasm_call_string_with_heartbeat/3",av,a=>this.toJSON(a+2));return new Promise(function(resolve,reject){let answers=callback?0:[];function next_foreach(rc){while(true){if(rc.yield!==undefined){switch(rc.yield){case"beat":return setTimeout(()=>next_foreach(rc.resume("true")),0);case"builtin":return rc.resume(rc=>next_foreach(rc));default:throw rc}}else if(rc.value){if(callback){answers++;callback.call(prolog,rc.value)}else{answers.push(rc.value)}if(rc.done==false){rc=q.next_yieldable();continue}}q.close();if(rc.error)return reject(rc.message);if(rc.done)return resolve(answers)}}return next_foreach(q.next_yieldable())})}abort(){this.abort_request=true}promise_sleep(time){const f=function(resolve,reject){f.reject=reject;f.timer=setTimeout(()=>{f.timer=undefined;resolve(true)},time*1e3)};f.abort=function(){if(f.timer){clearTimeout(f.timer);f.timer=undefined;f.reject("abort")}};return new this.Promise(f)}stream(name){const iob=this.bindings._PL_streams();let offset=undefined;switch(name){case"user_input":offset=0;break;case"user_output":offset=1;break;case"user_error":offset=2;break;default:throw`Unknown stream ${name}`}return this.module.getValue(iob+offset*4,"i32")}write(term,opts){opts=opts||{};const precedence=opts.precedence||1200;const flags=opts.flags==undefined?this.PL_WRT_QUOTED|this.PL_WRT_NEWLINE:flags;let s=undefined;if(opts.stream){if(typeof stream==="string")s=this.stream(opts.stream)}else{s=this.stream("user_output")}return this.bindings.PL_write_term(s,term,precedence,flags)}functor_arity(functor){return this.bindings.PL_functor_arity(functor)}functor_name(functor){return this.bindings.PL_functor_name(functor)}get_functor(term){const ptr=this.module._malloc(4);let result;if(this.bindings.PL_get_functor(term,ptr))result=this.module.getValue(ptr,"i32");else result=null;this.module._free(ptr);return result}get_integer(term){const ptr=this.module._malloc(8);let rc;if(this.bindings.PL_get_int64(term,ptr)){rc=this.module.getValue(ptr,"i64");if(rc>=Number.MIN_SAFE_INTEGER&&rc<=Number.MAX_SAFE_INTEGER)rc=Number(rc)}else{const s=this.get_chars(term,this.CVT_INTEGER);rc=BigInt(s)}this.module._free(ptr);return rc}get_float(term){const ptr=this.module._malloc(8);let rc;if(this.bindings.PL_get_float(term,ptr)){rc=this.module.getValue(ptr,"double")}else{rc=null}this.module._free(ptr);return rc}put_chars(term,string,flags){flags=flags||this.PL_STRING;flags|=this.REP_UTF8;const c=this.__string_to_c(string);const ret=!!this.bindings.PL_put_chars(term,flags,c.length,c.ptr);this.module._free(c.ptr);return ret}put_bytes(term,array_buffer){const content=new Uint8Array(array_buffer);return!!this.bindings.put_bytes(term,this.PL_STRING|this.REP_ISO_LATIN_1,content.length,content)}put_bigint(term,value){const s=value.toString();return this.bindings.PL_put_term_from_chars(term,this.REP_UTF8,-1,s)}unify(term1,term2){return!!this.bindings.PL_unify(term1,term2)}is_string(term){return!!this.bindings.PL_is_string(term)}is_variable(term){return!!this.bindings.PL_is_variable(term)}atom_chars(atom){const t=this.new_term_ref();this.bindings.PL_put_atom(t,atom);const str=this.get_chars(t,this.CVT_ATOM);this.bindings.PL_reset_term_refs(t);return str}ttymode(){return this.module.UTF8ToString(this.bindings.WASM_ttymode())}yield_request(){const tref=this.bindings.WASM_yield_request();return this.toJSON(tref)}set_yield_result(obj){this.with_frame(()=>{const term=this.toProlog(obj,undefined,{string:"string"});if(!term){console.log("Could not convert",obj);throw"Could not convert JavaScript data to Prolog"}this.bindings.WASM_set_yield_result(term)},true)}__call_yieldable(goal,module){var pred_call1;const flags=this.PL_Q_NORMAL|this.PL_Q_ALLOW_YIELD;if(!pred_call1)pred_call1=this.predicate("call",1,"system");const fid=this.bindings.PL_open_foreign_frame();const term=this.new_term_ref();if(!this.chars_to_term(goal,term))throw new Error("Query has a syntax error: "+query);const q=this.query(module,flags,pred_call1,term,fid);return q.next_yieldable()}set_arg_names(name,args){if(!this.functor_arg_names_[name])this.functor_arg_names_[name]={};this.functor_arg_names_[name][args.length]=args}arg_names(name,arity){if(this.functor_arg_names_[name])return this.functor_arg_names_[name][arity]}toJSON(term,options){options=options||{};function toJSON(prolog,term,options){switch(prolog.bindings.PL_term_type(term)){case prolog.PL_VARIABLE:return new prolog.Var(prolog.bindings.WASM_variable_id(term));case prolog.PL_STRING:if(options.string!=="string")return new prolog.String(prolog.get_chars(term));case prolog.PL_ATOM:return prolog.get_chars(term);case prolog.PL_NIL:return[];case prolog.PL_BLOB:{const id=prolog.bindings.js_get_obj(term);if(id!=-1)return prolog.objects[id];return new prolog.Blob}case prolog.PL_INTEGER:return prolog.get_integer(term);case prolog.PL_RATIONAL:{let s=prolog.get_chars(term,prolog.CVT_RATIONAL);let a=s.split("r");function toInt(s){const bi=BigInt(s);if(bi>=Number.MIN_SAFE_INTEGER&&bi<=Number.MAX_SAFE_INTEGER)return Number(bi);return bi}return new prolog.Rational(toInt(a[0]),toInt(a[1]))}case prolog.PL_FLOAT:return prolog.get_float(term);case prolog.PL_TERM:{const f=prolog.get_functor(term);const name=prolog.atom_chars(prolog.functor_name(f));const arity=prolog.functor_arity(f);const map=prolog.arg_names(name,arity);const a=prolog.new_term_ref();if(map){let result={$tag:name};for(var i=0;i=0&&rc;i--){rc=toProlog(prolog,data[i],h,ctx)&&prolog.bindings.PL_cons_list(term,h,term)}return rc}switch(typeof data){case"number":if(Number.isInteger(data))rc=prolog.bindings.PL_put_integer(term,data);else rc=prolog.bindings.PL_put_float(term,data);break;case"bigint":rc=prolog.put_bigint(term,data);break;case"string":{const flags=ctx.string==="string"?prolog.PL_STRING:prolog.PL_ATOM;rc=prolog.put_chars(term,data,flags);break}case"boolean":rc=prolog.put_chars(term,data?"true":"false",prolog.PL_ATOM);break;case"undefined":rc=prolog.put_chars(term,"undefined",prolog.PL_ATOM);break;case"object":if(data===null){rc=prolog.put_chars(term,"null",prolog.PL_ATOM)}else if(Array.isArray(data)){rc=toList(term,data)}else if(data.$t){switch(data.$t){case"s":rc=prolog.put_chars(term,data.v,prolog.PL_STRING);break;case"r":{const s=data.n+"r"+data.d;rc=prolog.bindings.PL_put_term_from_chars(term,prolog.REP_UTF8,-1,s);break}case"t":{const keys=Object.keys(data);let args;let name;for(var i=0;i{prolog.set_yield_result(value);return this.next()}}}}}next_yieldable(){function next(query){const prolog=query.prolog;while(true){let rc=query.next();if(rc.yield!==undefined){let request=rc.yield;if(prolog.abort_request){prolog.abort_request=undefined;prolog.set_yield_result("abort");continue}if(request==="beat"){const now=Date.now();const passed=now-prolog.lastyieldat;if(passed<20){prolog.set_yield_result("true");continue}prolog.lastyieldat=now}else if(request instanceof Promise){let result={yield:"builtin",request:request,query:query,resume:cont=>{if(typeof cont==="string"){prolog.set_yield_result(cont);return next(query)}else{result.cont=cont;request.then(value=>{prolog.set_yield_result(value);cont.call(prolog,next(query))}).catch(error=>{prolog.set_yield_result({$error:error});cont.call(prolog,next(query))})}},abort:()=>{if(!(request.abort&&request.abort())){console.log("Cannot abort",request);prolog.abort_request=true}}};return result}rc.resume=value=>{prolog.set_yield_result(value);return next(query)}}else if(rc.done===false){rc.resume=()=>next(query)}return rc}}return next(this)}once(){const rc=this.next();this.close();if(this.from_text){delete rc.done;if(rc.value){rc.value.success=true;return rc.value}else{if(!rc.error)rc.success=false;return rc}}else{return rc.value?rc.value:rc}}close(){if(this.open){const prolog=this.prolog;if(this!=prolog.open_queries.at(-1))console.log("Attempt for Query.close() on not innermost query");prolog.open_queries.pop();this.prolog.bindings.PL_cut_query(this.qid);if(this.frame)this.prolog.bindings.PL_discard_foreign_frame(this.frame);this.open=false}}}Module.onRuntimeInitialized=function(){Module.prolog=new Prolog(Module,Module.arguments)};function prolog_js_call(request,result){const prolog=Module.prolog;function eval_chain(ar,obj){obj=obj||window;function eval_one(obj,fname,args){if(args.length==0){switch(fname){case"instanceof":return obj.constructor.name}}else if(args.length==1){switch(fname){case"-":return-args[0];case"!":return!args[0];case"instanceof":return obj instanceof args[0]}}else if(args.length==2){switch(fname){case"+":return args[0]+args[1];case"-":return args[0]-args[1];case"*":return args[0]*args[1];case"/":return args[0]/args[1];case"&":return args[0]&args[1];case"|":return args[0]|args[1];case"&&":return args[0]&&args[1];case"||":return args[0]||args[1]}}const func=obj[fname];if(typeof func==="function")return func.apply(obj,args);else console.log("ERROR: Function",fname,"is not defined on",obj)}for(let i=0;ieval_chain(v));obj=eval_one(obj,next.f,args)}}return obj}try{return prolog.with_frame(()=>{const ar=prolog.toJSON(request,{string:"string"});let obj;if(ar.setter){const target=eval_chain(ar.target);const value=eval_chain(ar.value);target[ar.setter]=value;obj=true}else{obj=eval_chain(ar)}return prolog.unify(result,prolog.toProlog(obj))},false)}catch(e){return prolog.bindings.PL_raise_exception(prolog.toProlog(new prolog.Compound("error",[new prolog.Compound("js_error",[e.toString()]),new prolog.Var])))}}function prolog_js_obj_class_name(id){const prolog=Module.prolog;const obj=prolog.objects[id];return obj.constructor.name}function release_registered_object(id){const prolog=Module.prolog;const obj=prolog.objects[id];prolog.object_ids.delete(obj);delete prolog.objects[id]}if(BigInt.prototype.toJSON===undefined){BigInt.prototype.toJSON=function(){return this.toString()}}if(typeof HTMLCollection==="object"){HTMLCollection.prototype.toList=function(){const ar=[];for(let i=0;i* * * -eye - swipl -g main eye.pl -- - - --blogic support RDF surfaces - --csv-separator CSV separator such as , or ; - --debug output debug info on stderr - --debug-cnt output debug info about counters on stderr - --debug-djiti output debug info about DJITI on stderr - --debug-pvm output debug info about PVM code on stderr - --help show help info - --hmac-key HMAC key used in e:hmac-sha built-in - --ignore-inference-fuse do not halt in case of inference fuse - --image output all and all code to - --intermediate output all to - --license show license info - --max-inferences halt after maximum number of inferences - --multi-query go into query answer loop - --no-distinct-input no distinct triples in the input - --no-distinct-output no distinct answers in the output - --no-erase no erase functionality for blogic - --no-numerals no numerals in the output - --no-qnames no qnames in the output - --no-qvars no qvars in the output - --no-ucall no extended unifier for forward rules - --nope no proof explanation - --output output reasoner output to - --profile output profile info on stderr - --quantify quantify uris with in the output - --quiet quiet mode - --random-seed create random seed for e:random built-in - --restricted restricting to core built-ins - --rule-histogram output rule histogram info on stderr - --skolem-genid use in Skolem IRIs - --source read command line arguments from - --statistics output statistics info on stderr - --strings output log:outputString objects on stdout - --tactic limited-answer give only a limited number of answers - --tactic linear-select select each rule only once - --version show version info - --warn output warning info on stderr - --wcache to tell that is cached as - - [--n3] N3 triples and rules - --n3p N3P intermediate - --proof N3 proof lemmas - --turtle Turtle triples - - --entail output true if RDF graph is entailed - --not-entail output true if RDF graph is not entailed - --pass output deductive closure - --pass-all output deductive closure plus rules - --pass-all-ground ground the rules and run --pass-all - --pass-only-new output only new derived triples - --query output filtered with filter rules'). - -:- dynamic(answer/3). % answer(Predicate, Subject, Object) -:- dynamic(argi/1). -:- dynamic(base_uri/1). -:- dynamic(bcnd/2). -:- dynamic(bgot/3). -:- dynamic(brake/0). -:- dynamic(bref/2). -:- dynamic(bvar/1). -:- dynamic(cc/1). -:- dynamic(cpred/1). -:- dynamic(data_fuse/0). -:- dynamic(evar/3). -:- dynamic(exopred/3). % exopred(Predicate, Subject, Object) -:- dynamic(fact/1). -:- dynamic(flag/1). -:- dynamic(flag/2). -:- dynamic(fpred/1). -:- dynamic(got_dq/0). -:- dynamic(got_head/0). -:- dynamic(got_labelvars/3). -:- dynamic(got_pi/0). -:- dynamic(got_random/3). -:- dynamic(got_sq/0). -:- dynamic(got_unique/2). -:- dynamic(got_wi/5). % got_wi(Source, Premise, Premise_index, Conclusion, Rule) -:- dynamic(got_uuid/1). -:- dynamic(graph/2). -:- dynamic(hash_value/2). -:- dynamic(implies/3). % implies(Premise, Conclusion, Source) -:- dynamic(input_statements/1). -:- dynamic(intern/1). -:- dynamic(keep_skolem/1). -:- dynamic(lemma/6). % lemma(Count, Source, Premise, Conclusion, Premise-Conclusion_index, Rule) -:- dynamic(mtime/2). -:- dynamic(n3s/2). -:- dynamic(ncllit/0). -:- dynamic(ns/2). -:- dynamic(pass_only_new/1). -:- dynamic(pfx/2). -:- dynamic(pred/1). -:- dynamic(prfstep/7). % prfstep(Conclusion_triple, Premise, Premise_index, Conclusion, Rule, Chaining, Source) -:- dynamic(qevar/3). -:- dynamic(query/2). -:- dynamic(quvar/3). -:- dynamic(retwist/3). -:- dynamic(rule_uvar/1). -:- dynamic(scope/1). -:- dynamic(scount/1). -:- dynamic(semantics/2). -:- dynamic(span/1). -:- dynamic(tabl/3). -:- dynamic(tmpfile/1). -:- dynamic(tuple/2). -:- dynamic(tuple/3). -:- dynamic(tuple/4). -:- dynamic(tuple/5). -:- dynamic(tuple/6). -:- dynamic(tuple/7). -:- dynamic(tuple/8). -:- dynamic(wcache/2). -:- dynamic(wpfx/1). -:- dynamic(wtcache/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). -:- dynamic(''/2). - -% -% Main goal -% - -main(Argv) :- - set_prolog_flag(argv, Argv), - catch(run, Exc, - ( Exc = halt(_) - -> true - ; throw(Exc) - ) - ). - -main :- - catch(run, Exc, - ( Exc = halt(EC) - -> halt(EC) - ; throw(Exc) - ) - ). - -run :- - current_prolog_flag(version_data, swi(SV, _, _, _)), - ( SV < 8 - -> format(user_error, '** ERROR ** EYE requires at least swipl version 8 **~n', []), - flush_output(user_error), - throw(halt(1)) - ; true - ), - catch(set_stream(user_output, encoding(utf8)), _, true), - current_prolog_flag(argv, Argv), - ( append(_, ['--'|Argvp], Argv) - -> true - ; Argvp = Argv - ), - ( Argvp = ['--source', File] - -> ( File = '-' - -> read_line_to_codes(user_input, Codes) - ; read_file_to_codes(File, Codes, []) - ), - atom_codes(Atom, Codes), - atomic_list_concat(Argvs, ' ', Atom) - ; Argvs = Argvp - ), - argv(Argvs, Argus), - findall(Argij, - ( argi(Argij) - ), - Argil - ), - append(Argil, Argi), - format(user_error, 'eye~@~@~n', [w0(Argi), w1(Argus)]), - flush_output(user_error), - version_info(Version), - format(user_error, '~w~n', [Version]), - flush_output(user_error), - ( current_prolog_flag(version_git, PVersion) - -> true - ; current_prolog_flag(version_data, swi(Major, Minor, Patch, Options)), - ( memberchk(tag(Tag), Options) - -> atomic_list_concat([Major, '.', Minor, '.', Patch, '-', Tag], PVersion) - ; atomic_list_concat([Major, '.', Minor, '.', Patch], PVersion) - ) - ), - format(user_error, 'SWI-Prolog version ~w~n', [PVersion]), - flush_output(user_error), - ( retract(prolog_file_type(qlf, qlf)) - -> assertz(prolog_file_type(pvm, qlf)) - ; true - ), - ( Argv = ['--n3', _] - -> retractall(flag('parse-only')), - assertz(flag('parse-only')) - ; true - ), - catch(gre(Argus), Exc, - ( Exc = halt(0) - -> true - ; ( flag('parse-only') - -> true - ; format(user_error, '** ERROR ** gre ** ~w~n', [Exc]), - flush_output(user_error), - nb_setval(exit_code, 3) - ) - ) - ), - ( flag(statistics) - -> statistics - ; true - ), - ( flag('debug-pvm') - -> tell(user_error), - ignore(vm_list(_)), - told, - ( flag('output', Output) - -> tell(Output) - ; true - ) - ; true - ), - ( flag('debug-djiti') - -> tell(user_error), - jiti_list, - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ) - ; true - ), - nb_getval(exit_code, EC), - flush_output, - throw(halt(EC)). - -argv([], []) :- - !. -argv([Arg|Argvs], [U, V|Argus]) :- - sub_atom(Arg, B, 1, E, '='), - sub_atom(Arg, 0, B, _, U), - memberchk(U, ['--csv-separator', '--hmac-key', '--image', '--max-inferences', '--n3', '--n3p', '--proof', '--quantify', '--query', '--output', '--skolem-genid', '--tactic', '--turtle']), - !, - sub_atom(Arg, _, E, 0, V), - argv(Argvs, Argus). -argv([Arg|Argvs], [Arg|Argus]) :- - argv(Argvs, Argus). - - -% ------------------------------ -% GRE (Generic Reasoning Engine) -% ------------------------------ - -gre(Argus) :- - statistics(runtime, [T0, _]), - statistics(walltime, [T1, _]), - format(user_error, 'starting ~w [msec cputime] ~w [msec walltime]~n', [T0, T1]), - flush_output(user_error), - nb_setval(entail_mode, false), - nb_setval(exit_code, 0), - nb_setval(indentation, 0), - nb_setval(limit, -1), - nb_setval(bnet, not_done), - nb_setval(fnet, not_done), - nb_setval(tabl, -1), - nb_setval(tuple, -1), - nb_setval(fdepth, 0), - nb_setval(pdepth, 0), - nb_setval(cdepth, 0), - ( input_statements(Ist) - -> nb_setval(input_statements, Ist) - ; nb_setval(input_statements, 0) - ), - nb_setval(output_statements, 0), - nb_setval(current_scope, '<>'), - nb_setval(wn, 0), - opts(Argus, Args), - ( \+flag('multi-query'), - Args = [] - -> opts(['--help'], _) - ; true - ), - ( flag('skolem-genid', Genid) - -> true - ; A is random(2^62), - atom_number(Genid, A) - ), - atomic_list_concat(['http://josd.github.io/.well-known/genid/', Genid, '#'], Sns), - nb_setval(var_ns, Sns), - ( ( flag(strings) - ; flag(image, _) - ) - -> true - ; version_info(Version), - ( flag(quiet) - -> true - ; format('#Processed by ~w~n', [Version]) - ), - findall(Argij, - ( argi(Argij) - ), - Argil - ), - append(Argil, Argi), - ( flag(quiet) - -> true - ; format('#eye~@~@~n~n', [w0(Argi), w1(Argus)]), - flush_output - ) - ), - ( ( flag('no-qvars') - ; flag('pass-all-ground') - ) - -> retractall(pfx('var:', _)), - assertz(pfx('var:', '')) - ; true - ), - ( flag('intermediate', Out) - -> format(Out, 'flag(\'quantify\', \'~w\').~n', [Sns]) - ; true - ), - args(Args), - ( implies(_, Conc, _), - ( var(Conc) - ; Conc \= answer(_, _, _), - Conc \= (answer(_, _, _), _) - ) - -> true - ; ( \+flag(image, _), - \+flag(tactic, 'linear-select') - -> assertz(flag(tactic, 'linear-select')) - ; true - ) - ), - findall(Sc, - ( scope(Sc) - ), - Scope - ), - nb_setval(scope, Scope), - statistics(runtime, [_, T2]), - statistics(walltime, [_, T3]), - format(user_error, 'networking ~w [msec cputime] ~w [msec walltime]~n', [T2, T3]), - flush_output(user_error), - nb_getval(input_statements, SC), - ( flag(image, File) - -> assertz(argi(Argus)), - retractall(flag(image, _)), - assertz(flag('quantify', Sns)), - retractall(input_statements(_)), - assertz(input_statements(SC)), - reset_gensym, - ( current_predicate(qsave:qsave_program/1) - -> qsave_program(File) - ; save_program(File) - ), - throw(halt(0)) - ; true - ), - ( flag('intermediate', Out) - -> ( SC =\= 0 - -> write(Out, scount(SC)), - writeln(Out, '.') - ; true - ), - writeln(Out, 'end_of_file.'), - close(Out) - ; true - ), - ( \+implies(_, answer(_, _, _), _), - \+implies(_, (answer(_, _, _), _), _), - \+query(_, _), - \+flag('pass-only-new'), - \+flag('multi-query'), - \+flag(strings) - -> throw(halt(0)) - ; true - ), - ( flag(nope) - -> true - ; ( pfx('r:', _) - -> true - ; assertz(pfx('r:', '')) - ), - ( pfx('var:', _) - -> true - ; assertz(pfx('var:', '')) - ), - ( pfx('skolem:', _) - -> true - ; nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, '>'], B), - assertz(pfx('skolem:', B)) - ), - ( pfx('n3:', _) - -> true - ; assertz(pfx('n3:', '')) - ) - ), - nb_setval(tr, 0), - nb_setval(tc, 0), - nb_setval(tp, 0), - nb_setval(rn, 0), - nb_setval(lemma_count, 0), - nb_setval(lemma_cursor, 0), - nb_setval(answer_count, 0), - ( flag('multi-query') - -> nb_setval(mq, 0), - repeat, - catch((read_line_to_codes(user_input, Fc), atom_codes(Fa, Fc)), _, Fa = end_of_file), - ( atomic_list_concat([Fi, Fo], ', ', Fa) - -> open(Fo, write, Fos, [encoding(utf8)]) - ; Fi = Fa, - ( flag('output', Output) - -> Fos = Output - ; Fos = user_output - ) - ), - tell(Fos), - ( Fi = end_of_file - -> true - ; statistics(walltime, [_, _]), - nb_getval(output_statements, Outb), - statistics(inferences, Infb), - ( flag(blogic) - -> Amq = ['--n3', Fi] - ; Amq = ['--query', Fi] - ), - catch(args(Amq), Exc1, - ( format(user_error, '** ERROR ** args ** ~w~n', [Exc1]), - flush_output(user_error), - nb_setval(exit_code, 3) - ) - ), - catch(eam(0), Exc2, - ( ( Exc2 = halt(0) - -> true - ; format(user_error, '** ERROR ** eam ** ~w~n', [Exc2]), - flush_output(user_error), - ( Exc2 = inference_fuse(_) - -> nb_setval(exit_code, 2) - ; nb_setval(exit_code, 3) - ) - ) - ) - ), - ( flag(strings) - -> wst - ; true - ), - forall( - ( answer(A1, A2, A3), - nonvar(A1) - ), - retract(answer(A1, A2, A3)) - ), - retractall(implies(_, answer(_, _, _), _)), - retractall(implies(_, (answer(_, _, _), _), _)), - retractall(query(_, _)), - retractall(''(_, _)), - retractall(cc(_)), - retractall(brake), - retractall(prfstep(answer(_, _, _), _, _, _, _, _, _)), - retractall(lemma(_, _, _, _, _, _)), - retractall(got_wi(_, _, _, _, _)), - retractall(wpfx(_)), - retractall(''(_, _)), - retractall(''(_, _)), - nb_setval(csv_header, []), - cnt(mq), - nb_getval(mq, Cnt), - ( Cnt mod 10000 =:= 0 - -> garbage_collect_atoms - ; true - ), - statistics(runtime, [_, Ti4]), - statistics(walltime, [_, Ti5]), - format(user_error, 'reasoning ~w [msec cputime] ~w [msec walltime]~n', [Ti4, Ti5]), - flush_output(user_error), - nb_getval(output_statements, Oute), - Outd is Oute-Outb, - catch(Outs is round(Outd/Ti5*1000), _, Outs = ''), - ( ( flag(strings) - ; flag(quiet) - ) - -> nl - ; format('#DONE ~3d [sec] mq=~w out=~d out/sec=~w~n~n', [Ti5, Cnt, Outd, Outs]) - ), - timestamp(Stmp), - statistics(inferences, Infe), - Infd is Infe-Infb, - catch(Infs is round(Infd/Ti5*1000), _, Infs = ''), - format(user_error, '~w mq=~w out=~d inf=~w sec=~3d out/sec=~w inf/sec=~w~n~n', [Stmp, Cnt, Outd, Infd, Ti5, Outs, Infs]), - flush_output(user_error), - fail - ), - told - ; ( flag(profile) - -> asserta(pce_profile:pce_show_profile :- fail), - profiler(_, cputime) - ; true - ), - catch(eam(0), Exc3, - ( ( Exc3 = halt(0) - -> true - ; format(user_error, '** ERROR ** eam ** ~w~n', [Exc3]), - flush_output(user_error), - ( Exc3 = inference_fuse(_) - -> nb_setval(exit_code, 2) - ; nb_setval(exit_code, 3) - ) - ) - ) - ), - ( flag('pass-only-new') - -> wh, - forall( - pass_only_new(Zn), - ( indent, - relabel(Zn, Zr), - wt(Zr), - ws(Zr), - write('.'), - nl, - cnt(output_statements) - ) - ), - nl - ; true - ), - ( flag(profile) - -> profiler(_, false), - tell(user_error), - show_profile([]), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ) - ; true - ) - ), - ( flag(strings) - -> wst - ; true - ), - nb_getval(tc, TC), - nb_getval(tp, TP), - statistics(runtime, [_, T4]), - statistics(walltime, [_, T5]), - ( \+flag('multi-query') - -> format(user_error, 'reasoning ~w [msec cputime] ~w [msec walltime]~n', [T4, T5]), - flush_output(user_error) - ; true - ), - nb_getval(input_statements, Inp), - nb_getval(output_statements, Outp), - timestamp(Stamp), - Ent is TC, - Step is TP, - statistics(runtime, [Cpu, _]), - nb_getval(tr, TR), - Brake is TR, - ( statistics(inferences, Inf) - -> true - ; Inf = '' - ), - catch(Speed is round(Inf/Cpu*1000), _, Speed = ''), - ( ( flag(strings) - ; flag(quiet) - ) - -> true - ; format('#~w in=~d out=~d ent=~d step=~w brake=~w inf=~w sec=~3d inf/sec=~w~n#ENDS~n~n', [Stamp, Inp, Outp, Ent, Step, Brake, Inf, Cpu, Speed]) - ), - format(user_error, '~w in=~d out=~d ent=~d step=~w brake=~w inf=~w sec=~3d inf/sec=~w~n~n', [Stamp, Inp, Outp, Ent, Step, Brake, Inf, Cpu, Speed]), - flush_output(user_error), - ( flag('rule-histogram') - -> findall([RTC, RTP, R], - ( tabl(ETP, tp, Rule), - nb_getval(ETP, RTP), - ( tabl(ETC, tc, Rule) - -> nb_getval(ETC, RTC) - ; RTC = 0 - ), - with_output_to(atom(R), wt(Rule)) - ), - CntRl - ), - sort(CntRl, CntRs), - reverse(CntRs, CntRr), - format(user_error, '>>> rule histogram TR=~w <<<~n', [TR]), - forall( - member(RCnt, CntRr), - ( ( last(RCnt, ''(X, Y)), - conj_append(X, pstep(_), Z), - catch(clause(Y, Z), _, fail) - -> format(user_error, 'TC=~w TP=~w for component ~w~n', RCnt) - ; format(user_error, 'TC=~w TP=~w for rule ~w~n', RCnt) - ) - ) - ), - format(user_error, '~n', []), - flush_output(user_error) - ; true - ). - -% -% command line options -% - -opts([], []) :- - !. -opts(['--blogic'|Argus], Args) :- - !, - retractall(flag(blogic)), - assertz(flag(blogic)), - assertz(implies(''(_, G), G, '<>')), - assertz(implies((''(V, G), - makevars(G, H, beta(V)), - call(H) - ), false, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(W, H), L, K), - conj_list(C, K), - conj_list(H, M), - select(''(W, C), M, _) - ), ''(W, C), '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(_, H), L, K), - conj_list(C, K), - makevars(''(C, H), B, beta(V)) - ), B, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(W, H), L, K), - dsplit(K, M, J), - J \= [], - conj_list(R, M), - conj_list(T, J), - ( H = ''(W, A) - -> D = A - ; D = ''(W, H) - ), - ( T = ''(W, F) - -> E = F - ; E = ''(W, T) - ), - makevars(''((D, R), E), B, beta(V)) - ), B, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(W, H), L, K), - conj_list(R, K), - ( H = ''(W, A) - -> D = A - ; D = ''(W, H) - ), - makevars(''(R, D), B, beta(V)) - ), B, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - findall(M, - ( member(M, L), - M \= ''(_, _) - ), - J - ), - conj_list(C, J), - length(L, N), - length(J, K), - I is N-K, - I > 1, - makevars([C,L], [D,E], beta(V)), - call(D), - implies(_, H, _), - findall(F, - ( member(''(_, S), E), - implies(S, F, _) - ), - Q - ), - length(Q, I), - sort(Q, [H]) - ), H, '<>')), - assertz(implies((''(V, G), - conj_list(G, L), - select(''(_, H), L, K), - conj_list(R, K), - makevars(':-'(H, R), C, beta(V)), - copy_term_nat(C, CC), - labelvars(CC, 0, _, avar), - ( \+cc(CC) - -> assertz(cc(CC)), - assertz(C) - ; true - )), true, '<>')), - assertz(implies((''(V, G), - djiti_answer(answer(G), H), - makevars(implies(G, H, '<>'), C, beta(V)), - copy_term_nat(C, CC), - labelvars(CC, 0, _, avar), - ( \+cc(CC) - -> assertz(cc(CC)), - assertz(C), - retractall(brake) - ; true - )), true, '<>')), - opts(Argus, Args). -opts(['--csv-separator',Separator|Argus], Args) :- - !, - retractall(flag('csv-separator')), - assertz(flag('csv-separator', Separator)), - opts(Argus, Args). -opts(['--debug'|Argus], Args) :- - !, - retractall(flag(debug)), - assertz(flag(debug)), - opts(Argus, Args). -opts(['--debug-cnt'|Argus], Args) :- - !, - retractall(flag('debug-cnt')), - assertz(flag('debug-cnt')), - opts(Argus, Args). -opts(['--debug-djiti'|Argus], Args) :- - !, - retractall(flag('debug-djiti')), - assertz(flag('debug-djiti')), - opts(Argus, Args). -opts(['--debug-pvm'|Argus], Args) :- - !, - retractall(flag('debug-pvm')), - assertz(flag('debug-pvm')), - opts(Argus, Args). -opts(['--help'|_], _) :- - \+flag(image, _), - \+flag('debug-pvm'), - !, - help_info(Help), - format(user_error, '~w~n', [Help]), - flush_output(user_error), - throw(halt(0)). -opts(['--hmac-key',Key|Argus], Args) :- - !, - retractall(flag('hmac-key', _)), - assertz(flag('hmac-key', Key)), - opts(Argus, Args). -opts(['--ignore-inference-fuse'|Argus], Args) :- - !, - retractall(flag('ignore-inference-fuse')), - assertz(flag('ignore-inference-fuse')), - opts(Argus, Args). -opts(['--image',File|Argus], Args) :- - !, - retractall(flag(image, _)), - assertz(flag(image, File)), - opts(Argus, Args). -opts(['--license'|_], _) :- - !, - license_info(License), - format(user_error, '~w~n', [License]), - flush_output(user_error), - throw(halt(0)). -opts(['--max-inferences',Lim|Argus], Args) :- - !, - ( number(Lim) - -> Limit = Lim - ; catch(atom_number(Lim, Limit), Exc, - ( format(user_error, '** ERROR ** max-inferences ** ~w~n', [Exc]), - flush_output(user_error), - flush_output, - throw(halt(1)) - ) - ) - ), - retractall(flag('max-inferences', _)), - assertz(flag('max-inferences', Limit)), - opts(Argus, Args). -opts(['--multi-query'|Argus], Args) :- - !, - retractall(flag('multi-query')), - assertz(flag('multi-query')), - opts(Argus, Args). -opts(['--no-distinct-input'|Argus], Args) :- - !, - retractall(flag('no-distinct-input')), - assertz(flag('no-distinct-input')), - opts(Argus, Args). -opts(['--no-distinct-output'|Argus], Args) :- - !, - retractall(flag('no-distinct-output')), - assertz(flag('no-distinct-output')), - opts(Argus, Args). -opts(['--no-erase'|Argus], Args) :- - !, - retractall(flag('no-erase')), - assertz(flag('no-erase')), - opts(Argus, Args). -opts(['--no-numerals'|Argus], Args) :- - !, - retractall(flag('no-numerals')), - assertz(flag('no-numerals')), - opts(Argus, Args). -opts(['--no-qnames'|Argus], Args) :- - !, - retractall(flag('no-qnames')), - assertz(flag('no-qnames')), - opts(Argus, Args). -opts(['--no-qvars'|Argus], Args) :- - !, - retractall(flag('no-qvars')), - assertz(flag('no-qvars')), - opts(Argus, Args). -opts(['--no-ucall'|Argus], Args) :- - !, - retractall(flag('no-ucall')), - assertz(flag('no-ucall')), - opts(Argus, Args). -opts(['--nope'|Argus], Args) :- - !, - retractall(flag(nope)), - assertz(flag(nope)), - opts(Argus, Args). -opts(['--output',File|Argus], Args) :- - !, - retractall(flag('output', _)), - open(File, write, Out, [encoding(utf8)]), - tell(Out), - assertz(flag('output', Out)), - opts(Argus, Args). -opts(['--pass-all-ground'|Argus], Args) :- - !, - retractall(flag('pass-all-ground')), - assertz(flag('pass-all-ground')), - opts(['--pass-all'|Argus], Args). -opts(['--pass-only-new'|Argus], Args) :- - !, - retractall(flag('pass-only-new')), - assertz(flag('pass-only-new')), - opts(Argus, Args). -opts(['--intermediate',File|Argus], Args) :- - !, - retractall(flag('intermediate', _)), - open(File, write, Out, [encoding(utf8)]), - assertz(flag('intermediate', Out)), - opts(Argus, Args). -opts(['--profile'|Argus], Args) :- - !, - retractall(flag(profile)), - assertz(flag(profile)), - opts(Argus, Args). -opts(['--quantify',Prefix|Argus], Args) :- - !, - assertz(flag('quantify', Prefix)), - opts(Argus, Args). -opts(['--quiet'|Argus], Args) :- - !, - retractall(flag(quiet)), - assertz(flag(quiet)), - opts(Argus, Args). -opts(['--random-seed'|Argus], Args) :- - !, - N is random(2^120), - nb_setval(random, N), - opts(Argus, Args). -opts(['--restricted'|Argus], Args) :- - !, - retractall(flag(restricted)), - assertz(flag(restricted)), - opts(Argus, Args). -opts(['--rule-histogram'|Argus], Args) :- - !, - retractall(flag('rule-histogram')), - assertz(flag('rule-histogram')), - opts(Argus, Args). -opts(['--skolem-genid',Genid|Argus], Args) :- - !, - retractall(flag('skolem-genid', _)), - assertz(flag('skolem-genid', Genid)), - opts(Argus, Args). -opts(['--statistics'|Argus], Args) :- - !, - retractall(flag(statistics)), - assertz(flag(statistics)), - opts(Argus, Args). -opts(['--strings'|Argus], Args) :- - !, - retractall(flag(strings)), - assertz(flag(strings)), - opts(Argus, Args). -opts(['--tactic','limited-answer',Lim|Argus], Args) :- - !, - ( number(Lim) - -> Limit = Lim - ; catch(atom_number(Lim, Limit), Exc, - ( format(user_error, '** ERROR ** limited-answer ** ~w~n', [Exc]), - flush_output(user_error), - flush_output, - throw(halt(1)) - ) - ) - ), - retractall(flag('limited-answer', _)), - assertz(flag('limited-answer', Limit)), - opts(Argus, Args). -opts(['--tactic','linear-select'|Argus], Args) :- - !, - retractall(flag(tactic, 'linear-select')), - assertz(flag(tactic, 'linear-select')), - opts(Argus, Args). -opts(['--tactic',Tactic|_], _) :- - !, - throw(not_supported_tactic(Tactic)). -opts(['--version'|_], _) :- - !, - throw(halt(0)). -opts(['--warn'|Argus], Args) :- - !, - retractall(flag(warn)), - assertz(flag(warn)), - opts(Argus, Args). -opts(['--wcache',Argument,File|Argus], Args) :- - !, - absolute_uri(Argument, Arg), - retractall(wcache(Arg, _)), - assertz(wcache(Arg, File)), - opts(Argus, Args). -opts([Arg|_], _) :- - \+memberchk(Arg, ['--entail', '--help', '--n3', '--n3p', '--not-entail', '--pass', '--pass-all', '--proof', '--query', '--turtle']), - sub_atom(Arg, 0, 2, _, '--'), - !, - throw(not_supported_option(Arg)). -opts([Arg|Argus], [Arg|Args]) :- - opts(Argus, Args). - -args([]) :- - !. -args(['--entail',Arg|Args]) :- - !, - nb_setval(entail_mode, true), - n3_n3p(Arg, entail), - nb_setval(entail_mode, false), - args(Args). -args(['--not-entail',Arg|Args]) :- - !, - nb_setval(entail_mode, true), - n3_n3p(Arg, 'not-entail'), - nb_setval(entail_mode, false), - args(Args). -args(['--n3',Arg|Args]) :- - !, - absolute_uri(Arg, A), - atomic_list_concat(['<', A, '>'], R), - assertz(scope(R)), - ( flag('intermediate', Out) - -> portray_clause(Out, scope(R)) - ; true - ), - n3_n3p(Arg, data), - nb_setval(fdepth, 0), - nb_setval(pdepth, 0), - nb_setval(cdepth, 0), - args(Args). -args(['--n3p',Argument|Args]) :- - !, - absolute_uri(Argument, Arg), - ( wcacher(Arg, File) - -> format(user_error, 'GET ~w FROM ~w ', [Arg, File]), - flush_output(user_error), - open(File, read, In, [encoding(utf8)]) - ; format(user_error, 'GET ~w ', [Arg]), - flush_output(user_error), - ( ( sub_atom(Arg, 0, 5, _, 'http:') - -> true - ; sub_atom(Arg, 0, 6, _, 'https:') - ) - -> http_open(Arg, In, []), - set_stream(In, encoding(utf8)) - ; ( sub_atom(Arg, 0, 5, _, 'file:') - -> ( parse_url(Arg, Parts) - -> memberchk(path(File), Parts) - ; sub_atom(Arg, 7, _, 0, File) - ) - ; File = Arg - ), - ( File = '-' - -> In = user_input - ; open(File, read, In, [encoding(utf8)]) - ) - ) - ), - repeat, - read_term(In, Rt, []), - ( Rt = end_of_file - -> catch(read_term(In, _, []), _, true) - ; n3pin(Rt, In, File, data), - fail - ), - !, - ( File = '-' - -> true - ; close(In) - ), - ( retract(tmpfile(File)) - -> delete_file(File) - ; true - ), - findall(SCnt, - ( retract(scount(SCnt)) - ), - SCnts - ), - sum(SCnts, SC), - nb_getval(input_statements, IN), - Inp is SC+IN, - nb_setval(input_statements, Inp), - ( SC =\= 0 - -> format(user_error, 'SC=~w~n', [SC]) - ; format(user_error, '~n', []) - ), - flush_output(user_error), - args(Args). -args(['--pass'|Args]) :- - !, - ( flag(nope), - \+flag('limited-answer', _), - ( flag('no-distinct-input') - -> flag('no-distinct-output') - ; true - ), - \+implies(_, answer(_, _, _), _), - \+implies(_, (answer(_, _, _), _), _) - -> assertz(query(exopred(P, S, O), exopred(P, S, O))) - ; assertz(implies(exopred(P, S, O), answer(P, S, O), '')) - ), - ( flag('intermediate', Out) - -> portray_clause(Out, implies(exopred(P, S, O), answer(P, S, O), '')) - ; true - ), - args(Args). -args(['--pass-all'|Args]) :- - !, - assertz(implies((exopred(P, S, O), ''(P, '')), - answer(P, S, O), '')), - assertz(implies((''(A, C), ''(A, true)), - answer('', A, C), '')), - assertz(implies(':-'(C, A), - answer(':-', C, A), '')), - ( flag('intermediate', Out) - -> portray_clause(Out, implies((exopred(P, S, O), ''(P, '')), - answer(P, S, O), '')), - portray_clause(user_error, implies((''(A, C), ''(A, true)), - answer('', A, C), '')), - portray_clause(user_error, implies((':-'(C, A), ''(A, true)), - answer(':-', C, A), '')) - ; true - ), - args(Args). -args(['--proof',Arg|Args]) :- - !, - absolute_uri(Arg, A), - atomic_list_concat(['<', A, '>'], R), - assertz(scope(R)), - ( flag('intermediate', Out) - -> portray_clause(Out, scope(R)) - ; true - ), - n3_n3p(Arg, data), - ( got_pi - -> true - ; assertz(implies((''(LEMMA, ''), - ''(LEMMA, GRAPH), - ''(GRAPH, exopred(P, S, O))), - exopred(P, S, O), '')), - assertz(implies((''(LEMMA, ''), - ''(LEMMA, GRAPH), - ''(GRAPH, exopred(P, S, O))), - exopred(P, S, O), '')), - assertz(got_pi) - ), - args(Args). -args(['--query',Arg|Args]) :- - !, - n3_n3p(Arg, query), - args(Args). -args(['--turtle',Argument|Args]) :- - !, - absolute_uri(Argument, Arg), - atomic_list_concat(['<', Arg, '>'], R), - assertz(scope(R)), - ( flag('intermediate', Out) - -> portray_clause(Out, scope(R)) - ; true - ), - ( wcacher(Arg, File) - -> format(user_error, 'GET ~w FROM ~w ', [Arg, File]), - flush_output(user_error), - open(File, read, In, [encoding(utf8)]) - ; format(user_error, 'GET ~w ', [Arg]), - flush_output(user_error), - ( ( sub_atom(Arg, 0, 5, _, 'http:') - -> true - ; sub_atom(Arg, 0, 6, _, 'https:') - ) - -> http_open(Arg, In, []), - set_stream(In, encoding(utf8)) - ; ( sub_atom(Arg, 0, 5, _, 'file:') - -> ( parse_url(Arg, Parts) - -> memberchk(path(File), Parts) - ; sub_atom(Arg, 7, _, 0, File) - ) - ; File = Arg - ), - ( File = '-' - -> In = user_input - ; open(File, read, In, [encoding(utf8)]) - ) - ) - ), - retractall(base_uri(_)), - ( Arg = '-' - -> absolute_uri('', Abu), - assertz(base_uri(Abu)) - ; assertz(base_uri(Arg)) - ), - retractall(ns(_, _)), - ( Arg = '-' - -> D = '#' - ; atomic_list_concat([Arg, '#'], D) - ), - assertz(ns('', D)), - nb_setval(sc, 0), - rdf_read_turtle(stream(In), Triples, []), - close(In), - forall( - member(rdf(S, P, O), Triples), - ( ttl_n3p(S, Subject), - ttl_n3p(P, Predicate), - ttl_n3p(O, Object), - Triple =.. [Predicate, Subject, Object], - djiti_assertz(Triple), - ( flag('intermediate', Out) - -> format(Out, '~q.~n', [Triple]) - ; true - ), - ( flag(nope) - -> true - ; assertz(prfstep(Triple, true, _, Triple, _, forward, R)) - ) - ) - ), - length(Triples, SC), - nb_getval(input_statements, IN), - Inp is SC+IN, - nb_setval(input_statements, Inp), - format(user_error, 'SC=~w~n', [SC]), - flush_output(user_error), - args(Args). -args([Arg|Args]) :- - args(['--n3', Arg|Args]). - -n3pin(Rt, In, File, Mode) :- - ( Rt = ':-'(Rg) - -> ( flag('parse-only') - -> true - ; call(Rg) - ), - ( flag('intermediate', Out) - -> format(Out, '~q.~n', [Rt]) - ; true - ) - ; dynify(Rt), - ( ( Rt = ':-'(Rh, _) - -> predicate_property(Rh, dynamic) - ; predicate_property(Rt, dynamic) - ) - -> true - ; ( File = '-' - -> true - ; close(In) - ), - ( retract(tmpfile(File)) - -> delete_file(File) - ; true - ), - throw(builtin_redefinition(Rt)) - ), - ( Rt = pfx(Pfx, _) - -> retractall(pfx(Pfx, _)) - ; true - ), - ( Rt = scope(Scope) - -> nb_setval(current_scope, Scope) - ; true - ), - ( Rt = ':-'(Ci, Px), - conjify(Px, Pi) - -> ( Ci = true - -> ( flag('parse-only') - -> true - ; call(Pi) - ) - ; nb_getval(current_scope, Si), - copy_term_nat(''(Pi, Ci), Ri), - ( flag(nope) - -> Ph = Pi - ; ( Pi = when(Ai, Bi) - -> conj_append(Bi, istep(Si, Pi, Ci, Ri), Bh), - Ph = when(Ai, Bh) - ; conj_append(Pi, istep(Si, Pi, Ci, Ri), Ph) - ) - ), - ( flag('rule-histogram') - -> ( Ph = when(Ak, Bk) - -> conj_append(Bk, pstep(Ri), Bj), - Pj = when(Ak, Bj) - ; conj_append(Ph, pstep(Ri), Pj) - ) - ; Pj = Ph - ), - functor(Ci, CPi, _), - ( flag('intermediate', Out) - -> ( \+cpred(CPi) - -> portray_clause(Out, cpred(CPi)) - ; true - ), - portray_clause(Out, ':-'(Ci, Pi)) - ; true - ), - ( \+cpred(CPi) - -> assertz(cpred(CPi)) - ; true - ), - assertz(':-'(Ci, Pj)) - ) - ; ( Rt \= implies(_, _, _), - Rt \= scount(_), - \+flag('no-distinct-input'), - call(Rt) - -> true - ; ( Rt \= pred(''), - \+ (Rt = scope(_), Mode = query) - -> djiti_assertz(Rt), - ( flag('intermediate', Out), - Rt \= scount(_) - -> format(Out, '~q.~n', [Rt]) - ; true - ), - ( Rt \= flag(_, _), - Rt \= scope(_), - Rt \= pfx(_, _), - Rt \= pred(_), - Rt \= cpred(_), - Rt \= scount(_) - -> ( flag(nope) - -> true - ; term_index(true, Pnd), - nb_getval(current_scope, Src), - assertz(prfstep(Rt, true, Pnd, Rt, _, forward, Src)) - ) - ; true - ) - ; true - ) - ) - ) - ). - -% N3 to N3P compiler - -n3_n3p(Argument, Mode) :- - absolute_uri(Argument, Arg), - tmp_file(Tmp), - ( wcacher(Arg, File) - -> format(user_error, 'GET ~w FROM ~w ', [Arg, File]), - flush_output(user_error), - open(File, read, In, [encoding(utf8)]) - ; format(user_error, 'GET ~w ', [Arg]), - flush_output(user_error), - ( ( sub_atom(Arg, 0, 5, _, 'http:') - -> true - ; sub_atom(Arg, 0, 6, _, 'https:') - ) - -> http_open(Arg, In, []), - set_stream(In, encoding(utf8)) - ; ( sub_atom(Arg, 0, 5, _, 'file:') - -> ( parse_url(Arg, Parts) - -> memberchk(path(File), Parts) - ; sub_atom(Arg, 7, _, 0, File) - ) - ; File = Arg - ), - ( File = '-' - -> In = user_input - ; open(File, read, In, [encoding(utf8)]) - ) - ) - ), - retractall(base_uri(_)), - ( Arg = '-' - -> absolute_uri('', Abu), - assertz(base_uri(Abu)) - ; assertz(base_uri(Arg)) - ), - retractall(ns(_, _)), - ( Arg = '-' - -> D = '#' - ; atomic_list_concat([Arg, '#'], D) - ), - assertz(ns('', D)), - retractall(quvar(_, _, _)), - retractall(qevar(_, _, _)), - retractall(evar(_, _, _)), - nb_setval(line_number, 1), - nb_setval(sc, 0), - nb_setval(semantics, []), - atomic_list_concat(['\'<', Arg, '>\''], Src), - atomic_list_concat([Tmp, '_p'], Tmp_p), - assertz(tmpfile(Tmp_p)), - open(Tmp_p, write, Ws, [encoding(utf8)]), - tell(Ws), - catch( - ( repeat, - tokens(In, Tokens), - phrase(document(Triples), Tokens, Rest), - ( Rest = [] - -> true - ; nb_getval(line_number, Ln), - throw(invalid_document(after_line(Ln))) - ), - ( Mode = semantics - -> nb_getval(semantics, TriplesPrev), - append(TriplesPrev, Triples, TriplesNext), - findall(Tr, - ( member(Triple, TriplesNext), - ( Triple = ':-'(Head, Body) - -> Tr = '\'\''(Body, Head) - ; Tr = Triple - ) - ), - TriplesNext2 - ), - nb_setval(semantics, TriplesNext2) - ; tr_n3p(Triples, Src, Mode) - ), - Tokens = [] - ), - Exc2, - ( ( Mode = semantics - -> told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - throw(Exc2) - ; true - ), - ( wcacher(Arg, File) - -> format(user_error, '** ERROR ** ~w FROM ~w ** ~w~n', [Arg, File, Exc2]) - ; format(user_error, '** ERROR ** ~w ** ~w~n', [Arg, Exc2]) - ), - flush_output(user_error), - nb_setval(exit_code, 1), - ( ( \+data_fuse, - Mode == 'not-entail' - ; data_fuse, - Mode == entail - ) - -> write(query(true, true)), - writeln('.') - ; true - ), - assertz(data_fuse) - ) - ), - ( Mode = semantics - -> nb_getval(semantics, List), - write(semantics(Src, List)), - writeln('.') - ; true - ), - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - ( File = '-' - -> true - ; close(In) - ), - ( retract(tmpfile(Tmp)) - -> delete_file(Tmp) - ; true - ), - ( flag('intermediate', Out) - -> forall( - ( pfx(Pp, Pu), - \+wpfx(Pp) - ), - ( portray_clause(Out, pfx(Pp, Pu)), - assertz(wpfx(Pp)) - ) - ) - ; true - ), - open(Tmp_p, read, Rs, [encoding(utf8)]), - ( Mode = semantics - -> repeat, - read(Rs, Rt), - ( Rt = end_of_file - -> true - ; djiti_assertz(Rt), - ( Rt = semantics(_, L) - -> length(L, N), - nb_setval(sc, N) - ; Rt \= semantics(_, []), - nb_setval(sc, 1) - ), - fail - ) - ; repeat, - read(Rs, Rt), - ( Rt = end_of_file - -> true - ; dynify(Rt), - ( ground(Rt), - Rt \= ':-'(_, _) - -> ( predicate_property(Rt, dynamic) - -> true - ; close(Rs), - ( retract(tmpfile(Tmp_p)) - -> delete_file(Tmp_p) - ; true - ), - throw(builtin_redefinition(Rt)) - ), - ( Rt \= implies(_, _, _), - \+flag('no-distinct-input'), - call(Rt) - -> true - ; djiti_assertz(Rt), - cnt(sc), - ( flag('intermediate', Out) - -> portray_clause(Out, Rt) - ; true - ) - ) - ; ( Rt = prfstep(Ct, Pt, _, Qt, It, Mt, St) - -> term_index(Pt, Pnd), - ( nonvar(It) - -> copy_term_nat(It, Ic) - ; Ic = It - ), - ( \+prfstep(Ct, Pt, Pnd, Qt, Ic, Mt, St) - -> assertz(prfstep(Ct, Pt, Pnd, Qt, Ic, Mt, St)) - ; true - ) - ; ( Rt = ':-'(Ci, Px), - ( Px = true - -> functor(Ci, Cf, _), - ( \+pred(Cf), - \+cpred(Cf) - -> assertz(pred(Cf)) - ; true - ) - ; true - ), - conjify(Px, Pi) - -> ( Ci = true - -> ( flag('intermediate', Out) - -> portray_clause(Out, ':-'(Pi)) - ; true - ), - ( flag('parse-only') - -> true - ; call(Pi) - ) - ; atomic_list_concat(['<', Arg, '>'], Si), - copy_term_nat(''(Pi, Ci), Ri), - ( flag(nope) - -> Ph = Pi - ; ( Pi = when(Ai, Bi) - -> conj_append(Bi, istep(Si, Pi, Ci, Ri), Bh), - Ph = when(Ai, Bh) - ; conj_append(Pi, istep(Si, Pi, Ci, Ri), Ph) - ) - ), - ( flag('rule-histogram') - -> ( Ph = when(Ak, Bk) - -> conj_append(Bk, pstep(Ri), Bj), - Pj = when(Ak, Bj) - ; conj_append(Ph, pstep(Ri), Pj) - ) - ; Pj = Ph - ), - cnt(sc), - functor(Ci, CPi, _), - ( flag('intermediate', Out) - -> ( \+cpred(CPi) - -> portray_clause(Out, cpred(CPi)) - ; true - ), - portray_clause(Out, ':-'(Ci, Pi)) - ; true - ), - ( \+cpred(CPi) - -> assertz(cpred(CPi)) - ; true - ), - assertz(':-'(Ci, Pj)) - ) - ; djiti_assertz(Rt), - cnt(sc), - ( flag('intermediate', Out) - -> portray_clause(Out, Rt) - ; true - ) - ) - ) - ), - fail - ) - ), - close(Rs), - ( retract(tmpfile(Tmp_p)) - -> delete_file(Tmp_p) - ; true - ), - nb_getval(sc, SC), - nb_getval(input_statements, IN), - Inp is SC+IN, - nb_setval(input_statements, Inp), - format(user_error, 'SC=~w~n', [SC]), - flush_output(user_error), - !. - -tr_n3p([], _, _) :- - !. -tr_n3p(X, _, entail) :- - !, - conj_list(Y, X), - write(query(Y, true)), - writeln('.'). -tr_n3p(X, _, 'not-entail') :- - !, - conj_list(Y, X), - write(query(\+Y, true)), - writeln('.'). -tr_n3p(['\'\''(X, Y)|Z], Src, query) :- - !, - ( Y = '\'\''(_, T) - -> ( is_list(T) - -> H = T - ; findvars(X, U, epsilon), - distinct(U, H) - ), - nb_setval(csv_header, H), - V = '\'\''(_, H) - ; V = Y - ), - ( \+flag('limited-answer', _), - flag(nope), - ( flag('no-distinct-output') - ; V = '\'\''(_, _) - ) - -> write(query(X, V)), - writeln('.') - ; djiti_answer(answer(V), A), - write(implies(X, A, Src)), - writeln('.') - ), - tr_n3p(Z, Src, query). -tr_n3p([':-'(Y, X)|Z], Src, query) :- - !, - ( Y = '\'\''(_, T) - -> ( is_list(T) - -> H = T - ; findvars(X, U, epsilon), - distinct(U, H) - ), - nb_setval(csv_header, H), - V = '\'\''(_, H) - ; V = Y - ), - ( ( \+flag('limited-answer', _) - ; V = '\'\''(_, _), - flag(strings) - ), - flag(nope) - -> write(query(X, V)), - writeln('.') - ; djiti_answer(answer(V), A), - write(implies(X, A, Src)), - writeln('.') - ), - tr_n3p(Z, Src, query). -tr_n3p(['\'\''(X, Y)|Z], Src, Mode) :- - !, - ( flag(tactic, 'linear-select') - -> write(implies(X, '\'\''(X, Y), Src)), - writeln('.'), - write(implies('\'\''(X, Y), Y, Src)), - writeln('.') - ; write(implies(X, Y, Src)), - writeln('.') - ), - tr_n3p(Z, Src, Mode). -tr_n3p([':-'(Y, X)|Z], Src, Mode) :- - !, - tr_tr(Y, U), - write(':-'(U, X)), - writeln('.'), - tr_n3p(Z, Src, Mode). -tr_n3p(['\'\''(X, Y)|Z], Src, Mode) :- - !, - write('\'\''(X, Y)), - writeln('.'), - tr_n3p(Z, Src, Mode). -tr_n3p([X|Z], Src, Mode) :- - ( X \= '\'\''(_, _) - -> tr_tr(X, Y) - ; Y = X - ), - ( findvars(Y, U, epsilon), - U = [] - -> ( Y =.. [A, B, (C, D)] - -> format('~w(~w, (~w', [A, B, C]), - wcn(D), - format(')).~n') - ; write(Y), - writeln('.') - ), - ( flag(nope) - -> true - ; write(prfstep(Y, true, _, Y, _, forward, Src)), - writeln('.') - ) - ; write(':-'(Y, true)), - writeln('.') - ), - tr_n3p(Z, Src, Mode). - -tr_tr([], []) :- - !. -tr_tr([A|B], [C|D]) :- - !, - tr_tr(A, C), - tr_tr(B, D). -tr_tr(A, B) :- - atom(A), - !, - ( atom_concat('_', C, A), - ( sub_atom(C, 0, _, _, 'bn_') - ; sub_atom(C, 0, _, _, 'e_') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, C, '>\''], B) - ; B = A - ). -tr_tr(A, A) :- - number(A), - !. -tr_tr(A, B) :- - A =.. [C|D], - tr_tr(D, E), - B =.. [C|E]. - -tr_split([], [], []) :- - !. -tr_split([A|B], C, [A|D]) :- - functor(A, '\'\'', _), - !, - tr_split(B, C, D). -tr_split([A|B], C, D) :- - functor(A, '\'\'', _), - !, - tr_split(B, C, D). -tr_split([A|B], [A|C], D) :- - tr_split(B, C, D). - -ttl_n3p(literal(type(A, B)), literal(B, type(A))) :- - !. -ttl_n3p(literal(lang(A, B)), literal(B, lang(A))) :- - !. -ttl_n3p(literal(A), literal(A, type(''))) :- - !. -ttl_n3p(node(A), B) :- - !, - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'node_', A, '>'], B). -ttl_n3p(A, B) :- - atomic_list_concat(['<', A, '>'], B). - -% -% N3 parser -% -% according to http://www.w3.org/2000/10/swap/grammar/n3-ietf.txt -% inspired by http://code.google.com/p/km-rdf/wiki/Henry -% - -annotation(Triple, Triples) --> - [lb_pipe], - !, - propertylist(Triple, Triples), - { ( Triples \= [] - -> true - ; nb_getval(line_number, Ln), - throw('empty_triple_annotation'(after_line(Ln))) - ) - }, - [pipe_rb]. -annotation(_, []) --> - []. - -barename(BareName) --> - [name(BareName)]. - -barename_csl([BareName|Tail]) --> - barename(BareName), - !, - barename_csl_tail(Tail). -barename_csl([]) --> - []. - -barename_csl_tail([BareName|Tail]) --> - [','], - !, - barename(BareName), - barename_csl_tail(Tail). -barename_csl_tail([]) --> - []. - -boolean(true) --> - [name('true')], - !. -boolean(false) --> - [name('false')], - !. -boolean(Boolean) --> - literal(Atom, type(T)), - { T = '\'\'', - ( memberchk([Boolean, Atom], [[true, '\'true\''], [true, true], [true, '\'1\''], [false, '\'false\''], [false, false], [false, '\'0\'']]) - -> true - ; ( flag('parse-only') - -> true - ; nb_getval(line_number, Ln), - throw(invalid_boolean_literal(Atom, after_line(Ln))) - ) - ) - }. - -declaration --> - [atname(base)], - !, - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(base_uri(_)), - assertz(base_uri(URI)) - }. -declaration --> - [name(Name)], - { downcase_atom(Name, 'base') - }, - !, - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(base_uri(_)), - assertz(base_uri(URI)) - }, - withoutdot. -declaration --> - [atname(prefix)], - !, - prefix(Prefix), - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(ns(Prefix, _)), - assertz(ns(Prefix, URI)), - put_pfx(Prefix, URI) - }. -declaration --> - [name(Name)], - { downcase_atom(Name, 'prefix') - }, - prefix(Prefix), - explicituri(U), - { base_uri(V), - resolve_uri(U, V, URI), - retractall(ns(Prefix, _)), - assertz(ns(Prefix, URI)), - put_pfx(Prefix, URI) - }, - withoutdot. - -document(Triples) --> - statements_optional(Triples). - -dtlang(lang(Langcode)) --> - [atname(Name)], - { Name \= 'is', - Name \= 'has' - }, - !, - { downcase_atom(Name, N), - atomic_list_concat(['\'', N, '\''], Langcode) - }. -dtlang(type(Datatype)) --> - [caret_caret], - !, - uri(Datatype). -dtlang(type(T)) --> - { T = '\'\'' - }, - []. - -existential --> - [atname(forSome)], - !, - symbol_csl(Symbols), - { nb_getval(fdepth, D), - forall( - member(S, Symbols), - ( gensym('qe_', Q), - asserta(qevar(S, Q, D)) - ) - ) - }. - -explicituri(ExplicitURI) --> - [relative_uri(ExplicitURI)]. - -expression(Node, T) --> - pathitem(N1, T1), - pathtail(N1, Node, T2), - { append(T1, T2, T) - }. - -formulacontent(Formula) --> - statementlist(List), - { conj_list(Formula, List) - }. - -literal(Atom, DtLang) --> - string(Codes), - dtlang(DtLang), - { escape_string(Codes, B), - escape_string(B, C), - atom_codes(A, C), - ( sub_atom(A, _, 1, _, '\'') - -> escape_squote(C, D), - atom_codes(E, D) - ; E = A - ), - atomic_list_concat(['\'', E, '\''], Atom) - }. - -numericliteral(Number) --> - [numeric(_, NumB)], - { numeral(NumB, NumC), - number_codes(Number, NumC) - }. - -object(Node, Triples) --> - expression(Node, Triples). - -objecttail(Subject, Verb, [Triple|Triples]) --> - [','], - !, - object(Object, Triples1), - { ( Verb = isof(Vrb) - -> Trpl = triple(Object, Vrb, Subject) - ; Trpl = triple(Subject, Verb, Object) - ) - }, - annotation(Trpl, Triples2), - objecttail(Subject, Verb, Triples3), - { append([Triples1, Triples2, Triples3], Triples), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, Object, Subject] - ; Triple = exopred(V, Object, Subject) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, Subject, Object] - ; Triple = exopred(Verb, Subject, Object) - ) - ) - }. -objecttail(_, _, []) --> - []. - -pathitem(Name, []) --> - symbol(S), - !, - { ( qevar(S, N, D), - \+quvar(S, _, _) - -> ( D = 1, - nb_getval(fdepth, FD), - FD >= D, - \+flag('pass-all-ground') - -> atom_concat('_', N, Name) - ; atomic_list_concat(['\'\''], Name), - ( pfx('var:', _) - -> true - ; assertz(pfx('var:', '')) - ) - ) - ; ( quvar(S, N, D) - -> ( nb_getval(fdepth, FD), - FD >= D, - \+flag('pass-all-ground') - -> atom_concat('_', N, Name) - ; atomic_list_concat(['\'\''], Name), - ( pfx('var:', _) - -> true - ; assertz(pfx('var:', '')) - ) - ) - ; Name = S - ) - ) - }. -pathitem(VarID, []) --> - [uvar(Var)], - !, - { atom_codes(Var, VarCodes), - subst([[[0'-], [0'_, 0'M, 0'I, 0'N, 0'U, 0'S, 0'_]], [[0'.], [0'_, 0'D, 0'O, 0'T, 0'_]]], VarCodes, VarTidy), - atom_codes(VarAtom, [0'_|VarTidy]), - ( flag('pass-all-ground') - -> nb_getval(var_ns, Sns), - atom_codes(VarFrag, VarTidy), - atomic_list_concat(['\'<', Sns, VarFrag, '>\''], VarID) - ; VarID = VarAtom - ) - }. -pathitem(Number, []) --> - numericliteral(Number), - !. -pathitem(Boolean, []) --> - boolean(Boolean), - !. -pathitem(Atom, []) --> - literal(A, type(T)), - { T = '\'\'' - }, - !, - { atom_codes(A, B), - escape_string(C, B), - atom_codes(Atom, C) - }. -pathitem(Number, [], L1, L2) :- - literal(Atom, type(Type), L1, L2), - nb_getval(fdepth, 0), - memberchk(Type, ['\'\'', '\'\'', '\'\'', '\'\'']), - sub_atom(Atom, 1, _, 1, A), - atom_codes(A, NumB), - numeral(NumB, NumC), - number_codes(Number, NumC), - !. -pathitem(literal(Atom, DtLang), []) --> - literal(Atom, DtLang), - !. -pathitem(Subject, Triples) --> - ['[',name(id)], - !, - expression(Subject, T1), - propertylist(Subject, T2), - { append(T1, T2, Triples) - }, - [']']. -pathitem(Node, Triples) --> - ['['], - !, - { gensym('bn_', S), - ( ( nb_getval(entail_mode, false), - nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, S, '>\''], BN) - ; atom_concat('_', S, BN) - ) - }, - propertylist(BN, T), - { ( memberchk('\'\''(X, Head), T), - memberchk('\'\''(X, Tail), T), - del(T, '\'\''(X, '\'\''), U), - del(U, '\'\''(X, Head), V), - del(V, '\'\''(X, Tail), W) - -> Node = [Head|Tail], - Triples = W - ; Node = BN, - Triples = T - ) - }, - [']']. -pathitem(set(Distinct), Triples) --> - ['(', '$'], - !, - pathlist(List, Triples), - { sort(List, Distinct) - }, - ['$', ')']. -pathitem(List, Triples) --> - ['('], - !, - pathlist(List, Triples), - [')']. -pathitem(triple(S, P, O), Triples) --> - [lt_lt], - !, - pathlist(List, Triples), - { ( List = [S, P, O], - Triples = [] - -> true - ; nb_getval(line_number, Ln), - throw('invalid_n3_star_triple'(List, after_line(Ln))) - ) - }, - [gt_gt]. -pathitem(Node, []) --> - ['{'], - { nb_getval(fdepth, I), - J is I+1, - nb_setval(fdepth, J) - }, - formulacontent(Node), - { retractall(quvar(_, _, J)), - retractall(qevar(_, _, J)), - retractall(evar(_, _, J)), - nb_setval(fdepth, I), - ( nb_getval(entail_mode, true) - -> nb_getval(line_number, Ln), - throw(non_rdf_entailment(Node, after_line(Ln))) - ; true - ) - }, - ['}']. - -pathlist([Node|Rest], Triples) --> - expression(Node, T), - !, - pathlist(Rest, Tail), - { append(T, Tail, Triples) - }. -pathlist([], []) --> - []. - -pathtail(Node, PNode, [Triple|Triples]) --> - ['!'], - !, - pathitem(Item, Triples2), - { prolog_verb(Item, Verb), - gensym('bn_', S), - ( ( nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, S, '>\''], BNode) - ; atom_concat('_', S, BNode) - ), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, BNode, Node] - ; Triple = exopred(V, BNode, Node) - ) - ; ( Verb = prolog:Pred - -> ( BNode = true - -> Triple =.. [Pred|Node] - ; ( BNode = false - -> T =.. [Pred|Node], - Triple = \+(T) - ; ( prolog_sym(_, Pred, func) - -> T =.. [Pred|Node], - Triple = is(BNode, T) - ; Triple =.. [Pred, Node, BNode] - ) - ) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, Node, BNode] - ; Triple = exopred(Verb, Node, BNode) - ) - ) - ) - }, - pathtail(BNode, PNode, Tail), - { append(Triples2, Tail, Triples) - }. -pathtail(Node, PNode, [Triple|Triples]) --> - ['^'], - !, - pathitem(Item, Triples2), - { prolog_verb(Item, Verb), - gensym('bn_', S), - ( ( nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['\'<', Sns, S, '>\''], BNode) - ; atom_concat('_', S, BNode) - ), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, Node, BNode] - ; Triple = exopred(V, Node, BNode) - ) - ; ( Verb = prolog:Pred - -> ( Node = true - -> Triple =.. [Pred|BNode] - ; ( Node = false - -> T =.. [Pred|BNode], - Triple = \+(T) - ; ( prolog_sym(_, Pred, func) - -> T =.. [Pred|BNode], - Triple = is(Node, T) - ; Triple =.. [Pred, BNode, Node] - ) - ) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, BNode, Node] - ; Triple = exopred(Verb, BNode, Node) - ) - ) - ) - }, - pathtail(BNode, PNode, Tail), - { append(Triples2, Tail, Triples) - }. -pathtail(Node, Node, []) --> - []. - -prefix(Prefix) --> - [Prefix:'']. - -propertylist(Subject, [Triple|Triples]) --> - verb(Item, Triples1), - { prolog_verb(Item, Verb) - }, - !, - object(Object, Triples2), - { ( Verb = isof(Vrb) - -> Trpl = triple(Object, Vrb, Subject) - ; Trpl = triple(Subject, Verb, Object) - ) - }, - annotation(Trpl, Triples3), - objecttail(Subject, Verb, Triples4), - propertylisttail(Subject, Triples5), - { append([Triples1, Triples2, Triples3, Triples4, Triples5], Triples), - ( Verb = isof(V) - -> ( atom(V), - \+sub_atom(V, 0, 1, _, '_') - -> Triple =.. [V, Object, Subject] - ; Triple = exopred(V, Object, Subject) - ) - ; ( Verb = prolog:Pred - -> ( Object = true - -> Triple =.. [Pred|Subject] - ; ( Object = false - -> T =.. [Pred|Subject], - Triple = \+(T) - ; ( prolog_sym(_, Pred, func) - -> T =.. [Pred|Subject], - Triple = is(Object, T) - ; Triple =.. [Pred, Subject, Object] - ) - ) - ) - ; ( atom(Verb), - \+sub_atom(Verb, 0, 1, _, '_') - -> Triple =.. [Verb, Subject, Object] - ; Triple = exopred(Verb, Subject, Object) - ) - ) - ) - }. -propertylist(_, []) --> - []. - -propertylisttail(Subject, Triples) --> - [';'], - !, - propertylisttailsemis, - propertylist(Subject, Triples). -propertylisttail(_, []) --> - []. - -propertylisttailsemis --> - [';'], - !, - propertylisttailsemis. -propertylisttailsemis --> - []. - -qname(URI) --> - [NS:Name], - { ( ns(NS, Base) - -> atomic_list_concat([Base, Name], Name1), - ( sub_atom(Name1, _, 1, _, '\'') - -> atom_codes(Name1, Codes1), - escape_squote(Codes1, Codes2), - atom_codes(Name2, Codes2) - ; Name2 = Name1 - ), - atomic_list_concat(['\'<', Name2, '>\''], URI) - ; nb_getval(line_number, Ln), - throw(no_prefix_directive(NS, after_line(Ln))) - ) - }, - !. - -simpleStatement(Triples) --> - subject(Subject, Triples1), - ( { Subject = (D1;D2) - } - -> { Triples = [(D1;D2)] - } - ; propertylist(Subject, Triples2), - { append(Triples1, Triples2, Triples) - } - ). - -statement([]) --> - declaration, - !. -statement([]) --> - universal, - !. -statement([]) --> - existential, - !. -statement(Statement) --> - simpleStatement(Statement). - -statementlist(Triples) --> - statement(Tr), - !, - statementtail(T), - { append(Tr, T, Triples) - }. -statementlist([]) --> - []. - -statements_optional(Triples) --> - statement(Tr), - [dot(Ln)], - !, - { nb_setval(line_number, Ln) - }, - statements_optional(T), - { append(Tr, T, Triples) - }. -statements_optional([]) --> - []. - -statementtail(T) --> - [dot(Ln)], - !, - { nb_setval(line_number, Ln) - }, - statementlist(T). -statementtail([]) --> - []. - -string(Codes) --> - [literal(Codes)]. - -subject(Node, Triples) --> - expression(Node, Triples). - -symbol(Name) --> - uri(Name), - !. -symbol(Name) --> - [name(N)], - !, - { ( memberchk(N, [true, false]) - -> Name = N - ; nb_getval(line_number, Ln), - throw(invalid_keyword(N, after_line(Ln))) - ) - }. -symbol(Name) --> - [bnode(Label)], - { ( flag(blogic) - -> D = 0 - ; nb_getval(fdepth, D) - ), - ( evar(Label, S, D) - -> true - ; atom_concat(Label, '_', M), - gensym(M, S), - assertz(evar(Label, S, D)) - ), - ( ( nb_getval(entail_mode, false), - nb_getval(fdepth, 0) - ; flag('pass-all-ground') - ) - -> nb_getval(var_ns, Sns), - ( flag('pass-all-ground') - -> atomic_list_concat(['\'<', Sns, Label, '>\''], Name) - ; atomic_list_concat(['\'<', Sns, 'e_', S, '>\''], Name) - ) - ; atom_concat('_e_', S, Name) - ) - }. - -symbol_csl([Symbol|Tail]) --> - symbol(Symbol), - !, - symbol_csl_tail(Tail). -symbol_csl([]) --> - []. - -symbol_csl_tail([Symbol|T]) --> - [','], - !, - symbol(Symbol), - symbol_csl_tail(T). -symbol_csl_tail([]) --> - []. - -universal --> - [atname(forAll)], - !, - symbol_csl(Symbols), - { nb_getval(fdepth, D), - forall( - member(S, Symbols), - ( gensym('qu_', Q), - asserta(quvar(S, Q, D)) - ) - ) - }. - -uri(Name) --> - explicituri(U), - !, - { base_uri(V), - resolve_uri(U, V, W), - ( sub_atom(W, _, 1, _, '\'') - -> atom_codes(W, X), - escape_squote(X, Y), - atom_codes(Z, Y) - ; Z = W - ), - atomic_list_concat(['\'<', Z, '>\''], Name) - }. -uri(Name) --> - qname(Name). - -verb('\'\'', []) --> - ['=', '>'], - !. -verb('\'\'', []) --> - ['='], - !. -verb(':-', []) --> - [lt_eq], - !. -verb('\'\'', []) --> - [name(a)], - !. -verb(Node, Triples) --> - [name(has)], - !, - expression(Node, Triples). -verb(isof(Node), Triples) --> - [name(is)], - !, - expression(Node, Triples), - [name(of)]. -verb(isof(Node), Triples) --> - [lt_dash], - !, - expression(Node, Triples). -verb(Node, Triples) --> - expression(Node, Triples). - -withoutdot, [dot(Ln)] --> - [dot(Ln)], - !, - { throw(unexpected_dot(after_line(Ln))) - }. -withoutdot, [dot(Ln)] --> - [], - { nb_getval(line_number, Ln) - }. - -% -% N3 tokenizer -% - -tokens(In, List) :- - get_code(In, C0), - ( token(C0, In, C1, Tok1) - -> true - ; nb_getval(line_number, Ln), - char_code(Char, C0), - throw(illegal_token(char_code(Char, C0), line(Ln))) - ), - ( Tok1 == end_of_file - -> List = [] - ; List = [Tok1|Tokens], - tokens(C1, In, Tokens) - ). - -tokens(C0, In, List) :- - ( token(C0, In, C1, H) - -> true - ; nb_getval(line_number, Ln), - char_code(Char, C0), - throw(illegal_token(char_code(Char, C0), line(Ln))) - ), - ( H == end_of_file - -> List = [] - ; List = [H|T], - tokens(C1, In, T) - ). - -token(-1, _, -1, end_of_file) :- - !. -token(0'., In, C, Token) :- - ( peek_code(In, C0), - ( e(C0) - -> T1 = [0'0|T2], - get_code(In, CN1) - ; 0'0 =< C0, - C0 =< 0'9, - get_code(In, C1), - integer_codes(C1, In, CN1, T1, T2) - ) - -> ( exponent(CN1, In, C, T2) - -> Type = double - ; C = CN1, - T2 = [], - Type = decimal - ), - Token = numeric(Type, [0'0, 0'.|T1]) - ; nb_getval(line_number, Ln), - get_code(In, C), - !, - Token = dot(Ln) - ). -token(0'#, In, C, Token) :- - !, - get_code(In, C1), - skip_line(C1, In, C2), - token(C2, In, C, Token). -token(C0, In, C, Token) :- - white_space(C0), - !, - get_code(In, C1), - token(C1, In, C, Token). -token(C0, In, C, Number) :- - 0'0 =< C0, - C0 =< 0'9, - !, - number_n(C0, In, C, Number). -token(0'-, In, C, Number) :- - !, - number_n(0'-, In, C, Number). -token(0'+, In, C, Number) :- - !, - number_n(0'+, In, C, Number). -token(0'", In, C, literal(Codes)) :- - !, - ( peek_code(In, 0'") - -> get_code(In, 0'"), - ( peek_code(In, 0'") - -> get_code(In, 0'"), - get_code(In, C1), - dq_string(C1, In, C, Codes) - ; get_code(In, C), - Codes = [] - ) - ; get_code(In, C1), - string_dq(C1, In, C, Codes) - ). -token(0'', In, C, literal(Codes)) :- - !, - ( peek_code(In, 0'') - -> get_code(In, 0''), - ( peek_code(In, 0'') - -> get_code(In, 0''), - get_code(In, C1), - sq_string(C1, In, C, Codes) - ; get_code(In, C), - Codes = [] - ) - ; get_code(In, C1), - string_sq(C1, In, C, Codes) - ). -token(0'?, In, C, uvar(Name)) :- - !, - get_code(In, C0), - ( name(C0, In, C, Name) - -> true - ; C = C0, - nb_getval(line_number, Ln), - throw(empty_quickvar_name(line(Ln))) - ). -token(0'_, In, C, bnode(Name)) :- - peek_code(In, 0':), - !, - get_code(In, _), - get_code(In, C0), - ( name(C0, In, C, Name) - -> true - ; C = C0, - Name = '' - ). -token(0'<, In, C, lt_lt) :- - peek_code(In, 0'<), - !, - get_code(In, _), - get_code(In, C). -token(0'<, In, C, lt_eq) :- - peek_string(In, 2, D), - string_codes(D, [0'=, E]), - ( white_space(E) - ; punctuation(E, _) - ), - !, - get_code(In, _), - get_code(In, C). -token(0'<, In, C, lt_dash) :- - peek_code(In, 0'-), - !, - get_code(In, _), - get_code(In, C). -token(0'<, In, C, relative_uri(URI)) :- - peek_code(In, C1), - !, - get_code(In, C1), - iri_chars(C1, In, C, Codes), - D = Codes, - atom_codes(URI, D). -token(0'>, In, C, gt_gt) :- - peek_code(In, 0'>), - !, - get_code(In, _), - get_code(In, C). -token(0'{, In, C, lb_pipe) :- - peek_code(In, 0'|), - !, - get_code(In, _), - get_code(In, C). -token(0'|, In, C, pipe_rb) :- - peek_code(In, 0'}), - !, - get_code(In, _), - get_code(In, C). -token(0':, In, C, Token) :- - !, - get_code(In, C0), - ( local_name(C0, In, C, Name) - -> Token = '':Name - ; Token = '':'', - C = C0 - ). -token(0'@, In, C, atname(Name)) :- - get_code(In, C0), - token(C0, In, C, name(Name)), - !. -token(0'^, In, C, caret_caret) :- - peek_code(In, 0'^), - !, - get_code(In, _), - get_code(In, C). -token(C0, In, C, Token) :- - name(C0, In, C1, Name), - !, - ( C1 == 0': - -> get_code(In, C2), - ( local_name(C2, In, C, Name2) - -> Token = (Name:Name2) - ; Token = (Name:''), - C = C2 - ) - ; Token = name(Name), - C = C1 - ). -token(C0, In, C, P) :- - punctuation(C0, P), - !, - get_code(In, C). - -number_n(0'-, In, CN, numeric(T, [0'-|Codes])) :- - !, - get_code(In, C0), - number_nn(C0, In, CN, numeric(T, Codes)). -number_n(0'+, In, CN, numeric(T, [0'+|Codes])) :- - !, - get_code(In, C0), - number_nn(C0, In, CN, numeric(T, Codes)). -number_n(C0, In, CN, Value) :- - number_nn(C0, In, CN, Value). - -number_nn(C, In, CN, numeric(Type, Codes)) :- - integer_codes(C, In, CN0, Codes, T0), - ( CN0 == 0'., - peek_code(In, C0), - ( e(C0) - -> T1 = [0'0|T2], - get_code(In, CN1) - ; 0'0 =< C0, - C0 =< 0'9, - get_code(In, C1), - integer_codes(C1, In, CN1, T1, T2) - ), - T0 = [0'.|T1] - -> ( exponent(CN1, In, CN, T2) - -> Type = double - ; CN = CN1, - T2 = [], - Type = decimal - ) - ; ( exponent(CN0, In, CN, T0) - -> Type = double - ; T0 = [], - CN = CN0, - Type = integer - ) - ). - -integer_codes(C0, In, CN, [C0|T0], T) :- - 0'0 =< C0, - C0 =< 0'9, - !, - get_code(In, C1), - integer_codes(C1, In, CN, T0, T). -integer_codes(CN, _, CN, T, T). - -exponent(C0, In, CN, [C0|T0]) :- - e(C0), - !, - get_code(In, C1), - optional_sign(C1, In, CN0, T0, T1), - integer_codes(CN0, In, CN, T1, []), - ( T1 = [] - -> nb_getval(line_number, Ln), - throw(invalid_exponent(line(Ln))) - ; true - ). - -optional_sign(C0, In, CN, [C0|T], T) :- - sign(C0), - !, - get_code(In, CN). -optional_sign(CN, _, CN, T, T). - -e(0'e). -e(0'E). - -sign(0'-). -sign(0'+). - -dq_string(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -dq_string(0'", In, C, []) :- - ( retract(got_dq) - -> true - ; peek_code(In, 0'"), - get_code(In, _) - ), - ( retract(got_dq) - -> assertz(got_dq) - ; assertz(got_dq), - peek_code(In, 0'"), - get_code(In, _), - assertz(got_dq) - ), - !, - ( peek_code(In, 0'") - -> nb_getval(line_number, Ln), - throw(unexpected_double_quote(line(Ln))) - ; true - ), - retractall(got_dq), - get_code(In, C). -dq_string(0'", In, C, [0'"|T]) :- - !, - ( retract(got_dq) - -> C1 = 0'" - ; get_code(In, C1) - ), - dq_string(C1, In, C, T). -dq_string(0'\\, In, C, [H|T]) :- - ( retract(got_dq) - -> C1 = 0'" - ; get_code(In, C1) - ), - !, - string_escape(C1, In, C2, H), - dq_string(C2, In, C, T). -dq_string(C0, In, C, [C0|T]) :- - ( retract(got_dq) - -> C1 = 0'" - ; get_code(In, C1) - ), - dq_string(C1, In, C, T). - -sq_string(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -sq_string(0'', In, C, []) :- - ( retract(got_sq) - -> true - ; peek_code(In, 0''), - get_code(In, _) - ), - ( retract(got_sq) - -> assertz(got_sq) - ; assertz(got_sq), - peek_code(In, 0''), - get_code(In, _), - assertz(got_sq) - ), - !, - ( peek_code(In, 0'') - -> nb_getval(line_number, Ln), - throw(unexpected_single_quote(line(Ln))) - ; true - ), - retractall(got_sq), - get_code(In, C). -sq_string(0'', In, C, [0''|T]) :- - !, - ( retract(got_sq) - -> C1 = 0'' - ; get_code(In, C1) - ), - sq_string(C1, In, C, T). -sq_string(0'\\, In, C, [H|T]) :- - ( retract(got_sq) - -> C1 = 0'' - ; get_code(In, C1) - ), - !, - string_escape(C1, In, C2, H), - sq_string(C2, In, C, T). -sq_string(C0, In, C, [C0|T]) :- - ( retract(got_sq) - -> C1 = 0'' - ; get_code(In, C1) - ), - sq_string(C1, In, C, T). - -string_dq(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -string_dq(0'\n, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_line(line(Ln))). -string_dq(0'", In, C, []) :- - !, - get_code(In, C). -string_dq(0'\\, In, C, D) :- - get_code(In, C1), - !, - string_escape(C1, In, C2, H), - ( current_prolog_flag(windows, true), - H > 0xFFFF - -> E is (H-0x10000)>>10+0xD800, - F is (H-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [H|T] - ), - string_dq(C2, In, C, T). -string_dq(C0, In, C, D) :- - ( current_prolog_flag(windows, true), - C0 > 0xFFFF - -> E is (C0-0x10000)>>10+0xD800, - F is (C0-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [C0|T] - ), - get_code(In, C1), - string_dq(C1, In, C, T). - -string_sq(-1, _, _, []) :- - !, - nb_getval(line_number, Ln), - throw(unexpected_end_of_input(line(Ln))). -string_sq(0'', In, C, []) :- - !, - get_code(In, C). -string_sq(0'\\, In, C, D) :- - get_code(In, C1), - !, - string_escape(C1, In, C2, H), - ( current_prolog_flag(windows, true), - H > 0xFFFF - -> E is (H-0x10000)>>10+0xD800, - F is (H-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [H|T] - ), - string_sq(C2, In, C, T). -string_sq(C0, In, C, D) :- - ( current_prolog_flag(windows, true), - C0 > 0xFFFF - -> E is (C0-0x10000)>>10+0xD800, - F is (C0-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [C0|T] - ), - get_code(In, C1), - string_sq(C1, In, C, T). - -string_escape(0't, In, C, 0'\t) :- - !, - get_code(In, C). -string_escape(0'b, In, C, 0'\b) :- - !, - get_code(In, C). -string_escape(0'n, In, C, 0'\n) :- - !, - get_code(In, C). -string_escape(0'r, In, C, 0'\r) :- - !, - get_code(In, C). -string_escape(0'f, In, C, 0'\f) :- - !, - get_code(In, C). -string_escape(0'", In, C, 0'") :- - !, - get_code(In, C). -string_escape(0'', In, C, 0'') :- - !, - get_code(In, C). -string_escape(0'\\, In, C, 0'\\) :- - !, - get_code(In, C). -string_escape(0'u, In, C, Code) :- - !, - get_hhhh(In, A), - ( 0xD800 =< A, - A =< 0xDBFF - -> get_code(In, 0'\\), - get_code(In, 0'u), - get_hhhh(In, B), - Code is 0x10000+(A-0xD800)*0x400+(B-0xDC00) - ; Code is A - ), - get_code(In, C). -string_escape(0'U, In, C, Code) :- - !, - get_hhhh(In, Code0), - get_hhhh(In, Code1), - Code is Code0 << 16 + Code1, - get_code(In, C). -string_escape(C, _, _, _) :- - nb_getval(line_number, Ln), - atom_codes(A, [0'\\, C]), - throw(illegal_string_escape_sequence(A, line(Ln))). - -get_hhhh(In, Code) :- - get_code(In, C1), - code_type(C1, xdigit(D1)), - get_code(In, C2), - code_type(C2, xdigit(D2)), - get_code(In, C3), - code_type(C3, xdigit(D3)), - get_code(In, C4), - code_type(C4, xdigit(D4)), - Code is D1<<12+D2<<8+D3<<4+D4. - -language(C0, In, C, [C0|Codes]) :- - code_type(C0, lower), - get_code(In, C1), - lwr_word(C1, In, C2, Codes, Tail), - sub_langs(C2, In, C, Tail, []). - -lwr_word(C0, In, C, [C0|T0], T) :- - code_type(C0, lower), - !, - get_code(In, C1), - lwr_word(C1, In, C, T0, T). -lwr_word(C, _, C, T, T). - -sub_langs(0'-, In, C, [0'-, C1|Codes], T) :- - get_code(In, C1), - lwrdig(C1), - !, - get_code(In, C2), - lwrdigs(C2, In, C3, Codes, Tail), - sub_langs(C3, In, C, Tail, T). -sub_langs(C, _, C, T, T). - -lwrdig(C) :- - code_type(C, lower), - !. -lwrdig(C) :- - code_type(C, digit). - -lwrdigs(C0, In, C, [C0|T0], T) :- - lwrdig(C0), - !, - get_code(In, C1), - lwr_word(C1, In, C, T0, T). -lwrdigs(C, _, C, T, T). - -iri_chars(0'>, In, C, []) :- - !, - get_code(In, C). -iri_chars(0'\\, In, C, D) :- - !, - get_code(In, C1), - iri_escape(C1, In, C2, H), - \+non_iri_char(H), - ( current_prolog_flag(windows, true), - H > 0xFFFF - -> E is (H-0x10000)>>10+0xD800, - F is (H-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [H|T] - ), - iri_chars(C2, In, C, T). -iri_chars(0'%, In, C, [0'%, C1, C2|T]) :- - !, - get_code(In, C1), - code_type(C1, xdigit(_)), - get_code(In, C2), - code_type(C2, xdigit(_)), - get_code(In, C3), - iri_chars(C3, In, C, T). -iri_chars(-1, _, _, _) :- - !, - fail. -iri_chars(C0, In, C, D) :- - \+non_iri_char(C0), - ( current_prolog_flag(windows, true), - C0 > 0xFFFF - -> E is (C0-0x10000)>>10+0xD800, - F is (C0-0x10000) mod 0x400+0xDC00, - D = [E, F|T] - ; D = [C0|T] - ), - get_code(In, C1), - iri_chars(C1, In, C, T). - -iri_escape(0'u, In, C, Code) :- - !, - get_hhhh(In, A), - ( 0xD800 =< A, - A =< 0xDBFF - -> get_code(In, 0'\\), - get_code(In, 0'u), - get_hhhh(In, B), - Code is 0x10000+(A-0xD800)*0x400+(B-0xDC00) - ; Code is A - ), - get_code(In, C). -iri_escape(0'U, In, C, Code) :- - !, - get_hhhh(In, Code0), - get_hhhh(In, Code1), - Code is Code0 << 16 + Code1, - get_code(In, C). -iri_escape(C, _, _, _) :- - nb_getval(line_number, Ln), - atom_codes(A, [0'\\, C]), - throw(illegal_iri_escape_sequence(A, line(Ln))). - -non_iri_char(C) :- - 0x00 =< C, - C =< 0x20, - !. -non_iri_char(0'<). -non_iri_char(0'>). -non_iri_char(0'"). -non_iri_char(0'{). -non_iri_char(0'}). -non_iri_char(0'|). -non_iri_char(0'^). -non_iri_char(0'`). -non_iri_char(0'\\). - -name(C0, In, C, Atom) :- - name_start_char(C0), - get_code(In, C1), - name_chars(C1, In, C, T), - atom_codes(Atom, [C0|T]). - -name_start_char(C) :- - pn_chars_base(C), - !. -name_start_char(0'_). -name_start_char(C) :- - code_type(C, digit). - -name_chars(0'., In, C, [0'.|T]) :- - peek_code(In, C1), - pn_chars(C1), - !, - get_code(In, C1), - name_chars(C1, In, C, T). -name_chars(C0, In, C, [C0|T]) :- - pn_chars(C0), - !, - get_code(In, C1), - name_chars(C1, In, C, T). -name_chars(C, _, C, []). - -pn_chars_base(C) :- - code_type(C, alpha), - !. -pn_chars_base(C) :- - 0xC0 =< C, - C =< 0xD6, - !. -pn_chars_base(C) :- - 0xD8 =< C, - C =< 0xF6, - !. -pn_chars_base(C) :- - 0xF8 =< C, - C =< 0x2FF, - !. -pn_chars_base(C) :- - 0x370 =< C, - C =< 0x37D, - !. -pn_chars_base(C) :- - 0x37F =< C, - C =< 0x1FFF, - !. -pn_chars_base(C) :- - 0x200C =< C, - C =< 0x200D, - !. -pn_chars_base(C) :- - 0x2070 =< C, - C =< 0x218F, - !. -pn_chars_base(C) :- - 0x2C00 =< C, - C =< 0x2FEF, - !. -pn_chars_base(C) :- - 0x3001 =< C, - C =< 0xD7FF, - !. -pn_chars_base(C) :- - 0xF900 =< C, - C =< 0xFDCF, - !. -pn_chars_base(C) :- - 0xFDF0 =< C, - C =< 0xFFFD, - !. -pn_chars_base(C) :- - 0x10000 =< C, - C =< 0xEFFFF. - -pn_chars(C) :- - code_type(C, csym), - !. -pn_chars(C) :- - pn_chars_base(C), - !. -pn_chars(0'-) :- - !. -pn_chars(0xB7) :- - !. -pn_chars(C) :- - 0x0300 =< C, - C =< 0x036F, - !. -pn_chars(C) :- - 0x203F =< C, - C =< 0x2040. - -local_name(0'\\, In, C, Atom) :- - !, - get_code(In, C0), - reserved_char_escapes(C0), - get_code(In, C1), - local_name_chars(C1, In, C, T), - atom_codes(Atom, [C0|T]). -local_name(0'%, In, C, Atom) :- - !, - get_code(In, C0), - code_type(C0, xdigit(_)), - get_code(In, C1), - code_type(C1, xdigit(_)), - get_code(In, C2), - local_name_chars(C2, In, C, T), - atom_codes(Atom, [0'%, C0, C1|T]). -local_name(C0, In, C, Atom) :- - local_name_start_char(C0), - get_code(In, C1), - local_name_chars(C1, In, C, T), - atom_codes(Atom, [C0|T]). - -local_name_chars(0'\\, In, C, [C0|T]) :- - !, - get_code(In, C0), - reserved_char_escapes(C0), - get_code(In, C1), - local_name_chars(C1, In, C, T). -local_name_chars(0'%, In, C, [0'%, C0, C1|T]) :- - !, - get_code(In, C0), - code_type(C0, xdigit(_)), - get_code(In, C1), - code_type(C1, xdigit(_)), - get_code(In, C2), - local_name_chars(C2, In, C, T). -local_name_chars(0'., In, C, [0'.|T]) :- - peek_code(In, C1), - ( local_name_char(C1) - ; C1 = 0'. - ), - !, - get_code(In, C1), - local_name_chars(C1, In, C, T). -local_name_chars(C0, In, C, [C0|T]) :- - local_name_char(C0), - !, - get_code(In, C1), - local_name_chars(C1, In, C, T). -local_name_chars(C, _, C, []). - -local_name_start_char(C) :- - name_start_char(C), - !. -local_name_start_char(0':). -local_name_start_char(0'%). -local_name_start_char(0'\\). - -local_name_char(C) :- - pn_chars(C), - !. -local_name_char(0':). -local_name_char(0'%). -local_name_char(0'\\). - -reserved_char_escapes(0'~). -reserved_char_escapes(0'.). -reserved_char_escapes(0'-). -reserved_char_escapes(0'!). -reserved_char_escapes(0'$). -reserved_char_escapes(0'&). -reserved_char_escapes(0''). -reserved_char_escapes(0'(). -reserved_char_escapes(0')). -reserved_char_escapes(0'*). -reserved_char_escapes(0'+). -reserved_char_escapes(0',). -reserved_char_escapes(0';). -reserved_char_escapes(0'=). -reserved_char_escapes(0'/). -reserved_char_escapes(0'?). -reserved_char_escapes(0'#). -reserved_char_escapes(0'@). -reserved_char_escapes(0'%). -reserved_char_escapes(0'_). - -punctuation(0'(, '('). -punctuation(0'), ')'). -punctuation(0'[, '['). -punctuation(0'], ']'). -punctuation(0',, ','). -punctuation(0':, ':'). -punctuation(0';, ';'). -punctuation(0'{, '{'). -punctuation(0'}, '}'). -punctuation(0'?, '?'). -punctuation(0'!, '!'). -punctuation(0'^, '^'). -punctuation(0'=, '='). -punctuation(0'<, '<'). -punctuation(0'>, '>'). -punctuation(0'$, '$'). - -skip_line(-1, _, -1) :- - !. -skip_line(0xA, In, C) :- - !, - cnt(line_number), - get_code(In, C). -skip_line(0xD, In, C) :- - !, - get_code(In, C). -skip_line(_, In, C) :- - get_code(In, C1), - skip_line(C1, In, C). - -white_space(0x9). -white_space(0xA) :- - cnt(line_number). -white_space(0xD). -white_space(0x20). - -% -% Reasoning output -% - -w0([]) :- - !. -w0(['--image', _|A]) :- - !, - w0(A). -w0([A|B]) :- - ( \+sub_atom(A, 1, _, _, '"'), - sub_atom(A, _, 1, _, ' '), - \+sub_atom(A, _, _, 1, '"') - -> format(' "~w"', [A]) - ; format(' ~w', [A]) - ), - w0(B). - -w1([]) :- - !. -w1([A|B]) :- - ( \+sub_atom(A, 1, _, _, '"'), - sub_atom(A, _, 1, _, ' '), - \+sub_atom(A, _, _, 1, '"') - -> format(' "~w"', [A]) - ; format(' ~w', [A]) - ), - w1(B). - -wh :- - ( keep_skolem(_) - -> nb_getval(var_ns, Sns), - put_pfx('var', Sns) - ; true - ), - ( flag('no-qnames') - -> true - ; nb_setval(wpfx, false), - forall( - ( pfx(A, B), - \+wpfx(A) - ), - ( format('@prefix ~w ~w.~n',[A,B]), - assertz(wpfx(A)), - nb_setval(wpfx, true) - ) - ), - ( \+flag('pass-only-new'), - nb_getval(wpfx, true) - -> nl - ; true - ) - ). - -w3 :- - wh, - nb_setval(fdepth, 0), - nb_setval(pdepth, 0), - nb_setval(cdepth, 0), - flag(nope), - !, - ( query(Q, A), - ( Q = \+(R) - -> \+catch(call(R), _, fail) - ; catch(call(Q), _, fail) - ), - nb_getval(wn, W), - labelvars(A, W, N, some), - nb_setval(wn, N), - relabel(A, B), - indent, - wt(B), - ws(B), - write('.'), - nl, - ( A = (_, _), - conj_list(A, L) - -> length(L, I), - cnt(output_statements, I) - ; cnt(output_statements) - ), - fail - ; true - ), - ( answer(B1, B2, B3), - relabel([B1, B2, B3], [C1, C2, C3]), - djiti_answer(answer(C), answer(C1, C2, C3)), - indent, - wt(C), - ws(C), - write('.'), - nl, - cnt(output_statements), - fail - ; nl - ). -w3 :- - ( prfstep(answer(_, _, _), _, _, _, _, _, _), - !, - nb_setval(empty_gives, false), - indent, - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'proof', '>'], Sk), - wp(Sk), - write(' '), - wp(''), - write(' '), - wp(''), - write(', '), - wp(''), - write(';'), - indentation(2), - nl, - indent, - ( prfstep(answer(_, _, _), B, Pnd, Cn, R, _, A), - R =.. [P, S, O1], - djiti_answer(answer(O), O1), - Rule =.. [P, S, O], - djiti_answer(answer(C), Cn), - nb_setval(empty_gives, C), - \+got_wi(A, B, Pnd, C, Rule), - assertz(got_wi(A, B, Pnd, C, Rule)), - wp(''), - write(' '), - wi(A, B, C, Rule), - write(';'), - nl, - indent, - fail - ; retractall(got_wi(_, _, _, _, _)) - ), - wp(''), - ( nb_getval(empty_gives, true) - -> write(' true.') - ; write(' {'), - indentation(2), - ( prfstep(answer(B1, B2, B3), _, _, _, _, _, _), - relabel([B1, B2, B3], [C1, C2, C3]), - djiti_answer(answer(C), answer(C1, C2, C3)), - nl, - indent, - getvars(C, D), - ( C = ''(_, _) - -> Q = allv - ; Q = some - ), - wq(D, Q), - wt(C), - ws(C), - write('.'), - cnt(output_statements), - fail - ; true - ), - indentation(-2), - nl, - indent, - write('}.') - ), - indentation(-2), - nl, - nl - ; true - ), - ( nb_getval(lemma_count, Lco), - nb_getval(lemma_cursor, Lcu), - Lcu < Lco - -> repeat, - cnt(lemma_cursor), - nb_getval(lemma_cursor, Cursor), - lemma(Cursor, Ai, Bi, Ci, _, Di), - indent, - wj(Cursor, Ai, Bi, Ci, Di), - nl, - nl, - nb_getval(lemma_count, Cnt), - Cursor = Cnt, - ! - ; true - ). - -wi('<>', _, rule(_, _, A), _) :- % wi(Source, Premise, Conclusion, Rule) - !, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' '), - wg(A), - write(']'). -wi(A, B, C, Rule) :- - term_index(B-C, Ind), - ( lemma(Cnt, A, B, C, Ind, Rule) - -> true - ; cnt(lemma_count), - nb_getval(lemma_count, Cnt), - assertz(lemma(Cnt, A, B, C, Ind, Rule)) - ), - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'lemma', Cnt, '>'], Sk), - wp(Sk). - -wj(Cnt, A, true, C, Rule) :- % wj(Count, Source, Premise, Conclusion, Rule) - var(Rule), - C \= ''(_, _), - !, - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'lemma', Cnt, '>'], Sk), - wp(Sk), - write(' '), - wp(''), - write(' '), - wp(''), - writeln(';'), - indentation(2), - indent, - wp(''), - ( C = true - -> write(' true;') - ; write(' {'), - nl, - indentation(2), - indent, - ( C = rule(PVars, EVars, Rule) - -> wq(PVars, allv), - wq(EVars, some), - wt(Rule) - ; labelvars([A, C], 0, _, avar), - getvars(C, D), - wq(D, some), - wt(C) - ), - ws(C), - write('.'), - nl, - indentation(-2), - indent, - write('};') - ), - nl, - indent, - wp(''), - write(' [ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' '), - ( C = rule(_, _, Rl), - Rl =.. [P, S, O], - ''(triple(S, P, O), Src) - -> wt(Src) - ; ( C =.. [P, S, O], - ''(triple(S, P, O), Src) - -> wt(Src) - ; wt(A) - ) - ), - write('].'), - indentation(-2). -wj(Cnt, A, B, C, Rule) :- - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'lemma', Cnt, '>'], Sk), - wp(Sk), - write(' '), - wp(''), - write(' '), - wp(''), - writeln(';'), - indentation(2), - indent, - wp(''), - ( C = true - -> write(' true;') - ; write(' {'), - nl, - Rule = ''(Prem, Conc), - unifiable(Prem, B, Bs), - ( unifiable(Conc, C, Cs) - -> true - ; Cs = [] - ), - append(Bs, Cs, Ds), - sort(Ds, Bindings), - term_variables(Prem, PVars), - term_variables(Conc, CVars), - nb_getval(wn, W), - labelvars([A, B, C], W, N, some), - nb_setval(wn, N), - labelvars([Rule, PVars, CVars], 0, _, avar), - findall(V, - ( member(V, CVars), - \+member(V, PVars) - ), - EVars - ), - getvars(C, D), - ( C = ''(_, _) - -> Q = allv - ; Q = some - ), - indentation(2), - indent, - wq(D, Q), - wt(C), - ws(C), - write('.'), - nl, - indentation(-2), - indent, - write('};') - ), - nl, - indent, - wp(''), - write(' ('), - indentation(2), - wr(B), - indentation(-2), - nl, - indent, - write(');'), - retractall(got_wi(_, _, _, _, _)), - nl, - indent, - wb(Bindings), - wp(''), - write(' '), - wi(A, true, rule(PVars, EVars, Rule), _), - write('.'), - indentation(-2). - -wr(exopred(P, S, O)) :- - atom(P), - !, - U =.. [P, S, O], - wr(U). -wr((X, Y)) :- - !, - wr(X), - wr(Y). -wr(Z) :- - prfstep(Z, Y, _, Q, Rule, _, X), - !, - nl, - indent, - wi(X, Y, Q, Rule). -wr(Y) :- - nl, - indent, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' '), - ( Y = true - -> wt(Y) - ; write('{'), - labelvars(Y, 0, _, avar), - getvars(Y, Z), - wq(Z, some), - X = Y, - wt(X), - write('}') - ), - write(']'). - -wt(X) :- - var(X), - !, - write('?'), - write(X). -wt(X) :- - functor(X, _, A), - ( A = 0, - !, - wt0(X) - ; A = 1, - !, - wt1(X) - ; A = 2, - !, - wt2(X) - ; wtn(X) - ). - -wt0(!) :- - !, - write('("!") '), - wp(''), - write(' true'). -wt0(fail) :- - !, - write('("fail") '), - wp(''), - write(' true'). -wt0([]) :- - !, - write('()'). -wt0(X) :- - number(X), - !, - ( flag('no-numerals') - -> dtlit([U, V], X), - dtlit([U, V], W), - wt(W) - ; write(X) - ). -wt0(X) :- - atom(X), - atom_concat(some, Y, X), - !, - ( \+flag('no-qvars') - -> ( rule_uvar(L), - ( ncllit - -> ( memberchk(X, L) - -> true - ; retract(rule_uvar(L)), - assertz(rule_uvar([X|L])) - ) - ; memberchk(X, L) - ) - -> write('?U_') - ; write('_:sk_') - ), - write(Y) - ; atomic_list_concat([''], Z), - wt0(Z) - ). -wt0(X) :- - atom(X), - atom_concat(allv, Y, X), - !, - ( \+flag('no-qvars'), - \+flag('pass-all-ground') - -> write('?U_'), - write(Y) - ; atomic_list_concat([''], Z), - wt0(Z) - ). -wt0(X) :- - atom(X), - atom_concat(avar, Y, X), - !, - atomic_list_concat([''], Z), - wt0(Z). -wt0(X) :- - flag(nope), - \+flag('pass-all-ground'), - \+keep_skolem(X), - nb_getval(var_ns, Sns), - atom(X), - sub_atom(X, 1, I, _, Sns), - J is I+1, - sub_atom(X, J, _, 1, Y), - ( getlist(X, M) - -> wt(M) - ; ( rule_uvar(L), - ( ncllit - -> ( memberchk(Y, L) - -> true - ; retract(rule_uvar(L)), - assertz(rule_uvar([Y|L])) - ) - ; memberchk(Y, L) - ) - -> ( ( sub_atom(Y, 0, 2, _, 'e_') - ; sub_atom(Y, 0, 3, _, 'bn_') - ) - -> write('_:') - ; sub_atom(Y, 0, 2, _, Z), - memberchk(Z, ['x_', 't_']), - write('?') - ) - ; ( \+flag('no-qvars') - -> true - ; flag('quantify', Prefix), - sub_atom(X, 1, _, _, Prefix) - ), - write('_:') - ), - write(Y), - ( sub_atom(Y, 0, 2, _, 'x_') - -> write('_'), - nb_getval(rn, N), - write(N) - ; true - ) - ), - !. -wt0(X) :- - flag('quantify', Prefix), - flag(nope), - atom(X), - sub_atom(X, 1, _, _, Prefix), - !, - ( getlist(X, M) - -> wt(M) - ; ''(Y, ['quantify', Prefix, X]), - wt0(Y) - ). -wt0(X) :- - ( wtcache(X, W) - -> true - ; ( \+flag('no-qnames'), - atom(X), - ( sub_atom(X, I, 1, J, '#') - -> J > 1, - sub_atom(X, 0, I, _, C), - atom_concat(C, '#>', D) - ; ( sub_atom_last(X, I, 1, J, '/') - -> J > 1, - sub_atom(X, 0, I, _, C), - atom_concat(C, '/>', D) - ; J = 1, - D = X - ) - ), - pfx(E, D), - K is J-1, - sub_atom(X, _, K, 1, F) - -> atom_concat(E, F, W), - assertz(wtcache(X, W)) - ; ( \+flag(strings), - atom(X), - \+ (sub_atom(X, 0, 1, _, '<'), sub_atom(X, _, 1, 0, '>')), - X \= true, - X \= false - -> W = literal(X, type('')) - ; W = X - ) - ) - ), - ( W = literal(X, type('')) - -> wt2(W) - ; ( current_prolog_flag(windows, true) - -> atom_codes(W, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = W - ), - ( atom(Z) - -> write(Z) - ; ''(A, [blob, Z]), - wt(A) - ) - ). - -wt1(set(X)) :- - !, - write('($'), - wl(X), - write(' $)'). -wt1('$VAR'(X)) :- - !, - write('?V'), - write(X). -wt1(X) :- - X =.. [B|C], - ( atom(B), - \+ (sub_atom(B, 0, 1, _, '<'), sub_atom(B, _, 1, 0, '>')) - -> write('"'), - writeq(X), - write('"') - ; wt(C), - write(' '), - wp(B), - write(' true') - ). - -wt2((X, Y)) :- - !, - ( atomic(X), - X \= '!' - -> wt2([X, Y]), - write(' '), - wt0(''), - write(' true') - ; wt(X), - ws(X), - write('.'), - ( ( flag(strings) - ; flag(nope) - ) - -> write(' ') - ; nl, - indent - ), - wt(Y) - ). -wt2([X|Y]) :- - !, - ( \+last_tail([X|Y], []) - -> write('[ '), - wt0(''), - write(' '), - wg(X), - write('; '), - wt0(''), - write(' '), - wt(Y), - write(']') - ; write('('), - wg(X), - wl(Y), - write(')') - ). -wt2(literal(X, lang(Y))) :- - !, - write('"'), - ( current_prolog_flag(windows, true) - -> atom_codes(X, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = X - ), - write(Z), - write('"@'), - write(Y). -wt2(literal(X, type(''))) :- - !, - ( sub_atom(X, _, 2, _, '\\n') - -> write('"""'), - atom_codes(X, C), - escape_string(D, C), - atom_codes(Y, D), - ( current_prolog_flag(windows, true) - -> atom_codes(Y, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = Y - ), - write(Z), - write('"""') - ; write('"'), - ( current_prolog_flag(windows, true) - -> atom_codes(X, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = X - ), - write(Z), - write('"') - ). -wt2(literal(X, type(Y))) :- - !, - write('"'), - ( current_prolog_flag(windows, true) - -> atom_codes(X, U), - escape_unicode(U, V), - atom_codes(Z, V) - ; Z = X - ), - write(Z), - write('"^^'), - wt(Y). -wt2(rdiv(X, Y)) :- - number_codes(Y, [0'1|Z]), - lzero(Z, Z), - !, - ( Z = [] - -> F = '~d.0' - ; length(Z, N), - number_codes(X, U), - ( length(U, N) - -> F = '0.~d' - ; atomic_list_concat(['~', N, 'd'], F) - ) - ), - ( flag('no-numerals') - -> write('"') - ; true - ), - format(F, [X]), - ( flag('no-numerals') - -> write('"^^'), - wt0('') - ; true - ). -wt2(rdiv(X, Y)) :- - !, - ( flag('no-numerals') - -> write('"') - ; true - ), - format('~g', [rdiv(X, Y)]), - ( flag('no-numerals') - -> write('"^^'), - wt0('') - ; true - ). -wt2(''([X|Y], Z)) :- - flag(nope), - !, - ''(Y, U), - write('{'), - wt(U), - write('. _: '), - wp(''), - write(' '), - wt(Z), - write('} '), - wp(''), - write(' {'), - wt(X), - write('}'). -wt2(''([X|Y], Z)) :- - flag(nope), - !, - ''(Y, U), - write('{'), - wt(U), - write('. _: '), - wp(''), - write(' '), - wt(Z), - write('} '), - wp(''), - write(' {'), - wt(X), - write('}'). -wt2(''(X, Y)) :- - ( flag(nope) - -> U = X - ; ( X = when(A, B) - -> conj_append(B, istep(_, _, _, _), C), - U = when(A, C) - ; conj_append(X, istep(_, _, _, _), U) - ) - ), - ( flag('rule-histogram') - -> ( U = when(D, E) - -> conj_append(E, pstep(_), F), - Z = when(D, F) - ; conj_append(U, pstep(_), Z) - ) - ; Z = U - ), - ( rule_uvar(R) - -> true - ; R = [], - cnt(rn) - ), - ( nb_getval(pdepth, 0), - nb_getval(cdepth, 0) - -> assertz(rule_uvar(R)) - ; true - ), - ( catch(clause(Y, Z), _, fail) - -> ( nb_getval(fdepth, 0) - -> assertz(ncllit) - ; true - ), - wg(Y), - write(' <= '), - wg(X), - ( nb_getval(fdepth, 0) - -> retract(ncllit) - ; true - ) - ; ( clause(''(X, Y, _, _, _, _), true) - -> wg(X), - write(' => '), - wg(Y) - ; ( nb_getval(fdepth, 0) - -> assertz(ncllit) - ; true - ), - ( \+atom(X) - -> nb_getval(pdepth, PD), - PD1 is PD+1, - nb_setval(pdepth, PD1) - ; true - ), - wg(X), - ( \+atom(X) - -> nb_setval(pdepth, PD) - ; true - ), - ( nb_getval(fdepth, 0) - -> retract(ncllit) - ; true - ), - write(' => '), - ( \+atom(Y) - -> nb_getval(cdepth, CD), - CD1 is CD+1, - nb_setval(cdepth, CD1) - ; true - ), - wg(Y), - ( \+atom(Y) - -> nb_setval(cdepth, CD) - ; true - ) - ) - ), - ( nb_getval(pdepth, 0), - nb_getval(cdepth, 0) - -> retract(rule_uvar(_)) - ; true - ), - !. -wt2(':-'(X, Y)) :- - ( rule_uvar(R) - -> true - ; R = [], - cnt(rn) - ), - ( nb_getval(fdepth, 0) - -> assertz(ncllit) - ; true - ), - assertz(rule_uvar(R)), - ( Y = true - -> wt(X) - ; wg(X), - write(' <= '), - wg(Y), - retract(rule_uvar(U)), - ( U \= [], - retract(rule_uvar(V)), - append(U, V, W) - -> assertz(rule_uvar(W)) - ; true - ) - ), - ( nb_getval(fdepth, 0) - -> retract(ncllit) - ; true - ), - !. -wt2(is(O, T)) :- - !, - ( number(T), - T < 0 - -> P = -, - Q is -T, - S = [Q] - ; T =.. [P|S] - ), - wg(S), - write(' '), - wp(P), - write(' '), - wg(O). -wt2(prolog:X) :- - !, - ( X = '\';\'' - -> Y = disjunction - ; prolog_sym(Y, X, _) - ), - atomic_list_concat([''], Z), - wt0(Z). -wt2(X) :- - X =.. [P, S, O], - ( atom(P), - \+ (sub_atom(P, 0, 1, _, '<'), sub_atom(P, _, 1, 0, '>')), - \+sub_atom(P, 0, _, _, avar), - \+sub_atom(P, 0, _, _, some) - -> write('"'), - writeq(X), - write('"') - ; wg(S), - write(' '), - wp(P), - write(' '), - wg(O) - ). - -wtn(exopred(P, S, O)) :- - !, - ( atom(P) - -> X =.. [P, S, O], - wt2(X) - ; wg(S), - write(' '), - wg(P), - write(' '), - wg(O) - ). -wtn(triple(S, P, O)) :- - !, - write('<<'), - wg(S), - write(' '), - wp(P), - write(' '), - wg(O), - write('>>'). -wtn(X) :- - X =.. [B|C], - ( atom(B), - \+ (sub_atom(B, 0, 1, _, '<'), sub_atom(B, _, 1, 0, '>')) - -> write('"'), - writeq(X), - write('"') - ; wt(C), - write(' '), - wp(B), - write(' true') - ). - -wg(X) :- - var(X), - !, - write('?'), - write(X). -wg(X) :- - functor(X, F, A), - ( ( F = exopred, - ! - ; prolog_sym(_, F, _), - F \= true, - F \= false, - F \= '-', - F \= /, - ! - ; A = 2, - F \= '.', - F \= '[|]', - F \= ':', - F \= literal, - F \= rdiv, - ( sub_atom(F, 0, 1, _, '<'), - sub_atom(F, _, 1, 0, '>') - ; F = ':-' - ) - ) - -> write('{'), - indentation(1), - nb_getval(fdepth, D), - E is D+1, - nb_setval(fdepth, E), - wt(X), - nb_setval(fdepth, D), - indentation(-1), - write('}') - ; wt(X) - ). - -wp('') :- - \+flag('no-qnames'), - !, - write('a'). -wp('') :- - \+flag('no-qnames'), - !, - write('=>'). -wp(':-') :- - \+flag('no-qnames'), - !, - write('<='). -wp(X) :- - ( prolog_sym(Y, X, _), - X \= true, - X \= false - -> atomic_list_concat([''], Z), - wt(Z) - ; wg(X) - ). - -wk([]) :- - !. -wk([X|Y]) :- - write(', '), - wt(X), - wk(Y). - -wl([]) :- - !. -wl([X|Y]) :- - write(' '), - wg(X), - wl(Y). - -wq([],_) :- - !. -wq([X|Y],allv) :- - !, - write('@forAll '), - wt(X), - wk(Y), - write('. '). -wq([X|Y],some) :- - ( \+flag('no-qvars') - -> write('@forSome '), - wt(X), - wk(Y), - write('. ') - ; true - ). - -wb([]) :- - !. -wb([X = Y|Z]) :- - wp(''), - write(' [ '), - wp(''), - write(' '), - wv(X), - write('; '), - wp(''), - write(' '), - wv(Y), - write('];'), - nl, - indent, - wb(Z). - -wv(X) :- - atom(X), - atom_concat(avar, Y, X), - !, - write('[ '), - wp(''), - write(' "http://josd.github.io/var#x_'), - write(Y), - write('"]'). -wv(X) :- - atom(X), - atom_concat(some, Y, X), - !, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' "_:sk_'), - write(Y), - write('"]'). -wv(X) :- - atom(X), - nb_getval(var_ns, Sns), - sub_atom(X, 1, I, _, Sns), - !, - write('[ '), - wp(''), - write(' '), - wp(''), - write('; '), - wp(''), - write(' "'), - write(Sns), - J is I+1, - sub_atom(X, J, _, 1, Q), - write(Q), - write('"]'). -wv(X) :- - atom(X), - sub_atom(X, 1, _, 1, U), - atomic_list_concat(['<', U, '>'], X), - !, - write('[ '), - wp(''), - write(' "'), - write(U), - write('"]'). -wv(X) :- - wg(X). - -ws((X, Y)) :- - !, - conj_list((X, Y), Z), - last(Z, U), - ws(U). -ws(X) :- - X =.. Y, - last(Y, Z), - ( \+number(Z), - Z \= rdiv(_, _) - -> true - ; write(' ') - ). - -wst :- - findall([Key, Str], - ( ''(Key, Str) - ; answer(A1, A2, A3), - djiti_answer(answer(''(Key, Str)), answer(A1, A2, A3)) - ), - KS - ), - sort(KS, KT), - forall( - ( member([_, MT], KT), - getcodes(MT, LT) - ), - ( escape_string(NT, LT), - atom_codes(ST, NT), - wt(ST) - ) - ), - ( catch(nb_getval(csv_header, Header), _, Header = []), - wct(Header, Header), - length(Header, Headerl), - query(Where, ''(_, Select)), - catch(call(Where), _, fail), - write('\r\n'), - wct(Select, Header), - cnt(output_statements, Headerl), - cnt(answer_count), - nb_getval(answer_count, AnswerCount), - ( flag('limited-answer', AnswerLimit), - AnswerCount >= AnswerLimit - -> true - ; fail - ) - ; true - ). - -wct([], []) :- - !. -wct([A], [C]) :- - !, - wcf(A, C). -wct([A|B], [C|D]) :- - wcf(A, C), - ( flag('csv-separator', S) - -> true - ; S = ',' - ), - write(S), - wct(B, D). - -wcf(A, _) :- - var(A), - !. -wcf(rdiv(X, Y), _) :- - number_codes(Y, [0'1|Z]), - lzero(Z, Z), - !, - ( Z = [] - -> F = '~d.0' - ; length(Z, N), - number_codes(X, U), - ( length(U, N) - -> F = '0.~d' - ; atomic_list_concat(['~', N, 'd'], F) - ) - ), - format(F, [X]). -wcf(literal(A, B), _) :- - !, - atom_codes(A, C), - subst([[[0'\\, 0'"], [0'", 0'"]]], C, E), - atom_codes(F, E), - ( B \= type(''), - B \= type(''), - B \= type(''), - B \= type(''), - B \= type(''), - B \= type('') - -> write('"'), - write(F), - write('"') - ; write(F) - ). -wcf(A, _) :- - atom(A), - nb_getval(var_ns, Sns), - sub_atom(A, 1, I, _, Sns), - !, - J is I+1, - sub_atom(A, J, _, 1, B), - write('_:'), - write(B). -wcf(A, _) :- - atom(A), - flag('quantify', Prefix), - sub_atom(A, 1, _, _, Prefix), - !, - ''(B, ['quantify', Prefix, A]), - wt0(B). -wcf(A, B) :- - atom(A), - relabel(A, C), - sub_atom(C, 0, 1, _, '<'), - sub_atom(C, _, 1, 0, '>'), - !, - sub_atom(C, 1, _, 1, D), - ( sub_atom(B, _, 2, 0, 'ID') - -> ( flag('hmac-key', Key) - -> hmac_sha(Key, D, E, [algorithm(sha1)]) - ; sha_hash(D, E, [algorithm(sha1)]) - ), - atom_codes(F, E), - base64xml(F, G), - write(G) - ; write(D) - ). -wcf(A, _) :- - atom(A), - sub_atom(A, 0, 1, _, '_'), - !, - sub_atom(A, 1, _, 0, B), - write(B). -wcf(A, _) :- - with_output_to(atom(B), wg(A)), - write(B). - -wcn((A, B)) :- - !, - format(', ~w', [A]), - wcn(B). -wcn(A) :- - format(', ~w', [A]). - -indent:- - nb_getval(indentation, A), - tab(A). - -indentation(C) :- - nb_getval(indentation, A), - B is A+C, - nb_setval(indentation, B). - - -% ---------------------------- -% EAM (Euler Abstract Machine) -% ---------------------------- -% -% In a nutshell: -% -% 1/ Select rule P => C -% 2/ Prove P & NOT(C) (backward chaining) and if it fails backtrack to 1/ -% 3/ If P & NOT(C) assert C (forward chaining) and remove brake -% 4/ If C = answer(A) and tactic limited-answer stop, else backtrack to 2/ -% 5/ If brake or tactic linear-select stop, else start again at 1/ -% - -eam(Span) :- - ( cnt(tr), - ( flag(debug) - -> format(user_error, 'eam/1 entering span ~w~n', [Span]), - flush_output(user_error) - ; true - ), - ( flag('max-inferences', MaxInf), - statistics(inferences, Inf), - Inf > MaxInf - -> throw(max_inferences_exceeded(MaxInf)) - ; true - ), - implies(Prem, Conc, Src), - ignore(Prem = true), - ( flag(nope), - \+flag('rule-histogram') - -> true - ; copy_term_nat(''(Prem, Conc), Rule) - ), - ( flag(debug) - -> format(user_error, '. eam/1 selecting rule ~q~n', [implies(Prem, Conc, Src)]), - flush_output(user_error) - ; true - ), - ( flag('no-ucall') - -> catch(call_residue_vars(call(Prem), []), Exc, - ( Exc = error(existence_error(procedure, _), _) - -> fail - ; throw(Exc) - ) - ) - ; catch(call_residue_vars(ucall(Prem), []), Exc, - ( Exc = error(existence_error(procedure, _), _) - -> fail - ; throw(Exc) - ) - ) - ), - ( ( Conc = false - ; Conc = answer(false, void, void) - ) - -> with_output_to(atom(PN3), wt(''(Prem, false))), - ( flag('ignore-inference-fuse') - -> format(user_error, '** ERROR ** eam ** ~w~n', [inference_fuse(PN3)]), - fail - ; throw(inference_fuse(PN3)) - ) - ; true - ), - \+atom(Conc), - ( flag('rule-histogram'), - copy_term_nat(Rule, RuleL) - -> lookup(RTP, tp, RuleL), - catch(cnt(RTP), _, nb_setval(RTP, 0)) - ; true - ), - cnt(tp), - djiti_conc(Conc, Concd), - ( Concd = ':-'(Head, Body) - -> \+clause(Head, Body) - ; ( Concd = ''(_, _) - -> copy_term_nat(Concd, Concc), - labelvars(Concc, 0, _, avar), - \+cc(Concc), - assertz(cc(Concc)) - ; ( flag('no-ucall') - -> \+catch(call(Concd), _, fail) - ; \+catch(ucall(Concd), _, fail) - ) - ) - ), - ( flag('rule-histogram') - -> lookup(RTC, tc, RuleL), - catch(cnt(RTC), _, nb_setval(RTC, 0)) - ; true - ), - ( Concd = (_, _), - conj_list(Concd, Cl) - -> length(Cl, Ci), - cnt(tc, Ci) - ; cnt(tc) - ), - ( Concd \= ''(_, _), - Concd \= ':-'(_, _) - -> nb_getval(wn, W), - labelvars(Prem-Concd, W, N), % failing when Prem contains attributed variables - nb_setval(wn, N) - ; true - ), - ( flag(debug) - -> format(user_error, '... eam/1 assert step ~q~n', [Concd]), - flush_output(user_error) - ; true - ), - conj_list(Concd, La), - couple(La, La, Lc), - findall([D, F], - ( member([D, D], Lc), - unify(D, F), - ( F = ''(_, _) - -> true - ; catch(\+F, _, true) - ) - ), - Ld - ), - couple(Ls, Le, Ld), - conj_list(Concs, Ls), - conj_list(Conce, Le), - astep(Src, Prem, Concd, Conce, Rule), - ( ( Concs = answer(_, _, _) - ; Concs = (answer(_, _, _), _) - ) - -> cnt(answer_count) - ; true - ), - nb_getval(answer_count, AnswerCount), - ( flag('limited-answer', AnswerLimit), - AnswerCount >= AnswerLimit - -> ( flag(strings) - -> true - ; w3 - ) - ; retract(brake), - fail - ) - ; ( brake - ; flag(tactic, 'linear-select') - ), - ( S is Span+1, - ( \+span(S) - -> assertz(span(S)) - ; true - ), - nb_getval(limit, Limit), - Span < Limit, - eam(S) - ; ( flag(strings) - -> true - ; w3 - ) - ; true - ), - ! - ; assertz(brake), - exogen, - eam(Span) - ). - -astep(A, B, Cd, Cn, Rule) :- % astep(Source, Premise, Conclusion, Conclusion_unique, Rule) - ( Cn = (Dn, En) - -> functor(Dn, P, N), - ( \+pred(P), - P \= '', - P \= '', - P \= '', - P \= '', - P \= '', - N = 2 - -> assertz(pred(P)) - ; true - ), - ( Dn \= ''(_, _), - catch(call(Dn), _, fail) - -> true - ; djiti_assertz(Dn), - ( flag('pass-only-new'), - Dn \= answer(_, _, _), - \+pass_only_new(Dn) - -> assertz(pass_only_new(Dn)) - ; true - ), - ( flag(nope) - -> true - ; ( B = ''(P1, Q1), - Rule = ''(Q6, R6), - prfstep(''(P1, Q1), Q3, Q4, _, - ''(P6, Q6), forward, A) - -> assertz(prfstep(Dn, Q3, Q4, Cd, ''(P6, R6), forward, A)) - ; term_index(B, Pnd), - assertz(prfstep(Dn, B, Pnd, Cd, Rule, forward, A)) - ) - ) - ), - astep(A, B, Cd, En, Rule) - ; ( Cn = true - -> true - ; functor(Cn, P, N), - ( \+pred(P), - P \= '', - P \= '', - P \= '', - P \= '', - P \= '', - N = 2 - -> assertz(pred(P)) - ; true - ), - ( Cn \= ''(_, _), - catch(call(Cn), _, fail) - -> true - ; djiti_assertz(Cn), - ( flag('pass-only-new'), - Cn \= answer(_, _, _), - \+pass_only_new(Cn) - -> assertz(pass_only_new(Cn)) - ; true - ), - ( flag(nope) - -> true - ; ( B = ''(P1, Q1), - Rule = ''(Q6, R6), - prfstep(''(P1, Q1), Q3, Q4, _, - ''(P6, Q6), forward, A) - -> assertz(prfstep(Cn, Q3, Q4, Cd, ''(P6, R6), forward, A)) - ; term_index(B, Pnd), - assertz(prfstep(Cn, B, Pnd, Cd, Rule, forward, A)) - ) - ) - ) - ) - ). - -istep(Src, Prem, Conc, Rule) :- % istep(Source, Premise, Conclusion, Rule) - copy_term_nat(Prem, Prec), - labelvars(Prec, 0, _), - term_index(Prec, Pnd), - ( \+prfstep(Conc, Prec, Pnd, Conc, Rule, backward, Src) - -> assertz(prfstep(Conc, Prec, Pnd, Conc, Rule, backward, Src)) - ; true - ). - -pstep(Rule) :- - copy_term_nat(Rule, RuleL), - lookup(RTC, tc, RuleL), - catch(cnt(RTC), _, nb_setval(RTC, 0)), - lookup(RTP, tp, RuleL), - catch(cnt(RTP), _, nb_setval(RTP, 0)). - -hstep(A, B) :- - ( nonvar(A), - A = exopred(P, S, O) - -> pred(P), - U =.. [P, S, O], - qstep(U, B) - ; qstep(A, B) - ). - -qstep(A, B) :- - prfstep(A, B, _, _, _, _, _). -qstep(A, true) :- - ( nonvar(A) - -> ( A =.. [P, [S1, S2|S3], O] - -> B =.. [P, S1, S2, S3, O] - ; ( A =.. [P, S, literal(O1, O2)] - -> B =.. [P, S, O1, O2] - ; B = A - ) - ) - ; pred(P), - A =.. [P, _, _], - B = A - ), - catch(clause(B, true), _, fail), - \+prfstep(A, _, _, _, _, _, _). - -% -% DJITI (Deep Just In Time Indexing) -% - -djiti_answer(answer((A, B)), (C, D)) :- - !, - djiti_answer(answer(A), C), - djiti_answer(answer(B), D). -djiti_answer(answer(A), answer(P, S, O)) :- - ( nonvar(A) - ; atom(P), - S \= void - ), - A =.. [P, S, O], - !. -djiti_answer(answer(exopred(P, S, O)), answer(P, S, O)) :- - ( var(S) - ; S \= void - ), - !. -djiti_answer(answer(A), answer(A, void, void)) :- - !. -djiti_answer(A, A). - -djiti_conc(':-'(exopred(P, S, O), B), ':-'(A, B)) :- - !, - A =.. [P, S, O]. -djiti_conc(answer((A, B), void, void), (answer(A, void, void), D)) :- - !, - djiti_conc(answer(B, void, void), D). -djiti_conc(A, A). - -djiti_fact(answer(P, S, O), answer(P, S, O)) :- - atomic(P), - !, - ( P \= '', - P \= '', - \+pred(P) - -> assertz(pred(P)) - ; true - ). -djiti_fact(implies(A, B, C), implies(A, B, C)) :- - nonvar(B), - conj_list(B, D), - forall( - member(E, D), - ( unify(E, F), - F =.. [P, _, _], - ( \+fpred(P) - -> assertz(fpred(P)) - ; true - ) - ) - ), - !. -djiti_fact(''(A, B), C) :- - nonvar(B), - ( conj_list(B, D) - -> true - ; D = B - ), - forall( - member(E, D), - ( unify(E, F), - F =.. [P, _, _], - ( \+fpred(P) - -> assertz(fpred(P)) - ; true - ) - ) - ), - !, - ( retwist(A, B, Z) - -> true - ; Z = '<>' - ), - makevars(implies(A, B, Z), C, zeta). -djiti_fact(':-'(A, B), ':-'(C, D)) :- - !, - makevars((A, B), (C, E), eta), - copy_term_nat(''(E, C), F), - ( flag(nope) - -> D = E - ; retwist(E, C, G), - ( E = when(H, I) - -> conj_append(I, istep(G, E, C, F), J), - D = when(H, J) - ; conj_append(E, istep(G, E, C, F), D) - ) - ). -djiti_fact(''(A, B), ':-'(''(A, B), true)) :- - !. -djiti_fact(A, A) :- - ground(A), - A =.. [P, _, _], - ( P \= '', - P \= '', - P \= '', - P \= query, - P \= pfx, - P \= flag, - P \= semantics, - \+pred(P) - -> assertz(pred(P)) - ; true - ), - !. -djiti_fact(A, A). - -djiti_assertz(A) :- - djiti_fact(A, B), - assertz(B). - -% -% Built-ins -% - -''(A, B) :- - \+flag(restricted), - avg(A, B). - -''(A, B) :- - \+flag(restricted), - catch(call(A), _, fail), - A \= B, - unify(A, C), - conj_list(C, D), - forall( - member(E, D), - ( ( E = ''(Prem, Conc) - -> retract(implies(Prem, Conc, Src)), - assertz(retwist(Prem, Conc, Src)) - ; ( E = ':-'(Ci, Pi), - Pi \= true - -> ( flag(nope) - -> Ph = Pi - ; ( Pi = when(Ai, Bi) - -> conj_append(Bi, istep(Si, Pi, Ci, _), Bh), - Ph = when(Ai, Bh) - ; conj_append(Pi, istep(Si, Pi, Ci, _), Ph) - ), - ':-'(Ci, Ph), - assertz(retwist(Pi, Ci, Si)) - ), - retract(':-'(Ci, Ph)) - ; E \= ':-'(_, true), - retract(E) - ) - ), - djiti_answer(answer(E), Z), - retractall(Z), - ( flag('pass-only-new'), - pass_only_new(E) - -> retract(pass_only_new(E)) - ; true - ) - ) - ), - nb_getval(wn, W), - labelvars(B, W, N), - nb_setval(wn, N), - unify(B, F), - conj_list(F, G), - forall( - member(H, G), - ( djiti_assertz(H), - ( flag('pass-only-new'), - \+pass_only_new(H) - -> assertz(pass_only_new(H)) - ; true - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - A, - B. - -''([''(A, B)|C], D) :- - \+flag(restricted), - within_scope(_), - ( nb_getval(bnet, done) - -> true - ; bnet, - nb_setval(bnet, done) - ), - bvar(A), - bval(B), - bcon([''(A, B)], C, D). - -''(A, B) :- - \+flag(restricted), - getnumber(A, C), - ( C =:= 0.0 - -> B is 0.0 - ; ( C =:= 1.0 - -> B is 0.0 - ; B is -(C*log(C)+(1-C)*log(1-C))/log(2) - ) - ). - -''([literal(A, type(''))|B], C) :- - \+flag(restricted), - findall(U, - ( member(V, B), - getnumber(V, U) - ), - W - ), - read_term_from_atom(A, D, [variables(W)]), - catch(C is D, _, fail). - -''(A, B) :- - \+flag(restricted), - nonvar(A), - A \= [_,_], - !, - when( - ( nonvar(B) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - open(Tmp2, write, Ws2, [encoding(utf8)]), - tell(Ws2), - ( flag('no-qnames') - -> true - ; forall( - pfx(E, F), - format('@prefix ~w ~w.~n', [E, F]) - ), - nl - ), - labelvars(B, 0, _), - write('{'), - wt(B), - write('} => {'), - wt(B), - write('}.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp3), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--query', Tmp2, '>', Tmp3]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp3, semantics), - absolute_uri(Tmp3, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - L \= [] - ; delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - fail - ) - ) - ). -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - nonvar(A), - conjify(A, B), - catch(call(B), _, fail), - ( flag(nope) - -> true - ; copy_term_nat(''(B, ''(Sc, B)), C), - istep('<>', B, ''(Sc, B), C) - ). - -''(A, B) :- - \+flag(restricted), - findall(C, - ( cartesian(A, C) - ), - B - ). - -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - hstep(A, _). - -''([literal(A, type(''))|B], C) :- - \+flag(restricted), - atomify(B, D), - read_term_from_atom(A, C, [variables(D)]). - -''(A, B) :- - \+flag(restricted), - cov(A, B). - -''(A, B) :- - \+flag(restricted), - atomify(A, C), - D =.. C, - ( B = true - -> catch(call(D), _, fail) - ; \+catch(call(D), _, fail) - ). - -''(literal(A, type('')), B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( exec(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - nonvar(A), - A \= [_,_], - !, - when( - ( nonvar(B) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - open(Tmp2, write, Ws2, [encoding(utf8)]), - tell(Ws2), - ( flag('no-qnames') - -> true - ; forall( - pfx(E, F), - format('@prefix ~w ~w.~n', [E, F]) - ), - nl - ), - labelvars(B, 0, _), - write('{'), - wt(B), - write('} => {'), - wt(B), - write('}.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp3), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--query', Tmp2, '>', Tmp3]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp3, semantics), - absolute_uri(Tmp3, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - L = [] - ; delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - fail - ) - ) - ). -''(A, B) :- - \+flag(restricted), - within_scope(A), - \+catch(call(B), _, fail). - -''(literal(A, type('')), literal(B, type(''))) :- - \+flag(restricted), - read_file_to_string(A, C, []), - ( string_concat(D, "\n", C) - -> true - ; D = C - ), - atom_string(B, D). - -''(A, B) :- - \+flag(restricted), - call_cleanup(A, B), - ( flag(nope) - -> true - ; conj_append(A, B, C), - copy_term_nat(''(C, ''(A, B)), D), - istep('<>', C, ''(A, B), D) - ). - -''(A, B) :- - \+flag(restricted), - nonvar(A), - A \= [_,_], - !, - when( - ( nonvar(B) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - open(Tmp2, write, Ws2, [encoding(utf8)]), - tell(Ws2), - ( flag('no-qnames') - -> true - ; forall( - pfx(E, F), - format('@prefix ~w ~w.~n', [E, F]) - ), - nl - ), - write('{'), - wt(''(_, B)), - write('} => {'), - wt(''(_, B)), - write('}.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp3), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--query', Tmp2, '>', Tmp3]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp3, semantics), - absolute_uri(Tmp3, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - conj_list(K, L), - labelvars(K, 0, _), - B = [_, _, M], - K = ''(_, [_, _, M]), - delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3) - ; delete_file(Tmp1), - delete_file(Tmp2), - delete_file(Tmp3), - fail - ) - ) - ). -''(Sc, [A, B, C]) :- - \+flag(restricted), - within_scope(Sc), - nonvar(B), - \+is_list(B), - catch(findall(A, B, E), _, E = []), - ( flag(warn) - -> copy_term_nat([A, B, E], [Ac, Bc, Ec]), - labelvars([Ac, Bc, Ec], 0, _), - ( fact(''(Sc, [Ac, Bc, G])) - -> ( E \= G - -> format(user_error, '** WARNING ** conflicting_findall_answers ~w VERSUS ~w~n', [[A, B, G], [A, B, E]]), - flush_output(user_error) - ; true - ) - ; assertz(fact(''(Sc, [Ac, Bc, Ec]))) - ) - ; true - ), - E = C. - -''([A|B], [A, B]) :- - \+flag(restricted). - -''([literal(A, type(''))|B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, D), - preformat(B, E), - format_to_chars(D, E, F), - atom_codes(C, F) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( ''(A, C), - conj_list(C, L), - sort(L, M), - conj_list(K, M), - unify(K, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( makevars(A, C, delta), - difference(C, D), - unify(D, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( intersect(A, M), - unify(M, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( unify(A, C), - conj_list(C, D), - ( nonvar(B) - -> cflat(B, E), - ( ground(E) - -> distinct(E, D) - ; D = E - ) - ; ( ground(D) - -> distinct(D, B) - ; B = D - ) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( conj_list(A, C), - member(D, C), - unify(D, B) - ) - ). - -''((A, B), [A, B]) :- - \+flag(restricted). - -''(literal(A, type('')), literal(B, type(''))) :- - \+flag(restricted), - flag('hmac-key', Key), - hmac_sha(Key, A, C, [algorithm(sha1)]), - atom_codes(D, C), - base64xml(D, B). - -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - nonvar(A), - ( catch(call(A), _, fail) - -> ( flag(nope) - -> true - ; copy_term_nat(''(A, ''(Sc, A)), R), - istep('<>', A, ''(Sc, A), R) - ) - ; true - ). - -''(A, literal(B, type(''))) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( atom(A), - ( sub_atom(A, _, 19, _, '/.well-known/genid/') - -> ( sub_atom(A, I, 1, _, '#') - -> J is I+1, - sub_atom(A, J, _, 1, B) - ; B = '' - ) - ; atom_concat(some, C, A), - atomic_list_concat(['sk_', C], B) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - copy_term_nat(A, C), - labelvars(C, 0, _), - term_index(C, D), - ( got_labelvars(C, D, B) - -> true - ; copy_term_nat(A, B), - labelvars(B, 0, _, avar), - assertz(got_labelvars(C, D, B)) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( ( getlist(A, C) - -> true - ; conj_list(A, D), - ( ground(D) - -> distinct(D, C) - ; C = D - ) - ), - length(C, B) - ) - ). - -''(_, B) :- - \+flag(restricted), - \+ \+catch(call(B), _, fail). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( bmax(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( bmin(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A), - nonvar(B) - ), - ( sort(0, @=<, A, C), - sort(0, @=<, B, C) - ) - ). - -''(A, B) :- - \+flag(restricted), - \+''(A, B). - -''(A, B) :- - \+flag(restricted), - \+''(A, B). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( getnumber(A, B) - ) - ). - -''(Sc, A) :- - \+flag(restricted), - within_scope(Sc), - nonvar(A), - ( \+catch(call(A), _, fail) - -> true - ; catch(call(A), _, fail), - ( flag(nope) - -> true - ; copy_term_nat(''(A, ''(Sc, A)), R), - istep('<>', A, ''(Sc, A), R) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - pcc([A, B], C). - -''(Sc, literal(A, type(''))) :- - \+flag(restricted), - within_scope(Sc), - with_output_to_codes(wh, C), - atom_codes(A, C), - retractall(wpfx(_)). - -''([A], [B, C]) :- - \+flag(restricted), - !, - D =.. [A, B, C], - catch(call(D), _, fail). -''([A|B], [C, D]) :- - \+flag(restricted), - E =.. [A, C, F], - catch(call(E), _, fail), - ''(B, [F, D]). - -''([A|B], C) :- - \+flag(restricted), - term_index([A|B], I), - ( B \= [], - got_random([A|B], I, C) - -> true - ; catch(nb_getval(random, D), _, D = 16127), - E is mod(1046527*D+16769023, 1073676287), - nb_setval(random, E), - C is mod(E, A), - ( B \= [] - -> assertz(got_random([A|B], I, C)) - ; true - ) - ). - -''(A, B) :- - \+flag(restricted), - reverse(A, B). - -''(A, B) :- - \+flag(restricted), - rms(A, B). - -''(St, [Sen, Asp]) :- - \+flag(restricted), - getnumber(St, K), - ( getnumber(Sen, S) - -> Asp is 1-(1-exp(-K*(S-1)))*(1+exp(K))/(1+exp(-K*(S-1)))/(1-exp(K)) - ; getnumber(Asp, A), - Sen is (1-exp(-K*A))*(1+exp(-K))/(1+exp(-K*A))/(1-exp(-K)) - ). - -''(literal(A, type('')), literal(B, type(''))) :- - \+flag(restricted), - sha_hash(A, C, [algorithm(sha1)]), - atom_codes(D, C), - base64xml(D, B). - -''(A, B) :- - \+flag(restricted), - getnumber(A, C), - B is 1/(1+exp(-C)). - -''(X, Y) :- - \+flag(restricted), - ''(Y, X), - ( \+keep_skolem(Y) - -> assertz(keep_skolem(Y)) - ; true - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( sort(A, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - std(A, B). - -''(literal(X, Y), literal(Z, Y)) :- - \+flag(restricted), - when( - ( ground(X) - ), - ( atom_codes(X, U), - escape_string(U, V), - atom_codes(Z, V) - ) - ). - -''(literal(X, Y), literal(Z, Y)) :- - \+flag(restricted), - when( - ( ground(X) - ), - ( atom_codes(X, U), - reverse(U, V), - atom_codes(Z, V) - ) - ). - -''([literal(X, type('')), literal(Y, type(''))], - Z) :- - \+flag(restricted), - when( - ( ground([X, Y]) - ), - ( atom_codes(X, U), - atom_codes(Y, C), - ( C = [] - -> findall(literal(A, type('')), - ( member(B, U), - atom_codes(A, [B]) - ), - Z - ) - ; escape_string(V, C), - esplit_string(U, V, [], W), - findall(literal(A, type('')), - ( member(B, W), - atom_codes(A, B) - ), - Z - ) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( sub_list(A, B) - ) - ). - -''(X, Y) :- - \+flag(restricted), - tell(user_error), - write('TRACE '), - ( ( var(X) - ; findvar(X, beta) - ) - -> copy_term_nat(Y, Z), - wg(Z) - ; writeq(Y) - ), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ). - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( e_transpose(A, B) - ) - ). - -''(A, [B, C, D]) :- - \+flag(restricted), - A =.. [C, B, D]. - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ; ground(Y) - ), - ( ( is_list(Y), - length(Y, I), - I < 8 - -> Z =.. [tuple, X|Y] - ; Z = tuple(X, Y) - ), - ( call(Z) - -> true - ; var(X), - nb_getval(tuple, M), - N is M+1, - nb_setval(tuple, N), - atom_number(A, N), - nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 't_', A, '>'], X), - assertz(Z) - ) - ) - ). - -''(A, B) :- - \+flag(restricted), - ( got_unique(A, B) - -> fail - ; assertz(got_unique(A, B)) - ). - -''(A, B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( findvars(A, C, delta), - C \= [] - -> true - ; catch(call(B), _, A = B) - ) - ). - -''(X, literal(Y, type(''))) :- - \+flag(restricted), - when( - ( ground(X) - ; ground(Y) - ), - ( ( ground(X) - -> ( number(X) - -> atom_number(T, X) - ; X = literal(T, _) - ), - www_form_encode(T, Z), - atom_codes(Z, U), - subst([[[0'%, 0'2, 0'0], [0'+]]], U, V), - atom_codes(Y, V) - ; www_form_encode(X, Y) - ) - ) - ). - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [Y|Z], - nonvar(Z) - ) - ), - !. - -''(X, []) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [_] - ) - ), - !. -''(X, '') :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [_] - ) - ), - !. -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( X = [_|Y] - ) - ), - !. - -''(literal(A, type('')), literal(B, type(''))) :- - md5_hash(A, B, []). - -''(literal(A, type('')), literal(B, type(''))) :- - sha_hash(A, C, [algorithm(sha1)]), - hash_atom(C, B). - -''(literal(A, type('')), literal(B, type(''))) :- - sha_hash(A, C, [algorithm(sha256)]), - hash_atom(C, B). - -''(literal(A, type('')), literal(B, type(''))) :- - sha_hash(A, C, [algorithm(sha512)]), - hash_atom(C, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( makevars(A, C, delta), - difference(C, D), - unify(D, B) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( conj_list(A, D), - ( ground(D) - -> distinct(D, C) - ; C = D - ), - length(C, B) - ) - ). - -''(A, B) :- - conj_list(A, B). - -''(A, B) :- - ''(A, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - ( member(D, C), - var(D), - var(B) - -> true - ; append(C, B) - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - C = [B|D], - nonvar(D) - ) - ). - -''([A|B], [A, B]). - -''(A, B) :- - when( - ( nonvar(B) - ), - ( getlist(B, C), - member(A, C) - ) - ). - -''(A, [B, C]) :- - when( - ( nonvar(A) - ), - ( nth0(B, A, C) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - last(C, B) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( ( getlist(A, C) - -> true - ; conj_list(A, D), - ( ground(D) - -> distinct(D, C) - ; C = D - ) - ), - length(C, B) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A), - nonvar(B) - ), - ( getlist(A, D), - findall(E, - ( member(F, D), - G =.. [B, F, E], - G - ), - C - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - member(B, C) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A) - ), - ( nth0(B, A, C) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A), - nonvar(B) - ), - ( findall(I, - ( member(I, A), - I \= B - ), - C - ) - ) - ). - -''([A, B], C) :- - when( - ( nonvar(A) - ), - ( nth0(B, A, D), - findall(I, - ( member(I, A), - I \= D - ), - C - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - list_to_set(C, B) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( getlist(A, C), - C = [_|B] - ) - ). - -''(A, B) :- - when( - ( nonvar(A), - nonvar(B) - ), - ( getlist(A, C), - getlist(B, D), - sort(C, E), - sort(D, E) - ) - ). - -''(A, B) :- - \+''(A, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( sort(A, B) - ) - ). - -''(A, B) :- - ''(A, B). - -''(X, Y) :- - ( nonvar(X) - -> Y = true - ; Y = false - ). - -''(A, B) :- - call_cleanup(A, B), - ( flag(nope) - -> true - ; conj_append(A, B, C), - copy_term_nat(''(C, ''(A, B)), D), - istep('<>', C, ''(A, B), D) - ). - -''([A, B, C], Sc) :- - within_scope(Sc), - nonvar(B), - \+is_list(B), - catch(findall(A, B, E), _, E = []), - ( flag(warn) - -> copy_term_nat([A, B, E], [Ac, Bc, Ec]), - labelvars([Ac, Bc, Ec], 0, _), - ( fact(''(Sc, [Ac, Bc, G])) - -> ( E \= G - -> format(user_error, '** WARNING ** conflicting_collectAllIn_answers ~w VERSUS ~w~n', [[A, B, G], [A, B, E]]), - flush_output(user_error) - ; true - ) - ; assertz(fact(''(Sc, [Ac, Bc, Ec]))) - ) - ; true - ), - E = C. - -''(A, B) :- - when( - ( nonvar(A) - ), - ( reset_gensym, - tmp_file(Tmp1), - open(Tmp1, write, Ws1, [encoding(utf8)]), - tell(Ws1), - ( flag('no-qnames') - -> true - ; forall( - pfx(C, D), - format('@prefix ~w ~w.~n', [C, D]) - ), - nl - ), - labelvars(A, 0, _), - wt(A), - write('.'), - nl, - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - tmp_file(Tmp2), - !, - ( current_prolog_flag(windows, true) - -> A1 = ['cmd.exe', '/C'] - ; A1 = [] - ), - ( current_prolog_flag(argv, Argv), - append(Argu, ['--'|_], Argv) - -> append(Argu, ['--'], A2) - ; A2 = ['eye'] - ), - append([A1, A2, ['--nope', Tmp1, '--pass-all', '>', Tmp2]], A4), - findall([G, ' '], - ( member(G, A4) - ), - H - ), - flatten(H, I), - atomic_list_concat(I, J), - ( catch(exec(J, _), _, fail) - -> n3_n3p(Tmp2, semantics), - absolute_uri(Tmp2, Tmp), - atomic_list_concat(['<', Tmp, '>'], Res), - semantics(Res, L), - conj_list(B, L), - labelvars(B, 0, _), - delete_file(Tmp1), - delete_file(Tmp2) - ; delete_file(Tmp1), - delete_file(Tmp2), - fail - ) - ) - ). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( conjoin(A, M), - unify(M, B) - ) - ). - -''(A, B) :- - \+flag(restricted), - ''(A, C), - ''(C, B). - -''([A, B], C) :- - when( - ( ground(A) - ; nonvar(C) - ), - ( ground(A), - ( var(B) - -> ( member(B, ['', '', - '', '', '', - '', '', '']), - dtlit([A, B], C), - getnumber(C, D), - dtlit([_, B], D) - -> true - ; ( dtlit([A, ''], C), - getbool(C, _), - B = '' - -> true - ; B = '', - C = A - ) - ) - ; A = literal(E, _), - ( B = prolog:atom - -> C = E - ; C = literal(E, type(B)) - ), - ! - ) - ; nonvar(C), - dtlit([A, B], C) - ) - ). - -''(X, Y) :- - unify(X, Y). - -''([A, B], Sc) :- - within_scope(Sc), - when( - ( nonvar(A), - nonvar(B) - ), - ( forall(A, B) - ) - ). - -''(X, Y) :- - implies(U, V, _), - unify(U, X), - unify(V, Y), - ( commonvars(X, Y, []) - -> labelvars(Y, 0, _, avar) - ; true - ), - ( var(Y) - -> true - ; Y \= answer(_, _, _), - Y \= (answer(_, _, _), _) - ). - -''(X, Y) :- - within_scope(X), - !, - when( - ( nonvar(Y) - ), - ( Y - ) - ). -''(X, Y) :- - when( - ( nonvar(X), - nonvar(Y) - ), - ( conj_list(X, A), - conj_list(Y, B), - includes(A, B) - ) - ). - -''(X, Y) :- - within_scope(X), - !, - when( - ( nonvar(Y) - ), - ( \+ \+call(Y) - ) - ). -''(X, Y) :- - when( - ( nonvar(X), - nonvar(Y) - ), - ( conj_list(X, A), - conj_list(Y, B), - \+ \+includes(A, B) - ) - ). - -''(A, B) :- - ''(A, C), - ( nonvar(B) - -> ''([B,C], B) - ; B = C - ). - -''([literal(A, type('')), literal(B, type(''))], literal(A, lang(B))). - -''(A, literal(B, type(''))) :- - term_variables(A, V), - labelvars([A, V], 0, _, avar), - with_output_to_chars((wq(V, allv), wt(A)), E), - escape_string(E, F), - atom_codes(B, F). - -''(A, literal(B, type(''))) :- - when( - ( nonvar(A) - ), - ( sub_atom(A, 1, _, 1, C), - sub_atom_last(C, _, 1, N, '/'), - sub_atom(C, _, N, 0, B) - ) - ). - -''(A, literal(B, type(''))) :- - ( n3s(A, literal(B, type(''))) - -> true - ; retractall(wpfx(_)), - with_output_to_chars(wh, C1), - \+ (C1 = [], \+flag('no-qnames')), - numbervars(A), - with_output_to_chars(wt(A), C2), - append(C1, C2, C), - escape_string(C, D), - atom_codes(B, D), - assertz(n3s(A, literal(B, type('')))) - ). - -''(A, literal(B, type(''))) :- - when( - ( nonvar(A) - ), - ( sub_atom(A, 1, _, 1, C), - sub_atom_last(C, N, 1, _, '/'), - M is N+1, - sub_atom(C, 0, M, _, B) - ) - ). - -''(X, Y) :- - \+''(X, Y). - -''(X, Y) :- - ignore(within_scope(X)), - \+''(X, Y). - -''(literal(A, _), B) :- - atom_codes(A, C), - escape_string(D, C), - atom_codes(E, D), - tmp_file(Tmp), - open(Tmp, write, Ws, [encoding(utf8)]), - tell(Ws), - writef(E, []), - told, - ( flag('output', Output) - -> tell(Output) - ; true - ), - atomic_list_concat([''], F), - ''(F, B). - -''(A, B) :- - when( - ( nonvar(A) - ), - ( sub_atom(A, 1, _, 1, C), - sub_atom(C, N, 1, _, '#'), - sub_atom(C, 0, N, _, D), - atomic_list_concat(['<', D, '>'], B) - ) - ). - -''(A, B) :- - nonvar(A), - raw_type(A, C), - C = B. - -''(A, B) :- - C is A-1, - between(0, C, B). - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( ( semantics(X, L) - -> conj_list(Y, L) - ; sub_atom(X, 0, 1, _, '<'), - sub_atom(X, _, 1, 0, '>'), - sub_atom(X, 1, _, 1, Z), - catch( - n3_n3p(Z, semantics), - Exc, - ( format(user_error, '** ERROR ** ~w **~n', [Exc]), - flush_output(user_error), - fail - ) - ), - semantics(X, L), - conj_list(Y, L) - ) - ) - ). - -''(X, Y) :- - \+flag(restricted), - when( - ( nonvar(X) - ), - ( ( semantics(X, L) - -> conj_list(Y, L) - ; sub_atom(X, 0, 1, _, '<'), - sub_atom(X, _, 1, 0, '>'), - sub_atom(X, 1, _, 1, Z), - catch( - n3_n3p(Z, semantics), - Exc, - assertz(semantics(X, [literal(Exc, type(''))])) - ), - semantics(X, L), - conj_list(Y, L) - ) - ) - ). - -''(X, Y) :- - ''(Y, X), - ( \+keep_skolem(Y) - -> assertz(keep_skolem(Y)) - ; true - ). - -''(A, B) :- - ''(A, B). - -''(X, Y) :- - when( - ( nonvar(X) - ; nonvar(Y) - ), - ( atomic(X), - ( atom_concat(some, V, X) - -> nb_getval(var_ns, Sns), - atomic_list_concat(['<', Sns, 'sk_', V, '>'], U) - ; ( atom_concat(avar, V, X) - -> atomic_list_concat([''], U) - ; U = X - ) - ), - sub_atom(U, 1, _, 1, Z), - atomic_list_concat(['<', Z, '>'], U), - Y = literal(Z, type('')), - ! - ; nonvar(Y), - Y = literal(Z, type('')), - atomic_list_concat(['<', Z, '>'], X) - ) - ). - -''(X, literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( ''(X, literal(U, type(''))), - ( \+got_uuid(U) - -> uuid(Y, [uri(U)]), - assertz(got_uuid(U)) - ; true - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, U), - Y is abs(U) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is acos(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is acosh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is asin(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is asinh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is atan(W) - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - Z is atan(U/V) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, W), - Y is atanh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( - getnumber(X, U), - Y is ceiling(U) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is cos(U), - ! - ; getnumber(Y, W), - X is acos(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is cosh(U), - ! - ; getnumber(Y, W), - X is acosh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is U*180/pi, - ! - ; getnumber(Y, W), - X is W*pi/180 - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - Z is U-V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U =:= V - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ; ground([X, Z]) - ), - ( getnumber(X, U), - ( getnumber(Y, V), - Z is U**V, - ! - ; getnumber(Z, W), - W =\= 0, - U =\= 0, - Y is log(W)/log(U) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( - getnumber(X, U), - Y is floor(U) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U > V - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - ( V =\= 0 - -> Z is round(floor(U/V)) - ; throw(zero_division(''([X, Y], Z))) - ) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U < V - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ; ground([X, Z]) - ), - ( getnumber(X, U), - ( getnumber(Y, V), - V =\= 0, - U =\= 0, - Z is log(U)/log(V), - ! - ; getnumber(Z, W), - Y is U**(1/W) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( max_list(X, Y) - ) - ). - -''(X, Y) :- - when( - ( nonvar(X) - ), - ( ( getlist(X, Z) - -> true - ; conj_list(X, U), - ( ground(U) - -> distinct(U, Z) - ; Z = U - ) - ), - length(Z, Y) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( min_list(X, Y) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is -U, - ! - ; getnumber(Y, W), - X is -W - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U =\= V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U =< V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - U >= V - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( product(X, Y) - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - ( V =\= 0 - -> Z is U/V - ; throw(zero_division(''([X, Y], Z))) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is U*pi/180, - ! - ; getnumber(Y, W), - X is W*180/pi - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - ( V =\= 0 - -> Z is U-V*round(floor(U/V)) - ; throw(zero_division(''([X, Y], Z))) - ) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( getnumber(X, U), - Y is round(round(U)) - ) - ). - -''([X, Y], Z) :- - when( - ( ground([X, Y]) - ), - ( getnumber(X, U), - getnumber(Y, V), - F is 10**floor(V), - Z is round(round(U*F))/F - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is sin(U), - ! - ; getnumber(Y, W), - X is asin(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is sinh(U), - ! - ; getnumber(Y, W), - X is asinh(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ), - ( sum(X, Y) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is tan(U), - ! - ; getnumber(Y, W), - X is atan(W) - ) - ). - -''(X, Y) :- - when( - ( ground(X) - ; ground(Y) - ), - ( getnumber(X, U), - Y is tanh(U), - ! - ; getnumber(Y, W), - X is atanh(W) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground(X) - ), - ( sub_atom(X, 0, 1, _, A), - upcase_atom(A, B), - sub_atom(X, 1, _, 0, C), - downcase_atom(C, D), - atom_concat(B, D, Y) - ) - ). - -''(X, Y) :- - when( - ( nonvar(X) - ), - ( getlist(X, C), - labelvars(C, 0, _, avar), - ( member(D, C), - var(D), - var(Y) - -> true - ; findall(S, - ( member(A, X), - getcodes(A, S) - ), - Z - ), - flatten(Z, E), - atom_codes(F, E), - Y = literal(F, type('')) - ) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground([X, Y]) - ), - ( sub_atom(X, _, _, _, Y) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground([X, Y]) - ), - ( downcase_atom(X, U), - downcase_atom(Y, V), - sub_atom(U, _, _, _, V) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground([X, Y]) - ), - ( downcase_atom(X, R), - downcase_atom(Y, S), - normalize_space(atom(U), R), - normalize_space(atom(V), S), - sub_atom(U, _, _, _, V) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( sub_atom(X, _, _, 0, Y) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( downcase_atom(X, U), - downcase_atom(Y, U) - ) - ). - -''([literal(A, _)|B], literal(C, type(''))) :- - when( - ( ground([A, B]) - ), - ( atom_codes(A, D), - subst([[[0'%, 0's], [0'~, 0'w]]], D, E), - preformat(B, F), - format_to_chars(E, F, G), - atom_codes(C, G) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @> V - ) - ). - -''([X,Y], Z) :- - when( - ( nonvar(X) - ), - ( getlist(X, C), - getcodes(Y, D), - labelvars(C, 0, _, avar), - ( member(E, C), - var(E), - var(Z) - -> true - ; findall([D,S], - ( member(A, X), - getcodes(A, S) - ), - U - ), - flatten(U, V), - ( V = [] - -> F = V - ; append(D, F, V) - ), - atom_codes(G, F), - Z = literal(G, type('')) - ) - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @< V - ) - ). - -''(literal(A, _), B) :- - when( - ( ground(A) - ), - ( sub_atom(A, 0, B, 0, _) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground(X) - ), - ( downcase_atom(X, Y) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( regex(Y, X, _) - ) - ). - -''(X, Y) :- - \+''(X, Y). - -''(X, Y) :- - \+''(X, Y). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @=< V - ) - ). - -''(X, Y) :- - when( - ( ground([X, Y]) - ), - ( getstring(X, U), - getstring(Y, V), - U @>= V - ) - ). - -''(X, Y) :- - \+''(X, Y). - -''([literal(X, _),literal(Search, _),literal(Replace, _)], literal(Y, type(''))) :- - when( - ( ground([X,Search,Replace]) - ), - ( ( regex(Search, X, [S|_]) - -> atom_codes(X, XC), - string_codes(S, SC), - atom_codes(Replace, RC), - subst([[[0'$,0'1],SC]], RC, TC), - subst([[SC,TC]], XC, YC), - atom_codes(Y, YC) - ; Y = X - ) - ) - ). - -''([literal(X, _),SearchList,ReplaceList], literal(Y, type(''))) :- - when( - ( ground([X,SearchList,ReplaceList]) - ), - ( preformat(SearchList, SearchList2), - preformat(ReplaceList, ReplaceList2), - replace(SearchList2, ReplaceList2, X, Z), - atom_string(Y, Z) - ) - ). - -''([literal(X, _),literal(Y, _)], literal(Z, type(''))) :- - when( - ( ground([X,Y]) - ), - ( regex(Y, X, [W|_]), - atom_string(Z, W) - ) - ). - -''([literal(X, _),literal(Y, _)], Z) :- - when( - ( ground([X,Y]) - ), - ( scrape(X, Y, V), - preformat(Z, V) - ) - ). - -''([literal(X, _),literal(Y, _)], Z) :- - when( - ( ground([X, Y]) - ), - ( regex(Y, X, L), - findall(literal(A, type('')), - ( member(M, L), - atom_string(A, M) - ), - Z - ) - ) - ). - -''(literal(X, _), literal(Y, _)) :- - when( - ( ground([X, Y]) - ), - ( sub_atom(X, 0, _, _, Y) - ) - ). - -''([literal(A, _), B, C], literal(D, type(''))) :- - !, - when( - ( ground([A, B, C]) - ), - ( getint(B, I), - getint(C, J), - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = '' - ; sub_atom(A, G, H, _, D) - ) - ) - ). -''([literal(A, _), B], literal(D, type(''))) :- - when( - ( ground([A, B]) - ), - ( getint(B, I), - sub_atom(A, 0, E, 0, _), - J is E-I+1, - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = [] - ; sub_atom(A, G, H, _, D) - ) - ) - ). - -''(literal(X, Z), literal(Y, Z)) :- - when( - ( ground(X) - ), - ( upcase_atom(X, Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( sub_atom(X, 8, 2, _, Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( timestamp(Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( sub_atom(X, 5, 2, _, Y) - ) - ). - -''(literal(X, _), literal(Y, type(''))) :- - when( - ( ground(X) - ), - ( sub_atom(X, 0, 4, _, Y) - ) - ). - -% RIF built-ins according to RIF Datatypes and Built-Ins 1.0 -- http://www.w3.org/TR/rif-dtb/ - -% 4.1.1.1 pred:literal-not-identical - -''([literal(A, B), literal(C, B)], D) :- - \+flag(restricted), - when( - ( ground([A, B, C]) - ), - ( A \== C - -> D = true - ; D = false - ) - ). - -% 4.4.4 pred:iri-string - -''([A, literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( nonvar(A) - ; nonvar(B) - ), - ( atom(A), - sub_atom(A, 1, _, 1, U), - atomic_list_concat(['<', U, '>'], A), - !, - ( U = B - -> C = true - ; C = false - ) - ; nonvar(B), - ( atomic_list_concat(['<', B, '>'], A) - -> C = true - ; C = false - ) - ) - ). - -% 4.5.1 Numeric Functions - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sum([A, B], C) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - C is U-V - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - C is U*V - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( V =\= 0 - -> C is U/V - ; throw(zero_division(''([A, B], C))) - ) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( V =\= 0 - -> C is integer(floor(U/V)) - ; throw(zero_division(''([A, B], C))) - ) - ) - ). - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( V =\= 0 - -> C is U-V*integer(floor(U/V)) - ; throw(zero_division(''([A, B], C))) - ) - ) - ). - -% 4.5.2.1 pred:numeric-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U =:= V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.2 pred:numeric-less-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U < V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.3 pred:numeric-greater-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U > V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.4 pred:numeric-not-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U =\= V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.5 pred:numeric-less-than-or-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U =< V - -> C = true - ; C = false - ) - ) - ). - -% 4.5.2.6 pred:numeric-greater-than-or-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getnumber(A, U), - getnumber(B, V), - ( U >= V - -> C = true - ; C = false - ) - ) - ). - -% 4.6.1.1 func:not - -''([A], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( getbool(A, U), - ( ground(B) - -> getbool(B, V) - ; V = B - ), - inv(U, V) - ) - ). - -% 4.6.2.1 pred:boolean-equal - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getbool(A, U), - getbool(B, U) - -> C = true - ; C = false - ) - ). - -% 4.6.2.2 pred:boolean-less-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getbool(A, false), - getbool(B, true) - -> C = true - ; C = false - ) - ). - -% 4.6.2.3 pred:boolean-greater-than - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getbool(A, true), - getbool(B, false) - -> C = true - ; C = false - ) - ). - -% 4.7.1.1 func:compare @@partial implementation: no collation - -''([literal(A, B), literal(C, B)], D) :- - \+flag(restricted), - !, - ( A @< C - -> D = -1 - ; ( A == C - -> D = 0 - ; ( A @> C - -> D = 1 - ) - ) - ). - -% 4.7.1.2 func:concat - -''(A, literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( findall(F, - ( member(literal(S, type('')), A), - atom_codes(S, F) - ), - C - ), - flatten(C, D), - atom_codes(B, D) - ) - ). - -% 4.7.1.3 func:string-join - -''([A, literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(B, D), - findall([D, E], - ( member(literal(F, type('')), A), - atom_codes(F, E) - ), - G - ), - ( G = [[_, H]|I] - -> flatten([H|I], J), - atom_codes(C, J) - ; C = '' - ) - ) - ). - -% 4.7.1.4 func:substring - -''([literal(A, _), B, C], literal(D, type(''))) :- - \+flag(restricted), - !, - when( - ( ground([A, B, C]) - ), - ( getint(B, I), - getint(C, J), - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = '' - ; sub_atom(A, G, H, _, D) - ) - ) - ). -''([literal(A, _), B], literal(D, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( getint(B, I), - sub_atom(A, 0, E, 0, _), - J is E-I+1, - ( I < 1 - -> G is 0, - H is J+I-1 - ; G is I-1, - H is J - ), - ( H < 0 - -> D = [] - ; sub_atom(A, G, H, _, D) - ) - ) - ). - -% 4.7.1.5 func:string-length - -''([literal(A, _)], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( sub_atom(A, 0, B, 0, _) - ) - ). - -% 4.7.1.6 func:upper-case - -''([literal(A, B)], literal(C, B)) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( upcase_atom(A, C) - ) - ). - -% 4.7.1.7 func:lower-case - -''([literal(A, B)], literal(C, B)) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( downcase_atom(A, C) - ) - ). - -% 4.7.1.8 func:encode-for-uri - -''([literal(A, B)], literal(C, B)) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( www_form_encode(A, C) - ) - ). - -% 4.7.1.11 func:substring-before @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, W, _, _, B), - sub_atom(A, 0, W, _, C) - ) - ). - -% 4.7.1.12 func:substring-after @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, _, _, W, B), - sub_atom(A, _, W, 0, C) - ) - ). - -% 4.7.2.1 pred:contains @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(B, 0, D, 0, _), - sub_atom(A, _, D, _, B) - -> C = true - ; C = false - ) - ). - -% 4.7.2.2 pred:starts-with @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, 0, _, _, B) - -> C = true - ; C = false - ) - ). - -% 4.7.2.3 pred:ends-with @@partial implementation: no collation - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( sub_atom(A, _, _, 0, B) - -> C = true - ; C = false - ) - ). - -% 4.7.2.4 pred:matches @@partial implementation: no flags - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( regex(B, A, _) - -> C = true - ; C = false - ) - ). - -% 4.8.1.1 func:year-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(C, _, _, _, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.2 func:month-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, C, _, _, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.3 func:day-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, C, _, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.4 func:hours-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, C, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.5 func:minutes-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, _, C, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.6 func:seconds-from-dateTime - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, _, _, C, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.7 func:year-from-date - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(C, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.8 func:month-from-date - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(_, C, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.9 func:day-from-date - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(_, _, C, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.10 func:hours-from-time - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(C, _, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.11 func:minutes-from-time - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(_, C, _, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.12 func:seconds-from-time - -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(_, _, C, _, U, []), - ( nonvar(B) - -> C =:= B - ; C = B - ) - ) - ). - -% 4.8.1.13 func:years-from-duration - -''([literal(_, type(''))], 0) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - yearmonthduration(C, U, []), - D is C//12, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.14 func:months-from-duration - -''([literal(_, type(''))], 0) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - yearmonthduration(C, U, []), - D is C-(C//12)*12, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.15 func:days-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is integer(C)//86400, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.16 func:hours-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is (integer(C)-(integer(C)//86400)*86400)//3600, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.17 func:minutes-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is (integer(C)-(integer(C)//3600)*3600)//60, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.18 func:seconds-from-duration - -''([literal(_, type(''))], _) :- - \+flag(restricted), - !. -''([literal(A, type(''))], B) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - daytimeduration(C, U, []), - D is C-(integer(C)//60)*60, - ( nonvar(B) - -> D =:= B - ; D = B - ) - ) - ). - -% 4.8.1.19 func:timezone-from-dateTime - -''([literal(A, type(''))], literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - datetime(_, _, _, _, _, _, C, U, []), - ( ground(B) - -> atom_codes(B, V), - daytimeduration(D, V, []), - D =:= C - ; daytimeduration(C, E), - atom_codes(B, E) - ) - ) - ). - -% 4.8.1.20 func:timezone-from-date - -''([literal(A, type(''))], literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - date(_, _, _, C, U, []), - ( ground(B) - -> atom_codes(B, V), - daytimeduration(D, V, []), - D =:= C - ; daytimeduration(C, E), - atom_codes(B, E) - ) - ) - ). - -% 4.8.1.21 func:timezone-from-time - -''([literal(A, type(''))], literal(B, type(''))) :- - \+flag(restricted), - when( - ( ground(A) - ), - ( atom_codes(A, U), - time(_, _, _, C, U, []), - ( ground(B) - -> atom_codes(B, V), - daytimeduration(D, V, []), - D =:= C - ; daytimeduration(C, E), - atom_codes(B, E) - ) - ) - ). - -% 4.8.1.22 func:subtract-dateTimes - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.23 func:subtract-dates - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.24 func:subtract-times - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.25 func:add-yearMonthDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - F is D+E, - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.26 func:subtract-yearMonthDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.27 func:multiply-yearMonthDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - yearmonthduration(D, U, []), - getnumber(B, E), - F is integer(round(D*E-1)+1), - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.28 func:divide-yearMonthDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - yearmonthduration(D, U, []), - getnumber(B, E), - F is integer(round(D/E-1)+1), - ( ground(C) - -> atom_codes(C, W), - yearmonthduration(G, W, []), - G =:= F - ; yearmonthduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.29 func:divide-yearMonthDuration-by-yearMonthDuration - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - F is D/E, - ( ground(C) - -> C =:= F - ; C = F - ) - ) - ). - -% 4.8.1.30 func:add-dayTimeDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - F is D+E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.31 func:subtract-dayTimeDurations - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - F is D-E, - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.32 func:multiply-dayTimeDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - daytimeduration(D, U, []), - getnumber(B, E), - F is integer(round(D*E-1)+1), - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.33 func:divide-dayTimeDuration - -''([literal(A, type('')), B], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - daytimeduration(D, U, []), - getnumber(B, E), - F is integer(round(D/E-1)+1), - ( ground(C) - -> atom_codes(C, W), - daytimeduration(G, W, []), - G =:= F - ; daytimeduration(F, H), - atom_codes(C, H) - ) - ) - ). - -% 4.8.1.34 func:divide-dayTimeDuration-by-dayTimeDuration - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - F is D/E, - ( ground(C) - -> C =:= F - ; C = F - ) - ) - ). - -% 4.8.1.35 func:add-yearMonthDuration-to-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - yearmonthduration(K, V, []), - L is E+K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+I+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.36 func:add-yearMonthDuration-to-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - yearmonthduration(K, V, []), - L is E+K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+31536000-N-G))//60)*60, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.37 func:add-dayTimeDuration-to-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - daytimeduration(K, V, []), - L is I+K, - memotime(datime(D, E, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+L+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.38 func:add-dayTimeDuration-to-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is integer(K), - memotime(datime(D, E, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+L+31536000-N))//86400)*86400-G, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.39 func:add-dayTimeDuration-to-time - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is F+K, - memotime(datime(1972, 12, 31, D, E, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - Z is M+L+31536000-N-G, - O is Z-86400*integer(floor(Z/86400)), - ( ground(C) - -> atom_codes(C, W), - time(P, W, []), - O =:= P-86400*integer(floor(P/86400)) - ; Offset is -G, - stamp_date_time(O, date(_, _, _, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - time(Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.40 func:subtract-yearMonthDuration-from-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - yearmonthduration(K, V, []), - L is E-K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+I+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.41 func:subtract-yearMonthDuration-from-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - yearmonthduration(K, V, []), - L is E-K-1, - Q is D+integer(floor(L/12)), - R is L-integer(floor(L/12))*12+1, - memotime(datime(Q, R, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+31536000-N-G))//60)*60, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.42 func:subtract-dayTimeDuration-from-dateTime - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, E, F, G, H, I, J, U, []), - daytimeduration(K, V, []), - L is I-integer(K), - memotime(datime(D, E, F, G, H, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is M+L+31536000-N-J, - ( ground(C) - -> atom_codes(C, W), - datetime(P, W, []), - O =:= P - ; Offset is -J, - stamp_date_time(O, date(Year, Month, Day, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - datetime(Year, Month, Day, Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.43 func:subtract-dayTimeDuration-from-date - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is -integer(K), - memotime(datime(D, E, F, 0, 0, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - O is (integer(floor(M+L+31536000-N))//86400)*86400-G, - ( ground(C) - -> atom_codes(C, W), - date(P, W, []), - O =:= P - ; date(O, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.1.44 func:subtract-dayTimeDuration-from-time - -''([literal(A, type('')), literal(B, type(''))], literal(C, type(''))) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, E, F, G, U, []), - daytimeduration(K, V, []), - L is F-K, - memotime(datime(1972, 12, 31, D, E, 0), M), - memotime(datime(1971, 1, 1, 0, 0, 0), N), - Z is M+L+31536000-N-G, - O is Z-86400*integer(floor(Z/86400)), - ( ground(C) - -> atom_codes(C, W), - time(P, W, []), - O =:= P-86400*integer(floor(P/86400)) - ; Offset is -G, - stamp_date_time(O, date(_, _, _, Hour, Minute, Second, _, _, _), Offset), - fmsec(0, Second, Sec), - time(Hour, Minute, Sec, Offset, S), - atom_codes(C, S) - ) - ) - ). - -% 4.8.2.1 pred:dateTime-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.2 pred:dateTime-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.3 pred:dateTime-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.4 pred:date-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.5 pred:date-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.6 pred:date-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.7 pred:time-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.8 pred:time-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.9 pred:time-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.10 pred:duration-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - duration(D, U, []), - duration(E, V, []), - ( D =:= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.11 pred:dayTimeDuration-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.12 pred:dayTimeDuration-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.13 pred:yearMonthDuration-less-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D < E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.14 pred:yearMonthDuration-greater-than - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D > E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.15 pred:dateTime-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.16 pred:dateTime-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.17 pred:dateTime-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - datetime(D, U, []), - datetime(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.18 pred:date-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.19 pred:date-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.20 pred:date-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - date(D, U, []), - date(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.21 pred:time-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.22 pred:time-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.23 pred:time-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - time(D, U, []), - time(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.24 pred:duration-not-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - duration(D, U, []), - duration(E, V, []), - ( D =\= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.25 pred:dayTimeDuration-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.26 pred:dayTimeDuration-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - daytimeduration(D, U, []), - daytimeduration(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.27 pred:yearMonthDuration-less-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D =< E - -> C = true - ; C = false - ) - ) - ). - -% 4.8.2.28 pred:yearMonthDuration-greater-than-or-equal - -''([literal(A, type('')), literal(B, type(''))], C) :- - \+flag(restricted), - when( - ( ground([A, B]) - ), - ( atom_codes(A, U), - atom_codes(B, V), - yearmonthduration(D, U, []), - yearmonthduration(E, V, []), - ( D >= E - -> C = true - ; C = false - ) - ) - ). - -% 4.10.1.1 func:PlainLiteral-from-string-lang - -''([literal(A, type(''))], literal(A, type(''))) :- - \+flag(restricted), - !. -''([literal(A, type('')), literal(B, type(''))], literal(A, lang(C))) :- - \+flag(restricted), - downcase_atom(B, C). - -% 4.10.1.2 func:string-from-PlainLiteral - -''([literal(A, type(''))], literal(A, type(''))) :- - \+flag(restricted), - !. -''([literal(A, lang(_))], literal(A, type(''))) :- - \+flag(restricted). - -% 4.10.1.3 func:lang-from-PlainLiteral - -''([literal(_, type(''))], literal('', type(''))) :- - \+flag(restricted), - !. -''([literal(_, lang(A))], literal(A, type(''))) :- - \+flag(restricted). - -% 4.10.1.4 func:PlainLiteral-compare @@partial implementation: no collation - -''([literal(A, type('')), literal(C, type(''))], D) :- - \+flag(restricted), - !, - ( A @< C - -> D = -1 - ; ( A == C - -> D = 0 - ; ( A @> C - -> D = 1 - ) - ) - ). -''([literal(A, lang(B)), literal(C, lang(B))], D) :- - \+flag(restricted), - ( A @< C - -> D = -1 - ; ( A == C - -> D = 0 - ; ( A @> C - -> D = 1 - ) - ) - ). - -% 4.10.1.5 func:PlainLiteral-length - -''([literal(A, type(''))], C) :- - \+flag(restricted), - !, - sub_atom(A, 0, C, 0, _). -''([literal(A, lang(_))], C) :- - \+flag(restricted), - sub_atom(A, 0, C, 0, _). - -% 4.10.2.1 pred:matches-language-range @@partial implementation: no false results - -''([literal(A, lang(B)), literal(C, type(''))], true) :- - \+flag(restricted), - A \= '', - atom_codes(C, U), - regexp_wildcard(U, V), - atom_codes(E, V), - atomic_list_concat(['^', E], F), - downcase_atom(F, G), - downcase_atom(B, H), - regex(G, H, _). - -% 4.11.3.1 pred:is-list - -''([A], B) :- - \+flag(restricted), - ( is_list(A) - -> B = true - ; B = false - ). - -% 4.11.3.2 pred:list-contains - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( member(B, A) - -> C = true - ; C = false - ) - ). - -% 4.11.4.1 func:make-list - -''(A, A) :- - \+flag(restricted). - -% 4.11.4.2 func:count - -''([A], B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( length(A, B) - ) - ). - -% 4.11.4.3 func:get - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( getnumber(B, U), - nth0(U, A, C) - ) - ). - -% 4.11.4.4 func:sublist - -''([A, B, C], D) :- - \+flag(restricted), - !, - when( - ( nonvar(A), - ground([B, C]) - ), - ( getint(B, U), - getint(C, V), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - ( V < 0 - -> J is W+V - ; J is V - ), - append(E, F, A), - length(E, I), - append(D, G, F), - K is J-I, - ( length(D, K) - -> true - ; G = [] - ), - ! - ) - ). -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( getint(B, U), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - append(E, C, A), - length(E, I), - ! - ) - ). - -% 4.11.4.5 func:append - -''([A|B], C) :- - \+flag(restricted), - append(A, B, C). - -% 4.11.4.6 func:concatenate - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( append(A, B) - ) - ). - -% 4.11.4.7 func:insert-before - -''([A, B, C], D) :- - \+flag(restricted), - when( - ( nonvar(A), - ground([B, C]) - ), - ( getint(B, U), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - append(G, H, A), - length(G, I), - append([G, [C], H], D) - ) - ). - -% 4.11.4.8 func:remove - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( getint(B, U), - length(A, W), - ( U < 0 - -> I is W+U - ; I is U - ), - append(G, [_|T], A), - length(G, I), - append(G, T, C) - ) - ). - -% 4.11.4.9 func:reverse - -''([A], B) :- - \+flag(restricted), - reverse(A, B). - -% 4.11.4.10 func:index-of - -''([A, B], C) :- - \+flag(restricted), - when( - ( nonvar(A), - ground(B) - ), - ( findall(I, - ( nth0(I, A, B) - ), - C - ) - ) - ). - -% 4.11.4.11 func:union - -''(A, B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( append(A, C), - distinct(C, B) - ) - ). - -% 4.11.4.12 func:distinct-values - -''([A], B) :- - \+flag(restricted), - when( - ( nonvar(A) - ), - ( distinct(A, B) - ) - ). - -% 4.11.4.13 func:intersect - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground(A), - ground(B) - ), - ( findall(I, - ( member(I, A), - member(I, B) - ), - C - ) - ) - ). - -% 4.11.4.14 func:except - -''([A, B], C) :- - \+flag(restricted), - when( - ( ground(A), - ground(B) - ), - ( findall(I, - ( member(I, A), - \+member(I, B) - ), - C - ) - ) - ). - -% Prolog built-ins - -prolog_sym(abolish, abolish, rel). -prolog_sym(abort, abort, rel). -prolog_sym(abs, abs, func). -prolog_sym(absolute_file_name, absolute_file_name, rel). -prolog_sym(acos, acos, func). -prolog_sym(acosh, acosh, func). -prolog_sym(acyclic_term, acyclic_term, rel). -prolog_sym(alarm, alarm, rel). -prolog_sym(append, append, rel). -prolog_sym(arg, arg, rel). -prolog_sym(arithmetic_equal, =:=, rel). -prolog_sym(arithmetic_greater_than, >, rel). -prolog_sym(arithmetic_greater_than_or_equal, >=, rel). -prolog_sym(arithmetic_less_than, <, rel). -prolog_sym(arithmetic_less_than_or_equal, =<, rel). -prolog_sym(arithmetic_not_equal, =\=, rel). -prolog_sym(asin, asin, func). -prolog_sym(asinh, asinh, func). -prolog_sym(assert, assert, rel). -prolog_sym(asserta, asserta, rel). -prolog_sym(assertz, assertz, rel). -prolog_sym(at_end_of_stream, at_end_of_stream, rel). -prolog_sym(atan, atan, func). -prolog_sym(atan2, atan2, func). -prolog_sym(atanh, atanh, func). -prolog_sym(atom, atom, rel). -prolog_sym(atom_chars, atom_chars, rel). -prolog_sym(atom_codes, atom_codes, rel). -prolog_sym(atom_concat, atom_concat, rel). -prolog_sym(atom_length, atom_length, rel). -prolog_sym(atom_number, atom_number, rel). -prolog_sym(atomic, atomic, rel). -prolog_sym(atomic_concat, atomic_concat, rel). -prolog_sym(atomic_list_concat, atomic_list_concat, rel). -prolog_sym(b_getval, b_getval, rel). -prolog_sym(b_setval, b_setval, rel). -prolog_sym(bagof, bagof, rel). -prolog_sym(between, between, rel). -prolog_sym(break, break, rel). -prolog_sym(call, call, rel). -prolog_sym(call_residue_vars, call_residue_vars, rel). -prolog_sym(callable, callable, rel). -prolog_sym(catch, catch, rel). -prolog_sym(ceiling, ceiling, func). -prolog_sym(char_code, char_code, rel). -prolog_sym(char_conversion, char_conversion, rel). -prolog_sym(char_type, char_type, rel). -prolog_sym(character_count, character_count, rel). -prolog_sym(clause, clause, rel). -prolog_sym(close, close, rel). -prolog_sym(code_type, code_type, rel). -prolog_sym(compare, compare, rel). -prolog_sym(compound, compound, rel). -prolog_sym(conjunction, ',', rel). -prolog_sym(consult, consult, rel). -prolog_sym(copy_term, copy_term, rel). -prolog_sym(copy_term_nat, copy_term_nat, rel). -prolog_sym(cos, cos, func). -prolog_sym(cosh, cosh, func). -prolog_sym(cputime, cputime, func). -prolog_sym(create_mutable, create_mutable, rel). -prolog_sym(create_prolog_flag, create_prolog_flag, rel). -prolog_sym(current_atom, current_atom, rel). -prolog_sym(current_char_conversion, current_char_conversion, rel). -prolog_sym(current_input, current_input, rel). -prolog_sym(current_key, current_key, rel). -prolog_sym(current_module, current_module, rel). -prolog_sym(current_op, current_op, rel). -prolog_sym(current_output, current_output, rel). -prolog_sym(current_predicate, current_predicate, rel). -prolog_sym(current_prolog_flag, current_prolog_flag, rel). -prolog_sym(cut, !, rel). -prolog_sym(cyclic_term, cyclic_term, rel). -prolog_sym(date_time_stamp, date_time_stamp, rel). -prolog_sym(date_time_value, date_time_value, rel). -prolog_sym(day_of_the_week, day_of_the_week, rel). -prolog_sym(delete, delete, rel). -prolog_sym(dif, dif, rel). -prolog_sym(discontiguous, discontiguous, rel). -prolog_sym(disjunction, ;, rel). -prolog_sym(display, display, rel). -prolog_sym(div, div, func). -prolog_sym(duplicate_term, duplicate_term, rel). -prolog_sym(dynamic, dynamic, rel). -prolog_sym(e, e, func). -prolog_sym(ensure_loaded, ensure_loaded, rel). -prolog_sym(environ, environ, rel). -prolog_sym(epsilon, epsilon, func). -prolog_sym(erase, erase, rel). -prolog_sym(erf, erf, func). -prolog_sym(erfc, erfc, func). -prolog_sym(exception, exception, rel). -prolog_sym(exists, exists, rel). -prolog_sym(exp, exp, func). -prolog_sym(fail, fail, rel). -prolog_sym(false, false, rel). -prolog_sym(file_base_name, file_base_name, rel). -prolog_sym(file_name_extension, file_name_extension, rel). -prolog_sym(findall, findall, rel). -prolog_sym(flatten, flatten, rel). -prolog_sym(float, float, rel). -prolog_sym(float_fractional_part, float_fractional_part, func). -prolog_sym(float_function, float, func). -prolog_sym(float_integer_part, float_integer_part, func). -prolog_sym(floor, floor, func). -prolog_sym(flush_output, flush_output, rel). -prolog_sym(forall, forall, rel). -prolog_sym(format, format, rel). -prolog_sym(format_time, format_time, rel). -prolog_sym(freeze, freeze, rel). -prolog_sym(frozen, frozen, rel). -prolog_sym(functor, functor, rel). -prolog_sym(garbage_collect, garbage_collect, rel). -prolog_sym(garbage_collect_atoms, garbage_collect_atoms, rel). -prolog_sym(gc, gc, rel). -prolog_sym(gcd, gcd, func). -prolog_sym(get, get, rel). -prolog_sym(get_byte, get_byte, rel). -prolog_sym(get_char, get_char, rel). -prolog_sym(get_code, get_code, rel). -prolog_sym(get_mutable, get_mutable, rel). -prolog_sym(get_time, get_time, rel). -prolog_sym(get0, get0, rel). -prolog_sym(getcwd, getcwd, rel). -prolog_sym(ground, ground, rel). -prolog_sym(halt, halt, rel). -prolog_sym(if, soft_cut, rel). -prolog_sym(if_then, ->, rel). -prolog_sym(if_then_else, if_then_else, rel). -prolog_sym(ignore, ignore, rel). -prolog_sym(include, include, rel). -prolog_sym(initialization, initialization, rel). -prolog_sym(instance, instance, rel). -prolog_sym(integer, integer, rel). -prolog_sym(integer_conjunction, /\, func). -prolog_sym(integer_disjunction, \/, func). -prolog_sym(integer_exclusive_disjunction, xor, func). -prolog_sym(integer_function, integer, func). -prolog_sym(integer_left_logical_shift, <<, func). -prolog_sym(integer_negation, \, func). -prolog_sym(integer_power, ^, func). -prolog_sym(integer_quotient, //, func). -prolog_sym(integer_right_logical_shift, >>, func). -prolog_sym(is, is, rel). -prolog_sym(is_list, is_list, rel). -prolog_sym(is_stream, is_stream, rel). -prolog_sym(keysort, keysort, rel). -prolog_sym(last, last, rel). -prolog_sym(length, length, rel). -prolog_sym(lgamma, lgamma, func). -prolog_sym(line_count, line_count, rel). -prolog_sym(line_position, line_position, rel). -prolog_sym(listing, listing, rel). -prolog_sym(log, log, func). -prolog_sym(log10, log10, func). -prolog_sym(lsb, lsb, func). -prolog_sym(max, max, func). -prolog_sym(max_list, max_list, rel). -prolog_sym(member, member, rel). -prolog_sym(memberchk, memberchk, rel). -prolog_sym(message_to_string, message_to_string, rel). -prolog_sym(min, min, func). -prolog_sym(min_list, min_list, rel). -prolog_sym(minus, -, func). -prolog_sym(mod, mod, func). -prolog_sym(msb, msb, func). -prolog_sym(multifile, multifile, rel). -prolog_sym(name, name, rel). -prolog_sym(nb_current, nb_current, rel). -prolog_sym(nb_delete, nb_delete, rel). -prolog_sym(nb_getval, nb_getval, rel). -prolog_sym(nb_linkarg, nb_linkarg, rel). -prolog_sym(nb_linkval, nb_linkval, rel). -prolog_sym(nb_setarg, nb_setarg, rel). -prolog_sym(nb_setval, nb_setval, rel). -prolog_sym(nl, nl, rel). -prolog_sym(nonvar, nonvar, rel). -prolog_sym(not_provable, \+, rel). -prolog_sym(not_unifiable, \=, rel). -prolog_sym(nth, nth, rel). -prolog_sym(nth_clause, nth_clause, rel). -prolog_sym(nth0, nth0, rel). -prolog_sym(nth1, nth1, rel). -prolog_sym(number, number, rel). -prolog_sym(number_chars, number_chars, rel). -prolog_sym(number_codes, number_codes, rel). -prolog_sym(numbervars, numbervars, rel). -prolog_sym(numlist, numlist, rel). -prolog_sym(on_signal, on_signal, rel). -prolog_sym(once, once, rel). -prolog_sym(op, op, rel). -prolog_sym(open, open, rel). -prolog_sym(parse_time, parse_time, rel). -prolog_sym(peek_byte, peek_byte, rel). -prolog_sym(peek_char, peek_char, rel). -prolog_sym(peek_code, peek_code, rel). -prolog_sym(permutation, permutation, rel). -prolog_sym(pi, pi, func). -prolog_sym(plus, +, rel). -prolog_sym(plus_function, +, func). -prolog_sym(popcount, popcount, func). -prolog_sym(portray_clause, portray_clause, rel). -prolog_sym(power, **, func). -prolog_sym(predicate_property, predicate_property, rel). -prolog_sym(predsort, predsort, rel). -prolog_sym(print, print, rel). -prolog_sym(print_message, print_message, rel). -prolog_sym(print_message_lines, print_message_lines, rel). -prolog_sym(product, *, func). -prolog_sym(prolog_flag, prolog_flag, rel). -prolog_sym(prolog_load_context, prolog_load_context, rel). -prolog_sym(prompt, prompt, rel). -prolog_sym(put, put, rel). -prolog_sym(put_byte, put_byte, rel). -prolog_sym(put_char, put_char, rel). -prolog_sym(put_code, put_code, rel). -prolog_sym(quotient, /, func). -prolog_sym(random, random, func). -prolog_sym(random_float, random_float, func). -prolog_sym(rational, rational, rel). -prolog_sym(rational_function, rational, func). -prolog_sym(rationalize, rationalize, func). -prolog_sym(read, read, rel). -prolog_sym(read_term, read_term, rel). -prolog_sym(recorda, recorda, rel). -prolog_sym(recorded, recorded, rel). -prolog_sym(recordz, recordz, rel). -prolog_sym(rem, rem, func). -prolog_sym(rename_file, rename_file, rel). -prolog_sym(repeat, repeat, rel). -prolog_sym(retract, retract, rel). -prolog_sym(retractall, retractall, rel). -prolog_sym(reverse, reverse, rel). -prolog_sym(round, round, func). -prolog_sym(same_length, same_length, rel). -prolog_sym(see, see, rel). -prolog_sym(seeing, seeing, rel). -prolog_sym(seen, seen, rel). -prolog_sym(select, select, rel). -prolog_sym(selectchk, selectchk, rel). -prolog_sym(set_input, set_input, rel). -prolog_sym(set_output, set_output, rel). -prolog_sym(set_prolog_flag, set_prolog_flag, rel). -prolog_sym(set_stream_position, set_stream_position, rel). -prolog_sym(setarg, setarg, rel). -prolog_sym(setof, setof, rel). -prolog_sym(set_random, set_random, rel). -prolog_sym(shell, shell, rel). -prolog_sym(sign, sign, func). -prolog_sym(simple, simple, rel). -prolog_sym(sin, sin, func). -prolog_sym(sinh, sinh, func). -prolog_sym(skip, skip, rel). -prolog_sym(sort, sort, rel). -prolog_sym(source_file, source_file, rel). -prolog_sym(source_location, source_location, rel). -prolog_sym(sqrt, sqrt, func). -prolog_sym(stamp_date_time, stamp_date_time, rel). -prolog_sym(statistics, statistics, rel). -prolog_sym(stream_position, stream_position, rel). -prolog_sym(stream_position_data, stream_position_data, rel). -prolog_sym(stream_property, stream_property, rel). -prolog_sym(sub_atom, sub_atom, rel). -prolog_sym(sublist, sublist, rel). -prolog_sym(subsumes_term, subsumes_term, rel). -prolog_sym(succ, succ, rel). -prolog_sym(sum_list, sum_list, rel). -prolog_sym(tab, tab, rel). -prolog_sym(tan, tan, func). -prolog_sym(tanh, tanh, func). -prolog_sym(tell, tell, rel). -prolog_sym(telling, telling, rel). -prolog_sym(term_greater_than, @>, rel). -prolog_sym(term_greater_than_or_equal, @>=, rel). -prolog_sym(term_hash, term_index, rel). -prolog_sym(term_identical, ==, rel). -prolog_sym(term_less_than, @<, rel). -prolog_sym(term_less_than_or_equal, @=<, rel). -prolog_sym(term_not_identical, \==, rel). -prolog_sym(term_to_atom, term_to_atom, rel). -prolog_sym(term_variables, term_variables, rel). -prolog_sym(throw, throw, rel). -prolog_sym(time, time, rel). -prolog_sym(time_file, time_file, rel). -prolog_sym(told, told, rel). -prolog_sym(true, true, rel). -prolog_sym(truncate, truncate, func). -prolog_sym(unifiable, unifiable, rel). -prolog_sym(unify, =, rel). -prolog_sym(unify_with_occurs_check, unify_with_occurs_check, rel). -prolog_sym(univ, =.., rel). -prolog_sym(unknown, unknown, rel). -prolog_sym(update_mutable, update_mutable, rel). -prolog_sym(use_module, use_module, rel). -prolog_sym(var, var, rel). -prolog_sym(variant, variant, rel). -prolog_sym(version, version, rel). -prolog_sym(when, when, rel). -prolog_sym(with_output_to, with_output_to, rel). -prolog_sym(write, write, rel). -prolog_sym(write_canonical, write_canonical, rel). -prolog_sym(write_term, write_term, rel). -prolog_sym(writeln, writeln, rel). -prolog_sym(writeq, writeq, rel). - -% -% Support -% - -def_pfx('math:', ''). -def_pfx('e:', ''). -def_pfx('list:', ''). -def_pfx('xsd:', ''). -def_pfx('log:', ''). -def_pfx('r:', ''). -def_pfx('rdfs:', ''). -def_pfx('time:', ''). -def_pfx('rdf:', ''). -def_pfx('string:', ''). -def_pfx('owl:', ''). -def_pfx('n3:', ''). - -put_pfx(_, URI) :- - atomic_list_concat(['<', URI, '>'], U), - pfx(_, U), - !. -put_pfx(_, URI) :- - atomic_list_concat(['<', URI, '>'], U), - def_pfx(Pf, U), - \+pfx(Pf, _), - !, - assertz(pfx(Pf, U)). -put_pfx(Pf, URI) :- - atomic_list_concat(['<', URI, '>'], U), - fresh_pf(Pf, Pff), - assertz(pfx(Pff, U)). - -fresh_pf(Pf, Pfx) :- - atom_concat(Pf, ':', Pfx), - \+pfx(Pfx, _), - !. -fresh_pf(_, Pfx) :- - gensym(ns, Pfn), - fresh_pf(Pfn, Pfx). - -cnt(A) :- - nb_getval(A, B), - C is B+1, - nb_setval(A, C), - ( flag('debug-cnt'), - C mod 10000 =:= 0 - -> format(user_error, '~w = ~w~n', [A, C]), - flush_output(user_error) - ; true - ). - -cnt(A, I) :- - nb_getval(A, B), - C is B+I, - nb_setval(A, C), - ( flag('debug-cnt'), - C mod 10000 =:= 0 - -> format(user_error, '~w = ~w~n', [A, C]), - flush_output(user_error) - ; true - ). - -within_scope([A, B]) :- - ( var(B) - -> B = 1 - ; true - ), - ( B = 0 - -> brake - ; nb_getval(limit, C), - ( C < B - -> nb_setval(limit, B) - ; true - ), - span(B) - ), - nb_getval(scope, A). - -exopred(P, S, O) :- - ( var(P), - var(S), - var(O) - -> pred(P), - H =.. [P, S, O], - clause(H, true) - ; ( var(P) - -> pred(P) - ; atom(P), - current_predicate(P/2) - ), - call(P, S, O) - ). - -exogen :- - forall( - ( clause(exopred(P, S, O), Body), - ( nonvar(S) - ; nonvar(O) - ) - ), - ( ( var(P) - -> pred(P) - ; atom(P), - current_predicate(P/2) - ), - Head =.. [P, S, O], - ( \+clause(Head, Body) - -> assertz(Head :- Body) - ; true - ) - ) - ). -exogen :- - \+flag('multi-query'). - -ucall(A) :- - ( A = (B, C) - -> vcall(B), - ucall(C) - ; vcall(A) - ). - -vcall(A) :- - ( ( A =.. [_, V, W] - ; A = exopred(_, V, W) - ), - ( is_gl(V) - ; is_gl(W) - ) - -> unify(A, B) - ; B = A - ), - ( B =.. [C, D, E], - pred(C), - ( is_gl(D) - ; is_gl(E) - ) - -> G =.. [C, H, I], - call(G), - unify(H, D), - unify(I, E) - ; call(B) - ). - -is_gl(A) :- - nonvar(A), - \+is_list(A), - ( A = (_, _), - ! - ; A =.. [F, _, _], - F \= literal, - F \= rdiv, - ! - ; A = exopred(_, _, _) - ). - -unify(A, true) :- - \+flag('no-erase'), - nonvar(A), - A = ''(X, Y), - nonvar(Y), - labelvars(X, 0, _), - call(Y). -unify(A, B) :- - \+flag('no-erase'), - nonvar(A), - A = ''(X, Y), - conj_list(Y, C), - length(C, D), - D > 1, - ndsplit(C, E, F), - E \= [], - F \= [], - conj_list(G, F), - ( call(G) - -> conj_list(H, E), - B = ''(X, H) - ; ( G = ''(_, I) - -> call(I) - ; ''(_, G) - ), - B = true - ). -unify(A, B) :- - nonvar(A), - A = exopred(P, S, O), - ( ( nonvar(B) - ; nonvar(P) - ) - -> ( nonvar(P) - -> atom(P) - ; true - ), - B =.. [P, T, R], - atom(P), - unify(S, T), - unify(O, R) - ; B = exopred(P, T, R), - unify(S, T), - unify(O, R) - ), - !. -unify(A, B) :- - nonvar(B), - B = exopred(P, S, O), - ( ( nonvar(A) - ; nonvar(P) - ) - -> ( nonvar(P) - -> atom(P) - ; true - ), - A =.. [P, T, R], - atom(P), - unify(S, T), - unify(O, R) - ; A = exopred(P, T, R), - unify(S, T), - unify(O, R) - ), - !. -unify(A, B) :- - is_list(A), - !, - getlist(B, C), - C = A. -unify(A, B) :- - is_list(B), - !, - getlist(A, C), - C = B. -unify(A, B) :- - nonvar(A), - nonvar(B), - ( A = (_, _) - ; B = (_, _) - ), - !, - conj_list(A, C), - conj_list(B, D), - includes(C, D), - includes(D, C). -unify(A, B) :- - nonvar(A), - nonvar(B), - A =.. [P, S, O], - B =.. [P, T, R], - !, - unify(S, T), - unify(O, R). -unify(A, A). - -conj_list(true, []) :- - !. -conj_list(A, [A]) :- - A \= (_, _), - A \= false, - !. -conj_list((A, B), [A|C]) :- - conj_list(B, C). - -conj_append(A, true, A) :- - !. -conj_append((A, B), C, (A, D)) :- - conj_append(B, C, D), - !. -conj_append(A, B, (A, B)). - -cflat([], []). -cflat([A|B], C) :- - cflat(B, D), - copy_term_nat(A, E), - ( E = (_, _), - conj_list(E, F) - -> append(F, D, C) - ; ( E = true - -> C = D - ; C = [E|D] - ) - ). - -couple([], [], []). -couple([A|B], [C|D], [[A, C]|E]) :- - couple(B, D, E). - -includes(_, []) :- - !. -includes(X, [Y|Z]) :- - member(U, X), - unify(U, Y), - includes(X, Z). - -conjoin([X], X) :- - !. -conjoin([true|Y], Z) :- - conjoin(Y, Z), - !. -conjoin([X|Y], Z) :- - conjoin(Y, U), - conj_append(X, U, V), - ( ground(V) - -> conj_list(V, A), - sort(A, B), - conj_list(Z, B) - ; Z = V - ). - -difference([true, _], true) :- - !. -difference([X, true], X) :- - !. -difference([X, Y], Z) :- - conj_list(X, U), - conj_list(Y, V), - difference(U, V, W), - distinct(W, J), - conj_list(Z, J). - -difference([], _, []) :- - !. -difference([X|Y], U, V) :- - member(Z, U), - unify(X, Z), - !, - difference(Y, U, V). -difference([X|Y], U, [X|V]) :- - difference(Y, U, V). - -intersect([X], X) :- - !. -intersect([true|_], true) :- - !. -intersect([X|Y], Z) :- - intersect(Y, I), - conj_list(X, U), - conj_list(I, V), - intersect(U, V, W), - distinct(W, J), - conj_list(Z, J). - -intersect([], _, []) :- - !. -intersect([X|Y], U, V) :- - member(Z, U), - unify(X, Z), - V = [X|W], - intersect(Y, U, W). -intersect([_|Y], U, V) :- - intersect(Y, U, V). - -cartesian([], []). -cartesian([A|B], [C|D]) :- - member(C, A), - cartesian(B, D). - -distinct(A, B) :- - ( ground(A) - -> distinct_hash(A, B) - ; distinct_value(A, B) - ). - -distinct_hash([], []) :- - ( retract(hash_value(_, _)), - fail - ; true - ), - !. -distinct_hash([A|B], C) :- - term_index(A, D), - ( hash_value(D, E) - -> ( unify(A, E) - -> C = F - ; C = [A|F] - ) - ; assertz(hash_value(D, A)), - C = [A|F] - ), - distinct_hash(B, F). - -distinct_value([], []). -distinct_value([A|B], [A|D]) :- - nonvar(A), - !, - del(B, A, E), - distinct_value(E, D). -distinct_value([_|A], B) :- - distinct_value(A, B). - -del([], _, []). -del([A|B], C, D) :- - copy_term_nat(A, Ac), - copy_term_nat(C, Cc), - unify(Ac, Cc), - !, - del(B, C, D). -del([A|B], C, [A|D]) :- - del(B, C, D). - -subst(_, [], []). -subst(A, B, C) :- - member([D, E], A), - append(D, F, B), - !, - append(E, G, C), - subst(A, F, G). -subst(A, [B|C], [B|D]) :- - subst(A, C, D). - -replace([], [], X, X) :- - !. -replace([Search|SearchRest], [Replace|ReplaceRest], X, Y) :- - atomic_list_concat(['(', Search, ')'], Scap), - scrape(X, Scap, Scrape), - atom_codes(Replace, RC), - srlist(Scrape, RC, Subst), - atom_codes(X, XC), - subst(Subst, XC, ZC), - atom_codes(Z, ZC), - replace(SearchRest, ReplaceRest, Z, Y). - -scrape(X, Y, [V|Z]) :- - regex(Y, X, [W|_]), - !, - atom_string(V, W), - sub_atom(X, _, _, I, V), - sub_atom(X, _, I, 0, U), - scrape(U, Y, Z). -scrape(_, _, []). - -srlist([], _, []). -srlist([A|B], C, [[E,C]|D]) :- - string_codes(A, E), - srlist(B, C, D). - -quicksort([], []). -quicksort([A|B], C) :- - split(A, B, D, E), - quicksort(D, F), - quicksort(E, G), - append(F, [A|G], C). - -split(_, [], [], []). -split(A, [B|C], [B|D], E) :- - sort([A, B], [B, A]), - !, - split(A, C, D, E). -split(A, [B|C], D, [B|E]) :- - split(A, C, D, E). - -dsplit([], [], []). -dsplit([A|B], [A|C], D):- - dsplit(B, C, D). -dsplit([A|B], C, [A|D]):- - predicate_property(A, dynamic), - dsplit(B, C, D). - -ndsplit([], [], []). -ndsplit([A|B], [A|C], D):- - ndsplit(B, C, D). -ndsplit([A|B], C, [A|D]):- - ndsplit(B, C, D). - -last_tail([], []) :- - !. -last_tail([_|B], B) :- - \+is_list(B), - !. -last_tail([_|B], C) :- - last_tail(B, C). - -sub_list(A, A) :- - !. -sub_list([A|B], C) :- - sub_list(B, A, C). - -sub_list(A, _, A) :- - !. -sub_list([A|B], C, [C|D]) :- - !, - sub_list(B, A, D). -sub_list([A|B], _, C) :- - sub_list(B, A, C). - -e_transpose([], []). -e_transpose([A|B], C) :- - e_transpose(A, [A|B], C). - -e_transpose([], _, []). -e_transpose([_|A], B, [C|D]) :- - lists_fr(B, C, E), - e_transpose(A, E, D). - -lists_fr([], [], []). -lists_fr([[A|B]|C], [A|D], [B|E]) :- - lists_fr(C, D, E). - -sum([], 0) :- - !. -sum([A|B], C) :- - getnumber(A, X), - sum(B, D), - C is X+D. - -product([], 1) :- - !. -product([A|B], C) :- - getnumber(A, X), - product(B, D), - C is X*D. - -avg(A, B) :- - sum(A, As), - length(A, An), - B is As/An. - -cov([A, B], C) :- - avg(A, Am), - avg(B, Bm), - cov1(A, B, Am, Bm, Cp), - length(A, An), - C is Cp/(An-1). - -cov1([], [], _, _, 0). -cov1([A|B], [C|D], E, F, G) :- - cov1(B, D, E, F, H), - getnumber(A, I), - getnumber(C, J), - G is (I-E)*(J-F)+H. - -pcc([A, B], C) :- - avg(A, Am), - avg(B, Bm), - cov1(A, B, Am, Bm, Cp), - std1(A, Am, Ap), - std1(B, Bm, Bp), - C is Cp/sqrt(Ap*Bp). - -rms(A, B) :- - rms1(A, Ar), - length(A, An), - B is sqrt(Ar/An). - -rms1([], 0). -rms1([A|B], C) :- - rms1(B, D), - getnumber(A, E), - C is E^2+D. - -std(A, B) :- - avg(A, Am), - std1(A, Am, As), - length(A, An), - B is sqrt(As/(An-1)). - -std1([], _, 0). -std1([A|B], C, D) :- - std1(B, C, E), - getnumber(A, F), - D is (F-C)^2+E. - -bmax([A|B], C) :- - bmax(B, A, C). - -bmax([], A, A). -bmax([A|B], C, D) :- - getnumber(A, X), - getnumber(C, Y), - ( X > Y - -> bmax(B, A, D) - ; bmax(B, C, D) - ). - -bmin([A|B], C) :- - bmin(B, A, C). - -bmin([], A, A). -bmin([A|B], C, D) :- - getnumber(A, X), - getnumber(C, Y), - ( X < Y - -> bmin(B, A, D) - ; bmin(B, C, D) - ). - -inconsistent([''(A, '')|B]) :- - memberchk(''(A, ''), B), - !. -inconsistent([''(A, '')|B]) :- - memberchk(''(A, ''), B), - !. -inconsistent([_|B]) :- - inconsistent(B). - -inverse(''(A, ''), - ''(A, '')) :- - !. -inverse(''(A, ''), - ''(A, '')). - -bnet :- - ( ''([A|B], _), - sort(B, C), - findall(Y, - ( ''([A|X], Y), - sort(X, C) - ), - L - ), - sum(L, S), - length(L, N), - Z is S/N, - \+bcnd([A|B], _), - assertz(bcnd([A|B], Z)), - inverse(A, D), - \+bcnd([D|B], _), - E is 1-Z, - assertz(bcnd([D|B], E)), - fail - ; bcnd([''(A, _)|B], _), - ( \+bvar(A), - assertz(bvar(A)) - ; true - ), - member(''(C, _), B), - \+bref(C, A), - assertz(bref(C, A)), - \+bvar(C), - assertz(bvar(C)), - fail - ; true - ). - -bval(''). -bval(''). - -brel(''(A, _), ''(B, _)) :- - bref(A, B), - !. -brel(A, ''(B, _)) :- - bref(C, B), - brel(A, ''(C, _)). - -bpar([], []) :- - !. -bpar([''(A, _)|B], [A|C]) :- - bpar(B, C). - -bget(A, B, 1.0) :- - memberchk(A, B), - !. -bget(''(A, ''), B, 0.0) :- - memberchk(''(A, ''), B), - !. -bget(''(A, ''), B, C) :- - ( memberchk(''(A, ''), B), - !, - C is 0.0 - ; - !, - bget(''(A, ''), B, D), - C is 1-D - ). -bget(A, B, C) :- - ( bgot(A, B, C) - -> true - ; ( member(X, B), - brel(A, X), - member(G, B), - findall(_, - ( member(Z, [A|B]), - brel(G, Z) - ), - [] - ), - del(B, G, H), - !, - bget(G, [A|H], U), - bget(A, H, V), - bget(G, H, W), - ( W < 1e-15 - -> C is 0.5 - ; E is U*V/W, - bmin([E, 1.0], C) - ) - ; findall([Z, Y], - ( bcnd([A|O], P), - bcon(O, B, Q), - Z is P*Q, - bpar(O, Y) - ), - L - ), - findall(Z, - ( member([_, Z], L) - ), - N - ), - distinct(N, I), - findall(Z, - ( member(Y, I), - findall(P, - ( member([P, Y], L) - ), - Q - ), - sum(Q, R), - length(Q, S), - length(Y, T), - ( Q = [] - -> Z is 0.0 - ; D is 2**(T-ceiling(log(S)/log(2))), - ( D < 1 - -> Z is R*D - ; Z is R - ) - ) - ), - J - ), - ( J = [] - -> C is 0.0 - ; bmax(J, C) - ) - ), - assertz(bgot(A, B, C)) - ). - -bcon([], _, 1.0) :- - !. -bcon(_, B, 0.5) :- - inconsistent(B), - !. -bcon([A|B], C, D) :- - bget(A, C, E), - bcon(B, [A|C], F), - D is E*F. - -tmp_file(A) :- - ( current_prolog_flag(dialect, swi), - current_prolog_flag(windows, true), - current_prolog_flag(pid, B) - -> atomic_list_concat(['pl_eye_', B, '_'], C) - ; C = 'eye' - ), - tmp_file(C, A). - -exec(A, B) :- - shell(A, B), - ( B =:= 0 - -> true - ; throw(exec_error(A)) - ). - -getcwd(A) :- - working_directory(A, A). - -% -% Modified Base64 for XML identifiers -% - -base64xml(A, B) :- - base64(A, C), - atom_codes(C, D), - subst([[[0'+], [0'_]], [[0'/], [0':]], [[0'=], []]], D, E), - atom_codes(B, E). - -term_index(A, B) :- - term_hash(A, B). - -if_then_else(A, B, C) :- - ( catch(call(A), _, fail) - -> catch(call(B), _, fail) - ; catch(call(C), _, fail) - ). - -soft_cut(A, B, C) :- - ( catch(call(A), _, fail) - *-> catch(call(B), _, fail) - ; catch(call(C), _, fail) - ). - -inv(false, true). -inv(true, false). - -+(A, B, C) :- - plus(A, B, C). - -':-'(A, B) :- - ( var(A) - -> cpred(C), - A =.. [C, _, _] - ; true - ), - ( A = exopred(P, S, O) - -> Ax =.. [P, S, O] - ; Ax = A - ), - clause(Ax, D), - ( \+flag(nope), - ( D = when(H, I) - -> conj_append(J, istep(Src, _, _, _), I), - B = when(H, J) - ; conj_append(B, istep(Src, _, _, _), D) - ) - -> term_index(true, Pnd), - ( \+prfstep(':-'(Ax, B), true, Pnd, ':-'(Ax, B), _, forward, Src) - -> assertz(prfstep(':-'(Ax, B), true, Pnd, ':-'(Ax, B), _, forward, Src)) - ; true - ) - ; D = B - ). - -sub_atom_last(A, B, C, D, E) :- - sub_atom(A, B, C, D, E), - F is B+1, - sub_atom(A, F, _, 0, G), - ( sub_atom(G, _, C, _, E) - -> sub_atom_last(G, B, C, D, E) - ; true - ). - -lookup(A, B, C) :- - tabl(A, B, C), - !. -lookup(A, B, C) :- - var(A), - nb_getval(tabl, M), - N is M+1, - nb_setval(tabl, N), - atom_number(I, N), - atomic_list_concat([B, '_tabl_entry_', I], A), - assertz(tabl(A, B, C)). - -escape_string([], []) :- - !. -escape_string([0'\t|A], [0'\\, 0't|B]) :- - !, - escape_string(A, B). -escape_string([0'\b|A], [0'\\, 0'b|B]) :- - !, - escape_string(A, B). -escape_string([0'\n|A], [0'\\, 0'n|B]) :- - !, - escape_string(A, B). -escape_string([0'\r|A], [0'\\, 0'r|B]) :- - !, - escape_string(A, B). -escape_string([0'\f|A], [0'\\, 0'f|B]) :- - !, - escape_string(A, B). -escape_string([0'"|A], [0'\\, 0'"|B]) :- - !, - escape_string(A, B). -escape_string([0'\\|A], [0'\\, 0'\\|B]) :- - !, - escape_string(A, B). -escape_string([A|B], [A|C]) :- - escape_string(B, C). - -escape_squote([], []) :- - !. -escape_squote([0''|A], [0'\\, 0''|B]) :- - !, - escape_squote(A, B). -escape_squote([A|B], [A|C]) :- - escape_squote(B, C). - -escape_unicode([], []) :- - !. -escape_unicode([A, B|C], D) :- - 0xD800 =< A, - A =< 0xDBFF, - 0xDC00 =< B, - B =< 0xDFFF, - E is 0x10000+(A-0xD800)*0x400+(B-0xDC00), - ( 0x100000 =< E - -> with_output_to(codes(F), format('\\U00~16R', [E])) - ; with_output_to(codes(F), format('\\U000~16R', [E])) - ), - append(F, G, D), - !, - escape_unicode(C, G). -escape_unicode([A|B], [A|C]) :- - escape_unicode(B, C). - -esplit_string([], _, [], []) :- - !. -esplit_string([], _, A, [A]) :- - !. -esplit_string([A|B], C, [], D) :- - memberchk(A, C), - !, - esplit_string(B, C, [], D). -esplit_string([A|B], C, D, [D|E]) :- - memberchk(A, C), - !, - esplit_string(B, C, [], E). -esplit_string([A|B], C, D, E) :- - append(D, [A], F), - esplit_string(B, C, F, E). - -quant(A, some) :- - var(A), - !. -quant(''(_, _), allv) :- - !. -quant(':-'(_, _), allv) :- - !. -quant(answer('', _, _), allv) :- - !. -quant(answer(':-', _, _), allv) :- - !. -quant(answer('', _, _), allv) :- - !. -quant(_, some). - -labelvars(A, B, C) :- - quant(A, Q), - labelvars(A, B, C, Q). - -labelvars(A, B, C, D) :- - var(A), - !, - atom_number(E, B), - atomic_list_concat([D, E], A), % failing when A is an attributed variable - C is B+1. -labelvars(A, B, B, _) :- - atomic(A), - !. -labelvars(''(A, B), C, C, D) :- - D \= avar, - nonvar(A), - nonvar(B), - !. -labelvars((A, B), C, D, Q) :- - !, - labelvars(A, C, E, Q), - labelvars(B, E, D, Q). -labelvars([A|B], C, D, Q) :- - !, - labelvars(A, C, E, Q), - labelvars(B, E, D, Q). -labelvars(A, B, C, Q) :- - nonvar(A), - functor(A, _, D), - labelvars(0, D, A, B, C, Q). - -labelvars(A, A, _, B, B, _) :- - !. -labelvars(A, B, C, D, E, Q) :- - F is A+1, - arg(F, C, G), - labelvars(G, D, H, Q), - labelvars(F, B, C, H, E, Q). - -relabel(A, A) :- - var(A), - !, - nb_getval(wn, W), - labelvars(A, W, N, allv), - nb_setval(wn, N). -relabel([], []) :- - !. -relabel([A|B], [C|D]) :- - !, - relabel(A, C), - relabel(B, D). -relabel(A, B) :- - atom(A), - !, - ( ''(A, B) - -> labelvars(B, 0, _) - ; B = A - ). -relabel(A, A) :- - number(A), - !. -relabel(A, B) :- - A =.. [C|D], - relabel(C, E), - relabel(D, F), - B =.. [E|F]. - -dynify(A) :- - var(A), - !. -dynify((A, B)) :- - !, - dynify(A), - dynify(B). -dynify(implies(A, B, _)) :- - !, - dynify(A), - dynify(B). -dynify(':-'(A, B)) :- - !, - dynify(A), - dynify(B). -dynify(answer(A, _, _)) :- - nonvar(A), - !, - ( current_predicate(A/2) - -> true - ; dynamic(A/2) - ). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(''(_, A)) :- - !, - dynify(A). -dynify(A) :- - functor(A, F, N), - ( current_predicate(F/N) - -> true - ; dynamic(F/N) - ). - -conjify((A, B), (C, D)) :- - !, - conjify(A, C), - conjify(B, D). -conjify(''([literal(when, type('')), - ''([literal(A, type(''))|B], true), C], true), when(D, C)) :- - !, - D =.. [A|B]. -conjify(''([], true), !) :- - !. -conjify(''([literal(!, type(''))], true), !) :- - !. -conjify(A, A). - -atomify(A, A) :- - var(A), - !. -atomify([A|B], [C|D]) :- - !, - atomify(A, C), - atomify(B, D). -atomify(literal(A, type('')), A) :- - atom(A), - !. -atomify(A, A). - -commonvars(''(A, _), B, C) :- - !, - commonvars(A, B, C). -commonvars(A, B, C) :- - term_variables(A, D), - term_variables(B, E), - copy_term_nat([D, E], [F, G]), - labelvars([F, G], 0, _), - findall(H, - ( member(H, F), - member(H, G) - ), - C - ). - -getvars(A, B) :- - findvars(A, C, alpha), - distinct(C, B). - -makevars(A, B, beta(C)) :- - !, - distinct(C, D), - length(D, E), - length(F, E), - makevars(A, B, D, F). -makevars(A, B, Z) :- - findvars(A, C, Z), - distinct(C, D), - length(D, E), - length(F, E), - makevars(A, B, D, F). - -makevars(A, B, C, D) :- - atomic(A), - !, - ( atom(A), - nth0(E, C, A) - -> nth0(E, D, B) - ; B = A - ). -makevars(A, A, _, _) :- - var(A), - !. -makevars([], [], _, _) :- - !. -makevars([A|B], [C|D], E, F) :- - makevars(A, C, E, F), - makevars(B, D, E, F), - !. -makevars(A, B, E, F) :- - A =.. C, - makevars(C, D, E, F), - B =.. D. - -findvars(A, B, Z) :- - atomic(A), - !, - ( atom(A), - findvar(A, Z) - -> B = [A] - ; B = [] - ). -findvars(A, [], _) :- - var(A), - !. -findvars([], [], _) :- - !. -findvars([A|B], C, Z) :- - findvars(A, D, Z), - findvars(B, E, Z), - append(D, E, C), - !. -findvars(A, B, Z) :- - A =.. C, - findvars(C, B, Z). - -shallowvars(A, B, Z) :- - atomic(A), - !, - ( atom(A), - findvar(A, Z) - -> B = [A] - ; B = [] - ). -shallowvars(A, [], _) :- - var(A), - !. -shallowvars([], [], _) :- - !. -shallowvars([A|B], C, Z) :- - shallowvars(A, D, Z), - shallowvars(B, E, Z), - append(D, E, C), - !. -shallowvars(_, [], _). - -findvar(A, alpha) :- - !, - atom_concat('') :- - is_list(A), - !. -raw_type(A, '') :- - number(A), - !. -raw_type(A, '') :- - atom(A), - \+ sub_atom(A, 0, _, _, some), - \+ sub_atom(A, 0, _, _, avar), - \+ (sub_atom(A, 0, 1, _, '<'), sub_atom(A, _, 1, 0, '>')), - !. -raw_type(literal(_, _), '') :- - !. -raw_type(rdiv(_, _), '') :- - !. -raw_type('', '') :- - !. -raw_type((_, _), '') :- - !. -raw_type(set(_), '') :- - !. -raw_type(A, '') :- - functor(A, B, C), - B \= ':', - C >= 2, - !. -raw_type(_, ''). - -getnumber(rdiv(A, B), C) :- - nonvar(A), - !, - C is A/B. -getnumber(A, A) :- - number(A), - !. -getnumber(A, epsilon) :- - nonvar(A), - A = '', - !. -getnumber(A, A) :- - nonvar(A), - memberchk(A, [inf, -inf, nan]), - !. -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - datetime(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - date(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - time(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - duration(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - yearmonthduration(B, C, []). -getnumber(literal(A, type('')), B) :- - !, - ground(A), - atom_codes(A, C), - daytimeduration(B, C, []). -getnumber(literal(A, _), B) :- - ground(A), - atom_codes(A, C), - numeral(C, D), - catch(number_codes(B, D), _, fail). - -getint(A, B) :- - getnumber(A, C), - B is integer(round(C)). - -getbool(literal(false, type('')), false). -getbool(literal(true, type('')), true). -getbool(literal('0', type('')), false). -getbool(literal('1', type('')), true). -getbool(false, false). -getbool(true, true). - -getlist(A, A) :- - var(A), - !. -getlist(set(A), A) :- - !. -getlist('', []) :- - !. -getlist([], []) :- - !. -getlist([A|B], [C|D]) :- - getlist(A, C), - !, - getlist(B, D). -getlist([A|B], [A|D]) :- - !, - getlist(B, D). -getlist(A, [B|C]) :- - ''(A, B), - ''(A, D), - getlist(D, C). - -getstring(A, B) :- - ''(A, B), - !. -getstring(A, A). - -getcodes(literal(A, _), B) :- - nonvar(A), - !, - atom_codes(A, B). -getcodes(A, B) :- - nonvar(A), - with_output_to_chars(wg(A), B). - -preformat([], []) :- - !. -preformat([literal(A, type(''))|B], [A|D]) :- - !, - preformat(B, D). -preformat([A|B], [A|D]) :- - preformat(B, D). - -numeral([0'-, 0'.|A], [0'-, 0'0, 0'.|A]) :- - !. -numeral([0'+, 0'.|A], [0'+, 0'0, 0'.|A]) :- - !. -numeral([0'.|A], [0'0, 0'.|A]) :- - !. -numeral(A, B) :- - append([C, [0'., 0'e], D], A), - append([C, [0'., 0'0, 0'e], D], B), - !. -numeral(A, B) :- - append([C, [0'., 0'E], D], A), - append([C, [0'., 0'0, 0'E], D], B), - !. -numeral(A, B) :- - last(A, 0'.), - append(A, [0'0], B), - !. -numeral(A, A). - -rdiv_codes(rdiv(A, B), C) :- - append(D, [0'.|E], C), - append(D, E, F), - number_codes(A, F), - lzero(E, G), - number_codes(B, [0'1|G]), - !. -rdiv_codes(rdiv(A, 1), C) :- - number_codes(A, C). - -lzero([], []) :- - !. -lzero([_|A], [0'0|B]) :- - lzero(A, B). - -dtlit([literal(A, type('')), C], B) :- - nonvar(C), - ''(C, ''), - integer(B), - !, - atom_number(A, B). -dtlit([literal(A, type('')), ''], B) :- - integer(B), - !, - atom_number(A, B). -dtlit([literal(A, type('')), ''], B) :- - float(B), - !, - atom_number(A, B). -dtlit([literal(A, type('')), ''], B) :- - ( number(B) - -> datetime(B, C) - ; nonvar(B), - B = date(Year, Month, Day, Hour, Minute, Second, Offset, _, _), - datetime(Year, Month, Day, Hour, Minute, Second, Offset, C) - ), - !, - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - ( number(B) - -> date(B, C) - ; nonvar(B), - B = date(Year, Month, Day, _, _, _, Offset, _, _), - date(Year, Month, Day, Offset, C) - ), - !, - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - ( number(B) - -> time(B, C) - ; nonvar(B), - B = date(_, _, _, Hour, Minute, Second, Offset, _, _), - time(Hour, Minute, Second, Offset, C) - ), - !, - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - number(B), - !, - daytimeduration(B, C), - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - number(B), - !, - yearmonthduration(B, C), - atom_codes(A, C). -dtlit([literal(A, type('')), ''], B) :- - number(B), - !, - daytimeduration(B, C), - atom_codes(A, C). -dtlit([literal(A, type('')), ''], A) :- - atomic(A), - getbool(A, A), - !. -dtlit([literal(A, type('')), prolog:atom], A) :- - atomic(A), - \+ (sub_atom(A, 0, 1, _, '<'), sub_atom(A, _, 1, 0, '>')), - !. -dtlit([literal(A, type('')), ''], literal(A, lang(_))) :- - !. -dtlit([literal(A, type('')), B], literal(A, type(B))). - -hash_to_ascii([], L1, L1). -hash_to_ascii([A|B], [C, D|L3], L4) :- - E is A>>4 /\ 15, - F is A /\ 15, - code_type(C, xdigit(E)), - code_type(D, xdigit(F)), - hash_to_ascii(B, L3, L4). - -memotime(datime(A, B, C, D, E, F), G) :- - ( mtime(datime(A, B, C, D, E, F), G) - -> true - ; catch(date_time_stamp(date(A, B, C, D, E, F, 0, -, -), H), _, fail), - fmsec(F, H, G), - assertz(mtime(datime(A, B, C, D, E, F), G)) - ). - -datetime(A, L1, L13) :- - int(B, L1, [0'-|L3]), - int(C, L3, [0'-|L5]), - int(D, L5, [0'T|L7]), - int(E, L7, [0':|L9]), - int(F, L9, [0':|L11]), - decimal(G, L11, L12), - timezone(H, L12, L13), - I is -H, - catch(date_time_stamp(date(B, C, D, E, F, G, I, -, -), J), _, fail), - fmsec(G, J, A). - -datetime(A, B, C, D, E, F, G, L1, L13) :- - int(A, L1, [0'-|L3]), - int(B, L3, [0'-|L5]), - int(C, L5, [0'T|L7]), - int(D, L7, [0':|L9]), - int(E, L9, [0':|L11]), - decimal(F, L11, L12), - timezone(G, L12, L13). - -date(A, L1, L7) :- - int(B, L1, [0'-|L3]), - int(C, L3, [0'-|L5]), - int(D, L5, L6), - timezone(H, L6, L7), - I is -H, - catch(date_time_stamp(date(B, C, D, 0, 0, 0, I, -, -), E), _, fail), - fmsec(0, E, A). - -date(A, B, C, D, L1, L7) :- - int(A, L1, [0'-|L3]), - int(B, L3, [0'-|L5]), - int(C, L5, L6), - timezone(D, L6, L7). - -time(A, L1, L7) :- - int(B, L1, [0':|L3]), - int(C, L3, [0':|L5]), - decimal(D, L5, L6), - timezone(E, L6, L7), - ( B = 24 - -> A is C*60+D-E - ; A is B*3600+C*60+D-E - ). - -time(A, B, C, D, L1, L7) :- - int(A, L1, [0':|L3]), - int(B, L3, [0':|L5]), - decimal(C, L5, L6), - timezone(D, L6, L7). - -duration(A, L1, L7) :- - dsign(B, L1, [0'P|L3]), - years(C, L3, L4), - months(D, L4, L5), - days(E, L5, L6), - dtime(F, L6, L7), - A is B*(C*31556952+D*2629746+E*86400.0+F). - -yearmonthduration(A, L1, L5) :- - dsign(B, L1, [0'P|L3]), - years(C, L3, L4), - months(D, L4, L5), - A is B*(C*12+D). - -daytimeduration(A, L1, L5) :- - dsign(B, L1, [0'P|L3]), - days(C, L3, L4), - dtime(D, L4, L5), - A is B*(C*86400.0+D). - -timezone(A, L1, L4) :- - int(B, L1, [0':|L3]), - !, - int(C, L3, L4), - A is B*3600+C*60. -timezone(0, [0'Z|L2], L2) :- - !. -timezone(0, L1, L1). - -dsign(1, [0'+|L2], L2). -dsign(-1, [0'-|L2], L2). -dsign(1, L1, L1). - -dtime(A, [0'T|L2], L5) :- - !, - hours(B, L2, L3), - minutes(C, L3, L4), - seconds(D, L4, L5), - A is B*3600+C*60+D. -dtime(0, L1, L1). - -years(A, L1, L3) :- - int(A, L1, [0'Y|L3]). -years(0, L1, L1). - -months(A, L1, L3) :- - int(A, L1, [0'M|L3]). -months(0, L1, L1) . - -days(A, L1, L3) :- - int(A, L1, [0'D|L3]). -days(0, L1, L1). - -hours(A, L1, L3) :- - int(A, L1, [0'H|L3]). -hours(0, L1, L1). - -minutes(A, L1, L3) :- - int(A, L1, [0'M|L3]). -minutes(0, L1, L1). - -seconds(A, L1, L3) :- - decimal(A, L1, [0'S|L3]). -seconds(0, L1, L1). - -int(A, L1, L4) :- - sgn(B, L1, L2), - digit(C, L2, L3), - digits(D, L3, L4), - number_codes(A, [B, C|D]). - -decimal(A, L1, L5) :- - sgn(B, L1, L2), - digit(C, L2, L3), - digits(D, L3, L4), - fraction(E, L4, L5), - append([B, C|D], E, F), - number_codes(A, F). - -sgn(0'+, [0'+|L2], L2). -sgn(0'-, [0'-|L2], L2). -sgn(0'+, L1, L1). - -fraction([0'., A|B], [0'.|L2], L4) :- - !, - digit(A, L2, L3), - digits(B, L3, L4). -fraction([], L1, L1). - -digits([A|B], L1, L3) :- - digit(A, L1, L2), - digits(B, L2, L3). -digits([], L1, L1). - -digit(A, [A|L2], L2) :- - code_type(A, digit). - -fmsec(A, B, C) :- - integer(A), - !, - C is floor(B). -fmsec(_, B, B). - -datetime(A, B) :- - stamp_date_time(A, date(Year, Month, Day, Hour, Minute, Second, _, _, _), 0), - fmsec(A, Second, Sec), - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Sec, H), - append([C, [0'-], D, [0'-], E, [0'T], F, [0':], G, [0':], H, [0'Z]], B). - -datetime(Year, Month, Day, Hour, Minute, Second, Offset, B) :- - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Second, H), - ( Offset =:= 0 - -> append([C, [0'-], D, [0'-], E, [0'T], F, [0':], G, [0':], H, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([C, [0'-], D, [0'-], E, [0'T], F, [0':], G, [0':], H, I, J, [0':], K], B) - ). - -date(A, B) :- - N is A+3600*12, - stamp_date_time(N, date(Year, Month, Day, _, _, _, _, _, _), 0), - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - Offset is (round(floor(N)) mod 86400) - 3600*12, - ( Offset =:= 0 - -> append([C, [0'-], D, [0'-], E, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([C, [0'-], D, [0'-], E, I, J, [0':], K], B) - ). - -date(Year, Month, Day, Offset, B) :- - ycodes(Year, C), - ncodes(Month, D), - ncodes(Day, E), - ( Offset =:= 0 - -> append([C, [0'-], D, [0'-], E, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([C, [0'-], D, [0'-], E, I, J, [0':], K], B) - ). - -time(A, B) :- - stamp_date_time(A, date(_, _, _, Hour, Minute, Second, _, _, _), 0), - fmsec(A, Second, Sec), - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Sec, H), - append([F, [0':], G, [0':], H, [0'Z]], B). - -time(Hour, Minute, Second, Offset, B) :- - ncodes(Hour, F), - ncodes(Minute, G), - ncodes(Second, H), - ( Offset =:= 0 - -> append([F, [0':], G, [0':], H, [0'Z]], B) - ; ( Offset > 0 - -> I = [0'-], - OHour is Offset//3600 - ; I = [0'+], - OHour is -Offset//3600 - ), - ncodes(OHour, J), - OMinute is (Offset mod 3600)//60, - ncodes(OMinute, K), - append([F, [0':], G, [0':], H, I, J, [0':], K], B) - ). - -yearmonthduration(A, B) :- - ( A < 0 - -> C = [0'-] - ; C = [] - ), - D is abs(A), - E is D//12, - number_codes(E, Years), - F is D-(D//12)*12, - number_codes(F, Months), - append([C, [0'P], Years, [0'Y], Months, [0'M]], B). - -daytimeduration(A, B) :- - AInt is round(floor(A)), - AFrac is A-AInt, - ( AInt < 0 - -> C = [0'-] - ; C = [] - ), - D is abs(AInt), - E is D//86400, - number_codes(E, Days), - F is (D-(D//86400)*86400)//3600, - number_codes(F, Hours), - G is (D-(D//3600)*3600)//60, - number_codes(G, Minutes), - H is D-(D//60)*60+AFrac, - number_codes(H, Seconds), - append([C, [0'P| Days], [0'D, 0'T| Hours], [0'H| Minutes], [0'M| Seconds], [0'S]], B). - -ncodes(A, B) :- - number_codes(A, D), - ( A < 10 - -> B = [0'0| D] - ; B = D - ). - -ycodes(A, B) :- - C is abs(A), - number_codes(C, D), - ( C < 10 - -> E = [0'0, 0'0, 0'0| D] - ; ( C < 100 - -> E = [0'0, 0'0| D] - ; ( C < 1000 - -> E = [0'0| D] - ; E = D - ) - ) - ), - ( A >= 0 - -> B = E - ; B = [0'-|E] - ). - -absolute_uri('-', '-') :- - !. -absolute_uri(A, B) :- - ( is_absolute_url(A) - -> B = A - ; absolute_file_name(A, C), - prolog_to_os_filename(D, C), - atom_codes(D, E), - subst([[[0x20], [0'%, 0'2, 0'0]]], E, F), - atom_codes(G, F), - ( current_prolog_flag(windows, true) - -> atomic_list_concat(['file:///', G], B) - ; atomic_list_concat(['file://', G], B) - ) - ). - -resolve_uri(A, _, A) :- - sub_atom(A, _, 1, _, ':'), - !. -resolve_uri('', A, A) :- - !. -resolve_uri('#', A, B) :- - !, - atomic_list_concat([A, '#'], B). -resolve_uri(A, B, A) :- - \+sub_atom(B, _, 1, _, ':'), - !. -resolve_uri(A, B, C) :- - so_uri(U), - atom_length(U, V), - sub_atom(A, 0, 1, _, '#'), - sub_atom(B, 0, V, _, U), - !, - atomic_list_concat([B, A], C). -resolve_uri(A, B, C) :- - sub_atom(A, 0, 2, _, './'), - !, - sub_atom(A, 2, _, 0, R), - resolve_uri(R, B, C). -resolve_uri(A, B, C) :- - sub_atom(A, 0, 3, _, '../'), - !, - sub_atom(A, 3, _, 0, R), - so_uri(U), - atom_length(U, V), - sub_atom(B, 0, V, D, U), - sub_atom(B, V, D, _, E), - ( sub_atom(E, F, 1, G, '/'), - sub_atom(E, _, G, 0, H), - \+sub_atom(H, _, _, _, '/'), - K is V+F - -> sub_atom(B, 0, K, _, S) - ; S = B - ), - resolve_uri(R, S, C). -resolve_uri(A, B, C) :- - so_uri(U), - atom_length(U, V), - sub_atom(A, 0, 1, _, '/'), - sub_atom(B, 0, V, D, U), - sub_atom(B, V, D, _, E), - ( sub_atom(E, F, 1, _, '/') - -> sub_atom(E, 0, F, _, G) - ; G = E - ), - !, - atomic_list_concat([U, G, A], C). -resolve_uri(A, B, C) :- - so_uri(U), - atom_length(U, V), - sub_atom(B, 0, V, D, U), - sub_atom(B, V, D, _, E), - ( sub_atom(E, F, 1, G, '/'), - sub_atom(E, _, G, 0, H), - \+sub_atom(H, _, _, _, '/') - -> sub_atom(E, 0, F, _, I) - ; I = E - ), - !, - atomic_list_concat([U, I, '/', A], C). -resolve_uri(A, _, _) :- - nb_getval(line_number, Ln), - throw(unresolvable_relative_uri(A, after_line(Ln))). - -so_uri('http://'). -so_uri('https://'). -so_uri('ftp://'). -so_uri('file://'). - -wcacher(A, B) :- - wcache(A, B), - !. -wcacher(A, B) :- - wcache(C, D), - sub_atom(A, 0, I, _, C), - sub_atom(A, I, _, 0, E), - atomic_list_concat([D, E], B). - -prolog_verb(S, Name) :- - ( atom(S), - atom_concat('\'\'', A) - -> ( B = conjunction - -> Pred = '\', \'' - ; ( B = disjunction - -> Pred = '\';\'' - ; ( prolog_sym(B, Pred, _) - -> true - ; nb_getval(line_number, Ln), - throw(invalid_prolog_builtin(B, after_line(Ln))) - ) - ) - ), - Name = prolog:Pred - ; Name = S - ). - -timestamp(Stamp) :- - get_time(StampN), - datetime(StampN, StampC), - atom_codes(StampA, StampC), - ( sub_atom(StampA, I, 1, 0, 'Z'), - I > 23 - -> sub_atom(StampA, 0, 23, _, StampB), - atomic_list_concat([StampB, 'Z'], Stamp) - ; Stamp = StampA - ). - -% -% Regular expressions -% - -% Regular Expressions inspired by http://www.cs.sfu.ca/~cameron/Teaching/384/99-3/regexp-plg.html -regex(RE_esc_atom, Input_esc_atom, Output_esc_atoms) :- - atom_codes(RE_esc_atom, RE_esc), - atom_codes(Input_esc_atom, Input_esc), - escape_string(RE, RE_esc), - re(Parsed_RE, RE, []), - ( RE = [0'^|_] - -> Bos = true - ; Bos = false - ), - escape_string(Input, Input_esc), - tokenize2(Parsed_RE, Input, Outputs, Bos), - findall(Output_esc_atom, - ( member(Output, Outputs), - escape_string(Output, Output_esc), - atom_codes(Output_esc_atom, Output_esc) - ), - Output_esc_atoms - ), - !. - -tokenize2(_P_RE, [], [], true). -tokenize2(P_RE, Input, Output, Bos) :- - ( rematch1(P_RE, Input, _, Output) - -> true - ; Bos = false, - Input = [_|Inp], - tokenize2(P_RE, Inp, Output, Bos) - ). - -rematch1(union(RE1, _RE2), S, U, Selected) :- - rematch1(RE1, S, U, Selected). -rematch1(union(_RE1, RE2), S, U, Selected) :- - rematch1(RE2, S, U, Selected). -rematch1(conc(RE1, RE2), S, U, Selected) :- - rematch1(RE1, S, U1, Sel1), - rematch1(RE2, U1, U, Sel2), - append(Sel1, Sel2, Selected). -rematch1(star(RE), S, U, Selected) :- - rematch1(RE, S, U1, Sel1), - rematch1(star(RE), U1, U, Sel2), - append(Sel1, Sel2, Selected). -rematch1(star(_RE), S, S, []). -rematch1(qm(RE), S, U, Selected) :- - rematch1(RE, S, U, Selected). -rematch1(qm(_RE), S, S, []). -rematch1(plus(RE), S, U, Selected) :- - rematch1(RE, S, U1, Sel1), - rematch1(star(RE), U1, U, Sel2), - append(Sel1, Sel2, Selected). -rematch1(group(RE), S, U, Selected) :- - rematch1(RE, S, U, Sel1), - append(P, U, S), - append(Sel1, [P], Selected). -rematch1(any, [_C1|U], U, []). -rematch1(char(C), [C|U], U, []). -rematch1(bos, S, S, []). -rematch1(eos, [], [], []). -rematch1(negSet(Set), [C|U], U, []) :- - \+charSetMember(C, Set). -rematch1(posSet(Set), [C|U], U, []) :- - charSetMember(C, Set). - -charSetMember(C, [char(C)|_]). -charSetMember(C, [range(C1, C2)|_]) :- - C1 =< C, - C =< C2. -charSetMember(C, [negSet(Set)|_]) :- - \+charSetMember(C, Set). -charSetMember(C, [posSet(Set)|_]) :- - charSetMember(C, Set). -charSetMember(C, [_|T]) :- - charSetMember(C, T). - -re(Z, L1, L3) :- - basicRE(W, L1, L2), - reTail(W, Z, L2, L3). - -reTail(W, Z, [0'||L2], L4) :- - basicRE(X, L2, L3), - reTail(union(W, X), Z, L3, L4). -reTail(W, W, L1, L1). - -basicRE(Z, L1, L3) :- - simpleRE(W, L1, L2), - basicREtail(W, Z, L2, L3). - -basicREtail(W, Z, L1, L3) :- - simpleRE(X, L1, L2), - basicREtail(conc(W, X), Z, L2, L3). -basicREtail(W, W, L1, L1). - -simpleRE(Z, L1, L3) :- - elementalRE(W, L1, L2), - simpleREtail(W, Z, L2, L3). - -simpleREtail(W, star(W), [0'*|L2], L2). -simpleREtail(W, qm(W), [0'?|L2], L2). -simpleREtail(W, plus(W), [0'+|L2], L2). -simpleREtail(W, W, L1, L1). - -elementalRE(any, [0'.|L2], L2). -elementalRE(group(X), [0'(|L2], L4) :- - re(X, L2, [0')|L4]). -elementalRE(bos, [0'^|L2], L2). -elementalRE(eos, [0'$|L2], L2). -elementalRE(posSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'w|L2], L2). -elementalRE(negSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'W|L2], L2). -elementalRE(posSet([range(0'0, 0'9)]), [0'\\, 0'd|L2], L2). -elementalRE(negSet([range(0'0, 0'9)]), [0'\\, 0'D|L2], L2). -elementalRE(posSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0's|L2], L2). -elementalRE(negSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0'S|L2], L2). -elementalRE(char(C), [0'\\, C|L2], L2) :- - re_metachar([C]). -elementalRE(char(C), [C|L2], L2) :- - \+re_metachar([C]). -elementalRE(negSet(X), [0'[, 0'^|L2], L4) :- - !, - setItems(X, L2, [0']|L4]). -elementalRE(posSet(X), [0'[|L2], L4) :- - setItems(X, L2, [0']|L4]). - -re_metachar([0'\\]). -re_metachar([0'|]). -re_metachar([0'*]). -re_metachar([0'?]). -re_metachar([0'+]). -re_metachar([0'.]). -re_metachar([0'[]). -re_metachar([0'$]). -re_metachar([0'(]). -re_metachar([0')]). - -setItems([Item1|MoreItems], L1, L3) :- - setItem(Item1, L1, L2), - setItems(MoreItems, L2, L3). -setItems([Item1], L1, L2) :- - setItem(Item1, L1, L2). - -setItem(posSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'w|L2], L2). -setItem(negSet([range(0'A, 0'Z), range(0'a, 0'z), range(0'0, 0'9), char(0'_)]), [0'\\, 0'W|L2], L2). -setItem(posSet([range(0'0, 0'9)]), [0'\\, 0'd|L2], L2). -setItem(negSet([range(0'0, 0'9)]), [0'\\, 0'D|L2], L2). -setItem(posSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0's|L2], L2). -setItem(negSet([char(0x20), char(0'\t), char(0'\r), char(0'\n), char(0'\v), char(0'\f)]), [0'\\, 0'S|L2], L2). -setItem(char(C), [0'\\, C|L2], L2) :- - set_metachar([C]). -setItem(char(C), [C|L2], L2) :- - \+set_metachar([C]). -setItem(range(A, B), L1, L4) :- - setItem(char(A), L1, [0'-|L3]), - setItem(char(B), L3, L4). - -set_metachar([0'\\]). -set_metachar([0']]). -set_metachar([0'-]). - -regexp_wildcard([], []) :- - !. -regexp_wildcard([0'*|A], [0'., 0'*|B]) :- - !, - regexp_wildcard(A, B). -regexp_wildcard([A|B], [A|C]) :- - regexp_wildcard(B, C). - -fm(A) :- - format(user_error, '~n*** ~q~n', [A]), - flush_output(user_error). - -mf(A) :- - forall( - catch(A, _, fail), - format(user_error, '~n*** ~q~n', [A]) - ), - flush_output(user_error). diff --git a/lib/eyebrow/test/output.js b/lib/eyebrow/test/output.js deleted file mode 100644 index 316b369..0000000 --- a/lib/eyebrow/test/output.js +++ /dev/null @@ -1,54 +0,0 @@ -class _Output { - - constructor() { - this.buffers = { - stdout: [], - stderr: [] - }; - - this.output = document.getElementById('output'); - } - - write(to, c) { - if (c) - this.buffers[to].push(c); - - // console.log(c); - // if (c == 10 || c == null) - // this.flush(to); - } - - flushAll() { - return new Promise((resolve, reject) => { - let stderr = this.flush("stderr"); - if (stderr) { - if (stderr.includes("**")) { - let dl = stderr.lastIndexOf("**") + 2 - let error = stderr.substring(dl).trim() - - // console.log("error:", error) - resolve({ error: error }); - return; - } - } - - let output = this.flush("stdout"); - // console.log(output); - let dl = output.indexOf("\n", output.indexOf("#eye")) - let dl2 = output.lastIndexOf("\n", output.indexOf("#ENDS") - 2) - output = output.substring(dl, dl2).trim() - - // console.log("output:", output); - resolve({ success: output }); - }); - } - - flush(to) { - let str = String.fromCharCode.apply(null, this.buffers[to]); - this.buffers[to] = []; - - return str; - } -}; - -export { _Output as Output }; \ No newline at end of file diff --git a/lib/eyebrow/test/socrates-query.n3 b/lib/eyebrow/test/socrates-query.n3 deleted file mode 100644 index 683f68e..0000000 --- a/lib/eyebrow/test/socrates-query.n3 +++ /dev/null @@ -1,3 +0,0 @@ -@prefix : . - -{:Socrates a ?WHAT} => {:Socrates a ?WHAT}. diff --git a/lib/eyebrow/test/socrates.n3 b/lib/eyebrow/test/socrates.n3 deleted file mode 100644 index bba6e0b..0000000 --- a/lib/eyebrow/test/socrates.n3 +++ /dev/null @@ -1,8 +0,0 @@ -@prefix rdfs: . -@prefix : . -@prefix r: . - -:Socrates a :Human {| r:source |}. -:Human rdfs:subClassOf :Mortal {| r:source |}. - -{?A rdfs:subClassOf ?B. ?S a ?A} => {?S a ?B} {| r:source |}. diff --git a/lib/eyebrow/test/swipl-web.data b/lib/eyebrow/test/swipl-web.data deleted file mode 100644 index 7083dba..0000000 Binary files a/lib/eyebrow/test/swipl-web.data and /dev/null differ diff --git a/lib/eyebrow/test/swipl-web.js b/lib/eyebrow/test/swipl-web.js deleted file mode 100644 index cccc87a..0000000 --- a/lib/eyebrow/test/swipl-web.js +++ /dev/null @@ -1,21 +0,0 @@ - -var SWIPL = (() => { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(SWIPL) { - SWIPL = SWIPL || {}; - -var Module=typeof SWIPL!="undefined"?SWIPL:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0}Module.expectedDataFileDownloads++;(function(){if(Module["ENVIRONMENT_IS_PTHREAD"])return;var loadPackage=function(metadata){var PACKAGE_PATH="";if(typeof window==="object"){PACKAGE_PATH=window["encodeURIComponent"](window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/")}else if(typeof process==="undefined"&&typeof location!=="undefined"){PACKAGE_PATH=encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/")}var PACKAGE_NAME="src/swipl-web.data";var REMOTE_PACKAGE_BASE="swipl-web.data";if(typeof Module["locateFilePackage"]==="function"&&!Module["locateFile"]){Module["locateFile"]=Module["locateFilePackage"];err("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)")}var REMOTE_PACKAGE_NAME=Module["locateFile"]?Module["locateFile"](REMOTE_PACKAGE_BASE,""):REMOTE_PACKAGE_BASE;var REMOTE_PACKAGE_SIZE=metadata["remote_package_size"];function fetchRemotePackage(packageName,packageSize,callback,errback){if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){require("fs").readFile(packageName,function(err,contents){if(err){errback(err)}else{callback(contents.buffer)}});return}var xhr=new XMLHttpRequest;xhr.open("GET",packageName,true);xhr.responseType="arraybuffer";xhr.onprogress=function(event){var url=packageName;var size=packageSize;if(event.total)size=event.total;if(event.loaded){if(!xhr.addedTotal){xhr.addedTotal=true;if(!Module.dataFileDownloads)Module.dataFileDownloads={};Module.dataFileDownloads[url]={loaded:event.loaded,total:size}}else{Module.dataFileDownloads[url].loaded=event.loaded}var total=0;var loaded=0;var num=0;for(var download in Module.dataFileDownloads){var data=Module.dataFileDownloads[download];total+=data.total;loaded+=data.loaded;num++}total=Math.ceil(total*Module.expectedDataFileDownloads/num);if(Module["setStatus"])Module["setStatus"]("Downloading data... ("+loaded+"/"+total+")")}else if(!Module.dataFileDownloads){if(Module["setStatus"])Module["setStatus"]("Downloading data...")}};xhr.onerror=function(event){throw new Error("NetworkError for: "+packageName)};xhr.onload=function(event){if(xhr.status==200||xhr.status==304||xhr.status==206||xhr.status==0&&xhr.response){var packageData=xhr.response;callback(packageData)}else{throw new Error(xhr.statusText+" : "+xhr.responseURL)}};xhr.send(null)}function handleError(error){console.error("package error:",error)}var fetchedCallback=null;var fetched=Module["getPreloadedPackage"]?Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE):null;if(!fetched)fetchRemotePackage(REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE,function(data){if(fetchedCallback){fetchedCallback(data);fetchedCallback=null}else{fetched=data}},handleError);function runWithFS(){function assert(check,msg){if(!check)throw msg+(new Error).stack}Module["FS_createPath"]("/","swipl",true,true);Module["FS_createPath"]("/swipl","library",true,true);Module["FS_createPath"]("/swipl/library","iri_scheme",true,true);Module["FS_createPath"]("/swipl/library","http",true,true);Module["FS_createPath"]("/swipl/library","chr",true,true);Module["FS_createPath"]("/swipl/library","theme",true,true);Module["FS_createPath"]("/swipl/library","DTD",true,true);Module["FS_createPath"]("/swipl/library","lynx",true,true);Module["FS_createPath"]("/swipl/library","clp",true,true);Module["FS_createPath"]("/swipl/library/clp","clpqr",true,true);Module["FS_createPath"]("/swipl/library/clp","clpq",true,true);Module["FS_createPath"]("/swipl/library/clp","clpr",true,true);Module["FS_createPath"]("/swipl/library","dcg",true,true);Module["FS_createPath"]("/swipl/library","unicode",true,true);Module["FS_createPath"]("/swipl/library","build",true,true);Module["FS_createPath"]("/swipl/library","dialect",true,true);Module["FS_createPath"]("/swipl/library/dialect","swi",true,true);Module["FS_createPath"]("/swipl/library/dialect","xsb",true,true);Module["FS_createPath"]("/swipl/library/dialect","sicstus4",true,true);Module["FS_createPath"]("/swipl/library/dialect","eclipse",true,true);Module["FS_createPath"]("/swipl/library/dialect","yap",true,true);Module["FS_createPath"]("/swipl/library/dialect","sicstus",true,true);Module["FS_createPath"]("/swipl/library/dialect","hprolog",true,true);Module["FS_createPath"]("/swipl/library/dialect","iso",true,true);Module["FS_createPath"]("/swipl/library","semweb",true,true);function DataRequest(start,end,audio){this.start=start;this.end=end;this.audio=audio}DataRequest.prototype={requests:{},open:function(mode,name){this.name=name;this.requests[name]=this;Module["addRunDependency"]("fp "+this.name)},send:function(){},onload:function(){var byteArray=this.byteArray.subarray(this.start,this.end);this.finish(byteArray)},finish:function(byteArray){var that=this;Module["FS_createDataFile"](this.name,null,byteArray,true,true,true);Module["removeRunDependency"]("fp "+that.name);this.requests[this.name]=null}};var files=metadata["files"];for(var i=0;i{s+=a});Module.on_output(s,stream)}else{console.log.apply(null,args)}}function bind_std_streams(){decoder=new TextDecoder("utf-8");Module.FS.init(undefined,c=>write("stdout",c),c=>write("stderr",c))}if(Module.on_output){Module.preRun.push(bind_std_streams)}var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;function logExceptionOnExit(e){if(e instanceof ExitStatus)return;let toLog=e;err("exiting due to exception: "+toLog)}var fs;var nodePath;var requireNodeFS;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}requireNodeFS=()=>{if(!nodePath){fs=require("fs");nodePath=require("path")}};read_=function shell_read(filename,binary){requireNodeFS();filename=nodePath["normalize"](filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror)=>{requireNodeFS();filename=nodePath["normalize"](filename);fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer)})};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",function(reason){throw reason});quit_=(status,toThrow)=>{if(keepRuntimeAlive()){process["exitCode"]=status;throw toThrow}logExceptionOnExit(toThrow);process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=value=>{tempRet0=value};var getTempRet0=()=>tempRet0;var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||false;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf);Module["HEAP64"]=HEAP64=new BigInt64Array(buf);Module["HEAPU64"]=HEAPU64=new BigUint64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;var runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function exitRuntime(){___funcs_on_exit();callRuntimeCallbacks(__ATEXIT__);FS.quit();TTY.shutdown();runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){{if(Module["onAbort"]){Module["onAbort"](what)}}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="swipl-web.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["na"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Gb"];addOnInit(Module["asm"]["oa"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync().catch(readyPromiseReject);return{}}var ASM_CONSTS={270120:$0=>{release_registered_object($0)},270155:$0=>{const s=prolog_js_obj_class_name($0);const len=lengthBytesUTF8(s)+1;const mem=_malloc(len);stringToUTF8(s,mem,len);return mem},270298:($0,$1)=>{return prolog_js_call($0,$1)}};function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort("invalid type for getValue: "+type)}return null}function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort("invalid type for setValue: "+type)}}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}var wasmTableMirror=[];function getWasmTableEntry(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func}function ___call_sighandler(fp,sig){getWasmTableEntry(fp)(sig)}var PATH={isAbs:path=>path.charAt(0)==="/",splitPath:filename=>{var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(p=>!!p),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:path=>{if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:(l,r)=>{return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto=="object"&&typeof crypto["getRandomValues"]=="function"){var randomBuffer=new Uint8Array(1);return()=>{crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else if(ENVIRONMENT_IS_NODE){try{var crypto_module=require("crypto");return()=>crypto_module["randomBytes"](1)[0]}catch(e){}}return()=>abort("randomDevice")}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(p=>!!p),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:(from,to)=>{from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var TTY={ttys:[],init:function(){},shutdown:function(){},register:function(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open:function(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close:function(stream){stream.tty.ops.flush(stream.tty)},flush:function(stream){stream.tty.ops.flush(stream.tty)},read:function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function zeroMemory(address,size){HEAPU8.fill(0,address,address+size)}function alignMemory(size,alignment){return Math.ceil(size/alignment)*alignment}function mmapAlloc(size){size=alignMemory(size,65536);var ptr=_emscripten_builtin_memalign(65536,size);if(!ptr)return 0;zeroMemory(ptr,size);return ptr}var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray:function(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage:function(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).');onload(new Uint8Array(arrayBuffer));if(dep)removeRunDependency(dep)},event=>{if(onerror){onerror()}else{throw'Loading data file "'+url+'" failed.'}});if(dep)addRunDependency(dep)}var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(path,opts={})=>{path=PATH_FS.resolve(FS.cwd(),path);if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};opts=Object.assign(defaults,opts);if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=PATH.normalizeArray(path.split("/").filter(p=>!!p),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:node=>{var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:(parentid,name)=>{var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:node=>{var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:node=>{var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:(parent,name)=>{var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:(parent,name,mode,rdev)=>{var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:node=>{FS.hashRemoveNode(node)},isRoot:node=>{return node===node.parent},isMountpoint:node=>{return!!node.mounted},isFile:mode=>{return(mode&61440)===32768},isDir:mode=>{return(mode&61440)===16384},isLink:mode=>{return(mode&61440)===40960},isChrdev:mode=>{return(mode&61440)===8192},isBlkdev:mode=>{return(mode&61440)===24576},isFIFO:mode=>{return(mode&61440)===4096},isSocket:mode=>{return(mode&49152)===49152},flagModes:{"r":0,"r+":2,"w":577,"w+":578,"a":1089,"a+":1090},modeStringToFlags:str=>{var flags=FS.flagModes[str];if(typeof flags=="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:flag=>{var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:(node,perms)=>{if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup:dir=>{var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:(dir,name)=>{try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:(dir,name,isdir)=>{var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:(node,flags)=>{if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:(fd_start=0,fd_end=FS.MAX_OPEN_FDS)=>{for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:fd=>FS.streams[fd],createStream:(stream,fd_start,fd_end)=>{if(!FS.FSStream){FS.FSStream=function(){this.shared={}};FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(val){this.shared.flags=val}},position:{get:function(){return this.shared.position},set:function(val){this.shared.position=val}}})}stream=Object.assign(new FS.FSStream,stream);var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:fd=>{FS.streams[fd]=null},chrdev_stream_ops:{open:stream=>{var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:()=>{throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice:(dev,ops)=>{FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts:mount=>{var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:(populate,callback)=>{if(typeof populate=="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:(type,opts,mountpoint)=>{var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:mountpoint=>{var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:(parent,name)=>{return parent.node_ops.lookup(parent,name)},mknod:(path,mode,dev)=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:(path,mode)=>{mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:(path,mode)=>{mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:(path,mode)=>{var dirs=path.split("/");var d="";for(var i=0;i{if(typeof dev=="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink:(oldpath,newpath)=>{if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename:(old_path,new_path)=>{var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,"w");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir:path=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(54)}return node.node_ops.readdir(node)},unlink:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink:path=>{var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return PATH_FS.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))},stat:(path,dontFollow)=>{var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(44)}if(!node.node_ops.getattr){throw new FS.ErrnoError(63)}return node.node_ops.getattr(node)},lstat:path=>{return FS.stat(path,true)},chmod:(path,mode,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})},lchmod:(path,mode)=>{FS.chmod(path,mode,true)},fchmod:(fd,mode)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chmod(stream.node,mode)},chown:(path,uid,gid,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{timestamp:Date.now()})},lchown:(path,uid,gid)=>{FS.chown(path,uid,gid,true)},fchown:(fd,uid,gid)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chown(stream.node,uid,gid)},truncate:(path,len)=>{if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,"w");if(errCode){throw new FS.ErrnoError(errCode)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate:(fd,len)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.truncate(stream.node,len)},utime:(path,atime,mtime)=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open:(path,flags,mode)=>{if(path===""){throw new FS.ErrnoError(44)}flags=typeof flags=="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode=="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path=="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close:stream=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed:stream=>{return stream.fd===null},llseek:(stream,offset,whence)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read:(stream,buffer,offset,length,position)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write:(stream,buffer,offset,length,position,canOwn)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},allocate:(stream,offset,length)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(offset<0||length<=0){throw new FS.ErrnoError(28)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(stream.node.mode)){throw new FS.ErrnoError(43)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(138)}stream.stream_ops.allocate(stream,offset,length)},mmap:(stream,length,position,prot,flags)=>{if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync:(stream,buffer,offset,length,mmapFlags)=>{if(!stream||!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},munmap:stream=>0,ioctl:(stream,cmd,arg)=>{if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile:(path,opts={})=>{opts.flags=opts.flags||0;opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret},writeFile:(path,data,opts={})=>{opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data=="string"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,undefined,opts.canOwn)}else if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error("Unsupported data type")}FS.close(stream)},cwd:()=>FS.currentPath,chdir:path=>{var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,"x");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories:()=>{FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices:()=>{FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device=getRandomDevice();FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{FS.mkdir("/proc");var proc_self=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:()=>{var node=FS.createNode(proc_self,"fd",16384|511,73);node.node_ops={lookup:(parent,name)=>{var fd=+name;var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>stream.path}};ret.parent=ret;return ret}};return node}},{},"/proc/self/fd")},createStandardStreams:()=>{if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin",0);var stdout=FS.open("/dev/stdout",1);var stderr=FS.open("/dev/stderr",1)},ensureErrnoError:()=>{if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.node=node;this.setErrno=function(errno){this.errno=errno};this.setErrno(errno);this.message="FS error"};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[44].forEach(code=>{FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack=""})},staticInit:()=>{FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={"MEMFS":MEMFS}},init:(input,output,error)=>{FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()},quit:()=>{FS.init.initialized=false;_fflush(0);for(var i=0;i{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode},findObject:(path,dontResolveLastLink)=>{var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath:(path,dontResolveLastLink)=>{try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path==="/"}catch(e){ret.error=e.errno}return ret},createPath:(parent,path,canRead,canWrite)=>{parent=typeof parent=="string"?parent:FS.getPath(parent);var parts=path.split("/").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){}parent=current}return current},createFile:(parent,name,properties,canRead,canWrite)=>{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile:(parent,name,data,canRead,canWrite,canOwn)=>{var path=name;if(parent){parent=typeof parent=="string"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS.getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data=="string"){var arr=new Array(data.length);for(var i=0,len=data.length;i{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(!!input,!!output);if(!FS.createDevice.major)FS.createDevice.major=64;var dev=FS.makedev(FS.createDevice.major++,0);FS.registerDevice(dev,{open:stream=>{stream.seekable=false},close:stream=>{if(output&&output.buffer&&output.buffer.length){output(10)}},read:(stream,buffer,offset,length,pos)=>{var bytesRead=0;for(var i=0;i{for(var i=0;i{if(obj.isDevice||obj.isFolder||obj.link||obj.contents)return true;if(typeof XMLHttpRequest!="undefined"){throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")}else if(read_){try{obj.contents=intArrayFromString(read_(obj.url),true);obj.usedBytes=obj.contents.length}catch(e){throw new FS.ErrnoError(29)}}else{throw new Error("Cannot load without read() or XMLHttpRequest.")}},createLazyFile:(parent,name,url,canRead,canWrite)=>{function LazyUint8Array(){this.lengthKnown=false;this.chunks=[]}LazyUint8Array.prototype.get=function LazyUint8Array_get(idx){if(idx>this.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||"",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]=="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]=="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr:ptr,allocated:true}};node.stream_ops=stream_ops;return node},createPreloadedFile:(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency("cp "+fullname);function processData(byteArray){function finish(byteArray){if(preFinish)preFinish();if(!dontCreateFile){FS.createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}if(onload)onload();removeRunDependency(dep)}if(Browser.handledByPreloadPlugin(byteArray,fullname,finish,()=>{if(onerror)onerror();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url=="string"){asyncLoad(url,byteArray=>processData(byteArray),onerror)}else{processData(url)}},indexedDB:()=>{return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:()=>{return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=()=>{out("creating db");var db=openRequest.result;db.createObjectStore(FS.DB_STORE_NAME)};openRequest.onsuccess=()=>{var db=openRequest.result;var transaction=db.transaction([FS.DB_STORE_NAME],"readwrite");var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var putRequest=files.put(FS.analyzePath(path).object.contents,path);putRequest.onsuccess=()=>{ok++;if(ok+fail==total)finish()};putRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror},loadFilesFromDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=onerror;openRequest.onsuccess=()=>{var db=openRequest.result;try{var transaction=db.transaction([FS.DB_STORE_NAME],"readonly")}catch(e){onerror(e);return}var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var getRequest=files.get(path);getRequest.onsuccess=()=>{if(FS.analyzePath(path).exists){FS.unlink(path)}FS.createDataFile(PATH.dirname(path),PATH.basename(path),getRequest.result,true,true,true);ok++;if(ok+fail==total)finish()};getRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror}};var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=FS.getStream(dirfd);if(!dirstream)throw new FS.ErrnoError(8);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return PATH.join2(dir,path)},doStat:function(func,path,buf){try{var stat=func(path)}catch(e){if(e&&e.node&&PATH.normalize(path)!==PATH.normalize(FS.getPath(e.node))){return-54}throw e}HEAP32[buf>>2]=stat.dev;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP64[buf+40>>3]=BigInt(stat.size);HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;HEAP64[buf+56>>3]=BigInt(Math.floor(stat.atime.getTime()/1e3));HEAP32[buf+64>>2]=0;HEAP64[buf+72>>3]=BigInt(Math.floor(stat.mtime.getTime()/1e3));HEAP32[buf+80>>2]=0;HEAP64[buf+88>>3]=BigInt(Math.floor(stat.ctime.getTime()/1e3));HEAP32[buf+96>>2]=0;HEAP64[buf+104>>3]=BigInt(stat.ino);return 0},doMsync:function(addr,stream,len,flags,offset){var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream}};function ___syscall_chdir(path){try{path=SYSCALLS.getStr(path);FS.chdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_chmod(path,mode){try{path=SYSCALLS.getStr(path);FS.chmod(path,mode);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_dup3(fd,suggestFD,flags){try{var old=SYSCALLS.getStreamFromFD(fd);if(old.fd===suggestFD)return-28;var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.createStream(old,suggestFD,suggestFD+1).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_faccessat(dirfd,path,amode,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(amode&~7){return-28}var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.createStream(stream,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 5:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}var MAX_INT53=9007199254740992;var MIN_INT53=-9007199254740992;function bigintToI53Checked(num){return numMAX_INT53?NaN:Number(num)}function ___syscall_ftruncate64(fd,length){try{length=bigintToI53Checked(length);if(isNaN(length))return-61;FS.ftruncate(fd,length);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd)+1;if(size>3]=BigInt(id);HEAP64[dirp+pos+8>>3]=BigInt((idx+1)*struct_size);HEAP16[dirp+pos+16>>1]=280;HEAP8[dirp+pos+18>>0]=type;stringToUTF8(name,dirp+pos+19,256);pos+=struct_size;idx+=1}FS.llseek(stream,idx*struct_size,0);return pos}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(op){case 21509:case 21505:{if(!stream.tty)return-59;return 0}case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:{if(!stream.tty)return-59;return 0}case 21519:{if(!stream.tty)return-59;var argp=SYSCALLS.get();HEAP32[argp>>2]=0;return 0}case 21520:{if(!stream.tty)return-59;return-28}case 21531:{var argp=SYSCALLS.get();return FS.ioctl(stream,op,argp)}case 21523:{if(!stream.tty)return-59;return 0}case 21524:{if(!stream.tty)return-59;return 0}default:return-28}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_lstat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.lstat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_mkdirat(dirfd,path,mode){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_newfstatat(dirfd,path,buf,flags){try{path=SYSCALLS.getStr(path);var nofollow=flags&256;var allowEmpty=flags&4096;flags=flags&~4352;path=SYSCALLS.calculateAt(dirfd,path,allowEmpty);return SYSCALLS.doStat(nofollow?FS.lstat:FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs;try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);var mode=varargs?SYSCALLS.get():0;return FS.open(path,flags,mode).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_poll(fds,nfds,timeout){try{var nonzero=0;for(var i=0;i>2];var events=HEAP16[pollfd+4>>1];var mask=32;var stream=FS.getStream(fd);if(stream){mask=SYSCALLS.DEFAULT_POLLMASK;if(stream.stream_ops.poll){mask=stream.stream_ops.poll(stream)}}mask&=events|8|16;if(mask)nonzero++;HEAP16[pollfd+6>>1]=mask}return nonzero}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_readlinkat(dirfd,path,buf,bufsize){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_renameat(olddirfd,oldpath,newdirfd,newpath){try{oldpath=SYSCALLS.getStr(oldpath);newpath=SYSCALLS.getStr(newpath);oldpath=SYSCALLS.calculateAt(olddirfd,oldpath);newpath=SYSCALLS.calculateAt(newdirfd,newpath);FS.rename(oldpath,newpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_rmdir(path){try{path=SYSCALLS.getStr(path);FS.rmdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_stat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_symlink(target,linkpath){try{target=SYSCALLS.getStr(target);linkpath=SYSCALLS.getStr(linkpath);FS.symlink(target,linkpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_unlinkat(dirfd,path,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(flags===0){FS.unlink(path)}else if(flags===512){FS.rmdir(path)}else{abort("Invalid flags passed to unlinkat")}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function readI53FromI64(ptr){return HEAPU32[ptr>>2]+HEAP32[ptr+4>>2]*4294967296}function ___syscall_utimensat(dirfd,path,times,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path,true);if(!times){var atime=Date.now();var mtime=atime}else{var seconds=readI53FromI64(times);var nanoseconds=HEAP32[times+8>>2];atime=seconds*1e3+nanoseconds/(1e3*1e3);times+=16;seconds=readI53FromI64(times);nanoseconds=HEAP32[times+8>>2];mtime=seconds*1e3+nanoseconds/(1e3*1e3)}FS.utime(path,atime,mtime);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function __emscripten_date_now(){return Date.now()}var nowIsMonotonic=true;function __emscripten_get_now_is_monotonic(){return nowIsMonotonic}function __emscripten_throw_longjmp(){throw Infinity}function __localtime_js(time,tmPtr){var date=new Date(readI53FromI64(time)*1e3);HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getDay();var start=new Date(date.getFullYear(),0,1);var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>2]=dst}function __mktime_js(tmPtr){var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();return date.getTime()/1e3|0}function __munmap_js(addr,len,prot,flags,fd,offset){try{var stream=FS.getStream(fd);if(stream){if(prot&2){SYSCALLS.doMsync(addr,stream,len,flags,offset)}FS.munmap(stream)}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function _tzset_impl(timezone,daylight,tzname){var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAP32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAPU32[tzname+4>>2]=summerNamePtr}else{HEAPU32[tzname>>2]=summerNamePtr;HEAPU32[tzname+4>>2]=winterNamePtr}}function __tzset_js(timezone,daylight,tzname){if(__tzset_js.called)return;__tzset_js.called=true;_tzset_impl(timezone,daylight,tzname)}function _abort(){abort("")}var readAsmConstArgsArray=[];function readAsmConstArgs(sigPtr,buf){readAsmConstArgsArray.length=0;var ch;buf>>=2;while(ch=HEAPU8[sigPtr++]){buf+=ch!=105&buf;readAsmConstArgsArray.push(ch==105?HEAP32[buf]:(ch==106?HEAP64:HEAPF64)[buf++>>1]);++buf}return readAsmConstArgsArray}function _emscripten_asm_const_int(code,sigPtr,argbuf){var args=readAsmConstArgs(sigPtr,argbuf);return ASM_CONSTS[code].apply(null,args)}var _emscripten_asm_const_ptr=_emscripten_asm_const_int;function getHeapMax(){return 2147483648}function _emscripten_get_heap_max(){return getHeapMax()}var _emscripten_get_now;if(ENVIRONMENT_IS_NODE){_emscripten_get_now=()=>{var t=process["hrtime"]();return t[0]*1e3+t[1]/1e6}}else _emscripten_get_now=()=>performance.now();function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function _emscripten_run_script(ptr){eval(UTF8ToString(ptr))}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAPU32[penviron_buf_size>>2]=bufSize;return 0}function _proc_exit(code){EXITSTATUS=code;if(!keepRuntimeAlive()){if(Module["onExit"])Module["onExit"](code);ABORT=true}quit_(code,new ExitStatus(code))}function exitJS(status,implicit){EXITSTATUS=status;if(!keepRuntimeAlive()){exitRuntime()}_proc_exit(status)}var _exit=exitJS;function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_fdstat_get(fd,pbuf){try{var stream=SYSCALLS.getStreamFromFD(fd);var type=stream.tty?2:FS.isDir(stream.mode)?3:FS.isLink(stream.mode)?7:4;HEAP8[pbuf>>0]=type;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doReadv(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_seek(fd,offset,whence,newOffset){try{offset=bigintToI53Checked(offset);if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);HEAP64[newOffset>>3]=BigInt(stream.position);if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doWritev(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=doWritev(stream,iov,iovcnt);HEAPU32[pnum>>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _getTempRet0(){return getTempRet0()}function _setTempRet0(val){setTempRet0(val)}function __isLeapYear(year){return year%4===0&&(year%100!==0||year%400===0)}function __arraySum(array,index){var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date,days){var newDate=new Date(date.getTime());while(days>0){var leap=__isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate}function _strftime(s,maxsize,format,tm){var tm_zone=HEAP32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value=="number"?value.toString():value||"";while(str.length0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}return thisDate.getFullYear()}return thisDate.getFullYear()-1}var EXPANSION_RULES_2={"%a":function(date){return WEEKDAYS[date.tm_wday].substring(0,3)},"%A":function(date){return WEEKDAYS[date.tm_wday]},"%b":function(date){return MONTHS[date.tm_mon].substring(0,3)},"%B":function(date){return MONTHS[date.tm_mon]},"%C":function(date){var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":function(date){return leadingNulls(date.tm_mday,2)},"%e":function(date){return leadingSomething(date.tm_mday,2," ")},"%g":function(date){return getWeekBasedYear(date).toString().substring(2)},"%G":function(date){return getWeekBasedYear(date)},"%H":function(date){return leadingNulls(date.tm_hour,2)},"%I":function(date){var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":function(date){return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,date.tm_mon-1),3)},"%m":function(date){return leadingNulls(date.tm_mon+1,2)},"%M":function(date){return leadingNulls(date.tm_min,2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}return"PM"},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var days=date.tm_yday+7-date.tm_wday;return leadingNulls(Math.floor(days/7),2)},"%V":function(date){var val=Math.floor((date.tm_yday+7-(date.tm_wday+6)%7)/7);if((date.tm_wday+371-date.tm_yday-2)%7<=2){val++}if(!val){val=52;var dec31=(date.tm_wday+7-date.tm_yday-1)%7;if(dec31==4||dec31==5&&__isLeapYear(date.tm_year%400-1)){val++}}else if(val==53){var jan1=(date.tm_wday+371-date.tm_yday)%7;if(jan1!=4&&(jan1!=3||!__isLeapYear(date.tm_year)))val=1}return leadingNulls(val,2)},"%w":function(date){return date.tm_wday},"%W":function(date){var days=date.tm_yday+7-(date.tm_wday+6)%7;return leadingNulls(Math.floor(days/7),2)},"%y":function(date){return(date.tm_year+1900).toString().substring(2)},"%Y":function(date){return date.tm_year+1900},"%z":function(date){var off=date.tm_gmtoff;var ahead=off>=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};pattern=pattern.replace(/%%/g,"\0\0");for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}pattern=pattern.replace(/\0\0/g,"%");var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1}var ALLOC_NORMAL=0;var ALLOC_STACK=1;function allocate(slab,allocator){var ret;if(allocator==ALLOC_STACK){ret=stackAlloc(slab.length)}else{ret=_malloc(slab.length)}if(!slab.subarray&&!slab.slice){slab=new Uint8Array(slab)}HEAPU8.set(slab,ret);return ret}function getCFunc(ident){var func=Module["_"+ident];return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;itype==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_unlink"]=FS.unlink;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;var asmLibraryArg={"P":___call_sighandler,"fa":___syscall_chdir,"ea":___syscall_chmod,"da":___syscall_dup3,"ga":___syscall_faccessat,"n":___syscall_fcntl64,"Z":___syscall_fstat64,"V":___syscall_ftruncate64,"U":___syscall_getcwd,"O":___syscall_getdents64,"w":___syscall_ioctl,"W":___syscall_lstat64,"S":___syscall_mkdirat,"X":___syscall_newfstatat,"x":___syscall_openat,"Q":___syscall_poll,"N":___syscall_readlinkat,"L":___syscall_renameat,"t":___syscall_rmdir,"Y":___syscall_stat64,"K":___syscall_symlink,"M":___syscall_unlinkat,"I":___syscall_utimensat,"z":__emscripten_date_now,"_":__emscripten_get_now_is_monotonic,"G":__emscripten_throw_longjmp,"$":__localtime_js,"aa":__mktime_js,"R":__munmap_js,"ba":__tzset_js,"m":_abort,"A":_emscripten_asm_const_int,"ja":_emscripten_asm_const_ptr,"J":_emscripten_get_heap_max,"y":_emscripten_get_now,"ca":_emscripten_memcpy_big,"H":_emscripten_resize_heap,"ka":_emscripten_run_script,"ha":_environ_get,"ia":_environ_sizes_get,"i":_exit,"p":_fd_close,"u":_fd_fdstat_get,"v":_fd_read,"T":_fd_seek,"q":_fd_write,"a":_getTempRet0,"h":invoke_i,"d":invoke_ii,"c":invoke_iii,"f":invoke_iiii,"k":invoke_iiiii,"j":invoke_iiiiii,"C":invoke_iiiiiii,"s":invoke_iiiiiiii,"D":invoke_iiiiiiiii,"E":invoke_iiiiiiiiii,"F":invoke_iiiiiiiiiii,"ma":invoke_iiiiiiiiiiii,"r":invoke_iiji,"B":invoke_ij,"l":invoke_v,"e":invoke_vi,"g":invoke_vii,"o":invoke_viii,"b":_setTempRet0,"la":_strftime};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["oa"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["pa"]).apply(null,arguments)};var _PL_initialise=Module["_PL_initialise"]=function(){return(_PL_initialise=Module["_PL_initialise"]=Module["asm"]["qa"]).apply(null,arguments)};var _PL_halt=Module["_PL_halt"]=function(){return(_PL_halt=Module["_PL_halt"]=Module["asm"]["ra"]).apply(null,arguments)};var _PL_toplevel=Module["_PL_toplevel"]=function(){return(_PL_toplevel=Module["_PL_toplevel"]=Module["asm"]["sa"]).apply(null,arguments)};var _PL_unregister_blob_type=Module["_PL_unregister_blob_type"]=function(){return(_PL_unregister_blob_type=Module["_PL_unregister_blob_type"]=Module["asm"]["ta"]).apply(null,arguments)};var _PL_unregister_atom=Module["_PL_unregister_atom"]=function(){return(_PL_unregister_atom=Module["_PL_unregister_atom"]=Module["asm"]["ua"]).apply(null,arguments)};var _PL_agc_hook=Module["_PL_agc_hook"]=function(){return(_PL_agc_hook=Module["_PL_agc_hook"]=Module["asm"]["va"]).apply(null,arguments)};var _PL_register_atom=Module["_PL_register_atom"]=function(){return(_PL_register_atom=Module["_PL_register_atom"]=Module["asm"]["wa"]).apply(null,arguments)};var _PL_open_foreign_frame=Module["_PL_open_foreign_frame"]=function(){return(_PL_open_foreign_frame=Module["_PL_open_foreign_frame"]=Module["asm"]["xa"]).apply(null,arguments)};var _PL_close_foreign_frame=Module["_PL_close_foreign_frame"]=function(){return(_PL_close_foreign_frame=Module["_PL_close_foreign_frame"]=Module["asm"]["ya"]).apply(null,arguments)};var _PL_rewind_foreign_frame=Module["_PL_rewind_foreign_frame"]=function(){return(_PL_rewind_foreign_frame=Module["_PL_rewind_foreign_frame"]=Module["asm"]["za"]).apply(null,arguments)};var _PL_discard_foreign_frame=Module["_PL_discard_foreign_frame"]=function(){return(_PL_discard_foreign_frame=Module["_PL_discard_foreign_frame"]=Module["asm"]["Aa"]).apply(null,arguments)};var _PL_open_query=Module["_PL_open_query"]=function(){return(_PL_open_query=Module["_PL_open_query"]=Module["asm"]["Ba"]).apply(null,arguments)};var _PL_exception=Module["_PL_exception"]=function(){return(_PL_exception=Module["_PL_exception"]=Module["asm"]["Ca"]).apply(null,arguments)};var _PL_cut_query=Module["_PL_cut_query"]=function(){return(_PL_cut_query=Module["_PL_cut_query"]=Module["asm"]["Da"]).apply(null,arguments)};var _PL_close_query=Module["_PL_close_query"]=function(){return(_PL_close_query=Module["_PL_close_query"]=Module["asm"]["Ea"]).apply(null,arguments)};var _PL_current_query=Module["_PL_current_query"]=function(){return(_PL_current_query=Module["_PL_current_query"]=Module["asm"]["Fa"]).apply(null,arguments)};var _PL_next_solution=Module["_PL_next_solution"]=function(){return(_PL_next_solution=Module["_PL_next_solution"]=Module["asm"]["Ga"]).apply(null,arguments)};var _PL_instantiation_error=Module["_PL_instantiation_error"]=function(){return(_PL_instantiation_error=Module["_PL_instantiation_error"]=Module["asm"]["Ha"]).apply(null,arguments)};var _PL_uninstantiation_error=Module["_PL_uninstantiation_error"]=function(){return(_PL_uninstantiation_error=Module["_PL_uninstantiation_error"]=Module["asm"]["Ia"]).apply(null,arguments)};var _PL_representation_error=Module["_PL_representation_error"]=function(){return(_PL_representation_error=Module["_PL_representation_error"]=Module["asm"]["Ja"]).apply(null,arguments)};var _PL_type_error=Module["_PL_type_error"]=function(){return(_PL_type_error=Module["_PL_type_error"]=Module["asm"]["Ka"]).apply(null,arguments)};var _PL_domain_error=Module["_PL_domain_error"]=function(){return(_PL_domain_error=Module["_PL_domain_error"]=Module["asm"]["La"]).apply(null,arguments)};var _PL_existence_error=Module["_PL_existence_error"]=function(){return(_PL_existence_error=Module["_PL_existence_error"]=Module["asm"]["Ma"]).apply(null,arguments)};var _PL_permission_error=Module["_PL_permission_error"]=function(){return(_PL_permission_error=Module["_PL_permission_error"]=Module["asm"]["Na"]).apply(null,arguments)};var _PL_resource_error=Module["_PL_resource_error"]=function(){return(_PL_resource_error=Module["_PL_resource_error"]=Module["asm"]["Oa"]).apply(null,arguments)};var _PL_syntax_error=Module["_PL_syntax_error"]=function(){return(_PL_syntax_error=Module["_PL_syntax_error"]=Module["asm"]["Pa"]).apply(null,arguments)};var _PL_get_atom_ex=Module["_PL_get_atom_ex"]=function(){return(_PL_get_atom_ex=Module["_PL_get_atom_ex"]=Module["asm"]["Qa"]).apply(null,arguments)};var _PL_get_integer_ex=Module["_PL_get_integer_ex"]=function(){return(_PL_get_integer_ex=Module["_PL_get_integer_ex"]=Module["asm"]["Ra"]).apply(null,arguments)};var _PL_get_long_ex=Module["_PL_get_long_ex"]=function(){return(_PL_get_long_ex=Module["_PL_get_long_ex"]=Module["asm"]["Sa"]).apply(null,arguments)};var _PL_get_int64_ex=Module["_PL_get_int64_ex"]=function(){return(_PL_get_int64_ex=Module["_PL_get_int64_ex"]=Module["asm"]["Ta"]).apply(null,arguments)};var _PL_get_intptr_ex=Module["_PL_get_intptr_ex"]=function(){return(_PL_get_intptr_ex=Module["_PL_get_intptr_ex"]=Module["asm"]["Ua"]).apply(null,arguments)};var _PL_get_size_ex=Module["_PL_get_size_ex"]=function(){return(_PL_get_size_ex=Module["_PL_get_size_ex"]=Module["asm"]["Va"]).apply(null,arguments)};var _PL_get_bool_ex=Module["_PL_get_bool_ex"]=function(){return(_PL_get_bool_ex=Module["_PL_get_bool_ex"]=Module["asm"]["Wa"]).apply(null,arguments)};var _PL_get_float_ex=Module["_PL_get_float_ex"]=function(){return(_PL_get_float_ex=Module["_PL_get_float_ex"]=Module["asm"]["Xa"]).apply(null,arguments)};var _PL_get_char_ex=Module["_PL_get_char_ex"]=function(){return(_PL_get_char_ex=Module["_PL_get_char_ex"]=Module["asm"]["Ya"]).apply(null,arguments)};var _PL_get_pointer_ex=Module["_PL_get_pointer_ex"]=function(){return(_PL_get_pointer_ex=Module["_PL_get_pointer_ex"]=Module["asm"]["Za"]).apply(null,arguments)};var _PL_unify_list_ex=Module["_PL_unify_list_ex"]=function(){return(_PL_unify_list_ex=Module["_PL_unify_list_ex"]=Module["asm"]["_a"]).apply(null,arguments)};var _PL_unify_nil_ex=Module["_PL_unify_nil_ex"]=function(){return(_PL_unify_nil_ex=Module["_PL_unify_nil_ex"]=Module["asm"]["$a"]).apply(null,arguments)};var _PL_get_list_ex=Module["_PL_get_list_ex"]=function(){return(_PL_get_list_ex=Module["_PL_get_list_ex"]=Module["asm"]["ab"]).apply(null,arguments)};var _PL_get_nil_ex=Module["_PL_get_nil_ex"]=function(){return(_PL_get_nil_ex=Module["_PL_get_nil_ex"]=Module["asm"]["bb"]).apply(null,arguments)};var _PL_unify_bool_ex=Module["_PL_unify_bool_ex"]=function(){return(_PL_unify_bool_ex=Module["_PL_unify_bool_ex"]=Module["asm"]["cb"]).apply(null,arguments)};var _PL_is_ground=Module["_PL_is_ground"]=function(){return(_PL_is_ground=Module["_PL_is_ground"]=Module["asm"]["db"]).apply(null,arguments)};var _PL_is_acyclic=Module["_PL_is_acyclic"]=function(){return(_PL_is_acyclic=Module["_PL_is_acyclic"]=Module["asm"]["eb"]).apply(null,arguments)};var _PL_put_term_from_chars=Module["_PL_put_term_from_chars"]=function(){return(_PL_put_term_from_chars=Module["_PL_put_term_from_chars"]=Module["asm"]["fb"]).apply(null,arguments)};var _PL_chars_to_term=Module["_PL_chars_to_term"]=function(){return(_PL_chars_to_term=Module["_PL_chars_to_term"]=Module["asm"]["gb"]).apply(null,arguments)};var _PL_wchars_to_term=Module["_PL_wchars_to_term"]=function(){return(_PL_wchars_to_term=Module["_PL_wchars_to_term"]=Module["asm"]["hb"]).apply(null,arguments)};var _PL_record_external=Module["_PL_record_external"]=function(){return(_PL_record_external=Module["_PL_record_external"]=Module["asm"]["ib"]).apply(null,arguments)};var _PL_recorded_external=Module["_PL_recorded_external"]=function(){return(_PL_recorded_external=Module["_PL_recorded_external"]=Module["asm"]["jb"]).apply(null,arguments)};var _PL_erase_external=Module["_PL_erase_external"]=function(){return(_PL_erase_external=Module["_PL_erase_external"]=Module["asm"]["kb"]).apply(null,arguments)};var _PL_sigaction=Module["_PL_sigaction"]=function(){return(_PL_sigaction=Module["_PL_sigaction"]=Module["asm"]["lb"]).apply(null,arguments)};var _PL_get_signum_ex=Module["_PL_get_signum_ex"]=function(){return(_PL_get_signum_ex=Module["_PL_get_signum_ex"]=Module["asm"]["mb"]).apply(null,arguments)};var _PL_signal=Module["_PL_signal"]=function(){return(_PL_signal=Module["_PL_signal"]=Module["asm"]["nb"]).apply(null,arguments)};var _PL_handle_signals=Module["_PL_handle_signals"]=function(){return(_PL_handle_signals=Module["_PL_handle_signals"]=Module["asm"]["ob"]).apply(null,arguments)};var _PL_write_term=Module["_PL_write_term"]=function(){return(_PL_write_term=Module["_PL_write_term"]=Module["asm"]["pb"]).apply(null,arguments)};var _PL_cleanup_fork=Module["_PL_cleanup_fork"]=function(){return(_PL_cleanup_fork=Module["_PL_cleanup_fork"]=Module["asm"]["qb"]).apply(null,arguments)};var _PL_is_initialised=Module["_PL_is_initialised"]=function(){return(_PL_is_initialised=Module["_PL_is_initialised"]=Module["asm"]["rb"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["sb"]).apply(null,arguments)};var _PL_raise=Module["_PL_raise"]=function(){return(_PL_raise=Module["_PL_raise"]=Module["asm"]["tb"]).apply(null,arguments)};var _PL_new_atom=Module["_PL_new_atom"]=function(){return(_PL_new_atom=Module["_PL_new_atom"]=Module["asm"]["ub"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["vb"]).apply(null,arguments)};var _PL_put_atom_chars=Module["_PL_put_atom_chars"]=function(){return(_PL_put_atom_chars=Module["_PL_put_atom_chars"]=Module["asm"]["wb"]).apply(null,arguments)};var _PL_throw=Module["_PL_throw"]=function(){return(_PL_throw=Module["_PL_throw"]=Module["asm"]["xb"]).apply(null,arguments)};var _PL_raise_exception=Module["_PL_raise_exception"]=function(){return(_PL_raise_exception=Module["_PL_raise_exception"]=Module["asm"]["yb"]).apply(null,arguments)};var _PL_clear_exception=Module["_PL_clear_exception"]=function(){return(_PL_clear_exception=Module["_PL_clear_exception"]=Module["asm"]["zb"]).apply(null,arguments)};var _PL_put_nil=Module["_PL_put_nil"]=function(){return(_PL_put_nil=Module["_PL_put_nil"]=Module["asm"]["Ab"]).apply(null,arguments)};var _PL_atom_nchars=Module["_PL_atom_nchars"]=function(){return(_PL_atom_nchars=Module["_PL_atom_nchars"]=Module["asm"]["Bb"]).apply(null,arguments)};var _PL_atom_wchars=Module["_PL_atom_wchars"]=function(){return(_PL_atom_wchars=Module["_PL_atom_wchars"]=Module["asm"]["Cb"]).apply(null,arguments)};var _PL_is_integer=Module["_PL_is_integer"]=function(){return(_PL_is_integer=Module["_PL_is_integer"]=Module["asm"]["Db"]).apply(null,arguments)};var _PL_unify_uint64=Module["_PL_unify_uint64"]=function(){return(_PL_unify_uint64=Module["_PL_unify_uint64"]=Module["asm"]["Eb"]).apply(null,arguments)};var _PL_unify_float=Module["_PL_unify_float"]=function(){return(_PL_unify_float=Module["_PL_unify_float"]=Module["asm"]["Fb"]).apply(null,arguments)};var _PL_unify_nil=Module["_PL_unify_nil"]=function(){return(_PL_unify_nil=Module["_PL_unify_nil"]=Module["asm"]["Hb"]).apply(null,arguments)};var _PL_cons_functor_v=Module["_PL_cons_functor_v"]=function(){return(_PL_cons_functor_v=Module["_PL_cons_functor_v"]=Module["asm"]["Ib"]).apply(null,arguments)};var _PL_get_nil=Module["_PL_get_nil"]=function(){return(_PL_get_nil=Module["_PL_get_nil"]=Module["asm"]["Jb"]).apply(null,arguments)};var _PL_atom_chars=Module["_PL_atom_chars"]=function(){return(_PL_atom_chars=Module["_PL_atom_chars"]=Module["asm"]["Kb"]).apply(null,arguments)};var _PL_is_list=Module["_PL_is_list"]=function(){return(_PL_is_list=Module["_PL_is_list"]=Module["asm"]["Lb"]).apply(null,arguments)};var _PL_cons_functor=Module["_PL_cons_functor"]=function(){return(_PL_cons_functor=Module["_PL_cons_functor"]=Module["asm"]["Mb"]).apply(null,arguments)};var _PL_warning=Module["_PL_warning"]=function(){return(_PL_warning=Module["_PL_warning"]=Module["asm"]["Nb"]).apply(null,arguments)};var _PL_unify_chars=Module["_PL_unify_chars"]=function(){return(_PL_unify_chars=Module["_PL_unify_chars"]=Module["asm"]["Ob"]).apply(null,arguments)};var _PL_get_nchars=Module["_PL_get_nchars"]=function(){return(_PL_get_nchars=Module["_PL_get_nchars"]=Module["asm"]["Pb"]).apply(null,arguments)};var _PL_get_wchars=Module["_PL_get_wchars"]=function(){return(_PL_get_wchars=Module["_PL_get_wchars"]=Module["asm"]["Qb"]).apply(null,arguments)};var _PL_call_predicate=Module["_PL_call_predicate"]=function(){return(_PL_call_predicate=Module["_PL_call_predicate"]=Module["asm"]["Rb"]).apply(null,arguments)};var _PL_is_number=Module["_PL_is_number"]=function(){return(_PL_is_number=Module["_PL_is_number"]=Module["asm"]["Sb"]).apply(null,arguments)};var _PL_is_string=Module["_PL_is_string"]=function(){return(_PL_is_string=Module["_PL_is_string"]=Module["asm"]["Tb"]).apply(null,arguments)};var _PL_is_pair=Module["_PL_is_pair"]=function(){return(_PL_is_pair=Module["_PL_is_pair"]=Module["asm"]["Ub"]).apply(null,arguments)};var _PL_predicate=Module["_PL_predicate"]=function(){return(_PL_predicate=Module["_PL_predicate"]=Module["asm"]["Vb"]).apply(null,arguments)};var _PL_is_float=Module["_PL_is_float"]=function(){return(_PL_is_float=Module["_PL_is_float"]=Module["asm"]["Wb"]).apply(null,arguments)};var _PL_is_compound=Module["_PL_is_compound"]=function(){return(_PL_is_compound=Module["_PL_is_compound"]=Module["asm"]["Xb"]).apply(null,arguments)};var _PL_is_callable=Module["_PL_is_callable"]=function(){return(_PL_is_callable=Module["_PL_is_callable"]=Module["asm"]["Yb"]).apply(null,arguments)};var _PL_unify_compound=Module["_PL_unify_compound"]=function(){return(_PL_unify_compound=Module["_PL_unify_compound"]=Module["asm"]["Zb"]).apply(null,arguments)};var _PL_compare=Module["_PL_compare"]=function(){return(_PL_compare=Module["_PL_compare"]=Module["asm"]["_b"]).apply(null,arguments)};var _PL_unify_atom_nchars=Module["_PL_unify_atom_nchars"]=function(){return(_PL_unify_atom_nchars=Module["_PL_unify_atom_nchars"]=Module["asm"]["$b"]).apply(null,arguments)};var _PL_unify_wchars=Module["_PL_unify_wchars"]=function(){return(_PL_unify_wchars=Module["_PL_unify_wchars"]=Module["asm"]["ac"]).apply(null,arguments)};var _PL_get_atom_chars=Module["_PL_get_atom_chars"]=function(){return(_PL_get_atom_chars=Module["_PL_get_atom_chars"]=Module["asm"]["bc"]).apply(null,arguments)};var _PL_unify_bool=Module["_PL_unify_bool"]=function(){return(_PL_unify_bool=Module["_PL_unify_bool"]=Module["asm"]["cc"]).apply(null,arguments)};var _PL_get_chars=Module["_PL_get_chars"]=function(){return(_PL_get_chars=Module["_PL_get_chars"]=Module["asm"]["dc"]).apply(null,arguments)};var _PL_skip_list=Module["_PL_skip_list"]=function(){return(_PL_skip_list=Module["_PL_skip_list"]=Module["asm"]["ec"]).apply(null,arguments)};var _PL_is_atom=Module["_PL_is_atom"]=function(){return(_PL_is_atom=Module["_PL_is_atom"]=Module["asm"]["fc"]).apply(null,arguments)};var _PL_is_variable=Module["_PL_is_variable"]=function(){return(_PL_is_variable=Module["_PL_is_variable"]=Module["asm"]["gc"]).apply(null,arguments)};var _PL_unify_atom=Module["_PL_unify_atom"]=function(){return(_PL_unify_atom=Module["_PL_unify_atom"]=Module["asm"]["hc"]).apply(null,arguments)};var _PL_new_term_refs=Module["_PL_new_term_refs"]=function(){return(_PL_new_term_refs=Module["_PL_new_term_refs"]=Module["asm"]["ic"]).apply(null,arguments)};var _PL_put_atom=Module["_PL_put_atom"]=function(){return(_PL_put_atom=Module["_PL_put_atom"]=Module["asm"]["jc"]).apply(null,arguments)};var _PL_new_term_ref=Module["_PL_new_term_ref"]=function(){return(_PL_new_term_ref=Module["_PL_new_term_ref"]=Module["asm"]["kc"]).apply(null,arguments)};var _PL_unify=Module["_PL_unify"]=function(){return(_PL_unify=Module["_PL_unify"]=Module["asm"]["lc"]).apply(null,arguments)};var _PL_get_bool=Module["_PL_get_bool"]=function(){return(_PL_get_bool=Module["_PL_get_bool"]=Module["asm"]["mc"]).apply(null,arguments)};var _PL_get_float=Module["_PL_get_float"]=function(){return(_PL_get_float=Module["_PL_get_float"]=Module["asm"]["nc"]).apply(null,arguments)};var _PL_get_module=Module["_PL_get_module"]=function(){return(_PL_get_module=Module["_PL_get_module"]=Module["asm"]["oc"]).apply(null,arguments)};var _PL_erase=Module["_PL_erase"]=function(){return(_PL_erase=Module["_PL_erase"]=Module["asm"]["pc"]).apply(null,arguments)};var _PL_unify_string_nchars=Module["_PL_unify_string_nchars"]=function(){return(_PL_unify_string_nchars=Module["_PL_unify_string_nchars"]=Module["asm"]["qc"]).apply(null,arguments)};var _PL_get_intptr=Module["_PL_get_intptr"]=function(){return(_PL_get_intptr=Module["_PL_get_intptr"]=Module["asm"]["rc"]).apply(null,arguments)};var _PL_pred=Module["_PL_pred"]=function(){return(_PL_pred=Module["_PL_pred"]=Module["asm"]["sc"]).apply(null,arguments)};var _PL_is_blob=Module["_PL_is_blob"]=function(){return(_PL_is_blob=Module["_PL_is_blob"]=Module["asm"]["tc"]).apply(null,arguments)};var _PL_put_bool=Module["_PL_put_bool"]=function(){return(_PL_put_bool=Module["_PL_put_bool"]=Module["asm"]["uc"]).apply(null,arguments)};var _PL_unify_atom_chars=Module["_PL_unify_atom_chars"]=function(){return(_PL_unify_atom_chars=Module["_PL_unify_atom_chars"]=Module["asm"]["vc"]).apply(null,arguments)};var _PL_put_float=Module["_PL_put_float"]=function(){return(_PL_put_float=Module["_PL_put_float"]=Module["asm"]["wc"]).apply(null,arguments)};var _PL_put_pointer=Module["_PL_put_pointer"]=function(){return(_PL_put_pointer=Module["_PL_put_pointer"]=Module["asm"]["xc"]).apply(null,arguments)};var _PL_unify_int64=Module["_PL_unify_int64"]=function(){return(_PL_unify_int64=Module["_PL_unify_int64"]=Module["asm"]["yc"]).apply(null,arguments)};var _PL_get_atom=Module["_PL_get_atom"]=function(){return(_PL_get_atom=Module["_PL_get_atom"]=Module["asm"]["zc"]).apply(null,arguments)};var _PL_copy_term_ref=Module["_PL_copy_term_ref"]=function(){return(_PL_copy_term_ref=Module["_PL_copy_term_ref"]=Module["asm"]["Ac"]).apply(null,arguments)};var _PL_unify_integer=Module["_PL_unify_integer"]=function(){return(_PL_unify_integer=Module["_PL_unify_integer"]=Module["asm"]["Bc"]).apply(null,arguments)};var _PL_put_int64=Module["_PL_put_int64"]=function(){return(_PL_put_int64=Module["_PL_put_int64"]=Module["asm"]["Cc"]).apply(null,arguments)};var _PL_set_prolog_flag=Module["_PL_set_prolog_flag"]=function(){return(_PL_set_prolog_flag=Module["_PL_set_prolog_flag"]=Module["asm"]["Dc"]).apply(null,arguments)};var _PL_get_file_name=Module["_PL_get_file_name"]=function(){return(_PL_get_file_name=Module["_PL_get_file_name"]=Module["asm"]["Ec"]).apply(null,arguments)};var _PL_unify_blob=Module["_PL_unify_blob"]=function(){return(_PL_unify_blob=Module["_PL_unify_blob"]=Module["asm"]["Fc"]).apply(null,arguments)};var _PL_get_blob=Module["_PL_get_blob"]=function(){return(_PL_get_blob=Module["_PL_get_blob"]=Module["asm"]["Gc"]).apply(null,arguments)};var _PL_blob_data=Module["_PL_blob_data"]=function(){return(_PL_blob_data=Module["_PL_blob_data"]=Module["asm"]["Hc"]).apply(null,arguments)};var _PL_new_module=Module["_PL_new_module"]=function(){return(_PL_new_module=Module["_PL_new_module"]=Module["asm"]["Ic"]).apply(null,arguments)};var _PL_put_string_chars=Module["_PL_put_string_chars"]=function(){return(_PL_put_string_chars=Module["_PL_put_string_chars"]=Module["asm"]["Jc"]).apply(null,arguments)};var _PL_set_resource_db_mem=Module["_PL_set_resource_db_mem"]=function(){return(_PL_set_resource_db_mem=Module["_PL_set_resource_db_mem"]=Module["asm"]["Kc"]).apply(null,arguments)};var _PL_on_halt=Module["_PL_on_halt"]=function(){return(_PL_on_halt=Module["_PL_on_halt"]=Module["asm"]["Lc"]).apply(null,arguments)};var _PL_exit_hook=Module["_PL_exit_hook"]=function(){return(_PL_exit_hook=Module["_PL_exit_hook"]=Module["asm"]["Mc"]).apply(null,arguments)};var _PL_cleanup=Module["_PL_cleanup"]=function(){return(_PL_cleanup=Module["_PL_cleanup"]=Module["asm"]["Nc"]).apply(null,arguments)};var _PL_unify_string_chars=Module["_PL_unify_string_chars"]=function(){return(_PL_unify_string_chars=Module["_PL_unify_string_chars"]=Module["asm"]["Oc"]).apply(null,arguments)};var _PL_put_variable=Module["_PL_put_variable"]=function(){return(_PL_put_variable=Module["_PL_put_variable"]=Module["asm"]["Pc"]).apply(null,arguments)};var _PL_is_atomic=Module["_PL_is_atomic"]=function(){return(_PL_is_atomic=Module["_PL_is_atomic"]=Module["asm"]["Qc"]).apply(null,arguments)};var _PL_recorded=Module["_PL_recorded"]=function(){return(_PL_recorded=Module["_PL_recorded"]=Module["asm"]["Rc"]).apply(null,arguments)};var _PL_record=Module["_PL_record"]=function(){return(_PL_record=Module["_PL_record"]=Module["asm"]["Sc"]).apply(null,arguments)};var _PL_put_functor=Module["_PL_put_functor"]=function(){return(_PL_put_functor=Module["_PL_put_functor"]=Module["asm"]["Tc"]).apply(null,arguments)};var _PL_strip_module=Module["_PL_strip_module"]=function(){return(_PL_strip_module=Module["_PL_strip_module"]=Module["asm"]["Uc"]).apply(null,arguments)};var _PL_unify_list=Module["_PL_unify_list"]=function(){return(_PL_unify_list=Module["_PL_unify_list"]=Module["asm"]["Vc"]).apply(null,arguments)};var _PL_register_foreign_in_module=Module["_PL_register_foreign_in_module"]=function(){return(_PL_register_foreign_in_module=Module["_PL_register_foreign_in_module"]=Module["asm"]["Wc"]).apply(null,arguments)};var _PL_foreign_control=Module["_PL_foreign_control"]=function(){return(_PL_foreign_control=Module["_PL_foreign_control"]=Module["asm"]["Xc"]).apply(null,arguments)};var _PL_foreign_context_address=Module["_PL_foreign_context_address"]=function(){return(_PL_foreign_context_address=Module["_PL_foreign_context_address"]=Module["asm"]["Yc"]).apply(null,arguments)};var _PL_reset_term_refs=Module["_PL_reset_term_refs"]=function(){return(_PL_reset_term_refs=Module["_PL_reset_term_refs"]=Module["asm"]["Zc"]).apply(null,arguments)};var _PL_new_atom_nchars=Module["_PL_new_atom_nchars"]=function(){return(_PL_new_atom_nchars=Module["_PL_new_atom_nchars"]=Module["asm"]["_c"]).apply(null,arguments)};var _PL_new_atom_mbchars=Module["_PL_new_atom_mbchars"]=function(){return(_PL_new_atom_mbchars=Module["_PL_new_atom_mbchars"]=Module["asm"]["$c"]).apply(null,arguments)};var _PL_new_functor=Module["_PL_new_functor"]=function(){return(_PL_new_functor=Module["_PL_new_functor"]=Module["asm"]["ad"]).apply(null,arguments)};var _PL_functor_name=Module["_PL_functor_name"]=function(){return(_PL_functor_name=Module["_PL_functor_name"]=Module["asm"]["bd"]).apply(null,arguments)};var _PL_functor_arity=Module["_PL_functor_arity"]=function(){return(_PL_functor_arity=Module["_PL_functor_arity"]=Module["asm"]["cd"]).apply(null,arguments)};var _PL_new_atom_wchars=Module["_PL_new_atom_wchars"]=function(){return(_PL_new_atom_wchars=Module["_PL_new_atom_wchars"]=Module["asm"]["dd"]).apply(null,arguments)};var _PL_unify_wchars_diff=Module["_PL_unify_wchars_diff"]=function(){return(_PL_unify_wchars_diff=Module["_PL_unify_wchars_diff"]=Module["asm"]["ed"]).apply(null,arguments)};var _PL_same_compound=Module["_PL_same_compound"]=function(){return(_PL_same_compound=Module["_PL_same_compound"]=Module["asm"]["fd"]).apply(null,arguments)};var _PL_cons_list=Module["_PL_cons_list"]=function(){return(_PL_cons_list=Module["_PL_cons_list"]=Module["asm"]["gd"]).apply(null,arguments)};var _PL_get_atom_nchars=Module["_PL_get_atom_nchars"]=function(){return(_PL_get_atom_nchars=Module["_PL_get_atom_nchars"]=Module["asm"]["hd"]).apply(null,arguments)};var _PL_get_list_nchars=Module["_PL_get_list_nchars"]=function(){return(_PL_get_list_nchars=Module["_PL_get_list_nchars"]=Module["asm"]["id"]).apply(null,arguments)};var _PL_get_list_chars=Module["_PL_get_list_chars"]=function(){return(_PL_get_list_chars=Module["_PL_get_list_chars"]=Module["asm"]["jd"]).apply(null,arguments)};var _PL_quote=Module["_PL_quote"]=function(){return(_PL_quote=Module["_PL_quote"]=Module["asm"]["kd"]).apply(null,arguments)};var _PL_get_integer=Module["_PL_get_integer"]=function(){return(_PL_get_integer=Module["_PL_get_integer"]=Module["asm"]["ld"]).apply(null,arguments)};var _PL_get_long=Module["_PL_get_long"]=function(){return(_PL_get_long=Module["_PL_get_long"]=Module["asm"]["md"]).apply(null,arguments)};var _PL_get_int64=Module["_PL_get_int64"]=function(){return(_PL_get_int64=Module["_PL_get_int64"]=Module["asm"]["nd"]).apply(null,arguments)};var _PL_get_pointer=Module["_PL_get_pointer"]=function(){return(_PL_get_pointer=Module["_PL_get_pointer"]=Module["asm"]["od"]).apply(null,arguments)};var _PL_get_name_arity=Module["_PL_get_name_arity"]=function(){return(_PL_get_name_arity=Module["_PL_get_name_arity"]=Module["asm"]["pd"]).apply(null,arguments)};var _PL_get_compound_name_arity=Module["_PL_get_compound_name_arity"]=function(){return(_PL_get_compound_name_arity=Module["_PL_get_compound_name_arity"]=Module["asm"]["qd"]).apply(null,arguments)};var _PL_get_functor=Module["_PL_get_functor"]=function(){return(_PL_get_functor=Module["_PL_get_functor"]=Module["asm"]["rd"]).apply(null,arguments)};var _PL_get_arg=Module["_PL_get_arg"]=function(){return(_PL_get_arg=Module["_PL_get_arg"]=Module["asm"]["sd"]).apply(null,arguments)};var _PL_get_list=Module["_PL_get_list"]=function(){return(_PL_get_list=Module["_PL_get_list"]=Module["asm"]["td"]).apply(null,arguments)};var _PL_get_head=Module["_PL_get_head"]=function(){return(_PL_get_head=Module["_PL_get_head"]=Module["asm"]["ud"]).apply(null,arguments)};var _PL_get_tail=Module["_PL_get_tail"]=function(){return(_PL_get_tail=Module["_PL_get_tail"]=Module["asm"]["vd"]).apply(null,arguments)};var _PL_is_functor=Module["_PL_is_functor"]=function(){return(_PL_is_functor=Module["_PL_is_functor"]=Module["asm"]["wd"]).apply(null,arguments)};var _PL_put_atom_nchars=Module["_PL_put_atom_nchars"]=function(){return(_PL_put_atom_nchars=Module["_PL_put_atom_nchars"]=Module["asm"]["xd"]).apply(null,arguments)};var _PL_put_string_nchars=Module["_PL_put_string_nchars"]=function(){return(_PL_put_string_nchars=Module["_PL_put_string_nchars"]=Module["asm"]["yd"]).apply(null,arguments)};var _PL_put_chars=Module["_PL_put_chars"]=function(){return(_PL_put_chars=Module["_PL_put_chars"]=Module["asm"]["zd"]).apply(null,arguments)};var _PL_put_list_ncodes=Module["_PL_put_list_ncodes"]=function(){return(_PL_put_list_ncodes=Module["_PL_put_list_ncodes"]=Module["asm"]["Ad"]).apply(null,arguments)};var _PL_put_list_nchars=Module["_PL_put_list_nchars"]=function(){return(_PL_put_list_nchars=Module["_PL_put_list_nchars"]=Module["asm"]["Bd"]).apply(null,arguments)};var _PL_put_list_chars=Module["_PL_put_list_chars"]=function(){return(_PL_put_list_chars=Module["_PL_put_list_chars"]=Module["asm"]["Cd"]).apply(null,arguments)};var _PL_put_integer=Module["_PL_put_integer"]=function(){return(_PL_put_integer=Module["_PL_put_integer"]=Module["asm"]["Dd"]).apply(null,arguments)};var _PL_put_list=Module["_PL_put_list"]=function(){return(_PL_put_list=Module["_PL_put_list"]=Module["asm"]["Ed"]).apply(null,arguments)};var _PL_put_term=Module["_PL_put_term"]=function(){return(_PL_put_term=Module["_PL_put_term"]=Module["asm"]["Fd"]).apply(null,arguments)};var _PL_unify_functor=Module["_PL_unify_functor"]=function(){return(_PL_unify_functor=Module["_PL_unify_functor"]=Module["asm"]["Gd"]).apply(null,arguments)};var _PL_unify_list_ncodes=Module["_PL_unify_list_ncodes"]=function(){return(_PL_unify_list_ncodes=Module["_PL_unify_list_ncodes"]=Module["asm"]["Hd"]).apply(null,arguments)};var _PL_unify_list_nchars=Module["_PL_unify_list_nchars"]=function(){return(_PL_unify_list_nchars=Module["_PL_unify_list_nchars"]=Module["asm"]["Id"]).apply(null,arguments)};var _PL_unify_list_chars=Module["_PL_unify_list_chars"]=function(){return(_PL_unify_list_chars=Module["_PL_unify_list_chars"]=Module["asm"]["Jd"]).apply(null,arguments)};var _PL_unify_pointer=Module["_PL_unify_pointer"]=function(){return(_PL_unify_pointer=Module["_PL_unify_pointer"]=Module["asm"]["Kd"]).apply(null,arguments)};var _PL_unify_arg=Module["_PL_unify_arg"]=function(){return(_PL_unify_arg=Module["_PL_unify_arg"]=Module["asm"]["Ld"]).apply(null,arguments)};var _PL_unify_term=Module["_PL_unify_term"]=function(){return(_PL_unify_term=Module["_PL_unify_term"]=Module["asm"]["Md"]).apply(null,arguments)};var _PL_put_blob=Module["_PL_put_blob"]=function(){return(_PL_put_blob=Module["_PL_put_blob"]=Module["asm"]["Nd"]).apply(null,arguments)};var _PL_put_dict=Module["_PL_put_dict"]=function(){return(_PL_put_dict=Module["_PL_put_dict"]=Module["asm"]["Od"]).apply(null,arguments)};var _PL_term_type=Module["_PL_term_type"]=function(){return(_PL_term_type=Module["_PL_term_type"]=Module["asm"]["Pd"]).apply(null,arguments)};var _PL_context=Module["_PL_context"]=function(){return(_PL_context=Module["_PL_context"]=Module["asm"]["Qd"]).apply(null,arguments)};var _PL_module_name=Module["_PL_module_name"]=function(){return(_PL_module_name=Module["_PL_module_name"]=Module["asm"]["Rd"]).apply(null,arguments)};var _PL_predicate_info=Module["_PL_predicate_info"]=function(){return(_PL_predicate_info=Module["_PL_predicate_info"]=Module["asm"]["Sd"]).apply(null,arguments)};var _PL_call=Module["_PL_call"]=function(){return(_PL_call=Module["_PL_call"]=Module["asm"]["Td"]).apply(null,arguments)};var _PL_foreign_context=Module["_PL_foreign_context"]=function(){return(_PL_foreign_context=Module["_PL_foreign_context"]=Module["asm"]["Ud"]).apply(null,arguments)};var _PL_foreign_context_predicate=Module["_PL_foreign_context_predicate"]=function(){return(_PL_foreign_context_predicate=Module["_PL_foreign_context_predicate"]=Module["asm"]["Vd"]).apply(null,arguments)};var _PL_register_extensions_in_module=Module["_PL_register_extensions_in_module"]=function(){return(_PL_register_extensions_in_module=Module["_PL_register_extensions_in_module"]=Module["asm"]["Wd"]).apply(null,arguments)};var _PL_register_extensions=Module["_PL_register_extensions"]=function(){return(_PL_register_extensions=Module["_PL_register_extensions"]=Module["asm"]["Xd"]).apply(null,arguments)};var _PL_register_foreign=Module["_PL_register_foreign"]=function(){return(_PL_register_foreign=Module["_PL_register_foreign"]=Module["asm"]["Yd"]).apply(null,arguments)};var _PL_abort_hook=Module["_PL_abort_hook"]=function(){return(_PL_abort_hook=Module["_PL_abort_hook"]=Module["asm"]["Zd"]).apply(null,arguments)};var _PL_abort_unhook=Module["_PL_abort_unhook"]=function(){return(_PL_abort_unhook=Module["_PL_abort_unhook"]=Module["asm"]["_d"]).apply(null,arguments)};var _PL_dispatch_hook=Module["_PL_dispatch_hook"]=function(){return(_PL_dispatch_hook=Module["_PL_dispatch_hook"]=Module["asm"]["$d"]).apply(null,arguments)};var _PL_duplicate_record=Module["_PL_duplicate_record"]=function(){return(_PL_duplicate_record=Module["_PL_duplicate_record"]=Module["asm"]["ae"]).apply(null,arguments)};var _PL_action=Module["_PL_action"]=function(){return(_PL_action=Module["_PL_action"]=Module["asm"]["be"]).apply(null,arguments)};var _PL_query=Module["_PL_query"]=function(){return(_PL_query=Module["_PL_query"]=Module["asm"]["ce"]).apply(null,arguments)};var __PL_streams=Module["__PL_streams"]=function(){return(__PL_streams=Module["__PL_streams"]=Module["asm"]["de"]).apply(null,arguments)};var _PL_get_file_nameW=Module["_PL_get_file_nameW"]=function(){return(_PL_get_file_nameW=Module["_PL_get_file_nameW"]=Module["asm"]["ee"]).apply(null,arguments)};var _WASM_ttymode=Module["_WASM_ttymode"]=function(){return(_WASM_ttymode=Module["_WASM_ttymode"]=Module["asm"]["fe"]).apply(null,arguments)};var _WASM_variable_id=Module["_WASM_variable_id"]=function(){return(_WASM_variable_id=Module["_WASM_variable_id"]=Module["asm"]["ge"]).apply(null,arguments)};var _WASM_yield_request=Module["_WASM_yield_request"]=function(){return(_WASM_yield_request=Module["_WASM_yield_request"]=Module["asm"]["he"]).apply(null,arguments)};var _WASM_set_yield_result=Module["_WASM_set_yield_result"]=function(){return(_WASM_set_yield_result=Module["_WASM_set_yield_result"]=Module["asm"]["ie"]).apply(null,arguments)};var _js_unify_obj=Module["_js_unify_obj"]=function(){return(_js_unify_obj=Module["_js_unify_obj"]=Module["asm"]["je"]).apply(null,arguments)};var _js_get_obj=Module["_js_get_obj"]=function(){return(_js_get_obj=Module["_js_get_obj"]=Module["asm"]["ke"]).apply(null,arguments)};var ___funcs_on_exit=Module["___funcs_on_exit"]=function(){return(___funcs_on_exit=Module["___funcs_on_exit"]=Module["asm"]["le"]).apply(null,arguments)};var _fflush=Module["_fflush"]=function(){return(_fflush=Module["_fflush"]=Module["asm"]["me"]).apply(null,arguments)};var _emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=function(){return(_emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=Module["asm"]["ne"]).apply(null,arguments)};var _setThrew=Module["_setThrew"]=function(){return(_setThrew=Module["_setThrew"]=Module["asm"]["oe"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["pe"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["qe"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["re"]).apply(null,arguments)};function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiji(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ij(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;Module["addRunDependency"]=addRunDependency;Module["removeRunDependency"]=removeRunDependency;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;Module["cwrap"]=cwrap;Module["setValue"]=setValue;Module["getValue"]=getValue;Module["intArrayFromString"]=intArrayFromString;Module["FS"]=FS;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["allocate"]=allocate;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();const class_var=class PrologVar{constructor(id){this.$t="v";if(id!==undefined)this.v=id}};const class_string=class PrologString{constructor(string){this.$t="s";this.v=string}toString(){return this.v}toJSON(){return this.v}};const class_rational=class PrologRational{constructor(n,d){this.$t="r";this.n=n;this.d=d}toNumber(){return Number(this.d)/Number(this.n)}toString(){return this.d+"r"+this.n}toJSON(){return this.toString()}};const class_compound=class PrologCompound{constructor(name,args){this.$t="t";this.functor=name;this[name]=args}arguments(){return this[this.functor]}arg(n){return this.arguments[n]}arity(){return this.arguments.length}toJSON(){const obj={$t:"t"};obj[this.functor]=this.arguments();return obj}};const class_list=class PrologList{constructor(array,tail){this.$t="l";this.v=array;if(tail!==undefined)this.t=tail}};const class_blob=class PrologBlob{constructor(){this.$t="b"}};const class_abortable_promise=class AbortablePromise extends Promise{constructor(executer){super(executer);this.executer=executer}abort(){if(this.executer.abort)return this.executer.abort();else console.log("Cannot abort promise");return false}};class Prolog{constructor(module,args){this.module=module;this.args=args;this.lastyieldat=0;this.functor_arg_names_={};this.objects={};this.object_ids=new WeakMap;this.next_object_id=0;this.open_queries=[];this.__set_foreign_constants();this.__bind_foreign_functions();this.__export_classes();this.__initialize()}__initialize(){let argv0=this.args||[];argv0.unshift("swipl");let argv=argv0.map(function(arg){return this.module.allocate(this.module.intArrayFromString(arg),"i8",this.module.ALLOC_NORMAL)},this);var ptr=this.module._malloc(argv.length*4);argv.forEach(function(arg,i){this.module.setValue(ptr+i*4,arg,"*")},this);if(!this.bindings.PL_initialise(argv.length,ptr)){throw new Error("SWI-Prolog initialisation failed.")}this.MODULE_user=this.new_module("user");this.call("set_prolog_flag(color_term, false).");this.call("set_prolog_flag(debug_on_error, false)");this.call("use_module(library(wasm))")}__export_classes(){this.Var=class_var;this.String=class_string;this.Rational=class_rational;this.Compound=class_compound;this.List=class_list;this.Blob=class_blob;this.Promise=class_abortable_promise}__set_foreign_constants(){this.PL_VARIABLE=1;this.PL_ATOM=2;this.PL_INTEGER=3;this.PL_RATIONAL=4;this.PL_FLOAT=5;this.PL_STRING=6;this.PL_TERM=7;this.PL_NIL=8;this.PL_BLOB=9;this.PL_LIST_PAIR=10;this.PL_FUNCTOR=11;this.PL_LIST=12;this.PL_CHARS=13;this.PL_POINTER=14;this.PL_CODE_LIST=15;this.PL_CHAR_LIST=16;this.PL_BOOL=17;this.PL_FUNCTOR_CHARS=18;this._PL_PREDICATE_INDICATOR=19;this.PL_SHORT=20;this.PL_INT=21;this.PL_LONG=22;this.PL_DOUBLE=23;this.PL_NCHARS=24;this.PL_UTF8_CHARS=25;this.PL_UTF8_STRING=26;this.PL_INT64=27;this.PL_NUTF8_CHARS=28;this.PL_NUTF8_CODES=29;this.PL_NUTF8_STRING=30;this.PL_NWCHARS=31;this.PL_NWCODES=32;this.PL_NWSTRING=33;this.PL_MBCHARS=34;this.PL_MBCODES=35;this.PL_MBSTRING=36;this.PL_INTPTR=37;this.PL_CHAR=38;this.PL_CODE=39;this.PL_BYTE=40;this.PL_PARTIAL_LIST=41;this.PL_CYCLIC_TERM=42;this.PL_NOT_A_LIST=43;this.PL_DICT=44;this.REP_ISO_LATIN_1=0;this.REP_UTF8=1048576;this.REP_MB=2097152;this.REP_FN=this.REP_UTF8;this.CVT_ATOM=1;this.CVT_STRING=2;this.CVT_LIST=4;this.CVT_INTEGER=8;this.CVT_RATIONAL=16;this.CVT_FLOAT=32;this.CVT_VARIABLE=64;this.CVT_NUMBER=this.CVT_INTEGER|this.CVT_RATIONAL|this.CVT_FLOAT;this.CVT_ATOMIC=this.CVT_NUMBER|this.CVT_ATOM|this.CVT_STRING;this.CVT_WRITE=128;this.CVT_WRITE_CANONICAL=256;this.CVT_WRITEQ=512;this.CVT_ALL=this.CVT_ATOMIC|this.CVT_LIST;this.CVT_MASK=4095;this.CVT_EXCEPTION=4096;this.CVT_VARNOFAIL=8192;this.BUF_DISCARDABLE=0;this.BUF_STACK=65536;this.BUF_MALLOC=131072;this.BUF_ALLOW_STACK=262144;this.PL_Q_NORMAL=2;this.PL_Q_NODEBUG=4;this.PL_Q_CATCH_EXCEPTION=8;this.PL_Q_PASS_EXCEPTION=16;this.PL_Q_ALLOW_YIELD=32;this.PL_Q_EXT_STATUS=64;this.PL_S_EXCEPTION=-1;this.PL_S_FALSE=0;this.PL_S_TRUE=1;this.PL_S_LAST=2;this.PL_S_YIELD=255;this.PL_WRT_QUOTED=1;this.PL_WRT_NEWLINE=8192}__bind_foreign_functions(){this.bindings={_PL_streams:this.module.cwrap("_PL_streams","number",[]),PL_functor_arity:this.module.cwrap("PL_functor_arity","number",["number"]),PL_functor_name:this.module.cwrap("PL_functor_name","number",["number"]),PL_get_functor:this.module.cwrap("PL_get_functor","number",["number","number"]),PL_get_chars:this.module.cwrap("PL_get_chars","number",["number","number","number"]),PL_get_arg:this.module.cwrap("PL_get_arg","number",["number","number","number"]),PL_get_int64:this.module.cwrap("PL_get_int64","number",["number","number"]),PL_get_float:this.module.cwrap("PL_get_float","number",["number","number"]),PL_put_chars:this.module.cwrap("PL_put_chars","number",["number","number","number","number"]),put_bytes:this.module.cwrap("PL_put_chars","number",["number","number","number","array"]),PL_put_atom:this.module.cwrap("PL_put_atom","number",["number"]),PL_put_variable:this.module.cwrap("PL_put_variable","number",["number"]),PL_unify:this.module.cwrap("PL_unify","number",["number","number"]),PL_is_string:this.module.cwrap("PL_is_string","number",["number"]),PL_is_variable:this.module.cwrap("PL_is_variable","number",["number"]),PL_term_type:this.module.cwrap("PL_term_type","number",["number"]),PL_get_list:this.module.cwrap("PL_get_list","number",["number","number","number"]),PL_get_nil:this.module.cwrap("PL_get_nil","number",["number"]),PL_initialise:this.module.cwrap("PL_initialise","number",["number","number"]),PL_new_atom:this.module.cwrap("PL_new_atom","number",["string"]),PL_register_atom:this.module.cwrap("PL_register_atom",null,["number"]),PL_unregister_atom:this.module.cwrap("PL_unregister_atom",null,["number"]),PL_new_module:this.module.cwrap("PL_new_module","number",["number"]),PL_new_functor:this.module.cwrap("PL_new_functor","number",["number","number"]),PL_new_term_ref:this.module.cwrap("PL_new_term_ref","number",[]),PL_new_term_refs:this.module.cwrap("PL_new_term_refs","number",["number"]),PL_copy_term_ref:this.module.cwrap("PL_copy_term_ref","number",["number"]),PL_reset_term_refs:this.module.cwrap("PL_reset_term_refs",null,["number"]),PL_put_functor:this.module.cwrap("PL_put_functor","number",["number","number"]),PL_put_integer:this.module.cwrap("PL_put_integer","number",["number","number"]),PL_put_float:this.module.cwrap("PL_put_float","number",["number","number"]),PL_put_nil:this.module.cwrap("PL_put_nil","number",[]),PL_cons_functor_v:this.module.cwrap("PL_cons_functor_v","number",["number","number","number"]),PL_cons_list:this.module.cwrap("PL_cons_list","number",["number","number","number"]),PL_put_dict:this.module.cwrap("PL_put_dict","number",["number","number","number","number","number"]),PL_put_term_from_chars:this.module.cwrap("PL_put_term_from_chars","number",["number","number","number","string"]),PL_put_term:this.module.cwrap("PL_put_term","number",["number","number"]),PL_write_term:this.module.cwrap("PL_write_term","number",["number","number","number","number"]),PL_call:this.module.cwrap("PL_call","number",["number","number"]),PL_open_foreign_frame:this.module.cwrap("PL_open_foreign_frame","number",[]),PL_close_foreign_frame:this.module.cwrap("PL_close_foreign_frame","number",["number"]),PL_discard_foreign_frame:this.module.cwrap("PL_close_foreign_frame","number",["number"]),PL_predicate:this.module.cwrap("PL_predicate","number",["number","number","number"]),PL_open_query:this.module.cwrap("PL_open_query","number",["number","number","number","number"]),PL_next_solution:this.module.cwrap("PL_next_solution","number",["number"]),PL_close_query:this.module.cwrap("PL_close_query","number",["number"]),PL_cut_query:this.module.cwrap("PL_cut_query","number",["number"]),PL_exception:this.module.cwrap("PL_exception","number",["number"]),PL_raise_exception:this.module.cwrap("PL_raise_exception","number",["number"]),WASM_ttymode:this.module.cwrap("WASM_ttymode","number",[]),WASM_yield_request:this.module.cwrap("WASM_yield_request","number",[]),WASM_set_yield_result:this.module.cwrap("WASM_set_yield_result","number",["number"]),WASM_variable_id:this.module.cwrap("WASM_variable_id","number",["number"]),js_unify_obj:this.module.cwrap("js_unify_obj","number",["number","number"]),js_get_obj:this.module.cwrap("js_get_obj","number",["number"])}}call(goal,opts){opts=opts||{};if(typeof goal==="string"){if(opts.async){return this.__call_yieldable(goal,opts)}else{return this.with_frame(function(){const term=this.new_term_ref();if(!this.chars_to_term(goal,term))throw new Error("Query has a syntax error: "+query);const module=opts.module?this.new_module(opts.module):this.MODULE_user;return!!this.bindings.PL_call(term,module)})}}}with_frame(f,persist){const fid=this.bindings.PL_open_foreign_frame();if(fid){const rc=f.call(this);if(persist===false)this.bindings.PL_discard_foreign_frame(fid);else this.bindings.PL_close_foreign_frame(fid);return rc}return false}__string_to_c(string){const len=this.module.lengthBytesUTF8(string);const ptr=this.module._malloc(len+1);this.module.stringToUTF8(string,ptr,len+1);return{ptr:ptr,length:len}}predicate(name,arity,module){if(arity===undefined){let ar=/^([^:]+):(.*)\/([0-9]+)$/.exec(name);if(ar){module=ar[1];name=ar[2];arity=parseInt(ar[3])}else{ar=/(.*)\/([0-9]+)$/.exec(name);if(ar){name=ar[1];arity=parseInt(ar[2])}}if(arity===undefined)throw`Prolog.predicate: illegal specification: ${name}`}const c_name=allocateUTF8(name);const c_module=allocateUTF8(module||"user");const pred=this.bindings.PL_predicate(c_name,arity,c_module);this.module._free(c_name);this.module._free(c_module);return pred}new_module(name){const c_atom=this.new_atom(name);const module=this.bindings.PL_new_module(c_atom);this.unregister_atom(c_atom);return module}consult(...args){return this.forEach("load_files(user:Files)",{Files:args})}load_string(s,id){if(!id){this.__script_id=this.__script_id+1||1;id="/string/"+this.__script_id}return this.forEach("setup_call_cleanup("+"open_string(S, _In),"+"load_files(user:Id, [stream(_In)]),"+"close(_In))",{S:new this.String(s),Id:id})}async load_scripts(){const prolog=this;const scripts=document.querySelectorAll("script[type='text/prolog']");const loaded=[];for(let i=0;i{prolog.query(goal,{Event__:ev}).once()})}fetch(url,opts,type){return fetch(url,opts).then(response=>response[type]())}url_properties(url){return fetch(url,{method:"HEAD"}).then(r=>{if(r.status==200){const size=parseInt(r.headers.get("content-length"));const mods=r.headers.get("last-modified");const time=Date.parse(mods)||0;if(!size instanceof Number)size=-1;return{url:r.url,status:r.status,size:size,last_modified:time/1e3}}else{return{url:url,status:r.status}}})}message_to_string(term){return this.with_frame(()=>{const av=this.new_term_ref(2);this.bindings.PL_put_term(av+0,term);const flags=this.PL_Q_NORMAL;const pred=this.predicate("message_to_string/2");const qid=this.bindings.PL_open_query(0,flags,pred,av);let msg;if(this.bindings.PL_next_solution(qid))msg=this.get_chars(av+1);else msg="Unknown Prolog exception";this.bindings.PL_close_query(qid);return msg},false)}flush_output(stream){if(stream==undefined){flush("stderr");flush("stdout")}else{flush(stream)}}log(...args){log_output("stdout",args)}query(module,flags,pred,argv,map,fid){if(typeof argv==="number"){return new Query(this,module,flags,pred,argv,map)}else if(typeof module==="string"&&pred===undefined){const goal=module;const fid=this.bindings.PL_open_foreign_frame();const av=this.new_term_ref(3);const input=flags||{};this.frame=fid;this.put_chars(av+0,goal);this.toProlog(input,av+1);const q=new Query(this,0,this.PL_Q_CATCH_EXCEPTION,"wasm_call_string/3",av,a=>this.toJSON(a+2));q.from_text=true;return q}}forEach(goal,...args){const prolog=this;const fid=this.bindings.PL_open_foreign_frame();const av=this.new_term_ref(3);let callback;let input;if(typeof args[0]==="object"){input=args[0];callback=args[1]}else{input={};callback=args[0]}if(callback!==undefined&&typeof callback!=="function")throw TypeError("callback must be a function");this.frame=fid;this.put_chars(av+0,goal);this.toProlog(input,av+1);const q=new Query(this,this.MODULE_user,this.PL_Q_ALLOW_YIELD|this.PL_Q_CATCH_EXCEPTION,"wasm_call_string_with_heartbeat/3",av,a=>this.toJSON(a+2));return new Promise(function(resolve,reject){let answers=callback?0:[];function next_foreach(rc){while(true){if(rc.yield!==undefined){switch(rc.yield){case"beat":return setTimeout(()=>next_foreach(rc.resume("true")),0);case"builtin":return rc.resume(rc=>next_foreach(rc));default:throw rc}}else if(rc.value){if(callback){answers++;callback.call(prolog,rc.value)}else{answers.push(rc.value)}if(rc.done==false){rc=q.next_yieldable();continue}}q.close();if(rc.error)return reject(rc.message);if(rc.done)return resolve(answers)}}return next_foreach(q.next_yieldable())})}abort(){this.abort_request=true}promise_sleep(time){const f=function(resolve,reject){f.reject=reject;f.timer=setTimeout(()=>{f.timer=undefined;resolve(true)},time*1e3)};f.abort=function(){if(f.timer){clearTimeout(f.timer);f.timer=undefined;f.reject("abort")}};return new this.Promise(f)}stream(name){const iob=this.bindings._PL_streams();let offset=undefined;switch(name){case"user_input":offset=0;break;case"user_output":offset=1;break;case"user_error":offset=2;break;default:throw`Unknown stream ${name}`}return this.module.getValue(iob+offset*4,"i32")}write(term,opts){opts=opts||{};const precedence=opts.precedence||1200;const flags=opts.flags==undefined?this.PL_WRT_QUOTED|this.PL_WRT_NEWLINE:flags;let s=undefined;if(opts.stream){if(typeof stream==="string")s=this.stream(opts.stream)}else{s=this.stream("user_output")}return this.bindings.PL_write_term(s,term,precedence,flags)}functor_arity(functor){return this.bindings.PL_functor_arity(functor)}functor_name(functor){return this.bindings.PL_functor_name(functor)}get_functor(term){const ptr=this.module._malloc(4);let result;if(this.bindings.PL_get_functor(term,ptr))result=this.module.getValue(ptr,"i32");else result=null;this.module._free(ptr);return result}get_integer(term){const ptr=this.module._malloc(8);let rc;if(this.bindings.PL_get_int64(term,ptr)){rc=this.module.getValue(ptr,"i64");if(rc>=Number.MIN_SAFE_INTEGER&&rc<=Number.MAX_SAFE_INTEGER)rc=Number(rc)}else{const s=this.get_chars(term,this.CVT_INTEGER);rc=BigInt(s)}this.module._free(ptr);return rc}get_float(term){const ptr=this.module._malloc(8);let rc;if(this.bindings.PL_get_float(term,ptr)){rc=this.module.getValue(ptr,"double")}else{rc=null}this.module._free(ptr);return rc}put_chars(term,string,flags){flags=flags||this.PL_STRING;flags|=this.REP_UTF8;const c=this.__string_to_c(string);const ret=!!this.bindings.PL_put_chars(term,flags,c.length,c.ptr);this.module._free(c.ptr);return ret}put_bytes(term,array_buffer){const content=new Uint8Array(array_buffer);return!!this.bindings.put_bytes(term,this.PL_STRING|this.REP_ISO_LATIN_1,content.length,content)}put_bigint(term,value){const s=value.toString();return this.bindings.PL_put_term_from_chars(term,this.REP_UTF8,-1,s)}unify(term1,term2){return!!this.bindings.PL_unify(term1,term2)}is_string(term){return!!this.bindings.PL_is_string(term)}is_variable(term){return!!this.bindings.PL_is_variable(term)}atom_chars(atom){const t=this.new_term_ref();this.bindings.PL_put_atom(t,atom);const str=this.get_chars(t,this.CVT_ATOM);this.bindings.PL_reset_term_refs(t);return str}ttymode(){return this.module.UTF8ToString(this.bindings.WASM_ttymode())}yield_request(){const tref=this.bindings.WASM_yield_request();return this.toJSON(tref)}set_yield_result(obj){this.with_frame(()=>{const term=this.toProlog(obj,undefined,{string:"string"});if(!term){console.log("Could not convert",obj);throw"Could not convert JavaScript data to Prolog"}this.bindings.WASM_set_yield_result(term)},true)}__call_yieldable(goal,module){var pred_call1;const flags=this.PL_Q_NORMAL|this.PL_Q_ALLOW_YIELD;if(!pred_call1)pred_call1=this.predicate("call",1,"system");const fid=this.bindings.PL_open_foreign_frame();const term=this.new_term_ref();if(!this.chars_to_term(goal,term))throw new Error("Query has a syntax error: "+query);const q=this.query(module,flags,pred_call1,term,fid);return q.next_yieldable()}set_arg_names(name,args){if(!this.functor_arg_names_[name])this.functor_arg_names_[name]={};this.functor_arg_names_[name][args.length]=args}arg_names(name,arity){if(this.functor_arg_names_[name])return this.functor_arg_names_[name][arity]}toJSON(term,options){options=options||{};function toJSON(prolog,term,options){switch(prolog.bindings.PL_term_type(term)){case prolog.PL_VARIABLE:return new prolog.Var(prolog.bindings.WASM_variable_id(term));case prolog.PL_STRING:if(options.string!=="string")return new prolog.String(prolog.get_chars(term));case prolog.PL_ATOM:return prolog.get_chars(term);case prolog.PL_NIL:return[];case prolog.PL_BLOB:{const id=prolog.bindings.js_get_obj(term);if(id!=-1)return prolog.objects[id];return new prolog.Blob}case prolog.PL_INTEGER:return prolog.get_integer(term);case prolog.PL_RATIONAL:{let s=prolog.get_chars(term,prolog.CVT_RATIONAL);let a=s.split("r");function toInt(s){const bi=BigInt(s);if(bi>=Number.MIN_SAFE_INTEGER&&bi<=Number.MAX_SAFE_INTEGER)return Number(bi);return bi}return new prolog.Rational(toInt(a[0]),toInt(a[1]))}case prolog.PL_FLOAT:return prolog.get_float(term);case prolog.PL_TERM:{const f=prolog.get_functor(term);const name=prolog.atom_chars(prolog.functor_name(f));const arity=prolog.functor_arity(f);const map=prolog.arg_names(name,arity);const a=prolog.new_term_ref();if(map){let result={$tag:name};for(var i=0;i=0&&rc;i--){rc=toProlog(prolog,data[i],h,ctx)&&prolog.bindings.PL_cons_list(term,h,term)}return rc}switch(typeof data){case"number":if(Number.isInteger(data))rc=prolog.bindings.PL_put_integer(term,data);else rc=prolog.bindings.PL_put_float(term,data);break;case"bigint":rc=prolog.put_bigint(term,data);break;case"string":{const flags=ctx.string==="string"?prolog.PL_STRING:prolog.PL_ATOM;rc=prolog.put_chars(term,data,flags);break}case"boolean":rc=prolog.put_chars(term,data?"true":"false",prolog.PL_ATOM);break;case"undefined":rc=prolog.put_chars(term,"undefined",prolog.PL_ATOM);break;case"object":if(data===null){rc=prolog.put_chars(term,"null",prolog.PL_ATOM)}else if(Array.isArray(data)){rc=toList(term,data)}else if(data.$t){switch(data.$t){case"s":rc=prolog.put_chars(term,data.v,prolog.PL_STRING);break;case"r":{const s=data.n+"r"+data.d;rc=prolog.bindings.PL_put_term_from_chars(term,prolog.REP_UTF8,-1,s);break}case"t":{const keys=Object.keys(data);let args;let name;for(var i=0;i{prolog.set_yield_result(value);return this.next()}}}}}next_yieldable(){function next(query){const prolog=query.prolog;while(true){let rc=query.next();if(rc.yield!==undefined){let request=rc.yield;if(prolog.abort_request){prolog.abort_request=undefined;prolog.set_yield_result("abort");continue}if(request==="beat"){const now=Date.now();const passed=now-prolog.lastyieldat;if(passed<20){prolog.set_yield_result("true");continue}prolog.lastyieldat=now}else if(request instanceof Promise){let result={yield:"builtin",request:request,query:query,resume:cont=>{if(typeof cont==="string"){prolog.set_yield_result(cont);return next(query)}else{result.cont=cont;request.then(value=>{prolog.set_yield_result(value);cont.call(prolog,next(query))}).catch(error=>{prolog.set_yield_result({$error:error});cont.call(prolog,next(query))})}},abort:()=>{if(!(request.abort&&request.abort())){console.log("Cannot abort",request);prolog.abort_request=true}}};return result}rc.resume=value=>{prolog.set_yield_result(value);return next(query)}}else if(rc.done===false){rc.resume=()=>next(query)}return rc}}return next(this)}once(){const rc=this.next();this.close();if(this.from_text){delete rc.done;if(rc.value){rc.value.success=true;return rc.value}else{if(!rc.error)rc.success=false;return rc}}else{return rc.value?rc.value:rc}}close(){if(this.open){const prolog=this.prolog;if(this!=prolog.open_queries.at(-1))console.log("Attempt for Query.close() on not innermost query");prolog.open_queries.pop();this.prolog.bindings.PL_cut_query(this.qid);if(this.frame)this.prolog.bindings.PL_discard_foreign_frame(this.frame);this.open=false}}}Module.onRuntimeInitialized=function(){Module.prolog=new Prolog(Module,Module.arguments)};function prolog_js_call(request,result){const prolog=Module.prolog;function eval_chain(ar,obj){obj=obj||window;function eval_one(obj,fname,args){if(args.length==0){switch(fname){case"instanceof":return obj.constructor.name}}else if(args.length==1){switch(fname){case"-":return-args[0];case"!":return!args[0];case"instanceof":return obj instanceof args[0]}}else if(args.length==2){switch(fname){case"+":return args[0]+args[1];case"-":return args[0]-args[1];case"*":return args[0]*args[1];case"/":return args[0]/args[1];case"&":return args[0]&args[1];case"|":return args[0]|args[1];case"&&":return args[0]&&args[1];case"||":return args[0]||args[1]}}const func=obj[fname];if(typeof func==="function")return func.apply(obj,args);else console.log("ERROR: Function",fname,"is not defined on",obj)}for(let i=0;ieval_chain(v));obj=eval_one(obj,next.f,args)}}return obj}try{return prolog.with_frame(()=>{const ar=prolog.toJSON(request,{string:"string"});let obj;if(ar.setter){const target=eval_chain(ar.target);const value=eval_chain(ar.value);target[ar.setter]=value;obj=true}else{obj=eval_chain(ar)}return prolog.unify(result,prolog.toProlog(obj))},false)}catch(e){return prolog.bindings.PL_raise_exception(prolog.toProlog(new prolog.Compound("error",[new prolog.Compound("js_error",[e.toString()]),new prolog.Var])))}}function prolog_js_obj_class_name(id){const prolog=Module.prolog;const obj=prolog.objects[id];return obj.constructor.name}function release_registered_object(id){const prolog=Module.prolog;const obj=prolog.objects[id];prolog.object_ids.delete(obj);delete prolog.objects[id]}if(BigInt.prototype.toJSON===undefined){BigInt.prototype.toJSON=function(){return this.toString()}}if(typeof HTMLCollection==="object"){HTMLCollection.prototype.toList=function(){const ar=[];for(let i=0;i - - - - - - - - - Hello world! - - - \ No newline at end of file diff --git a/lib/eyebrow/test/test_input.html b/lib/eyebrow/test/test_input.html deleted file mode 100644 index 87b4447..0000000 --- a/lib/eyebrow/test/test_input.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - -
              - - - - - - - \ No newline at end of file diff --git a/lib/gen_link.js b/lib/gen_link.js index 3e2511a..31e47d7 100644 --- a/lib/gen_link.js +++ b/lib/gen_link.js @@ -1,31 +1,27 @@ -const mysqlx = require('@mysql/xdevapi'); -const randomstring = require("randomstring"); -const dateFormat = require('dateformat'); +const mysql = require("mysql") +const randomstring = require("randomstring") +const dateFormat = require('dateformat') const { config } = require('../config.js') -exports.generateLink = async function(formula, format) { - const session = await getDbConn() - const table = session.getSchema('n3_links').getTable('link') - - const id = await generateUniqueId(table) +exports.generateLink = async function (formula, format) { + const conn = await getDbConn() + + const id = await generateUniqueId(conn) // console.log("unique id?", id) - - await insertId(id, formula, format, table) - return id; + + await insertId(id, formula, format, conn) + return id } -exports.resolveLink = async function(id) { - const session = await getDbConn() - const table = session.getSchema('n3_links').getTable('link') - - // console.log("retrieving:", id) - - results = await getLink(id, table) - const result = results.fetchOne() - if (!result) +exports.resolveLink = async function (id) { + const conn = await getDbConn() + + let results = await getLink(id, conn) + if (results.length == 0) throw "link " + id + " does not exist" else { - var field = result[0] + const result = results[0] + var field = result.url if (field.startsWith("http")) { // url-encode hash symbol so we can work with url search params field = field.replace(/#/g, "%23"); @@ -50,53 +46,63 @@ exports.resolveLink = async function(id) { } function getDbConn() { - let dbc = config.link.db - return mysqlx.getSession({ - user: dbc.user, - password: dbc.pwd, - host: dbc.host, - port: dbc.port + return mysql.createPool({ + host: config.link.db.host, + user: config.link.db.user, + password: config.link.db.pwd, + database: config.link.db.db }) } -async function generateUniqueId(table) { +async function generateUniqueId(conn) { const id = ranString() // console.log("id?", id) - const exists = await checkId(id, table) + const exists = await checkId(id, conn) // console.log("exists?", exists) if (exists) - return generateUniqueId(table) + return generateUniqueId(conn) else - return id; + return id } -function checkId(id, table) { - return new Promise((resFn, rejFn) => - table - .select([ 'url' ]) - .where("id = :id") - .bind('id', id) - .execute() - .then((results) => resFn(results.fetchOne() !== undefined)) - .catch((error) => rejFn(error)) +function checkId(id, conn) { + return new Promise((resFn, rejFn) => + conn.query("SELECT url FROM link WHERE id = ?", [id], + (error, results) => { + if (error) + rejFn(error) + else + resFn(results.length > 0) + }) ) } -function insertId(id, formula, format, table) { - const time = dateFormat(new Date(), "yyyy-mm-dd hh:MM:ss"); - return table - .insert('id', 'url', 'time') - .values(id, format + "-" + formula, time) - .execute() +function insertId(id, formula, format, conn) { + return new Promise((resFn, rejFn) => { + const time = dateFormat(new Date(), "yyyy-mm-dd hh:MM:ss") + conn.query( + "INSERT INTO link (id, url, time) VALUES (?, ?, ?)", + [id, format + "-" + formula, time], (error, results) => { + if (error) + rejFn(error) + else + resFn(results) + }) + }); } -function getLink(id, table) { - return table - .select([ 'url' ]) - .where("id = :id") - .bind('id', id) - .execute() +function getLink(id, conn) { + return new Promise((resFn, rejFn) => + conn.query("SELECT url FROM link WHERE id = ?", [id], + (error, results) => { + if (error) + rejFn(error) + else + resFn(results) + }) + // return conn.query(`SELECT url FROM link WHERE id = '${id}'`) + ); } function ranString() { diff --git a/lib/jen3/codegen.jar b/lib/jen3/codegen.jar index 2fa753f..ac54db5 100644 Binary files a/lib/jen3/codegen.jar and b/lib/jen3/codegen.jar differ diff --git a/lib/jen3/jen3.jar b/lib/jen3/jen3.jar index fc79d7b..8055df6 100644 Binary files a/lib/jen3/jen3.jar and b/lib/jen3/jen3.jar differ diff --git a/lib/jen3/jen3.js b/lib/jen3/jen3.js index b08120c..de0f942 100644 --- a/lib/jen3/jen3.js +++ b/lib/jen3/jen3.js @@ -1,12 +1,12 @@ -var { exec } = require('child_process') +let { promiseExec } = require('../cmd_util.js') var prefix = require('../prefix_map.js') var { config } = require('../../config.js') -const jen3Exec = config.reasoners.jen3.exec; -const jen3Folder = config.reasoners.jen3.folder; -const jen3Codegen = config.reasoners.jen3.codegen; +const jen3Exec = config.tools.jen3.exec; +const jen3Folder = config.tools.jen3.folder; +const jen3Codegen = config.tools.jen3.codegen; -exports.exec = function(options, file, callback) { +exports.exec = async function(options, file) { let cmdOptions, jarFile; switch (options.task) { case 'derivations': @@ -31,16 +31,19 @@ exports.exec = function(options, file, callback) { break; } - var cmd = `java -jar ${jarFile} -n3 ${file} ${cmdOptions}`; - - console.log(cmd); - exec(cmd, (err, stdout, stderr) => { - if (stderr != "") { - callback({ error: stderr }) - - } else { - var output = prefix.collapse(stdout, file) - callback({ success: output }) - } - }) + const cmd = `java -jar ${jarFile} -n3 ${file} ${cmdOptions}`; + // console.log(cmd); + + let [ stdout, stderr ] = await promiseExec(cmd) + if (stderr != "") { + if (stderr.trim().startsWith("Picked up JAVA_TOOL_OPTIONS")) + stderr = stderr.substring(stderr.indexOf("\n") + 1).trim(); + + // console.log("stderr? ", stderr); + if (stderr) + throw stderr + } + + const output = prefix.collapse(stdout, file) + return output } diff --git a/lib/jena/jena.js b/lib/jena/jena.js new file mode 100644 index 0000000..ba3e793 --- /dev/null +++ b/lib/jena/jena.js @@ -0,0 +1,23 @@ +let { promiseExec } = require('../cmd_util.js') +var prefix = require('../prefix_map.js') +var { config } = require('../../config.js') + +const jenaExec = config.tools.jena.exec; + +exports.exec = async function(options, data, query) { + const cmd = `java -jar ${jenaExec} -n3 ${data} -query ${query}`; + // console.log(cmd); + + let [ stderr, stdout ] = await promiseExec(stdout, stderr) + if (stderr != "") { + if (stderr.trim().startsWith("Picked up JAVA_TOOL_OPTIONS")) + stderr = stderr.substring(stderr.indexOf("\n") + 1).trim(); + + // console.log("stderr? ", stderr); + if (stderr) + throw stderr + } + + const output = prefix.collapse(stdout, data) + return output +} diff --git a/lib/jena/sparql.jar b/lib/jena/sparql.jar new file mode 100644 index 0000000..94c9b27 Binary files /dev/null and b/lib/jena/sparql.jar differ diff --git a/lib/spin3/auxiliary-files/aux.n3 b/lib/spin3/auxiliary-files/aux.n3 new file mode 100644 index 0000000..04ee149 --- /dev/null +++ b/lib/spin3/auxiliary-files/aux.n3 @@ -0,0 +1,836 @@ +@prefix string: . +@prefix list: . +@prefix log: . +@prefix xsd: . +@prefix rdfs: . +@prefix spin: . +@prefix sp: . +@prefix ex: . +@prefix aux: . +@prefix math: . +@prefix time: . +@prefix crypto: . +@prefix rdf: . +@prefix e: . + + +################################################## +# create variable if needed (used in where clause and in select pattern) +################################################## + +{() aux:gets ()}<={ + true log:callWithCut true. + }. +{?s aux:gets ?s1}<={ ?s log:uri ?suri. + ?suri string:startsWith "http://spinrdf.org/". + ?s log:skolem ?s1. + true log:callWithCut true. + }. +{?s aux:gets ?s1}<={ ?s sp:varName ?name . ?name log:skolem ?s1. true log:callWithCut true. + }. +{?s aux:gets ?s1}<={ ?s sp:arg1 ?arg . ?s log:skolem ?s1. true log:callWithCut true. + }. +{?s aux:gets ?s1}<={ ?s sp:expression ?arg . ?s log:skolem ?s1. true log:callWithCut true. + }. +{?s aux:gets ?s}<={}. + + +################################################## +# translate where clause to n3 graph +################################################## +{ (?vars ?list) aux:createGraph ?graph}<={ +(?list ()) aux:flatten ?list2. +#1 e:trace {(?vars ?list) aux:createGraph ?graph}. +(?vars ?list2) aux:handleTriples ?graph1. +#2 e:trace {(?vars ?list2) aux:handleTriples ?graph1.}. +(?vars ?list2) aux:handlePropertyPath ?graph11. +#21 e:trace {(?vars ?list2) aux:handlePropertyPath ?graph11 .}. +(?vars ?list2) aux:handleFilter ?graph2. +#3 e:trace {(?vars ?list2) aux:handleFilter ?graph2.}. +(?vars ?list2) aux:handleUnion ?graph3. +#4 e:trace {(?vars ?list2) aux:handleUnion ?graph3.}. +(?vars ?list2) aux:handleBind ?graph4. +#5 e:trace {(?vars ?list2) aux:handleBind ?graph4.}. +(?vars ?list2) aux:handleOptional ?graph5. +# 6 e:trace {(?vars ?list2) aux:handleOptional ?graph5.}. +(?vars ?list2) aux:handleMinus ?graph6. +#7 e:trace {(?vars ?list2) aux:handleMinus ?graph6.}. +(?vars ?list2) aux:handleSubquery ?graph7. +#8 e:trace {(?vars ?list2) aux:handleSubquery ?graph7.}. + +(?graph1 ?graph11 ?graph2 ?graph3 ?graph4 ?graph5 ?graph6 ?graph7 +) log:conjunction ?graph + +}. + + + + +#create a graph from subject-predicate-object patterns +{(?vars ?list) aux:handleTriples ?graph }<={ + #normal triples + ({?s1 ?p1 ?o1}{?t list:in ?list. ?t sp:subject ?s; + sp:predicate ?p; + sp:object ?o. + ?s aux:gets ?s1. + ?p aux:gets ?p1. + ?o aux:gets ?o1. + } ?whereList) log:collectAllIn ?scope. + (?whereList ({})) list:append ?fl. + ?fl log:conjunction ?graph. + }. + +####################################### +# property paths +####################################### +{ + (?vars ?list) aux:handlePropertyPath ?graph +} +<= +{ + ({( ?s ?o ) aux:stepThroughPath ?steps} { + ?list list:member ?tp . + ?tp a sp:TriplePath ; + sp:path ?path . + ?tp sp:subject ?s1. ?s1 aux:gets ?s . + ?tp sp:object ?o1. ?o1 aux:gets ?o . + ?path aux:collectPathSteps ?steps . + } ?olist) log:collectAllIn ?scope. + (?olist ({})) list:append ?oolist. + ?oolist log:conjunction ?graph. +} . + + + + +# +{ ( ?s ?o ( ?pred 1 1 ) ) aux:propertyPathStep {?s ?pred ?o}}<= {} . +{ ( ?s ?o ( ?pred 0 -2 ) ) aux:propertyPathStep {( ?s ?o ) aux:optionalChain ?pred } }<= {} . +{ ( ?s ?o ( ?pred 1 -2 ) ) aux:propertyPathStep {( ?s ?o ) aux:chain ?pred}}<= {}. +{ ( ?s ?o ( ?pred 0 -1 ) ) aux:propertyPathStep {( ?s ?o ) aux:optional ?pred}}<= {} . + +# collect path steps for easier processing +# (also, flatten seq, alt paths) + +# +{ + ?x aux:collectPathSteps ?paths +} +<= +{ + ?x a sp:SeqPath ; + sp:path1 ?p1 ; + sp:path2 ?p2 . + # - flatten seq paths + ?p1 aux:collectPathSteps ?p1s . + ?p2 aux:collectPathSteps ?p2s . + ( ?p1s ?p2s ) list:append ?paths . +} . + +# +{ + ?x aux:collectPathSteps ( ( ?ps "rev" ) ) +} +<= +{ + ?x a sp:ReversePath ; + sp:subPath ?p . + ?p aux:collectPathSteps ?ps . +} . + +# +{ + ?x aux:collectPathSteps ( ( ?p1s ?p2s ) "alt" ) +} +<= +{ + ?x a sp:AltPath ; + sp:path1 ?p1 ; + sp:path2 ?p2 . + # - flatten alt paths + ?p1 aux:collectPathSteps ?p1s . + ?p2 aux:collectPathSteps ?p2s . +} . + +# +{ + ?x aux:collectPathSteps ( ( ?ps ?min ?max ) ) +} +<= +{ + ?x a sp:ModPath ; + sp:subPath ?p ; + sp:modMin ?min ; + sp:modMax ?max . + ?p aux:collectPathSteps ?ps . +} . + +# +{ + ?x aux:collectPathSteps ( ?cells "neg" ) +} +<= +{ + ?x a sp:NegatedPath ; + sp:subPath ?options . + ( + ( ?node ?type ) + { + ?option list:in ?options . + ?option a ?type ; + sp:node ?node + } + ?cells + ) log:collectAllIn _:t . +} . + +# +{ + ?x aux:collectPathSteps ( ( ?x 1 1 ) ) +} +<= +{ + ?x log:rawType log:Other . + ?x!log:uri string:notMatches "http://spinrdf.org/sp#(SeqPath|AltPath|ModPath|NegatedPath)" . +} . + + +######################## +# filter +####################### + {(?vars ?list) aux:handleFilter ?graph }<={ + (?tr2 {?t list:in ?list. ?t a sp:Filter ; + aux:getFunctionTriples ?tr. + (?vars ?tr ?t) aux:relabelGraph ?tr2. + } ?filterList) log:collectAllIn ?scope. + (?filterList ({})) list:append ?fl. + ?fl log:conjunction ?graph. + # (?vars ?graph1) aux:relabelGraph ?graph. +}. + + +########################################## +# union +########################################### +{(?vars ?list) aux:handleUnion ?graph}<={ + (?t {?t list:in ?list. ?t a sp:Union .} ?uList) log:collectAllIn ?scope. + (?uList {}) aux:createUGraph ?graph. + + }. + +{ (() ?graph) aux:createUGraph ?graph.}<={}. + +{(?uList ?ingraph ) aux:createUGraph ?graph.}<={ + ?uList rdf:first ?t. + ?t sp:elements ?elist. + ?et list:in ?elist. + (?vars ?et) aux:handleTriples ?tr. + ?uList rdf:rest ?rest. + (?ingraph ?tr) log:conjunction ?newgraph. + (?rest ?newgraph ) aux:createUGraph ?graph. + }. + +########################################## +# optional +########################################### +{(?vars ?list) aux:handleOptional ?graph}<={ + (?t {?t list:in ?list. ?t a sp:Optional .} ?oList) log:collectAllIn ?scope. + (?vars ?oList {}) aux:createOGraph ?graph. + + }. + +{ (?vars () ?graph) aux:createOGraph ?graph.}<={}. + +{(?vars ?oList ?ingraph ) aux:createOGraph ?graph.}<={ + ?oList rdf:first ?t. + ?oList rdf:rest ?rest. + ?t sp:elements ?elist. + (?vars ?elist) aux:createGraph ?gr. + ({true log:callWithOptional ?gr } ?ingraph ) log:conjunction ?newgraph. +(?vars ?rest ?newgraph ) aux:createOGraph ?graph + + }. + +############################################## +# minus +############################################## +#test: is there a minus? +#yes +{(?inVars ?list) aux:handleMinus ?graph}<={ + ?t list:in ?list. ?t a sp:Minus . + true log:callWithCut true. + + ?list aux:getVars ?vars. + + (?e {?t2 list:in ?list. ?t2 a sp:Minus . (?t2 ?vars) aux:createMinusExpression ?e } ?eList) log:collectAllIn ?scope. + ?eList log:conjunction ?graph. + }. + + # case: no minus + {(?vars ?list) aux:handleMinus {}}<={ }. + + {(?t ?vars) aux:createMinusExpression ?e}<={ + ?t sp:elements ?list. + ?list aux:getVars ?v2. + (?vars ?v2) aux:listIntersection ?intv. + (?intv ?t) aux:minExpr ?e. + }. + # TODO: multiple minus? + + {(() ?t) aux:minExpr {}.}<={true log:callWithCut true.}. + +{ (?list ?t) aux:minExpr {?scope log:notIncludes ?g}.}<={ + ?t sp:elements ?e. + (?list ?e) aux:createGraph ?g1. + (?list ?g1 ?t) aux:relabelGraph ?g. + :scope log:skolem ?scope. +}. +#relabel-function for ?g +{(false ?graph ?x) aux:relabelGraph ?graph}<={true log:callWithCut true}. +{(?list {} ?x) aux:relabelGraph {}}<={true log:callWithCut true}. + + +{(?list ?graph ?id) aux:relabelGraph ?gout} +<= +{ + ({?s1 ?p1 ?o1} {?graph log:includes {?s ?p ?o}. + (?id ?list ?s) aux:newLabel ?s1. (?id ?list ?p) aux:newLabel ?p1. (?id ?list ?o) aux:newLabel ?o1 + } ?tlist) log:collectAllIn ?scope. + ?tlist log:conjunction ?gout +}. + +{(?id ?list ?x) aux:newLabel ?x.}<={ (?z ?x) list:in ?list. true log:callWithCut true.}. +{(?id ?list ?x) aux:newLabel ?x1 .}<={?x log:rawType log:SkolemIRI. true log:callWithCut true. (?id ?x) e:skolem ?x1. }. +{(?id ?list ?x) aux:newLabel ?g.}<={?x log:rawType log:Formula. true log:callWithCut true. (?list ?x ?id) aux:relabelGraph ?g.}. +{(?id ?list ?x) aux:newLabel ?x.}<={?x log:rawType ?type. ?type list:in (log:Other log:Literal). true log:callWithCut true. }. +{(?id ?list ?x) aux:newLabel ?out.}<={?x log:rawType rdf:List. (?id ?list ?x ()) aux:newLabelList ?out. true log:callWithCut true. }. + +{(?id ?list () ?out) aux:newLabelList ?out}<={}. +{(?id ?list ?x ?in) aux:newLabelList ?out}<={?x rdf:first ?first. (?id ?list ?first) aux:newLabel ?l. (?in (?l)) list:append ?in2. + ?x rdf:rest ?rest. (?id ?list ?rest ?in2) aux:newLabelList ?out }. + + + +############################################## +#getFunctions +{?t aux:getFunctionTriples ?tr}<={ + ?t sp:expression ?e. + ?e sp:arg1 ?something. + true log:callWithCut true. + + + #getArguments + # get argument-predicates + (?argp {?e ?argp ?o. ?argp log:uri ?argpuri. + ?argpuri string:startsWith "http://spinrdf.org/sp#arg". + } ?ns ) log:collectAllIn ?scope. + ?ns aux:sort ?nsort. + # get labeled arguments in the right order + (?argl { + ?argp list:in ?nsort. + ?e ?argp ?arg. + ?arg aux:gets ?argl. + } ?arguments ) log:collectAllIn ?scope. + #get unlabled arguments + (?arg { + ?argp list:in ?nsort. + ?e ?argp ?arg. + } ?uarguments ) log:collectAllIn ?scope. + ?e a ?f. + ?t aux:gets ?e1. +{?arguments ?f ?e1 } log:equalTo ?in. + ?in aux:funcTranslation ?tr1. +# check for arguments of arguments +(?triples { + ?ar list:in ?uarguments. + ?ar ?p ?o. + ?ar aux:getFunctionTriples ?triples. + } ?trlist ) log:collectAllIn ?scope. + + ( ?trlist (?tr1)) list:append ?trs. + ?trs log:conjunction ?tr. + + }. + +#getFunctions +{?t aux:getFunctionTriples ?tr}<={ + + ?t sp:arg1 ?something. + true log:callWithCut true. + + + #getArguments + # get argument-predicates + (?argp {?t ?argp ?o. ?argp log:uri ?argpuri. + ?argpuri string:startsWith "http://spinrdf.org/sp#arg". + } ?ns ) log:collectAllIn ?scope. + + ?ns list:sort ?nsort. + # get labeled arguments in the right order + (?argl { + ?argp list:in ?nsort. + ?t ?argp ?arg. + ?arg aux:gets ?argl. + } ?arguments ) log:collectAllIn ?scope. + #get unlabled arguments + (?arg { + ?argp list:in ?nsort. + ?t ?argp ?arg. + } ?uarguments ) log:collectAllIn ?scope. + ?t a ?f. + ?t aux:gets ?e1. +{?arguments ?f ?e1 } log:equalTo ?in. + ?in aux:funcTranslation ?tr1. + +# check for arguments of arguments +(?triples { + ?ar list:in ?uarguments. + ?ar ?p ?o. + ?ar aux:getFunctionTriples ?triples. + } ?trlist ) log:collectAllIn ?scope. + + ( ?trlist (?tr1)) list:append ?trs. + ?trs log:conjunction ?tr. + + }. + + +{?t aux:getFunctionTriples ?tr.} +<= +{ +?t sp:expression ?ex. + +?ex sp:varName ?aggrVar. +true log:callWithCut true. +?t aux:gets ?nvar. + +?t a ?function. + + +(aux:aggregationInput ?aggrVar) log:skolem ?args. +# this log:equalTo is only here for technical reasons +?d log:equalTo {?args ?function ?nvar}. +?d aux:aggTranslation ?tr. + +}. + +{?t aux:getFunctionTriples ?tr.} +<= +{ +?t sp:expression ?ex. +?ex sp:expression [sp:varName ?aggrVar]. +true log:callWithCut true. +?t aux:gets ?nvar. + +?ex a ?function. + + + + (aux:aggregationInput ?aggrVar) log:skolem ?args. + # this log:equalTo is only here for technical reasons + + ?d log:equalTo {?args ?function ?nvar}. + ?d aux:aggTranslation ?tr. + +}. + +# not exists +{?e aux:getFunctionTriples {(1 ?graph ()) log:collectAllIn ?scope}}<={ + ?e sp:expression ?ex. + ?ex a sp:notExists; + sp:elements ?elements. + + (?vars ?elements) aux:createGraph ?graph. + :scope log:skolem ?scope + +}. + +# exists +{?e aux:getFunctionTriples {?scope log:includesNotBind ?graph}}<={ + ?e sp:expression ?ex. + ?ex a sp:exists; + sp:elements ?elements. + (?vars ?elements) aux:createGraph ?graph. + :scope log:skolem ?scope + +}. + + +# aggregation function has * as argument +#{?t aux:getFunctionTriples ?tr.} +#<= +#{ +#?t sp:expression ?ex. +#?ex sp:expression [sp:varName ?aggrVar]. +#true log:callWithCut true. +#?t aux:gets ?nvar. +#?ex a ?function. +#(aux:aggregationInput ) log:skolem ?args. + # this log:equalTo is only here for technical reasons + # ?d log:equalTo {?args ?function ?nvar}. + # ?d aux:aggTranslation ?tr. +#}. + +{?e aux:getFunctionTriples {}}<={}. + +#Bind +{ + (?vars ?list) aux:handleBind ?graph. + }<={ +(?t {?t list:in ?list. ?t a sp:Bind .} ?bList) log:collectAllIn ?scope. +(({?e1 log:equalTo ?v1} ?tr) {?b list:in ?bList. ?b sp:expression ?e. ?b sp:variable ?v. ?v aux:gets ?v1. ?e aux:gets ?e1. + ?e aux:getFunctionTriples ?tr. + } ?gList) log:collectAllIn ?scope. + +?gList list:append ?oList. +(?oList ({})) list:append ?pList. +?pList log:conjunction ?graph. +}. + + + +#select with variables +{?x aux:getResultVariables ?outvars}<={ + # ?x sp:where ?w. + # ?w log:notEqualTo (). + ?x sp:resultVariables ?varlist. + + true log:callWithCut true. + ((?name ?s1){?s list:in ?varlist. ?s sp:varName ?name . ?name log:skolem ?s1.} ?outvars) log:collectAllIn ?scope. + +}. +# select with empty graph +#{?x aux:getResultVariables ()}<={ +# ?x sp:where (). +#}. + +#select with star +{?x aux:getResultVariables ?outvars}<={ + ?x aux:getGraphVariables ?outvars +}. + + + +#get graph variables +{?x aux:getGraphVariables ?outvars} +<= +{ + + ?x sp:where ?where. + (?var {?t list:in ?where. ?t aux:bgpOrBindVars ?var. } ?vars1) log:collectAllIn _:x. + (?var2 {?t list:in ?where. ?t sp:query ?q. + ?q aux:getResultVariables ?var2. + } ?vars2) log:collectAllIn _:x. + (?vars2 ()) aux:flatten ?vars22. + (?vars22 ()) aux:makePairs ?pairs. + + (?vars1 ?pairs) list:append ?vars. + ?vars list:removeDuplicates ?outvars.}. + + + + + {?t aux:bgpOrBindVars (?name ?s1).}<= + { + ?t ?p ?s. + ?p list:in (sp:subject sp:predicate sp:object). + ?s sp:varName ?name . ?name log:skolem ?s1. + }. + + {?t aux:bgpOrBindVars (?name ?ns)}<={ + ?t a sp:Bind. + ?t sp:variable ?v. + ?v sp:varName ?name. + ?name log:skolem ?ns. + }. + + + +#get all variables mentioned in the result pattern +{ ?x aux:getQueryVariables ?invars.} +<= +{ +?x sp:resultVariables ?list. +(?var {?a list:in ?list. ?a aux:hasVar ?var} ?vars) log:collectAllIn _:t. +?vars list:append ?var2. +?var2 list:removeDuplicates ?invars. +}. + + + +# has variable +{?x aux:hasVar ((?name ?ns)).} +<= +{ + ?x sp:varName ?name. + ?name log:skolem ?ns. +}. + +{?x aux:hasVar ?var.} +<= +{ + ?x sp:expression ?e. + ?e aux:hasVar ?var. +}. + +{?x aux:hasVar ?var.} +<= +{ + ?x ?arg ?argument. + ?arg log:uri ?uri. + ?uri string:startsWith "http://spinrdf.org/sp#arg". + ?argument aux:hasVar ?var. +}. + + + + + + +################################################## +# handle aggregation +################################################## +{(?x ?g) aux:handleAggregation ?g2 }<={ + ?x sp:resultVariables ?list. + + _:t list:in ?list; sp:expression _:e. + true log:callWithCut true. + #getting all aggregate function expressions + + + (?tr {?t list:in ?list. + ?t aux:getFunctionTriples ?tr. + } ?aggList) log:collectAllIn ?scope. + + #make query to get groups + (?x ?g ) aux:makeGroups ?collectExpression. + #putting all together + ( (?collectExpression) ?aggList) list:append ?fl. + ?fl log:conjunction ?g2. + +}. + + +#case: no aggregation +{(?x ?g) aux:handleAggregation ?g }<={}. + + + + + + + + + +#makeGroups +{( ?x ?g) aux:makeGroups ?graph.}<={ +# ?x sp:groupBy ?vars. +# true log:callWithCut true. + # create all new variables needed +aux:scope log:skolem ?scope. +aux:pairs log:skolem ?pairs. +aux:aggVal log:skolem ?aggVal. +aux:f log:skolem ?f. +aux:g3 log:skolem ?g3. +aux:g2 log:skolem ?g2. +aux:ilist log:skolem ?ilist. +aux:value log:skolem ?value. + + #get group variables + ( (?groupVarName ?groupVar) { ?x!sp:groupBy!list:member sp:varName ?groupVarName. ?groupVarName log:skolem ?groupVar. } ?groupVars ) + log:collectAllIn _:t . + + + #get agg variables + ?x aux:getGraphVariables ?outvars2. + (?outvars2 ?groupVars) aux:listDifference ?outvars. + + + + + #get aggregation variables needed in the query + ?x aux:getQueryVariables ?qvars. + + + (?qvars ?outvars) aux:listIntersection ?aggvars. + + + + + + #get list of only aggvarsnames + ( ?name {(?name ?var) list:in ?aggvars } ?aggvarNames ) log:collectAllIn _:t. + + + #create one collectAllIn expression per aggregate variable name + ( + #what we produce + { + ( ?value {(?f ?ilist) list:in ?pairs. + (?name ?value ) list:in ?ilist }?args) log:collectAllIn ?scope. + } + #based on + {(?name ?var) list:in ?aggvars. + (aux:aggregationInput ?name) log:skolem ?args. + } ?tripleList ) log:collectAllIn _:t. + + +#group variables needed in the output +(?outvars2 ?groupVars) aux:listIntersection ?outList. +({?ell list:in ?f}{?ell list:in ?outList } ?unificationTriples) log:collectAllIn _:t. + + ( + ( + { + # get values + ( (?groupVars ?outvars) ?g ?pairs ) log:collectAllIn ?scope. + # get lists for one groupVar Value + (?f ?g3) list:in ?pairs. + } + ) + ?tripleList + ?unificationTriples + ) list:append ?graphList. + ?graphList log:conjunction ?graph. +}. + + +################################## +# handle subqueries +################################# +{(?vars ?list2) aux:handleSubquery ?graph7.} +<={ + + (?gr {?x list:in ?list2. ?x a sp:SubQuery. ?x sp:query ?y. + ?y aux:getResultVariables ?outvars. ?y sp:where ?w. (?outvars ?w ) aux:createGraph ?g1. (?y ?g1) aux:handleAggregation ?g. + (?outvars ?g ?y) aux:relabelGraph ?gr. + } ?gs) log:collectAllIn ?scope. + + + # (?gr {(?oin ?gin) list:in ?gs. (?oin ?gin) aux:relabelGraph ?gr } ?grs) log:collectAllIn ?scope. + + + (?gs ({})) list:append ?g2. + + ?g2 log:conjunction ?graph7. +}. + +################################# +# test: is subquery? +################################## +{?x aux:subtest false.}<={?scope e:fail {?y sp:query ?x. ?y a sp:SubQuery}}. + + +####################################################### +# list functions (use them where you want :) +####################################################### +# list difference +{(?result ()) aux:listDifference ?result}<={}. + +{(?l1 ?l2) aux:listDifference ?result}<={ + ?l2 rdf:first ?first. + (?l1 ?first) list:remove ?l11. + ?l2 rdf:rest ?rest. + (?l11 ?rest) aux:listDifference ?result. +}. + +# list intersection +{(?l1 ?l2) aux:listIntersection ?result}<={ + (?x {?x list:in ?l1, ?l2 } ?xs) log:collectAllIn _:t. + ?xs list:removeDuplicates ?result. +}. + +#flatten lists +{(() ?res ) aux:flatten ?res}<={ true log:callWithCut true}. +{(?list ?res ) aux:flatten ?olist}<={ + ?list rdf:first ?f. + ?f log:rawType rdf:List. true log:callWithCut true. + (?f ()) aux:flatten ?result. (?res ?result) list:append ?new. + ?list rdf:rest ?rest. (?rest ?new) aux:flatten ?olist }. + +{(?list ?res ) aux:flatten ?olist}<={ + ?list rdf:first ?f. + (?res (?f)) list:append ?new. + ?list rdf:rest ?rest. (?rest ?new) aux:flatten ?olist }. + +#make pairs +{(() ?result) aux:makePairs ?result.}<={true log:callWithCut true}. +{(?list ?res) aux:makePairs ?result.}<={ + ((?first ?second) ?rest) list:append ?list. + (?res ((?first ?second)) ) list:append ?res2. + (?rest ?res2) aux:makePairs ?result. + }. + + #create arument list in order (assumption: we start at 1 and count upwards) + { ?ns aux:sort ?nsort.}<={?ns list:sort ?slist. ?slist list:length ?n. (?n ()) aux:makeArgList ?nsort }. + {(0 ?list) aux:makeArgList ?list} <={}. + {(?n ?list) aux:makeArgList ?out} <={?n math:notEqualTo 0. ("http://spinrdf.org/sp#arg" ?n) string:concatenation ?con. ?uri log:uri ?con. ((?uri) ?list) list:append ?nlist. + (?n 1) math:difference ?m. + (?m ?nlist) aux:makeArgList ?out + }. + + +##################################################################################### +# sparql-functions and their translations +##################################################################################### +{{(?a1 ?a2) sp:lt ?o} aux:funcTranslation {?a1 math:lessThan ?a2}.}<={}. +{{(?a1 ?a2) sp:gt ?o} aux:funcTranslation {?a2 math:lessThan ?a1}.}<={}. +{{?list sp:concat ?o} aux:funcTranslation { ?list string:concatenation ?o. }. }<={}. +{{(?a1 ?a2) sp:eq ?o} aux:funcTranslation { ?a1 log:bound true. ?a2 log:bound true. ?a1 log:equalTo ?a2. }. }<={}. +{{(?a) sp:lcase ?o} aux:funcTranslation {?a string:lowerCase ?o}}<={}. +{{(?a) sp:ucase ?o} aux:funcTranslation {?a string:upperCase ?o}}<={}. +{{(?a) sp:uri ?o} aux:funcTranslation {?o log:uri ?a}}<={}. +{{(?a) sp:iri ?o} aux:funcTranslation {?o log:uri ?a}}<={}. +{{?list sp:replace ?o} aux:funcTranslation {?list string:replace ?o}}<={}. +{{(?a) sp:bound ?o} aux:funcTranslation {?a log:bound true}}<={}. +{{(?a) sp:isIri ?o} aux:funcTranslation {?a log:rawType log:Other. ?a log:uri []}}<={}. +{{(?a) sp:isUri ?o} aux:funcTranslation {?a log:rawType log:Other. ?a log:uri []}}<={}. +{{(?a) sp:isBlank ?o} aux:funcTranslation {?a log:rawType ?type. ?type list:in ( log:BlankNode log:LabeledBlankNode log:UnlabeledBlankNode)}} + <={(?a log:rawType) log:skolem ?type }. +{{(?a) sp:isLiteral ?o} aux:funcTranslation {?a log:rawType log:Literal. }}<={}. +{{(?a) sp:isNumeric ?o} aux:funcTranslation { (?z ?dt)log:dtlit ?a. ?dt list:in (xsd:byte xsd:decimal xsd:int xsd:integer xsd:long xsd:negativeInteger xsd:nonNegativeInteger xsd:nonPositiveInteger xsd:positiveInteger xsd:short xsd:unsignedLong xsd:unsignedInt xsd:unsignedShort xsd:unsignedByte )}} + <={(1 ?a log:dtlit) log:skolem ?z. (2 ?a log:dtlit) log:skolem ?dt.}. +{{(?a) sp:str ?o} aux:funcTranslation { true log:callWithOptional {?a log:uri ?o}. true log:callWithOptional {?a log:rawType log:Literal. ?a log:equalTo ?o}.}}<={}. +{{(?a) sp:lang ?o} aux:funcTranslation { (?sk ?o) log:langlit ?a}}<={(?a ?o log:langlit) log:skolem ?sk}. +{{(?a) sp:datatype ?o} aux:funcTranslation { (?sk ?o) log:dtlit ?a}}<={(?a ?o log:dtlit) log:skolem ?sk}. +{{?list sp:bnode ?o} aux:funcTranslation { ?list log:skolem ?o}}<={}. +{{?list sp:strdt ?o} aux:funcTranslation { ?list log:dtlit ?o}}<={}. +{{?list sp:strlang ?o} aux:funcTranslation { ?list log:langlit ?o}}<={}. +{{(?a) sp:strlen ?o} aux:funcTranslation { ?a string:length ?o}}<={}. +{{?list sp:substr ?o} aux:funcTranslation { ?list string:substring ?o}}<={}. +{{(?a1 ?a2) sp:strStarts ?o} aux:funcTranslation { ?a1 string:startsWith ?a2}}<={}. +{{(?a1 ?a2) sp:strEnds ?o} aux:funcTranslation { ?a1 string:endsWith ?a2}}<={}. +{{(?a1 ?a2) sp:contains ?o} aux:funcTranslation { ?a1 string:contains ?a2}}<={}. +{{(?a1 ?a2) sp:strbefore ?o} aux:funcTranslation {( "(.*?)%s.*" ?a2) string:format ?regex .( ?a1 ?regex) string:scrape ?o .}} + <={ ( ".*?%s(.*)" ?a2) log:skolem ?regex.}. +{{(?a1 ?a2) sp:strafter ?o} aux:funcTranslation {( ".*?%s(.*)" ?a2) string:format ?regex .( ?a1 ?regex) string:scrape ?o .}} + <={ ( ".*?%s(.*)" ?a2) log:skolem ?regex.}. +#Encode_For_URI +# problem: https://n3-editor.herokuapp.com/n3/editor/s/NZ0zbiJ2 +# langMatches +{{?list sp:mul ?o} aux:funcTranslation {?list math:product ?o}}<={}. +{{?list sp:sub ?o} aux:funcTranslation {?list math:difference ?o}}<={}. +# MISSING: uuid, struuid +{{(?a) sp:abs ?o} aux:funcTranslation {?a math:absoluteValue ?o}}<={}. +{{(?a) sp:round ?o} aux:funcTranslation {?a math:rounded ?o}}<={}. +{{(?a) sp:year ?o} aux:funcTranslation {?a time:year ?o}}<={}. +{{(?a) sp:month ?o} aux:funcTranslation {?a time:month ?o}}<={}. +{{(?a) sp:day ?o} aux:funcTranslation {?a time:day ?o}}<={}. +{{(?a) sp:hours ?o} aux:funcTranslation {?a time:hour ?o}}<={}. +{{(?a) sp:minutes ?o} aux:funcTranslation {?a time:minute ?o}}<={}. +{{(?a) sp:seconds ?o} aux:funcTranslation {?a time:second ?o}}<={}. +{{(?a) sp:sha1 ?o} aux:funcTranslation {?a crypto:sha ?o}}<={}. +{{?l sp:in ?o} aux:funcTranslation {?v list:in ?list}}<={ ?l rdf:first ?v. ?l rdf:rest ?list}. + +#logic +{{(?a1 ?a2) sp:and ?o} aux:funcTranslation ?tr}<={ ?a1 aux:getFunctionTriples ?tr1. ?a2 aux:getFunctionTriples ?tr2. ({} ?tr1 ?tr2) log:conjunction ?tr }. + +#aggregate functions +{{?values sp:Sum ?result } aux:aggTranslation {?values math:sum ?result }}<={} . +{{?values sp:Avg ?result } aux:aggTranslation {?values math:sum ?sum . ?values list:length ?l . ( ?sum ?l ) math:quotient ?result }} + <={ + (?values math:sum) log:skolem ?sum. + (?values list:length) log:skolem ?l }. +{{?values sp:Max ?result } aux:aggTranslation {?values math:max ?result }}<={}. +{{?values sp:Min ?result } aux:aggTranslation {?values math:min ?result }}<={}. +{{?values sp:Count ?result } aux:aggTranslation {?values list:length ?result . }}<={}. diff --git a/lib/spin3/auxiliary-files/csv-convert.n3 b/lib/spin3/auxiliary-files/csv-convert.n3 new file mode 100644 index 0000000..c380f2c --- /dev/null +++ b/lib/spin3/auxiliary-files/csv-convert.n3 @@ -0,0 +1,67 @@ +@prefix aux: . +@prefix e: . +@prefix ex: . +@prefix list: . +@prefix log: . +@prefix math: . +@prefix ns1: . +@prefix rdf: . +@prefix rdfs: . +@prefix sp: . +@prefix spin: . +@prefix string: . +@prefix var: . +@prefix xsd: . + + +# +{ + : :header ?header . + ( + ?row + { + ?x ns1:result ?results . + ( + ?valStr + { + ?results list:member ( ?name ?val ) . + ?val aux:getString ?valStr. + } + ?vals + ) log:collectAllIn _:t . + # + ( ?vals "," ) string:join ?row + } + ?rows + ) log:collectAllIn _:t . + # + ( ?rows "\n" ) string:join ?body . + ( ?header "\n" ?body ) string:concatenation ?table +} +=> +{ + 0 log:outputString ?table +} . + +# +{ + : :header ?header +} +<= +{ + ?x ns1:result ?results . + ( + ?nameStr + { + ?results list:member ( ?name ?val ) . + + ( ?name ) string:concatenation ?nameStr + } + ?names + ) log:collectAllIn _:t . + # + ( ?names "," ) string:join ?header +} . + +{?x aux:getString ?u}<={?x log:uri ?u. true log:callWithCut true}. +{?x aux:getString ?x}<={}. diff --git a/lib/spin3/auxiliary-files/nested_builtins.n3 b/lib/spin3/auxiliary-files/nested_builtins.n3 new file mode 100644 index 0000000..35b2129 --- /dev/null +++ b/lib/spin3/auxiliary-files/nested_builtins.n3 @@ -0,0 +1,73 @@ +@prefix list: . +@prefix log: . +@prefix string: . +@prefix rdfs: . +@prefix target: . +@prefix source: . +@prefix spin: . +@prefix s2n: . +@prefix aux: . + +[] a spin:Construct ; +spin:where + [ a spin:Bind ; + spin:expression [ a spin:uri ; + spin:arg1 [ a spin:concat ; + spin:arg1 "http://example.org/" ; + spin:arg2 [ spin:varName "moduleID" ] ; + spin:arg3 "_" ; + spin:arg4 [ a spin:replace ; + spin:arg1 [ spin:varName "moduleName" ] ; + spin:arg2 " " ; + spin:arg3 "" ]]] ; + spin:variable [ spin:varName "subject"] + ] . + +# create variable if needed +{?s aux:gets ?s1}<={?s log:uri ?suri. + ?suri string:startsWith "http://spinrdf.org/". + ?s log:skolem ?s1. +#true log:callWithCut true +}. +{?s aux:gets ?s1}<={?s spin:varName ?name . ?name log:skolem ?s1. +#true log:callWithCut true +}. +{?s aux:gets ?var}<={?s s2n:n3Var ?var}. +{?s aux:gets ?s}<={?s log:rawType log:Literal}. +#{?s aux:gets ?s}<={}. + +spin:replace a s2n:SparqlBuiltin ; + s2n:equivalent string:replace . + +spin:concat a s2n:SparqlBuiltin ; + s2n:equivalent string:concatenation . + +{ + ?sparqlBuiltin a ?builtinType . + ?builtinType a s2n:SparqlBuiltin . + ?builtinType s2n:equivalent ?n3Builtin . + + ?sparqlBuiltin log:skolem ?id . + + (?pred + { + ?sparqlBuiltin ?pred ?arg . + ?pred!log:uri string:startsWith "http://spinrdf.org/spin#arg" . + } + ?preds) log:collectAllIn _:t . + + (?n3Arg + { + ?sparqlBuiltin ?preds!list:member ?arg . + ?arg aux:gets ?n3Arg . + } + ?n3Args) log:collectAllIn _:t . + + ?preds list:length ?l . + ?n3Args list:length ?l . + +} => { + ?sparqlBuiltin + s2n:n3 { ?n3Args ?n3Builtin ?id } ; + s2n:n3Var ?id . +} . diff --git a/lib/spin3/auxiliary-files/runtime.n3 b/lib/spin3/auxiliary-files/runtime.n3 new file mode 100644 index 0000000..88d9819 --- /dev/null +++ b/lib/spin3/auxiliary-files/runtime.n3 @@ -0,0 +1,200 @@ +@prefix : . +@prefix aux: . +@prefix e: . +@prefix list: . +@prefix log: . +@prefix math: . +@prefix rdf: . +@prefix rdfs: . +@prefix sp: . +@prefix string: . + + +# - sequenceOfSteps + +# +{ + ( ?start ?end ) aux:stepThroughPath ?steps +} +<= +{ + + ?steps list:firstRest ( ?step ?rest ) . + true log:callWithCut true. + # steps = list with steps (again lists) as elements + # (individual steps would have numbers as last elements) + ?steps!list:last log:rawType rdf:List . + # "sequenceOfSteps" log:trace ?step . + ( ?start ?interm ) aux:stepThroughPath ?step . + # + ( ?interm ?end ) aux:stepThroughPath ?rest +} . + +# rest is empty: unify "start" with "end" +{ + ( ?start ?start ) aux:stepThroughPath ( ) +} +<= {} . + + +# - predicatePath +{ + ( ?s ?o ) aux:stepThroughPath ( ?pred 1 1 ) +} +<= +{ + #"singleStep" log:trace ( ?s ?o ?pred ) . + ?s ?pred ?o +} . + + +# - reversePath +{ + ( ?s ?o ) aux:stepThroughPath ( ?nested "rev" ) +} +<= +{ + ( ?o ?s ) aux:stepThroughPath ?nested +} . + + +# - oneOrMorePath +{ + ( ?start ?end ) aux:stepThroughPath ( ?nested 1 -2 ) +} +<= +{ + #"oneOrMorePath" log:trace ( ?start ?end ?nested ) . + ( ?start ?end ) aux:stepThroughPath ?nested . +} . + +# +{ + ( ?start ?end ) aux:stepThroughPath ( ?nested 1 -2 ) +} +<= +{ + ( ?start ?o ) aux:stepThroughPath ?nested . + ( ?o ?end ) aux:stepThroughPath ( ?nested 1 -2 ) . +} . + + +# - zeroOrMorePath +{ + ( ?start ?start ) aux:stepThroughPath ( ?nested 0 -2 ) +} +<= {} . + +# +{ + ( ?start ?end ) aux:stepThroughPath ( ?nested 0 -2 ) +} +<= +{ + ( ?start ?end ) aux:stepThroughPath ( ?nested 1 -2 ) +} . + + +# - zeroOrOnePath +{ + ( ?start ?start ) aux:stepThroughPath ( ?nested 0 -1 ) +} +<= {} . + +# +{ + ( ?start ?end ) aux:stepThroughPath ( ?nested 0 -1 ) +} +<= +{ + ( ?start ?end ) aux:stepThroughPath ?nested . +} . + +# - altPath +{ + ( ?start ?end ) aux:stepThroughPath ( ?options "alt" ) +} +<= +{ + # "altPath" log:trace ?options . + ( ?start ?end ) aux:tryAlts ?options . +} . + +# +{ + ( ?start ?end ) aux:tryAlts ?options +} +<= +{ + ?options rdf:first ?first . + ( ?start ?end ) aux:stepThroughPath ?first +} . + +# +{ + ( ?start ?end ) aux:tryAlts ?options +} +<= +{ + ?options rdf:rest ?rest . + ( ?start ?end ) aux:tryAlts ?rest +} . + + +# negatedPath +{ + ( ?start ?end ) aux:stepThroughPath ( ?options "neg" ) +} +<= +{ + ( ?start ?end ) aux:tryNeg ?options +} . + + +# +{ + ( ?start ?end ) aux:tryNeg ?options . +} +<= +{ + ( ?options sp:LinkPath ) aux:collectLinkRegex ?regex . + # + "tryNeg (1)" log:trace ( ?start ?end ?regex ) . + ?start ?pred ?end . + ?pred!log:uri string:notMatches ?regex +} . + + +# +{ + ( ?start ?end ) aux:tryNeg ?options . +} +<= +{ + ( ?options sp:ReverseLinkPath ) aux:collectLinkRegex ?regex . + # + "tryNeg (2)" log:trace ( ?start ?end ?regex ) . + ?end ?pred ?start . + ?pred!log:uri string:notMatches ?regex +} . + + +# +{ + ( ?options ?type ) aux:collectLinkRegex ?regex +} +<= +{ + ( + ?uriStr + { + ( ?option ?type ) list:in ?options . + ?option log:uri ?uriStr + } + ?uriStrs + ) log:collectAllIn _:t . + # + ?uriStrs!list:length math:greaterThan 0 . + ( ?uriStrs "|" ) string:join ?regex . +} . + diff --git a/lib/spin3/out/n3query.n3 b/lib/spin3/out/n3query.n3 new file mode 100644 index 0000000..b8458f1 --- /dev/null +++ b/lib/spin3/out/n3query.n3 @@ -0,0 +1,45 @@ +# Processed by EYE v4.6.0 (2023-07-14) +# eye /Users/wvw/git/n3/n3-editor-js/lib/spin3/out/query.spin /Users/wvw/git/n3/n3-editor-js/lib/spin3/auxiliary-files/aux.n3 --query /Users/wvw/git/n3/n3-editor-js/lib/spin3/queries/query_general.n3 --nope --quantify http://eyereasoner.github.io/.well-known/genid/ + +@prefix string: . +@prefix list: . +@prefix log: . +@prefix xsd: . +@prefix rdfs: . +@prefix spin: . +@prefix sp: . +@prefix ex: . +@prefix aux: . +@prefix math: . +@prefix time: . +@prefix crypto: . +@prefix rdf: . +@prefix e: . +@prefix var: . + +{ + ?t_14 "''}SELECT". +} => { + ?t_14 . +}. +{ + ?t_15 ?t_16 ?t_14. +} => { + ?t_14 ?t_16 ?t_15. +}. +{ + ((() (("x" ?t_14))) { + ?t_14 "\\\"{". + } ?t_17) log:collectAllIn ?t_18. + (?t_19 ?t_20) list:in ?t_17. + (?t_21 { + (?t_19 ?t_22) list:in ?t_17. + ("x" ?t_21) list:in ?t_22. + } ?t_23) log:collectAllIn ?t_18. + ?t_14 list:in ("{"). +} => { + _:bn_9 ex:result (("SELECT" _:t_24) ("CONSTRUCT" _:t_25)). +}. +# 2023-07-15T20:41:51.578Z in=169 out=3 ent=3 step=3 brake=2 inf=397952 sec=0.043 inf/sec=9254698 +# ENDS + diff --git a/lib/spin3/out/query.spin b/lib/spin3/out/query.spin new file mode 100644 index 0000000..d365c22 --- /dev/null +++ b/lib/spin3/out/query.spin @@ -0,0 +1,74 @@ +[ a ; + + ( [ ; + + ; + + [ + "x" ] + ] + ) ; + ( [ "''}SELECT" ; + + ; + + [ + "x" ] + ] + [ a ; + [ a ; + + ( [ + "x" ] + ) ; + () + ] + ] + ) +] . +[ a ; + + ( [ + "SELECT" ] + [ + [ a ; + [ + "x" ] ; + "{" + ] ; + + "CONSTRUCT" + ] + ) ; + ( [ "\\\"{" ; + + ; + + [ + "x" ] + ] + ) +] . +[ a ; + + ( [ [ + "z" ] ; + + [ + "y" ] ; + + [ + "x" ] + ] + ) ; + ( [ [ + "x" ] ; + + [ + "y" ] ; + + [ + "z" ] + ] + ) +] . diff --git a/lib/spin3/queries/query_csv.n3 b/lib/spin3/queries/query_csv.n3 new file mode 100644 index 0000000..ca656e4 --- /dev/null +++ b/lib/spin3/queries/query_csv.n3 @@ -0,0 +1,46 @@ +@prefix string: . +@prefix list: . +@prefix log: . +@prefix xsd: . +@prefix rdfs: . +@prefix spin: . +@prefix sp: . +@prefix ex: . +@prefix e: . +@prefix aux: . + + + + +## select +{ ?x a sp:Select . + + ?x sp:where ?where. + + + #get result variables + ?x aux:getResultVariables ?outvars. + #handle graph + (false ?where) aux:createGraph ?g1. + #handle aggregation + (?x ?g1) aux:handleAggregation ?g. + + + + + (?name {(?name ?value) list:in ?outvars} ?names) log:collectAllIn ?scope. + (?names ",") string:join ?nameString. + (?nameString "\n") string:concatenation ?outname. + ?names log:skolem ?out. + + + (?g { (?v2 {(?name ?value) list:in ?outvars. ?value aux:getString ?v2 } ?values) log:collectAllIn ?scope2. + (?values ",") string:join ?valString. (?valString "\n" ) string:concatenation ?out. } ) log:conjunction ?gout. + + + }=>{ + {?x11 aux:getString ?u11}<={?x11 log:uri ?u11. }. + {?x11 aux:getString ?x11}<={?x11 log:rawType ?t11. ?t11 log:notEqualTo log:Other}. + ?g => {1 log:outputString ?outname}. + ?gout => {2 log:outputString ?out}. + }. diff --git a/lib/spin3/queries/query_csv_direct.n3 b/lib/spin3/queries/query_csv_direct.n3 new file mode 100644 index 0000000..20f524f --- /dev/null +++ b/lib/spin3/queries/query_csv_direct.n3 @@ -0,0 +1,41 @@ +@prefix string: . +@prefix list: . +@prefix log: . +@prefix xsd: . +@prefix rdfs: . +@prefix spin: . +@prefix sp: . +@prefix ex: . +@prefix e: . +@prefix aux: . + + + + +## select +{ ?x a sp:Select . + + ?x sp:where ?where. + + + #get result variables + ?x aux:getResultVariables ?outvars. + #handle graph + (false ?where) aux:createGraph ?g1. + #handle aggregation + (?x ?g1) aux:handleAggregation ?g. + + + + + (?name {(?name ?value) list:in ?outvars} ?names) log:collectAllIn ?scope. + + + + (?value {(?name ?value) list:in ?outvars. } ?values) log:collectAllIn ?scope2. + + + + }=>{ + {?names e:csvTuple ?values}<=?g. + }. diff --git a/lib/spin3/queries/query_general.n3 b/lib/spin3/queries/query_general.n3 new file mode 100644 index 0000000..f3cc804 --- /dev/null +++ b/lib/spin3/queries/query_general.n3 @@ -0,0 +1,46 @@ +@prefix string: . +@prefix list: . +@prefix log: . +@prefix xsd: . +@prefix rdfs: . +@prefix spin: . +@prefix sp: . +@prefix ex: . +@prefix e: . +@prefix aux: . + +## construct +{ ?x a sp:Construct ; + sp:templates ?temps ; + sp:where ?where. + ?x aux:subtest false. + (false ?where) aux:createGraph ?g1. + (false ?temps) aux:handleTriples ?g2 + }=>{?g1=>?g2. }. + +## ask + { ?x a sp:Ask ; + sp:where ?where. + ?x aux:subtest false. + (false ?where) aux:createGraph ?g1. + }=>{?g1 => {?x ex:result true}. {(1 ?g1 ()) log:collectAllIn ?scope}=>{?x ex:result false} + }. + +## select +{ ?x a sp:Select . + + ?x sp:where ?where. + # only if this is no sub-query + ?x aux:subtest false. + + #get result variables + ?x aux:getResultVariables ?outvars. + #handle graph + (false ?where) aux:createGraph ?g1. + #handle aggregation + (?x ?g1) aux:handleAggregation ?g. + + + + }=>{?g => {?x ex:result ?outvars}. + }. diff --git a/lib/spin3/spin3.js b/lib/spin3/spin3.js new file mode 100644 index 0000000..04d22bd --- /dev/null +++ b/lib/spin3/spin3.js @@ -0,0 +1,66 @@ +let { promiseExec } = require('../cmd_util.js') +let { config } = require('../../config.js') +let fs = require('fs/promises') +let { clean } = require('../eye/eye.js') + +const out = config.out; +const folder = config.tools.spin3.folder; +const sparql2spin = config.tools.triplify.exec + +exports.exec = async function(options, data, query) { + const subTask = options.subTask; + + const times = [] + + // const spin_file = `${folder}/out/query.spin` + const spin_file = `${out}/query.spin` + let start = performance.now() + let cmd = `java -jar ${sparql2spin} -sparql ${query} -multi;` + const [ spin_output, ] = await promiseExec(cmd); + let end = performance.now() + times.push(`generate spin: ${parseFloat(end - start).toFixed(0)}`) + + const [ num_constructs, spin_code ] = parseSpinOutput(spin_output); + await fs.writeFile(spin_file, spin_code); + + // const n3_file = `${folder}/out/n3query.n3` + const n3_file = `${out}/n3query.n3` + cmd = `eye ${spin_file} ${folder}/auxiliary-files/aux.n3 --query ${folder}/queries/query_general.n3 --nope --quantify http://eyereasoner.github.io/.well-known/genid/ > ${n3_file} 2>/dev/null;` + start = performance.now() + await promiseExec(cmd); + end = performance.now() + times.push(`generate n3: ${parseFloat(end - start).toFixed(0)}`) + + let eyeCmd = `eye ${folder}/auxiliary-files/runtime.n3 ${data} --query ${n3_file} --nope` + switch (subTask) { + case 'derivations': + eyeCmd += " --pass-only-new" + break + case 'deductive_closure': + eyeCmd += " --pass-all" + break + } + cmd = `${eyeCmd} 2>/dev/null;` + start = performance.now() + let [ output, ] = await promiseExec(cmd); + end = performance.now() + times.push(`execute n3: ${parseFloat(end - start).toFixed(0)}`) + + output = clean(output, data) + + // const spin = await fs.readFile(spin_file) + "" + // const n3 = await fs.readFile(n3_file) + "" + + return { + data: output, + times: times, + num_constructs: num_constructs, + spin: "out/query.spin", + n3: "out/n3query.n3" + } +} + +function parseSpinOutput(str) { + let sep = str.indexOf("\n\n"); + return [ str.substring(1, sep), str.substring(sep + 2) ]; +} \ No newline at end of file diff --git a/lib/tmp.js b/lib/tmp.js index d97d77f..6db732b 100644 --- a/lib/tmp.js +++ b/lib/tmp.js @@ -1,31 +1,32 @@ -var fs = require('fs') +var fs = require('fs/promises') -exports.save = function(contents, callback, file) { +async function exists (path) { + try { + await fs.access(path) + return true + } catch { + return false + } + } + +exports.save = async function(contents, file) { if (file === undefined) file = "tmp/tmp_" + new Date().valueOf() + ".n3" - if (!fs.existsSync("tmp")) - fs.mkdirSync("tmp") + if (!await exists("tmp")) + await fs.mkdir("tmp") // console.log("file?", file) - fs.exists(file, (exists) => { - if (exists) { - file = "tmp/tmp_" + new Date().valueOf() + "_2.n3" - exports.save(contents, callback, file) + if (await exists(file)) { + file = "tmp/tmp_" + new Date().valueOf() + "_2.n3" + return await exports.save(contents, file) - } else { - fs.writeFile(file, contents, (err) => { - if (err) throw err - // console.log("saved " + file) - callback(file) - }) - } - }) + } else { + await fs.writeFile(file, contents) + return file + } } -exports.del = function(file) { - fs.unlink(file, (err) => { - if (err) throw err - // console.log("deleted " + file) - }) +exports.del = async function(file) { + await fs.unlink(file) } diff --git a/lib/triplify/sparql2spin.jar b/lib/triplify/sparql2spin.jar new file mode 100644 index 0000000..5efaf8f Binary files /dev/null and b/lib/triplify/sparql2spin.jar differ diff --git a/lib/triplify/triplify.js b/lib/triplify/triplify.js new file mode 100644 index 0000000..81e5989 --- /dev/null +++ b/lib/triplify/triplify.js @@ -0,0 +1,23 @@ +let { promiseExec } = require('../cmd_util.js') +var { config } = require('../../config.js') + +const jarFile = config.tools.triplify.exec; + +exports.exec = async function(options, file) { + const cmd = `java -jar ${jarFile} -sparql ${file}`; + console.log(cmd); + + let [ stdout, stderr ] = await promiseExec(cmd) + + if (stderr != "") { + if (stderr.trim().startsWith("Picked up JAVA_TOOL_OPTIONS")) + stderr = stderr.substring(stderr.indexOf("\n") + 1).trim(); + + // console.log("stderr? ", stderr); + if (stderr) { + throw stderr + } + } + + return stdout +} \ No newline at end of file diff --git a/nordicspa/nordicspa.jar b/nordicspa/nordicspa.jar new file mode 100644 index 0000000..f5ced3d Binary files /dev/null and b/nordicspa/nordicspa.jar differ diff --git a/nordicspa/work.sh b/nordicspa/work.sh new file mode 100755 index 0000000..8afa440 --- /dev/null +++ b/nordicspa/work.sh @@ -0,0 +1 @@ +java -jar nordicspa/nordicspa.jar -days sat,sun -months 2023-03 -num 4 -recip william.van.woensel@gmail.com,kelseyatjones@gmail.com diff --git a/opt/eye/bin/eye b/opt/eye/bin/eye index 2776667..c2bbcaa 100755 --- a/opt/eye/bin/eye +++ b/opt/eye/bin/eye @@ -1,3 +1,3 @@ #!/bin/sh -swipl -x /opt/eye/lib/eye.pvm -- "$@" # ppr -#swipl -x opt/eye/lib/eye.pvm -- "$@" # local +swipl -x /app/opt/eye/lib/eye.pvm -- "$@" +#swipl -x opt/eye/lib/eye.pvm -- "$@" diff --git a/opt/eye/lib/eye.pvm b/opt/eye/lib/eye.pvm index f192a3c..385be87 100755 Binary files a/opt/eye/lib/eye.pvm and b/opt/eye/lib/eye.pvm differ diff --git a/out/n3query.n3 b/out/n3query.n3 new file mode 100644 index 0000000..e62dda8 --- /dev/null +++ b/out/n3query.n3 @@ -0,0 +1,32 @@ +# Processed by EYE v4.6.0 (2023-07-14) +# eye /Users/wvw/git/n3/n3-editor-js/out/query.spin /Users/wvw/git/n3/n3-editor-js/lib/spin3/auxiliary-files/aux.n3 --query /Users/wvw/git/n3/n3-editor-js/lib/spin3/queries/query_general.n3 --nope --quantify http://eyereasoner.github.io/.well-known/genid/ + +@prefix string: . +@prefix list: . +@prefix log: . +@prefix xsd: . +@prefix rdfs: . +@prefix spin: . +@prefix sp: . +@prefix ex: . +@prefix aux: . +@prefix math: . +@prefix time: . +@prefix crypto: . +@prefix rdf: . +@prefix e: . +@prefix var: . + +{ + ?t_3 ?t_4. +} => { + ?t_4 _:t_5 ?t_3. +}. +{ + ?t_3 ?t_5 ?t_4. +} => { + ?t_4 ?t_5 ?t_3. +}. +# 2023-07-16T14:22:08.088Z in=154 out=2 ent=2 step=2 brake=2 inf=381231 sec=0.040 inf/sec=9530775 +# ENDS + diff --git a/out/query.spin b/out/query.spin new file mode 100644 index 0000000..ec135c2 --- /dev/null +++ b/out/query.spin @@ -0,0 +1,64 @@ + + + [ a ; + + ([ + [ + "z" + ] ; + + [ + "y" + ] ; + + [ + "x" + ] + ]) ; + + ([ + [ + "x" + ] ; + + ; + + [ + "z" + ] + ]) + ] . +# 1 + + + + [ a ; + + ([ + [ + "z" + ] ; + + [ + "y" + ] ; + + [ + "x" + ] + ]) ; + + ([ + [ + "x" + ] ; + + [ + "y" + ] ; + + [ + "z" + ] + ]) + ] . diff --git a/package-lock.json b/package-lock.json index 7314d69..4c0e3f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,17 +9,35 @@ "version": "0.0.1", "license": "see license in LICENSE", "dependencies": { + "@egjs/hammerjs": "^2.0.0", "@mysql/xdevapi": "8.0.22", + "@syntaxica/lib": "^0.0.13", "antlr4": "^4.10.1", + "base64-js": "^1.5.1", "body-parser": "^1.19.0", + "component-emitter": "^1.3.0", "cors": "^2.8.5", "dateformat": "^4.3.1", "express": "^4.17.1", + "fuse.js": "^6.6.2", + "html-react-parser": "^3.0.16", + "keycharm": "^0.4.0", "mysql": "^2.18.1", - "randomstring": "^1.1.5" + "pako": "^2.1.0", + "prismjs": "^1.29.0", + "randomstring": "^1.1.5", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-simple-code-editor": "^0.13.1", + "text-encoding-utf-8": "^1.0.2", + "timsort": "^0.3.0", + "uuid": "^9.0.0", + "vis-data": "^7.0.0", + "vis-network": "9.1.6", + "vis-util": "^5.0.1" }, "devDependencies": { - "webpack": "^5.73.0", + "webpack": "^5.75.0", "webpack-cli": "^4.10.0" } }, @@ -32,6 +50,17 @@ "node": ">=10.0.0" } }, + "node_modules/@egjs/hammerjs": { + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/@egjs/hammerjs/-/hammerjs-2.0.17.tgz", + "integrity": "sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==", + "dependencies": { + "@types/hammerjs": "^2.0.36" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/@mysql/xdevapi": { "version": "8.0.22", "resolved": "https://registry.npmjs.org/@mysql/xdevapi/-/xdevapi-8.0.22.tgz", @@ -45,6 +74,31 @@ "node": ">=4.2.0" } }, + "node_modules/@syntaxica/antlr": { + "version": "4.12.0-2", + "resolved": "https://registry.npmjs.org/@syntaxica/antlr/-/antlr-4.12.0-2.tgz", + "integrity": "sha512-0mIFOI7spnQFM2XGWBw7/EfNizrF/9DjIMjpI2blxwlsau5hPKm37Z/fumwRfVJCwf1Vslozb4cZGnbOc28Nfw==" + }, + "node_modules/@syntaxica/lib": { + "version": "0.0.13", + "resolved": "https://registry.npmjs.org/@syntaxica/lib/-/lib-0.0.13.tgz", + "integrity": "sha512-fHUaA14TuquPlPuw65TIVlv5V895HPTvwdRULbip6xqONCMVkeqzXmsmi7WWkRFL2W70y+ovOVNI/OX4yizClw==", + "dependencies": { + "@syntaxica/antlr": "^4.12.0-2", + "commander": "^11.0.0" + }, + "bin": { + "stxa": "dist/cli.js" + } + }, + "node_modules/@syntaxica/lib/node_modules/commander": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.0.0.tgz", + "integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==", + "engines": { + "node": ">=16" + } + }, "node_modules/@types/eslint": { "version": "8.4.5", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.5.tgz", @@ -71,6 +125,11 @@ "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", "dev": true }, + "node_modules/@types/hammerjs": { + "version": "2.0.41", + "resolved": "https://registry.npmjs.org/@types/hammerjs/-/hammerjs-2.0.41.tgz", + "integrity": "sha512-ewXv/ceBaJprikMcxCmWU1FKyMAQ2X7a9Gtmzw8fcg2kIePI1crERDM818W+XYrxqdBBOdlf2rm137bU+BltCA==" + }, "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -290,9 +349,9 @@ } }, "node_modules/acorn": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz", - "integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -356,6 +415,25 @@ "node": ">=0.10.0" } }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/bignumber.js": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", @@ -466,6 +544,11 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "node_modules/component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" + }, "node_modules/content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -558,6 +641,57 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -590,6 +724,17 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", @@ -792,6 +937,14 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "node_modules/fuse.js": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", + "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==", + "engines": { + "node": ">=10" + } + }, "node_modules/glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", @@ -830,6 +983,47 @@ "node": ">=8" } }, + "node_modules/html-dom-parser": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-3.1.7.tgz", + "integrity": "sha512-cDgNF4YgF6J3H+d9mcldGL19p0GzVdS3iGuDNzYWQpU47q3+IRM85X3Xo07E+nntF4ek4s78A9V24EwxlPTjig==", + "dependencies": { + "domhandler": "5.0.3", + "htmlparser2": "8.0.2" + } + }, + "node_modules/html-react-parser": { + "version": "3.0.16", + "resolved": "https://registry.npmjs.org/html-react-parser/-/html-react-parser-3.0.16.tgz", + "integrity": "sha512-ysQZtRFPcg+McVb4B05oNWSnqM14zagpvTgGcI5e1/BvCl38YwzWzKibrbBmXeemg70olN1bAoeixo7o06G5Eg==", + "dependencies": { + "domhandler": "5.0.3", + "html-dom-parser": "3.1.7", + "react-property": "2.0.0", + "style-to-js": "1.1.3" + }, + "peerDependencies": { + "react": "0.14 || 15 || 16 || 17 || 18" + } + }, + "node_modules/htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, "node_modules/http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -877,6 +1071,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "node_modules/inline-style-parser": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz", + "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==" + }, "node_modules/interpret": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", @@ -952,6 +1151,11 @@ "node": ">= 10.13.0" } }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -964,6 +1168,11 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "node_modules/keycharm": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/keycharm/-/keycharm-0.4.0.tgz", + "integrity": "sha512-TyQTtsabOVv3MeOpR92sIKk/br9wxS+zGj4BG7CR8YbK4jM3tyIBaF0zhzeBUMx36/Q/iQLOKKOT+3jOQtemRQ==" + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -994,6 +1203,17 @@ "node": ">=8" } }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -1160,6 +1380,11 @@ "node": ">=6" } }, + "node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -1220,6 +1445,14 @@ "node": ">=8" } }, + "node_modules/prismjs": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", + "engines": { + "node": ">=6" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -1299,6 +1532,43 @@ "node": ">= 0.8" } }, + "node_modules/react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", + "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/react-property": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/react-property/-/react-property-2.0.0.tgz", + "integrity": "sha512-kzmNjIgU32mO4mmH5+iUyrqlpFQhF8K2k7eZ4fdLSOPFrD1XgEuSBv9LDEgxRXTMBqMd8ppT0x6TIzqE5pdGdw==" + }, + "node_modules/react-simple-code-editor": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/react-simple-code-editor/-/react-simple-code-editor-0.13.1.tgz", + "integrity": "sha512-XYeVwRZwgyKtjNIYcAEgg2FaQcCZwhbarnkJIV20U2wkCU9q/CPFBo8nRXrK4GXUz3AvbqZFsZRrpUTkqqEYyQ==", + "peerDependencies": { + "react": "*", + "react-dom": "*" + } + }, "node_modules/readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -1369,6 +1639,14 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/scheduler": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", + "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -1519,6 +1797,22 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/style-to-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.3.tgz", + "integrity": "sha512-zKI5gN/zb7LS/Vm0eUwjmjrXWw8IMtyA8aPBJZdYiQTXj4+wQ3IucOLIOnF7zCHxvW8UhIGh/uZh/t9zEHXNTQ==", + "dependencies": { + "style-to-object": "0.4.1" + } + }, + "node_modules/style-to-object": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.4.1.tgz", + "integrity": "sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==", + "dependencies": { + "inline-style-parser": "0.1.1" + } + }, "node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -1604,6 +1898,16 @@ "node": ">= 8" } }, + "node_modules/text-encoding-utf-8": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" + }, + "node_modules/timsort": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", + "integrity": "sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==" + }, "node_modules/toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -1654,6 +1958,14 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -1662,6 +1974,55 @@ "node": ">= 0.8" } }, + "node_modules/vis-data": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/vis-data/-/vis-data-7.1.6.tgz", + "integrity": "sha512-lG7LJdkawlKSXsdcEkxe/zRDyW29a4r7N7PMwxCPxK12/QIdqxJwcMxwjVj9ozdisRhP5TyWDHZwsgjmj0g6Dg==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/visjs" + }, + "peerDependencies": { + "uuid": "^3.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "vis-util": "^5.0.1" + } + }, + "node_modules/vis-network": { + "version": "9.1.6", + "resolved": "https://registry.npmjs.org/vis-network/-/vis-network-9.1.6.tgz", + "integrity": "sha512-Eiwx1JleAsUqfy4pzcsFngCVlCEdjAtRPB/OwCV7PHBm+o2jtE4IZPcPITAEGUlxvL4Fdw7/lZsfD32dL+IL6g==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/visjs" + }, + "peerDependencies": { + "@egjs/hammerjs": "^2.0.0", + "component-emitter": "^1.3.0", + "keycharm": "^0.2.0 || ^0.3.0 || ^0.4.0", + "timsort": "^0.3.0", + "uuid": "^3.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "vis-data": "^6.3.0 || ^7.0.0", + "vis-util": "^5.0.1" + } + }, + "node_modules/vis-util": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/vis-util/-/vis-util-5.0.3.tgz", + "integrity": "sha512-Wf9STUcFrDzK4/Zr7B6epW2Kvm3ORNWF+WiwEz2dpf5RdWkLUXFSbLcuB88n1W6tCdFwVN+v3V4/Xmn9PeL39g==", + "engines": { + "node": ">=8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/visjs" + }, + "peerDependencies": { + "@egjs/hammerjs": "^2.0.0", + "component-emitter": "^1.3.0" + } + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", @@ -1676,9 +2037,9 @@ } }, "node_modules/webpack": { - "version": "5.73.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.73.0.tgz", - "integrity": "sha512-svjudQRPPa0YiOYa2lM/Gacw0r6PvxptHj4FuEKQ2kX05ZLkjbVc5MnPs6its5j7IZljnIqSVo/OsY2X0IpHGA==", + "version": "5.75.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz", + "integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==", "dev": true, "dependencies": { "@types/eslint-scope": "^3.7.3", @@ -1686,11 +2047,11 @@ "@webassemblyjs/ast": "1.11.1", "@webassemblyjs/wasm-edit": "1.11.1", "@webassemblyjs/wasm-parser": "1.11.1", - "acorn": "^8.4.1", + "acorn": "^8.7.1", "acorn-import-assertions": "^1.7.6", "browserslist": "^4.14.5", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.9.3", + "enhanced-resolve": "^5.10.0", "es-module-lexer": "^0.9.0", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -1703,7 +2064,7 @@ "schema-utils": "^3.1.0", "tapable": "^2.1.1", "terser-webpack-plugin": "^5.1.3", - "watchpack": "^2.3.1", + "watchpack": "^2.4.0", "webpack-sources": "^3.2.3" }, "bin": { @@ -1841,6 +2202,14 @@ "integrity": "sha512-6nFkfkmSeV/rqSaS4oWHgmpnYw194f6hmWF5is6b0J1naJZoiD0NTc9AiUwPHvWsowkjuHErCZT1wa0jg+BLIA==", "dev": true }, + "@egjs/hammerjs": { + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/@egjs/hammerjs/-/hammerjs-2.0.17.tgz", + "integrity": "sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==", + "requires": { + "@types/hammerjs": "^2.0.36" + } + }, "@mysql/xdevapi": { "version": "8.0.22", "resolved": "https://registry.npmjs.org/@mysql/xdevapi/-/xdevapi-8.0.22.tgz", @@ -1850,6 +2219,27 @@ "parsimmon": "1.6.2" } }, + "@syntaxica/antlr": { + "version": "4.12.0-2", + "resolved": "https://registry.npmjs.org/@syntaxica/antlr/-/antlr-4.12.0-2.tgz", + "integrity": "sha512-0mIFOI7spnQFM2XGWBw7/EfNizrF/9DjIMjpI2blxwlsau5hPKm37Z/fumwRfVJCwf1Vslozb4cZGnbOc28Nfw==" + }, + "@syntaxica/lib": { + "version": "0.0.13", + "resolved": "https://registry.npmjs.org/@syntaxica/lib/-/lib-0.0.13.tgz", + "integrity": "sha512-fHUaA14TuquPlPuw65TIVlv5V895HPTvwdRULbip6xqONCMVkeqzXmsmi7WWkRFL2W70y+ovOVNI/OX4yizClw==", + "requires": { + "@syntaxica/antlr": "^4.12.0-2", + "commander": "^11.0.0" + }, + "dependencies": { + "commander": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.0.0.tgz", + "integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==" + } + } + }, "@types/eslint": { "version": "8.4.5", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.5.tgz", @@ -1876,6 +2266,11 @@ "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", "dev": true }, + "@types/hammerjs": { + "version": "2.0.41", + "resolved": "https://registry.npmjs.org/@types/hammerjs/-/hammerjs-2.0.41.tgz", + "integrity": "sha512-ewXv/ceBaJprikMcxCmWU1FKyMAQ2X7a9Gtmzw8fcg2kIePI1crERDM818W+XYrxqdBBOdlf2rm137bU+BltCA==" + }, "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -2079,9 +2474,9 @@ } }, "acorn": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz", - "integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true }, "acorn-import-assertions": { @@ -2125,6 +2520,11 @@ "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz", "integrity": "sha1-X8w3OSB3VyPP1k1lxkvvU7+eum0=" }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, "bignumber.js": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", @@ -2206,6 +2606,11 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" + }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -2277,6 +2682,39 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + } + }, + "domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==" + }, + "domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "requires": { + "domelementtype": "^2.3.0" + } + }, + "domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "requires": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -2303,6 +2741,11 @@ "tapable": "^2.2.0" } }, + "entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==" + }, "envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", @@ -2465,6 +2908,11 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "fuse.js": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", + "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==" + }, "glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", @@ -2497,6 +2945,37 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, + "html-dom-parser": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-3.1.7.tgz", + "integrity": "sha512-cDgNF4YgF6J3H+d9mcldGL19p0GzVdS3iGuDNzYWQpU47q3+IRM85X3Xo07E+nntF4ek4s78A9V24EwxlPTjig==", + "requires": { + "domhandler": "5.0.3", + "htmlparser2": "8.0.2" + } + }, + "html-react-parser": { + "version": "3.0.16", + "resolved": "https://registry.npmjs.org/html-react-parser/-/html-react-parser-3.0.16.tgz", + "integrity": "sha512-ysQZtRFPcg+McVb4B05oNWSnqM14zagpvTgGcI5e1/BvCl38YwzWzKibrbBmXeemg70olN1bAoeixo7o06G5Eg==", + "requires": { + "domhandler": "5.0.3", + "html-dom-parser": "3.1.7", + "react-property": "2.0.0", + "style-to-js": "1.1.3" + } + }, + "htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -2532,6 +3011,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "inline-style-parser": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz", + "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==" + }, "interpret": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", @@ -2589,6 +3073,11 @@ "supports-color": "^8.0.0" } }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, "json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -2601,6 +3090,11 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "keycharm": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/keycharm/-/keycharm-0.4.0.tgz", + "integrity": "sha512-TyQTtsabOVv3MeOpR92sIKk/br9wxS+zGj4BG7CR8YbK4jM3tyIBaF0zhzeBUMx36/Q/iQLOKKOT+3jOQtemRQ==" + }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -2622,6 +3116,14 @@ "p-locate": "^4.1.0" } }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -2742,6 +3244,11 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -2790,6 +3297,11 @@ "find-up": "^4.0.0" } }, + "prismjs": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==" + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -2848,6 +3360,34 @@ "unpipe": "1.0.0" } }, + "react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "requires": { + "loose-envify": "^1.1.0" + } + }, + "react-dom": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", + "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "requires": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + } + }, + "react-property": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/react-property/-/react-property-2.0.0.tgz", + "integrity": "sha512-kzmNjIgU32mO4mmH5+iUyrqlpFQhF8K2k7eZ4fdLSOPFrD1XgEuSBv9LDEgxRXTMBqMd8ppT0x6TIzqE5pdGdw==" + }, + "react-simple-code-editor": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/react-simple-code-editor/-/react-simple-code-editor-0.13.1.tgz", + "integrity": "sha512-XYeVwRZwgyKtjNIYcAEgg2FaQcCZwhbarnkJIV20U2wkCU9q/CPFBo8nRXrK4GXUz3AvbqZFsZRrpUTkqqEYyQ==", + "requires": {} + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -2906,6 +3446,14 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "scheduler": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", + "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "requires": { + "loose-envify": "^1.1.0" + } + }, "schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -3027,6 +3575,22 @@ "safe-buffer": "~5.1.0" } }, + "style-to-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.3.tgz", + "integrity": "sha512-zKI5gN/zb7LS/Vm0eUwjmjrXWw8IMtyA8aPBJZdYiQTXj4+wQ3IucOLIOnF7zCHxvW8UhIGh/uZh/t9zEHXNTQ==", + "requires": { + "style-to-object": "0.4.1" + } + }, + "style-to-object": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.4.1.tgz", + "integrity": "sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==", + "requires": { + "inline-style-parser": "0.1.1" + } + }, "supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -3075,6 +3639,16 @@ "terser": "^5.7.2" } }, + "text-encoding-utf-8": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" + }, + "timsort": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", + "integrity": "sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==" + }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -3113,11 +3687,34 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "vis-data": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/vis-data/-/vis-data-7.1.6.tgz", + "integrity": "sha512-lG7LJdkawlKSXsdcEkxe/zRDyW29a4r7N7PMwxCPxK12/QIdqxJwcMxwjVj9ozdisRhP5TyWDHZwsgjmj0g6Dg==", + "requires": {} + }, + "vis-network": { + "version": "9.1.6", + "resolved": "https://registry.npmjs.org/vis-network/-/vis-network-9.1.6.tgz", + "integrity": "sha512-Eiwx1JleAsUqfy4pzcsFngCVlCEdjAtRPB/OwCV7PHBm+o2jtE4IZPcPITAEGUlxvL4Fdw7/lZsfD32dL+IL6g==", + "requires": {} + }, + "vis-util": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/vis-util/-/vis-util-5.0.3.tgz", + "integrity": "sha512-Wf9STUcFrDzK4/Zr7B6epW2Kvm3ORNWF+WiwEz2dpf5RdWkLUXFSbLcuB88n1W6tCdFwVN+v3V4/Xmn9PeL39g==", + "requires": {} + }, "watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", @@ -3129,9 +3726,9 @@ } }, "webpack": { - "version": "5.73.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.73.0.tgz", - "integrity": "sha512-svjudQRPPa0YiOYa2lM/Gacw0r6PvxptHj4FuEKQ2kX05ZLkjbVc5MnPs6its5j7IZljnIqSVo/OsY2X0IpHGA==", + "version": "5.75.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz", + "integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==", "dev": true, "requires": { "@types/eslint-scope": "^3.7.3", @@ -3139,11 +3736,11 @@ "@webassemblyjs/ast": "1.11.1", "@webassemblyjs/wasm-edit": "1.11.1", "@webassemblyjs/wasm-parser": "1.11.1", - "acorn": "^8.4.1", + "acorn": "^8.7.1", "acorn-import-assertions": "^1.7.6", "browserslist": "^4.14.5", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.9.3", + "enhanced-resolve": "^5.10.0", "es-module-lexer": "^0.9.0", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -3156,7 +3753,7 @@ "schema-utils": "^3.1.0", "tapable": "^2.1.1", "terser-webpack-plugin": "^5.1.3", - "watchpack": "^2.3.1", + "watchpack": "^2.4.0", "webpack-sources": "^3.2.3" } }, diff --git a/package.json b/package.json index f32d689..7cc04bf 100644 --- a/package.json +++ b/package.json @@ -14,10 +14,28 @@ "dateformat": "^4.3.1", "express": "^4.17.1", "mysql": "^2.18.1", - "randomstring": "^1.1.5" + "randomstring": "^1.1.5", + "@egjs/hammerjs": "^2.0.0", + "@syntaxica/lib": "^0.0.13", + "base64-js": "^1.5.1", + "component-emitter": "^1.3.0", + "fuse.js": "^6.6.2", + "html-react-parser": "^3.0.16", + "keycharm": "^0.4.0", + "pako": "^2.1.0", + "prismjs": "^1.29.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-simple-code-editor": "^0.13.1", + "text-encoding-utf-8": "^1.0.2", + "timsort": "^0.3.0", + "uuid": "^9.0.0", + "vis-data": "^7.0.0", + "vis-network": "9.1.6", + "vis-util": "^5.0.1" }, "devDependencies": { - "webpack": "^5.73.0", + "webpack": "^5.75.0", "webpack-cli": "^4.10.0" }, "scripts": { diff --git a/pe_out.ttl b/pe_out.ttl index 1c0694d..5bdbfdb 100644 --- a/pe_out.ttl +++ b/pe_out.ttl @@ -1,3 +1,81 @@ -#Processed by EYE v22.1105.2210 josd -#eye --n3 tmp/tmp_1670684286575.n3 --query target_out.ttl +# Processed by EYE v4.6.0 (2023-07-14) +# eye --n3 tmp/tmp_1689435880215.n3 --query target_out.ttl + +@prefix r: . +@prefix var: . +@prefix skolem: . +@prefix n3: . + +skolem:proof a r:Proof, r:Conjunction; + r:component skolem:lemma1; + r:component skolem:lemma2; + r:gives { + . + . + }. + +skolem:lemma1 a r:Inference; + r:gives { + . + }; + r:evidence ( + skolem:lemma3 + ); + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_0"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#b"]]; + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_1"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#a"]]; + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_2"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#c"]]; + r:rule skolem:lemma4. + +skolem:lemma2 a r:Inference; + r:gives { + . + }; + r:evidence ( + skolem:lemma5 + ); + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_0"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#b"]]; + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_1"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#c"]]; + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_2"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#a"]]; + r:rule skolem:lemma4. + +skolem:lemma3 a r:Extraction; + r:gives { + . + }; + r:because [ a r:Parsing; r:source ]. + +skolem:lemma4 a r:Extraction; + r:gives { + @forAll var:x_0, var:x_1, var:x_2. { + var:x_1 var:x_0 var:x_2. + } => { + var:x_1 var:x_0 var:x_2. + }. + }; + r:because [ a r:Parsing; r:source ]. + +skolem:lemma5 a r:Inference; + r:gives { + . + }; + r:evidence ( + skolem:lemma3 + ); + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_0"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#b"]]; + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_1"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#a"]]; + r:binding [ r:variable [ n3:uri "http://eyereasoner.github.io/var#x_2"]; r:boundTo [ n3:uri "file:///Users/wvw/git/n3/n3-editor-js/tmp/tmp_1689435880215.n3#c"]]; + r:rule skolem:lemma6. + +skolem:lemma6 a r:Extraction; + r:gives { + @forAll var:x_0, var:x_1, var:x_2. { + var:x_1 var:x_0 var:x_2. + } => { + var:x_2 var:x_0 var:x_1. + }. + }; + r:because [ a r:Parsing; r:source ]. + +# 2023-07-15T15:44:40.324Z in=3 out=2 ent=3 step=7 brake=2 inf=24810 sec=0.024 inf/sec=1033750 +# ENDS diff --git a/system.properties b/system.properties new file mode 100644 index 0000000..eafd676 --- /dev/null +++ b/system.properties @@ -0,0 +1 @@ +java.runtime.version=17 diff --git a/target_out.ttl b/target_out.ttl index 8f40fa2..133ad74 100644 --- a/target_out.ttl +++ b/target_out.ttl @@ -1,7 +1,11 @@ -#Processed by EYE v22.1105.2210 josd -#eye --nope --n3 tmp/tmp_1670684286575.n3 --query /Users/wvw/git/n3/n3-editor-js/lib/eye/explain/query_heads.n3 +# Processed by EYE v4.6.0 (2023-07-14) +# eye --nope --n3 tmp/tmp_1689435880215.n3 --query /Users/wvw/git/n3/n3-editor-js/lib/eye/explain/query_heads.n3 - -#2022-12-10T14:58:06.656Z in=2 out=0 ent=0 step=0 brake=1 inf=17541 sec=0.035 inf/sec=501171 -#ENDS +{ + ?U_1 ?U_0 ?U_2. +} <= { + ?U_1 ?U_0 ?U_2. +}. +# 2023-07-15T15:44:40.289Z in=3 out=1 ent=2 step=5 brake=2 inf=19444 sec=0.038 inf/sec=511684 +# ENDS diff --git a/update_eye.sh b/update_eye.sh new file mode 100755 index 0000000..1a19992 --- /dev/null +++ b/update_eye.sh @@ -0,0 +1 @@ +cp /opt/eye/lib/eye.pvm opt/eye/lib \ No newline at end of file