From ea7a11844a2bdf3c4517ee98d7fae690737c2339 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Mon, 26 Feb 2024 17:58:53 -0700 Subject: [PATCH 1/4] simple interpreter --- src/interpreter/builtin_signatures.ts | 106 + src/interpreter/environment.ts | 44 + src/interpreter/index.ts | 12 +- src/interpreter/interpreter.ts | 160 + src/parser/grammar.pegjs | 1 + src/parser/parser.ts | 10584 ++++++++++++------------ src/utils/exception.ts | 10 +- test/interpreter.spec.ts | 12 + test/parser.spec.ts | 10 +- test/programs/add-1-3.cps | 3 +- 10 files changed, 5490 insertions(+), 5452 deletions(-) create mode 100644 src/interpreter/builtin_signatures.ts create mode 100644 src/interpreter/environment.ts create mode 100644 src/interpreter/interpreter.ts create mode 100644 test/interpreter.spec.ts diff --git a/src/interpreter/builtin_signatures.ts b/src/interpreter/builtin_signatures.ts new file mode 100644 index 0000000..4ed99a7 --- /dev/null +++ b/src/interpreter/builtin_signatures.ts @@ -0,0 +1,106 @@ +import { BadArgumentError } from '@/utils'; +import type { DenotableValueType } from '.'; + +export type Signature = Array>; + +export const primitiveOperationSignatures: Record = { + '+': [ + ['int', 'int', 'int'], + ['real', 'real', 'real'], + ['int', 'real', 'real'], + ['real', 'int', 'real'], + ], + '-': [ + ['int', 'int', 'int'], + ['real', 'real', 'real'], + ['int', 'real', 'real'], + ['real', 'int', 'real'], + ], + '*': [ + ['int', 'int', 'int'], + ['real', 'real', 'real'], + ['int', 'real', 'real'], + ['real', 'int', 'real'], + ], + '/': [ + ['int', 'int', 'int'], + ['real', 'real', 'real'], + ['int', 'real', 'real'], + ['real', 'int', 'real'], + ], + '%': [['int', 'int', 'int']], + '**': [ + ['int', 'int', 'int'], + ['real', 'real', 'real'], + ['int', 'real', 'real'], + ['real', 'int', 'real'], + ], + '>>': [['int', 'int', 'int']], + '<<': [['int', 'int', 'int']], + '&': [['int', 'int', 'int']], + '|': [['int', 'int', 'int']], + '^': [['int', 'int', 'int']], + '==': [ + ['int', 'int', 'int'], + ['real', 'real', 'int'], + ['string', 'string', 'int'], + ], + '!=': [ + ['int', 'int', 'int'], + ['real', 'real', 'int'], + ['string', 'string', 'int'], + ], + '<': [ + ['int', 'int', 'int'], + ['real', 'real', 'int'], + ], + '>': [ + ['int', 'int', 'int'], + ['real', 'real', 'int'], + ], + '<=': [ + ['int', 'int', 'int'], + ['real', 'real', 'int'], + ], + '>=': [ + ['int', 'int', 'int'], + ['real', 'real', 'int'], + ], + '&&': [['int', 'int', 'int']], + '||': [['int', 'int', 'int']], + '!': [['int', 'int']], +}; + +export const getResultingType = ( + opr: string, + types: DenotableValueType[], +): DenotableValueType | Signature => { + const signature = primitiveOperationSignatures[opr]; + if (!signature) { + throw new BadArgumentError(`Invalid operation: ${opr}`); + } + + const resultingType = signature.find(sig => { + if (sig.length !== types.length) { + return false; + } + + return sig.every((type, i) => { + if (Array.isArray(type)) { + return getResultingType( + opr, + types.map((t, j) => (i === j ? t : 'int')), + ); + } + return type === 'int' || type === types[i]; + }); + }); + + if (!resultingType) { + throw new TypeError( + `Invalid types for operation ${opr}: ${types.join(', ')}`, + ); + } + + return resultingType as DenotableValueType | Signature; +}; diff --git a/src/interpreter/environment.ts b/src/interpreter/environment.ts new file mode 100644 index 0000000..cd0ee5c --- /dev/null +++ b/src/interpreter/environment.ts @@ -0,0 +1,44 @@ +import { UnknownSymbolError } from '@/utils'; +import type { DenotableValue } from '.'; + +export class Environment { + private scope: Map; + private parent: Environment | null; + + constructor(parent: Environment | null = null) { + this.parent = parent; + this.scope = new Map(); + } + + public set(name: string, value: DenotableValue) { + this.scope.set(name, value); + } + + public get(name: string): DenotableValue { + if (this.scope.has(name)) { + return this.scope.get(name); + } + + if (this.parent) { + return this.parent.get(name); + } + + throw new UnknownSymbolError(`Undefined variable: ${name}`); + } + + public has(name: string): boolean { + if (this.scope.has(name)) { + return true; + } + + if (this.parent) { + return this.parent.has(name); + } + + return false; + } + + public createChild(): Environment { + return new Environment(this); + } +} diff --git a/src/interpreter/index.ts b/src/interpreter/index.ts index 4178c19..dbc2d63 100644 --- a/src/interpreter/index.ts +++ b/src/interpreter/index.ts @@ -1 +1,11 @@ -export const evaluate = async (ast: Program) => {}; +export type DenotableValueType = + | 'null' + | 'int' + | 'real' + | 'string' + | 'function' + | 'reference'; +export type DenotableValue = { type: DenotableValueType; value: any }; + +export * from './environment'; +export * from './interpreter'; diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts new file mode 100644 index 0000000..bf76f4f --- /dev/null +++ b/src/interpreter/interpreter.ts @@ -0,0 +1,160 @@ +import { + type ContinuationExpression, + type PrimitiveOperationExpression, + type Program, + type Value, +} from '@/parser'; +import { Environment, type DenotableValue } from '.'; +import { + BadArgumentError, + InvalidStateError, + NotImplementedError, + type TracingLogger, +} from '@/utils'; + +const evaluateValue = ( + value: Value, + env: Environment, + logger: TracingLogger, +): DenotableValue => { + if (typeof value === 'string') { + return { type: 'string', value }; + } + + if ('real' in value) { + return { type: 'real', value: value.real }; + } + if ('int' in value) { + return { type: 'int', value: value.int }; + } + if ('name' in value) { + logger.debug(`Evaluating variable: ${value.name}`); + return env.get(value.name); + } + + throw new InvalidStateError(`Invalid value: ${value}`); +}; + +const evaluatePrimitiveOperation = ( + { primitiveOperation }: PrimitiveOperationExpression, + env: Environment, + logger: TracingLogger, +) => { + const { opr, operands, resultBindings, continuations } = primitiveOperation; + if (operands.length !== 2) { + throw new BadArgumentError('Primitive operations must have 2 operands'); + } + + const operandValues = operands.map(operand => + evaluateValue(operand, env, logger.createChild('evaluteValue')), + ); + + const rightReducingOperations = { + '+': (acc: number, operand: { value: number }) => acc + operand.value, + '-': (acc: number, operand: { value: number }) => acc - operand.value, + '*': (acc: number, operand: { value: number }) => acc * operand.value, + }; + const leftReducingOperations = { + '/': (acc: number, operand: { value: number }) => acc / operand.value, + '%': (acc: number, operand: { value: number }) => acc % operand.value, + '**': (acc: number, operand: { value: number }) => acc ** operand.value, + '>>': (acc: number, operand: { value: number }) => acc >> operand.value, + '<<': (acc: number, operand: { value: number }) => acc << operand.value, + '&': (acc: number, operand: { value: number }) => acc & operand.value, + '|': (acc: number, operand: { value: number }) => acc | operand.value, + '^': (acc: number, operand: { value: number }) => acc ^ operand.value, + }; + const someNumberIsReal = operandValues.some(({ type }) => type === 'real'); + + let result: DenotableValue = { type: 'null', value: null }; + const continuationEnvironment = env.createChild(); + if (opr in rightReducingOperations) { + logger.debug('Evaluating right reducing operation: ' + opr); + const sum = operandValues.reduce( + rightReducingOperations[opr as keyof typeof rightReducingOperations], + 0, + ); + result = { type: someNumberIsReal ? 'real' : 'int', value: sum }; + + for (const binding of resultBindings) { + continuationEnvironment.set(binding.name, result); + } + } + if (opr in leftReducingOperations) { + logger.debug('Evaluating left reducing operation: ' + opr); + const [first, ...rest] = operandValues; + const sum = rest.reduce( + leftReducingOperations[opr as keyof typeof leftReducingOperations], + first.value, + ); + result = { type: someNumberIsReal ? 'real' : 'int', value: sum }; + + for (const binding of resultBindings) { + continuationEnvironment.set(binding.name, result); + } + } + + // return the result of the last continuation + return continuations.reduce((_, continuation, i) => { + const childLogger = logger.createChild(`continuation[${i}]`); + return evaluteContinuationExpression( + continuation, + continuationEnvironment, + childLogger, + ); + }, result); +}; + +const evaluteContinuationExpression = ( + expr: ContinuationExpression, + env: Environment, + logger: TracingLogger, +): DenotableValue => { + if ('primitiveOperation' in expr) { + logger.debug('Evaluating primitive operation'); + return evaluatePrimitiveOperation( + expr, + env, + logger.createChild('evaluatePrimitiveOperation'), + ); + } + + if ('record' in expr) { + throw new NotImplementedError('Continuation records are not supported yet'); + } + if ('select' in expr) { + throw new NotImplementedError('Continuation select is not supported yet'); + } + if ('offset' in expr) { + throw new NotImplementedError('Continuation offset is not supported yet'); + } + if ('application' in expr) { + throw new NotImplementedError( + 'Continuation application is not supported yet', + ); + } + if ('switch' in expr) { + throw new NotImplementedError('Continuation switch is not supported yet'); + } + if ('fix' in expr) { + throw new NotImplementedError('Continuation fix is not supported yet'); + } + + throw new InvalidStateError(`Invalid continuation expression: ${expr}`); +}; + +export const evaluate = async ( + ast: Program, + logger: TracingLogger, +): Promise => { + const environment = new Environment(); + + return ast.reduce((_, continuation, i) => { + const exprLogger = logger.createChild(`statement[${i}]`); + return evaluteContinuationExpression( + continuation as ContinuationExpression, + environment, + exprLogger, + ); + }, null); +}; diff --git a/src/parser/grammar.pegjs b/src/parser/grammar.pegjs index d267b58..66facc5 100644 --- a/src/parser/grammar.pegjs +++ b/src/parser/grammar.pegjs @@ -285,6 +285,7 @@ ComparisonOperation / "!" / ">" / "<" + / "||" Integer = digits:("-"? [0-9]+) !"." { return { int: parseInt(digits.join(''), 10) }; } diff --git a/src/parser/parser.ts b/src/parser/parser.ts index d38d5a9..802488f 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -1,5411 +1,5119 @@ /* eslint-disable */ -const peggyParser: { parse: any; SyntaxError: any; DefaultTracer?: any } = // @generated by Peggy 4.0.0. - // - // https://peggyjs.org/ - // @ts-ignore - (function () { - // @ts-ignore - 'use strict'; - // @ts-ignore - function peg$subclass(child, parent) { - // @ts-ignore - function C() { - // @ts-ignore - this.constructor = child; + +const peggyParser: {parse: any, SyntaxError: any, DefaultTracer?: any} = // @generated by Peggy 4.0.0. +// +// https://peggyjs.org/ +// @ts-ignore +(function() { +// @ts-ignore + "use strict"; + +// @ts-ignore +function peg$subclass(child, parent) { +// @ts-ignore + function C() { this.constructor = child; } +// @ts-ignore + C.prototype = parent.prototype; +// @ts-ignore + child.prototype = new C(); +} + +// @ts-ignore +function peg$SyntaxError(message, expected, found, location) { +// @ts-ignore + var self = Error.call(this, message); + // istanbul ignore next Check is a necessary evil to support older environments +// @ts-ignore + if (Object.setPrototypeOf) { +// @ts-ignore + Object.setPrototypeOf(self, peg$SyntaxError.prototype); + } +// @ts-ignore + self.expected = expected; +// @ts-ignore + self.found = found; +// @ts-ignore + self.location = location; +// @ts-ignore + self.name = "SyntaxError"; +// @ts-ignore + return self; +} + +// @ts-ignore +peg$subclass(peg$SyntaxError, Error); + +// @ts-ignore +function peg$padEnd(str, targetLength, padString) { +// @ts-ignore + padString = padString || " "; +// @ts-ignore + if (str.length > targetLength) { return str; } +// @ts-ignore + targetLength -= str.length; +// @ts-ignore + padString += padString.repeat(targetLength); +// @ts-ignore + return str + padString.slice(0, targetLength); +} + +// @ts-ignore +peg$SyntaxError.prototype.format = function(sources) { +// @ts-ignore + var str = "Error: " + this.message; +// @ts-ignore + if (this.location) { +// @ts-ignore + var src = null; +// @ts-ignore + var k; +// @ts-ignore + for (k = 0; k < sources.length; k++) { +// @ts-ignore + if (sources[k].source === this.location.source) { +// @ts-ignore + src = sources[k].text.split(/\r\n|\n|\r/g); +// @ts-ignore + break; } - // @ts-ignore - C.prototype = parent.prototype; - // @ts-ignore - child.prototype = new C(); } - - // @ts-ignore - function peg$SyntaxError(message, expected, found, location) { - // @ts-ignore - var self = Error.call(this, message); - // istanbul ignore next Check is a necessary evil to support older environments - // @ts-ignore - if (Object.setPrototypeOf) { - // @ts-ignore - Object.setPrototypeOf(self, peg$SyntaxError.prototype); - } - // @ts-ignore - self.expected = expected; - // @ts-ignore - self.found = found; - // @ts-ignore - self.location = location; - // @ts-ignore - self.name = 'SyntaxError'; - // @ts-ignore - return self; +// @ts-ignore + var s = this.location.start; +// @ts-ignore + var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) +// @ts-ignore + ? this.location.source.offset(s) +// @ts-ignore + : s; +// @ts-ignore + var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; +// @ts-ignore + if (src) { +// @ts-ignore + var e = this.location.end; +// @ts-ignore + var filler = peg$padEnd("", offset_s.line.toString().length, ' '); +// @ts-ignore + var line = src[s.line - 1]; +// @ts-ignore + var last = s.line === e.line ? e.column : line.length + 1; +// @ts-ignore + var hatLen = (last - s.column) || 1; +// @ts-ignore + str += "\n --> " + loc + "\n" +// @ts-ignore + + filler + " |\n" +// @ts-ignore + + offset_s.line + " | " + line + "\n" +// @ts-ignore + + filler + " | " + peg$padEnd("", s.column - 1, ' ') +// @ts-ignore + + peg$padEnd("", hatLen, "^"); +// @ts-ignore + } else { +// @ts-ignore + str += "\n at " + loc; } + } +// @ts-ignore + return str; +}; - // @ts-ignore - peg$subclass(peg$SyntaxError, Error); +// @ts-ignore +peg$SyntaxError.buildMessage = function(expected, found) { +// @ts-ignore + var DESCRIBE_EXPECTATION_FNS = { +// @ts-ignore + literal: function(expectation) { +// @ts-ignore + return "\"" + literalEscape(expectation.text) + "\""; + }, - // @ts-ignore - function peg$padEnd(str, targetLength, padString) { - // @ts-ignore - padString = padString || ' '; - // @ts-ignore - if (str.length > targetLength) { - return str; - } - // @ts-ignore - targetLength -= str.length; - // @ts-ignore - padString += padString.repeat(targetLength); - // @ts-ignore - return str + padString.slice(0, targetLength); +// @ts-ignore + class: function(expectation) { +// @ts-ignore + var escapedParts = expectation.parts.map(function(part) { +// @ts-ignore + return Array.isArray(part) +// @ts-ignore + ? classEscape(part[0]) + "-" + classEscape(part[1]) +// @ts-ignore + : classEscape(part); + }); + +// @ts-ignore + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; + }, + +// @ts-ignore + any: function() { +// @ts-ignore + return "any character"; + }, + +// @ts-ignore + end: function() { +// @ts-ignore + return "end of input"; + }, + +// @ts-ignore + other: function(expectation) { +// @ts-ignore + return expectation.description; } + }; - // @ts-ignore - peg$SyntaxError.prototype.format = function (sources) { - // @ts-ignore - var str = 'Error: ' + this.message; - // @ts-ignore - if (this.location) { - // @ts-ignore - var src = null; - // @ts-ignore - var k; - // @ts-ignore - for (k = 0; k < sources.length; k++) { - // @ts-ignore - if (sources[k].source === this.location.source) { - // @ts-ignore - src = sources[k].text.split(/\r\n|\n|\r/g); - // @ts-ignore - break; - } - } - // @ts-ignore - var s = this.location.start; - // @ts-ignore - var offset_s = - this.location.source && - typeof this.location.source.offset === 'function' - ? // @ts-ignore - this.location.source.offset(s) - : // @ts-ignore - s; - // @ts-ignore - var loc = - this.location.source + ':' + offset_s.line + ':' + offset_s.column; - // @ts-ignore - if (src) { - // @ts-ignore - var e = this.location.end; - // @ts-ignore - var filler = peg$padEnd('', offset_s.line.toString().length, ' '); - // @ts-ignore - var line = src[s.line - 1]; - // @ts-ignore - var last = s.line === e.line ? e.column : line.length + 1; - // @ts-ignore - var hatLen = last - s.column || 1; - // @ts-ignore - str += - '\n --> ' + - loc + - '\n' + - // @ts-ignore - filler + - ' |\n' + - // @ts-ignore - offset_s.line + - ' | ' + - line + - '\n' + - // @ts-ignore - filler + - ' | ' + - peg$padEnd('', s.column - 1, ' ') + - // @ts-ignore - peg$padEnd('', hatLen, '^'); - // @ts-ignore - } else { - // @ts-ignore - str += '\n at ' + loc; +// @ts-ignore + function hex(ch) { +// @ts-ignore + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + +// @ts-ignore + function literalEscape(s) { +// @ts-ignore + return s +// @ts-ignore + .replace(/\\/g, "\\\\") +// @ts-ignore + .replace(/"/g, "\\\"") +// @ts-ignore + .replace(/\0/g, "\\0") +// @ts-ignore + .replace(/\t/g, "\\t") +// @ts-ignore + .replace(/\n/g, "\\n") +// @ts-ignore + .replace(/\r/g, "\\r") +// @ts-ignore + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) +// @ts-ignore + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + +// @ts-ignore + function classEscape(s) { +// @ts-ignore + return s +// @ts-ignore + .replace(/\\/g, "\\\\") +// @ts-ignore + .replace(/\]/g, "\\]") +// @ts-ignore + .replace(/\^/g, "\\^") +// @ts-ignore + .replace(/-/g, "\\-") +// @ts-ignore + .replace(/\0/g, "\\0") +// @ts-ignore + .replace(/\t/g, "\\t") +// @ts-ignore + .replace(/\n/g, "\\n") +// @ts-ignore + .replace(/\r/g, "\\r") +// @ts-ignore + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) +// @ts-ignore + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + +// @ts-ignore + function describeExpectation(expectation) { +// @ts-ignore + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + +// @ts-ignore + function describeExpected(expected) { +// @ts-ignore + var descriptions = expected.map(describeExpectation); +// @ts-ignore + var i, j; + +// @ts-ignore + descriptions.sort(); + +// @ts-ignore + if (descriptions.length > 0) { +// @ts-ignore + for (i = 1, j = 1; i < descriptions.length; i++) { +// @ts-ignore + if (descriptions[i - 1] !== descriptions[i]) { +// @ts-ignore + descriptions[j] = descriptions[i]; +// @ts-ignore + j++; } } - // @ts-ignore - return str; - }; +// @ts-ignore + descriptions.length = j; + } - // @ts-ignore - peg$SyntaxError.buildMessage = function (expected, found) { - // @ts-ignore - var DESCRIBE_EXPECTATION_FNS = { - // @ts-ignore - literal: function (expectation) { - // @ts-ignore - return '"' + literalEscape(expectation.text) + '"'; - }, +// @ts-ignore + switch (descriptions.length) { +// @ts-ignore + case 1: +// @ts-ignore + return descriptions[0]; - // @ts-ignore - class: function (expectation) { - // @ts-ignore - var escapedParts = expectation.parts.map(function (part) { - // @ts-ignore - return Array.isArray(part) - ? // @ts-ignore - classEscape(part[0]) + '-' + classEscape(part[1]) - : // @ts-ignore - classEscape(part); - }); +// @ts-ignore + case 2: +// @ts-ignore + return descriptions[0] + " or " + descriptions[1]; - // @ts-ignore - return ( - '[' + - (expectation.inverted ? '^' : '') + - escapedParts.join('') + - ']' - ); - }, +// @ts-ignore + default: +// @ts-ignore + return descriptions.slice(0, -1).join(", ") +// @ts-ignore + + ", or " +// @ts-ignore + + descriptions[descriptions.length - 1]; + } + } - // @ts-ignore - any: function () { - // @ts-ignore - return 'any character'; - }, +// @ts-ignore + function describeFound(found) { +// @ts-ignore + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } - // @ts-ignore - end: function () { - // @ts-ignore - return 'end of input'; - }, +// @ts-ignore + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; +}; - // @ts-ignore - other: function (expectation) { - // @ts-ignore - return expectation.description; +// @ts-ignore +function peg$parse(input, options) { +// @ts-ignore + options = options !== undefined ? options : {}; + +// @ts-ignore + var peg$FAILED = {}; +// @ts-ignore + var peg$source = options.grammarSource; + +// @ts-ignore + var peg$startRuleFunctions = { Program: peg$parseProgram }; +// @ts-ignore + var peg$startRuleFunction = peg$parseProgram; + +// @ts-ignore + var peg$c0 = "**"; + var peg$c1 = "%"; + var peg$c2 = ">>"; + var peg$c3 = "<<"; + var peg$c4 = "=="; + var peg$c5 = "<="; + var peg$c6 = ">="; + var peg$c7 = "!="; + var peg$c8 = "||"; + var peg$c9 = "-"; + var peg$c10 = "."; + var peg$c11 = "'"; + var peg$c12 = "\""; + var peg$c13 = "OFFSET"; + var peg$c14 = "OFFp"; + var peg$c15 = "SELp"; + var peg$c16 = "VAR"; + var peg$c17 = "INT"; + var peg$c18 = "REAL"; + var peg$c19 = "STRING"; + var peg$c20 = "APP"; + var peg$c21 = "RECORD"; + var peg$c22 = "SELECT"; + var peg$c23 = "FIX"; + var peg$c24 = "SWITCH"; + var peg$c25 = "PRIMOP"; + var peg$c26 = "LABEL"; + var peg$c27 = "store"; + var peg$c28 = "update"; + var peg$c29 = "makeref"; + var peg$c30 = "makerefunboxed"; + var peg$c31 = "unboxedupdate"; + var peg$c32 = "subscript"; + var peg$c33 = "boxed"; + var peg$c34 = "_"; + var peg$c35 = "["; + var peg$c36 = "]"; + var peg$c37 = ","; + var peg$c38 = "="; + var peg$c39 = "("; + var peg$c40 = ")"; + var peg$c41 = "\r\n"; + + var peg$r0 = /^[A-Za-z]/; + var peg$r1 = /^[0-9A-Z_a-z]/; + var peg$r2 = /^[*-+\-\/]/; + var peg$r3 = /^[\^~]/; + var peg$r4 = /^[!<>]/; + var peg$r5 = /^[0-9]/; + var peg$r6 = /^[^']/; + var peg$r7 = /^[^"]/; + var peg$r8 = /^[\t-\n ]/; + + var peg$e0 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false); + var peg$e1 = peg$classExpectation([["0", "9"], ["A", "Z"], "_", ["a", "z"]], false, false); + var peg$e2 = peg$classExpectation([["*", "+"], "-", "/"], false, false); + var peg$e3 = peg$literalExpectation("**", false); + var peg$e4 = peg$literalExpectation("%", false); + var peg$e5 = peg$literalExpectation(">>", false); + var peg$e6 = peg$literalExpectation("<<", false); + var peg$e7 = peg$classExpectation(["^", "~"], false, false); + var peg$e8 = peg$literalExpectation("==", false); + var peg$e9 = peg$literalExpectation("<=", false); + var peg$e10 = peg$literalExpectation(">=", false); + var peg$e11 = peg$literalExpectation("!=", false); + var peg$e12 = peg$classExpectation(["!", "<", ">"], false, false); + var peg$e13 = peg$literalExpectation("||", false); + var peg$e14 = peg$literalExpectation("-", false); + var peg$e15 = peg$classExpectation([["0", "9"]], false, false); + var peg$e16 = peg$literalExpectation(".", false); + var peg$e17 = peg$literalExpectation("'", false); + var peg$e18 = peg$classExpectation(["'"], true, false); + var peg$e19 = peg$literalExpectation("\"", false); + var peg$e20 = peg$classExpectation(["\""], true, false); + var peg$e21 = peg$literalExpectation("OFFSET", false); + var peg$e22 = peg$literalExpectation("OFFp", false); + var peg$e23 = peg$literalExpectation("SELp", false); + var peg$e24 = peg$literalExpectation("VAR", false); + var peg$e25 = peg$literalExpectation("INT", false); + var peg$e26 = peg$literalExpectation("REAL", false); + var peg$e27 = peg$literalExpectation("STRING", false); + var peg$e28 = peg$literalExpectation("APP", false); + var peg$e29 = peg$literalExpectation("RECORD", false); + var peg$e30 = peg$literalExpectation("SELECT", false); + var peg$e31 = peg$literalExpectation("FIX", false); + var peg$e32 = peg$literalExpectation("SWITCH", false); + var peg$e33 = peg$literalExpectation("PRIMOP", false); + var peg$e34 = peg$literalExpectation("LABEL", false); + var peg$e35 = peg$literalExpectation("store", false); + var peg$e36 = peg$literalExpectation("update", false); + var peg$e37 = peg$literalExpectation("makeref", false); + var peg$e38 = peg$literalExpectation("makerefunboxed", false); + var peg$e39 = peg$literalExpectation("unboxedupdate", false); + var peg$e40 = peg$literalExpectation("subscript", false); + var peg$e41 = peg$literalExpectation("boxed", false); + var peg$e42 = peg$literalExpectation("_", false); + var peg$e43 = peg$literalExpectation("[", false); + var peg$e44 = peg$literalExpectation("]", false); + var peg$e45 = peg$literalExpectation(",", false); + var peg$e46 = peg$literalExpectation("=", false); + var peg$e47 = peg$literalExpectation("(", false); + var peg$e48 = peg$literalExpectation(")", false); + var peg$e49 = peg$classExpectation([["\t", "\n"], " "], false, false); + var peg$e50 = peg$literalExpectation("\r\n", false); +// @ts-ignore + + var peg$f0 = function(exprs) { +// @ts-ignore + return exprs.filter(x => !Array.isArray(x)); + };// @ts-ignore + + var peg$f1 = function(record, val, bind, continuation) {// @ts-ignore + return { select: { record, val, bind, continuation } }; };// @ts-ignore + + var peg$f2 = function(index, val, bind, continuation) {// @ts-ignore + return { offset: { index, val, bind, continuation } }; };// @ts-ignore + + var peg$f3 = function(identifiers, lastIdent) { +// @ts-ignore + return identifiers.length || lastIdent +// @ts-ignore + ? [...identifiers.map(x => x[0]), lastIdent] + : []; + };// @ts-ignore + + var peg$f4 = function(values, lastValue) { +// @ts-ignore + return values.length || lastValue +// @ts-ignore + ? [...values.map(x => x[0]), lastValue] + : []; + };// @ts-ignore + + var peg$f5 = function(switchIndex, continuations) {// @ts-ignore + return { switch: { switchIndex, continuations } }; };// @ts-ignore + + var peg$f6 = function(fn, args) { +// @ts-ignore + return { application: { fn, args } }; + };// @ts-ignore + + var peg$f7 = function(bindings, lastBinding) { +// @ts-ignore + return bindings.length || lastBinding +// @ts-ignore + ? [...bindings.map(x => x[0]), lastBinding] + : []; + };// @ts-ignore + + var peg$f8 = function(fixBindings, continuation) {// @ts-ignore + return { fix: { fixBindings, continuation } }; };// @ts-ignore + + var peg$f9 = function(continuations, lastContinuation) { +// @ts-ignore + return lastContinuation || continuations.length +// @ts-ignore + ? [...continuations.map(x => x[0]), lastContinuation] + : []; + };// @ts-ignore + + var peg$f10 = function(opr, operands, resultBindings, continuations) { +// @ts-ignore + return { +// @ts-ignore + primitiveOperation: { opr, operands, resultBindings, continuations }, + }; + };// @ts-ignore + + var peg$f11 = function(variable, offset) {// @ts-ignore + return { variable, offset }; };// @ts-ignore + + var peg$f12 = function(records, lastRecord) { +// @ts-ignore + return records.length || lastRecord +// @ts-ignore + ? [...records.map(x => x[0]), lastRecord] + : []; + };// @ts-ignore + + var peg$f13 = function(records, address, body) { +// @ts-ignore + return { +// @ts-ignore + record: { +// @ts-ignore + records, +// @ts-ignore + address, +// @ts-ignore + body, }, }; + };// @ts-ignore - // @ts-ignore - function hex(ch) { - // @ts-ignore - return ch.charCodeAt(0).toString(16).toUpperCase(); - } + var peg$f14 = function(ident) {// @ts-ignore + return ident; };// @ts-ignore - // @ts-ignore - function literalEscape(s) { - // @ts-ignore - return ( - s - // @ts-ignore - .replace(/\\/g, '\\\\') - // @ts-ignore - .replace(/"/g, '\\"') - // @ts-ignore - .replace(/\0/g, '\\0') - // @ts-ignore - .replace(/\t/g, '\\t') - // @ts-ignore - .replace(/\n/g, '\\n') - // @ts-ignore - .replace(/\r/g, '\\r') - // @ts-ignore - .replace(/[\x00-\x0F]/g, function (ch) { - return '\\x0' + hex(ch); - }) - // @ts-ignore - .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { - return '\\x' + hex(ch); - }) - ); - } + var peg$f15 = function(ident) {// @ts-ignore + return ident; };// @ts-ignore - // @ts-ignore - function classEscape(s) { - // @ts-ignore - return ( - s - // @ts-ignore - .replace(/\\/g, '\\\\') - // @ts-ignore - .replace(/\]/g, '\\]') - // @ts-ignore - .replace(/\^/g, '\\^') - // @ts-ignore - .replace(/-/g, '\\-') - // @ts-ignore - .replace(/\0/g, '\\0') - // @ts-ignore - .replace(/\t/g, '\\t') - // @ts-ignore - .replace(/\n/g, '\\n') - // @ts-ignore - .replace(/\r/g, '\\r') - // @ts-ignore - .replace(/[\x00-\x0F]/g, function (ch) { - return '\\x0' + hex(ch); - }) - // @ts-ignore - .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { - return '\\x' + hex(ch); - }) - ); - } + var peg$f16 = function(int) {// @ts-ignore + return int; };// @ts-ignore - // @ts-ignore - function describeExpectation(expectation) { - // @ts-ignore - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } + var peg$f17 = function(real) {// @ts-ignore + return real; };// @ts-ignore - // @ts-ignore - function describeExpected(expected) { - // @ts-ignore - var descriptions = expected.map(describeExpectation); - // @ts-ignore - var i, j; + var peg$f18 = function(string) {// @ts-ignore + return string; };// @ts-ignore - // @ts-ignore - descriptions.sort(); + var peg$f19 = function(offset) {// @ts-ignore + return offset; };// @ts-ignore - // @ts-ignore - if (descriptions.length > 0) { - // @ts-ignore - for (i = 1, j = 1; i < descriptions.length; i++) { - // @ts-ignore - if (descriptions[i - 1] !== descriptions[i]) { - // @ts-ignore - descriptions[j] = descriptions[i]; - // @ts-ignore - j++; - } - } - // @ts-ignore - descriptions.length = j; - } + var peg$f20 = function(offset) {// @ts-ignore + return offset; };// @ts-ignore - // @ts-ignore - switch (descriptions.length) { - // @ts-ignore - case 1: - // @ts-ignore - return descriptions[0]; + var peg$f21 = function(name) { +// @ts-ignore + return { name: name[0] + name[1].join('') }; + };// @ts-ignore - // @ts-ignore - case 2: - // @ts-ignore - return descriptions[0] + ' or ' + descriptions[1]; + var peg$f22 = function(digits) {// @ts-ignore + return { int: parseInt(digits.join(''), 10) }; };// @ts-ignore - // @ts-ignore - default: - // @ts-ignore - return ( - descriptions.slice(0, -1).join(', ') + - // @ts-ignore - ', or ' + - // @ts-ignore - descriptions[descriptions.length - 1] - ); - } - } + var peg$f23 = function(content) {// @ts-ignore + return content.join(''); };// @ts-ignore - // @ts-ignore - function describeFound(found) { - // @ts-ignore - return found ? '"' + literalEscape(found) + '"' : 'end of input'; - } + var peg$f24 = function(content) {// @ts-ignore + return content.join(''); };// @ts-ignore - // @ts-ignore - return ( - 'Expected ' + - describeExpected(expected) + - ' but ' + - describeFound(found) + - ' found.' - ); + var peg$f25 = function(value) { +// @ts-ignore + return { real: parseFloat( +// @ts-ignore + value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''), + ) }; }; - - // @ts-ignore - function peg$parse(input, options) { - // @ts-ignore - options = options !== undefined ? options : {}; - - // @ts-ignore - var peg$FAILED = {}; - // @ts-ignore - var peg$source = options.grammarSource; - - // @ts-ignore - var peg$startRuleFunctions = { Program: peg$parseProgram }; - // @ts-ignore - var peg$startRuleFunction = peg$parseProgram; - - // @ts-ignore - var peg$c0 = '**'; - var peg$c1 = '%'; - var peg$c2 = '>>'; - var peg$c3 = '<<'; - var peg$c4 = '=='; - var peg$c5 = '<='; - var peg$c6 = '>='; - var peg$c7 = '!='; - var peg$c8 = '-'; - var peg$c9 = '.'; - var peg$c10 = "'"; - var peg$c11 = '"'; - var peg$c12 = 'OFFSET'; - var peg$c13 = 'OFFp'; - var peg$c14 = 'SELp'; - var peg$c15 = 'VAR'; - var peg$c16 = 'INT'; - var peg$c17 = 'REAL'; - var peg$c18 = 'STRING'; - var peg$c19 = 'APP'; - var peg$c20 = 'RECORD'; - var peg$c21 = 'SELECT'; - var peg$c22 = 'FIX'; - var peg$c23 = 'SWITCH'; - var peg$c24 = 'PRIMOP'; - var peg$c25 = 'LABEL'; - var peg$c26 = 'store'; - var peg$c27 = 'update'; - var peg$c28 = 'makeref'; - var peg$c29 = 'makerefunboxed'; - var peg$c30 = 'unboxedupdate'; - var peg$c31 = 'subscript'; - var peg$c32 = 'boxed'; - var peg$c33 = '_'; - var peg$c34 = '['; - var peg$c35 = ']'; - var peg$c36 = ','; - var peg$c37 = '='; - var peg$c38 = '('; - var peg$c39 = ')'; - var peg$c40 = '\r\n'; - - var peg$r0 = /^[A-Za-z]/; - var peg$r1 = /^[0-9A-Z_a-z]/; - var peg$r2 = /^[*-+\-\/]/; - var peg$r3 = /^[\^~]/; - var peg$r4 = /^[!<>]/; - var peg$r5 = /^[0-9]/; - var peg$r6 = /^[^']/; - var peg$r7 = /^[^"]/; - var peg$r8 = /^[\t-\n ]/; - - var peg$e0 = peg$classExpectation( - [ - ['A', 'Z'], - ['a', 'z'], - ], - false, - false, - ); - var peg$e1 = peg$classExpectation( - [['0', '9'], ['A', 'Z'], '_', ['a', 'z']], - false, - false, - ); - var peg$e2 = peg$classExpectation([['*', '+'], '-', '/'], false, false); - var peg$e3 = peg$literalExpectation('**', false); - var peg$e4 = peg$literalExpectation('%', false); - var peg$e5 = peg$literalExpectation('>>', false); - var peg$e6 = peg$literalExpectation('<<', false); - var peg$e7 = peg$classExpectation(['^', '~'], false, false); - var peg$e8 = peg$literalExpectation('==', false); - var peg$e9 = peg$literalExpectation('<=', false); - var peg$e10 = peg$literalExpectation('>=', false); - var peg$e11 = peg$literalExpectation('!=', false); - var peg$e12 = peg$classExpectation(['!', '<', '>'], false, false); - var peg$e13 = peg$literalExpectation('-', false); - var peg$e14 = peg$classExpectation([['0', '9']], false, false); - var peg$e15 = peg$literalExpectation('.', false); - var peg$e16 = peg$literalExpectation("'", false); - var peg$e17 = peg$classExpectation(["'"], true, false); - var peg$e18 = peg$literalExpectation('"', false); - var peg$e19 = peg$classExpectation(['"'], true, false); - var peg$e20 = peg$literalExpectation('OFFSET', false); - var peg$e21 = peg$literalExpectation('OFFp', false); - var peg$e22 = peg$literalExpectation('SELp', false); - var peg$e23 = peg$literalExpectation('VAR', false); - var peg$e24 = peg$literalExpectation('INT', false); - var peg$e25 = peg$literalExpectation('REAL', false); - var peg$e26 = peg$literalExpectation('STRING', false); - var peg$e27 = peg$literalExpectation('APP', false); - var peg$e28 = peg$literalExpectation('RECORD', false); - var peg$e29 = peg$literalExpectation('SELECT', false); - var peg$e30 = peg$literalExpectation('FIX', false); - var peg$e31 = peg$literalExpectation('SWITCH', false); - var peg$e32 = peg$literalExpectation('PRIMOP', false); - var peg$e33 = peg$literalExpectation('LABEL', false); - var peg$e34 = peg$literalExpectation('store', false); - var peg$e35 = peg$literalExpectation('update', false); - var peg$e36 = peg$literalExpectation('makeref', false); - var peg$e37 = peg$literalExpectation('makerefunboxed', false); - var peg$e38 = peg$literalExpectation('unboxedupdate', false); - var peg$e39 = peg$literalExpectation('subscript', false); - var peg$e40 = peg$literalExpectation('boxed', false); - var peg$e41 = peg$literalExpectation('_', false); - var peg$e42 = peg$literalExpectation('[', false); - var peg$e43 = peg$literalExpectation(']', false); - var peg$e44 = peg$literalExpectation(',', false); - var peg$e45 = peg$literalExpectation('=', false); - var peg$e46 = peg$literalExpectation('(', false); - var peg$e47 = peg$literalExpectation(')', false); - var peg$e48 = peg$classExpectation([['\t', '\n'], ' '], false, false); - var peg$e49 = peg$literalExpectation('\r\n', false); - // @ts-ignore - - var peg$f0 = function (exprs) { - // @ts-ignore - return exprs.filter(x => !Array.isArray(x)); - }; // @ts-ignore - - var peg$f1 = function (record, val, bind, continuation) { - // @ts-ignore - return { select: { record, val, bind, continuation } }; - }; // @ts-ignore - - var peg$f2 = function (index, val, bind, continuation) { - // @ts-ignore - return { offset: { index, val, bind, continuation } }; - }; // @ts-ignore - - var peg$f3 = function (identifiers, lastIdent) { - // @ts-ignore - return identifiers.length || lastIdent - ? // @ts-ignore - [...identifiers.map(x => x[0]), lastIdent] - : []; - }; // @ts-ignore - - var peg$f4 = function (values, lastValue) { - // @ts-ignore - return values.length || lastValue - ? // @ts-ignore - [...values.map(x => x[0]), lastValue] - : []; - }; // @ts-ignore - - var peg$f5 = function (switchIndex, continuations) { - // @ts-ignore - return { switch: { switchIndex, continuations } }; - }; // @ts-ignore - - var peg$f6 = function (fn, args) { - // @ts-ignore - return { application: { fn, args } }; - }; // @ts-ignore - - var peg$f7 = function (bindings, lastBinding) { - // @ts-ignore - return bindings.length || lastBinding - ? // @ts-ignore - [...bindings.map(x => x[0]), lastBinding] - : []; - }; // @ts-ignore - - var peg$f8 = function (fixBindings, continuation) { - // @ts-ignore - return { fix: { fixBindings, continuation } }; - }; // @ts-ignore - - var peg$f9 = function (continuations, lastContinuation) { - // @ts-ignore - return lastContinuation || continuations.length - ? // @ts-ignore - [...continuations.map(x => x[0]), lastContinuation] - : []; - }; // @ts-ignore - - var peg$f10 = function (opr, operands, resultBindings, continuations) { - // @ts-ignore - return { - // @ts-ignore - primitiveOperation: { opr, operands, resultBindings, continuations }, - }; - }; // @ts-ignore - - var peg$f11 = function (variable, offset) { - // @ts-ignore - return { variable, offset }; - }; // @ts-ignore - - var peg$f12 = function (records, lastRecord) { - // @ts-ignore - return records.length || lastRecord - ? // @ts-ignore - [...records.map(x => x[0]), lastRecord] - : []; - }; // @ts-ignore - - var peg$f13 = function (records, address, body) { - // @ts-ignore - return { - // @ts-ignore - record: { - // @ts-ignore - records, - // @ts-ignore - address, - // @ts-ignore - body, - }, - }; - }; // @ts-ignore - - var peg$f14 = function (ident) { - // @ts-ignore - return ident; - }; // @ts-ignore - - var peg$f15 = function (ident) { - // @ts-ignore - return ident; - }; // @ts-ignore - - var peg$f16 = function (int) { - // @ts-ignore - return int; - }; // @ts-ignore - - var peg$f17 = function (real) { - // @ts-ignore - return real; - }; // @ts-ignore - - var peg$f18 = function (string) { - // @ts-ignore - return string; - }; // @ts-ignore - - var peg$f19 = function (offset) { - // @ts-ignore - return offset; - }; // @ts-ignore - - var peg$f20 = function (offset) { - // @ts-ignore - return offset; - }; // @ts-ignore - - var peg$f21 = function (name) { - // @ts-ignore - return { name: name[0] + name[1].join('') }; - }; // @ts-ignore - - var peg$f22 = function (digits) { - // @ts-ignore - return { int: parseInt(digits.join(''), 10) }; - }; // @ts-ignore - - var peg$f23 = function (content) { - // @ts-ignore - return content.join(''); - }; // @ts-ignore - - var peg$f24 = function (content) { - // @ts-ignore - return content.join(''); - }; // @ts-ignore - - var peg$f25 = function (value) { - // @ts-ignore - return { - real: parseFloat( - // @ts-ignore - value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''), - ), - }; - }; - // @ts-ignore - var peg$currPos = options.peg$currPos | 0; - // @ts-ignore - var peg$savedPos = peg$currPos; - // @ts-ignore - var peg$posDetailsCache = [{ line: 1, column: 1 }]; - // @ts-ignore - var peg$maxFailPos = peg$currPos; - // @ts-ignore - var peg$maxFailExpected = options.peg$maxFailExpected || []; - // @ts-ignore - var peg$silentFails = options.peg$silentFails | 0; - - // @ts-ignore - var peg$result; - - // @ts-ignore - if (options.startRule) { - // @ts-ignore - if (!(options.startRule in peg$startRuleFunctions)) { - // @ts-ignore - throw new Error( - 'Can\'t start parsing from rule "' + options.startRule + '".', - ); - } - - // @ts-ignore - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - // @ts-ignore - function text() { - // @ts-ignore - return input.substring(peg$savedPos, peg$currPos); - } - - // @ts-ignore - function offset() { - // @ts-ignore - return peg$savedPos; - } - - // @ts-ignore - function range() { - // @ts-ignore - return { - // @ts-ignore - source: peg$source, - // @ts-ignore - start: peg$savedPos, - // @ts-ignore - end: peg$currPos, - }; - } - - // @ts-ignore - function location() { - // @ts-ignore - return peg$computeLocation(peg$savedPos, peg$currPos); - } - - // @ts-ignore - function expected(description, location) { - // @ts-ignore - location = - location !== undefined - ? // @ts-ignore - location - : // @ts-ignore - peg$computeLocation(peg$savedPos, peg$currPos); - - // @ts-ignore - throw peg$buildStructuredError( - // @ts-ignore - [peg$otherExpectation(description)], - // @ts-ignore - input.substring(peg$savedPos, peg$currPos), - // @ts-ignore - location, - ); - } - - // @ts-ignore - function error(message, location) { - // @ts-ignore - location = - location !== undefined - ? // @ts-ignore - location - : // @ts-ignore - peg$computeLocation(peg$savedPos, peg$currPos); - - // @ts-ignore - throw peg$buildSimpleError(message, location); - } - - // @ts-ignore - function peg$literalExpectation(text, ignoreCase) { - // @ts-ignore - return { type: 'literal', text: text, ignoreCase: ignoreCase }; - } - - // @ts-ignore - function peg$classExpectation(parts, inverted, ignoreCase) { - // @ts-ignore - return { - type: 'class', - parts: parts, - inverted: inverted, - ignoreCase: ignoreCase, - }; - } - - // @ts-ignore - function peg$anyExpectation() { - // @ts-ignore - return { type: 'any' }; - } - - // @ts-ignore - function peg$endExpectation() { - // @ts-ignore - return { type: 'end' }; - } - - // @ts-ignore - function peg$otherExpectation(description) { - // @ts-ignore - return { type: 'other', description: description }; - } - - // @ts-ignore - function peg$computePosDetails(pos) { - // @ts-ignore - var details = peg$posDetailsCache[pos]; - // @ts-ignore - var p; - - // @ts-ignore - if (details) { - // @ts-ignore - return details; - // @ts-ignore - } else { - // @ts-ignore - if (pos >= peg$posDetailsCache.length) { - // @ts-ignore - p = peg$posDetailsCache.length - 1; - // @ts-ignore - } else { - // @ts-ignore - p = pos; - // @ts-ignore - while (!peg$posDetailsCache[--p]) {} - } - - // @ts-ignore - details = peg$posDetailsCache[p]; - // @ts-ignore - details = { - // @ts-ignore - line: details.line, - // @ts-ignore - column: details.column, - }; - - // @ts-ignore - while (p < pos) { - // @ts-ignore - if (input.charCodeAt(p) === 10) { - // @ts-ignore - details.line++; - // @ts-ignore - details.column = 1; - // @ts-ignore - } else { - // @ts-ignore - details.column++; - } - - // @ts-ignore - p++; - } - - // @ts-ignore - peg$posDetailsCache[pos] = details; - - // @ts-ignore - return details; - } - } - - // @ts-ignore - function peg$computeLocation(startPos, endPos, offset) { - // @ts-ignore - var startPosDetails = peg$computePosDetails(startPos); - // @ts-ignore - var endPosDetails = peg$computePosDetails(endPos); - - // @ts-ignore - var res = { - // @ts-ignore - source: peg$source, - // @ts-ignore - start: { - // @ts-ignore - offset: startPos, - // @ts-ignore - line: startPosDetails.line, - // @ts-ignore - column: startPosDetails.column, - }, - // @ts-ignore - end: { - // @ts-ignore - offset: endPos, - // @ts-ignore - line: endPosDetails.line, - // @ts-ignore - column: endPosDetails.column, - }, - }; - // @ts-ignore - if (offset && peg$source && typeof peg$source.offset === 'function') { - // @ts-ignore - res.start = peg$source.offset(res.start); - // @ts-ignore - res.end = peg$source.offset(res.end); - } - // @ts-ignore - return res; - } - - // @ts-ignore - function peg$fail(expected) { - // @ts-ignore - if (peg$currPos < peg$maxFailPos) { - return; - } - - // @ts-ignore - if (peg$currPos > peg$maxFailPos) { - // @ts-ignore - peg$maxFailPos = peg$currPos; - // @ts-ignore - peg$maxFailExpected = []; - } - - // @ts-ignore - peg$maxFailExpected.push(expected); - } - - // @ts-ignore - function peg$buildSimpleError(message, location) { - // @ts-ignore - return new peg$SyntaxError(message, null, null, location); - } - - // @ts-ignore - function peg$buildStructuredError(expected, found, location) { - // @ts-ignore - return new peg$SyntaxError( - // @ts-ignore - peg$SyntaxError.buildMessage(expected, found), - // @ts-ignore - expected, - // @ts-ignore - found, - // @ts-ignore - location, - ); - } - - // @ts-ignore - function // @ts-ignore - peg$parseProgram() { - // @ts-ignore - var s0, s1, s2; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = []; - // @ts-ignore - s2 = peg$parseContinuationExpression(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - } - // @ts-ignore - while (s2 !== peg$FAILED) { - // @ts-ignore - s1.push(s2); - // @ts-ignore - s2 = peg$parseContinuationExpression(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - } - } - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s1 = peg$f0(s1); - // @ts-ignore - s0 = s1; - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseContinuationExpression() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = peg$parseRecordExpression(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseSelectExpression(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseOffsetExpression(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseApplicationExpression(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseFixExpression(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseSwitchExpression(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parsePrimitiveOperationExpression(); - } - } - } - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSelectExpression() { - // @ts-ignore - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseSELECT(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseInteger(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseValue(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseCOMMA(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - s12 = peg$parse_(); - // @ts-ignore - if (s12 === peg$FAILED) { - // @ts-ignore - s12 = null; - } - // @ts-ignore - s13 = peg$parseIdentifier(); - // @ts-ignore - if (s13 !== peg$FAILED) { - // @ts-ignore - s14 = peg$parse_(); - // @ts-ignore - if (s14 === peg$FAILED) { - // @ts-ignore - s14 = null; - } - // @ts-ignore - s15 = peg$parseCOMMA(); - // @ts-ignore - if (s15 !== peg$FAILED) { - // @ts-ignore - s16 = peg$parse_(); - // @ts-ignore - if (s16 === peg$FAILED) { - // @ts-ignore - s16 = null; - } - // @ts-ignore - s17 = peg$parseContinuationExpression(); - // @ts-ignore - if (s17 !== peg$FAILED) { - // @ts-ignore - s18 = peg$parse_(); - // @ts-ignore - if (s18 === peg$FAILED) { - // @ts-ignore - s18 = null; - } - // @ts-ignore - s19 = peg$parseRPAREN(); - // @ts-ignore - if (s19 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f1(s5, s9, s13, s17); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseOffsetExpression() { - // @ts-ignore - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseOFFSET(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseInteger(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseValue(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseCOMMA(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - s12 = peg$parse_(); - // @ts-ignore - if (s12 === peg$FAILED) { - // @ts-ignore - s12 = null; - } - // @ts-ignore - s13 = peg$parseIdentifier(); - // @ts-ignore - if (s13 !== peg$FAILED) { - // @ts-ignore - s14 = peg$parse_(); - // @ts-ignore - if (s14 === peg$FAILED) { - // @ts-ignore - s14 = null; - } - // @ts-ignore - s15 = peg$parseContinuationExpression(); - // @ts-ignore - if (s15 !== peg$FAILED) { - // @ts-ignore - s16 = peg$parse_(); - // @ts-ignore - if (s16 === peg$FAILED) { - // @ts-ignore - s16 = null; - } - // @ts-ignore - s17 = peg$parseRPAREN(); - // @ts-ignore - if (s17 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f2(s5, s9, s13, s15); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseIdentifierList() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLBRACKET(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseIdentifier(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseIdentifier(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - } - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseIdentifier(); - // @ts-ignore - if (s5 === peg$FAILED) { - // @ts-ignore - s5 = null; - } - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseRBRACKET(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f3(s3, s5); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseValueList() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLBRACKET(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseValue(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseValue(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - } - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseValue(); - // @ts-ignore - if (s5 === peg$FAILED) { - // @ts-ignore - s5 = null; - } - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseRBRACKET(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f4(s3, s5); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSwitchExpression() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseSWITCH(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseValue(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseContinuationList(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseRPAREN(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f5(s5, s9); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseApplicationExpression() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseAPP(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseValue(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseValueList(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseRPAREN(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f6(s5, s9); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseFixBinding() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLPAREN(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseIdentifier(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseCOMMA(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseIdentifierList(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseCOMMA(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseContinuationExpression(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - s12 = peg$parse_(); - // @ts-ignore - if (s12 === peg$FAILED) { - // @ts-ignore - s12 = null; - } - // @ts-ignore - s13 = peg$parseRPAREN(); - // @ts-ignore - if (s13 !== peg$FAILED) { - // @ts-ignore - s1 = [ - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - ]; - // @ts-ignore - s0 = s1; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseFixBindingList() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLBRACKET(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseFixBinding(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseFixBinding(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - } - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseFixBinding(); - // @ts-ignore - if (s5 === peg$FAILED) { - // @ts-ignore - s5 = null; - } - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseRBRACKET(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f7(s3, s5); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseFixExpression() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseFIX(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseFixBindingList(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseContinuationExpression(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseRPAREN(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f8(s5, s9); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseContinuationList() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLBRACKET(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseContinuationExpression(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseContinuationExpression(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - } - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseContinuationExpression(); - // @ts-ignore - if (s5 === peg$FAILED) { - // @ts-ignore - s5 = null; - } - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseRBRACKET(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f9(s3, s5); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parsePrimitiveOperationExpression() { - // @ts-ignore - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parsePRIMOP(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parsePrimitiveOperation(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseValueList(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseCOMMA(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - s12 = peg$parse_(); - // @ts-ignore - if (s12 === peg$FAILED) { - // @ts-ignore - s12 = null; - } - // @ts-ignore - s13 = peg$parseIdentifierList(); - // @ts-ignore - if (s13 !== peg$FAILED) { - // @ts-ignore - s14 = peg$parse_(); - // @ts-ignore - if (s14 === peg$FAILED) { - // @ts-ignore - s14 = null; - } - // @ts-ignore - s15 = peg$parseCOMMA(); - // @ts-ignore - if (s15 !== peg$FAILED) { - // @ts-ignore - s16 = peg$parse_(); - // @ts-ignore - if (s16 === peg$FAILED) { - // @ts-ignore - s16 = null; - } - // @ts-ignore - s17 = peg$parseContinuationList(); - // @ts-ignore - if (s17 !== peg$FAILED) { - // @ts-ignore - s18 = peg$parse_(); - // @ts-ignore - if (s18 === peg$FAILED) { - // @ts-ignore - s18 = null; - } - // @ts-ignore - s19 = peg$parseRPAREN(); - // @ts-ignore - if (s19 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f10(s5, s9, s13, s17); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRecordExpressionTuple() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLPAREN(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseVarStatement(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseCOMMA(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseOffsetStatement(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseRPAREN(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f11(s3, s7); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRecordExpressionTupleList() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLBRACKET(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseRecordExpressionTuple(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - s5 = peg$parseRecordExpressionTuple(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s5 = [s5, s6, s7, s8]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - } - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseRecordExpressionTuple(); - // @ts-ignore - if (s5 === peg$FAILED) { - // @ts-ignore - s5 = null; - } - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseRBRACKET(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f12(s3, s5); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRecordExpression() { - // @ts-ignore - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseRECORD(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = peg$parseLPAREN(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$parse_(); - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s5 = peg$parseRecordExpressionTupleList(); - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = peg$parse_(); - // @ts-ignore - if (s6 === peg$FAILED) { - // @ts-ignore - s6 = null; - } - // @ts-ignore - s7 = peg$parseCOMMA(); - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - s8 = peg$parse_(); - // @ts-ignore - if (s8 === peg$FAILED) { - // @ts-ignore - s8 = null; - } - // @ts-ignore - s9 = peg$parseLiteral(); - // @ts-ignore - if (s9 !== peg$FAILED) { - // @ts-ignore - s10 = peg$parse_(); - // @ts-ignore - if (s10 === peg$FAILED) { - // @ts-ignore - s10 = null; - } - // @ts-ignore - s11 = peg$parseCOMMA(); - // @ts-ignore - if (s11 !== peg$FAILED) { - // @ts-ignore - s12 = peg$parse_(); - // @ts-ignore - if (s12 === peg$FAILED) { - // @ts-ignore - s12 = null; - } - // @ts-ignore - s13 = peg$parseContinuationExpression(); - // @ts-ignore - if (s13 !== peg$FAILED) { - // @ts-ignore - s14 = peg$parse_(); - // @ts-ignore - if (s14 === peg$FAILED) { - // @ts-ignore - s14 = null; - } - // @ts-ignore - s15 = peg$parseRPAREN(); - // @ts-ignore - if (s15 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f13(s5, s9, s13); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseValue() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = peg$parseVarStatement(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseLabelStatement(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseIntStatement(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseRealStatement(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseStringStatement(); - } - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseVarStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseVAR(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseIdentifier(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f14(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseLabelStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseLABEL(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseIdentifier(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f15(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseIntStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseINT(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseInteger(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f16(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRealStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseREAL(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseReal(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f17(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseStringStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseSTRING(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseQuotedString(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f18(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseAccessStatement() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = peg$parseOffsetStatement(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseSelectStatement(); - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseOffsetStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseOFFP(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseInteger(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f19(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSelectStatement() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$parseSELP(); - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$parse_(); - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = peg$parseInteger(); - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f20(s3); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseIdentifier() { - // @ts-ignore - var s0, s1, s2, s3, s4; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$currPos; - // @ts-ignore - s2 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r0.test(s2)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s2 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e0); - } - } - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r1.test(s4)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s4 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e1); - } - } - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r1.test(s4)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s4 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e1); - } - } - } - // @ts-ignore - s2 = [s2, s3]; - // @ts-ignore - s1 = s2; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s1; - // @ts-ignore - s1 = peg$FAILED; - } - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s1 = peg$f21(s1); - } - // @ts-ignore - s0 = s1; - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parsePrimitiveOperation() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = peg$parseArithmeticOperation(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseComparisonOperation(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseBitOperation(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseStoreOperation(); - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseStoreOperation() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = peg$parseSTORE(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseUPDATE(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseMAKEREF(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseMAKEREFUNBOXED(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseUNBOXED_UPDATE(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseBOXED(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseSUBSCRIPT(); - } - } - } - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseArithmeticOperation() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r2.test(s0)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e2); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c0) { - // @ts-ignore - s0 = peg$c0; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e3); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 37) { - // @ts-ignore - s0 = peg$c1; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e4); - } - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseBitOperation() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c2) { - // @ts-ignore - s0 = peg$c2; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c3) { - // @ts-ignore - s0 = peg$c3; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e6); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r3.test(s0)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e7); - } - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseComparisonOperation() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c4) { - // @ts-ignore - s0 = peg$c4; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e8); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c5) { - // @ts-ignore - s0 = peg$c5; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e9); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c6) { - // @ts-ignore - s0 = peg$c6; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e10); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c7) { - // @ts-ignore - s0 = peg$c7; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e11); - } - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r4.test(s0)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e12); - } - } - } - } - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseInteger() { - // @ts-ignore - var s0, s1, s2, s3, s4; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$currPos; - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 45) { - // @ts-ignore - s2 = peg$c8; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s2 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e13); - } - } - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s4)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s4 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - // @ts-ignore - if (s4 !== peg$FAILED) { - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s4)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s4 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - } - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - } - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s2 = [s2, s3]; - // @ts-ignore - s1 = s2; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s1; - // @ts-ignore - s1 = peg$FAILED; - } - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = peg$currPos; - // @ts-ignore - peg$silentFails++; - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 46) { - // @ts-ignore - s3 = peg$c9; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e15); - } - } - // @ts-ignore - peg$silentFails--; - // @ts-ignore - if (s3 === peg$FAILED) { - // @ts-ignore - s2 = undefined; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s2; - // @ts-ignore - s2 = peg$FAILED; - } - // @ts-ignore - if (s2 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f22(s1); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseQuotedString() { - // @ts-ignore - var s0, s1, s2, s3; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 39) { - // @ts-ignore - s1 = peg$c10; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s1 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e16); - } - } - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = []; - // @ts-ignore - s3 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r6.test(s3)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e17); - } - } - // @ts-ignore - while (s3 !== peg$FAILED) { - // @ts-ignore - s2.push(s3); - // @ts-ignore - s3 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r6.test(s3)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e17); - } - } - } - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 39) { - // @ts-ignore - s3 = peg$c10; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e16); - } - } - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f23(s2); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 34) { - // @ts-ignore - s1 = peg$c11; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s1 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } - } - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - s2 = []; - // @ts-ignore - s3 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r7.test(s3)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e19); - } - } - // @ts-ignore - while (s3 !== peg$FAILED) { - // @ts-ignore - s2.push(s3); - // @ts-ignore - s3 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r7.test(s3)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e19); - } - } - } - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 34) { - // @ts-ignore - s3 = peg$c11; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } - } - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s0 = peg$f24(s2); - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s0; - // @ts-ignore - s0 = peg$FAILED; - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseReal() { - // @ts-ignore - var s0, s1, s2, s3, s4, s5, s6, s7; - - // @ts-ignore - s0 = peg$currPos; - // @ts-ignore - s1 = peg$currPos; - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 45) { - // @ts-ignore - s2 = peg$c8; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s2 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e13); - } - } - // @ts-ignore - if (s2 === peg$FAILED) { - // @ts-ignore - s2 = null; - } - // @ts-ignore - s3 = []; - // @ts-ignore - s4 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s4)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s4 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - // @ts-ignore - if (s4 !== peg$FAILED) { - // @ts-ignore - while (s4 !== peg$FAILED) { - // @ts-ignore - s3.push(s4); - // @ts-ignore - s4 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s4)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s4 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - } - // @ts-ignore - } else { - // @ts-ignore - s3 = peg$FAILED; - } - // @ts-ignore - if (s3 !== peg$FAILED) { - // @ts-ignore - s4 = peg$currPos; - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 46) { - // @ts-ignore - s5 = peg$c9; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s5 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e15); - } - } - // @ts-ignore - if (s5 !== peg$FAILED) { - // @ts-ignore - s6 = []; - // @ts-ignore - s7 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s7)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s7 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - // @ts-ignore - if (s7 !== peg$FAILED) { - // @ts-ignore - while (s7 !== peg$FAILED) { - // @ts-ignore - s6.push(s7); - // @ts-ignore - s7 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s7)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s7 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - } - // @ts-ignore - } else { - // @ts-ignore - s6 = peg$FAILED; - } - // @ts-ignore - if (s6 !== peg$FAILED) { - // @ts-ignore - s5 = [s5, s6]; - // @ts-ignore - s4 = s5; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s4; - // @ts-ignore - s4 = peg$FAILED; - } - // @ts-ignore - if (s4 === peg$FAILED) { - // @ts-ignore - s4 = null; - } - // @ts-ignore - s2 = [s2, s3, s4]; - // @ts-ignore - s1 = s2; - // @ts-ignore - } else { - // @ts-ignore - peg$currPos = s1; - // @ts-ignore - s1 = peg$FAILED; - } - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - peg$savedPos = s0; - // @ts-ignore - s1 = peg$f25(s1); - } - // @ts-ignore - s0 = s1; - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseLiteral() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = peg$parseReal(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseQuotedString(); - // @ts-ignore - if (s0 === peg$FAILED) { - // @ts-ignore - s0 = peg$parseInteger(); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseOFFSET() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c12) { - // @ts-ignore - s0 = peg$c12; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e20); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseOFFP() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 4) === peg$c13) { - // @ts-ignore - s0 = peg$c13; - // @ts-ignore - peg$currPos += 4; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e21); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSELP() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 4) === peg$c14) { - // @ts-ignore - s0 = peg$c14; - // @ts-ignore - peg$currPos += 4; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseVAR() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 3) === peg$c15) { - // @ts-ignore - s0 = peg$c15; - // @ts-ignore - peg$currPos += 3; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e23); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseINT() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 3) === peg$c16) { - // @ts-ignore - s0 = peg$c16; - // @ts-ignore - peg$currPos += 3; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e24); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseREAL() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 4) === peg$c17) { - // @ts-ignore - s0 = peg$c17; - // @ts-ignore - peg$currPos += 4; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e25); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSTRING() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c18) { - // @ts-ignore - s0 = peg$c18; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e26); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseAPP() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 3) === peg$c19) { - // @ts-ignore - s0 = peg$c19; - // @ts-ignore - peg$currPos += 3; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e27); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRECORD() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c20) { - // @ts-ignore - s0 = peg$c20; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e28); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSELECT() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c21) { - // @ts-ignore - s0 = peg$c21; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e29); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseFIX() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 3) === peg$c22) { - // @ts-ignore - s0 = peg$c22; - // @ts-ignore - peg$currPos += 3; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e30); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSWITCH() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c23) { - // @ts-ignore - s0 = peg$c23; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e31); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parsePRIMOP() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c24) { - // @ts-ignore - s0 = peg$c24; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e32); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseLABEL() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 5) === peg$c25) { - // @ts-ignore - s0 = peg$c25; - // @ts-ignore - peg$currPos += 5; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e33); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSTORE() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 5) === peg$c26) { - // @ts-ignore - s0 = peg$c26; - // @ts-ignore - peg$currPos += 5; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e34); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseUPDATE() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 6) === peg$c27) { - // @ts-ignore - s0 = peg$c27; - // @ts-ignore - peg$currPos += 6; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e35); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseMAKEREF() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 7) === peg$c28) { - // @ts-ignore - s0 = peg$c28; - // @ts-ignore - peg$currPos += 7; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e36); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseMAKEREFUNBOXED() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 14) === peg$c29) { - // @ts-ignore - s0 = peg$c29; - // @ts-ignore - peg$currPos += 14; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e37); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseUNBOXED_UPDATE() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 13) === peg$c30) { - // @ts-ignore - s0 = peg$c30; - // @ts-ignore - peg$currPos += 13; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e38); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSUBSCRIPT() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 9) === peg$c31) { - // @ts-ignore - s0 = peg$c31; - // @ts-ignore - peg$currPos += 9; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e39); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseBOXED() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.substr(peg$currPos, 5) === peg$c32) { - // @ts-ignore - s0 = peg$c32; - // @ts-ignore - peg$currPos += 5; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e40); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseLETTER() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r0.test(s0)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e0); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseSAFE_SYMBOL() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 95) { - // @ts-ignore - s0 = peg$c33; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e41); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseDIGIT() { - // @ts-ignore - var s0; - - // @ts-ignore - s0 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r5.test(s0)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseLBRACKET() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 91) { - // @ts-ignore - s0 = peg$c34; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e42); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRBRACKET() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 93) { - // @ts-ignore - s0 = peg$c35; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e43); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseCOMMA() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 44) { - // @ts-ignore - s0 = peg$c36; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e44); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseEQUALS() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 61) { - // @ts-ignore - s0 = peg$c37; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e45); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseLPAREN() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 40) { - // @ts-ignore - s0 = peg$c38; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e46); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parseRPAREN() { - // @ts-ignore - var s0; - - // @ts-ignore - if (input.charCodeAt(peg$currPos) === 41) { - // @ts-ignore - s0 = peg$c39; - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e47); - } - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - function // @ts-ignore - peg$parse_() { - // @ts-ignore - var s0, s1; - - // @ts-ignore - s0 = []; - // @ts-ignore - s1 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r8.test(s1)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s1 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e48); - } - } - // @ts-ignore - if (s1 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c40) { - // @ts-ignore - s1 = peg$c40; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s1 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e49); - } - } - } - // @ts-ignore - if (s1 !== peg$FAILED) { - // @ts-ignore - while (s1 !== peg$FAILED) { - // @ts-ignore - s0.push(s1); - // @ts-ignore - s1 = input.charAt(peg$currPos); - // @ts-ignore - if (peg$r8.test(s1)) { - // @ts-ignore - peg$currPos++; - // @ts-ignore - } else { - // @ts-ignore - s1 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e48); - } - } - // @ts-ignore - if (s1 === peg$FAILED) { - // @ts-ignore - if (input.substr(peg$currPos, 2) === peg$c40) { - // @ts-ignore - s1 = peg$c40; - // @ts-ignore - peg$currPos += 2; - // @ts-ignore - } else { - // @ts-ignore - s1 = peg$FAILED; - // @ts-ignore - if (peg$silentFails === 0) { - peg$fail(peg$e49); - } - } - } - } - // @ts-ignore - } else { - // @ts-ignore - s0 = peg$FAILED; - } - - // @ts-ignore - return s0; - } - - // @ts-ignore - peg$result = peg$startRuleFunction(); - - // @ts-ignore - if (options.peg$library) { - // @ts-ignore - return /** @type {any} */ { - // @ts-ignore - peg$result, - // @ts-ignore - peg$currPos, - // @ts-ignore - peg$FAILED, - // @ts-ignore - peg$maxFailExpected, - // @ts-ignore - peg$maxFailPos, - }; - } - // @ts-ignore - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - // @ts-ignore - return peg$result; - // @ts-ignore - } else { - // @ts-ignore - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - // @ts-ignore - peg$fail(peg$endExpectation()); - } - - // @ts-ignore - throw peg$buildStructuredError( - // @ts-ignore - peg$maxFailExpected, - // @ts-ignore - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, - // @ts-ignore - peg$maxFailPos < input.length - ? // @ts-ignore - peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : // @ts-ignore - peg$computeLocation(peg$maxFailPos, peg$maxFailPos), - ); - } +// @ts-ignore + var peg$currPos = options.peg$currPos | 0; +// @ts-ignore + var peg$savedPos = peg$currPos; +// @ts-ignore + var peg$posDetailsCache = [{ line: 1, column: 1 }]; +// @ts-ignore + var peg$maxFailPos = peg$currPos; +// @ts-ignore + var peg$maxFailExpected = options.peg$maxFailExpected || []; +// @ts-ignore + var peg$silentFails = options.peg$silentFails | 0; + +// @ts-ignore + var peg$result; + +// @ts-ignore + if (options.startRule) { +// @ts-ignore + if (!(options.startRule in peg$startRuleFunctions)) { +// @ts-ignore + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } - // @ts-ignore +// @ts-ignore + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + +// @ts-ignore + function text() { +// @ts-ignore + return input.substring(peg$savedPos, peg$currPos); + } + +// @ts-ignore + function offset() { +// @ts-ignore + return peg$savedPos; + } + +// @ts-ignore + function range() { +// @ts-ignore return { - StartRules: ['Program'], - SyntaxError: peg$SyntaxError, - parse: peg$parse, +// @ts-ignore + source: peg$source, +// @ts-ignore + start: peg$savedPos, +// @ts-ignore + end: peg$currPos }; - })(); + } + +// @ts-ignore + function location() { +// @ts-ignore + return peg$computeLocation(peg$savedPos, peg$currPos); + } + +// @ts-ignore + function expected(description, location) { +// @ts-ignore + location = location !== undefined +// @ts-ignore + ? location +// @ts-ignore + : peg$computeLocation(peg$savedPos, peg$currPos); + +// @ts-ignore + throw peg$buildStructuredError( +// @ts-ignore + [peg$otherExpectation(description)], +// @ts-ignore + input.substring(peg$savedPos, peg$currPos), +// @ts-ignore + location + ); + } + +// @ts-ignore + function error(message, location) { +// @ts-ignore + location = location !== undefined +// @ts-ignore + ? location +// @ts-ignore + : peg$computeLocation(peg$savedPos, peg$currPos); + +// @ts-ignore + throw peg$buildSimpleError(message, location); + } + +// @ts-ignore + function peg$literalExpectation(text, ignoreCase) { +// @ts-ignore + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + +// @ts-ignore + function peg$classExpectation(parts, inverted, ignoreCase) { +// @ts-ignore + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } + +// @ts-ignore + function peg$anyExpectation() { +// @ts-ignore + return { type: "any" }; + } + +// @ts-ignore + function peg$endExpectation() { +// @ts-ignore + return { type: "end" }; + } + +// @ts-ignore + function peg$otherExpectation(description) { +// @ts-ignore + return { type: "other", description: description }; + } + +// @ts-ignore + function peg$computePosDetails(pos) { +// @ts-ignore + var details = peg$posDetailsCache[pos]; +// @ts-ignore + var p; + +// @ts-ignore + if (details) { +// @ts-ignore + return details; +// @ts-ignore + } else { +// @ts-ignore + if (pos >= peg$posDetailsCache.length) { +// @ts-ignore + p = peg$posDetailsCache.length - 1; +// @ts-ignore + } else { +// @ts-ignore + p = pos; +// @ts-ignore + while (!peg$posDetailsCache[--p]) {} + } + +// @ts-ignore + details = peg$posDetailsCache[p]; +// @ts-ignore + details = { +// @ts-ignore + line: details.line, +// @ts-ignore + column: details.column + }; + +// @ts-ignore + while (p < pos) { +// @ts-ignore + if (input.charCodeAt(p) === 10) { +// @ts-ignore + details.line++; +// @ts-ignore + details.column = 1; +// @ts-ignore + } else { +// @ts-ignore + details.column++; + } + +// @ts-ignore + p++; + } + +// @ts-ignore + peg$posDetailsCache[pos] = details; + +// @ts-ignore + return details; + } + } + +// @ts-ignore + function peg$computeLocation(startPos, endPos, offset) { +// @ts-ignore + var startPosDetails = peg$computePosDetails(startPos); +// @ts-ignore + var endPosDetails = peg$computePosDetails(endPos); + +// @ts-ignore + var res = { +// @ts-ignore + source: peg$source, +// @ts-ignore + start: { +// @ts-ignore + offset: startPos, +// @ts-ignore + line: startPosDetails.line, +// @ts-ignore + column: startPosDetails.column + }, +// @ts-ignore + end: { +// @ts-ignore + offset: endPos, +// @ts-ignore + line: endPosDetails.line, +// @ts-ignore + column: endPosDetails.column + } + }; +// @ts-ignore + if (offset && peg$source && (typeof peg$source.offset === "function")) { +// @ts-ignore + res.start = peg$source.offset(res.start); +// @ts-ignore + res.end = peg$source.offset(res.end); + } +// @ts-ignore + return res; + } + +// @ts-ignore + function peg$fail(expected) { +// @ts-ignore + if (peg$currPos < peg$maxFailPos) { return; } + +// @ts-ignore + if (peg$currPos > peg$maxFailPos) { +// @ts-ignore + peg$maxFailPos = peg$currPos; +// @ts-ignore + peg$maxFailExpected = []; + } + +// @ts-ignore + peg$maxFailExpected.push(expected); + } + +// @ts-ignore + function peg$buildSimpleError(message, location) { +// @ts-ignore + return new peg$SyntaxError(message, null, null, location); + } + +// @ts-ignore + function peg$buildStructuredError(expected, found, location) { +// @ts-ignore + return new peg$SyntaxError( +// @ts-ignore + peg$SyntaxError.buildMessage(expected, found), +// @ts-ignore + expected, +// @ts-ignore + found, +// @ts-ignore + location + ); + } + +// @ts-ignore + function // @ts-ignore +peg$parseProgram() { +// @ts-ignore + var s0, s1, s2; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = []; +// @ts-ignore + s2 = peg$parseContinuationExpression(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); + } +// @ts-ignore + while (s2 !== peg$FAILED) { +// @ts-ignore + s1.push(s2); +// @ts-ignore + s2 = peg$parseContinuationExpression(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); + } + } +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s1 = peg$f0(s1); +// @ts-ignore + s0 = s1; + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseContinuationExpression() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseRecordExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSelectExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseOffsetExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseApplicationExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseFixExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSwitchExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parsePrimitiveOperationExpression(); + } + } + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSelectExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSELECT(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseInteger(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValue(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseIdentifier(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseCOMMA(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + s16 = peg$parse_(); +// @ts-ignore + if (s16 === peg$FAILED) { +// @ts-ignore + s16 = null; + } +// @ts-ignore + s17 = peg$parseContinuationExpression(); +// @ts-ignore + if (s17 !== peg$FAILED) { +// @ts-ignore + s18 = peg$parse_(); +// @ts-ignore + if (s18 === peg$FAILED) { +// @ts-ignore + s18 = null; + } +// @ts-ignore + s19 = peg$parseRPAREN(); +// @ts-ignore + if (s19 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f1(s5, s9, s13, s17); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOffsetExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseOFFSET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseInteger(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValue(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseIdentifier(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseContinuationExpression(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + s16 = peg$parse_(); +// @ts-ignore + if (s16 === peg$FAILED) { +// @ts-ignore + s16 = null; + } +// @ts-ignore + s17 = peg$parseRPAREN(); +// @ts-ignore + if (s17 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f2(s5, s9, s13, s15); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseIdentifierList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseIdentifier(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseIdentifier(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseIdentifier(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f3(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseValueList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f4(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSwitchExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSWITCH(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseContinuationList(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseRPAREN(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f5(s5, s9); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseApplicationExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseAPP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValueList(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseRPAREN(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f6(s5, s9); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFixBinding() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLPAREN(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseIdentifier(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseCOMMA(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseIdentifierList(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseCOMMA(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseContinuationExpression(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseRPAREN(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s1 = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13]; +// @ts-ignore + s0 = s1; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFixBindingList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseFixBinding(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseFixBinding(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseFixBinding(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f7(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFixExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseFIX(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseFixBindingList(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseContinuationExpression(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseRPAREN(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f8(s5, s9); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseContinuationList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseContinuationExpression(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseContinuationExpression(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseContinuationExpression(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f9(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parsePrimitiveOperationExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parsePRIMOP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parsePrimitiveOperation(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValueList(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseIdentifierList(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseCOMMA(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + s16 = peg$parse_(); +// @ts-ignore + if (s16 === peg$FAILED) { +// @ts-ignore + s16 = null; + } +// @ts-ignore + s17 = peg$parseContinuationList(); +// @ts-ignore + if (s17 !== peg$FAILED) { +// @ts-ignore + s18 = peg$parse_(); +// @ts-ignore + if (s18 === peg$FAILED) { +// @ts-ignore + s18 = null; + } +// @ts-ignore + s19 = peg$parseRPAREN(); +// @ts-ignore + if (s19 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f10(s5, s9, s13, s17); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRecordExpressionTuple() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLPAREN(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseVarStatement(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseCOMMA(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseOffsetStatement(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseRPAREN(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f11(s3, s7); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRecordExpressionTupleList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseRecordExpressionTuple(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseRecordExpressionTuple(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseRecordExpressionTuple(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f12(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRecordExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseRECORD(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseRecordExpressionTupleList(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseLiteral(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseContinuationExpression(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseRPAREN(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f13(s5, s9, s13); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseValue() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseVarStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseLabelStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseIntStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseRealStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseStringStatement(); + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseVarStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseVAR(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseIdentifier(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f14(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLabelStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLABEL(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseIdentifier(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f15(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseIntStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseINT(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseInteger(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f16(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRealStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseREAL(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseReal(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f17(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseStringStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSTRING(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseQuotedString(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f18(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseAccessStatement() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseOffsetStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSelectStatement(); + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOffsetStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseOFFP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseInteger(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f19(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSelectStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSELP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseInteger(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f20(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseIdentifier() { +// @ts-ignore + var s0, s1, s2, s3, s4; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$currPos; +// @ts-ignore + s2 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r0.test(s2)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r1.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r1.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } +// @ts-ignore + s2 = [s2, s3]; +// @ts-ignore + s1 = s2; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s1 = peg$f21(s1); + } +// @ts-ignore + s0 = s1; + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parsePrimitiveOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseArithmeticOperation(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseComparisonOperation(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseBitOperation(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseStoreOperation(); + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseStoreOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseSTORE(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseUPDATE(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseMAKEREF(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseMAKEREFUNBOXED(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseUNBOXED_UPDATE(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseBOXED(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSUBSCRIPT(); + } + } + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseArithmeticOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r2.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c0) { +// @ts-ignore + s0 = peg$c0; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 37) { +// @ts-ignore + s0 = peg$c1; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseBitOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c2) { +// @ts-ignore + s0 = peg$c2; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c3) { +// @ts-ignore + s0 = peg$c3; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r3.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseComparisonOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c4) { +// @ts-ignore + s0 = peg$c4; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c5) { +// @ts-ignore + s0 = peg$c5; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c6) { +// @ts-ignore + s0 = peg$c6; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c7) { +// @ts-ignore + s0 = peg$c7; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r4.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c8) { +// @ts-ignore + s0 = peg$c8; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + } + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseInteger() { +// @ts-ignore + var s0, s1, s2, s3, s4; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 45) { +// @ts-ignore + s2 = peg$c9; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } +// @ts-ignore + if (s4 !== peg$FAILED) { +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + } +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s2 = [s2, s3]; +// @ts-ignore + s1 = s2; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$currPos; +// @ts-ignore + peg$silentFails++; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 46) { +// @ts-ignore + s3 = peg$c10; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } +// @ts-ignore + peg$silentFails--; +// @ts-ignore + if (s3 === peg$FAILED) { +// @ts-ignore + s2 = undefined; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s2; +// @ts-ignore + s2 = peg$FAILED; + } +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f22(s1); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseQuotedString() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 39) { +// @ts-ignore + s1 = peg$c11; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = []; +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r6.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } +// @ts-ignore + while (s3 !== peg$FAILED) { +// @ts-ignore + s2.push(s3); +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r6.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + } +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 39) { +// @ts-ignore + s3 = peg$c11; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f23(s2); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 34) { +// @ts-ignore + s1 = peg$c12; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = []; +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r7.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } +// @ts-ignore + while (s3 !== peg$FAILED) { +// @ts-ignore + s2.push(s3); +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r7.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 34) { +// @ts-ignore + s3 = peg$c12; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f24(s2); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseReal() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 45) { +// @ts-ignore + s2 = peg$c9; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } +// @ts-ignore + if (s4 !== peg$FAILED) { +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + } +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 46) { +// @ts-ignore + s5 = peg$c10; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s5 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = []; +// @ts-ignore + s7 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s7)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s7 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + while (s7 !== peg$FAILED) { +// @ts-ignore + s6.push(s7); +// @ts-ignore + s7 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s7)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s7 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + } +// @ts-ignore + } else { +// @ts-ignore + s6 = peg$FAILED; + } +// @ts-ignore + if (s6 !== peg$FAILED) { +// @ts-ignore + s5 = [s5, s6]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s2 = [s2, s3, s4]; +// @ts-ignore + s1 = s2; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s1 = peg$f25(s1); + } +// @ts-ignore + s0 = s1; + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLiteral() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseReal(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseQuotedString(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseInteger(); + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOFFSET() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c13) { +// @ts-ignore + s0 = peg$c13; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOFFP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 4) === peg$c14) { +// @ts-ignore + s0 = peg$c14; +// @ts-ignore + peg$currPos += 4; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSELP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 4) === peg$c15) { +// @ts-ignore + s0 = peg$c15; +// @ts-ignore + peg$currPos += 4; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e23); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseVAR() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c16) { +// @ts-ignore + s0 = peg$c16; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseINT() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c17) { +// @ts-ignore + s0 = peg$c17; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e25); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseREAL() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 4) === peg$c18) { +// @ts-ignore + s0 = peg$c18; +// @ts-ignore + peg$currPos += 4; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSTRING() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c19) { +// @ts-ignore + s0 = peg$c19; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseAPP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c20) { +// @ts-ignore + s0 = peg$c20; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRECORD() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c21) { +// @ts-ignore + s0 = peg$c21; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSELECT() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c22) { +// @ts-ignore + s0 = peg$c22; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e30); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFIX() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c23) { +// @ts-ignore + s0 = peg$c23; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e31); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSWITCH() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c24) { +// @ts-ignore + s0 = peg$c24; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e32); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parsePRIMOP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c25) { +// @ts-ignore + s0 = peg$c25; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e33); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLABEL() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 5) === peg$c26) { +// @ts-ignore + s0 = peg$c26; +// @ts-ignore + peg$currPos += 5; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e34); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSTORE() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 5) === peg$c27) { +// @ts-ignore + s0 = peg$c27; +// @ts-ignore + peg$currPos += 5; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e35); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseUPDATE() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c28) { +// @ts-ignore + s0 = peg$c28; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e36); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseMAKEREF() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 7) === peg$c29) { +// @ts-ignore + s0 = peg$c29; +// @ts-ignore + peg$currPos += 7; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e37); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseMAKEREFUNBOXED() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 14) === peg$c30) { +// @ts-ignore + s0 = peg$c30; +// @ts-ignore + peg$currPos += 14; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e38); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseUNBOXED_UPDATE() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 13) === peg$c31) { +// @ts-ignore + s0 = peg$c31; +// @ts-ignore + peg$currPos += 13; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e39); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSUBSCRIPT() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 9) === peg$c32) { +// @ts-ignore + s0 = peg$c32; +// @ts-ignore + peg$currPos += 9; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e40); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseBOXED() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 5) === peg$c33) { +// @ts-ignore + s0 = peg$c33; +// @ts-ignore + peg$currPos += 5; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e41); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLETTER() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r0.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSAFE_SYMBOL() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 95) { +// @ts-ignore + s0 = peg$c34; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e42); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseDIGIT() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLBRACKET() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 91) { +// @ts-ignore + s0 = peg$c35; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e43); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRBRACKET() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 93) { +// @ts-ignore + s0 = peg$c36; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e44); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseCOMMA() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 44) { +// @ts-ignore + s0 = peg$c37; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e45); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseEQUALS() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 61) { +// @ts-ignore + s0 = peg$c38; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e46); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLPAREN() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 40) { +// @ts-ignore + s0 = peg$c39; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e47); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRPAREN() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 41) { +// @ts-ignore + s0 = peg$c40; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e48); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parse_() { +// @ts-ignore + var s0, s1; + +// @ts-ignore + s0 = []; +// @ts-ignore + s1 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r8.test(s1)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e49); } + } +// @ts-ignore + if (s1 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c41) { +// @ts-ignore + s1 = peg$c41; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e50); } + } + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + while (s1 !== peg$FAILED) { +// @ts-ignore + s0.push(s1); +// @ts-ignore + s1 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r8.test(s1)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e49); } + } +// @ts-ignore + if (s1 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c41) { +// @ts-ignore + s1 = peg$c41; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e50); } + } + } + } +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + peg$result = peg$startRuleFunction(); + +// @ts-ignore + if (options.peg$library) { +// @ts-ignore + return /** @type {any} */ ({ +// @ts-ignore + peg$result, +// @ts-ignore + peg$currPos, +// @ts-ignore + peg$FAILED, +// @ts-ignore + peg$maxFailExpected, +// @ts-ignore + peg$maxFailPos + }); + } +// @ts-ignore + if (peg$result !== peg$FAILED && peg$currPos === input.length) { +// @ts-ignore + return peg$result; +// @ts-ignore + } else { +// @ts-ignore + if (peg$result !== peg$FAILED && peg$currPos < input.length) { +// @ts-ignore + peg$fail(peg$endExpectation()); + } + +// @ts-ignore + throw peg$buildStructuredError( +// @ts-ignore + peg$maxFailExpected, +// @ts-ignore + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, +// @ts-ignore + peg$maxFailPos < input.length +// @ts-ignore + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) +// @ts-ignore + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } +} + +// @ts-ignore + return { + StartRules: ["Program"], + SyntaxError: peg$SyntaxError, + parse: peg$parse + }; +})() export interface FilePosition { offset: number; @@ -5420,7 +5128,7 @@ export interface FileRange { } export interface LiteralExpectation { - type: 'literal'; + type: "literal"; text: string; ignoreCase: boolean; } @@ -5428,88 +5136,70 @@ export interface LiteralExpectation { export interface ClassParts extends Array {} export interface ClassExpectation { - type: 'class'; + type: "class"; parts: ClassParts; inverted: boolean; ignoreCase: boolean; } export interface AnyExpectation { - type: 'any'; + type: "any"; } export interface EndExpectation { - type: 'end'; + type: "end"; } export interface OtherExpectation { - type: 'other'; + type: "other"; description: string; } -export type Expectation = - | LiteralExpectation - | ClassExpectation - | AnyExpectation - | EndExpectation - | OtherExpectation; +export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation; declare class _PeggySyntaxError extends Error { - public static buildMessage( - expected: Expectation[], - found: string | null, - ): string; + public static buildMessage(expected: Expectation[], found: string | null): string; public message: string; public expected: Expectation[]; public found: string | null; public location: FileRange; public name: string; - constructor( - message: string, - expected: Expectation[], - found: string | null, - location: FileRange, - ); - format( - sources: { - source?: any; - text: string; - }[], - ): string; + constructor(message: string, expected: Expectation[], found: string | null, location: FileRange); + format(sources: { + source?: any; + text: string; + }[]): string; } export interface TraceEvent { - type: string; - rule: string; - result?: any; - location: FileRange; -} + type: string; + rule: string; + result?: any; + location: FileRange; + } declare class _DefaultTracer { private indentLevel: number; public trace(event: TraceEvent): void; } -peggyParser.SyntaxError.prototype.name = 'PeggySyntaxError'; +peggyParser.SyntaxError.prototype.name = "PeggySyntaxError"; export interface ParseOptions { filename?: string; - startRule?: 'Program'; + startRule?: "Program"; tracer?: any; [key: string]: any; } export type ParseFunction = ( - input: string, - options?: Options, -) => Options extends { startRule: infer StartRule } - ? StartRule extends 'Program' - ? Program - : Program - : Program; + input: string, + options?: Options + ) => Options extends { startRule: infer StartRule } ? + StartRule extends "Program" ? Program : Program + : Program; export const parse: ParseFunction = peggyParser.parse; -export const PeggySyntaxError = - peggyParser.SyntaxError as typeof _PeggySyntaxError; +export const PeggySyntaxError = peggyParser.SyntaxError as typeof _PeggySyntaxError; export type PeggySyntaxError = _PeggySyntaxError; @@ -5560,7 +5250,7 @@ export type FixBinding = [ _ | null, ContinuationExpression, _ | null, - RPAREN, + RPAREN ]; export type FixBindingList = any[]; export type FixExpression = { @@ -5615,41 +5305,41 @@ export type StoreOperation = | UNBOXEDUPDATE | BOXED | SUBSCRIPT; -export type ArithmeticOperation = string | '**' | '%'; -export type BitOperation = '>>' | '<<' | string; -export type ComparisonOperation = '==' | '<=' | '>=' | '!=' | string; +export type ArithmeticOperation = string | "**" | "%"; +export type BitOperation = ">>" | "<<" | string; +export type ComparisonOperation = "==" | "<=" | ">=" | "!=" | string | "||"; export type Integer = { int: number }; export type QuotedString = string; export type Real = { real: number }; export type Literal = Real | QuotedString | Integer; -export type OFFSET = 'OFFSET'; -export type OFFP = 'OFFp'; -export type SELP = 'SELp'; -export type VAR = 'VAR'; -export type INT = 'INT'; -export type REAL = 'REAL'; -export type STRING = 'STRING'; -export type APP = 'APP'; -export type RECORD = 'RECORD'; -export type SELECT = 'SELECT'; -export type FIX = 'FIX'; -export type SWITCH = 'SWITCH'; -export type PRIMOP = 'PRIMOP'; -export type LABEL = 'LABEL'; -export type STORE = 'store'; -export type UPDATE = 'update'; -export type MAKEREF = 'makeref'; -export type MAKEREFUNBOXED = 'makerefunboxed'; -export type UNBOXEDUPDATE = 'unboxedupdate'; -export type SUBSCRIPT = 'subscript'; -export type BOXED = 'boxed'; +export type OFFSET = "OFFSET"; +export type OFFP = "OFFp"; +export type SELP = "SELp"; +export type VAR = "VAR"; +export type INT = "INT"; +export type REAL = "REAL"; +export type STRING = "STRING"; +export type APP = "APP"; +export type RECORD = "RECORD"; +export type SELECT = "SELECT"; +export type FIX = "FIX"; +export type SWITCH = "SWITCH"; +export type PRIMOP = "PRIMOP"; +export type LABEL = "LABEL"; +export type STORE = "store"; +export type UPDATE = "update"; +export type MAKEREF = "makeref"; +export type MAKEREFUNBOXED = "makerefunboxed"; +export type UNBOXEDUPDATE = "unboxedupdate"; +export type SUBSCRIPT = "subscript"; +export type BOXED = "boxed"; export type LETTER = string; -export type SAFESYMBOL = '_'; +export type SAFESYMBOL = "_"; export type DIGIT = string; -export type LBRACKET = '['; -export type RBRACKET = ']'; -export type COMMA = ','; -export type EQUALS = '='; -export type LPAREN = '('; -export type RPAREN = ')'; -export type _ = (string | '\r\n')[]; +export type LBRACKET = "["; +export type RBRACKET = "]"; +export type COMMA = ","; +export type EQUALS = "="; +export type LPAREN = "("; +export type RPAREN = ")"; +export type _ = (string | "\r\n")[]; diff --git a/src/utils/exception.ts b/src/utils/exception.ts index 625c32a..f1ea92d 100644 --- a/src/utils/exception.ts +++ b/src/utils/exception.ts @@ -1 +1,9 @@ -export class NotImplementedException extends Error {} +export class NotImplementedError extends Error {} + +export class UnknownSymbolError extends Error {} + +export class InvalidStateError extends Error {} + +export class BadArgumentError extends Error {} + +export class TypeError extends Error {} diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts new file mode 100644 index 0000000..4dd0028 --- /dev/null +++ b/test/interpreter.spec.ts @@ -0,0 +1,12 @@ +import { expect, test } from 'bun:test'; +import { TestPrograms } from './programs'; +import { peggyParse } from '@/parser'; +import { evaluate } from '@/interpreter'; +import { testingLogger } from './logger'; + +test('Add (1 real) and (3 int) => (4 real)', async () => { + const ast = peggyParse(await TestPrograms.AddOneThree); + + const result = await evaluate(ast, testingLogger); + expect(result).toEqual({ type: 'real', value: 4 }); +}); diff --git a/test/parser.spec.ts b/test/parser.spec.ts index e174383..385a4dc 100644 --- a/test/parser.spec.ts +++ b/test/parser.spec.ts @@ -3,5 +3,13 @@ import { TestPrograms } from './programs'; import { peggyParse } from '@/parser'; test('Primitive Operations', async () => { - const ast = peggyParse(await TestPrograms.AddOneThree); + const [operation] = peggyParse(await TestPrograms.AddOneThree); + const { primitiveOperation } = operation; + + expect(primitiveOperation).toEqual({ + opr: '+', + operands: [{ real: 1 }, { int: 3 }], + resultBindings: [{ name: 'result' }], + continuations: [], + }); }); diff --git a/test/programs/add-1-3.cps b/test/programs/add-1-3.cps index 95b9939..e890aca 100644 --- a/test/programs/add-1-3.cps +++ b/test/programs/add-1-3.cps @@ -1,2 +1 @@ -PRIMOP(+, [INT 1, INT 2], [u], - [APP(LABEL identity, [VAR u])]) \ No newline at end of file +PRIMOP(+, [REAL 1, INT 3], [result], []) \ No newline at end of file -- 2.45.2 From f5faa68baff93e4d4405265757e5de907f2ecdeb Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 28 Feb 2024 10:52:40 -0700 Subject: [PATCH 2/4] checkpoint --- src/interpreter/builtin_signatures.ts | 106 -------------------------- src/interpreter/builtins.ts | 94 +++++++++++++++++++++++ src/interpreter/denotable.ts | 71 +++++++++++++++++ src/interpreter/environment.ts | 27 +++++-- src/interpreter/index.ts | 10 +-- src/interpreter/interpreter.ts | 52 ++----------- src/utils/exception.ts | 2 +- test/interpreter.spec.ts | 16 ++++ test/programs/index.ts | 6 ++ test/programs/string-equal.cps | 1 + test/programs/string-unequal.cps | 1 + test/signature_match.spec.ts | 41 ++++++++++ 12 files changed, 258 insertions(+), 169 deletions(-) delete mode 100644 src/interpreter/builtin_signatures.ts create mode 100644 src/interpreter/builtins.ts create mode 100644 src/interpreter/denotable.ts create mode 100644 test/programs/string-equal.cps create mode 100644 test/programs/string-unequal.cps create mode 100644 test/signature_match.spec.ts diff --git a/src/interpreter/builtin_signatures.ts b/src/interpreter/builtin_signatures.ts deleted file mode 100644 index 4ed99a7..0000000 --- a/src/interpreter/builtin_signatures.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { BadArgumentError } from '@/utils'; -import type { DenotableValueType } from '.'; - -export type Signature = Array>; - -export const primitiveOperationSignatures: Record = { - '+': [ - ['int', 'int', 'int'], - ['real', 'real', 'real'], - ['int', 'real', 'real'], - ['real', 'int', 'real'], - ], - '-': [ - ['int', 'int', 'int'], - ['real', 'real', 'real'], - ['int', 'real', 'real'], - ['real', 'int', 'real'], - ], - '*': [ - ['int', 'int', 'int'], - ['real', 'real', 'real'], - ['int', 'real', 'real'], - ['real', 'int', 'real'], - ], - '/': [ - ['int', 'int', 'int'], - ['real', 'real', 'real'], - ['int', 'real', 'real'], - ['real', 'int', 'real'], - ], - '%': [['int', 'int', 'int']], - '**': [ - ['int', 'int', 'int'], - ['real', 'real', 'real'], - ['int', 'real', 'real'], - ['real', 'int', 'real'], - ], - '>>': [['int', 'int', 'int']], - '<<': [['int', 'int', 'int']], - '&': [['int', 'int', 'int']], - '|': [['int', 'int', 'int']], - '^': [['int', 'int', 'int']], - '==': [ - ['int', 'int', 'int'], - ['real', 'real', 'int'], - ['string', 'string', 'int'], - ], - '!=': [ - ['int', 'int', 'int'], - ['real', 'real', 'int'], - ['string', 'string', 'int'], - ], - '<': [ - ['int', 'int', 'int'], - ['real', 'real', 'int'], - ], - '>': [ - ['int', 'int', 'int'], - ['real', 'real', 'int'], - ], - '<=': [ - ['int', 'int', 'int'], - ['real', 'real', 'int'], - ], - '>=': [ - ['int', 'int', 'int'], - ['real', 'real', 'int'], - ], - '&&': [['int', 'int', 'int']], - '||': [['int', 'int', 'int']], - '!': [['int', 'int']], -}; - -export const getResultingType = ( - opr: string, - types: DenotableValueType[], -): DenotableValueType | Signature => { - const signature = primitiveOperationSignatures[opr]; - if (!signature) { - throw new BadArgumentError(`Invalid operation: ${opr}`); - } - - const resultingType = signature.find(sig => { - if (sig.length !== types.length) { - return false; - } - - return sig.every((type, i) => { - if (Array.isArray(type)) { - return getResultingType( - opr, - types.map((t, j) => (i === j ? t : 'int')), - ); - } - return type === 'int' || type === types[i]; - }); - }); - - if (!resultingType) { - throw new TypeError( - `Invalid types for operation ${opr}: ${types.join(', ')}`, - ); - } - - return resultingType as DenotableValueType | Signature; -}; diff --git a/src/interpreter/builtins.ts b/src/interpreter/builtins.ts new file mode 100644 index 0000000..e18d4a3 --- /dev/null +++ b/src/interpreter/builtins.ts @@ -0,0 +1,94 @@ +import { type DenotableFunctionSignature, Environment } from '.'; + +const addUnaryIntegerOperationsTo = (env: Environment) => { + const unaryIntegerOperationSignatures: DenotableFunctionSignature[] = [ + { + arguments: ['int'], + return: 'int', + }, + ]; + + for (const { name, fn } of [ + { name: '~', fn: (a: number) => ~a }, + { name: '!', fn: (a: number) => (!a ? 1 : 0) }, + ]) { + env.set(name, { + type: 'function', + value: { signatures: unaryIntegerOperationSignatures, body: fn }, + }); + } + + return env; +}; + +const addBinaryIntegerOperationsTo = (env: Environment) => { + const binaryIntegerOperationSignatures: DenotableFunctionSignature[] = [ + { + arguments: ['int', 'int'], + return: 'int', + }, + ]; + + for (const { name, fn } of [ + { name: '%', fn: (a: number, b: number) => a % b }, + { name: '>>', fn: (a: number, b: number) => a >> b }, + { name: '<<', fn: (a: number, b: number) => a << b }, + { name: '|', fn: (a: number, b: number) => a | b }, + { name: '^', fn: (a: number, b: number) => a ^ b }, + { name: '&&', fn: (a: number, b: number) => (a && b ? 1 : 0) }, + { name: '<=', fn: (a: number, b: number) => (a <= b ? 1 : 0) }, + { name: '<', fn: (a: number, b: number) => (a < b ? 1 : 0) }, + { name: '>', fn: (a: number, b: number) => (a > b ? 1 : 0) }, + { name: '>=', fn: (a: number, b: number) => (a >= b ? 1 : 0) }, + { name: '||', fn: (a: number, b: number) => (a || b ? 1 : 0) }, + { name: '==', fn: (a: number, b: number) => (a == b ? 1 : 0) }, + ]) { + env.set(name, { + type: 'function', + value: { signatures: binaryIntegerOperationSignatures, body: fn }, + }); + } + + return env; +}; + +const addBinaryArithmeticOperationsTo = (env: Environment) => { + const binaryArithmeticSignatures: DenotableFunctionSignature[] = [ + { + arguments: ['int', 'int'], + return: 'int', + }, + { + arguments: [ + ['int', 'real'], + ['int', 'real'], + ], + return: 'real', + }, + ]; + + for (const { name, fn } of [ + { name: '+', fn: (a: number, b: number) => a + b }, + { name: '-', fn: (a: number, b: number) => a - b }, + { name: '*', fn: (a: number, b: number) => a * b }, + { name: '/', fn: (a: number, b: number) => a / b }, + { name: '**', fn: (a: number, b: number) => a ** b }, + ]) { + env.set(name, { + type: 'function', + value: { signatures: binaryArithmeticSignatures, body: fn }, + }); + } + + return env; +}; + +export const environmentWithBuiltins = () => { + const environment = new Environment(); + + return [ + addBinaryArithmeticOperationsTo, + addBinaryIntegerOperationsTo, + addUnaryIntegerOperationsTo, + ].reduce((acc, builtinsAdder) => builtinsAdder(acc), environment); +}; diff --git a/src/interpreter/denotable.ts b/src/interpreter/denotable.ts new file mode 100644 index 0000000..5fe3a3f --- /dev/null +++ b/src/interpreter/denotable.ts @@ -0,0 +1,71 @@ +import type { Identifier } from '@/parser'; + +export type UnionDenotableType = + | Array + | DenotableType + | DenotableFunctionSignature; + +export type DenotableFunctionSignature = { + arguments: Array; + return: UnionDenotableType; +}; + +export type DenotableFunction = { + signatures: Array; + body: Function; +}; + +export type DenotableType = + | 'null' + | 'int' + | 'real' + | 'string' + | 'bytearray' + | 'function' + | 'reference'; + +export type DenotableValue = + | null + | number + | string + | Uint8Array + | DenotableFunction + | Identifier; + +export type Denotable = { + type: DenotableType; + value: DenotableValue; +}; + +export const functionSignaturesEqual = ( + a: DenotableFunctionSignature, + b: DenotableFunctionSignature, +): boolean => { + if (a.arguments.length !== b.arguments.length) { + return false; + } + + if (typeof a.return !== typeof b.return) { + return false; + } + + if ( + typeof a.return === 'object' && + typeof b.return === 'object' && + 'return' in a.return && + 'return' in b.return + ) { + return functionSignaturesEqual(a.return, b.return); + } +}; + +export const matchSignature = ( + args: Array, + signatures: Array, +): DenotableFunctionSignature | undefined => { + return signatures.find(signature => { + if (args.length !== signature.arguments.length) { + return false; + } + }); +}; diff --git a/src/interpreter/environment.ts b/src/interpreter/environment.ts index cd0ee5c..aac0285 100644 --- a/src/interpreter/environment.ts +++ b/src/interpreter/environment.ts @@ -1,8 +1,14 @@ -import { UnknownSymbolError } from '@/utils'; -import type { DenotableValue } from '.'; +import { UnknownSymbolError, InvalidType } from '@/utils'; +import type { + Denotable, + DenotableFunction, + DenotableFunctionSignature, + DenotableType, + DenotableValue, +} from '.'; export class Environment { - private scope: Map; + private scope: Map; private parent: Environment | null; constructor(parent: Environment | null = null) { @@ -10,13 +16,13 @@ export class Environment { this.scope = new Map(); } - public set(name: string, value: DenotableValue) { + public set(name: string, value: Denotable) { this.scope.set(name, value); } - public get(name: string): DenotableValue { + public get(name: string): Denotable { if (this.scope.has(name)) { - return this.scope.get(name); + return this.scope.get(name)!; } if (this.parent) { @@ -41,4 +47,13 @@ export class Environment { public createChild(): Environment { return new Environment(this); } + + public apply(name: string, args: Denotable[]): Denotable { + const fn = this.get(name); + if (typeof fn.value !== 'object' || !fn.value || !('body' in fn.value)) { + throw new InvalidType(name + ' is not a valid function'); + } + + return { type: 'real', value: 0 }; + } } diff --git a/src/interpreter/index.ts b/src/interpreter/index.ts index dbc2d63..1c7c9db 100644 --- a/src/interpreter/index.ts +++ b/src/interpreter/index.ts @@ -1,11 +1,3 @@ -export type DenotableValueType = - | 'null' - | 'int' - | 'real' - | 'string' - | 'function' - | 'reference'; -export type DenotableValue = { type: DenotableValueType; value: any }; - +export * from './denotable'; export * from './environment'; export * from './interpreter'; diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts index bf76f4f..af1baf7 100644 --- a/src/interpreter/interpreter.ts +++ b/src/interpreter/interpreter.ts @@ -4,7 +4,7 @@ import { type Program, type Value, } from '@/parser'; -import { Environment, type DenotableValue } from '.'; +import { Environment, type Denotable } from '.'; import { BadArgumentError, InvalidStateError, @@ -16,7 +16,7 @@ const evaluateValue = ( value: Value, env: Environment, logger: TracingLogger, -): DenotableValue => { +): Denotable => { if (typeof value === 'string') { return { type: 'string', value }; } @@ -49,50 +49,8 @@ const evaluatePrimitiveOperation = ( evaluateValue(operand, env, logger.createChild('evaluteValue')), ); - const rightReducingOperations = { - '+': (acc: number, operand: { value: number }) => acc + operand.value, - '-': (acc: number, operand: { value: number }) => acc - operand.value, - '*': (acc: number, operand: { value: number }) => acc * operand.value, - }; - const leftReducingOperations = { - '/': (acc: number, operand: { value: number }) => acc / operand.value, - '%': (acc: number, operand: { value: number }) => acc % operand.value, - '**': (acc: number, operand: { value: number }) => acc ** operand.value, - '>>': (acc: number, operand: { value: number }) => acc >> operand.value, - '<<': (acc: number, operand: { value: number }) => acc << operand.value, - '&': (acc: number, operand: { value: number }) => acc & operand.value, - '|': (acc: number, operand: { value: number }) => acc | operand.value, - '^': (acc: number, operand: { value: number }) => acc ^ operand.value, - }; - const someNumberIsReal = operandValues.some(({ type }) => type === 'real'); - - let result: DenotableValue = { type: 'null', value: null }; + let result: Denotable = { type: 'null', value: null }; const continuationEnvironment = env.createChild(); - if (opr in rightReducingOperations) { - logger.debug('Evaluating right reducing operation: ' + opr); - const sum = operandValues.reduce( - rightReducingOperations[opr as keyof typeof rightReducingOperations], - 0, - ); - result = { type: someNumberIsReal ? 'real' : 'int', value: sum }; - - for (const binding of resultBindings) { - continuationEnvironment.set(binding.name, result); - } - } - if (opr in leftReducingOperations) { - logger.debug('Evaluating left reducing operation: ' + opr); - const [first, ...rest] = operandValues; - const sum = rest.reduce( - leftReducingOperations[opr as keyof typeof leftReducingOperations], - first.value, - ); - result = { type: someNumberIsReal ? 'real' : 'int', value: sum }; - - for (const binding of resultBindings) { - continuationEnvironment.set(binding.name, result); - } - } // return the result of the last continuation return continuations.reduce((_, continuation, i) => { @@ -109,7 +67,7 @@ const evaluteContinuationExpression = ( expr: ContinuationExpression, env: Environment, logger: TracingLogger, -): DenotableValue => { +): Denotable => { if ('primitiveOperation' in expr) { logger.debug('Evaluating primitive operation'); return evaluatePrimitiveOperation( @@ -146,7 +104,7 @@ const evaluteContinuationExpression = ( export const evaluate = async ( ast: Program, logger: TracingLogger, -): Promise => { +): Promise => { const environment = new Environment(); return ast.reduce((_, continuation, i) => { diff --git a/src/utils/exception.ts b/src/utils/exception.ts index f1ea92d..0472003 100644 --- a/src/utils/exception.ts +++ b/src/utils/exception.ts @@ -6,4 +6,4 @@ export class InvalidStateError extends Error {} export class BadArgumentError extends Error {} -export class TypeError extends Error {} +export class InvalidType extends Error {} diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts index 4dd0028..0da25c3 100644 --- a/test/interpreter.spec.ts +++ b/test/interpreter.spec.ts @@ -10,3 +10,19 @@ test('Add (1 real) and (3 int) => (4 real)', async () => { const result = await evaluate(ast, testingLogger); expect(result).toEqual({ type: 'real', value: 4 }); }); + +/* +test('String equality', async () => { + const ast = peggyParse(await TestPrograms.StringEquality); + + const result = await evaluate(ast, testingLogger); + expect(result).toEqual({ type: 'int', value: 1 }); +}); + +test('String inequality', async () => { + const ast = peggyParse(await TestPrograms.StringInEquality); + + const result = await evaluate(ast, testingLogger); + expect(result).toEqual({ type: 'int', value: 0 }); +}); +*/ diff --git a/test/programs/index.ts b/test/programs/index.ts index e0403fd..6dcd873 100644 --- a/test/programs/index.ts +++ b/test/programs/index.ts @@ -4,4 +4,10 @@ export namespace TestPrograms { export const AddOneThree = Bun.file( join(import.meta.dir + '/add-1-3.cps'), ).text(); + export const StringEquality = Bun.file( + join(import.meta.dir + '/string-equal.cps'), + ).text(); + export const StringInEquality = Bun.file( + join(import.meta.dir + '/string-unequal.cps'), + ).text(); } diff --git a/test/programs/string-equal.cps b/test/programs/string-equal.cps new file mode 100644 index 0000000..ea49b22 --- /dev/null +++ b/test/programs/string-equal.cps @@ -0,0 +1 @@ +PRIMOP(==, ["asdf", "asdf"], [result], []) \ No newline at end of file diff --git a/test/programs/string-unequal.cps b/test/programs/string-unequal.cps new file mode 100644 index 0000000..ccd278e --- /dev/null +++ b/test/programs/string-unequal.cps @@ -0,0 +1 @@ +PRIMOP(==, ["asdfasdf", "asdf"], [result], []) diff --git a/test/signature_match.spec.ts b/test/signature_match.spec.ts new file mode 100644 index 0000000..af17a93 --- /dev/null +++ b/test/signature_match.spec.ts @@ -0,0 +1,41 @@ +import { expect, test } from 'bun:test'; +import { TestPrograms } from './programs'; +import { peggyParse } from '@/parser'; +import { + evaluate, + type DenotableFunctionSignature, + matchSignature, +} from '@/interpreter'; +import { testingLogger } from './logger'; + +test('matches simple signatures', async () => { + const simpleSignature: DenotableFunctionSignature[] = [ + { + arguments: ['int'], + return: 'int', + }, + ]; + + expect(matchSignature(['int'], simpleSignature)).toEqual(simpleSignature[0]); +}); + +test('finds first match', async () => { + const simpleSignature: DenotableFunctionSignature[] = [ + { + arguments: ['int', 'int'], + return: 'int', + }, + { + arguments: [['int', 'real'], 'int'], + return: 'real', + }, + ]; + + expect(matchSignature(['int', 'int'], simpleSignature)).toEqual( + simpleSignature[0], + ); + + expect(matchSignature(['real', 'int'], simpleSignature)).toEqual( + simpleSignature[1], + ); +}); -- 2.45.2 From 68745f5b94b604578d6b91dd9e8f57e34fa32eb3 Mon Sep 17 00:00:00 2001 From: Lizzy Hunt Date: Wed, 28 Feb 2024 12:48:03 -0700 Subject: [PATCH 3/4] primitive operations setup --- src/interpreter/builtins.ts | 29 +++++--- src/interpreter/denotable.ts | 60 +++++++++++------ src/interpreter/environment.ts | 46 ++++++++++--- src/interpreter/interpreter.ts | 9 ++- test/signature_match.spec.ts | 119 +++++++++++++++++++++++++++++++++ 5 files changed, 222 insertions(+), 41 deletions(-) diff --git a/src/interpreter/builtins.ts b/src/interpreter/builtins.ts index e18d4a3..c5769db 100644 --- a/src/interpreter/builtins.ts +++ b/src/interpreter/builtins.ts @@ -1,4 +1,8 @@ -import { type DenotableFunctionSignature, Environment } from '.'; +import { + type DenotableFunctionSignature, + Environment, + type Denotable, +} from '.'; const addUnaryIntegerOperationsTo = (env: Environment) => { const unaryIntegerOperationSignatures: DenotableFunctionSignature[] = [ @@ -14,7 +18,10 @@ const addUnaryIntegerOperationsTo = (env: Environment) => { ]) { env.set(name, { type: 'function', - value: { signatures: unaryIntegerOperationSignatures, body: fn }, + value: { + signatures: unaryIntegerOperationSignatures, + body: ({ value }: Denotable) => fn(value as number), + }, }); } @@ -45,7 +52,11 @@ const addBinaryIntegerOperationsTo = (env: Environment) => { ]) { env.set(name, { type: 'function', - value: { signatures: binaryIntegerOperationSignatures, body: fn }, + value: { + signatures: binaryIntegerOperationSignatures, + body: ({ value: a }: Denotable, { value: b }: Denotable) => + fn(a as number, b as number), + }, }); } @@ -76,19 +87,21 @@ const addBinaryArithmeticOperationsTo = (env: Environment) => { ]) { env.set(name, { type: 'function', - value: { signatures: binaryArithmeticSignatures, body: fn }, + value: { + signatures: binaryArithmeticSignatures, + body: ({ value: a }: Denotable, { value: b }: Denotable) => + fn(a as number, b as number), + }, }); } return env; }; -export const environmentWithBuiltins = () => { - const environment = new Environment(); - +export const putBuiltinsOnEnvironemtn = (env: Environment) => { return [ addBinaryArithmeticOperationsTo, addBinaryIntegerOperationsTo, addUnaryIntegerOperationsTo, - ].reduce((acc, builtinsAdder) => builtinsAdder(acc), environment); + ].reduce((acc, builtinsAdder) => builtinsAdder(acc), env); }; diff --git a/src/interpreter/denotable.ts b/src/interpreter/denotable.ts index 5fe3a3f..65aee86 100644 --- a/src/interpreter/denotable.ts +++ b/src/interpreter/denotable.ts @@ -1,13 +1,15 @@ import type { Identifier } from '@/parser'; +import { testingLogger } from '@t/logger'; export type UnionDenotableType = | Array | DenotableType - | DenotableFunctionSignature; + | DenotableFunctionSignature + | Array; export type DenotableFunctionSignature = { arguments: Array; - return: UnionDenotableType; + return: DenotableType; }; export type DenotableFunction = { @@ -37,35 +39,55 @@ export type Denotable = { value: DenotableValue; }; -export const functionSignaturesEqual = ( - a: DenotableFunctionSignature, - b: DenotableFunctionSignature, +export const denotableTypesEquivalent = ( + a: UnionDenotableType, + b: UnionDenotableType, ): boolean => { - if (a.arguments.length !== b.arguments.length) { - return false; - } + if (typeof a !== typeof b) return false; - if (typeof a.return !== typeof b.return) { - return false; + if (Array.isArray(a) && Array.isArray(b)) { + if (a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) { + if (!denotableTypesEquivalent(a[i], b[i])) return false; + } + return true; } if ( - typeof a.return === 'object' && - typeof b.return === 'object' && - 'return' in a.return && - 'return' in b.return + typeof a === 'object' && + typeof b === 'object' && + 'arguments' in a && + 'arguments' in b ) { - return functionSignaturesEqual(a.return, b.return); + if (a.arguments.length !== b.arguments.length) return false; + if (!denotableTypesEquivalent(a.return, b.return)) return false; + for (let i = 0; i < a.arguments.length; i++) { + if (!denotableTypesEquivalent(a.arguments[i], b.arguments[i])) { + return false; + } + } + return true; } + + if (a === b) return true; + + return false; }; export const matchSignature = ( - args: Array, + args: Array, signatures: Array, ): DenotableFunctionSignature | undefined => { return signatures.find(signature => { - if (args.length !== signature.arguments.length) { - return false; - } + if (args.length !== signature.arguments.length) return false; + + return args.every((arg, i) => { + const argSignature = signature.arguments[i]; + if (Array.isArray(argSignature)) { + return argSignature.some(a => denotableTypesEquivalent(a, arg)); + } + + return denotableTypesEquivalent(arg, signature.arguments[i]); + }); }); }; diff --git a/src/interpreter/environment.ts b/src/interpreter/environment.ts index aac0285..1c451aa 100644 --- a/src/interpreter/environment.ts +++ b/src/interpreter/environment.ts @@ -1,17 +1,13 @@ -import { UnknownSymbolError, InvalidType } from '@/utils'; -import type { - Denotable, - DenotableFunction, - DenotableFunctionSignature, - DenotableType, - DenotableValue, -} from '.'; +import { UnknownSymbolError, InvalidType, type TracingLogger } from '@/utils'; +import { matchSignature, type Denotable } from '.'; export class Environment { private scope: Map; private parent: Environment | null; + private logger: TracingLogger; - constructor(parent: Environment | null = null) { + constructor(logger: TracingLogger, parent: Environment | null = null) { + this.logger = logger; this.parent = parent; this.scope = new Map(); } @@ -22,10 +18,12 @@ export class Environment { public get(name: string): Denotable { if (this.scope.has(name)) { + this.logger.debug(`Found Name=(${name}) in current scope`); return this.scope.get(name)!; } if (this.parent) { + this.logger.debug(`Looking for Name=(${name}) in parent scope`); return this.parent.get(name); } @@ -34,18 +32,21 @@ export class Environment { public has(name: string): boolean { if (this.scope.has(name)) { + this.logger.debug(`Found Name=(${name}) in current scope`); return true; } if (this.parent) { + this.logger.debug(`Found Name=(${name}) in current scope`); return this.parent.has(name); } + this.logger.debug(`Name=(${name}) not found in any scope`); return false; } public createChild(): Environment { - return new Environment(this); + return new Environment(this.logger.createChild('Env'), this); } public apply(name: string, args: Denotable[]): Denotable { @@ -54,6 +55,29 @@ export class Environment { throw new InvalidType(name + ' is not a valid function'); } - return { type: 'real', value: 0 }; + const argTypes = args.map(arg => { + const { type, value } = arg; + const isFunction = + type === 'function' && + typeof value === 'object' && + value && + 'signatures' in value; + if (isFunction) { + return value.signatures; + } + return type; + }); + + const appliedSignature = matchSignature(argTypes, fn.value.signatures); + if (!appliedSignature) { + throw new InvalidType(`No matching signature for ${name}`); + } + + this.logger.debug( + `Applying Function=(${name}) with Args=(${JSON.stringify(args)}) with Signature=(${JSON.stringify(appliedSignature)})`, + ); + + const value = fn.value.body.apply(this, args); + return { type: appliedSignature.return, value }; } } diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts index af1baf7..4a0be05 100644 --- a/src/interpreter/interpreter.ts +++ b/src/interpreter/interpreter.ts @@ -11,6 +11,7 @@ import { NotImplementedError, type TracingLogger, } from '@/utils'; +import { putBuiltinsOnEnvironemtn } from './builtins'; const evaluateValue = ( value: Value, @@ -49,7 +50,7 @@ const evaluatePrimitiveOperation = ( evaluateValue(operand, env, logger.createChild('evaluteValue')), ); - let result: Denotable = { type: 'null', value: null }; + const result = env.apply(opr, operandValues); const continuationEnvironment = env.createChild(); // return the result of the last continuation @@ -105,13 +106,15 @@ export const evaluate = async ( ast: Program, logger: TracingLogger, ): Promise => { - const environment = new Environment(); + const globalEnvironment = putBuiltinsOnEnvironemtn( + new Environment(logger.createChild('Root')), + ); return ast.reduce((_, continuation, i) => { const exprLogger = logger.createChild(`statement[${i}]`); return evaluteContinuationExpression( continuation as ContinuationExpression, - environment, + globalEnvironment, exprLogger, ); }, null); diff --git a/test/signature_match.spec.ts b/test/signature_match.spec.ts index af17a93..10be880 100644 --- a/test/signature_match.spec.ts +++ b/test/signature_match.spec.ts @@ -4,10 +4,59 @@ import { peggyParse } from '@/parser'; import { evaluate, type DenotableFunctionSignature, + denotableTypesEquivalent, matchSignature, } from '@/interpreter'; import { testingLogger } from './logger'; +test('simple denotable types are equivalent', () => { + expect(denotableTypesEquivalent('int', 'int')).toBe(true); + expect(denotableTypesEquivalent('int', 'real')).toBe(false); + expect(denotableTypesEquivalent('int', 'null')).toBe(false); + expect(denotableTypesEquivalent('null', 'null')).toBe(true); +}); + +test('union data types are equivalent', () => { + expect(denotableTypesEquivalent(['int', 'real'], ['int', 'real'])).toBe(true); + expect(denotableTypesEquivalent('int', ['int', 'real'])).toBe(false); +}); + +test('function data types are equivalent', () => { + expect( + denotableTypesEquivalent( + [ + { + arguments: ['int', 'real'], + return: 'int', + }, + ], + [ + { + arguments: ['int', 'real'], + return: 'int', + }, + ], + ), + ).toBe(true); + + expect( + denotableTypesEquivalent( + [ + { + arguments: ['int', 'real'], + return: 'real', + }, + ], + [ + { + arguments: ['int', 'real'], + return: 'int', + }, + ], + ), + ).toBe(false); +}); + test('matches simple signatures', async () => { const simpleSignature: DenotableFunctionSignature[] = [ { @@ -39,3 +88,73 @@ test('finds first match', async () => { simpleSignature[1], ); }); + +test('finds first match with a function signature', async () => { + const testSignature: DenotableFunctionSignature = { + arguments: ['int', 'real'], + return: 'int', + }; + + const simpleSignature: DenotableFunctionSignature[] = [ + { + arguments: ['int', 'int'], + return: 'int', + }, + { + arguments: [[testSignature, 'real'], 'int'], + return: 'function', + }, + ]; + + expect(matchSignature(['int', 'int'], simpleSignature)).toEqual( + simpleSignature[0], + ); + + expect(matchSignature(['real', 'int'], simpleSignature)).toEqual( + simpleSignature[1], + ); + + expect(matchSignature([testSignature, 'int'], simpleSignature)).toEqual( + simpleSignature[1], + ); +}); + +test('finds first match with a function with many signatures', async () => { + const testSignature: DenotableFunctionSignature[] = [ + { + arguments: ['int', 'real'], + return: 'int', + }, + { + arguments: ['int', 'int'], + return: 'int', + }, + ]; + + const simpleSignature: DenotableFunctionSignature[] = [ + { + arguments: ['int', 'int'], + return: 'int', + }, + { + arguments: [[testSignature, 'real'], 'int'], + return: 'function', + }, + ]; + + expect(matchSignature(['int', 'int'], simpleSignature)).toEqual( + simpleSignature[0], + ); + + expect(matchSignature(['real', 'int'], simpleSignature)).toEqual( + simpleSignature[1], + ); + + expect(matchSignature([testSignature, 'int'], simpleSignature)).toEqual( + simpleSignature[1], + ); + + expect( + matchSignature([[testSignature[0]], 'int'], simpleSignature), + ).toBeUndefined(); +}); -- 2.45.2 From c9dc50cb972652fa5e1ee0fcb422f3079fecb064 Mon Sep 17 00:00:00 2001 From: Lizzy Hunt Date: Wed, 28 Feb 2024 12:59:01 -0700 Subject: [PATCH 4/4] correct scope --- src/interpreter/builtins.ts | 1 - src/interpreter/interpreter.ts | 5 ++++- test/interpreter.spec.ts | 7 +++++++ test/parser.spec.ts | 32 +++++++++++++++++++++++++++++++- test/programs/add-1-3.cps | 2 +- test/programs/index.ts | 3 +++ test/programs/primop-scope.cps | 5 +++++ 7 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 test/programs/primop-scope.cps diff --git a/src/interpreter/builtins.ts b/src/interpreter/builtins.ts index c5769db..200131f 100644 --- a/src/interpreter/builtins.ts +++ b/src/interpreter/builtins.ts @@ -48,7 +48,6 @@ const addBinaryIntegerOperationsTo = (env: Environment) => { { name: '>', fn: (a: number, b: number) => (a > b ? 1 : 0) }, { name: '>=', fn: (a: number, b: number) => (a >= b ? 1 : 0) }, { name: '||', fn: (a: number, b: number) => (a || b ? 1 : 0) }, - { name: '==', fn: (a: number, b: number) => (a == b ? 1 : 0) }, ]) { env.set(name, { type: 'function', diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts index 4a0be05..ebd605c 100644 --- a/src/interpreter/interpreter.ts +++ b/src/interpreter/interpreter.ts @@ -52,6 +52,9 @@ const evaluatePrimitiveOperation = ( const result = env.apply(opr, operandValues); const continuationEnvironment = env.createChild(); + for (const { name } of resultBindings) { + continuationEnvironment.set(name, result); + } // return the result of the last continuation return continuations.reduce((_, continuation, i) => { @@ -107,7 +110,7 @@ export const evaluate = async ( logger: TracingLogger, ): Promise => { const globalEnvironment = putBuiltinsOnEnvironemtn( - new Environment(logger.createChild('Root')), + new Environment(logger.createChild('RootEnv')), ); return ast.reduce((_, continuation, i) => { diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts index 0da25c3..fa74ef0 100644 --- a/test/interpreter.spec.ts +++ b/test/interpreter.spec.ts @@ -11,6 +11,13 @@ test('Add (1 real) and (3 int) => (4 real)', async () => { expect(result).toEqual({ type: 'real', value: 4 }); }); +test('Add (1 real) and (3 int) -> result => (real 1 - result) = -3 done with correct lexical scope', async () => { + const ast = peggyParse(await TestPrograms.PrimopScope); + + const result = await evaluate(ast, testingLogger); + expect(result).toEqual({ type: 'real', value: -3 }); +}); + /* test('String equality', async () => { const ast = peggyParse(await TestPrograms.StringEquality); diff --git a/test/parser.spec.ts b/test/parser.spec.ts index 385a4dc..07353b8 100644 --- a/test/parser.spec.ts +++ b/test/parser.spec.ts @@ -2,7 +2,7 @@ import { expect, test } from 'bun:test'; import { TestPrograms } from './programs'; import { peggyParse } from '@/parser'; -test('Primitive Operations', async () => { +test('primitive operation', async () => { const [operation] = peggyParse(await TestPrograms.AddOneThree); const { primitiveOperation } = operation; @@ -13,3 +13,33 @@ test('Primitive Operations', async () => { continuations: [], }); }); + +test('primitive operation with continuation', async () => { + const [operation] = peggyParse(await TestPrograms.PrimopScope); + const { primitiveOperation } = operation; + + const continuation = { + primitiveOperation: { + opr: '-', + operands: [{ real: 1 }, { name: 'result' }], + resultBindings: [{ name: 'result' }], + continuations: [ + { + primitiveOperation: { + opr: '+', + operands: [{ name: 'result' }, { real: 0 }], + resultBindings: [], + continuations: [], + }, + }, + ], + }, + }; + + expect(primitiveOperation).toEqual({ + opr: '+', + operands: [{ real: 1 }, { int: 3 }], + resultBindings: [{ name: 'result' }], + continuations: [continuation], + }); +}); diff --git a/test/programs/add-1-3.cps b/test/programs/add-1-3.cps index e890aca..66759f7 100644 --- a/test/programs/add-1-3.cps +++ b/test/programs/add-1-3.cps @@ -1 +1 @@ -PRIMOP(+, [REAL 1, INT 3], [result], []) \ No newline at end of file +PRIMOP(+, [REAL 1.0, INT 3], [result], []) \ No newline at end of file diff --git a/test/programs/index.ts b/test/programs/index.ts index 6dcd873..c8f3c85 100644 --- a/test/programs/index.ts +++ b/test/programs/index.ts @@ -4,6 +4,9 @@ export namespace TestPrograms { export const AddOneThree = Bun.file( join(import.meta.dir + '/add-1-3.cps'), ).text(); + export const PrimopScope = Bun.file( + join(import.meta.dir + '/primop-scope.cps'), + ).text(); export const StringEquality = Bun.file( join(import.meta.dir + '/string-equal.cps'), ).text(); diff --git a/test/programs/primop-scope.cps b/test/programs/primop-scope.cps new file mode 100644 index 0000000..eb834fd --- /dev/null +++ b/test/programs/primop-scope.cps @@ -0,0 +1,5 @@ +PRIMOP(+, [REAL 1.0, INT 3], [result], [ + PRIMOP(-, [REAL 1.0, VAR result], [result], [ + PRIMOP(+, [VAR result, REAL 0], [], []) + ]) +]) \ No newline at end of file -- 2.45.2