summaryrefslogtreecommitdiff
path: root/src/parser/grammar.pegjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/grammar.pegjs')
-rw-r--r--src/parser/grammar.pegjs58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/parser/grammar.pegjs b/src/parser/grammar.pegjs
index b375608..007bc1d 100644
--- a/src/parser/grammar.pegjs
+++ b/src/parser/grammar.pegjs
@@ -17,7 +17,7 @@ SelectExpression
_?
LPAREN
_?
- select:Integer
+ record:Integer
_?
COMMA
_?
@@ -27,16 +27,18 @@ SelectExpression
_?
bind:Identifier
_?
+ COMMA
+ _?
continuation:ContinuationExpression
_?
- RPAREN { return { select, val, bind, continuation }; }
+ RPAREN { return { select: { record, val, bind, continuation } }; }
OffsetExpression
= OFFSET
_?
LPAREN
_?
- offset:Integer
+ index:Integer
_?
COMMA
_?
@@ -48,31 +50,25 @@ OffsetExpression
_?
continuation:ContinuationExpression
_?
- RPAREN { return { offset, val, bind, continuation }; }
+ RPAREN { return { offset: { index, val, bind, continuation } }; }
IdentifierList
= LBRACKET
_?
- identifiers:(ident:Identifier _? COMMA _?)*
+ identifiers:(Identifier _? COMMA _?)*
_?
lastIdent:Identifier?
_?
RBRACKET {
return identifiers.length || lastIdent
- ? [...identifiers.map(x => x.ident), lastIdent]
+ ? [...identifiers.map(x => x[0]), lastIdent]
: [];
}
ValueList
- = LBRACKET
- _?
- values:(value:Value _? COMMA _?)*
- _?
- lastValue:Value?
- _?
- RBRACKET {
+ = LBRACKET _? values:(Value _? COMMA _?)* _? lastValue:Value? _? RBRACKET {
return values.length || lastValue
- ? [...values.map(x => x.value), lastValue]
+ ? [...values.map(x => x[0]), lastValue]
: [];
}
@@ -87,11 +83,11 @@ SwitchExpression
_?
continuations:ContinuationList
_?
- RPAREN { return { switchIndex, continuations }; }
+ RPAREN { return { switch: { switchIndex, continuations } }; }
ApplicationExpression
= APP _? LPAREN _? fn:Value _? COMMA _? args:ValueList _? RPAREN {
- return { fn, args };
+ return { application: { fn, args } };
}
FixBinding
@@ -111,14 +107,14 @@ FixBinding
FixBindingList
= LBRACKET
- _
- bindings:(binding:FixBinding _? COMMA _?)*
+ _?
+ bindings:(FixBinding _? COMMA _?)*
_?
lastBinding:FixBinding?
_?
RBRACKET {
return bindings.length || lastBinding
- ? [...bindings.map(x => x.binding), lastBinding]
+ ? [...bindings.map(x => x[0]), lastBinding]
: [];
}
@@ -133,18 +129,18 @@ FixExpression
_?
continuation:ContinuationExpression
_?
- RPAREN { return { fixBindings, continuation }; }
+ RPAREN { return { fix: { fixBindings, continuation } }; }
ContinuationList
= LBRACKET
_?
- continuations:(continuation:ContinuationExpression _? COMMA _?)*
+ continuations:(ContinuationExpression _? COMMA _?)*
_?
lastContinuation:ContinuationExpression?
_?
RBRACKET {
return lastContinuation || continuations.length
- ? [...continuations.map(x => x.continuation), lastContinuation]
+ ? [...continuations.map(x => x[0]), lastContinuation]
: [];
}
@@ -167,7 +163,11 @@ PrimitiveOperationExpression
_?
continuations:ContinuationList
_?
- RPAREN { return { opr, operands, resultBindings, continuations }; }
+ RPAREN {
+ return {
+ primitiveOperation: { opr, operands, resultBindings, continuations },
+ };
+ }
RecordExpressionTuple
= LPAREN
@@ -183,13 +183,13 @@ RecordExpressionTuple
RecordExpressionTupleList
= LBRACKET
_?
- records:(record:RecordExpressionTuple _? COMMA _?)*
+ records:(RecordExpressionTuple _? COMMA _?)*
_?
lastRecord:RecordExpressionTuple?
_?
RBRACKET {
return records.length || lastRecord
- ? [...records.map(x => x.record), lastRecord]
+ ? [...records.map(x => x[0]), lastRecord]
: [];
}
@@ -210,9 +210,11 @@ RecordExpression
_?
RPAREN {
return {
- records,
- address,
- body,
+ record: {
+ records,
+ address,
+ body,
+ },
};
}