summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLizzy Hunt <lizzy.hunt@usu.edu>2024-02-28 13:41:53 -0700
committerLizzy Hunt <lizzy.hunt@usu.edu>2024-02-28 13:41:53 -0700
commitd39cf84965dffd11cab440f5a4efa1b16932ba73 (patch)
treee0239d2047756120c51fd431999520ffbb38d29b
parent7cc3ef5fa1feec8087618c899441a11052f84c48 (diff)
downloadcps-interpreter-d39cf84965dffd11cab440f5a4efa1b16932ba73.tar.gz
cps-interpreter-d39cf84965dffd11cab440f5a4efa1b16932ba73.zip
branching
-rw-r--r--src/interpreter/builtins.ts120
-rw-r--r--src/interpreter/denotable.ts1
-rw-r--r--src/interpreter/interpreter.ts44
-rw-r--r--src/parser/grammar.pegjs6
-rw-r--r--src/parser/parser.ts512
-rw-r--r--test/interpreter.spec.ts7
-rw-r--r--test/programs/branching.cps10
-rw-r--r--test/programs/index.ts3
-rw-r--r--test/signature_match.spec.ts4
9 files changed, 488 insertions, 219 deletions
diff --git a/src/interpreter/builtins.ts b/src/interpreter/builtins.ts
index 200131f..bc666e9 100644
--- a/src/interpreter/builtins.ts
+++ b/src/interpreter/builtins.ts
@@ -28,6 +28,117 @@ const addUnaryIntegerOperationsTo = (env: Environment) => {
return env;
};
+const addNumberComparisonOperationsTo = (env: Environment) => {
+ const comparisonOperationsSignatures: DenotableFunctionSignature[] = [
+ {
+ arguments: [
+ ['real', 'int'],
+ ['real', 'int'],
+ ],
+ return: 'bool',
+ },
+ ];
+
+ for (const { name, fn } of [
+ { 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: comparisonOperationsSignatures,
+ body: ({ value: a }: Denotable, { value: b }: Denotable) =>
+ fn(a as number, b as number),
+ },
+ });
+ }
+
+ return env;
+};
+
+const addEqualityOperationsTo = (env: Environment) => {
+ const equalityOperationSignatures: DenotableFunctionSignature[] = [
+ {
+ arguments: ['int', 'int'],
+ return: 'bool',
+ },
+ {
+ arguments: ['real', 'real'],
+ return: 'bool',
+ },
+ {
+ arguments: ['bool', 'bool'],
+ return: 'bool',
+ },
+ {
+ arguments: ['string', 'string'],
+ return: 'bool',
+ },
+ ];
+
+ for (const { name, fn } of [
+ {
+ name: '==',
+ fn: (a: number | string, b: number | string) => (a === b ? 1 : 0),
+ },
+ {
+ name: '!=',
+ fn: (a: number | string, b: number | string) => (a !== b ? 1 : 0),
+ },
+ ]) {
+ env.set(name, {
+ type: 'function',
+ value: {
+ signatures: equalityOperationSignatures,
+ body: ({ value: a }: Denotable, { value: b }: Denotable) =>
+ fn(a as number | string, b as number | string),
+ },
+ });
+ }
+
+ return env;
+};
+
+const addBooleanAlgebraOperationsTo = (env: Environment) => {
+ const binaryBooleanOps: DenotableFunctionSignature[] = [
+ {
+ arguments: ['bool', 'bool'],
+ return: 'bool',
+ },
+ ];
+
+ for (const { name, fn } of [
+ { name: '||', fn: (a: number, b: number) => (a === 1 || b === 1 ? 1 : 0) },
+ { name: '&&', fn: (a: number, b: number) => (a === 1 && b === 1 ? 1 : 0) },
+ ]) {
+ env.set(name, {
+ type: 'function',
+ value: {
+ signatures: binaryBooleanOps,
+ body: ({ value: a }: Denotable, { value: b }: Denotable) =>
+ fn(a as number, b as number),
+ },
+ });
+ }
+
+ env.set('!', {
+ type: 'function',
+ value: {
+ signatures: [
+ {
+ arguments: ['bool'],
+ return: 'bool',
+ },
+ ],
+ body: ({ value }: Denotable) => (value === 1 ? 0 : 1),
+ },
+ });
+
+ return env;
+};
+
const addBinaryIntegerOperationsTo = (env: Environment) => {
const binaryIntegerOperationSignatures: DenotableFunctionSignature[] = [
{
@@ -42,12 +153,6 @@ const addBinaryIntegerOperationsTo = (env: Environment) => {
{ 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) },
]) {
env.set(name, {
type: 'function',
@@ -102,5 +207,8 @@ export const putBuiltinsOnEnvironemtn = (env: Environment) => {
addBinaryArithmeticOperationsTo,
addBinaryIntegerOperationsTo,
addUnaryIntegerOperationsTo,
+ addNumberComparisonOperationsTo,
+ addBooleanAlgebraOperationsTo,
+ addEqualityOperationsTo,
].reduce((acc, builtinsAdder) => builtinsAdder(acc), env);
};
diff --git a/src/interpreter/denotable.ts b/src/interpreter/denotable.ts
index 65aee86..bb520f8 100644
--- a/src/interpreter/denotable.ts
+++ b/src/interpreter/denotable.ts
@@ -21,6 +21,7 @@ export type DenotableType =
| 'null'
| 'int'
| 'real'
+ | 'bool'
| 'string'
| 'bytearray'
| 'function'
diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts
index ebd605c..94e263c 100644
--- a/src/interpreter/interpreter.ts
+++ b/src/interpreter/interpreter.ts
@@ -29,7 +29,6 @@ const evaluateValue = (
return { type: 'int', value: value.int };
}
if ('name' in value) {
- logger.debug(`Evaluating variable: ${value.name}`);
return env.get(value.name);
}
@@ -42,10 +41,6 @@ const evaluatePrimitiveOperation = (
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')),
);
@@ -56,15 +51,46 @@ const evaluatePrimitiveOperation = (
continuationEnvironment.set(name, result);
}
- // return the result of the last continuation
- return continuations.reduce((_, continuation, i) => {
- const childLogger = logger.createChild(`continuation[${i}]`);
+ if (result.type === 'bool') {
+ if (continuations.length > 2) {
+ throw new BadArgumentError(
+ `Expected <= 2 continuations for boolean result, got ${continuations.length}`,
+ );
+ }
+ if (continuations.length !== 2) {
+ logger.warn(
+ `Expected 2 continuations for boolean result, got ContinuationLength=(${continuations.length})`,
+ );
+ }
+
+ const [trueContinuation, falseContinuation] = continuations;
+ const childLogger = logger.createChild('continuation[true]');
+ const continuation = result.value ? trueContinuation : falseContinuation;
return evaluteContinuationExpression(
continuation,
continuationEnvironment,
childLogger,
);
- }, result);
+ }
+
+ if (continuations.length > 1) {
+ throw new BadArgumentError(
+ `Expected <= 1 continuations for non-boolean result, got ${continuations.length}`,
+ );
+ } else if (continuations.length === 0) {
+ logger.warn(
+ `!! Expected 1 continuation in continuation list... implicitly returning result but PLEASE NOTE this is technically undefined behavior !!`,
+ );
+ return result;
+ }
+
+ const [continuation] = continuations;
+ const childLogger = logger.createChild('continuation');
+ return evaluteContinuationExpression(
+ continuation,
+ continuationEnvironment,
+ childLogger,
+ );
};
const evaluteContinuationExpression = (
diff --git a/src/parser/grammar.pegjs b/src/parser/grammar.pegjs
index 66facc5..e237af9 100644
--- a/src/parser/grammar.pegjs
+++ b/src/parser/grammar.pegjs
@@ -223,6 +223,7 @@ Value
/ LabelStatement
/ IntStatement
/ RealStatement
+ / BoolStatement
/ StringStatement
VarStatement = VAR _ ident:Identifier { return ident; }
@@ -233,6 +234,8 @@ IntStatement = INT _ int:Integer { return int; }
RealStatement = REAL _ real:Real { return real; }
+BoolStatement = BOOL _ bool:Integer { return bool; }
+
StringStatement = STRING _ string:QuotedString { return string; }
AccessStatement
@@ -286,6 +289,7 @@ ComparisonOperation
/ ">"
/ "<"
/ "||"
+ / "&&"
Integer = digits:("-"? [0-9]+) !"." { return { int: parseInt(digits.join(''), 10) }; }
@@ -317,6 +321,8 @@ INT = "INT"
REAL = "REAL"
+BOOL = "BOOL"
+
STRING = "STRING"
APP = "APP"
diff --git a/src/parser/parser.ts b/src/parser/parser.ts
index 802488f..500a763 100644
--- a/src/parser/parser.ts
+++ b/src/parser/parser.ts
@@ -310,39 +310,41 @@ function peg$parse(input, options) {
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$c9 = "&&";
+ var peg$c10 = "-";
+ var peg$c11 = ".";
+ var peg$c12 = "'";
+ var peg$c13 = "\"";
+ var peg$c14 = "OFFSET";
+ var peg$c15 = "OFFp";
+ var peg$c16 = "SELp";
+ var peg$c17 = "VAR";
+ var peg$c18 = "INT";
+ var peg$c19 = "REAL";
+ var peg$c20 = "BOOL";
+ var peg$c21 = "STRING";
+ var peg$c22 = "APP";
+ var peg$c23 = "RECORD";
+ var peg$c24 = "SELECT";
+ var peg$c25 = "FIX";
+ var peg$c26 = "SWITCH";
+ var peg$c27 = "PRIMOP";
+ var peg$c28 = "LABEL";
+ var peg$c29 = "store";
+ var peg$c30 = "update";
+ var peg$c31 = "makeref";
+ var peg$c32 = "makerefunboxed";
+ var peg$c33 = "unboxedupdate";
+ var peg$c34 = "subscript";
+ var peg$c35 = "boxed";
+ var peg$c36 = "_";
+ var peg$c37 = "[";
+ var peg$c38 = "]";
+ var peg$c39 = ",";
+ var peg$c40 = "=";
+ var peg$c41 = "(";
+ var peg$c42 = ")";
+ var peg$c43 = "\r\n";
var peg$r0 = /^[A-Za-z]/;
var peg$r1 = /^[0-9A-Z_a-z]/;
@@ -368,43 +370,45 @@ function peg$parse(input, options) {
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);
+ var peg$e14 = peg$literalExpectation("&&", false);
+ var peg$e15 = peg$literalExpectation("-", false);
+ var peg$e16 = peg$classExpectation([["0", "9"]], false, false);
+ var peg$e17 = peg$literalExpectation(".", false);
+ var peg$e18 = peg$literalExpectation("'", false);
+ var peg$e19 = peg$classExpectation(["'"], true, false);
+ var peg$e20 = peg$literalExpectation("\"", false);
+ var peg$e21 = peg$classExpectation(["\""], true, false);
+ var peg$e22 = peg$literalExpectation("OFFSET", false);
+ var peg$e23 = peg$literalExpectation("OFFp", false);
+ var peg$e24 = peg$literalExpectation("SELp", false);
+ var peg$e25 = peg$literalExpectation("VAR", false);
+ var peg$e26 = peg$literalExpectation("INT", false);
+ var peg$e27 = peg$literalExpectation("REAL", false);
+ var peg$e28 = peg$literalExpectation("BOOL", false);
+ var peg$e29 = peg$literalExpectation("STRING", false);
+ var peg$e30 = peg$literalExpectation("APP", false);
+ var peg$e31 = peg$literalExpectation("RECORD", false);
+ var peg$e32 = peg$literalExpectation("SELECT", false);
+ var peg$e33 = peg$literalExpectation("FIX", false);
+ var peg$e34 = peg$literalExpectation("SWITCH", false);
+ var peg$e35 = peg$literalExpectation("PRIMOP", false);
+ var peg$e36 = peg$literalExpectation("LABEL", false);
+ var peg$e37 = peg$literalExpectation("store", false);
+ var peg$e38 = peg$literalExpectation("update", false);
+ var peg$e39 = peg$literalExpectation("makeref", false);
+ var peg$e40 = peg$literalExpectation("makerefunboxed", false);
+ var peg$e41 = peg$literalExpectation("unboxedupdate", false);
+ var peg$e42 = peg$literalExpectation("subscript", false);
+ var peg$e43 = peg$literalExpectation("boxed", 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$literalExpectation("(", false);
+ var peg$e50 = peg$literalExpectation(")", false);
+ var peg$e51 = peg$classExpectation([["\t", "\n"], " "], false, false);
+ var peg$e52 = peg$literalExpectation("\r\n", false);
// @ts-ignore
var peg$f0 = function(exprs) {
@@ -507,30 +511,33 @@ function peg$parse(input, options) {
var peg$f17 = function(real) {// @ts-ignore
return real; };// @ts-ignore
- var peg$f18 = function(string) {// @ts-ignore
+ var peg$f18 = function(bool) {// @ts-ignore
+ return bool; };// @ts-ignore
+
+ var peg$f19 = function(string) {// @ts-ignore
return string; };// @ts-ignore
- var peg$f19 = function(offset) {// @ts-ignore
+ var peg$f20 = function(offset) {// @ts-ignore
return offset; };// @ts-ignore
- var peg$f20 = function(offset) {// @ts-ignore
+ var peg$f21 = function(offset) {// @ts-ignore
return offset; };// @ts-ignore
- var peg$f21 = function(name) {
+ var peg$f22 = function(name) {
// @ts-ignore
return { name: name[0] + name[1].join('') };
};// @ts-ignore
- var peg$f22 = function(digits) {// @ts-ignore
+ var peg$f23 = function(digits) {// @ts-ignore
return { int: parseInt(digits.join(''), 10) }; };// @ts-ignore
- var peg$f23 = function(content) {// @ts-ignore
+ var peg$f24 = function(content) {// @ts-ignore
return content.join(''); };// @ts-ignore
- var peg$f24 = function(content) {// @ts-ignore
+ var peg$f25 = function(content) {// @ts-ignore
return content.join(''); };// @ts-ignore
- var peg$f25 = function(value) {
+ var peg$f26 = function(value) {
// @ts-ignore
return { real: parseFloat(
// @ts-ignore
@@ -2991,7 +2998,12 @@ peg$parseValue() {
// @ts-ignore
if (s0 === peg$FAILED) {
// @ts-ignore
- s0 = peg$parseStringStatement();
+ s0 = peg$parseBoolStatement();
+// @ts-ignore
+ if (s0 === peg$FAILED) {
+// @ts-ignore
+ s0 = peg$parseStringStatement();
+ }
}
}
}
@@ -3203,6 +3215,56 @@ peg$parseRealStatement() {
// @ts-ignore
function // @ts-ignore
+peg$parseBoolStatement() {
+// @ts-ignore
+ var s0, s1, s2, s3;
+
+// @ts-ignore
+ s0 = peg$currPos;
+// @ts-ignore
+ s1 = peg$parseBOOL();
+// @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$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$parseStringStatement() {
// @ts-ignore
var s0, s1, s2, s3;
@@ -3224,7 +3286,7 @@ peg$parseStringStatement() {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s0 = peg$f18(s3);
+ s0 = peg$f19(s3);
// @ts-ignore
} else {
// @ts-ignore
@@ -3292,7 +3354,7 @@ peg$parseOffsetStatement() {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s0 = peg$f19(s3);
+ s0 = peg$f20(s3);
// @ts-ignore
} else {
// @ts-ignore
@@ -3342,7 +3404,7 @@ peg$parseSelectStatement() {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s0 = peg$f20(s3);
+ s0 = peg$f21(s3);
// @ts-ignore
} else {
// @ts-ignore
@@ -3443,7 +3505,7 @@ peg$parseIdentifier() {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s1 = peg$f21(s1);
+ s1 = peg$f22(s1);
}
// @ts-ignore
s0 = s1;
@@ -3729,6 +3791,22 @@ peg$parseComparisonOperation() {
// @ts-ignore
if (peg$silentFails === 0) { peg$fail(peg$e13); }
}
+// @ts-ignore
+ if (s0 === peg$FAILED) {
+// @ts-ignore
+ if (input.substr(peg$currPos, 2) === peg$c9) {
+// @ts-ignore
+ s0 = peg$c9;
+// @ts-ignore
+ peg$currPos += 2;
+// @ts-ignore
+ } else {
+// @ts-ignore
+ s0 = peg$FAILED;
+// @ts-ignore
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
+ }
+ }
}
}
}
@@ -3752,7 +3830,7 @@ peg$parseInteger() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 45) {
// @ts-ignore
- s2 = peg$c9;
+ s2 = peg$c10;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -3760,7 +3838,7 @@ peg$parseInteger() {
// @ts-ignore
s2 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
}
// @ts-ignore
if (s2 === peg$FAILED) {
@@ -3780,7 +3858,7 @@ peg$parseInteger() {
// @ts-ignore
s4 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
// @ts-ignore
if (s4 !== peg$FAILED) {
@@ -3799,7 +3877,7 @@ peg$parseInteger() {
// @ts-ignore
s4 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
}
// @ts-ignore
@@ -3829,7 +3907,7 @@ peg$parseInteger() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 46) {
// @ts-ignore
- s3 = peg$c10;
+ s3 = peg$c11;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -3837,7 +3915,7 @@ peg$parseInteger() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
}
// @ts-ignore
peg$silentFails--;
@@ -3857,7 +3935,7 @@ peg$parseInteger() {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s0 = peg$f22(s1);
+ s0 = peg$f23(s1);
// @ts-ignore
} else {
// @ts-ignore
@@ -3888,7 +3966,7 @@ peg$parseQuotedString() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 39) {
// @ts-ignore
- s1 = peg$c11;
+ s1 = peg$c12;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -3896,7 +3974,7 @@ peg$parseQuotedString() {
// @ts-ignore
s1 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e17); }
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
}
// @ts-ignore
if (s1 !== peg$FAILED) {
@@ -3913,7 +3991,7 @@ peg$parseQuotedString() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e18); }
+ if (peg$silentFails === 0) { peg$fail(peg$e19); }
}
// @ts-ignore
while (s3 !== peg$FAILED) {
@@ -3930,13 +4008,13 @@ peg$parseQuotedString() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e18); }
+ if (peg$silentFails === 0) { peg$fail(peg$e19); }
}
}
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 39) {
// @ts-ignore
- s3 = peg$c11;
+ s3 = peg$c12;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -3944,14 +4022,14 @@ peg$parseQuotedString() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e17); }
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
}
// @ts-ignore
if (s3 !== peg$FAILED) {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s0 = peg$f23(s2);
+ s0 = peg$f24(s2);
// @ts-ignore
} else {
// @ts-ignore
@@ -3973,7 +4051,7 @@ peg$parseQuotedString() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 34) {
// @ts-ignore
- s1 = peg$c12;
+ s1 = peg$c13;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -3981,7 +4059,7 @@ peg$parseQuotedString() {
// @ts-ignore
s1 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e19); }
+ if (peg$silentFails === 0) { peg$fail(peg$e20); }
}
// @ts-ignore
if (s1 !== peg$FAILED) {
@@ -3998,7 +4076,7 @@ peg$parseQuotedString() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e20); }
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
}
// @ts-ignore
while (s3 !== peg$FAILED) {
@@ -4015,13 +4093,13 @@ peg$parseQuotedString() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e20); }
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
}
}
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 34) {
// @ts-ignore
- s3 = peg$c12;
+ s3 = peg$c13;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4029,14 +4107,14 @@ peg$parseQuotedString() {
// @ts-ignore
s3 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e19); }
+ if (peg$silentFails === 0) { peg$fail(peg$e20); }
}
// @ts-ignore
if (s3 !== peg$FAILED) {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s0 = peg$f24(s2);
+ s0 = peg$f25(s2);
// @ts-ignore
} else {
// @ts-ignore
@@ -4070,7 +4148,7 @@ peg$parseReal() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 45) {
// @ts-ignore
- s2 = peg$c9;
+ s2 = peg$c10;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4078,7 +4156,7 @@ peg$parseReal() {
// @ts-ignore
s2 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
}
// @ts-ignore
if (s2 === peg$FAILED) {
@@ -4098,7 +4176,7 @@ peg$parseReal() {
// @ts-ignore
s4 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
// @ts-ignore
if (s4 !== peg$FAILED) {
@@ -4117,7 +4195,7 @@ peg$parseReal() {
// @ts-ignore
s4 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
}
// @ts-ignore
@@ -4132,7 +4210,7 @@ peg$parseReal() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 46) {
// @ts-ignore
- s5 = peg$c10;
+ s5 = peg$c11;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4140,7 +4218,7 @@ peg$parseReal() {
// @ts-ignore
s5 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
}
// @ts-ignore
if (s5 !== peg$FAILED) {
@@ -4157,7 +4235,7 @@ peg$parseReal() {
// @ts-ignore
s7 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
// @ts-ignore
if (s7 !== peg$FAILED) {
@@ -4176,7 +4254,7 @@ peg$parseReal() {
// @ts-ignore
s7 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
}
// @ts-ignore
@@ -4225,7 +4303,7 @@ peg$parseReal() {
// @ts-ignore
peg$savedPos = s0;
// @ts-ignore
- s1 = peg$f25(s1);
+ s1 = peg$f26(s1);
}
// @ts-ignore
s0 = s1;
@@ -4264,9 +4342,9 @@ peg$parseOFFSET() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c13) {
+ if (input.substr(peg$currPos, 6) === peg$c14) {
// @ts-ignore
- s0 = peg$c13;
+ s0 = peg$c14;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4274,7 +4352,7 @@ peg$parseOFFSET() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e21); }
+ if (peg$silentFails === 0) { peg$fail(peg$e22); }
}
// @ts-ignore
@@ -4288,9 +4366,9 @@ peg$parseOFFP() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 4) === peg$c14) {
+ if (input.substr(peg$currPos, 4) === peg$c15) {
// @ts-ignore
- s0 = peg$c14;
+ s0 = peg$c15;
// @ts-ignore
peg$currPos += 4;
// @ts-ignore
@@ -4298,7 +4376,7 @@ peg$parseOFFP() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
+ if (peg$silentFails === 0) { peg$fail(peg$e23); }
}
// @ts-ignore
@@ -4312,9 +4390,9 @@ peg$parseSELP() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 4) === peg$c15) {
+ if (input.substr(peg$currPos, 4) === peg$c16) {
// @ts-ignore
- s0 = peg$c15;
+ s0 = peg$c16;
// @ts-ignore
peg$currPos += 4;
// @ts-ignore
@@ -4322,7 +4400,7 @@ peg$parseSELP() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e23); }
+ if (peg$silentFails === 0) { peg$fail(peg$e24); }
}
// @ts-ignore
@@ -4336,9 +4414,9 @@ peg$parseVAR() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 3) === peg$c16) {
+ if (input.substr(peg$currPos, 3) === peg$c17) {
// @ts-ignore
- s0 = peg$c16;
+ s0 = peg$c17;
// @ts-ignore
peg$currPos += 3;
// @ts-ignore
@@ -4346,7 +4424,7 @@ peg$parseVAR() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e24); }
+ if (peg$silentFails === 0) { peg$fail(peg$e25); }
}
// @ts-ignore
@@ -4360,9 +4438,9 @@ peg$parseINT() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 3) === peg$c17) {
+ if (input.substr(peg$currPos, 3) === peg$c18) {
// @ts-ignore
- s0 = peg$c17;
+ s0 = peg$c18;
// @ts-ignore
peg$currPos += 3;
// @ts-ignore
@@ -4370,7 +4448,7 @@ peg$parseINT() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
+ if (peg$silentFails === 0) { peg$fail(peg$e26); }
}
// @ts-ignore
@@ -4384,9 +4462,9 @@ peg$parseREAL() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 4) === peg$c18) {
+ if (input.substr(peg$currPos, 4) === peg$c19) {
// @ts-ignore
- s0 = peg$c18;
+ s0 = peg$c19;
// @ts-ignore
peg$currPos += 4;
// @ts-ignore
@@ -4394,7 +4472,31 @@ peg$parseREAL() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e26); }
+ if (peg$silentFails === 0) { peg$fail(peg$e27); }
+ }
+
+// @ts-ignore
+ return s0;
+ }
+
+// @ts-ignore
+ function // @ts-ignore
+peg$parseBOOL() {
+// @ts-ignore
+ var s0;
+
+// @ts-ignore
+ if (input.substr(peg$currPos, 4) === peg$c20) {
+// @ts-ignore
+ s0 = peg$c20;
+// @ts-ignore
+ peg$currPos += 4;
+// @ts-ignore
+ } else {
+// @ts-ignore
+ s0 = peg$FAILED;
+// @ts-ignore
+ if (peg$silentFails === 0) { peg$fail(peg$e28); }
}
// @ts-ignore
@@ -4408,9 +4510,9 @@ peg$parseSTRING() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c19) {
+ if (input.substr(peg$currPos, 6) === peg$c21) {
// @ts-ignore
- s0 = peg$c19;
+ s0 = peg$c21;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4418,7 +4520,7 @@ peg$parseSTRING() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e27); }
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
}
// @ts-ignore
@@ -4432,9 +4534,9 @@ peg$parseAPP() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 3) === peg$c20) {
+ if (input.substr(peg$currPos, 3) === peg$c22) {
// @ts-ignore
- s0 = peg$c20;
+ s0 = peg$c22;
// @ts-ignore
peg$currPos += 3;
// @ts-ignore
@@ -4442,7 +4544,7 @@ peg$parseAPP() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e28); }
+ if (peg$silentFails === 0) { peg$fail(peg$e30); }
}
// @ts-ignore
@@ -4456,9 +4558,9 @@ peg$parseRECORD() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c21) {
+ if (input.substr(peg$currPos, 6) === peg$c23) {
// @ts-ignore
- s0 = peg$c21;
+ s0 = peg$c23;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4466,7 +4568,7 @@ peg$parseRECORD() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e29); }
+ if (peg$silentFails === 0) { peg$fail(peg$e31); }
}
// @ts-ignore
@@ -4480,9 +4582,9 @@ peg$parseSELECT() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c22) {
+ if (input.substr(peg$currPos, 6) === peg$c24) {
// @ts-ignore
- s0 = peg$c22;
+ s0 = peg$c24;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4490,7 +4592,7 @@ peg$parseSELECT() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e30); }
+ if (peg$silentFails === 0) { peg$fail(peg$e32); }
}
// @ts-ignore
@@ -4504,9 +4606,9 @@ peg$parseFIX() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 3) === peg$c23) {
+ if (input.substr(peg$currPos, 3) === peg$c25) {
// @ts-ignore
- s0 = peg$c23;
+ s0 = peg$c25;
// @ts-ignore
peg$currPos += 3;
// @ts-ignore
@@ -4514,7 +4616,7 @@ peg$parseFIX() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e31); }
+ if (peg$silentFails === 0) { peg$fail(peg$e33); }
}
// @ts-ignore
@@ -4528,9 +4630,9 @@ peg$parseSWITCH() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c24) {
+ if (input.substr(peg$currPos, 6) === peg$c26) {
// @ts-ignore
- s0 = peg$c24;
+ s0 = peg$c26;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4538,7 +4640,7 @@ peg$parseSWITCH() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e32); }
+ if (peg$silentFails === 0) { peg$fail(peg$e34); }
}
// @ts-ignore
@@ -4552,9 +4654,9 @@ peg$parsePRIMOP() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c25) {
+ if (input.substr(peg$currPos, 6) === peg$c27) {
// @ts-ignore
- s0 = peg$c25;
+ s0 = peg$c27;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4562,7 +4664,7 @@ peg$parsePRIMOP() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e33); }
+ if (peg$silentFails === 0) { peg$fail(peg$e35); }
}
// @ts-ignore
@@ -4576,9 +4678,9 @@ peg$parseLABEL() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 5) === peg$c26) {
+ if (input.substr(peg$currPos, 5) === peg$c28) {
// @ts-ignore
- s0 = peg$c26;
+ s0 = peg$c28;
// @ts-ignore
peg$currPos += 5;
// @ts-ignore
@@ -4586,7 +4688,7 @@ peg$parseLABEL() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e34); }
+ if (peg$silentFails === 0) { peg$fail(peg$e36); }
}
// @ts-ignore
@@ -4600,9 +4702,9 @@ peg$parseSTORE() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 5) === peg$c27) {
+ if (input.substr(peg$currPos, 5) === peg$c29) {
// @ts-ignore
- s0 = peg$c27;
+ s0 = peg$c29;
// @ts-ignore
peg$currPos += 5;
// @ts-ignore
@@ -4610,7 +4712,7 @@ peg$parseSTORE() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e35); }
+ if (peg$silentFails === 0) { peg$fail(peg$e37); }
}
// @ts-ignore
@@ -4624,9 +4726,9 @@ peg$parseUPDATE() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 6) === peg$c28) {
+ if (input.substr(peg$currPos, 6) === peg$c30) {
// @ts-ignore
- s0 = peg$c28;
+ s0 = peg$c30;
// @ts-ignore
peg$currPos += 6;
// @ts-ignore
@@ -4634,7 +4736,7 @@ peg$parseUPDATE() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e36); }
+ if (peg$silentFails === 0) { peg$fail(peg$e38); }
}
// @ts-ignore
@@ -4648,9 +4750,9 @@ peg$parseMAKEREF() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 7) === peg$c29) {
+ if (input.substr(peg$currPos, 7) === peg$c31) {
// @ts-ignore
- s0 = peg$c29;
+ s0 = peg$c31;
// @ts-ignore
peg$currPos += 7;
// @ts-ignore
@@ -4658,7 +4760,7 @@ peg$parseMAKEREF() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e37); }
+ if (peg$silentFails === 0) { peg$fail(peg$e39); }
}
// @ts-ignore
@@ -4672,9 +4774,9 @@ peg$parseMAKEREFUNBOXED() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 14) === peg$c30) {
+ if (input.substr(peg$currPos, 14) === peg$c32) {
// @ts-ignore
- s0 = peg$c30;
+ s0 = peg$c32;
// @ts-ignore
peg$currPos += 14;
// @ts-ignore
@@ -4682,7 +4784,7 @@ peg$parseMAKEREFUNBOXED() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e38); }
+ if (peg$silentFails === 0) { peg$fail(peg$e40); }
}
// @ts-ignore
@@ -4696,9 +4798,9 @@ peg$parseUNBOXED_UPDATE() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 13) === peg$c31) {
+ if (input.substr(peg$currPos, 13) === peg$c33) {
// @ts-ignore
- s0 = peg$c31;
+ s0 = peg$c33;
// @ts-ignore
peg$currPos += 13;
// @ts-ignore
@@ -4706,7 +4808,7 @@ peg$parseUNBOXED_UPDATE() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e39); }
+ if (peg$silentFails === 0) { peg$fail(peg$e41); }
}
// @ts-ignore
@@ -4720,9 +4822,9 @@ peg$parseSUBSCRIPT() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 9) === peg$c32) {
+ if (input.substr(peg$currPos, 9) === peg$c34) {
// @ts-ignore
- s0 = peg$c32;
+ s0 = peg$c34;
// @ts-ignore
peg$currPos += 9;
// @ts-ignore
@@ -4730,7 +4832,7 @@ peg$parseSUBSCRIPT() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e40); }
+ if (peg$silentFails === 0) { peg$fail(peg$e42); }
}
// @ts-ignore
@@ -4744,9 +4846,9 @@ peg$parseBOXED() {
var s0;
// @ts-ignore
- if (input.substr(peg$currPos, 5) === peg$c33) {
+ if (input.substr(peg$currPos, 5) === peg$c35) {
// @ts-ignore
- s0 = peg$c33;
+ s0 = peg$c35;
// @ts-ignore
peg$currPos += 5;
// @ts-ignore
@@ -4754,7 +4856,7 @@ peg$parseBOXED() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e41); }
+ if (peg$silentFails === 0) { peg$fail(peg$e43); }
}
// @ts-ignore
@@ -4794,7 +4896,7 @@ peg$parseSAFE_SYMBOL() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 95) {
// @ts-ignore
- s0 = peg$c34;
+ s0 = peg$c36;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4802,7 +4904,7 @@ peg$parseSAFE_SYMBOL() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e42); }
+ if (peg$silentFails === 0) { peg$fail(peg$e44); }
}
// @ts-ignore
@@ -4826,7 +4928,7 @@ peg$parseDIGIT() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
// @ts-ignore
@@ -4842,7 +4944,7 @@ peg$parseLBRACKET() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 91) {
// @ts-ignore
- s0 = peg$c35;
+ s0 = peg$c37;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4850,7 +4952,7 @@ peg$parseLBRACKET() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
+ if (peg$silentFails === 0) { peg$fail(peg$e45); }
}
// @ts-ignore
@@ -4866,7 +4968,7 @@ peg$parseRBRACKET() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 93) {
// @ts-ignore
- s0 = peg$c36;
+ s0 = peg$c38;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4874,7 +4976,7 @@ peg$parseRBRACKET() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
+ if (peg$silentFails === 0) { peg$fail(peg$e46); }
}
// @ts-ignore
@@ -4890,7 +4992,7 @@ peg$parseCOMMA() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 44) {
// @ts-ignore
- s0 = peg$c37;
+ s0 = peg$c39;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4898,7 +5000,7 @@ peg$parseCOMMA() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
+ if (peg$silentFails === 0) { peg$fail(peg$e47); }
}
// @ts-ignore
@@ -4914,7 +5016,7 @@ peg$parseEQUALS() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 61) {
// @ts-ignore
- s0 = peg$c38;
+ s0 = peg$c40;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4922,7 +5024,7 @@ peg$parseEQUALS() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e46); }
+ if (peg$silentFails === 0) { peg$fail(peg$e48); }
}
// @ts-ignore
@@ -4938,7 +5040,7 @@ peg$parseLPAREN() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 40) {
// @ts-ignore
- s0 = peg$c39;
+ s0 = peg$c41;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4946,7 +5048,7 @@ peg$parseLPAREN() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e47); }
+ if (peg$silentFails === 0) { peg$fail(peg$e49); }
}
// @ts-ignore
@@ -4962,7 +5064,7 @@ peg$parseRPAREN() {
// @ts-ignore
if (input.charCodeAt(peg$currPos) === 41) {
// @ts-ignore
- s0 = peg$c40;
+ s0 = peg$c42;
// @ts-ignore
peg$currPos++;
// @ts-ignore
@@ -4970,7 +5072,7 @@ peg$parseRPAREN() {
// @ts-ignore
s0 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e48); }
+ if (peg$silentFails === 0) { peg$fail(peg$e50); }
}
// @ts-ignore
@@ -4996,14 +5098,14 @@ peg$parse_() {
// @ts-ignore
s1 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e49); }
+ if (peg$silentFails === 0) { peg$fail(peg$e51); }
}
// @ts-ignore
if (s1 === peg$FAILED) {
// @ts-ignore
- if (input.substr(peg$currPos, 2) === peg$c41) {
+ if (input.substr(peg$currPos, 2) === peg$c43) {
// @ts-ignore
- s1 = peg$c41;
+ s1 = peg$c43;
// @ts-ignore
peg$currPos += 2;
// @ts-ignore
@@ -5011,7 +5113,7 @@ peg$parse_() {
// @ts-ignore
s1 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e50); }
+ if (peg$silentFails === 0) { peg$fail(peg$e52); }
}
}
// @ts-ignore
@@ -5031,14 +5133,14 @@ peg$parse_() {
// @ts-ignore
s1 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e49); }
+ if (peg$silentFails === 0) { peg$fail(peg$e51); }
}
// @ts-ignore
if (s1 === peg$FAILED) {
// @ts-ignore
- if (input.substr(peg$currPos, 2) === peg$c41) {
+ if (input.substr(peg$currPos, 2) === peg$c43) {
// @ts-ignore
- s1 = peg$c41;
+ s1 = peg$c43;
// @ts-ignore
peg$currPos += 2;
// @ts-ignore
@@ -5046,7 +5148,7 @@ peg$parse_() {
// @ts-ignore
s1 = peg$FAILED;
// @ts-ignore
- if (peg$silentFails === 0) { peg$fail(peg$e50); }
+ if (peg$silentFails === 0) { peg$fail(peg$e52); }
}
}
}
@@ -5282,11 +5384,13 @@ export type Value =
| LabelStatement
| IntStatement
| RealStatement
+ | BoolStatement
| StringStatement;
export type VarStatement = Identifier;
export type LabelStatement = Identifier;
export type IntStatement = Integer;
export type RealStatement = Real;
+export type BoolStatement = Integer;
export type StringStatement = QuotedString;
export type AccessStatement = OffsetStatement | SelectStatement;
export type OffsetStatement = Integer;
@@ -5307,7 +5411,14 @@ export type StoreOperation =
| SUBSCRIPT;
export type ArithmeticOperation = string | "**" | "%";
export type BitOperation = ">>" | "<<" | string;
-export type ComparisonOperation = "==" | "<=" | ">=" | "!=" | string | "||";
+export type ComparisonOperation =
+ | "=="
+ | "<="
+ | ">="
+ | "!="
+ | string
+ | "||"
+ | "&&";
export type Integer = { int: number };
export type QuotedString = string;
export type Real = { real: number };
@@ -5318,6 +5429,7 @@ export type SELP = "SELp";
export type VAR = "VAR";
export type INT = "INT";
export type REAL = "REAL";
+export type BOOL = "BOOL";
export type STRING = "STRING";
export type APP = "APP";
export type RECORD = "RECORD";
diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts
index fa74ef0..49b741e 100644
--- a/test/interpreter.spec.ts
+++ b/test/interpreter.spec.ts
@@ -18,6 +18,13 @@ test('Add (1 real) and (3 int) -> result => (real 1 - result) = -3 done with cor
expect(result).toEqual({ type: 'real', value: -3 });
});
+test('Branching', async () => {
+ const ast = peggyParse(await TestPrograms.Branching);
+
+ const result = await evaluate(ast, testingLogger);
+ expect(result).toEqual({ type: 'real', value: 2 });
+});
+
/*
test('String equality', async () => {
const ast = peggyParse(await TestPrograms.StringEquality);
diff --git a/test/programs/branching.cps b/test/programs/branching.cps
new file mode 100644
index 0000000..f73704c
--- /dev/null
+++ b/test/programs/branching.cps
@@ -0,0 +1,10 @@
+PRIMOP(>=, [REAL 0, REAL 1], [resultFalse], [
+ PRIMOP(+, [REAL 2, REAL 4], [result], []),
+ PRIMOP(<=, [INT 1, REAL 1], [resultTrue], [
+ PRIMOP(&&, [VAR resultTrue, VAR resultFalse], [fin], [
+ PRIMOP(-, [REAL 1, REAL 1], [result], []),
+ PRIMOP(+, [REAL 1, REAL 1], [twoWhenFinIsFalse], [])
+ ]),
+ PRIMOP(-, [REAL 1, REAL 1], [result], [])
+ ])
+]) \ No newline at end of file
diff --git a/test/programs/index.ts b/test/programs/index.ts
index c8f3c85..864169f 100644
--- a/test/programs/index.ts
+++ b/test/programs/index.ts
@@ -7,6 +7,9 @@ export namespace TestPrograms {
export const PrimopScope = Bun.file(
join(import.meta.dir + '/primop-scope.cps'),
).text();
+ export const Branching = Bun.file(
+ join(import.meta.dir + '/branching.cps'),
+ ).text();
export const StringEquality = Bun.file(
join(import.meta.dir + '/string-equal.cps'),
).text();
diff --git a/test/signature_match.spec.ts b/test/signature_match.spec.ts
index 10be880..02b8c89 100644
--- a/test/signature_match.spec.ts
+++ b/test/signature_match.spec.ts
@@ -1,13 +1,9 @@
import { expect, test } from 'bun:test';
-import { TestPrograms } from './programs';
-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);