summaryrefslogtreecommitdiff
path: root/src/parser/parser.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/parser.ts')
-rw-r--r--src/parser/parser.ts242
1 files changed, 136 insertions, 106 deletions
diff --git a/src/parser/parser.ts b/src/parser/parser.ts
index 6e09c0d..c3708cf 100644
--- a/src/parser/parser.ts
+++ b/src/parser/parser.ts
@@ -408,17 +408,17 @@ function peg$parse(input, options) {
return exprs.filter(x => !Array.isArray(x));
};// @ts-ignore
- var peg$f1 = function(select, val, bind, continuation) {// @ts-ignore
- return { select, val, bind, continuation }; };// @ts-ignore
+ var peg$f1 = function(record, val, bind, continuation) {// @ts-ignore
+ return { select: { record, val, bind, continuation } }; };// @ts-ignore
- var peg$f2 = function(offset, val, bind, continuation) {// @ts-ignore
- return { offset, 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.ident), lastIdent]
+ ? [...identifiers.map(x => x[0]), lastIdent]
: [];
};// @ts-ignore
@@ -426,39 +426,44 @@ function peg$parse(input, options) {
// @ts-ignore
return values.length || lastValue
// @ts-ignore
- ? [...values.map(x => x.value), lastValue]
+ ? [...values.map(x => x[0]), lastValue]
: [];
};// @ts-ignore
var peg$f5 = function(switchIndex, continuations) {// @ts-ignore
- return { switchIndex, continuations }; };// @ts-ignore
+ return { switch: { switchIndex, continuations } }; };// @ts-ignore
var peg$f6 = function(fn, args) {
// @ts-ignore
- return { fn, args };
+ return { application: { fn, args } };
};// @ts-ignore
var peg$f7 = function(bindings, lastBinding) {
// @ts-ignore
return bindings.length || lastBinding
// @ts-ignore
- ? [...bindings.map(x => x.binding), lastBinding]
+ ? [...bindings.map(x => x[0]), lastBinding]
: [];
};// @ts-ignore
var peg$f8 = function(fixBindings, continuation) {// @ts-ignore
- return { 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.continuation), lastContinuation]
+ ? [...continuations.map(x => x[0]), lastContinuation]
: [];
};// @ts-ignore
- var peg$f10 = function(opr, operands, resultBindings, continuations) {// @ts-ignore
- return { opr, operands, resultBindings, continuations }; };// @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
@@ -467,7 +472,7 @@ function peg$parse(input, options) {
// @ts-ignore
return records.length || lastRecord
// @ts-ignore
- ? [...records.map(x => x.record), lastRecord]
+ ? [...records.map(x => x[0]), lastRecord]
: [];
};// @ts-ignore
@@ -475,11 +480,14 @@ function peg$parse(input, options) {
// @ts-ignore
return {
// @ts-ignore
- records,
+ record: {
// @ts-ignore
- address,
+ records,
// @ts-ignore
- body,
+ address,
+// @ts-ignore
+ body,
+ },
};
};// @ts-ignore
@@ -874,7 +882,7 @@ peg$parseContinuationExpression() {
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;
+ 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;
@@ -956,7 +964,7 @@ peg$parseSelectExpression() {
s14 = null;
}
// @ts-ignore
- s15 = peg$parseContinuationExpression();
+ s15 = peg$parseCOMMA();
// @ts-ignore
if (s15 !== peg$FAILED) {
// @ts-ignore
@@ -967,13 +975,31 @@ peg$parseSelectExpression() {
s16 = null;
}
// @ts-ignore
- s17 = peg$parseRPAREN();
+ s17 = peg$parseContinuationExpression();
// @ts-ignore
if (s17 !== peg$FAILED) {
// @ts-ignore
- peg$savedPos = s0;
+ 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
- s0 = peg$f1(s5, s9, s13, s15);
+ 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
@@ -1917,44 +1943,40 @@ peg$parseFixBindingList() {
// @ts-ignore
s2 = peg$parse_();
// @ts-ignore
- if (s2 !== peg$FAILED) {
-// @ts-ignore
- s3 = [];
-// @ts-ignore
- s4 = peg$currPos;
+ if (s2 === peg$FAILED) {
// @ts-ignore
- s5 = peg$parseFixBinding();
+ s2 = null;
+ }
// @ts-ignore
- if (s5 !== peg$FAILED) {
+ s3 = [];
// @ts-ignore
- s6 = peg$parse_();
+ s4 = peg$currPos;
// @ts-ignore
- if (s6 === peg$FAILED) {
+ s5 = peg$parseFixBinding();
// @ts-ignore
- s6 = null;
- }
+ if (s5 !== peg$FAILED) {
// @ts-ignore
- s7 = peg$parseCOMMA();
+ s6 = peg$parse_();
// @ts-ignore
- if (s7 !== peg$FAILED) {
+ if (s6 === peg$FAILED) {
// @ts-ignore
- s8 = peg$parse_();
+ s6 = null;
+ }
// @ts-ignore
- if (s8 === peg$FAILED) {
+ s7 = peg$parseCOMMA();
// @ts-ignore
- s8 = null;
- }
+ if (s7 !== peg$FAILED) {
// @ts-ignore
- s5 = [s5, s6, s7, s8];
+ s8 = peg$parse_();
// @ts-ignore
- s4 = s5;
+ if (s8 === peg$FAILED) {
// @ts-ignore
- } else {
+ s8 = null;
+ }
// @ts-ignore
- peg$currPos = s4;
+ s5 = [s5, s6, s7, s8];
// @ts-ignore
- s4 = peg$FAILED;
- }
+ s4 = s5;
// @ts-ignore
} else {
// @ts-ignore
@@ -1963,44 +1985,44 @@ peg$parseFixBindingList() {
s4 = peg$FAILED;
}
// @ts-ignore
- while (s4 !== peg$FAILED) {
+ } else {
// @ts-ignore
- s3.push(s4);
+ peg$currPos = s4;
// @ts-ignore
- s4 = peg$currPos;
+ s4 = peg$FAILED;
+ }
// @ts-ignore
- s5 = peg$parseFixBinding();
+ while (s4 !== peg$FAILED) {
// @ts-ignore
- if (s5 !== peg$FAILED) {
+ s3.push(s4);
// @ts-ignore
- s6 = peg$parse_();
+ s4 = peg$currPos;
// @ts-ignore
- if (s6 === peg$FAILED) {
+ s5 = peg$parseFixBinding();
// @ts-ignore
- s6 = null;
- }
+ if (s5 !== peg$FAILED) {
// @ts-ignore
- s7 = peg$parseCOMMA();
+ s6 = peg$parse_();
// @ts-ignore
- if (s7 !== peg$FAILED) {
+ if (s6 === peg$FAILED) {
// @ts-ignore
- s8 = peg$parse_();
+ s6 = null;
+ }
// @ts-ignore
- if (s8 === peg$FAILED) {
+ s7 = peg$parseCOMMA();
// @ts-ignore
- s8 = null;
- }
+ if (s7 !== peg$FAILED) {
// @ts-ignore
- s5 = [s5, s6, s7, s8];
+ s8 = peg$parse_();
// @ts-ignore
- s4 = s5;
+ if (s8 === peg$FAILED) {
// @ts-ignore
- } else {
+ s8 = null;
+ }
// @ts-ignore
- peg$currPos = s4;
+ s5 = [s5, s6, s7, s8];
// @ts-ignore
- s4 = peg$FAILED;
- }
+ s4 = s5;
// @ts-ignore
} else {
// @ts-ignore
@@ -2008,43 +2030,43 @@ peg$parseFixBindingList() {
// @ts-ignore
s4 = peg$FAILED;
}
- }
// @ts-ignore
- s4 = peg$parse_();
+ } else {
// @ts-ignore
- if (s4 === peg$FAILED) {
+ peg$currPos = s4;
// @ts-ignore
- s4 = null;
+ s4 = peg$FAILED;
}
+ }
// @ts-ignore
- s5 = peg$parseFixBinding();
+ s4 = peg$parse_();
// @ts-ignore
- if (s5 === peg$FAILED) {
+ if (s4 === peg$FAILED) {
// @ts-ignore
- s5 = null;
- }
+ s4 = null;
+ }
// @ts-ignore
- s6 = peg$parse_();
+ s5 = peg$parseFixBinding();
// @ts-ignore
- if (s6 === peg$FAILED) {
+ if (s5 === peg$FAILED) {
// @ts-ignore
- s6 = null;
- }
+ s5 = null;
+ }
// @ts-ignore
- s7 = peg$parseRBRACKET();
+ s6 = peg$parse_();
// @ts-ignore
- if (s7 !== peg$FAILED) {
+ if (s6 === peg$FAILED) {
// @ts-ignore
- peg$savedPos = s0;
+ s6 = null;
+ }
// @ts-ignore
- s0 = peg$f7(s3, s5);
+ s7 = peg$parseRBRACKET();
// @ts-ignore
- } else {
+ if (s7 !== peg$FAILED) {
// @ts-ignore
- peg$currPos = s0;
+ peg$savedPos = s0;
// @ts-ignore
- s0 = peg$FAILED;
- }
+ s0 = peg$f7(s3, s5);
// @ts-ignore
} else {
// @ts-ignore
@@ -5112,24 +5134,29 @@ export type ContinuationExpression =
| SwitchExpression
| PrimitiveOperationExpression;
export type SelectExpression = {
- select: Integer;
- val: Value;
- bind: Identifier;
- continuation: ContinuationExpression;
+ select: {
+ record: Integer;
+ val: Value;
+ bind: Identifier;
+ continuation: ContinuationExpression;
+ };
};
export type OffsetExpression = {
- offset: Integer;
- val: Value;
- bind: Identifier;
- continuation: ContinuationExpression;
+ offset: {
+ index: Integer;
+ val: Value;
+ bind: Identifier;
+ continuation: ContinuationExpression;
+ };
};
export type IdentifierList = any[];
export type ValueList = any[];
export type SwitchExpression = {
- switchIndex: Value;
- continuations: ContinuationList;
+ switch: { switchIndex: Value; continuations: ContinuationList };
+};
+export type ApplicationExpression = {
+ application: { fn: Value; args: ValueList };
};
-export type ApplicationExpression = { fn: Value; args: ValueList };
export type FixBinding = [
LPAREN,
_ | null,
@@ -5147,15 +5174,16 @@ export type FixBinding = [
];
export type FixBindingList = any[];
export type FixExpression = {
- fixBindings: FixBindingList;
- continuation: ContinuationExpression;
+ fix: { fixBindings: FixBindingList; continuation: ContinuationExpression };
};
export type ContinuationList = any[];
export type PrimitiveOperationExpression = {
- opr: PrimitiveOperation;
- operands: ValueList;
- resultBindings: IdentifierList;
- continuations: ContinuationList;
+ primitiveOperation: {
+ opr: PrimitiveOperation;
+ operands: ValueList;
+ resultBindings: IdentifierList;
+ continuations: ContinuationList;
+ };
};
export type RecordExpressionTuple = {
variable: VarStatement;
@@ -5163,9 +5191,11 @@ export type RecordExpressionTuple = {
};
export type RecordExpressionTupleList = any[];
export type RecordExpression = {
- records: RecordExpressionTupleList;
- address: Literal;
- body: ContinuationExpression;
+ record: {
+ records: RecordExpressionTupleList;
+ address: Literal;
+ body: ContinuationExpression;
+ };
};
export type Value =
| VarStatement