implement lambda calls in web components

This commit is contained in:
Vyacheslav Matyukhin 2022-08-30 15:16:57 +04:00
parent a7bbfad94b
commit ba280c9292
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
10 changed files with 185 additions and 219 deletions

View File

@ -1,5 +1,5 @@
import * as React from "react";
import { SqLambda, environment } from "@quri/squiggle-lang";
import { SqLambda, environment, SqValueTag } from "@quri/squiggle-lang";
import { FunctionChart1Dist } from "./FunctionChart1Dist";
import { FunctionChart1Number } from "./FunctionChart1Number";
import { DistributionPlottingSettings } from "./DistributionChart";
@ -33,10 +33,8 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
</MessageAlert>
);
}
return <div>NOT IMPLEMENTED IN 0.4 YET</div>;
/*
const result1 = runForeign(fn, [chartSettings.start], environment);
const result2 = runForeign(fn, [chartSettings.stop], environment);
const result1 = fn.call([chartSettings.start]);
const result2 = fn.call([chartSettings.stop]);
const getValidResult = () => {
if (result1.tag === "Ok") {
return result1;
@ -55,7 +53,7 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
}
switch (validResult.value.tag) {
case "distribution":
case SqValueTag.Distribution:
return (
<FunctionChart1Dist
fn={fn}
@ -65,7 +63,7 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
distributionPlotSettings={distributionPlotSettings}
/>
);
case "number":
case SqValueTag.Number:
return (
<FunctionChart1Number
fn={fn}
@ -82,5 +80,4 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
</MessageAlert>
);
}
*/
};

View File

@ -6,6 +6,9 @@ import {
result,
SqLambda,
environment,
SqError,
SqValue,
SqValueTag,
} from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega";
import * as percentilesSpec from "../vega-specs/spec-percentiles.json";
@ -75,9 +78,15 @@ type errors = _.Dictionary<
type point = { x: number; value: result<SqDistribution, string> };
let getPercentiles = ({ chartSettings, fn, environment }) => {
throw new Error("NOT IMPLEMENTED IN 0.4 YET");
/*
let getPercentiles = ({
chartSettings,
fn,
environment,
}: {
chartSettings: FunctionChartSettings;
fn: SqLambda;
environment: environment;
}) => {
let chartPointsToRender = _rangeByCount(
chartSettings.start,
chartSettings.stop,
@ -85,9 +94,9 @@ let getPercentiles = ({ chartSettings, fn, environment }) => {
);
let chartPointsData: point[] = chartPointsToRender.map((x) => {
let result = runForeign(fn, [x], environment);
let result = fn.call([x]);
if (result.tag === "Ok") {
if (result.value.tag === "distribution") {
if (result.value.tag === SqValueTag.Distribution) {
return { x, value: { tag: "Ok", value: result.value.value } };
} else {
return {
@ -108,7 +117,7 @@ let getPercentiles = ({ chartSettings, fn, environment }) => {
});
let initialPartition: [
{ x: number; value: Distribution }[],
{ x: number; value: SqDistribution }[],
{ x: number; value: string }[]
] = [[], []];
@ -127,27 +136,26 @@ let getPercentiles = ({ chartSettings, fn, environment }) => {
// We convert it to to a pointSet distribution first, so that in case its a sample set
// distribution, it doesn't internally convert it to a pointSet distribution for every
// single inv() call.
let toPointSet: Distribution = unwrap(value.toPointSet());
let toPointSet = unwrap(value.pointSet(environment)).asDistribution();
return {
x: x,
p1: unwrap(toPointSet.inv(0.01)),
p5: unwrap(toPointSet.inv(0.05)),
p10: unwrap(toPointSet.inv(0.1)),
p20: unwrap(toPointSet.inv(0.2)),
p30: unwrap(toPointSet.inv(0.3)),
p40: unwrap(toPointSet.inv(0.4)),
p50: unwrap(toPointSet.inv(0.5)),
p60: unwrap(toPointSet.inv(0.6)),
p70: unwrap(toPointSet.inv(0.7)),
p80: unwrap(toPointSet.inv(0.8)),
p90: unwrap(toPointSet.inv(0.9)),
p95: unwrap(toPointSet.inv(0.95)),
p99: unwrap(toPointSet.inv(0.99)),
p1: unwrap(toPointSet.inv(environment, 0.01)),
p5: unwrap(toPointSet.inv(environment, 0.05)),
p10: unwrap(toPointSet.inv(environment, 0.1)),
p20: unwrap(toPointSet.inv(environment, 0.2)),
p30: unwrap(toPointSet.inv(environment, 0.3)),
p40: unwrap(toPointSet.inv(environment, 0.4)),
p50: unwrap(toPointSet.inv(environment, 0.5)),
p60: unwrap(toPointSet.inv(environment, 0.6)),
p70: unwrap(toPointSet.inv(environment, 0.7)),
p80: unwrap(toPointSet.inv(environment, 0.8)),
p90: unwrap(toPointSet.inv(environment, 0.9)),
p95: unwrap(toPointSet.inv(environment, 0.95)),
p99: unwrap(toPointSet.inv(environment, 0.99)),
};
});
return { percentiles, errors: groupedErrors };
*/
};
export const FunctionChart1Dist: React.FC<FunctionChart1DistProps> = ({
@ -166,23 +174,21 @@ export const FunctionChart1Dist: React.FC<FunctionChart1DistProps> = ({
}
const signalListeners = { mousemove: handleHover, mouseout: handleOut };
return <div>NOT IMPLEMENTED IN 0.4 YET</div>;
/*
//TODO: This custom error handling is a bit hacky and should be improved.
let mouseItem: result<squiggleExpression, errorValue> = !!mouseOverlay
? runForeign(fn, [mouseOverlay], environment)
let mouseItem: result<SqValue, SqError> = !!mouseOverlay
? fn.call([mouseOverlay])
: {
tag: "Error",
value: {
tag: "RETodo",
value: "Hover x-coordinate returned NaN. Expected a number.",
},
value: SqError.createOtherError(
"Hover x-coordinate returned NaN. Expected a number."
),
};
let showChart =
mouseItem.tag === "Ok" && mouseItem.value.tag === "distribution" ? (
mouseItem.tag === "Ok" &&
mouseItem.value.tag === SqValueTag.Distribution ? (
<DistributionChart
plot={defaultPlot(mouseItem.value.value)}
environment={environment}
width={400}
height={50}
{...distributionPlotSettings}
@ -219,5 +225,4 @@ export const FunctionChart1Dist: React.FC<FunctionChart1DistProps> = ({
)}
</>
);
*/
};

View File

@ -1,10 +1,11 @@
import * as React from "react";
import _ from "lodash";
import type { Spec } from "vega";
import { result, SqLambda, environment } from "@quri/squiggle-lang";
import { result, SqLambda, environment, SqValueTag } from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega";
import * as lineChartSpec from "../vega-specs/spec-line-chart.json";
import { ErrorAlert } from "./Alert";
import { squiggleValueTag } from "@quri/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_tag";
let SquiggleLineChart = createClassFromSpec({
spec: lineChartSpec as Spec,
@ -32,9 +33,15 @@ interface FunctionChart1NumberProps {
type point = { x: number; value: result<number, string> };
let getFunctionImage = ({ chartSettings, fn, environment }) => {
throw new Error("NOT IMPLEMENTED IN 0.4 YET");
/*
let getFunctionImage = ({
chartSettings,
fn,
environment,
}: {
chartSettings: FunctionChartSettings;
fn: SqLambda;
environment: environment;
}) => {
let chartPointsToRender = _rangeByCount(
chartSettings.start,
chartSettings.stop,
@ -42,9 +49,9 @@ let getFunctionImage = ({ chartSettings, fn, environment }) => {
);
let chartPointsData: point[] = chartPointsToRender.map((x) => {
let result = runForeign(fn, [x], environment);
let result = fn.call([x]);
if (result.tag === "Ok") {
if (result.value.tag == "number") {
if (result.value.tag === SqValueTag.Number) {
return { x, value: { tag: "Ok", value: result.value.value } };
} else {
return {
@ -78,7 +85,6 @@ let getFunctionImage = ({ chartSettings, fn, environment }) => {
}, initialPartition);
return { errors, functionImage };
*/
};
export const FunctionChart1Number: React.FC<FunctionChart1NumberProps> = ({
@ -87,8 +93,6 @@ export const FunctionChart1Number: React.FC<FunctionChart1NumberProps> = ({
environment,
height,
}: FunctionChart1NumberProps) => {
return <div>NOT IMPLEMENTED IN 0.4 YET</div>;
/*
let getFunctionImageMemoized = React.useMemo(
() => getFunctionImage({ chartSettings, fn, environment }),
[environment, fn]
@ -112,5 +116,4 @@ export const FunctionChart1Number: React.FC<FunctionChart1NumberProps> = ({
))}
</>
);
*/
};

View File

@ -6,4 +6,12 @@ export class SqError {
toString() {
return RSErrorValue.toString(this._value);
}
static createTodoError(v: string) {
return new SqError(RSErrorValue.createTodoError(v));
}
static createOtherError(v: string) {
return new SqError(RSErrorValue.createOtherError(v));
}
}

View File

@ -1,5 +1,8 @@
import * as RSLambda from "../rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.gen";
import { SqError } from "./SqError";
import { SqValue } from "./SqValue";
import { SqValueLocation } from "./SqValueLocation";
import { result } from "./types";
type T = RSLambda.squiggleValue_Lambda;
@ -9,4 +12,32 @@ export class SqLambda {
parameters() {
return RSLambda.parameters(this._value);
}
call(args: (number | string)[]): result<SqValue, SqError> {
const { project, sourceId } = this.location;
// Might be good to use uuid instead, but there's no way to remove sources from projects.
// So this is not thread-safe.
const callId = "__lambda__";
if (this.location.path.root !== "bindings") {
return {
tag: "Error",
value: SqError.createTodoError("Only bindings lambdas can be rendered"),
};
}
const quote = (arg: string) =>
`"${arg.replace(new RegExp('"', "g"), '\\"')}"`;
const argsSource = args
.map((arg) => (typeof arg === "number" ? arg : quote(arg)))
.join(",");
const functionNameSource = this.location.path.items
.map((item, i) =>
typeof item === "string" ? (i ? "." + item : item) : `[${item}]`
)
.join("");
const source = `${functionNameSource}(${argsSource})`;
project.setSource(callId, source);
project.setContinues(callId, [sourceId]);
project.run(callId);
return project.getResult(callId);
}
}

View File

@ -1,4 +1,5 @@
import * as _ from "lodash";
import { wrapDistribution } from "./SqDistribution";
import * as RSPointSetDist from "../rescript/ForTS/ForTS_Distribution/ForTS_Distribution_PointSetDistribution.gen";
import { pointSetDistributionTag as Tag } from "../rescript/ForTS/ForTS_Distribution/ForTS_Distribution_PointSetDistribution_tag";
@ -34,6 +35,10 @@ abstract class SqAbstractPointSetDist {
if (!value) throw new Error("Internal casting error");
return value;
};
asDistribution() {
return wrapDistribution(RSPointSetDist.toDistribution(this._value));
}
}
export class SqMixedPointSetDist extends SqAbstractPointSetDist {

View File

@ -45,3 +45,6 @@ let getContinues = (variant: pointSetDistribution): 'd =>
| Continuous(continuous) => continuous->Some
| _ => None
}
@genType
let toDistribution = (v: pointSetDistribution): DistributionTypes.genericDist => PointSet(v)

View File

@ -10,3 +10,9 @@ let getLocation = (e: reducerErrorValue): option<syntaxErrorLocation> =>
| RESyntaxError(_, optionalLocation) => optionalLocation
| _ => None
}
@genType
let createTodoError = (v: string) => Reducer_ErrorValue.RETodo(v)
@genType
let createOtherError = (v: string) => Reducer_ErrorValue.REOther(v)

View File

@ -22,6 +22,7 @@ type errorValue =
| RETodo(string) // To do
| REUnitNotFound(string)
| RENeedToRun
| REOther(string)
type t = errorValue
@ -59,4 +60,5 @@ let errorToString = err =>
| REExpectedType(typeName, valueString) => `Expected type: ${typeName} but got: ${valueString}`
| REUnitNotFound(unitName) => `Unit not found: ${unitName}`
| RENeedToRun => "Need to run"
| REOther(msg) => `Error: ${msg}`
}

View File

@ -5,9 +5,7 @@
"use strict";
function peg$subclass(child, parent) {
function C() {
this.constructor = child;
}
function C() { this.constructor = child; }
C.prototype = parent.prototype;
child.prototype = new C();
}
@ -29,9 +27,7 @@ peg$subclass(peg$SyntaxError, Error);
function peg$padEnd(str, targetLength, padString) {
padString = padString || " ";
if (str.length > targetLength) {
return str;
}
if (str.length > targetLength) { return str; }
targetLength -= str.length;
padString += padString.repeat(targetLength);
return str + padString.slice(0, targetLength);
@ -52,24 +48,15 @@ peg$SyntaxError.prototype.format = function (sources) {
var loc = this.location.source + ":" + s.line + ":" + s.column;
if (src) {
var e = this.location.end;
var filler = peg$padEnd("", s.line.toString().length, " ");
var filler = peg$padEnd("", s.line.toString().length, ' ');
var line = src[s.line - 1];
var last = s.line === e.line ? e.column : line.length + 1;
var hatLen = last - s.column || 1;
str +=
"\n --> " +
loc +
"\n" +
filler +
" |\n" +
s.line +
" | " +
line +
"\n" +
filler +
" | " +
peg$padEnd("", s.column - 1, " ") +
peg$padEnd("", hatLen, "^");
var hatLen = (last - s.column) || 1;
str += "\n --> " + loc + "\n"
+ filler + " |\n"
+ s.line + " | " + line + "\n"
+ filler + " | " + peg$padEnd("", s.column - 1, ' ')
+ peg$padEnd("", hatLen, "^");
} else {
str += "\n at " + loc;
}
@ -80,7 +67,7 @@ peg$SyntaxError.prototype.format = function (sources) {
peg$SyntaxError.buildMessage = function(expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function(expectation) {
return '"' + literalEscape(expectation.text) + '"';
return "\"" + literalEscape(expectation.text) + "\"";
},
class: function(expectation) {
@ -90,9 +77,7 @@ peg$SyntaxError.buildMessage = function (expected, found) {
: classEscape(part);
});
return (
"[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"
);
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
},
any: function() {
@ -105,7 +90,7 @@ peg$SyntaxError.buildMessage = function (expected, found) {
other: function(expectation) {
return expectation.description;
},
}
};
function hex(ch) {
@ -115,17 +100,13 @@ peg$SyntaxError.buildMessage = function (expected, found) {
function literalEscape(s) {
return s
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/"/g, "\\\"")
.replace(/\0/g, "\\0")
.replace(/\t/g, "\\t")
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/[\x00-\x0F]/g, function (ch) {
return "\\x0" + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return "\\x" + hex(ch);
});
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
}
function classEscape(s) {
@ -138,12 +119,8 @@ peg$SyntaxError.buildMessage = function (expected, found) {
.replace(/\t/g, "\\t")
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/[\x00-\x0F]/g, function (ch) {
return "\\x0" + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return "\\x" + hex(ch);
});
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
}
function describeExpectation(expectation) {
@ -174,25 +151,17 @@ peg$SyntaxError.buildMessage = function (expected, found) {
return descriptions[0] + " or " + descriptions[1];
default:
return (
descriptions.slice(0, -1).join(", ") +
", or " +
descriptions[descriptions.length - 1]
);
return descriptions.slice(0, -1).join(", ")
+ ", or "
+ descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? '"' + literalEscape(found) + '"' : "end of input";
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return (
"Expected " +
describeExpected(expected) +
" but " +
describeFound(found) +
" found."
);
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
@ -206,7 +175,7 @@ function peg$parse(input, options) {
var peg$c0 = "#include";
var peg$c1 = "'";
var peg$c2 = '"';
var peg$c2 = "\"";
var peg$c3 = "//";
var peg$c4 = "/*";
var peg$c5 = "*/";
@ -222,8 +191,8 @@ function peg$parse(input, options) {
var peg$e1 = peg$otherExpectation("string");
var peg$e2 = peg$literalExpectation("'", false);
var peg$e3 = peg$classExpectation(["'"], true, false);
var peg$e4 = peg$literalExpectation('"', false);
var peg$e5 = peg$classExpectation(['"'], true, false);
var peg$e4 = peg$literalExpectation("\"", false);
var peg$e5 = peg$classExpectation(["\""], true, false);
var peg$e6 = peg$literalExpectation("//", false);
var peg$e7 = peg$literalExpectation("/*", false);
var peg$e8 = peg$classExpectation(["*"], true, false);
@ -234,24 +203,12 @@ function peg$parse(input, options) {
var peg$e13 = peg$classExpectation(["\n", "\r"], false, false);
var peg$e14 = peg$classExpectation(["\r", "\n"], true, false);
var peg$f0 = function (head, tail) {
return [head, ...tail].filter((e) => e != "");
};
var peg$f1 = function () {
return [];
};
var peg$f2 = function (characters) {
return characters.join("");
};
var peg$f3 = function (characters) {
return characters.join("");
};
var peg$f4 = function () {
return "";
};
var peg$f5 = function () {
return "";
};
var peg$f0 = function(head, tail) {return [head, ...tail].filter( e => e != '');};
var peg$f1 = function() {return [];};
var peg$f2 = function(characters) {return characters.join('');};
var peg$f3 = function(characters) {return characters.join('');};
var peg$f4 = function() { return '';};
var peg$f5 = function() { return '';};
var peg$currPos = 0;
var peg$savedPos = 0;
var peg$posDetailsCache = [{ line: 1, column: 1 }];
@ -265,9 +222,7 @@ function peg$parse(input, options) {
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error(
"Can't start parsing from rule \"" + options.startRule + '".'
);
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
@ -285,7 +240,7 @@ function peg$parse(input, options) {
return {
source: peg$source,
start: peg$savedPos,
end: peg$currPos,
end: peg$currPos
};
}
@ -294,8 +249,7 @@ function peg$parse(input, options) {
}
function expected(description, location) {
location =
location !== undefined
location = location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
@ -307,8 +261,7 @@ function peg$parse(input, options) {
}
function error(message, location) {
location =
location !== undefined
location = location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
@ -320,12 +273,7 @@ function peg$parse(input, options) {
}
function peg$classExpectation(parts, inverted, ignoreCase) {
return {
type: "class",
parts: parts,
inverted: inverted,
ignoreCase: ignoreCase,
};
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
}
function peg$anyExpectation() {
@ -355,7 +303,7 @@ function peg$parse(input, options) {
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column,
column: details.column
};
while (p < pos) {
@ -384,20 +332,18 @@ function peg$parse(input, options) {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column,
},
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) {
return;
}
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
@ -585,9 +531,7 @@ function peg$parse(input, options) {
peg$currPos += 8;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e0);
}
if (peg$silentFails === 0) { peg$fail(peg$e0); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -645,9 +589,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e2);
}
if (peg$silentFails === 0) { peg$fail(peg$e2); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -656,9 +598,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e3);
}
if (peg$silentFails === 0) { peg$fail(peg$e3); }
}
while (s4 !== peg$FAILED) {
s3.push(s4);
@ -667,9 +607,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e3);
}
if (peg$silentFails === 0) { peg$fail(peg$e3); }
}
}
if (input.charCodeAt(peg$currPos) === 39) {
@ -677,9 +615,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e2);
}
if (peg$silentFails === 0) { peg$fail(peg$e2); }
}
if (s4 !== peg$FAILED) {
s1 = s3;
@ -704,9 +640,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e4);
}
if (peg$silentFails === 0) { peg$fail(peg$e4); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -715,9 +649,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e5);
}
if (peg$silentFails === 0) { peg$fail(peg$e5); }
}
while (s4 !== peg$FAILED) {
s3.push(s4);
@ -726,9 +658,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e5);
}
if (peg$silentFails === 0) { peg$fail(peg$e5); }
}
}
if (input.charCodeAt(peg$currPos) === 34) {
@ -736,9 +666,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e4);
}
if (peg$silentFails === 0) { peg$fail(peg$e4); }
}
if (s4 !== peg$FAILED) {
s1 = s3;
@ -759,9 +687,7 @@ function peg$parse(input, options) {
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e1);
}
if (peg$silentFails === 0) { peg$fail(peg$e1); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -823,9 +749,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e6);
}
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
if (s1 !== peg$FAILED) {
s2 = [];
@ -864,9 +788,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e7);
}
if (peg$silentFails === 0) { peg$fail(peg$e7); }
}
if (s1 !== peg$FAILED) {
s2 = [];
@ -875,9 +797,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e8);
}
if (peg$silentFails === 0) { peg$fail(peg$e8); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
@ -886,9 +806,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e8);
}
if (peg$silentFails === 0) { peg$fail(peg$e8); }
}
}
if (input.substr(peg$currPos, 2) === peg$c5) {
@ -896,9 +814,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e9);
}
if (peg$silentFails === 0) { peg$fail(peg$e9); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
@ -935,16 +851,12 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e11);
}
if (peg$silentFails === 0) { peg$fail(peg$e11); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e10);
}
if (peg$silentFails === 0) { peg$fail(peg$e10); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -970,16 +882,12 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e13);
}
if (peg$silentFails === 0) { peg$fail(peg$e13); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e12);
}
if (peg$silentFails === 0) { peg$fail(peg$e12); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1004,9 +912,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e14);
}
if (peg$silentFails === 0) { peg$fail(peg$e14); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1035,5 +941,5 @@ function peg$parse(input, options) {
module.exports = {
SyntaxError: peg$SyntaxError,
parse: peg$parse,
parse: peg$parse
};